@coinflowlabs/vue 1.2.1 → 1.2.2

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.
@@ -1,22 +1,22 @@
1
- (function(he,te){typeof exports=="object"&&typeof module<"u"?te(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],te):(he=typeof globalThis<"u"?globalThis:he||self,te(he.VueTypeWriter={},he.Vue))})(this,function(he,te){"use strict";var Lm=Object.defineProperty;var Cm=(he,te,or)=>te in he?Lm(he,te,{enumerable:!0,configurable:!0,writable:!0,value:or}):he[te]=or;var Ye=(he,te,or)=>Cm(he,typeof te!="symbol"?te+"":te,or);var or=(n=>(n.Credits="Credits",n.USDC="USDC",n.Bank="Bank",n))(or||{}),bs=(n=>(n.Rounded="rounded",n.Sharp="sharp",n.Pill="pill",n))(bs||{}),Rs=(n=>(n.NoPreference="NoPreference",n.Frictionless="Frictionless",n.Challenge="Challenge",n))(Rs||{}),Es=(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))(Es||{}),br=(n=>(n.VISA="VISA",n.MASTERCARD="MSTR",n.AMEX="AMEX",n.DISCOVER="DISC",n))(br||{});function zr(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function zn(n){if(Object.prototype.hasOwnProperty.call(n,"__esModule"))return n;var e=n.default;if(typeof e=="function"){var t=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var s=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:function(){return n[r]}})}),t}var $n={},$r={},Ss;function Ya(){if(Ss)return $r;Ss=1,$r.byteLength=a,$r.toByteArray=g,$r.fromByteArray=x;for(var n=[],e=[],t=typeof Uint8Array<"u"?Uint8Array:Array,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,i=r.length;s<i;++s)n[s]=r[s],e[r.charCodeAt(s)]=s;e[45]=62,e[95]=63;function o(T){var L=T.length;if(L%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var k=T.indexOf("=");k===-1&&(k=L);var N=k===L?0:4-k%4;return[k,N]}function a(T){var L=o(T),k=L[0],N=L[1];return(k+N)*3/4-N}function f(T,L,k){return(L+k)*3/4-k}function g(T){var L,k=o(T),N=k[0],M=k[1],W=new t(f(T,N,M)),$=0,J=M>0?N-4:N,q;for(q=0;q<J;q+=4)L=e[T.charCodeAt(q)]<<18|e[T.charCodeAt(q+1)]<<12|e[T.charCodeAt(q+2)]<<6|e[T.charCodeAt(q+3)],W[$++]=L>>16&255,W[$++]=L>>8&255,W[$++]=L&255;return M===2&&(L=e[T.charCodeAt(q)]<<2|e[T.charCodeAt(q+1)]>>4,W[$++]=L&255),M===1&&(L=e[T.charCodeAt(q)]<<10|e[T.charCodeAt(q+1)]<<4|e[T.charCodeAt(q+2)]>>2,W[$++]=L>>8&255,W[$++]=L&255),W}function _(T){return n[T>>18&63]+n[T>>12&63]+n[T>>6&63]+n[T&63]}function b(T,L,k){for(var N,M=[],W=L;W<k;W+=3)N=(T[W]<<16&16711680)+(T[W+1]<<8&65280)+(T[W+2]&255),M.push(_(N));return M.join("")}function x(T){for(var L,k=T.length,N=k%3,M=[],W=16383,$=0,J=k-N;$<J;$+=W)M.push(b(T,$,$+W>J?J:$+W));return N===1?(L=T[k-1],M.push(n[L>>2]+n[L<<4&63]+"==")):N===2&&(L=(T[k-2]<<8)+T[k-1],M.push(n[L>>10]+n[L>>4&63]+n[L<<2&63]+"=")),M.join("")}return $r}var nn={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var As;function ja(){return As||(As=1,nn.read=function(n,e,t,r,s){var i,o,a=s*8-r-1,f=(1<<a)-1,g=f>>1,_=-7,b=t?s-1:0,x=t?-1:1,T=n[e+b];for(b+=x,i=T&(1<<-_)-1,T>>=-_,_+=a;_>0;i=i*256+n[e+b],b+=x,_-=8);for(o=i&(1<<-_)-1,i>>=-_,_+=r;_>0;o=o*256+n[e+b],b+=x,_-=8);if(i===0)i=1-g;else{if(i===f)return o?NaN:(T?-1:1)*(1/0);o=o+Math.pow(2,r),i=i-g}return(T?-1:1)*o*Math.pow(2,i-r)},nn.write=function(n,e,t,r,s,i){var o,a,f,g=i*8-s-1,_=(1<<g)-1,b=_>>1,x=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,T=r?0:i-1,L=r?1:-1,k=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=_):(o=Math.floor(Math.log(e)/Math.LN2),e*(f=Math.pow(2,-o))<1&&(o--,f*=2),o+b>=1?e+=x/f:e+=x*Math.pow(2,1-b),e*f>=2&&(o++,f/=2),o+b>=_?(a=0,o=_):o+b>=1?(a=(e*f-1)*Math.pow(2,s),o=o+b):(a=e*Math.pow(2,b-1)*Math.pow(2,s),o=0));s>=8;n[t+T]=a&255,T+=L,a/=256,s-=8);for(o=o<<s|a,g+=s;g>0;n[t+T]=o&255,T+=L,o/=256,g-=8);n[t+T-L]|=k*128}),nn}/*!
1
+ (function(fe,te){typeof exports=="object"&&typeof module<"u"?te(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],te):(fe=typeof globalThis<"u"?globalThis:fe||self,te(fe.VueTypeWriter={},fe.Vue))})(this,function(fe,te){"use strict";var N1=Object.defineProperty;var x1=(fe,te,or)=>te in fe?N1(fe,te,{enumerable:!0,configurable:!0,writable:!0,value:or}):fe[te]=or;var Ye=(fe,te,or)=>x1(fe,typeof te!="symbol"?te+"":te,or);var or=(n=>(n.Credits="Credits",n.USDC="USDC",n.Bank="Bank",n))(or||{}),bs=(n=>(n.Rounded="rounded",n.Sharp="sharp",n.Pill="pill",n))(bs||{}),Rs=(n=>(n.NoPreference="NoPreference",n.Frictionless="Frictionless",n.Challenge="Challenge",n))(Rs||{}),Es=(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))(Es||{}),br=(n=>(n.VISA="VISA",n.MASTERCARD="MSTR",n.AMEX="AMEX",n.DISCOVER="DISC",n))(br||{});function zr(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function zn(n){if(Object.prototype.hasOwnProperty.call(n,"__esModule"))return n;var e=n.default;if(typeof e=="function"){var t=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var s=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:function(){return n[r]}})}),t}var Kn={},Kr={},Ss;function Ya(){if(Ss)return Kr;Ss=1,Kr.byteLength=a,Kr.toByteArray=g,Kr.fromByteArray=x;for(var n=[],e=[],t=typeof Uint8Array<"u"?Uint8Array:Array,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,i=r.length;s<i;++s)n[s]=r[s],e[r.charCodeAt(s)]=s;e[45]=62,e[95]=63;function o(T){var L=T.length;if(L%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var k=T.indexOf("=");k===-1&&(k=L);var N=k===L?0:4-k%4;return[k,N]}function a(T){var L=o(T),k=L[0],N=L[1];return(k+N)*3/4-N}function f(T,L,k){return(L+k)*3/4-k}function g(T){var L,k=o(T),N=k[0],M=k[1],H=new t(f(T,N,M)),K=0,J=M>0?N-4:N,q;for(q=0;q<J;q+=4)L=e[T.charCodeAt(q)]<<18|e[T.charCodeAt(q+1)]<<12|e[T.charCodeAt(q+2)]<<6|e[T.charCodeAt(q+3)],H[K++]=L>>16&255,H[K++]=L>>8&255,H[K++]=L&255;return M===2&&(L=e[T.charCodeAt(q)]<<2|e[T.charCodeAt(q+1)]>>4,H[K++]=L&255),M===1&&(L=e[T.charCodeAt(q)]<<10|e[T.charCodeAt(q+1)]<<4|e[T.charCodeAt(q+2)]>>2,H[K++]=L>>8&255,H[K++]=L&255),H}function _(T){return n[T>>18&63]+n[T>>12&63]+n[T>>6&63]+n[T&63]}function b(T,L,k){for(var N,M=[],H=L;H<k;H+=3)N=(T[H]<<16&16711680)+(T[H+1]<<8&65280)+(T[H+2]&255),M.push(_(N));return M.join("")}function x(T){for(var L,k=T.length,N=k%3,M=[],H=16383,K=0,J=k-N;K<J;K+=H)M.push(b(T,K,K+H>J?J:K+H));return N===1?(L=T[k-1],M.push(n[L>>2]+n[L<<4&63]+"==")):N===2&&(L=(T[k-2]<<8)+T[k-1],M.push(n[L>>10]+n[L>>4&63]+n[L<<2&63]+"=")),M.join("")}return Kr}var nn={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var As;function ja(){return As||(As=1,nn.read=function(n,e,t,r,s){var i,o,a=s*8-r-1,f=(1<<a)-1,g=f>>1,_=-7,b=t?s-1:0,x=t?-1:1,T=n[e+b];for(b+=x,i=T&(1<<-_)-1,T>>=-_,_+=a;_>0;i=i*256+n[e+b],b+=x,_-=8);for(o=i&(1<<-_)-1,i>>=-_,_+=r;_>0;o=o*256+n[e+b],b+=x,_-=8);if(i===0)i=1-g;else{if(i===f)return o?NaN:(T?-1:1)*(1/0);o=o+Math.pow(2,r),i=i-g}return(T?-1:1)*o*Math.pow(2,i-r)},nn.write=function(n,e,t,r,s,i){var o,a,f,g=i*8-s-1,_=(1<<g)-1,b=_>>1,x=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,T=r?0:i-1,L=r?1:-1,k=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=_):(o=Math.floor(Math.log(e)/Math.LN2),e*(f=Math.pow(2,-o))<1&&(o--,f*=2),o+b>=1?e+=x/f:e+=x*Math.pow(2,1-b),e*f>=2&&(o++,f/=2),o+b>=_?(a=0,o=_):o+b>=1?(a=(e*f-1)*Math.pow(2,s),o=o+b):(a=e*Math.pow(2,b-1)*Math.pow(2,s),o=0));s>=8;n[t+T]=a&255,T+=L,a/=256,s-=8);for(o=o<<s|a,g+=s;g>0;n[t+T]=o&255,T+=L,o/=256,g-=8);n[t+T-L]|=k*128}),nn}/*!
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 Is;function Kn(){return Is||(Is=1,function(n){const e=Ya(),t=ja(),r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=a,n.SlowBuffer=W,n.INSPECT_MAX_BYTES=50;const s=2147483647;n.kMaxLength=s,a.TYPED_ARRAY_SUPPORT=i(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function i(){try{const y=new Uint8Array(1),h={foo:function(){return 42}};return Object.setPrototypeOf(h,Uint8Array.prototype),Object.setPrototypeOf(y,h),y.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function o(y){if(y>s)throw new RangeError('The value "'+y+'" is invalid for option "size"');const h=new Uint8Array(y);return Object.setPrototypeOf(h,a.prototype),h}function a(y,h,d){if(typeof y=="number"){if(typeof h=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return b(y)}return f(y,h,d)}a.poolSize=8192;function f(y,h,d){if(typeof y=="string")return x(y,h);if(ArrayBuffer.isView(y))return L(y);if(y==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof y);if(St(y,ArrayBuffer)||y&&St(y.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(St(y,SharedArrayBuffer)||y&&St(y.buffer,SharedArrayBuffer)))return k(y,h,d);if(typeof y=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const O=y.valueOf&&y.valueOf();if(O!=null&&O!==y)return a.from(O,h,d);const U=N(y);if(U)return U;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof y[Symbol.toPrimitive]=="function")return a.from(y[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 y)}a.from=function(y,h,d){return f(y,h,d)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function g(y){if(typeof y!="number")throw new TypeError('"size" argument must be of type number');if(y<0)throw new RangeError('The value "'+y+'" is invalid for option "size"')}function _(y,h,d){return g(y),y<=0?o(y):h!==void 0?typeof d=="string"?o(y).fill(h,d):o(y).fill(h):o(y)}a.alloc=function(y,h,d){return _(y,h,d)};function b(y){return g(y),o(y<0?0:M(y)|0)}a.allocUnsafe=function(y){return b(y)},a.allocUnsafeSlow=function(y){return b(y)};function x(y,h){if((typeof h!="string"||h==="")&&(h="utf8"),!a.isEncoding(h))throw new TypeError("Unknown encoding: "+h);const d=$(y,h)|0;let O=o(d);const U=O.write(y,h);return U!==d&&(O=O.slice(0,U)),O}function T(y){const h=y.length<0?0:M(y.length)|0,d=o(h);for(let O=0;O<h;O+=1)d[O]=y[O]&255;return d}function L(y){if(St(y,Uint8Array)){const h=new Uint8Array(y);return k(h.buffer,h.byteOffset,h.byteLength)}return T(y)}function k(y,h,d){if(h<0||y.byteLength<h)throw new RangeError('"offset" is outside of buffer bounds');if(y.byteLength<h+(d||0))throw new RangeError('"length" is outside of buffer bounds');let O;return h===void 0&&d===void 0?O=new Uint8Array(y):d===void 0?O=new Uint8Array(y,h):O=new Uint8Array(y,h,d),Object.setPrototypeOf(O,a.prototype),O}function N(y){if(a.isBuffer(y)){const h=M(y.length)|0,d=o(h);return d.length===0||y.copy(d,0,0,h),d}if(y.length!==void 0)return typeof y.length!="number"||Me(y.length)?o(0):T(y);if(y.type==="Buffer"&&Array.isArray(y.data))return T(y.data)}function M(y){if(y>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return y|0}function W(y){return+y!=y&&(y=0),a.alloc(+y)}a.isBuffer=function(h){return h!=null&&h._isBuffer===!0&&h!==a.prototype},a.compare=function(h,d){if(St(h,Uint8Array)&&(h=a.from(h,h.offset,h.byteLength)),St(d,Uint8Array)&&(d=a.from(d,d.offset,d.byteLength)),!a.isBuffer(h)||!a.isBuffer(d))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(h===d)return 0;let O=h.length,U=d.length;for(let F=0,Y=Math.min(O,U);F<Y;++F)if(h[F]!==d[F]){O=h[F],U=d[F];break}return O<U?-1:U<O?1:0},a.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}},a.concat=function(h,d){if(!Array.isArray(h))throw new TypeError('"list" argument must be an Array of Buffers');if(h.length===0)return a.alloc(0);let O;if(d===void 0)for(d=0,O=0;O<h.length;++O)d+=h[O].length;const U=a.allocUnsafe(d);let F=0;for(O=0;O<h.length;++O){let Y=h[O];if(St(Y,Uint8Array))F+Y.length>U.length?(a.isBuffer(Y)||(Y=a.from(Y)),Y.copy(U,F)):Uint8Array.prototype.set.call(U,Y,F);else if(a.isBuffer(Y))Y.copy(U,F);else throw new TypeError('"list" argument must be an Array of Buffers');F+=Y.length}return U};function $(y,h){if(a.isBuffer(y))return y.length;if(ArrayBuffer.isView(y)||St(y,ArrayBuffer))return y.byteLength;if(typeof y!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof y);const d=y.length,O=arguments.length>2&&arguments[2]===!0;if(!O&&d===0)return 0;let U=!1;for(;;)switch(h){case"ascii":case"latin1":case"binary":return d;case"utf8":case"utf-8":return Le(y).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return d*2;case"hex":return d>>>1;case"base64":return Fe(y).length;default:if(U)return O?-1:Le(y).length;h=(""+h).toLowerCase(),U=!0}}a.byteLength=$;function J(y,h,d){let O=!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(y||(y="utf8");;)switch(y){case"hex":return I(this,h,d);case"utf8":case"utf-8":return c(this,h,d);case"ascii":return v(this,h,d);case"latin1":case"binary":return S(this,h,d);case"base64":return A(this,h,d);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,h,d);default:if(O)throw new TypeError("Unknown encoding: "+y);y=(y+"").toLowerCase(),O=!0}}a.prototype._isBuffer=!0;function q(y,h,d){const O=y[h];y[h]=y[d],y[d]=O}a.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)q(this,d,d+1);return this},a.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)q(this,d,d+3),q(this,d+1,d+2);return this},a.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)q(this,d,d+7),q(this,d+1,d+6),q(this,d+2,d+5),q(this,d+3,d+4);return this},a.prototype.toString=function(){const h=this.length;return h===0?"":arguments.length===0?c(this,0,h):J.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(h){if(!a.isBuffer(h))throw new TypeError("Argument must be a Buffer");return this===h?!0:a.compare(this,h)===0},a.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&&(a.prototype[r]=a.prototype.inspect),a.prototype.compare=function(h,d,O,U,F){if(St(h,Uint8Array)&&(h=a.from(h,h.offset,h.byteLength)),!a.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),O===void 0&&(O=h?h.length:0),U===void 0&&(U=0),F===void 0&&(F=this.length),d<0||O>h.length||U<0||F>this.length)throw new RangeError("out of range index");if(U>=F&&d>=O)return 0;if(U>=F)return-1;if(d>=O)return 1;if(d>>>=0,O>>>=0,U>>>=0,F>>>=0,this===h)return 0;let Y=F-U,be=O-d;const me=Math.min(Y,be),pe=this.slice(U,F),$e=h.slice(d,O);for(let de=0;de<me;++de)if(pe[de]!==$e[de]){Y=pe[de],be=$e[de];break}return Y<be?-1:be<Y?1:0};function D(y,h,d,O,U){if(y.length===0)return-1;if(typeof d=="string"?(O=d,d=0):d>2147483647?d=2147483647:d<-2147483648&&(d=-2147483648),d=+d,Me(d)&&(d=U?0:y.length-1),d<0&&(d=y.length+d),d>=y.length){if(U)return-1;d=y.length-1}else if(d<0)if(U)d=0;else return-1;if(typeof h=="string"&&(h=a.from(h,O)),a.isBuffer(h))return h.length===0?-1:Z(y,h,d,O,U);if(typeof h=="number")return h=h&255,typeof Uint8Array.prototype.indexOf=="function"?U?Uint8Array.prototype.indexOf.call(y,h,d):Uint8Array.prototype.lastIndexOf.call(y,h,d):Z(y,[h],d,O,U);throw new TypeError("val must be string, number or Buffer")}function Z(y,h,d,O,U){let F=1,Y=y.length,be=h.length;if(O!==void 0&&(O=String(O).toLowerCase(),O==="ucs2"||O==="ucs-2"||O==="utf16le"||O==="utf-16le")){if(y.length<2||h.length<2)return-1;F=2,Y/=2,be/=2,d/=2}function me($e,de){return F===1?$e[de]:$e.readUInt16BE(de*F)}let pe;if(U){let $e=-1;for(pe=d;pe<Y;pe++)if(me(y,pe)===me(h,$e===-1?0:pe-$e)){if($e===-1&&($e=pe),pe-$e+1===be)return $e*F}else $e!==-1&&(pe-=pe-$e),$e=-1}else for(d+be>Y&&(d=Y-be),pe=d;pe>=0;pe--){let $e=!0;for(let de=0;de<be;de++)if(me(y,pe+de)!==me(h,de)){$e=!1;break}if($e)return pe}return-1}a.prototype.includes=function(h,d,O){return this.indexOf(h,d,O)!==-1},a.prototype.indexOf=function(h,d,O){return D(this,h,d,O,!0)},a.prototype.lastIndexOf=function(h,d,O){return D(this,h,d,O,!1)};function j(y,h,d,O){d=Number(d)||0;const U=y.length-d;O?(O=Number(O),O>U&&(O=U)):O=U;const F=h.length;O>F/2&&(O=F/2);let Y;for(Y=0;Y<O;++Y){const be=parseInt(h.substr(Y*2,2),16);if(Me(be))return Y;y[d+Y]=be}return Y}function X(y,h,d,O){return Ce(Le(h,y.length-d),y,d,O)}function z(y,h,d,O){return Ce(We(h),y,d,O)}function G(y,h,d,O){return Ce(Fe(h),y,d,O)}function Q(y,h,d,O){return Ce(Fr(h,y.length-d),y,d,O)}a.prototype.write=function(h,d,O,U){if(d===void 0)U="utf8",O=this.length,d=0;else if(O===void 0&&typeof d=="string")U=d,O=this.length,d=0;else if(isFinite(d))d=d>>>0,isFinite(O)?(O=O>>>0,U===void 0&&(U="utf8")):(U=O,O=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const F=this.length-d;if((O===void 0||O>F)&&(O=F),h.length>0&&(O<0||d<0)||d>this.length)throw new RangeError("Attempt to write outside buffer bounds");U||(U="utf8");let Y=!1;for(;;)switch(U){case"hex":return j(this,h,d,O);case"utf8":case"utf-8":return X(this,h,d,O);case"ascii":case"latin1":case"binary":return z(this,h,d,O);case"base64":return G(this,h,d,O);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Q(this,h,d,O);default:if(Y)throw new TypeError("Unknown encoding: "+U);U=(""+U).toLowerCase(),Y=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function A(y,h,d){return h===0&&d===y.length?e.fromByteArray(y):e.fromByteArray(y.slice(h,d))}function c(y,h,d){d=Math.min(y.length,d);const O=[];let U=h;for(;U<d;){const F=y[U];let Y=null,be=F>239?4:F>223?3:F>191?2:1;if(U+be<=d){let me,pe,$e,de;switch(be){case 1:F<128&&(Y=F);break;case 2:me=y[U+1],(me&192)===128&&(de=(F&31)<<6|me&63,de>127&&(Y=de));break;case 3:me=y[U+1],pe=y[U+2],(me&192)===128&&(pe&192)===128&&(de=(F&15)<<12|(me&63)<<6|pe&63,de>2047&&(de<55296||de>57343)&&(Y=de));break;case 4:me=y[U+1],pe=y[U+2],$e=y[U+3],(me&192)===128&&(pe&192)===128&&($e&192)===128&&(de=(F&15)<<18|(me&63)<<12|(pe&63)<<6|$e&63,de>65535&&de<1114112&&(Y=de))}}Y===null?(Y=65533,be=1):Y>65535&&(Y-=65536,O.push(Y>>>10&1023|55296),Y=56320|Y&1023),O.push(Y),U+=be}return m(O)}const p=4096;function m(y){const h=y.length;if(h<=p)return String.fromCharCode.apply(String,y);let d="",O=0;for(;O<h;)d+=String.fromCharCode.apply(String,y.slice(O,O+=p));return d}function v(y,h,d){let O="";d=Math.min(y.length,d);for(let U=h;U<d;++U)O+=String.fromCharCode(y[U]&127);return O}function S(y,h,d){let O="";d=Math.min(y.length,d);for(let U=h;U<d;++U)O+=String.fromCharCode(y[U]);return O}function I(y,h,d){const O=y.length;(!h||h<0)&&(h=0),(!d||d<0||d>O)&&(d=O);let U="";for(let F=h;F<d;++F)U+=De[y[F]];return U}function C(y,h,d){const O=y.slice(h,d);let U="";for(let F=0;F<O.length-1;F+=2)U+=String.fromCharCode(O[F]+O[F+1]*256);return U}a.prototype.slice=function(h,d){const O=this.length;h=~~h,d=d===void 0?O:~~d,h<0?(h+=O,h<0&&(h=0)):h>O&&(h=O),d<0?(d+=O,d<0&&(d=0)):d>O&&(d=O),d<h&&(d=h);const U=this.subarray(h,d);return Object.setPrototypeOf(U,a.prototype),U};function R(y,h,d){if(y%1!==0||y<0)throw new RangeError("offset is not uint");if(y+h>d)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(h,d,O){h=h>>>0,d=d>>>0,O||R(h,d,this.length);let U=this[h],F=1,Y=0;for(;++Y<d&&(F*=256);)U+=this[h+Y]*F;return U},a.prototype.readUintBE=a.prototype.readUIntBE=function(h,d,O){h=h>>>0,d=d>>>0,O||R(h,d,this.length);let U=this[h+--d],F=1;for(;d>0&&(F*=256);)U+=this[h+--d]*F;return U},a.prototype.readUint8=a.prototype.readUInt8=function(h,d){return h=h>>>0,d||R(h,1,this.length),this[h]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(h,d){return h=h>>>0,d||R(h,2,this.length),this[h]|this[h+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(h,d){return h=h>>>0,d||R(h,2,this.length),this[h]<<8|this[h+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(h,d){return h=h>>>0,d||R(h,4,this.length),(this[h]|this[h+1]<<8|this[h+2]<<16)+this[h+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(h,d){return h=h>>>0,d||R(h,4,this.length),this[h]*16777216+(this[h+1]<<16|this[h+2]<<8|this[h+3])},a.prototype.readBigUInt64LE=Ot(function(h){h=h>>>0,ke(h,"offset");const d=this[h],O=this[h+7];(d===void 0||O===void 0)&&Ee(h,this.length-8);const U=d+this[++h]*2**8+this[++h]*2**16+this[++h]*2**24,F=this[++h]+this[++h]*2**8+this[++h]*2**16+O*2**24;return BigInt(U)+(BigInt(F)<<BigInt(32))}),a.prototype.readBigUInt64BE=Ot(function(h){h=h>>>0,ke(h,"offset");const d=this[h],O=this[h+7];(d===void 0||O===void 0)&&Ee(h,this.length-8);const U=d*2**24+this[++h]*2**16+this[++h]*2**8+this[++h],F=this[++h]*2**24+this[++h]*2**16+this[++h]*2**8+O;return(BigInt(U)<<BigInt(32))+BigInt(F)}),a.prototype.readIntLE=function(h,d,O){h=h>>>0,d=d>>>0,O||R(h,d,this.length);let U=this[h],F=1,Y=0;for(;++Y<d&&(F*=256);)U+=this[h+Y]*F;return F*=128,U>=F&&(U-=Math.pow(2,8*d)),U},a.prototype.readIntBE=function(h,d,O){h=h>>>0,d=d>>>0,O||R(h,d,this.length);let U=d,F=1,Y=this[h+--U];for(;U>0&&(F*=256);)Y+=this[h+--U]*F;return F*=128,Y>=F&&(Y-=Math.pow(2,8*d)),Y},a.prototype.readInt8=function(h,d){return h=h>>>0,d||R(h,1,this.length),this[h]&128?(255-this[h]+1)*-1:this[h]},a.prototype.readInt16LE=function(h,d){h=h>>>0,d||R(h,2,this.length);const O=this[h]|this[h+1]<<8;return O&32768?O|4294901760:O},a.prototype.readInt16BE=function(h,d){h=h>>>0,d||R(h,2,this.length);const O=this[h+1]|this[h]<<8;return O&32768?O|4294901760:O},a.prototype.readInt32LE=function(h,d){return h=h>>>0,d||R(h,4,this.length),this[h]|this[h+1]<<8|this[h+2]<<16|this[h+3]<<24},a.prototype.readInt32BE=function(h,d){return h=h>>>0,d||R(h,4,this.length),this[h]<<24|this[h+1]<<16|this[h+2]<<8|this[h+3]},a.prototype.readBigInt64LE=Ot(function(h){h=h>>>0,ke(h,"offset");const d=this[h],O=this[h+7];(d===void 0||O===void 0)&&Ee(h,this.length-8);const U=this[h+4]+this[h+5]*2**8+this[h+6]*2**16+(O<<24);return(BigInt(U)<<BigInt(32))+BigInt(d+this[++h]*2**8+this[++h]*2**16+this[++h]*2**24)}),a.prototype.readBigInt64BE=Ot(function(h){h=h>>>0,ke(h,"offset");const d=this[h],O=this[h+7];(d===void 0||O===void 0)&&Ee(h,this.length-8);const U=(d<<24)+this[++h]*2**16+this[++h]*2**8+this[++h];return(BigInt(U)<<BigInt(32))+BigInt(this[++h]*2**24+this[++h]*2**16+this[++h]*2**8+O)}),a.prototype.readFloatLE=function(h,d){return h=h>>>0,d||R(h,4,this.length),t.read(this,h,!0,23,4)},a.prototype.readFloatBE=function(h,d){return h=h>>>0,d||R(h,4,this.length),t.read(this,h,!1,23,4)},a.prototype.readDoubleLE=function(h,d){return h=h>>>0,d||R(h,8,this.length),t.read(this,h,!0,52,8)},a.prototype.readDoubleBE=function(h,d){return h=h>>>0,d||R(h,8,this.length),t.read(this,h,!1,52,8)};function u(y,h,d,O,U,F){if(!a.isBuffer(y))throw new TypeError('"buffer" argument must be a Buffer instance');if(h>U||h<F)throw new RangeError('"value" argument is out of bounds');if(d+O>y.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(h,d,O,U){if(h=+h,d=d>>>0,O=O>>>0,!U){const be=Math.pow(2,8*O)-1;u(this,h,d,O,be,0)}let F=1,Y=0;for(this[d]=h&255;++Y<O&&(F*=256);)this[d+Y]=h/F&255;return d+O},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(h,d,O,U){if(h=+h,d=d>>>0,O=O>>>0,!U){const be=Math.pow(2,8*O)-1;u(this,h,d,O,be,0)}let F=O-1,Y=1;for(this[d+F]=h&255;--F>=0&&(Y*=256);)this[d+F]=h/Y&255;return d+O},a.prototype.writeUint8=a.prototype.writeUInt8=function(h,d,O){return h=+h,d=d>>>0,O||u(this,h,d,1,255,0),this[d]=h&255,d+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(h,d,O){return h=+h,d=d>>>0,O||u(this,h,d,2,65535,0),this[d]=h&255,this[d+1]=h>>>8,d+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(h,d,O){return h=+h,d=d>>>0,O||u(this,h,d,2,65535,0),this[d]=h>>>8,this[d+1]=h&255,d+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(h,d,O){return h=+h,d=d>>>0,O||u(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},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(h,d,O){return h=+h,d=d>>>0,O||u(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(y,h,d,O,U){Re(h,O,U,y,d,7);let F=Number(h&BigInt(4294967295));y[d++]=F,F=F>>8,y[d++]=F,F=F>>8,y[d++]=F,F=F>>8,y[d++]=F;let Y=Number(h>>BigInt(32)&BigInt(4294967295));return y[d++]=Y,Y=Y>>8,y[d++]=Y,Y=Y>>8,y[d++]=Y,Y=Y>>8,y[d++]=Y,d}function w(y,h,d,O,U){Re(h,O,U,y,d,7);let F=Number(h&BigInt(4294967295));y[d+7]=F,F=F>>8,y[d+6]=F,F=F>>8,y[d+5]=F,F=F>>8,y[d+4]=F;let Y=Number(h>>BigInt(32)&BigInt(4294967295));return y[d+3]=Y,Y=Y>>8,y[d+2]=Y,Y=Y>>8,y[d+1]=Y,Y=Y>>8,y[d]=Y,d+8}a.prototype.writeBigUInt64LE=Ot(function(h,d=0){return l(this,h,d,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=Ot(function(h,d=0){return w(this,h,d,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(h,d,O,U){if(h=+h,d=d>>>0,!U){const me=Math.pow(2,8*O-1);u(this,h,d,O,me-1,-me)}let F=0,Y=1,be=0;for(this[d]=h&255;++F<O&&(Y*=256);)h<0&&be===0&&this[d+F-1]!==0&&(be=1),this[d+F]=(h/Y>>0)-be&255;return d+O},a.prototype.writeIntBE=function(h,d,O,U){if(h=+h,d=d>>>0,!U){const me=Math.pow(2,8*O-1);u(this,h,d,O,me-1,-me)}let F=O-1,Y=1,be=0;for(this[d+F]=h&255;--F>=0&&(Y*=256);)h<0&&be===0&&this[d+F+1]!==0&&(be=1),this[d+F]=(h/Y>>0)-be&255;return d+O},a.prototype.writeInt8=function(h,d,O){return h=+h,d=d>>>0,O||u(this,h,d,1,127,-128),h<0&&(h=255+h+1),this[d]=h&255,d+1},a.prototype.writeInt16LE=function(h,d,O){return h=+h,d=d>>>0,O||u(this,h,d,2,32767,-32768),this[d]=h&255,this[d+1]=h>>>8,d+2},a.prototype.writeInt16BE=function(h,d,O){return h=+h,d=d>>>0,O||u(this,h,d,2,32767,-32768),this[d]=h>>>8,this[d+1]=h&255,d+2},a.prototype.writeInt32LE=function(h,d,O){return h=+h,d=d>>>0,O||u(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},a.prototype.writeInt32BE=function(h,d,O){return h=+h,d=d>>>0,O||u(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},a.prototype.writeBigInt64LE=Ot(function(h,d=0){return l(this,h,d,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=Ot(function(h,d=0){return w(this,h,d,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function E(y,h,d,O,U,F){if(d+O>y.length)throw new RangeError("Index out of range");if(d<0)throw new RangeError("Index out of range")}function P(y,h,d,O,U){return h=+h,d=d>>>0,U||E(y,h,d,4),t.write(y,h,d,O,23,4),d+4}a.prototype.writeFloatLE=function(h,d,O){return P(this,h,d,!0,O)},a.prototype.writeFloatBE=function(h,d,O){return P(this,h,d,!1,O)};function V(y,h,d,O,U){return h=+h,d=d>>>0,U||E(y,h,d,8),t.write(y,h,d,O,52,8),d+8}a.prototype.writeDoubleLE=function(h,d,O){return V(this,h,d,!0,O)},a.prototype.writeDoubleBE=function(h,d,O){return V(this,h,d,!1,O)},a.prototype.copy=function(h,d,O,U){if(!a.isBuffer(h))throw new TypeError("argument should be a Buffer");if(O||(O=0),!U&&U!==0&&(U=this.length),d>=h.length&&(d=h.length),d||(d=0),U>0&&U<O&&(U=O),U===O||h.length===0||this.length===0)return 0;if(d<0)throw new RangeError("targetStart out of bounds");if(O<0||O>=this.length)throw new RangeError("Index out of range");if(U<0)throw new RangeError("sourceEnd out of bounds");U>this.length&&(U=this.length),h.length-d<U-O&&(U=h.length-d+O);const F=U-O;return this===h&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(d,O,U):Uint8Array.prototype.set.call(h,this.subarray(O,U),d),F},a.prototype.fill=function(h,d,O,U){if(typeof h=="string"){if(typeof d=="string"?(U=d,d=0,O=this.length):typeof O=="string"&&(U=O,O=this.length),U!==void 0&&typeof U!="string")throw new TypeError("encoding must be a string");if(typeof U=="string"&&!a.isEncoding(U))throw new TypeError("Unknown encoding: "+U);if(h.length===1){const Y=h.charCodeAt(0);(U==="utf8"&&Y<128||U==="latin1")&&(h=Y)}}else typeof h=="number"?h=h&255:typeof h=="boolean"&&(h=Number(h));if(d<0||this.length<d||this.length<O)throw new RangeError("Out of range index");if(O<=d)return this;d=d>>>0,O=O===void 0?this.length:O>>>0,h||(h=0);let F;if(typeof h=="number")for(F=d;F<O;++F)this[F]=h;else{const Y=a.isBuffer(h)?h:a.from(h,U),be=Y.length;if(be===0)throw new TypeError('The value "'+h+'" is invalid for argument "value"');for(F=0;F<O-d;++F)this[F+d]=Y[F%be]}return this};const ne={};function ce(y,h,d){ne[y]=class extends d{constructor(){super(),Object.defineProperty(this,"message",{value:h.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${y}]`,this.stack,delete this.name}get code(){return y}set code(U){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:U,writable:!0})}toString(){return`${this.name} [${y}]: ${this.message}`}}}ce("ERR_BUFFER_OUT_OF_BOUNDS",function(y){return y?`${y} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),ce("ERR_INVALID_ARG_TYPE",function(y,h){return`The "${y}" argument must be of type number. Received type ${typeof h}`},TypeError),ce("ERR_OUT_OF_RANGE",function(y,h,d){let O=`The value of "${y}" is out of range.`,U=d;return Number.isInteger(d)&&Math.abs(d)>2**32?U=ve(String(d)):typeof d=="bigint"&&(U=String(d),(d>BigInt(2)**BigInt(32)||d<-(BigInt(2)**BigInt(32)))&&(U=ve(U)),U+="n"),O+=` It must be ${h}. Received ${U}`,O},RangeError);function ve(y){let h="",d=y.length;const O=y[0]==="-"?1:0;for(;d>=O+4;d-=3)h=`_${y.slice(d-3,d)}${h}`;return`${y.slice(0,d)}${h}`}function ge(y,h,d){ke(h,"offset"),(y[h]===void 0||y[h+d]===void 0)&&Ee(h,y.length-(d+1))}function Re(y,h,d,O,U,F){if(y>d||y<h){const Y=typeof h=="bigint"?"n":"";let be;throw h===0||h===BigInt(0)?be=`>= 0${Y} and < 2${Y} ** ${(F+1)*8}${Y}`:be=`>= -(2${Y} ** ${(F+1)*8-1}${Y}) and < 2 ** ${(F+1)*8-1}${Y}`,new ne.ERR_OUT_OF_RANGE("value",be,y)}ge(O,U,F)}function ke(y,h){if(typeof y!="number")throw new ne.ERR_INVALID_ARG_TYPE(h,"number",y)}function Ee(y,h,d){throw Math.floor(y)!==y?(ke(y,d),new ne.ERR_OUT_OF_RANGE("offset","an integer",y)):h<0?new ne.ERR_BUFFER_OUT_OF_BOUNDS:new ne.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${h}`,y)}const Ne=/[^+/0-9A-Za-z-_]/g;function qt(y){if(y=y.split("=")[0],y=y.trim().replace(Ne,""),y.length<2)return"";for(;y.length%4!==0;)y=y+"=";return y}function Le(y,h){h=h||1/0;let d;const O=y.length;let U=null;const F=[];for(let Y=0;Y<O;++Y){if(d=y.charCodeAt(Y),d>55295&&d<57344){if(!U){if(d>56319){(h-=3)>-1&&F.push(239,191,189);continue}else if(Y+1===O){(h-=3)>-1&&F.push(239,191,189);continue}U=d;continue}if(d<56320){(h-=3)>-1&&F.push(239,191,189),U=d;continue}d=(U-55296<<10|d-56320)+65536}else U&&(h-=3)>-1&&F.push(239,191,189);if(U=null,d<128){if((h-=1)<0)break;F.push(d)}else if(d<2048){if((h-=2)<0)break;F.push(d>>6|192,d&63|128)}else if(d<65536){if((h-=3)<0)break;F.push(d>>12|224,d>>6&63|128,d&63|128)}else if(d<1114112){if((h-=4)<0)break;F.push(d>>18|240,d>>12&63|128,d>>6&63|128,d&63|128)}else throw new Error("Invalid code point")}return F}function We(y){const h=[];for(let d=0;d<y.length;++d)h.push(y.charCodeAt(d)&255);return h}function Fr(y,h){let d,O,U;const F=[];for(let Y=0;Y<y.length&&!((h-=2)<0);++Y)d=y.charCodeAt(Y),O=d>>8,U=d%256,F.push(U),F.push(O);return F}function Fe(y){return e.toByteArray(qt(y))}function Ce(y,h,d,O){let U;for(U=0;U<O&&!(U+d>=h.length||U>=y.length);++U)h[U+d]=y[U];return U}function St(y,h){return y instanceof h||y!=null&&y.constructor!=null&&y.constructor.name!=null&&y.constructor.name===h.name}function Me(y){return y!==y}const De=function(){const y="0123456789abcdef",h=new Array(256);for(let d=0;d<16;++d){const O=d*16;for(let U=0;U<16;++U)h[O+U]=y[d]+y[U]}return h}();function Ot(y){return typeof BigInt>"u"?ze:y}function ze(){throw new Error("BigInt not supported")}}($n)),$n}var fe=Kn();function sn(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 Kr(n,...e){if(!Za(n))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(n.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${n.length}`)}function Xa(n){if(typeof n!="function"||typeof n.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");sn(n.outputLen),sn(n.blockLen)}function Rr(n,e=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(e&&n.finished)throw new Error("Hash#digest() has already been called")}function vs(n,e){Kr(n);const t=e.outputLen;if(n.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}const Wn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ja=n=>new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)),Hn=n=>new DataView(n.buffer,n.byteOffset,n.byteLength),Ct=(n,e)=>n<<32-e|n>>>e,Os=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,Qa=n=>n<<24&4278190080|n<<8&16711680|n>>>8&65280|n>>>24&255;function ks(n){for(let e=0;e<n.length;e++)n[e]=Qa(n[e])}function ec(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function on(n){return typeof n=="string"&&(n=ec(n)),Kr(n),n}function tc(...n){let e=0;for(let r=0;r<n.length;r++){const s=n[r];Kr(s),e+=s.length}const t=new Uint8Array(e);for(let r=0,s=0;r<n.length;r++){const i=n[r];t.set(i,s),s+=i.length}return t}class qn{clone(){return this._cloneInto()}}function Gn(n){const e=r=>n().update(on(r)).digest(),t=n();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>n(),e}function Ts(n=32){if(Wn&&typeof Wn.getRandomValues=="function")return Wn.getRandomValues(new Uint8Array(n));throw new Error("crypto.getRandomValues must be defined")}function rc(n,e,t,r){if(typeof n.setBigUint64=="function")return n.setBigUint64(e,t,r);const s=BigInt(32),i=BigInt(4294967295),o=Number(t>>s&i),a=Number(t&i),f=r?4:0,g=r?0:4;n.setUint32(e+f,o,r),n.setUint32(e+g,a,r)}const nc=(n,e,t)=>n&e^~n&t,ic=(n,e,t)=>n&e^n&t^e&t;class Ns extends qn{constructor(e,t,r,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Hn(this.buffer)}update(e){Rr(this);const{view:t,buffer:r,blockLen:s}=this;e=on(e);const i=e.length;for(let o=0;o<i;){const a=Math.min(s-this.pos,i-o);if(a===s){const f=Hn(e);for(;s<=i-o;o+=s)this.process(f,o);continue}r.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Rr(this),vs(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:s,isLE:i}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>s-o&&(this.process(r,0),o=0);for(let b=o;b<s;b++)t[b]=0;rc(r,s-8,BigInt(this.length*8),i),this.process(r,0);const a=Hn(e),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const g=f/4,_=this.get();if(g>_.length)throw new Error("_sha2: outputLen bigger than state");for(let b=0;b<g;b++)a.setUint32(4*b,_[b],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:s,finished:i,destroyed:o,pos:a}=this;return e.length=s,e.pos=a,e.finished=i,e.destroyed=o,s%t&&e.buffer.set(r),e}}const an=BigInt(2**32-1),Vn=BigInt(32);function xs(n,e=!1){return e?{h:Number(n&an),l:Number(n>>Vn&an)}:{h:Number(n>>Vn&an)|0,l:Number(n&an)|0}}function Bs(n,e=!1){let t=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let s=0;s<n.length;s++){const{h:i,l:o}=xs(n[s],e);[t[s],r[s]]=[i,o]}return[t,r]}const sc=(n,e)=>BigInt(n>>>0)<<Vn|BigInt(e>>>0),oc=(n,e,t)=>n>>>t,ac=(n,e,t)=>n<<32-t|e>>>t,cc=(n,e,t)=>n>>>t|e<<32-t,uc=(n,e,t)=>n<<32-t|e>>>t,lc=(n,e,t)=>n<<64-t|e>>>t-32,hc=(n,e,t)=>n>>>t-32|e<<64-t,fc=(n,e)=>e,dc=(n,e)=>n,Ls=(n,e,t)=>n<<t|e>>>32-t,Cs=(n,e,t)=>e<<t|n>>>32-t,Ms=(n,e,t)=>e<<t-32|n>>>64-t,Ps=(n,e,t)=>n<<t-32|e>>>64-t;function pc(n,e,t,r){const s=(e>>>0)+(r>>>0);return{h:n+t+(s/2**32|0)|0,l:s|0}}const ye={fromBig:xs,split:Bs,toBig:sc,shrSH:oc,shrSL:ac,rotrSH:cc,rotrSL:uc,rotrBH:lc,rotrBL:hc,rotr32H:fc,rotr32L:dc,rotlSH:Ls,rotlSL:Cs,rotlBH:Ms,rotlBL:Ps,add:pc,add3L:(n,e,t)=>(n>>>0)+(e>>>0)+(t>>>0),add3H:(n,e,t,r)=>e+t+r+(n/2**32|0)|0,add4L:(n,e,t,r)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0),add4H:(n,e,t,r,s)=>e+t+r+s+(n/2**32|0)|0,add5H:(n,e,t,r,s,i)=>e+t+r+s+i+(n/2**32|0)|0,add5L:(n,e,t,r,s)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0)},[gc,mc]=ye.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))),Qt=new Uint32Array(80),er=new Uint32Array(80);class yc extends Ns{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:e,Al:t,Bh:r,Bl:s,Ch:i,Cl:o,Dh:a,Dl:f,Eh:g,El:_,Fh:b,Fl:x,Gh:T,Gl:L,Hh:k,Hl:N}=this;return[e,t,r,s,i,o,a,f,g,_,b,x,T,L,k,N]}set(e,t,r,s,i,o,a,f,g,_,b,x,T,L,k,N){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=s|0,this.Ch=i|0,this.Cl=o|0,this.Dh=a|0,this.Dl=f|0,this.Eh=g|0,this.El=_|0,this.Fh=b|0,this.Fl=x|0,this.Gh=T|0,this.Gl=L|0,this.Hh=k|0,this.Hl=N|0}process(e,t){for(let $=0;$<16;$++,t+=4)Qt[$]=e.getUint32(t),er[$]=e.getUint32(t+=4);for(let $=16;$<80;$++){const J=Qt[$-15]|0,q=er[$-15]|0,D=ye.rotrSH(J,q,1)^ye.rotrSH(J,q,8)^ye.shrSH(J,q,7),Z=ye.rotrSL(J,q,1)^ye.rotrSL(J,q,8)^ye.shrSL(J,q,7),j=Qt[$-2]|0,X=er[$-2]|0,z=ye.rotrSH(j,X,19)^ye.rotrBH(j,X,61)^ye.shrSH(j,X,6),G=ye.rotrSL(j,X,19)^ye.rotrBL(j,X,61)^ye.shrSL(j,X,6),Q=ye.add4L(Z,G,er[$-7],er[$-16]),A=ye.add4H(Q,D,z,Qt[$-7],Qt[$-16]);Qt[$]=A|0,er[$]=Q|0}let{Ah:r,Al:s,Bh:i,Bl:o,Ch:a,Cl:f,Dh:g,Dl:_,Eh:b,El:x,Fh:T,Fl:L,Gh:k,Gl:N,Hh:M,Hl:W}=this;for(let $=0;$<80;$++){const J=ye.rotrSH(b,x,14)^ye.rotrSH(b,x,18)^ye.rotrBH(b,x,41),q=ye.rotrSL(b,x,14)^ye.rotrSL(b,x,18)^ye.rotrBL(b,x,41),D=b&T^~b&k,Z=x&L^~x&N,j=ye.add5L(W,q,Z,mc[$],er[$]),X=ye.add5H(j,M,J,D,gc[$],Qt[$]),z=j|0,G=ye.rotrSH(r,s,28)^ye.rotrBH(r,s,34)^ye.rotrBH(r,s,39),Q=ye.rotrSL(r,s,28)^ye.rotrBL(r,s,34)^ye.rotrBL(r,s,39),A=r&i^r&a^i&a,c=s&o^s&f^o&f;M=k|0,W=N|0,k=T|0,N=L|0,T=b|0,L=x|0,{h:b,l:x}=ye.add(g|0,_|0,X|0,z|0),g=a|0,_=f|0,a=i|0,f=o|0,i=r|0,o=s|0;const p=ye.add3L(z,Q,c);r=ye.add3H(p,X,G,A),s=p|0}({h:r,l:s}=ye.add(this.Ah|0,this.Al|0,r|0,s|0)),{h:i,l:o}=ye.add(this.Bh|0,this.Bl|0,i|0,o|0),{h:a,l:f}=ye.add(this.Ch|0,this.Cl|0,a|0,f|0),{h:g,l:_}=ye.add(this.Dh|0,this.Dl|0,g|0,_|0),{h:b,l:x}=ye.add(this.Eh|0,this.El|0,b|0,x|0),{h:T,l:L}=ye.add(this.Fh|0,this.Fl|0,T|0,L|0),{h:k,l:N}=ye.add(this.Gh|0,this.Gl|0,k|0,N|0),{h:M,l:W}=ye.add(this.Hh|0,this.Hl|0,M|0,W|0),this.set(r,s,i,o,a,f,g,_,b,x,T,L,k,N,M,W)}roundClean(){Qt.fill(0),er.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 _c=Gn(()=>new yc);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Us=BigInt(0),cn=BigInt(1),wc=BigInt(2);function ar(n){return n instanceof Uint8Array||n!=null&&typeof n=="object"&&n.constructor.name==="Uint8Array"}function Wr(n){if(!ar(n))throw new Error("Uint8Array expected")}const bc=Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function cr(n){Wr(n);let e="";for(let t=0;t<n.length;t++)e+=bc[n[t]];return e}function Ds(n){const e=n.toString(16);return e.length&1?`0${e}`:e}function Yn(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);return BigInt(n===""?"0":`0x${n}`)}const Gt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Fs(n){if(n>=Gt._0&&n<=Gt._9)return n-Gt._0;if(n>=Gt._A&&n<=Gt._F)return n-(Gt._A-10);if(n>=Gt._a&&n<=Gt._f)return n-(Gt._a-10)}function Er(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);const e=n.length,t=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(t);for(let s=0,i=0;s<t;s++,i+=2){const o=Fs(n.charCodeAt(i)),a=Fs(n.charCodeAt(i+1));if(o===void 0||a===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+a}return r}function ur(n){return Yn(cr(n))}function Sr(n){return Wr(n),Yn(cr(Uint8Array.from(n).reverse()))}function Ar(n,e){return Er(n.toString(16).padStart(e*2,"0"))}function Hr(n,e){return Ar(n,e).reverse()}function Rc(n){return Er(Ds(n))}function dt(n,e,t){let r;if(typeof e=="string")try{r=Er(e)}catch(i){throw new Error(`${n} must be valid hex string, got "${e}". Cause: ${i}`)}else if(ar(e))r=Uint8Array.from(e);else throw new Error(`${n} must be hex string or Uint8Array`);const s=r.length;if(typeof t=="number"&&s!==t)throw new Error(`${n} expected ${t} bytes, got ${s}`);return r}function lr(...n){let e=0;for(let r=0;r<n.length;r++){const s=n[r];Wr(s),e+=s.length}const t=new Uint8Array(e);for(let r=0,s=0;r<n.length;r++){const i=n[r];t.set(i,s),s+=i.length}return t}function Ec(n,e){if(n.length!==e.length)return!1;let t=0;for(let r=0;r<n.length;r++)t|=n[r]^e[r];return t===0}function Sc(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function Ac(n){let e;for(e=0;n>Us;n>>=cn,e+=1);return e}function Ic(n,e){return n>>BigInt(e)&cn}function vc(n,e,t){return n|(t?cn:Us)<<BigInt(e)}const jn=n=>(wc<<BigInt(n-1))-cn,Zn=n=>new Uint8Array(n),zs=n=>Uint8Array.from(n);function $s(n,e,t){if(typeof n!="number"||n<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let r=Zn(n),s=Zn(n),i=0;const o=()=>{r.fill(1),s.fill(0),i=0},a=(...b)=>t(s,r,...b),f=(b=Zn())=>{s=a(zs([0]),b),r=a(),b.length!==0&&(s=a(zs([1]),b),r=a())},g=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let b=0;const x=[];for(;b<e;){r=a();const T=r.slice();x.push(T),b+=r.length}return lr(...x)};return(b,x)=>{o(),f(b);let T;for(;!(T=x(g()));)f();return o(),T}}const Oc={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"||ar(n),isSafeInteger:n=>Number.isSafeInteger(n),array:n=>Array.isArray(n),field:(n,e)=>e.Fp.isValid(n),hash:n=>typeof n=="function"&&Number.isSafeInteger(n.outputLen)};function Ir(n,e,t={}){const r=(s,i,o)=>{const a=Oc[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);const f=n[s];if(!(o&&f===void 0)&&!a(f,n))throw new Error(`Invalid param ${String(s)}=${f} (${typeof f}), expected ${i}`)};for(const[s,i]of Object.entries(e))r(s,i,!1);for(const[s,i]of Object.entries(t))r(s,i,!0);return n}const kc=Object.freeze(Object.defineProperty({__proto__:null,abytes:Wr,bitGet:Ic,bitLen:Ac,bitMask:jn,bitSet:vc,bytesToHex:cr,bytesToNumberBE:ur,bytesToNumberLE:Sr,concatBytes:lr,createHmacDrbg:$s,ensureBytes:dt,equalBytes:Ec,hexToBytes:Er,hexToNumber:Yn,isBytes:ar,numberToBytesBE:Ar,numberToBytesLE:Hr,numberToHexUnpadded:Ds,numberToVarBytesBE:Rc,utf8ToBytes:Sc,validateObject:Ir},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const pt=BigInt(0),He=BigInt(1),hr=BigInt(2),Tc=BigInt(3),Xn=BigInt(4),Ks=BigInt(5),Ws=BigInt(8);BigInt(9),BigInt(16);function Ke(n,e){const t=n%e;return t>=pt?t:e+t}function Nc(n,e,t){if(t<=pt||e<pt)throw new Error("Expected power/modulo > 0");if(t===He)return pt;let r=He;for(;e>pt;)e&He&&(r=r*n%t),n=n*n%t,e>>=He;return r}function Ve(n,e,t){let r=n;for(;e-- >pt;)r*=r,r%=t;return r}function Jn(n,e){if(n===pt||e<=pt)throw new Error(`invert: expected positive integers, got n=${n} mod=${e}`);let t=Ke(n,e),r=e,s=pt,i=He;for(;t!==pt;){const a=r/t,f=r%t,g=s-i*a;r=t,t=f,s=i,i=g}if(r!==He)throw new Error("invert: does not exist");return Ke(s,e)}function xc(n){const e=(n-He)/hr;let t,r,s;for(t=n-He,r=0;t%hr===pt;t/=hr,r++);for(s=hr;s<n&&Nc(s,e,n)!==n-He;s++);if(r===1){const o=(n+He)/Xn;return function(f,g){const _=f.pow(g,o);if(!f.eql(f.sqr(_),g))throw new Error("Cannot find square root");return _}}const i=(t+He)/hr;return function(a,f){if(a.pow(f,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let g=r,_=a.pow(a.mul(a.ONE,s),t),b=a.pow(f,i),x=a.pow(f,t);for(;!a.eql(x,a.ONE);){if(a.eql(x,a.ZERO))return a.ZERO;let T=1;for(let k=a.sqr(x);T<g&&!a.eql(k,a.ONE);T++)k=a.sqr(k);const L=a.pow(_,He<<BigInt(g-T-1));_=a.sqr(L),b=a.mul(b,L),x=a.mul(x,_),g=T}return b}}function Bc(n){if(n%Xn===Tc){const e=(n+He)/Xn;return function(r,s){const i=r.pow(s,e);if(!r.eql(r.sqr(i),s))throw new Error("Cannot find square root");return i}}if(n%Ws===Ks){const e=(n-Ks)/Ws;return function(r,s){const i=r.mul(s,hr),o=r.pow(i,e),a=r.mul(s,o),f=r.mul(r.mul(a,hr),o),g=r.mul(a,r.sub(f,r.ONE));if(!r.eql(r.sqr(g),s))throw new Error("Cannot find square root");return g}}return xc(n)}const Lc=(n,e)=>(Ke(n,e)&He)===He,Cc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Mc(n){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=Cc.reduce((r,s)=>(r[s]="function",r),e);return Ir(n,t)}function Pc(n,e,t){if(t<pt)throw new Error("Expected power > 0");if(t===pt)return n.ONE;if(t===He)return e;let r=n.ONE,s=e;for(;t>pt;)t&He&&(r=n.mul(r,s)),s=n.sqr(s),t>>=He;return r}function Uc(n,e){const t=new Array(e.length),r=e.reduce((i,o,a)=>n.is0(o)?i:(t[a]=i,n.mul(i,o)),n.ONE),s=n.inv(r);return e.reduceRight((i,o,a)=>n.is0(o)?i:(t[a]=n.mul(i,t[a]),n.mul(i,o)),s),t}function Hs(n,e){const t=e!==void 0?e:n.toString(2).length,r=Math.ceil(t/8);return{nBitLength:t,nByteLength:r}}function qs(n,e,t=!1,r={}){if(n<=pt)throw new Error(`Expected Field ORDER > 0, got ${n}`);const{nBitLength:s,nByteLength:i}=Hs(n,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=Bc(n),a=Object.freeze({ORDER:n,BITS:s,BYTES:i,MASK:jn(s),ZERO:pt,ONE:He,create:f=>Ke(f,n),isValid:f=>{if(typeof f!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof f}`);return pt<=f&&f<n},is0:f=>f===pt,isOdd:f=>(f&He)===He,neg:f=>Ke(-f,n),eql:(f,g)=>f===g,sqr:f=>Ke(f*f,n),add:(f,g)=>Ke(f+g,n),sub:(f,g)=>Ke(f-g,n),mul:(f,g)=>Ke(f*g,n),pow:(f,g)=>Pc(a,f,g),div:(f,g)=>Ke(f*Jn(g,n),n),sqrN:f=>f*f,addN:(f,g)=>f+g,subN:(f,g)=>f-g,mulN:(f,g)=>f*g,inv:f=>Jn(f,n),sqrt:r.sqrt||(f=>o(a,f)),invertBatch:f=>Uc(a,f),cmov:(f,g,_)=>_?g:f,toBytes:f=>t?Hr(f,i):Ar(f,i),fromBytes:f=>{if(f.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${f.length}`);return t?Sr(f):ur(f)}});return Object.freeze(a)}function Gs(n){if(typeof n!="bigint")throw new Error("field order must be bigint");const e=n.toString(2).length;return Math.ceil(e/8)}function Vs(n){const e=Gs(n);return e+Math.ceil(e/2)}function Dc(n,e,t=!1){const r=n.length,s=Gs(e),i=Vs(e);if(r<16||r<i||r>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const o=t?ur(n):Sr(n),a=Ke(o,e-He)+He;return t?Hr(a,s):Ar(a,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Fc=BigInt(0),Qn=BigInt(1);function Ys(n,e){const t=(s,i)=>{const o=i.negate();return s?o:i},r=s=>{const i=Math.ceil(e/s)+1,o=2**(s-1);return{windows:i,windowSize:o}};return{constTimeNegate:t,unsafeLadder(s,i){let o=n.ZERO,a=s;for(;i>Fc;)i&Qn&&(o=o.add(a)),a=a.double(),i>>=Qn;return o},precomputeWindow(s,i){const{windows:o,windowSize:a}=r(i),f=[];let g=s,_=g;for(let b=0;b<o;b++){_=g,f.push(_);for(let x=1;x<a;x++)_=_.add(g),f.push(_);g=_.double()}return f},wNAF(s,i,o){const{windows:a,windowSize:f}=r(s);let g=n.ZERO,_=n.BASE;const b=BigInt(2**s-1),x=2**s,T=BigInt(s);for(let L=0;L<a;L++){const k=L*f;let N=Number(o&b);o>>=T,N>f&&(N-=x,o+=Qn);const M=k,W=k+Math.abs(N)-1,$=L%2!==0,J=N<0;N===0?_=_.add(t($,i[M])):g=g.add(t(J,i[W]))}return{p:g,f:_}},wNAFCached(s,i,o,a){const f=s._WINDOW_SIZE||1;let g=i.get(s);return g||(g=this.precomputeWindow(s,f),f!==1&&i.set(s,a(g))),this.wNAF(f,g,o)}}}function ei(n){return Mc(n.Fp),Ir(n,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Hs(n.n,n.nBitLength),...n,p:n.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const xt=BigInt(0),kt=BigInt(1),un=BigInt(2),zc=BigInt(8),$c={zip215:!0};function Kc(n){const e=ei(n);return Ir(n,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Wc(n){const e=Kc(n),{Fp:t,n:r,prehash:s,hash:i,randomBytes:o,nByteLength:a,h:f}=e,g=un<<BigInt(a*8)-kt,_=t.create,b=e.uvRatio||((S,I)=>{try{return{isValid:!0,value:t.sqrt(S*t.inv(I))}}catch{return{isValid:!1,value:xt}}}),x=e.adjustScalarBytes||(S=>S),T=e.domain||((S,I,C)=>{if(I.length||C)throw new Error("Contexts/pre-hash are not supported");return S}),L=S=>typeof S=="bigint"&&xt<S,k=(S,I)=>L(S)&&L(I)&&S<I,N=S=>S===xt||k(S,g);function M(S,I){if(k(S,I))return S;throw new Error(`Expected valid scalar < ${I}, got ${typeof S} ${S}`)}function W(S){return S===xt?S:M(S,r)}const $=new Map;function J(S){if(!(S instanceof q))throw new Error("ExtendedPoint expected")}class q{constructor(I,C,R,u){if(this.ex=I,this.ey=C,this.ez=R,this.et=u,!N(I))throw new Error("x required");if(!N(C))throw new Error("y required");if(!N(R))throw new Error("z required");if(!N(u))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(I){if(I instanceof q)throw new Error("extended point not allowed");const{x:C,y:R}=I||{};if(!N(C)||!N(R))throw new Error("invalid affine point");return new q(C,R,kt,_(C*R))}static normalizeZ(I){const C=t.invertBatch(I.map(R=>R.ez));return I.map((R,u)=>R.toAffine(C[u])).map(q.fromAffine)}_setWindowSize(I){this._WINDOW_SIZE=I,$.delete(this)}assertValidity(){const{a:I,d:C}=e;if(this.is0())throw new Error("bad point: ZERO");const{ex:R,ey:u,ez:l,et:w}=this,E=_(R*R),P=_(u*u),V=_(l*l),ne=_(V*V),ce=_(E*I),ve=_(V*_(ce+P)),ge=_(ne+_(C*_(E*P)));if(ve!==ge)throw new Error("bad point: equation left != right (1)");const Re=_(R*u),ke=_(l*w);if(Re!==ke)throw new Error("bad point: equation left != right (2)")}equals(I){J(I);const{ex:C,ey:R,ez:u}=this,{ex:l,ey:w,ez:E}=I,P=_(C*E),V=_(l*u),ne=_(R*E),ce=_(w*u);return P===V&&ne===ce}is0(){return this.equals(q.ZERO)}negate(){return new q(_(-this.ex),this.ey,this.ez,_(-this.et))}double(){const{a:I}=e,{ex:C,ey:R,ez:u}=this,l=_(C*C),w=_(R*R),E=_(un*_(u*u)),P=_(I*l),V=C+R,ne=_(_(V*V)-l-w),ce=P+w,ve=ce-E,ge=P-w,Re=_(ne*ve),ke=_(ce*ge),Ee=_(ne*ge),Ne=_(ve*ce);return new q(Re,ke,Ne,Ee)}add(I){J(I);const{a:C,d:R}=e,{ex:u,ey:l,ez:w,et:E}=this,{ex:P,ey:V,ez:ne,et:ce}=I;if(C===BigInt(-1)){const St=_((l-u)*(V+P)),Me=_((l+u)*(V-P)),De=_(Me-St);if(De===xt)return this.double();const Ot=_(w*un*ce),ze=_(E*un*ne),y=ze+Ot,h=Me+St,d=ze-Ot,O=_(y*De),U=_(h*d),F=_(y*d),Y=_(De*h);return new q(O,U,Y,F)}const ve=_(u*P),ge=_(l*V),Re=_(E*R*ce),ke=_(w*ne),Ee=_((u+l)*(P+V)-ve-ge),Ne=ke-Re,qt=ke+Re,Le=_(ge-C*ve),We=_(Ee*Ne),Fr=_(qt*Le),Fe=_(Ee*Le),Ce=_(Ne*qt);return new q(We,Fr,Ce,Fe)}subtract(I){return this.add(I.negate())}wNAF(I){return j.wNAFCached(this,$,I,q.normalizeZ)}multiply(I){const{p:C,f:R}=this.wNAF(M(I,r));return q.normalizeZ([C,R])[0]}multiplyUnsafe(I){let C=W(I);return C===xt?Z:this.equals(Z)||C===kt?this:this.equals(D)?this.wNAF(C).p:j.unsafeLadder(this,C)}isSmallOrder(){return this.multiplyUnsafe(f).is0()}isTorsionFree(){return j.unsafeLadder(this,r).is0()}toAffine(I){const{ex:C,ey:R,ez:u}=this,l=this.is0();I==null&&(I=l?zc:t.inv(u));const w=_(C*I),E=_(R*I),P=_(u*I);if(l)return{x:xt,y:kt};if(P!==kt)throw new Error("invZ was invalid");return{x:w,y:E}}clearCofactor(){const{h:I}=e;return I===kt?this:this.multiplyUnsafe(I)}static fromHex(I,C=!1){const{d:R,a:u}=e,l=t.BYTES;I=dt("pointHex",I,l);const w=I.slice(),E=I[l-1];w[l-1]=E&-129;const P=Sr(w);P===xt||(C?M(P,g):M(P,t.ORDER));const V=_(P*P),ne=_(V-kt),ce=_(R*V-u);let{isValid:ve,value:ge}=b(ne,ce);if(!ve)throw new Error("Point.fromHex: invalid y coordinate");const Re=(ge&kt)===kt,ke=(E&128)!==0;if(!C&&ge===xt&&ke)throw new Error("Point.fromHex: x=0 and x_0=1");return ke!==Re&&(ge=_(-ge)),q.fromAffine({x:ge,y:P})}static fromPrivateKey(I){return G(I).point}toRawBytes(){const{x:I,y:C}=this.toAffine(),R=Hr(C,t.BYTES);return R[R.length-1]|=I&kt?128:0,R}toHex(){return cr(this.toRawBytes())}}q.BASE=new q(e.Gx,e.Gy,kt,_(e.Gx*e.Gy)),q.ZERO=new q(xt,kt,kt,xt);const{BASE:D,ZERO:Z}=q,j=Ys(q,a*8);function X(S){return Ke(S,r)}function z(S){return X(Sr(S))}function G(S){const I=a;S=dt("private key",S,I);const C=dt("hashed private key",i(S),2*I),R=x(C.slice(0,I)),u=C.slice(I,2*I),l=z(R),w=D.multiply(l),E=w.toRawBytes();return{head:R,prefix:u,scalar:l,point:w,pointBytes:E}}function Q(S){return G(S).pointBytes}function A(S=new Uint8Array,...I){const C=lr(...I);return z(i(T(C,dt("context",S),!!s)))}function c(S,I,C={}){S=dt("message",S),s&&(S=s(S));const{prefix:R,scalar:u,pointBytes:l}=G(I),w=A(C.context,R,S),E=D.multiply(w).toRawBytes(),P=A(C.context,E,l,S),V=X(w+P*u);W(V);const ne=lr(E,Hr(V,t.BYTES));return dt("result",ne,a*2)}const p=$c;function m(S,I,C,R=p){const{context:u,zip215:l}=R,w=t.BYTES;S=dt("signature",S,2*w),I=dt("message",I),s&&(I=s(I));const E=Sr(S.slice(w,2*w));let P,V,ne;try{P=q.fromHex(C,l),V=q.fromHex(S.slice(0,w),l),ne=D.multiplyUnsafe(E)}catch{return!1}if(!l&&P.isSmallOrder())return!1;const ce=A(u,V.toRawBytes(),P.toRawBytes(),I);return V.add(P.multiplyUnsafe(ce)).subtract(ne).clearCofactor().equals(q.ZERO)}return D._setWindowSize(8),{CURVE:e,getPublicKey:Q,sign:c,verify:m,ExtendedPoint:q,utils:{getExtendedPublicKey:G,randomPrivateKey:()=>o(t.BYTES),precompute(S=8,I=q.BASE){return I._setWindowSize(S),I.multiply(BigInt(3)),I}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ti=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),js=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const Hc=BigInt(1),Zs=BigInt(2);BigInt(3);const qc=BigInt(5),Gc=BigInt(8);function Vc(n){const e=BigInt(10),t=BigInt(20),r=BigInt(40),s=BigInt(80),i=ti,a=n*n%i*n%i,f=Ve(a,Zs,i)*a%i,g=Ve(f,Hc,i)*n%i,_=Ve(g,qc,i)*g%i,b=Ve(_,e,i)*_%i,x=Ve(b,t,i)*b%i,T=Ve(x,r,i)*x%i,L=Ve(T,s,i)*T%i,k=Ve(L,s,i)*T%i,N=Ve(k,e,i)*_%i;return{pow_p_5_8:Ve(N,Zs,i)*n%i,b2:a}}function Yc(n){return n[0]&=248,n[31]&=127,n[31]|=64,n}function jc(n,e){const t=ti,r=Ke(e*e*e,t),s=Ke(r*r*e,t),i=Vc(n*s).pow_p_5_8;let o=Ke(n*r*i,t);const a=Ke(e*o*o,t),f=o,g=Ke(o*js,t),_=a===n,b=a===Ke(-n,t),x=a===Ke(-n*js,t);return _&&(o=f),(b||x)&&(o=g),Lc(o,t)&&(o=Ke(-o,t)),{isValid:_||b,value:o}}const Zc=qs(ti,void 0,!0),Xc={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Zc,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Gc,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:_c,randomBytes:Ts,adjustScalarBytes:Yc,uvRatio:jc},vr=Wc(Xc);var ln={exports:{}};const Jc=zn(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Qc=ln.exports,Xs;function Js(){return Xs||(Xs=1,function(n){(function(e,t){function r(A,c){if(!A)throw new Error(c||"Assertion failed")}function s(A,c){A.super_=c;var p=function(){};p.prototype=c.prototype,A.prototype=new p,A.prototype.constructor=A}function i(A,c,p){if(i.isBN(A))return A;this.negative=0,this.words=null,this.length=0,this.red=null,A!==null&&((c==="le"||c==="be")&&(p=c,c=10),this._init(A||0,c||10,p||"be"))}typeof e=="object"?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Jc.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,m){if(typeof c=="number")return this._initNumber(c,p,m);if(typeof c=="object")return this._initArray(c,p,m);p==="hex"&&(p=16),r(p===(p|0)&&p>=2&&p<=36),c=c.toString().replace(/\s+/g,"");var v=0;c[0]==="-"&&(v++,this.negative=1),v<c.length&&(p===16?this._parseHex(c,v,m):(this._parseBase(c,p,v),m==="le"&&this._initArray(this.toArray(),p,m)))},i.prototype._initNumber=function(c,p,m){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),m==="le"&&this._initArray(this.toArray(),p,m)},i.prototype._initArray=function(c,p,m){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 v=0;v<this.length;v++)this.words[v]=0;var S,I,C=0;if(m==="be")for(v=c.length-1,S=0;v>=0;v-=3)I=c[v]|c[v-1]<<8|c[v-2]<<16,this.words[S]|=I<<C&67108863,this.words[S+1]=I>>>26-C&67108863,C+=24,C>=26&&(C-=26,S++);else if(m==="le")for(v=0,S=0;v<c.length;v+=3)I=c[v]|c[v+1]<<8|c[v+2]<<16,this.words[S]|=I<<C&67108863,this.words[S+1]=I>>>26-C&67108863,C+=24,C>=26&&(C-=26,S++);return this._strip()};function a(A,c){var p=A.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 "+A)}function f(A,c,p){var m=a(A,p);return p-1>=c&&(m|=a(A,p-1)<<4),m}i.prototype._parseHex=function(c,p,m){this.length=Math.ceil((c.length-p)/6),this.words=new Array(this.length);for(var v=0;v<this.length;v++)this.words[v]=0;var S=0,I=0,C;if(m==="be")for(v=c.length-1;v>=p;v-=2)C=f(c,p,v)<<S,this.words[I]|=C&67108863,S>=18?(S-=18,I+=1,this.words[I]|=C>>>26):S+=8;else{var R=c.length-p;for(v=R%2===0?p+1:p;v<c.length;v+=2)C=f(c,p,v)<<S,this.words[I]|=C&67108863,S>=18?(S-=18,I+=1,this.words[I]|=C>>>26):S+=8}this._strip()};function g(A,c,p,m){for(var v=0,S=0,I=Math.min(A.length,p),C=c;C<I;C++){var R=A.charCodeAt(C)-48;v*=m,R>=49?S=R-49+10:R>=17?S=R-17+10:S=R,r(R>=0&&S<m,"Invalid character"),v+=S}return v}i.prototype._parseBase=function(c,p,m){this.words=[0],this.length=1;for(var v=0,S=1;S<=67108863;S*=p)v++;v--,S=S/p|0;for(var I=c.length-m,C=I%v,R=Math.min(I,I-C)+m,u=0,l=m;l<R;l+=v)u=g(c,l,l+v,p),this.imuln(S),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(C!==0){var w=1;for(u=g(c,l,c.length,p),l=0;l<C;l++)w*=p;this.imuln(w),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}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 _(A,c){A.words=c.words,A.length=c.length,A.negative=c.negative,A.red=c.red}if(i.prototype._move=function(c){_(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")]=b}catch{i.prototype.inspect=b}else i.prototype.inspect=b;function b(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var x=["","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"],T=[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],L=[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 m;if(c===16||c==="hex"){m="";for(var v=0,S=0,I=0;I<this.length;I++){var C=this.words[I],R=((C<<v|S)&16777215).toString(16);S=C>>>24-v&16777215,v+=2,v>=26&&(v-=26,I--),S!==0||I!==this.length-1?m=x[6-R.length]+R+m:m=R+m}for(S!==0&&(m=S.toString(16)+m);m.length%p!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}if(c===(c|0)&&c>=2&&c<=36){var u=T[c],l=L[c];m="";var w=this.clone();for(w.negative=0;!w.isZero();){var E=w.modrn(l).toString(c);w=w.idivn(l),w.isZero()?m=E+m:m=x[u-E.length]+E+m}for(this.isZero()&&(m="0"+m);m.length%p!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var 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 k=function(c,p){return c.allocUnsafe?c.allocUnsafe(p):new c(p)};i.prototype.toArrayLike=function(c,p,m){this._strip();var v=this.byteLength(),S=m||Math.max(1,v);r(v<=S,"byte array longer than desired length"),r(S>0,"Requested array length <= 0");var I=k(c,S),C=p==="le"?"LE":"BE";return this["_toArrayLike"+C](I,v),I},i.prototype._toArrayLikeLE=function(c,p){for(var m=0,v=0,S=0,I=0;S<this.length;S++){var C=this.words[S]<<I|v;c[m++]=C&255,m<c.length&&(c[m++]=C>>8&255),m<c.length&&(c[m++]=C>>16&255),I===6?(m<c.length&&(c[m++]=C>>24&255),v=0,I=0):(v=C>>>24,I+=2)}if(m<c.length)for(c[m++]=v;m<c.length;)c[m++]=0},i.prototype._toArrayLikeBE=function(c,p){for(var m=c.length-1,v=0,S=0,I=0;S<this.length;S++){var C=this.words[S]<<I|v;c[m--]=C&255,m>=0&&(c[m--]=C>>8&255),m>=0&&(c[m--]=C>>16&255),I===6?(m>=0&&(c[m--]=C>>24&255),v=0,I=0):(v=C>>>24,I+=2)}if(m>=0)for(c[m--]=v;m>=0;)c[m--]=0},Math.clz32?i.prototype._countBits=function(c){return 32-Math.clz32(c)}:i.prototype._countBits=function(c){var p=c,m=0;return p>=4096&&(m+=13,p>>>=13),p>=64&&(m+=7,p>>>=7),p>=8&&(m+=4,p>>>=4),p>=2&&(m+=2,p>>>=2),m+p},i.prototype._zeroBits=function(c){if(c===0)return 26;var p=c,m=0;return(p&8191)===0&&(m+=13,p>>>=13),(p&127)===0&&(m+=7,p>>>=7),(p&15)===0&&(m+=4,p>>>=4),(p&3)===0&&(m+=2,p>>>=2),(p&1)===0&&m++,m},i.prototype.bitLength=function(){var c=this.words[this.length-1],p=this._countBits(c);return(this.length-1)*26+p};function N(A){for(var c=new Array(A.bitLength()),p=0;p<c.length;p++){var m=p/26|0,v=p%26;c[p]=A.words[m]>>>v&1}return c}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var c=0,p=0;p<this.length;p++){var m=this._zeroBits(this.words[p]);if(c+=m,m!==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 m=0;m<p.length;m++)this.words[m]=this.words[m]&c.words[m];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,m;this.length>c.length?(p=this,m=c):(p=c,m=this);for(var v=0;v<m.length;v++)this.words[v]=p.words[v]^m.words[v];if(this!==p)for(;v<p.length;v++)this.words[v]=p.words[v];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,m=c%26;this._expand(p),m>0&&p--;for(var v=0;v<p;v++)this.words[v]=~this.words[v]&67108863;return m>0&&(this.words[v]=~this.words[v]&67108863>>26-m),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 m=c/26|0,v=c%26;return this._expand(m+1),p?this.words[m]=this.words[m]|1<<v:this.words[m]=this.words[m]&~(1<<v),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 m,v;this.length>c.length?(m=this,v=c):(m=c,v=this);for(var S=0,I=0;I<v.length;I++)p=(m.words[I]|0)+(v.words[I]|0)+S,this.words[I]=p&67108863,S=p>>>26;for(;S!==0&&I<m.length;I++)p=(m.words[I]|0)+S,this.words[I]=p&67108863,S=p>>>26;if(this.length=m.length,S!==0)this.words[this.length]=S,this.length++;else if(m!==this)for(;I<m.length;I++)this.words[I]=m.words[I];return this},i.prototype.add=function(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 m=this.cmp(c);if(m===0)return this.negative=0,this.length=1,this.words[0]=0,this;var v,S;m>0?(v=this,S=c):(v=c,S=this);for(var I=0,C=0;C<S.length;C++)p=(v.words[C]|0)-(S.words[C]|0)+I,I=p>>26,this.words[C]=p&67108863;for(;I!==0&&C<v.length;C++)p=(v.words[C]|0)+I,I=p>>26,this.words[C]=p&67108863;if(I===0&&C<v.length&&v!==this)for(;C<v.length;C++)this.words[C]=v.words[C];return this.length=Math.max(this.length,C),v!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(c){return this.clone().isub(c)};function M(A,c,p){p.negative=c.negative^A.negative;var m=A.length+c.length|0;p.length=m,m=m-1|0;var v=A.words[0]|0,S=c.words[0]|0,I=v*S,C=I&67108863,R=I/67108864|0;p.words[0]=C;for(var u=1;u<m;u++){for(var l=R>>>26,w=R&67108863,E=Math.min(u,c.length-1),P=Math.max(0,u-A.length+1);P<=E;P++){var V=u-P|0;v=A.words[V]|0,S=c.words[P]|0,I=v*S+w,l+=I/67108864|0,w=I&67108863}p.words[u]=w|0,R=l|0}return R!==0?p.words[u]=R|0:p.length--,p._strip()}var W=function(c,p,m){var v=c.words,S=p.words,I=m.words,C=0,R,u,l,w=v[0]|0,E=w&8191,P=w>>>13,V=v[1]|0,ne=V&8191,ce=V>>>13,ve=v[2]|0,ge=ve&8191,Re=ve>>>13,ke=v[3]|0,Ee=ke&8191,Ne=ke>>>13,qt=v[4]|0,Le=qt&8191,We=qt>>>13,Fr=v[5]|0,Fe=Fr&8191,Ce=Fr>>>13,St=v[6]|0,Me=St&8191,De=St>>>13,Ot=v[7]|0,ze=Ot&8191,y=Ot>>>13,h=v[8]|0,d=h&8191,O=h>>>13,U=v[9]|0,F=U&8191,Y=U>>>13,be=S[0]|0,me=be&8191,pe=be>>>13,$e=S[1]|0,de=$e&8191,Ze=$e>>>13,za=S[2]|0,Xe=za&8191,Je=za>>>13,$a=S[3]|0,Qe=$a&8191,et=$a>>>13,Ka=S[4]|0,tt=Ka&8191,rt=Ka>>>13,Wa=S[5]|0,nt=Wa&8191,it=Wa>>>13,Ha=S[6]|0,st=Ha&8191,ot=Ha>>>13,qa=S[7]|0,at=qa&8191,ct=qa>>>13,Ga=S[8]|0,ut=Ga&8191,lt=Ga>>>13,Va=S[9]|0,ht=Va&8191,ft=Va>>>13;m.negative=c.negative^p.negative,m.length=19,R=Math.imul(E,me),u=Math.imul(E,pe),u=u+Math.imul(P,me)|0,l=Math.imul(P,pe);var ts=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(ts>>>26)|0,ts&=67108863,R=Math.imul(ne,me),u=Math.imul(ne,pe),u=u+Math.imul(ce,me)|0,l=Math.imul(ce,pe),R=R+Math.imul(E,de)|0,u=u+Math.imul(E,Ze)|0,u=u+Math.imul(P,de)|0,l=l+Math.imul(P,Ze)|0;var rs=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(rs>>>26)|0,rs&=67108863,R=Math.imul(ge,me),u=Math.imul(ge,pe),u=u+Math.imul(Re,me)|0,l=Math.imul(Re,pe),R=R+Math.imul(ne,de)|0,u=u+Math.imul(ne,Ze)|0,u=u+Math.imul(ce,de)|0,l=l+Math.imul(ce,Ze)|0,R=R+Math.imul(E,Xe)|0,u=u+Math.imul(E,Je)|0,u=u+Math.imul(P,Xe)|0,l=l+Math.imul(P,Je)|0;var ns=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(ns>>>26)|0,ns&=67108863,R=Math.imul(Ee,me),u=Math.imul(Ee,pe),u=u+Math.imul(Ne,me)|0,l=Math.imul(Ne,pe),R=R+Math.imul(ge,de)|0,u=u+Math.imul(ge,Ze)|0,u=u+Math.imul(Re,de)|0,l=l+Math.imul(Re,Ze)|0,R=R+Math.imul(ne,Xe)|0,u=u+Math.imul(ne,Je)|0,u=u+Math.imul(ce,Xe)|0,l=l+Math.imul(ce,Je)|0,R=R+Math.imul(E,Qe)|0,u=u+Math.imul(E,et)|0,u=u+Math.imul(P,Qe)|0,l=l+Math.imul(P,et)|0;var is=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(is>>>26)|0,is&=67108863,R=Math.imul(Le,me),u=Math.imul(Le,pe),u=u+Math.imul(We,me)|0,l=Math.imul(We,pe),R=R+Math.imul(Ee,de)|0,u=u+Math.imul(Ee,Ze)|0,u=u+Math.imul(Ne,de)|0,l=l+Math.imul(Ne,Ze)|0,R=R+Math.imul(ge,Xe)|0,u=u+Math.imul(ge,Je)|0,u=u+Math.imul(Re,Xe)|0,l=l+Math.imul(Re,Je)|0,R=R+Math.imul(ne,Qe)|0,u=u+Math.imul(ne,et)|0,u=u+Math.imul(ce,Qe)|0,l=l+Math.imul(ce,et)|0,R=R+Math.imul(E,tt)|0,u=u+Math.imul(E,rt)|0,u=u+Math.imul(P,tt)|0,l=l+Math.imul(P,rt)|0;var ss=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(ss>>>26)|0,ss&=67108863,R=Math.imul(Fe,me),u=Math.imul(Fe,pe),u=u+Math.imul(Ce,me)|0,l=Math.imul(Ce,pe),R=R+Math.imul(Le,de)|0,u=u+Math.imul(Le,Ze)|0,u=u+Math.imul(We,de)|0,l=l+Math.imul(We,Ze)|0,R=R+Math.imul(Ee,Xe)|0,u=u+Math.imul(Ee,Je)|0,u=u+Math.imul(Ne,Xe)|0,l=l+Math.imul(Ne,Je)|0,R=R+Math.imul(ge,Qe)|0,u=u+Math.imul(ge,et)|0,u=u+Math.imul(Re,Qe)|0,l=l+Math.imul(Re,et)|0,R=R+Math.imul(ne,tt)|0,u=u+Math.imul(ne,rt)|0,u=u+Math.imul(ce,tt)|0,l=l+Math.imul(ce,rt)|0,R=R+Math.imul(E,nt)|0,u=u+Math.imul(E,it)|0,u=u+Math.imul(P,nt)|0,l=l+Math.imul(P,it)|0;var os=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(os>>>26)|0,os&=67108863,R=Math.imul(Me,me),u=Math.imul(Me,pe),u=u+Math.imul(De,me)|0,l=Math.imul(De,pe),R=R+Math.imul(Fe,de)|0,u=u+Math.imul(Fe,Ze)|0,u=u+Math.imul(Ce,de)|0,l=l+Math.imul(Ce,Ze)|0,R=R+Math.imul(Le,Xe)|0,u=u+Math.imul(Le,Je)|0,u=u+Math.imul(We,Xe)|0,l=l+Math.imul(We,Je)|0,R=R+Math.imul(Ee,Qe)|0,u=u+Math.imul(Ee,et)|0,u=u+Math.imul(Ne,Qe)|0,l=l+Math.imul(Ne,et)|0,R=R+Math.imul(ge,tt)|0,u=u+Math.imul(ge,rt)|0,u=u+Math.imul(Re,tt)|0,l=l+Math.imul(Re,rt)|0,R=R+Math.imul(ne,nt)|0,u=u+Math.imul(ne,it)|0,u=u+Math.imul(ce,nt)|0,l=l+Math.imul(ce,it)|0,R=R+Math.imul(E,st)|0,u=u+Math.imul(E,ot)|0,u=u+Math.imul(P,st)|0,l=l+Math.imul(P,ot)|0;var as=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(as>>>26)|0,as&=67108863,R=Math.imul(ze,me),u=Math.imul(ze,pe),u=u+Math.imul(y,me)|0,l=Math.imul(y,pe),R=R+Math.imul(Me,de)|0,u=u+Math.imul(Me,Ze)|0,u=u+Math.imul(De,de)|0,l=l+Math.imul(De,Ze)|0,R=R+Math.imul(Fe,Xe)|0,u=u+Math.imul(Fe,Je)|0,u=u+Math.imul(Ce,Xe)|0,l=l+Math.imul(Ce,Je)|0,R=R+Math.imul(Le,Qe)|0,u=u+Math.imul(Le,et)|0,u=u+Math.imul(We,Qe)|0,l=l+Math.imul(We,et)|0,R=R+Math.imul(Ee,tt)|0,u=u+Math.imul(Ee,rt)|0,u=u+Math.imul(Ne,tt)|0,l=l+Math.imul(Ne,rt)|0,R=R+Math.imul(ge,nt)|0,u=u+Math.imul(ge,it)|0,u=u+Math.imul(Re,nt)|0,l=l+Math.imul(Re,it)|0,R=R+Math.imul(ne,st)|0,u=u+Math.imul(ne,ot)|0,u=u+Math.imul(ce,st)|0,l=l+Math.imul(ce,ot)|0,R=R+Math.imul(E,at)|0,u=u+Math.imul(E,ct)|0,u=u+Math.imul(P,at)|0,l=l+Math.imul(P,ct)|0;var cs=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(cs>>>26)|0,cs&=67108863,R=Math.imul(d,me),u=Math.imul(d,pe),u=u+Math.imul(O,me)|0,l=Math.imul(O,pe),R=R+Math.imul(ze,de)|0,u=u+Math.imul(ze,Ze)|0,u=u+Math.imul(y,de)|0,l=l+Math.imul(y,Ze)|0,R=R+Math.imul(Me,Xe)|0,u=u+Math.imul(Me,Je)|0,u=u+Math.imul(De,Xe)|0,l=l+Math.imul(De,Je)|0,R=R+Math.imul(Fe,Qe)|0,u=u+Math.imul(Fe,et)|0,u=u+Math.imul(Ce,Qe)|0,l=l+Math.imul(Ce,et)|0,R=R+Math.imul(Le,tt)|0,u=u+Math.imul(Le,rt)|0,u=u+Math.imul(We,tt)|0,l=l+Math.imul(We,rt)|0,R=R+Math.imul(Ee,nt)|0,u=u+Math.imul(Ee,it)|0,u=u+Math.imul(Ne,nt)|0,l=l+Math.imul(Ne,it)|0,R=R+Math.imul(ge,st)|0,u=u+Math.imul(ge,ot)|0,u=u+Math.imul(Re,st)|0,l=l+Math.imul(Re,ot)|0,R=R+Math.imul(ne,at)|0,u=u+Math.imul(ne,ct)|0,u=u+Math.imul(ce,at)|0,l=l+Math.imul(ce,ct)|0,R=R+Math.imul(E,ut)|0,u=u+Math.imul(E,lt)|0,u=u+Math.imul(P,ut)|0,l=l+Math.imul(P,lt)|0;var us=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(us>>>26)|0,us&=67108863,R=Math.imul(F,me),u=Math.imul(F,pe),u=u+Math.imul(Y,me)|0,l=Math.imul(Y,pe),R=R+Math.imul(d,de)|0,u=u+Math.imul(d,Ze)|0,u=u+Math.imul(O,de)|0,l=l+Math.imul(O,Ze)|0,R=R+Math.imul(ze,Xe)|0,u=u+Math.imul(ze,Je)|0,u=u+Math.imul(y,Xe)|0,l=l+Math.imul(y,Je)|0,R=R+Math.imul(Me,Qe)|0,u=u+Math.imul(Me,et)|0,u=u+Math.imul(De,Qe)|0,l=l+Math.imul(De,et)|0,R=R+Math.imul(Fe,tt)|0,u=u+Math.imul(Fe,rt)|0,u=u+Math.imul(Ce,tt)|0,l=l+Math.imul(Ce,rt)|0,R=R+Math.imul(Le,nt)|0,u=u+Math.imul(Le,it)|0,u=u+Math.imul(We,nt)|0,l=l+Math.imul(We,it)|0,R=R+Math.imul(Ee,st)|0,u=u+Math.imul(Ee,ot)|0,u=u+Math.imul(Ne,st)|0,l=l+Math.imul(Ne,ot)|0,R=R+Math.imul(ge,at)|0,u=u+Math.imul(ge,ct)|0,u=u+Math.imul(Re,at)|0,l=l+Math.imul(Re,ct)|0,R=R+Math.imul(ne,ut)|0,u=u+Math.imul(ne,lt)|0,u=u+Math.imul(ce,ut)|0,l=l+Math.imul(ce,lt)|0,R=R+Math.imul(E,ht)|0,u=u+Math.imul(E,ft)|0,u=u+Math.imul(P,ht)|0,l=l+Math.imul(P,ft)|0;var ls=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(ls>>>26)|0,ls&=67108863,R=Math.imul(F,de),u=Math.imul(F,Ze),u=u+Math.imul(Y,de)|0,l=Math.imul(Y,Ze),R=R+Math.imul(d,Xe)|0,u=u+Math.imul(d,Je)|0,u=u+Math.imul(O,Xe)|0,l=l+Math.imul(O,Je)|0,R=R+Math.imul(ze,Qe)|0,u=u+Math.imul(ze,et)|0,u=u+Math.imul(y,Qe)|0,l=l+Math.imul(y,et)|0,R=R+Math.imul(Me,tt)|0,u=u+Math.imul(Me,rt)|0,u=u+Math.imul(De,tt)|0,l=l+Math.imul(De,rt)|0,R=R+Math.imul(Fe,nt)|0,u=u+Math.imul(Fe,it)|0,u=u+Math.imul(Ce,nt)|0,l=l+Math.imul(Ce,it)|0,R=R+Math.imul(Le,st)|0,u=u+Math.imul(Le,ot)|0,u=u+Math.imul(We,st)|0,l=l+Math.imul(We,ot)|0,R=R+Math.imul(Ee,at)|0,u=u+Math.imul(Ee,ct)|0,u=u+Math.imul(Ne,at)|0,l=l+Math.imul(Ne,ct)|0,R=R+Math.imul(ge,ut)|0,u=u+Math.imul(ge,lt)|0,u=u+Math.imul(Re,ut)|0,l=l+Math.imul(Re,lt)|0,R=R+Math.imul(ne,ht)|0,u=u+Math.imul(ne,ft)|0,u=u+Math.imul(ce,ht)|0,l=l+Math.imul(ce,ft)|0;var hs=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(hs>>>26)|0,hs&=67108863,R=Math.imul(F,Xe),u=Math.imul(F,Je),u=u+Math.imul(Y,Xe)|0,l=Math.imul(Y,Je),R=R+Math.imul(d,Qe)|0,u=u+Math.imul(d,et)|0,u=u+Math.imul(O,Qe)|0,l=l+Math.imul(O,et)|0,R=R+Math.imul(ze,tt)|0,u=u+Math.imul(ze,rt)|0,u=u+Math.imul(y,tt)|0,l=l+Math.imul(y,rt)|0,R=R+Math.imul(Me,nt)|0,u=u+Math.imul(Me,it)|0,u=u+Math.imul(De,nt)|0,l=l+Math.imul(De,it)|0,R=R+Math.imul(Fe,st)|0,u=u+Math.imul(Fe,ot)|0,u=u+Math.imul(Ce,st)|0,l=l+Math.imul(Ce,ot)|0,R=R+Math.imul(Le,at)|0,u=u+Math.imul(Le,ct)|0,u=u+Math.imul(We,at)|0,l=l+Math.imul(We,ct)|0,R=R+Math.imul(Ee,ut)|0,u=u+Math.imul(Ee,lt)|0,u=u+Math.imul(Ne,ut)|0,l=l+Math.imul(Ne,lt)|0,R=R+Math.imul(ge,ht)|0,u=u+Math.imul(ge,ft)|0,u=u+Math.imul(Re,ht)|0,l=l+Math.imul(Re,ft)|0;var fs=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(fs>>>26)|0,fs&=67108863,R=Math.imul(F,Qe),u=Math.imul(F,et),u=u+Math.imul(Y,Qe)|0,l=Math.imul(Y,et),R=R+Math.imul(d,tt)|0,u=u+Math.imul(d,rt)|0,u=u+Math.imul(O,tt)|0,l=l+Math.imul(O,rt)|0,R=R+Math.imul(ze,nt)|0,u=u+Math.imul(ze,it)|0,u=u+Math.imul(y,nt)|0,l=l+Math.imul(y,it)|0,R=R+Math.imul(Me,st)|0,u=u+Math.imul(Me,ot)|0,u=u+Math.imul(De,st)|0,l=l+Math.imul(De,ot)|0,R=R+Math.imul(Fe,at)|0,u=u+Math.imul(Fe,ct)|0,u=u+Math.imul(Ce,at)|0,l=l+Math.imul(Ce,ct)|0,R=R+Math.imul(Le,ut)|0,u=u+Math.imul(Le,lt)|0,u=u+Math.imul(We,ut)|0,l=l+Math.imul(We,lt)|0,R=R+Math.imul(Ee,ht)|0,u=u+Math.imul(Ee,ft)|0,u=u+Math.imul(Ne,ht)|0,l=l+Math.imul(Ne,ft)|0;var ds=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(ds>>>26)|0,ds&=67108863,R=Math.imul(F,tt),u=Math.imul(F,rt),u=u+Math.imul(Y,tt)|0,l=Math.imul(Y,rt),R=R+Math.imul(d,nt)|0,u=u+Math.imul(d,it)|0,u=u+Math.imul(O,nt)|0,l=l+Math.imul(O,it)|0,R=R+Math.imul(ze,st)|0,u=u+Math.imul(ze,ot)|0,u=u+Math.imul(y,st)|0,l=l+Math.imul(y,ot)|0,R=R+Math.imul(Me,at)|0,u=u+Math.imul(Me,ct)|0,u=u+Math.imul(De,at)|0,l=l+Math.imul(De,ct)|0,R=R+Math.imul(Fe,ut)|0,u=u+Math.imul(Fe,lt)|0,u=u+Math.imul(Ce,ut)|0,l=l+Math.imul(Ce,lt)|0,R=R+Math.imul(Le,ht)|0,u=u+Math.imul(Le,ft)|0,u=u+Math.imul(We,ht)|0,l=l+Math.imul(We,ft)|0;var ps=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(ps>>>26)|0,ps&=67108863,R=Math.imul(F,nt),u=Math.imul(F,it),u=u+Math.imul(Y,nt)|0,l=Math.imul(Y,it),R=R+Math.imul(d,st)|0,u=u+Math.imul(d,ot)|0,u=u+Math.imul(O,st)|0,l=l+Math.imul(O,ot)|0,R=R+Math.imul(ze,at)|0,u=u+Math.imul(ze,ct)|0,u=u+Math.imul(y,at)|0,l=l+Math.imul(y,ct)|0,R=R+Math.imul(Me,ut)|0,u=u+Math.imul(Me,lt)|0,u=u+Math.imul(De,ut)|0,l=l+Math.imul(De,lt)|0,R=R+Math.imul(Fe,ht)|0,u=u+Math.imul(Fe,ft)|0,u=u+Math.imul(Ce,ht)|0,l=l+Math.imul(Ce,ft)|0;var gs=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(gs>>>26)|0,gs&=67108863,R=Math.imul(F,st),u=Math.imul(F,ot),u=u+Math.imul(Y,st)|0,l=Math.imul(Y,ot),R=R+Math.imul(d,at)|0,u=u+Math.imul(d,ct)|0,u=u+Math.imul(O,at)|0,l=l+Math.imul(O,ct)|0,R=R+Math.imul(ze,ut)|0,u=u+Math.imul(ze,lt)|0,u=u+Math.imul(y,ut)|0,l=l+Math.imul(y,lt)|0,R=R+Math.imul(Me,ht)|0,u=u+Math.imul(Me,ft)|0,u=u+Math.imul(De,ht)|0,l=l+Math.imul(De,ft)|0;var ms=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(ms>>>26)|0,ms&=67108863,R=Math.imul(F,at),u=Math.imul(F,ct),u=u+Math.imul(Y,at)|0,l=Math.imul(Y,ct),R=R+Math.imul(d,ut)|0,u=u+Math.imul(d,lt)|0,u=u+Math.imul(O,ut)|0,l=l+Math.imul(O,lt)|0,R=R+Math.imul(ze,ht)|0,u=u+Math.imul(ze,ft)|0,u=u+Math.imul(y,ht)|0,l=l+Math.imul(y,ft)|0;var ys=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(ys>>>26)|0,ys&=67108863,R=Math.imul(F,ut),u=Math.imul(F,lt),u=u+Math.imul(Y,ut)|0,l=Math.imul(Y,lt),R=R+Math.imul(d,ht)|0,u=u+Math.imul(d,ft)|0,u=u+Math.imul(O,ht)|0,l=l+Math.imul(O,ft)|0;var _s=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(_s>>>26)|0,_s&=67108863,R=Math.imul(F,ht),u=Math.imul(F,ft),u=u+Math.imul(Y,ht)|0,l=Math.imul(Y,ft);var ws=(C+R|0)+((u&8191)<<13)|0;return C=(l+(u>>>13)|0)+(ws>>>26)|0,ws&=67108863,I[0]=ts,I[1]=rs,I[2]=ns,I[3]=is,I[4]=ss,I[5]=os,I[6]=as,I[7]=cs,I[8]=us,I[9]=ls,I[10]=hs,I[11]=fs,I[12]=ds,I[13]=ps,I[14]=gs,I[15]=ms,I[16]=ys,I[17]=_s,I[18]=ws,C!==0&&(I[19]=C,m.length++),m};Math.imul||(W=M);function $(A,c,p){p.negative=c.negative^A.negative,p.length=A.length+c.length;for(var m=0,v=0,S=0;S<p.length-1;S++){var I=v;v=0;for(var C=m&67108863,R=Math.min(S,c.length-1),u=Math.max(0,S-A.length+1);u<=R;u++){var l=S-u,w=A.words[l]|0,E=c.words[u]|0,P=w*E,V=P&67108863;I=I+(P/67108864|0)|0,V=V+C|0,C=V&67108863,I=I+(V>>>26)|0,v+=I>>>26,I&=67108863}p.words[S]=C,m=I,I=v}return m!==0?p.words[S]=m:p.length--,p._strip()}function J(A,c,p){return $(A,c,p)}i.prototype.mulTo=function(c,p){var m,v=this.length+c.length;return this.length===10&&c.length===10?m=W(this,c,p):v<63?m=M(this,c,p):v<1024?m=$(this,c,p):m=J(this,c,p),m},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),J(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 m=0,v=0;v<this.length;v++){var S=(this.words[v]|0)*c,I=(S&67108863)+(m&67108863);m>>=26,m+=S/67108864|0,m+=I>>>26,this.words[v]=I&67108863}return m!==0&&(this.words[v]=m,this.length++),this.length=c===0?1: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=N(c);if(p.length===0)return new i(1);for(var m=this,v=0;v<p.length&&p[v]===0;v++,m=m.sqr());if(++v<p.length)for(var S=m.sqr();v<p.length;v++,S=S.sqr())p[v]!==0&&(m=m.mul(S));return m},i.prototype.iushln=function(c){r(typeof c=="number"&&c>=0);var p=c%26,m=(c-p)/26,v=67108863>>>26-p<<26-p,S;if(p!==0){var I=0;for(S=0;S<this.length;S++){var C=this.words[S]&v,R=(this.words[S]|0)-C<<p;this.words[S]=R|I,I=C>>>26-p}I&&(this.words[S]=I,this.length++)}if(m!==0){for(S=this.length-1;S>=0;S--)this.words[S+m]=this.words[S];for(S=0;S<m;S++)this.words[S]=0;this.length+=m}return this._strip()},i.prototype.ishln=function(c){return r(this.negative===0),this.iushln(c)},i.prototype.iushrn=function(c,p,m){r(typeof c=="number"&&c>=0);var v;p?v=(p-p%26)/26:v=0;var S=c%26,I=Math.min((c-S)/26,this.length),C=67108863^67108863>>>S<<S,R=m;if(v-=I,v=Math.max(0,v),R){for(var u=0;u<I;u++)R.words[u]=this.words[u];R.length=I}if(I!==0)if(this.length>I)for(this.length-=I,u=0;u<this.length;u++)this.words[u]=this.words[u+I];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(l!==0||u>=v);u--){var w=this.words[u]|0;this.words[u]=l<<26-S|w>>>S,l=w&C}return R&&l!==0&&(R.words[R.length++]=l),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(c,p,m){return r(this.negative===0),this.iushrn(c,p,m)},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,m=(c-p)/26,v=1<<p;if(this.length<=m)return!1;var S=this.words[m];return!!(S&v)},i.prototype.imaskn=function(c){r(typeof c=="number"&&c>=0);var p=c%26,m=(c-p)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=m)return this;if(p!==0&&m++,this.length=Math.min(m,this.length),p!==0){var v=67108863^67108863>>>p<<p;this.words[this.length-1]&=v}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,m){var v=c.length+m,S;this._expand(v);var I,C=0;for(S=0;S<c.length;S++){I=(this.words[S+m]|0)+C;var R=(c.words[S]|0)*p;I-=R&67108863,C=(I>>26)-(R/67108864|0),this.words[S+m]=I&67108863}for(;S<this.length-m;S++)I=(this.words[S+m]|0)+C,C=I>>26,this.words[S+m]=I&67108863;if(C===0)return this._strip();for(r(C===-1),C=0,S=0;S<this.length;S++)I=-(this.words[S]|0)+C,C=I>>26,this.words[S]=I&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(c,p){var m=this.length-c.length,v=this.clone(),S=c,I=S.words[S.length-1]|0,C=this._countBits(I);m=26-C,m!==0&&(S=S.ushln(m),v.iushln(m),I=S.words[S.length-1]|0);var R=v.length-S.length,u;if(p!=="mod"){u=new i(null),u.length=R+1,u.words=new Array(u.length);for(var l=0;l<u.length;l++)u.words[l]=0}var w=v.clone()._ishlnsubmul(S,1,R);w.negative===0&&(v=w,u&&(u.words[R]=1));for(var E=R-1;E>=0;E--){var P=(v.words[S.length+E]|0)*67108864+(v.words[S.length+E-1]|0);for(P=Math.min(P/I|0,67108863),v._ishlnsubmul(S,P,E);v.negative!==0;)P--,v.negative=0,v._ishlnsubmul(S,1,E),v.isZero()||(v.negative^=1);u&&(u.words[E]=P)}return u&&u._strip(),v._strip(),p!=="div"&&m!==0&&v.iushrn(m),{div:u||null,mod:v}},i.prototype.divmod=function(c,p,m){if(r(!c.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var v,S,I;return this.negative!==0&&c.negative===0?(I=this.neg().divmod(c,p),p!=="mod"&&(v=I.div.neg()),p!=="div"&&(S=I.mod.neg(),m&&S.negative!==0&&S.iadd(c)),{div:v,mod:S}):this.negative===0&&c.negative!==0?(I=this.divmod(c.neg(),p),p!=="mod"&&(v=I.div.neg()),{div:v,mod:I.mod}):(this.negative&c.negative)!==0?(I=this.neg().divmod(c.neg(),p),p!=="div"&&(S=I.mod.neg(),m&&S.negative!==0&&S.isub(c)),{div:I.div,mod:S}):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 m=p.div.negative!==0?p.mod.isub(c):p.mod,v=c.ushrn(1),S=c.andln(1),I=m.cmp(v);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(c){var p=c<0;p&&(c=-c),r(c<=67108863);for(var m=(1<<26)%c,v=0,S=this.length-1;S>=0;S--)v=(m*v+(this.words[S]|0))%c;return p?-v:v},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 m=0,v=this.length-1;v>=0;v--){var S=(this.words[v]|0)+m*67108864;this.words[v]=S/c|0,m=S%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,m=c.clone();p.negative!==0?p=p.umod(c):p=p.clone();for(var v=new i(1),S=new i(0),I=new i(0),C=new i(1),R=0;p.isEven()&&m.isEven();)p.iushrn(1),m.iushrn(1),++R;for(var u=m.clone(),l=p.clone();!p.isZero();){for(var w=0,E=1;(p.words[0]&E)===0&&w<26;++w,E<<=1);if(w>0)for(p.iushrn(w);w-- >0;)(v.isOdd()||S.isOdd())&&(v.iadd(u),S.isub(l)),v.iushrn(1),S.iushrn(1);for(var P=0,V=1;(m.words[0]&V)===0&&P<26;++P,V<<=1);if(P>0)for(m.iushrn(P);P-- >0;)(I.isOdd()||C.isOdd())&&(I.iadd(u),C.isub(l)),I.iushrn(1),C.iushrn(1);p.cmp(m)>=0?(p.isub(m),v.isub(I),S.isub(C)):(m.isub(p),I.isub(v),C.isub(S))}return{a:I,b:C,gcd:m.iushln(R)}},i.prototype._invmp=function(c){r(c.negative===0),r(!c.isZero());var p=this,m=c.clone();p.negative!==0?p=p.umod(c):p=p.clone();for(var v=new i(1),S=new i(0),I=m.clone();p.cmpn(1)>0&&m.cmpn(1)>0;){for(var C=0,R=1;(p.words[0]&R)===0&&C<26;++C,R<<=1);if(C>0)for(p.iushrn(C);C-- >0;)v.isOdd()&&v.iadd(I),v.iushrn(1);for(var u=0,l=1;(m.words[0]&l)===0&&u<26;++u,l<<=1);if(u>0)for(m.iushrn(u);u-- >0;)S.isOdd()&&S.iadd(I),S.iushrn(1);p.cmp(m)>=0?(p.isub(m),v.isub(S)):(m.isub(p),S.isub(v))}var w;return p.cmpn(1)===0?w=v:w=S,w.cmpn(0)<0&&w.iadd(c),w},i.prototype.gcd=function(c){if(this.isZero())return c.abs();if(c.isZero())return this.abs();var p=this.clone(),m=c.clone();p.negative=0,m.negative=0;for(var v=0;p.isEven()&&m.isEven();v++)p.iushrn(1),m.iushrn(1);do{for(;p.isEven();)p.iushrn(1);for(;m.isEven();)m.iushrn(1);var S=p.cmp(m);if(S<0){var I=p;p=m,m=I}else if(S===0||m.cmpn(1)===0)break;p.isub(m)}while(!0);return m.iushln(v)},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,m=(c-p)/26,v=1<<p;if(this.length<=m)return this._expand(m+1),this.words[m]|=v,this;for(var S=v,I=m;S!==0&&I<this.length;I++){var C=this.words[I]|0;C+=S,S=C>>>26,C&=67108863,this.words[I]=C}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(c){var p=c<0;if(this.negative!==0&&!p)return-1;if(this.negative===0&&p)return 1;this._strip();var m;if(this.length>1)m=1;else{p&&(c=-c),r(c<=67108863,"Number is too big");var v=this.words[0]|0;m=v===c?0:v<c?-1:1}return this.negative!==0?-m|0:m},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,m=this.length-1;m>=0;m--){var v=this.words[m]|0,S=c.words[m]|0;if(v!==S){v<S?p=-1:v>S&&(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 G(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 q={k256:null,p224:null,p192:null,p25519:null};function D(A,c){this.name=A,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()}D.prototype._tmp=function(){var c=new i(null);return c.words=new Array(Math.ceil(this.n/13)),c},D.prototype.ireduce=function(c){var p=c,m;do this.split(p,this.tmp),p=this.imulK(p),p=p.iadd(this.tmp),m=p.bitLength();while(m>this.n);var v=m<this.n?-1:p.ucmp(this.p);return v===0?(p.words[0]=0,p.length=1):v>0?p.isub(this.p):p.strip!==void 0?p.strip():p._strip(),p},D.prototype.split=function(c,p){c.iushrn(this.n,0,p)},D.prototype.imulK=function(c){return c.imul(this.k)};function Z(){D.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}s(Z,D),Z.prototype.split=function(c,p){for(var m=4194303,v=Math.min(c.length,9),S=0;S<v;S++)p.words[S]=c.words[S];if(p.length=v,c.length<=9){c.words[0]=0,c.length=1;return}var I=c.words[9];for(p.words[p.length++]=I&m,S=10;S<c.length;S++){var C=c.words[S]|0;c.words[S-10]=(C&m)<<4|I>>>22,I=C}I>>>=22,c.words[S-10]=I,I===0&&c.length>10?c.length-=10:c.length-=9},Z.prototype.imulK=function(c){c.words[c.length]=0,c.words[c.length+1]=0,c.length+=2;for(var p=0,m=0;m<c.length;m++){var v=c.words[m]|0;p+=v*977,c.words[m]=p&67108863,p=v*64+(p/67108864|0)}return c.words[c.length-1]===0&&(c.length--,c.words[c.length-1]===0&&c.length--),c};function j(){D.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}s(j,D);function X(){D.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}s(X,D);function z(){D.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}s(z,D),z.prototype.imulK=function(c){for(var p=0,m=0;m<c.length;m++){var v=(c.words[m]|0)*19+p,S=v&67108863;v>>>=26,c.words[m]=S,p=v}return p!==0&&(c.words[c.length++]=p),c},i._prime=function(c){if(q[c])return q[c];var p;if(c==="k256")p=new Z;else if(c==="p224")p=new j;else if(c==="p192")p=new X;else if(c==="p25519")p=new z;else throw new Error("Unknown prime "+c);return q[c]=p,p};function G(A){if(typeof A=="string"){var c=i._prime(A);this.m=c.p,this.prime=c}else r(A.gtn(1),"modulus must be greater than 1"),this.m=A,this.prime=null}G.prototype._verify1=function(c){r(c.negative===0,"red works only with positives"),r(c.red,"red works only with red numbers")},G.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")},G.prototype.imod=function(c){return this.prime?this.prime.ireduce(c)._forceRed(this):(_(c,c.umod(this.m)._forceRed(this)),c)},G.prototype.neg=function(c){return c.isZero()?c.clone():this.m.sub(c)._forceRed(this)},G.prototype.add=function(c,p){this._verify2(c,p);var m=c.add(p);return m.cmp(this.m)>=0&&m.isub(this.m),m._forceRed(this)},G.prototype.iadd=function(c,p){this._verify2(c,p);var m=c.iadd(p);return m.cmp(this.m)>=0&&m.isub(this.m),m},G.prototype.sub=function(c,p){this._verify2(c,p);var m=c.sub(p);return m.cmpn(0)<0&&m.iadd(this.m),m._forceRed(this)},G.prototype.isub=function(c,p){this._verify2(c,p);var m=c.isub(p);return m.cmpn(0)<0&&m.iadd(this.m),m},G.prototype.shl=function(c,p){return this._verify1(c),this.imod(c.ushln(p))},G.prototype.imul=function(c,p){return this._verify2(c,p),this.imod(c.imul(p))},G.prototype.mul=function(c,p){return this._verify2(c,p),this.imod(c.mul(p))},G.prototype.isqr=function(c){return this.imul(c,c.clone())},G.prototype.sqr=function(c){return this.mul(c,c)},G.prototype.sqrt=function(c){if(c.isZero())return c.clone();var p=this.m.andln(3);if(r(p%2===1),p===3){var m=this.m.add(new i(1)).iushrn(2);return this.pow(c,m)}for(var v=this.m.subn(1),S=0;!v.isZero()&&v.andln(1)===0;)S++,v.iushrn(1);r(!v.isZero());var I=new i(1).toRed(this),C=I.redNeg(),R=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new i(2*u*u).toRed(this);this.pow(u,R).cmp(C)!==0;)u.redIAdd(C);for(var l=this.pow(u,v),w=this.pow(c,v.addn(1).iushrn(1)),E=this.pow(c,v),P=S;E.cmp(I)!==0;){for(var V=E,ne=0;V.cmp(I)!==0;ne++)V=V.redSqr();r(ne<P);var ce=this.pow(l,new i(1).iushln(P-ne-1));w=w.redMul(ce),l=ce.redSqr(),E=E.redMul(l),P=ne}return w},G.prototype.invm=function(c){var p=c._invmp(this.m);return p.negative!==0?(p.negative=0,this.imod(p).redNeg()):this.imod(p)},G.prototype.pow=function(c,p){if(p.isZero())return new i(1).toRed(this);if(p.cmpn(1)===0)return c.clone();var m=4,v=new Array(1<<m);v[0]=new i(1).toRed(this),v[1]=c;for(var S=2;S<v.length;S++)v[S]=this.mul(v[S-1],c);var I=v[0],C=0,R=0,u=p.bitLength()%26;for(u===0&&(u=26),S=p.length-1;S>=0;S--){for(var l=p.words[S],w=u-1;w>=0;w--){var E=l>>w&1;if(I!==v[0]&&(I=this.sqr(I)),E===0&&C===0){R=0;continue}C<<=1,C|=E,R++,!(R!==m&&(S!==0||w!==0))&&(I=this.mul(I,v[C]),R=0,C=0)}u=26}return I},G.prototype.convertTo=function(c){var p=c.umod(this.m);return p===c?p.clone():p},G.prototype.convertFrom=function(c){var p=c.clone();return p.red=null,p},i.mont=function(c){return new Q(c)};function Q(A){G.call(this,A),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,G),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 m=c.imul(p),v=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),S=m.isub(v).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(c,p){if(c.isZero()||p.isZero())return new i(0)._forceRed(this);var m=c.mul(p),v=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),S=m.isub(v).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(c){var p=this.imod(c._invmp(this.m).mul(this.r2));return p._forceRed(this)}})(n,Qc)}(ln)),ln.exports}var eu=Js();const Qs=zr(eu);var hn={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var eo;function tu(){return eo||(eo=1,function(n,e){var t=Kn(),r=t.Buffer;function s(o,a){for(var f in o)a[f]=o[f]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?n.exports=t:(s(t,e),e.Buffer=i);function i(o,a,f){return r(o,a,f)}i.prototype=Object.create(r.prototype),s(r,i),i.from=function(o,a,f){if(typeof o=="number")throw new TypeError("Argument must not be a number");return r(o,a,f)},i.alloc=function(o,a,f){if(typeof o!="number")throw new TypeError("Argument must be a number");var g=r(o);return a!==void 0?typeof f=="string"?g.fill(a,f):g.fill(a):g.fill(0),g},i.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return r(o)},i.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return t.SlowBuffer(o)}}(hn,hn.exports)),hn.exports}var ri,to;function ru(){if(to)return ri;to=1;var n=tu().Buffer;function e(t){if(t.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<t.length;i++){var o=t.charAt(i),a=o.charCodeAt(0);if(r[a]!==255)throw new TypeError(o+" is ambiguous");r[a]=i}var f=t.length,g=t.charAt(0),_=Math.log(f)/Math.log(256),b=Math.log(256)/Math.log(f);function x(k){if((Array.isArray(k)||k instanceof Uint8Array)&&(k=n.from(k)),!n.isBuffer(k))throw new TypeError("Expected Buffer");if(k.length===0)return"";for(var N=0,M=0,W=0,$=k.length;W!==$&&k[W]===0;)W++,N++;for(var J=($-W)*b+1>>>0,q=new Uint8Array(J);W!==$;){for(var D=k[W],Z=0,j=J-1;(D!==0||Z<M)&&j!==-1;j--,Z++)D+=256*q[j]>>>0,q[j]=D%f>>>0,D=D/f>>>0;if(D!==0)throw new Error("Non-zero carry");M=Z,W++}for(var X=J-M;X!==J&&q[X]===0;)X++;for(var z=g.repeat(N);X<J;++X)z+=t.charAt(q[X]);return z}function T(k){if(typeof k!="string")throw new TypeError("Expected String");if(k.length===0)return n.alloc(0);for(var N=0,M=0,W=0;k[N]===g;)M++,N++;for(var $=(k.length-N)*_+1>>>0,J=new Uint8Array($);N<k.length;){var q=k.charCodeAt(N);if(q>255)return;var D=r[q];if(D===255)return;for(var Z=0,j=$-1;(D!==0||Z<W)&&j!==-1;j--,Z++)D+=f*J[j]>>>0,J[j]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");W=Z,N++}for(var X=$-W;X!==$&&J[X]===0;)X++;var z=n.allocUnsafe(M+($-X));z.fill(0,0,M);for(var G=M;X!==$;)z[G++]=J[X++];return z}function L(k){var N=T(k);if(N)return N;throw new Error("Non-base"+f+" character")}return{encode:x,decodeUnsafe:T,decode:L}}return ri=e,ri}var ni,ro;function no(){if(ro)return ni;ro=1;var n=ru(),e="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";return ni=n(e),ni}var nu=no();const gt=zr(nu),iu=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]),tr=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),rr=new Uint32Array(64);class su extends Ns{constructor(){super(64,32,8,!1),this.A=tr[0]|0,this.B=tr[1]|0,this.C=tr[2]|0,this.D=tr[3]|0,this.E=tr[4]|0,this.F=tr[5]|0,this.G=tr[6]|0,this.H=tr[7]|0}get(){const{A:e,B:t,C:r,D:s,E:i,F:o,G:a,H:f}=this;return[e,t,r,s,i,o,a,f]}set(e,t,r,s,i,o,a,f){this.A=e|0,this.B=t|0,this.C=r|0,this.D=s|0,this.E=i|0,this.F=o|0,this.G=a|0,this.H=f|0}process(e,t){for(let b=0;b<16;b++,t+=4)rr[b]=e.getUint32(t,!1);for(let b=16;b<64;b++){const x=rr[b-15],T=rr[b-2],L=Ct(x,7)^Ct(x,18)^x>>>3,k=Ct(T,17)^Ct(T,19)^T>>>10;rr[b]=k+rr[b-7]+L+rr[b-16]|0}let{A:r,B:s,C:i,D:o,E:a,F:f,G:g,H:_}=this;for(let b=0;b<64;b++){const x=Ct(a,6)^Ct(a,11)^Ct(a,25),T=_+x+nc(a,f,g)+iu[b]+rr[b]|0,k=(Ct(r,2)^Ct(r,13)^Ct(r,22))+ic(r,s,i)|0;_=g,g=f,f=a,a=o+T|0,o=i,i=s,s=r,r=T+k|0}r=r+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,f=f+this.F|0,g=g+this.G|0,_=_+this.H|0,this.set(r,s,i,o,a,f,g,_)}roundClean(){rr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const ii=Gn(()=>new su);var xe={};function Vt(n,e,t){return e<=n&&n<=t}function fn(n){if(n===void 0)return{};if(n===Object(n))return n;throw TypeError("Could not convert argument to dictionary")}function ou(n){for(var e=String(n),t=e.length,r=0,s=[];r<t;){var i=e.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===t-1)s.push(65533);else{var o=n.charCodeAt(r+1);if(56320<=o&&o<=57343){var a=i&1023,f=o&1023;s.push(65536+(a<<10)+f),r+=1}else s.push(65533)}r+=1}return s}function au(n){for(var e="",t=0;t<n.length;++t){var r=n[t];r<=65535?e+=String.fromCharCode(r):(r-=65536,e+=String.fromCharCode((r>>10)+55296,(r&1023)+56320))}return e}var dn=-1;function si(n){this.tokens=[].slice.call(n)}si.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():dn},prepend:function(n){if(Array.isArray(n))for(var e=n;e.length;)this.tokens.unshift(e.pop());else this.tokens.unshift(n)},push:function(n){if(Array.isArray(n))for(var e=n;e.length;)this.tokens.push(e.shift());else this.tokens.push(n)}};var Or=-1;function oi(n,e){if(n)throw TypeError("Decoder error");return e||65533}var pn="utf-8";function gn(n,e){if(!(this instanceof gn))return new gn(n,e);if(n=n!==void 0?String(n).toLowerCase():pn,n!==pn)throw new Error("Encoding not supported. Only utf-8 is supported");e=fn(e),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!e.fatal,this._ignoreBOM=!!e.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}gn.prototype={decode:function(e,t){var r;typeof e=="object"&&e instanceof ArrayBuffer?r=new Uint8Array(e):typeof e=="object"&&"buffer"in e&&e.buffer instanceof ArrayBuffer?r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):r=new Uint8Array(0),t=fn(t),this._streaming||(this._decoder=new cu({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!t.stream;for(var s=new si(r),i=[],o;!s.endOfStream()&&(o=this._decoder.handler(s,s.read()),o!==Or);)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===Or)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),au(i)}};function mn(n,e){if(!(this instanceof mn))return new mn(n,e);if(n=n!==void 0?String(n).toLowerCase():pn,n!==pn)throw new Error("Encoding not supported. Only utf-8 is supported");e=fn(e),this._streaming=!1,this._encoder=null,this._options={fatal:!!e.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}mn.prototype={encode:function(e,t){e=e?String(e):"",t=fn(t),this._streaming||(this._encoder=new uu(this._options)),this._streaming=!!t.stream;for(var r=[],s=new si(ou(e)),i;!s.endOfStream()&&(i=this._encoder.handler(s,s.read()),i!==Or);)Array.isArray(i)?r.push.apply(r,i):r.push(i);if(!this._streaming){for(;i=this._encoder.handler(s,s.read()),i!==Or;)Array.isArray(i)?r.push.apply(r,i):r.push(i);this._encoder=null}return new Uint8Array(r)}};function cu(n){var e=n.fatal,t=0,r=0,s=0,i=128,o=191;this.handler=function(a,f){if(f===dn&&s!==0)return s=0,oi(e);if(f===dn)return Or;if(s===0){if(Vt(f,0,127))return f;if(Vt(f,194,223))s=1,t=f-192;else if(Vt(f,224,239))f===224&&(i=160),f===237&&(o=159),s=2,t=f-224;else if(Vt(f,240,244))f===240&&(i=144),f===244&&(o=143),s=3,t=f-240;else return oi(e);return t=t<<6*s,null}if(!Vt(f,i,o))return t=s=r=0,i=128,o=191,a.prepend(f),oi(e);if(i=128,o=191,r+=1,t+=f-128<<6*(s-r),r!==s)return null;var g=t;return t=s=r=0,g}}function uu(n){n.fatal,this.handler=function(e,t){if(t===dn)return Or;if(Vt(t,0,127))return t;var r,s;Vt(t,128,2047)?(r=1,s=192):Vt(t,2048,65535)?(r=2,s=224):Vt(t,65536,1114111)&&(r=3,s=240);for(var i=[(t>>6*r)+s];r>0;){var o=t>>6*(r-1);i.push(128|o&63),r-=1}return i}}const lu=zn(Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:gn,TextEncoder:mn},Symbol.toStringTag,{value:"Module"})));var io;function hu(){if(io)return xe;io=1;var n=xe&&xe.__createBinding||(Object.create?function(X,z,G,Q){Q===void 0&&(Q=G),Object.defineProperty(X,Q,{enumerable:!0,get:function(){return z[G]}})}:function(X,z,G,Q){Q===void 0&&(Q=G),X[Q]=z[G]}),e=xe&&xe.__setModuleDefault||(Object.create?function(X,z){Object.defineProperty(X,"default",{enumerable:!0,value:z})}:function(X,z){X.default=z}),t=xe&&xe.__decorate||function(X,z,G,Q){var A=arguments.length,c=A<3?z:Q===null?Q=Object.getOwnPropertyDescriptor(z,G):Q,p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")c=Reflect.decorate(X,z,G,Q);else for(var m=X.length-1;m>=0;m--)(p=X[m])&&(c=(A<3?p(c):A>3?p(z,G,c):p(z,G))||c);return A>3&&c&&Object.defineProperty(z,G,c),c},r=xe&&xe.__importStar||function(X){if(X&&X.__esModule)return X;var z={};if(X!=null)for(var G in X)G!=="default"&&Object.hasOwnProperty.call(X,G)&&n(z,X,G);return e(z,X),z},s=xe&&xe.__importDefault||function(X){return X&&X.__esModule?X:{default:X}};Object.defineProperty(xe,"__esModule",{value:!0}),xe.deserializeUnchecked=xe.deserialize=xe.serialize=xe.BinaryReader=xe.BinaryWriter=xe.BorshError=xe.baseDecode=xe.baseEncode=void 0;const i=s(Js()),o=s(no()),a=r(lu),f=typeof TextDecoder!="function"?a.TextDecoder:TextDecoder,g=new f("utf-8",{fatal:!0});function _(X){return typeof X=="string"&&(X=Buffer.from(X,"utf8")),o.default.encode(Buffer.from(X))}xe.baseEncode=_;function b(X){return Buffer.from(o.default.decode(X))}xe.baseDecode=b;const x=1024;class T extends Error{constructor(z){super(z),this.fieldPath=[],this.originalMessage=z}addToFieldPath(z){this.fieldPath.splice(0,0,z),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}xe.BorshError=T;class L{constructor(){this.buf=Buffer.alloc(x),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(x)]))}writeU8(z){this.maybeResize(),this.buf.writeUInt8(z,this.length),this.length+=1}writeU16(z){this.maybeResize(),this.buf.writeUInt16LE(z,this.length),this.length+=2}writeU32(z){this.maybeResize(),this.buf.writeUInt32LE(z,this.length),this.length+=4}writeU64(z){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(z).toArray("le",8)))}writeU128(z){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(z).toArray("le",16)))}writeU256(z){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(z).toArray("le",32)))}writeU512(z){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(z).toArray("le",64)))}writeBuffer(z){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),z,Buffer.alloc(x)]),this.length+=z.length}writeString(z){this.maybeResize();const G=Buffer.from(z,"utf8");this.writeU32(G.length),this.writeBuffer(G)}writeFixedArray(z){this.writeBuffer(Buffer.from(z))}writeArray(z,G){this.maybeResize(),this.writeU32(z.length);for(const Q of z)this.maybeResize(),G(Q)}toArray(){return this.buf.subarray(0,this.length)}}xe.BinaryWriter=L;function k(X,z,G){const Q=G.value;G.value=function(...A){try{return Q.apply(this,A)}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 T("Reached the end of buffer when deserializing")}throw c}}}class N{constructor(z){this.buf=z,this.offset=0}readU8(){const z=this.buf.readUInt8(this.offset);return this.offset+=1,z}readU16(){const z=this.buf.readUInt16LE(this.offset);return this.offset+=2,z}readU32(){const z=this.buf.readUInt32LE(this.offset);return this.offset+=4,z}readU64(){const z=this.readBuffer(8);return new i.default(z,"le")}readU128(){const z=this.readBuffer(16);return new i.default(z,"le")}readU256(){const z=this.readBuffer(32);return new i.default(z,"le")}readU512(){const z=this.readBuffer(64);return new i.default(z,"le")}readBuffer(z){if(this.offset+z>this.buf.length)throw new T(`Expected buffer length ${z} isn't within bounds`);const G=this.buf.slice(this.offset,this.offset+z);return this.offset+=z,G}readString(){const z=this.readU32(),G=this.readBuffer(z);try{return g.decode(G)}catch(Q){throw new T(`Error decoding UTF-8 string: ${Q}`)}}readFixedArray(z){return new Uint8Array(this.readBuffer(z))}readArray(z){const G=this.readU32(),Q=Array();for(let A=0;A<G;++A)Q.push(z());return Q}}t([k],N.prototype,"readU8",null),t([k],N.prototype,"readU16",null),t([k],N.prototype,"readU32",null),t([k],N.prototype,"readU64",null),t([k],N.prototype,"readU128",null),t([k],N.prototype,"readU256",null),t([k],N.prototype,"readU512",null),t([k],N.prototype,"readString",null),t([k],N.prototype,"readFixedArray",null),t([k],N.prototype,"readArray",null),xe.BinaryReader=N;function M(X){return X.charAt(0).toUpperCase()+X.slice(1)}function W(X,z,G,Q,A){try{if(typeof Q=="string")A[`write${M(Q)}`](G);else if(Q instanceof Array)if(typeof Q[0]=="number"){if(G.length!==Q[0])throw new T(`Expecting byte array of length ${Q[0]}, but got ${G.length} bytes`);A.writeFixedArray(G)}else if(Q.length===2&&typeof Q[1]=="number"){if(G.length!==Q[1])throw new T(`Expecting byte array of length ${Q[1]}, but got ${G.length} bytes`);for(let c=0;c<Q[1];c++)W(X,null,G[c],Q[0],A)}else A.writeArray(G,c=>{W(X,z,c,Q[0],A)});else if(Q.kind!==void 0)switch(Q.kind){case"option":{G==null?A.writeU8(0):(A.writeU8(1),W(X,z,G,Q.type,A));break}case"map":{A.writeU32(G.size),G.forEach((c,p)=>{W(X,z,p,Q.key,A),W(X,z,c,Q.value,A)});break}default:throw new T(`FieldType ${Q} unrecognized`)}else $(X,G,A)}catch(c){throw c instanceof T&&c.addToFieldPath(z),c}}function $(X,z,G){if(typeof z.borshSerialize=="function"){z.borshSerialize(G);return}const Q=X.get(z.constructor);if(!Q)throw new T(`Class ${z.constructor.name} is missing in schema`);if(Q.kind==="struct")Q.fields.map(([A,c])=>{W(X,A,z[A],c,G)});else if(Q.kind==="enum"){const A=z[Q.field];for(let c=0;c<Q.values.length;++c){const[p,m]=Q.values[c];if(p===A){G.writeU8(c),W(X,p,z[p],m,G);break}}}else throw new T(`Unexpected schema kind: ${Q.kind} for ${z.constructor.name}`)}function J(X,z,G=L){const Q=new G;return $(X,z,Q),Q.toArray()}xe.serialize=J;function q(X,z,G,Q){try{if(typeof G=="string")return Q[`read${M(G)}`]();if(G instanceof Array){if(typeof G[0]=="number")return Q.readFixedArray(G[0]);if(typeof G[1]=="number"){const A=[];for(let c=0;c<G[1];c++)A.push(q(X,null,G[0],Q));return A}else return Q.readArray(()=>q(X,z,G[0],Q))}if(G.kind==="option")return Q.readU8()?q(X,z,G.type,Q):void 0;if(G.kind==="map"){let A=new Map;const c=Q.readU32();for(let p=0;p<c;p++){const m=q(X,z,G.key,Q),v=q(X,z,G.value,Q);A.set(m,v)}return A}return D(X,G,Q)}catch(A){throw A instanceof T&&A.addToFieldPath(z),A}}function D(X,z,G){if(typeof z.borshDeserialize=="function")return z.borshDeserialize(G);const Q=X.get(z);if(!Q)throw new T(`Class ${z.name} is missing in schema`);if(Q.kind==="struct"){const A={};for(const[c,p]of X.get(z).fields)A[c]=q(X,c,p,G);return new z(A)}if(Q.kind==="enum"){const A=G.readU8();if(A>=Q.values.length)throw new T(`Enum index: ${A} is out of range`);const[c,p]=Q.values[A],m=q(X,c,p,G);return new z({[c]:m})}throw new T(`Unexpected schema kind: ${Q.kind} for ${z.constructor.name}`)}function Z(X,z,G,Q=N){const A=new Q(G),c=D(X,z,A);if(A.offset<G.length)throw new T(`Unexpected ${G.length-A.offset} bytes after deserialized data`);return c}xe.deserialize=Z;function j(X,z,G,Q=N){const A=new Q(G);return D(X,z,A)}return xe.deserializeUnchecked=j,xe}var ai=hu(),H={},so;function fu(){if(so)return H;so=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=Kn();function e(u){if(!(u instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}H.checkUint8Array=e;function t(u){return e(u),n.Buffer.from(u.buffer,u.byteOffset,u.length)}H.uint8ArrayToBuffer=t;let r=class{constructor(l,w){if(!Number.isInteger(l))throw new TypeError("span must be an integer");this.span=l,this.property=w}makeDestinationObject(){return{}}getSpan(l,w){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(l){const w=Object.create(this.constructor.prototype);return Object.assign(w,this),w.property=l,w}fromArray(l){}};H.Layout=r;function s(u,l){return l.property?u+"["+l.property+"]":u}H.nameWithProperty=s;function i(u,l){if(typeof u!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(u,"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");u.layout_=l,l.boundConstructor_=u,l.makeDestinationObject=()=>new u,Object.defineProperty(u.prototype,"encode",{value(w,E){return l.encode(this,w,E)},writable:!0}),Object.defineProperty(u,"decode",{value(w,E){return l.decode(w,E)},writable:!0})}H.bindConstructorLayout=i;class o extends r{isCount(){throw new Error("ExternalLayout is abstract")}}H.ExternalLayout=o;class a extends o{constructor(l=1,w){if(!Number.isInteger(l)||0>=l)throw new TypeError("elementSpan must be a (positive) integer");super(-1,w),this.elementSpan=l}isCount(){return!0}decode(l,w=0){e(l);const E=l.length-w;return Math.floor(E/this.elementSpan)}encode(l,w,E){return 0}}H.GreedyCount=a;class f extends o{constructor(l,w=0,E){if(!(l instanceof r))throw new TypeError("layout must be a Layout");if(!Number.isInteger(w))throw new TypeError("offset must be integer or undefined");super(l.span,E||l.property),this.layout=l,this.offset=w}isCount(){return this.layout instanceof g||this.layout instanceof _}decode(l,w=0){return this.layout.decode(l,w+this.offset)}encode(l,w,E=0){return this.layout.encode(l,w,E+this.offset)}}H.OffsetLayout=f;class g extends r{constructor(l,w){if(super(l,w),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,w=0){return t(l).readUIntLE(w,this.span)}encode(l,w,E=0){return t(w).writeUIntLE(l,E,this.span),this.span}}H.UInt=g;class _ extends r{constructor(l,w){if(super(l,w),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,w=0){return t(l).readUIntBE(w,this.span)}encode(l,w,E=0){return t(w).writeUIntBE(l,E,this.span),this.span}}H.UIntBE=_;class b extends r{constructor(l,w){if(super(l,w),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,w=0){return t(l).readIntLE(w,this.span)}encode(l,w,E=0){return t(w).writeIntLE(l,E,this.span),this.span}}H.Int=b;class x extends r{constructor(l,w){if(super(l,w),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,w=0){return t(l).readIntBE(w,this.span)}encode(l,w,E=0){return t(w).writeIntBE(l,E,this.span),this.span}}H.IntBE=x;const T=Math.pow(2,32);function L(u){const l=Math.floor(u/T),w=u-l*T;return{hi32:l,lo32:w}}function k(u,l){return u*T+l}class N extends r{constructor(l){super(8,l)}decode(l,w=0){const E=t(l),P=E.readUInt32LE(w),V=E.readUInt32LE(w+4);return k(V,P)}encode(l,w,E=0){const P=L(l),V=t(w);return V.writeUInt32LE(P.lo32,E),V.writeUInt32LE(P.hi32,E+4),8}}H.NearUInt64=N;class M extends r{constructor(l){super(8,l)}decode(l,w=0){const E=t(l),P=E.readUInt32BE(w),V=E.readUInt32BE(w+4);return k(P,V)}encode(l,w,E=0){const P=L(l),V=t(w);return V.writeUInt32BE(P.hi32,E),V.writeUInt32BE(P.lo32,E+4),8}}H.NearUInt64BE=M;class W extends r{constructor(l){super(8,l)}decode(l,w=0){const E=t(l),P=E.readUInt32LE(w),V=E.readInt32LE(w+4);return k(V,P)}encode(l,w,E=0){const P=L(l),V=t(w);return V.writeUInt32LE(P.lo32,E),V.writeInt32LE(P.hi32,E+4),8}}H.NearInt64=W;class $ extends r{constructor(l){super(8,l)}decode(l,w=0){const E=t(l),P=E.readInt32BE(w),V=E.readUInt32BE(w+4);return k(P,V)}encode(l,w,E=0){const P=L(l),V=t(w);return V.writeInt32BE(P.hi32,E),V.writeUInt32BE(P.lo32,E+4),8}}H.NearInt64BE=$;class J extends r{constructor(l){super(4,l)}decode(l,w=0){return t(l).readFloatLE(w)}encode(l,w,E=0){return t(w).writeFloatLE(l,E),4}}H.Float=J;class q extends r{constructor(l){super(4,l)}decode(l,w=0){return t(l).readFloatBE(w)}encode(l,w,E=0){return t(w).writeFloatBE(l,E),4}}H.FloatBE=q;class D extends r{constructor(l){super(8,l)}decode(l,w=0){return t(l).readDoubleLE(w)}encode(l,w,E=0){return t(w).writeDoubleLE(l,E),8}}H.Double=D;class Z extends r{constructor(l){super(8,l)}decode(l,w=0){return t(l).readDoubleBE(w)}encode(l,w,E=0){return t(w).writeDoubleBE(l,E),8}}H.DoubleBE=Z;class j extends r{constructor(l,w,E){if(!(l instanceof r))throw new TypeError("elementLayout must be a Layout");if(!(w instanceof o&&w.isCount()||Number.isInteger(w)&&0<=w))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let P=-1;!(w instanceof o)&&0<l.span&&(P=w*l.span),super(P,E),this.elementLayout=l,this.count=w}getSpan(l,w=0){if(0<=this.span)return this.span;let E=0,P=this.count;if(P instanceof o&&(P=P.decode(l,w)),0<this.elementLayout.span)E=P*this.elementLayout.span;else{let V=0;for(;V<P;)E+=this.elementLayout.getSpan(l,w+E),++V}return E}decode(l,w=0){const E=[];let P=0,V=this.count;for(V instanceof o&&(V=V.decode(l,w));P<V;)E.push(this.elementLayout.decode(l,w)),w+=this.elementLayout.getSpan(l,w),P+=1;return E}encode(l,w,E=0){const P=this.elementLayout,V=l.reduce((ne,ce)=>ne+P.encode(ce,w,E+ne),0);return this.count instanceof o&&this.count.encode(l.length,w,E),V}}H.Sequence=j;class X extends r{constructor(l,w,E){if(!(Array.isArray(l)&&l.reduce((V,ne)=>V&&ne instanceof r,!0)))throw new TypeError("fields must be array of Layout instances");typeof w=="boolean"&&E===void 0&&(E=w,w=void 0);for(const V of l)if(0>V.span&&V.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let P=-1;try{P=l.reduce((V,ne)=>V+ne.getSpan(),0)}catch{}super(P,w),this.fields=l,this.decodePrefixes=!!E}getSpan(l,w=0){if(0<=this.span)return this.span;let E=0;try{E=this.fields.reduce((P,V)=>{const ne=V.getSpan(l,w);return w+=ne,P+ne},0)}catch{throw new RangeError("indeterminate span")}return E}decode(l,w=0){e(l);const E=this.makeDestinationObject();for(const P of this.fields)if(P.property!==void 0&&(E[P.property]=P.decode(l,w)),w+=P.getSpan(l,w),this.decodePrefixes&&l.length===w)break;return E}encode(l,w,E=0){const P=E;let V=0,ne=0;for(const ce of this.fields){let ve=ce.span;if(ne=0<ve?ve:0,ce.property!==void 0){const ge=l[ce.property];ge!==void 0&&(ne=ce.encode(ge,w,E),0>ve&&(ve=ce.getSpan(w,E)))}V=E,E+=ve}return V+ne-P}fromArray(l){const w=this.makeDestinationObject();for(const E of this.fields)E.property!==void 0&&0<l.length&&(w[E.property]=l.shift());return w}layoutFor(l){if(typeof l!="string")throw new TypeError("property must be string");for(const w of this.fields)if(w.property===l)return w}offsetOf(l){if(typeof l!="string")throw new TypeError("property must be string");let w=0;for(const E of this.fields){if(E.property===l)return w;0>E.span?w=-1:0<=w&&(w+=E.span)}}}H.Structure=X;class z{constructor(l){this.property=l}decode(l,w){throw new Error("UnionDiscriminator is abstract")}encode(l,w,E){throw new Error("UnionDiscriminator is abstract")}}H.UnionDiscriminator=z;class G extends z{constructor(l,w){if(!(l instanceof o&&l.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(w||l.property||"variant"),this.layout=l}decode(l,w){return this.layout.decode(l,w)}encode(l,w,E){return this.layout.encode(l,w,E)}}H.UnionLayoutDiscriminator=G;class Q extends r{constructor(l,w,E){let P;if(l instanceof g||l instanceof _)P=new G(new f(l));else if(l instanceof o&&l.isCount())P=new G(l);else if(l instanceof z)P=l;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(w===void 0&&(w=null),!(w===null||w instanceof r))throw new TypeError("defaultLayout must be null or a Layout");if(w!==null){if(0>w.span)throw new Error("defaultLayout must have constant span");w.property===void 0&&(w=w.replicate("content"))}let V=-1;w&&(V=w.span,0<=V&&(l instanceof g||l instanceof _)&&(V+=P.layout.span)),super(V,E),this.discriminator=P,this.usesPrefixDiscriminator=l instanceof g||l instanceof _,this.defaultLayout=w,this.registry={};let ne=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(ce){return ne(ce)},this.configGetSourceVariant=function(ce){ne=ce.bind(this)}}getSpan(l,w=0){if(0<=this.span)return this.span;const E=this.getVariant(l,w);if(!E)throw new Error("unable to determine span for unrecognized variant");return E.getSpan(l,w)}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 w=this.registry[l[this.discriminator.property]];if(w&&(!w.layout||w.property&&Object.prototype.hasOwnProperty.call(l,w.property)))return w}else for(const w in this.registry){const E=this.registry[w];if(E.property&&Object.prototype.hasOwnProperty.call(l,E.property))return E}throw new Error("unable to infer src variant")}decode(l,w=0){let E;const P=this.discriminator,V=P.decode(l,w),ne=this.registry[V];if(ne===void 0){const ce=this.defaultLayout;let ve=0;this.usesPrefixDiscriminator&&(ve=P.layout.span),E=this.makeDestinationObject(),E[P.property]=V,E[ce.property]=ce.decode(l,w+ve)}else E=ne.decode(l,w);return E}encode(l,w,E=0){const P=this.getSourceVariant(l);if(P===void 0){const V=this.discriminator,ne=this.defaultLayout;let ce=0;return this.usesPrefixDiscriminator&&(ce=V.layout.span),V.encode(l[V.property],w,E),ce+ne.encode(l[ne.property],w,E+ce)}return P.encode(l,w,E)}addVariant(l,w,E){const P=new A(this,l,w,E);return this.registry[l]=P,P}getVariant(l,w=0){let E;return l instanceof Uint8Array?E=this.discriminator.decode(l,w):E=l,this.registry[E]}}H.Union=Q;class A extends r{constructor(l,w,E,P){if(!(l instanceof Q))throw new TypeError("union must be a Union");if(!Number.isInteger(w)||0>w)throw new TypeError("variant must be a (non-negative) integer");if(typeof E=="string"&&P===void 0&&(P=E,E=null),E){if(!(E instanceof r))throw new TypeError("layout must be a Layout");if(l.defaultLayout!==null&&0<=E.span&&E.span>l.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof P!="string")throw new TypeError("variant must have a String property")}let V=l.span;0>l.span&&(V=E?E.span:0,0<=V&&l.usesPrefixDiscriminator&&(V+=l.discriminator.layout.span)),super(V,P),this.union=l,this.variant=w,this.layout=E||null}getSpan(l,w=0){if(0<=this.span)return this.span;let E=0;this.union.usesPrefixDiscriminator&&(E=this.union.discriminator.layout.span);let P=0;return this.layout&&(P=this.layout.getSpan(l,w+E)),E+P}decode(l,w=0){const E=this.makeDestinationObject();if(this!==this.union.getVariant(l,w))throw new Error("variant mismatch");let P=0;return this.union.usesPrefixDiscriminator&&(P=this.union.discriminator.layout.span),this.layout?E[this.property]=this.layout.decode(l,w+P):this.property?E[this.property]=!0:this.union.usesPrefixDiscriminator&&(E[this.union.discriminator.property]=this.variant),E}encode(l,w,E=0){let P=0;if(this.union.usesPrefixDiscriminator&&(P=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,w,E);let V=P;if(this.layout&&(this.layout.encode(l[this.property],w,E+P),V+=this.layout.getSpan(w,E+P),0<=this.union.span&&V>this.union.span))throw new Error("encoded variant overruns containing union");return V}fromArray(l){if(this.layout)return this.layout.fromArray(l)}}H.VariantLayout=A;function c(u){return 0>u&&(u+=4294967296),u}class p extends r{constructor(l,w,E){if(!(l instanceof g||l instanceof _))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof w=="string"&&E===void 0&&(E=w,w=!1),4<l.span)throw new RangeError("word cannot exceed 32 bits");super(l.span,E),this.word=l,this.msb=!!w,this.fields=[];let P=0;this._packedSetValue=function(V){return P=c(V),this},this._packedGetValue=function(){return P}}decode(l,w=0){const E=this.makeDestinationObject(),P=this.word.decode(l,w);this._packedSetValue(P);for(const V of this.fields)V.property!==void 0&&(E[V.property]=V.decode(l));return E}encode(l,w,E=0){const P=this.word.decode(w,E);this._packedSetValue(P);for(const V of this.fields)if(V.property!==void 0){const ne=l[V.property];ne!==void 0&&V.encode(ne)}return this.word.encode(this._packedGetValue(),w,E)}addField(l,w){const E=new m(this,l,w);return this.fields.push(E),E}addBoolean(l){const w=new v(this,l);return this.fields.push(w),w}fieldFor(l){if(typeof l!="string")throw new TypeError("property must be string");for(const w of this.fields)if(w.property===l)return w}}H.BitStructure=p;class m{constructor(l,w,E){if(!(l instanceof p))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(w)||0>=w)throw new TypeError("bits must be positive integer");const P=8*l.span,V=l.fields.reduce((ne,ce)=>ne+ce.bits,0);if(w+V>P)throw new Error("bits too long for span remainder ("+(P-V)+" of "+P+" remain)");this.container=l,this.bits=w,this.valueMask=(1<<w)-1,w===32&&(this.valueMask=4294967295),this.start=V,this.container.msb&&(this.start=P-V-w),this.wordMask=c(this.valueMask<<this.start),this.property=E}decode(l,w){const E=this.container._packedGetValue();return c(E&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 w=this.container._packedGetValue(),E=c(l<<this.start);this.container._packedSetValue(c(w&~this.wordMask)|E)}}H.BitField=m;class v extends m{constructor(l,w){super(l,1,w)}decode(l,w){return!!super.decode(l,w)}encode(l){typeof l=="boolean"&&(l=+l),super.encode(l)}}H.Boolean=v;class S extends r{constructor(l,w){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 E=-1;l instanceof o||(E=l),super(E,w),this.length=l}getSpan(l,w){let E=this.span;return 0>E&&(E=this.length.decode(l,w)),E}decode(l,w=0){let E=this.span;return 0>E&&(E=this.length.decode(l,w)),t(l).slice(w,w+E)}encode(l,w,E){let P=this.length;if(this.length instanceof o&&(P=l.length),!(l instanceof Uint8Array&&P===l.length))throw new TypeError(s("Blob.encode",this)+" requires (length "+P+") Uint8Array as src");if(E+P>w.length)throw new RangeError("encoding overruns Uint8Array");const V=t(l);return t(w).write(V.toString("hex"),E,P,"hex"),this.length instanceof o&&this.length.encode(P,w,E),P}}H.Blob=S;class I extends r{constructor(l){super(-1,l)}getSpan(l,w=0){e(l);let E=w;for(;E<l.length&&l[E]!==0;)E+=1;return 1+E-w}decode(l,w=0){const E=this.getSpan(l,w);return t(l).slice(w,w+E-1).toString("utf-8")}encode(l,w,E=0){typeof l!="string"&&(l=String(l));const P=n.Buffer.from(l,"utf8"),V=P.length;if(E+V>w.length)throw new RangeError("encoding overruns Buffer");const ne=t(w);return P.copy(ne,E),ne[E+V]=0,V+1}}H.CString=I;class C extends r{constructor(l,w){if(typeof l=="string"&&w===void 0&&(w=l,l=void 0),l===void 0)l=-1;else if(!Number.isInteger(l))throw new TypeError("maxSpan must be an integer");super(-1,w),this.maxSpan=l}getSpan(l,w=0){return e(l),l.length-w}decode(l,w=0){const E=this.getSpan(l,w);if(0<=this.maxSpan&&this.maxSpan<E)throw new RangeError("text length exceeds maxSpan");return t(l).slice(w,w+E).toString("utf-8")}encode(l,w,E=0){typeof l!="string"&&(l=String(l));const P=n.Buffer.from(l,"utf8"),V=P.length;if(0<=this.maxSpan&&this.maxSpan<V)throw new RangeError("text length exceeds maxSpan");if(E+V>w.length)throw new RangeError("encoding overruns Buffer");return P.copy(t(w),E),V}}H.UTF8=C;class R extends r{constructor(l,w){super(0,w),this.value=l}decode(l,w){return this.value}encode(l,w,E){return 0}}return H.Constant=R,H.greedy=(u,l)=>new a(u,l),H.offset=(u,l,w)=>new f(u,l,w),H.u8=u=>new g(1,u),H.u16=u=>new g(2,u),H.u24=u=>new g(3,u),H.u32=u=>new g(4,u),H.u40=u=>new g(5,u),H.u48=u=>new g(6,u),H.nu64=u=>new N(u),H.u16be=u=>new _(2,u),H.u24be=u=>new _(3,u),H.u32be=u=>new _(4,u),H.u40be=u=>new _(5,u),H.u48be=u=>new _(6,u),H.nu64be=u=>new M(u),H.s8=u=>new b(1,u),H.s16=u=>new b(2,u),H.s24=u=>new b(3,u),H.s32=u=>new b(4,u),H.s40=u=>new b(5,u),H.s48=u=>new b(6,u),H.ns64=u=>new W(u),H.s16be=u=>new x(2,u),H.s24be=u=>new x(3,u),H.s32be=u=>new x(4,u),H.s40be=u=>new x(5,u),H.s48be=u=>new x(6,u),H.ns64be=u=>new $(u),H.f32=u=>new J(u),H.f32be=u=>new q(u),H.f64=u=>new D(u),H.f64be=u=>new Z(u),H.struct=(u,l,w)=>new X(u,l,w),H.bits=(u,l,w)=>new p(u,l,w),H.seq=(u,l,w)=>new j(u,l,w),H.union=(u,l,w)=>new Q(u,l,w),H.unionLayoutDiscriminator=(u,l)=>new G(u,l),H.blob=(u,l)=>new S(u,l),H.cstr=u=>new I(u),H.utf8=(u,l)=>new C(u,l),H.constant=(u,l)=>new R(u,l),H}var B=fu(),du=1,pu=2,gu=3,mu=4,yu=5,_u=6,wu=7,bu=8,Ru=9,Eu=10,Su=-32700,Au=-32603,Iu=-32602,vu=-32601,Ou=-32600,ku=-32016,Tu=-32015,Nu=-32014,xu=-32013,Bu=-32012,Lu=-32011,Cu=-32010,Mu=-32009,Pu=-32008,Uu=-32007,Du=-32006,Fu=-32005,zu=-32004,$u=-32003,Ku=-32002,Wu=-32001,Hu=28e5,qu=2800001,Gu=2800002,Vu=2800003,Yu=2800004,ju=2800005,Zu=2800006,Xu=2800007,Ju=2800008,Qu=2800009,el=2800010,tl=323e4,rl=32300001,nl=3230002,il=3230003,sl=3230004,ol=361e4,al=3610001,cl=3610002,ul=3610003,ll=3610004,hl=3610005,fl=3610006,dl=3610007,pl=3611e3,gl=3704e3,ml=3704001,yl=3704002,_l=3704003,wl=3704004,bl=4128e3,Rl=4128001,El=4128002,Sl=4615e3,Al=4615001,Il=4615002,vl=4615003,Ol=4615004,kl=4615005,Tl=4615006,Nl=4615007,xl=4615008,Bl=4615009,Ll=4615010,Cl=4615011,Ml=4615012,Pl=4615013,Ul=4615014,Dl=4615015,Fl=4615016,zl=4615017,$l=4615018,Kl=4615019,Wl=4615020,Hl=4615021,ql=4615022,Gl=4615023,Vl=4615024,Yl=4615025,jl=4615026,Zl=4615027,Xl=4615028,Jl=4615029,Ql=4615030,eh=4615031,th=4615032,rh=4615033,nh=4615034,ih=4615035,sh=4615036,oh=4615037,ah=4615038,ch=4615039,uh=4615040,lh=4615041,hh=4615042,fh=4615043,dh=4615044,ph=4615045,gh=4615046,mh=4615047,yh=4615048,_h=4615049,wh=4615050,bh=4615051,Rh=4615052,Eh=4615053,Sh=4615054,Ah=5508e3,Ih=5508001,vh=5508002,Oh=5508003,kh=5508004,Th=5508005,Nh=5508006,xh=5508007,Bh=5508008,Lh=5508009,Ch=5508010,Mh=5508011,Ph=5663e3,Uh=5663001,Dh=5663002,Fh=5663003,zh=5663004,$h=5663005,Kh=5663006,Wh=5663007,Hh=5663008,qh=5663009,Gh=5663010,Vh=5663011,Yh=5663012,jh=5663013,Zh=5663014,Xh=5663015,Jh=5663016,Qh=5663017,ef=5663018,tf=5663019,rf=705e4,nf=7050001,sf=7050002,of=7050003,af=7050004,cf=7050005,uf=7050006,lf=7050007,hf=7050008,ff=7050009,df=7050010,pf=7050011,gf=7050012,mf=7050013,yf=7050014,_f=7050015,wf=7050016,bf=7050017,Rf=7050018,Ef=7050019,Sf=7050020,Af=7050021,If=7050022,vf=7050023,Of=7050024,kf=7050025,Tf=7050026,Nf=7050027,xf=7050028,Bf=7050029,Lf=7050030,Cf=7050031,Mf=7050032,Pf=7050033,Uf=7050034,Df=7050035,Ff=7050036,oo=8078e3,ao=8078001,zf=8078002,$f=8078003,co=8078004,uo=8078005,lo=8078006,Kf=8078007,Wf=8078008,Hf=8078009,qf=8078010,ho=8078011,Gf=8078012,Vf=8078013,Yf=8078014,jf=8078015,Zf=8078016,Xf=8078017,Jf=8078018,Qf=8078019,ed=8078020,td=8078021,rd=8078022,nd=81e5,id=8100001,sd=8100002,od=8100003,ad=819e4,cd=8190001,ud=8190002,ld=8190003,hd=8190004,fd=99e5,dd=9900001,pd=9900002,gd=9900003,md=9900004;function fo(n){return Array.isArray(n)?"%5B"+n.map(fo).join("%2C%20")+"%5D":typeof n=="bigint"?`${n}n`:encodeURIComponent(String(n!=null&&Object.getPrototypeOf(n)===null?{...n}:n))}function yd([n,e]){return`${n}=${fo(e)}`}function _d(n){const e=Object.entries(n).map(yd).join("&");return btoa(e)}var wd={[tl]:"Account not found at address: $address",[sl]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[il]:"Expected decoded account at address: $address",[nl]:"Failed to decode account data at address: $address",[rl]:"Accounts not found at addresses: $addresses",[Qu]:"Unable to find a viable program address bump seed.",[Gu]:"$putativeAddress is not a base58-encoded address.",[Hu]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[Vu]:"The `CryptoKey` must be an `Ed25519` public key.",[Ju]:"Invalid seeds; point must fall off the Ed25519 curve.",[Yu]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[Zu]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[Xu]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[ju]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[el]:"Program address cannot end with PDA marker.",[qu]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[mu]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[du]:"The network has progressed past the last block for which this transaction could have been committed.",[oo]:"Codec [$codecDescription] cannot decode empty byte arrays.",[rd]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[ed]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[uo]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[lo]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[co]:"Encoder and decoder must either both be fixed-size or variable-size.",[Wf]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[zf]:"Expected a fixed-size codec, got a variable-size one.",[Vf]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[$f]:"Expected a variable-size codec, got a fixed-size one.",[Qf]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[ao]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[Jf]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[Hf]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[qf]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[jf]:"Invalid literal union variant. Expected one of [$variants], got $value.",[Kf]:"Expected [$codecDescription] to have $expected items, got $actual.",[Gf]:"Invalid value $value for base $base with alphabet $alphabet.",[Zf]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[ho]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[Yf]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[td]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[Xf]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[pl]:"No random values implementation could be found.",[Bl]:"instruction requires an uninitialized account",[Gl]:"instruction tries to borrow reference for an account which is already borrowed",[Vl]:"instruction left account with an outstanding borrowed reference",[Hl]:"program other than the account's owner changed the size of the account data",[kl]:"account data too small for instruction",[ql]:"instruction expected an executable account",[gh]:"An account does not have enough lamports to be rent-exempt",[yh]:"Program arithmetic overflowed",[ph]:"Failed to serialize or deserialize account data: $encodedData",[Sh]:"Builtin programs must consume compute units",[th]:"Cross-program invocation call depth too deep",[ah]:"Computational budget exceeded",[jl]:"custom program error: #$code",[zl]:"instruction contains duplicate accounts",[Yl]:"instruction modifications of multiply-passed account differ",[Ql]:"executable accounts must be rent exempt",[Xl]:"instruction changed executable accounts data",[Jl]:"instruction changed the balance of an executable account",[$l]:"instruction changed executable bit of an account",[Ul]:"instruction modified data of an account it does not own",[Pl]:"instruction spent from the balance of an account it does not own",[Al]:"generic instruction error",[wh]:"Provided owner is not allowed",[fh]:"Account is immutable",[dh]:"Incorrect authority provided",[Nl]:"incorrect program id for instruction",[Tl]:"insufficient funds for instruction",[Ol]:"invalid account data for instruction",[mh]:"Invalid account owner",[Il]:"invalid program argument",[Zl]:"program returned invalid error code",[vl]:"invalid instruction data",[oh]:"Failed to reallocate account data",[sh]:"Provided seeds do not result in a valid address",[bh]:"Accounts data allocations exceeded the maximum allowed per transaction",[Rh]:"Max accounts exceeded",[Eh]:"Max instruction trace length exceeded",[ih]:"Length of the seed is too long for address generation",[rh]:"An account required by the instruction is missing",[xl]:"missing required signature for instruction",[Ml]:"instruction illegally modified the program id of an account",[Wl]:"insufficient account keys for instruction",[ch]:"Cross-program invocation with unauthorized signer or writable account",[uh]:"Failed to create program execution environment",[hh]:"Program failed to compile",[lh]:"Program failed to complete",[Fl]:"instruction modified data of a read-only account",[Dl]:"instruction changed the balance of a read-only account",[nh]:"Cross-program invocation reentrancy not allowed for this instruction",[Kl]:"instruction modified rent epoch of an account",[Cl]:"sum of account balances before and after instruction do not match",[Ll]:"instruction requires an initialized account",[Sl]:"",[eh]:"Unsupported program id",[_h]:"Unsupported sysvar",[bl]:"The instruction does not have any accounts.",[Rl]:"The instruction does not have any data.",[El]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[yu]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[pu]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[pd]:"Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[md]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[dd]:"Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[fd]:"Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[gd]:"Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[Au]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[Iu]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[Ou]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[vu]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[Su]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[Bu]:"$__serverMessage",[Wu]:"$__serverMessage",[zu]:"$__serverMessage",[Nu]:"$__serverMessage",[Cu]:"$__serverMessage",[Mu]:"$__serverMessage",[ku]:"Minimum context slot has not been reached",[Fu]:"Node is unhealthy; behind by $numSlotsBehind slots",[Pu]:"No snapshot",[Ku]:"Transaction simulation failed",[Uu]:"$__serverMessage",[Lu]:"Transaction history is not available from this node",[Du]:"$__serverMessage",[xu]:"Transaction signature length mismatch",[$u]:"Transaction signature verification failure",[Tu]:"$__serverMessage",[gl]:"Key pair bytes must be of length 64, got $byteLength.",[ml]:"Expected private key bytes with length 32. Actual length: $actualLength.",[yl]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[wl]:"The provided private key does not match the provided public key.",[_l]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[_u]:"Lamports value must be in the range [0, 2e64-1]",[wu]:"`$value` cannot be parsed as a `BigInt`",[Eu]:"$message",[bu]:"`$value` cannot be parsed as a `Number`",[gu]:"No nonce account could be found at address `$nonceAccountAddress`",[ad]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[ud]:"WebSocket was closed before payload could be added to the send buffer",[ld]:"WebSocket connection closed",[hd]:"WebSocket failed to connect",[cd]:"Failed to obtain a subscription id from the server",[od]:"Could not find an API plan for RPC method: `$method`",[nd]:"The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",[sd]:"HTTP error ($statusCode): $message",[id]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[Ah]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[Ih]:"The provided value does not implement the `KeyPairSigner` interface",[Oh]:"The provided value does not implement the `MessageModifyingSigner` interface",[kh]:"The provided value does not implement the `MessagePartialSigner` interface",[vh]:"The provided value does not implement any of the `MessageSigner` interfaces",[Nh]:"The provided value does not implement the `TransactionModifyingSigner` interface",[xh]:"The provided value does not implement the `TransactionPartialSigner` interface",[Bh]:"The provided value does not implement the `TransactionSendingSigner` interface",[Th]:"The provided value does not implement any of the `TransactionSigner` interfaces",[Lh]:"More than one `TransactionSendingSigner` was identified.",[Ch]:"No `TransactionSendingSigner` was identified. Please provide a valid `ITransactionWithSingleSendingSigner` transaction.",[Mh]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[dl]:"Cannot export a non-extractable key.",[al]:"No digest implementation could be found.",[ol]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[cl]:`This runtime does not support the generation of Ed25519 key pairs.
6
+ */var Is;function $n(){return Is||(Is=1,function(n){const e=Ya(),t=ja(),r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=a,n.SlowBuffer=H,n.INSPECT_MAX_BYTES=50;const s=2147483647;n.kMaxLength=s,a.TYPED_ARRAY_SUPPORT=i(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function i(){try{const y=new Uint8Array(1),h={foo:function(){return 42}};return Object.setPrototypeOf(h,Uint8Array.prototype),Object.setPrototypeOf(y,h),y.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function o(y){if(y>s)throw new RangeError('The value "'+y+'" is invalid for option "size"');const h=new Uint8Array(y);return Object.setPrototypeOf(h,a.prototype),h}function a(y,h,d){if(typeof y=="number"){if(typeof h=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return b(y)}return f(y,h,d)}a.poolSize=8192;function f(y,h,d){if(typeof y=="string")return x(y,h);if(ArrayBuffer.isView(y))return L(y);if(y==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof y);if(St(y,ArrayBuffer)||y&&St(y.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(St(y,SharedArrayBuffer)||y&&St(y.buffer,SharedArrayBuffer)))return k(y,h,d);if(typeof y=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const O=y.valueOf&&y.valueOf();if(O!=null&&O!==y)return a.from(O,h,d);const U=N(y);if(U)return U;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof y[Symbol.toPrimitive]=="function")return a.from(y[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 y)}a.from=function(y,h,d){return f(y,h,d)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function g(y){if(typeof y!="number")throw new TypeError('"size" argument must be of type number');if(y<0)throw new RangeError('The value "'+y+'" is invalid for option "size"')}function _(y,h,d){return g(y),y<=0?o(y):h!==void 0?typeof d=="string"?o(y).fill(h,d):o(y).fill(h):o(y)}a.alloc=function(y,h,d){return _(y,h,d)};function b(y){return g(y),o(y<0?0:M(y)|0)}a.allocUnsafe=function(y){return b(y)},a.allocUnsafeSlow=function(y){return b(y)};function x(y,h){if((typeof h!="string"||h==="")&&(h="utf8"),!a.isEncoding(h))throw new TypeError("Unknown encoding: "+h);const d=K(y,h)|0;let O=o(d);const U=O.write(y,h);return U!==d&&(O=O.slice(0,U)),O}function T(y){const h=y.length<0?0:M(y.length)|0,d=o(h);for(let O=0;O<h;O+=1)d[O]=y[O]&255;return d}function L(y){if(St(y,Uint8Array)){const h=new Uint8Array(y);return k(h.buffer,h.byteOffset,h.byteLength)}return T(y)}function k(y,h,d){if(h<0||y.byteLength<h)throw new RangeError('"offset" is outside of buffer bounds');if(y.byteLength<h+(d||0))throw new RangeError('"length" is outside of buffer bounds');let O;return h===void 0&&d===void 0?O=new Uint8Array(y):d===void 0?O=new Uint8Array(y,h):O=new Uint8Array(y,h,d),Object.setPrototypeOf(O,a.prototype),O}function N(y){if(a.isBuffer(y)){const h=M(y.length)|0,d=o(h);return d.length===0||y.copy(d,0,0,h),d}if(y.length!==void 0)return typeof y.length!="number"||Me(y.length)?o(0):T(y);if(y.type==="Buffer"&&Array.isArray(y.data))return T(y.data)}function M(y){if(y>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return y|0}function H(y){return+y!=y&&(y=0),a.alloc(+y)}a.isBuffer=function(h){return h!=null&&h._isBuffer===!0&&h!==a.prototype},a.compare=function(h,d){if(St(h,Uint8Array)&&(h=a.from(h,h.offset,h.byteLength)),St(d,Uint8Array)&&(d=a.from(d,d.offset,d.byteLength)),!a.isBuffer(h)||!a.isBuffer(d))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(h===d)return 0;let O=h.length,U=d.length;for(let F=0,Y=Math.min(O,U);F<Y;++F)if(h[F]!==d[F]){O=h[F],U=d[F];break}return O<U?-1:U<O?1:0},a.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}},a.concat=function(h,d){if(!Array.isArray(h))throw new TypeError('"list" argument must be an Array of Buffers');if(h.length===0)return a.alloc(0);let O;if(d===void 0)for(d=0,O=0;O<h.length;++O)d+=h[O].length;const U=a.allocUnsafe(d);let F=0;for(O=0;O<h.length;++O){let Y=h[O];if(St(Y,Uint8Array))F+Y.length>U.length?(a.isBuffer(Y)||(Y=a.from(Y)),Y.copy(U,F)):Uint8Array.prototype.set.call(U,Y,F);else if(a.isBuffer(Y))Y.copy(U,F);else throw new TypeError('"list" argument must be an Array of Buffers');F+=Y.length}return U};function K(y,h){if(a.isBuffer(y))return y.length;if(ArrayBuffer.isView(y)||St(y,ArrayBuffer))return y.byteLength;if(typeof y!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof y);const d=y.length,O=arguments.length>2&&arguments[2]===!0;if(!O&&d===0)return 0;let U=!1;for(;;)switch(h){case"ascii":case"latin1":case"binary":return d;case"utf8":case"utf-8":return Le(y).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return d*2;case"hex":return d>>>1;case"base64":return Fe(y).length;default:if(U)return O?-1:Le(y).length;h=(""+h).toLowerCase(),U=!0}}a.byteLength=K;function J(y,h,d){let O=!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(y||(y="utf8");;)switch(y){case"hex":return I(this,h,d);case"utf8":case"utf-8":return c(this,h,d);case"ascii":return v(this,h,d);case"latin1":case"binary":return S(this,h,d);case"base64":return A(this,h,d);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,h,d);default:if(O)throw new TypeError("Unknown encoding: "+y);y=(y+"").toLowerCase(),O=!0}}a.prototype._isBuffer=!0;function q(y,h,d){const O=y[h];y[h]=y[d],y[d]=O}a.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)q(this,d,d+1);return this},a.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)q(this,d,d+3),q(this,d+1,d+2);return this},a.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)q(this,d,d+7),q(this,d+1,d+6),q(this,d+2,d+5),q(this,d+3,d+4);return this},a.prototype.toString=function(){const h=this.length;return h===0?"":arguments.length===0?c(this,0,h):J.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(h){if(!a.isBuffer(h))throw new TypeError("Argument must be a Buffer");return this===h?!0:a.compare(this,h)===0},a.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&&(a.prototype[r]=a.prototype.inspect),a.prototype.compare=function(h,d,O,U,F){if(St(h,Uint8Array)&&(h=a.from(h,h.offset,h.byteLength)),!a.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),O===void 0&&(O=h?h.length:0),U===void 0&&(U=0),F===void 0&&(F=this.length),d<0||O>h.length||U<0||F>this.length)throw new RangeError("out of range index");if(U>=F&&d>=O)return 0;if(U>=F)return-1;if(d>=O)return 1;if(d>>>=0,O>>>=0,U>>>=0,F>>>=0,this===h)return 0;let Y=F-U,be=O-d;const me=Math.min(Y,be),pe=this.slice(U,F),Ke=h.slice(d,O);for(let de=0;de<me;++de)if(pe[de]!==Ke[de]){Y=pe[de],be=Ke[de];break}return Y<be?-1:be<Y?1:0};function D(y,h,d,O,U){if(y.length===0)return-1;if(typeof d=="string"?(O=d,d=0):d>2147483647?d=2147483647:d<-2147483648&&(d=-2147483648),d=+d,Me(d)&&(d=U?0:y.length-1),d<0&&(d=y.length+d),d>=y.length){if(U)return-1;d=y.length-1}else if(d<0)if(U)d=0;else return-1;if(typeof h=="string"&&(h=a.from(h,O)),a.isBuffer(h))return h.length===0?-1:Z(y,h,d,O,U);if(typeof h=="number")return h=h&255,typeof Uint8Array.prototype.indexOf=="function"?U?Uint8Array.prototype.indexOf.call(y,h,d):Uint8Array.prototype.lastIndexOf.call(y,h,d):Z(y,[h],d,O,U);throw new TypeError("val must be string, number or Buffer")}function Z(y,h,d,O,U){let F=1,Y=y.length,be=h.length;if(O!==void 0&&(O=String(O).toLowerCase(),O==="ucs2"||O==="ucs-2"||O==="utf16le"||O==="utf-16le")){if(y.length<2||h.length<2)return-1;F=2,Y/=2,be/=2,d/=2}function me(Ke,de){return F===1?Ke[de]:Ke.readUInt16BE(de*F)}let pe;if(U){let Ke=-1;for(pe=d;pe<Y;pe++)if(me(y,pe)===me(h,Ke===-1?0:pe-Ke)){if(Ke===-1&&(Ke=pe),pe-Ke+1===be)return Ke*F}else Ke!==-1&&(pe-=pe-Ke),Ke=-1}else for(d+be>Y&&(d=Y-be),pe=d;pe>=0;pe--){let Ke=!0;for(let de=0;de<be;de++)if(me(y,pe+de)!==me(h,de)){Ke=!1;break}if(Ke)return pe}return-1}a.prototype.includes=function(h,d,O){return this.indexOf(h,d,O)!==-1},a.prototype.indexOf=function(h,d,O){return D(this,h,d,O,!0)},a.prototype.lastIndexOf=function(h,d,O){return D(this,h,d,O,!1)};function j(y,h,d,O){d=Number(d)||0;const U=y.length-d;O?(O=Number(O),O>U&&(O=U)):O=U;const F=h.length;O>F/2&&(O=F/2);let Y;for(Y=0;Y<O;++Y){const be=parseInt(h.substr(Y*2,2),16);if(Me(be))return Y;y[d+Y]=be}return Y}function X(y,h,d,O){return Ce(Le(h,y.length-d),y,d,O)}function z(y,h,d,O){return Ce(He(h),y,d,O)}function V(y,h,d,O){return Ce(Fe(h),y,d,O)}function Q(y,h,d,O){return Ce(Fr(h,y.length-d),y,d,O)}a.prototype.write=function(h,d,O,U){if(d===void 0)U="utf8",O=this.length,d=0;else if(O===void 0&&typeof d=="string")U=d,O=this.length,d=0;else if(isFinite(d))d=d>>>0,isFinite(O)?(O=O>>>0,U===void 0&&(U="utf8")):(U=O,O=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const F=this.length-d;if((O===void 0||O>F)&&(O=F),h.length>0&&(O<0||d<0)||d>this.length)throw new RangeError("Attempt to write outside buffer bounds");U||(U="utf8");let Y=!1;for(;;)switch(U){case"hex":return j(this,h,d,O);case"utf8":case"utf-8":return X(this,h,d,O);case"ascii":case"latin1":case"binary":return z(this,h,d,O);case"base64":return V(this,h,d,O);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Q(this,h,d,O);default:if(Y)throw new TypeError("Unknown encoding: "+U);U=(""+U).toLowerCase(),Y=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function A(y,h,d){return h===0&&d===y.length?e.fromByteArray(y):e.fromByteArray(y.slice(h,d))}function c(y,h,d){d=Math.min(y.length,d);const O=[];let U=h;for(;U<d;){const F=y[U];let Y=null,be=F>239?4:F>223?3:F>191?2:1;if(U+be<=d){let me,pe,Ke,de;switch(be){case 1:F<128&&(Y=F);break;case 2:me=y[U+1],(me&192)===128&&(de=(F&31)<<6|me&63,de>127&&(Y=de));break;case 3:me=y[U+1],pe=y[U+2],(me&192)===128&&(pe&192)===128&&(de=(F&15)<<12|(me&63)<<6|pe&63,de>2047&&(de<55296||de>57343)&&(Y=de));break;case 4:me=y[U+1],pe=y[U+2],Ke=y[U+3],(me&192)===128&&(pe&192)===128&&(Ke&192)===128&&(de=(F&15)<<18|(me&63)<<12|(pe&63)<<6|Ke&63,de>65535&&de<1114112&&(Y=de))}}Y===null?(Y=65533,be=1):Y>65535&&(Y-=65536,O.push(Y>>>10&1023|55296),Y=56320|Y&1023),O.push(Y),U+=be}return m(O)}const p=4096;function m(y){const h=y.length;if(h<=p)return String.fromCharCode.apply(String,y);let d="",O=0;for(;O<h;)d+=String.fromCharCode.apply(String,y.slice(O,O+=p));return d}function v(y,h,d){let O="";d=Math.min(y.length,d);for(let U=h;U<d;++U)O+=String.fromCharCode(y[U]&127);return O}function S(y,h,d){let O="";d=Math.min(y.length,d);for(let U=h;U<d;++U)O+=String.fromCharCode(y[U]);return O}function I(y,h,d){const O=y.length;(!h||h<0)&&(h=0),(!d||d<0||d>O)&&(d=O);let U="";for(let F=h;F<d;++F)U+=De[y[F]];return U}function C(y,h,d){const O=y.slice(h,d);let U="";for(let F=0;F<O.length-1;F+=2)U+=String.fromCharCode(O[F]+O[F+1]*256);return U}a.prototype.slice=function(h,d){const O=this.length;h=~~h,d=d===void 0?O:~~d,h<0?(h+=O,h<0&&(h=0)):h>O&&(h=O),d<0?(d+=O,d<0&&(d=0)):d>O&&(d=O),d<h&&(d=h);const U=this.subarray(h,d);return Object.setPrototypeOf(U,a.prototype),U};function R(y,h,d){if(y%1!==0||y<0)throw new RangeError("offset is not uint");if(y+h>d)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(h,d,O){h=h>>>0,d=d>>>0,O||R(h,d,this.length);let U=this[h],F=1,Y=0;for(;++Y<d&&(F*=256);)U+=this[h+Y]*F;return U},a.prototype.readUintBE=a.prototype.readUIntBE=function(h,d,O){h=h>>>0,d=d>>>0,O||R(h,d,this.length);let U=this[h+--d],F=1;for(;d>0&&(F*=256);)U+=this[h+--d]*F;return U},a.prototype.readUint8=a.prototype.readUInt8=function(h,d){return h=h>>>0,d||R(h,1,this.length),this[h]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(h,d){return h=h>>>0,d||R(h,2,this.length),this[h]|this[h+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(h,d){return h=h>>>0,d||R(h,2,this.length),this[h]<<8|this[h+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(h,d){return h=h>>>0,d||R(h,4,this.length),(this[h]|this[h+1]<<8|this[h+2]<<16)+this[h+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(h,d){return h=h>>>0,d||R(h,4,this.length),this[h]*16777216+(this[h+1]<<16|this[h+2]<<8|this[h+3])},a.prototype.readBigUInt64LE=Ot(function(h){h=h>>>0,ke(h,"offset");const d=this[h],O=this[h+7];(d===void 0||O===void 0)&&Ee(h,this.length-8);const U=d+this[++h]*2**8+this[++h]*2**16+this[++h]*2**24,F=this[++h]+this[++h]*2**8+this[++h]*2**16+O*2**24;return BigInt(U)+(BigInt(F)<<BigInt(32))}),a.prototype.readBigUInt64BE=Ot(function(h){h=h>>>0,ke(h,"offset");const d=this[h],O=this[h+7];(d===void 0||O===void 0)&&Ee(h,this.length-8);const U=d*2**24+this[++h]*2**16+this[++h]*2**8+this[++h],F=this[++h]*2**24+this[++h]*2**16+this[++h]*2**8+O;return(BigInt(U)<<BigInt(32))+BigInt(F)}),a.prototype.readIntLE=function(h,d,O){h=h>>>0,d=d>>>0,O||R(h,d,this.length);let U=this[h],F=1,Y=0;for(;++Y<d&&(F*=256);)U+=this[h+Y]*F;return F*=128,U>=F&&(U-=Math.pow(2,8*d)),U},a.prototype.readIntBE=function(h,d,O){h=h>>>0,d=d>>>0,O||R(h,d,this.length);let U=d,F=1,Y=this[h+--U];for(;U>0&&(F*=256);)Y+=this[h+--U]*F;return F*=128,Y>=F&&(Y-=Math.pow(2,8*d)),Y},a.prototype.readInt8=function(h,d){return h=h>>>0,d||R(h,1,this.length),this[h]&128?(255-this[h]+1)*-1:this[h]},a.prototype.readInt16LE=function(h,d){h=h>>>0,d||R(h,2,this.length);const O=this[h]|this[h+1]<<8;return O&32768?O|4294901760:O},a.prototype.readInt16BE=function(h,d){h=h>>>0,d||R(h,2,this.length);const O=this[h+1]|this[h]<<8;return O&32768?O|4294901760:O},a.prototype.readInt32LE=function(h,d){return h=h>>>0,d||R(h,4,this.length),this[h]|this[h+1]<<8|this[h+2]<<16|this[h+3]<<24},a.prototype.readInt32BE=function(h,d){return h=h>>>0,d||R(h,4,this.length),this[h]<<24|this[h+1]<<16|this[h+2]<<8|this[h+3]},a.prototype.readBigInt64LE=Ot(function(h){h=h>>>0,ke(h,"offset");const d=this[h],O=this[h+7];(d===void 0||O===void 0)&&Ee(h,this.length-8);const U=this[h+4]+this[h+5]*2**8+this[h+6]*2**16+(O<<24);return(BigInt(U)<<BigInt(32))+BigInt(d+this[++h]*2**8+this[++h]*2**16+this[++h]*2**24)}),a.prototype.readBigInt64BE=Ot(function(h){h=h>>>0,ke(h,"offset");const d=this[h],O=this[h+7];(d===void 0||O===void 0)&&Ee(h,this.length-8);const U=(d<<24)+this[++h]*2**16+this[++h]*2**8+this[++h];return(BigInt(U)<<BigInt(32))+BigInt(this[++h]*2**24+this[++h]*2**16+this[++h]*2**8+O)}),a.prototype.readFloatLE=function(h,d){return h=h>>>0,d||R(h,4,this.length),t.read(this,h,!0,23,4)},a.prototype.readFloatBE=function(h,d){return h=h>>>0,d||R(h,4,this.length),t.read(this,h,!1,23,4)},a.prototype.readDoubleLE=function(h,d){return h=h>>>0,d||R(h,8,this.length),t.read(this,h,!0,52,8)},a.prototype.readDoubleBE=function(h,d){return h=h>>>0,d||R(h,8,this.length),t.read(this,h,!1,52,8)};function u(y,h,d,O,U,F){if(!a.isBuffer(y))throw new TypeError('"buffer" argument must be a Buffer instance');if(h>U||h<F)throw new RangeError('"value" argument is out of bounds');if(d+O>y.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(h,d,O,U){if(h=+h,d=d>>>0,O=O>>>0,!U){const be=Math.pow(2,8*O)-1;u(this,h,d,O,be,0)}let F=1,Y=0;for(this[d]=h&255;++Y<O&&(F*=256);)this[d+Y]=h/F&255;return d+O},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(h,d,O,U){if(h=+h,d=d>>>0,O=O>>>0,!U){const be=Math.pow(2,8*O)-1;u(this,h,d,O,be,0)}let F=O-1,Y=1;for(this[d+F]=h&255;--F>=0&&(Y*=256);)this[d+F]=h/Y&255;return d+O},a.prototype.writeUint8=a.prototype.writeUInt8=function(h,d,O){return h=+h,d=d>>>0,O||u(this,h,d,1,255,0),this[d]=h&255,d+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(h,d,O){return h=+h,d=d>>>0,O||u(this,h,d,2,65535,0),this[d]=h&255,this[d+1]=h>>>8,d+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(h,d,O){return h=+h,d=d>>>0,O||u(this,h,d,2,65535,0),this[d]=h>>>8,this[d+1]=h&255,d+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(h,d,O){return h=+h,d=d>>>0,O||u(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},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(h,d,O){return h=+h,d=d>>>0,O||u(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(y,h,d,O,U){Re(h,O,U,y,d,7);let F=Number(h&BigInt(4294967295));y[d++]=F,F=F>>8,y[d++]=F,F=F>>8,y[d++]=F,F=F>>8,y[d++]=F;let Y=Number(h>>BigInt(32)&BigInt(4294967295));return y[d++]=Y,Y=Y>>8,y[d++]=Y,Y=Y>>8,y[d++]=Y,Y=Y>>8,y[d++]=Y,d}function w(y,h,d,O,U){Re(h,O,U,y,d,7);let F=Number(h&BigInt(4294967295));y[d+7]=F,F=F>>8,y[d+6]=F,F=F>>8,y[d+5]=F,F=F>>8,y[d+4]=F;let Y=Number(h>>BigInt(32)&BigInt(4294967295));return y[d+3]=Y,Y=Y>>8,y[d+2]=Y,Y=Y>>8,y[d+1]=Y,Y=Y>>8,y[d]=Y,d+8}a.prototype.writeBigUInt64LE=Ot(function(h,d=0){return l(this,h,d,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=Ot(function(h,d=0){return w(this,h,d,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(h,d,O,U){if(h=+h,d=d>>>0,!U){const me=Math.pow(2,8*O-1);u(this,h,d,O,me-1,-me)}let F=0,Y=1,be=0;for(this[d]=h&255;++F<O&&(Y*=256);)h<0&&be===0&&this[d+F-1]!==0&&(be=1),this[d+F]=(h/Y>>0)-be&255;return d+O},a.prototype.writeIntBE=function(h,d,O,U){if(h=+h,d=d>>>0,!U){const me=Math.pow(2,8*O-1);u(this,h,d,O,me-1,-me)}let F=O-1,Y=1,be=0;for(this[d+F]=h&255;--F>=0&&(Y*=256);)h<0&&be===0&&this[d+F+1]!==0&&(be=1),this[d+F]=(h/Y>>0)-be&255;return d+O},a.prototype.writeInt8=function(h,d,O){return h=+h,d=d>>>0,O||u(this,h,d,1,127,-128),h<0&&(h=255+h+1),this[d]=h&255,d+1},a.prototype.writeInt16LE=function(h,d,O){return h=+h,d=d>>>0,O||u(this,h,d,2,32767,-32768),this[d]=h&255,this[d+1]=h>>>8,d+2},a.prototype.writeInt16BE=function(h,d,O){return h=+h,d=d>>>0,O||u(this,h,d,2,32767,-32768),this[d]=h>>>8,this[d+1]=h&255,d+2},a.prototype.writeInt32LE=function(h,d,O){return h=+h,d=d>>>0,O||u(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},a.prototype.writeInt32BE=function(h,d,O){return h=+h,d=d>>>0,O||u(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},a.prototype.writeBigInt64LE=Ot(function(h,d=0){return l(this,h,d,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=Ot(function(h,d=0){return w(this,h,d,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function E(y,h,d,O,U,F){if(d+O>y.length)throw new RangeError("Index out of range");if(d<0)throw new RangeError("Index out of range")}function P(y,h,d,O,U){return h=+h,d=d>>>0,U||E(y,h,d,4),t.write(y,h,d,O,23,4),d+4}a.prototype.writeFloatLE=function(h,d,O){return P(this,h,d,!0,O)},a.prototype.writeFloatBE=function(h,d,O){return P(this,h,d,!1,O)};function G(y,h,d,O,U){return h=+h,d=d>>>0,U||E(y,h,d,8),t.write(y,h,d,O,52,8),d+8}a.prototype.writeDoubleLE=function(h,d,O){return G(this,h,d,!0,O)},a.prototype.writeDoubleBE=function(h,d,O){return G(this,h,d,!1,O)},a.prototype.copy=function(h,d,O,U){if(!a.isBuffer(h))throw new TypeError("argument should be a Buffer");if(O||(O=0),!U&&U!==0&&(U=this.length),d>=h.length&&(d=h.length),d||(d=0),U>0&&U<O&&(U=O),U===O||h.length===0||this.length===0)return 0;if(d<0)throw new RangeError("targetStart out of bounds");if(O<0||O>=this.length)throw new RangeError("Index out of range");if(U<0)throw new RangeError("sourceEnd out of bounds");U>this.length&&(U=this.length),h.length-d<U-O&&(U=h.length-d+O);const F=U-O;return this===h&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(d,O,U):Uint8Array.prototype.set.call(h,this.subarray(O,U),d),F},a.prototype.fill=function(h,d,O,U){if(typeof h=="string"){if(typeof d=="string"?(U=d,d=0,O=this.length):typeof O=="string"&&(U=O,O=this.length),U!==void 0&&typeof U!="string")throw new TypeError("encoding must be a string");if(typeof U=="string"&&!a.isEncoding(U))throw new TypeError("Unknown encoding: "+U);if(h.length===1){const Y=h.charCodeAt(0);(U==="utf8"&&Y<128||U==="latin1")&&(h=Y)}}else typeof h=="number"?h=h&255:typeof h=="boolean"&&(h=Number(h));if(d<0||this.length<d||this.length<O)throw new RangeError("Out of range index");if(O<=d)return this;d=d>>>0,O=O===void 0?this.length:O>>>0,h||(h=0);let F;if(typeof h=="number")for(F=d;F<O;++F)this[F]=h;else{const Y=a.isBuffer(h)?h:a.from(h,U),be=Y.length;if(be===0)throw new TypeError('The value "'+h+'" is invalid for argument "value"');for(F=0;F<O-d;++F)this[F+d]=Y[F%be]}return this};const ne={};function ce(y,h,d){ne[y]=class extends d{constructor(){super(),Object.defineProperty(this,"message",{value:h.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${y}]`,this.stack,delete this.name}get code(){return y}set code(U){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:U,writable:!0})}toString(){return`${this.name} [${y}]: ${this.message}`}}}ce("ERR_BUFFER_OUT_OF_BOUNDS",function(y){return y?`${y} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),ce("ERR_INVALID_ARG_TYPE",function(y,h){return`The "${y}" argument must be of type number. Received type ${typeof h}`},TypeError),ce("ERR_OUT_OF_RANGE",function(y,h,d){let O=`The value of "${y}" is out of range.`,U=d;return Number.isInteger(d)&&Math.abs(d)>2**32?U=ve(String(d)):typeof d=="bigint"&&(U=String(d),(d>BigInt(2)**BigInt(32)||d<-(BigInt(2)**BigInt(32)))&&(U=ve(U)),U+="n"),O+=` It must be ${h}. Received ${U}`,O},RangeError);function ve(y){let h="",d=y.length;const O=y[0]==="-"?1:0;for(;d>=O+4;d-=3)h=`_${y.slice(d-3,d)}${h}`;return`${y.slice(0,d)}${h}`}function ge(y,h,d){ke(h,"offset"),(y[h]===void 0||y[h+d]===void 0)&&Ee(h,y.length-(d+1))}function Re(y,h,d,O,U,F){if(y>d||y<h){const Y=typeof h=="bigint"?"n":"";let be;throw h===0||h===BigInt(0)?be=`>= 0${Y} and < 2${Y} ** ${(F+1)*8}${Y}`:be=`>= -(2${Y} ** ${(F+1)*8-1}${Y}) and < 2 ** ${(F+1)*8-1}${Y}`,new ne.ERR_OUT_OF_RANGE("value",be,y)}ge(O,U,F)}function ke(y,h){if(typeof y!="number")throw new ne.ERR_INVALID_ARG_TYPE(h,"number",y)}function Ee(y,h,d){throw Math.floor(y)!==y?(ke(y,d),new ne.ERR_OUT_OF_RANGE("offset","an integer",y)):h<0?new ne.ERR_BUFFER_OUT_OF_BOUNDS:new ne.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${h}`,y)}const Ne=/[^+/0-9A-Za-z-_]/g;function qt(y){if(y=y.split("=")[0],y=y.trim().replace(Ne,""),y.length<2)return"";for(;y.length%4!==0;)y=y+"=";return y}function Le(y,h){h=h||1/0;let d;const O=y.length;let U=null;const F=[];for(let Y=0;Y<O;++Y){if(d=y.charCodeAt(Y),d>55295&&d<57344){if(!U){if(d>56319){(h-=3)>-1&&F.push(239,191,189);continue}else if(Y+1===O){(h-=3)>-1&&F.push(239,191,189);continue}U=d;continue}if(d<56320){(h-=3)>-1&&F.push(239,191,189),U=d;continue}d=(U-55296<<10|d-56320)+65536}else U&&(h-=3)>-1&&F.push(239,191,189);if(U=null,d<128){if((h-=1)<0)break;F.push(d)}else if(d<2048){if((h-=2)<0)break;F.push(d>>6|192,d&63|128)}else if(d<65536){if((h-=3)<0)break;F.push(d>>12|224,d>>6&63|128,d&63|128)}else if(d<1114112){if((h-=4)<0)break;F.push(d>>18|240,d>>12&63|128,d>>6&63|128,d&63|128)}else throw new Error("Invalid code point")}return F}function He(y){const h=[];for(let d=0;d<y.length;++d)h.push(y.charCodeAt(d)&255);return h}function Fr(y,h){let d,O,U;const F=[];for(let Y=0;Y<y.length&&!((h-=2)<0);++Y)d=y.charCodeAt(Y),O=d>>8,U=d%256,F.push(U),F.push(O);return F}function Fe(y){return e.toByteArray(qt(y))}function Ce(y,h,d,O){let U;for(U=0;U<O&&!(U+d>=h.length||U>=y.length);++U)h[U+d]=y[U];return U}function St(y,h){return y instanceof h||y!=null&&y.constructor!=null&&y.constructor.name!=null&&y.constructor.name===h.name}function Me(y){return y!==y}const De=function(){const y="0123456789abcdef",h=new Array(256);for(let d=0;d<16;++d){const O=d*16;for(let U=0;U<16;++U)h[O+U]=y[d]+y[U]}return h}();function Ot(y){return typeof BigInt>"u"?ze:y}function ze(){throw new Error("BigInt not supported")}}(Kn)),Kn}var he=$n();function sn(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 $r(n,...e){if(!Za(n))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(n.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${n.length}`)}function Xa(n){if(typeof n!="function"||typeof n.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");sn(n.outputLen),sn(n.blockLen)}function Rr(n,e=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(e&&n.finished)throw new Error("Hash#digest() has already been called")}function vs(n,e){$r(n);const t=e.outputLen;if(n.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}const Hn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ja=n=>new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)),Wn=n=>new DataView(n.buffer,n.byteOffset,n.byteLength),Ct=(n,e)=>n<<32-e|n>>>e,Os=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,Qa=n=>n<<24&4278190080|n<<8&16711680|n>>>8&65280|n>>>24&255;function ks(n){for(let e=0;e<n.length;e++)n[e]=Qa(n[e])}function ec(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function on(n){return typeof n=="string"&&(n=ec(n)),$r(n),n}function tc(...n){let e=0;for(let r=0;r<n.length;r++){const s=n[r];$r(s),e+=s.length}const t=new Uint8Array(e);for(let r=0,s=0;r<n.length;r++){const i=n[r];t.set(i,s),s+=i.length}return t}class qn{clone(){return this._cloneInto()}}function Vn(n){const e=r=>n().update(on(r)).digest(),t=n();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>n(),e}function Ts(n=32){if(Hn&&typeof Hn.getRandomValues=="function")return Hn.getRandomValues(new Uint8Array(n));throw new Error("crypto.getRandomValues must be defined")}function rc(n,e,t,r){if(typeof n.setBigUint64=="function")return n.setBigUint64(e,t,r);const s=BigInt(32),i=BigInt(4294967295),o=Number(t>>s&i),a=Number(t&i),f=r?4:0,g=r?0:4;n.setUint32(e+f,o,r),n.setUint32(e+g,a,r)}const nc=(n,e,t)=>n&e^~n&t,ic=(n,e,t)=>n&e^n&t^e&t;class Ns extends qn{constructor(e,t,r,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Wn(this.buffer)}update(e){Rr(this);const{view:t,buffer:r,blockLen:s}=this;e=on(e);const i=e.length;for(let o=0;o<i;){const a=Math.min(s-this.pos,i-o);if(a===s){const f=Wn(e);for(;s<=i-o;o+=s)this.process(f,o);continue}r.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Rr(this),vs(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:s,isLE:i}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>s-o&&(this.process(r,0),o=0);for(let b=o;b<s;b++)t[b]=0;rc(r,s-8,BigInt(this.length*8),i),this.process(r,0);const a=Wn(e),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const g=f/4,_=this.get();if(g>_.length)throw new Error("_sha2: outputLen bigger than state");for(let b=0;b<g;b++)a.setUint32(4*b,_[b],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:s,finished:i,destroyed:o,pos:a}=this;return e.length=s,e.pos=a,e.finished=i,e.destroyed=o,s%t&&e.buffer.set(r),e}}const an=BigInt(2**32-1),Gn=BigInt(32);function xs(n,e=!1){return e?{h:Number(n&an),l:Number(n>>Gn&an)}:{h:Number(n>>Gn&an)|0,l:Number(n&an)|0}}function Bs(n,e=!1){let t=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let s=0;s<n.length;s++){const{h:i,l:o}=xs(n[s],e);[t[s],r[s]]=[i,o]}return[t,r]}const sc=(n,e)=>BigInt(n>>>0)<<Gn|BigInt(e>>>0),oc=(n,e,t)=>n>>>t,ac=(n,e,t)=>n<<32-t|e>>>t,cc=(n,e,t)=>n>>>t|e<<32-t,uc=(n,e,t)=>n<<32-t|e>>>t,lc=(n,e,t)=>n<<64-t|e>>>t-32,hc=(n,e,t)=>n>>>t-32|e<<64-t,fc=(n,e)=>e,dc=(n,e)=>n,Ls=(n,e,t)=>n<<t|e>>>32-t,Cs=(n,e,t)=>e<<t|n>>>32-t,Ms=(n,e,t)=>e<<t-32|n>>>64-t,Ps=(n,e,t)=>n<<t-32|e>>>64-t;function pc(n,e,t,r){const s=(e>>>0)+(r>>>0);return{h:n+t+(s/2**32|0)|0,l:s|0}}const ye={fromBig:xs,split:Bs,toBig:sc,shrSH:oc,shrSL:ac,rotrSH:cc,rotrSL:uc,rotrBH:lc,rotrBL:hc,rotr32H:fc,rotr32L:dc,rotlSH:Ls,rotlSL:Cs,rotlBH:Ms,rotlBL:Ps,add:pc,add3L:(n,e,t)=>(n>>>0)+(e>>>0)+(t>>>0),add3H:(n,e,t,r)=>e+t+r+(n/2**32|0)|0,add4L:(n,e,t,r)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0),add4H:(n,e,t,r,s)=>e+t+r+s+(n/2**32|0)|0,add5H:(n,e,t,r,s,i)=>e+t+r+s+i+(n/2**32|0)|0,add5L:(n,e,t,r,s)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0)},[gc,mc]=ye.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))),Jt=new Uint32Array(80),Qt=new Uint32Array(80);class yc extends Ns{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:e,Al:t,Bh:r,Bl:s,Ch:i,Cl:o,Dh:a,Dl:f,Eh:g,El:_,Fh:b,Fl:x,Gh:T,Gl:L,Hh:k,Hl:N}=this;return[e,t,r,s,i,o,a,f,g,_,b,x,T,L,k,N]}set(e,t,r,s,i,o,a,f,g,_,b,x,T,L,k,N){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=s|0,this.Ch=i|0,this.Cl=o|0,this.Dh=a|0,this.Dl=f|0,this.Eh=g|0,this.El=_|0,this.Fh=b|0,this.Fl=x|0,this.Gh=T|0,this.Gl=L|0,this.Hh=k|0,this.Hl=N|0}process(e,t){for(let K=0;K<16;K++,t+=4)Jt[K]=e.getUint32(t),Qt[K]=e.getUint32(t+=4);for(let K=16;K<80;K++){const J=Jt[K-15]|0,q=Qt[K-15]|0,D=ye.rotrSH(J,q,1)^ye.rotrSH(J,q,8)^ye.shrSH(J,q,7),Z=ye.rotrSL(J,q,1)^ye.rotrSL(J,q,8)^ye.shrSL(J,q,7),j=Jt[K-2]|0,X=Qt[K-2]|0,z=ye.rotrSH(j,X,19)^ye.rotrBH(j,X,61)^ye.shrSH(j,X,6),V=ye.rotrSL(j,X,19)^ye.rotrBL(j,X,61)^ye.shrSL(j,X,6),Q=ye.add4L(Z,V,Qt[K-7],Qt[K-16]),A=ye.add4H(Q,D,z,Jt[K-7],Jt[K-16]);Jt[K]=A|0,Qt[K]=Q|0}let{Ah:r,Al:s,Bh:i,Bl:o,Ch:a,Cl:f,Dh:g,Dl:_,Eh:b,El:x,Fh:T,Fl:L,Gh:k,Gl:N,Hh:M,Hl:H}=this;for(let K=0;K<80;K++){const J=ye.rotrSH(b,x,14)^ye.rotrSH(b,x,18)^ye.rotrBH(b,x,41),q=ye.rotrSL(b,x,14)^ye.rotrSL(b,x,18)^ye.rotrBL(b,x,41),D=b&T^~b&k,Z=x&L^~x&N,j=ye.add5L(H,q,Z,mc[K],Qt[K]),X=ye.add5H(j,M,J,D,gc[K],Jt[K]),z=j|0,V=ye.rotrSH(r,s,28)^ye.rotrBH(r,s,34)^ye.rotrBH(r,s,39),Q=ye.rotrSL(r,s,28)^ye.rotrBL(r,s,34)^ye.rotrBL(r,s,39),A=r&i^r&a^i&a,c=s&o^s&f^o&f;M=k|0,H=N|0,k=T|0,N=L|0,T=b|0,L=x|0,{h:b,l:x}=ye.add(g|0,_|0,X|0,z|0),g=a|0,_=f|0,a=i|0,f=o|0,i=r|0,o=s|0;const p=ye.add3L(z,Q,c);r=ye.add3H(p,X,V,A),s=p|0}({h:r,l:s}=ye.add(this.Ah|0,this.Al|0,r|0,s|0)),{h:i,l:o}=ye.add(this.Bh|0,this.Bl|0,i|0,o|0),{h:a,l:f}=ye.add(this.Ch|0,this.Cl|0,a|0,f|0),{h:g,l:_}=ye.add(this.Dh|0,this.Dl|0,g|0,_|0),{h:b,l:x}=ye.add(this.Eh|0,this.El|0,b|0,x|0),{h:T,l:L}=ye.add(this.Fh|0,this.Fl|0,T|0,L|0),{h:k,l:N}=ye.add(this.Gh|0,this.Gl|0,k|0,N|0),{h:M,l:H}=ye.add(this.Hh|0,this.Hl|0,M|0,H|0),this.set(r,s,i,o,a,f,g,_,b,x,T,L,k,N,M,H)}roundClean(){Jt.fill(0),Qt.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 _c=Vn(()=>new yc);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Us=BigInt(0),cn=BigInt(1),wc=BigInt(2);function ar(n){return n instanceof Uint8Array||n!=null&&typeof n=="object"&&n.constructor.name==="Uint8Array"}function Hr(n){if(!ar(n))throw new Error("Uint8Array expected")}const bc=Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function cr(n){Hr(n);let e="";for(let t=0;t<n.length;t++)e+=bc[n[t]];return e}function Ds(n){const e=n.toString(16);return e.length&1?`0${e}`:e}function Yn(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);return BigInt(n===""?"0":`0x${n}`)}const Vt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Fs(n){if(n>=Vt._0&&n<=Vt._9)return n-Vt._0;if(n>=Vt._A&&n<=Vt._F)return n-(Vt._A-10);if(n>=Vt._a&&n<=Vt._f)return n-(Vt._a-10)}function Er(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);const e=n.length,t=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(t);for(let s=0,i=0;s<t;s++,i+=2){const o=Fs(n.charCodeAt(i)),a=Fs(n.charCodeAt(i+1));if(o===void 0||a===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+a}return r}function ur(n){return Yn(cr(n))}function Sr(n){return Hr(n),Yn(cr(Uint8Array.from(n).reverse()))}function Ar(n,e){return Er(n.toString(16).padStart(e*2,"0"))}function Wr(n,e){return Ar(n,e).reverse()}function Rc(n){return Er(Ds(n))}function dt(n,e,t){let r;if(typeof e=="string")try{r=Er(e)}catch(i){throw new Error(`${n} must be valid hex string, got "${e}". Cause: ${i}`)}else if(ar(e))r=Uint8Array.from(e);else throw new Error(`${n} must be hex string or Uint8Array`);const s=r.length;if(typeof t=="number"&&s!==t)throw new Error(`${n} expected ${t} bytes, got ${s}`);return r}function lr(...n){let e=0;for(let r=0;r<n.length;r++){const s=n[r];Hr(s),e+=s.length}const t=new Uint8Array(e);for(let r=0,s=0;r<n.length;r++){const i=n[r];t.set(i,s),s+=i.length}return t}function Ec(n,e){if(n.length!==e.length)return!1;let t=0;for(let r=0;r<n.length;r++)t|=n[r]^e[r];return t===0}function Sc(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function Ac(n){let e;for(e=0;n>Us;n>>=cn,e+=1);return e}function Ic(n,e){return n>>BigInt(e)&cn}function vc(n,e,t){return n|(t?cn:Us)<<BigInt(e)}const jn=n=>(wc<<BigInt(n-1))-cn,Zn=n=>new Uint8Array(n),zs=n=>Uint8Array.from(n);function Ks(n,e,t){if(typeof n!="number"||n<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let r=Zn(n),s=Zn(n),i=0;const o=()=>{r.fill(1),s.fill(0),i=0},a=(...b)=>t(s,r,...b),f=(b=Zn())=>{s=a(zs([0]),b),r=a(),b.length!==0&&(s=a(zs([1]),b),r=a())},g=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let b=0;const x=[];for(;b<e;){r=a();const T=r.slice();x.push(T),b+=r.length}return lr(...x)};return(b,x)=>{o(),f(b);let T;for(;!(T=x(g()));)f();return o(),T}}const Oc={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"||ar(n),isSafeInteger:n=>Number.isSafeInteger(n),array:n=>Array.isArray(n),field:(n,e)=>e.Fp.isValid(n),hash:n=>typeof n=="function"&&Number.isSafeInteger(n.outputLen)};function Ir(n,e,t={}){const r=(s,i,o)=>{const a=Oc[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);const f=n[s];if(!(o&&f===void 0)&&!a(f,n))throw new Error(`Invalid param ${String(s)}=${f} (${typeof f}), expected ${i}`)};for(const[s,i]of Object.entries(e))r(s,i,!1);for(const[s,i]of Object.entries(t))r(s,i,!0);return n}const kc=Object.freeze(Object.defineProperty({__proto__:null,abytes:Hr,bitGet:Ic,bitLen:Ac,bitMask:jn,bitSet:vc,bytesToHex:cr,bytesToNumberBE:ur,bytesToNumberLE:Sr,concatBytes:lr,createHmacDrbg:Ks,ensureBytes:dt,equalBytes:Ec,hexToBytes:Er,hexToNumber:Yn,isBytes:ar,numberToBytesBE:Ar,numberToBytesLE:Wr,numberToHexUnpadded:Ds,numberToVarBytesBE:Rc,utf8ToBytes:Sc,validateObject:Ir},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const pt=BigInt(0),We=BigInt(1),hr=BigInt(2),Tc=BigInt(3),Xn=BigInt(4),$s=BigInt(5),Hs=BigInt(8);BigInt(9),BigInt(16);function $e(n,e){const t=n%e;return t>=pt?t:e+t}function Nc(n,e,t){if(t<=pt||e<pt)throw new Error("Expected power/modulo > 0");if(t===We)return pt;let r=We;for(;e>pt;)e&We&&(r=r*n%t),n=n*n%t,e>>=We;return r}function Ge(n,e,t){let r=n;for(;e-- >pt;)r*=r,r%=t;return r}function Jn(n,e){if(n===pt||e<=pt)throw new Error(`invert: expected positive integers, got n=${n} mod=${e}`);let t=$e(n,e),r=e,s=pt,i=We;for(;t!==pt;){const a=r/t,f=r%t,g=s-i*a;r=t,t=f,s=i,i=g}if(r!==We)throw new Error("invert: does not exist");return $e(s,e)}function xc(n){const e=(n-We)/hr;let t,r,s;for(t=n-We,r=0;t%hr===pt;t/=hr,r++);for(s=hr;s<n&&Nc(s,e,n)!==n-We;s++);if(r===1){const o=(n+We)/Xn;return function(f,g){const _=f.pow(g,o);if(!f.eql(f.sqr(_),g))throw new Error("Cannot find square root");return _}}const i=(t+We)/hr;return function(a,f){if(a.pow(f,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let g=r,_=a.pow(a.mul(a.ONE,s),t),b=a.pow(f,i),x=a.pow(f,t);for(;!a.eql(x,a.ONE);){if(a.eql(x,a.ZERO))return a.ZERO;let T=1;for(let k=a.sqr(x);T<g&&!a.eql(k,a.ONE);T++)k=a.sqr(k);const L=a.pow(_,We<<BigInt(g-T-1));_=a.sqr(L),b=a.mul(b,L),x=a.mul(x,_),g=T}return b}}function Bc(n){if(n%Xn===Tc){const e=(n+We)/Xn;return function(r,s){const i=r.pow(s,e);if(!r.eql(r.sqr(i),s))throw new Error("Cannot find square root");return i}}if(n%Hs===$s){const e=(n-$s)/Hs;return function(r,s){const i=r.mul(s,hr),o=r.pow(i,e),a=r.mul(s,o),f=r.mul(r.mul(a,hr),o),g=r.mul(a,r.sub(f,r.ONE));if(!r.eql(r.sqr(g),s))throw new Error("Cannot find square root");return g}}return xc(n)}const Lc=(n,e)=>($e(n,e)&We)===We,Cc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Mc(n){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=Cc.reduce((r,s)=>(r[s]="function",r),e);return Ir(n,t)}function Pc(n,e,t){if(t<pt)throw new Error("Expected power > 0");if(t===pt)return n.ONE;if(t===We)return e;let r=n.ONE,s=e;for(;t>pt;)t&We&&(r=n.mul(r,s)),s=n.sqr(s),t>>=We;return r}function Uc(n,e){const t=new Array(e.length),r=e.reduce((i,o,a)=>n.is0(o)?i:(t[a]=i,n.mul(i,o)),n.ONE),s=n.inv(r);return e.reduceRight((i,o,a)=>n.is0(o)?i:(t[a]=n.mul(i,t[a]),n.mul(i,o)),s),t}function Ws(n,e){const t=e!==void 0?e:n.toString(2).length,r=Math.ceil(t/8);return{nBitLength:t,nByteLength:r}}function qs(n,e,t=!1,r={}){if(n<=pt)throw new Error(`Expected Field ORDER > 0, got ${n}`);const{nBitLength:s,nByteLength:i}=Ws(n,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=Bc(n),a=Object.freeze({ORDER:n,BITS:s,BYTES:i,MASK:jn(s),ZERO:pt,ONE:We,create:f=>$e(f,n),isValid:f=>{if(typeof f!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof f}`);return pt<=f&&f<n},is0:f=>f===pt,isOdd:f=>(f&We)===We,neg:f=>$e(-f,n),eql:(f,g)=>f===g,sqr:f=>$e(f*f,n),add:(f,g)=>$e(f+g,n),sub:(f,g)=>$e(f-g,n),mul:(f,g)=>$e(f*g,n),pow:(f,g)=>Pc(a,f,g),div:(f,g)=>$e(f*Jn(g,n),n),sqrN:f=>f*f,addN:(f,g)=>f+g,subN:(f,g)=>f-g,mulN:(f,g)=>f*g,inv:f=>Jn(f,n),sqrt:r.sqrt||(f=>o(a,f)),invertBatch:f=>Uc(a,f),cmov:(f,g,_)=>_?g:f,toBytes:f=>t?Wr(f,i):Ar(f,i),fromBytes:f=>{if(f.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${f.length}`);return t?Sr(f):ur(f)}});return Object.freeze(a)}function Vs(n){if(typeof n!="bigint")throw new Error("field order must be bigint");const e=n.toString(2).length;return Math.ceil(e/8)}function Gs(n){const e=Vs(n);return e+Math.ceil(e/2)}function Dc(n,e,t=!1){const r=n.length,s=Vs(e),i=Gs(e);if(r<16||r<i||r>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const o=t?ur(n):Sr(n),a=$e(o,e-We)+We;return t?Wr(a,s):Ar(a,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Fc=BigInt(0),Qn=BigInt(1);function Ys(n,e){const t=(s,i)=>{const o=i.negate();return s?o:i},r=s=>{const i=Math.ceil(e/s)+1,o=2**(s-1);return{windows:i,windowSize:o}};return{constTimeNegate:t,unsafeLadder(s,i){let o=n.ZERO,a=s;for(;i>Fc;)i&Qn&&(o=o.add(a)),a=a.double(),i>>=Qn;return o},precomputeWindow(s,i){const{windows:o,windowSize:a}=r(i),f=[];let g=s,_=g;for(let b=0;b<o;b++){_=g,f.push(_);for(let x=1;x<a;x++)_=_.add(g),f.push(_);g=_.double()}return f},wNAF(s,i,o){const{windows:a,windowSize:f}=r(s);let g=n.ZERO,_=n.BASE;const b=BigInt(2**s-1),x=2**s,T=BigInt(s);for(let L=0;L<a;L++){const k=L*f;let N=Number(o&b);o>>=T,N>f&&(N-=x,o+=Qn);const M=k,H=k+Math.abs(N)-1,K=L%2!==0,J=N<0;N===0?_=_.add(t(K,i[M])):g=g.add(t(J,i[H]))}return{p:g,f:_}},wNAFCached(s,i,o,a){const f=s._WINDOW_SIZE||1;let g=i.get(s);return g||(g=this.precomputeWindow(s,f),f!==1&&i.set(s,a(g))),this.wNAF(f,g,o)}}}function ei(n){return Mc(n.Fp),Ir(n,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ws(n.n,n.nBitLength),...n,p:n.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const xt=BigInt(0),kt=BigInt(1),un=BigInt(2),zc=BigInt(8),Kc={zip215:!0};function $c(n){const e=ei(n);return Ir(n,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Hc(n){const e=$c(n),{Fp:t,n:r,prehash:s,hash:i,randomBytes:o,nByteLength:a,h:f}=e,g=un<<BigInt(a*8)-kt,_=t.create,b=e.uvRatio||((S,I)=>{try{return{isValid:!0,value:t.sqrt(S*t.inv(I))}}catch{return{isValid:!1,value:xt}}}),x=e.adjustScalarBytes||(S=>S),T=e.domain||((S,I,C)=>{if(I.length||C)throw new Error("Contexts/pre-hash are not supported");return S}),L=S=>typeof S=="bigint"&&xt<S,k=(S,I)=>L(S)&&L(I)&&S<I,N=S=>S===xt||k(S,g);function M(S,I){if(k(S,I))return S;throw new Error(`Expected valid scalar < ${I}, got ${typeof S} ${S}`)}function H(S){return S===xt?S:M(S,r)}const K=new Map;function J(S){if(!(S instanceof q))throw new Error("ExtendedPoint expected")}class q{constructor(I,C,R,u){if(this.ex=I,this.ey=C,this.ez=R,this.et=u,!N(I))throw new Error("x required");if(!N(C))throw new Error("y required");if(!N(R))throw new Error("z required");if(!N(u))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(I){if(I instanceof q)throw new Error("extended point not allowed");const{x:C,y:R}=I||{};if(!N(C)||!N(R))throw new Error("invalid affine point");return new q(C,R,kt,_(C*R))}static normalizeZ(I){const C=t.invertBatch(I.map(R=>R.ez));return I.map((R,u)=>R.toAffine(C[u])).map(q.fromAffine)}_setWindowSize(I){this._WINDOW_SIZE=I,K.delete(this)}assertValidity(){const{a:I,d:C}=e;if(this.is0())throw new Error("bad point: ZERO");const{ex:R,ey:u,ez:l,et:w}=this,E=_(R*R),P=_(u*u),G=_(l*l),ne=_(G*G),ce=_(E*I),ve=_(G*_(ce+P)),ge=_(ne+_(C*_(E*P)));if(ve!==ge)throw new Error("bad point: equation left != right (1)");const Re=_(R*u),ke=_(l*w);if(Re!==ke)throw new Error("bad point: equation left != right (2)")}equals(I){J(I);const{ex:C,ey:R,ez:u}=this,{ex:l,ey:w,ez:E}=I,P=_(C*E),G=_(l*u),ne=_(R*E),ce=_(w*u);return P===G&&ne===ce}is0(){return this.equals(q.ZERO)}negate(){return new q(_(-this.ex),this.ey,this.ez,_(-this.et))}double(){const{a:I}=e,{ex:C,ey:R,ez:u}=this,l=_(C*C),w=_(R*R),E=_(un*_(u*u)),P=_(I*l),G=C+R,ne=_(_(G*G)-l-w),ce=P+w,ve=ce-E,ge=P-w,Re=_(ne*ve),ke=_(ce*ge),Ee=_(ne*ge),Ne=_(ve*ce);return new q(Re,ke,Ne,Ee)}add(I){J(I);const{a:C,d:R}=e,{ex:u,ey:l,ez:w,et:E}=this,{ex:P,ey:G,ez:ne,et:ce}=I;if(C===BigInt(-1)){const St=_((l-u)*(G+P)),Me=_((l+u)*(G-P)),De=_(Me-St);if(De===xt)return this.double();const Ot=_(w*un*ce),ze=_(E*un*ne),y=ze+Ot,h=Me+St,d=ze-Ot,O=_(y*De),U=_(h*d),F=_(y*d),Y=_(De*h);return new q(O,U,Y,F)}const ve=_(u*P),ge=_(l*G),Re=_(E*R*ce),ke=_(w*ne),Ee=_((u+l)*(P+G)-ve-ge),Ne=ke-Re,qt=ke+Re,Le=_(ge-C*ve),He=_(Ee*Ne),Fr=_(qt*Le),Fe=_(Ee*Le),Ce=_(Ne*qt);return new q(He,Fr,Ce,Fe)}subtract(I){return this.add(I.negate())}wNAF(I){return j.wNAFCached(this,K,I,q.normalizeZ)}multiply(I){const{p:C,f:R}=this.wNAF(M(I,r));return q.normalizeZ([C,R])[0]}multiplyUnsafe(I){let C=H(I);return C===xt?Z:this.equals(Z)||C===kt?this:this.equals(D)?this.wNAF(C).p:j.unsafeLadder(this,C)}isSmallOrder(){return this.multiplyUnsafe(f).is0()}isTorsionFree(){return j.unsafeLadder(this,r).is0()}toAffine(I){const{ex:C,ey:R,ez:u}=this,l=this.is0();I==null&&(I=l?zc:t.inv(u));const w=_(C*I),E=_(R*I),P=_(u*I);if(l)return{x:xt,y:kt};if(P!==kt)throw new Error("invZ was invalid");return{x:w,y:E}}clearCofactor(){const{h:I}=e;return I===kt?this:this.multiplyUnsafe(I)}static fromHex(I,C=!1){const{d:R,a:u}=e,l=t.BYTES;I=dt("pointHex",I,l);const w=I.slice(),E=I[l-1];w[l-1]=E&-129;const P=Sr(w);P===xt||(C?M(P,g):M(P,t.ORDER));const G=_(P*P),ne=_(G-kt),ce=_(R*G-u);let{isValid:ve,value:ge}=b(ne,ce);if(!ve)throw new Error("Point.fromHex: invalid y coordinate");const Re=(ge&kt)===kt,ke=(E&128)!==0;if(!C&&ge===xt&&ke)throw new Error("Point.fromHex: x=0 and x_0=1");return ke!==Re&&(ge=_(-ge)),q.fromAffine({x:ge,y:P})}static fromPrivateKey(I){return V(I).point}toRawBytes(){const{x:I,y:C}=this.toAffine(),R=Wr(C,t.BYTES);return R[R.length-1]|=I&kt?128:0,R}toHex(){return cr(this.toRawBytes())}}q.BASE=new q(e.Gx,e.Gy,kt,_(e.Gx*e.Gy)),q.ZERO=new q(xt,kt,kt,xt);const{BASE:D,ZERO:Z}=q,j=Ys(q,a*8);function X(S){return $e(S,r)}function z(S){return X(Sr(S))}function V(S){const I=a;S=dt("private key",S,I);const C=dt("hashed private key",i(S),2*I),R=x(C.slice(0,I)),u=C.slice(I,2*I),l=z(R),w=D.multiply(l),E=w.toRawBytes();return{head:R,prefix:u,scalar:l,point:w,pointBytes:E}}function Q(S){return V(S).pointBytes}function A(S=new Uint8Array,...I){const C=lr(...I);return z(i(T(C,dt("context",S),!!s)))}function c(S,I,C={}){S=dt("message",S),s&&(S=s(S));const{prefix:R,scalar:u,pointBytes:l}=V(I),w=A(C.context,R,S),E=D.multiply(w).toRawBytes(),P=A(C.context,E,l,S),G=X(w+P*u);H(G);const ne=lr(E,Wr(G,t.BYTES));return dt("result",ne,a*2)}const p=Kc;function m(S,I,C,R=p){const{context:u,zip215:l}=R,w=t.BYTES;S=dt("signature",S,2*w),I=dt("message",I),s&&(I=s(I));const E=Sr(S.slice(w,2*w));let P,G,ne;try{P=q.fromHex(C,l),G=q.fromHex(S.slice(0,w),l),ne=D.multiplyUnsafe(E)}catch{return!1}if(!l&&P.isSmallOrder())return!1;const ce=A(u,G.toRawBytes(),P.toRawBytes(),I);return G.add(P.multiplyUnsafe(ce)).subtract(ne).clearCofactor().equals(q.ZERO)}return D._setWindowSize(8),{CURVE:e,getPublicKey:Q,sign:c,verify:m,ExtendedPoint:q,utils:{getExtendedPublicKey:V,randomPrivateKey:()=>o(t.BYTES),precompute(S=8,I=q.BASE){return I._setWindowSize(S),I.multiply(BigInt(3)),I}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ti=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),js=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const Wc=BigInt(1),Zs=BigInt(2);BigInt(3);const qc=BigInt(5),Vc=BigInt(8);function Gc(n){const e=BigInt(10),t=BigInt(20),r=BigInt(40),s=BigInt(80),i=ti,a=n*n%i*n%i,f=Ge(a,Zs,i)*a%i,g=Ge(f,Wc,i)*n%i,_=Ge(g,qc,i)*g%i,b=Ge(_,e,i)*_%i,x=Ge(b,t,i)*b%i,T=Ge(x,r,i)*x%i,L=Ge(T,s,i)*T%i,k=Ge(L,s,i)*T%i,N=Ge(k,e,i)*_%i;return{pow_p_5_8:Ge(N,Zs,i)*n%i,b2:a}}function Yc(n){return n[0]&=248,n[31]&=127,n[31]|=64,n}function jc(n,e){const t=ti,r=$e(e*e*e,t),s=$e(r*r*e,t),i=Gc(n*s).pow_p_5_8;let o=$e(n*r*i,t);const a=$e(e*o*o,t),f=o,g=$e(o*js,t),_=a===n,b=a===$e(-n,t),x=a===$e(-n*js,t);return _&&(o=f),(b||x)&&(o=g),Lc(o,t)&&(o=$e(-o,t)),{isValid:_||b,value:o}}const Zc=qs(ti,void 0,!0),Xc={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Zc,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Vc,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:_c,randomBytes:Ts,adjustScalarBytes:Yc,uvRatio:jc},vr=Hc(Xc);var ln={exports:{}};const Jc=zn(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Qc=ln.exports,Xs;function Js(){return Xs||(Xs=1,function(n){(function(e,t){function r(A,c){if(!A)throw new Error(c||"Assertion failed")}function s(A,c){A.super_=c;var p=function(){};p.prototype=c.prototype,A.prototype=new p,A.prototype.constructor=A}function i(A,c,p){if(i.isBN(A))return A;this.negative=0,this.words=null,this.length=0,this.red=null,A!==null&&((c==="le"||c==="be")&&(p=c,c=10),this._init(A||0,c||10,p||"be"))}typeof e=="object"?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Jc.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,m){if(typeof c=="number")return this._initNumber(c,p,m);if(typeof c=="object")return this._initArray(c,p,m);p==="hex"&&(p=16),r(p===(p|0)&&p>=2&&p<=36),c=c.toString().replace(/\s+/g,"");var v=0;c[0]==="-"&&(v++,this.negative=1),v<c.length&&(p===16?this._parseHex(c,v,m):(this._parseBase(c,p,v),m==="le"&&this._initArray(this.toArray(),p,m)))},i.prototype._initNumber=function(c,p,m){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),m==="le"&&this._initArray(this.toArray(),p,m)},i.prototype._initArray=function(c,p,m){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 v=0;v<this.length;v++)this.words[v]=0;var S,I,C=0;if(m==="be")for(v=c.length-1,S=0;v>=0;v-=3)I=c[v]|c[v-1]<<8|c[v-2]<<16,this.words[S]|=I<<C&67108863,this.words[S+1]=I>>>26-C&67108863,C+=24,C>=26&&(C-=26,S++);else if(m==="le")for(v=0,S=0;v<c.length;v+=3)I=c[v]|c[v+1]<<8|c[v+2]<<16,this.words[S]|=I<<C&67108863,this.words[S+1]=I>>>26-C&67108863,C+=24,C>=26&&(C-=26,S++);return this._strip()};function a(A,c){var p=A.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 "+A)}function f(A,c,p){var m=a(A,p);return p-1>=c&&(m|=a(A,p-1)<<4),m}i.prototype._parseHex=function(c,p,m){this.length=Math.ceil((c.length-p)/6),this.words=new Array(this.length);for(var v=0;v<this.length;v++)this.words[v]=0;var S=0,I=0,C;if(m==="be")for(v=c.length-1;v>=p;v-=2)C=f(c,p,v)<<S,this.words[I]|=C&67108863,S>=18?(S-=18,I+=1,this.words[I]|=C>>>26):S+=8;else{var R=c.length-p;for(v=R%2===0?p+1:p;v<c.length;v+=2)C=f(c,p,v)<<S,this.words[I]|=C&67108863,S>=18?(S-=18,I+=1,this.words[I]|=C>>>26):S+=8}this._strip()};function g(A,c,p,m){for(var v=0,S=0,I=Math.min(A.length,p),C=c;C<I;C++){var R=A.charCodeAt(C)-48;v*=m,R>=49?S=R-49+10:R>=17?S=R-17+10:S=R,r(R>=0&&S<m,"Invalid character"),v+=S}return v}i.prototype._parseBase=function(c,p,m){this.words=[0],this.length=1;for(var v=0,S=1;S<=67108863;S*=p)v++;v--,S=S/p|0;for(var I=c.length-m,C=I%v,R=Math.min(I,I-C)+m,u=0,l=m;l<R;l+=v)u=g(c,l,l+v,p),this.imuln(S),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(C!==0){var w=1;for(u=g(c,l,c.length,p),l=0;l<C;l++)w*=p;this.imuln(w),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}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 _(A,c){A.words=c.words,A.length=c.length,A.negative=c.negative,A.red=c.red}if(i.prototype._move=function(c){_(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")]=b}catch{i.prototype.inspect=b}else i.prototype.inspect=b;function b(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var x=["","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"],T=[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],L=[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 m;if(c===16||c==="hex"){m="";for(var v=0,S=0,I=0;I<this.length;I++){var C=this.words[I],R=((C<<v|S)&16777215).toString(16);S=C>>>24-v&16777215,v+=2,v>=26&&(v-=26,I--),S!==0||I!==this.length-1?m=x[6-R.length]+R+m:m=R+m}for(S!==0&&(m=S.toString(16)+m);m.length%p!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}if(c===(c|0)&&c>=2&&c<=36){var u=T[c],l=L[c];m="";var w=this.clone();for(w.negative=0;!w.isZero();){var E=w.modrn(l).toString(c);w=w.idivn(l),w.isZero()?m=E+m:m=x[u-E.length]+E+m}for(this.isZero()&&(m="0"+m);m.length%p!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var 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 k=function(c,p){return c.allocUnsafe?c.allocUnsafe(p):new c(p)};i.prototype.toArrayLike=function(c,p,m){this._strip();var v=this.byteLength(),S=m||Math.max(1,v);r(v<=S,"byte array longer than desired length"),r(S>0,"Requested array length <= 0");var I=k(c,S),C=p==="le"?"LE":"BE";return this["_toArrayLike"+C](I,v),I},i.prototype._toArrayLikeLE=function(c,p){for(var m=0,v=0,S=0,I=0;S<this.length;S++){var C=this.words[S]<<I|v;c[m++]=C&255,m<c.length&&(c[m++]=C>>8&255),m<c.length&&(c[m++]=C>>16&255),I===6?(m<c.length&&(c[m++]=C>>24&255),v=0,I=0):(v=C>>>24,I+=2)}if(m<c.length)for(c[m++]=v;m<c.length;)c[m++]=0},i.prototype._toArrayLikeBE=function(c,p){for(var m=c.length-1,v=0,S=0,I=0;S<this.length;S++){var C=this.words[S]<<I|v;c[m--]=C&255,m>=0&&(c[m--]=C>>8&255),m>=0&&(c[m--]=C>>16&255),I===6?(m>=0&&(c[m--]=C>>24&255),v=0,I=0):(v=C>>>24,I+=2)}if(m>=0)for(c[m--]=v;m>=0;)c[m--]=0},Math.clz32?i.prototype._countBits=function(c){return 32-Math.clz32(c)}:i.prototype._countBits=function(c){var p=c,m=0;return p>=4096&&(m+=13,p>>>=13),p>=64&&(m+=7,p>>>=7),p>=8&&(m+=4,p>>>=4),p>=2&&(m+=2,p>>>=2),m+p},i.prototype._zeroBits=function(c){if(c===0)return 26;var p=c,m=0;return(p&8191)===0&&(m+=13,p>>>=13),(p&127)===0&&(m+=7,p>>>=7),(p&15)===0&&(m+=4,p>>>=4),(p&3)===0&&(m+=2,p>>>=2),(p&1)===0&&m++,m},i.prototype.bitLength=function(){var c=this.words[this.length-1],p=this._countBits(c);return(this.length-1)*26+p};function N(A){for(var c=new Array(A.bitLength()),p=0;p<c.length;p++){var m=p/26|0,v=p%26;c[p]=A.words[m]>>>v&1}return c}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var c=0,p=0;p<this.length;p++){var m=this._zeroBits(this.words[p]);if(c+=m,m!==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 m=0;m<p.length;m++)this.words[m]=this.words[m]&c.words[m];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,m;this.length>c.length?(p=this,m=c):(p=c,m=this);for(var v=0;v<m.length;v++)this.words[v]=p.words[v]^m.words[v];if(this!==p)for(;v<p.length;v++)this.words[v]=p.words[v];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,m=c%26;this._expand(p),m>0&&p--;for(var v=0;v<p;v++)this.words[v]=~this.words[v]&67108863;return m>0&&(this.words[v]=~this.words[v]&67108863>>26-m),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 m=c/26|0,v=c%26;return this._expand(m+1),p?this.words[m]=this.words[m]|1<<v:this.words[m]=this.words[m]&~(1<<v),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 m,v;this.length>c.length?(m=this,v=c):(m=c,v=this);for(var S=0,I=0;I<v.length;I++)p=(m.words[I]|0)+(v.words[I]|0)+S,this.words[I]=p&67108863,S=p>>>26;for(;S!==0&&I<m.length;I++)p=(m.words[I]|0)+S,this.words[I]=p&67108863,S=p>>>26;if(this.length=m.length,S!==0)this.words[this.length]=S,this.length++;else if(m!==this)for(;I<m.length;I++)this.words[I]=m.words[I];return this},i.prototype.add=function(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 m=this.cmp(c);if(m===0)return this.negative=0,this.length=1,this.words[0]=0,this;var v,S;m>0?(v=this,S=c):(v=c,S=this);for(var I=0,C=0;C<S.length;C++)p=(v.words[C]|0)-(S.words[C]|0)+I,I=p>>26,this.words[C]=p&67108863;for(;I!==0&&C<v.length;C++)p=(v.words[C]|0)+I,I=p>>26,this.words[C]=p&67108863;if(I===0&&C<v.length&&v!==this)for(;C<v.length;C++)this.words[C]=v.words[C];return this.length=Math.max(this.length,C),v!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(c){return this.clone().isub(c)};function M(A,c,p){p.negative=c.negative^A.negative;var m=A.length+c.length|0;p.length=m,m=m-1|0;var v=A.words[0]|0,S=c.words[0]|0,I=v*S,C=I&67108863,R=I/67108864|0;p.words[0]=C;for(var u=1;u<m;u++){for(var l=R>>>26,w=R&67108863,E=Math.min(u,c.length-1),P=Math.max(0,u-A.length+1);P<=E;P++){var G=u-P|0;v=A.words[G]|0,S=c.words[P]|0,I=v*S+w,l+=I/67108864|0,w=I&67108863}p.words[u]=w|0,R=l|0}return R!==0?p.words[u]=R|0:p.length--,p._strip()}var H=function(c,p,m){var v=c.words,S=p.words,I=m.words,C=0,R,u,l,w=v[0]|0,E=w&8191,P=w>>>13,G=v[1]|0,ne=G&8191,ce=G>>>13,ve=v[2]|0,ge=ve&8191,Re=ve>>>13,ke=v[3]|0,Ee=ke&8191,Ne=ke>>>13,qt=v[4]|0,Le=qt&8191,He=qt>>>13,Fr=v[5]|0,Fe=Fr&8191,Ce=Fr>>>13,St=v[6]|0,Me=St&8191,De=St>>>13,Ot=v[7]|0,ze=Ot&8191,y=Ot>>>13,h=v[8]|0,d=h&8191,O=h>>>13,U=v[9]|0,F=U&8191,Y=U>>>13,be=S[0]|0,me=be&8191,pe=be>>>13,Ke=S[1]|0,de=Ke&8191,Ze=Ke>>>13,za=S[2]|0,Xe=za&8191,Je=za>>>13,Ka=S[3]|0,Qe=Ka&8191,et=Ka>>>13,$a=S[4]|0,tt=$a&8191,rt=$a>>>13,Ha=S[5]|0,nt=Ha&8191,it=Ha>>>13,Wa=S[6]|0,st=Wa&8191,ot=Wa>>>13,qa=S[7]|0,at=qa&8191,ct=qa>>>13,Va=S[8]|0,ut=Va&8191,lt=Va>>>13,Ga=S[9]|0,ht=Ga&8191,ft=Ga>>>13;m.negative=c.negative^p.negative,m.length=19,R=Math.imul(E,me),u=Math.imul(E,pe),u=u+Math.imul(P,me)|0,l=Math.imul(P,pe);var ts=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(ts>>>26)|0,ts&=67108863,R=Math.imul(ne,me),u=Math.imul(ne,pe),u=u+Math.imul(ce,me)|0,l=Math.imul(ce,pe),R=R+Math.imul(E,de)|0,u=u+Math.imul(E,Ze)|0,u=u+Math.imul(P,de)|0,l=l+Math.imul(P,Ze)|0;var rs=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(rs>>>26)|0,rs&=67108863,R=Math.imul(ge,me),u=Math.imul(ge,pe),u=u+Math.imul(Re,me)|0,l=Math.imul(Re,pe),R=R+Math.imul(ne,de)|0,u=u+Math.imul(ne,Ze)|0,u=u+Math.imul(ce,de)|0,l=l+Math.imul(ce,Ze)|0,R=R+Math.imul(E,Xe)|0,u=u+Math.imul(E,Je)|0,u=u+Math.imul(P,Xe)|0,l=l+Math.imul(P,Je)|0;var ns=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(ns>>>26)|0,ns&=67108863,R=Math.imul(Ee,me),u=Math.imul(Ee,pe),u=u+Math.imul(Ne,me)|0,l=Math.imul(Ne,pe),R=R+Math.imul(ge,de)|0,u=u+Math.imul(ge,Ze)|0,u=u+Math.imul(Re,de)|0,l=l+Math.imul(Re,Ze)|0,R=R+Math.imul(ne,Xe)|0,u=u+Math.imul(ne,Je)|0,u=u+Math.imul(ce,Xe)|0,l=l+Math.imul(ce,Je)|0,R=R+Math.imul(E,Qe)|0,u=u+Math.imul(E,et)|0,u=u+Math.imul(P,Qe)|0,l=l+Math.imul(P,et)|0;var is=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(is>>>26)|0,is&=67108863,R=Math.imul(Le,me),u=Math.imul(Le,pe),u=u+Math.imul(He,me)|0,l=Math.imul(He,pe),R=R+Math.imul(Ee,de)|0,u=u+Math.imul(Ee,Ze)|0,u=u+Math.imul(Ne,de)|0,l=l+Math.imul(Ne,Ze)|0,R=R+Math.imul(ge,Xe)|0,u=u+Math.imul(ge,Je)|0,u=u+Math.imul(Re,Xe)|0,l=l+Math.imul(Re,Je)|0,R=R+Math.imul(ne,Qe)|0,u=u+Math.imul(ne,et)|0,u=u+Math.imul(ce,Qe)|0,l=l+Math.imul(ce,et)|0,R=R+Math.imul(E,tt)|0,u=u+Math.imul(E,rt)|0,u=u+Math.imul(P,tt)|0,l=l+Math.imul(P,rt)|0;var ss=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(ss>>>26)|0,ss&=67108863,R=Math.imul(Fe,me),u=Math.imul(Fe,pe),u=u+Math.imul(Ce,me)|0,l=Math.imul(Ce,pe),R=R+Math.imul(Le,de)|0,u=u+Math.imul(Le,Ze)|0,u=u+Math.imul(He,de)|0,l=l+Math.imul(He,Ze)|0,R=R+Math.imul(Ee,Xe)|0,u=u+Math.imul(Ee,Je)|0,u=u+Math.imul(Ne,Xe)|0,l=l+Math.imul(Ne,Je)|0,R=R+Math.imul(ge,Qe)|0,u=u+Math.imul(ge,et)|0,u=u+Math.imul(Re,Qe)|0,l=l+Math.imul(Re,et)|0,R=R+Math.imul(ne,tt)|0,u=u+Math.imul(ne,rt)|0,u=u+Math.imul(ce,tt)|0,l=l+Math.imul(ce,rt)|0,R=R+Math.imul(E,nt)|0,u=u+Math.imul(E,it)|0,u=u+Math.imul(P,nt)|0,l=l+Math.imul(P,it)|0;var os=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(os>>>26)|0,os&=67108863,R=Math.imul(Me,me),u=Math.imul(Me,pe),u=u+Math.imul(De,me)|0,l=Math.imul(De,pe),R=R+Math.imul(Fe,de)|0,u=u+Math.imul(Fe,Ze)|0,u=u+Math.imul(Ce,de)|0,l=l+Math.imul(Ce,Ze)|0,R=R+Math.imul(Le,Xe)|0,u=u+Math.imul(Le,Je)|0,u=u+Math.imul(He,Xe)|0,l=l+Math.imul(He,Je)|0,R=R+Math.imul(Ee,Qe)|0,u=u+Math.imul(Ee,et)|0,u=u+Math.imul(Ne,Qe)|0,l=l+Math.imul(Ne,et)|0,R=R+Math.imul(ge,tt)|0,u=u+Math.imul(ge,rt)|0,u=u+Math.imul(Re,tt)|0,l=l+Math.imul(Re,rt)|0,R=R+Math.imul(ne,nt)|0,u=u+Math.imul(ne,it)|0,u=u+Math.imul(ce,nt)|0,l=l+Math.imul(ce,it)|0,R=R+Math.imul(E,st)|0,u=u+Math.imul(E,ot)|0,u=u+Math.imul(P,st)|0,l=l+Math.imul(P,ot)|0;var as=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(as>>>26)|0,as&=67108863,R=Math.imul(ze,me),u=Math.imul(ze,pe),u=u+Math.imul(y,me)|0,l=Math.imul(y,pe),R=R+Math.imul(Me,de)|0,u=u+Math.imul(Me,Ze)|0,u=u+Math.imul(De,de)|0,l=l+Math.imul(De,Ze)|0,R=R+Math.imul(Fe,Xe)|0,u=u+Math.imul(Fe,Je)|0,u=u+Math.imul(Ce,Xe)|0,l=l+Math.imul(Ce,Je)|0,R=R+Math.imul(Le,Qe)|0,u=u+Math.imul(Le,et)|0,u=u+Math.imul(He,Qe)|0,l=l+Math.imul(He,et)|0,R=R+Math.imul(Ee,tt)|0,u=u+Math.imul(Ee,rt)|0,u=u+Math.imul(Ne,tt)|0,l=l+Math.imul(Ne,rt)|0,R=R+Math.imul(ge,nt)|0,u=u+Math.imul(ge,it)|0,u=u+Math.imul(Re,nt)|0,l=l+Math.imul(Re,it)|0,R=R+Math.imul(ne,st)|0,u=u+Math.imul(ne,ot)|0,u=u+Math.imul(ce,st)|0,l=l+Math.imul(ce,ot)|0,R=R+Math.imul(E,at)|0,u=u+Math.imul(E,ct)|0,u=u+Math.imul(P,at)|0,l=l+Math.imul(P,ct)|0;var cs=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(cs>>>26)|0,cs&=67108863,R=Math.imul(d,me),u=Math.imul(d,pe),u=u+Math.imul(O,me)|0,l=Math.imul(O,pe),R=R+Math.imul(ze,de)|0,u=u+Math.imul(ze,Ze)|0,u=u+Math.imul(y,de)|0,l=l+Math.imul(y,Ze)|0,R=R+Math.imul(Me,Xe)|0,u=u+Math.imul(Me,Je)|0,u=u+Math.imul(De,Xe)|0,l=l+Math.imul(De,Je)|0,R=R+Math.imul(Fe,Qe)|0,u=u+Math.imul(Fe,et)|0,u=u+Math.imul(Ce,Qe)|0,l=l+Math.imul(Ce,et)|0,R=R+Math.imul(Le,tt)|0,u=u+Math.imul(Le,rt)|0,u=u+Math.imul(He,tt)|0,l=l+Math.imul(He,rt)|0,R=R+Math.imul(Ee,nt)|0,u=u+Math.imul(Ee,it)|0,u=u+Math.imul(Ne,nt)|0,l=l+Math.imul(Ne,it)|0,R=R+Math.imul(ge,st)|0,u=u+Math.imul(ge,ot)|0,u=u+Math.imul(Re,st)|0,l=l+Math.imul(Re,ot)|0,R=R+Math.imul(ne,at)|0,u=u+Math.imul(ne,ct)|0,u=u+Math.imul(ce,at)|0,l=l+Math.imul(ce,ct)|0,R=R+Math.imul(E,ut)|0,u=u+Math.imul(E,lt)|0,u=u+Math.imul(P,ut)|0,l=l+Math.imul(P,lt)|0;var us=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(us>>>26)|0,us&=67108863,R=Math.imul(F,me),u=Math.imul(F,pe),u=u+Math.imul(Y,me)|0,l=Math.imul(Y,pe),R=R+Math.imul(d,de)|0,u=u+Math.imul(d,Ze)|0,u=u+Math.imul(O,de)|0,l=l+Math.imul(O,Ze)|0,R=R+Math.imul(ze,Xe)|0,u=u+Math.imul(ze,Je)|0,u=u+Math.imul(y,Xe)|0,l=l+Math.imul(y,Je)|0,R=R+Math.imul(Me,Qe)|0,u=u+Math.imul(Me,et)|0,u=u+Math.imul(De,Qe)|0,l=l+Math.imul(De,et)|0,R=R+Math.imul(Fe,tt)|0,u=u+Math.imul(Fe,rt)|0,u=u+Math.imul(Ce,tt)|0,l=l+Math.imul(Ce,rt)|0,R=R+Math.imul(Le,nt)|0,u=u+Math.imul(Le,it)|0,u=u+Math.imul(He,nt)|0,l=l+Math.imul(He,it)|0,R=R+Math.imul(Ee,st)|0,u=u+Math.imul(Ee,ot)|0,u=u+Math.imul(Ne,st)|0,l=l+Math.imul(Ne,ot)|0,R=R+Math.imul(ge,at)|0,u=u+Math.imul(ge,ct)|0,u=u+Math.imul(Re,at)|0,l=l+Math.imul(Re,ct)|0,R=R+Math.imul(ne,ut)|0,u=u+Math.imul(ne,lt)|0,u=u+Math.imul(ce,ut)|0,l=l+Math.imul(ce,lt)|0,R=R+Math.imul(E,ht)|0,u=u+Math.imul(E,ft)|0,u=u+Math.imul(P,ht)|0,l=l+Math.imul(P,ft)|0;var ls=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(ls>>>26)|0,ls&=67108863,R=Math.imul(F,de),u=Math.imul(F,Ze),u=u+Math.imul(Y,de)|0,l=Math.imul(Y,Ze),R=R+Math.imul(d,Xe)|0,u=u+Math.imul(d,Je)|0,u=u+Math.imul(O,Xe)|0,l=l+Math.imul(O,Je)|0,R=R+Math.imul(ze,Qe)|0,u=u+Math.imul(ze,et)|0,u=u+Math.imul(y,Qe)|0,l=l+Math.imul(y,et)|0,R=R+Math.imul(Me,tt)|0,u=u+Math.imul(Me,rt)|0,u=u+Math.imul(De,tt)|0,l=l+Math.imul(De,rt)|0,R=R+Math.imul(Fe,nt)|0,u=u+Math.imul(Fe,it)|0,u=u+Math.imul(Ce,nt)|0,l=l+Math.imul(Ce,it)|0,R=R+Math.imul(Le,st)|0,u=u+Math.imul(Le,ot)|0,u=u+Math.imul(He,st)|0,l=l+Math.imul(He,ot)|0,R=R+Math.imul(Ee,at)|0,u=u+Math.imul(Ee,ct)|0,u=u+Math.imul(Ne,at)|0,l=l+Math.imul(Ne,ct)|0,R=R+Math.imul(ge,ut)|0,u=u+Math.imul(ge,lt)|0,u=u+Math.imul(Re,ut)|0,l=l+Math.imul(Re,lt)|0,R=R+Math.imul(ne,ht)|0,u=u+Math.imul(ne,ft)|0,u=u+Math.imul(ce,ht)|0,l=l+Math.imul(ce,ft)|0;var hs=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(hs>>>26)|0,hs&=67108863,R=Math.imul(F,Xe),u=Math.imul(F,Je),u=u+Math.imul(Y,Xe)|0,l=Math.imul(Y,Je),R=R+Math.imul(d,Qe)|0,u=u+Math.imul(d,et)|0,u=u+Math.imul(O,Qe)|0,l=l+Math.imul(O,et)|0,R=R+Math.imul(ze,tt)|0,u=u+Math.imul(ze,rt)|0,u=u+Math.imul(y,tt)|0,l=l+Math.imul(y,rt)|0,R=R+Math.imul(Me,nt)|0,u=u+Math.imul(Me,it)|0,u=u+Math.imul(De,nt)|0,l=l+Math.imul(De,it)|0,R=R+Math.imul(Fe,st)|0,u=u+Math.imul(Fe,ot)|0,u=u+Math.imul(Ce,st)|0,l=l+Math.imul(Ce,ot)|0,R=R+Math.imul(Le,at)|0,u=u+Math.imul(Le,ct)|0,u=u+Math.imul(He,at)|0,l=l+Math.imul(He,ct)|0,R=R+Math.imul(Ee,ut)|0,u=u+Math.imul(Ee,lt)|0,u=u+Math.imul(Ne,ut)|0,l=l+Math.imul(Ne,lt)|0,R=R+Math.imul(ge,ht)|0,u=u+Math.imul(ge,ft)|0,u=u+Math.imul(Re,ht)|0,l=l+Math.imul(Re,ft)|0;var fs=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(fs>>>26)|0,fs&=67108863,R=Math.imul(F,Qe),u=Math.imul(F,et),u=u+Math.imul(Y,Qe)|0,l=Math.imul(Y,et),R=R+Math.imul(d,tt)|0,u=u+Math.imul(d,rt)|0,u=u+Math.imul(O,tt)|0,l=l+Math.imul(O,rt)|0,R=R+Math.imul(ze,nt)|0,u=u+Math.imul(ze,it)|0,u=u+Math.imul(y,nt)|0,l=l+Math.imul(y,it)|0,R=R+Math.imul(Me,st)|0,u=u+Math.imul(Me,ot)|0,u=u+Math.imul(De,st)|0,l=l+Math.imul(De,ot)|0,R=R+Math.imul(Fe,at)|0,u=u+Math.imul(Fe,ct)|0,u=u+Math.imul(Ce,at)|0,l=l+Math.imul(Ce,ct)|0,R=R+Math.imul(Le,ut)|0,u=u+Math.imul(Le,lt)|0,u=u+Math.imul(He,ut)|0,l=l+Math.imul(He,lt)|0,R=R+Math.imul(Ee,ht)|0,u=u+Math.imul(Ee,ft)|0,u=u+Math.imul(Ne,ht)|0,l=l+Math.imul(Ne,ft)|0;var ds=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(ds>>>26)|0,ds&=67108863,R=Math.imul(F,tt),u=Math.imul(F,rt),u=u+Math.imul(Y,tt)|0,l=Math.imul(Y,rt),R=R+Math.imul(d,nt)|0,u=u+Math.imul(d,it)|0,u=u+Math.imul(O,nt)|0,l=l+Math.imul(O,it)|0,R=R+Math.imul(ze,st)|0,u=u+Math.imul(ze,ot)|0,u=u+Math.imul(y,st)|0,l=l+Math.imul(y,ot)|0,R=R+Math.imul(Me,at)|0,u=u+Math.imul(Me,ct)|0,u=u+Math.imul(De,at)|0,l=l+Math.imul(De,ct)|0,R=R+Math.imul(Fe,ut)|0,u=u+Math.imul(Fe,lt)|0,u=u+Math.imul(Ce,ut)|0,l=l+Math.imul(Ce,lt)|0,R=R+Math.imul(Le,ht)|0,u=u+Math.imul(Le,ft)|0,u=u+Math.imul(He,ht)|0,l=l+Math.imul(He,ft)|0;var ps=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(ps>>>26)|0,ps&=67108863,R=Math.imul(F,nt),u=Math.imul(F,it),u=u+Math.imul(Y,nt)|0,l=Math.imul(Y,it),R=R+Math.imul(d,st)|0,u=u+Math.imul(d,ot)|0,u=u+Math.imul(O,st)|0,l=l+Math.imul(O,ot)|0,R=R+Math.imul(ze,at)|0,u=u+Math.imul(ze,ct)|0,u=u+Math.imul(y,at)|0,l=l+Math.imul(y,ct)|0,R=R+Math.imul(Me,ut)|0,u=u+Math.imul(Me,lt)|0,u=u+Math.imul(De,ut)|0,l=l+Math.imul(De,lt)|0,R=R+Math.imul(Fe,ht)|0,u=u+Math.imul(Fe,ft)|0,u=u+Math.imul(Ce,ht)|0,l=l+Math.imul(Ce,ft)|0;var gs=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(gs>>>26)|0,gs&=67108863,R=Math.imul(F,st),u=Math.imul(F,ot),u=u+Math.imul(Y,st)|0,l=Math.imul(Y,ot),R=R+Math.imul(d,at)|0,u=u+Math.imul(d,ct)|0,u=u+Math.imul(O,at)|0,l=l+Math.imul(O,ct)|0,R=R+Math.imul(ze,ut)|0,u=u+Math.imul(ze,lt)|0,u=u+Math.imul(y,ut)|0,l=l+Math.imul(y,lt)|0,R=R+Math.imul(Me,ht)|0,u=u+Math.imul(Me,ft)|0,u=u+Math.imul(De,ht)|0,l=l+Math.imul(De,ft)|0;var ms=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(ms>>>26)|0,ms&=67108863,R=Math.imul(F,at),u=Math.imul(F,ct),u=u+Math.imul(Y,at)|0,l=Math.imul(Y,ct),R=R+Math.imul(d,ut)|0,u=u+Math.imul(d,lt)|0,u=u+Math.imul(O,ut)|0,l=l+Math.imul(O,lt)|0,R=R+Math.imul(ze,ht)|0,u=u+Math.imul(ze,ft)|0,u=u+Math.imul(y,ht)|0,l=l+Math.imul(y,ft)|0;var ys=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(ys>>>26)|0,ys&=67108863,R=Math.imul(F,ut),u=Math.imul(F,lt),u=u+Math.imul(Y,ut)|0,l=Math.imul(Y,lt),R=R+Math.imul(d,ht)|0,u=u+Math.imul(d,ft)|0,u=u+Math.imul(O,ht)|0,l=l+Math.imul(O,ft)|0;var _s=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(_s>>>26)|0,_s&=67108863,R=Math.imul(F,ht),u=Math.imul(F,ft),u=u+Math.imul(Y,ht)|0,l=Math.imul(Y,ft);var ws=(C+R|0)+((u&8191)<<13)|0;return C=(l+(u>>>13)|0)+(ws>>>26)|0,ws&=67108863,I[0]=ts,I[1]=rs,I[2]=ns,I[3]=is,I[4]=ss,I[5]=os,I[6]=as,I[7]=cs,I[8]=us,I[9]=ls,I[10]=hs,I[11]=fs,I[12]=ds,I[13]=ps,I[14]=gs,I[15]=ms,I[16]=ys,I[17]=_s,I[18]=ws,C!==0&&(I[19]=C,m.length++),m};Math.imul||(H=M);function K(A,c,p){p.negative=c.negative^A.negative,p.length=A.length+c.length;for(var m=0,v=0,S=0;S<p.length-1;S++){var I=v;v=0;for(var C=m&67108863,R=Math.min(S,c.length-1),u=Math.max(0,S-A.length+1);u<=R;u++){var l=S-u,w=A.words[l]|0,E=c.words[u]|0,P=w*E,G=P&67108863;I=I+(P/67108864|0)|0,G=G+C|0,C=G&67108863,I=I+(G>>>26)|0,v+=I>>>26,I&=67108863}p.words[S]=C,m=I,I=v}return m!==0?p.words[S]=m:p.length--,p._strip()}function J(A,c,p){return K(A,c,p)}i.prototype.mulTo=function(c,p){var m,v=this.length+c.length;return this.length===10&&c.length===10?m=H(this,c,p):v<63?m=M(this,c,p):v<1024?m=K(this,c,p):m=J(this,c,p),m},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),J(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 m=0,v=0;v<this.length;v++){var S=(this.words[v]|0)*c,I=(S&67108863)+(m&67108863);m>>=26,m+=S/67108864|0,m+=I>>>26,this.words[v]=I&67108863}return m!==0&&(this.words[v]=m,this.length++),this.length=c===0?1: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=N(c);if(p.length===0)return new i(1);for(var m=this,v=0;v<p.length&&p[v]===0;v++,m=m.sqr());if(++v<p.length)for(var S=m.sqr();v<p.length;v++,S=S.sqr())p[v]!==0&&(m=m.mul(S));return m},i.prototype.iushln=function(c){r(typeof c=="number"&&c>=0);var p=c%26,m=(c-p)/26,v=67108863>>>26-p<<26-p,S;if(p!==0){var I=0;for(S=0;S<this.length;S++){var C=this.words[S]&v,R=(this.words[S]|0)-C<<p;this.words[S]=R|I,I=C>>>26-p}I&&(this.words[S]=I,this.length++)}if(m!==0){for(S=this.length-1;S>=0;S--)this.words[S+m]=this.words[S];for(S=0;S<m;S++)this.words[S]=0;this.length+=m}return this._strip()},i.prototype.ishln=function(c){return r(this.negative===0),this.iushln(c)},i.prototype.iushrn=function(c,p,m){r(typeof c=="number"&&c>=0);var v;p?v=(p-p%26)/26:v=0;var S=c%26,I=Math.min((c-S)/26,this.length),C=67108863^67108863>>>S<<S,R=m;if(v-=I,v=Math.max(0,v),R){for(var u=0;u<I;u++)R.words[u]=this.words[u];R.length=I}if(I!==0)if(this.length>I)for(this.length-=I,u=0;u<this.length;u++)this.words[u]=this.words[u+I];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(l!==0||u>=v);u--){var w=this.words[u]|0;this.words[u]=l<<26-S|w>>>S,l=w&C}return R&&l!==0&&(R.words[R.length++]=l),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(c,p,m){return r(this.negative===0),this.iushrn(c,p,m)},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,m=(c-p)/26,v=1<<p;if(this.length<=m)return!1;var S=this.words[m];return!!(S&v)},i.prototype.imaskn=function(c){r(typeof c=="number"&&c>=0);var p=c%26,m=(c-p)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=m)return this;if(p!==0&&m++,this.length=Math.min(m,this.length),p!==0){var v=67108863^67108863>>>p<<p;this.words[this.length-1]&=v}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,m){var v=c.length+m,S;this._expand(v);var I,C=0;for(S=0;S<c.length;S++){I=(this.words[S+m]|0)+C;var R=(c.words[S]|0)*p;I-=R&67108863,C=(I>>26)-(R/67108864|0),this.words[S+m]=I&67108863}for(;S<this.length-m;S++)I=(this.words[S+m]|0)+C,C=I>>26,this.words[S+m]=I&67108863;if(C===0)return this._strip();for(r(C===-1),C=0,S=0;S<this.length;S++)I=-(this.words[S]|0)+C,C=I>>26,this.words[S]=I&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(c,p){var m=this.length-c.length,v=this.clone(),S=c,I=S.words[S.length-1]|0,C=this._countBits(I);m=26-C,m!==0&&(S=S.ushln(m),v.iushln(m),I=S.words[S.length-1]|0);var R=v.length-S.length,u;if(p!=="mod"){u=new i(null),u.length=R+1,u.words=new Array(u.length);for(var l=0;l<u.length;l++)u.words[l]=0}var w=v.clone()._ishlnsubmul(S,1,R);w.negative===0&&(v=w,u&&(u.words[R]=1));for(var E=R-1;E>=0;E--){var P=(v.words[S.length+E]|0)*67108864+(v.words[S.length+E-1]|0);for(P=Math.min(P/I|0,67108863),v._ishlnsubmul(S,P,E);v.negative!==0;)P--,v.negative=0,v._ishlnsubmul(S,1,E),v.isZero()||(v.negative^=1);u&&(u.words[E]=P)}return u&&u._strip(),v._strip(),p!=="div"&&m!==0&&v.iushrn(m),{div:u||null,mod:v}},i.prototype.divmod=function(c,p,m){if(r(!c.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var v,S,I;return this.negative!==0&&c.negative===0?(I=this.neg().divmod(c,p),p!=="mod"&&(v=I.div.neg()),p!=="div"&&(S=I.mod.neg(),m&&S.negative!==0&&S.iadd(c)),{div:v,mod:S}):this.negative===0&&c.negative!==0?(I=this.divmod(c.neg(),p),p!=="mod"&&(v=I.div.neg()),{div:v,mod:I.mod}):(this.negative&c.negative)!==0?(I=this.neg().divmod(c.neg(),p),p!=="div"&&(S=I.mod.neg(),m&&S.negative!==0&&S.isub(c)),{div:I.div,mod:S}):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 m=p.div.negative!==0?p.mod.isub(c):p.mod,v=c.ushrn(1),S=c.andln(1),I=m.cmp(v);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(c){var p=c<0;p&&(c=-c),r(c<=67108863);for(var m=(1<<26)%c,v=0,S=this.length-1;S>=0;S--)v=(m*v+(this.words[S]|0))%c;return p?-v:v},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 m=0,v=this.length-1;v>=0;v--){var S=(this.words[v]|0)+m*67108864;this.words[v]=S/c|0,m=S%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,m=c.clone();p.negative!==0?p=p.umod(c):p=p.clone();for(var v=new i(1),S=new i(0),I=new i(0),C=new i(1),R=0;p.isEven()&&m.isEven();)p.iushrn(1),m.iushrn(1),++R;for(var u=m.clone(),l=p.clone();!p.isZero();){for(var w=0,E=1;(p.words[0]&E)===0&&w<26;++w,E<<=1);if(w>0)for(p.iushrn(w);w-- >0;)(v.isOdd()||S.isOdd())&&(v.iadd(u),S.isub(l)),v.iushrn(1),S.iushrn(1);for(var P=0,G=1;(m.words[0]&G)===0&&P<26;++P,G<<=1);if(P>0)for(m.iushrn(P);P-- >0;)(I.isOdd()||C.isOdd())&&(I.iadd(u),C.isub(l)),I.iushrn(1),C.iushrn(1);p.cmp(m)>=0?(p.isub(m),v.isub(I),S.isub(C)):(m.isub(p),I.isub(v),C.isub(S))}return{a:I,b:C,gcd:m.iushln(R)}},i.prototype._invmp=function(c){r(c.negative===0),r(!c.isZero());var p=this,m=c.clone();p.negative!==0?p=p.umod(c):p=p.clone();for(var v=new i(1),S=new i(0),I=m.clone();p.cmpn(1)>0&&m.cmpn(1)>0;){for(var C=0,R=1;(p.words[0]&R)===0&&C<26;++C,R<<=1);if(C>0)for(p.iushrn(C);C-- >0;)v.isOdd()&&v.iadd(I),v.iushrn(1);for(var u=0,l=1;(m.words[0]&l)===0&&u<26;++u,l<<=1);if(u>0)for(m.iushrn(u);u-- >0;)S.isOdd()&&S.iadd(I),S.iushrn(1);p.cmp(m)>=0?(p.isub(m),v.isub(S)):(m.isub(p),S.isub(v))}var w;return p.cmpn(1)===0?w=v:w=S,w.cmpn(0)<0&&w.iadd(c),w},i.prototype.gcd=function(c){if(this.isZero())return c.abs();if(c.isZero())return this.abs();var p=this.clone(),m=c.clone();p.negative=0,m.negative=0;for(var v=0;p.isEven()&&m.isEven();v++)p.iushrn(1),m.iushrn(1);do{for(;p.isEven();)p.iushrn(1);for(;m.isEven();)m.iushrn(1);var S=p.cmp(m);if(S<0){var I=p;p=m,m=I}else if(S===0||m.cmpn(1)===0)break;p.isub(m)}while(!0);return m.iushln(v)},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,m=(c-p)/26,v=1<<p;if(this.length<=m)return this._expand(m+1),this.words[m]|=v,this;for(var S=v,I=m;S!==0&&I<this.length;I++){var C=this.words[I]|0;C+=S,S=C>>>26,C&=67108863,this.words[I]=C}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(c){var p=c<0;if(this.negative!==0&&!p)return-1;if(this.negative===0&&p)return 1;this._strip();var m;if(this.length>1)m=1;else{p&&(c=-c),r(c<=67108863,"Number is too big");var v=this.words[0]|0;m=v===c?0:v<c?-1:1}return this.negative!==0?-m|0:m},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,m=this.length-1;m>=0;m--){var v=this.words[m]|0,S=c.words[m]|0;if(v!==S){v<S?p=-1:v>S&&(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 q={k256:null,p224:null,p192:null,p25519:null};function D(A,c){this.name=A,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()}D.prototype._tmp=function(){var c=new i(null);return c.words=new Array(Math.ceil(this.n/13)),c},D.prototype.ireduce=function(c){var p=c,m;do this.split(p,this.tmp),p=this.imulK(p),p=p.iadd(this.tmp),m=p.bitLength();while(m>this.n);var v=m<this.n?-1:p.ucmp(this.p);return v===0?(p.words[0]=0,p.length=1):v>0?p.isub(this.p):p.strip!==void 0?p.strip():p._strip(),p},D.prototype.split=function(c,p){c.iushrn(this.n,0,p)},D.prototype.imulK=function(c){return c.imul(this.k)};function Z(){D.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}s(Z,D),Z.prototype.split=function(c,p){for(var m=4194303,v=Math.min(c.length,9),S=0;S<v;S++)p.words[S]=c.words[S];if(p.length=v,c.length<=9){c.words[0]=0,c.length=1;return}var I=c.words[9];for(p.words[p.length++]=I&m,S=10;S<c.length;S++){var C=c.words[S]|0;c.words[S-10]=(C&m)<<4|I>>>22,I=C}I>>>=22,c.words[S-10]=I,I===0&&c.length>10?c.length-=10:c.length-=9},Z.prototype.imulK=function(c){c.words[c.length]=0,c.words[c.length+1]=0,c.length+=2;for(var p=0,m=0;m<c.length;m++){var v=c.words[m]|0;p+=v*977,c.words[m]=p&67108863,p=v*64+(p/67108864|0)}return c.words[c.length-1]===0&&(c.length--,c.words[c.length-1]===0&&c.length--),c};function j(){D.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}s(j,D);function X(){D.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}s(X,D);function z(){D.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}s(z,D),z.prototype.imulK=function(c){for(var p=0,m=0;m<c.length;m++){var v=(c.words[m]|0)*19+p,S=v&67108863;v>>>=26,c.words[m]=S,p=v}return p!==0&&(c.words[c.length++]=p),c},i._prime=function(c){if(q[c])return q[c];var p;if(c==="k256")p=new Z;else if(c==="p224")p=new j;else if(c==="p192")p=new X;else if(c==="p25519")p=new z;else throw new Error("Unknown prime "+c);return q[c]=p,p};function V(A){if(typeof A=="string"){var c=i._prime(A);this.m=c.p,this.prime=c}else r(A.gtn(1),"modulus must be greater than 1"),this.m=A,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):(_(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 m=c.add(p);return m.cmp(this.m)>=0&&m.isub(this.m),m._forceRed(this)},V.prototype.iadd=function(c,p){this._verify2(c,p);var m=c.iadd(p);return m.cmp(this.m)>=0&&m.isub(this.m),m},V.prototype.sub=function(c,p){this._verify2(c,p);var m=c.sub(p);return m.cmpn(0)<0&&m.iadd(this.m),m._forceRed(this)},V.prototype.isub=function(c,p){this._verify2(c,p);var m=c.isub(p);return m.cmpn(0)<0&&m.iadd(this.m),m},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 m=this.m.add(new i(1)).iushrn(2);return this.pow(c,m)}for(var v=this.m.subn(1),S=0;!v.isZero()&&v.andln(1)===0;)S++,v.iushrn(1);r(!v.isZero());var I=new i(1).toRed(this),C=I.redNeg(),R=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new i(2*u*u).toRed(this);this.pow(u,R).cmp(C)!==0;)u.redIAdd(C);for(var l=this.pow(u,v),w=this.pow(c,v.addn(1).iushrn(1)),E=this.pow(c,v),P=S;E.cmp(I)!==0;){for(var G=E,ne=0;G.cmp(I)!==0;ne++)G=G.redSqr();r(ne<P);var ce=this.pow(l,new i(1).iushln(P-ne-1));w=w.redMul(ce),l=ce.redSqr(),E=E.redMul(l),P=ne}return w},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 m=4,v=new Array(1<<m);v[0]=new i(1).toRed(this),v[1]=c;for(var S=2;S<v.length;S++)v[S]=this.mul(v[S-1],c);var I=v[0],C=0,R=0,u=p.bitLength()%26;for(u===0&&(u=26),S=p.length-1;S>=0;S--){for(var l=p.words[S],w=u-1;w>=0;w--){var E=l>>w&1;if(I!==v[0]&&(I=this.sqr(I)),E===0&&C===0){R=0;continue}C<<=1,C|=E,R++,!(R!==m&&(S!==0||w!==0))&&(I=this.mul(I,v[C]),R=0,C=0)}u=26}return I},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(A){V.call(this,A),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 m=c.imul(p),v=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),S=m.isub(v).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(c,p){if(c.isZero()||p.isZero())return new i(0)._forceRed(this);var m=c.mul(p),v=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),S=m.isub(v).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(c){var p=this.imod(c._invmp(this.m).mul(this.r2));return p._forceRed(this)}})(n,Qc)}(ln)),ln.exports}var eu=Js();const Qs=zr(eu);var hn={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var eo;function tu(){return eo||(eo=1,function(n,e){var t=$n(),r=t.Buffer;function s(o,a){for(var f in o)a[f]=o[f]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?n.exports=t:(s(t,e),e.Buffer=i);function i(o,a,f){return r(o,a,f)}i.prototype=Object.create(r.prototype),s(r,i),i.from=function(o,a,f){if(typeof o=="number")throw new TypeError("Argument must not be a number");return r(o,a,f)},i.alloc=function(o,a,f){if(typeof o!="number")throw new TypeError("Argument must be a number");var g=r(o);return a!==void 0?typeof f=="string"?g.fill(a,f):g.fill(a):g.fill(0),g},i.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return r(o)},i.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return t.SlowBuffer(o)}}(hn,hn.exports)),hn.exports}var ri,to;function ru(){if(to)return ri;to=1;var n=tu().Buffer;function e(t){if(t.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<t.length;i++){var o=t.charAt(i),a=o.charCodeAt(0);if(r[a]!==255)throw new TypeError(o+" is ambiguous");r[a]=i}var f=t.length,g=t.charAt(0),_=Math.log(f)/Math.log(256),b=Math.log(256)/Math.log(f);function x(k){if((Array.isArray(k)||k instanceof Uint8Array)&&(k=n.from(k)),!n.isBuffer(k))throw new TypeError("Expected Buffer");if(k.length===0)return"";for(var N=0,M=0,H=0,K=k.length;H!==K&&k[H]===0;)H++,N++;for(var J=(K-H)*b+1>>>0,q=new Uint8Array(J);H!==K;){for(var D=k[H],Z=0,j=J-1;(D!==0||Z<M)&&j!==-1;j--,Z++)D+=256*q[j]>>>0,q[j]=D%f>>>0,D=D/f>>>0;if(D!==0)throw new Error("Non-zero carry");M=Z,H++}for(var X=J-M;X!==J&&q[X]===0;)X++;for(var z=g.repeat(N);X<J;++X)z+=t.charAt(q[X]);return z}function T(k){if(typeof k!="string")throw new TypeError("Expected String");if(k.length===0)return n.alloc(0);for(var N=0,M=0,H=0;k[N]===g;)M++,N++;for(var K=(k.length-N)*_+1>>>0,J=new Uint8Array(K);N<k.length;){var q=k.charCodeAt(N);if(q>255)return;var D=r[q];if(D===255)return;for(var Z=0,j=K-1;(D!==0||Z<H)&&j!==-1;j--,Z++)D+=f*J[j]>>>0,J[j]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");H=Z,N++}for(var X=K-H;X!==K&&J[X]===0;)X++;var z=n.allocUnsafe(M+(K-X));z.fill(0,0,M);for(var V=M;X!==K;)z[V++]=J[X++];return z}function L(k){var N=T(k);if(N)return N;throw new Error("Non-base"+f+" character")}return{encode:x,decodeUnsafe:T,decode:L}}return ri=e,ri}var ni,ro;function no(){if(ro)return ni;ro=1;var n=ru(),e="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";return ni=n(e),ni}var nu=no();const gt=zr(nu),iu=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]),er=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),tr=new Uint32Array(64);class su extends Ns{constructor(){super(64,32,8,!1),this.A=er[0]|0,this.B=er[1]|0,this.C=er[2]|0,this.D=er[3]|0,this.E=er[4]|0,this.F=er[5]|0,this.G=er[6]|0,this.H=er[7]|0}get(){const{A:e,B:t,C:r,D:s,E:i,F:o,G:a,H:f}=this;return[e,t,r,s,i,o,a,f]}set(e,t,r,s,i,o,a,f){this.A=e|0,this.B=t|0,this.C=r|0,this.D=s|0,this.E=i|0,this.F=o|0,this.G=a|0,this.H=f|0}process(e,t){for(let b=0;b<16;b++,t+=4)tr[b]=e.getUint32(t,!1);for(let b=16;b<64;b++){const x=tr[b-15],T=tr[b-2],L=Ct(x,7)^Ct(x,18)^x>>>3,k=Ct(T,17)^Ct(T,19)^T>>>10;tr[b]=k+tr[b-7]+L+tr[b-16]|0}let{A:r,B:s,C:i,D:o,E:a,F:f,G:g,H:_}=this;for(let b=0;b<64;b++){const x=Ct(a,6)^Ct(a,11)^Ct(a,25),T=_+x+nc(a,f,g)+iu[b]+tr[b]|0,k=(Ct(r,2)^Ct(r,13)^Ct(r,22))+ic(r,s,i)|0;_=g,g=f,f=a,a=o+T|0,o=i,i=s,s=r,r=T+k|0}r=r+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,f=f+this.F|0,g=g+this.G|0,_=_+this.H|0,this.set(r,s,i,o,a,f,g,_)}roundClean(){tr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const ii=Vn(()=>new su);var xe={};function Gt(n,e,t){return e<=n&&n<=t}function fn(n){if(n===void 0)return{};if(n===Object(n))return n;throw TypeError("Could not convert argument to dictionary")}function ou(n){for(var e=String(n),t=e.length,r=0,s=[];r<t;){var i=e.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===t-1)s.push(65533);else{var o=n.charCodeAt(r+1);if(56320<=o&&o<=57343){var a=i&1023,f=o&1023;s.push(65536+(a<<10)+f),r+=1}else s.push(65533)}r+=1}return s}function au(n){for(var e="",t=0;t<n.length;++t){var r=n[t];r<=65535?e+=String.fromCharCode(r):(r-=65536,e+=String.fromCharCode((r>>10)+55296,(r&1023)+56320))}return e}var dn=-1;function si(n){this.tokens=[].slice.call(n)}si.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():dn},prepend:function(n){if(Array.isArray(n))for(var e=n;e.length;)this.tokens.unshift(e.pop());else this.tokens.unshift(n)},push:function(n){if(Array.isArray(n))for(var e=n;e.length;)this.tokens.push(e.shift());else this.tokens.push(n)}};var Or=-1;function oi(n,e){if(n)throw TypeError("Decoder error");return e||65533}var pn="utf-8";function gn(n,e){if(!(this instanceof gn))return new gn(n,e);if(n=n!==void 0?String(n).toLowerCase():pn,n!==pn)throw new Error("Encoding not supported. Only utf-8 is supported");e=fn(e),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!e.fatal,this._ignoreBOM=!!e.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}gn.prototype={decode:function(e,t){var r;typeof e=="object"&&e instanceof ArrayBuffer?r=new Uint8Array(e):typeof e=="object"&&"buffer"in e&&e.buffer instanceof ArrayBuffer?r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):r=new Uint8Array(0),t=fn(t),this._streaming||(this._decoder=new cu({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!t.stream;for(var s=new si(r),i=[],o;!s.endOfStream()&&(o=this._decoder.handler(s,s.read()),o!==Or);)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===Or)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),au(i)}};function mn(n,e){if(!(this instanceof mn))return new mn(n,e);if(n=n!==void 0?String(n).toLowerCase():pn,n!==pn)throw new Error("Encoding not supported. Only utf-8 is supported");e=fn(e),this._streaming=!1,this._encoder=null,this._options={fatal:!!e.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}mn.prototype={encode:function(e,t){e=e?String(e):"",t=fn(t),this._streaming||(this._encoder=new uu(this._options)),this._streaming=!!t.stream;for(var r=[],s=new si(ou(e)),i;!s.endOfStream()&&(i=this._encoder.handler(s,s.read()),i!==Or);)Array.isArray(i)?r.push.apply(r,i):r.push(i);if(!this._streaming){for(;i=this._encoder.handler(s,s.read()),i!==Or;)Array.isArray(i)?r.push.apply(r,i):r.push(i);this._encoder=null}return new Uint8Array(r)}};function cu(n){var e=n.fatal,t=0,r=0,s=0,i=128,o=191;this.handler=function(a,f){if(f===dn&&s!==0)return s=0,oi(e);if(f===dn)return Or;if(s===0){if(Gt(f,0,127))return f;if(Gt(f,194,223))s=1,t=f-192;else if(Gt(f,224,239))f===224&&(i=160),f===237&&(o=159),s=2,t=f-224;else if(Gt(f,240,244))f===240&&(i=144),f===244&&(o=143),s=3,t=f-240;else return oi(e);return t=t<<6*s,null}if(!Gt(f,i,o))return t=s=r=0,i=128,o=191,a.prepend(f),oi(e);if(i=128,o=191,r+=1,t+=f-128<<6*(s-r),r!==s)return null;var g=t;return t=s=r=0,g}}function uu(n){n.fatal,this.handler=function(e,t){if(t===dn)return Or;if(Gt(t,0,127))return t;var r,s;Gt(t,128,2047)?(r=1,s=192):Gt(t,2048,65535)?(r=2,s=224):Gt(t,65536,1114111)&&(r=3,s=240);for(var i=[(t>>6*r)+s];r>0;){var o=t>>6*(r-1);i.push(128|o&63),r-=1}return i}}const lu=zn(Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:gn,TextEncoder:mn},Symbol.toStringTag,{value:"Module"})));var io;function hu(){if(io)return xe;io=1;var n=xe&&xe.__createBinding||(Object.create?function(X,z,V,Q){Q===void 0&&(Q=V),Object.defineProperty(X,Q,{enumerable:!0,get:function(){return z[V]}})}:function(X,z,V,Q){Q===void 0&&(Q=V),X[Q]=z[V]}),e=xe&&xe.__setModuleDefault||(Object.create?function(X,z){Object.defineProperty(X,"default",{enumerable:!0,value:z})}:function(X,z){X.default=z}),t=xe&&xe.__decorate||function(X,z,V,Q){var A=arguments.length,c=A<3?z:Q===null?Q=Object.getOwnPropertyDescriptor(z,V):Q,p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")c=Reflect.decorate(X,z,V,Q);else for(var m=X.length-1;m>=0;m--)(p=X[m])&&(c=(A<3?p(c):A>3?p(z,V,c):p(z,V))||c);return A>3&&c&&Object.defineProperty(z,V,c),c},r=xe&&xe.__importStar||function(X){if(X&&X.__esModule)return X;var z={};if(X!=null)for(var V in X)V!=="default"&&Object.hasOwnProperty.call(X,V)&&n(z,X,V);return e(z,X),z},s=xe&&xe.__importDefault||function(X){return X&&X.__esModule?X:{default:X}};Object.defineProperty(xe,"__esModule",{value:!0}),xe.deserializeUnchecked=xe.deserialize=xe.serialize=xe.BinaryReader=xe.BinaryWriter=xe.BorshError=xe.baseDecode=xe.baseEncode=void 0;const i=s(Js()),o=s(no()),a=r(lu),f=typeof TextDecoder!="function"?a.TextDecoder:TextDecoder,g=new f("utf-8",{fatal:!0});function _(X){return typeof X=="string"&&(X=Buffer.from(X,"utf8")),o.default.encode(Buffer.from(X))}xe.baseEncode=_;function b(X){return Buffer.from(o.default.decode(X))}xe.baseDecode=b;const x=1024;class T extends Error{constructor(z){super(z),this.fieldPath=[],this.originalMessage=z}addToFieldPath(z){this.fieldPath.splice(0,0,z),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}xe.BorshError=T;class L{constructor(){this.buf=Buffer.alloc(x),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(x)]))}writeU8(z){this.maybeResize(),this.buf.writeUInt8(z,this.length),this.length+=1}writeU16(z){this.maybeResize(),this.buf.writeUInt16LE(z,this.length),this.length+=2}writeU32(z){this.maybeResize(),this.buf.writeUInt32LE(z,this.length),this.length+=4}writeU64(z){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(z).toArray("le",8)))}writeU128(z){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(z).toArray("le",16)))}writeU256(z){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(z).toArray("le",32)))}writeU512(z){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(z).toArray("le",64)))}writeBuffer(z){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),z,Buffer.alloc(x)]),this.length+=z.length}writeString(z){this.maybeResize();const V=Buffer.from(z,"utf8");this.writeU32(V.length),this.writeBuffer(V)}writeFixedArray(z){this.writeBuffer(Buffer.from(z))}writeArray(z,V){this.maybeResize(),this.writeU32(z.length);for(const Q of z)this.maybeResize(),V(Q)}toArray(){return this.buf.subarray(0,this.length)}}xe.BinaryWriter=L;function k(X,z,V){const Q=V.value;V.value=function(...A){try{return Q.apply(this,A)}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 T("Reached the end of buffer when deserializing")}throw c}}}class N{constructor(z){this.buf=z,this.offset=0}readU8(){const z=this.buf.readUInt8(this.offset);return this.offset+=1,z}readU16(){const z=this.buf.readUInt16LE(this.offset);return this.offset+=2,z}readU32(){const z=this.buf.readUInt32LE(this.offset);return this.offset+=4,z}readU64(){const z=this.readBuffer(8);return new i.default(z,"le")}readU128(){const z=this.readBuffer(16);return new i.default(z,"le")}readU256(){const z=this.readBuffer(32);return new i.default(z,"le")}readU512(){const z=this.readBuffer(64);return new i.default(z,"le")}readBuffer(z){if(this.offset+z>this.buf.length)throw new T(`Expected buffer length ${z} isn't within bounds`);const V=this.buf.slice(this.offset,this.offset+z);return this.offset+=z,V}readString(){const z=this.readU32(),V=this.readBuffer(z);try{return g.decode(V)}catch(Q){throw new T(`Error decoding UTF-8 string: ${Q}`)}}readFixedArray(z){return new Uint8Array(this.readBuffer(z))}readArray(z){const V=this.readU32(),Q=Array();for(let A=0;A<V;++A)Q.push(z());return Q}}t([k],N.prototype,"readU8",null),t([k],N.prototype,"readU16",null),t([k],N.prototype,"readU32",null),t([k],N.prototype,"readU64",null),t([k],N.prototype,"readU128",null),t([k],N.prototype,"readU256",null),t([k],N.prototype,"readU512",null),t([k],N.prototype,"readString",null),t([k],N.prototype,"readFixedArray",null),t([k],N.prototype,"readArray",null),xe.BinaryReader=N;function M(X){return X.charAt(0).toUpperCase()+X.slice(1)}function H(X,z,V,Q,A){try{if(typeof Q=="string")A[`write${M(Q)}`](V);else if(Q instanceof Array)if(typeof Q[0]=="number"){if(V.length!==Q[0])throw new T(`Expecting byte array of length ${Q[0]}, but got ${V.length} bytes`);A.writeFixedArray(V)}else if(Q.length===2&&typeof Q[1]=="number"){if(V.length!==Q[1])throw new T(`Expecting byte array of length ${Q[1]}, but got ${V.length} bytes`);for(let c=0;c<Q[1];c++)H(X,null,V[c],Q[0],A)}else A.writeArray(V,c=>{H(X,z,c,Q[0],A)});else if(Q.kind!==void 0)switch(Q.kind){case"option":{V==null?A.writeU8(0):(A.writeU8(1),H(X,z,V,Q.type,A));break}case"map":{A.writeU32(V.size),V.forEach((c,p)=>{H(X,z,p,Q.key,A),H(X,z,c,Q.value,A)});break}default:throw new T(`FieldType ${Q} unrecognized`)}else K(X,V,A)}catch(c){throw c instanceof T&&c.addToFieldPath(z),c}}function K(X,z,V){if(typeof z.borshSerialize=="function"){z.borshSerialize(V);return}const Q=X.get(z.constructor);if(!Q)throw new T(`Class ${z.constructor.name} is missing in schema`);if(Q.kind==="struct")Q.fields.map(([A,c])=>{H(X,A,z[A],c,V)});else if(Q.kind==="enum"){const A=z[Q.field];for(let c=0;c<Q.values.length;++c){const[p,m]=Q.values[c];if(p===A){V.writeU8(c),H(X,p,z[p],m,V);break}}}else throw new T(`Unexpected schema kind: ${Q.kind} for ${z.constructor.name}`)}function J(X,z,V=L){const Q=new V;return K(X,z,Q),Q.toArray()}xe.serialize=J;function q(X,z,V,Q){try{if(typeof V=="string")return Q[`read${M(V)}`]();if(V instanceof Array){if(typeof V[0]=="number")return Q.readFixedArray(V[0]);if(typeof V[1]=="number"){const A=[];for(let c=0;c<V[1];c++)A.push(q(X,null,V[0],Q));return A}else return Q.readArray(()=>q(X,z,V[0],Q))}if(V.kind==="option")return Q.readU8()?q(X,z,V.type,Q):void 0;if(V.kind==="map"){let A=new Map;const c=Q.readU32();for(let p=0;p<c;p++){const m=q(X,z,V.key,Q),v=q(X,z,V.value,Q);A.set(m,v)}return A}return D(X,V,Q)}catch(A){throw A instanceof T&&A.addToFieldPath(z),A}}function D(X,z,V){if(typeof z.borshDeserialize=="function")return z.borshDeserialize(V);const Q=X.get(z);if(!Q)throw new T(`Class ${z.name} is missing in schema`);if(Q.kind==="struct"){const A={};for(const[c,p]of X.get(z).fields)A[c]=q(X,c,p,V);return new z(A)}if(Q.kind==="enum"){const A=V.readU8();if(A>=Q.values.length)throw new T(`Enum index: ${A} is out of range`);const[c,p]=Q.values[A],m=q(X,c,p,V);return new z({[c]:m})}throw new T(`Unexpected schema kind: ${Q.kind} for ${z.constructor.name}`)}function Z(X,z,V,Q=N){const A=new Q(V),c=D(X,z,A);if(A.offset<V.length)throw new T(`Unexpected ${V.length-A.offset} bytes after deserialized data`);return c}xe.deserialize=Z;function j(X,z,V,Q=N){const A=new Q(V);return D(X,z,A)}return xe.deserializeUnchecked=j,xe}var ai=hu(),W={},so;function fu(){if(so)return W;so=1,Object.defineProperty(W,"__esModule",{value:!0}),W.s16=W.s8=W.nu64be=W.u48be=W.u40be=W.u32be=W.u24be=W.u16be=W.nu64=W.u48=W.u40=W.u32=W.u24=W.u16=W.u8=W.offset=W.greedy=W.Constant=W.UTF8=W.CString=W.Blob=W.Boolean=W.BitField=W.BitStructure=W.VariantLayout=W.Union=W.UnionLayoutDiscriminator=W.UnionDiscriminator=W.Structure=W.Sequence=W.DoubleBE=W.Double=W.FloatBE=W.Float=W.NearInt64BE=W.NearInt64=W.NearUInt64BE=W.NearUInt64=W.IntBE=W.Int=W.UIntBE=W.UInt=W.OffsetLayout=W.GreedyCount=W.ExternalLayout=W.bindConstructorLayout=W.nameWithProperty=W.Layout=W.uint8ArrayToBuffer=W.checkUint8Array=void 0,W.constant=W.utf8=W.cstr=W.blob=W.unionLayoutDiscriminator=W.union=W.seq=W.bits=W.struct=W.f64be=W.f64=W.f32be=W.f32=W.ns64be=W.s48be=W.s40be=W.s32be=W.s24be=W.s16be=W.ns64=W.s48=W.s40=W.s32=W.s24=void 0;const n=$n();function e(u){if(!(u instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}W.checkUint8Array=e;function t(u){return e(u),n.Buffer.from(u.buffer,u.byteOffset,u.length)}W.uint8ArrayToBuffer=t;let r=class{constructor(l,w){if(!Number.isInteger(l))throw new TypeError("span must be an integer");this.span=l,this.property=w}makeDestinationObject(){return{}}getSpan(l,w){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(l){const w=Object.create(this.constructor.prototype);return Object.assign(w,this),w.property=l,w}fromArray(l){}};W.Layout=r;function s(u,l){return l.property?u+"["+l.property+"]":u}W.nameWithProperty=s;function i(u,l){if(typeof u!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(u,"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");u.layout_=l,l.boundConstructor_=u,l.makeDestinationObject=()=>new u,Object.defineProperty(u.prototype,"encode",{value(w,E){return l.encode(this,w,E)},writable:!0}),Object.defineProperty(u,"decode",{value(w,E){return l.decode(w,E)},writable:!0})}W.bindConstructorLayout=i;class o extends r{isCount(){throw new Error("ExternalLayout is abstract")}}W.ExternalLayout=o;class a extends o{constructor(l=1,w){if(!Number.isInteger(l)||0>=l)throw new TypeError("elementSpan must be a (positive) integer");super(-1,w),this.elementSpan=l}isCount(){return!0}decode(l,w=0){e(l);const E=l.length-w;return Math.floor(E/this.elementSpan)}encode(l,w,E){return 0}}W.GreedyCount=a;class f extends o{constructor(l,w=0,E){if(!(l instanceof r))throw new TypeError("layout must be a Layout");if(!Number.isInteger(w))throw new TypeError("offset must be integer or undefined");super(l.span,E||l.property),this.layout=l,this.offset=w}isCount(){return this.layout instanceof g||this.layout instanceof _}decode(l,w=0){return this.layout.decode(l,w+this.offset)}encode(l,w,E=0){return this.layout.encode(l,w,E+this.offset)}}W.OffsetLayout=f;class g extends r{constructor(l,w){if(super(l,w),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,w=0){return t(l).readUIntLE(w,this.span)}encode(l,w,E=0){return t(w).writeUIntLE(l,E,this.span),this.span}}W.UInt=g;class _ extends r{constructor(l,w){if(super(l,w),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,w=0){return t(l).readUIntBE(w,this.span)}encode(l,w,E=0){return t(w).writeUIntBE(l,E,this.span),this.span}}W.UIntBE=_;class b extends r{constructor(l,w){if(super(l,w),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,w=0){return t(l).readIntLE(w,this.span)}encode(l,w,E=0){return t(w).writeIntLE(l,E,this.span),this.span}}W.Int=b;class x extends r{constructor(l,w){if(super(l,w),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,w=0){return t(l).readIntBE(w,this.span)}encode(l,w,E=0){return t(w).writeIntBE(l,E,this.span),this.span}}W.IntBE=x;const T=Math.pow(2,32);function L(u){const l=Math.floor(u/T),w=u-l*T;return{hi32:l,lo32:w}}function k(u,l){return u*T+l}class N extends r{constructor(l){super(8,l)}decode(l,w=0){const E=t(l),P=E.readUInt32LE(w),G=E.readUInt32LE(w+4);return k(G,P)}encode(l,w,E=0){const P=L(l),G=t(w);return G.writeUInt32LE(P.lo32,E),G.writeUInt32LE(P.hi32,E+4),8}}W.NearUInt64=N;class M extends r{constructor(l){super(8,l)}decode(l,w=0){const E=t(l),P=E.readUInt32BE(w),G=E.readUInt32BE(w+4);return k(P,G)}encode(l,w,E=0){const P=L(l),G=t(w);return G.writeUInt32BE(P.hi32,E),G.writeUInt32BE(P.lo32,E+4),8}}W.NearUInt64BE=M;class H extends r{constructor(l){super(8,l)}decode(l,w=0){const E=t(l),P=E.readUInt32LE(w),G=E.readInt32LE(w+4);return k(G,P)}encode(l,w,E=0){const P=L(l),G=t(w);return G.writeUInt32LE(P.lo32,E),G.writeInt32LE(P.hi32,E+4),8}}W.NearInt64=H;class K extends r{constructor(l){super(8,l)}decode(l,w=0){const E=t(l),P=E.readInt32BE(w),G=E.readUInt32BE(w+4);return k(P,G)}encode(l,w,E=0){const P=L(l),G=t(w);return G.writeInt32BE(P.hi32,E),G.writeUInt32BE(P.lo32,E+4),8}}W.NearInt64BE=K;class J extends r{constructor(l){super(4,l)}decode(l,w=0){return t(l).readFloatLE(w)}encode(l,w,E=0){return t(w).writeFloatLE(l,E),4}}W.Float=J;class q extends r{constructor(l){super(4,l)}decode(l,w=0){return t(l).readFloatBE(w)}encode(l,w,E=0){return t(w).writeFloatBE(l,E),4}}W.FloatBE=q;class D extends r{constructor(l){super(8,l)}decode(l,w=0){return t(l).readDoubleLE(w)}encode(l,w,E=0){return t(w).writeDoubleLE(l,E),8}}W.Double=D;class Z extends r{constructor(l){super(8,l)}decode(l,w=0){return t(l).readDoubleBE(w)}encode(l,w,E=0){return t(w).writeDoubleBE(l,E),8}}W.DoubleBE=Z;class j extends r{constructor(l,w,E){if(!(l instanceof r))throw new TypeError("elementLayout must be a Layout");if(!(w instanceof o&&w.isCount()||Number.isInteger(w)&&0<=w))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let P=-1;!(w instanceof o)&&0<l.span&&(P=w*l.span),super(P,E),this.elementLayout=l,this.count=w}getSpan(l,w=0){if(0<=this.span)return this.span;let E=0,P=this.count;if(P instanceof o&&(P=P.decode(l,w)),0<this.elementLayout.span)E=P*this.elementLayout.span;else{let G=0;for(;G<P;)E+=this.elementLayout.getSpan(l,w+E),++G}return E}decode(l,w=0){const E=[];let P=0,G=this.count;for(G instanceof o&&(G=G.decode(l,w));P<G;)E.push(this.elementLayout.decode(l,w)),w+=this.elementLayout.getSpan(l,w),P+=1;return E}encode(l,w,E=0){const P=this.elementLayout,G=l.reduce((ne,ce)=>ne+P.encode(ce,w,E+ne),0);return this.count instanceof o&&this.count.encode(l.length,w,E),G}}W.Sequence=j;class X extends r{constructor(l,w,E){if(!(Array.isArray(l)&&l.reduce((G,ne)=>G&&ne instanceof r,!0)))throw new TypeError("fields must be array of Layout instances");typeof w=="boolean"&&E===void 0&&(E=w,w=void 0);for(const G of l)if(0>G.span&&G.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let P=-1;try{P=l.reduce((G,ne)=>G+ne.getSpan(),0)}catch{}super(P,w),this.fields=l,this.decodePrefixes=!!E}getSpan(l,w=0){if(0<=this.span)return this.span;let E=0;try{E=this.fields.reduce((P,G)=>{const ne=G.getSpan(l,w);return w+=ne,P+ne},0)}catch{throw new RangeError("indeterminate span")}return E}decode(l,w=0){e(l);const E=this.makeDestinationObject();for(const P of this.fields)if(P.property!==void 0&&(E[P.property]=P.decode(l,w)),w+=P.getSpan(l,w),this.decodePrefixes&&l.length===w)break;return E}encode(l,w,E=0){const P=E;let G=0,ne=0;for(const ce of this.fields){let ve=ce.span;if(ne=0<ve?ve:0,ce.property!==void 0){const ge=l[ce.property];ge!==void 0&&(ne=ce.encode(ge,w,E),0>ve&&(ve=ce.getSpan(w,E)))}G=E,E+=ve}return G+ne-P}fromArray(l){const w=this.makeDestinationObject();for(const E of this.fields)E.property!==void 0&&0<l.length&&(w[E.property]=l.shift());return w}layoutFor(l){if(typeof l!="string")throw new TypeError("property must be string");for(const w of this.fields)if(w.property===l)return w}offsetOf(l){if(typeof l!="string")throw new TypeError("property must be string");let w=0;for(const E of this.fields){if(E.property===l)return w;0>E.span?w=-1:0<=w&&(w+=E.span)}}}W.Structure=X;class z{constructor(l){this.property=l}decode(l,w){throw new Error("UnionDiscriminator is abstract")}encode(l,w,E){throw new Error("UnionDiscriminator is abstract")}}W.UnionDiscriminator=z;class V extends z{constructor(l,w){if(!(l instanceof o&&l.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(w||l.property||"variant"),this.layout=l}decode(l,w){return this.layout.decode(l,w)}encode(l,w,E){return this.layout.encode(l,w,E)}}W.UnionLayoutDiscriminator=V;class Q extends r{constructor(l,w,E){let P;if(l instanceof g||l instanceof _)P=new V(new f(l));else if(l instanceof o&&l.isCount())P=new V(l);else if(l instanceof z)P=l;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(w===void 0&&(w=null),!(w===null||w instanceof r))throw new TypeError("defaultLayout must be null or a Layout");if(w!==null){if(0>w.span)throw new Error("defaultLayout must have constant span");w.property===void 0&&(w=w.replicate("content"))}let G=-1;w&&(G=w.span,0<=G&&(l instanceof g||l instanceof _)&&(G+=P.layout.span)),super(G,E),this.discriminator=P,this.usesPrefixDiscriminator=l instanceof g||l instanceof _,this.defaultLayout=w,this.registry={};let ne=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(ce){return ne(ce)},this.configGetSourceVariant=function(ce){ne=ce.bind(this)}}getSpan(l,w=0){if(0<=this.span)return this.span;const E=this.getVariant(l,w);if(!E)throw new Error("unable to determine span for unrecognized variant");return E.getSpan(l,w)}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 w=this.registry[l[this.discriminator.property]];if(w&&(!w.layout||w.property&&Object.prototype.hasOwnProperty.call(l,w.property)))return w}else for(const w in this.registry){const E=this.registry[w];if(E.property&&Object.prototype.hasOwnProperty.call(l,E.property))return E}throw new Error("unable to infer src variant")}decode(l,w=0){let E;const P=this.discriminator,G=P.decode(l,w),ne=this.registry[G];if(ne===void 0){const ce=this.defaultLayout;let ve=0;this.usesPrefixDiscriminator&&(ve=P.layout.span),E=this.makeDestinationObject(),E[P.property]=G,E[ce.property]=ce.decode(l,w+ve)}else E=ne.decode(l,w);return E}encode(l,w,E=0){const P=this.getSourceVariant(l);if(P===void 0){const G=this.discriminator,ne=this.defaultLayout;let ce=0;return this.usesPrefixDiscriminator&&(ce=G.layout.span),G.encode(l[G.property],w,E),ce+ne.encode(l[ne.property],w,E+ce)}return P.encode(l,w,E)}addVariant(l,w,E){const P=new A(this,l,w,E);return this.registry[l]=P,P}getVariant(l,w=0){let E;return l instanceof Uint8Array?E=this.discriminator.decode(l,w):E=l,this.registry[E]}}W.Union=Q;class A extends r{constructor(l,w,E,P){if(!(l instanceof Q))throw new TypeError("union must be a Union");if(!Number.isInteger(w)||0>w)throw new TypeError("variant must be a (non-negative) integer");if(typeof E=="string"&&P===void 0&&(P=E,E=null),E){if(!(E instanceof r))throw new TypeError("layout must be a Layout");if(l.defaultLayout!==null&&0<=E.span&&E.span>l.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof P!="string")throw new TypeError("variant must have a String property")}let G=l.span;0>l.span&&(G=E?E.span:0,0<=G&&l.usesPrefixDiscriminator&&(G+=l.discriminator.layout.span)),super(G,P),this.union=l,this.variant=w,this.layout=E||null}getSpan(l,w=0){if(0<=this.span)return this.span;let E=0;this.union.usesPrefixDiscriminator&&(E=this.union.discriminator.layout.span);let P=0;return this.layout&&(P=this.layout.getSpan(l,w+E)),E+P}decode(l,w=0){const E=this.makeDestinationObject();if(this!==this.union.getVariant(l,w))throw new Error("variant mismatch");let P=0;return this.union.usesPrefixDiscriminator&&(P=this.union.discriminator.layout.span),this.layout?E[this.property]=this.layout.decode(l,w+P):this.property?E[this.property]=!0:this.union.usesPrefixDiscriminator&&(E[this.union.discriminator.property]=this.variant),E}encode(l,w,E=0){let P=0;if(this.union.usesPrefixDiscriminator&&(P=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,w,E);let G=P;if(this.layout&&(this.layout.encode(l[this.property],w,E+P),G+=this.layout.getSpan(w,E+P),0<=this.union.span&&G>this.union.span))throw new Error("encoded variant overruns containing union");return G}fromArray(l){if(this.layout)return this.layout.fromArray(l)}}W.VariantLayout=A;function c(u){return 0>u&&(u+=4294967296),u}class p extends r{constructor(l,w,E){if(!(l instanceof g||l instanceof _))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof w=="string"&&E===void 0&&(E=w,w=!1),4<l.span)throw new RangeError("word cannot exceed 32 bits");super(l.span,E),this.word=l,this.msb=!!w,this.fields=[];let P=0;this._packedSetValue=function(G){return P=c(G),this},this._packedGetValue=function(){return P}}decode(l,w=0){const E=this.makeDestinationObject(),P=this.word.decode(l,w);this._packedSetValue(P);for(const G of this.fields)G.property!==void 0&&(E[G.property]=G.decode(l));return E}encode(l,w,E=0){const P=this.word.decode(w,E);this._packedSetValue(P);for(const G of this.fields)if(G.property!==void 0){const ne=l[G.property];ne!==void 0&&G.encode(ne)}return this.word.encode(this._packedGetValue(),w,E)}addField(l,w){const E=new m(this,l,w);return this.fields.push(E),E}addBoolean(l){const w=new v(this,l);return this.fields.push(w),w}fieldFor(l){if(typeof l!="string")throw new TypeError("property must be string");for(const w of this.fields)if(w.property===l)return w}}W.BitStructure=p;class m{constructor(l,w,E){if(!(l instanceof p))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(w)||0>=w)throw new TypeError("bits must be positive integer");const P=8*l.span,G=l.fields.reduce((ne,ce)=>ne+ce.bits,0);if(w+G>P)throw new Error("bits too long for span remainder ("+(P-G)+" of "+P+" remain)");this.container=l,this.bits=w,this.valueMask=(1<<w)-1,w===32&&(this.valueMask=4294967295),this.start=G,this.container.msb&&(this.start=P-G-w),this.wordMask=c(this.valueMask<<this.start),this.property=E}decode(l,w){const E=this.container._packedGetValue();return c(E&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 w=this.container._packedGetValue(),E=c(l<<this.start);this.container._packedSetValue(c(w&~this.wordMask)|E)}}W.BitField=m;class v extends m{constructor(l,w){super(l,1,w)}decode(l,w){return!!super.decode(l,w)}encode(l){typeof l=="boolean"&&(l=+l),super.encode(l)}}W.Boolean=v;class S extends r{constructor(l,w){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 E=-1;l instanceof o||(E=l),super(E,w),this.length=l}getSpan(l,w){let E=this.span;return 0>E&&(E=this.length.decode(l,w)),E}decode(l,w=0){let E=this.span;return 0>E&&(E=this.length.decode(l,w)),t(l).slice(w,w+E)}encode(l,w,E){let P=this.length;if(this.length instanceof o&&(P=l.length),!(l instanceof Uint8Array&&P===l.length))throw new TypeError(s("Blob.encode",this)+" requires (length "+P+") Uint8Array as src");if(E+P>w.length)throw new RangeError("encoding overruns Uint8Array");const G=t(l);return t(w).write(G.toString("hex"),E,P,"hex"),this.length instanceof o&&this.length.encode(P,w,E),P}}W.Blob=S;class I extends r{constructor(l){super(-1,l)}getSpan(l,w=0){e(l);let E=w;for(;E<l.length&&l[E]!==0;)E+=1;return 1+E-w}decode(l,w=0){const E=this.getSpan(l,w);return t(l).slice(w,w+E-1).toString("utf-8")}encode(l,w,E=0){typeof l!="string"&&(l=String(l));const P=n.Buffer.from(l,"utf8"),G=P.length;if(E+G>w.length)throw new RangeError("encoding overruns Buffer");const ne=t(w);return P.copy(ne,E),ne[E+G]=0,G+1}}W.CString=I;class C extends r{constructor(l,w){if(typeof l=="string"&&w===void 0&&(w=l,l=void 0),l===void 0)l=-1;else if(!Number.isInteger(l))throw new TypeError("maxSpan must be an integer");super(-1,w),this.maxSpan=l}getSpan(l,w=0){return e(l),l.length-w}decode(l,w=0){const E=this.getSpan(l,w);if(0<=this.maxSpan&&this.maxSpan<E)throw new RangeError("text length exceeds maxSpan");return t(l).slice(w,w+E).toString("utf-8")}encode(l,w,E=0){typeof l!="string"&&(l=String(l));const P=n.Buffer.from(l,"utf8"),G=P.length;if(0<=this.maxSpan&&this.maxSpan<G)throw new RangeError("text length exceeds maxSpan");if(E+G>w.length)throw new RangeError("encoding overruns Buffer");return P.copy(t(w),E),G}}W.UTF8=C;class R extends r{constructor(l,w){super(0,w),this.value=l}decode(l,w){return this.value}encode(l,w,E){return 0}}return W.Constant=R,W.greedy=(u,l)=>new a(u,l),W.offset=(u,l,w)=>new f(u,l,w),W.u8=u=>new g(1,u),W.u16=u=>new g(2,u),W.u24=u=>new g(3,u),W.u32=u=>new g(4,u),W.u40=u=>new g(5,u),W.u48=u=>new g(6,u),W.nu64=u=>new N(u),W.u16be=u=>new _(2,u),W.u24be=u=>new _(3,u),W.u32be=u=>new _(4,u),W.u40be=u=>new _(5,u),W.u48be=u=>new _(6,u),W.nu64be=u=>new M(u),W.s8=u=>new b(1,u),W.s16=u=>new b(2,u),W.s24=u=>new b(3,u),W.s32=u=>new b(4,u),W.s40=u=>new b(5,u),W.s48=u=>new b(6,u),W.ns64=u=>new H(u),W.s16be=u=>new x(2,u),W.s24be=u=>new x(3,u),W.s32be=u=>new x(4,u),W.s40be=u=>new x(5,u),W.s48be=u=>new x(6,u),W.ns64be=u=>new K(u),W.f32=u=>new J(u),W.f32be=u=>new q(u),W.f64=u=>new D(u),W.f64be=u=>new Z(u),W.struct=(u,l,w)=>new X(u,l,w),W.bits=(u,l,w)=>new p(u,l,w),W.seq=(u,l,w)=>new j(u,l,w),W.union=(u,l,w)=>new Q(u,l,w),W.unionLayoutDiscriminator=(u,l)=>new V(u,l),W.blob=(u,l)=>new S(u,l),W.cstr=u=>new I(u),W.utf8=(u,l)=>new C(u,l),W.constant=(u,l)=>new R(u,l),W}var B=fu(),du=1,pu=2,gu=3,mu=4,yu=5,_u=6,wu=7,bu=8,Ru=9,Eu=10,Su=-32700,Au=-32603,Iu=-32602,vu=-32601,Ou=-32600,ku=-32016,Tu=-32015,Nu=-32014,xu=-32013,Bu=-32012,Lu=-32011,Cu=-32010,Mu=-32009,Pu=-32008,Uu=-32007,Du=-32006,Fu=-32005,zu=-32004,Ku=-32003,$u=-32002,Hu=-32001,Wu=28e5,qu=2800001,Vu=2800002,Gu=2800003,Yu=2800004,ju=2800005,Zu=2800006,Xu=2800007,Ju=2800008,Qu=2800009,el=2800010,tl=323e4,rl=32300001,nl=3230002,il=3230003,sl=3230004,ol=361e4,al=3610001,cl=3610002,ul=3610003,ll=3610004,hl=3610005,fl=3610006,dl=3610007,pl=3611e3,gl=3704e3,ml=3704001,yl=3704002,_l=3704003,wl=3704004,bl=4128e3,Rl=4128001,El=4128002,Sl=4615e3,Al=4615001,Il=4615002,vl=4615003,Ol=4615004,kl=4615005,Tl=4615006,Nl=4615007,xl=4615008,Bl=4615009,Ll=4615010,Cl=4615011,Ml=4615012,Pl=4615013,Ul=4615014,Dl=4615015,Fl=4615016,zl=4615017,Kl=4615018,$l=4615019,Hl=4615020,Wl=4615021,ql=4615022,Vl=4615023,Gl=4615024,Yl=4615025,jl=4615026,Zl=4615027,Xl=4615028,Jl=4615029,Ql=4615030,eh=4615031,th=4615032,rh=4615033,nh=4615034,ih=4615035,sh=4615036,oh=4615037,ah=4615038,ch=4615039,uh=4615040,lh=4615041,hh=4615042,fh=4615043,dh=4615044,ph=4615045,gh=4615046,mh=4615047,yh=4615048,_h=4615049,wh=4615050,bh=4615051,Rh=4615052,Eh=4615053,Sh=4615054,Ah=5508e3,Ih=5508001,vh=5508002,Oh=5508003,kh=5508004,Th=5508005,Nh=5508006,xh=5508007,Bh=5508008,Lh=5508009,Ch=5508010,Mh=5508011,Ph=5663e3,Uh=5663001,Dh=5663002,Fh=5663003,zh=5663004,Kh=5663005,$h=5663006,Hh=5663007,Wh=5663008,qh=5663009,Vh=5663010,Gh=5663011,Yh=5663012,jh=5663013,Zh=5663014,Xh=5663015,Jh=5663016,Qh=5663017,ef=5663018,tf=5663019,rf=705e4,nf=7050001,sf=7050002,of=7050003,af=7050004,cf=7050005,uf=7050006,lf=7050007,hf=7050008,ff=7050009,df=7050010,pf=7050011,gf=7050012,mf=7050013,yf=7050014,_f=7050015,wf=7050016,bf=7050017,Rf=7050018,Ef=7050019,Sf=7050020,Af=7050021,If=7050022,vf=7050023,Of=7050024,kf=7050025,Tf=7050026,Nf=7050027,xf=7050028,Bf=7050029,Lf=7050030,Cf=7050031,Mf=7050032,Pf=7050033,Uf=7050034,Df=7050035,Ff=7050036,oo=8078e3,ao=8078001,zf=8078002,Kf=8078003,co=8078004,uo=8078005,lo=8078006,$f=8078007,Hf=8078008,Wf=8078009,qf=8078010,ho=8078011,Vf=8078012,Gf=8078013,Yf=8078014,jf=8078015,Zf=8078016,Xf=8078017,Jf=8078018,Qf=8078019,ed=8078020,td=8078021,rd=8078022,nd=81e5,id=8100001,sd=8100002,od=8100003,ad=819e4,cd=8190001,ud=8190002,ld=8190003,hd=8190004,fd=99e5,dd=9900001,pd=9900002,gd=9900003,md=9900004;function fo(n){return Array.isArray(n)?"%5B"+n.map(fo).join("%2C%20")+"%5D":typeof n=="bigint"?`${n}n`:encodeURIComponent(String(n!=null&&Object.getPrototypeOf(n)===null?{...n}:n))}function yd([n,e]){return`${n}=${fo(e)}`}function _d(n){const e=Object.entries(n).map(yd).join("&");return btoa(e)}var wd={[tl]:"Account not found at address: $address",[sl]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[il]:"Expected decoded account at address: $address",[nl]:"Failed to decode account data at address: $address",[rl]:"Accounts not found at addresses: $addresses",[Qu]:"Unable to find a viable program address bump seed.",[Vu]:"$putativeAddress is not a base58-encoded address.",[Wu]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[Gu]:"The `CryptoKey` must be an `Ed25519` public key.",[Ju]:"Invalid seeds; point must fall off the Ed25519 curve.",[Yu]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[Zu]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[Xu]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[ju]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[el]:"Program address cannot end with PDA marker.",[qu]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[mu]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[du]:"The network has progressed past the last block for which this transaction could have been committed.",[oo]:"Codec [$codecDescription] cannot decode empty byte arrays.",[rd]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[ed]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[uo]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[lo]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[co]:"Encoder and decoder must either both be fixed-size or variable-size.",[Hf]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[zf]:"Expected a fixed-size codec, got a variable-size one.",[Gf]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[Kf]:"Expected a variable-size codec, got a fixed-size one.",[Qf]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[ao]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[Jf]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[Wf]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[qf]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[jf]:"Invalid literal union variant. Expected one of [$variants], got $value.",[$f]:"Expected [$codecDescription] to have $expected items, got $actual.",[Vf]:"Invalid value $value for base $base with alphabet $alphabet.",[Zf]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[ho]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[Yf]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[td]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[Xf]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[pl]:"No random values implementation could be found.",[Bl]:"instruction requires an uninitialized account",[Vl]:"instruction tries to borrow reference for an account which is already borrowed",[Gl]:"instruction left account with an outstanding borrowed reference",[Wl]:"program other than the account's owner changed the size of the account data",[kl]:"account data too small for instruction",[ql]:"instruction expected an executable account",[gh]:"An account does not have enough lamports to be rent-exempt",[yh]:"Program arithmetic overflowed",[ph]:"Failed to serialize or deserialize account data: $encodedData",[Sh]:"Builtin programs must consume compute units",[th]:"Cross-program invocation call depth too deep",[ah]:"Computational budget exceeded",[jl]:"custom program error: #$code",[zl]:"instruction contains duplicate accounts",[Yl]:"instruction modifications of multiply-passed account differ",[Ql]:"executable accounts must be rent exempt",[Xl]:"instruction changed executable accounts data",[Jl]:"instruction changed the balance of an executable account",[Kl]:"instruction changed executable bit of an account",[Ul]:"instruction modified data of an account it does not own",[Pl]:"instruction spent from the balance of an account it does not own",[Al]:"generic instruction error",[wh]:"Provided owner is not allowed",[fh]:"Account is immutable",[dh]:"Incorrect authority provided",[Nl]:"incorrect program id for instruction",[Tl]:"insufficient funds for instruction",[Ol]:"invalid account data for instruction",[mh]:"Invalid account owner",[Il]:"invalid program argument",[Zl]:"program returned invalid error code",[vl]:"invalid instruction data",[oh]:"Failed to reallocate account data",[sh]:"Provided seeds do not result in a valid address",[bh]:"Accounts data allocations exceeded the maximum allowed per transaction",[Rh]:"Max accounts exceeded",[Eh]:"Max instruction trace length exceeded",[ih]:"Length of the seed is too long for address generation",[rh]:"An account required by the instruction is missing",[xl]:"missing required signature for instruction",[Ml]:"instruction illegally modified the program id of an account",[Hl]:"insufficient account keys for instruction",[ch]:"Cross-program invocation with unauthorized signer or writable account",[uh]:"Failed to create program execution environment",[hh]:"Program failed to compile",[lh]:"Program failed to complete",[Fl]:"instruction modified data of a read-only account",[Dl]:"instruction changed the balance of a read-only account",[nh]:"Cross-program invocation reentrancy not allowed for this instruction",[$l]:"instruction modified rent epoch of an account",[Cl]:"sum of account balances before and after instruction do not match",[Ll]:"instruction requires an initialized account",[Sl]:"",[eh]:"Unsupported program id",[_h]:"Unsupported sysvar",[bl]:"The instruction does not have any accounts.",[Rl]:"The instruction does not have any data.",[El]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[yu]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[pu]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[pd]:"Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[md]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[dd]:"Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[fd]:"Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[gd]:"Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[Au]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[Iu]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[Ou]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[vu]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[Su]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[Bu]:"$__serverMessage",[Hu]:"$__serverMessage",[zu]:"$__serverMessage",[Nu]:"$__serverMessage",[Cu]:"$__serverMessage",[Mu]:"$__serverMessage",[ku]:"Minimum context slot has not been reached",[Fu]:"Node is unhealthy; behind by $numSlotsBehind slots",[Pu]:"No snapshot",[$u]:"Transaction simulation failed",[Uu]:"$__serverMessage",[Lu]:"Transaction history is not available from this node",[Du]:"$__serverMessage",[xu]:"Transaction signature length mismatch",[Ku]:"Transaction signature verification failure",[Tu]:"$__serverMessage",[gl]:"Key pair bytes must be of length 64, got $byteLength.",[ml]:"Expected private key bytes with length 32. Actual length: $actualLength.",[yl]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[wl]:"The provided private key does not match the provided public key.",[_l]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[_u]:"Lamports value must be in the range [0, 2e64-1]",[wu]:"`$value` cannot be parsed as a `BigInt`",[Eu]:"$message",[bu]:"`$value` cannot be parsed as a `Number`",[gu]:"No nonce account could be found at address `$nonceAccountAddress`",[ad]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[ud]:"WebSocket was closed before payload could be added to the send buffer",[ld]:"WebSocket connection closed",[hd]:"WebSocket failed to connect",[cd]:"Failed to obtain a subscription id from the server",[od]:"Could not find an API plan for RPC method: `$method`",[nd]:"The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",[sd]:"HTTP error ($statusCode): $message",[id]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[Ah]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[Ih]:"The provided value does not implement the `KeyPairSigner` interface",[Oh]:"The provided value does not implement the `MessageModifyingSigner` interface",[kh]:"The provided value does not implement the `MessagePartialSigner` interface",[vh]:"The provided value does not implement any of the `MessageSigner` interfaces",[Nh]:"The provided value does not implement the `TransactionModifyingSigner` interface",[xh]:"The provided value does not implement the `TransactionPartialSigner` interface",[Bh]:"The provided value does not implement the `TransactionSendingSigner` interface",[Th]:"The provided value does not implement any of the `TransactionSigner` interfaces",[Lh]:"More than one `TransactionSendingSigner` was identified.",[Ch]:"No `TransactionSendingSigner` was identified. Please provide a valid `ITransactionWithSingleSendingSigner` transaction.",[Mh]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[dl]:"Cannot export a non-extractable key.",[al]:"No digest implementation could be found.",[ol]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[cl]:`This runtime does not support the generation of Ed25519 key pairs.
7
7
 
8
8
  Install @solana/webcrypto-ed25519-polyfill and call its \`install\` function before generating keys in environments that do not support Ed25519.
9
9
 
10
- For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[ul]:"No signature verification implementation could be found.",[ll]:"No key generation implementation could be found.",[hl]:"No signing implementation could be found.",[fl]:"No key export implementation could be found.",[Ru]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[wf]:"Transaction processing left an account with an outstanding borrowed reference",[nf]:"Account in use",[sf]:"Account loaded twice",[of]:"Attempt to debit an account but found no record of a prior credit.",[vf]:"Transaction loads an address table account that doesn't exist",[lf]:"This transaction has already been processed",[hf]:"Blockhash not found",[ff]:"Loader call chain is too deep",[_f]:"Transactions are currently disabled due to cluster maintenance",[Lf]:"Transaction contains a duplicate instruction ($index) that is not allowed",[cf]:"Insufficient funds for fee",[Cf]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[uf]:"This account may not be used to pay transaction fees",[pf]:"Transaction contains an invalid account reference",[kf]:"Transaction loads an address table account with invalid data",[Tf]:"Transaction address table lookup uses an invalid index",[Of]:"Transaction loads an address table account with an invalid owner",[Pf]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[mf]:"This program may not be used for executing instructions",[Nf]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[Ef]:"Transaction loads a writable account that cannot be written",[Mf]:"Transaction exceeded max loaded accounts data size cap",[df]:"Transaction requires a fee but has no signature present",[af]:"Attempt to load a program that does not exist",[Df]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[Uf]:"ResanitizationNeeded",[yf]:"Transaction failed to sanitize accounts offsets correctly",[gf]:"Transaction did not pass signature verification",[If]:"Transaction locked too many accounts",[Ff]:"Sum of account balances before and after transaction do not match",[rf]:"The transaction failed with the error `$errorName`",[Rf]:"Transaction version is unsupported",[Af]:"Transaction would exceed account data limit within the block",[Bf]:"Transaction would exceed total account data limit",[Sf]:"Transaction would exceed max account limit within the block",[bf]:"Transaction would exceed max Block Cost Limit",[xf]:"Transaction would exceed max Vote Cost Limit",[Xh]:"Attempted to sign a transaction with an address that is not a signer for it",[Gh]:"Transaction is missing an address at index: $index.",[Jh]:"Transaction has no expected signers therefore it cannot be encoded",[Dh]:"Transaction does not have a blockhash lifetime",[Fh]:"Transaction is not a durable nonce transaction",[$h]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[Kh]:"Lookup of address at index $highestRequestedIndex failed for lookup table `$lookupTableAddress`. Highest known index is $highestKnownIndex. The lookup table may have been extended since its contents were retrieved",[Hh]:"No fee payer set in CompiledTransaction",[Wh]:"Could not find program address at index $index",[ef]:"Failed to estimate the compute unit consumption for this transaction message. This is likely because simulating the transaction failed. Inspect the `cause` property of this error to learn more",[tf]:"Transaction failed when it was simulated in order to estimate the compute unit consumption. The compute unit estimate provided is for a transaction that failed when simulated and may not be representative of the compute units this transaction would consume if successful. Inspect the `cause` property of this error to learn more",[Vh]:"Transaction is missing a fee payer.",[Yh]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[Zh]:"Transaction first instruction is not advance nonce account instruction.",[jh]:"Transaction with no instructions cannot be durable nonce transaction.",[Ph]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[Uh]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[Qh]:"The transaction message expected the transaction to have $signerAddressesLength signatures, got $signaturesLength.",[qh]:"Transaction is missing signatures for addresses: $addresses.",[zh]:"Transaction version must be in the range [0, 127]. `$actualVersion` given"},Yt="i",Mt="t";function bd(n,e={}){const t=wd[n];if(t.length===0)return"";let r;function s(o){if(r[Mt]===2){const a=t.slice(r[Yt]+1,o);i.push(a in e?`${e[a]}`:`$${a}`)}else r[Mt]===1&&i.push(t.slice(r[Yt],o))}const i=[];return t.split("").forEach((o,a)=>{if(a===0){r={[Yt]:0,[Mt]:t[0]==="\\"?0:t[0]==="$"?2:1};return}let f;switch(r[Mt]){case 0:f={[Yt]:a,[Mt]:1};break;case 1:o==="\\"?f={[Yt]:a,[Mt]:0}:o==="$"&&(f={[Yt]:a,[Mt]:2});break;case 2:o==="\\"?f={[Yt]:a,[Mt]:0}:o==="$"?f={[Yt]:a,[Mt]:2}:o.match(/\w/)||(f={[Yt]:a,[Mt]:1});break}f&&(r!==f&&s(a),r=f)}),s(),i.join("")}function Rd(n,e={}){if(process.env.NODE_ENV!=="production")return bd(n,e);{let t=`Solana error #${n}; Decode this error by running \`npx @solana/errors decode -- ${n}`;return Object.keys(e).length&&(t+=` '${_d(e)}'`),`${t}\``}}var kr=class extends Error{constructor(...[e,t]){let r,s;if(t){const{cause:o,...a}=t;o&&(s={cause:o}),Object.keys(a).length>0&&(r=a)}const i=Rd(e,r);super(i,s);Ye(this,"cause",this.cause);Ye(this,"context");this.context={__code:e,...r},this.name="SolanaError"}};function Ed(n,e){return"fixedSize"in e?e.fixedSize:e.getSizeFromValue(n)}function Sd(n){return Object.freeze({...n,encode:e=>{const t=new Uint8Array(Ed(e,n));return n.write(e,t,0),t}})}function Ad(n){return Object.freeze({...n,decode:(e,t=0)=>n.read(e,t)[0]})}function Tr(n){return"fixedSize"in n&&typeof n.fixedSize=="number"}function Id(n,e){if(Tr(n)!==Tr(e))throw new kr(co);if(Tr(n)&&Tr(e)&&n.fixedSize!==e.fixedSize)throw new kr(uo,{decoderFixedSize:e.fixedSize,encoderFixedSize:n.fixedSize});if(!Tr(n)&&!Tr(e)&&n.maxSize!==e.maxSize)throw new kr(lo,{decoderMaxSize:e.maxSize,encoderMaxSize:n.maxSize});return{...e,...n,decode:e.decode,encode:n.encode,read:e.read,write:n.write}}function vd(n,e,t=0){if(e.length-t<=0)throw new kr(oo,{codecDescription:n})}function Od(n,e,t,r=0){const s=t.length-r;if(s<e)throw new kr(ao,{bytesLength:s,codecDescription:n,expected:e})}function kd(n,e,t,r){if(r<e||r>t)throw new kr(ho,{codecDescription:n,max:t,min:e,value:r})}function po(n){return(n==null?void 0:n.endian)!==1}function Td(n){return Sd({fixedSize:n.size,write(e,t,r){n.range&&kd(n.name,n.range[0],n.range[1],e);const s=new ArrayBuffer(n.size);return n.set(new DataView(s),e,po(n.config)),t.set(new Uint8Array(s),r),r+n.size}})}function Nd(n){return Ad({fixedSize:n.size,read(e,t=0){vd(n.name,e,t),Od(n.name,n.size,e,t);const r=new DataView(xd(e,t,n.size));return[n.get(r,po(n.config)),t+n.size]}})}function xd(n,e,t){const r=n.byteOffset+(e??0),s=t??n.byteLength;return n.buffer.slice(r,r+s)}var go=(n={})=>Td({config:n,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(e,t,r)=>e.setBigUint64(0,BigInt(t),r),size:8}),Bd=(n={})=>Nd({config:n,get:(e,t)=>e.getBigUint64(0,t),name:"u64",size:8}),Ld=(n={})=>Id(go(n),Bd(n));class Cd extends TypeError{constructor(e,t){let r;const{message:s,explanation:i,...o}=e,{path:a}=e,f=a.length===0?s:`At path: ${a.join(".")} -- ${s}`;super(i??f),i!=null&&(this.cause=f),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>r??(r=[e,...t()])}}function Md(n){return qr(n)&&typeof n[Symbol.iterator]=="function"}function qr(n){return typeof n=="object"&&n!=null}function yn(n){return qr(n)&&!Array.isArray(n)}function Bt(n){return typeof n=="symbol"?n.toString():typeof n=="string"?JSON.stringify(n):`${n}`}function Pd(n){const{done:e,value:t}=n.next();return e?void 0:t}function Ud(n,e,t,r){if(n===!0)return;n===!1?n={}:typeof n=="string"&&(n={message:n});const{path:s,branch:i}=e,{type:o}=t,{refinement:a,message:f=`Expected a value of type \`${o}\`${a?` with refinement \`${a}\``:""}, but received: \`${Bt(r)}\``}=n;return{value:r,type:o,refinement:a,key:s[s.length-1],path:s,branch:i,...n,message:f}}function*mo(n,e,t,r){Md(n)||(n=[n]);for(const s of n){const i=Ud(s,e,t,r);i&&(yield i)}}function*ci(n,e,t={}){const{path:r=[],branch:s=[n],coerce:i=!1,mask:o=!1}=t,a={path:r,branch:s,mask:o};i&&(n=e.coercer(n,a));let f="valid";for(const g of e.validator(n,a))g.explanation=t.message,f="not_valid",yield[g,void 0];for(let[g,_,b]of e.entries(n,a)){const x=ci(_,b,{path:g===void 0?r:[...r,g],branch:g===void 0?s:[...s,_],coerce:i,mask:o,message:t.message});for(const T of x)T[0]?(f=T[0].refinement!=null?"not_refined":"not_valid",yield[T[0],void 0]):i&&(_=T[1],g===void 0?n=_:n instanceof Map?n.set(g,_):n instanceof Set?n.add(_):qr(n)&&(_!==void 0||g in n)&&(n[g]=_))}if(f!=="not_valid")for(const g of e.refiner(n,a))g.explanation=t.message,f="not_refined",yield[g,void 0];f==="valid"&&(yield[void 0,n])}let Pt=class{constructor(e){const{type:t,schema:r,validator:s,refiner:i,coercer:o=f=>f,entries:a=function*(){}}=e;this.type=t,this.schema=r,this.entries=a,this.coercer=o,s?this.validator=(f,g)=>{const _=s(f,g);return mo(_,g,this,f)}:this.validator=()=>[],i?this.refiner=(f,g)=>{const _=i(f,g);return mo(_,g,this,f)}:this.refiner=()=>[]}assert(e,t){return yo(e,this,t)}create(e,t){return se(e,this,t)}is(e){return _o(e,this)}mask(e,t){return Dd(e,this,t)}validate(e,t={}){return Gr(e,this,t)}};function yo(n,e,t){const r=Gr(n,e,{message:t});if(r[0])throw r[0]}function se(n,e,t){const r=Gr(n,e,{coerce:!0,message:t});if(r[0])throw r[0];return r[1]}function Dd(n,e,t){const r=Gr(n,e,{coerce:!0,mask:!0,message:t});if(r[0])throw r[0];return r[1]}function _o(n,e){return!Gr(n,e)[0]}function Gr(n,e,t={}){const r=ci(n,e,t),s=Pd(r);return s[0]?[new Cd(s[0],function*(){for(const o of r)o[0]&&(yield o[0])}),void 0]:[void 0,s[1]]}function fr(n,e){return new Pt({type:n,schema:null,validator:e})}function Fd(){return fr("any",()=>!0)}function oe(n){return new Pt({type:"array",schema:n,*entries(e){if(n&&Array.isArray(e))for(const[t,r]of e.entries())yield[t,r,n]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${Bt(e)}`}})}function Ut(){return fr("boolean",n=>typeof n=="boolean")}function ui(n){return fr("instance",e=>e instanceof n||`Expected a \`${n.name}\` instance, but received: ${Bt(e)}`)}function qe(n){const e=Bt(n),t=typeof n;return new Pt({type:"literal",schema:t==="string"||t==="number"||t==="boolean"?n:null,validator(r){return r===n||`Expected the literal \`${e}\`, but received: ${Bt(r)}`}})}function zd(){return fr("never",()=>!1)}function ae(n){return new Pt({...n,validator:(e,t)=>e===null||n.validator(e,t),refiner:(e,t)=>e===null||n.refiner(e,t)})}function K(){return fr("number",n=>typeof n=="number"&&!isNaN(n)||`Expected a number, but received: ${Bt(n)}`)}function le(n){return new Pt({...n,validator:(e,t)=>e===void 0||n.validator(e,t),refiner:(e,t)=>e===void 0||n.refiner(e,t)})}function wo(n,e){return new Pt({type:"record",schema:null,*entries(t){if(qr(t))for(const r in t){const s=t[r];yield[r,r,n],yield[r,s,e]}},validator(t){return yn(t)||`Expected an object, but received: ${Bt(t)}`},coercer(t){return yn(t)?{...t}:t}})}function re(){return fr("string",n=>typeof n=="string"||`Expected a string, but received: ${Bt(n)}`)}function li(n){const e=zd();return new Pt({type:"tuple",schema:null,*entries(t){if(Array.isArray(t)){const r=Math.max(n.length,t.length);for(let s=0;s<r;s++)yield[s,t[s],n[s]||e]}},validator(t){return Array.isArray(t)||`Expected an array, but received: ${Bt(t)}`},coercer(t){return Array.isArray(t)?t.slice():t}})}function ee(n){const e=Object.keys(n);return new Pt({type:"type",schema:n,*entries(t){if(qr(t))for(const r of e)yield[r,t[r],n[r]]},validator(t){return yn(t)||`Expected an object, but received: ${Bt(t)}`},coercer(t){return yn(t)?{...t}:t}})}function At(n){const e=n.map(t=>t.type).join(" | ");return new Pt({type:"union",schema:null,coercer(t,r){for(const s of n){const[i,o]=s.validate(t,{coerce:!0,mask:r.mask});if(!i)return o}return t},validator(t,r){const s=[];for(const i of n){const[...o]=ci(t,i,r),[a]=o;if(a[0])for(const[f]of o)f&&s.push(f);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${Bt(t)}`,...s]}})}function Nr(){return fr("unknown",()=>!0)}function Vr(n,e,t){return new Pt({...n,coercer:(r,s)=>_o(r,e)?n.coercer(t(r,s),s):n.coercer(r,s)})}var _n,$d=new Uint8Array(16);function bo(){if(!_n&&(_n=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!_n))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return _n($d)}const Kd=/^(?:[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 wn(n){return typeof n=="string"&&Kd.test(n)}for(var _t=[],hi=0;hi<256;++hi)_t.push((hi+256).toString(16).substr(1));function bn(n){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=(_t[n[e+0]]+_t[n[e+1]]+_t[n[e+2]]+_t[n[e+3]]+"-"+_t[n[e+4]]+_t[n[e+5]]+"-"+_t[n[e+6]]+_t[n[e+7]]+"-"+_t[n[e+8]]+_t[n[e+9]]+"-"+_t[n[e+10]]+_t[n[e+11]]+_t[n[e+12]]+_t[n[e+13]]+_t[n[e+14]]+_t[n[e+15]]).toLowerCase();if(!wn(t))throw TypeError("Stringified UUID is invalid");return t}var Ro,fi,di=0,pi=0;function Wd(n,e,t){var r=e&&t||0,s=e||new Array(16);n=n||{};var i=n.node||Ro,o=n.clockseq!==void 0?n.clockseq:fi;if(i==null||o==null){var a=n.random||(n.rng||bo)();i==null&&(i=Ro=[a[0]|1,a[1],a[2],a[3],a[4],a[5]]),o==null&&(o=fi=(a[6]<<8|a[7])&16383)}var f=n.msecs!==void 0?n.msecs:Date.now(),g=n.nsecs!==void 0?n.nsecs:pi+1,_=f-di+(g-pi)/1e4;if(_<0&&n.clockseq===void 0&&(o=o+1&16383),(_<0||f>di)&&n.nsecs===void 0&&(g=0),g>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");di=f,pi=g,fi=o,f+=122192928e5;var b=((f&268435455)*1e4+g)%4294967296;s[r++]=b>>>24&255,s[r++]=b>>>16&255,s[r++]=b>>>8&255,s[r++]=b&255;var x=f/4294967296*1e4&268435455;s[r++]=x>>>8&255,s[r++]=x&255,s[r++]=x>>>24&15|16,s[r++]=x>>>16&255,s[r++]=o>>>8|128,s[r++]=o&255;for(var T=0;T<6;++T)s[r+T]=i[T];return e||bn(s)}function Eo(n){if(!wn(n))throw TypeError("Invalid UUID");var e,t=new Uint8Array(16);return t[0]=(e=parseInt(n.slice(0,8),16))>>>24,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=e&255,t[4]=(e=parseInt(n.slice(9,13),16))>>>8,t[5]=e&255,t[6]=(e=parseInt(n.slice(14,18),16))>>>8,t[7]=e&255,t[8]=(e=parseInt(n.slice(19,23),16))>>>8,t[9]=e&255,t[10]=(e=parseInt(n.slice(24,36),16))/1099511627776&255,t[11]=e/4294967296&255,t[12]=e>>>24&255,t[13]=e>>>16&255,t[14]=e>>>8&255,t[15]=e&255,t}function Hd(n){n=unescape(encodeURIComponent(n));for(var e=[],t=0;t<n.length;++t)e.push(n.charCodeAt(t));return e}var qd="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Gd="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function So(n,e,t){function r(s,i,o,a){if(typeof s=="string"&&(s=Hd(s)),typeof i=="string"&&(i=Eo(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=t(f),f[6]=f[6]&15|e,f[8]=f[8]&63|128,o){a=a||0;for(var g=0;g<16;++g)o[a+g]=f[g];return o}return bn(f)}try{r.name=n}catch{}return r.DNS=qd,r.URL=Gd,r}function Vd(n){if(typeof n=="string"){var e=unescape(encodeURIComponent(n));n=new Uint8Array(e.length);for(var t=0;t<e.length;++t)n[t]=e.charCodeAt(t)}return Yd(jd(Zd(n),n.length*8))}function Yd(n){for(var e=[],t=n.length*32,r="0123456789abcdef",s=0;s<t;s+=8){var i=n[s>>5]>>>s%32&255,o=parseInt(r.charAt(i>>>4&15)+r.charAt(i&15),16);e.push(o)}return e}function Ao(n){return(n+64>>>9<<4)+14+1}function jd(n,e){n[e>>5]|=128<<e%32,n[Ao(e)-1]=e;for(var t=1732584193,r=-271733879,s=-1732584194,i=271733878,o=0;o<n.length;o+=16){var a=t,f=r,g=s,_=i;t=wt(t,r,s,i,n[o],7,-680876936),i=wt(i,t,r,s,n[o+1],12,-389564586),s=wt(s,i,t,r,n[o+2],17,606105819),r=wt(r,s,i,t,n[o+3],22,-1044525330),t=wt(t,r,s,i,n[o+4],7,-176418897),i=wt(i,t,r,s,n[o+5],12,1200080426),s=wt(s,i,t,r,n[o+6],17,-1473231341),r=wt(r,s,i,t,n[o+7],22,-45705983),t=wt(t,r,s,i,n[o+8],7,1770035416),i=wt(i,t,r,s,n[o+9],12,-1958414417),s=wt(s,i,t,r,n[o+10],17,-42063),r=wt(r,s,i,t,n[o+11],22,-1990404162),t=wt(t,r,s,i,n[o+12],7,1804603682),i=wt(i,t,r,s,n[o+13],12,-40341101),s=wt(s,i,t,r,n[o+14],17,-1502002290),r=wt(r,s,i,t,n[o+15],22,1236535329),t=bt(t,r,s,i,n[o+1],5,-165796510),i=bt(i,t,r,s,n[o+6],9,-1069501632),s=bt(s,i,t,r,n[o+11],14,643717713),r=bt(r,s,i,t,n[o],20,-373897302),t=bt(t,r,s,i,n[o+5],5,-701558691),i=bt(i,t,r,s,n[o+10],9,38016083),s=bt(s,i,t,r,n[o+15],14,-660478335),r=bt(r,s,i,t,n[o+4],20,-405537848),t=bt(t,r,s,i,n[o+9],5,568446438),i=bt(i,t,r,s,n[o+14],9,-1019803690),s=bt(s,i,t,r,n[o+3],14,-187363961),r=bt(r,s,i,t,n[o+8],20,1163531501),t=bt(t,r,s,i,n[o+13],5,-1444681467),i=bt(i,t,r,s,n[o+2],9,-51403784),s=bt(s,i,t,r,n[o+7],14,1735328473),r=bt(r,s,i,t,n[o+12],20,-1926607734),t=Rt(t,r,s,i,n[o+5],4,-378558),i=Rt(i,t,r,s,n[o+8],11,-2022574463),s=Rt(s,i,t,r,n[o+11],16,1839030562),r=Rt(r,s,i,t,n[o+14],23,-35309556),t=Rt(t,r,s,i,n[o+1],4,-1530992060),i=Rt(i,t,r,s,n[o+4],11,1272893353),s=Rt(s,i,t,r,n[o+7],16,-155497632),r=Rt(r,s,i,t,n[o+10],23,-1094730640),t=Rt(t,r,s,i,n[o+13],4,681279174),i=Rt(i,t,r,s,n[o],11,-358537222),s=Rt(s,i,t,r,n[o+3],16,-722521979),r=Rt(r,s,i,t,n[o+6],23,76029189),t=Rt(t,r,s,i,n[o+9],4,-640364487),i=Rt(i,t,r,s,n[o+12],11,-421815835),s=Rt(s,i,t,r,n[o+15],16,530742520),r=Rt(r,s,i,t,n[o+2],23,-995338651),t=Et(t,r,s,i,n[o],6,-198630844),i=Et(i,t,r,s,n[o+7],10,1126891415),s=Et(s,i,t,r,n[o+14],15,-1416354905),r=Et(r,s,i,t,n[o+5],21,-57434055),t=Et(t,r,s,i,n[o+12],6,1700485571),i=Et(i,t,r,s,n[o+3],10,-1894986606),s=Et(s,i,t,r,n[o+10],15,-1051523),r=Et(r,s,i,t,n[o+1],21,-2054922799),t=Et(t,r,s,i,n[o+8],6,1873313359),i=Et(i,t,r,s,n[o+15],10,-30611744),s=Et(s,i,t,r,n[o+6],15,-1560198380),r=Et(r,s,i,t,n[o+13],21,1309151649),t=Et(t,r,s,i,n[o+4],6,-145523070),i=Et(i,t,r,s,n[o+11],10,-1120210379),s=Et(s,i,t,r,n[o+2],15,718787259),r=Et(r,s,i,t,n[o+9],21,-343485551),t=nr(t,a),r=nr(r,f),s=nr(s,g),i=nr(i,_)}return[t,r,s,i]}function Zd(n){if(n.length===0)return[];for(var e=n.length*8,t=new Uint32Array(Ao(e)),r=0;r<e;r+=8)t[r>>5]|=(n[r/8]&255)<<r%32;return t}function nr(n,e){var t=(n&65535)+(e&65535),r=(n>>16)+(e>>16)+(t>>16);return r<<16|t&65535}function Xd(n,e){return n<<e|n>>>32-e}function Rn(n,e,t,r,s,i){return nr(Xd(nr(nr(e,n),nr(r,i)),s),t)}function wt(n,e,t,r,s,i,o){return Rn(e&t|~e&r,n,e,s,i,o)}function bt(n,e,t,r,s,i,o){return Rn(e&r|t&~r,n,e,s,i,o)}function Rt(n,e,t,r,s,i,o){return Rn(e^t^r,n,e,s,i,o)}function Et(n,e,t,r,s,i,o){return Rn(t^(e|~r),n,e,s,i,o)}var Jd=So("v3",48,Vd);function Qd(n,e,t){n=n||{};var r=n.random||(n.rng||bo)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){t=t||0;for(var s=0;s<16;++s)e[t+s]=r[s];return e}return bn(r)}function e0(n,e,t,r){switch(n){case 0:return e&t^~e&r;case 1:return e^t^r;case 2:return e&t^e&r^t&r;case 3:return e^t^r}}function gi(n,e){return n<<e|n>>>32-e}function t0(n){var e=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof n=="string"){var r=unescape(encodeURIComponent(n));n=[];for(var s=0;s<r.length;++s)n.push(r.charCodeAt(s))}else Array.isArray(n)||(n=Array.prototype.slice.call(n));n.push(128);for(var i=n.length/4+2,o=Math.ceil(i/16),a=new Array(o),f=0;f<o;++f){for(var g=new Uint32Array(16),_=0;_<16;++_)g[_]=n[f*64+_*4]<<24|n[f*64+_*4+1]<<16|n[f*64+_*4+2]<<8|n[f*64+_*4+3];a[f]=g}a[o-1][14]=(n.length-1)*8/Math.pow(2,32),a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=(n.length-1)*8&4294967295;for(var b=0;b<o;++b){for(var x=new Uint32Array(80),T=0;T<16;++T)x[T]=a[b][T];for(var L=16;L<80;++L)x[L]=gi(x[L-3]^x[L-8]^x[L-14]^x[L-16],1);for(var k=t[0],N=t[1],M=t[2],W=t[3],$=t[4],J=0;J<80;++J){var q=Math.floor(J/20),D=gi(k,5)+e0(q,N,M,W)+$+e[q]+x[J]>>>0;$=W,W=M,M=gi(N,30)>>>0,N=k,k=D}t[0]=t[0]+k>>>0,t[1]=t[1]+N>>>0,t[2]=t[2]+M>>>0,t[3]=t[3]+W>>>0,t[4]=t[4]+$>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,t[0]&255,t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,t[1]&255,t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,t[2]&255,t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,t[3]&255,t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,t[4]&255]}var r0=So("v5",80,t0);const n0="00000000-0000-0000-0000-000000000000";function i0(n){if(!wn(n))throw TypeError("Invalid UUID");return parseInt(n.substr(14,1),16)}const Io=zn(Object.freeze(Object.defineProperty({__proto__:null,NIL:n0,parse:Eo,stringify:bn,v1:Wd,v3:Jd,v4:Qd,v5:r0,validate:wn,version:i0},Symbol.toStringTag,{value:"Module"})));var mi,vo;function s0(){if(vo)return mi;vo=1;const n=Io.v4;return mi=function(t,r,s,i){if(typeof t!="string")throw new TypeError(t+" must be a string");i=i||{};const o=typeof i.version=="number"?i.version:2;if(o!==1&&o!==2)throw new TypeError(o+" must be 1 or 2");const a={method:t};if(o===2&&(a.jsonrpc="2.0"),r){if(typeof r!="object"&&!Array.isArray(r))throw new TypeError(r+" must be an object, array or omitted");a.params=r}if(typeof s>"u"){const f=typeof i.generator=="function"?i.generator:function(){return n()};a.id=f(a,i)}else o===2&&s===null?i.notificationIdNull&&(a.id=null):a.id=s;return a},mi}var yi,Oo;function o0(){if(Oo)return yi;Oo=1;const n=Io.v4,e=s0(),t=function(r,s){if(!(this instanceof t))return new t(r,s);s||(s={}),this.options={reviver:typeof s.reviver<"u"?s.reviver:null,replacer:typeof s.replacer<"u"?s.replacer:null,generator:typeof s.generator<"u"?s.generator:function(){return n()},version:typeof s.version<"u"?s.version:2,notificationIdNull:typeof s.notificationIdNull=="boolean"?s.notificationIdNull:!1},this.callServer=r};return yi=t,t.prototype.request=function(r,s,i,o){const a=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 x=typeof o=="function";try{f=e(r,s,i,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(T){if(x)return o(T);throw T}if(!x)return f}let b;try{b=JSON.stringify(f,this.options.replacer)}catch(x){return o(x)}return this.callServer(b,function(x,T){a._parseResponse(x,T,o)}),f},t.prototype._parseResponse=function(r,s,i){if(r){i(r);return}if(!s)return i();let o;try{o=JSON.parse(s,this.options.reviver)}catch(a){return i(a)}if(i.length===3)if(Array.isArray(o)){const a=function(g){return typeof g.error<"u"},f=function(g){return!a(g)};return i(null,o.filter(a),o.filter(f))}else return i(null,o.error,o.result);i(null,o)},yi}var a0=o0();const c0=zr(a0);var _i={exports:{}},ko;function u0(){return ko||(ko=1,function(n){var e=Object.prototype.hasOwnProperty,t="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(t=!1));function s(f,g,_){this.fn=f,this.context=g,this.once=_||!1}function i(f,g,_,b,x){if(typeof _!="function")throw new TypeError("The listener must be a function");var T=new s(_,b||f,x),L=t?t+g:g;return f._events[L]?f._events[L].fn?f._events[L]=[f._events[L],T]:f._events[L].push(T):(f._events[L]=T,f._eventsCount++),f}function o(f,g){--f._eventsCount===0?f._events=new r:delete f._events[g]}function a(){this._events=new r,this._eventsCount=0}a.prototype.eventNames=function(){var g=[],_,b;if(this._eventsCount===0)return g;for(b in _=this._events)e.call(_,b)&&g.push(t?b.slice(1):b);return Object.getOwnPropertySymbols?g.concat(Object.getOwnPropertySymbols(_)):g},a.prototype.listeners=function(g){var _=t?t+g:g,b=this._events[_];if(!b)return[];if(b.fn)return[b.fn];for(var x=0,T=b.length,L=new Array(T);x<T;x++)L[x]=b[x].fn;return L},a.prototype.listenerCount=function(g){var _=t?t+g:g,b=this._events[_];return b?b.fn?1:b.length:0},a.prototype.emit=function(g,_,b,x,T,L){var k=t?t+g:g;if(!this._events[k])return!1;var N=this._events[k],M=arguments.length,W,$;if(N.fn){switch(N.once&&this.removeListener(g,N.fn,void 0,!0),M){case 1:return N.fn.call(N.context),!0;case 2:return N.fn.call(N.context,_),!0;case 3:return N.fn.call(N.context,_,b),!0;case 4:return N.fn.call(N.context,_,b,x),!0;case 5:return N.fn.call(N.context,_,b,x,T),!0;case 6:return N.fn.call(N.context,_,b,x,T,L),!0}for($=1,W=new Array(M-1);$<M;$++)W[$-1]=arguments[$];N.fn.apply(N.context,W)}else{var J=N.length,q;for($=0;$<J;$++)switch(N[$].once&&this.removeListener(g,N[$].fn,void 0,!0),M){case 1:N[$].fn.call(N[$].context);break;case 2:N[$].fn.call(N[$].context,_);break;case 3:N[$].fn.call(N[$].context,_,b);break;case 4:N[$].fn.call(N[$].context,_,b,x);break;default:if(!W)for(q=1,W=new Array(M-1);q<M;q++)W[q-1]=arguments[q];N[$].fn.apply(N[$].context,W)}}return!0},a.prototype.on=function(g,_,b){return i(this,g,_,b,!1)},a.prototype.once=function(g,_,b){return i(this,g,_,b,!0)},a.prototype.removeListener=function(g,_,b,x){var T=t?t+g:g;if(!this._events[T])return this;if(!_)return o(this,T),this;var L=this._events[T];if(L.fn)L.fn===_&&(!x||L.once)&&(!b||L.context===b)&&o(this,T);else{for(var k=0,N=[],M=L.length;k<M;k++)(L[k].fn!==_||x&&!L[k].once||b&&L[k].context!==b)&&N.push(L[k]);N.length?this._events[T]=N.length===1?N[0]:N:o(this,T)}return this},a.prototype.removeAllListeners=function(g){var _;return g?(_=t?t+g:g,this._events[_]&&o(this,_)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=t,a.EventEmitter=a,n.exports=a}(_i)),_i.exports}var l0=u0();const To=zr(l0);var h0=class extends To{constructor(e,t,r){super();Ye(this,"socket");this.socket=new window.WebSocket(e,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(e,t,r){const s=r||t;try{this.socket.send(e),s()}catch(i){s(i)}}close(e,t){this.socket.close(e,t)}addEventListener(e,t,r){this.socket.addEventListener(e,t,r)}};function f0(n,e){return new h0(n,e)}var d0=class{encode(n){return JSON.stringify(n)}decode(n){return JSON.parse(n)}},p0=class extends To{constructor(e,t="ws://localhost:8080",{autoconnect:r=!0,reconnect:s=!0,reconnect_interval:i=1e3,max_reconnects:o=5,...a}={},f,g){super();Ye(this,"address");Ye(this,"rpc_id");Ye(this,"queue");Ye(this,"options");Ye(this,"autoconnect");Ye(this,"ready");Ye(this,"reconnect");Ye(this,"reconnect_timer_id");Ye(this,"reconnect_interval");Ye(this,"max_reconnects");Ye(this,"rest_options");Ye(this,"current_reconnects");Ye(this,"generate_request_id");Ye(this,"socket");Ye(this,"webSocketFactory");Ye(this,"dataPack");this.webSocketFactory=e,this.queue={},this.rpc_id=0,this.address=t,this.autoconnect=r,this.ready=!1,this.reconnect=s,this.reconnect_timer_id=void 0,this.reconnect_interval=i,this.max_reconnects=o,this.rest_options=a,this.current_reconnects=0,this.generate_request_id=f||(()=>++this.rpc_id),g?this.dataPack=g:this.dataPack=new d0,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(e,t,r,s){return!s&&typeof r=="object"&&(s=r,r=null),new Promise((i,o)=>{if(!this.ready)return o(new Error("socket not ready"));const a=this.generate_request_id(e,t),f={jsonrpc:"2.0",method:e,params:t||void 0,id:a};this.socket.send(this.dataPack.encode(f),s,g=>{if(g)return o(g);this.queue[a]={promise:[i,o]},r&&(this.queue[a].timeout=setTimeout(()=>{delete this.queue[a],o(new Error("reply timeout"))},r))})})}async login(e){const t=await this.call("rpc.login",e);if(!t)throw new Error("authentication failed");return t}async listMethods(){return await this.call("__listMethods")}notify(e,t){return new Promise((r,s)=>{if(!this.ready)return s(new Error("socket not ready"));const i={jsonrpc:"2.0",method:e,params:t};this.socket.send(this.dataPack.encode(i),o=>{if(o)return s(o);r()})})}async subscribe(e){typeof e=="string"&&(e=[e]);const t=await this.call("rpc.on",e);if(typeof e=="string"&&t[e]!=="ok")throw new Error("Failed subscribing to an event '"+e+"' with: "+t[e]);return t}async unsubscribe(e){typeof e=="string"&&(e=[e]);const t=await this.call("rpc.off",e);if(typeof e=="string"&&t[e]!=="ok")throw new Error("Failed unsubscribing from an event with: "+t);return t}close(e,t){this.socket.close(e||1e3,t)}setAutoReconnect(e){this.reconnect=e}setReconnectInterval(e){this.reconnect_interval=e}setMaxReconnects(e){this.max_reconnects=e}_connect(e,t){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(e,t),this.socket.addEventListener("open",()=>{this.ready=!0,this.emit("open"),this.current_reconnects=0}),this.socket.addEventListener("message",({data:r})=>{r instanceof ArrayBuffer&&(r=fe.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(e,t),this.reconnect_interval)))})}};const No=[],xo=[],Bo=[],g0=BigInt(0),Yr=BigInt(1),m0=BigInt(2),y0=BigInt(7),_0=BigInt(256),w0=BigInt(113);for(let n=0,e=Yr,t=1,r=0;n<24;n++){[t,r]=[r,(2*t+3*r)%5],No.push(2*(5*r+t)),xo.push((n+1)*(n+2)/2%64);let s=g0;for(let i=0;i<7;i++)e=(e<<Yr^(e>>y0)*w0)%_0,e&m0&&(s^=Yr<<(Yr<<BigInt(i))-Yr);Bo.push(s)}const[b0,R0]=Bs(Bo,!0),Lo=(n,e,t)=>t>32?Ms(n,e,t):Ls(n,e,t),Co=(n,e,t)=>t>32?Ps(n,e,t):Cs(n,e,t);function E0(n,e=24){const t=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)t[o]=n[o]^n[o+10]^n[o+20]^n[o+30]^n[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,f=(o+2)%10,g=t[f],_=t[f+1],b=Lo(g,_,1)^t[a],x=Co(g,_,1)^t[a+1];for(let T=0;T<50;T+=10)n[o+T]^=b,n[o+T+1]^=x}let s=n[2],i=n[3];for(let o=0;o<24;o++){const a=xo[o],f=Lo(s,i,a),g=Co(s,i,a),_=No[o];s=n[_],i=n[_+1],n[_]=f,n[_+1]=g}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=n[o+a];for(let a=0;a<10;a++)n[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}n[0]^=b0[r],n[1]^=R0[r]}t.fill(0)}class wi extends qn{constructor(e,t,r,s=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,sn(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Ja(this.state)}keccak(){Os||ks(this.state32),E0(this.state32,this.rounds),Os||ks(this.state32),this.posOut=0,this.pos=0}update(e){Rr(this);const{blockLen:t,state:r}=this;e=on(e);const s=e.length;for(let i=0;i<s;){const o=Math.min(t-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:r,blockLen:s}=this;e[r]^=t,(t&128)!==0&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){Rr(this,!1),Kr(e),this.finish();const t=this.state,{blockLen:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-s);e.set(t.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return sn(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(vs(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new wi(t,r,s,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}}const Mo=((n,e,t)=>Gn(()=>new wi(e,n,t)))(1,136,256/8);class Po extends qn{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Xa(e);const r=on(t);if(this.iHash=e.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?e.create().update(r).digest():r);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=e.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),i.fill(0)}update(e){return Rr(this),this.iHash.update(e),this}digestInto(e){Rr(this),Kr(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:r,finished:s,destroyed:i,blockLen:o,outputLen:a}=this;return e=e,e.finished=s,e.destroyed=i,e.blockLen=o,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Uo=(n,e,t)=>new Po(n,e).update(t).digest();Uo.create=(n,e)=>new Po(n,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function S0(n){const e=ei(n);Ir(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:t,Fp:r,a:s}=e;if(t){if(!r.eql(s,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:A0,hexToBytes:I0}=kc,dr={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(n){const{Err:e}=dr;if(n.length<2||n[0]!==2)throw new e("Invalid signature integer tag");const t=n[1],r=n.subarray(2,t+2);if(!t||r.length!==t)throw new e("Invalid signature integer: wrong length");if(r[0]&128)throw new e("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:A0(r),l:n.subarray(t+2)}},toSig(n){const{Err:e}=dr,t=typeof n=="string"?I0(n):n;Wr(t);let r=t.length;if(r<2||t[0]!=48)throw new e("Invalid signature tag");if(t[1]!==r-2)throw new e("Invalid signature: incorrect length");const{d:s,l:i}=dr._parseInt(t.subarray(2)),{d:o,l:a}=dr._parseInt(i);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:s,s:o}},hexFromSig(n){const e=g=>Number.parseInt(g[0],16)&8?"00"+g:g,t=g=>{const _=g.toString(16);return _.length&1?`0${_}`:_},r=e(t(n.s)),s=e(t(n.r)),i=r.length/2,o=s.length/2,a=t(i),f=t(o);return`30${t(o+i+4)}02${f}${s}02${a}${r}`}},jt=BigInt(0),Nt=BigInt(1);BigInt(2);const Do=BigInt(3);BigInt(4);function v0(n){const e=S0(n),{Fp:t}=e,r=e.toBytes||((L,k,N)=>{const M=k.toAffine();return lr(Uint8Array.from([4]),t.toBytes(M.x),t.toBytes(M.y))}),s=e.fromBytes||(L=>{const k=L.subarray(1),N=t.fromBytes(k.subarray(0,t.BYTES)),M=t.fromBytes(k.subarray(t.BYTES,2*t.BYTES));return{x:N,y:M}});function i(L){const{a:k,b:N}=e,M=t.sqr(L),W=t.mul(M,L);return t.add(t.add(W,t.mul(L,k)),N)}if(!t.eql(t.sqr(e.Gy),i(e.Gx)))throw new Error("bad generator point: equation left != right");function o(L){return typeof L=="bigint"&&jt<L&&L<e.n}function a(L){if(!o(L))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function f(L){const{allowedPrivateKeyLengths:k,nByteLength:N,wrapPrivateKey:M,n:W}=e;if(k&&typeof L!="bigint"){if(ar(L)&&(L=cr(L)),typeof L!="string"||!k.includes(L.length))throw new Error("Invalid key");L=L.padStart(N*2,"0")}let $;try{$=typeof L=="bigint"?L:ur(dt("private key",L,N))}catch{throw new Error(`private key must be ${N} bytes, hex or bigint, not ${typeof L}`)}return M&&($=Ke($,W)),a($),$}const g=new Map;function _(L){if(!(L instanceof b))throw new Error("ProjectivePoint expected")}class b{constructor(k,N,M){if(this.px=k,this.py=N,this.pz=M,k==null||!t.isValid(k))throw new Error("x required");if(N==null||!t.isValid(N))throw new Error("y required");if(M==null||!t.isValid(M))throw new Error("z required")}static fromAffine(k){const{x:N,y:M}=k||{};if(!k||!t.isValid(N)||!t.isValid(M))throw new Error("invalid affine point");if(k instanceof b)throw new Error("projective point not allowed");const W=$=>t.eql($,t.ZERO);return W(N)&&W(M)?b.ZERO:new b(N,M,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(k){const N=t.invertBatch(k.map(M=>M.pz));return k.map((M,W)=>M.toAffine(N[W])).map(b.fromAffine)}static fromHex(k){const N=b.fromAffine(s(dt("pointHex",k)));return N.assertValidity(),N}static fromPrivateKey(k){return b.BASE.multiply(f(k))}_setWindowSize(k){this._WINDOW_SIZE=k,g.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!t.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:k,y:N}=this.toAffine();if(!t.isValid(k)||!t.isValid(N))throw new Error("bad point: x or y not FE");const M=t.sqr(N),W=i(k);if(!t.eql(M,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:k}=this.toAffine();if(t.isOdd)return!t.isOdd(k);throw new Error("Field doesn't support isOdd")}equals(k){_(k);const{px:N,py:M,pz:W}=this,{px:$,py:J,pz:q}=k,D=t.eql(t.mul(N,q),t.mul($,W)),Z=t.eql(t.mul(M,q),t.mul(J,W));return D&&Z}negate(){return new b(this.px,t.neg(this.py),this.pz)}double(){const{a:k,b:N}=e,M=t.mul(N,Do),{px:W,py:$,pz:J}=this;let q=t.ZERO,D=t.ZERO,Z=t.ZERO,j=t.mul(W,W),X=t.mul($,$),z=t.mul(J,J),G=t.mul(W,$);return G=t.add(G,G),Z=t.mul(W,J),Z=t.add(Z,Z),q=t.mul(k,Z),D=t.mul(M,z),D=t.add(q,D),q=t.sub(X,D),D=t.add(X,D),D=t.mul(q,D),q=t.mul(G,q),Z=t.mul(M,Z),z=t.mul(k,z),G=t.sub(j,z),G=t.mul(k,G),G=t.add(G,Z),Z=t.add(j,j),j=t.add(Z,j),j=t.add(j,z),j=t.mul(j,G),D=t.add(D,j),z=t.mul($,J),z=t.add(z,z),j=t.mul(z,G),q=t.sub(q,j),Z=t.mul(z,X),Z=t.add(Z,Z),Z=t.add(Z,Z),new b(q,D,Z)}add(k){_(k);const{px:N,py:M,pz:W}=this,{px:$,py:J,pz:q}=k;let D=t.ZERO,Z=t.ZERO,j=t.ZERO;const X=e.a,z=t.mul(e.b,Do);let G=t.mul(N,$),Q=t.mul(M,J),A=t.mul(W,q),c=t.add(N,M),p=t.add($,J);c=t.mul(c,p),p=t.add(G,Q),c=t.sub(c,p),p=t.add(N,W);let m=t.add($,q);return p=t.mul(p,m),m=t.add(G,A),p=t.sub(p,m),m=t.add(M,W),D=t.add(J,q),m=t.mul(m,D),D=t.add(Q,A),m=t.sub(m,D),j=t.mul(X,p),D=t.mul(z,A),j=t.add(D,j),D=t.sub(Q,j),j=t.add(Q,j),Z=t.mul(D,j),Q=t.add(G,G),Q=t.add(Q,G),A=t.mul(X,A),p=t.mul(z,p),Q=t.add(Q,A),A=t.sub(G,A),A=t.mul(X,A),p=t.add(p,A),G=t.mul(Q,p),Z=t.add(Z,G),G=t.mul(m,p),D=t.mul(c,D),D=t.sub(D,G),G=t.mul(c,Q),j=t.mul(m,j),j=t.add(j,G),new b(D,Z,j)}subtract(k){return this.add(k.negate())}is0(){return this.equals(b.ZERO)}wNAF(k){return T.wNAFCached(this,g,k,N=>{const M=t.invertBatch(N.map(W=>W.pz));return N.map((W,$)=>W.toAffine(M[$])).map(b.fromAffine)})}multiplyUnsafe(k){const N=b.ZERO;if(k===jt)return N;if(a(k),k===Nt)return this;const{endo:M}=e;if(!M)return T.unsafeLadder(this,k);let{k1neg:W,k1:$,k2neg:J,k2:q}=M.splitScalar(k),D=N,Z=N,j=this;for(;$>jt||q>jt;)$&Nt&&(D=D.add(j)),q&Nt&&(Z=Z.add(j)),j=j.double(),$>>=Nt,q>>=Nt;return W&&(D=D.negate()),J&&(Z=Z.negate()),Z=new b(t.mul(Z.px,M.beta),Z.py,Z.pz),D.add(Z)}multiply(k){a(k);let N=k,M,W;const{endo:$}=e;if($){const{k1neg:J,k1:q,k2neg:D,k2:Z}=$.splitScalar(N);let{p:j,f:X}=this.wNAF(q),{p:z,f:G}=this.wNAF(Z);j=T.constTimeNegate(J,j),z=T.constTimeNegate(D,z),z=new b(t.mul(z.px,$.beta),z.py,z.pz),M=j.add(z),W=X.add(G)}else{const{p:J,f:q}=this.wNAF(N);M=J,W=q}return b.normalizeZ([M,W])[0]}multiplyAndAddUnsafe(k,N,M){const W=b.BASE,$=(q,D)=>D===jt||D===Nt||!q.equals(W)?q.multiplyUnsafe(D):q.multiply(D),J=$(this,N).add($(k,M));return J.is0()?void 0:J}toAffine(k){const{px:N,py:M,pz:W}=this,$=this.is0();k==null&&(k=$?t.ONE:t.inv(W));const J=t.mul(N,k),q=t.mul(M,k),D=t.mul(W,k);if($)return{x:t.ZERO,y:t.ZERO};if(!t.eql(D,t.ONE))throw new Error("invZ was invalid");return{x:J,y:q}}isTorsionFree(){const{h:k,isTorsionFree:N}=e;if(k===Nt)return!0;if(N)return N(b,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:k,clearCofactor:N}=e;return k===Nt?this:N?N(b,this):this.multiplyUnsafe(e.h)}toRawBytes(k=!0){return this.assertValidity(),r(b,this,k)}toHex(k=!0){return cr(this.toRawBytes(k))}}b.BASE=new b(e.Gx,e.Gy,t.ONE),b.ZERO=new b(t.ZERO,t.ONE,t.ZERO);const x=e.nBitLength,T=Ys(b,e.endo?Math.ceil(x/2):x);return{CURVE:e,ProjectivePoint:b,normPrivateKeyToScalar:f,weierstrassEquation:i,isWithinCurveOrder:o}}function O0(n){const e=ei(n);return Ir(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function k0(n){const e=O0(n),{Fp:t,n:r}=e,s=t.BYTES+1,i=2*t.BYTES+1;function o(p){return jt<p&&p<t.ORDER}function a(p){return Ke(p,r)}function f(p){return Jn(p,r)}const{ProjectivePoint:g,normPrivateKeyToScalar:_,weierstrassEquation:b,isWithinCurveOrder:x}=v0({...e,toBytes(p,m,v){const S=m.toAffine(),I=t.toBytes(S.x),C=lr;return v?C(Uint8Array.from([m.hasEvenY()?2:3]),I):C(Uint8Array.from([4]),I,t.toBytes(S.y))},fromBytes(p){const m=p.length,v=p[0],S=p.subarray(1);if(m===s&&(v===2||v===3)){const I=ur(S);if(!o(I))throw new Error("Point is not on curve");const C=b(I);let R;try{R=t.sqrt(C)}catch(w){const E=w instanceof Error?": "+w.message:"";throw new Error("Point is not on curve"+E)}const u=(R&Nt)===Nt;return(v&1)===1!==u&&(R=t.neg(R)),{x:I,y:R}}else if(m===i&&v===4){const I=t.fromBytes(S.subarray(0,t.BYTES)),C=t.fromBytes(S.subarray(t.BYTES,2*t.BYTES));return{x:I,y:C}}else throw new Error(`Point of length ${m} was invalid. Expected ${s} compressed bytes or ${i} uncompressed bytes`)}}),T=p=>cr(Ar(p,e.nByteLength));function L(p){const m=r>>Nt;return p>m}function k(p){return L(p)?a(-p):p}const N=(p,m,v)=>ur(p.slice(m,v));class M{constructor(m,v,S){this.r=m,this.s=v,this.recovery=S,this.assertValidity()}static fromCompact(m){const v=e.nByteLength;return m=dt("compactSignature",m,v*2),new M(N(m,0,v),N(m,v,2*v))}static fromDER(m){const{r:v,s:S}=dr.toSig(dt("DER",m));return new M(v,S)}assertValidity(){if(!x(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!x(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(m){return new M(this.r,this.s,m)}recoverPublicKey(m){const{r:v,s:S,recovery:I}=this,C=Z(dt("msgHash",m));if(I==null||![0,1,2,3].includes(I))throw new Error("recovery id invalid");const R=I===2||I===3?v+e.n:v;if(R>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const u=(I&1)===0?"02":"03",l=g.fromHex(u+T(R)),w=f(R),E=a(-C*w),P=a(S*w),V=g.BASE.multiplyAndAddUnsafe(l,E,P);if(!V)throw new Error("point at infinify");return V.assertValidity(),V}hasHighS(){return L(this.s)}normalizeS(){return this.hasHighS()?new M(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Er(this.toDERHex())}toDERHex(){return dr.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Er(this.toCompactHex())}toCompactHex(){return T(this.r)+T(this.s)}}const W={isValidPrivateKey(p){try{return _(p),!0}catch{return!1}},normPrivateKeyToScalar:_,randomPrivateKey:()=>{const p=Vs(e.n);return Dc(e.randomBytes(p),e.n)},precompute(p=8,m=g.BASE){return m._setWindowSize(p),m.multiply(BigInt(3)),m}};function $(p,m=!0){return g.fromPrivateKey(p).toRawBytes(m)}function J(p){const m=ar(p),v=typeof p=="string",S=(m||v)&&p.length;return m?S===s||S===i:v?S===2*s||S===2*i:p instanceof g}function q(p,m,v=!0){if(J(p))throw new Error("first arg must be private key");if(!J(m))throw new Error("second arg must be public key");return g.fromHex(m).multiply(_(p)).toRawBytes(v)}const D=e.bits2int||function(p){const m=ur(p),v=p.length*8-e.nBitLength;return v>0?m>>BigInt(v):m},Z=e.bits2int_modN||function(p){return a(D(p))},j=jn(e.nBitLength);function X(p){if(typeof p!="bigint")throw new Error("bigint expected");if(!(jt<=p&&p<j))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Ar(p,e.nByteLength)}function z(p,m,v=G){if(["recovered","canonical"].some(ce=>ce in v))throw new Error("sign() legacy options not supported");const{hash:S,randomBytes:I}=e;let{lowS:C,prehash:R,extraEntropy:u}=v;C==null&&(C=!0),p=dt("msgHash",p),R&&(p=dt("prehashed msgHash",S(p)));const l=Z(p),w=_(m),E=[X(w),X(l)];if(u!=null&&u!==!1){const ce=u===!0?I(t.BYTES):u;E.push(dt("extraEntropy",ce))}const P=lr(...E),V=l;function ne(ce){const ve=D(ce);if(!x(ve))return;const ge=f(ve),Re=g.BASE.multiply(ve).toAffine(),ke=a(Re.x);if(ke===jt)return;const Ee=a(ge*a(V+ke*w));if(Ee===jt)return;let Ne=(Re.x===ke?0:2)|Number(Re.y&Nt),qt=Ee;return C&&L(Ee)&&(qt=k(Ee),Ne^=1),new M(ke,qt,Ne)}return{seed:P,k2sig:ne}}const G={lowS:e.lowS,prehash:!1},Q={lowS:e.lowS,prehash:!1};function A(p,m,v=G){const{seed:S,k2sig:I}=z(p,m,v),C=e;return $s(C.hash.outputLen,C.nByteLength,C.hmac)(S,I)}g.BASE._setWindowSize(8);function c(p,m,v,S=Q){var Re;const I=p;if(m=dt("msgHash",m),v=dt("publicKey",v),"strict"in S)throw new Error("options.strict was renamed to lowS");const{lowS:C,prehash:R}=S;let u,l;try{if(typeof I=="string"||ar(I))try{u=M.fromDER(I)}catch(ke){if(!(ke instanceof dr.Err))throw ke;u=M.fromCompact(I)}else if(typeof I=="object"&&typeof I.r=="bigint"&&typeof I.s=="bigint"){const{r:ke,s:Ee}=I;u=new M(ke,Ee)}else throw new Error("PARSE");l=g.fromHex(v)}catch(ke){if(ke.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(C&&u.hasHighS())return!1;R&&(m=e.hash(m));const{r:w,s:E}=u,P=Z(m),V=f(E),ne=a(P*V),ce=a(w*V),ve=(Re=g.BASE.multiplyAndAddUnsafe(l,ne,ce))==null?void 0:Re.toAffine();return ve?a(ve.x)===w:!1}return{CURVE:e,getPublicKey:$,getSharedSecret:q,sign:A,verify:c,ProjectivePoint:g,Signature:M,utils:W}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function T0(n){return{hash:n,hmac:(e,...t)=>Uo(n,e,tc(...t)),randomBytes:Ts}}function N0(n,e){const t=r=>k0({...n,...T0(r)});return Object.freeze({...t(e),create:t})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Fo=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),zo=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),x0=BigInt(1),bi=BigInt(2),$o=(n,e)=>(n+e/bi)/e;function B0(n){const e=Fo,t=BigInt(3),r=BigInt(6),s=BigInt(11),i=BigInt(22),o=BigInt(23),a=BigInt(44),f=BigInt(88),g=n*n*n%e,_=g*g*n%e,b=Ve(_,t,e)*_%e,x=Ve(b,t,e)*_%e,T=Ve(x,bi,e)*g%e,L=Ve(T,s,e)*T%e,k=Ve(L,i,e)*L%e,N=Ve(k,a,e)*k%e,M=Ve(N,f,e)*N%e,W=Ve(M,a,e)*k%e,$=Ve(W,t,e)*_%e,J=Ve($,o,e)*L%e,q=Ve(J,r,e)*g%e,D=Ve(q,bi,e);if(!Ri.eql(Ri.sqr(D),n))throw new Error("Cannot find square root");return D}const Ri=qs(Fo,void 0,void 0,{sqrt:B0}),En=N0({a:BigInt(0),b:BigInt(7),Fp:Ri,n:zo,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:n=>{const e=zo,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-x0*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=t,o=BigInt("0x100000000000000000000000000000000"),a=$o(i*n,e),f=$o(-r*n,e);let g=Ke(n-a*t-f*s,e),_=Ke(-a*r-f*i,e);const b=g>o,x=_>o;if(b&&(g=e-g),x&&(_=e-_),g>o||_>o)throw new Error("splitScalar: Endomorphism failed, k="+n);return{k1neg:b,k1:g,k2neg:x,k2:_}}}},ii);BigInt(0),En.ProjectivePoint;const L0=vr.utils.randomPrivateKey,Ko=()=>{const n=vr.utils.randomPrivateKey(),e=Sn(n),t=new Uint8Array(64);return t.set(n),t.set(e,32),{publicKey:e,secretKey:t}},Sn=vr.getPublicKey;function Wo(n){try{return vr.ExtendedPoint.fromHex(n),!0}catch{return!1}}const Ei=(n,e)=>vr.sign(n,e.slice(0,32)),C0=vr.verify,_e=n=>fe.Buffer.isBuffer(n)?n:n instanceof Uint8Array?fe.Buffer.from(n.buffer,n.byteOffset,n.byteLength):fe.Buffer.from(n);class Si{constructor(e){Object.assign(this,e)}encode(){return fe.Buffer.from(ai.serialize(jr,this))}static decode(e){return ai.deserialize(jr,this,e)}static decodeUnchecked(e){return ai.deserializeUnchecked(jr,this,e)}}class M0 extends Si{constructor(e){if(super(e),this.enum="",Object.keys(e).length!==1)throw new Error("Enum can only take single value");Object.keys(e).map(t=>{this.enum=t})}}const jr=new Map;var Ho;const qo=32,Dt=32;function P0(n){return n._bn!==void 0}let Go=1;class ie extends Si{constructor(e){if(super({}),this._bn=void 0,P0(e))this._bn=e._bn;else{if(typeof e=="string"){const t=gt.decode(e);if(t.length!=Dt)throw new Error("Invalid public key input");this._bn=new Qs(t)}else this._bn=new Qs(e);if(this._bn.byteLength()>Dt)throw new Error("Invalid public key input")}}static unique(){const e=new ie(Go);return Go+=1,new ie(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return gt.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){const e=this._bn.toArrayLike(fe.Buffer);if(e.length===Dt)return e;const t=fe.Buffer.alloc(32);return e.copy(t,32-e.length),t}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(e,t,r){const s=fe.Buffer.concat([e.toBuffer(),fe.Buffer.from(t),r.toBuffer()]),i=ii(s);return new ie(i)}static createProgramAddressSync(e,t){let r=fe.Buffer.alloc(0);e.forEach(function(i){if(i.length>qo)throw new TypeError("Max seed length exceeded");r=fe.Buffer.concat([r,_e(i)])}),r=fe.Buffer.concat([r,t.toBuffer(),fe.Buffer.from("ProgramDerivedAddress")]);const s=ii(r);if(Wo(s))throw new Error("Invalid seeds, address must fall off the curve");return new ie(s)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let r=255,s;for(;r!=0;){try{const i=e.concat(fe.Buffer.from([r]));s=this.createProgramAddressSync(i,t)}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(e,t){return this.findProgramAddressSync(e,t)}static isOnCurve(e){const t=new ie(e);return Wo(t.toBytes())}}Ho=ie,ie.default=new Ho("11111111111111111111111111111111"),jr.set(ie,{kind:"struct",fields:[["_bn","u256"]]});class U0{constructor(e){if(this._publicKey=void 0,this._secretKey=void 0,e){const t=_e(e);if(e.length!==64)throw new Error("bad secret key size");this._publicKey=t.slice(32,64),this._secretKey=t.slice(0,32)}else this._secretKey=_e(L0()),this._publicKey=_e(Sn(this._secretKey))}get publicKey(){return new ie(this._publicKey)}get secretKey(){return fe.Buffer.concat([this._secretKey,this._publicKey],64)}}const D0=new ie("BPFLoader1111111111111111111111111111111111"),ir=1232,An=127,Zr=64;class Ai extends Error{constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}}Object.defineProperty(Ai.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class Ii extends Error{constructor(e,t){super(`Transaction was not confirmed in ${t.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${e} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=e}}Object.defineProperty(Ii.prototype,"name",{value:"TransactionExpiredTimeoutError"});class xr extends Error{constructor(e){super(`Signature ${e} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=e}}Object.defineProperty(xr.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class Xr{constructor(e,t){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=t}keySegments(){const e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(const t of this.keySegments()){if(e<t.length)return t[e];e-=t.length}}get length(){return this.keySegments().flat().length}compileInstructions(e){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 e.map(i=>({programIdIndex:s(i.programId),accountKeyIndexes:i.keys.map(o=>s(o.pubkey)),data:i.data}))}}const Se=(n="publicKey")=>B.blob(32,n),F0=(n="signature")=>B.blob(64,n),pr=(n="string")=>{const e=B.struct([B.u32("length"),B.u32("lengthPadding"),B.blob(B.offset(B.u32(),-8),"chars")],n),t=e.decode.bind(e),r=e.encode.bind(e),s=e;return s.decode=(i,o)=>t(i,o).chars.toString(),s.encode=(i,o,a)=>{const f={chars:fe.Buffer.from(i,"utf8")};return r(f,o,a)},s.alloc=i=>B.u32().span+B.u32().span+fe.Buffer.from(i,"utf8").length,s},z0=(n="authorized")=>B.struct([Se("staker"),Se("withdrawer")],n),$0=(n="lockup")=>B.struct([B.ns64("unixTimestamp"),B.ns64("epoch"),Se("custodian")],n),K0=(n="voteInit")=>B.struct([Se("nodePubkey"),Se("authorizedVoter"),Se("authorizedWithdrawer"),B.u8("commission")],n),W0=(n="voteAuthorizeWithSeedArgs")=>B.struct([B.u32("voteAuthorizationType"),Se("currentAuthorityDerivedKeyOwnerPubkey"),pr("currentAuthorityDerivedKeySeed"),Se("newAuthorized")],n);function Vo(n,e){const t=s=>{if(s.span>=0)return s.span;if(typeof s.alloc=="function")return s.alloc(e[s.property]);if("count"in s&&"elementLayout"in s){const i=e[s.property];if(Array.isArray(i))return i.length*t(s.elementLayout)}else if("fields"in s)return Vo({layout:s},e[s.property]);return 0};let r=0;return n.layout.fields.forEach(s=>{r+=t(s)}),r}function It(n){let e=0,t=0;for(;;){let r=n.shift();if(e|=(r&127)<<t*7,t+=1,(r&128)===0)break}return e}function Tt(n,e){let t=e;for(;;){let r=t&127;if(t>>=7,t==0){n.push(r);break}else r|=128,n.push(r)}}function Ie(n,e){if(!n)throw new Error(e||"Assertion failed")}class In{constructor(e,t){this.payer=void 0,this.keyMetaMap=void 0,this.payer=e,this.keyMetaMap=t}static compile(e,t){const r=new Map,s=o=>{const a=o.toBase58();let f=r.get(a);return f===void 0&&(f={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(a,f)),f},i=s(t);i.isSigner=!0,i.isWritable=!0;for(const o of e){s(o.programId).isInvoked=!0;for(const a of o.keys){const f=s(a.pubkey);f.isSigner||(f.isSigner=a.isSigner),f.isWritable||(f.isWritable=a.isWritable)}}return new In(t,r)}getMessageComponents(){const e=[...this.keyMetaMap.entries()];Ie(e.length<=256,"Max static account keys length exceeded");const t=e.filter(([,f])=>f.isSigner&&f.isWritable),r=e.filter(([,f])=>f.isSigner&&!f.isWritable),s=e.filter(([,f])=>!f.isSigner&&f.isWritable),i=e.filter(([,f])=>!f.isSigner&&!f.isWritable),o={numRequiredSignatures:t.length+r.length,numReadonlySignedAccounts:r.length,numReadonlyUnsignedAccounts:i.length};{Ie(t.length>0,"Expected at least one writable signer key");const[f]=t[0];Ie(f===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const a=[...t.map(([f])=>new ie(f)),...r.map(([f])=>new ie(f)),...s.map(([f])=>new ie(f)),...i.map(([f])=>new ie(f))];return[o,a]}extractTableLookup(e){const[t,r]=this.drainKeysFoundInLookupTable(e.state.addresses,o=>!o.isSigner&&!o.isInvoked&&o.isWritable),[s,i]=this.drainKeysFoundInLookupTable(e.state.addresses,o=>!o.isSigner&&!o.isInvoked&&!o.isWritable);if(!(t.length===0&&s.length===0))return[{accountKey:e.key,writableIndexes:t,readonlyIndexes:s},{writable:r,readonly:i}]}drainKeysFoundInLookupTable(e,t){const r=new Array,s=new Array;for(const[i,o]of this.keyMetaMap.entries())if(t(o)){const a=new ie(i),f=e.findIndex(g=>g.equals(a));f>=0&&(Ie(f<256,"Max lookup table index exceeded"),r.push(f),s.push(a),this.keyMetaMap.delete(i))}return[r,s]}}const Yo="Reached end of buffer unexpectedly";function Ft(n){if(n.length===0)throw new Error(Yo);return n.shift()}function vt(n,...e){const[t]=e;if(e.length===2?t+(e[1]??0)>n.length:t>=n.length)throw new Error(Yo);return n.splice(...e)}class Lt{constructor(e){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=e.header,this.accountKeys=e.accountKeys.map(t=>new ie(t)),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach(t=>this.indexToProgramIds.set(t.programIdIndex,this.accountKeys[t.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:gt.decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new Xr(this.staticAccountKeys)}static compile(e){const t=In.compile(e.instructions,e.payerKey),[r,s]=t.getMessageComponents(),o=new Xr(s).compileInstructions(e.instructions).map(a=>({programIdIndex:a.programIdIndex,accounts:a.accountKeyIndexes,data:gt.encode(a.data)}));return new Lt({header:r,accountKeys:s,recentBlockhash:e.recentBlockhash,instructions:o})}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){const t=this.header.numRequiredSignatures;if(e>=this.header.numRequiredSignatures){const r=e-t,i=this.accountKeys.length-t-this.header.numReadonlyUnsignedAccounts;return r<i}else{const r=t-this.header.numReadonlySignedAccounts;return e<r}}isProgramId(e){return this.indexToProgramIds.has(e)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((e,t)=>!this.isProgramId(t))}serialize(){const e=this.accountKeys.length;let t=[];Tt(t,e);const r=this.instructions.map(b=>{const{accounts:x,programIdIndex:T}=b,L=Array.from(gt.decode(b.data));let k=[];Tt(k,x.length);let N=[];return Tt(N,L.length),{programIdIndex:T,keyIndicesCount:fe.Buffer.from(k),keyIndices:x,dataLength:fe.Buffer.from(N),data:L}});let s=[];Tt(s,r.length);let i=fe.Buffer.alloc(ir);fe.Buffer.from(s).copy(i);let o=s.length;r.forEach(b=>{const T=B.struct([B.u8("programIdIndex"),B.blob(b.keyIndicesCount.length,"keyIndicesCount"),B.seq(B.u8("keyIndex"),b.keyIndices.length,"keyIndices"),B.blob(b.dataLength.length,"dataLength"),B.seq(B.u8("userdatum"),b.data.length,"data")]).encode(b,i,o);o+=T}),i=i.slice(0,o);const a=B.struct([B.blob(1,"numRequiredSignatures"),B.blob(1,"numReadonlySignedAccounts"),B.blob(1,"numReadonlyUnsignedAccounts"),B.blob(t.length,"keyCount"),B.seq(Se("key"),e,"keys"),Se("recentBlockhash")]),f={numRequiredSignatures:fe.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:fe.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:fe.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:fe.Buffer.from(t),keys:this.accountKeys.map(b=>_e(b.toBytes())),recentBlockhash:gt.decode(this.recentBlockhash)};let g=fe.Buffer.alloc(2048);const _=a.encode(f,g);return i.copy(g,_),g.slice(0,_+i.length)}static from(e){let t=[...e];const r=Ft(t);if(r!==(r&An))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const s=Ft(t),i=Ft(t),o=It(t);let a=[];for(let x=0;x<o;x++){const T=vt(t,0,Dt);a.push(new ie(fe.Buffer.from(T)))}const f=vt(t,0,Dt),g=It(t);let _=[];for(let x=0;x<g;x++){const T=Ft(t),L=It(t),k=vt(t,0,L),N=It(t),M=vt(t,0,N),W=gt.encode(fe.Buffer.from(M));_.push({programIdIndex:T,accounts:k,data:W})}const b={header:{numRequiredSignatures:r,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:i},recentBlockhash:gt.encode(fe.Buffer.from(f)),accountKeys:a,instructions:_};return new Lt(b)}}class gr{constructor(e){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=e.header,this.staticAccountKeys=e.staticAccountKeys,this.recentBlockhash=e.recentBlockhash,this.compiledInstructions=e.compiledInstructions,this.addressTableLookups=e.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let e=0;for(const t of this.addressTableLookups)e+=t.readonlyIndexes.length+t.writableIndexes.length;return e}getAccountKeys(e){let t;if(e&&"accountKeysFromLookups"in e&&e.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=e.accountKeysFromLookups.writable.length+e.accountKeysFromLookups.readonly.length)throw new Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");t=e.accountKeysFromLookups}else if(e&&"addressLookupTableAccounts"in e&&e.addressLookupTableAccounts)t=this.resolveAddressTableLookups(e.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new Xr(this.staticAccountKeys,t)}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){const t=this.header.numRequiredSignatures,r=this.staticAccountKeys.length;if(e>=r){const s=e-r,i=this.addressTableLookups.reduce((o,a)=>o+a.writableIndexes.length,0);return s<i}else if(e>=this.header.numRequiredSignatures){const s=e-t,o=r-t-this.header.numReadonlyUnsignedAccounts;return s<o}else{const s=t-this.header.numReadonlySignedAccounts;return e<s}}resolveAddressTableLookups(e){const t={writable:[],readonly:[]};for(const r of this.addressTableLookups){const s=e.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)t.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)t.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 t}static compile(e){const t=In.compile(e.instructions,e.payerKey),r=new Array,s={writable:new Array,readonly:new Array},i=e.addressLookupTableAccounts||[];for(const _ of i){const b=t.extractTableLookup(_);if(b!==void 0){const[x,{writable:T,readonly:L}]=b;r.push(x),s.writable.push(...T),s.readonly.push(...L)}}const[o,a]=t.getMessageComponents(),g=new Xr(a,s).compileInstructions(e.instructions);return new gr({header:o,staticAccountKeys:a,recentBlockhash:e.recentBlockhash,compiledInstructions:g,addressTableLookups:r})}serialize(){const e=Array();Tt(e,this.staticAccountKeys.length);const t=this.serializeInstructions(),r=Array();Tt(r,this.compiledInstructions.length);const s=this.serializeAddressTableLookups(),i=Array();Tt(i,this.addressTableLookups.length);const o=B.struct([B.u8("prefix"),B.struct([B.u8("numRequiredSignatures"),B.u8("numReadonlySignedAccounts"),B.u8("numReadonlyUnsignedAccounts")],"header"),B.blob(e.length,"staticAccountKeysLength"),B.seq(Se(),this.staticAccountKeys.length,"staticAccountKeys"),Se("recentBlockhash"),B.blob(r.length,"instructionsLength"),B.blob(t.length,"serializedInstructions"),B.blob(i.length,"addressTableLookupsLength"),B.blob(s.length,"serializedAddressTableLookups")]),a=new Uint8Array(ir),g=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(_=>_.toBytes()),recentBlockhash:gt.decode(this.recentBlockhash),instructionsLength:new Uint8Array(r),serializedInstructions:t,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:s},a);return a.slice(0,g)}serializeInstructions(){let e=0;const t=new Uint8Array(ir);for(const r of this.compiledInstructions){const s=Array();Tt(s,r.accountKeyIndexes.length);const i=Array();Tt(i,r.data.length);const o=B.struct([B.u8("programIdIndex"),B.blob(s.length,"encodedAccountKeyIndexesLength"),B.seq(B.u8(),r.accountKeyIndexes.length,"accountKeyIndexes"),B.blob(i.length,"encodedDataLength"),B.blob(r.data.length,"data")]);e+=o.encode({programIdIndex:r.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(s),accountKeyIndexes:r.accountKeyIndexes,encodedDataLength:new Uint8Array(i),data:r.data},t,e)}return t.slice(0,e)}serializeAddressTableLookups(){let e=0;const t=new Uint8Array(ir);for(const r of this.addressTableLookups){const s=Array();Tt(s,r.writableIndexes.length);const i=Array();Tt(i,r.readonlyIndexes.length);const o=B.struct([Se("accountKey"),B.blob(s.length,"encodedWritableIndexesLength"),B.seq(B.u8(),r.writableIndexes.length,"writableIndexes"),B.blob(i.length,"encodedReadonlyIndexesLength"),B.seq(B.u8(),r.readonlyIndexes.length,"readonlyIndexes")]);e+=o.encode({accountKey:r.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(s),writableIndexes:r.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(i),readonlyIndexes:r.readonlyIndexes},t,e)}return t.slice(0,e)}static deserialize(e){let t=[...e];const r=Ft(t),s=r&An;Ie(r!==s,"Expected versioned message but received legacy message");const i=s;Ie(i===0,`Expected versioned message with version 0 but found version ${i}`);const o={numRequiredSignatures:Ft(t),numReadonlySignedAccounts:Ft(t),numReadonlyUnsignedAccounts:Ft(t)},a=[],f=It(t);for(let L=0;L<f;L++)a.push(new ie(vt(t,0,Dt)));const g=gt.encode(vt(t,0,Dt)),_=It(t),b=[];for(let L=0;L<_;L++){const k=Ft(t),N=It(t),M=vt(t,0,N),W=It(t),$=new Uint8Array(vt(t,0,W));b.push({programIdIndex:k,accountKeyIndexes:M,data:$})}const x=It(t),T=[];for(let L=0;L<x;L++){const k=new ie(vt(t,0,Dt)),N=It(t),M=vt(t,0,N),W=It(t),$=vt(t,0,W);T.push({accountKey:k,writableIndexes:M,readonlyIndexes:$})}return new gr({header:o,staticAccountKeys:a,recentBlockhash:g,compiledInstructions:b,addressTableLookups:T})}}const vi={deserializeMessageVersion(n){const e=n[0],t=e&An;return t===e?"legacy":t},deserialize:n=>{const e=vi.deserializeMessageVersion(n);if(e==="legacy")return Lt.from(n);if(e===0)return gr.deserialize(n);throw new Error(`Transaction message version ${e} deserialization is not supported`)}};let Zt=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 H0=fe.Buffer.alloc(Zr).fill(0);class Be{constructor(e){this.keys=void 0,this.programId=void 0,this.data=fe.Buffer.alloc(0),this.programId=e.programId,this.keys=e.keys,e.data&&(this.data=e.data)}toJSON(){return{keys:this.keys.map(({pubkey:e,isSigner:t,isWritable:r})=>({pubkey:e.toJSON(),isSigner:t,isWritable:r})),programId:this.programId.toJSON(),data:[...this.data]}}}class Oe{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(e){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,!!e)if(e.feePayer&&(this.feePayer=e.feePayer),e.signatures&&(this.signatures=e.signatures),Object.prototype.hasOwnProperty.call(e,"nonceInfo")){const{minContextSlot:t,nonceInfo:r}=e;this.minNonceContextSlot=t,this.nonceInfo=r}else if(Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")){const{blockhash:t,lastValidBlockHeight:r}=e;this.recentBlockhash=t,this.lastValidBlockHeight=r}else{const{recentBlockhash:t,nonceInfo:r}=e;r&&(this.nonceInfo=r),this.recentBlockhash=t}}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(e=>e.toJSON()),signers:this.signatures.map(({publicKey:e})=>e.toJSON())}}add(...e){if(e.length===0)throw new Error("No instructions");return e.forEach(t=>{"instructions"in t?this.instructions=this.instructions.concat(t.instructions):"data"in t&&"programId"in t&&"keys"in t?this.instructions.push(t):this.instructions.push(new Be(t))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let e,t;if(this.nonceInfo?(e=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?t=[this.nonceInfo.nonceInstruction,...this.instructions]:t=this.instructions):(e=this.recentBlockhash,t=this.instructions),!e)throw new Error("Transaction recentBlockhash required");t.length<1&&console.warn("No instructions provided");let r;if(this.feePayer)r=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)r=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let k=0;k<t.length;k++)if(t[k].programId===void 0)throw new Error(`Transaction instruction index ${k} has undefined program id`);const s=[],i=[];t.forEach(k=>{k.keys.forEach(M=>{i.push({...M})});const N=k.programId.toString();s.includes(N)||s.push(N)}),s.forEach(k=>{i.push({pubkey:new ie(k),isSigner:!1,isWritable:!1})});const o=[];i.forEach(k=>{const N=k.pubkey.toString(),M=o.findIndex(W=>W.pubkey.toString()===N);M>-1?(o[M].isWritable=o[M].isWritable||k.isWritable,o[M].isSigner=o[M].isSigner||k.isSigner):o.push(k)}),o.sort(function(k,N){if(k.isSigner!==N.isSigner)return k.isSigner?-1:1;if(k.isWritable!==N.isWritable)return k.isWritable?-1:1;const M={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return k.pubkey.toBase58().localeCompare(N.pubkey.toBase58(),"en",M)});const a=o.findIndex(k=>k.pubkey.equals(r));if(a>-1){const[k]=o.splice(a,1);k.isSigner=!0,k.isWritable=!0,o.unshift(k)}else o.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(const k of this.signatures){const N=o.findIndex(M=>M.pubkey.equals(k.publicKey));if(N>-1)o[N].isSigner||(o[N].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."));else throw new Error(`unknown signer: ${k.publicKey.toString()}`)}let f=0,g=0,_=0;const b=[],x=[];o.forEach(({pubkey:k,isSigner:N,isWritable:M})=>{N?(b.push(k.toString()),f+=1,M||(g+=1)):(x.push(k.toString()),M||(_+=1))});const T=b.concat(x),L=t.map(k=>{const{data:N,programId:M}=k;return{programIdIndex:T.indexOf(M.toString()),accounts:k.keys.map(W=>T.indexOf(W.pubkey.toString())),data:gt.encode(N)}});return L.forEach(k=>{Ie(k.programIdIndex>=0),k.accounts.forEach(N=>Ie(N>=0))}),new Lt({header:{numRequiredSignatures:f,numReadonlySignedAccounts:g,numReadonlyUnsignedAccounts:_},accountKeys:T,recentBlockhash:e,instructions:L})}_compile(){const e=this.compileMessage(),t=e.accountKeys.slice(0,e.header.numRequiredSignatures);return this.signatures.length===t.length&&this.signatures.every((s,i)=>t[i].equals(s.publicKey))||(this.signatures=t.map(r=>({signature:null,publicKey:r}))),e}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(e){return(await e.getFeeForMessage(this.compileMessage())).value}setSigners(...e){if(e.length===0)throw new Error("No signers");const t=new Set;this.signatures=e.filter(r=>{const s=r.toString();return t.has(s)?!1:(t.add(s),!0)}).map(r=>({signature:null,publicKey:r}))}sign(...e){if(e.length===0)throw new Error("No signers");const t=new Set,r=[];for(const i of e){const o=i.publicKey.toString();t.has(o)||(t.add(o),r.push(i))}this.signatures=r.map(i=>({signature:null,publicKey:i.publicKey}));const s=this._compile();this._partialSign(s,...r)}partialSign(...e){if(e.length===0)throw new Error("No signers");const t=new Set,r=[];for(const i of e){const o=i.publicKey.toString();t.has(o)||(t.add(o),r.push(i))}const s=this._compile();this._partialSign(s,...r)}_partialSign(e,...t){const r=e.serialize();t.forEach(s=>{const i=Ei(r,s.secretKey);this._addSignature(s.publicKey,_e(i))})}addSignature(e,t){this._compile(),this._addSignature(e,t)}_addSignature(e,t){Ie(t.length===64);const r=this.signatures.findIndex(s=>e.equals(s.publicKey));if(r<0)throw new Error(`unknown signer: ${e.toString()}`);this.signatures[r].signature=fe.Buffer.from(t)}verifySignatures(e=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),e)}_getMessageSignednessErrors(e,t){const r={};for(const{signature:s,publicKey:i}of this.signatures)s===null?t&&(r.missing||(r.missing=[])).push(i):C0(s,e,i.toBytes())||(r.invalid||(r.invalid=[])).push(i);return r.invalid||r.missing?r:void 0}serialize(e){const{requireAllSignatures:t,verifySignatures:r}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),s=this.serializeMessage();if(r){const i=this._getMessageSignednessErrors(s,t);if(i){let o="Signature verification failed.";throw i.invalid&&(o+=`
10
+ For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[ul]:"No signature verification implementation could be found.",[ll]:"No key generation implementation could be found.",[hl]:"No signing implementation could be found.",[fl]:"No key export implementation could be found.",[Ru]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[wf]:"Transaction processing left an account with an outstanding borrowed reference",[nf]:"Account in use",[sf]:"Account loaded twice",[of]:"Attempt to debit an account but found no record of a prior credit.",[vf]:"Transaction loads an address table account that doesn't exist",[lf]:"This transaction has already been processed",[hf]:"Blockhash not found",[ff]:"Loader call chain is too deep",[_f]:"Transactions are currently disabled due to cluster maintenance",[Lf]:"Transaction contains a duplicate instruction ($index) that is not allowed",[cf]:"Insufficient funds for fee",[Cf]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[uf]:"This account may not be used to pay transaction fees",[pf]:"Transaction contains an invalid account reference",[kf]:"Transaction loads an address table account with invalid data",[Tf]:"Transaction address table lookup uses an invalid index",[Of]:"Transaction loads an address table account with an invalid owner",[Pf]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[mf]:"This program may not be used for executing instructions",[Nf]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[Ef]:"Transaction loads a writable account that cannot be written",[Mf]:"Transaction exceeded max loaded accounts data size cap",[df]:"Transaction requires a fee but has no signature present",[af]:"Attempt to load a program that does not exist",[Df]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[Uf]:"ResanitizationNeeded",[yf]:"Transaction failed to sanitize accounts offsets correctly",[gf]:"Transaction did not pass signature verification",[If]:"Transaction locked too many accounts",[Ff]:"Sum of account balances before and after transaction do not match",[rf]:"The transaction failed with the error `$errorName`",[Rf]:"Transaction version is unsupported",[Af]:"Transaction would exceed account data limit within the block",[Bf]:"Transaction would exceed total account data limit",[Sf]:"Transaction would exceed max account limit within the block",[bf]:"Transaction would exceed max Block Cost Limit",[xf]:"Transaction would exceed max Vote Cost Limit",[Xh]:"Attempted to sign a transaction with an address that is not a signer for it",[Vh]:"Transaction is missing an address at index: $index.",[Jh]:"Transaction has no expected signers therefore it cannot be encoded",[Dh]:"Transaction does not have a blockhash lifetime",[Fh]:"Transaction is not a durable nonce transaction",[Kh]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[$h]:"Lookup of address at index $highestRequestedIndex failed for lookup table `$lookupTableAddress`. Highest known index is $highestKnownIndex. The lookup table may have been extended since its contents were retrieved",[Wh]:"No fee payer set in CompiledTransaction",[Hh]:"Could not find program address at index $index",[ef]:"Failed to estimate the compute unit consumption for this transaction message. This is likely because simulating the transaction failed. Inspect the `cause` property of this error to learn more",[tf]:"Transaction failed when it was simulated in order to estimate the compute unit consumption. The compute unit estimate provided is for a transaction that failed when simulated and may not be representative of the compute units this transaction would consume if successful. Inspect the `cause` property of this error to learn more",[Gh]:"Transaction is missing a fee payer.",[Yh]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[Zh]:"Transaction first instruction is not advance nonce account instruction.",[jh]:"Transaction with no instructions cannot be durable nonce transaction.",[Ph]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[Uh]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[Qh]:"The transaction message expected the transaction to have $signerAddressesLength signatures, got $signaturesLength.",[qh]:"Transaction is missing signatures for addresses: $addresses.",[zh]:"Transaction version must be in the range [0, 127]. `$actualVersion` given"},Yt="i",Mt="t";function bd(n,e={}){const t=wd[n];if(t.length===0)return"";let r;function s(o){if(r[Mt]===2){const a=t.slice(r[Yt]+1,o);i.push(a in e?`${e[a]}`:`$${a}`)}else r[Mt]===1&&i.push(t.slice(r[Yt],o))}const i=[];return t.split("").forEach((o,a)=>{if(a===0){r={[Yt]:0,[Mt]:t[0]==="\\"?0:t[0]==="$"?2:1};return}let f;switch(r[Mt]){case 0:f={[Yt]:a,[Mt]:1};break;case 1:o==="\\"?f={[Yt]:a,[Mt]:0}:o==="$"&&(f={[Yt]:a,[Mt]:2});break;case 2:o==="\\"?f={[Yt]:a,[Mt]:0}:o==="$"?f={[Yt]:a,[Mt]:2}:o.match(/\w/)||(f={[Yt]:a,[Mt]:1});break}f&&(r!==f&&s(a),r=f)}),s(),i.join("")}function Rd(n,e={}){if(process.env.NODE_ENV!=="production")return bd(n,e);{let t=`Solana error #${n}; Decode this error by running \`npx @solana/errors decode -- ${n}`;return Object.keys(e).length&&(t+=` '${_d(e)}'`),`${t}\``}}var kr=class extends Error{constructor(...[e,t]){let r,s;if(t){const{cause:o,...a}=t;o&&(s={cause:o}),Object.keys(a).length>0&&(r=a)}const i=Rd(e,r);super(i,s);Ye(this,"cause",this.cause);Ye(this,"context");this.context={__code:e,...r},this.name="SolanaError"}};function Ed(n,e){return"fixedSize"in e?e.fixedSize:e.getSizeFromValue(n)}function Sd(n){return Object.freeze({...n,encode:e=>{const t=new Uint8Array(Ed(e,n));return n.write(e,t,0),t}})}function Ad(n){return Object.freeze({...n,decode:(e,t=0)=>n.read(e,t)[0]})}function Tr(n){return"fixedSize"in n&&typeof n.fixedSize=="number"}function Id(n,e){if(Tr(n)!==Tr(e))throw new kr(co);if(Tr(n)&&Tr(e)&&n.fixedSize!==e.fixedSize)throw new kr(uo,{decoderFixedSize:e.fixedSize,encoderFixedSize:n.fixedSize});if(!Tr(n)&&!Tr(e)&&n.maxSize!==e.maxSize)throw new kr(lo,{decoderMaxSize:e.maxSize,encoderMaxSize:n.maxSize});return{...e,...n,decode:e.decode,encode:n.encode,read:e.read,write:n.write}}function vd(n,e,t=0){if(e.length-t<=0)throw new kr(oo,{codecDescription:n})}function Od(n,e,t,r=0){const s=t.length-r;if(s<e)throw new kr(ao,{bytesLength:s,codecDescription:n,expected:e})}function kd(n,e,t,r){if(r<e||r>t)throw new kr(ho,{codecDescription:n,max:t,min:e,value:r})}function po(n){return(n==null?void 0:n.endian)!==1}function Td(n){return Sd({fixedSize:n.size,write(e,t,r){n.range&&kd(n.name,n.range[0],n.range[1],e);const s=new ArrayBuffer(n.size);return n.set(new DataView(s),e,po(n.config)),t.set(new Uint8Array(s),r),r+n.size}})}function Nd(n){return Ad({fixedSize:n.size,read(e,t=0){vd(n.name,e,t),Od(n.name,n.size,e,t);const r=new DataView(xd(e,t,n.size));return[n.get(r,po(n.config)),t+n.size]}})}function xd(n,e,t){const r=n.byteOffset+(e??0),s=t??n.byteLength;return n.buffer.slice(r,r+s)}var go=(n={})=>Td({config:n,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(e,t,r)=>e.setBigUint64(0,BigInt(t),r),size:8}),Bd=(n={})=>Nd({config:n,get:(e,t)=>e.getBigUint64(0,t),name:"u64",size:8}),Ld=(n={})=>Id(go(n),Bd(n));class Cd extends TypeError{constructor(e,t){let r;const{message:s,explanation:i,...o}=e,{path:a}=e,f=a.length===0?s:`At path: ${a.join(".")} -- ${s}`;super(i??f),i!=null&&(this.cause=f),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>r??(r=[e,...t()])}}function Md(n){return qr(n)&&typeof n[Symbol.iterator]=="function"}function qr(n){return typeof n=="object"&&n!=null}function yn(n){return qr(n)&&!Array.isArray(n)}function Bt(n){return typeof n=="symbol"?n.toString():typeof n=="string"?JSON.stringify(n):`${n}`}function Pd(n){const{done:e,value:t}=n.next();return e?void 0:t}function Ud(n,e,t,r){if(n===!0)return;n===!1?n={}:typeof n=="string"&&(n={message:n});const{path:s,branch:i}=e,{type:o}=t,{refinement:a,message:f=`Expected a value of type \`${o}\`${a?` with refinement \`${a}\``:""}, but received: \`${Bt(r)}\``}=n;return{value:r,type:o,refinement:a,key:s[s.length-1],path:s,branch:i,...n,message:f}}function*mo(n,e,t,r){Md(n)||(n=[n]);for(const s of n){const i=Ud(s,e,t,r);i&&(yield i)}}function*ci(n,e,t={}){const{path:r=[],branch:s=[n],coerce:i=!1,mask:o=!1}=t,a={path:r,branch:s,mask:o};i&&(n=e.coercer(n,a));let f="valid";for(const g of e.validator(n,a))g.explanation=t.message,f="not_valid",yield[g,void 0];for(let[g,_,b]of e.entries(n,a)){const x=ci(_,b,{path:g===void 0?r:[...r,g],branch:g===void 0?s:[...s,_],coerce:i,mask:o,message:t.message});for(const T of x)T[0]?(f=T[0].refinement!=null?"not_refined":"not_valid",yield[T[0],void 0]):i&&(_=T[1],g===void 0?n=_:n instanceof Map?n.set(g,_):n instanceof Set?n.add(_):qr(n)&&(_!==void 0||g in n)&&(n[g]=_))}if(f!=="not_valid")for(const g of e.refiner(n,a))g.explanation=t.message,f="not_refined",yield[g,void 0];f==="valid"&&(yield[void 0,n])}let Pt=class{constructor(e){const{type:t,schema:r,validator:s,refiner:i,coercer:o=f=>f,entries:a=function*(){}}=e;this.type=t,this.schema=r,this.entries=a,this.coercer=o,s?this.validator=(f,g)=>{const _=s(f,g);return mo(_,g,this,f)}:this.validator=()=>[],i?this.refiner=(f,g)=>{const _=i(f,g);return mo(_,g,this,f)}:this.refiner=()=>[]}assert(e,t){return yo(e,this,t)}create(e,t){return se(e,this,t)}is(e){return _o(e,this)}mask(e,t){return Dd(e,this,t)}validate(e,t={}){return Vr(e,this,t)}};function yo(n,e,t){const r=Vr(n,e,{message:t});if(r[0])throw r[0]}function se(n,e,t){const r=Vr(n,e,{coerce:!0,message:t});if(r[0])throw r[0];return r[1]}function Dd(n,e,t){const r=Vr(n,e,{coerce:!0,mask:!0,message:t});if(r[0])throw r[0];return r[1]}function _o(n,e){return!Vr(n,e)[0]}function Vr(n,e,t={}){const r=ci(n,e,t),s=Pd(r);return s[0]?[new Cd(s[0],function*(){for(const o of r)o[0]&&(yield o[0])}),void 0]:[void 0,s[1]]}function fr(n,e){return new Pt({type:n,schema:null,validator:e})}function Fd(){return fr("any",()=>!0)}function oe(n){return new Pt({type:"array",schema:n,*entries(e){if(n&&Array.isArray(e))for(const[t,r]of e.entries())yield[t,r,n]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${Bt(e)}`}})}function Ut(){return fr("boolean",n=>typeof n=="boolean")}function ui(n){return fr("instance",e=>e instanceof n||`Expected a \`${n.name}\` instance, but received: ${Bt(e)}`)}function qe(n){const e=Bt(n),t=typeof n;return new Pt({type:"literal",schema:t==="string"||t==="number"||t==="boolean"?n:null,validator(r){return r===n||`Expected the literal \`${e}\`, but received: ${Bt(r)}`}})}function zd(){return fr("never",()=>!1)}function ae(n){return new Pt({...n,validator:(e,t)=>e===null||n.validator(e,t),refiner:(e,t)=>e===null||n.refiner(e,t)})}function $(){return fr("number",n=>typeof n=="number"&&!isNaN(n)||`Expected a number, but received: ${Bt(n)}`)}function le(n){return new Pt({...n,validator:(e,t)=>e===void 0||n.validator(e,t),refiner:(e,t)=>e===void 0||n.refiner(e,t)})}function wo(n,e){return new Pt({type:"record",schema:null,*entries(t){if(qr(t))for(const r in t){const s=t[r];yield[r,r,n],yield[r,s,e]}},validator(t){return yn(t)||`Expected an object, but received: ${Bt(t)}`},coercer(t){return yn(t)?{...t}:t}})}function re(){return fr("string",n=>typeof n=="string"||`Expected a string, but received: ${Bt(n)}`)}function li(n){const e=zd();return new Pt({type:"tuple",schema:null,*entries(t){if(Array.isArray(t)){const r=Math.max(n.length,t.length);for(let s=0;s<r;s++)yield[s,t[s],n[s]||e]}},validator(t){return Array.isArray(t)||`Expected an array, but received: ${Bt(t)}`},coercer(t){return Array.isArray(t)?t.slice():t}})}function ee(n){const e=Object.keys(n);return new Pt({type:"type",schema:n,*entries(t){if(qr(t))for(const r of e)yield[r,t[r],n[r]]},validator(t){return yn(t)||`Expected an object, but received: ${Bt(t)}`},coercer(t){return yn(t)?{...t}:t}})}function At(n){const e=n.map(t=>t.type).join(" | ");return new Pt({type:"union",schema:null,coercer(t,r){for(const s of n){const[i,o]=s.validate(t,{coerce:!0,mask:r.mask});if(!i)return o}return t},validator(t,r){const s=[];for(const i of n){const[...o]=ci(t,i,r),[a]=o;if(a[0])for(const[f]of o)f&&s.push(f);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${Bt(t)}`,...s]}})}function Nr(){return fr("unknown",()=>!0)}function Gr(n,e,t){return new Pt({...n,coercer:(r,s)=>_o(r,e)?n.coercer(t(r,s),s):n.coercer(r,s)})}var _n,Kd=new Uint8Array(16);function bo(){if(!_n&&(_n=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!_n))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return _n(Kd)}const $d=/^(?:[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 wn(n){return typeof n=="string"&&$d.test(n)}for(var _t=[],hi=0;hi<256;++hi)_t.push((hi+256).toString(16).substr(1));function bn(n){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=(_t[n[e+0]]+_t[n[e+1]]+_t[n[e+2]]+_t[n[e+3]]+"-"+_t[n[e+4]]+_t[n[e+5]]+"-"+_t[n[e+6]]+_t[n[e+7]]+"-"+_t[n[e+8]]+_t[n[e+9]]+"-"+_t[n[e+10]]+_t[n[e+11]]+_t[n[e+12]]+_t[n[e+13]]+_t[n[e+14]]+_t[n[e+15]]).toLowerCase();if(!wn(t))throw TypeError("Stringified UUID is invalid");return t}var Ro,fi,di=0,pi=0;function Hd(n,e,t){var r=e&&t||0,s=e||new Array(16);n=n||{};var i=n.node||Ro,o=n.clockseq!==void 0?n.clockseq:fi;if(i==null||o==null){var a=n.random||(n.rng||bo)();i==null&&(i=Ro=[a[0]|1,a[1],a[2],a[3],a[4],a[5]]),o==null&&(o=fi=(a[6]<<8|a[7])&16383)}var f=n.msecs!==void 0?n.msecs:Date.now(),g=n.nsecs!==void 0?n.nsecs:pi+1,_=f-di+(g-pi)/1e4;if(_<0&&n.clockseq===void 0&&(o=o+1&16383),(_<0||f>di)&&n.nsecs===void 0&&(g=0),g>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");di=f,pi=g,fi=o,f+=122192928e5;var b=((f&268435455)*1e4+g)%4294967296;s[r++]=b>>>24&255,s[r++]=b>>>16&255,s[r++]=b>>>8&255,s[r++]=b&255;var x=f/4294967296*1e4&268435455;s[r++]=x>>>8&255,s[r++]=x&255,s[r++]=x>>>24&15|16,s[r++]=x>>>16&255,s[r++]=o>>>8|128,s[r++]=o&255;for(var T=0;T<6;++T)s[r+T]=i[T];return e||bn(s)}function Eo(n){if(!wn(n))throw TypeError("Invalid UUID");var e,t=new Uint8Array(16);return t[0]=(e=parseInt(n.slice(0,8),16))>>>24,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=e&255,t[4]=(e=parseInt(n.slice(9,13),16))>>>8,t[5]=e&255,t[6]=(e=parseInt(n.slice(14,18),16))>>>8,t[7]=e&255,t[8]=(e=parseInt(n.slice(19,23),16))>>>8,t[9]=e&255,t[10]=(e=parseInt(n.slice(24,36),16))/1099511627776&255,t[11]=e/4294967296&255,t[12]=e>>>24&255,t[13]=e>>>16&255,t[14]=e>>>8&255,t[15]=e&255,t}function Wd(n){n=unescape(encodeURIComponent(n));for(var e=[],t=0;t<n.length;++t)e.push(n.charCodeAt(t));return e}var qd="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Vd="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function So(n,e,t){function r(s,i,o,a){if(typeof s=="string"&&(s=Wd(s)),typeof i=="string"&&(i=Eo(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=t(f),f[6]=f[6]&15|e,f[8]=f[8]&63|128,o){a=a||0;for(var g=0;g<16;++g)o[a+g]=f[g];return o}return bn(f)}try{r.name=n}catch{}return r.DNS=qd,r.URL=Vd,r}function Gd(n){if(typeof n=="string"){var e=unescape(encodeURIComponent(n));n=new Uint8Array(e.length);for(var t=0;t<e.length;++t)n[t]=e.charCodeAt(t)}return Yd(jd(Zd(n),n.length*8))}function Yd(n){for(var e=[],t=n.length*32,r="0123456789abcdef",s=0;s<t;s+=8){var i=n[s>>5]>>>s%32&255,o=parseInt(r.charAt(i>>>4&15)+r.charAt(i&15),16);e.push(o)}return e}function Ao(n){return(n+64>>>9<<4)+14+1}function jd(n,e){n[e>>5]|=128<<e%32,n[Ao(e)-1]=e;for(var t=1732584193,r=-271733879,s=-1732584194,i=271733878,o=0;o<n.length;o+=16){var a=t,f=r,g=s,_=i;t=wt(t,r,s,i,n[o],7,-680876936),i=wt(i,t,r,s,n[o+1],12,-389564586),s=wt(s,i,t,r,n[o+2],17,606105819),r=wt(r,s,i,t,n[o+3],22,-1044525330),t=wt(t,r,s,i,n[o+4],7,-176418897),i=wt(i,t,r,s,n[o+5],12,1200080426),s=wt(s,i,t,r,n[o+6],17,-1473231341),r=wt(r,s,i,t,n[o+7],22,-45705983),t=wt(t,r,s,i,n[o+8],7,1770035416),i=wt(i,t,r,s,n[o+9],12,-1958414417),s=wt(s,i,t,r,n[o+10],17,-42063),r=wt(r,s,i,t,n[o+11],22,-1990404162),t=wt(t,r,s,i,n[o+12],7,1804603682),i=wt(i,t,r,s,n[o+13],12,-40341101),s=wt(s,i,t,r,n[o+14],17,-1502002290),r=wt(r,s,i,t,n[o+15],22,1236535329),t=bt(t,r,s,i,n[o+1],5,-165796510),i=bt(i,t,r,s,n[o+6],9,-1069501632),s=bt(s,i,t,r,n[o+11],14,643717713),r=bt(r,s,i,t,n[o],20,-373897302),t=bt(t,r,s,i,n[o+5],5,-701558691),i=bt(i,t,r,s,n[o+10],9,38016083),s=bt(s,i,t,r,n[o+15],14,-660478335),r=bt(r,s,i,t,n[o+4],20,-405537848),t=bt(t,r,s,i,n[o+9],5,568446438),i=bt(i,t,r,s,n[o+14],9,-1019803690),s=bt(s,i,t,r,n[o+3],14,-187363961),r=bt(r,s,i,t,n[o+8],20,1163531501),t=bt(t,r,s,i,n[o+13],5,-1444681467),i=bt(i,t,r,s,n[o+2],9,-51403784),s=bt(s,i,t,r,n[o+7],14,1735328473),r=bt(r,s,i,t,n[o+12],20,-1926607734),t=Rt(t,r,s,i,n[o+5],4,-378558),i=Rt(i,t,r,s,n[o+8],11,-2022574463),s=Rt(s,i,t,r,n[o+11],16,1839030562),r=Rt(r,s,i,t,n[o+14],23,-35309556),t=Rt(t,r,s,i,n[o+1],4,-1530992060),i=Rt(i,t,r,s,n[o+4],11,1272893353),s=Rt(s,i,t,r,n[o+7],16,-155497632),r=Rt(r,s,i,t,n[o+10],23,-1094730640),t=Rt(t,r,s,i,n[o+13],4,681279174),i=Rt(i,t,r,s,n[o],11,-358537222),s=Rt(s,i,t,r,n[o+3],16,-722521979),r=Rt(r,s,i,t,n[o+6],23,76029189),t=Rt(t,r,s,i,n[o+9],4,-640364487),i=Rt(i,t,r,s,n[o+12],11,-421815835),s=Rt(s,i,t,r,n[o+15],16,530742520),r=Rt(r,s,i,t,n[o+2],23,-995338651),t=Et(t,r,s,i,n[o],6,-198630844),i=Et(i,t,r,s,n[o+7],10,1126891415),s=Et(s,i,t,r,n[o+14],15,-1416354905),r=Et(r,s,i,t,n[o+5],21,-57434055),t=Et(t,r,s,i,n[o+12],6,1700485571),i=Et(i,t,r,s,n[o+3],10,-1894986606),s=Et(s,i,t,r,n[o+10],15,-1051523),r=Et(r,s,i,t,n[o+1],21,-2054922799),t=Et(t,r,s,i,n[o+8],6,1873313359),i=Et(i,t,r,s,n[o+15],10,-30611744),s=Et(s,i,t,r,n[o+6],15,-1560198380),r=Et(r,s,i,t,n[o+13],21,1309151649),t=Et(t,r,s,i,n[o+4],6,-145523070),i=Et(i,t,r,s,n[o+11],10,-1120210379),s=Et(s,i,t,r,n[o+2],15,718787259),r=Et(r,s,i,t,n[o+9],21,-343485551),t=rr(t,a),r=rr(r,f),s=rr(s,g),i=rr(i,_)}return[t,r,s,i]}function Zd(n){if(n.length===0)return[];for(var e=n.length*8,t=new Uint32Array(Ao(e)),r=0;r<e;r+=8)t[r>>5]|=(n[r/8]&255)<<r%32;return t}function rr(n,e){var t=(n&65535)+(e&65535),r=(n>>16)+(e>>16)+(t>>16);return r<<16|t&65535}function Xd(n,e){return n<<e|n>>>32-e}function Rn(n,e,t,r,s,i){return rr(Xd(rr(rr(e,n),rr(r,i)),s),t)}function wt(n,e,t,r,s,i,o){return Rn(e&t|~e&r,n,e,s,i,o)}function bt(n,e,t,r,s,i,o){return Rn(e&r|t&~r,n,e,s,i,o)}function Rt(n,e,t,r,s,i,o){return Rn(e^t^r,n,e,s,i,o)}function Et(n,e,t,r,s,i,o){return Rn(t^(e|~r),n,e,s,i,o)}var Jd=So("v3",48,Gd);function Qd(n,e,t){n=n||{};var r=n.random||(n.rng||bo)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){t=t||0;for(var s=0;s<16;++s)e[t+s]=r[s];return e}return bn(r)}function e0(n,e,t,r){switch(n){case 0:return e&t^~e&r;case 1:return e^t^r;case 2:return e&t^e&r^t&r;case 3:return e^t^r}}function gi(n,e){return n<<e|n>>>32-e}function t0(n){var e=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof n=="string"){var r=unescape(encodeURIComponent(n));n=[];for(var s=0;s<r.length;++s)n.push(r.charCodeAt(s))}else Array.isArray(n)||(n=Array.prototype.slice.call(n));n.push(128);for(var i=n.length/4+2,o=Math.ceil(i/16),a=new Array(o),f=0;f<o;++f){for(var g=new Uint32Array(16),_=0;_<16;++_)g[_]=n[f*64+_*4]<<24|n[f*64+_*4+1]<<16|n[f*64+_*4+2]<<8|n[f*64+_*4+3];a[f]=g}a[o-1][14]=(n.length-1)*8/Math.pow(2,32),a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=(n.length-1)*8&4294967295;for(var b=0;b<o;++b){for(var x=new Uint32Array(80),T=0;T<16;++T)x[T]=a[b][T];for(var L=16;L<80;++L)x[L]=gi(x[L-3]^x[L-8]^x[L-14]^x[L-16],1);for(var k=t[0],N=t[1],M=t[2],H=t[3],K=t[4],J=0;J<80;++J){var q=Math.floor(J/20),D=gi(k,5)+e0(q,N,M,H)+K+e[q]+x[J]>>>0;K=H,H=M,M=gi(N,30)>>>0,N=k,k=D}t[0]=t[0]+k>>>0,t[1]=t[1]+N>>>0,t[2]=t[2]+M>>>0,t[3]=t[3]+H>>>0,t[4]=t[4]+K>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,t[0]&255,t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,t[1]&255,t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,t[2]&255,t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,t[3]&255,t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,t[4]&255]}var r0=So("v5",80,t0);const n0="00000000-0000-0000-0000-000000000000";function i0(n){if(!wn(n))throw TypeError("Invalid UUID");return parseInt(n.substr(14,1),16)}const Io=zn(Object.freeze(Object.defineProperty({__proto__:null,NIL:n0,parse:Eo,stringify:bn,v1:Hd,v3:Jd,v4:Qd,v5:r0,validate:wn,version:i0},Symbol.toStringTag,{value:"Module"})));var mi,vo;function s0(){if(vo)return mi;vo=1;const n=Io.v4;return mi=function(t,r,s,i){if(typeof t!="string")throw new TypeError(t+" must be a string");i=i||{};const o=typeof i.version=="number"?i.version:2;if(o!==1&&o!==2)throw new TypeError(o+" must be 1 or 2");const a={method:t};if(o===2&&(a.jsonrpc="2.0"),r){if(typeof r!="object"&&!Array.isArray(r))throw new TypeError(r+" must be an object, array or omitted");a.params=r}if(typeof s>"u"){const f=typeof i.generator=="function"?i.generator:function(){return n()};a.id=f(a,i)}else o===2&&s===null?i.notificationIdNull&&(a.id=null):a.id=s;return a},mi}var yi,Oo;function o0(){if(Oo)return yi;Oo=1;const n=Io.v4,e=s0(),t=function(r,s){if(!(this instanceof t))return new t(r,s);s||(s={}),this.options={reviver:typeof s.reviver<"u"?s.reviver:null,replacer:typeof s.replacer<"u"?s.replacer:null,generator:typeof s.generator<"u"?s.generator:function(){return n()},version:typeof s.version<"u"?s.version:2,notificationIdNull:typeof s.notificationIdNull=="boolean"?s.notificationIdNull:!1},this.callServer=r};return yi=t,t.prototype.request=function(r,s,i,o){const a=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 x=typeof o=="function";try{f=e(r,s,i,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(T){if(x)return o(T);throw T}if(!x)return f}let b;try{b=JSON.stringify(f,this.options.replacer)}catch(x){return o(x)}return this.callServer(b,function(x,T){a._parseResponse(x,T,o)}),f},t.prototype._parseResponse=function(r,s,i){if(r){i(r);return}if(!s)return i();let o;try{o=JSON.parse(s,this.options.reviver)}catch(a){return i(a)}if(i.length===3)if(Array.isArray(o)){const a=function(g){return typeof g.error<"u"},f=function(g){return!a(g)};return i(null,o.filter(a),o.filter(f))}else return i(null,o.error,o.result);i(null,o)},yi}var a0=o0();const c0=zr(a0);var _i={exports:{}},ko;function u0(){return ko||(ko=1,function(n){var e=Object.prototype.hasOwnProperty,t="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(t=!1));function s(f,g,_){this.fn=f,this.context=g,this.once=_||!1}function i(f,g,_,b,x){if(typeof _!="function")throw new TypeError("The listener must be a function");var T=new s(_,b||f,x),L=t?t+g:g;return f._events[L]?f._events[L].fn?f._events[L]=[f._events[L],T]:f._events[L].push(T):(f._events[L]=T,f._eventsCount++),f}function o(f,g){--f._eventsCount===0?f._events=new r:delete f._events[g]}function a(){this._events=new r,this._eventsCount=0}a.prototype.eventNames=function(){var g=[],_,b;if(this._eventsCount===0)return g;for(b in _=this._events)e.call(_,b)&&g.push(t?b.slice(1):b);return Object.getOwnPropertySymbols?g.concat(Object.getOwnPropertySymbols(_)):g},a.prototype.listeners=function(g){var _=t?t+g:g,b=this._events[_];if(!b)return[];if(b.fn)return[b.fn];for(var x=0,T=b.length,L=new Array(T);x<T;x++)L[x]=b[x].fn;return L},a.prototype.listenerCount=function(g){var _=t?t+g:g,b=this._events[_];return b?b.fn?1:b.length:0},a.prototype.emit=function(g,_,b,x,T,L){var k=t?t+g:g;if(!this._events[k])return!1;var N=this._events[k],M=arguments.length,H,K;if(N.fn){switch(N.once&&this.removeListener(g,N.fn,void 0,!0),M){case 1:return N.fn.call(N.context),!0;case 2:return N.fn.call(N.context,_),!0;case 3:return N.fn.call(N.context,_,b),!0;case 4:return N.fn.call(N.context,_,b,x),!0;case 5:return N.fn.call(N.context,_,b,x,T),!0;case 6:return N.fn.call(N.context,_,b,x,T,L),!0}for(K=1,H=new Array(M-1);K<M;K++)H[K-1]=arguments[K];N.fn.apply(N.context,H)}else{var J=N.length,q;for(K=0;K<J;K++)switch(N[K].once&&this.removeListener(g,N[K].fn,void 0,!0),M){case 1:N[K].fn.call(N[K].context);break;case 2:N[K].fn.call(N[K].context,_);break;case 3:N[K].fn.call(N[K].context,_,b);break;case 4:N[K].fn.call(N[K].context,_,b,x);break;default:if(!H)for(q=1,H=new Array(M-1);q<M;q++)H[q-1]=arguments[q];N[K].fn.apply(N[K].context,H)}}return!0},a.prototype.on=function(g,_,b){return i(this,g,_,b,!1)},a.prototype.once=function(g,_,b){return i(this,g,_,b,!0)},a.prototype.removeListener=function(g,_,b,x){var T=t?t+g:g;if(!this._events[T])return this;if(!_)return o(this,T),this;var L=this._events[T];if(L.fn)L.fn===_&&(!x||L.once)&&(!b||L.context===b)&&o(this,T);else{for(var k=0,N=[],M=L.length;k<M;k++)(L[k].fn!==_||x&&!L[k].once||b&&L[k].context!==b)&&N.push(L[k]);N.length?this._events[T]=N.length===1?N[0]:N:o(this,T)}return this},a.prototype.removeAllListeners=function(g){var _;return g?(_=t?t+g:g,this._events[_]&&o(this,_)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=t,a.EventEmitter=a,n.exports=a}(_i)),_i.exports}var l0=u0();const To=zr(l0);var h0=class extends To{constructor(e,t,r){super();Ye(this,"socket");this.socket=new window.WebSocket(e,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(e,t,r){const s=r||t;try{this.socket.send(e),s()}catch(i){s(i)}}close(e,t){this.socket.close(e,t)}addEventListener(e,t,r){this.socket.addEventListener(e,t,r)}};function f0(n,e){return new h0(n,e)}var d0=class{encode(n){return JSON.stringify(n)}decode(n){return JSON.parse(n)}},p0=class extends To{constructor(e,t="ws://localhost:8080",{autoconnect:r=!0,reconnect:s=!0,reconnect_interval:i=1e3,max_reconnects:o=5,...a}={},f,g){super();Ye(this,"address");Ye(this,"rpc_id");Ye(this,"queue");Ye(this,"options");Ye(this,"autoconnect");Ye(this,"ready");Ye(this,"reconnect");Ye(this,"reconnect_timer_id");Ye(this,"reconnect_interval");Ye(this,"max_reconnects");Ye(this,"rest_options");Ye(this,"current_reconnects");Ye(this,"generate_request_id");Ye(this,"socket");Ye(this,"webSocketFactory");Ye(this,"dataPack");this.webSocketFactory=e,this.queue={},this.rpc_id=0,this.address=t,this.autoconnect=r,this.ready=!1,this.reconnect=s,this.reconnect_timer_id=void 0,this.reconnect_interval=i,this.max_reconnects=o,this.rest_options=a,this.current_reconnects=0,this.generate_request_id=f||(()=>++this.rpc_id),g?this.dataPack=g:this.dataPack=new d0,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(e,t,r,s){return!s&&typeof r=="object"&&(s=r,r=null),new Promise((i,o)=>{if(!this.ready)return o(new Error("socket not ready"));const a=this.generate_request_id(e,t),f={jsonrpc:"2.0",method:e,params:t||void 0,id:a};this.socket.send(this.dataPack.encode(f),s,g=>{if(g)return o(g);this.queue[a]={promise:[i,o]},r&&(this.queue[a].timeout=setTimeout(()=>{delete this.queue[a],o(new Error("reply timeout"))},r))})})}async login(e){const t=await this.call("rpc.login",e);if(!t)throw new Error("authentication failed");return t}async listMethods(){return await this.call("__listMethods")}notify(e,t){return new Promise((r,s)=>{if(!this.ready)return s(new Error("socket not ready"));const i={jsonrpc:"2.0",method:e,params:t};this.socket.send(this.dataPack.encode(i),o=>{if(o)return s(o);r()})})}async subscribe(e){typeof e=="string"&&(e=[e]);const t=await this.call("rpc.on",e);if(typeof e=="string"&&t[e]!=="ok")throw new Error("Failed subscribing to an event '"+e+"' with: "+t[e]);return t}async unsubscribe(e){typeof e=="string"&&(e=[e]);const t=await this.call("rpc.off",e);if(typeof e=="string"&&t[e]!=="ok")throw new Error("Failed unsubscribing from an event with: "+t);return t}close(e,t){this.socket.close(e||1e3,t)}setAutoReconnect(e){this.reconnect=e}setReconnectInterval(e){this.reconnect_interval=e}setMaxReconnects(e){this.max_reconnects=e}_connect(e,t){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(e,t),this.socket.addEventListener("open",()=>{this.ready=!0,this.emit("open"),this.current_reconnects=0}),this.socket.addEventListener("message",({data:r})=>{r instanceof ArrayBuffer&&(r=he.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(e,t),this.reconnect_interval)))})}};const No=[],xo=[],Bo=[],g0=BigInt(0),Yr=BigInt(1),m0=BigInt(2),y0=BigInt(7),_0=BigInt(256),w0=BigInt(113);for(let n=0,e=Yr,t=1,r=0;n<24;n++){[t,r]=[r,(2*t+3*r)%5],No.push(2*(5*r+t)),xo.push((n+1)*(n+2)/2%64);let s=g0;for(let i=0;i<7;i++)e=(e<<Yr^(e>>y0)*w0)%_0,e&m0&&(s^=Yr<<(Yr<<BigInt(i))-Yr);Bo.push(s)}const[b0,R0]=Bs(Bo,!0),Lo=(n,e,t)=>t>32?Ms(n,e,t):Ls(n,e,t),Co=(n,e,t)=>t>32?Ps(n,e,t):Cs(n,e,t);function E0(n,e=24){const t=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)t[o]=n[o]^n[o+10]^n[o+20]^n[o+30]^n[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,f=(o+2)%10,g=t[f],_=t[f+1],b=Lo(g,_,1)^t[a],x=Co(g,_,1)^t[a+1];for(let T=0;T<50;T+=10)n[o+T]^=b,n[o+T+1]^=x}let s=n[2],i=n[3];for(let o=0;o<24;o++){const a=xo[o],f=Lo(s,i,a),g=Co(s,i,a),_=No[o];s=n[_],i=n[_+1],n[_]=f,n[_+1]=g}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=n[o+a];for(let a=0;a<10;a++)n[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}n[0]^=b0[r],n[1]^=R0[r]}t.fill(0)}class wi extends qn{constructor(e,t,r,s=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,sn(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Ja(this.state)}keccak(){Os||ks(this.state32),E0(this.state32,this.rounds),Os||ks(this.state32),this.posOut=0,this.pos=0}update(e){Rr(this);const{blockLen:t,state:r}=this;e=on(e);const s=e.length;for(let i=0;i<s;){const o=Math.min(t-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:r,blockLen:s}=this;e[r]^=t,(t&128)!==0&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){Rr(this,!1),$r(e),this.finish();const t=this.state,{blockLen:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-s);e.set(t.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return sn(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(vs(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new wi(t,r,s,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}}const Mo=((n,e,t)=>Vn(()=>new wi(e,n,t)))(1,136,256/8);class Po extends qn{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Xa(e);const r=on(t);if(this.iHash=e.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?e.create().update(r).digest():r);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=e.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),i.fill(0)}update(e){return Rr(this),this.iHash.update(e),this}digestInto(e){Rr(this),$r(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:r,finished:s,destroyed:i,blockLen:o,outputLen:a}=this;return e=e,e.finished=s,e.destroyed=i,e.blockLen=o,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Uo=(n,e,t)=>new Po(n,e).update(t).digest();Uo.create=(n,e)=>new Po(n,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function S0(n){const e=ei(n);Ir(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:t,Fp:r,a:s}=e;if(t){if(!r.eql(s,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:A0,hexToBytes:I0}=kc,dr={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(n){const{Err:e}=dr;if(n.length<2||n[0]!==2)throw new e("Invalid signature integer tag");const t=n[1],r=n.subarray(2,t+2);if(!t||r.length!==t)throw new e("Invalid signature integer: wrong length");if(r[0]&128)throw new e("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:A0(r),l:n.subarray(t+2)}},toSig(n){const{Err:e}=dr,t=typeof n=="string"?I0(n):n;Hr(t);let r=t.length;if(r<2||t[0]!=48)throw new e("Invalid signature tag");if(t[1]!==r-2)throw new e("Invalid signature: incorrect length");const{d:s,l:i}=dr._parseInt(t.subarray(2)),{d:o,l:a}=dr._parseInt(i);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:s,s:o}},hexFromSig(n){const e=g=>Number.parseInt(g[0],16)&8?"00"+g:g,t=g=>{const _=g.toString(16);return _.length&1?`0${_}`:_},r=e(t(n.s)),s=e(t(n.r)),i=r.length/2,o=s.length/2,a=t(i),f=t(o);return`30${t(o+i+4)}02${f}${s}02${a}${r}`}},jt=BigInt(0),Nt=BigInt(1);BigInt(2);const Do=BigInt(3);BigInt(4);function v0(n){const e=S0(n),{Fp:t}=e,r=e.toBytes||((L,k,N)=>{const M=k.toAffine();return lr(Uint8Array.from([4]),t.toBytes(M.x),t.toBytes(M.y))}),s=e.fromBytes||(L=>{const k=L.subarray(1),N=t.fromBytes(k.subarray(0,t.BYTES)),M=t.fromBytes(k.subarray(t.BYTES,2*t.BYTES));return{x:N,y:M}});function i(L){const{a:k,b:N}=e,M=t.sqr(L),H=t.mul(M,L);return t.add(t.add(H,t.mul(L,k)),N)}if(!t.eql(t.sqr(e.Gy),i(e.Gx)))throw new Error("bad generator point: equation left != right");function o(L){return typeof L=="bigint"&&jt<L&&L<e.n}function a(L){if(!o(L))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function f(L){const{allowedPrivateKeyLengths:k,nByteLength:N,wrapPrivateKey:M,n:H}=e;if(k&&typeof L!="bigint"){if(ar(L)&&(L=cr(L)),typeof L!="string"||!k.includes(L.length))throw new Error("Invalid key");L=L.padStart(N*2,"0")}let K;try{K=typeof L=="bigint"?L:ur(dt("private key",L,N))}catch{throw new Error(`private key must be ${N} bytes, hex or bigint, not ${typeof L}`)}return M&&(K=$e(K,H)),a(K),K}const g=new Map;function _(L){if(!(L instanceof b))throw new Error("ProjectivePoint expected")}class b{constructor(k,N,M){if(this.px=k,this.py=N,this.pz=M,k==null||!t.isValid(k))throw new Error("x required");if(N==null||!t.isValid(N))throw new Error("y required");if(M==null||!t.isValid(M))throw new Error("z required")}static fromAffine(k){const{x:N,y:M}=k||{};if(!k||!t.isValid(N)||!t.isValid(M))throw new Error("invalid affine point");if(k instanceof b)throw new Error("projective point not allowed");const H=K=>t.eql(K,t.ZERO);return H(N)&&H(M)?b.ZERO:new b(N,M,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(k){const N=t.invertBatch(k.map(M=>M.pz));return k.map((M,H)=>M.toAffine(N[H])).map(b.fromAffine)}static fromHex(k){const N=b.fromAffine(s(dt("pointHex",k)));return N.assertValidity(),N}static fromPrivateKey(k){return b.BASE.multiply(f(k))}_setWindowSize(k){this._WINDOW_SIZE=k,g.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!t.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:k,y:N}=this.toAffine();if(!t.isValid(k)||!t.isValid(N))throw new Error("bad point: x or y not FE");const M=t.sqr(N),H=i(k);if(!t.eql(M,H))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:k}=this.toAffine();if(t.isOdd)return!t.isOdd(k);throw new Error("Field doesn't support isOdd")}equals(k){_(k);const{px:N,py:M,pz:H}=this,{px:K,py:J,pz:q}=k,D=t.eql(t.mul(N,q),t.mul(K,H)),Z=t.eql(t.mul(M,q),t.mul(J,H));return D&&Z}negate(){return new b(this.px,t.neg(this.py),this.pz)}double(){const{a:k,b:N}=e,M=t.mul(N,Do),{px:H,py:K,pz:J}=this;let q=t.ZERO,D=t.ZERO,Z=t.ZERO,j=t.mul(H,H),X=t.mul(K,K),z=t.mul(J,J),V=t.mul(H,K);return V=t.add(V,V),Z=t.mul(H,J),Z=t.add(Z,Z),q=t.mul(k,Z),D=t.mul(M,z),D=t.add(q,D),q=t.sub(X,D),D=t.add(X,D),D=t.mul(q,D),q=t.mul(V,q),Z=t.mul(M,Z),z=t.mul(k,z),V=t.sub(j,z),V=t.mul(k,V),V=t.add(V,Z),Z=t.add(j,j),j=t.add(Z,j),j=t.add(j,z),j=t.mul(j,V),D=t.add(D,j),z=t.mul(K,J),z=t.add(z,z),j=t.mul(z,V),q=t.sub(q,j),Z=t.mul(z,X),Z=t.add(Z,Z),Z=t.add(Z,Z),new b(q,D,Z)}add(k){_(k);const{px:N,py:M,pz:H}=this,{px:K,py:J,pz:q}=k;let D=t.ZERO,Z=t.ZERO,j=t.ZERO;const X=e.a,z=t.mul(e.b,Do);let V=t.mul(N,K),Q=t.mul(M,J),A=t.mul(H,q),c=t.add(N,M),p=t.add(K,J);c=t.mul(c,p),p=t.add(V,Q),c=t.sub(c,p),p=t.add(N,H);let m=t.add(K,q);return p=t.mul(p,m),m=t.add(V,A),p=t.sub(p,m),m=t.add(M,H),D=t.add(J,q),m=t.mul(m,D),D=t.add(Q,A),m=t.sub(m,D),j=t.mul(X,p),D=t.mul(z,A),j=t.add(D,j),D=t.sub(Q,j),j=t.add(Q,j),Z=t.mul(D,j),Q=t.add(V,V),Q=t.add(Q,V),A=t.mul(X,A),p=t.mul(z,p),Q=t.add(Q,A),A=t.sub(V,A),A=t.mul(X,A),p=t.add(p,A),V=t.mul(Q,p),Z=t.add(Z,V),V=t.mul(m,p),D=t.mul(c,D),D=t.sub(D,V),V=t.mul(c,Q),j=t.mul(m,j),j=t.add(j,V),new b(D,Z,j)}subtract(k){return this.add(k.negate())}is0(){return this.equals(b.ZERO)}wNAF(k){return T.wNAFCached(this,g,k,N=>{const M=t.invertBatch(N.map(H=>H.pz));return N.map((H,K)=>H.toAffine(M[K])).map(b.fromAffine)})}multiplyUnsafe(k){const N=b.ZERO;if(k===jt)return N;if(a(k),k===Nt)return this;const{endo:M}=e;if(!M)return T.unsafeLadder(this,k);let{k1neg:H,k1:K,k2neg:J,k2:q}=M.splitScalar(k),D=N,Z=N,j=this;for(;K>jt||q>jt;)K&Nt&&(D=D.add(j)),q&Nt&&(Z=Z.add(j)),j=j.double(),K>>=Nt,q>>=Nt;return H&&(D=D.negate()),J&&(Z=Z.negate()),Z=new b(t.mul(Z.px,M.beta),Z.py,Z.pz),D.add(Z)}multiply(k){a(k);let N=k,M,H;const{endo:K}=e;if(K){const{k1neg:J,k1:q,k2neg:D,k2:Z}=K.splitScalar(N);let{p:j,f:X}=this.wNAF(q),{p:z,f:V}=this.wNAF(Z);j=T.constTimeNegate(J,j),z=T.constTimeNegate(D,z),z=new b(t.mul(z.px,K.beta),z.py,z.pz),M=j.add(z),H=X.add(V)}else{const{p:J,f:q}=this.wNAF(N);M=J,H=q}return b.normalizeZ([M,H])[0]}multiplyAndAddUnsafe(k,N,M){const H=b.BASE,K=(q,D)=>D===jt||D===Nt||!q.equals(H)?q.multiplyUnsafe(D):q.multiply(D),J=K(this,N).add(K(k,M));return J.is0()?void 0:J}toAffine(k){const{px:N,py:M,pz:H}=this,K=this.is0();k==null&&(k=K?t.ONE:t.inv(H));const J=t.mul(N,k),q=t.mul(M,k),D=t.mul(H,k);if(K)return{x:t.ZERO,y:t.ZERO};if(!t.eql(D,t.ONE))throw new Error("invZ was invalid");return{x:J,y:q}}isTorsionFree(){const{h:k,isTorsionFree:N}=e;if(k===Nt)return!0;if(N)return N(b,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:k,clearCofactor:N}=e;return k===Nt?this:N?N(b,this):this.multiplyUnsafe(e.h)}toRawBytes(k=!0){return this.assertValidity(),r(b,this,k)}toHex(k=!0){return cr(this.toRawBytes(k))}}b.BASE=new b(e.Gx,e.Gy,t.ONE),b.ZERO=new b(t.ZERO,t.ONE,t.ZERO);const x=e.nBitLength,T=Ys(b,e.endo?Math.ceil(x/2):x);return{CURVE:e,ProjectivePoint:b,normPrivateKeyToScalar:f,weierstrassEquation:i,isWithinCurveOrder:o}}function O0(n){const e=ei(n);return Ir(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function k0(n){const e=O0(n),{Fp:t,n:r}=e,s=t.BYTES+1,i=2*t.BYTES+1;function o(p){return jt<p&&p<t.ORDER}function a(p){return $e(p,r)}function f(p){return Jn(p,r)}const{ProjectivePoint:g,normPrivateKeyToScalar:_,weierstrassEquation:b,isWithinCurveOrder:x}=v0({...e,toBytes(p,m,v){const S=m.toAffine(),I=t.toBytes(S.x),C=lr;return v?C(Uint8Array.from([m.hasEvenY()?2:3]),I):C(Uint8Array.from([4]),I,t.toBytes(S.y))},fromBytes(p){const m=p.length,v=p[0],S=p.subarray(1);if(m===s&&(v===2||v===3)){const I=ur(S);if(!o(I))throw new Error("Point is not on curve");const C=b(I);let R;try{R=t.sqrt(C)}catch(w){const E=w instanceof Error?": "+w.message:"";throw new Error("Point is not on curve"+E)}const u=(R&Nt)===Nt;return(v&1)===1!==u&&(R=t.neg(R)),{x:I,y:R}}else if(m===i&&v===4){const I=t.fromBytes(S.subarray(0,t.BYTES)),C=t.fromBytes(S.subarray(t.BYTES,2*t.BYTES));return{x:I,y:C}}else throw new Error(`Point of length ${m} was invalid. Expected ${s} compressed bytes or ${i} uncompressed bytes`)}}),T=p=>cr(Ar(p,e.nByteLength));function L(p){const m=r>>Nt;return p>m}function k(p){return L(p)?a(-p):p}const N=(p,m,v)=>ur(p.slice(m,v));class M{constructor(m,v,S){this.r=m,this.s=v,this.recovery=S,this.assertValidity()}static fromCompact(m){const v=e.nByteLength;return m=dt("compactSignature",m,v*2),new M(N(m,0,v),N(m,v,2*v))}static fromDER(m){const{r:v,s:S}=dr.toSig(dt("DER",m));return new M(v,S)}assertValidity(){if(!x(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!x(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(m){return new M(this.r,this.s,m)}recoverPublicKey(m){const{r:v,s:S,recovery:I}=this,C=Z(dt("msgHash",m));if(I==null||![0,1,2,3].includes(I))throw new Error("recovery id invalid");const R=I===2||I===3?v+e.n:v;if(R>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const u=(I&1)===0?"02":"03",l=g.fromHex(u+T(R)),w=f(R),E=a(-C*w),P=a(S*w),G=g.BASE.multiplyAndAddUnsafe(l,E,P);if(!G)throw new Error("point at infinify");return G.assertValidity(),G}hasHighS(){return L(this.s)}normalizeS(){return this.hasHighS()?new M(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Er(this.toDERHex())}toDERHex(){return dr.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Er(this.toCompactHex())}toCompactHex(){return T(this.r)+T(this.s)}}const H={isValidPrivateKey(p){try{return _(p),!0}catch{return!1}},normPrivateKeyToScalar:_,randomPrivateKey:()=>{const p=Gs(e.n);return Dc(e.randomBytes(p),e.n)},precompute(p=8,m=g.BASE){return m._setWindowSize(p),m.multiply(BigInt(3)),m}};function K(p,m=!0){return g.fromPrivateKey(p).toRawBytes(m)}function J(p){const m=ar(p),v=typeof p=="string",S=(m||v)&&p.length;return m?S===s||S===i:v?S===2*s||S===2*i:p instanceof g}function q(p,m,v=!0){if(J(p))throw new Error("first arg must be private key");if(!J(m))throw new Error("second arg must be public key");return g.fromHex(m).multiply(_(p)).toRawBytes(v)}const D=e.bits2int||function(p){const m=ur(p),v=p.length*8-e.nBitLength;return v>0?m>>BigInt(v):m},Z=e.bits2int_modN||function(p){return a(D(p))},j=jn(e.nBitLength);function X(p){if(typeof p!="bigint")throw new Error("bigint expected");if(!(jt<=p&&p<j))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Ar(p,e.nByteLength)}function z(p,m,v=V){if(["recovered","canonical"].some(ce=>ce in v))throw new Error("sign() legacy options not supported");const{hash:S,randomBytes:I}=e;let{lowS:C,prehash:R,extraEntropy:u}=v;C==null&&(C=!0),p=dt("msgHash",p),R&&(p=dt("prehashed msgHash",S(p)));const l=Z(p),w=_(m),E=[X(w),X(l)];if(u!=null&&u!==!1){const ce=u===!0?I(t.BYTES):u;E.push(dt("extraEntropy",ce))}const P=lr(...E),G=l;function ne(ce){const ve=D(ce);if(!x(ve))return;const ge=f(ve),Re=g.BASE.multiply(ve).toAffine(),ke=a(Re.x);if(ke===jt)return;const Ee=a(ge*a(G+ke*w));if(Ee===jt)return;let Ne=(Re.x===ke?0:2)|Number(Re.y&Nt),qt=Ee;return C&&L(Ee)&&(qt=k(Ee),Ne^=1),new M(ke,qt,Ne)}return{seed:P,k2sig:ne}}const V={lowS:e.lowS,prehash:!1},Q={lowS:e.lowS,prehash:!1};function A(p,m,v=V){const{seed:S,k2sig:I}=z(p,m,v),C=e;return Ks(C.hash.outputLen,C.nByteLength,C.hmac)(S,I)}g.BASE._setWindowSize(8);function c(p,m,v,S=Q){var Re;const I=p;if(m=dt("msgHash",m),v=dt("publicKey",v),"strict"in S)throw new Error("options.strict was renamed to lowS");const{lowS:C,prehash:R}=S;let u,l;try{if(typeof I=="string"||ar(I))try{u=M.fromDER(I)}catch(ke){if(!(ke instanceof dr.Err))throw ke;u=M.fromCompact(I)}else if(typeof I=="object"&&typeof I.r=="bigint"&&typeof I.s=="bigint"){const{r:ke,s:Ee}=I;u=new M(ke,Ee)}else throw new Error("PARSE");l=g.fromHex(v)}catch(ke){if(ke.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(C&&u.hasHighS())return!1;R&&(m=e.hash(m));const{r:w,s:E}=u,P=Z(m),G=f(E),ne=a(P*G),ce=a(w*G),ve=(Re=g.BASE.multiplyAndAddUnsafe(l,ne,ce))==null?void 0:Re.toAffine();return ve?a(ve.x)===w:!1}return{CURVE:e,getPublicKey:K,getSharedSecret:q,sign:A,verify:c,ProjectivePoint:g,Signature:M,utils:H}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function T0(n){return{hash:n,hmac:(e,...t)=>Uo(n,e,tc(...t)),randomBytes:Ts}}function N0(n,e){const t=r=>k0({...n,...T0(r)});return Object.freeze({...t(e),create:t})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Fo=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),zo=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),x0=BigInt(1),bi=BigInt(2),Ko=(n,e)=>(n+e/bi)/e;function B0(n){const e=Fo,t=BigInt(3),r=BigInt(6),s=BigInt(11),i=BigInt(22),o=BigInt(23),a=BigInt(44),f=BigInt(88),g=n*n*n%e,_=g*g*n%e,b=Ge(_,t,e)*_%e,x=Ge(b,t,e)*_%e,T=Ge(x,bi,e)*g%e,L=Ge(T,s,e)*T%e,k=Ge(L,i,e)*L%e,N=Ge(k,a,e)*k%e,M=Ge(N,f,e)*N%e,H=Ge(M,a,e)*k%e,K=Ge(H,t,e)*_%e,J=Ge(K,o,e)*L%e,q=Ge(J,r,e)*g%e,D=Ge(q,bi,e);if(!Ri.eql(Ri.sqr(D),n))throw new Error("Cannot find square root");return D}const Ri=qs(Fo,void 0,void 0,{sqrt:B0}),En=N0({a:BigInt(0),b:BigInt(7),Fp:Ri,n:zo,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:n=>{const e=zo,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-x0*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=t,o=BigInt("0x100000000000000000000000000000000"),a=Ko(i*n,e),f=Ko(-r*n,e);let g=$e(n-a*t-f*s,e),_=$e(-a*r-f*i,e);const b=g>o,x=_>o;if(b&&(g=e-g),x&&(_=e-_),g>o||_>o)throw new Error("splitScalar: Endomorphism failed, k="+n);return{k1neg:b,k1:g,k2neg:x,k2:_}}}},ii);BigInt(0),En.ProjectivePoint;const L0=vr.utils.randomPrivateKey,$o=()=>{const n=vr.utils.randomPrivateKey(),e=Sn(n),t=new Uint8Array(64);return t.set(n),t.set(e,32),{publicKey:e,secretKey:t}},Sn=vr.getPublicKey;function Ho(n){try{return vr.ExtendedPoint.fromHex(n),!0}catch{return!1}}const Ei=(n,e)=>vr.sign(n,e.slice(0,32)),C0=vr.verify,_e=n=>he.Buffer.isBuffer(n)?n:n instanceof Uint8Array?he.Buffer.from(n.buffer,n.byteOffset,n.byteLength):he.Buffer.from(n);class Si{constructor(e){Object.assign(this,e)}encode(){return he.Buffer.from(ai.serialize(jr,this))}static decode(e){return ai.deserialize(jr,this,e)}static decodeUnchecked(e){return ai.deserializeUnchecked(jr,this,e)}}class M0 extends Si{constructor(e){if(super(e),this.enum="",Object.keys(e).length!==1)throw new Error("Enum can only take single value");Object.keys(e).map(t=>{this.enum=t})}}const jr=new Map;var Wo;const qo=32,Dt=32;function P0(n){return n._bn!==void 0}let Vo=1;class ie extends Si{constructor(e){if(super({}),this._bn=void 0,P0(e))this._bn=e._bn;else{if(typeof e=="string"){const t=gt.decode(e);if(t.length!=Dt)throw new Error("Invalid public key input");this._bn=new Qs(t)}else this._bn=new Qs(e);if(this._bn.byteLength()>Dt)throw new Error("Invalid public key input")}}static unique(){const e=new ie(Vo);return Vo+=1,new ie(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return gt.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){const e=this._bn.toArrayLike(he.Buffer);if(e.length===Dt)return e;const t=he.Buffer.alloc(32);return e.copy(t,32-e.length),t}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(e,t,r){const s=he.Buffer.concat([e.toBuffer(),he.Buffer.from(t),r.toBuffer()]),i=ii(s);return new ie(i)}static createProgramAddressSync(e,t){let r=he.Buffer.alloc(0);e.forEach(function(i){if(i.length>qo)throw new TypeError("Max seed length exceeded");r=he.Buffer.concat([r,_e(i)])}),r=he.Buffer.concat([r,t.toBuffer(),he.Buffer.from("ProgramDerivedAddress")]);const s=ii(r);if(Ho(s))throw new Error("Invalid seeds, address must fall off the curve");return new ie(s)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let r=255,s;for(;r!=0;){try{const i=e.concat(he.Buffer.from([r]));s=this.createProgramAddressSync(i,t)}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(e,t){return this.findProgramAddressSync(e,t)}static isOnCurve(e){const t=new ie(e);return Ho(t.toBytes())}}Wo=ie,ie.default=new Wo("11111111111111111111111111111111"),jr.set(ie,{kind:"struct",fields:[["_bn","u256"]]});class U0{constructor(e){if(this._publicKey=void 0,this._secretKey=void 0,e){const t=_e(e);if(e.length!==64)throw new Error("bad secret key size");this._publicKey=t.slice(32,64),this._secretKey=t.slice(0,32)}else this._secretKey=_e(L0()),this._publicKey=_e(Sn(this._secretKey))}get publicKey(){return new ie(this._publicKey)}get secretKey(){return he.Buffer.concat([this._secretKey,this._publicKey],64)}}const D0=new ie("BPFLoader1111111111111111111111111111111111"),nr=1232,An=127,Zr=64;class Ai extends Error{constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}}Object.defineProperty(Ai.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class Ii extends Error{constructor(e,t){super(`Transaction was not confirmed in ${t.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${e} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=e}}Object.defineProperty(Ii.prototype,"name",{value:"TransactionExpiredTimeoutError"});class xr extends Error{constructor(e){super(`Signature ${e} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=e}}Object.defineProperty(xr.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class Xr{constructor(e,t){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=t}keySegments(){const e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(const t of this.keySegments()){if(e<t.length)return t[e];e-=t.length}}get length(){return this.keySegments().flat().length}compileInstructions(e){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 e.map(i=>({programIdIndex:s(i.programId),accountKeyIndexes:i.keys.map(o=>s(o.pubkey)),data:i.data}))}}const Se=(n="publicKey")=>B.blob(32,n),F0=(n="signature")=>B.blob(64,n),pr=(n="string")=>{const e=B.struct([B.u32("length"),B.u32("lengthPadding"),B.blob(B.offset(B.u32(),-8),"chars")],n),t=e.decode.bind(e),r=e.encode.bind(e),s=e;return s.decode=(i,o)=>t(i,o).chars.toString(),s.encode=(i,o,a)=>{const f={chars:he.Buffer.from(i,"utf8")};return r(f,o,a)},s.alloc=i=>B.u32().span+B.u32().span+he.Buffer.from(i,"utf8").length,s},z0=(n="authorized")=>B.struct([Se("staker"),Se("withdrawer")],n),K0=(n="lockup")=>B.struct([B.ns64("unixTimestamp"),B.ns64("epoch"),Se("custodian")],n),$0=(n="voteInit")=>B.struct([Se("nodePubkey"),Se("authorizedVoter"),Se("authorizedWithdrawer"),B.u8("commission")],n),H0=(n="voteAuthorizeWithSeedArgs")=>B.struct([B.u32("voteAuthorizationType"),Se("currentAuthorityDerivedKeyOwnerPubkey"),pr("currentAuthorityDerivedKeySeed"),Se("newAuthorized")],n);function Go(n,e){const t=s=>{if(s.span>=0)return s.span;if(typeof s.alloc=="function")return s.alloc(e[s.property]);if("count"in s&&"elementLayout"in s){const i=e[s.property];if(Array.isArray(i))return i.length*t(s.elementLayout)}else if("fields"in s)return Go({layout:s},e[s.property]);return 0};let r=0;return n.layout.fields.forEach(s=>{r+=t(s)}),r}function It(n){let e=0,t=0;for(;;){let r=n.shift();if(e|=(r&127)<<t*7,t+=1,(r&128)===0)break}return e}function Tt(n,e){let t=e;for(;;){let r=t&127;if(t>>=7,t==0){n.push(r);break}else r|=128,n.push(r)}}function Ie(n,e){if(!n)throw new Error(e||"Assertion failed")}class In{constructor(e,t){this.payer=void 0,this.keyMetaMap=void 0,this.payer=e,this.keyMetaMap=t}static compile(e,t){const r=new Map,s=o=>{const a=o.toBase58();let f=r.get(a);return f===void 0&&(f={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(a,f)),f},i=s(t);i.isSigner=!0,i.isWritable=!0;for(const o of e){s(o.programId).isInvoked=!0;for(const a of o.keys){const f=s(a.pubkey);f.isSigner||(f.isSigner=a.isSigner),f.isWritable||(f.isWritable=a.isWritable)}}return new In(t,r)}getMessageComponents(){const e=[...this.keyMetaMap.entries()];Ie(e.length<=256,"Max static account keys length exceeded");const t=e.filter(([,f])=>f.isSigner&&f.isWritable),r=e.filter(([,f])=>f.isSigner&&!f.isWritable),s=e.filter(([,f])=>!f.isSigner&&f.isWritable),i=e.filter(([,f])=>!f.isSigner&&!f.isWritable),o={numRequiredSignatures:t.length+r.length,numReadonlySignedAccounts:r.length,numReadonlyUnsignedAccounts:i.length};{Ie(t.length>0,"Expected at least one writable signer key");const[f]=t[0];Ie(f===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const a=[...t.map(([f])=>new ie(f)),...r.map(([f])=>new ie(f)),...s.map(([f])=>new ie(f)),...i.map(([f])=>new ie(f))];return[o,a]}extractTableLookup(e){const[t,r]=this.drainKeysFoundInLookupTable(e.state.addresses,o=>!o.isSigner&&!o.isInvoked&&o.isWritable),[s,i]=this.drainKeysFoundInLookupTable(e.state.addresses,o=>!o.isSigner&&!o.isInvoked&&!o.isWritable);if(!(t.length===0&&s.length===0))return[{accountKey:e.key,writableIndexes:t,readonlyIndexes:s},{writable:r,readonly:i}]}drainKeysFoundInLookupTable(e,t){const r=new Array,s=new Array;for(const[i,o]of this.keyMetaMap.entries())if(t(o)){const a=new ie(i),f=e.findIndex(g=>g.equals(a));f>=0&&(Ie(f<256,"Max lookup table index exceeded"),r.push(f),s.push(a),this.keyMetaMap.delete(i))}return[r,s]}}const Yo="Reached end of buffer unexpectedly";function Ft(n){if(n.length===0)throw new Error(Yo);return n.shift()}function vt(n,...e){const[t]=e;if(e.length===2?t+(e[1]??0)>n.length:t>=n.length)throw new Error(Yo);return n.splice(...e)}class Lt{constructor(e){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=e.header,this.accountKeys=e.accountKeys.map(t=>new ie(t)),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach(t=>this.indexToProgramIds.set(t.programIdIndex,this.accountKeys[t.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:gt.decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new Xr(this.staticAccountKeys)}static compile(e){const t=In.compile(e.instructions,e.payerKey),[r,s]=t.getMessageComponents(),o=new Xr(s).compileInstructions(e.instructions).map(a=>({programIdIndex:a.programIdIndex,accounts:a.accountKeyIndexes,data:gt.encode(a.data)}));return new Lt({header:r,accountKeys:s,recentBlockhash:e.recentBlockhash,instructions:o})}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){const t=this.header.numRequiredSignatures;if(e>=this.header.numRequiredSignatures){const r=e-t,i=this.accountKeys.length-t-this.header.numReadonlyUnsignedAccounts;return r<i}else{const r=t-this.header.numReadonlySignedAccounts;return e<r}}isProgramId(e){return this.indexToProgramIds.has(e)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((e,t)=>!this.isProgramId(t))}serialize(){const e=this.accountKeys.length;let t=[];Tt(t,e);const r=this.instructions.map(b=>{const{accounts:x,programIdIndex:T}=b,L=Array.from(gt.decode(b.data));let k=[];Tt(k,x.length);let N=[];return Tt(N,L.length),{programIdIndex:T,keyIndicesCount:he.Buffer.from(k),keyIndices:x,dataLength:he.Buffer.from(N),data:L}});let s=[];Tt(s,r.length);let i=he.Buffer.alloc(nr);he.Buffer.from(s).copy(i);let o=s.length;r.forEach(b=>{const T=B.struct([B.u8("programIdIndex"),B.blob(b.keyIndicesCount.length,"keyIndicesCount"),B.seq(B.u8("keyIndex"),b.keyIndices.length,"keyIndices"),B.blob(b.dataLength.length,"dataLength"),B.seq(B.u8("userdatum"),b.data.length,"data")]).encode(b,i,o);o+=T}),i=i.slice(0,o);const a=B.struct([B.blob(1,"numRequiredSignatures"),B.blob(1,"numReadonlySignedAccounts"),B.blob(1,"numReadonlyUnsignedAccounts"),B.blob(t.length,"keyCount"),B.seq(Se("key"),e,"keys"),Se("recentBlockhash")]),f={numRequiredSignatures:he.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:he.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:he.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:he.Buffer.from(t),keys:this.accountKeys.map(b=>_e(b.toBytes())),recentBlockhash:gt.decode(this.recentBlockhash)};let g=he.Buffer.alloc(2048);const _=a.encode(f,g);return i.copy(g,_),g.slice(0,_+i.length)}static from(e){let t=[...e];const r=Ft(t);if(r!==(r&An))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const s=Ft(t),i=Ft(t),o=It(t);let a=[];for(let x=0;x<o;x++){const T=vt(t,0,Dt);a.push(new ie(he.Buffer.from(T)))}const f=vt(t,0,Dt),g=It(t);let _=[];for(let x=0;x<g;x++){const T=Ft(t),L=It(t),k=vt(t,0,L),N=It(t),M=vt(t,0,N),H=gt.encode(he.Buffer.from(M));_.push({programIdIndex:T,accounts:k,data:H})}const b={header:{numRequiredSignatures:r,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:i},recentBlockhash:gt.encode(he.Buffer.from(f)),accountKeys:a,instructions:_};return new Lt(b)}}class gr{constructor(e){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=e.header,this.staticAccountKeys=e.staticAccountKeys,this.recentBlockhash=e.recentBlockhash,this.compiledInstructions=e.compiledInstructions,this.addressTableLookups=e.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let e=0;for(const t of this.addressTableLookups)e+=t.readonlyIndexes.length+t.writableIndexes.length;return e}getAccountKeys(e){let t;if(e&&"accountKeysFromLookups"in e&&e.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=e.accountKeysFromLookups.writable.length+e.accountKeysFromLookups.readonly.length)throw new Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");t=e.accountKeysFromLookups}else if(e&&"addressLookupTableAccounts"in e&&e.addressLookupTableAccounts)t=this.resolveAddressTableLookups(e.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new Xr(this.staticAccountKeys,t)}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){const t=this.header.numRequiredSignatures,r=this.staticAccountKeys.length;if(e>=r){const s=e-r,i=this.addressTableLookups.reduce((o,a)=>o+a.writableIndexes.length,0);return s<i}else if(e>=this.header.numRequiredSignatures){const s=e-t,o=r-t-this.header.numReadonlyUnsignedAccounts;return s<o}else{const s=t-this.header.numReadonlySignedAccounts;return e<s}}resolveAddressTableLookups(e){const t={writable:[],readonly:[]};for(const r of this.addressTableLookups){const s=e.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)t.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)t.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 t}static compile(e){const t=In.compile(e.instructions,e.payerKey),r=new Array,s={writable:new Array,readonly:new Array},i=e.addressLookupTableAccounts||[];for(const _ of i){const b=t.extractTableLookup(_);if(b!==void 0){const[x,{writable:T,readonly:L}]=b;r.push(x),s.writable.push(...T),s.readonly.push(...L)}}const[o,a]=t.getMessageComponents(),g=new Xr(a,s).compileInstructions(e.instructions);return new gr({header:o,staticAccountKeys:a,recentBlockhash:e.recentBlockhash,compiledInstructions:g,addressTableLookups:r})}serialize(){const e=Array();Tt(e,this.staticAccountKeys.length);const t=this.serializeInstructions(),r=Array();Tt(r,this.compiledInstructions.length);const s=this.serializeAddressTableLookups(),i=Array();Tt(i,this.addressTableLookups.length);const o=B.struct([B.u8("prefix"),B.struct([B.u8("numRequiredSignatures"),B.u8("numReadonlySignedAccounts"),B.u8("numReadonlyUnsignedAccounts")],"header"),B.blob(e.length,"staticAccountKeysLength"),B.seq(Se(),this.staticAccountKeys.length,"staticAccountKeys"),Se("recentBlockhash"),B.blob(r.length,"instructionsLength"),B.blob(t.length,"serializedInstructions"),B.blob(i.length,"addressTableLookupsLength"),B.blob(s.length,"serializedAddressTableLookups")]),a=new Uint8Array(nr),g=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(_=>_.toBytes()),recentBlockhash:gt.decode(this.recentBlockhash),instructionsLength:new Uint8Array(r),serializedInstructions:t,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:s},a);return a.slice(0,g)}serializeInstructions(){let e=0;const t=new Uint8Array(nr);for(const r of this.compiledInstructions){const s=Array();Tt(s,r.accountKeyIndexes.length);const i=Array();Tt(i,r.data.length);const o=B.struct([B.u8("programIdIndex"),B.blob(s.length,"encodedAccountKeyIndexesLength"),B.seq(B.u8(),r.accountKeyIndexes.length,"accountKeyIndexes"),B.blob(i.length,"encodedDataLength"),B.blob(r.data.length,"data")]);e+=o.encode({programIdIndex:r.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(s),accountKeyIndexes:r.accountKeyIndexes,encodedDataLength:new Uint8Array(i),data:r.data},t,e)}return t.slice(0,e)}serializeAddressTableLookups(){let e=0;const t=new Uint8Array(nr);for(const r of this.addressTableLookups){const s=Array();Tt(s,r.writableIndexes.length);const i=Array();Tt(i,r.readonlyIndexes.length);const o=B.struct([Se("accountKey"),B.blob(s.length,"encodedWritableIndexesLength"),B.seq(B.u8(),r.writableIndexes.length,"writableIndexes"),B.blob(i.length,"encodedReadonlyIndexesLength"),B.seq(B.u8(),r.readonlyIndexes.length,"readonlyIndexes")]);e+=o.encode({accountKey:r.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(s),writableIndexes:r.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(i),readonlyIndexes:r.readonlyIndexes},t,e)}return t.slice(0,e)}static deserialize(e){let t=[...e];const r=Ft(t),s=r&An;Ie(r!==s,"Expected versioned message but received legacy message");const i=s;Ie(i===0,`Expected versioned message with version 0 but found version ${i}`);const o={numRequiredSignatures:Ft(t),numReadonlySignedAccounts:Ft(t),numReadonlyUnsignedAccounts:Ft(t)},a=[],f=It(t);for(let L=0;L<f;L++)a.push(new ie(vt(t,0,Dt)));const g=gt.encode(vt(t,0,Dt)),_=It(t),b=[];for(let L=0;L<_;L++){const k=Ft(t),N=It(t),M=vt(t,0,N),H=It(t),K=new Uint8Array(vt(t,0,H));b.push({programIdIndex:k,accountKeyIndexes:M,data:K})}const x=It(t),T=[];for(let L=0;L<x;L++){const k=new ie(vt(t,0,Dt)),N=It(t),M=vt(t,0,N),H=It(t),K=vt(t,0,H);T.push({accountKey:k,writableIndexes:M,readonlyIndexes:K})}return new gr({header:o,staticAccountKeys:a,recentBlockhash:g,compiledInstructions:b,addressTableLookups:T})}}const vi={deserializeMessageVersion(n){const e=n[0],t=e&An;return t===e?"legacy":t},deserialize:n=>{const e=vi.deserializeMessageVersion(n);if(e==="legacy")return Lt.from(n);if(e===0)return gr.deserialize(n);throw new Error(`Transaction message version ${e} deserialization is not supported`)}};let Zt=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 W0=he.Buffer.alloc(Zr).fill(0);class Be{constructor(e){this.keys=void 0,this.programId=void 0,this.data=he.Buffer.alloc(0),this.programId=e.programId,this.keys=e.keys,e.data&&(this.data=e.data)}toJSON(){return{keys:this.keys.map(({pubkey:e,isSigner:t,isWritable:r})=>({pubkey:e.toJSON(),isSigner:t,isWritable:r})),programId:this.programId.toJSON(),data:[...this.data]}}}class Oe{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(e){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,!!e)if(e.feePayer&&(this.feePayer=e.feePayer),e.signatures&&(this.signatures=e.signatures),Object.prototype.hasOwnProperty.call(e,"nonceInfo")){const{minContextSlot:t,nonceInfo:r}=e;this.minNonceContextSlot=t,this.nonceInfo=r}else if(Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")){const{blockhash:t,lastValidBlockHeight:r}=e;this.recentBlockhash=t,this.lastValidBlockHeight=r}else{const{recentBlockhash:t,nonceInfo:r}=e;r&&(this.nonceInfo=r),this.recentBlockhash=t}}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(e=>e.toJSON()),signers:this.signatures.map(({publicKey:e})=>e.toJSON())}}add(...e){if(e.length===0)throw new Error("No instructions");return e.forEach(t=>{"instructions"in t?this.instructions=this.instructions.concat(t.instructions):"data"in t&&"programId"in t&&"keys"in t?this.instructions.push(t):this.instructions.push(new Be(t))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let e,t;if(this.nonceInfo?(e=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?t=[this.nonceInfo.nonceInstruction,...this.instructions]:t=this.instructions):(e=this.recentBlockhash,t=this.instructions),!e)throw new Error("Transaction recentBlockhash required");t.length<1&&console.warn("No instructions provided");let r;if(this.feePayer)r=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)r=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let k=0;k<t.length;k++)if(t[k].programId===void 0)throw new Error(`Transaction instruction index ${k} has undefined program id`);const s=[],i=[];t.forEach(k=>{k.keys.forEach(M=>{i.push({...M})});const N=k.programId.toString();s.includes(N)||s.push(N)}),s.forEach(k=>{i.push({pubkey:new ie(k),isSigner:!1,isWritable:!1})});const o=[];i.forEach(k=>{const N=k.pubkey.toString(),M=o.findIndex(H=>H.pubkey.toString()===N);M>-1?(o[M].isWritable=o[M].isWritable||k.isWritable,o[M].isSigner=o[M].isSigner||k.isSigner):o.push(k)}),o.sort(function(k,N){if(k.isSigner!==N.isSigner)return k.isSigner?-1:1;if(k.isWritable!==N.isWritable)return k.isWritable?-1:1;const M={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return k.pubkey.toBase58().localeCompare(N.pubkey.toBase58(),"en",M)});const a=o.findIndex(k=>k.pubkey.equals(r));if(a>-1){const[k]=o.splice(a,1);k.isSigner=!0,k.isWritable=!0,o.unshift(k)}else o.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(const k of this.signatures){const N=o.findIndex(M=>M.pubkey.equals(k.publicKey));if(N>-1)o[N].isSigner||(o[N].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."));else throw new Error(`unknown signer: ${k.publicKey.toString()}`)}let f=0,g=0,_=0;const b=[],x=[];o.forEach(({pubkey:k,isSigner:N,isWritable:M})=>{N?(b.push(k.toString()),f+=1,M||(g+=1)):(x.push(k.toString()),M||(_+=1))});const T=b.concat(x),L=t.map(k=>{const{data:N,programId:M}=k;return{programIdIndex:T.indexOf(M.toString()),accounts:k.keys.map(H=>T.indexOf(H.pubkey.toString())),data:gt.encode(N)}});return L.forEach(k=>{Ie(k.programIdIndex>=0),k.accounts.forEach(N=>Ie(N>=0))}),new Lt({header:{numRequiredSignatures:f,numReadonlySignedAccounts:g,numReadonlyUnsignedAccounts:_},accountKeys:T,recentBlockhash:e,instructions:L})}_compile(){const e=this.compileMessage(),t=e.accountKeys.slice(0,e.header.numRequiredSignatures);return this.signatures.length===t.length&&this.signatures.every((s,i)=>t[i].equals(s.publicKey))||(this.signatures=t.map(r=>({signature:null,publicKey:r}))),e}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(e){return(await e.getFeeForMessage(this.compileMessage())).value}setSigners(...e){if(e.length===0)throw new Error("No signers");const t=new Set;this.signatures=e.filter(r=>{const s=r.toString();return t.has(s)?!1:(t.add(s),!0)}).map(r=>({signature:null,publicKey:r}))}sign(...e){if(e.length===0)throw new Error("No signers");const t=new Set,r=[];for(const i of e){const o=i.publicKey.toString();t.has(o)||(t.add(o),r.push(i))}this.signatures=r.map(i=>({signature:null,publicKey:i.publicKey}));const s=this._compile();this._partialSign(s,...r)}partialSign(...e){if(e.length===0)throw new Error("No signers");const t=new Set,r=[];for(const i of e){const o=i.publicKey.toString();t.has(o)||(t.add(o),r.push(i))}const s=this._compile();this._partialSign(s,...r)}_partialSign(e,...t){const r=e.serialize();t.forEach(s=>{const i=Ei(r,s.secretKey);this._addSignature(s.publicKey,_e(i))})}addSignature(e,t){this._compile(),this._addSignature(e,t)}_addSignature(e,t){Ie(t.length===64);const r=this.signatures.findIndex(s=>e.equals(s.publicKey));if(r<0)throw new Error(`unknown signer: ${e.toString()}`);this.signatures[r].signature=he.Buffer.from(t)}verifySignatures(e=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),e)}_getMessageSignednessErrors(e,t){const r={};for(const{signature:s,publicKey:i}of this.signatures)s===null?t&&(r.missing||(r.missing=[])).push(i):C0(s,e,i.toBytes())||(r.invalid||(r.invalid=[])).push(i);return r.invalid||r.missing?r:void 0}serialize(e){const{requireAllSignatures:t,verifySignatures:r}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),s=this.serializeMessage();if(r){const i=this._getMessageSignednessErrors(s,t);if(i){let o="Signature verification failed.";throw i.invalid&&(o+=`
11
11
  Invalid signature for public key${i.invalid.length===1?"":"(s)"} [\`${i.invalid.map(a=>a.toBase58()).join("`, `")}\`].`),i.missing&&(o+=`
12
- Missing signature for public key${i.missing.length===1?"":"(s)"} [\`${i.missing.map(a=>a.toBase58()).join("`, `")}\`].`),new Error(o)}}return this._serialize(s)}_serialize(e){const{signatures:t}=this,r=[];Tt(r,t.length);const s=r.length+t.length*64+e.length,i=fe.Buffer.alloc(s);return Ie(t.length<256),fe.Buffer.from(r).copy(i,0),t.forEach(({signature:o},a)=>{o!==null&&(Ie(o.length===64,"signature has invalid length"),fe.Buffer.from(o).copy(i,r.length+a*64))}),e.copy(i,r.length+t.length*64),Ie(i.length<=ir,`Transaction too large: ${i.length} > ${ir}`),i}get keys(){return Ie(this.instructions.length===1),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return Ie(this.instructions.length===1),this.instructions[0].programId}get data(){return Ie(this.instructions.length===1),this.instructions[0].data}static from(e){let t=[...e];const r=It(t);let s=[];for(let i=0;i<r;i++){const o=vt(t,0,Zr);s.push(gt.encode(fe.Buffer.from(o)))}return Oe.populate(Lt.from(t),s)}static populate(e,t=[]){const r=new Oe;return r.recentBlockhash=e.recentBlockhash,e.header.numRequiredSignatures>0&&(r.feePayer=e.accountKeys[0]),t.forEach((s,i)=>{const o={signature:s==gt.encode(H0)?null:gt.decode(s),publicKey:e.accountKeys[i]};r.signatures.push(o)}),e.instructions.forEach(s=>{const i=s.accounts.map(o=>{const a=e.accountKeys[o];return{pubkey:a,isSigner:r.signatures.some(f=>f.publicKey.toString()===a.toString())||e.isAccountSigner(o),isWritable:e.isAccountWritable(o)}});r.instructions.push(new Be({keys:i,programId:e.accountKeys[s.programIdIndex],data:gt.decode(s.data)}))}),r._message=e,r._json=r.toJSON(),r}}class Oi{constructor(e){this.payerKey=void 0,this.instructions=void 0,this.recentBlockhash=void 0,this.payerKey=e.payerKey,this.instructions=e.instructions,this.recentBlockhash=e.recentBlockhash}static decompile(e,t){const{header:r,compiledInstructions:s,recentBlockhash:i}=e,{numRequiredSignatures:o,numReadonlySignedAccounts:a,numReadonlyUnsignedAccounts:f}=r,g=o-a;Ie(g>0,"Message header is invalid");const _=e.staticAccountKeys.length-o-f;Ie(_>=0,"Message header is invalid");const b=e.getAccountKeys(t),x=b.get(0);if(x===void 0)throw new Error("Failed to decompile message because no account keys were found");const T=[];for(const L of s){const k=[];for(const M of L.accountKeyIndexes){const W=b.get(M);if(W===void 0)throw new Error(`Failed to find key for account key index ${M}`);const $=M<o;let J;$?J=M<g:M<b.staticAccountKeys.length?J=M-o<_:J=M-b.staticAccountKeys.length<b.accountKeysFromLookups.writable.length,k.push({pubkey:W,isSigner:M<r.numRequiredSignatures,isWritable:J})}const N=b.get(L.programIdIndex);if(N===void 0)throw new Error(`Failed to find program id for program id index ${L.programIdIndex}`);T.push(new Be({programId:N,data:_e(L.data),keys:k}))}return new Oi({payerKey:x,instructions:T,recentBlockhash:i})}compileToLegacyMessage(){return Lt.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions})}compileToV0Message(e){return gr.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions,addressLookupTableAccounts:e})}}class ki{get version(){return this.message.version}constructor(e,t){if(this.signatures=void 0,this.message=void 0,t!==void 0)Ie(t.length===e.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=t;else{const r=[];for(let s=0;s<e.header.numRequiredSignatures;s++)r.push(new Uint8Array(Zr));this.signatures=r}this.message=e}serialize(){const e=this.message.serialize(),t=Array();Tt(t,this.signatures.length);const r=B.struct([B.blob(t.length,"encodedSignaturesLength"),B.seq(F0(),this.signatures.length,"signatures"),B.blob(e.length,"serializedMessage")]),s=new Uint8Array(2048),i=r.encode({encodedSignaturesLength:new Uint8Array(t),signatures:this.signatures,serializedMessage:e},s);return s.slice(0,i)}static deserialize(e){let t=[...e];const r=[],s=It(t);for(let o=0;o<s;o++)r.push(new Uint8Array(vt(t,0,Zr)));const i=vi.deserialize(new Uint8Array(t));return new ki(i,r)}sign(e){const t=this.message.serialize(),r=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(const s of e){const i=r.findIndex(o=>o.equals(s.publicKey));Ie(i>=0,`Cannot sign with non signer key ${s.publicKey.toBase58()}`),this.signatures[i]=Ei(t,s.secretKey)}}addSignature(e,t){Ie(t.byteLength===64,"Signature must be 64 bytes long");const s=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(i=>i.equals(e));Ie(s>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[s]=t}}const jo=1e3/(160/64),zt=new ie("SysvarC1ock11111111111111111111111111111111"),q0=new ie("SysvarEpochSchedu1e111111111111111111111111"),G0=new ie("Sysvar1nstructions1111111111111111111111111"),vn=new ie("SysvarRecentB1ockHashes11111111111111111111"),Br=new ie("SysvarRent111111111111111111111111111111111"),V0=new ie("SysvarRewards111111111111111111111111111111"),Y0=new ie("SysvarS1otHashes111111111111111111111111111"),j0=new ie("SysvarS1otHistory11111111111111111111111111"),On=new ie("SysvarStakeHistory1111111111111111111111111");class Jr extends Error{constructor({action:e,signature:t,transactionMessage:r,logs:s}){const i=s?`Logs:
12
+ Missing signature for public key${i.missing.length===1?"":"(s)"} [\`${i.missing.map(a=>a.toBase58()).join("`, `")}\`].`),new Error(o)}}return this._serialize(s)}_serialize(e){const{signatures:t}=this,r=[];Tt(r,t.length);const s=r.length+t.length*64+e.length,i=he.Buffer.alloc(s);return Ie(t.length<256),he.Buffer.from(r).copy(i,0),t.forEach(({signature:o},a)=>{o!==null&&(Ie(o.length===64,"signature has invalid length"),he.Buffer.from(o).copy(i,r.length+a*64))}),e.copy(i,r.length+t.length*64),Ie(i.length<=nr,`Transaction too large: ${i.length} > ${nr}`),i}get keys(){return Ie(this.instructions.length===1),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return Ie(this.instructions.length===1),this.instructions[0].programId}get data(){return Ie(this.instructions.length===1),this.instructions[0].data}static from(e){let t=[...e];const r=It(t);let s=[];for(let i=0;i<r;i++){const o=vt(t,0,Zr);s.push(gt.encode(he.Buffer.from(o)))}return Oe.populate(Lt.from(t),s)}static populate(e,t=[]){const r=new Oe;return r.recentBlockhash=e.recentBlockhash,e.header.numRequiredSignatures>0&&(r.feePayer=e.accountKeys[0]),t.forEach((s,i)=>{const o={signature:s==gt.encode(W0)?null:gt.decode(s),publicKey:e.accountKeys[i]};r.signatures.push(o)}),e.instructions.forEach(s=>{const i=s.accounts.map(o=>{const a=e.accountKeys[o];return{pubkey:a,isSigner:r.signatures.some(f=>f.publicKey.toString()===a.toString())||e.isAccountSigner(o),isWritable:e.isAccountWritable(o)}});r.instructions.push(new Be({keys:i,programId:e.accountKeys[s.programIdIndex],data:gt.decode(s.data)}))}),r._message=e,r._json=r.toJSON(),r}}class Oi{constructor(e){this.payerKey=void 0,this.instructions=void 0,this.recentBlockhash=void 0,this.payerKey=e.payerKey,this.instructions=e.instructions,this.recentBlockhash=e.recentBlockhash}static decompile(e,t){const{header:r,compiledInstructions:s,recentBlockhash:i}=e,{numRequiredSignatures:o,numReadonlySignedAccounts:a,numReadonlyUnsignedAccounts:f}=r,g=o-a;Ie(g>0,"Message header is invalid");const _=e.staticAccountKeys.length-o-f;Ie(_>=0,"Message header is invalid");const b=e.getAccountKeys(t),x=b.get(0);if(x===void 0)throw new Error("Failed to decompile message because no account keys were found");const T=[];for(const L of s){const k=[];for(const M of L.accountKeyIndexes){const H=b.get(M);if(H===void 0)throw new Error(`Failed to find key for account key index ${M}`);const K=M<o;let J;K?J=M<g:M<b.staticAccountKeys.length?J=M-o<_:J=M-b.staticAccountKeys.length<b.accountKeysFromLookups.writable.length,k.push({pubkey:H,isSigner:M<r.numRequiredSignatures,isWritable:J})}const N=b.get(L.programIdIndex);if(N===void 0)throw new Error(`Failed to find program id for program id index ${L.programIdIndex}`);T.push(new Be({programId:N,data:_e(L.data),keys:k}))}return new Oi({payerKey:x,instructions:T,recentBlockhash:i})}compileToLegacyMessage(){return Lt.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions})}compileToV0Message(e){return gr.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions,addressLookupTableAccounts:e})}}class ki{get version(){return this.message.version}constructor(e,t){if(this.signatures=void 0,this.message=void 0,t!==void 0)Ie(t.length===e.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=t;else{const r=[];for(let s=0;s<e.header.numRequiredSignatures;s++)r.push(new Uint8Array(Zr));this.signatures=r}this.message=e}serialize(){const e=this.message.serialize(),t=Array();Tt(t,this.signatures.length);const r=B.struct([B.blob(t.length,"encodedSignaturesLength"),B.seq(F0(),this.signatures.length,"signatures"),B.blob(e.length,"serializedMessage")]),s=new Uint8Array(2048),i=r.encode({encodedSignaturesLength:new Uint8Array(t),signatures:this.signatures,serializedMessage:e},s);return s.slice(0,i)}static deserialize(e){let t=[...e];const r=[],s=It(t);for(let o=0;o<s;o++)r.push(new Uint8Array(vt(t,0,Zr)));const i=vi.deserialize(new Uint8Array(t));return new ki(i,r)}sign(e){const t=this.message.serialize(),r=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(const s of e){const i=r.findIndex(o=>o.equals(s.publicKey));Ie(i>=0,`Cannot sign with non signer key ${s.publicKey.toBase58()}`),this.signatures[i]=Ei(t,s.secretKey)}}addSignature(e,t){Ie(t.byteLength===64,"Signature must be 64 bytes long");const s=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(i=>i.equals(e));Ie(s>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[s]=t}}const jo=1e3/(160/64),zt=new ie("SysvarC1ock11111111111111111111111111111111"),q0=new ie("SysvarEpochSchedu1e111111111111111111111111"),V0=new ie("Sysvar1nstructions1111111111111111111111111"),vn=new ie("SysvarRecentB1ockHashes11111111111111111111"),Br=new ie("SysvarRent111111111111111111111111111111111"),G0=new ie("SysvarRewards111111111111111111111111111111"),Y0=new ie("SysvarS1otHashes111111111111111111111111111"),j0=new ie("SysvarS1otHistory11111111111111111111111111"),On=new ie("SysvarStakeHistory1111111111111111111111111");class Jr extends Error{constructor({action:e,signature:t,transactionMessage:r,logs:s}){const i=s?`Logs:
13
13
  ${JSON.stringify(s.slice(-10),null,2)}. `:"",o="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";let a;switch(e){case"send":a=`Transaction ${t} resulted in an error.
14
14
  ${r}. `+i+o;break;case"simulate":a=`Simulation failed.
15
15
  Message: ${r}.
16
- `+i+o;break;default:a=`Unknown action '${(f=>f)(e)}'`}super(a),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=t,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 e=this.transactionLogs;if(!(e!=null&&typeof e=="object"&&"then"in e))return e}async getLogs(e){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((t,r)=>{e.getTransaction(this.signature).then(s=>{if(s&&s.meta&&s.meta.logMessages){const i=s.meta.logMessages;this.transactionLogs=i,t(i)}else r(new Error("Log messages not found"))}).catch(r)})),await this.transactionLogs}}const Z0={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 ue extends Error{constructor({code:e,message:t,data:r},s){super(s!=null?`${s}: ${t}`:t),this.code=void 0,this.data=void 0,this.code=e,this.data=r,this.name="SolanaJSONRPCError"}}async function Ti(n,e,t,r){const s=r&&{skipPreflight:r.skipPreflight,preflightCommitment:r.preflightCommitment||r.commitment,maxRetries:r.maxRetries,minContextSlot:r.minContextSlot},i=await n.sendTransaction(e,t,s);let o;if(e.recentBlockhash!=null&&e.lastValidBlockHeight!=null)o=(await n.confirmTransaction({abortSignal:r==null?void 0:r.abortSignal,signature:i,blockhash:e.recentBlockhash,lastValidBlockHeight:e.lastValidBlockHeight},r&&r.commitment)).value;else if(e.minNonceContextSlot!=null&&e.nonceInfo!=null){const{nonceInstruction:a}=e.nonceInfo,f=a.keys[0].pubkey;o=(await n.confirmTransaction({abortSignal:r==null?void 0:r.abortSignal,minContextSlot:e.minNonceContextSlot,nonceAccountPubkey:f,nonceValue:e.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 Jr({action:"send",signature:i,transactionMessage:`Status: (${JSON.stringify(o)})`}):new Error(`Transaction ${i} failed (${JSON.stringify(o)})`);return i}function mr(n){return new Promise(e=>setTimeout(e,n))}function Ae(n,e){const t=n.layout.span>=0?n.layout.span:Vo(n,e),r=fe.Buffer.alloc(t),s=Object.assign({instruction:n.index},e);return n.layout.encode(s,r),r}function Te(n,e){let t;try{t=n.layout.decode(e)}catch(r){throw new Error("invalid instruction; "+r)}if(t.instruction!==n.index)throw new Error(`invalid instruction; instruction index mismatch ${t.instruction} != ${n.index}`);return t}const Zo=B.nu64("lamportsPerSignature"),Xo=B.struct([B.u32("version"),B.u32("state"),Se("authorizedPubkey"),Se("nonce"),B.struct([Zo],"feeCalculator")]),Ni=Xo.span;class kn{constructor(e){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=e.authorizedPubkey,this.nonce=e.nonce,this.feeCalculator=e.feeCalculator}static fromAccountData(e){const t=Xo.decode(_e(e),0);return new kn({authorizedPubkey:new ie(t.authorizedPubkey),nonce:new ie(t.nonce).toString(),feeCalculator:t.feeCalculator})}}function Lr(n){const e=B.blob(8,n),t=e.decode.bind(e),r=e.encode.bind(e),s=e,i=Ld();return s.decode=(o,a)=>{const f=t(o,a);return i.decode(f)},s.encode=(o,a,f)=>{const g=i.encode(o);return r(g,a,f)},s}class X0{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const r=B.u32("instruction").decode(e.data);let s;for(const[i,o]of Object.entries(Pe))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a SystemInstruction");return s}static decodeCreateAccount(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{lamports:t,space:r,programId:s}=Te(Pe.Create,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,lamports:t,space:r,programId:new ie(s)}}static decodeTransfer(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{lamports:t}=Te(Pe.Transfer,e.data);return{fromPubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,lamports:t}}static decodeTransferWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{lamports:t,seed:r,programId:s}=Te(Pe.TransferWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,basePubkey:e.keys[1].pubkey,toPubkey:e.keys[2].pubkey,lamports:t,seed:r,programId:new ie(s)}}static decodeAllocate(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{space:t}=Te(Pe.Allocate,e.data);return{accountPubkey:e.keys[0].pubkey,space:t}}static decodeAllocateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{base:t,seed:r,space:s,programId:i}=Te(Pe.AllocateWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new ie(t),seed:r,space:s,programId:new ie(i)}}static decodeAssign(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{programId:t}=Te(Pe.Assign,e.data);return{accountPubkey:e.keys[0].pubkey,programId:new ie(t)}}static decodeAssignWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{base:t,seed:r,programId:s}=Te(Pe.AssignWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new ie(t),seed:r,programId:new ie(s)}}static decodeCreateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{base:t,seed:r,lamports:s,space:i,programId:o}=Te(Pe.CreateWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,basePubkey:new ie(t),seed:r,lamports:s,space:i,programId:new ie(o)}}static decodeNonceInitialize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{authorized:t}=Te(Pe.InitializeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:new ie(t)}}static decodeNonceAdvance(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),Te(Pe.AdvanceNonceAccount,e.data),{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey}}static decodeNonceWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,5);const{lamports:t}=Te(Pe.WithdrawNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey,lamports:t}}static decodeNonceAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{authorized:t}=Te(Pe.AuthorizeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[1].pubkey,newAuthorizedPubkey:new ie(t)}}static checkProgramId(e){if(!e.equals(mt.programId))throw new Error("invalid instruction; programId is not SystemProgram")}static checkKeyLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}const Pe=Object.freeze({Create:{index:0,layout:B.struct([B.u32("instruction"),B.ns64("lamports"),B.ns64("space"),Se("programId")])},Assign:{index:1,layout:B.struct([B.u32("instruction"),Se("programId")])},Transfer:{index:2,layout:B.struct([B.u32("instruction"),Lr("lamports")])},CreateWithSeed:{index:3,layout:B.struct([B.u32("instruction"),Se("base"),pr("seed"),B.ns64("lamports"),B.ns64("space"),Se("programId")])},AdvanceNonceAccount:{index:4,layout:B.struct([B.u32("instruction")])},WithdrawNonceAccount:{index:5,layout:B.struct([B.u32("instruction"),B.ns64("lamports")])},InitializeNonceAccount:{index:6,layout:B.struct([B.u32("instruction"),Se("authorized")])},AuthorizeNonceAccount:{index:7,layout:B.struct([B.u32("instruction"),Se("authorized")])},Allocate:{index:8,layout:B.struct([B.u32("instruction"),B.ns64("space")])},AllocateWithSeed:{index:9,layout:B.struct([B.u32("instruction"),Se("base"),pr("seed"),B.ns64("space"),Se("programId")])},AssignWithSeed:{index:10,layout:B.struct([B.u32("instruction"),Se("base"),pr("seed"),Se("programId")])},TransferWithSeed:{index:11,layout:B.struct([B.u32("instruction"),Lr("lamports"),pr("seed"),Se("programId")])},UpgradeNonceAccount:{index:12,layout:B.struct([B.u32("instruction")])}});class mt{constructor(){}static createAccount(e){const t=Pe.Create,r=Ae(t,{lamports:e.lamports,space:e.space,programId:_e(e.programId.toBuffer())});return new Be({keys:[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:r})}static transfer(e){let t,r;if("basePubkey"in e){const s=Pe.TransferWithSeed;t=Ae(s,{lamports:BigInt(e.lamports),seed:e.seed,programId:_e(e.programId.toBuffer())}),r=[{pubkey:e.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}else{const s=Pe.Transfer;t=Ae(s,{lamports:BigInt(e.lamports)}),r=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}return new Be({keys:r,programId:this.programId,data:t})}static assign(e){let t,r;if("basePubkey"in e){const s=Pe.AssignWithSeed;t=Ae(s,{base:_e(e.basePubkey.toBuffer()),seed:e.seed,programId:_e(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{const s=Pe.Assign;t=Ae(s,{programId:_e(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new Be({keys:r,programId:this.programId,data:t})}static createAccountWithSeed(e){const t=Pe.CreateWithSeed,r=Ae(t,{base:_e(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:_e(e.programId.toBuffer())});let s=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!1,isWritable:!0}];return e.basePubkey.equals(e.fromPubkey)||s.push({pubkey:e.basePubkey,isSigner:!0,isWritable:!1}),new Be({keys:s,programId:this.programId,data:r})}static createNonceAccount(e){const t=new Oe;"basePubkey"in e&&"seed"in e?t.add(mt.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:Ni,programId:this.programId})):t.add(mt.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,lamports:e.lamports,space:Ni,programId:this.programId}));const r={noncePubkey:e.noncePubkey,authorizedPubkey:e.authorizedPubkey};return t.add(this.nonceInitialize(r)),t}static nonceInitialize(e){const t=Pe.InitializeNonceAccount,r=Ae(t,{authorized:_e(e.authorizedPubkey.toBuffer())}),s={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:vn,isSigner:!1,isWritable:!1},{pubkey:Br,isSigner:!1,isWritable:!1}],programId:this.programId,data:r};return new Be(s)}static nonceAdvance(e){const t=Pe.AdvanceNonceAccount,r=Ae(t),s={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:vn,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r};return new Be(s)}static nonceWithdraw(e){const t=Pe.WithdrawNonceAccount,r=Ae(t,{lamports:e.lamports});return new Be({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0},{pubkey:vn,isSigner:!1,isWritable:!1},{pubkey:Br,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}static nonceAuthorize(e){const t=Pe.AuthorizeNonceAccount,r=Ae(t,{authorized:_e(e.newAuthorizedPubkey.toBuffer())});return new Be({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}static allocate(e){let t,r;if("basePubkey"in e){const s=Pe.AllocateWithSeed;t=Ae(s,{base:_e(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:_e(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{const s=Pe.Allocate;t=Ae(s,{space:e.space}),r=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new Be({keys:r,programId:this.programId,data:t})}}mt.programId=new ie("11111111111111111111111111111111");const J0=ir-300;class yr{constructor(){}static getMinNumSignatures(e){return 2*(Math.ceil(e/yr.chunkSize)+1+1)}static async load(e,t,r,s,i){{const b=await e.getMinimumBalanceForRentExemption(i.length),x=await e.getAccountInfo(r.publicKey,"confirmed");let T=null;if(x!==null){if(x.executable)return console.error("Program load failed, account is already executable"),!1;x.data.length!==i.length&&(T=T||new Oe,T.add(mt.allocate({accountPubkey:r.publicKey,space:i.length}))),x.owner.equals(s)||(T=T||new Oe,T.add(mt.assign({accountPubkey:r.publicKey,programId:s}))),x.lamports<b&&(T=T||new Oe,T.add(mt.transfer({fromPubkey:t.publicKey,toPubkey:r.publicKey,lamports:b-x.lamports})))}else T=new Oe().add(mt.createAccount({fromPubkey:t.publicKey,newAccountPubkey:r.publicKey,lamports:b>0?b:1,space:i.length,programId:s}));T!==null&&await Ti(e,T,[t,r],{commitment:"confirmed"})}const o=B.struct([B.u32("instruction"),B.u32("offset"),B.u32("bytesLength"),B.u32("bytesLengthPadding"),B.seq(B.u8("byte"),B.offset(B.u32(),-8),"bytes")]),a=yr.chunkSize;let f=0,g=i,_=[];for(;g.length>0;){const b=g.slice(0,a),x=fe.Buffer.alloc(a+16);o.encode({instruction:0,offset:f,bytes:b,bytesLength:0,bytesLengthPadding:0},x);const T=new Oe().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0}],programId:s,data:x});_.push(Ti(e,T,[t,r],{commitment:"confirmed"})),e._rpcEndpoint.includes("solana.com")&&await mr(1e3/4),f+=a,g=g.slice(a)}await Promise.all(_);{const b=B.struct([B.u32("instruction")]),x=fe.Buffer.alloc(b.span);b.encode({instruction:1},x);const T=new Oe().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0},{pubkey:Br,isSigner:!1,isWritable:!1}],programId:s,data:x}),L="processed",k=await e.sendTransaction(T,[t,r],{preflightCommitment:L}),{context:N,value:M}=await e.confirmTransaction({signature:k,lastValidBlockHeight:T.lastValidBlockHeight,blockhash:T.recentBlockhash},L);if(M.err)throw new Error(`Transaction ${k} failed (${JSON.stringify(M)})`);for(;;){try{if(await e.getSlot({commitment:L})>N.slot)break}catch{}await new Promise(W=>setTimeout(W,Math.round(jo/2)))}}return!0}}yr.chunkSize=J0;const Q0=new ie("BPFLoader2111111111111111111111111111111111");class ep{static getMinNumSignatures(e){return yr.getMinNumSignatures(e)}static load(e,t,r,s,i){return yr.load(e,t,r,i,s)}}function tp(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var xi,Jo;function rp(){if(Jo)return xi;Jo=1;var n=Object.prototype.toString,e=Object.keys||function(r){var s=[];for(var i in r)s.push(i);return s};function t(r,s){var i,o,a,f,g,_,b;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 t(r.toJSON(),s);if(b=n.call(r),b==="[object Array]"){for(a="[",o=r.length-1,i=0;i<o;i++)a+=t(r[i],!0)+",";return o>-1&&(a+=t(r[i],!0)),a+"]"}else if(b==="[object Object]"){for(f=e(r).sort(),o=f.length,a="",i=0;i<o;)g=f[i],_=t(r[g],!1),_!==void 0&&(a&&(a+=","),a+=JSON.stringify(g)+":"+_),i++;return"{"+a+"}"}else return JSON.stringify(r);case"function":case"undefined":return s?null:void 0;case"string":return JSON.stringify(r);default:return isFinite(r)?r:null}}return xi=function(r){var s=t(r,!1);if(s!==void 0)return""+s},xi}var np=rp(),Qo=tp(np);const Qr=32;function Bi(n){let e=0;for(;n>1;)n/=2,e++;return e}function ip(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 ea{constructor(e,t,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=e,this.leaderScheduleSlotOffset=t,this.warmup=r,this.firstNormalEpoch=s,this.firstNormalSlot=i}getEpoch(e){return this.getEpochAndSlotIndex(e)[0]}getEpochAndSlotIndex(e){if(e<this.firstNormalSlot){const t=Bi(ip(e+Qr+1))-Bi(Qr)-1,r=this.getSlotsInEpoch(t),s=e-(r-Qr);return[t,s]}else{const t=e-this.firstNormalSlot,r=Math.floor(t/this.slotsPerEpoch),s=this.firstNormalEpoch+r,i=t%this.slotsPerEpoch;return[s,i]}}getFirstSlotInEpoch(e){return e<=this.firstNormalEpoch?(Math.pow(2,e)-1)*Qr:(e-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(e){return this.getFirstSlotInEpoch(e)+this.getSlotsInEpoch(e)-1}getSlotsInEpoch(e){return e<this.firstNormalEpoch?Math.pow(2,e+Bi(Qr)):this.slotsPerEpoch}}var sp=globalThis.fetch;class op extends p0{constructor(e,t,r){const s=i=>{const o=f0(i,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...t});return"socket"in o?this.underlyingSocket=o.socket:this.underlyingSocket=o,o};super(s,e,t,r),this.underlyingSocket=void 0}call(...e){var r;const t=(r=this.underlyingSocket)==null?void 0:r.readyState;return t===1?super.call(...e):Promise.reject(new Error("Tried to call a JSON-RPC method `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}notify(...e){var r;const t=(r=this.underlyingSocket)==null?void 0:r.readyState;return t===1?super.notify(...e):Promise.reject(new Error("Tried to send a JSON-RPC notification `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}}function ap(n,e){let t;try{t=n.layout.decode(e)}catch(r){throw new Error("invalid instruction; "+r)}if(t.typeIndex!==n.index)throw new Error(`invalid account data; account type mismatch ${t.typeIndex} != ${n.index}`);return t}const ta=56;class Li{constructor(e){this.key=void 0,this.state=void 0,this.key=e.key,this.state=e.state}isActive(){const e=BigInt("0xffffffffffffffff");return this.state.deactivationSlot===e}static deserialize(e){const t=ap(cp,e),r=e.length-ta;Ie(r>=0,"lookup table is invalid"),Ie(r%32===0,"lookup table is invalid");const s=r/32,{addresses:i}=B.struct([B.seq(Se(),s,"addresses")]).decode(e.slice(ta));return{deactivationSlot:t.deactivationSlot,lastExtendedSlot:t.lastExtendedSlot,lastExtendedSlotStartIndex:t.lastExtendedStartIndex,authority:t.authority.length!==0?new ie(t.authority[0]):void 0,addresses:i.map(o=>new ie(o))}}}const cp={index:1,layout:B.struct([B.u32("typeIndex"),Lr("deactivationSlot"),B.nu64("lastExtendedSlot"),B.u8("lastExtendedStartIndex"),B.u8(),B.seq(Se(),B.offset(B.u8(),-1),"authority")])},up=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function lp(n){const e=n.match(up);if(e==null)throw TypeError(`Failed to validate endpoint URL \`${n}\``);const[t,r,s,i]=e,o=n.startsWith("https:")?"wss:":"ws:",a=s==null?null:parseInt(s.slice(1),10),f=a==null?"":`:${a+1}`;return`${o}//${r}${f}${i}`}const Ge=Vr(ui(ie),re(),n=>new ie(n)),ra=li([re(),qe("base64")]),Ci=Vr(ui(fe.Buffer),ra,n=>fe.Buffer.from(n[0],"base64")),na=30*1e3;function hp(n){if(/^https?:/.test(n)===!1)throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return n}function Ue(n){let e,t;if(typeof n=="string")e=n;else if(n){const{commitment:r,...s}=n;e=r,t=s}return{commitment:e,config:t}}function ia(n){return n.map(e=>"memcmp"in e?{...e,memcmp:{...e.memcmp,encoding:e.memcmp.encoding??"base58"}}:e)}function sa(n){return At([ee({jsonrpc:qe("2.0"),id:re(),result:n}),ee({jsonrpc:qe("2.0"),id:re(),error:ee({code:Nr(),message:re(),data:le(Fd())})})])}const fp=sa(Nr());function we(n){return Vr(sa(n),fp,e=>"error"in e?e:{...e,result:se(e.result,n)})}function je(n){return we(ee({context:ee({slot:K()}),value:n}))}function Tn(n){return ee({context:ee({slot:K()}),value:n})}function Mi(n,e){return n===0?new gr({header:e.header,staticAccountKeys:e.accountKeys.map(t=>new ie(t)),recentBlockhash:e.recentBlockhash,compiledInstructions:e.instructions.map(t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:gt.decode(t.data)})),addressTableLookups:e.addressTableLookups}):new Lt(e)}const dp=ee({foundation:K(),foundationTerm:K(),initial:K(),taper:K(),terminal:K()}),pp=we(oe(ae(ee({epoch:K(),effectiveSlot:K(),amount:K(),postBalance:K(),commission:le(ae(K()))})))),gp=oe(ee({slot:K(),prioritizationFee:K()})),mp=ee({total:K(),validator:K(),foundation:K(),epoch:K()}),yp=ee({epoch:K(),slotIndex:K(),slotsInEpoch:K(),absoluteSlot:K(),blockHeight:le(K()),transactionCount:le(K())}),_p=ee({slotsPerEpoch:K(),leaderScheduleSlotOffset:K(),warmup:Ut(),firstNormalEpoch:K(),firstNormalSlot:K()}),wp=wo(re(),oe(K())),_r=ae(At([ee({}),re()])),bp=ee({err:_r}),Rp=qe("receivedSignature"),Ep=ee({"solana-core":re(),"feature-set":le(K())}),Sp=ee({program:re(),programId:Ge,parsed:Nr()}),Ap=ee({programId:Ge,accounts:oe(Ge),data:re()}),oa=je(ee({err:ae(At([ee({}),re()])),logs:ae(oe(re())),accounts:le(ae(oe(ae(ee({executable:Ut(),owner:re(),lamports:K(),data:oe(re()),rentEpoch:le(K())}))))),unitsConsumed:le(K()),returnData:le(ae(ee({programId:re(),data:li([re(),qe("base64")])}))),innerInstructions:le(ae(oe(ee({index:K(),instructions:oe(At([Sp,Ap]))}))))})),Ip=je(ee({byIdentity:wo(re(),oe(K())),range:ee({firstSlot:K(),lastSlot:K()})}));function vp(n,e,t,r,s,i){const o=t||sp;let a;i!=null&&console.warn("You have supplied an `httpAgent` when creating a `Connection` in a browser environment.It has been ignored; `httpAgent` is only used in Node environments.");let f;return r&&(f=async(_,b)=>{const x=await new Promise((T,L)=>{try{r(_,b,(k,N)=>T([k,N]))}catch(k){L(k)}});return await o(...x)}),new c0(async(_,b)=>{const x={method:"POST",body:_,agent:a,headers:Object.assign({"Content-Type":"application/json"},e||{},vg)};try{let T=5,L,k=500;for(;f?L=await f(n,x):L=await o(n,x),!(L.status!==429||s===!0||(T-=1,T===0));)console.error(`Server responded with ${L.status} ${L.statusText}. Retrying after ${k}ms delay...`),await mr(k),k*=2;const N=await L.text();L.ok?b(null,N):b(new Error(`${L.status} ${L.statusText}: ${N}`))}catch(T){T instanceof Error&&b(T)}},{})}function Op(n){return(e,t)=>new Promise((r,s)=>{n.request(e,t,(i,o)=>{if(i){s(i);return}r(o)})})}function kp(n){return e=>new Promise((t,r)=>{e.length===0&&t([]);const s=e.map(i=>n.request(i.methodName,i.args));n.request(s,(i,o)=>{if(i){r(i);return}t(o)})})}const Tp=we(dp),Np=we(mp),xp=we(gp),Bp=we(yp),Lp=we(_p),Cp=we(wp),Mp=we(K()),Pp=je(ee({total:K(),circulating:K(),nonCirculating:K(),nonCirculatingAccounts:oe(Ge)})),Pi=ee({amount:re(),uiAmount:ae(K()),decimals:K(),uiAmountString:le(re())}),Up=je(oe(ee({address:Ge,amount:re(),uiAmount:ae(K()),decimals:K(),uiAmountString:le(re())}))),Dp=je(oe(ee({pubkey:Ge,account:ee({executable:Ut(),owner:Ge,lamports:K(),data:Ci,rentEpoch:K()})}))),Ui=ee({program:re(),parsed:Nr(),space:K()}),Fp=je(oe(ee({pubkey:Ge,account:ee({executable:Ut(),owner:Ge,lamports:K(),data:Ui,rentEpoch:K()})}))),zp=je(oe(ee({lamports:K(),address:Ge}))),en=ee({executable:Ut(),owner:Ge,lamports:K(),data:Ci,rentEpoch:K()}),$p=ee({pubkey:Ge,account:en}),Kp=Vr(At([ui(fe.Buffer),Ui]),At([ra,Ui]),n=>Array.isArray(n)?se(n,Ci):n),Di=ee({executable:Ut(),owner:Ge,lamports:K(),data:Kp,rentEpoch:K()}),Wp=ee({pubkey:Ge,account:Di}),Hp=ee({state:At([qe("active"),qe("inactive"),qe("activating"),qe("deactivating")]),active:K(),inactive:K()}),qp=we(oe(ee({signature:re(),slot:K(),err:_r,memo:ae(re()),blockTime:le(ae(K()))}))),Gp=we(oe(ee({signature:re(),slot:K(),err:_r,memo:ae(re()),blockTime:le(ae(K()))}))),Vp=ee({subscription:K(),result:Tn(en)}),Yp=ee({pubkey:Ge,account:en}),jp=ee({subscription:K(),result:Tn(Yp)}),Zp=ee({parent:K(),slot:K(),root:K()}),Xp=ee({subscription:K(),result:Zp}),Jp=At([ee({type:At([qe("firstShredReceived"),qe("completed"),qe("optimisticConfirmation"),qe("root")]),slot:K(),timestamp:K()}),ee({type:qe("createdBank"),parent:K(),slot:K(),timestamp:K()}),ee({type:qe("frozen"),slot:K(),timestamp:K(),stats:ee({numTransactionEntries:K(),numSuccessfulTransactions:K(),numFailedTransactions:K(),maxTransactionsPerEntry:K()})}),ee({type:qe("dead"),slot:K(),timestamp:K(),err:re()})]),Qp=ee({subscription:K(),result:Jp}),eg=ee({subscription:K(),result:Tn(At([bp,Rp]))}),tg=ee({subscription:K(),result:K()}),rg=ee({pubkey:re(),gossip:ae(re()),tpu:ae(re()),rpc:ae(re()),version:ae(re())}),aa=ee({votePubkey:re(),nodePubkey:re(),activatedStake:K(),epochVoteAccount:Ut(),epochCredits:oe(li([K(),K(),K()])),commission:K(),lastVote:K(),rootSlot:ae(K())}),ng=we(ee({current:oe(aa),delinquent:oe(aa)})),ig=At([qe("processed"),qe("confirmed"),qe("finalized")]),sg=ee({slot:K(),confirmations:ae(K()),err:_r,confirmationStatus:le(ig)}),og=je(oe(ae(sg))),ag=we(K()),ca=ee({accountKey:Ge,writableIndexes:oe(K()),readonlyIndexes:oe(K())}),Fi=ee({signatures:oe(re()),message:ee({accountKeys:oe(re()),header:ee({numRequiredSignatures:K(),numReadonlySignedAccounts:K(),numReadonlyUnsignedAccounts:K()}),instructions:oe(ee({accounts:oe(K()),data:re(),programIdIndex:K()})),recentBlockhash:re(),addressTableLookups:le(oe(ca))})}),ua=ee({pubkey:Ge,signer:Ut(),writable:Ut(),source:le(At([qe("transaction"),qe("lookupTable")]))}),la=ee({accountKeys:oe(ua),signatures:oe(re())}),ha=ee({parsed:Nr(),program:re(),programId:Ge}),fa=ee({accounts:oe(Ge),data:re(),programId:Ge}),cg=At([fa,ha]),ug=At([ee({parsed:Nr(),program:re(),programId:re()}),ee({accounts:oe(re()),data:re(),programId:re()})]),da=Vr(cg,ug,n=>"accounts"in n?se(n,fa):se(n,ha)),pa=ee({signatures:oe(re()),message:ee({accountKeys:oe(ua),instructions:oe(da),recentBlockhash:re(),addressTableLookups:le(ae(oe(ca)))})}),Nn=ee({accountIndex:K(),mint:re(),owner:le(re()),programId:le(re()),uiTokenAmount:Pi}),ga=ee({writable:oe(Ge),readonly:oe(Ge)}),xn=ee({err:_r,fee:K(),innerInstructions:le(ae(oe(ee({index:K(),instructions:oe(ee({accounts:oe(K()),data:re(),programIdIndex:K()}))})))),preBalances:oe(K()),postBalances:oe(K()),logMessages:le(ae(oe(re()))),preTokenBalances:le(ae(oe(Nn))),postTokenBalances:le(ae(oe(Nn))),loadedAddresses:le(ga),computeUnitsConsumed:le(K())}),zi=ee({err:_r,fee:K(),innerInstructions:le(ae(oe(ee({index:K(),instructions:oe(da)})))),preBalances:oe(K()),postBalances:oe(K()),logMessages:le(ae(oe(re()))),preTokenBalances:le(ae(oe(Nn))),postTokenBalances:le(ae(oe(Nn))),loadedAddresses:le(ga),computeUnitsConsumed:le(K())}),Cr=At([qe(0),qe("legacy")]),wr=ee({pubkey:re(),lamports:K(),postBalance:ae(K()),rewardType:ae(re()),commission:le(ae(K()))}),lg=we(ae(ee({blockhash:re(),previousBlockhash:re(),parentSlot:K(),transactions:oe(ee({transaction:Fi,meta:ae(xn),version:le(Cr)})),rewards:le(oe(wr)),blockTime:ae(K()),blockHeight:ae(K())}))),hg=we(ae(ee({blockhash:re(),previousBlockhash:re(),parentSlot:K(),rewards:le(oe(wr)),blockTime:ae(K()),blockHeight:ae(K())}))),fg=we(ae(ee({blockhash:re(),previousBlockhash:re(),parentSlot:K(),transactions:oe(ee({transaction:la,meta:ae(xn),version:le(Cr)})),rewards:le(oe(wr)),blockTime:ae(K()),blockHeight:ae(K())}))),dg=we(ae(ee({blockhash:re(),previousBlockhash:re(),parentSlot:K(),transactions:oe(ee({transaction:pa,meta:ae(zi),version:le(Cr)})),rewards:le(oe(wr)),blockTime:ae(K()),blockHeight:ae(K())}))),pg=we(ae(ee({blockhash:re(),previousBlockhash:re(),parentSlot:K(),transactions:oe(ee({transaction:la,meta:ae(zi),version:le(Cr)})),rewards:le(oe(wr)),blockTime:ae(K()),blockHeight:ae(K())}))),gg=we(ae(ee({blockhash:re(),previousBlockhash:re(),parentSlot:K(),rewards:le(oe(wr)),blockTime:ae(K()),blockHeight:ae(K())}))),mg=we(ae(ee({blockhash:re(),previousBlockhash:re(),parentSlot:K(),transactions:oe(ee({transaction:Fi,meta:ae(xn)})),rewards:le(oe(wr)),blockTime:ae(K())}))),ma=we(ae(ee({blockhash:re(),previousBlockhash:re(),parentSlot:K(),signatures:oe(re()),blockTime:ae(K())}))),$i=we(ae(ee({slot:K(),meta:ae(xn),blockTime:le(ae(K())),transaction:Fi,version:le(Cr)}))),Bn=we(ae(ee({slot:K(),transaction:pa,meta:ae(zi),blockTime:le(ae(K())),version:le(Cr)}))),yg=je(ee({blockhash:re(),lastValidBlockHeight:K()})),_g=je(Ut()),wg=ee({slot:K(),numTransactions:K(),numSlots:K(),samplePeriodSecs:K()}),bg=we(oe(wg)),Rg=je(ae(ee({feeCalculator:ee({lamportsPerSignature:K()})}))),Eg=we(re()),Sg=we(re()),Ag=ee({err:_r,logs:oe(re()),signature:re()}),Ig=ee({result:Tn(Ag),subscription:K()}),vg={"solana-client":"js/1.0.0-maintenance"};class Og{constructor(e,t){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 _=>{const{commitment:b,config:x}=Ue(_),T=this._buildArgs([],b,void 0,x),L=Qo(T);return g[L]=g[L]??(async()=>{try{const k=await this._rpcRequest("getBlockHeight",T),N=se(k,we(K()));if("error"in N)throw new ue(N.error,"failed to get block height information");return N.result}finally{delete g[L]}})(),await g[L]}})();let r,s,i,o,a,f;t&&typeof t=="string"?this._commitment=t:t&&(this._commitment=t.commitment,this._confirmTransactionInitialTimeout=t.confirmTransactionInitialTimeout,r=t.wsEndpoint,s=t.httpHeaders,i=t.fetch,o=t.fetchMiddleware,a=t.disableRetryOnRateLimit,f=t.httpAgent),this._rpcEndpoint=hp(e),this._rpcWsEndpoint=r||lp(e),this._rpcClient=vp(e,s,i,o,a,f),this._rpcRequest=Op(this._rpcClient),this._rpcBatchRequest=kp(this._rpcClient),this._rpcWebSocket=new op(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(e,t){const{commitment:r,config:s}=Ue(t),i=this._buildArgs([e.toBase58()],r,void 0,s),o=await this._rpcRequest("getBalance",i),a=se(o,je(K()));if("error"in a)throw new ue(a.error,`failed to get balance for ${e.toBase58()}`);return a.result}async getBalance(e,t){return await this.getBalanceAndContext(e,t).then(r=>r.value).catch(r=>{throw new Error("failed to get balance of account "+e.toBase58()+": "+r)})}async getBlockTime(e){const t=await this._rpcRequest("getBlockTime",[e]),r=se(t,we(ae(K())));if("error"in r)throw new ue(r.error,`failed to get block time for slot ${e}`);return r.result}async getMinimumLedgerSlot(){const e=await this._rpcRequest("minimumLedgerSlot",[]),t=se(e,we(K()));if("error"in t)throw new ue(t.error,"failed to get minimum ledger slot");return t.result}async getFirstAvailableBlock(){const e=await this._rpcRequest("getFirstAvailableBlock",[]),t=se(e,Mp);if("error"in t)throw new ue(t.error,"failed to get first available block");return t.result}async getSupply(e){let t={};typeof e=="string"?t={commitment:e}:e?t={...e,commitment:e&&e.commitment||this.commitment}:t={commitment:this.commitment};const r=await this._rpcRequest("getSupply",[t]),s=se(r,Pp);if("error"in s)throw new ue(s.error,"failed to get supply");return s.result}async getTokenSupply(e,t){const r=this._buildArgs([e.toBase58()],t),s=await this._rpcRequest("getTokenSupply",r),i=se(s,je(Pi));if("error"in i)throw new ue(i.error,"failed to get token supply");return i.result}async getTokenAccountBalance(e,t){const r=this._buildArgs([e.toBase58()],t),s=await this._rpcRequest("getTokenAccountBalance",r),i=se(s,je(Pi));if("error"in i)throw new ue(i.error,"failed to get token account balance");return i.result}async getTokenAccountsByOwner(e,t,r){const{commitment:s,config:i}=Ue(r);let o=[e.toBase58()];"mint"in t?o.push({mint:t.mint.toBase58()}):o.push({programId:t.programId.toBase58()});const a=this._buildArgs(o,s,"base64",i),f=await this._rpcRequest("getTokenAccountsByOwner",a),g=se(f,Dp);if("error"in g)throw new ue(g.error,`failed to get token accounts owned by account ${e.toBase58()}`);return g.result}async getParsedTokenAccountsByOwner(e,t,r){let s=[e.toBase58()];"mint"in t?s.push({mint:t.mint.toBase58()}):s.push({programId:t.programId.toBase58()});const i=this._buildArgs(s,r,"jsonParsed"),o=await this._rpcRequest("getTokenAccountsByOwner",i),a=se(o,Fp);if("error"in a)throw new ue(a.error,`failed to get token accounts owned by account ${e.toBase58()}`);return a.result}async getLargestAccounts(e){const t={...e,commitment:e&&e.commitment||this.commitment},r=t.filter||t.commitment?[t]:[],s=await this._rpcRequest("getLargestAccounts",r),i=se(s,zp);if("error"in i)throw new ue(i.error,"failed to get largest accounts");return i.result}async getTokenLargestAccounts(e,t){const r=this._buildArgs([e.toBase58()],t),s=await this._rpcRequest("getTokenLargestAccounts",r),i=se(s,Up);if("error"in i)throw new ue(i.error,"failed to get token largest accounts");return i.result}async getAccountInfoAndContext(e,t){const{commitment:r,config:s}=Ue(t),i=this._buildArgs([e.toBase58()],r,"base64",s),o=await this._rpcRequest("getAccountInfo",i),a=se(o,je(ae(en)));if("error"in a)throw new ue(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getParsedAccountInfo(e,t){const{commitment:r,config:s}=Ue(t),i=this._buildArgs([e.toBase58()],r,"jsonParsed",s),o=await this._rpcRequest("getAccountInfo",i),a=se(o,je(ae(Di)));if("error"in a)throw new ue(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getAccountInfo(e,t){try{return(await this.getAccountInfoAndContext(e,t)).value}catch(r){throw new Error("failed to get info about account "+e.toBase58()+": "+r)}}async getMultipleParsedAccounts(e,t){const{commitment:r,config:s}=Ue(t),i=e.map(g=>g.toBase58()),o=this._buildArgs([i],r,"jsonParsed",s),a=await this._rpcRequest("getMultipleAccounts",o),f=se(a,je(oe(ae(Di))));if("error"in f)throw new ue(f.error,`failed to get info for accounts ${i}`);return f.result}async getMultipleAccountsInfoAndContext(e,t){const{commitment:r,config:s}=Ue(t),i=e.map(g=>g.toBase58()),o=this._buildArgs([i],r,"base64",s),a=await this._rpcRequest("getMultipleAccounts",o),f=se(a,je(oe(ae(en))));if("error"in f)throw new ue(f.error,`failed to get info for accounts ${i}`);return f.result}async getMultipleAccountsInfo(e,t){return(await this.getMultipleAccountsInfoAndContext(e,t)).value}async getStakeActivation(e,t,r){const{commitment:s,config:i}=Ue(t),o=this._buildArgs([e.toBase58()],s,void 0,{...i,epoch:r??(i==null?void 0:i.epoch)}),a=await this._rpcRequest("getStakeActivation",o),f=se(a,we(Hp));if("error"in f)throw new ue(f.error,`failed to get Stake Activation ${e.toBase58()}`);return f.result}async getProgramAccounts(e,t){const{commitment:r,config:s}=Ue(t),{encoding:i,...o}=s||{},a=this._buildArgs([e.toBase58()],r,i||"base64",{...o,...o.filters?{filters:ia(o.filters)}:null}),f=await this._rpcRequest("getProgramAccounts",a),g=oe($p),_=o.withContext===!0?se(f,je(g)):se(f,we(g));if("error"in _)throw new ue(_.error,`failed to get accounts owned by program ${e.toBase58()}`);return _.result}async getParsedProgramAccounts(e,t){const{commitment:r,config:s}=Ue(t),i=this._buildArgs([e.toBase58()],r,"jsonParsed",s),o=await this._rpcRequest("getProgramAccounts",i),a=se(o,we(oe(Wp)));if("error"in a)throw new ue(a.error,`failed to get accounts owned by program ${e.toBase58()}`);return a.result}async confirmTransaction(e,t){var i;let r;if(typeof e=="string")r=e;else{const o=e;if((i=o.abortSignal)!=null&&i.aborted)return Promise.reject(o.abortSignal.reason);r=o.signature}let s;try{s=gt.decode(r)}catch{throw new Error("signature must be base58 encoded: "+r)}return Ie(s.length===64,"signature has invalid length"),typeof e=="string"?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:t||this.commitment,signature:r}):"lastValidBlockHeight"in e?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t||this.commitment,strategy:e}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:t||this.commitment,strategy:e})}getCancellationPromise(e){return new Promise((t,r)=>{e!=null&&(e.aborted?r(e.reason):e.addEventListener("abort",()=>{r(e.reason)}))})}getTransactionConfirmationPromise({commitment:e,signature:t}){let r,s,i=!1;const o=new Promise((f,g)=>{try{r=this.onSignature(t,(b,x)=>{r=void 0;const T={context:x,value:b};f({__type:Zt.PROCESSED,response:T})},e);const _=new Promise(b=>{r==null?b():s=this._onSubscriptionStateChange(r,x=>{x==="subscribed"&&b()})});(async()=>{if(await _,i)return;const b=await this.getSignatureStatus(t);if(i||b==null)return;const{context:x,value:T}=b;if(T!=null)if(T!=null&&T.err)g(T.err);else{switch(e){case"confirmed":case"single":case"singleGossip":{if(T.confirmationStatus==="processed")return;break}case"finalized":case"max":case"root":{if(T.confirmationStatus==="processed"||T.confirmationStatus==="confirmed")return;break}case"processed":case"recent":}i=!0,f({__type:Zt.PROCESSED,response:{context:x,value:T}})}})()}catch(_){g(_)}});return{abortConfirmation:()=>{s&&(s(),s=void 0),r!=null&&(this.removeSignatureListener(r),r=void 0)},confirmationPromise:o}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e,strategy:{abortSignal:t,lastValidBlockHeight:r,signature:s}}){let i=!1;const o=new Promise(b=>{const x=async()=>{try{return await this.getBlockHeight(e)}catch{return-1}};(async()=>{let T=await x();if(!i){for(;T<=r;)if(await mr(1e3),i||(T=await x(),i))return;b({__type:Zt.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:a,confirmationPromise:f}=this.getTransactionConfirmationPromise({commitment:e,signature:s}),g=this.getCancellationPromise(t);let _;try{const b=await Promise.race([g,f,o]);if(b.__type===Zt.PROCESSED)_=b.response;else throw new Ai(s)}finally{i=!0,a()}return _}async confirmTransactionUsingDurableNonceStrategy({commitment:e,strategy:{abortSignal:t,minContextSlot:r,nonceAccountPubkey:s,nonceValue:i,signature:o}}){let a=!1;const f=new Promise(T=>{let L=i,k=null;const N=async()=>{try{const{context:M,value:W}=await this.getNonceAndContext(s,{commitment:e,minContextSlot:r});return k=M.slot,W==null?void 0:W.nonce}catch{return L}};(async()=>{if(L=await N(),!a)for(;;){if(i!==L){T({__type:Zt.NONCE_INVALID,slotInWhichNonceDidAdvance:k});return}if(await mr(2e3),a||(L=await N(),a))return}})()}),{abortConfirmation:g,confirmationPromise:_}=this.getTransactionConfirmationPromise({commitment:e,signature:o}),b=this.getCancellationPromise(t);let x;try{const T=await Promise.race([b,_,f]);if(T.__type===Zt.PROCESSED)x=T.response;else{let L;for(;;){const k=await this.getSignatureStatus(o);if(k==null)break;if(k.context.slot<(T.slotInWhichNonceDidAdvance??r)){await mr(400);continue}L=k;break}if(L!=null&&L.value){const k=e||"finalized",{confirmationStatus:N}=L.value;switch(k){case"processed":case"recent":if(N!=="processed"&&N!=="confirmed"&&N!=="finalized")throw new xr(o);break;case"confirmed":case"single":case"singleGossip":if(N!=="confirmed"&&N!=="finalized")throw new xr(o);break;case"finalized":case"max":case"root":if(N!=="finalized")throw new xr(o);break;default:}x={context:L.context,value:{err:L.value.err}}}else throw new xr(o)}}finally{a=!0,g()}return x}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:e,signature:t}){let r;const s=new Promise(f=>{let g=this._confirmTransactionInitialTimeout||6e4;switch(e){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{g=this._confirmTransactionInitialTimeout||3e4;break}}r=setTimeout(()=>f({__type:Zt.TIMED_OUT,timeoutMs:g}),g)}),{abortConfirmation:i,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:e,signature:t});let a;try{const f=await Promise.race([o,s]);if(f.__type===Zt.PROCESSED)a=f.response;else throw new Ii(t,f.timeoutMs/1e3)}finally{clearTimeout(r),i()}return a}async getClusterNodes(){const e=await this._rpcRequest("getClusterNodes",[]),t=se(e,we(oe(rg)));if("error"in t)throw new ue(t.error,"failed to get cluster nodes");return t.result}async getVoteAccounts(e){const t=this._buildArgs([],e),r=await this._rpcRequest("getVoteAccounts",t),s=se(r,ng);if("error"in s)throw new ue(s.error,"failed to get vote accounts");return s.result}async getSlot(e){const{commitment:t,config:r}=Ue(e),s=this._buildArgs([],t,void 0,r),i=await this._rpcRequest("getSlot",s),o=se(i,we(K()));if("error"in o)throw new ue(o.error,"failed to get slot");return o.result}async getSlotLeader(e){const{commitment:t,config:r}=Ue(e),s=this._buildArgs([],t,void 0,r),i=await this._rpcRequest("getSlotLeader",s),o=se(i,we(re()));if("error"in o)throw new ue(o.error,"failed to get slot leader");return o.result}async getSlotLeaders(e,t){const r=[e,t],s=await this._rpcRequest("getSlotLeaders",r),i=se(s,we(oe(Ge)));if("error"in i)throw new ue(i.error,"failed to get slot leaders");return i.result}async getSignatureStatus(e,t){const{context:r,value:s}=await this.getSignatureStatuses([e],t);Ie(s.length===1);const i=s[0];return{context:r,value:i}}async getSignatureStatuses(e,t){const r=[e];t&&r.push(t);const s=await this._rpcRequest("getSignatureStatuses",r),i=se(s,og);if("error"in i)throw new ue(i.error,"failed to get signature status");return i.result}async getTransactionCount(e){const{commitment:t,config:r}=Ue(e),s=this._buildArgs([],t,void 0,r),i=await this._rpcRequest("getTransactionCount",s),o=se(i,we(K()));if("error"in o)throw new ue(o.error,"failed to get transaction count");return o.result}async getTotalSupply(e){return(await this.getSupply({commitment:e,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(e){const t=this._buildArgs([],e),r=await this._rpcRequest("getInflationGovernor",t),s=se(r,Tp);if("error"in s)throw new ue(s.error,"failed to get inflation");return s.result}async getInflationReward(e,t,r){const{commitment:s,config:i}=Ue(r),o=this._buildArgs([e.map(g=>g.toBase58())],s,void 0,{...i,epoch:t??(i==null?void 0:i.epoch)}),a=await this._rpcRequest("getInflationReward",o),f=se(a,pp);if("error"in f)throw new ue(f.error,"failed to get inflation reward");return f.result}async getInflationRate(){const e=await this._rpcRequest("getInflationRate",[]),t=se(e,Np);if("error"in t)throw new ue(t.error,"failed to get inflation rate");return t.result}async getEpochInfo(e){const{commitment:t,config:r}=Ue(e),s=this._buildArgs([],t,void 0,r),i=await this._rpcRequest("getEpochInfo",s),o=se(i,Bp);if("error"in o)throw new ue(o.error,"failed to get epoch info");return o.result}async getEpochSchedule(){const e=await this._rpcRequest("getEpochSchedule",[]),t=se(e,Lp);if("error"in t)throw new ue(t.error,"failed to get epoch schedule");const r=t.result;return new ea(r.slotsPerEpoch,r.leaderScheduleSlotOffset,r.warmup,r.firstNormalEpoch,r.firstNormalSlot)}async getLeaderSchedule(){const e=await this._rpcRequest("getLeaderSchedule",[]),t=se(e,Cp);if("error"in t)throw new ue(t.error,"failed to get leader schedule");return t.result}async getMinimumBalanceForRentExemption(e,t){const r=this._buildArgs([e],t),s=await this._rpcRequest("getMinimumBalanceForRentExemption",r),i=se(s,ag);return"error"in i?(console.warn("Unable to fetch minimum balance for rent exemption"),0):i.result}async getRecentBlockhashAndContext(e){const{context:t,value:{blockhash:r}}=await this.getLatestBlockhashAndContext(e);return{context:t,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(e){const t=await this._rpcRequest("getRecentPerformanceSamples",e?[e]:[]),r=se(t,bg);if("error"in r)throw new ue(r.error,"failed to get recent performance samples");return r.result}async getFeeCalculatorForBlockhash(e,t){const r=this._buildArgs([e],t),s=await this._rpcRequest("getFeeCalculatorForBlockhash",r),i=se(s,Rg);if("error"in i)throw new ue(i.error,"failed to get fee calculator");const{context:o,value:a}=i.result;return{context:o,value:a!==null?a.feeCalculator:null}}async getFeeForMessage(e,t){const r=_e(e.serialize()).toString("base64"),s=this._buildArgs([r],t),i=await this._rpcRequest("getFeeForMessage",s),o=se(i,je(ae(K())));if("error"in o)throw new ue(o.error,"failed to get fee for message");if(o.result===null)throw new Error("invalid blockhash");return o.result}async getRecentPrioritizationFees(e){var o;const t=(o=e==null?void 0:e.lockedWritableAccounts)==null?void 0:o.map(a=>a.toBase58()),r=t!=null&&t.length?[t]:[],s=await this._rpcRequest("getRecentPrioritizationFees",r),i=se(s,xp);if("error"in i)throw new ue(i.error,"failed to get recent prioritization fees");return i.result}async getRecentBlockhash(e){try{return(await this.getRecentBlockhashAndContext(e)).value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhash(e){try{return(await this.getLatestBlockhashAndContext(e)).value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhashAndContext(e){const{commitment:t,config:r}=Ue(e),s=this._buildArgs([],t,void 0,r),i=await this._rpcRequest("getLatestBlockhash",s),o=se(i,yg);if("error"in o)throw new ue(o.error,"failed to get latest blockhash");return o.result}async isBlockhashValid(e,t){const{commitment:r,config:s}=Ue(t),i=this._buildArgs([e],r,void 0,s),o=await this._rpcRequest("isBlockhashValid",i),a=se(o,_g);if("error"in a)throw new ue(a.error,"failed to determine if the blockhash `"+e+"`is valid");return a.result}async getVersion(){const e=await this._rpcRequest("getVersion",[]),t=se(e,we(Ep));if("error"in t)throw new ue(t.error,"failed to get version");return t.result}async getGenesisHash(){const e=await this._rpcRequest("getGenesisHash",[]),t=se(e,we(re()));if("error"in t)throw new ue(t.error,"failed to get genesis hash");return t.result}async getBlock(e,t){const{commitment:r,config:s}=Ue(t),i=this._buildArgsAtLeastConfirmed([e],r,void 0,s),o=await this._rpcRequest("getBlock",i);try{switch(s==null?void 0:s.transactionDetails){case"accounts":{const a=se(o,fg);if("error"in a)throw a.error;return a.result}case"none":{const a=se(o,hg);if("error"in a)throw a.error;return a.result}default:{const a=se(o,lg);if("error"in a)throw a.error;const{result:f}=a;return f?{...f,transactions:f.transactions.map(({transaction:g,meta:_,version:b})=>({meta:_,transaction:{...g,message:Mi(b,g.message)},version:b}))}:null}}}catch(a){throw new ue(a,"failed to get confirmed block")}}async getParsedBlock(e,t){const{commitment:r,config:s}=Ue(t),i=this._buildArgsAtLeastConfirmed([e],r,"jsonParsed",s),o=await this._rpcRequest("getBlock",i);try{switch(s==null?void 0:s.transactionDetails){case"accounts":{const a=se(o,pg);if("error"in a)throw a.error;return a.result}case"none":{const a=se(o,gg);if("error"in a)throw a.error;return a.result}default:{const a=se(o,dg);if("error"in a)throw a.error;return a.result}}}catch(a){throw new ue(a,"failed to get block")}}async getBlockProduction(e){let t,r;if(typeof e=="string")r=e;else if(e){const{commitment:a,...f}=e;r=a,t=f}const s=this._buildArgs([],r,"base64",t),i=await this._rpcRequest("getBlockProduction",s),o=se(i,Ip);if("error"in o)throw new ue(o.error,"failed to get block production information");return o.result}async getTransaction(e,t){const{commitment:r,config:s}=Ue(t),i=this._buildArgsAtLeastConfirmed([e],r,void 0,s),o=await this._rpcRequest("getTransaction",i),a=se(o,$i);if("error"in a)throw new ue(a.error,"failed to get transaction");const f=a.result;return f&&{...f,transaction:{...f.transaction,message:Mi(f.version,f.transaction.message)}}}async getParsedTransaction(e,t){const{commitment:r,config:s}=Ue(t),i=this._buildArgsAtLeastConfirmed([e],r,"jsonParsed",s),o=await this._rpcRequest("getTransaction",i),a=se(o,Bn);if("error"in a)throw new ue(a.error,"failed to get transaction");return a.result}async getParsedTransactions(e,t){const{commitment:r,config:s}=Ue(t),i=e.map(f=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([f],r,"jsonParsed",s)}));return(await this._rpcBatchRequest(i)).map(f=>{const g=se(f,Bn);if("error"in g)throw new ue(g.error,"failed to get transactions");return g.result})}async getTransactions(e,t){const{commitment:r,config:s}=Ue(t),i=e.map(f=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([f],r,void 0,s)}));return(await this._rpcBatchRequest(i)).map(f=>{const g=se(f,$i);if("error"in g)throw new ue(g.error,"failed to get transactions");const _=g.result;return _&&{..._,transaction:{..._.transaction,message:Mi(_.version,_.transaction.message)}}})}async getConfirmedBlock(e,t){const r=this._buildArgsAtLeastConfirmed([e],t),s=await this._rpcRequest("getBlock",r),i=se(s,mg);if("error"in i)throw new ue(i.error,"failed to get confirmed block");const o=i.result;if(!o)throw new Error("Confirmed block "+e+" not found");const a={...o,transactions:o.transactions.map(({transaction:f,meta:g})=>{const _=new Lt(f.message);return{meta:g,transaction:{...f,message:_}}})};return{...a,transactions:a.transactions.map(({transaction:f,meta:g})=>({meta:g,transaction:Oe.populate(f.message,f.signatures)}))}}async getBlocks(e,t,r){const s=this._buildArgsAtLeastConfirmed(t!==void 0?[e,t]:[e],r),i=await this._rpcRequest("getBlocks",s),o=se(i,we(oe(K())));if("error"in o)throw new ue(o.error,"failed to get blocks");return o.result}async getBlockSignatures(e,t){const r=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),s=await this._rpcRequest("getBlock",r),i=se(s,ma);if("error"in i)throw new ue(i.error,"failed to get block");const o=i.result;if(!o)throw new Error("Block "+e+" not found");return o}async getConfirmedBlockSignatures(e,t){const r=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),s=await this._rpcRequest("getBlock",r),i=se(s,ma);if("error"in i)throw new ue(i.error,"failed to get confirmed block");const o=i.result;if(!o)throw new Error("Confirmed block "+e+" not found");return o}async getConfirmedTransaction(e,t){const r=this._buildArgsAtLeastConfirmed([e],t),s=await this._rpcRequest("getTransaction",r),i=se(s,$i);if("error"in i)throw new ue(i.error,"failed to get transaction");const o=i.result;if(!o)return o;const a=new Lt(o.transaction.message),f=o.transaction.signatures;return{...o,transaction:Oe.populate(a,f)}}async getParsedConfirmedTransaction(e,t){const r=this._buildArgsAtLeastConfirmed([e],t,"jsonParsed"),s=await this._rpcRequest("getTransaction",r),i=se(s,Bn);if("error"in i)throw new ue(i.error,"failed to get confirmed transaction");return i.result}async getParsedConfirmedTransactions(e,t){const r=e.map(o=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([o],t,"jsonParsed")}));return(await this._rpcBatchRequest(r)).map(o=>{const a=se(o,Bn);if("error"in a)throw new ue(a.error,"failed to get confirmed transactions");return a.result})}async getConfirmedSignaturesForAddress(e,t,r){let s={},i=await this.getFirstAvailableBlock();for(;!("until"in s)&&(t--,!(t<=0||t<i));)try{const f=await this.getConfirmedBlockSignatures(t,"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(e,s)).map(f=>f.signature)}async getConfirmedSignaturesForAddress2(e,t,r){const s=this._buildArgsAtLeastConfirmed([e.toBase58()],r,void 0,t),i=await this._rpcRequest("getConfirmedSignaturesForAddress2",s),o=se(i,qp);if("error"in o)throw new ue(o.error,"failed to get confirmed signatures for address");return o.result}async getSignaturesForAddress(e,t,r){const s=this._buildArgsAtLeastConfirmed([e.toBase58()],r,void 0,t),i=await this._rpcRequest("getSignaturesForAddress",s),o=se(i,Gp);if("error"in o)throw new ue(o.error,"failed to get signatures for address");return o.result}async getAddressLookupTable(e,t){const{context:r,value:s}=await this.getAccountInfoAndContext(e,t);let i=null;return s!==null&&(i=new Li({key:e,state:Li.deserialize(s.data)})),{context:r,value:i}}async getNonceAndContext(e,t){const{context:r,value:s}=await this.getAccountInfoAndContext(e,t);let i=null;return s!==null&&(i=kn.fromAccountData(s.data)),{context:r,value:i}}async getNonce(e,t){return await this.getNonceAndContext(e,t).then(r=>r.value).catch(r=>{throw new Error("failed to get nonce for account "+e.toBase58()+": "+r)})}async requestAirdrop(e,t){const r=await this._rpcRequest("requestAirdrop",[e.toBase58(),t]),s=se(r,Eg);if("error"in s)throw new ue(s.error,`airdrop to ${e.toBase58()} failed`);return s.result}async _blockhashWithExpiryBlockHeight(e){if(!e){for(;this._pollingBlockhash;)await mr(100);const r=Date.now()-this._blockhashInfo.lastFetch>=na;if(this._blockhashInfo.latestBlockhash!==null&&!r)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{const e=Date.now(),t=this._blockhashInfo.latestBlockhash,r=t?t.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 mr(jo/2)}throw new Error(`Unable to obtain a new blockhash after ${Date.now()-e}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(e){const{commitment:t,config:r}=Ue(e),s=this._buildArgs([],t,"base64",r),i=await this._rpcRequest("getStakeMinimumDelegation",s),o=se(i,je(K()));if("error"in o)throw new ue(o.error,"failed to get stake minimum delegation");return o.result}async simulateTransaction(e,t,r){if("message"in e){const k=e.serialize(),N=fe.Buffer.from(k).toString("base64");if(Array.isArray(t)||r!==void 0)throw new Error("Invalid arguments");const M=t||{};M.encoding="base64","commitment"in M||(M.commitment=this.commitment),t&&typeof t=="object"&&"innerInstructions"in t&&(M.innerInstructions=t.innerInstructions);const W=[N,M],$=await this._rpcRequest("simulateTransaction",W),J=se($,oa);if("error"in J)throw new Error("failed to simulate transaction: "+J.error.message);return J.result}let s;if(e instanceof Oe){let L=e;s=new Oe,s.feePayer=L.feePayer,s.instructions=e.instructions,s.nonceInfo=L.nonceInfo,s.signatures=L.signatures}else s=Oe.populate(e),s._message=s._json=void 0;if(t!==void 0&&!Array.isArray(t))throw new Error("Invalid arguments");const i=t;if(s.nonceInfo&&i)s.sign(...i);else{let L=this._disableBlockhashCaching;for(;;){const k=await this._blockhashWithExpiryBlockHeight(L);if(s.lastValidBlockHeight=k.lastValidBlockHeight,s.recentBlockhash=k.blockhash,!i)break;if(s.sign(...i),!s.signature)throw new Error("!signature");const N=s.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(N)&&!this._blockhashInfo.transactionSignatures.includes(N)){this._blockhashInfo.simulatedSignatures.push(N);break}else L=!0}}const o=s._compile(),a=o.serialize(),g=s._serialize(a).toString("base64"),_={encoding:"base64",commitment:this.commitment};if(r){const L=(Array.isArray(r)?r:o.nonProgramIds()).map(k=>k.toBase58());_.accounts={encoding:"base64",addresses:L}}i&&(_.sigVerify=!0),t&&typeof t=="object"&&"innerInstructions"in t&&(_.innerInstructions=t.innerInstructions);const b=[g,_],x=await this._rpcRequest("simulateTransaction",b),T=se(x,oa);if("error"in T){let L;if("data"in T.error&&(L=T.error.data.logs,L&&Array.isArray(L))){const k=`
17
- `,N=k+L.join(k);console.error(T.error.message,N)}throw new Jr({action:"simulate",signature:"",transactionMessage:T.error.message,logs:L})}return T.result}async sendTransaction(e,t,r){if("version"in e){if(t&&Array.isArray(t))throw new Error("Invalid arguments");const o=e.serialize();return await this.sendRawTransaction(o,t)}if(t===void 0||!Array.isArray(t))throw new Error("Invalid arguments");const s=t;if(e.nonceInfo)e.sign(...s);else{let o=this._disableBlockhashCaching;for(;;){const a=await this._blockhashWithExpiryBlockHeight(o);if(e.lastValidBlockHeight=a.lastValidBlockHeight,e.recentBlockhash=a.blockhash,e.sign(...s),!e.signature)throw new Error("!signature");const f=e.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(f))o=!0;else{this._blockhashInfo.transactionSignatures.push(f);break}}}const i=e.serialize();return await this.sendRawTransaction(i,r)}async sendRawTransaction(e,t){const r=_e(e).toString("base64");return await this.sendEncodedTransaction(r,t)}async sendEncodedTransaction(e,t){const r={encoding:"base64"},s=t&&t.skipPreflight,i=s===!0?"processed":t&&t.preflightCommitment||this.commitment;t&&t.maxRetries!=null&&(r.maxRetries=t.maxRetries),t&&t.minContextSlot!=null&&(r.minContextSlot=t.minContextSlot),s&&(r.skipPreflight=s),i&&(r.preflightCommitment=i);const o=[e,r],a=await this._rpcRequest("sendTransaction",o),f=se(a,Sg);if("error"in f){let g;throw"data"in f.error&&(g=f.error.data.logs),new Jr({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(e){this._rpcWebSocketConnected=!1,console.error("ws error:",e.message)}_wsOnClose(e){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),e===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([t,r])=>{this._setSubscription(t,{...r,state:"pending"})})}_setSubscription(e,t){var s;const r=(s=this._subscriptionsByHash[e])==null?void 0:s.state;if(this._subscriptionsByHash[e]=t,r!==t.state){const i=this._subscriptionStateChangeCallbacksByHash[e];i&&i.forEach(o=>{try{o(t.state)}catch{}})}}_onSubscriptionStateChange(e,t){var i;const r=this._subscriptionHashByClientSubscriptionId[e];if(r==null)return()=>{};const s=(i=this._subscriptionStateChangeCallbacksByHash)[r]||(i[r]=new Set);return s.add(t),()=>{s.delete(t),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 e=this._rpcWebSocketGeneration,t=()=>e===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async r=>{const s=this._subscriptionsByHash[r];if(s!==void 0)switch(s.state){case"pending":case"unsubscribed":if(s.callbacks.size===0){delete this._subscriptionsByHash[r],s.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[s.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{const{args:i,method:o}=s;try{this._setSubscription(r,{...s,state:"subscribing"});const a=await this._rpcWebSocket.call(o,i);this._setSubscription(r,{...s,serverSubscriptionId:a,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[a]=s.callbacks,await this._updateSubscriptions()}catch(a){if(console.error(`Received ${a instanceof Error?"":"JSON-RPC "}error calling \`${o}\``,{args:i,error:a}),!t())return;this._setSubscription(r,{...s,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":s.callbacks.size===0&&await(async()=>{const{serverSubscriptionId:i,unsubscribeMethod:o}=s;if(this._subscriptionsAutoDisposedByRpc.has(i))this._subscriptionsAutoDisposedByRpc.delete(i);else{this._setSubscription(r,{...s,state:"unsubscribing"}),this._setSubscription(r,{...s,state:"unsubscribing"});try{await this._rpcWebSocket.call(o,[i])}catch(a){if(a instanceof Error&&console.error(`${o} error:`,a.message),!t())return;this._setSubscription(r,{...s,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(r,{...s,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(e,t){const r=this._subscriptionCallbacksByServerSubscriptionId[e];r!==void 0&&r.forEach(s=>{try{s(...t)}catch(i){console.error(i)}})}_wsOnAccountNotification(e){const{result:t,subscription:r}=se(e,Vp);this._handleServerNotification(r,[t.value,t.context])}_makeSubscription(e,t){const r=this._nextClientSubscriptionId++,s=Qo([e.method,t]),i=this._subscriptionsByHash[s];return i===void 0?this._subscriptionsByHash[s]={...e,args:t,callbacks:new Set([e.callback]),state:"pending"}:i.callbacks.add(e.callback),this._subscriptionHashByClientSubscriptionId[r]=s,this._subscriptionDisposeFunctionsByClientSubscriptionId[r]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[r],delete this._subscriptionHashByClientSubscriptionId[r];const o=this._subscriptionsByHash[s];Ie(o!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${r}`),o.callbacks.delete(e.callback),await this._updateSubscriptions()},this._updateSubscriptions(),r}onAccountChange(e,t,r){const{commitment:s,config:i}=Ue(r),o=this._buildArgs([e.toBase58()],s||this._commitment||"finalized","base64",i);return this._makeSubscription({callback:t,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},o)}async removeAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"account change")}_wsOnProgramAccountNotification(e){const{result:t,subscription:r}=se(e,jp);this._handleServerNotification(r,[{accountId:t.value.pubkey,accountInfo:t.value.account},t.context])}onProgramAccountChange(e,t,r,s){const{commitment:i,config:o}=Ue(r),a=this._buildArgs([e.toBase58()],i||this._commitment||"finalized","base64",o||(s?{filters:ia(s)}:void 0));return this._makeSubscription({callback:t,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},a)}async removeProgramAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"program account change")}onLogs(e,t,r){const s=this._buildArgs([typeof e=="object"?{mentions:[e.toString()]}:e],r||this._commitment||"finalized");return this._makeSubscription({callback:t,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},s)}async removeOnLogsListener(e){await this._unsubscribeClientSubscription(e,"logs")}_wsOnLogsNotification(e){const{result:t,subscription:r}=se(e,Ig);this._handleServerNotification(r,[t.value,t.context])}_wsOnSlotNotification(e){const{result:t,subscription:r}=se(e,Xp);this._handleServerNotification(r,[t])}onSlotChange(e){return this._makeSubscription({callback:e,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(e){await this._unsubscribeClientSubscription(e,"slot change")}_wsOnSlotUpdatesNotification(e){const{result:t,subscription:r}=se(e,Qp);this._handleServerNotification(r,[t])}onSlotUpdate(e){return this._makeSubscription({callback:e,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(e){await this._unsubscribeClientSubscription(e,"slot update")}async _unsubscribeClientSubscription(e,t){const r=this._subscriptionDisposeFunctionsByClientSubscriptionId[e];r?await r():console.warn(`Ignored unsubscribe request because an active subscription with id \`${e}\` for '${t}' events could not be found.`)}_buildArgs(e,t,r,s){const i=t||this._commitment;if(i||r||s){let o={};r&&(o.encoding=r),i&&(o.commitment=i),s&&(o=Object.assign(o,s)),e.push(o)}return e}_buildArgsAtLeastConfirmed(e,t,r,s){const i=t||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(e,t,r,s)}_wsOnSignatureNotification(e){const{result:t,subscription:r}=se(e,eg);t.value!=="receivedSignature"&&this._subscriptionsAutoDisposedByRpc.add(r),this._handleServerNotification(r,t.value==="receivedSignature"?[{type:"received"},t.context]:[{type:"status",result:t.value},t.context])}onSignature(e,t,r){const s=this._buildArgs([e],r||this._commitment||"finalized"),i=this._makeSubscription({callback:(o,a)=>{if(o.type==="status"){t(o.result,a);try{this.removeSignatureListener(i)}catch{}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},s);return i}onSignatureWithOptions(e,t,r){const{commitment:s,...i}={...r,commitment:r&&r.commitment||this._commitment||"finalized"},o=this._buildArgs([e],s,void 0,i),a=this._makeSubscription({callback:(f,g)=>{t(f,g);try{this.removeSignatureListener(a)}catch{}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},o);return a}async removeSignatureListener(e){await this._unsubscribeClientSubscription(e,"signature result")}_wsOnRootNotification(e){const{result:t,subscription:r}=se(e,tg);this._handleServerNotification(r,[t])}onRootChange(e){return this._makeSubscription({callback:e,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(e){await this._unsubscribeClientSubscription(e,"root change")}}class Mr{constructor(e){this._keypair=void 0,this._keypair=e??Ko()}static generate(){return new Mr(Ko())}static fromSecretKey(e,t){if(e.byteLength!==64)throw new Error("bad secret key size");const r=e.slice(32,64);if(!t||!t.skipValidation){const s=e.slice(0,32),i=Sn(s);for(let o=0;o<32;o++)if(r[o]!==i[o])throw new Error("provided secretKey is invalid")}return new Mr({publicKey:r,secretKey:e})}static fromSeed(e){const t=Sn(e),r=new Uint8Array(64);return r.set(e),r.set(t,32),new Mr({publicKey:t,secretKey:r})}get publicKey(){return new ie(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}const Xt=Object.freeze({CreateLookupTable:{index:0,layout:B.struct([B.u32("instruction"),Lr("recentSlot"),B.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:B.struct([B.u32("instruction")])},ExtendLookupTable:{index:2,layout:B.struct([B.u32("instruction"),Lr(),B.seq(Se(),B.offset(B.u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:B.struct([B.u32("instruction")])},CloseLookupTable:{index:4,layout:B.struct([B.u32("instruction")])}});class kg{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const r=B.u32("instruction").decode(e.data);let s;for(const[i,o]of Object.entries(Xt))if(o.index==r){s=i;break}if(!s)throw new Error("Invalid Instruction. Should be a LookupTable Instruction");return s}static decodeCreateLookupTable(e){this.checkProgramId(e.programId),this.checkKeysLength(e.keys,4);const{recentSlot:t}=Te(Xt.CreateLookupTable,e.data);return{authority:e.keys[1].pubkey,payer:e.keys[2].pubkey,recentSlot:Number(t)}}static decodeExtendLookupTable(e){if(this.checkProgramId(e.programId),e.keys.length<2)throw new Error(`invalid instruction; found ${e.keys.length} keys, expected at least 2`);const{addresses:t}=Te(Xt.ExtendLookupTable,e.data);return{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey,payer:e.keys.length>2?e.keys[2].pubkey:void 0,addresses:t.map(r=>new ie(r))}}static decodeCloseLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,3),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey,recipient:e.keys[2].pubkey}}static decodeFreezeLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,2),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey}}static decodeDeactivateLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,2),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey}}static checkProgramId(e){if(!e.equals(Ki.programId))throw new Error("invalid instruction; programId is not AddressLookupTable Program")}static checkKeysLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}class Ki{constructor(){}static createLookupTable(e){const[t,r]=ie.findProgramAddressSync([e.authority.toBuffer(),go().encode(e.recentSlot)],this.programId),s=Xt.CreateLookupTable,i=Ae(s,{recentSlot:BigInt(e.recentSlot),bumpSeed:r}),o=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:mt.programId,isSigner:!1,isWritable:!1}];return[new Be({programId:this.programId,keys:o,data:i}),t]}static freezeLookupTable(e){const t=Xt.FreezeLookupTable,r=Ae(t),s=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new Be({programId:this.programId,keys:s,data:r})}static extendLookupTable(e){const t=Xt.ExtendLookupTable,r=Ae(t,{addresses:e.addresses.map(i=>i.toBytes())}),s=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return e.payer&&s.push({pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:mt.programId,isSigner:!1,isWritable:!1}),new Be({programId:this.programId,keys:s,data:r})}static deactivateLookupTable(e){const t=Xt.DeactivateLookupTable,r=Ae(t),s=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new Be({programId:this.programId,keys:s,data:r})}static closeLookupTable(e){const t=Xt.CloseLookupTable,r=Ae(t),s=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.recipient,isSigner:!1,isWritable:!0}];return new Be({programId:this.programId,keys:s,data:r})}}Ki.programId=new ie("AddressLookupTab1e1111111111111111111111111");class Tg{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const r=B.u8("instruction").decode(e.data);let s;for(const[i,o]of Object.entries($t))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a ComputeBudgetInstruction");return s}static decodeRequestUnits(e){this.checkProgramId(e.programId);const{units:t,additionalFee:r}=Te($t.RequestUnits,e.data);return{units:t,additionalFee:r}}static decodeRequestHeapFrame(e){this.checkProgramId(e.programId);const{bytes:t}=Te($t.RequestHeapFrame,e.data);return{bytes:t}}static decodeSetComputeUnitLimit(e){this.checkProgramId(e.programId);const{units:t}=Te($t.SetComputeUnitLimit,e.data);return{units:t}}static decodeSetComputeUnitPrice(e){this.checkProgramId(e.programId);const{microLamports:t}=Te($t.SetComputeUnitPrice,e.data);return{microLamports:t}}static checkProgramId(e){if(!e.equals(Wi.programId))throw new Error("invalid instruction; programId is not ComputeBudgetProgram")}}const $t=Object.freeze({RequestUnits:{index:0,layout:B.struct([B.u8("instruction"),B.u32("units"),B.u32("additionalFee")])},RequestHeapFrame:{index:1,layout:B.struct([B.u8("instruction"),B.u32("bytes")])},SetComputeUnitLimit:{index:2,layout:B.struct([B.u8("instruction"),B.u32("units")])},SetComputeUnitPrice:{index:3,layout:B.struct([B.u8("instruction"),Lr("microLamports")])}});class Wi{constructor(){}static requestUnits(e){const t=$t.RequestUnits,r=Ae(t,e);return new Be({keys:[],programId:this.programId,data:r})}static requestHeapFrame(e){const t=$t.RequestHeapFrame,r=Ae(t,e);return new Be({keys:[],programId:this.programId,data:r})}static setComputeUnitLimit(e){const t=$t.SetComputeUnitLimit,r=Ae(t,e);return new Be({keys:[],programId:this.programId,data:r})}static setComputeUnitPrice(e){const t=$t.SetComputeUnitPrice,r=Ae(t,{microLamports:BigInt(e.microLamports)});return new Be({keys:[],programId:this.programId,data:r})}}Wi.programId=new ie("ComputeBudget111111111111111111111111111111");const ya=64,_a=32,wa=64,ba=B.struct([B.u8("numSignatures"),B.u8("padding"),B.u16("signatureOffset"),B.u16("signatureInstructionIndex"),B.u16("publicKeyOffset"),B.u16("publicKeyInstructionIndex"),B.u16("messageDataOffset"),B.u16("messageDataSize"),B.u16("messageInstructionIndex")]);class Ln{constructor(){}static createInstructionWithPublicKey(e){const{publicKey:t,message:r,signature:s,instructionIndex:i}=e;Ie(t.length===_a,`Public Key must be ${_a} bytes but received ${t.length} bytes`),Ie(s.length===wa,`Signature must be ${wa} bytes but received ${s.length} bytes`);const o=ba.span,a=o+t.length,f=a+s.length,g=1,_=fe.Buffer.alloc(f+r.length),b=i??65535;return ba.encode({numSignatures:g,padding:0,signatureOffset:a,signatureInstructionIndex:b,publicKeyOffset:o,publicKeyInstructionIndex:b,messageDataOffset:f,messageDataSize:r.length,messageInstructionIndex:b},_),_.fill(t,o),_.fill(s,a),_.fill(r,f),new Be({keys:[],programId:Ln.programId,data:_})}static createInstructionWithPrivateKey(e){const{privateKey:t,message:r,instructionIndex:s}=e;Ie(t.length===ya,`Private key must be ${ya} bytes but received ${t.length} bytes`);try{const i=Mr.fromSecretKey(t),o=i.publicKey.toBytes(),a=Ei(r,i.secretKey);return this.createInstructionWithPublicKey({publicKey:o,message:r,signature:a,instructionIndex:s})}catch(i){throw new Error(`Error creating instruction; ${i}`)}}}Ln.programId=new ie("Ed25519SigVerify111111111111111111111111111");const Ng=(n,e)=>{const t=En.sign(n,e);return[t.toCompactRawBytes(),t.recovery]};En.utils.isValidPrivateKey;const xg=En.getPublicKey,Ra=32,Hi=20,Ea=64,Bg=11,qi=B.struct([B.u8("numSignatures"),B.u16("signatureOffset"),B.u8("signatureInstructionIndex"),B.u16("ethAddressOffset"),B.u8("ethAddressInstructionIndex"),B.u16("messageDataOffset"),B.u16("messageDataSize"),B.u8("messageInstructionIndex"),B.blob(20,"ethAddress"),B.blob(64,"signature"),B.u8("recoveryId")]);class Pr{constructor(){}static publicKeyToEthAddress(e){Ie(e.length===Ea,`Public key must be ${Ea} bytes but received ${e.length} bytes`);try{return fe.Buffer.from(Mo(_e(e))).slice(-Hi)}catch(t){throw new Error(`Error constructing Ethereum address: ${t}`)}}static createInstructionWithPublicKey(e){const{publicKey:t,message:r,signature:s,recoveryId:i,instructionIndex:o}=e;return Pr.createInstructionWithEthAddress({ethAddress:Pr.publicKeyToEthAddress(t),message:r,signature:s,recoveryId:i,instructionIndex:o})}static createInstructionWithEthAddress(e){const{ethAddress:t,message:r,signature:s,recoveryId:i,instructionIndex:o=0}=e;let a;typeof t=="string"?t.startsWith("0x")?a=fe.Buffer.from(t.substr(2),"hex"):a=fe.Buffer.from(t,"hex"):a=t,Ie(a.length===Hi,`Address must be ${Hi} bytes but received ${a.length} bytes`);const f=1+Bg,g=f,_=f+a.length,b=_+s.length+1,x=1,T=fe.Buffer.alloc(qi.span+r.length);return qi.encode({numSignatures:x,signatureOffset:_,signatureInstructionIndex:o,ethAddressOffset:g,ethAddressInstructionIndex:o,messageDataOffset:b,messageDataSize:r.length,messageInstructionIndex:o,signature:_e(s),ethAddress:_e(a),recoveryId:i},T),T.fill(_e(r),qi.span),new Be({keys:[],programId:Pr.programId,data:T})}static createInstructionWithPrivateKey(e){const{privateKey:t,message:r,instructionIndex:s}=e;Ie(t.length===Ra,`Private key must be ${Ra} bytes but received ${t.length} bytes`);try{const i=_e(t),o=xg(i,!1).slice(1),a=fe.Buffer.from(Mo(_e(r))),[f,g]=Ng(a,i);return this.createInstructionWithPublicKey({publicKey:o,message:r,signature:f,recoveryId:g,instructionIndex:s})}catch(i){throw new Error(`Error creating instruction; ${i}`)}}}Pr.programId=new ie("KeccakSecp256k11111111111111111111111111111");var Sa;const Aa=new ie("StakeConfig11111111111111111111111111111111");class Ia{constructor(e,t){this.staker=void 0,this.withdrawer=void 0,this.staker=e,this.withdrawer=t}}class tn{constructor(e,t,r){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=t,this.custodian=r}}Sa=tn,tn.default=new Sa(0,0,ie.default);class Lg{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const r=B.u32("instruction").decode(e.data);let s;for(const[i,o]of Object.entries(yt))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a StakeInstruction");return s}static decodeInitialize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{authorized:t,lockup:r}=Te(yt.Initialize,e.data);return{stakePubkey:e.keys[0].pubkey,authorized:new Ia(new ie(t.staker),new ie(t.withdrawer)),lockup:new tn(r.unixTimestamp,r.epoch,new ie(r.custodian))}}static decodeDelegate(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,6),Te(yt.Delegate,e.data),{stakePubkey:e.keys[0].pubkey,votePubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[5].pubkey}}static decodeAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{newAuthorized:t,stakeAuthorizationType:r}=Te(yt.Authorize,e.data),s={stakePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey,newAuthorizedPubkey:new ie(t),stakeAuthorizationType:{index:r}};return e.keys.length>3&&(s.custodianPubkey=e.keys[3].pubkey),s}static decodeAuthorizeWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{newAuthorized:t,stakeAuthorizationType:r,authoritySeed:s,authorityOwner:i}=Te(yt.AuthorizeWithSeed,e.data),o={stakePubkey:e.keys[0].pubkey,authorityBase:e.keys[1].pubkey,authoritySeed:s,authorityOwner:new ie(i),newAuthorizedPubkey:new ie(t),stakeAuthorizationType:{index:r}};return e.keys.length>3&&(o.custodianPubkey=e.keys[3].pubkey),o}static decodeSplit(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{lamports:t}=Te(yt.Split,e.data);return{stakePubkey:e.keys[0].pubkey,splitStakePubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[2].pubkey,lamports:t}}static decodeMerge(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),Te(yt.Merge,e.data),{stakePubkey:e.keys[0].pubkey,sourceStakePubKey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey}}static decodeWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,5);const{lamports:t}=Te(yt.Withdraw,e.data),r={stakePubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey,lamports:t};return e.keys.length>5&&(r.custodianPubkey=e.keys[5].pubkey),r}static decodeDeactivate(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),Te(yt.Deactivate,e.data),{stakePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey}}static checkProgramId(e){if(!e.equals(Cn.programId))throw new Error("invalid instruction; programId is not StakeProgram")}static checkKeyLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}const yt=Object.freeze({Initialize:{index:0,layout:B.struct([B.u32("instruction"),z0(),$0()])},Authorize:{index:1,layout:B.struct([B.u32("instruction"),Se("newAuthorized"),B.u32("stakeAuthorizationType")])},Delegate:{index:2,layout:B.struct([B.u32("instruction")])},Split:{index:3,layout:B.struct([B.u32("instruction"),B.ns64("lamports")])},Withdraw:{index:4,layout:B.struct([B.u32("instruction"),B.ns64("lamports")])},Deactivate:{index:5,layout:B.struct([B.u32("instruction")])},Merge:{index:7,layout:B.struct([B.u32("instruction")])},AuthorizeWithSeed:{index:8,layout:B.struct([B.u32("instruction"),Se("newAuthorized"),B.u32("stakeAuthorizationType"),pr("authoritySeed"),Se("authorityOwner")])}}),Cg=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class Cn{constructor(){}static initialize(e){const{stakePubkey:t,authorized:r,lockup:s}=e,i=s||tn.default,o=yt.Initialize,a=Ae(o,{authorized:{staker:_e(r.staker.toBuffer()),withdrawer:_e(r.withdrawer.toBuffer())},lockup:{unixTimestamp:i.unixTimestamp,epoch:i.epoch,custodian:_e(i.custodian.toBuffer())}}),f={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Br,isSigner:!1,isWritable:!1}],programId:this.programId,data:a};return new Be(f)}static createAccountWithSeed(e){const t=new Oe;t.add(mt.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:this.space,programId:this.programId}));const{stakePubkey:r,authorized:s,lockup:i}=e;return t.add(this.initialize({stakePubkey:r,authorized:s,lockup:i}))}static createAccount(e){const t=new Oe;t.add(mt.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,lamports:e.lamports,space:this.space,programId:this.programId}));const{stakePubkey:r,authorized:s,lockup:i}=e;return t.add(this.initialize({stakePubkey:r,authorized:s,lockup:i}))}static delegate(e){const{stakePubkey:t,authorizedPubkey:r,votePubkey:s}=e,i=yt.Delegate,o=Ae(i);return new Oe().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!1},{pubkey:zt,isSigner:!1,isWritable:!1},{pubkey:On,isSigner:!1,isWritable:!1},{pubkey:Aa,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static authorize(e){const{stakePubkey:t,authorizedPubkey:r,newAuthorizedPubkey:s,stakeAuthorizationType:i,custodianPubkey:o}=e,a=yt.Authorize,f=Ae(a,{newAuthorized:_e(s.toBuffer()),stakeAuthorizationType:i.index}),g=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:zt,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return o&&g.push({pubkey:o,isSigner:!0,isWritable:!1}),new Oe().add({keys:g,programId:this.programId,data:f})}static authorizeWithSeed(e){const{stakePubkey:t,authorityBase:r,authoritySeed:s,authorityOwner:i,newAuthorizedPubkey:o,stakeAuthorizationType:a,custodianPubkey:f}=e,g=yt.AuthorizeWithSeed,_=Ae(g,{newAuthorized:_e(o.toBuffer()),stakeAuthorizationType:a.index,authoritySeed:s,authorityOwner:_e(i.toBuffer())}),b=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1},{pubkey:zt,isSigner:!1,isWritable:!1}];return f&&b.push({pubkey:f,isSigner:!0,isWritable:!1}),new Oe().add({keys:b,programId:this.programId,data:_})}static splitInstruction(e){const{stakePubkey:t,authorizedPubkey:r,splitStakePubkey:s,lamports:i}=e,o=yt.Split,a=Ae(o,{lamports:i});return new Be({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static split(e,t){const r=new Oe;return r.add(mt.createAccount({fromPubkey:e.authorizedPubkey,newAccountPubkey:e.splitStakePubkey,lamports:t,space:this.space,programId:this.programId})),r.add(this.splitInstruction(e))}static splitWithSeed(e,t){const{stakePubkey:r,authorizedPubkey:s,splitStakePubkey:i,basePubkey:o,seed:a,lamports:f}=e,g=new Oe;return g.add(mt.allocate({accountPubkey:i,basePubkey:o,seed:a,space:this.space,programId:this.programId})),t&&t>0&&g.add(mt.transfer({fromPubkey:e.authorizedPubkey,toPubkey:i,lamports:t})),g.add(this.splitInstruction({stakePubkey:r,authorizedPubkey:s,splitStakePubkey:i,lamports:f}))}static merge(e){const{stakePubkey:t,sourceStakePubKey:r,authorizedPubkey:s}=e,i=yt.Merge,o=Ae(i);return new Oe().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:zt,isSigner:!1,isWritable:!1},{pubkey:On,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static withdraw(e){const{stakePubkey:t,authorizedPubkey:r,toPubkey:s,lamports:i,custodianPubkey:o}=e,a=yt.Withdraw,f=Ae(a,{lamports:i}),g=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:zt,isSigner:!1,isWritable:!1},{pubkey:On,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return o&&g.push({pubkey:o,isSigner:!0,isWritable:!1}),new Oe().add({keys:g,programId:this.programId,data:f})}static deactivate(e){const{stakePubkey:t,authorizedPubkey:r}=e,s=yt.Deactivate,i=Ae(s);return new Oe().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:zt,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}}Cn.programId=new ie("Stake11111111111111111111111111111111111111"),Cn.space=200;class va{constructor(e,t,r,s){this.nodePubkey=void 0,this.authorizedVoter=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.nodePubkey=e,this.authorizedVoter=t,this.authorizedWithdrawer=r,this.commission=s}}class Mg{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const r=B.u32("instruction").decode(e.data);let s;for(const[i,o]of Object.entries(Kt))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a VoteInstruction");return s}static decodeInitializeAccount(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,4);const{voteInit:t}=Te(Kt.InitializeAccount,e.data);return{votePubkey:e.keys[0].pubkey,nodePubkey:e.keys[3].pubkey,voteInit:new va(new ie(t.nodePubkey),new ie(t.authorizedVoter),new ie(t.authorizedWithdrawer),t.commission)}}static decodeAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{newAuthorized:t,voteAuthorizationType:r}=Te(Kt.Authorize,e.data);return{votePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey,newAuthorizedPubkey:new ie(t),voteAuthorizationType:{index:r}}}static decodeAuthorizeWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:t,currentAuthorityDerivedKeySeed:r,newAuthorized:s,voteAuthorizationType:i}}=Te(Kt.AuthorizeWithSeed,e.data);return{currentAuthorityDerivedKeyBasePubkey:e.keys[2].pubkey,currentAuthorityDerivedKeyOwnerPubkey:new ie(t),currentAuthorityDerivedKeySeed:r,newAuthorizedPubkey:new ie(s),voteAuthorizationType:{index:i},votePubkey:e.keys[0].pubkey}}static decodeWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{lamports:t}=Te(Kt.Withdraw,e.data);return{votePubkey:e.keys[0].pubkey,authorizedWithdrawerPubkey:e.keys[2].pubkey,lamports:t,toPubkey:e.keys[1].pubkey}}static checkProgramId(e){if(!e.equals(Ur.programId))throw new Error("invalid instruction; programId is not VoteProgram")}static checkKeyLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}const Kt=Object.freeze({InitializeAccount:{index:0,layout:B.struct([B.u32("instruction"),K0()])},Authorize:{index:1,layout:B.struct([B.u32("instruction"),Se("newAuthorized"),B.u32("voteAuthorizationType")])},Withdraw:{index:3,layout:B.struct([B.u32("instruction"),B.ns64("lamports")])},UpdateValidatorIdentity:{index:4,layout:B.struct([B.u32("instruction")])},AuthorizeWithSeed:{index:10,layout:B.struct([B.u32("instruction"),W0()])}}),Pg=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class Ur{constructor(){}static initializeAccount(e){const{votePubkey:t,nodePubkey:r,voteInit:s}=e,i=Kt.InitializeAccount,o=Ae(i,{voteInit:{nodePubkey:_e(s.nodePubkey.toBuffer()),authorizedVoter:_e(s.authorizedVoter.toBuffer()),authorizedWithdrawer:_e(s.authorizedWithdrawer.toBuffer()),commission:s.commission}}),a={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Br,isSigner:!1,isWritable:!1},{pubkey:zt,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:o};return new Be(a)}static createAccount(e){const t=new Oe;return t.add(mt.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.votePubkey,lamports:e.lamports,space:this.space,programId:this.programId})),t.add(this.initializeAccount({votePubkey:e.votePubkey,nodePubkey:e.voteInit.nodePubkey,voteInit:e.voteInit}))}static authorize(e){const{votePubkey:t,authorizedPubkey:r,newAuthorizedPubkey:s,voteAuthorizationType:i}=e,o=Kt.Authorize,a=Ae(o,{newAuthorized:_e(s.toBuffer()),voteAuthorizationType:i.index}),f=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:zt,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new Oe().add({keys:f,programId:this.programId,data:a})}static authorizeWithSeed(e){const{currentAuthorityDerivedKeyBasePubkey:t,currentAuthorityDerivedKeyOwnerPubkey:r,currentAuthorityDerivedKeySeed:s,newAuthorizedPubkey:i,voteAuthorizationType:o,votePubkey:a}=e,f=Kt.AuthorizeWithSeed,g=Ae(f,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:_e(r.toBuffer()),currentAuthorityDerivedKeySeed:s,newAuthorized:_e(i.toBuffer()),voteAuthorizationType:o.index}}),_=[{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:zt,isSigner:!1,isWritable:!1},{pubkey:t,isSigner:!0,isWritable:!1}];return new Oe().add({keys:_,programId:this.programId,data:g})}static withdraw(e){const{votePubkey:t,authorizedWithdrawerPubkey:r,lamports:s,toPubkey:i}=e,o=Kt.Withdraw,a=Ae(o,{lamports:s}),f=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return new Oe().add({keys:f,programId:this.programId,data:a})}static safeWithdraw(e,t,r){if(e.lamports>t-r)throw new Error("Withdraw will leave vote account with insufficient funds.");return Ur.withdraw(e)}static updateValidatorIdentity(e){const{votePubkey:t,authorizedWithdrawerPubkey:r,nodePubkey:s}=e,i=Kt.UpdateValidatorIdentity,o=Ae(i),a=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!0,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new Oe().add({keys:a,programId:this.programId,data:o})}}Ur.programId=new ie("Vote111111111111111111111111111111111111111"),Ur.space=3762;const Oa=new ie("Va1idator1nfo111111111111111111111111111111"),Ug=ee({name:re(),website:le(re()),details:le(re()),iconUrl:le(re()),keybaseUsername:le(re())});class Gi{constructor(e,t){this.key=void 0,this.info=void 0,this.key=e,this.info=t}static fromConfigData(e){let t=[...e];if(It(t)!==2)return null;const s=[];for(let i=0;i<2;i++){const o=new ie(vt(t,0,Dt)),a=Ft(t)===1;s.push({publicKey:o,isSigner:a})}if(s[0].publicKey.equals(Oa)&&s[1].isSigner){const i=pr().decode(fe.Buffer.from(t)),o=JSON.parse(i);return yo(o,Ug),new Gi(s[1].publicKey,o)}return null}}const Dg=new ie("Vote111111111111111111111111111111111111111"),Fg=B.struct([Se("nodePubkey"),Se("authorizedWithdrawer"),B.u8("commission"),B.nu64(),B.seq(B.struct([B.nu64("slot"),B.u32("confirmationCount")]),B.offset(B.u32(),-8),"votes"),B.u8("rootSlotValid"),B.nu64("rootSlot"),B.nu64(),B.seq(B.struct([B.nu64("epoch"),Se("authorizedVoter")]),B.offset(B.u32(),-8),"authorizedVoters"),B.struct([B.seq(B.struct([Se("authorizedPubkey"),B.nu64("epochOfLastAuthorizedSwitch"),B.nu64("targetEpoch")]),32,"buf"),B.nu64("idx"),B.u8("isEmpty")],"priorVoters"),B.nu64(),B.seq(B.struct([B.nu64("epoch"),B.nu64("credits"),B.nu64("prevCredits")]),B.offset(B.u32(),-8),"epochCredits"),B.struct([B.nu64("slot"),B.nu64("timestamp")],"lastTimestamp")]);class Vi{constructor(e){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=e.nodePubkey,this.authorizedWithdrawer=e.authorizedWithdrawer,this.commission=e.commission,this.rootSlot=e.rootSlot,this.votes=e.votes,this.authorizedVoters=e.authorizedVoters,this.priorVoters=e.priorVoters,this.epochCredits=e.epochCredits,this.lastTimestamp=e.lastTimestamp}static fromAccountData(e){const r=Fg.decode(_e(e),4);let s=r.rootSlot;return r.rootSlotValid||(s=null),new Vi({nodePubkey:new ie(r.nodePubkey),authorizedWithdrawer:new ie(r.authorizedWithdrawer),commission:r.commission,votes:r.votes,rootSlot:s,authorizedVoters:r.authorizedVoters.map(zg),priorVoters:$g(r.priorVoters),epochCredits:r.epochCredits,lastTimestamp:r.lastTimestamp})}}function zg({authorizedVoter:n,epoch:e}){return{epoch:e,authorizedVoter:new ie(n)}}function ka({authorizedPubkey:n,epochOfLastAuthorizedSwitch:e,targetEpoch:t}){return{authorizedPubkey:new ie(n),epochOfLastAuthorizedSwitch:e,targetEpoch:t}}function $g({buf:n,idx:e,isEmpty:t}){return t?[]:[...n.slice(e+1).map(ka),...n.slice(0,e).map(ka)]}const Ta={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 Kg(n,e){const t=e===!1?"http":"https";if(!n)return Ta[t].devnet;const r=Ta[t][n];if(!r)throw new Error(`Unknown ${t} cluster: ${n}`);return r}async function Wg(n,e,t,r){let s,i;t&&Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")||t&&Object.prototype.hasOwnProperty.call(t,"nonceValue")?(s=t,i=r):i=t;const o=i&&{skipPreflight:i.skipPreflight,preflightCommitment:i.preflightCommitment||i.commitment,minContextSlot:i.minContextSlot},a=await n.sendRawTransaction(e,o),f=i&&i.commitment,_=(await(s?n.confirmTransaction(s,f):n.confirmTransaction(a,f))).value;if(_.err)throw a!=null?new Jr({action:o!=null&&o.skipPreflight?"send":"simulate",signature:a,transactionMessage:`Status: (${JSON.stringify(_)})`}):new Error(`Raw transaction ${a} failed (${JSON.stringify(_)})`);return a}const Mn=Object.freeze(Object.defineProperty({__proto__:null,Account:U0,AddressLookupTableAccount:Li,AddressLookupTableInstruction:kg,AddressLookupTableProgram:Ki,Authorized:Ia,BLOCKHASH_CACHE_TIMEOUT_MS:na,BPF_LOADER_DEPRECATED_PROGRAM_ID:D0,BPF_LOADER_PROGRAM_ID:Q0,BpfLoader:ep,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:$t,ComputeBudgetInstruction:Tg,ComputeBudgetProgram:Wi,Connection:Og,Ed25519Program:Ln,Enum:M0,EpochSchedule:ea,FeeCalculatorLayout:Zo,Keypair:Mr,LAMPORTS_PER_SOL:1e9,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:Xt,Loader:yr,Lockup:tn,MAX_SEED_LENGTH:qo,Message:Lt,MessageAccountKeys:Xr,MessageV0:gr,NONCE_ACCOUNT_LENGTH:Ni,NonceAccount:kn,PACKET_DATA_SIZE:ir,PUBLIC_KEY_LENGTH:Dt,PublicKey:ie,SIGNATURE_LENGTH_IN_BYTES:Zr,SOLANA_SCHEMA:jr,STAKE_CONFIG_ID:Aa,STAKE_INSTRUCTION_LAYOUTS:yt,SYSTEM_INSTRUCTION_LAYOUTS:Pe,SYSVAR_CLOCK_PUBKEY:zt,SYSVAR_EPOCH_SCHEDULE_PUBKEY:q0,SYSVAR_INSTRUCTIONS_PUBKEY:G0,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:vn,SYSVAR_RENT_PUBKEY:Br,SYSVAR_REWARDS_PUBKEY:V0,SYSVAR_SLOT_HASHES_PUBKEY:Y0,SYSVAR_SLOT_HISTORY_PUBKEY:j0,SYSVAR_STAKE_HISTORY_PUBKEY:On,Secp256k1Program:Pr,SendTransactionError:Jr,SolanaJSONRPCError:ue,SolanaJSONRPCErrorCode:Z0,StakeAuthorizationLayout:Cg,StakeInstruction:Lg,StakeProgram:Cn,Struct:Si,SystemInstruction:X0,SystemProgram:mt,Transaction:Oe,TransactionExpiredBlockheightExceededError:Ai,TransactionExpiredNonceInvalidError:xr,TransactionExpiredTimeoutError:Ii,TransactionInstruction:Be,TransactionMessage:Oi,TransactionStatus:Zt,VALIDATOR_INFO_KEY:Oa,VERSION_PREFIX_MASK:An,VOTE_PROGRAM_ID:Dg,ValidatorInfo:Gi,VersionedMessage:vi,VersionedTransaction:ki,VoteAccount:Vi,VoteAuthorizationLayout:Pg,VoteInit:va,VoteInstruction:Mg,VoteProgram:Ur,clusterApiUrl:Kg,sendAndConfirmRawTransaction:Wg,sendAndConfirmTransaction:Ti},Symbol.toStringTag,{value:"Module"})),sr=gt;var Yi={exports:{}},Na;function Hg(){return Na||(Na=1,function(n){var e=function(){var t=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",i={};function o(f,g){if(!i[f]){i[f]={};for(var _=0;_<f.length;_++)i[f][f.charAt(_)]=_}return i[f][g]}var a={compressToBase64:function(f){if(f==null)return"";var g=a._compress(f,6,function(_){return r.charAt(_)});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:a._decompress(f.length,32,function(g){return o(r,f.charAt(g))})},compressToUTF16:function(f){return f==null?"":a._compress(f,15,function(g){return t(g+32)})+" "},decompressFromUTF16:function(f){return f==null?"":f==""?null:a._decompress(f.length,16384,function(g){return f.charCodeAt(g)-32})},compressToUint8Array:function(f){for(var g=a.compress(f),_=new Uint8Array(g.length*2),b=0,x=g.length;b<x;b++){var T=g.charCodeAt(b);_[b*2]=T>>>8,_[b*2+1]=T%256}return _},decompressFromUint8Array:function(f){if(f==null)return a.decompress(f);for(var g=new Array(f.length/2),_=0,b=g.length;_<b;_++)g[_]=f[_*2]*256+f[_*2+1];var x=[];return g.forEach(function(T){x.push(t(T))}),a.decompress(x.join(""))},compressToEncodedURIComponent:function(f){return f==null?"":a._compress(f,6,function(g){return s.charAt(g)})},decompressFromEncodedURIComponent:function(f){return f==null?"":f==""?null:(f=f.replace(/ /g,"+"),a._decompress(f.length,32,function(g){return o(s,f.charAt(g))}))},compress:function(f){return a._compress(f,16,function(g){return t(g)})},_compress:function(f,g,_){if(f==null)return"";var b,x,T={},L={},k="",N="",M="",W=2,$=3,J=2,q=[],D=0,Z=0,j;for(j=0;j<f.length;j+=1)if(k=f.charAt(j),Object.prototype.hasOwnProperty.call(T,k)||(T[k]=$++,L[k]=!0),N=M+k,Object.prototype.hasOwnProperty.call(T,N))M=N;else{if(Object.prototype.hasOwnProperty.call(L,M)){if(M.charCodeAt(0)<256){for(b=0;b<J;b++)D=D<<1,Z==g-1?(Z=0,q.push(_(D)),D=0):Z++;for(x=M.charCodeAt(0),b=0;b<8;b++)D=D<<1|x&1,Z==g-1?(Z=0,q.push(_(D)),D=0):Z++,x=x>>1}else{for(x=1,b=0;b<J;b++)D=D<<1|x,Z==g-1?(Z=0,q.push(_(D)),D=0):Z++,x=0;for(x=M.charCodeAt(0),b=0;b<16;b++)D=D<<1|x&1,Z==g-1?(Z=0,q.push(_(D)),D=0):Z++,x=x>>1}W--,W==0&&(W=Math.pow(2,J),J++),delete L[M]}else for(x=T[M],b=0;b<J;b++)D=D<<1|x&1,Z==g-1?(Z=0,q.push(_(D)),D=0):Z++,x=x>>1;W--,W==0&&(W=Math.pow(2,J),J++),T[N]=$++,M=String(k)}if(M!==""){if(Object.prototype.hasOwnProperty.call(L,M)){if(M.charCodeAt(0)<256){for(b=0;b<J;b++)D=D<<1,Z==g-1?(Z=0,q.push(_(D)),D=0):Z++;for(x=M.charCodeAt(0),b=0;b<8;b++)D=D<<1|x&1,Z==g-1?(Z=0,q.push(_(D)),D=0):Z++,x=x>>1}else{for(x=1,b=0;b<J;b++)D=D<<1|x,Z==g-1?(Z=0,q.push(_(D)),D=0):Z++,x=0;for(x=M.charCodeAt(0),b=0;b<16;b++)D=D<<1|x&1,Z==g-1?(Z=0,q.push(_(D)),D=0):Z++,x=x>>1}W--,W==0&&(W=Math.pow(2,J),J++),delete L[M]}else for(x=T[M],b=0;b<J;b++)D=D<<1|x&1,Z==g-1?(Z=0,q.push(_(D)),D=0):Z++,x=x>>1;W--,W==0&&(W=Math.pow(2,J),J++)}for(x=2,b=0;b<J;b++)D=D<<1|x&1,Z==g-1?(Z=0,q.push(_(D)),D=0):Z++,x=x>>1;for(;;)if(D=D<<1,Z==g-1){q.push(_(D));break}else Z++;return q.join("")},decompress:function(f){return f==null?"":f==""?null:a._decompress(f.length,32768,function(g){return f.charCodeAt(g)})},_decompress:function(f,g,_){var b=[],x=4,T=4,L=3,k="",N=[],M,W,$,J,q,D,Z,j={val:_(0),position:g,index:1};for(M=0;M<3;M+=1)b[M]=M;for($=0,q=Math.pow(2,2),D=1;D!=q;)J=j.val&j.position,j.position>>=1,j.position==0&&(j.position=g,j.val=_(j.index++)),$|=(J>0?1:0)*D,D<<=1;switch($){case 0:for($=0,q=Math.pow(2,8),D=1;D!=q;)J=j.val&j.position,j.position>>=1,j.position==0&&(j.position=g,j.val=_(j.index++)),$|=(J>0?1:0)*D,D<<=1;Z=t($);break;case 1:for($=0,q=Math.pow(2,16),D=1;D!=q;)J=j.val&j.position,j.position>>=1,j.position==0&&(j.position=g,j.val=_(j.index++)),$|=(J>0?1:0)*D,D<<=1;Z=t($);break;case 2:return""}for(b[3]=Z,W=Z,N.push(Z);;){if(j.index>f)return"";for($=0,q=Math.pow(2,L),D=1;D!=q;)J=j.val&j.position,j.position>>=1,j.position==0&&(j.position=g,j.val=_(j.index++)),$|=(J>0?1:0)*D,D<<=1;switch(Z=$){case 0:for($=0,q=Math.pow(2,8),D=1;D!=q;)J=j.val&j.position,j.position>>=1,j.position==0&&(j.position=g,j.val=_(j.index++)),$|=(J>0?1:0)*D,D<<=1;b[T++]=t($),Z=T-1,x--;break;case 1:for($=0,q=Math.pow(2,16),D=1;D!=q;)J=j.val&j.position,j.position>>=1,j.position==0&&(j.position=g,j.val=_(j.index++)),$|=(J>0?1:0)*D,D<<=1;b[T++]=t($),Z=T-1,x--;break;case 2:return N.join("")}if(x==0&&(x=Math.pow(2,L),L++),b[Z])k=b[Z];else if(Z===T)k=W+W.charAt(0);else return null;N.push(k),b[T++]=W+k.charAt(0),x--,W=k,x==0&&(x=Math.pow(2,L),L++)}}};return a}();n!=null?n.exports=e:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return e})}(Yi)),Yi.exports}var qg=Hg();const Wt=zr(qg);var ji=(n=>(n.USD="USD",n.AED="AED",n.AFN="AFN",n.ALL="ALL",n.ANG="ANG",n.AOA="AOA",n.AUD="AUD",n.AWG="AWG",n.AZN="AZN",n.BAM="BAM",n.BBD="BBD",n.BDT="BDT",n.BGN="BGN",n.BHD="BHD",n.BIF="BIF",n.BND="BND",n.BOB="BOB",n.BRL="BRL",n.BTN="BTN",n.BWP="BWP",n.BZD="BZD",n.CAD="CAD",n.CHF="CHF",n.CLP="CLP",n.CNY="CNY",n.COP="COP",n.CRC="CRC",n.CVE="CVE",n.CZK="CZK",n.DJF="DJF",n.DKK="DKK",n.DOP="DOP",n.DZD="DZD",n.EGP="EGP",n.ETB="ETB",n.EUR="EUR",n.GBP="GBP",n.GEL="GEL",n.GHS="GHS",n.GMD="GMD",n.GNF="GNF",n.GTQ="GTQ",n.GYD="GYD",n.HKD="HKD",n.HNL="HNL",n.HTG="HTG",n.HUF="HUF",n.IDR="IDR",n.INR="INR",n.IQD="IQD",n.IRR="IRR",n.ISK="ISK",n.JMD="JMD",n.JOD="JOD",n.JPY="JPY",n.KES="KES",n.KGS="KGS",n.KHR="KHR",n.KMF="KMF",n.KRW="KRW",n.KWD="KWD",n.KYD="KYD",n.KZT="KZT",n.LKR="LKR",n.LRD="LRD",n.LSL="LSL",n.LYD="LYD",n.MAD="MAD",n.MDL="MDL",n.MGA="MGA",n.MKD="MKD",n.MMK="MMK",n.MNT="MNT",n.MOP="MOP",n.MRU="MRU",n.MUR="MUR",n.MVR="MVR",n.MXN="MXN",n.MYR="MYR",n.NAD="NAD",n.NGN="NGN",n.NIO="NIO",n.NOK="NOK",n.NPR="NPR",n.NZD="NZD",n.OMR="OMR",n.PAB="PAB",n.PEN="PEN",n.PHP="PHP",n.PKR="PKR",n.PLN="PLN",n.PYG="PYG",n.QAR="QAR",n.RON="RON",n.RSD="RSD",n.RWF="RWF",n.SAR="SAR",n.SCR="SCR",n.SDG="SDG",n.SEK="SEK",n.SGD="SGD",n.SLE="SLE",n.SLL="SLL",n.SOS="SOS",n.STN="STN",n.SVC="SVC",n.SYP="SYP",n.SZL="SZL",n.THB="THB",n.TJS="TJS",n.TMT="TMT",n.TND="TND",n.TRY="TRY",n.TTD="TTD",n.TWD="TWD",n.TZS="TZS",n.UAH="UAH",n.UGX="UGX",n.UYU="UYU",n.UZS="UZS",n.VND="VND",n.XAF="XAF",n.XCD="XCD",n.XOF="XOF",n.XPF="XPF",n.YER="YER",n.ZAR="ZAR",n.ZMW="ZMW",n))(ji||{});const Gg={AED:"784",AFN:"971",ALL:"008",ANG:"532",AOA:"973",AUD:"036",AWG:"533",AZN:"944",BAM:"977",BBD:"052",BDT:"050",BGN:"975",BHD:"048",BIF:"108",BND:"096",BOB:"068",BRL:"986",BTN:"064",BWP:"072",BZD:"084",CAD:"124",CHF:"756",CLP:"152",CNY:"156",COP:"170",CRC:"188",CVE:"132",CZK:"203",DJF:"262",DKK:"208",DOP:"214",DZD:"012",EGP:"818",ETB:"230",EUR:"978",GBP:"826",GEL:"981",GHS:"936",GMD:"270",GNF:"324",GTQ:"320",GYD:"328",HKD:"344",HNL:"340",HTG:"332",HUF:"348",IDR:"360",INR:"356",IQD:"368",IRR:"364",ISK:"352",JMD:"388",JOD:"400",JPY:"392",KES:"404",KGS:"417",KHR:"116",KMF:"174",KRW:"410",KWD:"414",KYD:"136",KZT:"398",LKR:"144",LRD:"430",LSL:"426",LYD:"434",MAD:"504",MDL:"498",MGA:"969",MKD:"807",MMK:"104",MNT:"496",MOP:"446",MRU:"929",MUR:"480",MVR:"462",MXN:"484",MYR:"458",NAD:"516",NGN:"566",NIO:"558",NOK:"578",NPR:"524",NZD:"554",OMR:"512",PAB:"590",PEN:"604",PHP:"608",PKR:"586",PLN:"985",PYG:"600",QAR:"634",RON:"946",RSD:"941",RWF:"646",SAR:"682",SCR:"690",SDG:"938",SEK:"752",SGD:"702",SLE:"925",SLL:"694",SOS:"706",STN:"930",SVC:"222",SYP:"760",SZL:"748",THB:"764",TJS:"972",TMT:"934",TND:"788",TRY:"949",TTD:"780",TWD:"901",TZS:"834",UAH:"980",UGX:"800",USD:"840",UYU:"858",UZS:"860",VND:"704",XAF:"950",XCD:"951",XOF:"952",XPF:"953",YER:"886",ZAR:"710",ZMW:"967"},xa={USD:"USD",EUR:"EUR",GBP:"GBP",BRL:"BRL",CAD:"CAD"};function Vg(n){return n in xa}function Yg(n,e){return n.currency===e}class Ht{constructor(e){Ye(this,"env");Ye(this,"url");this.env=e??"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(e){return fetch(this.url+`/merchant/view/${e}`).then(t=>t.json()).then(t=>{var r;return((r=t.nSureSettings)==null?void 0:r.nSurePartnerId)||t.nSurePartnerId}).catch(t=>{console.error(t)})}static getCoinflowBaseUrl(e){return!e||e==="prod"?"https://coinflow.cash":e==="ngrok"?"https://coinflow.ngrok.app":e==="local"?"http://localhost:3000":`https://${e}.coinflow.cash`}static getCoinflowApiUrl(e){return!e||e==="prod"?"https://api.coinflow.cash":e==="local"?"http://localhost:5000":`https://api-${e}.coinflow.cash`}static getCoinflowUrl({walletPubkey:e,sessionKey:t,route:r,routePrefix:s,env:i,subtotal:o,presentment:a,transaction:f,blockchain:g="solana",webhookInfo:_,email:b,loaderBackground:x,handleHeightChangeId:T,bankAccountLinkRedirect:L,additionalWallets:k,chargebackProtectionData:N,merchantCss:M,color:W,rent:$,lockDefaultToken:J,tokens:q,planCode:D,disableApplePay:Z,disableGooglePay:j,customerInfo:X,settlementType:z,lockAmount:G,nativeSolToConvert:Q,theme:A,usePermit:c,transactionSigner:p,authOnly:m,deviceId:v,jwtToken:S,origins:I,threeDsChallengePreference:C,supportEmail:R,destinationAuthKey:u,allowedPaymentMethods:l}){var P;const w=s?`/${s}/${g}`:`/${g}`,E=new URL(w+r,Ht.getCoinflowBaseUrl(i));if(e&&E.searchParams.append("pubkey",e),t&&E.searchParams.append("sessionKey",t),f&&E.searchParams.append("transaction",f),o&&("cents"in o?(E.searchParams.append("cents",o.cents.toString()),"currency"in o?E.searchParams.append("currency",o.currency.toString()):E.searchParams.append("currency",ji.USD)):(E.searchParams.append("token",o.address.toString()),E.searchParams.append("amount",o.amount.toString()))),a&&E.searchParams.append("presentment",a),_&&E.searchParams.append("webhookInfo",Wt.compressToEncodedURIComponent(JSON.stringify(_))),A&&E.searchParams.append("theme",Wt.compressToEncodedURIComponent(JSON.stringify(A))),X&&E.searchParams.append("customerInfo",Wt.compressToEncodedURIComponent(JSON.stringify(X))),b&&E.searchParams.append("email",b),R&&E.searchParams.append("supportEmail",R),q&&E.searchParams.append("tokens",q.toString()),x&&E.searchParams.append("loaderBackground",x),T&&E.searchParams.append("useHeightChange",T.toString()),L&&E.searchParams.append("bankAccountLinkRedirect",L),k&&E.searchParams.append("additionalWallets",Wt.compressToEncodedURIComponent(JSON.stringify(k))),N&&E.searchParams.append("chargebackProtectionData",Wt.compressToEncodedURIComponent(JSON.stringify(N))),v)E.searchParams.append("deviceId",v);else if(typeof window<"u"){const V=(P=window==null?void 0:window.nSureSDK)==null?void 0:P.getDeviceId();V&&E.searchParams.append("deviceId",V)}return M&&E.searchParams.append("merchantCss",M),W&&E.searchParams.append("color",W),$&&E.searchParams.append("rent",$.lamports.toString()),Q&&E.searchParams.append("nativeSolToConvert",Q.lamports.toString()),J&&E.searchParams.append("lockDefaultToken","true"),D&&E.searchParams.append("planCode",D),Z&&E.searchParams.append("disableApplePay","true"),j&&E.searchParams.append("disableGooglePay","true"),z&&E.searchParams.append("settlementType",z),G&&E.searchParams.append("lockAmount","true"),c===!1&&E.searchParams.append("usePermit","false"),p&&E.searchParams.append("transactionSigner",p),m===!0&&E.searchParams.append("authOnly","true"),S&&E.searchParams.append("jwtToken",S),I&&E.searchParams.append("origins",Wt.compressToEncodedURIComponent(JSON.stringify(I))),l&&E.searchParams.append("allowedPaymentMethods",l.join(",")),C&&E.searchParams.append("threeDsChallengePreference",C),u&&E.searchParams.append("destinationAuthKey",u),E.toString()}static getTransaction(e){if(e.blockchain)return this.byBlockchain(e.blockchain,{solana:()=>{if(!("transaction"in e))return;const{transaction:t}=e;if(!Mn)throw new Error("@solana/web3.js dependency is required for Solana");if(!sr)throw new Error("bs58 dependency is required for Solana");if(t)return sr.encode(t.serialize({requireAllSignatures:!1,verifySignatures:!1}))},polygon:()=>{if(!("transaction"in e))return;const{transaction:t}=e;return Wt.compressToEncodedURIComponent(JSON.stringify(t))},eth:()=>{if(!("transaction"in e))return;const{transaction:t}=e;return Wt.compressToEncodedURIComponent(JSON.stringify(t))},base:()=>{if(!("transaction"in e))return;const{transaction:t}=e;return Wt.compressToEncodedURIComponent(JSON.stringify(t))},arbitrum:()=>{if(!("transaction"in e))return;const{transaction:t}=e;return Wt.compressToEncodedURIComponent(JSON.stringify(t))},user:()=>{}})()}static byBlockchain(e,t){switch(e){case"solana":return t.solana;case"polygon":return t.polygon;case"eth":return t.eth;case"base":return t.base;case"arbitrum":return t.arbitrum;case"user":return t.user;default:throw new Error("blockchain not supported!")}}}function jg(n){if(!n)return;let e,t;if("name"in n&&n.name&&(e=n.name.split(" ")[0],t=n.name.split(" ").slice(1).join(" ")),"firstName"in n&&n.firstName&&(e=n.firstName),"lastName"in n&&n.lastName&&(t=n.lastName),e&&t)return{firstName:e,lastName:t}}var Zi=(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))(Zi||{});function Pn(n){let e;if("signer"in n&&typeof n.signer=="object"&&n.signer&&"wallet"in n.signer?e=n.signer.wallet:"wallet"in n&&n.wallet&&(e=n.wallet),!!e){if(typeof e=="string")return e;if(typeof e=="object"){if("publicKey"in e)return e.publicKey?e.publicKey.toString():void 0;if("address"in e)return e.address?e.address:void 0}return null}}function Ba(n,e,t){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 e.handleSignMessage?e.handleSignMessage(s):void 0;case"signTransaction":return e.handleSignTransaction?e.handleSignTransaction(s):void 0;case"sendTransaction":return e.handleSendTransaction(s);case"heightChange:"+t:return e.handleHeightChange?e.handleHeightChange(s):void 0;case"success":if(!e.onSuccess)return;e.onSuccess(r.info);return;case"authDeclined":if(!e.onAuthDeclined)return;e.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(Zi)}`)}function Un(n){let e,t;return"signer"in n&&typeof n.signer=="object"&&n.signer&&"blockchain"in n.signer&&"wallet"in n.signer?(e=n.signer.blockchain,t=n.signer.wallet):"blockchain"in n&&n.blockchain&&(e=n.blockchain,t=n.wallet),e?Ht.byBlockchain(e,{solana:()=>Zg({wallet:t,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),eth:()=>Dn({wallet:t,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),polygon:()=>Dn({wallet:t,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),base:()=>Dn({wallet:t,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),arbitrum:()=>Dn({wallet:t,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),user:()=>Xg(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 Zg({wallet:n,onSuccess:e,onAuthDeclined:t}){return{handleSendTransaction:async r=>{const s=La(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(!sr)throw new Error("bs58 dependency is required");return sr.encode(i)},handleSignTransaction:async r=>{const s=n.signTransaction;if(!s)throw new Error("signTransaction is not supported by this wallet");const i=La(r),o=await s(i);if(!sr)throw new Error("bs58 dependency is required");return sr.encode(o.serialize({requireAllSignatures:!1,verifySignatures:!1}))},onSuccess:e,onAuthDeclined:t}}function La(n){if(!Mn)throw new Error("@solana/web3.js is not defined. Please install @solana/web3.js into your project");if(!sr)throw new Error("bs58 is not defined. Please install bs58 into your project");const e=sr.decode(n),t=Mn.VersionedTransaction.deserialize(e);return t.version==="legacy"?Mn.Transaction.from(e):t}function Dn({wallet:n,onSuccess:e,onAuthDeclined:t}){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:e,onAuthDeclined:t}}function Xg({onSuccess:n,onAuthDeclined:e}){return{handleSendTransaction:async()=>Promise.resolve(""),onSuccess:n,onAuthDeclined:e}}const rn="tokenExCardNumber",Dr="tokenExCardCvv",Ca={[br.VISA]:"visa",[br.MASTERCARD]:"masterCard",[br.AMEX]:"americanExpress",[br.DISCOVER]:"discover"};async function Ma(n){const{token:e,origins:t,env:r}=n;return new Promise((s,i)=>{fetch(new Ht(r).url+"/api/checkout/v2/authentication-key",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({origins:t,token:e,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 Xi({env:n,setTokenExScriptLoaded:e}){const t="tokenex-script";document.head.querySelector(`#${t}`)&&e(!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=t,document.head.appendChild(r),document.getElementById(t).addEventListener("load",()=>{console.log("Setting tokenExScriptLoaded to true!"),e(!0)})}function Jg({iframe:n,setCachedToken:e,setLoaded:t}){const r=async()=>(n.tokenize(),await new Promise((s,i)=>{n.on("tokenize",o=>{e(o.token),s(o)}),n.on("validate",o=>{(!o.isValid||o.isCvvValid===!1)&&i(o)})}));return n.on("change",()=>e(void 0)),n.on("cvvChange",()=>e(void 0)),n.on("load",()=>{setTimeout(()=>t(!0),350);const s=document.querySelector("#tx_iframe_tokenExCardNumber");s&&(s.scrolling="no")}),n.on("focus",()=>{n.focus()}),n.on("cvvFocus",()=>{n.cvvFocus()}),t(!1),n.load(),{...n,tokenize:r}}async function Pa(n){const{token:e,cardType:t}=n;return await Ji(Dr,n,{cvvOnly:!0,cvv:!0,cvvContainerID:Dr,placeholder:"CVV",token:e,cardType:Ca[t]})}async function Ua(n){return await Ji(rn,n,{cvv:!0,cvvContainerID:Dr,cvvPlaceholder:"CVV"})}async function Da(n){return await Ji(rn,n,{cvv:!1})}async function Ji(n,e,t){const{tokenExScriptLoaded:r,css:s,debug:i,font:o,setCachedToken:a,setLoaded:f}=e;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 Ma({...e,token:t.token}),{styles:_}=Qg(s),b={...g,placeholder:"0000 0000 0000 0000",enablePrettyFormat:!0,styles:_,font:o,debug:i??!1,...t},x=TokenEx.Iframe(n,b);return Jg({iframe:x,setCachedToken:a,setLoaded:f})}function Qg(n){var r,s,i;const e=JSON.parse(n);return{styles:{base:Jt(e.base),focus:Jt(e.focus),error:Jt(e.error),placeholder:Jt(e.placeholder),cvv:{base:Jt((r=e.cvv)==null?void 0:r.base),focus:Jt((s=e.cvv)==null?void 0:s.focus),error:Jt((i=e.cvv)==null?void 0:i.error),placeholder:Jt(e==null?void 0:e.placeholder)}}}}const em=new Set(["animationIterationCount","aspectRatio","borderImageOutset","borderImageSlice","borderImageWidth","boxFlex","boxFlexGroup","boxOrdinalGroup","columnCount","columns","flex","flexGrow","flexPositive","flexShrink","flexNegative","flexOrder","gridArea","gridRow","gridRowEnd","gridRowSpan","gridRowStart","gridColumn","gridColumnEnd","gridColumnSpan","gridColumnStart","fontWeight","lineClamp","lineHeight","opacity","order","orphans","scale","rotate","rotateX","rotateY","rotateZ","scaleX","scaleY","scaleZ","skew","skewX","skewY","tabSize","widows","zIndex","zoom","fillOpacity","floodOpacity","stopOpacity","strokeDasharray","strokeDashoffset","strokeMiterlimit","strokeOpacity","strokeWidth"]),tm=/^(Webkit|Moz|ms|O)/,rm=/[A-Z]/g;function Jt(n){if(!n||Object.keys(n).length===0)return"";const e=[];for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)){const r=n[t];if(r==null||r==="")continue;let s=t;s.startsWith("--")||(s=s.replace(rm,o=>`-${o.toLowerCase()}`),tm.test(t)&&(s=`-${s}`));let i;typeof r=="number"?em.has(t)?i=String(r):i=r===0?"0":`${r}px`:i=String(r),e.push(`${s}: ${i}`)}return e.length===0?"":e.join("; ")+";"}he.nftCartItem=void 0,(n=>{(e=>{e.NFT="nft"})(n.itemClass||(n.itemClass={})),(e=>{e.IN_GAME_PRODUCT="inGameProduct",e.GAME_OF_SKILL="gameOfSkill",e.DATA_STORAGE="dataStorage",e.COMPUTING_RESOURCES="computingResources",e.SPORTS_TICKET="sportsTicket",e.E_SPORTS_TICKET="eSportsTicket",e.MUSIC_TICKET="musicTicket",e.CONFERENCE_TICKET="conferenceTicket",e.VIRTUAL_SPORTS_TICKET="virtualSportsTicket",e.VIRTUAL_ESPORTS_TICKET="virtualESportsTicket",e.VIRTUAL_MUSIC_TICKET="virtualMusicTicket",e.VIRTUAL_CONFERENCE_TICKET="virtualConferenceTicket",e.ALCOHOL="alcohol",e.DLC="DLC",e.SUBSCRIPTION="subscription",e.FUND_ACAUSE="fundACause",e.REAL_ESTATE="realEstate",e.COMPUTING_CONTRACT="computingContract",e.DIGITAL_ART="digitalArt",e.TOP_UP="topUp",e.OWNERSHIP_CONTRACT="ownershipContract",e.IN_GAME_CURRENCY="inGameCurrency",e.MONEY_TOP_UP_CART_ITEM="moneyTopUpCartItem"})(n.productType||(n.productType={}))})(he.nftCartItem||(he.nftCartItem={}));const nm=te.defineComponent({name:"CoinflowIFrame",props:{args:{type:Object,required:!0}},computed:{url(){return Ht.getCoinflowUrl(this.args)}},emits:{onMessage(n){return!0}},methods:{sendMessage(n){const e=this.$refs.iframeRef;if(!(e!=null&&e.contentWindow))throw new Error("Iframe not defined");e.contentWindow.postMessage(n,"*")},handleIframeMessages({data:n,origin:e}){if(!e.includes(Ht.getCoinflowBaseUrl(this.args.env)))return;this.$emit("onMessage",{data:n,origin:e});const t=Ba(n,this.args,this.args.handleHeightChangeId);t&&t.then(this.sendMessage).catch(r=>{console.error(r),this.sendMessage("ERROR "+r.message)})},async listenForMessage(n){let e;return new Promise((t,r)=>{if(e=({data:s,origin:i})=>{if(i.includes(Ht.getCoinflowBaseUrl(this.args.env))){if(s.startsWith("ERROR")){r(new Error(s.replace("ERROR","")));return}n(s)&&t(s)}},!window)throw new Error("Window not defined");window.addEventListener("message",e)}).finally(()=>{window.removeEventListener("message",e)})},async sendAndReceiveMessage(n,e){return this.sendMessage(n),this.listenForMessage(e)}},mounted(){if(!window)throw new Error("Window not defined");return window.addEventListener("message",this.handleIframeMessages),()=>{window.removeEventListener("message",this.handleIframeMessages)}}}),Qi=(n,e)=>{const t=n.__vccOpts||n;for(const[r,s]of e)t[r]=s;return t},im=["src","scrolling"];function sm(n,e,t,r,s,i){return te.openBlock(),te.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:e[0]||(e[0]=()=>{const o=n.$refs.iframeRef;o&&(o.style.opacity="1")})},null,40,im)}const Fn=Qi(nm,[["render",sm]]),om=te.defineComponent({name:"CoinflowWithdraw",components:{CoinflowIFrame:Fn},props:{args:{type:Object,required:!0}},computed:{handleHeightChangeId(){return Math.random().toString(16).substring(2)},iframeProps(){const n=Pn(this.args);return{...this.args,walletPubkey:n,route:`/withdraw/${this.args.merchantId}`,transaction:void 0}},messageHandlers(){return{...Un(this.args),handleHeightChange:this.args.handleHeightChange}}}});function am(n,e,t,r,s,i){const o=te.resolveComponent("coinflow-i-frame");return te.openBlock(),te.createBlock(o,{args:{...n.iframeProps,...n.messageHandlers,handleHeightChangeId:n.handleHeightChangeId}},null,8,["args"])}const cm=Qi(om,[["render",am]]),um=te.defineComponent({name:"CoinflowPurchase",components:{CoinflowIFrame:Fn},props:{args:{type:Object,required:!0}},computed:{handleHeightChangeId(){return Math.random().toString(16).substring(2)},iframeProps(){const n=Pn(this.args);return{...this.args,walletPubkey:n,route:`/purchase-v2/${this.args.merchantId}`,transaction:Ht.getTransaction(this.args)}},messageHandlers(){return{...Un(this.args),handleHeightChange:this.args.handleHeightChange}}}});function lm(n,e,t,r,s,i){const o=te.resolveComponent("coinflow-i-frame");return te.openBlock(),te.createBlock(o,{args:{...n.iframeProps,...n.messageHandlers,handleHeightChangeId:n.handleHeightChangeId}},null,8,["args"])}const hm=Qi(um,[["render",lm]]),es=n=>{const e=te.ref(!1),t=te.ref(!1),r=te.ref(void 0),s=te.ref(void 0);te.onMounted(()=>{Xi({env:n.env,setTokenExScriptLoaded:()=>{console.log("tokenExScriptLoaded.value = true"),t.value=!0}})});const i=b=>s.value=b,o=()=>e.value=!0,a=b=>r.value=b,f=async b=>{const x=await Pa({...n,...b,tokenExScriptLoaded:t.value,setCachedToken:i,setLoaded:o});return a(x),x},g=async b=>{const x=await Ua({...n,...b,tokenExScriptLoaded:t.value,setCachedToken:i,setLoaded:o});return a(x),x},_=async b=>{const x=await Da({...n,...b,tokenExScriptLoaded:t.value,setCachedToken:i,setLoaded:o});return a(x),x};return te.watchEffect(b=>{r.value&&(r.value.load(),b(()=>{var x;return(x=r.value)==null?void 0:x.remove()}))}),{tokenExIframe:r,initializeTokenExIframe:g,initializeCvvOnlyTokenExIframe:f,initializeTokenExCardOnlyIframe:_,loaded:e,cachedToken:s,setTokenExScriptTag:Xi,tokenExScriptLoaded:t}},fm=["id"],dm=te.defineComponent({__name:"CoinflowCardNumberInput",props:{args:{type:Object,required:!0}},setup(n,{expose:e}){const{initializeTokenExIframe:t,tokenExIframe:r}=es(n.args);async function s(){if(!r.value)throw new Error("Unable to get token");return r.value.tokenize()}e({getToken:s});function i(){return JSON.stringify(n.args.css)}return te.watchEffect(()=>{t({css:i(),debug:n.args.debug,origins:n.args.origins,font:n.args.font})},{}),(o,a)=>(te.openBlock(),te.createElementBlock("div",{id:te.unref(rn)},null,8,fm))}}),pm=["id"],gm=te.defineComponent({__name:"CoinflowCvvInput",setup(n){return(e,t)=>(te.openBlock(),te.createElementBlock("div",{id:te.unref(Dr)},null,8,pm))}}),mm=["id"],ym=te.defineComponent({__name:"CoinflowCvvOnlyInput",props:{args:{type:Object,required:!0}},setup(n,{expose:e}){const{initializeCvvOnlyTokenExIframe:t,tokenExIframe:r}=es(n.args);async function s(){if(!r.value)throw new Error("Unable to get token");return r.value.tokenize()}e({getToken:s});function i(){return JSON.stringify(n.args.css)}return te.watchEffect(()=>{t({...n.args,origins:n.args.origins??[],css:i(),font:n.args.font})},{}),(o,a)=>(te.openBlock(),te.createElementBlock("div",{id:te.unref(Dr)},null,8,mm))}}),_m=te.defineComponent({__name:"CoinflowPurchaseProtection",props:{args:{type:Object,required:!0}},setup(n){const e=te.ref(void 0);te.onMounted(()=>new Ht(n.args.env).getNSurePartnerId(n.args.merchantId).then(s=>e.value=s));function t(){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 te.watchEffect(s=>{if(!e.value)return;const i=document.createElement("script");i.src=r(),document.head.appendChild(i);const o=`window.nSureAsyncInit = function(deviceId) {
16
+ `+i+o;break;default:a=`Unknown action '${(f=>f)(e)}'`}super(a),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=t,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 e=this.transactionLogs;if(!(e!=null&&typeof e=="object"&&"then"in e))return e}async getLogs(e){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((t,r)=>{e.getTransaction(this.signature).then(s=>{if(s&&s.meta&&s.meta.logMessages){const i=s.meta.logMessages;this.transactionLogs=i,t(i)}else r(new Error("Log messages not found"))}).catch(r)})),await this.transactionLogs}}const Z0={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 ue extends Error{constructor({code:e,message:t,data:r},s){super(s!=null?`${s}: ${t}`:t),this.code=void 0,this.data=void 0,this.code=e,this.data=r,this.name="SolanaJSONRPCError"}}async function Ti(n,e,t,r){const s=r&&{skipPreflight:r.skipPreflight,preflightCommitment:r.preflightCommitment||r.commitment,maxRetries:r.maxRetries,minContextSlot:r.minContextSlot},i=await n.sendTransaction(e,t,s);let o;if(e.recentBlockhash!=null&&e.lastValidBlockHeight!=null)o=(await n.confirmTransaction({abortSignal:r==null?void 0:r.abortSignal,signature:i,blockhash:e.recentBlockhash,lastValidBlockHeight:e.lastValidBlockHeight},r&&r.commitment)).value;else if(e.minNonceContextSlot!=null&&e.nonceInfo!=null){const{nonceInstruction:a}=e.nonceInfo,f=a.keys[0].pubkey;o=(await n.confirmTransaction({abortSignal:r==null?void 0:r.abortSignal,minContextSlot:e.minNonceContextSlot,nonceAccountPubkey:f,nonceValue:e.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 Jr({action:"send",signature:i,transactionMessage:`Status: (${JSON.stringify(o)})`}):new Error(`Transaction ${i} failed (${JSON.stringify(o)})`);return i}function mr(n){return new Promise(e=>setTimeout(e,n))}function Ae(n,e){const t=n.layout.span>=0?n.layout.span:Go(n,e),r=he.Buffer.alloc(t),s=Object.assign({instruction:n.index},e);return n.layout.encode(s,r),r}function Te(n,e){let t;try{t=n.layout.decode(e)}catch(r){throw new Error("invalid instruction; "+r)}if(t.instruction!==n.index)throw new Error(`invalid instruction; instruction index mismatch ${t.instruction} != ${n.index}`);return t}const Zo=B.nu64("lamportsPerSignature"),Xo=B.struct([B.u32("version"),B.u32("state"),Se("authorizedPubkey"),Se("nonce"),B.struct([Zo],"feeCalculator")]),Ni=Xo.span;class kn{constructor(e){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=e.authorizedPubkey,this.nonce=e.nonce,this.feeCalculator=e.feeCalculator}static fromAccountData(e){const t=Xo.decode(_e(e),0);return new kn({authorizedPubkey:new ie(t.authorizedPubkey),nonce:new ie(t.nonce).toString(),feeCalculator:t.feeCalculator})}}function Lr(n){const e=B.blob(8,n),t=e.decode.bind(e),r=e.encode.bind(e),s=e,i=Ld();return s.decode=(o,a)=>{const f=t(o,a);return i.decode(f)},s.encode=(o,a,f)=>{const g=i.encode(o);return r(g,a,f)},s}class X0{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const r=B.u32("instruction").decode(e.data);let s;for(const[i,o]of Object.entries(Pe))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a SystemInstruction");return s}static decodeCreateAccount(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{lamports:t,space:r,programId:s}=Te(Pe.Create,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,lamports:t,space:r,programId:new ie(s)}}static decodeTransfer(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{lamports:t}=Te(Pe.Transfer,e.data);return{fromPubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,lamports:t}}static decodeTransferWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{lamports:t,seed:r,programId:s}=Te(Pe.TransferWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,basePubkey:e.keys[1].pubkey,toPubkey:e.keys[2].pubkey,lamports:t,seed:r,programId:new ie(s)}}static decodeAllocate(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{space:t}=Te(Pe.Allocate,e.data);return{accountPubkey:e.keys[0].pubkey,space:t}}static decodeAllocateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{base:t,seed:r,space:s,programId:i}=Te(Pe.AllocateWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new ie(t),seed:r,space:s,programId:new ie(i)}}static decodeAssign(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{programId:t}=Te(Pe.Assign,e.data);return{accountPubkey:e.keys[0].pubkey,programId:new ie(t)}}static decodeAssignWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{base:t,seed:r,programId:s}=Te(Pe.AssignWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new ie(t),seed:r,programId:new ie(s)}}static decodeCreateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{base:t,seed:r,lamports:s,space:i,programId:o}=Te(Pe.CreateWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,basePubkey:new ie(t),seed:r,lamports:s,space:i,programId:new ie(o)}}static decodeNonceInitialize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{authorized:t}=Te(Pe.InitializeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:new ie(t)}}static decodeNonceAdvance(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),Te(Pe.AdvanceNonceAccount,e.data),{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey}}static decodeNonceWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,5);const{lamports:t}=Te(Pe.WithdrawNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey,lamports:t}}static decodeNonceAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{authorized:t}=Te(Pe.AuthorizeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[1].pubkey,newAuthorizedPubkey:new ie(t)}}static checkProgramId(e){if(!e.equals(mt.programId))throw new Error("invalid instruction; programId is not SystemProgram")}static checkKeyLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}const Pe=Object.freeze({Create:{index:0,layout:B.struct([B.u32("instruction"),B.ns64("lamports"),B.ns64("space"),Se("programId")])},Assign:{index:1,layout:B.struct([B.u32("instruction"),Se("programId")])},Transfer:{index:2,layout:B.struct([B.u32("instruction"),Lr("lamports")])},CreateWithSeed:{index:3,layout:B.struct([B.u32("instruction"),Se("base"),pr("seed"),B.ns64("lamports"),B.ns64("space"),Se("programId")])},AdvanceNonceAccount:{index:4,layout:B.struct([B.u32("instruction")])},WithdrawNonceAccount:{index:5,layout:B.struct([B.u32("instruction"),B.ns64("lamports")])},InitializeNonceAccount:{index:6,layout:B.struct([B.u32("instruction"),Se("authorized")])},AuthorizeNonceAccount:{index:7,layout:B.struct([B.u32("instruction"),Se("authorized")])},Allocate:{index:8,layout:B.struct([B.u32("instruction"),B.ns64("space")])},AllocateWithSeed:{index:9,layout:B.struct([B.u32("instruction"),Se("base"),pr("seed"),B.ns64("space"),Se("programId")])},AssignWithSeed:{index:10,layout:B.struct([B.u32("instruction"),Se("base"),pr("seed"),Se("programId")])},TransferWithSeed:{index:11,layout:B.struct([B.u32("instruction"),Lr("lamports"),pr("seed"),Se("programId")])},UpgradeNonceAccount:{index:12,layout:B.struct([B.u32("instruction")])}});class mt{constructor(){}static createAccount(e){const t=Pe.Create,r=Ae(t,{lamports:e.lamports,space:e.space,programId:_e(e.programId.toBuffer())});return new Be({keys:[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:r})}static transfer(e){let t,r;if("basePubkey"in e){const s=Pe.TransferWithSeed;t=Ae(s,{lamports:BigInt(e.lamports),seed:e.seed,programId:_e(e.programId.toBuffer())}),r=[{pubkey:e.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}else{const s=Pe.Transfer;t=Ae(s,{lamports:BigInt(e.lamports)}),r=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}return new Be({keys:r,programId:this.programId,data:t})}static assign(e){let t,r;if("basePubkey"in e){const s=Pe.AssignWithSeed;t=Ae(s,{base:_e(e.basePubkey.toBuffer()),seed:e.seed,programId:_e(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{const s=Pe.Assign;t=Ae(s,{programId:_e(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new Be({keys:r,programId:this.programId,data:t})}static createAccountWithSeed(e){const t=Pe.CreateWithSeed,r=Ae(t,{base:_e(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:_e(e.programId.toBuffer())});let s=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!1,isWritable:!0}];return e.basePubkey.equals(e.fromPubkey)||s.push({pubkey:e.basePubkey,isSigner:!0,isWritable:!1}),new Be({keys:s,programId:this.programId,data:r})}static createNonceAccount(e){const t=new Oe;"basePubkey"in e&&"seed"in e?t.add(mt.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:Ni,programId:this.programId})):t.add(mt.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,lamports:e.lamports,space:Ni,programId:this.programId}));const r={noncePubkey:e.noncePubkey,authorizedPubkey:e.authorizedPubkey};return t.add(this.nonceInitialize(r)),t}static nonceInitialize(e){const t=Pe.InitializeNonceAccount,r=Ae(t,{authorized:_e(e.authorizedPubkey.toBuffer())}),s={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:vn,isSigner:!1,isWritable:!1},{pubkey:Br,isSigner:!1,isWritable:!1}],programId:this.programId,data:r};return new Be(s)}static nonceAdvance(e){const t=Pe.AdvanceNonceAccount,r=Ae(t),s={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:vn,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r};return new Be(s)}static nonceWithdraw(e){const t=Pe.WithdrawNonceAccount,r=Ae(t,{lamports:e.lamports});return new Be({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0},{pubkey:vn,isSigner:!1,isWritable:!1},{pubkey:Br,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}static nonceAuthorize(e){const t=Pe.AuthorizeNonceAccount,r=Ae(t,{authorized:_e(e.newAuthorizedPubkey.toBuffer())});return new Be({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}static allocate(e){let t,r;if("basePubkey"in e){const s=Pe.AllocateWithSeed;t=Ae(s,{base:_e(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:_e(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{const s=Pe.Allocate;t=Ae(s,{space:e.space}),r=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new Be({keys:r,programId:this.programId,data:t})}}mt.programId=new ie("11111111111111111111111111111111");const J0=nr-300;class yr{constructor(){}static getMinNumSignatures(e){return 2*(Math.ceil(e/yr.chunkSize)+1+1)}static async load(e,t,r,s,i){{const b=await e.getMinimumBalanceForRentExemption(i.length),x=await e.getAccountInfo(r.publicKey,"confirmed");let T=null;if(x!==null){if(x.executable)return console.error("Program load failed, account is already executable"),!1;x.data.length!==i.length&&(T=T||new Oe,T.add(mt.allocate({accountPubkey:r.publicKey,space:i.length}))),x.owner.equals(s)||(T=T||new Oe,T.add(mt.assign({accountPubkey:r.publicKey,programId:s}))),x.lamports<b&&(T=T||new Oe,T.add(mt.transfer({fromPubkey:t.publicKey,toPubkey:r.publicKey,lamports:b-x.lamports})))}else T=new Oe().add(mt.createAccount({fromPubkey:t.publicKey,newAccountPubkey:r.publicKey,lamports:b>0?b:1,space:i.length,programId:s}));T!==null&&await Ti(e,T,[t,r],{commitment:"confirmed"})}const o=B.struct([B.u32("instruction"),B.u32("offset"),B.u32("bytesLength"),B.u32("bytesLengthPadding"),B.seq(B.u8("byte"),B.offset(B.u32(),-8),"bytes")]),a=yr.chunkSize;let f=0,g=i,_=[];for(;g.length>0;){const b=g.slice(0,a),x=he.Buffer.alloc(a+16);o.encode({instruction:0,offset:f,bytes:b,bytesLength:0,bytesLengthPadding:0},x);const T=new Oe().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0}],programId:s,data:x});_.push(Ti(e,T,[t,r],{commitment:"confirmed"})),e._rpcEndpoint.includes("solana.com")&&await mr(1e3/4),f+=a,g=g.slice(a)}await Promise.all(_);{const b=B.struct([B.u32("instruction")]),x=he.Buffer.alloc(b.span);b.encode({instruction:1},x);const T=new Oe().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0},{pubkey:Br,isSigner:!1,isWritable:!1}],programId:s,data:x}),L="processed",k=await e.sendTransaction(T,[t,r],{preflightCommitment:L}),{context:N,value:M}=await e.confirmTransaction({signature:k,lastValidBlockHeight:T.lastValidBlockHeight,blockhash:T.recentBlockhash},L);if(M.err)throw new Error(`Transaction ${k} failed (${JSON.stringify(M)})`);for(;;){try{if(await e.getSlot({commitment:L})>N.slot)break}catch{}await new Promise(H=>setTimeout(H,Math.round(jo/2)))}}return!0}}yr.chunkSize=J0;const Q0=new ie("BPFLoader2111111111111111111111111111111111");class ep{static getMinNumSignatures(e){return yr.getMinNumSignatures(e)}static load(e,t,r,s,i){return yr.load(e,t,r,i,s)}}function tp(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var xi,Jo;function rp(){if(Jo)return xi;Jo=1;var n=Object.prototype.toString,e=Object.keys||function(r){var s=[];for(var i in r)s.push(i);return s};function t(r,s){var i,o,a,f,g,_,b;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 t(r.toJSON(),s);if(b=n.call(r),b==="[object Array]"){for(a="[",o=r.length-1,i=0;i<o;i++)a+=t(r[i],!0)+",";return o>-1&&(a+=t(r[i],!0)),a+"]"}else if(b==="[object Object]"){for(f=e(r).sort(),o=f.length,a="",i=0;i<o;)g=f[i],_=t(r[g],!1),_!==void 0&&(a&&(a+=","),a+=JSON.stringify(g)+":"+_),i++;return"{"+a+"}"}else return JSON.stringify(r);case"function":case"undefined":return s?null:void 0;case"string":return JSON.stringify(r);default:return isFinite(r)?r:null}}return xi=function(r){var s=t(r,!1);if(s!==void 0)return""+s},xi}var np=rp(),Qo=tp(np);const Qr=32;function Bi(n){let e=0;for(;n>1;)n/=2,e++;return e}function ip(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 ea{constructor(e,t,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=e,this.leaderScheduleSlotOffset=t,this.warmup=r,this.firstNormalEpoch=s,this.firstNormalSlot=i}getEpoch(e){return this.getEpochAndSlotIndex(e)[0]}getEpochAndSlotIndex(e){if(e<this.firstNormalSlot){const t=Bi(ip(e+Qr+1))-Bi(Qr)-1,r=this.getSlotsInEpoch(t),s=e-(r-Qr);return[t,s]}else{const t=e-this.firstNormalSlot,r=Math.floor(t/this.slotsPerEpoch),s=this.firstNormalEpoch+r,i=t%this.slotsPerEpoch;return[s,i]}}getFirstSlotInEpoch(e){return e<=this.firstNormalEpoch?(Math.pow(2,e)-1)*Qr:(e-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(e){return this.getFirstSlotInEpoch(e)+this.getSlotsInEpoch(e)-1}getSlotsInEpoch(e){return e<this.firstNormalEpoch?Math.pow(2,e+Bi(Qr)):this.slotsPerEpoch}}var sp=globalThis.fetch;class op extends p0{constructor(e,t,r){const s=i=>{const o=f0(i,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...t});return"socket"in o?this.underlyingSocket=o.socket:this.underlyingSocket=o,o};super(s,e,t,r),this.underlyingSocket=void 0}call(...e){var r;const t=(r=this.underlyingSocket)==null?void 0:r.readyState;return t===1?super.call(...e):Promise.reject(new Error("Tried to call a JSON-RPC method `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}notify(...e){var r;const t=(r=this.underlyingSocket)==null?void 0:r.readyState;return t===1?super.notify(...e):Promise.reject(new Error("Tried to send a JSON-RPC notification `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}}function ap(n,e){let t;try{t=n.layout.decode(e)}catch(r){throw new Error("invalid instruction; "+r)}if(t.typeIndex!==n.index)throw new Error(`invalid account data; account type mismatch ${t.typeIndex} != ${n.index}`);return t}const ta=56;class Li{constructor(e){this.key=void 0,this.state=void 0,this.key=e.key,this.state=e.state}isActive(){const e=BigInt("0xffffffffffffffff");return this.state.deactivationSlot===e}static deserialize(e){const t=ap(cp,e),r=e.length-ta;Ie(r>=0,"lookup table is invalid"),Ie(r%32===0,"lookup table is invalid");const s=r/32,{addresses:i}=B.struct([B.seq(Se(),s,"addresses")]).decode(e.slice(ta));return{deactivationSlot:t.deactivationSlot,lastExtendedSlot:t.lastExtendedSlot,lastExtendedSlotStartIndex:t.lastExtendedStartIndex,authority:t.authority.length!==0?new ie(t.authority[0]):void 0,addresses:i.map(o=>new ie(o))}}}const cp={index:1,layout:B.struct([B.u32("typeIndex"),Lr("deactivationSlot"),B.nu64("lastExtendedSlot"),B.u8("lastExtendedStartIndex"),B.u8(),B.seq(Se(),B.offset(B.u8(),-1),"authority")])},up=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function lp(n){const e=n.match(up);if(e==null)throw TypeError(`Failed to validate endpoint URL \`${n}\``);const[t,r,s,i]=e,o=n.startsWith("https:")?"wss:":"ws:",a=s==null?null:parseInt(s.slice(1),10),f=a==null?"":`:${a+1}`;return`${o}//${r}${f}${i}`}const Ve=Gr(ui(ie),re(),n=>new ie(n)),ra=li([re(),qe("base64")]),Ci=Gr(ui(he.Buffer),ra,n=>he.Buffer.from(n[0],"base64")),na=30*1e3;function hp(n){if(/^https?:/.test(n)===!1)throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return n}function Ue(n){let e,t;if(typeof n=="string")e=n;else if(n){const{commitment:r,...s}=n;e=r,t=s}return{commitment:e,config:t}}function ia(n){return n.map(e=>"memcmp"in e?{...e,memcmp:{...e.memcmp,encoding:e.memcmp.encoding??"base58"}}:e)}function sa(n){return At([ee({jsonrpc:qe("2.0"),id:re(),result:n}),ee({jsonrpc:qe("2.0"),id:re(),error:ee({code:Nr(),message:re(),data:le(Fd())})})])}const fp=sa(Nr());function we(n){return Gr(sa(n),fp,e=>"error"in e?e:{...e,result:se(e.result,n)})}function je(n){return we(ee({context:ee({slot:$()}),value:n}))}function Tn(n){return ee({context:ee({slot:$()}),value:n})}function Mi(n,e){return n===0?new gr({header:e.header,staticAccountKeys:e.accountKeys.map(t=>new ie(t)),recentBlockhash:e.recentBlockhash,compiledInstructions:e.instructions.map(t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:gt.decode(t.data)})),addressTableLookups:e.addressTableLookups}):new Lt(e)}const dp=ee({foundation:$(),foundationTerm:$(),initial:$(),taper:$(),terminal:$()}),pp=we(oe(ae(ee({epoch:$(),effectiveSlot:$(),amount:$(),postBalance:$(),commission:le(ae($()))})))),gp=oe(ee({slot:$(),prioritizationFee:$()})),mp=ee({total:$(),validator:$(),foundation:$(),epoch:$()}),yp=ee({epoch:$(),slotIndex:$(),slotsInEpoch:$(),absoluteSlot:$(),blockHeight:le($()),transactionCount:le($())}),_p=ee({slotsPerEpoch:$(),leaderScheduleSlotOffset:$(),warmup:Ut(),firstNormalEpoch:$(),firstNormalSlot:$()}),wp=wo(re(),oe($())),_r=ae(At([ee({}),re()])),bp=ee({err:_r}),Rp=qe("receivedSignature"),Ep=ee({"solana-core":re(),"feature-set":le($())}),Sp=ee({program:re(),programId:Ve,parsed:Nr()}),Ap=ee({programId:Ve,accounts:oe(Ve),data:re()}),oa=je(ee({err:ae(At([ee({}),re()])),logs:ae(oe(re())),accounts:le(ae(oe(ae(ee({executable:Ut(),owner:re(),lamports:$(),data:oe(re()),rentEpoch:le($())}))))),unitsConsumed:le($()),returnData:le(ae(ee({programId:re(),data:li([re(),qe("base64")])}))),innerInstructions:le(ae(oe(ee({index:$(),instructions:oe(At([Sp,Ap]))}))))})),Ip=je(ee({byIdentity:wo(re(),oe($())),range:ee({firstSlot:$(),lastSlot:$()})}));function vp(n,e,t,r,s,i){const o=t||sp;let a;i!=null&&console.warn("You have supplied an `httpAgent` when creating a `Connection` in a browser environment.It has been ignored; `httpAgent` is only used in Node environments.");let f;return r&&(f=async(_,b)=>{const x=await new Promise((T,L)=>{try{r(_,b,(k,N)=>T([k,N]))}catch(k){L(k)}});return await o(...x)}),new c0(async(_,b)=>{const x={method:"POST",body:_,agent:a,headers:Object.assign({"Content-Type":"application/json"},e||{},vg)};try{let T=5,L,k=500;for(;f?L=await f(n,x):L=await o(n,x),!(L.status!==429||s===!0||(T-=1,T===0));)console.error(`Server responded with ${L.status} ${L.statusText}. Retrying after ${k}ms delay...`),await mr(k),k*=2;const N=await L.text();L.ok?b(null,N):b(new Error(`${L.status} ${L.statusText}: ${N}`))}catch(T){T instanceof Error&&b(T)}},{})}function Op(n){return(e,t)=>new Promise((r,s)=>{n.request(e,t,(i,o)=>{if(i){s(i);return}r(o)})})}function kp(n){return e=>new Promise((t,r)=>{e.length===0&&t([]);const s=e.map(i=>n.request(i.methodName,i.args));n.request(s,(i,o)=>{if(i){r(i);return}t(o)})})}const Tp=we(dp),Np=we(mp),xp=we(gp),Bp=we(yp),Lp=we(_p),Cp=we(wp),Mp=we($()),Pp=je(ee({total:$(),circulating:$(),nonCirculating:$(),nonCirculatingAccounts:oe(Ve)})),Pi=ee({amount:re(),uiAmount:ae($()),decimals:$(),uiAmountString:le(re())}),Up=je(oe(ee({address:Ve,amount:re(),uiAmount:ae($()),decimals:$(),uiAmountString:le(re())}))),Dp=je(oe(ee({pubkey:Ve,account:ee({executable:Ut(),owner:Ve,lamports:$(),data:Ci,rentEpoch:$()})}))),Ui=ee({program:re(),parsed:Nr(),space:$()}),Fp=je(oe(ee({pubkey:Ve,account:ee({executable:Ut(),owner:Ve,lamports:$(),data:Ui,rentEpoch:$()})}))),zp=je(oe(ee({lamports:$(),address:Ve}))),en=ee({executable:Ut(),owner:Ve,lamports:$(),data:Ci,rentEpoch:$()}),Kp=ee({pubkey:Ve,account:en}),$p=Gr(At([ui(he.Buffer),Ui]),At([ra,Ui]),n=>Array.isArray(n)?se(n,Ci):n),Di=ee({executable:Ut(),owner:Ve,lamports:$(),data:$p,rentEpoch:$()}),Hp=ee({pubkey:Ve,account:Di}),Wp=ee({state:At([qe("active"),qe("inactive"),qe("activating"),qe("deactivating")]),active:$(),inactive:$()}),qp=we(oe(ee({signature:re(),slot:$(),err:_r,memo:ae(re()),blockTime:le(ae($()))}))),Vp=we(oe(ee({signature:re(),slot:$(),err:_r,memo:ae(re()),blockTime:le(ae($()))}))),Gp=ee({subscription:$(),result:Tn(en)}),Yp=ee({pubkey:Ve,account:en}),jp=ee({subscription:$(),result:Tn(Yp)}),Zp=ee({parent:$(),slot:$(),root:$()}),Xp=ee({subscription:$(),result:Zp}),Jp=At([ee({type:At([qe("firstShredReceived"),qe("completed"),qe("optimisticConfirmation"),qe("root")]),slot:$(),timestamp:$()}),ee({type:qe("createdBank"),parent:$(),slot:$(),timestamp:$()}),ee({type:qe("frozen"),slot:$(),timestamp:$(),stats:ee({numTransactionEntries:$(),numSuccessfulTransactions:$(),numFailedTransactions:$(),maxTransactionsPerEntry:$()})}),ee({type:qe("dead"),slot:$(),timestamp:$(),err:re()})]),Qp=ee({subscription:$(),result:Jp}),eg=ee({subscription:$(),result:Tn(At([bp,Rp]))}),tg=ee({subscription:$(),result:$()}),rg=ee({pubkey:re(),gossip:ae(re()),tpu:ae(re()),rpc:ae(re()),version:ae(re())}),aa=ee({votePubkey:re(),nodePubkey:re(),activatedStake:$(),epochVoteAccount:Ut(),epochCredits:oe(li([$(),$(),$()])),commission:$(),lastVote:$(),rootSlot:ae($())}),ng=we(ee({current:oe(aa),delinquent:oe(aa)})),ig=At([qe("processed"),qe("confirmed"),qe("finalized")]),sg=ee({slot:$(),confirmations:ae($()),err:_r,confirmationStatus:le(ig)}),og=je(oe(ae(sg))),ag=we($()),ca=ee({accountKey:Ve,writableIndexes:oe($()),readonlyIndexes:oe($())}),Fi=ee({signatures:oe(re()),message:ee({accountKeys:oe(re()),header:ee({numRequiredSignatures:$(),numReadonlySignedAccounts:$(),numReadonlyUnsignedAccounts:$()}),instructions:oe(ee({accounts:oe($()),data:re(),programIdIndex:$()})),recentBlockhash:re(),addressTableLookups:le(oe(ca))})}),ua=ee({pubkey:Ve,signer:Ut(),writable:Ut(),source:le(At([qe("transaction"),qe("lookupTable")]))}),la=ee({accountKeys:oe(ua),signatures:oe(re())}),ha=ee({parsed:Nr(),program:re(),programId:Ve}),fa=ee({accounts:oe(Ve),data:re(),programId:Ve}),cg=At([fa,ha]),ug=At([ee({parsed:Nr(),program:re(),programId:re()}),ee({accounts:oe(re()),data:re(),programId:re()})]),da=Gr(cg,ug,n=>"accounts"in n?se(n,fa):se(n,ha)),pa=ee({signatures:oe(re()),message:ee({accountKeys:oe(ua),instructions:oe(da),recentBlockhash:re(),addressTableLookups:le(ae(oe(ca)))})}),Nn=ee({accountIndex:$(),mint:re(),owner:le(re()),programId:le(re()),uiTokenAmount:Pi}),ga=ee({writable:oe(Ve),readonly:oe(Ve)}),xn=ee({err:_r,fee:$(),innerInstructions:le(ae(oe(ee({index:$(),instructions:oe(ee({accounts:oe($()),data:re(),programIdIndex:$()}))})))),preBalances:oe($()),postBalances:oe($()),logMessages:le(ae(oe(re()))),preTokenBalances:le(ae(oe(Nn))),postTokenBalances:le(ae(oe(Nn))),loadedAddresses:le(ga),computeUnitsConsumed:le($())}),zi=ee({err:_r,fee:$(),innerInstructions:le(ae(oe(ee({index:$(),instructions:oe(da)})))),preBalances:oe($()),postBalances:oe($()),logMessages:le(ae(oe(re()))),preTokenBalances:le(ae(oe(Nn))),postTokenBalances:le(ae(oe(Nn))),loadedAddresses:le(ga),computeUnitsConsumed:le($())}),Cr=At([qe(0),qe("legacy")]),wr=ee({pubkey:re(),lamports:$(),postBalance:ae($()),rewardType:ae(re()),commission:le(ae($()))}),lg=we(ae(ee({blockhash:re(),previousBlockhash:re(),parentSlot:$(),transactions:oe(ee({transaction:Fi,meta:ae(xn),version:le(Cr)})),rewards:le(oe(wr)),blockTime:ae($()),blockHeight:ae($())}))),hg=we(ae(ee({blockhash:re(),previousBlockhash:re(),parentSlot:$(),rewards:le(oe(wr)),blockTime:ae($()),blockHeight:ae($())}))),fg=we(ae(ee({blockhash:re(),previousBlockhash:re(),parentSlot:$(),transactions:oe(ee({transaction:la,meta:ae(xn),version:le(Cr)})),rewards:le(oe(wr)),blockTime:ae($()),blockHeight:ae($())}))),dg=we(ae(ee({blockhash:re(),previousBlockhash:re(),parentSlot:$(),transactions:oe(ee({transaction:pa,meta:ae(zi),version:le(Cr)})),rewards:le(oe(wr)),blockTime:ae($()),blockHeight:ae($())}))),pg=we(ae(ee({blockhash:re(),previousBlockhash:re(),parentSlot:$(),transactions:oe(ee({transaction:la,meta:ae(zi),version:le(Cr)})),rewards:le(oe(wr)),blockTime:ae($()),blockHeight:ae($())}))),gg=we(ae(ee({blockhash:re(),previousBlockhash:re(),parentSlot:$(),rewards:le(oe(wr)),blockTime:ae($()),blockHeight:ae($())}))),mg=we(ae(ee({blockhash:re(),previousBlockhash:re(),parentSlot:$(),transactions:oe(ee({transaction:Fi,meta:ae(xn)})),rewards:le(oe(wr)),blockTime:ae($())}))),ma=we(ae(ee({blockhash:re(),previousBlockhash:re(),parentSlot:$(),signatures:oe(re()),blockTime:ae($())}))),Ki=we(ae(ee({slot:$(),meta:ae(xn),blockTime:le(ae($())),transaction:Fi,version:le(Cr)}))),Bn=we(ae(ee({slot:$(),transaction:pa,meta:ae(zi),blockTime:le(ae($())),version:le(Cr)}))),yg=je(ee({blockhash:re(),lastValidBlockHeight:$()})),_g=je(Ut()),wg=ee({slot:$(),numTransactions:$(),numSlots:$(),samplePeriodSecs:$()}),bg=we(oe(wg)),Rg=je(ae(ee({feeCalculator:ee({lamportsPerSignature:$()})}))),Eg=we(re()),Sg=we(re()),Ag=ee({err:_r,logs:oe(re()),signature:re()}),Ig=ee({result:Tn(Ag),subscription:$()}),vg={"solana-client":"js/1.0.0-maintenance"};class Og{constructor(e,t){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 _=>{const{commitment:b,config:x}=Ue(_),T=this._buildArgs([],b,void 0,x),L=Qo(T);return g[L]=g[L]??(async()=>{try{const k=await this._rpcRequest("getBlockHeight",T),N=se(k,we($()));if("error"in N)throw new ue(N.error,"failed to get block height information");return N.result}finally{delete g[L]}})(),await g[L]}})();let r,s,i,o,a,f;t&&typeof t=="string"?this._commitment=t:t&&(this._commitment=t.commitment,this._confirmTransactionInitialTimeout=t.confirmTransactionInitialTimeout,r=t.wsEndpoint,s=t.httpHeaders,i=t.fetch,o=t.fetchMiddleware,a=t.disableRetryOnRateLimit,f=t.httpAgent),this._rpcEndpoint=hp(e),this._rpcWsEndpoint=r||lp(e),this._rpcClient=vp(e,s,i,o,a,f),this._rpcRequest=Op(this._rpcClient),this._rpcBatchRequest=kp(this._rpcClient),this._rpcWebSocket=new op(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(e,t){const{commitment:r,config:s}=Ue(t),i=this._buildArgs([e.toBase58()],r,void 0,s),o=await this._rpcRequest("getBalance",i),a=se(o,je($()));if("error"in a)throw new ue(a.error,`failed to get balance for ${e.toBase58()}`);return a.result}async getBalance(e,t){return await this.getBalanceAndContext(e,t).then(r=>r.value).catch(r=>{throw new Error("failed to get balance of account "+e.toBase58()+": "+r)})}async getBlockTime(e){const t=await this._rpcRequest("getBlockTime",[e]),r=se(t,we(ae($())));if("error"in r)throw new ue(r.error,`failed to get block time for slot ${e}`);return r.result}async getMinimumLedgerSlot(){const e=await this._rpcRequest("minimumLedgerSlot",[]),t=se(e,we($()));if("error"in t)throw new ue(t.error,"failed to get minimum ledger slot");return t.result}async getFirstAvailableBlock(){const e=await this._rpcRequest("getFirstAvailableBlock",[]),t=se(e,Mp);if("error"in t)throw new ue(t.error,"failed to get first available block");return t.result}async getSupply(e){let t={};typeof e=="string"?t={commitment:e}:e?t={...e,commitment:e&&e.commitment||this.commitment}:t={commitment:this.commitment};const r=await this._rpcRequest("getSupply",[t]),s=se(r,Pp);if("error"in s)throw new ue(s.error,"failed to get supply");return s.result}async getTokenSupply(e,t){const r=this._buildArgs([e.toBase58()],t),s=await this._rpcRequest("getTokenSupply",r),i=se(s,je(Pi));if("error"in i)throw new ue(i.error,"failed to get token supply");return i.result}async getTokenAccountBalance(e,t){const r=this._buildArgs([e.toBase58()],t),s=await this._rpcRequest("getTokenAccountBalance",r),i=se(s,je(Pi));if("error"in i)throw new ue(i.error,"failed to get token account balance");return i.result}async getTokenAccountsByOwner(e,t,r){const{commitment:s,config:i}=Ue(r);let o=[e.toBase58()];"mint"in t?o.push({mint:t.mint.toBase58()}):o.push({programId:t.programId.toBase58()});const a=this._buildArgs(o,s,"base64",i),f=await this._rpcRequest("getTokenAccountsByOwner",a),g=se(f,Dp);if("error"in g)throw new ue(g.error,`failed to get token accounts owned by account ${e.toBase58()}`);return g.result}async getParsedTokenAccountsByOwner(e,t,r){let s=[e.toBase58()];"mint"in t?s.push({mint:t.mint.toBase58()}):s.push({programId:t.programId.toBase58()});const i=this._buildArgs(s,r,"jsonParsed"),o=await this._rpcRequest("getTokenAccountsByOwner",i),a=se(o,Fp);if("error"in a)throw new ue(a.error,`failed to get token accounts owned by account ${e.toBase58()}`);return a.result}async getLargestAccounts(e){const t={...e,commitment:e&&e.commitment||this.commitment},r=t.filter||t.commitment?[t]:[],s=await this._rpcRequest("getLargestAccounts",r),i=se(s,zp);if("error"in i)throw new ue(i.error,"failed to get largest accounts");return i.result}async getTokenLargestAccounts(e,t){const r=this._buildArgs([e.toBase58()],t),s=await this._rpcRequest("getTokenLargestAccounts",r),i=se(s,Up);if("error"in i)throw new ue(i.error,"failed to get token largest accounts");return i.result}async getAccountInfoAndContext(e,t){const{commitment:r,config:s}=Ue(t),i=this._buildArgs([e.toBase58()],r,"base64",s),o=await this._rpcRequest("getAccountInfo",i),a=se(o,je(ae(en)));if("error"in a)throw new ue(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getParsedAccountInfo(e,t){const{commitment:r,config:s}=Ue(t),i=this._buildArgs([e.toBase58()],r,"jsonParsed",s),o=await this._rpcRequest("getAccountInfo",i),a=se(o,je(ae(Di)));if("error"in a)throw new ue(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getAccountInfo(e,t){try{return(await this.getAccountInfoAndContext(e,t)).value}catch(r){throw new Error("failed to get info about account "+e.toBase58()+": "+r)}}async getMultipleParsedAccounts(e,t){const{commitment:r,config:s}=Ue(t),i=e.map(g=>g.toBase58()),o=this._buildArgs([i],r,"jsonParsed",s),a=await this._rpcRequest("getMultipleAccounts",o),f=se(a,je(oe(ae(Di))));if("error"in f)throw new ue(f.error,`failed to get info for accounts ${i}`);return f.result}async getMultipleAccountsInfoAndContext(e,t){const{commitment:r,config:s}=Ue(t),i=e.map(g=>g.toBase58()),o=this._buildArgs([i],r,"base64",s),a=await this._rpcRequest("getMultipleAccounts",o),f=se(a,je(oe(ae(en))));if("error"in f)throw new ue(f.error,`failed to get info for accounts ${i}`);return f.result}async getMultipleAccountsInfo(e,t){return(await this.getMultipleAccountsInfoAndContext(e,t)).value}async getStakeActivation(e,t,r){const{commitment:s,config:i}=Ue(t),o=this._buildArgs([e.toBase58()],s,void 0,{...i,epoch:r??(i==null?void 0:i.epoch)}),a=await this._rpcRequest("getStakeActivation",o),f=se(a,we(Wp));if("error"in f)throw new ue(f.error,`failed to get Stake Activation ${e.toBase58()}`);return f.result}async getProgramAccounts(e,t){const{commitment:r,config:s}=Ue(t),{encoding:i,...o}=s||{},a=this._buildArgs([e.toBase58()],r,i||"base64",{...o,...o.filters?{filters:ia(o.filters)}:null}),f=await this._rpcRequest("getProgramAccounts",a),g=oe(Kp),_=o.withContext===!0?se(f,je(g)):se(f,we(g));if("error"in _)throw new ue(_.error,`failed to get accounts owned by program ${e.toBase58()}`);return _.result}async getParsedProgramAccounts(e,t){const{commitment:r,config:s}=Ue(t),i=this._buildArgs([e.toBase58()],r,"jsonParsed",s),o=await this._rpcRequest("getProgramAccounts",i),a=se(o,we(oe(Hp)));if("error"in a)throw new ue(a.error,`failed to get accounts owned by program ${e.toBase58()}`);return a.result}async confirmTransaction(e,t){var i;let r;if(typeof e=="string")r=e;else{const o=e;if((i=o.abortSignal)!=null&&i.aborted)return Promise.reject(o.abortSignal.reason);r=o.signature}let s;try{s=gt.decode(r)}catch{throw new Error("signature must be base58 encoded: "+r)}return Ie(s.length===64,"signature has invalid length"),typeof e=="string"?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:t||this.commitment,signature:r}):"lastValidBlockHeight"in e?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t||this.commitment,strategy:e}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:t||this.commitment,strategy:e})}getCancellationPromise(e){return new Promise((t,r)=>{e!=null&&(e.aborted?r(e.reason):e.addEventListener("abort",()=>{r(e.reason)}))})}getTransactionConfirmationPromise({commitment:e,signature:t}){let r,s,i=!1;const o=new Promise((f,g)=>{try{r=this.onSignature(t,(b,x)=>{r=void 0;const T={context:x,value:b};f({__type:Zt.PROCESSED,response:T})},e);const _=new Promise(b=>{r==null?b():s=this._onSubscriptionStateChange(r,x=>{x==="subscribed"&&b()})});(async()=>{if(await _,i)return;const b=await this.getSignatureStatus(t);if(i||b==null)return;const{context:x,value:T}=b;if(T!=null)if(T!=null&&T.err)g(T.err);else{switch(e){case"confirmed":case"single":case"singleGossip":{if(T.confirmationStatus==="processed")return;break}case"finalized":case"max":case"root":{if(T.confirmationStatus==="processed"||T.confirmationStatus==="confirmed")return;break}case"processed":case"recent":}i=!0,f({__type:Zt.PROCESSED,response:{context:x,value:T}})}})()}catch(_){g(_)}});return{abortConfirmation:()=>{s&&(s(),s=void 0),r!=null&&(this.removeSignatureListener(r),r=void 0)},confirmationPromise:o}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e,strategy:{abortSignal:t,lastValidBlockHeight:r,signature:s}}){let i=!1;const o=new Promise(b=>{const x=async()=>{try{return await this.getBlockHeight(e)}catch{return-1}};(async()=>{let T=await x();if(!i){for(;T<=r;)if(await mr(1e3),i||(T=await x(),i))return;b({__type:Zt.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:a,confirmationPromise:f}=this.getTransactionConfirmationPromise({commitment:e,signature:s}),g=this.getCancellationPromise(t);let _;try{const b=await Promise.race([g,f,o]);if(b.__type===Zt.PROCESSED)_=b.response;else throw new Ai(s)}finally{i=!0,a()}return _}async confirmTransactionUsingDurableNonceStrategy({commitment:e,strategy:{abortSignal:t,minContextSlot:r,nonceAccountPubkey:s,nonceValue:i,signature:o}}){let a=!1;const f=new Promise(T=>{let L=i,k=null;const N=async()=>{try{const{context:M,value:H}=await this.getNonceAndContext(s,{commitment:e,minContextSlot:r});return k=M.slot,H==null?void 0:H.nonce}catch{return L}};(async()=>{if(L=await N(),!a)for(;;){if(i!==L){T({__type:Zt.NONCE_INVALID,slotInWhichNonceDidAdvance:k});return}if(await mr(2e3),a||(L=await N(),a))return}})()}),{abortConfirmation:g,confirmationPromise:_}=this.getTransactionConfirmationPromise({commitment:e,signature:o}),b=this.getCancellationPromise(t);let x;try{const T=await Promise.race([b,_,f]);if(T.__type===Zt.PROCESSED)x=T.response;else{let L;for(;;){const k=await this.getSignatureStatus(o);if(k==null)break;if(k.context.slot<(T.slotInWhichNonceDidAdvance??r)){await mr(400);continue}L=k;break}if(L!=null&&L.value){const k=e||"finalized",{confirmationStatus:N}=L.value;switch(k){case"processed":case"recent":if(N!=="processed"&&N!=="confirmed"&&N!=="finalized")throw new xr(o);break;case"confirmed":case"single":case"singleGossip":if(N!=="confirmed"&&N!=="finalized")throw new xr(o);break;case"finalized":case"max":case"root":if(N!=="finalized")throw new xr(o);break;default:}x={context:L.context,value:{err:L.value.err}}}else throw new xr(o)}}finally{a=!0,g()}return x}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:e,signature:t}){let r;const s=new Promise(f=>{let g=this._confirmTransactionInitialTimeout||6e4;switch(e){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{g=this._confirmTransactionInitialTimeout||3e4;break}}r=setTimeout(()=>f({__type:Zt.TIMED_OUT,timeoutMs:g}),g)}),{abortConfirmation:i,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:e,signature:t});let a;try{const f=await Promise.race([o,s]);if(f.__type===Zt.PROCESSED)a=f.response;else throw new Ii(t,f.timeoutMs/1e3)}finally{clearTimeout(r),i()}return a}async getClusterNodes(){const e=await this._rpcRequest("getClusterNodes",[]),t=se(e,we(oe(rg)));if("error"in t)throw new ue(t.error,"failed to get cluster nodes");return t.result}async getVoteAccounts(e){const t=this._buildArgs([],e),r=await this._rpcRequest("getVoteAccounts",t),s=se(r,ng);if("error"in s)throw new ue(s.error,"failed to get vote accounts");return s.result}async getSlot(e){const{commitment:t,config:r}=Ue(e),s=this._buildArgs([],t,void 0,r),i=await this._rpcRequest("getSlot",s),o=se(i,we($()));if("error"in o)throw new ue(o.error,"failed to get slot");return o.result}async getSlotLeader(e){const{commitment:t,config:r}=Ue(e),s=this._buildArgs([],t,void 0,r),i=await this._rpcRequest("getSlotLeader",s),o=se(i,we(re()));if("error"in o)throw new ue(o.error,"failed to get slot leader");return o.result}async getSlotLeaders(e,t){const r=[e,t],s=await this._rpcRequest("getSlotLeaders",r),i=se(s,we(oe(Ve)));if("error"in i)throw new ue(i.error,"failed to get slot leaders");return i.result}async getSignatureStatus(e,t){const{context:r,value:s}=await this.getSignatureStatuses([e],t);Ie(s.length===1);const i=s[0];return{context:r,value:i}}async getSignatureStatuses(e,t){const r=[e];t&&r.push(t);const s=await this._rpcRequest("getSignatureStatuses",r),i=se(s,og);if("error"in i)throw new ue(i.error,"failed to get signature status");return i.result}async getTransactionCount(e){const{commitment:t,config:r}=Ue(e),s=this._buildArgs([],t,void 0,r),i=await this._rpcRequest("getTransactionCount",s),o=se(i,we($()));if("error"in o)throw new ue(o.error,"failed to get transaction count");return o.result}async getTotalSupply(e){return(await this.getSupply({commitment:e,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(e){const t=this._buildArgs([],e),r=await this._rpcRequest("getInflationGovernor",t),s=se(r,Tp);if("error"in s)throw new ue(s.error,"failed to get inflation");return s.result}async getInflationReward(e,t,r){const{commitment:s,config:i}=Ue(r),o=this._buildArgs([e.map(g=>g.toBase58())],s,void 0,{...i,epoch:t??(i==null?void 0:i.epoch)}),a=await this._rpcRequest("getInflationReward",o),f=se(a,pp);if("error"in f)throw new ue(f.error,"failed to get inflation reward");return f.result}async getInflationRate(){const e=await this._rpcRequest("getInflationRate",[]),t=se(e,Np);if("error"in t)throw new ue(t.error,"failed to get inflation rate");return t.result}async getEpochInfo(e){const{commitment:t,config:r}=Ue(e),s=this._buildArgs([],t,void 0,r),i=await this._rpcRequest("getEpochInfo",s),o=se(i,Bp);if("error"in o)throw new ue(o.error,"failed to get epoch info");return o.result}async getEpochSchedule(){const e=await this._rpcRequest("getEpochSchedule",[]),t=se(e,Lp);if("error"in t)throw new ue(t.error,"failed to get epoch schedule");const r=t.result;return new ea(r.slotsPerEpoch,r.leaderScheduleSlotOffset,r.warmup,r.firstNormalEpoch,r.firstNormalSlot)}async getLeaderSchedule(){const e=await this._rpcRequest("getLeaderSchedule",[]),t=se(e,Cp);if("error"in t)throw new ue(t.error,"failed to get leader schedule");return t.result}async getMinimumBalanceForRentExemption(e,t){const r=this._buildArgs([e],t),s=await this._rpcRequest("getMinimumBalanceForRentExemption",r),i=se(s,ag);return"error"in i?(console.warn("Unable to fetch minimum balance for rent exemption"),0):i.result}async getRecentBlockhashAndContext(e){const{context:t,value:{blockhash:r}}=await this.getLatestBlockhashAndContext(e);return{context:t,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(e){const t=await this._rpcRequest("getRecentPerformanceSamples",e?[e]:[]),r=se(t,bg);if("error"in r)throw new ue(r.error,"failed to get recent performance samples");return r.result}async getFeeCalculatorForBlockhash(e,t){const r=this._buildArgs([e],t),s=await this._rpcRequest("getFeeCalculatorForBlockhash",r),i=se(s,Rg);if("error"in i)throw new ue(i.error,"failed to get fee calculator");const{context:o,value:a}=i.result;return{context:o,value:a!==null?a.feeCalculator:null}}async getFeeForMessage(e,t){const r=_e(e.serialize()).toString("base64"),s=this._buildArgs([r],t),i=await this._rpcRequest("getFeeForMessage",s),o=se(i,je(ae($())));if("error"in o)throw new ue(o.error,"failed to get fee for message");if(o.result===null)throw new Error("invalid blockhash");return o.result}async getRecentPrioritizationFees(e){var o;const t=(o=e==null?void 0:e.lockedWritableAccounts)==null?void 0:o.map(a=>a.toBase58()),r=t!=null&&t.length?[t]:[],s=await this._rpcRequest("getRecentPrioritizationFees",r),i=se(s,xp);if("error"in i)throw new ue(i.error,"failed to get recent prioritization fees");return i.result}async getRecentBlockhash(e){try{return(await this.getRecentBlockhashAndContext(e)).value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhash(e){try{return(await this.getLatestBlockhashAndContext(e)).value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhashAndContext(e){const{commitment:t,config:r}=Ue(e),s=this._buildArgs([],t,void 0,r),i=await this._rpcRequest("getLatestBlockhash",s),o=se(i,yg);if("error"in o)throw new ue(o.error,"failed to get latest blockhash");return o.result}async isBlockhashValid(e,t){const{commitment:r,config:s}=Ue(t),i=this._buildArgs([e],r,void 0,s),o=await this._rpcRequest("isBlockhashValid",i),a=se(o,_g);if("error"in a)throw new ue(a.error,"failed to determine if the blockhash `"+e+"`is valid");return a.result}async getVersion(){const e=await this._rpcRequest("getVersion",[]),t=se(e,we(Ep));if("error"in t)throw new ue(t.error,"failed to get version");return t.result}async getGenesisHash(){const e=await this._rpcRequest("getGenesisHash",[]),t=se(e,we(re()));if("error"in t)throw new ue(t.error,"failed to get genesis hash");return t.result}async getBlock(e,t){const{commitment:r,config:s}=Ue(t),i=this._buildArgsAtLeastConfirmed([e],r,void 0,s),o=await this._rpcRequest("getBlock",i);try{switch(s==null?void 0:s.transactionDetails){case"accounts":{const a=se(o,fg);if("error"in a)throw a.error;return a.result}case"none":{const a=se(o,hg);if("error"in a)throw a.error;return a.result}default:{const a=se(o,lg);if("error"in a)throw a.error;const{result:f}=a;return f?{...f,transactions:f.transactions.map(({transaction:g,meta:_,version:b})=>({meta:_,transaction:{...g,message:Mi(b,g.message)},version:b}))}:null}}}catch(a){throw new ue(a,"failed to get confirmed block")}}async getParsedBlock(e,t){const{commitment:r,config:s}=Ue(t),i=this._buildArgsAtLeastConfirmed([e],r,"jsonParsed",s),o=await this._rpcRequest("getBlock",i);try{switch(s==null?void 0:s.transactionDetails){case"accounts":{const a=se(o,pg);if("error"in a)throw a.error;return a.result}case"none":{const a=se(o,gg);if("error"in a)throw a.error;return a.result}default:{const a=se(o,dg);if("error"in a)throw a.error;return a.result}}}catch(a){throw new ue(a,"failed to get block")}}async getBlockProduction(e){let t,r;if(typeof e=="string")r=e;else if(e){const{commitment:a,...f}=e;r=a,t=f}const s=this._buildArgs([],r,"base64",t),i=await this._rpcRequest("getBlockProduction",s),o=se(i,Ip);if("error"in o)throw new ue(o.error,"failed to get block production information");return o.result}async getTransaction(e,t){const{commitment:r,config:s}=Ue(t),i=this._buildArgsAtLeastConfirmed([e],r,void 0,s),o=await this._rpcRequest("getTransaction",i),a=se(o,Ki);if("error"in a)throw new ue(a.error,"failed to get transaction");const f=a.result;return f&&{...f,transaction:{...f.transaction,message:Mi(f.version,f.transaction.message)}}}async getParsedTransaction(e,t){const{commitment:r,config:s}=Ue(t),i=this._buildArgsAtLeastConfirmed([e],r,"jsonParsed",s),o=await this._rpcRequest("getTransaction",i),a=se(o,Bn);if("error"in a)throw new ue(a.error,"failed to get transaction");return a.result}async getParsedTransactions(e,t){const{commitment:r,config:s}=Ue(t),i=e.map(f=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([f],r,"jsonParsed",s)}));return(await this._rpcBatchRequest(i)).map(f=>{const g=se(f,Bn);if("error"in g)throw new ue(g.error,"failed to get transactions");return g.result})}async getTransactions(e,t){const{commitment:r,config:s}=Ue(t),i=e.map(f=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([f],r,void 0,s)}));return(await this._rpcBatchRequest(i)).map(f=>{const g=se(f,Ki);if("error"in g)throw new ue(g.error,"failed to get transactions");const _=g.result;return _&&{..._,transaction:{..._.transaction,message:Mi(_.version,_.transaction.message)}}})}async getConfirmedBlock(e,t){const r=this._buildArgsAtLeastConfirmed([e],t),s=await this._rpcRequest("getBlock",r),i=se(s,mg);if("error"in i)throw new ue(i.error,"failed to get confirmed block");const o=i.result;if(!o)throw new Error("Confirmed block "+e+" not found");const a={...o,transactions:o.transactions.map(({transaction:f,meta:g})=>{const _=new Lt(f.message);return{meta:g,transaction:{...f,message:_}}})};return{...a,transactions:a.transactions.map(({transaction:f,meta:g})=>({meta:g,transaction:Oe.populate(f.message,f.signatures)}))}}async getBlocks(e,t,r){const s=this._buildArgsAtLeastConfirmed(t!==void 0?[e,t]:[e],r),i=await this._rpcRequest("getBlocks",s),o=se(i,we(oe($())));if("error"in o)throw new ue(o.error,"failed to get blocks");return o.result}async getBlockSignatures(e,t){const r=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),s=await this._rpcRequest("getBlock",r),i=se(s,ma);if("error"in i)throw new ue(i.error,"failed to get block");const o=i.result;if(!o)throw new Error("Block "+e+" not found");return o}async getConfirmedBlockSignatures(e,t){const r=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),s=await this._rpcRequest("getBlock",r),i=se(s,ma);if("error"in i)throw new ue(i.error,"failed to get confirmed block");const o=i.result;if(!o)throw new Error("Confirmed block "+e+" not found");return o}async getConfirmedTransaction(e,t){const r=this._buildArgsAtLeastConfirmed([e],t),s=await this._rpcRequest("getTransaction",r),i=se(s,Ki);if("error"in i)throw new ue(i.error,"failed to get transaction");const o=i.result;if(!o)return o;const a=new Lt(o.transaction.message),f=o.transaction.signatures;return{...o,transaction:Oe.populate(a,f)}}async getParsedConfirmedTransaction(e,t){const r=this._buildArgsAtLeastConfirmed([e],t,"jsonParsed"),s=await this._rpcRequest("getTransaction",r),i=se(s,Bn);if("error"in i)throw new ue(i.error,"failed to get confirmed transaction");return i.result}async getParsedConfirmedTransactions(e,t){const r=e.map(o=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([o],t,"jsonParsed")}));return(await this._rpcBatchRequest(r)).map(o=>{const a=se(o,Bn);if("error"in a)throw new ue(a.error,"failed to get confirmed transactions");return a.result})}async getConfirmedSignaturesForAddress(e,t,r){let s={},i=await this.getFirstAvailableBlock();for(;!("until"in s)&&(t--,!(t<=0||t<i));)try{const f=await this.getConfirmedBlockSignatures(t,"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(e,s)).map(f=>f.signature)}async getConfirmedSignaturesForAddress2(e,t,r){const s=this._buildArgsAtLeastConfirmed([e.toBase58()],r,void 0,t),i=await this._rpcRequest("getConfirmedSignaturesForAddress2",s),o=se(i,qp);if("error"in o)throw new ue(o.error,"failed to get confirmed signatures for address");return o.result}async getSignaturesForAddress(e,t,r){const s=this._buildArgsAtLeastConfirmed([e.toBase58()],r,void 0,t),i=await this._rpcRequest("getSignaturesForAddress",s),o=se(i,Vp);if("error"in o)throw new ue(o.error,"failed to get signatures for address");return o.result}async getAddressLookupTable(e,t){const{context:r,value:s}=await this.getAccountInfoAndContext(e,t);let i=null;return s!==null&&(i=new Li({key:e,state:Li.deserialize(s.data)})),{context:r,value:i}}async getNonceAndContext(e,t){const{context:r,value:s}=await this.getAccountInfoAndContext(e,t);let i=null;return s!==null&&(i=kn.fromAccountData(s.data)),{context:r,value:i}}async getNonce(e,t){return await this.getNonceAndContext(e,t).then(r=>r.value).catch(r=>{throw new Error("failed to get nonce for account "+e.toBase58()+": "+r)})}async requestAirdrop(e,t){const r=await this._rpcRequest("requestAirdrop",[e.toBase58(),t]),s=se(r,Eg);if("error"in s)throw new ue(s.error,`airdrop to ${e.toBase58()} failed`);return s.result}async _blockhashWithExpiryBlockHeight(e){if(!e){for(;this._pollingBlockhash;)await mr(100);const r=Date.now()-this._blockhashInfo.lastFetch>=na;if(this._blockhashInfo.latestBlockhash!==null&&!r)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{const e=Date.now(),t=this._blockhashInfo.latestBlockhash,r=t?t.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 mr(jo/2)}throw new Error(`Unable to obtain a new blockhash after ${Date.now()-e}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(e){const{commitment:t,config:r}=Ue(e),s=this._buildArgs([],t,"base64",r),i=await this._rpcRequest("getStakeMinimumDelegation",s),o=se(i,je($()));if("error"in o)throw new ue(o.error,"failed to get stake minimum delegation");return o.result}async simulateTransaction(e,t,r){if("message"in e){const k=e.serialize(),N=he.Buffer.from(k).toString("base64");if(Array.isArray(t)||r!==void 0)throw new Error("Invalid arguments");const M=t||{};M.encoding="base64","commitment"in M||(M.commitment=this.commitment),t&&typeof t=="object"&&"innerInstructions"in t&&(M.innerInstructions=t.innerInstructions);const H=[N,M],K=await this._rpcRequest("simulateTransaction",H),J=se(K,oa);if("error"in J)throw new Error("failed to simulate transaction: "+J.error.message);return J.result}let s;if(e instanceof Oe){let L=e;s=new Oe,s.feePayer=L.feePayer,s.instructions=e.instructions,s.nonceInfo=L.nonceInfo,s.signatures=L.signatures}else s=Oe.populate(e),s._message=s._json=void 0;if(t!==void 0&&!Array.isArray(t))throw new Error("Invalid arguments");const i=t;if(s.nonceInfo&&i)s.sign(...i);else{let L=this._disableBlockhashCaching;for(;;){const k=await this._blockhashWithExpiryBlockHeight(L);if(s.lastValidBlockHeight=k.lastValidBlockHeight,s.recentBlockhash=k.blockhash,!i)break;if(s.sign(...i),!s.signature)throw new Error("!signature");const N=s.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(N)&&!this._blockhashInfo.transactionSignatures.includes(N)){this._blockhashInfo.simulatedSignatures.push(N);break}else L=!0}}const o=s._compile(),a=o.serialize(),g=s._serialize(a).toString("base64"),_={encoding:"base64",commitment:this.commitment};if(r){const L=(Array.isArray(r)?r:o.nonProgramIds()).map(k=>k.toBase58());_.accounts={encoding:"base64",addresses:L}}i&&(_.sigVerify=!0),t&&typeof t=="object"&&"innerInstructions"in t&&(_.innerInstructions=t.innerInstructions);const b=[g,_],x=await this._rpcRequest("simulateTransaction",b),T=se(x,oa);if("error"in T){let L;if("data"in T.error&&(L=T.error.data.logs,L&&Array.isArray(L))){const k=`
17
+ `,N=k+L.join(k);console.error(T.error.message,N)}throw new Jr({action:"simulate",signature:"",transactionMessage:T.error.message,logs:L})}return T.result}async sendTransaction(e,t,r){if("version"in e){if(t&&Array.isArray(t))throw new Error("Invalid arguments");const o=e.serialize();return await this.sendRawTransaction(o,t)}if(t===void 0||!Array.isArray(t))throw new Error("Invalid arguments");const s=t;if(e.nonceInfo)e.sign(...s);else{let o=this._disableBlockhashCaching;for(;;){const a=await this._blockhashWithExpiryBlockHeight(o);if(e.lastValidBlockHeight=a.lastValidBlockHeight,e.recentBlockhash=a.blockhash,e.sign(...s),!e.signature)throw new Error("!signature");const f=e.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(f))o=!0;else{this._blockhashInfo.transactionSignatures.push(f);break}}}const i=e.serialize();return await this.sendRawTransaction(i,r)}async sendRawTransaction(e,t){const r=_e(e).toString("base64");return await this.sendEncodedTransaction(r,t)}async sendEncodedTransaction(e,t){const r={encoding:"base64"},s=t&&t.skipPreflight,i=s===!0?"processed":t&&t.preflightCommitment||this.commitment;t&&t.maxRetries!=null&&(r.maxRetries=t.maxRetries),t&&t.minContextSlot!=null&&(r.minContextSlot=t.minContextSlot),s&&(r.skipPreflight=s),i&&(r.preflightCommitment=i);const o=[e,r],a=await this._rpcRequest("sendTransaction",o),f=se(a,Sg);if("error"in f){let g;throw"data"in f.error&&(g=f.error.data.logs),new Jr({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(e){this._rpcWebSocketConnected=!1,console.error("ws error:",e.message)}_wsOnClose(e){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),e===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([t,r])=>{this._setSubscription(t,{...r,state:"pending"})})}_setSubscription(e,t){var s;const r=(s=this._subscriptionsByHash[e])==null?void 0:s.state;if(this._subscriptionsByHash[e]=t,r!==t.state){const i=this._subscriptionStateChangeCallbacksByHash[e];i&&i.forEach(o=>{try{o(t.state)}catch{}})}}_onSubscriptionStateChange(e,t){var i;const r=this._subscriptionHashByClientSubscriptionId[e];if(r==null)return()=>{};const s=(i=this._subscriptionStateChangeCallbacksByHash)[r]||(i[r]=new Set);return s.add(t),()=>{s.delete(t),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 e=this._rpcWebSocketGeneration,t=()=>e===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async r=>{const s=this._subscriptionsByHash[r];if(s!==void 0)switch(s.state){case"pending":case"unsubscribed":if(s.callbacks.size===0){delete this._subscriptionsByHash[r],s.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[s.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{const{args:i,method:o}=s;try{this._setSubscription(r,{...s,state:"subscribing"});const a=await this._rpcWebSocket.call(o,i);this._setSubscription(r,{...s,serverSubscriptionId:a,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[a]=s.callbacks,await this._updateSubscriptions()}catch(a){if(console.error(`Received ${a instanceof Error?"":"JSON-RPC "}error calling \`${o}\``,{args:i,error:a}),!t())return;this._setSubscription(r,{...s,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":s.callbacks.size===0&&await(async()=>{const{serverSubscriptionId:i,unsubscribeMethod:o}=s;if(this._subscriptionsAutoDisposedByRpc.has(i))this._subscriptionsAutoDisposedByRpc.delete(i);else{this._setSubscription(r,{...s,state:"unsubscribing"}),this._setSubscription(r,{...s,state:"unsubscribing"});try{await this._rpcWebSocket.call(o,[i])}catch(a){if(a instanceof Error&&console.error(`${o} error:`,a.message),!t())return;this._setSubscription(r,{...s,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(r,{...s,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(e,t){const r=this._subscriptionCallbacksByServerSubscriptionId[e];r!==void 0&&r.forEach(s=>{try{s(...t)}catch(i){console.error(i)}})}_wsOnAccountNotification(e){const{result:t,subscription:r}=se(e,Gp);this._handleServerNotification(r,[t.value,t.context])}_makeSubscription(e,t){const r=this._nextClientSubscriptionId++,s=Qo([e.method,t]),i=this._subscriptionsByHash[s];return i===void 0?this._subscriptionsByHash[s]={...e,args:t,callbacks:new Set([e.callback]),state:"pending"}:i.callbacks.add(e.callback),this._subscriptionHashByClientSubscriptionId[r]=s,this._subscriptionDisposeFunctionsByClientSubscriptionId[r]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[r],delete this._subscriptionHashByClientSubscriptionId[r];const o=this._subscriptionsByHash[s];Ie(o!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${r}`),o.callbacks.delete(e.callback),await this._updateSubscriptions()},this._updateSubscriptions(),r}onAccountChange(e,t,r){const{commitment:s,config:i}=Ue(r),o=this._buildArgs([e.toBase58()],s||this._commitment||"finalized","base64",i);return this._makeSubscription({callback:t,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},o)}async removeAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"account change")}_wsOnProgramAccountNotification(e){const{result:t,subscription:r}=se(e,jp);this._handleServerNotification(r,[{accountId:t.value.pubkey,accountInfo:t.value.account},t.context])}onProgramAccountChange(e,t,r,s){const{commitment:i,config:o}=Ue(r),a=this._buildArgs([e.toBase58()],i||this._commitment||"finalized","base64",o||(s?{filters:ia(s)}:void 0));return this._makeSubscription({callback:t,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},a)}async removeProgramAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"program account change")}onLogs(e,t,r){const s=this._buildArgs([typeof e=="object"?{mentions:[e.toString()]}:e],r||this._commitment||"finalized");return this._makeSubscription({callback:t,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},s)}async removeOnLogsListener(e){await this._unsubscribeClientSubscription(e,"logs")}_wsOnLogsNotification(e){const{result:t,subscription:r}=se(e,Ig);this._handleServerNotification(r,[t.value,t.context])}_wsOnSlotNotification(e){const{result:t,subscription:r}=se(e,Xp);this._handleServerNotification(r,[t])}onSlotChange(e){return this._makeSubscription({callback:e,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(e){await this._unsubscribeClientSubscription(e,"slot change")}_wsOnSlotUpdatesNotification(e){const{result:t,subscription:r}=se(e,Qp);this._handleServerNotification(r,[t])}onSlotUpdate(e){return this._makeSubscription({callback:e,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(e){await this._unsubscribeClientSubscription(e,"slot update")}async _unsubscribeClientSubscription(e,t){const r=this._subscriptionDisposeFunctionsByClientSubscriptionId[e];r?await r():console.warn(`Ignored unsubscribe request because an active subscription with id \`${e}\` for '${t}' events could not be found.`)}_buildArgs(e,t,r,s){const i=t||this._commitment;if(i||r||s){let o={};r&&(o.encoding=r),i&&(o.commitment=i),s&&(o=Object.assign(o,s)),e.push(o)}return e}_buildArgsAtLeastConfirmed(e,t,r,s){const i=t||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(e,t,r,s)}_wsOnSignatureNotification(e){const{result:t,subscription:r}=se(e,eg);t.value!=="receivedSignature"&&this._subscriptionsAutoDisposedByRpc.add(r),this._handleServerNotification(r,t.value==="receivedSignature"?[{type:"received"},t.context]:[{type:"status",result:t.value},t.context])}onSignature(e,t,r){const s=this._buildArgs([e],r||this._commitment||"finalized"),i=this._makeSubscription({callback:(o,a)=>{if(o.type==="status"){t(o.result,a);try{this.removeSignatureListener(i)}catch{}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},s);return i}onSignatureWithOptions(e,t,r){const{commitment:s,...i}={...r,commitment:r&&r.commitment||this._commitment||"finalized"},o=this._buildArgs([e],s,void 0,i),a=this._makeSubscription({callback:(f,g)=>{t(f,g);try{this.removeSignatureListener(a)}catch{}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},o);return a}async removeSignatureListener(e){await this._unsubscribeClientSubscription(e,"signature result")}_wsOnRootNotification(e){const{result:t,subscription:r}=se(e,tg);this._handleServerNotification(r,[t])}onRootChange(e){return this._makeSubscription({callback:e,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(e){await this._unsubscribeClientSubscription(e,"root change")}}class Mr{constructor(e){this._keypair=void 0,this._keypair=e??$o()}static generate(){return new Mr($o())}static fromSecretKey(e,t){if(e.byteLength!==64)throw new Error("bad secret key size");const r=e.slice(32,64);if(!t||!t.skipValidation){const s=e.slice(0,32),i=Sn(s);for(let o=0;o<32;o++)if(r[o]!==i[o])throw new Error("provided secretKey is invalid")}return new Mr({publicKey:r,secretKey:e})}static fromSeed(e){const t=Sn(e),r=new Uint8Array(64);return r.set(e),r.set(t,32),new Mr({publicKey:t,secretKey:r})}get publicKey(){return new ie(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}const Xt=Object.freeze({CreateLookupTable:{index:0,layout:B.struct([B.u32("instruction"),Lr("recentSlot"),B.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:B.struct([B.u32("instruction")])},ExtendLookupTable:{index:2,layout:B.struct([B.u32("instruction"),Lr(),B.seq(Se(),B.offset(B.u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:B.struct([B.u32("instruction")])},CloseLookupTable:{index:4,layout:B.struct([B.u32("instruction")])}});class kg{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const r=B.u32("instruction").decode(e.data);let s;for(const[i,o]of Object.entries(Xt))if(o.index==r){s=i;break}if(!s)throw new Error("Invalid Instruction. Should be a LookupTable Instruction");return s}static decodeCreateLookupTable(e){this.checkProgramId(e.programId),this.checkKeysLength(e.keys,4);const{recentSlot:t}=Te(Xt.CreateLookupTable,e.data);return{authority:e.keys[1].pubkey,payer:e.keys[2].pubkey,recentSlot:Number(t)}}static decodeExtendLookupTable(e){if(this.checkProgramId(e.programId),e.keys.length<2)throw new Error(`invalid instruction; found ${e.keys.length} keys, expected at least 2`);const{addresses:t}=Te(Xt.ExtendLookupTable,e.data);return{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey,payer:e.keys.length>2?e.keys[2].pubkey:void 0,addresses:t.map(r=>new ie(r))}}static decodeCloseLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,3),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey,recipient:e.keys[2].pubkey}}static decodeFreezeLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,2),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey}}static decodeDeactivateLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,2),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey}}static checkProgramId(e){if(!e.equals($i.programId))throw new Error("invalid instruction; programId is not AddressLookupTable Program")}static checkKeysLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}class $i{constructor(){}static createLookupTable(e){const[t,r]=ie.findProgramAddressSync([e.authority.toBuffer(),go().encode(e.recentSlot)],this.programId),s=Xt.CreateLookupTable,i=Ae(s,{recentSlot:BigInt(e.recentSlot),bumpSeed:r}),o=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:mt.programId,isSigner:!1,isWritable:!1}];return[new Be({programId:this.programId,keys:o,data:i}),t]}static freezeLookupTable(e){const t=Xt.FreezeLookupTable,r=Ae(t),s=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new Be({programId:this.programId,keys:s,data:r})}static extendLookupTable(e){const t=Xt.ExtendLookupTable,r=Ae(t,{addresses:e.addresses.map(i=>i.toBytes())}),s=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return e.payer&&s.push({pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:mt.programId,isSigner:!1,isWritable:!1}),new Be({programId:this.programId,keys:s,data:r})}static deactivateLookupTable(e){const t=Xt.DeactivateLookupTable,r=Ae(t),s=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new Be({programId:this.programId,keys:s,data:r})}static closeLookupTable(e){const t=Xt.CloseLookupTable,r=Ae(t),s=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.recipient,isSigner:!1,isWritable:!0}];return new Be({programId:this.programId,keys:s,data:r})}}$i.programId=new ie("AddressLookupTab1e1111111111111111111111111");class Tg{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const r=B.u8("instruction").decode(e.data);let s;for(const[i,o]of Object.entries(Kt))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a ComputeBudgetInstruction");return s}static decodeRequestUnits(e){this.checkProgramId(e.programId);const{units:t,additionalFee:r}=Te(Kt.RequestUnits,e.data);return{units:t,additionalFee:r}}static decodeRequestHeapFrame(e){this.checkProgramId(e.programId);const{bytes:t}=Te(Kt.RequestHeapFrame,e.data);return{bytes:t}}static decodeSetComputeUnitLimit(e){this.checkProgramId(e.programId);const{units:t}=Te(Kt.SetComputeUnitLimit,e.data);return{units:t}}static decodeSetComputeUnitPrice(e){this.checkProgramId(e.programId);const{microLamports:t}=Te(Kt.SetComputeUnitPrice,e.data);return{microLamports:t}}static checkProgramId(e){if(!e.equals(Hi.programId))throw new Error("invalid instruction; programId is not ComputeBudgetProgram")}}const Kt=Object.freeze({RequestUnits:{index:0,layout:B.struct([B.u8("instruction"),B.u32("units"),B.u32("additionalFee")])},RequestHeapFrame:{index:1,layout:B.struct([B.u8("instruction"),B.u32("bytes")])},SetComputeUnitLimit:{index:2,layout:B.struct([B.u8("instruction"),B.u32("units")])},SetComputeUnitPrice:{index:3,layout:B.struct([B.u8("instruction"),Lr("microLamports")])}});class Hi{constructor(){}static requestUnits(e){const t=Kt.RequestUnits,r=Ae(t,e);return new Be({keys:[],programId:this.programId,data:r})}static requestHeapFrame(e){const t=Kt.RequestHeapFrame,r=Ae(t,e);return new Be({keys:[],programId:this.programId,data:r})}static setComputeUnitLimit(e){const t=Kt.SetComputeUnitLimit,r=Ae(t,e);return new Be({keys:[],programId:this.programId,data:r})}static setComputeUnitPrice(e){const t=Kt.SetComputeUnitPrice,r=Ae(t,{microLamports:BigInt(e.microLamports)});return new Be({keys:[],programId:this.programId,data:r})}}Hi.programId=new ie("ComputeBudget111111111111111111111111111111");const ya=64,_a=32,wa=64,ba=B.struct([B.u8("numSignatures"),B.u8("padding"),B.u16("signatureOffset"),B.u16("signatureInstructionIndex"),B.u16("publicKeyOffset"),B.u16("publicKeyInstructionIndex"),B.u16("messageDataOffset"),B.u16("messageDataSize"),B.u16("messageInstructionIndex")]);class Ln{constructor(){}static createInstructionWithPublicKey(e){const{publicKey:t,message:r,signature:s,instructionIndex:i}=e;Ie(t.length===_a,`Public Key must be ${_a} bytes but received ${t.length} bytes`),Ie(s.length===wa,`Signature must be ${wa} bytes but received ${s.length} bytes`);const o=ba.span,a=o+t.length,f=a+s.length,g=1,_=he.Buffer.alloc(f+r.length),b=i??65535;return ba.encode({numSignatures:g,padding:0,signatureOffset:a,signatureInstructionIndex:b,publicKeyOffset:o,publicKeyInstructionIndex:b,messageDataOffset:f,messageDataSize:r.length,messageInstructionIndex:b},_),_.fill(t,o),_.fill(s,a),_.fill(r,f),new Be({keys:[],programId:Ln.programId,data:_})}static createInstructionWithPrivateKey(e){const{privateKey:t,message:r,instructionIndex:s}=e;Ie(t.length===ya,`Private key must be ${ya} bytes but received ${t.length} bytes`);try{const i=Mr.fromSecretKey(t),o=i.publicKey.toBytes(),a=Ei(r,i.secretKey);return this.createInstructionWithPublicKey({publicKey:o,message:r,signature:a,instructionIndex:s})}catch(i){throw new Error(`Error creating instruction; ${i}`)}}}Ln.programId=new ie("Ed25519SigVerify111111111111111111111111111");const Ng=(n,e)=>{const t=En.sign(n,e);return[t.toCompactRawBytes(),t.recovery]};En.utils.isValidPrivateKey;const xg=En.getPublicKey,Ra=32,Wi=20,Ea=64,Bg=11,qi=B.struct([B.u8("numSignatures"),B.u16("signatureOffset"),B.u8("signatureInstructionIndex"),B.u16("ethAddressOffset"),B.u8("ethAddressInstructionIndex"),B.u16("messageDataOffset"),B.u16("messageDataSize"),B.u8("messageInstructionIndex"),B.blob(20,"ethAddress"),B.blob(64,"signature"),B.u8("recoveryId")]);class Pr{constructor(){}static publicKeyToEthAddress(e){Ie(e.length===Ea,`Public key must be ${Ea} bytes but received ${e.length} bytes`);try{return he.Buffer.from(Mo(_e(e))).slice(-Wi)}catch(t){throw new Error(`Error constructing Ethereum address: ${t}`)}}static createInstructionWithPublicKey(e){const{publicKey:t,message:r,signature:s,recoveryId:i,instructionIndex:o}=e;return Pr.createInstructionWithEthAddress({ethAddress:Pr.publicKeyToEthAddress(t),message:r,signature:s,recoveryId:i,instructionIndex:o})}static createInstructionWithEthAddress(e){const{ethAddress:t,message:r,signature:s,recoveryId:i,instructionIndex:o=0}=e;let a;typeof t=="string"?t.startsWith("0x")?a=he.Buffer.from(t.substr(2),"hex"):a=he.Buffer.from(t,"hex"):a=t,Ie(a.length===Wi,`Address must be ${Wi} bytes but received ${a.length} bytes`);const f=1+Bg,g=f,_=f+a.length,b=_+s.length+1,x=1,T=he.Buffer.alloc(qi.span+r.length);return qi.encode({numSignatures:x,signatureOffset:_,signatureInstructionIndex:o,ethAddressOffset:g,ethAddressInstructionIndex:o,messageDataOffset:b,messageDataSize:r.length,messageInstructionIndex:o,signature:_e(s),ethAddress:_e(a),recoveryId:i},T),T.fill(_e(r),qi.span),new Be({keys:[],programId:Pr.programId,data:T})}static createInstructionWithPrivateKey(e){const{privateKey:t,message:r,instructionIndex:s}=e;Ie(t.length===Ra,`Private key must be ${Ra} bytes but received ${t.length} bytes`);try{const i=_e(t),o=xg(i,!1).slice(1),a=he.Buffer.from(Mo(_e(r))),[f,g]=Ng(a,i);return this.createInstructionWithPublicKey({publicKey:o,message:r,signature:f,recoveryId:g,instructionIndex:s})}catch(i){throw new Error(`Error creating instruction; ${i}`)}}}Pr.programId=new ie("KeccakSecp256k11111111111111111111111111111");var Sa;const Aa=new ie("StakeConfig11111111111111111111111111111111");class Ia{constructor(e,t){this.staker=void 0,this.withdrawer=void 0,this.staker=e,this.withdrawer=t}}class tn{constructor(e,t,r){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=t,this.custodian=r}}Sa=tn,tn.default=new Sa(0,0,ie.default);class Lg{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const r=B.u32("instruction").decode(e.data);let s;for(const[i,o]of Object.entries(yt))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a StakeInstruction");return s}static decodeInitialize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{authorized:t,lockup:r}=Te(yt.Initialize,e.data);return{stakePubkey:e.keys[0].pubkey,authorized:new Ia(new ie(t.staker),new ie(t.withdrawer)),lockup:new tn(r.unixTimestamp,r.epoch,new ie(r.custodian))}}static decodeDelegate(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,6),Te(yt.Delegate,e.data),{stakePubkey:e.keys[0].pubkey,votePubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[5].pubkey}}static decodeAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{newAuthorized:t,stakeAuthorizationType:r}=Te(yt.Authorize,e.data),s={stakePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey,newAuthorizedPubkey:new ie(t),stakeAuthorizationType:{index:r}};return e.keys.length>3&&(s.custodianPubkey=e.keys[3].pubkey),s}static decodeAuthorizeWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{newAuthorized:t,stakeAuthorizationType:r,authoritySeed:s,authorityOwner:i}=Te(yt.AuthorizeWithSeed,e.data),o={stakePubkey:e.keys[0].pubkey,authorityBase:e.keys[1].pubkey,authoritySeed:s,authorityOwner:new ie(i),newAuthorizedPubkey:new ie(t),stakeAuthorizationType:{index:r}};return e.keys.length>3&&(o.custodianPubkey=e.keys[3].pubkey),o}static decodeSplit(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{lamports:t}=Te(yt.Split,e.data);return{stakePubkey:e.keys[0].pubkey,splitStakePubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[2].pubkey,lamports:t}}static decodeMerge(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),Te(yt.Merge,e.data),{stakePubkey:e.keys[0].pubkey,sourceStakePubKey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey}}static decodeWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,5);const{lamports:t}=Te(yt.Withdraw,e.data),r={stakePubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey,lamports:t};return e.keys.length>5&&(r.custodianPubkey=e.keys[5].pubkey),r}static decodeDeactivate(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),Te(yt.Deactivate,e.data),{stakePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey}}static checkProgramId(e){if(!e.equals(Cn.programId))throw new Error("invalid instruction; programId is not StakeProgram")}static checkKeyLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}const yt=Object.freeze({Initialize:{index:0,layout:B.struct([B.u32("instruction"),z0(),K0()])},Authorize:{index:1,layout:B.struct([B.u32("instruction"),Se("newAuthorized"),B.u32("stakeAuthorizationType")])},Delegate:{index:2,layout:B.struct([B.u32("instruction")])},Split:{index:3,layout:B.struct([B.u32("instruction"),B.ns64("lamports")])},Withdraw:{index:4,layout:B.struct([B.u32("instruction"),B.ns64("lamports")])},Deactivate:{index:5,layout:B.struct([B.u32("instruction")])},Merge:{index:7,layout:B.struct([B.u32("instruction")])},AuthorizeWithSeed:{index:8,layout:B.struct([B.u32("instruction"),Se("newAuthorized"),B.u32("stakeAuthorizationType"),pr("authoritySeed"),Se("authorityOwner")])}}),Cg=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class Cn{constructor(){}static initialize(e){const{stakePubkey:t,authorized:r,lockup:s}=e,i=s||tn.default,o=yt.Initialize,a=Ae(o,{authorized:{staker:_e(r.staker.toBuffer()),withdrawer:_e(r.withdrawer.toBuffer())},lockup:{unixTimestamp:i.unixTimestamp,epoch:i.epoch,custodian:_e(i.custodian.toBuffer())}}),f={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Br,isSigner:!1,isWritable:!1}],programId:this.programId,data:a};return new Be(f)}static createAccountWithSeed(e){const t=new Oe;t.add(mt.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:this.space,programId:this.programId}));const{stakePubkey:r,authorized:s,lockup:i}=e;return t.add(this.initialize({stakePubkey:r,authorized:s,lockup:i}))}static createAccount(e){const t=new Oe;t.add(mt.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,lamports:e.lamports,space:this.space,programId:this.programId}));const{stakePubkey:r,authorized:s,lockup:i}=e;return t.add(this.initialize({stakePubkey:r,authorized:s,lockup:i}))}static delegate(e){const{stakePubkey:t,authorizedPubkey:r,votePubkey:s}=e,i=yt.Delegate,o=Ae(i);return new Oe().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!1},{pubkey:zt,isSigner:!1,isWritable:!1},{pubkey:On,isSigner:!1,isWritable:!1},{pubkey:Aa,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static authorize(e){const{stakePubkey:t,authorizedPubkey:r,newAuthorizedPubkey:s,stakeAuthorizationType:i,custodianPubkey:o}=e,a=yt.Authorize,f=Ae(a,{newAuthorized:_e(s.toBuffer()),stakeAuthorizationType:i.index}),g=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:zt,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return o&&g.push({pubkey:o,isSigner:!0,isWritable:!1}),new Oe().add({keys:g,programId:this.programId,data:f})}static authorizeWithSeed(e){const{stakePubkey:t,authorityBase:r,authoritySeed:s,authorityOwner:i,newAuthorizedPubkey:o,stakeAuthorizationType:a,custodianPubkey:f}=e,g=yt.AuthorizeWithSeed,_=Ae(g,{newAuthorized:_e(o.toBuffer()),stakeAuthorizationType:a.index,authoritySeed:s,authorityOwner:_e(i.toBuffer())}),b=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1},{pubkey:zt,isSigner:!1,isWritable:!1}];return f&&b.push({pubkey:f,isSigner:!0,isWritable:!1}),new Oe().add({keys:b,programId:this.programId,data:_})}static splitInstruction(e){const{stakePubkey:t,authorizedPubkey:r,splitStakePubkey:s,lamports:i}=e,o=yt.Split,a=Ae(o,{lamports:i});return new Be({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static split(e,t){const r=new Oe;return r.add(mt.createAccount({fromPubkey:e.authorizedPubkey,newAccountPubkey:e.splitStakePubkey,lamports:t,space:this.space,programId:this.programId})),r.add(this.splitInstruction(e))}static splitWithSeed(e,t){const{stakePubkey:r,authorizedPubkey:s,splitStakePubkey:i,basePubkey:o,seed:a,lamports:f}=e,g=new Oe;return g.add(mt.allocate({accountPubkey:i,basePubkey:o,seed:a,space:this.space,programId:this.programId})),t&&t>0&&g.add(mt.transfer({fromPubkey:e.authorizedPubkey,toPubkey:i,lamports:t})),g.add(this.splitInstruction({stakePubkey:r,authorizedPubkey:s,splitStakePubkey:i,lamports:f}))}static merge(e){const{stakePubkey:t,sourceStakePubKey:r,authorizedPubkey:s}=e,i=yt.Merge,o=Ae(i);return new Oe().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:zt,isSigner:!1,isWritable:!1},{pubkey:On,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static withdraw(e){const{stakePubkey:t,authorizedPubkey:r,toPubkey:s,lamports:i,custodianPubkey:o}=e,a=yt.Withdraw,f=Ae(a,{lamports:i}),g=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:zt,isSigner:!1,isWritable:!1},{pubkey:On,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return o&&g.push({pubkey:o,isSigner:!0,isWritable:!1}),new Oe().add({keys:g,programId:this.programId,data:f})}static deactivate(e){const{stakePubkey:t,authorizedPubkey:r}=e,s=yt.Deactivate,i=Ae(s);return new Oe().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:zt,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}}Cn.programId=new ie("Stake11111111111111111111111111111111111111"),Cn.space=200;class va{constructor(e,t,r,s){this.nodePubkey=void 0,this.authorizedVoter=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.nodePubkey=e,this.authorizedVoter=t,this.authorizedWithdrawer=r,this.commission=s}}class Mg{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const r=B.u32("instruction").decode(e.data);let s;for(const[i,o]of Object.entries($t))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a VoteInstruction");return s}static decodeInitializeAccount(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,4);const{voteInit:t}=Te($t.InitializeAccount,e.data);return{votePubkey:e.keys[0].pubkey,nodePubkey:e.keys[3].pubkey,voteInit:new va(new ie(t.nodePubkey),new ie(t.authorizedVoter),new ie(t.authorizedWithdrawer),t.commission)}}static decodeAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{newAuthorized:t,voteAuthorizationType:r}=Te($t.Authorize,e.data);return{votePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey,newAuthorizedPubkey:new ie(t),voteAuthorizationType:{index:r}}}static decodeAuthorizeWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:t,currentAuthorityDerivedKeySeed:r,newAuthorized:s,voteAuthorizationType:i}}=Te($t.AuthorizeWithSeed,e.data);return{currentAuthorityDerivedKeyBasePubkey:e.keys[2].pubkey,currentAuthorityDerivedKeyOwnerPubkey:new ie(t),currentAuthorityDerivedKeySeed:r,newAuthorizedPubkey:new ie(s),voteAuthorizationType:{index:i},votePubkey:e.keys[0].pubkey}}static decodeWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{lamports:t}=Te($t.Withdraw,e.data);return{votePubkey:e.keys[0].pubkey,authorizedWithdrawerPubkey:e.keys[2].pubkey,lamports:t,toPubkey:e.keys[1].pubkey}}static checkProgramId(e){if(!e.equals(Ur.programId))throw new Error("invalid instruction; programId is not VoteProgram")}static checkKeyLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}const $t=Object.freeze({InitializeAccount:{index:0,layout:B.struct([B.u32("instruction"),$0()])},Authorize:{index:1,layout:B.struct([B.u32("instruction"),Se("newAuthorized"),B.u32("voteAuthorizationType")])},Withdraw:{index:3,layout:B.struct([B.u32("instruction"),B.ns64("lamports")])},UpdateValidatorIdentity:{index:4,layout:B.struct([B.u32("instruction")])},AuthorizeWithSeed:{index:10,layout:B.struct([B.u32("instruction"),H0()])}}),Pg=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class Ur{constructor(){}static initializeAccount(e){const{votePubkey:t,nodePubkey:r,voteInit:s}=e,i=$t.InitializeAccount,o=Ae(i,{voteInit:{nodePubkey:_e(s.nodePubkey.toBuffer()),authorizedVoter:_e(s.authorizedVoter.toBuffer()),authorizedWithdrawer:_e(s.authorizedWithdrawer.toBuffer()),commission:s.commission}}),a={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Br,isSigner:!1,isWritable:!1},{pubkey:zt,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:o};return new Be(a)}static createAccount(e){const t=new Oe;return t.add(mt.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.votePubkey,lamports:e.lamports,space:this.space,programId:this.programId})),t.add(this.initializeAccount({votePubkey:e.votePubkey,nodePubkey:e.voteInit.nodePubkey,voteInit:e.voteInit}))}static authorize(e){const{votePubkey:t,authorizedPubkey:r,newAuthorizedPubkey:s,voteAuthorizationType:i}=e,o=$t.Authorize,a=Ae(o,{newAuthorized:_e(s.toBuffer()),voteAuthorizationType:i.index}),f=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:zt,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new Oe().add({keys:f,programId:this.programId,data:a})}static authorizeWithSeed(e){const{currentAuthorityDerivedKeyBasePubkey:t,currentAuthorityDerivedKeyOwnerPubkey:r,currentAuthorityDerivedKeySeed:s,newAuthorizedPubkey:i,voteAuthorizationType:o,votePubkey:a}=e,f=$t.AuthorizeWithSeed,g=Ae(f,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:_e(r.toBuffer()),currentAuthorityDerivedKeySeed:s,newAuthorized:_e(i.toBuffer()),voteAuthorizationType:o.index}}),_=[{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:zt,isSigner:!1,isWritable:!1},{pubkey:t,isSigner:!0,isWritable:!1}];return new Oe().add({keys:_,programId:this.programId,data:g})}static withdraw(e){const{votePubkey:t,authorizedWithdrawerPubkey:r,lamports:s,toPubkey:i}=e,o=$t.Withdraw,a=Ae(o,{lamports:s}),f=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return new Oe().add({keys:f,programId:this.programId,data:a})}static safeWithdraw(e,t,r){if(e.lamports>t-r)throw new Error("Withdraw will leave vote account with insufficient funds.");return Ur.withdraw(e)}static updateValidatorIdentity(e){const{votePubkey:t,authorizedWithdrawerPubkey:r,nodePubkey:s}=e,i=$t.UpdateValidatorIdentity,o=Ae(i),a=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!0,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new Oe().add({keys:a,programId:this.programId,data:o})}}Ur.programId=new ie("Vote111111111111111111111111111111111111111"),Ur.space=3762;const Oa=new ie("Va1idator1nfo111111111111111111111111111111"),Ug=ee({name:re(),website:le(re()),details:le(re()),iconUrl:le(re()),keybaseUsername:le(re())});class Vi{constructor(e,t){this.key=void 0,this.info=void 0,this.key=e,this.info=t}static fromConfigData(e){let t=[...e];if(It(t)!==2)return null;const s=[];for(let i=0;i<2;i++){const o=new ie(vt(t,0,Dt)),a=Ft(t)===1;s.push({publicKey:o,isSigner:a})}if(s[0].publicKey.equals(Oa)&&s[1].isSigner){const i=pr().decode(he.Buffer.from(t)),o=JSON.parse(i);return yo(o,Ug),new Vi(s[1].publicKey,o)}return null}}const Dg=new ie("Vote111111111111111111111111111111111111111"),Fg=B.struct([Se("nodePubkey"),Se("authorizedWithdrawer"),B.u8("commission"),B.nu64(),B.seq(B.struct([B.nu64("slot"),B.u32("confirmationCount")]),B.offset(B.u32(),-8),"votes"),B.u8("rootSlotValid"),B.nu64("rootSlot"),B.nu64(),B.seq(B.struct([B.nu64("epoch"),Se("authorizedVoter")]),B.offset(B.u32(),-8),"authorizedVoters"),B.struct([B.seq(B.struct([Se("authorizedPubkey"),B.nu64("epochOfLastAuthorizedSwitch"),B.nu64("targetEpoch")]),32,"buf"),B.nu64("idx"),B.u8("isEmpty")],"priorVoters"),B.nu64(),B.seq(B.struct([B.nu64("epoch"),B.nu64("credits"),B.nu64("prevCredits")]),B.offset(B.u32(),-8),"epochCredits"),B.struct([B.nu64("slot"),B.nu64("timestamp")],"lastTimestamp")]);class Gi{constructor(e){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=e.nodePubkey,this.authorizedWithdrawer=e.authorizedWithdrawer,this.commission=e.commission,this.rootSlot=e.rootSlot,this.votes=e.votes,this.authorizedVoters=e.authorizedVoters,this.priorVoters=e.priorVoters,this.epochCredits=e.epochCredits,this.lastTimestamp=e.lastTimestamp}static fromAccountData(e){const r=Fg.decode(_e(e),4);let s=r.rootSlot;return r.rootSlotValid||(s=null),new Gi({nodePubkey:new ie(r.nodePubkey),authorizedWithdrawer:new ie(r.authorizedWithdrawer),commission:r.commission,votes:r.votes,rootSlot:s,authorizedVoters:r.authorizedVoters.map(zg),priorVoters:Kg(r.priorVoters),epochCredits:r.epochCredits,lastTimestamp:r.lastTimestamp})}}function zg({authorizedVoter:n,epoch:e}){return{epoch:e,authorizedVoter:new ie(n)}}function ka({authorizedPubkey:n,epochOfLastAuthorizedSwitch:e,targetEpoch:t}){return{authorizedPubkey:new ie(n),epochOfLastAuthorizedSwitch:e,targetEpoch:t}}function Kg({buf:n,idx:e,isEmpty:t}){return t?[]:[...n.slice(e+1).map(ka),...n.slice(0,e).map(ka)]}const Ta={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 $g(n,e){const t=e===!1?"http":"https";if(!n)return Ta[t].devnet;const r=Ta[t][n];if(!r)throw new Error(`Unknown ${t} cluster: ${n}`);return r}async function Hg(n,e,t,r){let s,i;t&&Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")||t&&Object.prototype.hasOwnProperty.call(t,"nonceValue")?(s=t,i=r):i=t;const o=i&&{skipPreflight:i.skipPreflight,preflightCommitment:i.preflightCommitment||i.commitment,minContextSlot:i.minContextSlot},a=await n.sendRawTransaction(e,o),f=i&&i.commitment,_=(await(s?n.confirmTransaction(s,f):n.confirmTransaction(a,f))).value;if(_.err)throw a!=null?new Jr({action:o!=null&&o.skipPreflight?"send":"simulate",signature:a,transactionMessage:`Status: (${JSON.stringify(_)})`}):new Error(`Raw transaction ${a} failed (${JSON.stringify(_)})`);return a}const Mn=Object.freeze(Object.defineProperty({__proto__:null,Account:U0,AddressLookupTableAccount:Li,AddressLookupTableInstruction:kg,AddressLookupTableProgram:$i,Authorized:Ia,BLOCKHASH_CACHE_TIMEOUT_MS:na,BPF_LOADER_DEPRECATED_PROGRAM_ID:D0,BPF_LOADER_PROGRAM_ID:Q0,BpfLoader:ep,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:Kt,ComputeBudgetInstruction:Tg,ComputeBudgetProgram:Hi,Connection:Og,Ed25519Program:Ln,Enum:M0,EpochSchedule:ea,FeeCalculatorLayout:Zo,Keypair:Mr,LAMPORTS_PER_SOL:1e9,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:Xt,Loader:yr,Lockup:tn,MAX_SEED_LENGTH:qo,Message:Lt,MessageAccountKeys:Xr,MessageV0:gr,NONCE_ACCOUNT_LENGTH:Ni,NonceAccount:kn,PACKET_DATA_SIZE:nr,PUBLIC_KEY_LENGTH:Dt,PublicKey:ie,SIGNATURE_LENGTH_IN_BYTES:Zr,SOLANA_SCHEMA:jr,STAKE_CONFIG_ID:Aa,STAKE_INSTRUCTION_LAYOUTS:yt,SYSTEM_INSTRUCTION_LAYOUTS:Pe,SYSVAR_CLOCK_PUBKEY:zt,SYSVAR_EPOCH_SCHEDULE_PUBKEY:q0,SYSVAR_INSTRUCTIONS_PUBKEY:V0,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:vn,SYSVAR_RENT_PUBKEY:Br,SYSVAR_REWARDS_PUBKEY:G0,SYSVAR_SLOT_HASHES_PUBKEY:Y0,SYSVAR_SLOT_HISTORY_PUBKEY:j0,SYSVAR_STAKE_HISTORY_PUBKEY:On,Secp256k1Program:Pr,SendTransactionError:Jr,SolanaJSONRPCError:ue,SolanaJSONRPCErrorCode:Z0,StakeAuthorizationLayout:Cg,StakeInstruction:Lg,StakeProgram:Cn,Struct:Si,SystemInstruction:X0,SystemProgram:mt,Transaction:Oe,TransactionExpiredBlockheightExceededError:Ai,TransactionExpiredNonceInvalidError:xr,TransactionExpiredTimeoutError:Ii,TransactionInstruction:Be,TransactionMessage:Oi,TransactionStatus:Zt,VALIDATOR_INFO_KEY:Oa,VERSION_PREFIX_MASK:An,VOTE_PROGRAM_ID:Dg,ValidatorInfo:Vi,VersionedMessage:vi,VersionedTransaction:ki,VoteAccount:Gi,VoteAuthorizationLayout:Pg,VoteInit:va,VoteInstruction:Mg,VoteProgram:Ur,clusterApiUrl:$g,sendAndConfirmRawTransaction:Hg,sendAndConfirmTransaction:Ti},Symbol.toStringTag,{value:"Module"})),ir=gt;var Yi={exports:{}},Na;function Wg(){return Na||(Na=1,function(n){var e=function(){var t=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",i={};function o(f,g){if(!i[f]){i[f]={};for(var _=0;_<f.length;_++)i[f][f.charAt(_)]=_}return i[f][g]}var a={compressToBase64:function(f){if(f==null)return"";var g=a._compress(f,6,function(_){return r.charAt(_)});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:a._decompress(f.length,32,function(g){return o(r,f.charAt(g))})},compressToUTF16:function(f){return f==null?"":a._compress(f,15,function(g){return t(g+32)})+" "},decompressFromUTF16:function(f){return f==null?"":f==""?null:a._decompress(f.length,16384,function(g){return f.charCodeAt(g)-32})},compressToUint8Array:function(f){for(var g=a.compress(f),_=new Uint8Array(g.length*2),b=0,x=g.length;b<x;b++){var T=g.charCodeAt(b);_[b*2]=T>>>8,_[b*2+1]=T%256}return _},decompressFromUint8Array:function(f){if(f==null)return a.decompress(f);for(var g=new Array(f.length/2),_=0,b=g.length;_<b;_++)g[_]=f[_*2]*256+f[_*2+1];var x=[];return g.forEach(function(T){x.push(t(T))}),a.decompress(x.join(""))},compressToEncodedURIComponent:function(f){return f==null?"":a._compress(f,6,function(g){return s.charAt(g)})},decompressFromEncodedURIComponent:function(f){return f==null?"":f==""?null:(f=f.replace(/ /g,"+"),a._decompress(f.length,32,function(g){return o(s,f.charAt(g))}))},compress:function(f){return a._compress(f,16,function(g){return t(g)})},_compress:function(f,g,_){if(f==null)return"";var b,x,T={},L={},k="",N="",M="",H=2,K=3,J=2,q=[],D=0,Z=0,j;for(j=0;j<f.length;j+=1)if(k=f.charAt(j),Object.prototype.hasOwnProperty.call(T,k)||(T[k]=K++,L[k]=!0),N=M+k,Object.prototype.hasOwnProperty.call(T,N))M=N;else{if(Object.prototype.hasOwnProperty.call(L,M)){if(M.charCodeAt(0)<256){for(b=0;b<J;b++)D=D<<1,Z==g-1?(Z=0,q.push(_(D)),D=0):Z++;for(x=M.charCodeAt(0),b=0;b<8;b++)D=D<<1|x&1,Z==g-1?(Z=0,q.push(_(D)),D=0):Z++,x=x>>1}else{for(x=1,b=0;b<J;b++)D=D<<1|x,Z==g-1?(Z=0,q.push(_(D)),D=0):Z++,x=0;for(x=M.charCodeAt(0),b=0;b<16;b++)D=D<<1|x&1,Z==g-1?(Z=0,q.push(_(D)),D=0):Z++,x=x>>1}H--,H==0&&(H=Math.pow(2,J),J++),delete L[M]}else for(x=T[M],b=0;b<J;b++)D=D<<1|x&1,Z==g-1?(Z=0,q.push(_(D)),D=0):Z++,x=x>>1;H--,H==0&&(H=Math.pow(2,J),J++),T[N]=K++,M=String(k)}if(M!==""){if(Object.prototype.hasOwnProperty.call(L,M)){if(M.charCodeAt(0)<256){for(b=0;b<J;b++)D=D<<1,Z==g-1?(Z=0,q.push(_(D)),D=0):Z++;for(x=M.charCodeAt(0),b=0;b<8;b++)D=D<<1|x&1,Z==g-1?(Z=0,q.push(_(D)),D=0):Z++,x=x>>1}else{for(x=1,b=0;b<J;b++)D=D<<1|x,Z==g-1?(Z=0,q.push(_(D)),D=0):Z++,x=0;for(x=M.charCodeAt(0),b=0;b<16;b++)D=D<<1|x&1,Z==g-1?(Z=0,q.push(_(D)),D=0):Z++,x=x>>1}H--,H==0&&(H=Math.pow(2,J),J++),delete L[M]}else for(x=T[M],b=0;b<J;b++)D=D<<1|x&1,Z==g-1?(Z=0,q.push(_(D)),D=0):Z++,x=x>>1;H--,H==0&&(H=Math.pow(2,J),J++)}for(x=2,b=0;b<J;b++)D=D<<1|x&1,Z==g-1?(Z=0,q.push(_(D)),D=0):Z++,x=x>>1;for(;;)if(D=D<<1,Z==g-1){q.push(_(D));break}else Z++;return q.join("")},decompress:function(f){return f==null?"":f==""?null:a._decompress(f.length,32768,function(g){return f.charCodeAt(g)})},_decompress:function(f,g,_){var b=[],x=4,T=4,L=3,k="",N=[],M,H,K,J,q,D,Z,j={val:_(0),position:g,index:1};for(M=0;M<3;M+=1)b[M]=M;for(K=0,q=Math.pow(2,2),D=1;D!=q;)J=j.val&j.position,j.position>>=1,j.position==0&&(j.position=g,j.val=_(j.index++)),K|=(J>0?1:0)*D,D<<=1;switch(K){case 0:for(K=0,q=Math.pow(2,8),D=1;D!=q;)J=j.val&j.position,j.position>>=1,j.position==0&&(j.position=g,j.val=_(j.index++)),K|=(J>0?1:0)*D,D<<=1;Z=t(K);break;case 1:for(K=0,q=Math.pow(2,16),D=1;D!=q;)J=j.val&j.position,j.position>>=1,j.position==0&&(j.position=g,j.val=_(j.index++)),K|=(J>0?1:0)*D,D<<=1;Z=t(K);break;case 2:return""}for(b[3]=Z,H=Z,N.push(Z);;){if(j.index>f)return"";for(K=0,q=Math.pow(2,L),D=1;D!=q;)J=j.val&j.position,j.position>>=1,j.position==0&&(j.position=g,j.val=_(j.index++)),K|=(J>0?1:0)*D,D<<=1;switch(Z=K){case 0:for(K=0,q=Math.pow(2,8),D=1;D!=q;)J=j.val&j.position,j.position>>=1,j.position==0&&(j.position=g,j.val=_(j.index++)),K|=(J>0?1:0)*D,D<<=1;b[T++]=t(K),Z=T-1,x--;break;case 1:for(K=0,q=Math.pow(2,16),D=1;D!=q;)J=j.val&j.position,j.position>>=1,j.position==0&&(j.position=g,j.val=_(j.index++)),K|=(J>0?1:0)*D,D<<=1;b[T++]=t(K),Z=T-1,x--;break;case 2:return N.join("")}if(x==0&&(x=Math.pow(2,L),L++),b[Z])k=b[Z];else if(Z===T)k=H+H.charAt(0);else return null;N.push(k),b[T++]=H+k.charAt(0),x--,H=k,x==0&&(x=Math.pow(2,L),L++)}}};return a}();n!=null?n.exports=e:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return e})}(Yi)),Yi.exports}var qg=Wg();const Ht=zr(qg);var ji=(n=>(n.USD="USD",n.AED="AED",n.AFN="AFN",n.ALL="ALL",n.ANG="ANG",n.AOA="AOA",n.AUD="AUD",n.AWG="AWG",n.AZN="AZN",n.BAM="BAM",n.BBD="BBD",n.BDT="BDT",n.BGN="BGN",n.BHD="BHD",n.BIF="BIF",n.BND="BND",n.BOB="BOB",n.BRL="BRL",n.BTN="BTN",n.BWP="BWP",n.BZD="BZD",n.CAD="CAD",n.CHF="CHF",n.CLP="CLP",n.CNY="CNY",n.COP="COP",n.CRC="CRC",n.CVE="CVE",n.CZK="CZK",n.DJF="DJF",n.DKK="DKK",n.DOP="DOP",n.DZD="DZD",n.EGP="EGP",n.ETB="ETB",n.EUR="EUR",n.GBP="GBP",n.GEL="GEL",n.GHS="GHS",n.GMD="GMD",n.GNF="GNF",n.GTQ="GTQ",n.GYD="GYD",n.HKD="HKD",n.HNL="HNL",n.HTG="HTG",n.HUF="HUF",n.IDR="IDR",n.INR="INR",n.IQD="IQD",n.IRR="IRR",n.ISK="ISK",n.JMD="JMD",n.JOD="JOD",n.JPY="JPY",n.KES="KES",n.KGS="KGS",n.KHR="KHR",n.KMF="KMF",n.KRW="KRW",n.KWD="KWD",n.KYD="KYD",n.KZT="KZT",n.LKR="LKR",n.LRD="LRD",n.LSL="LSL",n.LYD="LYD",n.MAD="MAD",n.MDL="MDL",n.MGA="MGA",n.MKD="MKD",n.MMK="MMK",n.MNT="MNT",n.MOP="MOP",n.MRU="MRU",n.MUR="MUR",n.MVR="MVR",n.MXN="MXN",n.MYR="MYR",n.NAD="NAD",n.NGN="NGN",n.NIO="NIO",n.NOK="NOK",n.NPR="NPR",n.NZD="NZD",n.OMR="OMR",n.PAB="PAB",n.PEN="PEN",n.PHP="PHP",n.PKR="PKR",n.PLN="PLN",n.PYG="PYG",n.QAR="QAR",n.RON="RON",n.RSD="RSD",n.RWF="RWF",n.SAR="SAR",n.SCR="SCR",n.SDG="SDG",n.SEK="SEK",n.SGD="SGD",n.SLE="SLE",n.SLL="SLL",n.SOS="SOS",n.STN="STN",n.SVC="SVC",n.SYP="SYP",n.SZL="SZL",n.THB="THB",n.TJS="TJS",n.TMT="TMT",n.TND="TND",n.TRY="TRY",n.TTD="TTD",n.TWD="TWD",n.TZS="TZS",n.UAH="UAH",n.UGX="UGX",n.UYU="UYU",n.UZS="UZS",n.VND="VND",n.XAF="XAF",n.XCD="XCD",n.XOF="XOF",n.XPF="XPF",n.YER="YER",n.ZAR="ZAR",n.ZMW="ZMW",n))(ji||{});const Vg={AED:"784",AFN:"971",ALL:"008",ANG:"532",AOA:"973",AUD:"036",AWG:"533",AZN:"944",BAM:"977",BBD:"052",BDT:"050",BGN:"975",BHD:"048",BIF:"108",BND:"096",BOB:"068",BRL:"986",BTN:"064",BWP:"072",BZD:"084",CAD:"124",CHF:"756",CLP:"152",CNY:"156",COP:"170",CRC:"188",CVE:"132",CZK:"203",DJF:"262",DKK:"208",DOP:"214",DZD:"012",EGP:"818",ETB:"230",EUR:"978",GBP:"826",GEL:"981",GHS:"936",GMD:"270",GNF:"324",GTQ:"320",GYD:"328",HKD:"344",HNL:"340",HTG:"332",HUF:"348",IDR:"360",INR:"356",IQD:"368",IRR:"364",ISK:"352",JMD:"388",JOD:"400",JPY:"392",KES:"404",KGS:"417",KHR:"116",KMF:"174",KRW:"410",KWD:"414",KYD:"136",KZT:"398",LKR:"144",LRD:"430",LSL:"426",LYD:"434",MAD:"504",MDL:"498",MGA:"969",MKD:"807",MMK:"104",MNT:"496",MOP:"446",MRU:"929",MUR:"480",MVR:"462",MXN:"484",MYR:"458",NAD:"516",NGN:"566",NIO:"558",NOK:"578",NPR:"524",NZD:"554",OMR:"512",PAB:"590",PEN:"604",PHP:"608",PKR:"586",PLN:"985",PYG:"600",QAR:"634",RON:"946",RSD:"941",RWF:"646",SAR:"682",SCR:"690",SDG:"938",SEK:"752",SGD:"702",SLE:"925",SLL:"694",SOS:"706",STN:"930",SVC:"222",SYP:"760",SZL:"748",THB:"764",TJS:"972",TMT:"934",TND:"788",TRY:"949",TTD:"780",TWD:"901",TZS:"834",UAH:"980",UGX:"800",USD:"840",UYU:"858",UZS:"860",VND:"704",XAF:"950",XCD:"951",XOF:"952",XPF:"953",YER:"886",ZAR:"710",ZMW:"967"},xa={USD:"USD",EUR:"EUR",GBP:"GBP",BRL:"BRL",CAD:"CAD"};function Gg(n){return n in xa}function Yg(n,e){return n.currency===e}class Wt{constructor(e){Ye(this,"env");Ye(this,"url");this.env=e??"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(e){return fetch(this.url+`/merchant/view/${e}`).then(t=>t.json()).then(t=>{var r;return((r=t.nSureSettings)==null?void 0:r.nSurePartnerId)||t.nSurePartnerId}).catch(t=>{console.error(t)})}static getCoinflowBaseUrl(e){return!e||e==="prod"?"https://coinflow.cash":e==="ngrok"?"https://coinflow.ngrok.app":e==="local"?"http://localhost:3000":`https://${e}.coinflow.cash`}static getCoinflowApiUrl(e){return!e||e==="prod"?"https://api.coinflow.cash":e==="local"?"http://localhost:5000":`https://api-${e}.coinflow.cash`}static getCoinflowUrl({walletPubkey:e,sessionKey:t,route:r,routePrefix:s,env:i,subtotal:o,presentment:a,transaction:f,blockchain:g="solana",webhookInfo:_,email:b,loaderBackground:x,handleHeightChangeId:T,bankAccountLinkRedirect:L,additionalWallets:k,chargebackProtectionData:N,merchantCss:M,color:H,rent:K,lockDefaultToken:J,tokens:q,planCode:D,disableApplePay:Z,disableGooglePay:j,customerInfo:X,settlementType:z,lockAmount:V,nativeSolToConvert:Q,theme:A,usePermit:c,transactionSigner:p,authOnly:m,deviceId:v,jwtToken:S,origins:I,threeDsChallengePreference:C,supportEmail:R,destinationAuthKey:u,allowedPaymentMethods:l}){var P;const w=s?`/${s}/${g}`:`/${g}`,E=new URL(w+r,Wt.getCoinflowBaseUrl(i));if(e&&E.searchParams.append("pubkey",e),t&&E.searchParams.append("sessionKey",t),f&&E.searchParams.append("transaction",f),o&&("cents"in o?(E.searchParams.append("cents",o.cents.toString()),"currency"in o?E.searchParams.append("currency",o.currency.toString()):E.searchParams.append("currency",ji.USD)):(E.searchParams.append("token",o.address.toString()),E.searchParams.append("amount",o.amount.toString()))),a&&E.searchParams.append("presentment",a),_&&E.searchParams.append("webhookInfo",Ht.compressToEncodedURIComponent(JSON.stringify(_))),A&&E.searchParams.append("theme",Ht.compressToEncodedURIComponent(JSON.stringify(A))),X&&E.searchParams.append("customerInfo",Ht.compressToEncodedURIComponent(JSON.stringify(X))),b&&E.searchParams.append("email",b),R&&E.searchParams.append("supportEmail",R),q&&E.searchParams.append("tokens",q.toString()),x&&E.searchParams.append("loaderBackground",x),T&&E.searchParams.append("useHeightChange",T.toString()),L&&E.searchParams.append("bankAccountLinkRedirect",L),k&&E.searchParams.append("additionalWallets",Ht.compressToEncodedURIComponent(JSON.stringify(k))),N&&E.searchParams.append("chargebackProtectionData",Ht.compressToEncodedURIComponent(JSON.stringify(N))),v)E.searchParams.append("deviceId",v);else if(typeof window<"u"){const G=(P=window==null?void 0:window.nSureSDK)==null?void 0:P.getDeviceId();G&&E.searchParams.append("deviceId",G)}return M&&E.searchParams.append("merchantCss",M),H&&E.searchParams.append("color",H),K&&E.searchParams.append("rent",K.lamports.toString()),Q&&E.searchParams.append("nativeSolToConvert",Q.lamports.toString()),J&&E.searchParams.append("lockDefaultToken","true"),D&&E.searchParams.append("planCode",D),Z&&E.searchParams.append("disableApplePay","true"),j&&E.searchParams.append("disableGooglePay","true"),z&&E.searchParams.append("settlementType",z),V&&E.searchParams.append("lockAmount","true"),c===!1&&E.searchParams.append("usePermit","false"),p&&E.searchParams.append("transactionSigner",p),m===!0&&E.searchParams.append("authOnly","true"),S&&E.searchParams.append("jwtToken",S),I&&E.searchParams.append("origins",Ht.compressToEncodedURIComponent(JSON.stringify(I))),l&&E.searchParams.append("allowedPaymentMethods",l.join(",")),C&&E.searchParams.append("threeDsChallengePreference",C),u&&E.searchParams.append("destinationAuthKey",u),E.toString()}static getTransaction(e){if(e.blockchain)return this.byBlockchain(e.blockchain,{solana:()=>{if(!("transaction"in e))return;const{transaction:t}=e;if(!Mn)throw new Error("@solana/web3.js dependency is required for Solana");if(!ir)throw new Error("bs58 dependency is required for Solana");if(t)return ir.encode(t.serialize({requireAllSignatures:!1,verifySignatures:!1}))},polygon:()=>{if(!("transaction"in e))return;const{transaction:t}=e;return Ht.compressToEncodedURIComponent(JSON.stringify(t))},eth:()=>{if(!("transaction"in e))return;const{transaction:t}=e;return Ht.compressToEncodedURIComponent(JSON.stringify(t))},base:()=>{if(!("transaction"in e))return;const{transaction:t}=e;return Ht.compressToEncodedURIComponent(JSON.stringify(t))},arbitrum:()=>{if(!("transaction"in e))return;const{transaction:t}=e;return Ht.compressToEncodedURIComponent(JSON.stringify(t))},user:()=>{}})()}static byBlockchain(e,t){switch(e){case"solana":return t.solana;case"polygon":return t.polygon;case"eth":return t.eth;case"base":return t.base;case"arbitrum":return t.arbitrum;case"user":return t.user;default:throw new Error("blockchain not supported!")}}}function jg(n){if(!n)return;let e,t;if("name"in n&&n.name&&(e=n.name.split(" ")[0],t=n.name.split(" ").slice(1).join(" ")),"firstName"in n&&n.firstName&&(e=n.firstName),"lastName"in n&&n.lastName&&(t=n.lastName),e&&t)return{firstName:e,lastName:t}}var Zi=(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))(Zi||{});function Pn(n){let e;if("signer"in n&&typeof n.signer=="object"&&n.signer&&"wallet"in n.signer?e=n.signer.wallet:"wallet"in n&&n.wallet&&(e=n.wallet),!!e){if(typeof e=="string")return e;if(typeof e=="object"){if("publicKey"in e)return e.publicKey?e.publicKey.toString():void 0;if("address"in e)return e.address?e.address:void 0}return null}}function Ba(n,e,t){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 e.handleSignMessage?e.handleSignMessage(s):void 0;case"signTransaction":return e.handleSignTransaction?e.handleSignTransaction(s):void 0;case"sendTransaction":return e.handleSendTransaction(s);case"heightChange:"+t:return e.handleHeightChange?e.handleHeightChange(s):void 0;case"success":if(!e.onSuccess)return;e.onSuccess(r.info);return;case"authDeclined":if(!e.onAuthDeclined)return;e.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(Zi)}`)}function Un(n){let e,t;return"signer"in n&&typeof n.signer=="object"&&n.signer&&"blockchain"in n.signer&&"wallet"in n.signer?(e=n.signer.blockchain,t=n.signer.wallet):"blockchain"in n&&n.blockchain&&(e=n.blockchain,t=n.wallet),e?Wt.byBlockchain(e,{solana:()=>Zg({wallet:t,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),eth:()=>Dn({wallet:t,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),polygon:()=>Dn({wallet:t,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),base:()=>Dn({wallet:t,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),arbitrum:()=>Dn({wallet:t,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),user:()=>Xg(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 Zg({wallet:n,onSuccess:e,onAuthDeclined:t}){return{handleSendTransaction:async r=>{const s=La(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(!ir)throw new Error("bs58 dependency is required");return ir.encode(i)},handleSignTransaction:async r=>{const s=n.signTransaction;if(!s)throw new Error("signTransaction is not supported by this wallet");const i=La(r),o=await s(i);if(!ir)throw new Error("bs58 dependency is required");return ir.encode(o.serialize({requireAllSignatures:!1,verifySignatures:!1}))},onSuccess:e,onAuthDeclined:t}}function La(n){if(!Mn)throw new Error("@solana/web3.js is not defined. Please install @solana/web3.js into your project");if(!ir)throw new Error("bs58 is not defined. Please install bs58 into your project");const e=ir.decode(n),t=Mn.VersionedTransaction.deserialize(e);return t.version==="legacy"?Mn.Transaction.from(e):t}function Dn({wallet:n,onSuccess:e,onAuthDeclined:t}){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:e,onAuthDeclined:t}}function Xg({onSuccess:n,onAuthDeclined:e}){return{handleSendTransaction:async()=>Promise.resolve(""),onSuccess:n,onAuthDeclined:e}}const rn="tokenExCardNumber",Dr="tokenExCardCvv",Ca={[br.VISA]:"visa",[br.MASTERCARD]:"masterCard",[br.AMEX]:"americanExpress",[br.DISCOVER]:"discover"};async function Ma(n){const{token:e,origins:t,env:r}=n;return new Promise((s,i)=>{fetch(new Wt(r).url+"/api/checkout/v2/authentication-key",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({origins:t,token:e,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 Xi({env:n,setTokenExScriptLoaded:e}){const t="tokenex-script";document.head.querySelector(`#${t}`)&&e(!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=t,document.head.appendChild(r),document.getElementById(t).addEventListener("load",()=>{console.log("Setting tokenExScriptLoaded to true!"),e(!0)})}function Jg({iframe:n,setCachedToken:e,setLoaded:t}){const r=async()=>(n.tokenize(),await new Promise((s,i)=>{n.on("tokenize",o=>{e(o.token),s(o)}),n.on("validate",o=>{(!o.isValid||o.isCvvValid===!1)&&i(o)})}));return n.on("change",()=>e(void 0)),n.on("cvvChange",()=>e(void 0)),n.on("load",()=>{setTimeout(()=>t(!0),350);const s=document.querySelector("#tx_iframe_tokenExCardNumber");s&&(s.scrolling="no")}),n.on("focus",()=>{n.focus()}),n.on("cvvFocus",()=>{n.cvvFocus()}),t(!1),n.load(),{...n,tokenize:r}}async function Pa(n){const{token:e,cardType:t}=n;return await Ji(Dr,n,{cvvOnly:!0,cvv:!0,cvvContainerID:Dr,placeholder:"CVV",token:e,cardType:Ca[t]})}async function Ua(n){return await Ji(rn,n,{cvv:!0,cvvContainerID:Dr,cvvPlaceholder:"CVV"})}async function Da(n){return await Ji(rn,n,{cvv:!1})}async function Ji(n,e,t){const{tokenExScriptLoaded:r,css:s,debug:i,font:o,setCachedToken:a,setLoaded:f}=e;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 Ma({...e,token:t.token}),{styles:_}=Qg(s),b={...g,placeholder:"0000 0000 0000 0000",enablePrettyFormat:!0,styles:_,font:o,debug:i??!1,...t},x=TokenEx.Iframe(n,b);return Jg({iframe:x,setCachedToken:a,setLoaded:f})}function Qg(n){var r,s,i;const e=JSON.parse(n);return{styles:{base:sr(e.base),focus:sr(e.focus),error:sr(e.error),placeholder:sr(e.placeholder),cvv:{base:sr((r=e.cvv)==null?void 0:r.base),focus:sr((s=e.cvv)==null?void 0:s.focus),error:sr((i=e.cvv)==null?void 0:i.error),placeholder:sr(e==null?void 0:e.placeholder)}}}}function sr(n){if(!n)return"";if(typeof n=="string")return n;let e="";for(const[t,r]of Object.entries(n)){let s="";t.split("").forEach(i=>{i.toUpperCase()===i?s+="-"+i.toLowerCase():s+=i}),e+=s+":"+r+";"}return e}fe.nftCartItem=void 0,(n=>{(e=>{e.NFT="nft"})(n.itemClass||(n.itemClass={})),(e=>{e.IN_GAME_PRODUCT="inGameProduct",e.GAME_OF_SKILL="gameOfSkill",e.DATA_STORAGE="dataStorage",e.COMPUTING_RESOURCES="computingResources",e.SPORTS_TICKET="sportsTicket",e.E_SPORTS_TICKET="eSportsTicket",e.MUSIC_TICKET="musicTicket",e.CONFERENCE_TICKET="conferenceTicket",e.VIRTUAL_SPORTS_TICKET="virtualSportsTicket",e.VIRTUAL_ESPORTS_TICKET="virtualESportsTicket",e.VIRTUAL_MUSIC_TICKET="virtualMusicTicket",e.VIRTUAL_CONFERENCE_TICKET="virtualConferenceTicket",e.ALCOHOL="alcohol",e.DLC="DLC",e.SUBSCRIPTION="subscription",e.FUND_ACAUSE="fundACause",e.REAL_ESTATE="realEstate",e.COMPUTING_CONTRACT="computingContract",e.DIGITAL_ART="digitalArt",e.TOP_UP="topUp",e.OWNERSHIP_CONTRACT="ownershipContract",e.IN_GAME_CURRENCY="inGameCurrency",e.MONEY_TOP_UP_CART_ITEM="moneyTopUpCartItem"})(n.productType||(n.productType={}))})(fe.nftCartItem||(fe.nftCartItem={}));const e1=te.defineComponent({name:"CoinflowIFrame",props:{args:{type:Object,required:!0}},computed:{url(){return Wt.getCoinflowUrl(this.args)}},emits:{onMessage(n){return!0}},methods:{sendMessage(n){const e=this.$refs.iframeRef;if(!(e!=null&&e.contentWindow))throw new Error("Iframe not defined");e.contentWindow.postMessage(n,"*")},handleIframeMessages({data:n,origin:e}){if(!e.includes(Wt.getCoinflowBaseUrl(this.args.env)))return;this.$emit("onMessage",{data:n,origin:e});const t=Ba(n,this.args,this.args.handleHeightChangeId);t&&t.then(this.sendMessage).catch(r=>{console.error(r),this.sendMessage("ERROR "+r.message)})},async listenForMessage(n){let e;return new Promise((t,r)=>{if(e=({data:s,origin:i})=>{if(i.includes(Wt.getCoinflowBaseUrl(this.args.env))){if(s.startsWith("ERROR")){r(new Error(s.replace("ERROR","")));return}n(s)&&t(s)}},!window)throw new Error("Window not defined");window.addEventListener("message",e)}).finally(()=>{window.removeEventListener("message",e)})},async sendAndReceiveMessage(n,e){return this.sendMessage(n),this.listenForMessage(e)}},mounted(){if(!window)throw new Error("Window not defined");return window.addEventListener("message",this.handleIframeMessages),()=>{window.removeEventListener("message",this.handleIframeMessages)}}}),Qi=(n,e)=>{const t=n.__vccOpts||n;for(const[r,s]of e)t[r]=s;return t},t1=["src","scrolling"];function r1(n,e,t,r,s,i){return te.openBlock(),te.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:e[0]||(e[0]=()=>{const o=n.$refs.iframeRef;o&&(o.style.opacity="1")})},null,40,t1)}const Fn=Qi(e1,[["render",r1]]),n1=te.defineComponent({name:"CoinflowWithdraw",components:{CoinflowIFrame:Fn},props:{args:{type:Object,required:!0}},computed:{handleHeightChangeId(){return Math.random().toString(16).substring(2)},iframeProps(){const n=Pn(this.args);return{...this.args,walletPubkey:n,route:`/withdraw/${this.args.merchantId}`,transaction:void 0}},messageHandlers(){return{...Un(this.args),handleHeightChange:this.args.handleHeightChange}}}});function i1(n,e,t,r,s,i){const o=te.resolveComponent("coinflow-i-frame");return te.openBlock(),te.createBlock(o,{args:{...n.iframeProps,...n.messageHandlers,handleHeightChangeId:n.handleHeightChangeId}},null,8,["args"])}const s1=Qi(n1,[["render",i1]]),o1=te.defineComponent({name:"CoinflowPurchase",components:{CoinflowIFrame:Fn},props:{args:{type:Object,required:!0}},computed:{handleHeightChangeId(){return Math.random().toString(16).substring(2)},iframeProps(){const n=Pn(this.args);return{...this.args,walletPubkey:n,route:`/purchase-v2/${this.args.merchantId}`,transaction:Wt.getTransaction(this.args)}},messageHandlers(){return{...Un(this.args),handleHeightChange:this.args.handleHeightChange}}}});function a1(n,e,t,r,s,i){const o=te.resolveComponent("coinflow-i-frame");return te.openBlock(),te.createBlock(o,{args:{...n.iframeProps,...n.messageHandlers,handleHeightChangeId:n.handleHeightChangeId}},null,8,["args"])}const c1=Qi(o1,[["render",a1]]),es=n=>{const e=te.ref(!1),t=te.ref(!1),r=te.ref(void 0),s=te.ref(void 0);te.onMounted(()=>{Xi({env:n.env,setTokenExScriptLoaded:()=>{console.log("tokenExScriptLoaded.value = true"),t.value=!0}})});const i=b=>s.value=b,o=()=>e.value=!0,a=b=>r.value=b,f=async b=>{const x=await Pa({...n,...b,tokenExScriptLoaded:t.value,setCachedToken:i,setLoaded:o});return a(x),x},g=async b=>{const x=await Ua({...n,...b,tokenExScriptLoaded:t.value,setCachedToken:i,setLoaded:o});return a(x),x},_=async b=>{const x=await Da({...n,...b,tokenExScriptLoaded:t.value,setCachedToken:i,setLoaded:o});return a(x),x};return te.watchEffect(b=>{r.value&&(r.value.load(),b(()=>{var x;return(x=r.value)==null?void 0:x.remove()}))}),{tokenExIframe:r,initializeTokenExIframe:g,initializeCvvOnlyTokenExIframe:f,initializeTokenExCardOnlyIframe:_,loaded:e,cachedToken:s,setTokenExScriptTag:Xi,tokenExScriptLoaded:t}},u1=["id"],l1=te.defineComponent({__name:"CoinflowCardNumberInput",props:{args:{type:Object,required:!0}},setup(n,{expose:e}){const{initializeTokenExIframe:t,tokenExIframe:r}=es(n.args);async function s(){if(!r.value)throw new Error("Unable to get token");return r.value.tokenize()}e({getToken:s});function i(){return JSON.stringify(n.args.css)}return te.watchEffect(()=>{t({css:i(),debug:n.args.debug,origins:n.args.origins,font:n.args.font})},{}),(o,a)=>(te.openBlock(),te.createElementBlock("div",{id:te.unref(rn)},null,8,u1))}}),h1=["id"],f1=te.defineComponent({__name:"CoinflowCvvInput",setup(n){return(e,t)=>(te.openBlock(),te.createElementBlock("div",{id:te.unref(Dr)},null,8,h1))}}),d1=["id"],p1=te.defineComponent({__name:"CoinflowCvvOnlyInput",props:{args:{type:Object,required:!0}},setup(n,{expose:e}){const{initializeCvvOnlyTokenExIframe:t,tokenExIframe:r}=es(n.args);async function s(){if(!r.value)throw new Error("Unable to get token");return r.value.tokenize()}e({getToken:s});function i(){return JSON.stringify(n.args.css)}return te.watchEffect(()=>{t({...n.args,origins:n.args.origins??[],css:i(),font:n.args.font})},{}),(o,a)=>(te.openBlock(),te.createElementBlock("div",{id:te.unref(Dr)},null,8,d1))}}),g1=te.defineComponent({__name:"CoinflowPurchaseProtection",props:{args:{type:Object,required:!0}},setup(n){const e=te.ref(void 0);te.onMounted(()=>new Wt(n.args.env).getNSurePartnerId(n.args.merchantId).then(s=>e.value=s));function t(){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 te.watchEffect(s=>{if(!e.value)return;const i=document.createElement("script");i.src=r(),document.head.appendChild(i);const o=`window.nSureAsyncInit = function(deviceId) {
18
18
  window.nSureSDK.init({
19
19
  appId: '${t()}',
20
20
  partnerId: '${e.value}',
21
21
  });
22
- };`,a=document.createElement("script");a.innerHTML=o,document.head.appendChild(a),s(()=>{document.head.removeChild(i),document.head.removeChild(a)})}),(s,i)=>null}}),wm=["id"],bm=te.defineComponent({__name:"CoinflowCardNumberOnlyInput",props:{args:{type:Object,required:!0}},setup(n,{expose:e}){const{tokenExIframe:t,initializeTokenExCardOnlyIframe:r}=es(n.args);async function s(){if(!t.value)throw new Error("Unable to get token");return t.value.tokenize()}e({getToken:s});function i(){return JSON.stringify(n.args.css)}return te.watchEffect(()=>{r({css:i(),debug:n.args.debug,origins:n.args.origins,font:n.args.font})},{}),(o,a)=>(te.openBlock(),te.createElementBlock("div",{id:te.unref(rn)},null,8,wm))}}),Rm={style:{position:"relative",height:"100%"}},Em={style:{position:"relative",zIndex:10,height:"100%"}},Fa=te.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:e}=n.args;function t(){const f=Pn(n.args);return{...n.args,walletPubkey:f,transaction:void 0,routePrefix:"form",route:`/${n.route}/${n.args.merchantId}`}}function r(){return{...Un(n.args),handleHeightChange:n.args.handleHeightChange}}const s=te.ref(.8),i=te.ref("flex"),o=Math.random().toString(16).substring(2);function a({data:f}){var g,_;try{const b=JSON.parse(f);if("method"in b&&b.method==="loaded"&&(s.value=1,setTimeout(()=>{i.value="none"},2e3)),"method"in b&&b.data.startsWith("ERROR"))return(_=(g=n.args)==null?void 0:g.onError)==null||_.call(g,b.info),!1;if(!("method"in b)||b.method!=="getToken")return}catch{return}e==null||e(f)}return(f,g)=>(te.openBlock(),te.createElementBlock("div",Rm,[te.createElementVNode("div",{style:te.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"})},[te.renderSlot(f.$slots,"default")],4),te.createElementVNode("div",Em,[te.createVNode(Fn,{onOnMessage:a,args:{...t(),...r(),handleHeightChangeId:te.unref(o)}},null,8,["args"])])]))}}),Sm={id:"svg-logo",viewBox:"0 0 35 15"},Am={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"},Im={stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},vm=["fill"],Om=te.defineComponent({__name:"ApplePayOverlay",props:{color:{type:String,required:!0}},setup(n){const e=n.color==="white"?"#000":"#FFF";return(t,r)=>(te.openBlock(),te.createElementBlock("svg",Sm,[(te.openBlock(),te.createElementBlock("svg",Am,[r[1]||(r[1]=te.createElementVNode("title",null,"Apple Logo",-1)),te.createElementVNode("g",Im,[te.createElementVNode("g",{fill:te.unref(e)},r[0]||(r[0]=[te.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,vm)])]))]))}}),km=te.defineComponent({__name:"CoinflowApplePayButton",props:{args:{type:Object,required:!0}},setup(n){return(e,t)=>(te.openBlock(),te.createBlock(Fa,{route:"apple-pay",args:n.args},{default:te.withCtx(()=>[te.createVNode(Om,{color:n.args.color},null,8,["color"])]),_:1},8,["args"]))}}),Tm={key:0,xmlns:"http://www.w3.org/2000/svg",width:"41",height:"17"},Nm={key:1,xmlns:"http://www.w3.org/2000/svg",width:"41",height:"17"},xm=te.defineComponent({__name:"GooglePayOverlay",props:{color:{type:String,required:!0}},setup(n){return(e,t)=>(te.openBlock(),te.createElementBlock(te.Fragment,null,[n.color==="white"?(te.openBlock(),te.createElementBlock("svg",Tm,t[0]||(t[0]=[te.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)]))):te.createCommentVNode("",!0),n.color==="black"?(te.openBlock(),te.createElementBlock("svg",Nm,t[1]||(t[1]=[te.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)]))):te.createCommentVNode("",!0)],64))}}),Bm=te.defineComponent({__name:"CoinflowGooglePayButton",props:{args:{type:Object,required:!0}},setup(n){return(e,t)=>(te.openBlock(),te.createBlock(Fa,{route:"google-pay",args:n.args,overlayDisplayOverride:"flex",alignItems:"center"},{default:te.withCtx(()=>[te.createVNode(xm,{color:n.args.color},null,8,["color"])]),_:1},8,["args"]))}});he.CARD_TYPE_MAPPING=Ca,he.CSSPropertiesToComponent=Jt,he.CardType=br,he.CoinflowApplePayButton=km,he.CoinflowCardNumberInput=dm,he.CoinflowCardNumberOnlyInput=bm,he.CoinflowCvvInput=gm,he.CoinflowCvvOnlyInput=ym,he.CoinflowGooglePayButton=Bm,he.CoinflowIframe=Fn,he.CoinflowPurchase=hm,he.CoinflowPurchaseProtection=_m,he.CoinflowUtils=Ht,he.CoinflowWithdraw=cm,he.Currency=ji,he.CurrencyToISO4217=Gg,he.IFrameMessageMethods=Zi,he.MerchantStyle=bs,he.PaymentMethods=Es,he.SettlementType=or,he.ThreeDsChallengePreference=Rs,he.TokenExCardNumberIframeId=rn,he.TokenExCvvContainerID=Dr,he.WithdrawCurrencies=xa,he.doInitializeCvvOnlyTokenExIframe=Pa,he.doInitializeTokenExCardOnlyIframe=Da,he.doInitializeTokenExIframe=Ua,he.getCustomerName=jg,he.getHandlers=Un,he.getIframeConfig=Ma,he.getWalletPubkey=Pn,he.handleIFrameMessage=Ba,he.isTypedCurrencyCents=Yg,he.isWithdrawCurrency=Vg,he.setTokenExScriptTag=Xi,Object.defineProperty(he,Symbol.toStringTag,{value:"Module"})});
22
+ };`,a=document.createElement("script");a.innerHTML=o,document.head.appendChild(a),s(()=>{document.head.removeChild(i),document.head.removeChild(a)})}),(s,i)=>null}}),m1=["id"],y1=te.defineComponent({__name:"CoinflowCardNumberOnlyInput",props:{args:{type:Object,required:!0}},setup(n,{expose:e}){const{tokenExIframe:t,initializeTokenExCardOnlyIframe:r}=es(n.args);async function s(){if(!t.value)throw new Error("Unable to get token");return t.value.tokenize()}e({getToken:s});function i(){return JSON.stringify(n.args.css)}return te.watchEffect(()=>{r({css:i(),debug:n.args.debug,origins:n.args.origins,font:n.args.font})},{}),(o,a)=>(te.openBlock(),te.createElementBlock("div",{id:te.unref(rn)},null,8,m1))}}),_1={style:{position:"relative",height:"100%"}},w1={style:{position:"relative",zIndex:10,height:"100%"}},Fa=te.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:e}=n.args;function t(){const f=Pn(n.args);return{...n.args,walletPubkey:f,transaction:void 0,routePrefix:"form",route:`/${n.route}/${n.args.merchantId}`}}function r(){return{...Un(n.args),handleHeightChange:n.args.handleHeightChange}}const s=te.ref(.8),i=te.ref("flex"),o=Math.random().toString(16).substring(2);function a({data:f}){var g,_;try{const b=JSON.parse(f);if("method"in b&&b.method==="loaded"&&(s.value=1,setTimeout(()=>{i.value="none"},2e3)),"method"in b&&b.data.startsWith("ERROR"))return(_=(g=n.args)==null?void 0:g.onError)==null||_.call(g,b.info),!1;if(!("method"in b)||b.method!=="getToken")return}catch{return}e==null||e(f)}return(f,g)=>(te.openBlock(),te.createElementBlock("div",_1,[te.createElementVNode("div",{style:te.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"})},[te.renderSlot(f.$slots,"default")],4),te.createElementVNode("div",w1,[te.createVNode(Fn,{onOnMessage:a,args:{...t(),...r(),handleHeightChangeId:te.unref(o)}},null,8,["args"])])]))}}),b1={id:"svg-logo",viewBox:"0 0 35 15"},R1={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"},E1={stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},S1=["fill"],A1=te.defineComponent({__name:"ApplePayOverlay",props:{color:{type:String,required:!0}},setup(n){const e=n.color==="white"?"#000":"#FFF";return(t,r)=>(te.openBlock(),te.createElementBlock("svg",b1,[(te.openBlock(),te.createElementBlock("svg",R1,[r[1]||(r[1]=te.createElementVNode("title",null,"Apple Logo",-1)),te.createElementVNode("g",E1,[te.createElementVNode("g",{fill:te.unref(e)},r[0]||(r[0]=[te.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,S1)])]))]))}}),I1=te.defineComponent({__name:"CoinflowApplePayButton",props:{args:{type:Object,required:!0}},setup(n){return(e,t)=>(te.openBlock(),te.createBlock(Fa,{route:"apple-pay",args:n.args},{default:te.withCtx(()=>[te.createVNode(A1,{color:n.args.color},null,8,["color"])]),_:1},8,["args"]))}}),v1={key:0,xmlns:"http://www.w3.org/2000/svg",width:"41",height:"17"},O1={key:1,xmlns:"http://www.w3.org/2000/svg",width:"41",height:"17"},k1=te.defineComponent({__name:"GooglePayOverlay",props:{color:{type:String,required:!0}},setup(n){return(e,t)=>(te.openBlock(),te.createElementBlock(te.Fragment,null,[n.color==="white"?(te.openBlock(),te.createElementBlock("svg",v1,t[0]||(t[0]=[te.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)]))):te.createCommentVNode("",!0),n.color==="black"?(te.openBlock(),te.createElementBlock("svg",O1,t[1]||(t[1]=[te.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)]))):te.createCommentVNode("",!0)],64))}}),T1=te.defineComponent({__name:"CoinflowGooglePayButton",props:{args:{type:Object,required:!0}},setup(n){return(e,t)=>(te.openBlock(),te.createBlock(Fa,{route:"google-pay",args:n.args,overlayDisplayOverride:"flex",alignItems:"center"},{default:te.withCtx(()=>[te.createVNode(k1,{color:n.args.color},null,8,["color"])]),_:1},8,["args"]))}});fe.CARD_TYPE_MAPPING=Ca,fe.CardType=br,fe.CoinflowApplePayButton=I1,fe.CoinflowCardNumberInput=l1,fe.CoinflowCardNumberOnlyInput=y1,fe.CoinflowCvvInput=f1,fe.CoinflowCvvOnlyInput=p1,fe.CoinflowGooglePayButton=T1,fe.CoinflowIframe=Fn,fe.CoinflowPurchase=c1,fe.CoinflowPurchaseProtection=g1,fe.CoinflowUtils=Wt,fe.CoinflowWithdraw=s1,fe.Currency=ji,fe.CurrencyToISO4217=Vg,fe.IFrameMessageMethods=Zi,fe.MerchantStyle=bs,fe.PaymentMethods=Es,fe.SettlementType=or,fe.ThreeDsChallengePreference=Rs,fe.TokenExCardNumberIframeId=rn,fe.TokenExCvvContainerID=Dr,fe.WithdrawCurrencies=xa,fe.doInitializeCvvOnlyTokenExIframe=Pa,fe.doInitializeTokenExCardOnlyIframe=Da,fe.doInitializeTokenExIframe=Ua,fe.getCustomerName=jg,fe.getHandlers=Un,fe.getIframeConfig=Ma,fe.getWalletPubkey=Pn,fe.handleIFrameMessage=Ba,fe.isTypedCurrencyCents=Yg,fe.isWithdrawCurrency=Gg,fe.setTokenExScriptTag=Xi,Object.defineProperty(fe,Symbol.toStringTag,{value:"Module"})});