@tribecloud/sdk 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/core.d.ts +19 -2
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +15218 -10
- package/dist/esm/types.d.ts +59 -1
- package/dist/iife/sdk.min.js +59 -20
- package/package.json +4 -1
package/dist/iife/sdk.min.js
CHANGED
|
@@ -1,47 +1,61 @@
|
|
|
1
|
-
class A{siteId;baseUrl;sessionId;pageStart;currentPath;tokenKey;anonIdKey;autoTrackingActive=!1;originalPushState=null;popstateHandler=null;visibilityHandler=null;constructor(T){if(this.siteId=T.siteId,this.baseUrl=T.baseUrl,this.sessionId=Math.random().toString(36).slice(2),this.pageStart=Date.now(),this.currentPath=location.pathname,this.tokenKey=`__tribe_${T.siteId}`,this.anonIdKey=`__tribe_anon_${T.siteId}`,T.autoTrack!==!1)this.startAutoTracking()}static init(T){return new A(T)}startAutoTracking(){if(this.autoTrackingActive)return;this.autoTrackingActive=!0,this.sendEvent("pageview"),this.visibilityHandler=()=>{if(document.visibilityState==="hidden")this.sendEvent("leave",{d:Date.now()-this.pageStart})},document.addEventListener("visibilitychange",this.visibilityHandler),this.originalPushState=history.pushState,history.pushState=(...T)=>{this.sendEvent("leave",{d:Date.now()-this.pageStart}),this.originalPushState.apply(history,T),this.pageStart=Date.now(),this.currentPath=location.pathname,this.sendEvent("pageview")},this.popstateHandler=()=>{this.sendEvent("leave",{d:Date.now()-this.pageStart}),this.pageStart=Date.now(),this.currentPath=location.pathname,this.sendEvent("pageview")},window.addEventListener("popstate",this.popstateHandler)}stopAutoTracking(){if(!this.autoTrackingActive)return;if(this.autoTrackingActive=!1,this.visibilityHandler)document.removeEventListener("visibilitychange",this.visibilityHandler),this.visibilityHandler=null;if(this.originalPushState)history.pushState=this.originalPushState,this.originalPushState=null;if(this.popstateHandler)window.removeEventListener("popstate",this.popstateHandler),this.popstateHandler=null}sendEvent(T,E={}){let U={s:this.siteId,t:T,p:this.currentPath,r:document.referrer||null,sid:this.sessionId,w:screen.width,...E};if(navigator.sendBeacon){let _=new Blob([JSON.stringify(U)],{type:"application/json"});navigator.sendBeacon(`${this.baseUrl}/collect`,_)}else fetch(`${this.baseUrl}/collect`,{method:"POST",body:JSON.stringify(U),keepalive:!0,headers:{"Content-Type":"application/json"}}).catch(()=>{})}async gql(T,E){let U=localStorage.getItem(this.tokenKey),_={"Content-Type":"application/json"};if(U)_.Authorization=`Bearer ${U}`;else _["X-Tribe-Anonymous-Id"]=this.getAnonymousId();let B=await(await fetch(`${this.baseUrl}/graphql`,{method:"POST",headers:_,body:JSON.stringify({query:T,variables:E})})).json();if(B.errors)throw Error(B.errors[0].message);return B.data}getAnonymousId(){let T=localStorage.getItem(this.anonIdKey);if(!T)T=crypto.randomUUID(),localStorage.setItem(this.anonIdKey,T);return T}async register(T,E){let U=await this.gql(`mutation($siteId: ID!, $email: String!, $password: String!) {
|
|
1
|
+
var F5=Object.create;var{getPrototypeOf:_5,defineProperty:K2,getOwnPropertyNames:HG,getOwnPropertyDescriptor:g5}=Object,jG=Object.prototype.hasOwnProperty;var R8=($,J,Q)=>{Q=$!=null?F5(_5($)):{};let G=J||!$||!$.__esModule?K2(Q,"default",{value:$,enumerable:!0}):Q;for(let Y of HG($))if(!jG.call(G,Y))K2(G,Y,{get:()=>$[Y],enumerable:!0});return G},zG=new WeakMap,m8=($)=>{var J=zG.get($),Q;if(J)return J;if(J=K2({},"__esModule",{value:!0}),$&&typeof $==="object"||typeof $==="function")HG($).map((G)=>!jG.call(J,G)&&K2(J,G,{get:()=>$[G],enumerable:!(Q=g5($,G))||Q.enumerable}));return zG.set($,J),J},c1=($,J)=>()=>(J||$((J={exports:{}}).exports,J),J.exports);var $J=($,J)=>{for(var Q in J)K2($,Q,{get:J[Q],enumerable:!0,configurable:!0,set:(G)=>J[Q]=()=>G})};var Y1=($,J)=>()=>($&&(J=$($=0)),J);var c2={};$J(c2,{transcode:()=>CZ,resolveObjectURL:()=>zZ,kStringMaxLength:()=>LG,kMaxLength:()=>q2,isUtf8:()=>HZ,isAscii:()=>jZ,default:()=>AZ,constants:()=>c5,btoa:()=>b5,atob:()=>m5,INSPECT_MAX_BYTES:()=>PG,File:()=>p5,Buffer:()=>S,Blob:()=>u5});function x5($){var J=$.length;if(J%4>0)throw Error("Invalid string. Length must be a multiple of 4");var Q=$.indexOf("=");if(Q===-1)Q=J;var G=Q===J?0:4-Q%4;return[Q,G]}function v5($,J){return($+J)*3/4-J}function h5($){var J,Q=x5($),G=Q[0],Y=Q[1],X=new Uint8Array(v5(G,Y)),M=0,I=Y>0?G-4:G,U;for(U=0;U<I;U+=4)J=L1[$.charCodeAt(U)]<<18|L1[$.charCodeAt(U+1)]<<12|L1[$.charCodeAt(U+2)]<<6|L1[$.charCodeAt(U+3)],X[M++]=J>>16&255,X[M++]=J>>8&255,X[M++]=J&255;if(Y===2)J=L1[$.charCodeAt(U)]<<2|L1[$.charCodeAt(U+1)]>>4,X[M++]=J&255;if(Y===1)J=L1[$.charCodeAt(U)]<<10|L1[$.charCodeAt(U+1)]<<4|L1[$.charCodeAt(U+2)]>>2,X[M++]=J>>8&255,X[M++]=J&255;return X}function y5($){return h1[$>>18&63]+h1[$>>12&63]+h1[$>>6&63]+h1[$&63]}function f5($,J,Q){var G,Y=[];for(var X=J;X<Q;X+=3)G=($[X]<<16&16711680)+($[X+1]<<8&65280)+($[X+2]&255),Y.push(y5(G));return Y.join("")}function AG($){var J,Q=$.length,G=Q%3,Y=[],X=16383;for(var M=0,I=Q-G;M<I;M+=X)Y.push(f5($,M,M+X>I?I:M+X));if(G===1)J=$[Q-1],Y.push(h1[J>>2]+h1[J<<4&63]+"==");else if(G===2)J=($[Q-2]<<8)+$[Q-1],Y.push(h1[J>>10]+h1[J>>4&63]+h1[J<<2&63]+"=");return Y.join("")}function p2($,J,Q,G,Y){var X,M,I=Y*8-G-1,U=(1<<I)-1,T=U>>1,A=-7,L=Q?Y-1:0,N=Q?-1:1,k=$[J+L];L+=N,X=k&(1<<-A)-1,k>>=-A,A+=I;for(;A>0;X=X*256+$[J+L],L+=N,A-=8);M=X&(1<<-A)-1,X>>=-A,A+=G;for(;A>0;M=M*256+$[J+L],L+=N,A-=8);if(X===0)X=1-T;else if(X===U)return M?NaN:(k?-1:1)*(1/0);else M=M+Math.pow(2,G),X=X-T;return(k?-1:1)*M*Math.pow(2,X-G)}function kG($,J,Q,G,Y,X){var M,I,U,T=X*8-Y-1,A=(1<<T)-1,L=A>>1,N=Y===23?Math.pow(2,-24)-Math.pow(2,-77):0,k=G?0:X-1,P=G?1:-1,F=J<0||J===0&&1/J<0?1:0;if(J=Math.abs(J),isNaN(J)||J===1/0)I=isNaN(J)?1:0,M=A;else{if(M=Math.floor(Math.log(J)/Math.LN2),J*(U=Math.pow(2,-M))<1)M--,U*=2;if(M+L>=1)J+=N/U;else J+=N*Math.pow(2,1-L);if(J*U>=2)M++,U/=2;if(M+L>=A)I=0,M=A;else if(M+L>=1)I=(J*U-1)*Math.pow(2,Y),M=M+L;else I=J*Math.pow(2,L-1)*Math.pow(2,Y),M=0}for(;Y>=8;$[Q+k]=I&255,k+=P,I/=256,Y-=8);M=M<<Y|I,T+=Y;for(;T>0;$[Q+k]=M&255,k+=P,M/=256,T-=8);$[Q+k-P]|=F*128}function l1($){if($>q2)throw RangeError('The value "'+$+'" is invalid for option "size"');let J=new Uint8Array($);return Object.setPrototypeOf(J,S.prototype),J}function ZJ($,J,Q){return class extends Q{constructor(){super();Object.defineProperty(this,"message",{value:J.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${$}]`,this.stack,delete this.name}get code(){return $}set code(G){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:G,writable:!0})}toString(){return`${this.name} [${$}]: ${this.message}`}}}function S($,J,Q){if(typeof $==="number"){if(typeof J==="string")throw TypeError('The "string" argument must be of type string. Received type number');return MJ($)}return SG($,J,Q)}function SG($,J,Q){if(typeof $==="string")return i5($,J);if(ArrayBuffer.isView($))return r5($);if($==null)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof $);if(y1($,ArrayBuffer)||$&&y1($.buffer,ArrayBuffer))return YJ($,J,Q);if(typeof SharedArrayBuffer<"u"&&(y1($,SharedArrayBuffer)||$&&y1($.buffer,SharedArrayBuffer)))return YJ($,J,Q);if(typeof $==="number")throw TypeError('The "value" argument must not be of type number. Received type number');let G=$.valueOf&&$.valueOf();if(G!=null&&G!==$)return S.from(G,J,Q);let Y=o5($);if(Y)return Y;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof $[Symbol.toPrimitive]==="function")return S.from($[Symbol.toPrimitive]("string"),J,Q);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof $)}function EG($){if(typeof $!=="number")throw TypeError('"size" argument must be of type number');else if($<0)throw RangeError('The value "'+$+'" is invalid for option "size"')}function n5($,J,Q){if(EG($),$<=0)return l1($);if(J!==void 0)return typeof Q==="string"?l1($).fill(J,Q):l1($).fill(J);return l1($)}function MJ($){return EG($),l1($<0?0:KJ($)|0)}function i5($,J){if(typeof J!=="string"||J==="")J="utf8";if(!S.isEncoding(J))throw TypeError("Unknown encoding: "+J);let Q=BG($,J)|0,G=l1(Q),Y=G.write($,J);if(Y!==Q)G=G.slice(0,Y);return G}function GJ($){let J=$.length<0?0:KJ($.length)|0,Q=l1(J);for(let G=0;G<J;G+=1)Q[G]=$[G]&255;return Q}function r5($){if(y1($,Uint8Array)){let J=new Uint8Array($);return YJ(J.buffer,J.byteOffset,J.byteLength)}return GJ($)}function YJ($,J,Q){if(J<0||$.byteLength<J)throw RangeError('"offset" is outside of buffer bounds');if($.byteLength<J+(Q||0))throw RangeError('"length" is outside of buffer bounds');let G;if(J===void 0&&Q===void 0)G=new Uint8Array($);else if(Q===void 0)G=new Uint8Array($,J);else G=new Uint8Array($,J,Q);return Object.setPrototypeOf(G,S.prototype),G}function o5($){if(S.isBuffer($)){let J=KJ($.length)|0,Q=l1(J);if(Q.length===0)return Q;return $.copy(Q,0,0,J),Q}if($.length!==void 0){if(typeof $.length!=="number"||Number.isNaN($.length))return l1(0);return GJ($)}if($.type==="Buffer"&&Array.isArray($.data))return GJ($.data)}function KJ($){if($>=q2)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q2.toString(16)+" bytes");return $|0}function BG($,J){if(S.isBuffer($))return $.length;if(ArrayBuffer.isView($)||y1($,ArrayBuffer))return $.byteLength;if(typeof $!=="string")throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof $);let Q=$.length,G=arguments.length>2&&arguments[2]===!0;if(!G&&Q===0)return 0;let Y=!1;for(;;)switch(J){case"ascii":case"latin1":case"binary":return Q;case"utf8":case"utf-8":return XJ($).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Q*2;case"hex":return Q>>>1;case"base64":return fG($).length;default:if(Y)return G?-1:XJ($).length;J=(""+J).toLowerCase(),Y=!0}}function a5($,J,Q){let G=!1;if(J===void 0||J<0)J=0;if(J>this.length)return"";if(Q===void 0||Q>this.length)Q=this.length;if(Q<=0)return"";if(Q>>>=0,J>>>=0,Q<=J)return"";if(!$)$="utf8";while(!0)switch($){case"hex":return ZZ(this,J,Q);case"utf8":case"utf-8":return FG(this,J,Q);case"ascii":return YZ(this,J,Q);case"latin1":case"binary":return XZ(this,J,Q);case"base64":return QZ(this,J,Q);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return MZ(this,J,Q);default:if(G)throw TypeError("Unknown encoding: "+$);$=($+"").toLowerCase(),G=!0}}function N8($,J,Q){let G=$[J];$[J]=$[Q],$[Q]=G}function wG($,J,Q,G,Y){if($.length===0)return-1;if(typeof Q==="string")G=Q,Q=0;else if(Q>2147483647)Q=2147483647;else if(Q<-2147483648)Q=-2147483648;if(Q=+Q,Number.isNaN(Q))Q=Y?0:$.length-1;if(Q<0)Q=$.length+Q;if(Q>=$.length)if(Y)return-1;else Q=$.length-1;else if(Q<0)if(Y)Q=0;else return-1;if(typeof J==="string")J=S.from(J,G);if(S.isBuffer(J)){if(J.length===0)return-1;return RG($,J,Q,G,Y)}else if(typeof J==="number"){if(J=J&255,typeof Uint8Array.prototype.indexOf==="function")if(Y)return Uint8Array.prototype.indexOf.call($,J,Q);else return Uint8Array.prototype.lastIndexOf.call($,J,Q);return RG($,[J],Q,G,Y)}throw TypeError("val must be string, number or Buffer")}function RG($,J,Q,G,Y){let X=1,M=$.length,I=J.length;if(G!==void 0){if(G=String(G).toLowerCase(),G==="ucs2"||G==="ucs-2"||G==="utf16le"||G==="utf-16le"){if($.length<2||J.length<2)return-1;X=2,M/=2,I/=2,Q/=2}}function U(A,L){if(X===1)return A[L];else return A.readUInt16BE(L*X)}let T;if(Y){let A=-1;for(T=Q;T<M;T++)if(U($,T)===U(J,A===-1?0:T-A)){if(A===-1)A=T;if(T-A+1===I)return A*X}else{if(A!==-1)T-=T-A;A=-1}}else{if(Q+I>M)Q=M-I;for(T=Q;T>=0;T--){let A=!0;for(let L=0;L<I;L++)if(U($,T+L)!==U(J,L)){A=!1;break}if(A)return T}}return-1}function s5($,J,Q,G){Q=Number(Q)||0;let Y=$.length-Q;if(!G)G=Y;else if(G=Number(G),G>Y)G=Y;let X=J.length;if(G>X/2)G=X/2;let M;for(M=0;M<G;++M){let I=parseInt(J.substr(M*2,2),16);if(Number.isNaN(I))return M;$[Q+M]=I}return M}function t5($,J,Q,G){return u2(XJ(J,$.length-Q),$,Q,G)}function e5($,J,Q,G){return u2(UZ(J),$,Q,G)}function $Z($,J,Q,G){return u2(fG(J),$,Q,G)}function JZ($,J,Q,G){return u2(IZ(J,$.length-Q),$,Q,G)}function QZ($,J,Q){if(J===0&&Q===$.length)return AG($);else return AG($.slice(J,Q))}function FG($,J,Q){Q=Math.min($.length,Q);let G=[],Y=J;while(Y<Q){let X=$[Y],M=null,I=X>239?4:X>223?3:X>191?2:1;if(Y+I<=Q){let U,T,A,L;switch(I){case 1:if(X<128)M=X;break;case 2:if(U=$[Y+1],(U&192)===128){if(L=(X&31)<<6|U&63,L>127)M=L}break;case 3:if(U=$[Y+1],T=$[Y+2],(U&192)===128&&(T&192)===128){if(L=(X&15)<<12|(U&63)<<6|T&63,L>2047&&(L<55296||L>57343))M=L}break;case 4:if(U=$[Y+1],T=$[Y+2],A=$[Y+3],(U&192)===128&&(T&192)===128&&(A&192)===128){if(L=(X&15)<<18|(U&63)<<12|(T&63)<<6|A&63,L>65535&&L<1114112)M=L}}}if(M===null)M=65533,I=1;else if(M>65535)M-=65536,G.push(M>>>10&1023|55296),M=56320|M&1023;G.push(M),Y+=I}return GZ(G)}function GZ($){let J=$.length;if(J<=OG)return String.fromCharCode.apply(String,$);let Q="",G=0;while(G<J)Q+=String.fromCharCode.apply(String,$.slice(G,G+=OG));return Q}function YZ($,J,Q){let G="";Q=Math.min($.length,Q);for(let Y=J;Y<Q;++Y)G+=String.fromCharCode($[Y]&127);return G}function XZ($,J,Q){let G="";Q=Math.min($.length,Q);for(let Y=J;Y<Q;++Y)G+=String.fromCharCode($[Y]);return G}function ZZ($,J,Q){let G=$.length;if(!J||J<0)J=0;if(!Q||Q<0||Q>G)Q=G;let Y="";for(let X=J;X<Q;++X)Y+=DZ[$[X]];return Y}function MZ($,J,Q){let G=$.slice(J,Q),Y="";for(let X=0;X<G.length-1;X+=2)Y+=String.fromCharCode(G[X]+G[X+1]*256);return Y}function t0($,J,Q){if($%1!==0||$<0)throw RangeError("offset is not uint");if($+J>Q)throw RangeError("Trying to access beyond buffer length")}function A1($,J,Q,G,Y,X){if(!S.isBuffer($))throw TypeError('"buffer" argument must be a Buffer instance');if(J>Y||J<X)throw RangeError('"value" argument is out of bounds');if(Q+G>$.length)throw RangeError("Index out of range")}function _G($,J,Q,G,Y){yG(J,G,Y,$,Q,7);let X=Number(J&BigInt(4294967295));$[Q++]=X,X=X>>8,$[Q++]=X,X=X>>8,$[Q++]=X,X=X>>8,$[Q++]=X;let M=Number(J>>BigInt(32)&BigInt(4294967295));return $[Q++]=M,M=M>>8,$[Q++]=M,M=M>>8,$[Q++]=M,M=M>>8,$[Q++]=M,Q}function gG($,J,Q,G,Y){yG(J,G,Y,$,Q,7);let X=Number(J&BigInt(4294967295));$[Q+7]=X,X=X>>8,$[Q+6]=X,X=X>>8,$[Q+5]=X,X=X>>8,$[Q+4]=X;let M=Number(J>>BigInt(32)&BigInt(4294967295));return $[Q+3]=M,M=M>>8,$[Q+2]=M,M=M>>8,$[Q+1]=M,M=M>>8,$[Q]=M,Q+8}function xG($,J,Q,G,Y,X){if(Q+G>$.length)throw RangeError("Index out of range");if(Q<0)throw RangeError("Index out of range")}function vG($,J,Q,G,Y){if(J=+J,Q=Q>>>0,!Y)xG($,J,Q,4,340282346638528860000000000000000000000,-340282346638528860000000000000000000000);return kG($,J,Q,G,23,4),Q+4}function hG($,J,Q,G,Y){if(J=+J,Q=Q>>>0,!Y)xG($,J,Q,8,179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,-179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000);return kG($,J,Q,G,52,8),Q+8}function NG($){let J="",Q=$.length,G=$[0]==="-"?1:0;for(;Q>=G+4;Q-=3)J=`_${$.slice(Q-3,Q)}${J}`;return`${$.slice(0,Q)}${J}`}function KZ($,J,Q){if(p8(J,"offset"),$[J]===void 0||$[J+Q]===void 0)W2(J,$.length-(Q+1))}function yG($,J,Q,G,Y,X){if($>Q||$<J){let M=typeof J==="bigint"?"n":"",I;if(X>3)if(J===0||J===BigInt(0))I=`>= 0${M} and < 2${M} ** ${(X+1)*8}${M}`;else I=`>= -(2${M} ** ${(X+1)*8-1}${M}) and < 2 ** ${(X+1)*8-1}${M}`;else I=`>= ${J}${M} and <= ${Q}${M}`;throw new QJ("value",I,$)}KZ(G,Y,X)}function p8($,J){if(typeof $!=="number")throw new d5(J,"number",$)}function W2($,J,Q){if(Math.floor($)!==$)throw p8($,Q),new QJ(Q||"offset","an integer",$);if(J<0)throw new l5;throw new QJ(Q||"offset",`>= ${Q?1:0} and <= ${J}`,$)}function WZ($){if($=$.split("=")[0],$=$.trim().replace(qZ,""),$.length<2)return"";while($.length%4!==0)$=$+"=";return $}function XJ($,J){J=J||1/0;let Q,G=$.length,Y=null,X=[];for(let M=0;M<G;++M){if(Q=$.charCodeAt(M),Q>55295&&Q<57344){if(!Y){if(Q>56319){if((J-=3)>-1)X.push(239,191,189);continue}else if(M+1===G){if((J-=3)>-1)X.push(239,191,189);continue}Y=Q;continue}if(Q<56320){if((J-=3)>-1)X.push(239,191,189);Y=Q;continue}Q=(Y-55296<<10|Q-56320)+65536}else if(Y){if((J-=3)>-1)X.push(239,191,189)}if(Y=null,Q<128){if((J-=1)<0)break;X.push(Q)}else if(Q<2048){if((J-=2)<0)break;X.push(Q>>6|192,Q&63|128)}else if(Q<65536){if((J-=3)<0)break;X.push(Q>>12|224,Q>>6&63|128,Q&63|128)}else if(Q<1114112){if((J-=4)<0)break;X.push(Q>>18|240,Q>>12&63|128,Q>>6&63|128,Q&63|128)}else throw Error("Invalid code point")}return X}function UZ($){let J=[];for(let Q=0;Q<$.length;++Q)J.push($.charCodeAt(Q)&255);return J}function IZ($,J){let Q,G,Y,X=[];for(let M=0;M<$.length;++M){if((J-=2)<0)break;Q=$.charCodeAt(M),G=Q>>8,Y=Q%256,X.push(Y),X.push(G)}return X}function fG($){return h5(WZ($))}function u2($,J,Q,G){let Y;for(Y=0;Y<G;++Y){if(Y+Q>=J.length||Y>=$.length)break;J[Y+Q]=$[Y]}return Y}function y1($,J){return $ instanceof J||$!=null&&$.constructor!=null&&$.constructor.name!=null&&$.constructor.name===J.name}function X8($){return typeof BigInt>"u"?VZ:$}function VZ(){throw Error("BigInt not supported")}function qJ($){return()=>{throw Error($+" is not implemented for node:buffer browser polyfill")}}var h1,L1,JJ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",O8,CG,TG,PG=50,q2=2147483647,LG=536870888,b5,m5,p5,u5,c5,l5,d5,QJ,OG=4096,qZ,DZ,zZ,HZ,jZ=($)=>{for(let J of $)if(J.charCodeAt(0)>127)return!1;return!0},CZ,AZ;var u8=Y1(()=>{h1=[],L1=[];for(O8=0,CG=JJ.length;O8<CG;++O8)h1[O8]=JJ[O8],L1[JJ.charCodeAt(O8)]=O8;L1[45]=62;L1[95]=63;TG=typeof Symbol==="function"&&typeof Symbol.for==="function"?Symbol.for("nodejs.util.inspect.custom"):null,b5=globalThis.btoa,m5=globalThis.atob,p5=globalThis.File,u5=globalThis.Blob,c5={MAX_LENGTH:q2,MAX_STRING_LENGTH:LG};l5=ZJ("ERR_BUFFER_OUT_OF_BOUNDS",function($){if($)return`${$} is outside of buffer bounds`;return"Attempt to access memory outside buffer bounds"},RangeError),d5=ZJ("ERR_INVALID_ARG_TYPE",function($,J){return`The "${$}" argument must be of type number. Received type ${typeof J}`},TypeError),QJ=ZJ("ERR_OUT_OF_RANGE",function($,J,Q){let G=`The value of "${$}" is out of range.`,Y=Q;if(Number.isInteger(Q)&&Math.abs(Q)>4294967296)Y=NG(String(Q));else if(typeof Q==="bigint"){if(Y=String(Q),Q>BigInt(2)**BigInt(32)||Q<-(BigInt(2)**BigInt(32)))Y=NG(Y);Y+="n"}return G+=` It must be ${J}. Received ${Y}`,G},RangeError);Object.defineProperty(S.prototype,"parent",{enumerable:!0,get:function(){if(!S.isBuffer(this))return;return this.buffer}});Object.defineProperty(S.prototype,"offset",{enumerable:!0,get:function(){if(!S.isBuffer(this))return;return this.byteOffset}});S.poolSize=8192;S.from=function($,J,Q){return SG($,J,Q)};Object.setPrototypeOf(S.prototype,Uint8Array.prototype);Object.setPrototypeOf(S,Uint8Array);S.alloc=function($,J,Q){return n5($,J,Q)};S.allocUnsafe=function($){return MJ($)};S.allocUnsafeSlow=function($){return MJ($)};S.isBuffer=function($){return $!=null&&$._isBuffer===!0&&$!==S.prototype};S.compare=function($,J){if(y1($,Uint8Array))$=S.from($,$.offset,$.byteLength);if(y1(J,Uint8Array))J=S.from(J,J.offset,J.byteLength);if(!S.isBuffer($)||!S.isBuffer(J))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if($===J)return 0;let Q=$.length,G=J.length;for(let Y=0,X=Math.min(Q,G);Y<X;++Y)if($[Y]!==J[Y]){Q=$[Y],G=J[Y];break}if(Q<G)return-1;if(G<Q)return 1;return 0};S.isEncoding=function($){switch(String($).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}};S.concat=function($,J){if(!Array.isArray($))throw TypeError('"list" argument must be an Array of Buffers');if($.length===0)return S.alloc(0);let Q;if(J===void 0){J=0;for(Q=0;Q<$.length;++Q)J+=$[Q].length}let G=S.allocUnsafe(J),Y=0;for(Q=0;Q<$.length;++Q){let X=$[Q];if(y1(X,Uint8Array))if(Y+X.length>G.length){if(!S.isBuffer(X))X=S.from(X);X.copy(G,Y)}else Uint8Array.prototype.set.call(G,X,Y);else if(!S.isBuffer(X))throw TypeError('"list" argument must be an Array of Buffers');else X.copy(G,Y);Y+=X.length}return G};S.byteLength=BG;S.prototype._isBuffer=!0;S.prototype.swap16=function(){let $=this.length;if($%2!==0)throw RangeError("Buffer size must be a multiple of 16-bits");for(let J=0;J<$;J+=2)N8(this,J,J+1);return this};S.prototype.swap32=function(){let $=this.length;if($%4!==0)throw RangeError("Buffer size must be a multiple of 32-bits");for(let J=0;J<$;J+=4)N8(this,J,J+3),N8(this,J+1,J+2);return this};S.prototype.swap64=function(){let $=this.length;if($%8!==0)throw RangeError("Buffer size must be a multiple of 64-bits");for(let J=0;J<$;J+=8)N8(this,J,J+7),N8(this,J+1,J+6),N8(this,J+2,J+5),N8(this,J+3,J+4);return this};S.prototype.toString=function(){let $=this.length;if($===0)return"";if(arguments.length===0)return FG(this,0,$);return a5.apply(this,arguments)};S.prototype.toLocaleString=S.prototype.toString;S.prototype.equals=function($){if(!S.isBuffer($))throw TypeError("Argument must be a Buffer");if(this===$)return!0;return S.compare(this,$)===0};S.prototype.inspect=function(){let $="",J=PG;if($=this.toString("hex",0,J).replace(/(.{2})/g,"$1 ").trim(),this.length>J)$+=" ... ";return"<Buffer "+$+">"};if(TG)S.prototype[TG]=S.prototype.inspect;S.prototype.compare=function($,J,Q,G,Y){if(y1($,Uint8Array))$=S.from($,$.offset,$.byteLength);if(!S.isBuffer($))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof $);if(J===void 0)J=0;if(Q===void 0)Q=$?$.length:0;if(G===void 0)G=0;if(Y===void 0)Y=this.length;if(J<0||Q>$.length||G<0||Y>this.length)throw RangeError("out of range index");if(G>=Y&&J>=Q)return 0;if(G>=Y)return-1;if(J>=Q)return 1;if(J>>>=0,Q>>>=0,G>>>=0,Y>>>=0,this===$)return 0;let X=Y-G,M=Q-J,I=Math.min(X,M),U=this.slice(G,Y),T=$.slice(J,Q);for(let A=0;A<I;++A)if(U[A]!==T[A]){X=U[A],M=T[A];break}if(X<M)return-1;if(M<X)return 1;return 0};S.prototype.includes=function($,J,Q){return this.indexOf($,J,Q)!==-1};S.prototype.indexOf=function($,J,Q){return wG(this,$,J,Q,!0)};S.prototype.lastIndexOf=function($,J,Q){return wG(this,$,J,Q,!1)};S.prototype.write=function($,J,Q,G){if(J===void 0)G="utf8",Q=this.length,J=0;else if(Q===void 0&&typeof J==="string")G=J,Q=this.length,J=0;else if(isFinite(J))if(J=J>>>0,isFinite(Q)){if(Q=Q>>>0,G===void 0)G="utf8"}else G=Q,Q=void 0;else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let Y=this.length-J;if(Q===void 0||Q>Y)Q=Y;if($.length>0&&(Q<0||J<0)||J>this.length)throw RangeError("Attempt to write outside buffer bounds");if(!G)G="utf8";let X=!1;for(;;)switch(G){case"hex":return s5(this,$,J,Q);case"utf8":case"utf-8":return t5(this,$,J,Q);case"ascii":case"latin1":case"binary":return e5(this,$,J,Q);case"base64":return $Z(this,$,J,Q);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return JZ(this,$,J,Q);default:if(X)throw TypeError("Unknown encoding: "+G);G=(""+G).toLowerCase(),X=!0}};S.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};S.prototype.slice=function($,J){let Q=this.length;if($=~~$,J=J===void 0?Q:~~J,$<0){if($+=Q,$<0)$=0}else if($>Q)$=Q;if(J<0){if(J+=Q,J<0)J=0}else if(J>Q)J=Q;if(J<$)J=$;let G=this.subarray($,J);return Object.setPrototypeOf(G,S.prototype),G};S.prototype.readUintLE=S.prototype.readUIntLE=function($,J,Q){if($=$>>>0,J=J>>>0,!Q)t0($,J,this.length);let G=this[$],Y=1,X=0;while(++X<J&&(Y*=256))G+=this[$+X]*Y;return G};S.prototype.readUintBE=S.prototype.readUIntBE=function($,J,Q){if($=$>>>0,J=J>>>0,!Q)t0($,J,this.length);let G=this[$+--J],Y=1;while(J>0&&(Y*=256))G+=this[$+--J]*Y;return G};S.prototype.readUint8=S.prototype.readUInt8=function($,J){if($=$>>>0,!J)t0($,1,this.length);return this[$]};S.prototype.readUint16LE=S.prototype.readUInt16LE=function($,J){if($=$>>>0,!J)t0($,2,this.length);return this[$]|this[$+1]<<8};S.prototype.readUint16BE=S.prototype.readUInt16BE=function($,J){if($=$>>>0,!J)t0($,2,this.length);return this[$]<<8|this[$+1]};S.prototype.readUint32LE=S.prototype.readUInt32LE=function($,J){if($=$>>>0,!J)t0($,4,this.length);return(this[$]|this[$+1]<<8|this[$+2]<<16)+this[$+3]*16777216};S.prototype.readUint32BE=S.prototype.readUInt32BE=function($,J){if($=$>>>0,!J)t0($,4,this.length);return this[$]*16777216+(this[$+1]<<16|this[$+2]<<8|this[$+3])};S.prototype.readBigUInt64LE=X8(function($){$=$>>>0,p8($,"offset");let J=this[$],Q=this[$+7];if(J===void 0||Q===void 0)W2($,this.length-8);let G=J+this[++$]*256+this[++$]*65536+this[++$]*16777216,Y=this[++$]+this[++$]*256+this[++$]*65536+Q*16777216;return BigInt(G)+(BigInt(Y)<<BigInt(32))});S.prototype.readBigUInt64BE=X8(function($){$=$>>>0,p8($,"offset");let J=this[$],Q=this[$+7];if(J===void 0||Q===void 0)W2($,this.length-8);let G=J*16777216+this[++$]*65536+this[++$]*256+this[++$],Y=this[++$]*16777216+this[++$]*65536+this[++$]*256+Q;return(BigInt(G)<<BigInt(32))+BigInt(Y)});S.prototype.readIntLE=function($,J,Q){if($=$>>>0,J=J>>>0,!Q)t0($,J,this.length);let G=this[$],Y=1,X=0;while(++X<J&&(Y*=256))G+=this[$+X]*Y;if(Y*=128,G>=Y)G-=Math.pow(2,8*J);return G};S.prototype.readIntBE=function($,J,Q){if($=$>>>0,J=J>>>0,!Q)t0($,J,this.length);let G=J,Y=1,X=this[$+--G];while(G>0&&(Y*=256))X+=this[$+--G]*Y;if(Y*=128,X>=Y)X-=Math.pow(2,8*J);return X};S.prototype.readInt8=function($,J){if($=$>>>0,!J)t0($,1,this.length);if(!(this[$]&128))return this[$];return(255-this[$]+1)*-1};S.prototype.readInt16LE=function($,J){if($=$>>>0,!J)t0($,2,this.length);let Q=this[$]|this[$+1]<<8;return Q&32768?Q|4294901760:Q};S.prototype.readInt16BE=function($,J){if($=$>>>0,!J)t0($,2,this.length);let Q=this[$+1]|this[$]<<8;return Q&32768?Q|4294901760:Q};S.prototype.readInt32LE=function($,J){if($=$>>>0,!J)t0($,4,this.length);return this[$]|this[$+1]<<8|this[$+2]<<16|this[$+3]<<24};S.prototype.readInt32BE=function($,J){if($=$>>>0,!J)t0($,4,this.length);return this[$]<<24|this[$+1]<<16|this[$+2]<<8|this[$+3]};S.prototype.readBigInt64LE=X8(function($){$=$>>>0,p8($,"offset");let J=this[$],Q=this[$+7];if(J===void 0||Q===void 0)W2($,this.length-8);let G=this[$+4]+this[$+5]*256+this[$+6]*65536+(Q<<24);return(BigInt(G)<<BigInt(32))+BigInt(J+this[++$]*256+this[++$]*65536+this[++$]*16777216)});S.prototype.readBigInt64BE=X8(function($){$=$>>>0,p8($,"offset");let J=this[$],Q=this[$+7];if(J===void 0||Q===void 0)W2($,this.length-8);let G=(J<<24)+this[++$]*65536+this[++$]*256+this[++$];return(BigInt(G)<<BigInt(32))+BigInt(this[++$]*16777216+this[++$]*65536+this[++$]*256+Q)});S.prototype.readFloatLE=function($,J){if($=$>>>0,!J)t0($,4,this.length);return p2(this,$,!0,23,4)};S.prototype.readFloatBE=function($,J){if($=$>>>0,!J)t0($,4,this.length);return p2(this,$,!1,23,4)};S.prototype.readDoubleLE=function($,J){if($=$>>>0,!J)t0($,8,this.length);return p2(this,$,!0,52,8)};S.prototype.readDoubleBE=function($,J){if($=$>>>0,!J)t0($,8,this.length);return p2(this,$,!1,52,8)};S.prototype.writeUintLE=S.prototype.writeUIntLE=function($,J,Q,G){if($=+$,J=J>>>0,Q=Q>>>0,!G){let M=Math.pow(2,8*Q)-1;A1(this,$,J,Q,M,0)}let Y=1,X=0;this[J]=$&255;while(++X<Q&&(Y*=256))this[J+X]=$/Y&255;return J+Q};S.prototype.writeUintBE=S.prototype.writeUIntBE=function($,J,Q,G){if($=+$,J=J>>>0,Q=Q>>>0,!G){let M=Math.pow(2,8*Q)-1;A1(this,$,J,Q,M,0)}let Y=Q-1,X=1;this[J+Y]=$&255;while(--Y>=0&&(X*=256))this[J+Y]=$/X&255;return J+Q};S.prototype.writeUint8=S.prototype.writeUInt8=function($,J,Q){if($=+$,J=J>>>0,!Q)A1(this,$,J,1,255,0);return this[J]=$&255,J+1};S.prototype.writeUint16LE=S.prototype.writeUInt16LE=function($,J,Q){if($=+$,J=J>>>0,!Q)A1(this,$,J,2,65535,0);return this[J]=$&255,this[J+1]=$>>>8,J+2};S.prototype.writeUint16BE=S.prototype.writeUInt16BE=function($,J,Q){if($=+$,J=J>>>0,!Q)A1(this,$,J,2,65535,0);return this[J]=$>>>8,this[J+1]=$&255,J+2};S.prototype.writeUint32LE=S.prototype.writeUInt32LE=function($,J,Q){if($=+$,J=J>>>0,!Q)A1(this,$,J,4,4294967295,0);return this[J+3]=$>>>24,this[J+2]=$>>>16,this[J+1]=$>>>8,this[J]=$&255,J+4};S.prototype.writeUint32BE=S.prototype.writeUInt32BE=function($,J,Q){if($=+$,J=J>>>0,!Q)A1(this,$,J,4,4294967295,0);return this[J]=$>>>24,this[J+1]=$>>>16,this[J+2]=$>>>8,this[J+3]=$&255,J+4};S.prototype.writeBigUInt64LE=X8(function($,J=0){return _G(this,$,J,BigInt(0),BigInt("0xffffffffffffffff"))});S.prototype.writeBigUInt64BE=X8(function($,J=0){return gG(this,$,J,BigInt(0),BigInt("0xffffffffffffffff"))});S.prototype.writeIntLE=function($,J,Q,G){if($=+$,J=J>>>0,!G){let I=Math.pow(2,8*Q-1);A1(this,$,J,Q,I-1,-I)}let Y=0,X=1,M=0;this[J]=$&255;while(++Y<Q&&(X*=256)){if($<0&&M===0&&this[J+Y-1]!==0)M=1;this[J+Y]=($/X>>0)-M&255}return J+Q};S.prototype.writeIntBE=function($,J,Q,G){if($=+$,J=J>>>0,!G){let I=Math.pow(2,8*Q-1);A1(this,$,J,Q,I-1,-I)}let Y=Q-1,X=1,M=0;this[J+Y]=$&255;while(--Y>=0&&(X*=256)){if($<0&&M===0&&this[J+Y+1]!==0)M=1;this[J+Y]=($/X>>0)-M&255}return J+Q};S.prototype.writeInt8=function($,J,Q){if($=+$,J=J>>>0,!Q)A1(this,$,J,1,127,-128);if($<0)$=255+$+1;return this[J]=$&255,J+1};S.prototype.writeInt16LE=function($,J,Q){if($=+$,J=J>>>0,!Q)A1(this,$,J,2,32767,-32768);return this[J]=$&255,this[J+1]=$>>>8,J+2};S.prototype.writeInt16BE=function($,J,Q){if($=+$,J=J>>>0,!Q)A1(this,$,J,2,32767,-32768);return this[J]=$>>>8,this[J+1]=$&255,J+2};S.prototype.writeInt32LE=function($,J,Q){if($=+$,J=J>>>0,!Q)A1(this,$,J,4,2147483647,-2147483648);return this[J]=$&255,this[J+1]=$>>>8,this[J+2]=$>>>16,this[J+3]=$>>>24,J+4};S.prototype.writeInt32BE=function($,J,Q){if($=+$,J=J>>>0,!Q)A1(this,$,J,4,2147483647,-2147483648);if($<0)$=4294967295+$+1;return this[J]=$>>>24,this[J+1]=$>>>16,this[J+2]=$>>>8,this[J+3]=$&255,J+4};S.prototype.writeBigInt64LE=X8(function($,J=0){return _G(this,$,J,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});S.prototype.writeBigInt64BE=X8(function($,J=0){return gG(this,$,J,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});S.prototype.writeFloatLE=function($,J,Q){return vG(this,$,J,!0,Q)};S.prototype.writeFloatBE=function($,J,Q){return vG(this,$,J,!1,Q)};S.prototype.writeDoubleLE=function($,J,Q){return hG(this,$,J,!0,Q)};S.prototype.writeDoubleBE=function($,J,Q){return hG(this,$,J,!1,Q)};S.prototype.copy=function($,J,Q,G){if(!S.isBuffer($))throw TypeError("argument should be a Buffer");if(!Q)Q=0;if(!G&&G!==0)G=this.length;if(J>=$.length)J=$.length;if(!J)J=0;if(G>0&&G<Q)G=Q;if(G===Q)return 0;if($.length===0||this.length===0)return 0;if(J<0)throw RangeError("targetStart out of bounds");if(Q<0||Q>=this.length)throw RangeError("Index out of range");if(G<0)throw RangeError("sourceEnd out of bounds");if(G>this.length)G=this.length;if($.length-J<G-Q)G=$.length-J+Q;let Y=G-Q;if(this===$&&typeof Uint8Array.prototype.copyWithin==="function")this.copyWithin(J,Q,G);else Uint8Array.prototype.set.call($,this.subarray(Q,G),J);return Y};S.prototype.fill=function($,J,Q,G){if(typeof $==="string"){if(typeof J==="string")G=J,J=0,Q=this.length;else if(typeof Q==="string")G=Q,Q=this.length;if(G!==void 0&&typeof G!=="string")throw TypeError("encoding must be a string");if(typeof G==="string"&&!S.isEncoding(G))throw TypeError("Unknown encoding: "+G);if($.length===1){let X=$.charCodeAt(0);if(G==="utf8"&&X<128||G==="latin1")$=X}}else if(typeof $==="number")$=$&255;else if(typeof $==="boolean")$=Number($);if(J<0||this.length<J||this.length<Q)throw RangeError("Out of range index");if(Q<=J)return this;if(J=J>>>0,Q=Q===void 0?this.length:Q>>>0,!$)$=0;let Y;if(typeof $==="number")for(Y=J;Y<Q;++Y)this[Y]=$;else{let X=S.isBuffer($)?$:S.from($,G),M=X.length;if(M===0)throw TypeError('The value "'+$+'" is invalid for argument "value"');for(Y=0;Y<Q-J;++Y)this[Y+J]=X[Y%M]}return this};qZ=/[^+/0-9A-Za-z-_]/g;DZ=function(){let $=Array(256);for(let J=0;J<16;++J){let Q=J*16;for(let G=0;G<16;++G)$[Q+G]="0123456789abcdef"[J]+"0123456789abcdef"[G]}return $}();zZ=qJ("resolveObjectURL"),HZ=qJ("isUtf8"),CZ=qJ("transcode"),AZ=S});var vJ=c1((EY,xJ)=>{(function($,J){function Q(z,Z){if(!z)throw Error(Z||"Assertion failed")}function G(z,Z){z.super_=Z;var K=function(){};K.prototype=Z.prototype,z.prototype=new K,z.prototype.constructor=z}function Y(z,Z,K){if(Y.isBN(z))return z;if(this.negative=0,this.words=null,this.length=0,this.red=null,z!==null){if(Z==="le"||Z==="be")K=Z,Z=10;this._init(z||0,Z||10,K||"be")}}if(typeof $==="object")$.exports=Y;else J.BN=Y;Y.BN=Y,Y.wordSize=26;var X;try{if(typeof window<"u"&&typeof window.Buffer<"u")X=window.Buffer;else X=(u8(),m8(c2)).Buffer}catch(z){}Y.isBN=function(Z){if(Z instanceof Y)return!0;return Z!==null&&typeof Z==="object"&&Z.constructor.wordSize===Y.wordSize&&Array.isArray(Z.words)},Y.max=function(Z,K){if(Z.cmp(K)>0)return Z;return K},Y.min=function(Z,K){if(Z.cmp(K)<0)return Z;return K},Y.prototype._init=function(Z,K,W){if(typeof Z==="number")return this._initNumber(Z,K,W);if(typeof Z==="object")return this._initArray(Z,K,W);if(K==="hex")K=16;Q(K===(K|0)&&K>=2&&K<=36),Z=Z.toString().replace(/\s+/g,"");var D=0;if(Z[0]==="-")D++,this.negative=1;if(D<Z.length){if(K===16)this._parseHex(Z,D,W);else if(this._parseBase(Z,K,D),W==="le")this._initArray(this.toArray(),K,W)}},Y.prototype._initNumber=function(Z,K,W){if(Z<0)this.negative=1,Z=-Z;if(Z<67108864)this.words=[Z&67108863],this.length=1;else if(Z<4503599627370496)this.words=[Z&67108863,Z/67108864&67108863],this.length=2;else Q(Z<9007199254740992),this.words=[Z&67108863,Z/67108864&67108863,1],this.length=3;if(W!=="le")return;this._initArray(this.toArray(),K,W)},Y.prototype._initArray=function(Z,K,W){if(Q(typeof Z.length==="number"),Z.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(Z.length/3),this.words=Array(this.length);for(var D=0;D<this.length;D++)this.words[D]=0;var V,C,R=0;if(W==="be"){for(D=Z.length-1,V=0;D>=0;D-=3)if(C=Z[D]|Z[D-1]<<8|Z[D-2]<<16,this.words[V]|=C<<R&67108863,this.words[V+1]=C>>>26-R&67108863,R+=24,R>=26)R-=26,V++}else if(W==="le"){for(D=0,V=0;D<Z.length;D+=3)if(C=Z[D]|Z[D+1]<<8|Z[D+2]<<16,this.words[V]|=C<<R&67108863,this.words[V+1]=C>>>26-R&67108863,R+=24,R>=26)R-=26,V++}return this._strip()};function M(z,Z){var K=z.charCodeAt(Z);if(K>=48&&K<=57)return K-48;else if(K>=65&&K<=70)return K-55;else if(K>=97&&K<=102)return K-87;else Q(!1,"Invalid character in "+z)}function I(z,Z,K){var W=M(z,K);if(K-1>=Z)W|=M(z,K-1)<<4;return W}Y.prototype._parseHex=function(Z,K,W){this.length=Math.ceil((Z.length-K)/6),this.words=Array(this.length);for(var D=0;D<this.length;D++)this.words[D]=0;var V=0,C=0,R;if(W==="be")for(D=Z.length-1;D>=K;D-=2)if(R=I(Z,K,D)<<V,this.words[C]|=R&67108863,V>=18)V-=18,C+=1,this.words[C]|=R>>>26;else V+=8;else{var H=Z.length-K;for(D=H%2===0?K+1:K;D<Z.length;D+=2)if(R=I(Z,K,D)<<V,this.words[C]|=R&67108863,V>=18)V-=18,C+=1,this.words[C]|=R>>>26;else V+=8}this._strip()};function U(z,Z,K,W){var D=0,V=0,C=Math.min(z.length,K);for(var R=Z;R<C;R++){var H=z.charCodeAt(R)-48;if(D*=W,H>=49)V=H-49+10;else if(H>=17)V=H-17+10;else V=H;Q(H>=0&&V<W,"Invalid character"),D+=V}return D}Y.prototype._parseBase=function(Z,K,W){this.words=[0],this.length=1;for(var D=0,V=1;V<=67108863;V*=K)D++;D--,V=V/K|0;var C=Z.length-W,R=C%D,H=Math.min(C,C-R)+W,q=0;for(var j=W;j<H;j+=D)if(q=U(Z,j,j+D,K),this.imuln(V),this.words[0]+q<67108864)this.words[0]+=q;else this._iaddn(q);if(R!==0){var v=1;q=U(Z,j,Z.length,K);for(j=0;j<R;j++)v*=K;if(this.imuln(v),this.words[0]+q<67108864)this.words[0]+=q;else this._iaddn(q)}this._strip()},Y.prototype.copy=function(Z){Z.words=Array(this.length);for(var K=0;K<this.length;K++)Z.words[K]=this.words[K];Z.length=this.length,Z.negative=this.negative,Z.red=this.red};function T(z,Z){z.words=Z.words,z.length=Z.length,z.negative=Z.negative,z.red=Z.red}if(Y.prototype._move=function(Z){T(Z,this)},Y.prototype.clone=function(){var Z=new Y(null);return this.copy(Z),Z},Y.prototype._expand=function(Z){while(this.length<Z)this.words[this.length++]=0;return this},Y.prototype._strip=function(){while(this.length>1&&this.words[this.length-1]===0)this.length--;return this._normSign()},Y.prototype._normSign=function(){if(this.length===1&&this.words[0]===0)this.negative=0;return this},typeof Symbol<"u"&&typeof Symbol.for==="function")try{Y.prototype[Symbol.for("nodejs.util.inspect.custom")]=A}catch(z){Y.prototype.inspect=A}else Y.prototype.inspect=A;function A(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var L=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],N=[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],k=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64000000,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,24300000,28629151,33554432,39135393,45435424,52521875,60466176];if(Y.prototype.toString=function(Z,K){Z=Z||10,K=K|0||1;var W;if(Z===16||Z==="hex"){W="";var D=0,V=0;for(var C=0;C<this.length;C++){var R=this.words[C],H=((R<<D|V)&16777215).toString(16);if(V=R>>>24-D&16777215,D+=2,D>=26)D-=26,C--;if(V!==0||C!==this.length-1)W=L[6-H.length]+H+W;else W=H+W}if(V!==0)W=V.toString(16)+W;while(W.length%K!==0)W="0"+W;if(this.negative!==0)W="-"+W;return W}if(Z===(Z|0)&&Z>=2&&Z<=36){var q=N[Z],j=k[Z];W="";var v=this.clone();v.negative=0;while(!v.isZero()){var m=v.modrn(j).toString(Z);if(v=v.idivn(j),!v.isZero())W=L[q-m.length]+m+W;else W=m+W}if(this.isZero())W="0"+W;while(W.length%K!==0)W="0"+W;if(this.negative!==0)W="-"+W;return W}Q(!1,"Base should be between 2 and 36")},Y.prototype.toNumber=function(){var Z=this.words[0];if(this.length===2)Z+=this.words[1]*67108864;else if(this.length===3&&this.words[2]===1)Z+=4503599627370496+this.words[1]*67108864;else if(this.length>2)Q(!1,"Number can only safely store up to 53 bits");return this.negative!==0?-Z:Z},Y.prototype.toJSON=function(){return this.toString(16,2)},X)Y.prototype.toBuffer=function(Z,K){return this.toArrayLike(X,Z,K)};Y.prototype.toArray=function(Z,K){return this.toArrayLike(Array,Z,K)};var P=function(Z,K){if(Z.allocUnsafe)return Z.allocUnsafe(K);return new Z(K)};if(Y.prototype.toArrayLike=function(Z,K,W){this._strip();var D=this.byteLength(),V=W||Math.max(1,D);Q(D<=V,"byte array longer than desired length"),Q(V>0,"Requested array length <= 0");var C=P(Z,V),R=K==="le"?"LE":"BE";return this["_toArrayLike"+R](C,D),C},Y.prototype._toArrayLikeLE=function(Z,K){var W=0,D=0;for(var V=0,C=0;V<this.length;V++){var R=this.words[V]<<C|D;if(Z[W++]=R&255,W<Z.length)Z[W++]=R>>8&255;if(W<Z.length)Z[W++]=R>>16&255;if(C===6){if(W<Z.length)Z[W++]=R>>24&255;D=0,C=0}else D=R>>>24,C+=2}if(W<Z.length){Z[W++]=D;while(W<Z.length)Z[W++]=0}},Y.prototype._toArrayLikeBE=function(Z,K){var W=Z.length-1,D=0;for(var V=0,C=0;V<this.length;V++){var R=this.words[V]<<C|D;if(Z[W--]=R&255,W>=0)Z[W--]=R>>8&255;if(W>=0)Z[W--]=R>>16&255;if(C===6){if(W>=0)Z[W--]=R>>24&255;D=0,C=0}else D=R>>>24,C+=2}if(W>=0){Z[W--]=D;while(W>=0)Z[W--]=0}},Math.clz32)Y.prototype._countBits=function(Z){return 32-Math.clz32(Z)};else Y.prototype._countBits=function(Z){var K=Z,W=0;if(K>=4096)W+=13,K>>>=13;if(K>=64)W+=7,K>>>=7;if(K>=8)W+=4,K>>>=4;if(K>=2)W+=2,K>>>=2;return W+K};Y.prototype._zeroBits=function(Z){if(Z===0)return 26;var K=Z,W=0;if((K&8191)===0)W+=13,K>>>=13;if((K&127)===0)W+=7,K>>>=7;if((K&15)===0)W+=4,K>>>=4;if((K&3)===0)W+=2,K>>>=2;if((K&1)===0)W++;return W},Y.prototype.bitLength=function(){var Z=this.words[this.length-1],K=this._countBits(Z);return(this.length-1)*26+K};function F(z){var Z=Array(z.bitLength());for(var K=0;K<Z.length;K++){var W=K/26|0,D=K%26;Z[K]=z.words[W]>>>D&1}return Z}Y.prototype.zeroBits=function(){if(this.isZero())return 0;var Z=0;for(var K=0;K<this.length;K++){var W=this._zeroBits(this.words[K]);if(Z+=W,W!==26)break}return Z},Y.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},Y.prototype.toTwos=function(Z){if(this.negative!==0)return this.abs().inotn(Z).iaddn(1);return this.clone()},Y.prototype.fromTwos=function(Z){if(this.testn(Z-1))return this.notn(Z).iaddn(1).ineg();return this.clone()},Y.prototype.isNeg=function(){return this.negative!==0},Y.prototype.neg=function(){return this.clone().ineg()},Y.prototype.ineg=function(){if(!this.isZero())this.negative^=1;return this},Y.prototype.iuor=function(Z){while(this.length<Z.length)this.words[this.length++]=0;for(var K=0;K<Z.length;K++)this.words[K]=this.words[K]|Z.words[K];return this._strip()},Y.prototype.ior=function(Z){return Q((this.negative|Z.negative)===0),this.iuor(Z)},Y.prototype.or=function(Z){if(this.length>Z.length)return this.clone().ior(Z);return Z.clone().ior(this)},Y.prototype.uor=function(Z){if(this.length>Z.length)return this.clone().iuor(Z);return Z.clone().iuor(this)},Y.prototype.iuand=function(Z){var K;if(this.length>Z.length)K=Z;else K=this;for(var W=0;W<K.length;W++)this.words[W]=this.words[W]&Z.words[W];return this.length=K.length,this._strip()},Y.prototype.iand=function(Z){return Q((this.negative|Z.negative)===0),this.iuand(Z)},Y.prototype.and=function(Z){if(this.length>Z.length)return this.clone().iand(Z);return Z.clone().iand(this)},Y.prototype.uand=function(Z){if(this.length>Z.length)return this.clone().iuand(Z);return Z.clone().iuand(this)},Y.prototype.iuxor=function(Z){var K,W;if(this.length>Z.length)K=this,W=Z;else K=Z,W=this;for(var D=0;D<W.length;D++)this.words[D]=K.words[D]^W.words[D];if(this!==K)for(;D<K.length;D++)this.words[D]=K.words[D];return this.length=K.length,this._strip()},Y.prototype.ixor=function(Z){return Q((this.negative|Z.negative)===0),this.iuxor(Z)},Y.prototype.xor=function(Z){if(this.length>Z.length)return this.clone().ixor(Z);return Z.clone().ixor(this)},Y.prototype.uxor=function(Z){if(this.length>Z.length)return this.clone().iuxor(Z);return Z.clone().iuxor(this)},Y.prototype.inotn=function(Z){Q(typeof Z==="number"&&Z>=0);var K=Math.ceil(Z/26)|0,W=Z%26;if(this._expand(K),W>0)K--;for(var D=0;D<K;D++)this.words[D]=~this.words[D]&67108863;if(W>0)this.words[D]=~this.words[D]&67108863>>26-W;return this._strip()},Y.prototype.notn=function(Z){return this.clone().inotn(Z)},Y.prototype.setn=function(Z,K){Q(typeof Z==="number"&&Z>=0);var W=Z/26|0,D=Z%26;if(this._expand(W+1),K)this.words[W]=this.words[W]|1<<D;else this.words[W]=this.words[W]&~(1<<D);return this._strip()},Y.prototype.iadd=function(Z){var K;if(this.negative!==0&&Z.negative===0)return this.negative=0,K=this.isub(Z),this.negative^=1,this._normSign();else if(this.negative===0&&Z.negative!==0)return Z.negative=0,K=this.isub(Z),Z.negative=1,K._normSign();var W,D;if(this.length>Z.length)W=this,D=Z;else W=Z,D=this;var V=0;for(var C=0;C<D.length;C++)K=(W.words[C]|0)+(D.words[C]|0)+V,this.words[C]=K&67108863,V=K>>>26;for(;V!==0&&C<W.length;C++)K=(W.words[C]|0)+V,this.words[C]=K&67108863,V=K>>>26;if(this.length=W.length,V!==0)this.words[this.length]=V,this.length++;else if(W!==this)for(;C<W.length;C++)this.words[C]=W.words[C];return this},Y.prototype.add=function(Z){var K;if(Z.negative!==0&&this.negative===0)return Z.negative=0,K=this.sub(Z),Z.negative^=1,K;else if(Z.negative===0&&this.negative!==0)return this.negative=0,K=Z.sub(this),this.negative=1,K;if(this.length>Z.length)return this.clone().iadd(Z);return Z.clone().iadd(this)},Y.prototype.isub=function(Z){if(Z.negative!==0){Z.negative=0;var K=this.iadd(Z);return Z.negative=1,K._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(Z),this.negative=1,this._normSign();var W=this.cmp(Z);if(W===0)return this.negative=0,this.length=1,this.words[0]=0,this;var D,V;if(W>0)D=this,V=Z;else D=Z,V=this;var C=0;for(var R=0;R<V.length;R++)K=(D.words[R]|0)-(V.words[R]|0)+C,C=K>>26,this.words[R]=K&67108863;for(;C!==0&&R<D.length;R++)K=(D.words[R]|0)+C,C=K>>26,this.words[R]=K&67108863;if(C===0&&R<D.length&&D!==this)for(;R<D.length;R++)this.words[R]=D.words[R];if(this.length=Math.max(this.length,R),D!==this)this.negative=1;return this._strip()},Y.prototype.sub=function(Z){return this.clone().isub(Z)};function B(z,Z,K){K.negative=Z.negative^z.negative;var W=z.length+Z.length|0;K.length=W,W=W-1|0;var D=z.words[0]|0,V=Z.words[0]|0,C=D*V,R=C&67108863,H=C/67108864|0;K.words[0]=R;for(var q=1;q<W;q++){var j=H>>>26,v=H&67108863,m=Math.min(q,Z.length-1);for(var b=Math.max(0,q-z.length+1);b<=m;b++){var n=q-b|0;D=z.words[n]|0,V=Z.words[b]|0,C=D*V+v,j+=C/67108864|0,v=C&67108863}K.words[q]=v|0,H=j|0}if(H!==0)K.words[q]=H|0;else K.length--;return K._strip()}var _=function(Z,K,W){var D=Z.words,V=K.words,C=W.words,R=0,H,q,j,v=D[0]|0,m=v&8191,b=v>>>13,n=D[1]|0,a=n&8191,e=n>>>13,C1=D[2]|0,X0=C1&8191,q0=C1>>>13,M2=D[3]|0,j0=M2&8191,C0=M2>>>13,eQ=D[4]|0,A0=eQ&8191,T0=eQ>>>13,$G=D[5]|0,R0=$G&8191,O0=$G>>>13,JG=D[6]|0,N0=JG&8191,k0=JG>>>13,QG=D[7]|0,P0=QG&8191,L0=QG>>>13,GG=D[8]|0,S0=GG&8191,E0=GG>>>13,YG=D[9]|0,B0=YG&8191,w0=YG>>>13,XG=V[0]|0,F0=XG&8191,_0=XG>>>13,ZG=V[1]|0,g0=ZG&8191,x0=ZG>>>13,MG=V[2]|0,v0=MG&8191,h0=MG>>>13,KG=V[3]|0,y0=KG&8191,f0=KG>>>13,qG=V[4]|0,b0=qG&8191,m0=qG>>>13,WG=V[5]|0,p0=WG&8191,u0=WG>>>13,UG=V[6]|0,c0=UG&8191,l0=UG>>>13,IG=V[7]|0,d0=IG&8191,n0=IG>>>13,DG=V[8]|0,i0=DG&8191,r0=DG>>>13,VG=V[9]|0,o0=VG&8191,a0=VG>>>13;W.negative=Z.negative^K.negative,W.length=19,H=Math.imul(m,F0),q=Math.imul(m,_0),q=q+Math.imul(b,F0)|0,j=Math.imul(b,_0);var v$=(R+H|0)+((q&8191)<<13)|0;R=(j+(q>>>13)|0)+(v$>>>26)|0,v$&=67108863,H=Math.imul(a,F0),q=Math.imul(a,_0),q=q+Math.imul(e,F0)|0,j=Math.imul(e,_0),H=H+Math.imul(m,g0)|0,q=q+Math.imul(m,x0)|0,q=q+Math.imul(b,g0)|0,j=j+Math.imul(b,x0)|0;var h$=(R+H|0)+((q&8191)<<13)|0;R=(j+(q>>>13)|0)+(h$>>>26)|0,h$&=67108863,H=Math.imul(X0,F0),q=Math.imul(X0,_0),q=q+Math.imul(q0,F0)|0,j=Math.imul(q0,_0),H=H+Math.imul(a,g0)|0,q=q+Math.imul(a,x0)|0,q=q+Math.imul(e,g0)|0,j=j+Math.imul(e,x0)|0,H=H+Math.imul(m,v0)|0,q=q+Math.imul(m,h0)|0,q=q+Math.imul(b,v0)|0,j=j+Math.imul(b,h0)|0;var y$=(R+H|0)+((q&8191)<<13)|0;R=(j+(q>>>13)|0)+(y$>>>26)|0,y$&=67108863,H=Math.imul(j0,F0),q=Math.imul(j0,_0),q=q+Math.imul(C0,F0)|0,j=Math.imul(C0,_0),H=H+Math.imul(X0,g0)|0,q=q+Math.imul(X0,x0)|0,q=q+Math.imul(q0,g0)|0,j=j+Math.imul(q0,x0)|0,H=H+Math.imul(a,v0)|0,q=q+Math.imul(a,h0)|0,q=q+Math.imul(e,v0)|0,j=j+Math.imul(e,h0)|0,H=H+Math.imul(m,y0)|0,q=q+Math.imul(m,f0)|0,q=q+Math.imul(b,y0)|0,j=j+Math.imul(b,f0)|0;var f$=(R+H|0)+((q&8191)<<13)|0;R=(j+(q>>>13)|0)+(f$>>>26)|0,f$&=67108863,H=Math.imul(A0,F0),q=Math.imul(A0,_0),q=q+Math.imul(T0,F0)|0,j=Math.imul(T0,_0),H=H+Math.imul(j0,g0)|0,q=q+Math.imul(j0,x0)|0,q=q+Math.imul(C0,g0)|0,j=j+Math.imul(C0,x0)|0,H=H+Math.imul(X0,v0)|0,q=q+Math.imul(X0,h0)|0,q=q+Math.imul(q0,v0)|0,j=j+Math.imul(q0,h0)|0,H=H+Math.imul(a,y0)|0,q=q+Math.imul(a,f0)|0,q=q+Math.imul(e,y0)|0,j=j+Math.imul(e,f0)|0,H=H+Math.imul(m,b0)|0,q=q+Math.imul(m,m0)|0,q=q+Math.imul(b,b0)|0,j=j+Math.imul(b,m0)|0;var b$=(R+H|0)+((q&8191)<<13)|0;R=(j+(q>>>13)|0)+(b$>>>26)|0,b$&=67108863,H=Math.imul(R0,F0),q=Math.imul(R0,_0),q=q+Math.imul(O0,F0)|0,j=Math.imul(O0,_0),H=H+Math.imul(A0,g0)|0,q=q+Math.imul(A0,x0)|0,q=q+Math.imul(T0,g0)|0,j=j+Math.imul(T0,x0)|0,H=H+Math.imul(j0,v0)|0,q=q+Math.imul(j0,h0)|0,q=q+Math.imul(C0,v0)|0,j=j+Math.imul(C0,h0)|0,H=H+Math.imul(X0,y0)|0,q=q+Math.imul(X0,f0)|0,q=q+Math.imul(q0,y0)|0,j=j+Math.imul(q0,f0)|0,H=H+Math.imul(a,b0)|0,q=q+Math.imul(a,m0)|0,q=q+Math.imul(e,b0)|0,j=j+Math.imul(e,m0)|0,H=H+Math.imul(m,p0)|0,q=q+Math.imul(m,u0)|0,q=q+Math.imul(b,p0)|0,j=j+Math.imul(b,u0)|0;var m$=(R+H|0)+((q&8191)<<13)|0;R=(j+(q>>>13)|0)+(m$>>>26)|0,m$&=67108863,H=Math.imul(N0,F0),q=Math.imul(N0,_0),q=q+Math.imul(k0,F0)|0,j=Math.imul(k0,_0),H=H+Math.imul(R0,g0)|0,q=q+Math.imul(R0,x0)|0,q=q+Math.imul(O0,g0)|0,j=j+Math.imul(O0,x0)|0,H=H+Math.imul(A0,v0)|0,q=q+Math.imul(A0,h0)|0,q=q+Math.imul(T0,v0)|0,j=j+Math.imul(T0,h0)|0,H=H+Math.imul(j0,y0)|0,q=q+Math.imul(j0,f0)|0,q=q+Math.imul(C0,y0)|0,j=j+Math.imul(C0,f0)|0,H=H+Math.imul(X0,b0)|0,q=q+Math.imul(X0,m0)|0,q=q+Math.imul(q0,b0)|0,j=j+Math.imul(q0,m0)|0,H=H+Math.imul(a,p0)|0,q=q+Math.imul(a,u0)|0,q=q+Math.imul(e,p0)|0,j=j+Math.imul(e,u0)|0,H=H+Math.imul(m,c0)|0,q=q+Math.imul(m,l0)|0,q=q+Math.imul(b,c0)|0,j=j+Math.imul(b,l0)|0;var p$=(R+H|0)+((q&8191)<<13)|0;R=(j+(q>>>13)|0)+(p$>>>26)|0,p$&=67108863,H=Math.imul(P0,F0),q=Math.imul(P0,_0),q=q+Math.imul(L0,F0)|0,j=Math.imul(L0,_0),H=H+Math.imul(N0,g0)|0,q=q+Math.imul(N0,x0)|0,q=q+Math.imul(k0,g0)|0,j=j+Math.imul(k0,x0)|0,H=H+Math.imul(R0,v0)|0,q=q+Math.imul(R0,h0)|0,q=q+Math.imul(O0,v0)|0,j=j+Math.imul(O0,h0)|0,H=H+Math.imul(A0,y0)|0,q=q+Math.imul(A0,f0)|0,q=q+Math.imul(T0,y0)|0,j=j+Math.imul(T0,f0)|0,H=H+Math.imul(j0,b0)|0,q=q+Math.imul(j0,m0)|0,q=q+Math.imul(C0,b0)|0,j=j+Math.imul(C0,m0)|0,H=H+Math.imul(X0,p0)|0,q=q+Math.imul(X0,u0)|0,q=q+Math.imul(q0,p0)|0,j=j+Math.imul(q0,u0)|0,H=H+Math.imul(a,c0)|0,q=q+Math.imul(a,l0)|0,q=q+Math.imul(e,c0)|0,j=j+Math.imul(e,l0)|0,H=H+Math.imul(m,d0)|0,q=q+Math.imul(m,n0)|0,q=q+Math.imul(b,d0)|0,j=j+Math.imul(b,n0)|0;var u$=(R+H|0)+((q&8191)<<13)|0;R=(j+(q>>>13)|0)+(u$>>>26)|0,u$&=67108863,H=Math.imul(S0,F0),q=Math.imul(S0,_0),q=q+Math.imul(E0,F0)|0,j=Math.imul(E0,_0),H=H+Math.imul(P0,g0)|0,q=q+Math.imul(P0,x0)|0,q=q+Math.imul(L0,g0)|0,j=j+Math.imul(L0,x0)|0,H=H+Math.imul(N0,v0)|0,q=q+Math.imul(N0,h0)|0,q=q+Math.imul(k0,v0)|0,j=j+Math.imul(k0,h0)|0,H=H+Math.imul(R0,y0)|0,q=q+Math.imul(R0,f0)|0,q=q+Math.imul(O0,y0)|0,j=j+Math.imul(O0,f0)|0,H=H+Math.imul(A0,b0)|0,q=q+Math.imul(A0,m0)|0,q=q+Math.imul(T0,b0)|0,j=j+Math.imul(T0,m0)|0,H=H+Math.imul(j0,p0)|0,q=q+Math.imul(j0,u0)|0,q=q+Math.imul(C0,p0)|0,j=j+Math.imul(C0,u0)|0,H=H+Math.imul(X0,c0)|0,q=q+Math.imul(X0,l0)|0,q=q+Math.imul(q0,c0)|0,j=j+Math.imul(q0,l0)|0,H=H+Math.imul(a,d0)|0,q=q+Math.imul(a,n0)|0,q=q+Math.imul(e,d0)|0,j=j+Math.imul(e,n0)|0,H=H+Math.imul(m,i0)|0,q=q+Math.imul(m,r0)|0,q=q+Math.imul(b,i0)|0,j=j+Math.imul(b,r0)|0;var c$=(R+H|0)+((q&8191)<<13)|0;R=(j+(q>>>13)|0)+(c$>>>26)|0,c$&=67108863,H=Math.imul(B0,F0),q=Math.imul(B0,_0),q=q+Math.imul(w0,F0)|0,j=Math.imul(w0,_0),H=H+Math.imul(S0,g0)|0,q=q+Math.imul(S0,x0)|0,q=q+Math.imul(E0,g0)|0,j=j+Math.imul(E0,x0)|0,H=H+Math.imul(P0,v0)|0,q=q+Math.imul(P0,h0)|0,q=q+Math.imul(L0,v0)|0,j=j+Math.imul(L0,h0)|0,H=H+Math.imul(N0,y0)|0,q=q+Math.imul(N0,f0)|0,q=q+Math.imul(k0,y0)|0,j=j+Math.imul(k0,f0)|0,H=H+Math.imul(R0,b0)|0,q=q+Math.imul(R0,m0)|0,q=q+Math.imul(O0,b0)|0,j=j+Math.imul(O0,m0)|0,H=H+Math.imul(A0,p0)|0,q=q+Math.imul(A0,u0)|0,q=q+Math.imul(T0,p0)|0,j=j+Math.imul(T0,u0)|0,H=H+Math.imul(j0,c0)|0,q=q+Math.imul(j0,l0)|0,q=q+Math.imul(C0,c0)|0,j=j+Math.imul(C0,l0)|0,H=H+Math.imul(X0,d0)|0,q=q+Math.imul(X0,n0)|0,q=q+Math.imul(q0,d0)|0,j=j+Math.imul(q0,n0)|0,H=H+Math.imul(a,i0)|0,q=q+Math.imul(a,r0)|0,q=q+Math.imul(e,i0)|0,j=j+Math.imul(e,r0)|0,H=H+Math.imul(m,o0)|0,q=q+Math.imul(m,a0)|0,q=q+Math.imul(b,o0)|0,j=j+Math.imul(b,a0)|0;var l$=(R+H|0)+((q&8191)<<13)|0;R=(j+(q>>>13)|0)+(l$>>>26)|0,l$&=67108863,H=Math.imul(B0,g0),q=Math.imul(B0,x0),q=q+Math.imul(w0,g0)|0,j=Math.imul(w0,x0),H=H+Math.imul(S0,v0)|0,q=q+Math.imul(S0,h0)|0,q=q+Math.imul(E0,v0)|0,j=j+Math.imul(E0,h0)|0,H=H+Math.imul(P0,y0)|0,q=q+Math.imul(P0,f0)|0,q=q+Math.imul(L0,y0)|0,j=j+Math.imul(L0,f0)|0,H=H+Math.imul(N0,b0)|0,q=q+Math.imul(N0,m0)|0,q=q+Math.imul(k0,b0)|0,j=j+Math.imul(k0,m0)|0,H=H+Math.imul(R0,p0)|0,q=q+Math.imul(R0,u0)|0,q=q+Math.imul(O0,p0)|0,j=j+Math.imul(O0,u0)|0,H=H+Math.imul(A0,c0)|0,q=q+Math.imul(A0,l0)|0,q=q+Math.imul(T0,c0)|0,j=j+Math.imul(T0,l0)|0,H=H+Math.imul(j0,d0)|0,q=q+Math.imul(j0,n0)|0,q=q+Math.imul(C0,d0)|0,j=j+Math.imul(C0,n0)|0,H=H+Math.imul(X0,i0)|0,q=q+Math.imul(X0,r0)|0,q=q+Math.imul(q0,i0)|0,j=j+Math.imul(q0,r0)|0,H=H+Math.imul(a,o0)|0,q=q+Math.imul(a,a0)|0,q=q+Math.imul(e,o0)|0,j=j+Math.imul(e,a0)|0;var d$=(R+H|0)+((q&8191)<<13)|0;R=(j+(q>>>13)|0)+(d$>>>26)|0,d$&=67108863,H=Math.imul(B0,v0),q=Math.imul(B0,h0),q=q+Math.imul(w0,v0)|0,j=Math.imul(w0,h0),H=H+Math.imul(S0,y0)|0,q=q+Math.imul(S0,f0)|0,q=q+Math.imul(E0,y0)|0,j=j+Math.imul(E0,f0)|0,H=H+Math.imul(P0,b0)|0,q=q+Math.imul(P0,m0)|0,q=q+Math.imul(L0,b0)|0,j=j+Math.imul(L0,m0)|0,H=H+Math.imul(N0,p0)|0,q=q+Math.imul(N0,u0)|0,q=q+Math.imul(k0,p0)|0,j=j+Math.imul(k0,u0)|0,H=H+Math.imul(R0,c0)|0,q=q+Math.imul(R0,l0)|0,q=q+Math.imul(O0,c0)|0,j=j+Math.imul(O0,l0)|0,H=H+Math.imul(A0,d0)|0,q=q+Math.imul(A0,n0)|0,q=q+Math.imul(T0,d0)|0,j=j+Math.imul(T0,n0)|0,H=H+Math.imul(j0,i0)|0,q=q+Math.imul(j0,r0)|0,q=q+Math.imul(C0,i0)|0,j=j+Math.imul(C0,r0)|0,H=H+Math.imul(X0,o0)|0,q=q+Math.imul(X0,a0)|0,q=q+Math.imul(q0,o0)|0,j=j+Math.imul(q0,a0)|0;var n$=(R+H|0)+((q&8191)<<13)|0;R=(j+(q>>>13)|0)+(n$>>>26)|0,n$&=67108863,H=Math.imul(B0,y0),q=Math.imul(B0,f0),q=q+Math.imul(w0,y0)|0,j=Math.imul(w0,f0),H=H+Math.imul(S0,b0)|0,q=q+Math.imul(S0,m0)|0,q=q+Math.imul(E0,b0)|0,j=j+Math.imul(E0,m0)|0,H=H+Math.imul(P0,p0)|0,q=q+Math.imul(P0,u0)|0,q=q+Math.imul(L0,p0)|0,j=j+Math.imul(L0,u0)|0,H=H+Math.imul(N0,c0)|0,q=q+Math.imul(N0,l0)|0,q=q+Math.imul(k0,c0)|0,j=j+Math.imul(k0,l0)|0,H=H+Math.imul(R0,d0)|0,q=q+Math.imul(R0,n0)|0,q=q+Math.imul(O0,d0)|0,j=j+Math.imul(O0,n0)|0,H=H+Math.imul(A0,i0)|0,q=q+Math.imul(A0,r0)|0,q=q+Math.imul(T0,i0)|0,j=j+Math.imul(T0,r0)|0,H=H+Math.imul(j0,o0)|0,q=q+Math.imul(j0,a0)|0,q=q+Math.imul(C0,o0)|0,j=j+Math.imul(C0,a0)|0;var i$=(R+H|0)+((q&8191)<<13)|0;R=(j+(q>>>13)|0)+(i$>>>26)|0,i$&=67108863,H=Math.imul(B0,b0),q=Math.imul(B0,m0),q=q+Math.imul(w0,b0)|0,j=Math.imul(w0,m0),H=H+Math.imul(S0,p0)|0,q=q+Math.imul(S0,u0)|0,q=q+Math.imul(E0,p0)|0,j=j+Math.imul(E0,u0)|0,H=H+Math.imul(P0,c0)|0,q=q+Math.imul(P0,l0)|0,q=q+Math.imul(L0,c0)|0,j=j+Math.imul(L0,l0)|0,H=H+Math.imul(N0,d0)|0,q=q+Math.imul(N0,n0)|0,q=q+Math.imul(k0,d0)|0,j=j+Math.imul(k0,n0)|0,H=H+Math.imul(R0,i0)|0,q=q+Math.imul(R0,r0)|0,q=q+Math.imul(O0,i0)|0,j=j+Math.imul(O0,r0)|0,H=H+Math.imul(A0,o0)|0,q=q+Math.imul(A0,a0)|0,q=q+Math.imul(T0,o0)|0,j=j+Math.imul(T0,a0)|0;var r$=(R+H|0)+((q&8191)<<13)|0;R=(j+(q>>>13)|0)+(r$>>>26)|0,r$&=67108863,H=Math.imul(B0,p0),q=Math.imul(B0,u0),q=q+Math.imul(w0,p0)|0,j=Math.imul(w0,u0),H=H+Math.imul(S0,c0)|0,q=q+Math.imul(S0,l0)|0,q=q+Math.imul(E0,c0)|0,j=j+Math.imul(E0,l0)|0,H=H+Math.imul(P0,d0)|0,q=q+Math.imul(P0,n0)|0,q=q+Math.imul(L0,d0)|0,j=j+Math.imul(L0,n0)|0,H=H+Math.imul(N0,i0)|0,q=q+Math.imul(N0,r0)|0,q=q+Math.imul(k0,i0)|0,j=j+Math.imul(k0,r0)|0,H=H+Math.imul(R0,o0)|0,q=q+Math.imul(R0,a0)|0,q=q+Math.imul(O0,o0)|0,j=j+Math.imul(O0,a0)|0;var o$=(R+H|0)+((q&8191)<<13)|0;R=(j+(q>>>13)|0)+(o$>>>26)|0,o$&=67108863,H=Math.imul(B0,c0),q=Math.imul(B0,l0),q=q+Math.imul(w0,c0)|0,j=Math.imul(w0,l0),H=H+Math.imul(S0,d0)|0,q=q+Math.imul(S0,n0)|0,q=q+Math.imul(E0,d0)|0,j=j+Math.imul(E0,n0)|0,H=H+Math.imul(P0,i0)|0,q=q+Math.imul(P0,r0)|0,q=q+Math.imul(L0,i0)|0,j=j+Math.imul(L0,r0)|0,H=H+Math.imul(N0,o0)|0,q=q+Math.imul(N0,a0)|0,q=q+Math.imul(k0,o0)|0,j=j+Math.imul(k0,a0)|0;var a$=(R+H|0)+((q&8191)<<13)|0;R=(j+(q>>>13)|0)+(a$>>>26)|0,a$&=67108863,H=Math.imul(B0,d0),q=Math.imul(B0,n0),q=q+Math.imul(w0,d0)|0,j=Math.imul(w0,n0),H=H+Math.imul(S0,i0)|0,q=q+Math.imul(S0,r0)|0,q=q+Math.imul(E0,i0)|0,j=j+Math.imul(E0,r0)|0,H=H+Math.imul(P0,o0)|0,q=q+Math.imul(P0,a0)|0,q=q+Math.imul(L0,o0)|0,j=j+Math.imul(L0,a0)|0;var s$=(R+H|0)+((q&8191)<<13)|0;R=(j+(q>>>13)|0)+(s$>>>26)|0,s$&=67108863,H=Math.imul(B0,i0),q=Math.imul(B0,r0),q=q+Math.imul(w0,i0)|0,j=Math.imul(w0,r0),H=H+Math.imul(S0,o0)|0,q=q+Math.imul(S0,a0)|0,q=q+Math.imul(E0,o0)|0,j=j+Math.imul(E0,a0)|0;var t$=(R+H|0)+((q&8191)<<13)|0;R=(j+(q>>>13)|0)+(t$>>>26)|0,t$&=67108863,H=Math.imul(B0,o0),q=Math.imul(B0,a0),q=q+Math.imul(w0,o0)|0,j=Math.imul(w0,a0);var e$=(R+H|0)+((q&8191)<<13)|0;if(R=(j+(q>>>13)|0)+(e$>>>26)|0,e$&=67108863,C[0]=v$,C[1]=h$,C[2]=y$,C[3]=f$,C[4]=b$,C[5]=m$,C[6]=p$,C[7]=u$,C[8]=c$,C[9]=l$,C[10]=d$,C[11]=n$,C[12]=i$,C[13]=r$,C[14]=o$,C[15]=a$,C[16]=s$,C[17]=t$,C[18]=e$,R!==0)C[19]=R,W.length++;return W};if(!Math.imul)_=B;function h(z,Z,K){K.negative=Z.negative^z.negative,K.length=z.length+Z.length;var W=0,D=0;for(var V=0;V<K.length-1;V++){var C=D;D=0;var R=W&67108863,H=Math.min(V,Z.length-1);for(var q=Math.max(0,V-z.length+1);q<=H;q++){var j=V-q,v=z.words[j]|0,m=Z.words[q]|0,b=v*m,n=b&67108863;C=C+(b/67108864|0)|0,n=n+R|0,R=n&67108863,C=C+(n>>>26)|0,D+=C>>>26,C&=67108863}K.words[V]=R,W=C,C=D}if(W!==0)K.words[V]=W;else K.length--;return K._strip()}function f(z,Z,K){return h(z,Z,K)}Y.prototype.mulTo=function(Z,K){var W,D=this.length+Z.length;if(this.length===10&&Z.length===10)W=_(this,Z,K);else if(D<63)W=B(this,Z,K);else if(D<1024)W=h(this,Z,K);else W=f(this,Z,K);return W};function c(z,Z){this.x=z,this.y=Z}c.prototype.makeRBT=function(Z){var K=Array(Z),W=Y.prototype._countBits(Z)-1;for(var D=0;D<Z;D++)K[D]=this.revBin(D,W,Z);return K},c.prototype.revBin=function(Z,K,W){if(Z===0||Z===W-1)return Z;var D=0;for(var V=0;V<K;V++)D|=(Z&1)<<K-V-1,Z>>=1;return D},c.prototype.permute=function(Z,K,W,D,V,C){for(var R=0;R<C;R++)D[R]=K[Z[R]],V[R]=W[Z[R]]},c.prototype.transform=function(Z,K,W,D,V,C){this.permute(C,Z,K,W,D,V);for(var R=1;R<V;R<<=1){var H=R<<1,q=Math.cos(2*Math.PI/H),j=Math.sin(2*Math.PI/H);for(var v=0;v<V;v+=H){var m=q,b=j;for(var n=0;n<R;n++){var a=W[v+n],e=D[v+n],C1=W[v+n+R],X0=D[v+n+R],q0=m*C1-b*X0;if(X0=m*X0+b*C1,C1=q0,W[v+n]=a+C1,D[v+n]=e+X0,W[v+n+R]=a-C1,D[v+n+R]=e-X0,n!==H)q0=q*m-j*b,b=q*b+j*m,m=q0}}}},c.prototype.guessLen13b=function(Z,K){var W=Math.max(K,Z)|1,D=W&1,V=0;for(W=W/2|0;W;W=W>>>1)V++;return 1<<V+1+D},c.prototype.conjugate=function(Z,K,W){if(W<=1)return;for(var D=0;D<W/2;D++){var V=Z[D];Z[D]=Z[W-D-1],Z[W-D-1]=V,V=K[D],K[D]=-K[W-D-1],K[W-D-1]=-V}},c.prototype.normalize13b=function(Z,K){var W=0;for(var D=0;D<K/2;D++){var V=Math.round(Z[2*D+1]/K)*8192+Math.round(Z[2*D]/K)+W;if(Z[D]=V&67108863,V<67108864)W=0;else W=V/67108864|0}return Z},c.prototype.convert13b=function(Z,K,W,D){var V=0;for(var C=0;C<K;C++)V=V+(Z[C]|0),W[2*C]=V&8191,V=V>>>13,W[2*C+1]=V&8191,V=V>>>13;for(C=2*K;C<D;++C)W[C]=0;Q(V===0),Q((V&-8192)===0)},c.prototype.stub=function(Z){var K=Array(Z);for(var W=0;W<Z;W++)K[W]=0;return K},c.prototype.mulp=function(Z,K,W){var D=2*this.guessLen13b(Z.length,K.length),V=this.makeRBT(D),C=this.stub(D),R=Array(D),H=Array(D),q=Array(D),j=Array(D),v=Array(D),m=Array(D),b=W.words;b.length=D,this.convert13b(Z.words,Z.length,R,D),this.convert13b(K.words,K.length,j,D),this.transform(R,C,H,q,D,V),this.transform(j,C,v,m,D,V);for(var n=0;n<D;n++){var a=H[n]*v[n]-q[n]*m[n];q[n]=H[n]*m[n]+q[n]*v[n],H[n]=a}return this.conjugate(H,q,D),this.transform(H,q,b,C,D,V),this.conjugate(b,C,D),this.normalize13b(b,D),W.negative=Z.negative^K.negative,W.length=Z.length+K.length,W._strip()},Y.prototype.mul=function(Z){var K=new Y(null);return K.words=Array(this.length+Z.length),this.mulTo(Z,K)},Y.prototype.mulf=function(Z){var K=new Y(null);return K.words=Array(this.length+Z.length),f(this,Z,K)},Y.prototype.imul=function(Z){return this.clone().mulTo(Z,this)},Y.prototype.imuln=function(Z){var K=Z<0;if(K)Z=-Z;Q(typeof Z==="number"),Q(Z<67108864);var W=0;for(var D=0;D<this.length;D++){var V=(this.words[D]|0)*Z,C=(V&67108863)+(W&67108863);W>>=26,W+=V/67108864|0,W+=C>>>26,this.words[D]=C&67108863}if(W!==0)this.words[D]=W,this.length++;return this.length=Z===0?1:this.length,K?this.ineg():this},Y.prototype.muln=function(Z){return this.clone().imuln(Z)},Y.prototype.sqr=function(){return this.mul(this)},Y.prototype.isqr=function(){return this.imul(this.clone())},Y.prototype.pow=function(Z){var K=F(Z);if(K.length===0)return new Y(1);var W=this;for(var D=0;D<K.length;D++,W=W.sqr())if(K[D]!==0)break;if(++D<K.length)for(var V=W.sqr();D<K.length;D++,V=V.sqr()){if(K[D]===0)continue;W=W.mul(V)}return W},Y.prototype.iushln=function(Z){Q(typeof Z==="number"&&Z>=0);var K=Z%26,W=(Z-K)/26,D=67108863>>>26-K<<26-K,V;if(K!==0){var C=0;for(V=0;V<this.length;V++){var R=this.words[V]&D,H=(this.words[V]|0)-R<<K;this.words[V]=H|C,C=R>>>26-K}if(C)this.words[V]=C,this.length++}if(W!==0){for(V=this.length-1;V>=0;V--)this.words[V+W]=this.words[V];for(V=0;V<W;V++)this.words[V]=0;this.length+=W}return this._strip()},Y.prototype.ishln=function(Z){return Q(this.negative===0),this.iushln(Z)},Y.prototype.iushrn=function(Z,K,W){Q(typeof Z==="number"&&Z>=0);var D;if(K)D=(K-K%26)/26;else D=0;var V=Z%26,C=Math.min((Z-V)/26,this.length),R=67108863^67108863>>>V<<V,H=W;if(D-=C,D=Math.max(0,D),H){for(var q=0;q<C;q++)H.words[q]=this.words[q];H.length=C}if(C===0);else if(this.length>C){this.length-=C;for(q=0;q<this.length;q++)this.words[q]=this.words[q+C]}else this.words[0]=0,this.length=1;var j=0;for(q=this.length-1;q>=0&&(j!==0||q>=D);q--){var v=this.words[q]|0;this.words[q]=j<<26-V|v>>>V,j=v&R}if(H&&j!==0)H.words[H.length++]=j;if(this.length===0)this.words[0]=0,this.length=1;return this._strip()},Y.prototype.ishrn=function(Z,K,W){return Q(this.negative===0),this.iushrn(Z,K,W)},Y.prototype.shln=function(Z){return this.clone().ishln(Z)},Y.prototype.ushln=function(Z){return this.clone().iushln(Z)},Y.prototype.shrn=function(Z){return this.clone().ishrn(Z)},Y.prototype.ushrn=function(Z){return this.clone().iushrn(Z)},Y.prototype.testn=function(Z){Q(typeof Z==="number"&&Z>=0);var K=Z%26,W=(Z-K)/26,D=1<<K;if(this.length<=W)return!1;var V=this.words[W];return!!(V&D)},Y.prototype.imaskn=function(Z){Q(typeof Z==="number"&&Z>=0);var K=Z%26,W=(Z-K)/26;if(Q(this.negative===0,"imaskn works only with positive numbers"),this.length<=W)return this;if(K!==0)W++;if(this.length=Math.min(W,this.length),K!==0){var D=67108863^67108863>>>K<<K;this.words[this.length-1]&=D}return this._strip()},Y.prototype.maskn=function(Z){return this.clone().imaskn(Z)},Y.prototype.iaddn=function(Z){if(Q(typeof Z==="number"),Q(Z<67108864),Z<0)return this.isubn(-Z);if(this.negative!==0){if(this.length===1&&(this.words[0]|0)<=Z)return this.words[0]=Z-(this.words[0]|0),this.negative=0,this;return this.negative=0,this.isubn(Z),this.negative=1,this}return this._iaddn(Z)},Y.prototype._iaddn=function(Z){this.words[0]+=Z;for(var K=0;K<this.length&&this.words[K]>=67108864;K++)if(this.words[K]-=67108864,K===this.length-1)this.words[K+1]=1;else this.words[K+1]++;return this.length=Math.max(this.length,K+1),this},Y.prototype.isubn=function(Z){if(Q(typeof Z==="number"),Q(Z<67108864),Z<0)return this.iaddn(-Z);if(this.negative!==0)return this.negative=0,this.iaddn(Z),this.negative=1,this;if(this.words[0]-=Z,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var K=0;K<this.length&&this.words[K]<0;K++)this.words[K]+=67108864,this.words[K+1]-=1;return this._strip()},Y.prototype.addn=function(Z){return this.clone().iaddn(Z)},Y.prototype.subn=function(Z){return this.clone().isubn(Z)},Y.prototype.iabs=function(){return this.negative=0,this},Y.prototype.abs=function(){return this.clone().iabs()},Y.prototype._ishlnsubmul=function(Z,K,W){var D=Z.length+W,V;this._expand(D);var C,R=0;for(V=0;V<Z.length;V++){C=(this.words[V+W]|0)+R;var H=(Z.words[V]|0)*K;C-=H&67108863,R=(C>>26)-(H/67108864|0),this.words[V+W]=C&67108863}for(;V<this.length-W;V++)C=(this.words[V+W]|0)+R,R=C>>26,this.words[V+W]=C&67108863;if(R===0)return this._strip();Q(R===-1),R=0;for(V=0;V<this.length;V++)C=-(this.words[V]|0)+R,R=C>>26,this.words[V]=C&67108863;return this.negative=1,this._strip()},Y.prototype._wordDiv=function(Z,K){var W=this.length-Z.length,D=this.clone(),V=Z,C=V.words[V.length-1]|0,R=this._countBits(C);if(W=26-R,W!==0)V=V.ushln(W),D.iushln(W),C=V.words[V.length-1]|0;var H=D.length-V.length,q;if(K!=="mod"){q=new Y(null),q.length=H+1,q.words=Array(q.length);for(var j=0;j<q.length;j++)q.words[j]=0}var v=D.clone()._ishlnsubmul(V,1,H);if(v.negative===0){if(D=v,q)q.words[H]=1}for(var m=H-1;m>=0;m--){var b=(D.words[V.length+m]|0)*67108864+(D.words[V.length+m-1]|0);b=Math.min(b/C|0,67108863),D._ishlnsubmul(V,b,m);while(D.negative!==0)if(b--,D.negative=0,D._ishlnsubmul(V,1,m),!D.isZero())D.negative^=1;if(q)q.words[m]=b}if(q)q._strip();if(D._strip(),K!=="div"&&W!==0)D.iushrn(W);return{div:q||null,mod:D}},Y.prototype.divmod=function(Z,K,W){if(Q(!Z.isZero()),this.isZero())return{div:new Y(0),mod:new Y(0)};var D,V,C;if(this.negative!==0&&Z.negative===0){if(C=this.neg().divmod(Z,K),K!=="mod")D=C.div.neg();if(K!=="div"){if(V=C.mod.neg(),W&&V.negative!==0)V.iadd(Z)}return{div:D,mod:V}}if(this.negative===0&&Z.negative!==0){if(C=this.divmod(Z.neg(),K),K!=="mod")D=C.div.neg();return{div:D,mod:C.mod}}if((this.negative&Z.negative)!==0){if(C=this.neg().divmod(Z.neg(),K),K!=="div"){if(V=C.mod.neg(),W&&V.negative!==0)V.isub(Z)}return{div:C.div,mod:V}}if(Z.length>this.length||this.cmp(Z)<0)return{div:new Y(0),mod:this};if(Z.length===1){if(K==="div")return{div:this.divn(Z.words[0]),mod:null};if(K==="mod")return{div:null,mod:new Y(this.modrn(Z.words[0]))};return{div:this.divn(Z.words[0]),mod:new Y(this.modrn(Z.words[0]))}}return this._wordDiv(Z,K)},Y.prototype.div=function(Z){return this.divmod(Z,"div",!1).div},Y.prototype.mod=function(Z){return this.divmod(Z,"mod",!1).mod},Y.prototype.umod=function(Z){return this.divmod(Z,"mod",!0).mod},Y.prototype.divRound=function(Z){var K=this.divmod(Z);if(K.mod.isZero())return K.div;var W=K.div.negative!==0?K.mod.isub(Z):K.mod,D=Z.ushrn(1),V=Z.andln(1),C=W.cmp(D);if(C<0||V===1&&C===0)return K.div;return K.div.negative!==0?K.div.isubn(1):K.div.iaddn(1)},Y.prototype.modrn=function(Z){var K=Z<0;if(K)Z=-Z;Q(Z<=67108863);var W=67108864%Z,D=0;for(var V=this.length-1;V>=0;V--)D=(W*D+(this.words[V]|0))%Z;return K?-D:D},Y.prototype.modn=function(Z){return this.modrn(Z)},Y.prototype.idivn=function(Z){var K=Z<0;if(K)Z=-Z;Q(Z<=67108863);var W=0;for(var D=this.length-1;D>=0;D--){var V=(this.words[D]|0)+W*67108864;this.words[D]=V/Z|0,W=V%Z}return this._strip(),K?this.ineg():this},Y.prototype.divn=function(Z){return this.clone().idivn(Z)},Y.prototype.egcd=function(Z){Q(Z.negative===0),Q(!Z.isZero());var K=this,W=Z.clone();if(K.negative!==0)K=K.umod(Z);else K=K.clone();var D=new Y(1),V=new Y(0),C=new Y(0),R=new Y(1),H=0;while(K.isEven()&&W.isEven())K.iushrn(1),W.iushrn(1),++H;var q=W.clone(),j=K.clone();while(!K.isZero()){for(var v=0,m=1;(K.words[0]&m)===0&&v<26;++v,m<<=1);if(v>0){K.iushrn(v);while(v-- >0){if(D.isOdd()||V.isOdd())D.iadd(q),V.isub(j);D.iushrn(1),V.iushrn(1)}}for(var b=0,n=1;(W.words[0]&n)===0&&b<26;++b,n<<=1);if(b>0){W.iushrn(b);while(b-- >0){if(C.isOdd()||R.isOdd())C.iadd(q),R.isub(j);C.iushrn(1),R.iushrn(1)}}if(K.cmp(W)>=0)K.isub(W),D.isub(C),V.isub(R);else W.isub(K),C.isub(D),R.isub(V)}return{a:C,b:R,gcd:W.iushln(H)}},Y.prototype._invmp=function(Z){Q(Z.negative===0),Q(!Z.isZero());var K=this,W=Z.clone();if(K.negative!==0)K=K.umod(Z);else K=K.clone();var D=new Y(1),V=new Y(0),C=W.clone();while(K.cmpn(1)>0&&W.cmpn(1)>0){for(var R=0,H=1;(K.words[0]&H)===0&&R<26;++R,H<<=1);if(R>0){K.iushrn(R);while(R-- >0){if(D.isOdd())D.iadd(C);D.iushrn(1)}}for(var q=0,j=1;(W.words[0]&j)===0&&q<26;++q,j<<=1);if(q>0){W.iushrn(q);while(q-- >0){if(V.isOdd())V.iadd(C);V.iushrn(1)}}if(K.cmp(W)>=0)K.isub(W),D.isub(V);else W.isub(K),V.isub(D)}var v;if(K.cmpn(1)===0)v=D;else v=V;if(v.cmpn(0)<0)v.iadd(Z);return v},Y.prototype.gcd=function(Z){if(this.isZero())return Z.abs();if(Z.isZero())return this.abs();var K=this.clone(),W=Z.clone();K.negative=0,W.negative=0;for(var D=0;K.isEven()&&W.isEven();D++)K.iushrn(1),W.iushrn(1);do{while(K.isEven())K.iushrn(1);while(W.isEven())W.iushrn(1);var V=K.cmp(W);if(V<0){var C=K;K=W,W=C}else if(V===0||W.cmpn(1)===0)break;K.isub(W)}while(!0);return W.iushln(D)},Y.prototype.invm=function(Z){return this.egcd(Z).a.umod(Z)},Y.prototype.isEven=function(){return(this.words[0]&1)===0},Y.prototype.isOdd=function(){return(this.words[0]&1)===1},Y.prototype.andln=function(Z){return this.words[0]&Z},Y.prototype.bincn=function(Z){Q(typeof Z==="number");var K=Z%26,W=(Z-K)/26,D=1<<K;if(this.length<=W)return this._expand(W+1),this.words[W]|=D,this;var V=D;for(var C=W;V!==0&&C<this.length;C++){var R=this.words[C]|0;R+=V,V=R>>>26,R&=67108863,this.words[C]=R}if(V!==0)this.words[C]=V,this.length++;return this},Y.prototype.isZero=function(){return this.length===1&&this.words[0]===0},Y.prototype.cmpn=function(Z){var K=Z<0;if(this.negative!==0&&!K)return-1;if(this.negative===0&&K)return 1;this._strip();var W;if(this.length>1)W=1;else{if(K)Z=-Z;Q(Z<=67108863,"Number is too big");var D=this.words[0]|0;W=D===Z?0:D<Z?-1:1}if(this.negative!==0)return-W|0;return W},Y.prototype.cmp=function(Z){if(this.negative!==0&&Z.negative===0)return-1;if(this.negative===0&&Z.negative!==0)return 1;var K=this.ucmp(Z);if(this.negative!==0)return-K|0;return K},Y.prototype.ucmp=function(Z){if(this.length>Z.length)return 1;if(this.length<Z.length)return-1;var K=0;for(var W=this.length-1;W>=0;W--){var D=this.words[W]|0,V=Z.words[W]|0;if(D===V)continue;if(D<V)K=-1;else if(D>V)K=1;break}return K},Y.prototype.gtn=function(Z){return this.cmpn(Z)===1},Y.prototype.gt=function(Z){return this.cmp(Z)===1},Y.prototype.gten=function(Z){return this.cmpn(Z)>=0},Y.prototype.gte=function(Z){return this.cmp(Z)>=0},Y.prototype.ltn=function(Z){return this.cmpn(Z)===-1},Y.prototype.lt=function(Z){return this.cmp(Z)===-1},Y.prototype.lten=function(Z){return this.cmpn(Z)<=0},Y.prototype.lte=function(Z){return this.cmp(Z)<=0},Y.prototype.eqn=function(Z){return this.cmpn(Z)===0},Y.prototype.eq=function(Z){return this.cmp(Z)===0},Y.red=function(Z){return new l(Z)},Y.prototype.toRed=function(Z){return Q(!this.red,"Already a number in reduction context"),Q(this.negative===0,"red works only with positives"),Z.convertTo(this)._forceRed(Z)},Y.prototype.fromRed=function(){return Q(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},Y.prototype._forceRed=function(Z){return this.red=Z,this},Y.prototype.forceRed=function(Z){return Q(!this.red,"Already a number in reduction context"),this._forceRed(Z)},Y.prototype.redAdd=function(Z){return Q(this.red,"redAdd works only with red numbers"),this.red.add(this,Z)},Y.prototype.redIAdd=function(Z){return Q(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,Z)},Y.prototype.redSub=function(Z){return Q(this.red,"redSub works only with red numbers"),this.red.sub(this,Z)},Y.prototype.redISub=function(Z){return Q(this.red,"redISub works only with red numbers"),this.red.isub(this,Z)},Y.prototype.redShl=function(Z){return Q(this.red,"redShl works only with red numbers"),this.red.shl(this,Z)},Y.prototype.redMul=function(Z){return Q(this.red,"redMul works only with red numbers"),this.red._verify2(this,Z),this.red.mul(this,Z)},Y.prototype.redIMul=function(Z){return Q(this.red,"redMul works only with red numbers"),this.red._verify2(this,Z),this.red.imul(this,Z)},Y.prototype.redSqr=function(){return Q(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},Y.prototype.redISqr=function(){return Q(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},Y.prototype.redSqrt=function(){return Q(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},Y.prototype.redInvm=function(){return Q(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},Y.prototype.redNeg=function(){return Q(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},Y.prototype.redPow=function(Z){return Q(this.red&&!Z.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,Z)};var s={k256:null,p224:null,p192:null,p25519:null};function o(z,Z){this.name=z,this.p=new Y(Z,16),this.n=this.p.bitLength(),this.k=new Y(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}o.prototype._tmp=function(){var Z=new Y(null);return Z.words=Array(Math.ceil(this.n/13)),Z},o.prototype.ireduce=function(Z){var K=Z,W;do this.split(K,this.tmp),K=this.imulK(K),K=K.iadd(this.tmp),W=K.bitLength();while(W>this.n);var D=W<this.n?-1:K.ucmp(this.p);if(D===0)K.words[0]=0,K.length=1;else if(D>0)K.isub(this.p);else if(K.strip!==void 0)K.strip();else K._strip();return K},o.prototype.split=function(Z,K){Z.iushrn(this.n,0,K)},o.prototype.imulK=function(Z){return Z.imul(this.k)};function r(){o.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}G(r,o),r.prototype.split=function(Z,K){var W=4194303,D=Math.min(Z.length,9);for(var V=0;V<D;V++)K.words[V]=Z.words[V];if(K.length=D,Z.length<=9){Z.words[0]=0,Z.length=1;return}var C=Z.words[9];K.words[K.length++]=C&W;for(V=10;V<Z.length;V++){var R=Z.words[V]|0;Z.words[V-10]=(R&W)<<4|C>>>22,C=R}if(C>>>=22,Z.words[V-10]=C,C===0&&Z.length>10)Z.length-=10;else Z.length-=9},r.prototype.imulK=function(Z){Z.words[Z.length]=0,Z.words[Z.length+1]=0,Z.length+=2;var K=0;for(var W=0;W<Z.length;W++){var D=Z.words[W]|0;K+=D*977,Z.words[W]=K&67108863,K=D*64+(K/67108864|0)}if(Z.words[Z.length-1]===0){if(Z.length--,Z.words[Z.length-1]===0)Z.length--}return Z};function t(){o.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}G(t,o);function x(){o.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}G(x,o);function d(){o.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}G(d,o),d.prototype.imulK=function(Z){var K=0;for(var W=0;W<Z.length;W++){var D=(Z.words[W]|0)*19+K,V=D&67108863;D>>>=26,Z.words[W]=V,K=D}if(K!==0)Z.words[Z.length++]=K;return Z},Y._prime=function(Z){if(s[Z])return s[Z];var K;if(Z==="k256")K=new r;else if(Z==="p224")K=new t;else if(Z==="p192")K=new x;else if(Z==="p25519")K=new d;else throw Error("Unknown prime "+Z);return s[Z]=K,K};function l(z){if(typeof z==="string"){var Z=Y._prime(z);this.m=Z.p,this.prime=Z}else Q(z.gtn(1),"modulus must be greater than 1"),this.m=z,this.prime=null}l.prototype._verify1=function(Z){Q(Z.negative===0,"red works only with positives"),Q(Z.red,"red works only with red numbers")},l.prototype._verify2=function(Z,K){Q((Z.negative|K.negative)===0,"red works only with positives"),Q(Z.red&&Z.red===K.red,"red works only with red numbers")},l.prototype.imod=function(Z){if(this.prime)return this.prime.ireduce(Z)._forceRed(this);return T(Z,Z.umod(this.m)._forceRed(this)),Z},l.prototype.neg=function(Z){if(Z.isZero())return Z.clone();return this.m.sub(Z)._forceRed(this)},l.prototype.add=function(Z,K){this._verify2(Z,K);var W=Z.add(K);if(W.cmp(this.m)>=0)W.isub(this.m);return W._forceRed(this)},l.prototype.iadd=function(Z,K){this._verify2(Z,K);var W=Z.iadd(K);if(W.cmp(this.m)>=0)W.isub(this.m);return W},l.prototype.sub=function(Z,K){this._verify2(Z,K);var W=Z.sub(K);if(W.cmpn(0)<0)W.iadd(this.m);return W._forceRed(this)},l.prototype.isub=function(Z,K){this._verify2(Z,K);var W=Z.isub(K);if(W.cmpn(0)<0)W.iadd(this.m);return W},l.prototype.shl=function(Z,K){return this._verify1(Z),this.imod(Z.ushln(K))},l.prototype.imul=function(Z,K){return this._verify2(Z,K),this.imod(Z.imul(K))},l.prototype.mul=function(Z,K){return this._verify2(Z,K),this.imod(Z.mul(K))},l.prototype.isqr=function(Z){return this.imul(Z,Z.clone())},l.prototype.sqr=function(Z){return this.mul(Z,Z)},l.prototype.sqrt=function(Z){if(Z.isZero())return Z.clone();var K=this.m.andln(3);if(Q(K%2===1),K===3){var W=this.m.add(new Y(1)).iushrn(2);return this.pow(Z,W)}var D=this.m.subn(1),V=0;while(!D.isZero()&&D.andln(1)===0)V++,D.iushrn(1);Q(!D.isZero());var C=new Y(1).toRed(this),R=C.redNeg(),H=this.m.subn(1).iushrn(1),q=this.m.bitLength();q=new Y(2*q*q).toRed(this);while(this.pow(q,H).cmp(R)!==0)q.redIAdd(R);var j=this.pow(q,D),v=this.pow(Z,D.addn(1).iushrn(1)),m=this.pow(Z,D),b=V;while(m.cmp(C)!==0){var n=m;for(var a=0;n.cmp(C)!==0;a++)n=n.redSqr();Q(a<b);var e=this.pow(j,new Y(1).iushln(b-a-1));v=v.redMul(e),j=e.redSqr(),m=m.redMul(j),b=a}return v},l.prototype.invm=function(Z){var K=Z._invmp(this.m);if(K.negative!==0)return K.negative=0,this.imod(K).redNeg();else return this.imod(K)},l.prototype.pow=function(Z,K){if(K.isZero())return new Y(1).toRed(this);if(K.cmpn(1)===0)return Z.clone();var W=4,D=Array(1<<W);D[0]=new Y(1).toRed(this),D[1]=Z;for(var V=2;V<D.length;V++)D[V]=this.mul(D[V-1],Z);var C=D[0],R=0,H=0,q=K.bitLength()%26;if(q===0)q=26;for(V=K.length-1;V>=0;V--){var j=K.words[V];for(var v=q-1;v>=0;v--){var m=j>>v&1;if(C!==D[0])C=this.sqr(C);if(m===0&&R===0){H=0;continue}if(R<<=1,R|=m,H++,H!==W&&(V!==0||v!==0))continue;C=this.mul(C,D[R]),H=0,R=0}q=26}return C},l.prototype.convertTo=function(Z){var K=Z.umod(this.m);return K===Z?K.clone():K},l.prototype.convertFrom=function(Z){var K=Z.clone();return K.red=null,K},Y.mont=function(Z){return new w(Z)};function w(z){if(l.call(this,z),this.shift=this.m.bitLength(),this.shift%26!==0)this.shift+=26-this.shift%26;this.r=new Y(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)}G(w,l),w.prototype.convertTo=function(Z){return this.imod(Z.ushln(this.shift))},w.prototype.convertFrom=function(Z){var K=this.imod(Z.mul(this.rinv));return K.red=null,K},w.prototype.imul=function(Z,K){if(Z.isZero()||K.isZero())return Z.words[0]=0,Z.length=1,Z;var W=Z.imul(K),D=W.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),V=W.isub(D).iushrn(this.shift),C=V;if(V.cmp(this.m)>=0)C=V.isub(this.m);else if(V.cmpn(0)<0)C=V.iadd(this.m);return C._forceRed(this)},w.prototype.mul=function(Z,K){if(Z.isZero()||K.isZero())return new Y(0)._forceRed(this);var W=Z.mul(K),D=W.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),V=W.isub(D).iushrn(this.shift),C=V;if(V.cmp(this.m)>=0)C=V.isub(this.m);else if(V.cmpn(0)<0)C=V.iadd(this.m);return C._forceRed(this)},w.prototype.invm=function(Z){var K=this.imod(Z._invmp(this.m).mul(this.r2));return K._forceRed(this)}})(typeof xJ>"u"||xJ,EY)});var FY=c1((hJ,wY)=>{/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var J$=(u8(),m8(c2)),b1=J$.Buffer;function BY($,J){for(var Q in $)J[Q]=$[Q]}if(b1.from&&b1.alloc&&b1.allocUnsafe&&b1.allocUnsafeSlow)wY.exports=J$;else BY(J$,hJ),hJ.Buffer=_8;function _8($,J,Q){return b1($,J,Q)}_8.prototype=Object.create(b1.prototype);BY(b1,_8);_8.from=function($,J,Q){if(typeof $==="number")throw TypeError("Argument must not be a number");return b1($,J,Q)};_8.alloc=function($,J,Q){if(typeof $!=="number")throw TypeError("Argument must be a number");var G=b1($);if(J!==void 0)if(typeof Q==="string")G.fill(J,Q);else G.fill(J);else G.fill(0);return G};_8.allocUnsafe=function($){if(typeof $!=="number")throw TypeError("Argument must be a number");return b1($)};_8.allocUnsafeSlow=function($){if(typeof $!=="number")throw TypeError("Argument must be a number");return J$.SlowBuffer($)}});var gY=c1((OI,_Y)=>{var Q$=FY().Buffer;function YM($){if($.length>=255)throw TypeError("Alphabet too long");var J=new Uint8Array(256);for(var Q=0;Q<J.length;Q++)J[Q]=255;for(var G=0;G<$.length;G++){var Y=$.charAt(G),X=Y.charCodeAt(0);if(J[X]!==255)throw TypeError(Y+" is ambiguous");J[X]=G}var M=$.length,I=$.charAt(0),U=Math.log(M)/Math.log(256),T=Math.log(256)/Math.log(M);function A(k){if(Array.isArray(k)||k instanceof Uint8Array)k=Q$.from(k);if(!Q$.isBuffer(k))throw TypeError("Expected Buffer");if(k.length===0)return"";var P=0,F=0,B=0,_=k.length;while(B!==_&&k[B]===0)B++,P++;var h=(_-B)*T+1>>>0,f=new Uint8Array(h);while(B!==_){var c=k[B],s=0;for(var o=h-1;(c!==0||s<F)&&o!==-1;o--,s++)c+=256*f[o]>>>0,f[o]=c%M>>>0,c=c/M>>>0;if(c!==0)throw Error("Non-zero carry");F=s,B++}var r=h-F;while(r!==h&&f[r]===0)r++;var t=I.repeat(P);for(;r<h;++r)t+=$.charAt(f[r]);return t}function L(k){if(typeof k!=="string")throw TypeError("Expected String");if(k.length===0)return Q$.alloc(0);var P=0,F=0,B=0;while(k[P]===I)F++,P++;var _=(k.length-P)*U+1>>>0,h=new Uint8Array(_);while(P<k.length){var f=k.charCodeAt(P);if(f>255)return;var c=J[f];if(c===255)return;var s=0;for(var o=_-1;(c!==0||s<B)&&o!==-1;o--,s++)c+=M*h[o]>>>0,h[o]=c%256>>>0,c=c/256>>>0;if(c!==0)throw Error("Non-zero carry");B=s,P++}var r=_-B;while(r!==_&&h[r]===0)r++;var t=Q$.allocUnsafe(F+(_-r));t.fill(0,0,F);var x=F;while(r!==_)t[x++]=h[r++];return t}function N(k){var P=L(k);if(P)return P;throw Error("Non-base"+M+" character")}return{encode:A,decodeUnsafe:L,decode:N}}_Y.exports=YM});var yJ=c1((NI,xY)=>{var XM=gY(),ZM="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";xY.exports=XM(ZM)});var vY={};$J(vY,{TextEncoder:()=>Z$,TextDecoder:()=>X$});function $8($,J,Q){return J<=$&&$<=Q}function M$($){if($===void 0)return{};if($===Object($))return $;throw TypeError("Could not convert argument to dictionary")}function MM($){var J=String($),Q=J.length,G=0,Y=[];while(G<Q){var X=J.charCodeAt(G);if(X<55296||X>57343)Y.push(X);else if(56320<=X&&X<=57343)Y.push(65533);else if(55296<=X&&X<=56319)if(G===Q-1)Y.push(65533);else{var M=$.charCodeAt(G+1);if(56320<=M&&M<=57343){var I=X&1023,U=M&1023;Y.push(65536+(I<<10)+U),G+=1}else Y.push(65533)}G+=1}return Y}function KM($){var J="";for(var Q=0;Q<$.length;++Q){var G=$[Q];if(G<=65535)J+=String.fromCharCode(G);else G-=65536,J+=String.fromCharCode((G>>10)+55296,(G&1023)+56320)}return J}function mJ($){this.tokens=[].slice.call($)}function bJ($,J){if($)throw TypeError("Decoder error");return J||65533}function qM(){}function WM(){}function X$($,J){if(!(this instanceof X$))return new X$($,J);if($=$!==void 0?String($).toLowerCase():Y$,$!==Y$)throw Error("Encoding not supported. Only utf-8 is supported");J=M$(J),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=Boolean(J.fatal),this._ignoreBOM=Boolean(J.ignoreBOM),Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}function Z$($,J){if(!(this instanceof Z$))return new Z$($,J);if($=$!==void 0?String($).toLowerCase():Y$,$!==Y$)throw Error("Encoding not supported. Only utf-8 is supported");J=M$(J),this._streaming=!1,this._encoder=null,this._options={fatal:Boolean(J.fatal)},Object.defineProperty(this,"encoding",{value:"utf-8"})}function UM($){var J=$.fatal,Q=0,G=0,Y=0,X=128,M=191;this.handler=function(I,U){if(U===G$&&Y!==0)return Y=0,bJ(J);if(U===G$)return o8;if(Y===0){if($8(U,0,127))return U;if($8(U,194,223))Y=1,Q=U-192;else if($8(U,224,239)){if(U===224)X=160;if(U===237)M=159;Y=2,Q=U-224}else if($8(U,240,244)){if(U===240)X=144;if(U===244)M=143;Y=3,Q=U-240}else return bJ(J);return Q=Q<<6*Y,null}if(!$8(U,X,M))return Q=Y=G=0,X=128,M=191,I.prepend(U),bJ(J);if(X=128,M=191,G+=1,Q+=U-128<<6*(Y-G),G!==Y)return null;var T=Q;return Q=Y=G=0,T}}function IM($){var J=$.fatal;this.handler=function(Q,G){if(G===G$)return o8;if($8(G,0,127))return G;var Y,X;if($8(G,128,2047))Y=1,X=192;else if($8(G,2048,65535))Y=2,X=224;else if($8(G,65536,1114111))Y=3,X=240;var M=[(G>>6*Y)+X];while(Y>0){var I=G>>6*(Y-1);M.push(128|I&63),Y-=1}return M}}var G$=-1,o8=-1,Y$="utf-8";var hY=Y1(()=>{mJ.prototype={endOfStream:function(){return!this.tokens.length},read:function(){if(!this.tokens.length)return G$;return this.tokens.shift()},prepend:function($){if(Array.isArray($)){var J=$;while(J.length)this.tokens.unshift(J.pop())}else this.tokens.unshift($)},push:function($){if(Array.isArray($)){var J=$;while(J.length)this.tokens.push(J.shift())}else this.tokens.push($)}};qM.prototype={handler:function($,J){}};WM.prototype={handler:function($,J){}};X$.prototype={decode:function(J,Q){var G;if(typeof J==="object"&&J instanceof ArrayBuffer)G=new Uint8Array(J);else if(typeof J==="object"&&"buffer"in J&&J.buffer instanceof ArrayBuffer)G=new Uint8Array(J.buffer,J.byteOffset,J.byteLength);else G=new Uint8Array(0);if(Q=M$(Q),!this._streaming)this._decoder=new UM({fatal:this._fatal}),this._BOMseen=!1;this._streaming=Boolean(Q.stream);var Y=new mJ(G),X=[],M;while(!Y.endOfStream()){if(M=this._decoder.handler(Y,Y.read()),M===o8)break;if(M===null)continue;if(Array.isArray(M))X.push.apply(X,M);else X.push(M)}if(!this._streaming){do{if(M=this._decoder.handler(Y,Y.read()),M===o8)break;if(M===null)continue;if(Array.isArray(M))X.push.apply(X,M);else X.push(M)}while(!Y.endOfStream());this._decoder=null}if(X.length){if(["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen)if(X[0]===65279)this._BOMseen=!0,X.shift();else this._BOMseen=!0}return KM(X)}};Z$.prototype={encode:function(J,Q){if(J=J?String(J):"",Q=M$(Q),!this._streaming)this._encoder=new IM(this._options);this._streaming=Boolean(Q.stream);var G=[],Y=new mJ(MM(J)),X;while(!Y.endOfStream()){if(X=this._encoder.handler(Y,Y.read()),X===o8)break;if(Array.isArray(X))G.push.apply(G,X);else G.push(X)}if(!this._streaming){while(!0){if(X=this._encoder.handler(Y,Y.read()),X===o8)break;if(Array.isArray(X))G.push.apply(G,X);else G.push(X)}this._encoder=null}return new Uint8Array(G)}}});var pY=c1((K0)=>{var DM=K0&&K0.__createBinding||(Object.create?function($,J,Q,G){if(G===void 0)G=Q;Object.defineProperty($,G,{enumerable:!0,get:function(){return J[Q]}})}:function($,J,Q,G){if(G===void 0)G=Q;$[G]=J[Q]}),VM=K0&&K0.__setModuleDefault||(Object.create?function($,J){Object.defineProperty($,"default",{enumerable:!0,value:J})}:function($,J){$.default=J}),m1=K0&&K0.__decorate||function($,J,Q,G){var Y=arguments.length,X=Y<3?J:G===null?G=Object.getOwnPropertyDescriptor(J,Q):G,M;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")X=Reflect.decorate($,J,Q,G);else for(var I=$.length-1;I>=0;I--)if(M=$[I])X=(Y<3?M(X):Y>3?M(J,Q,X):M(J,Q))||X;return Y>3&&X&&Object.defineProperty(J,Q,X),X},zM=K0&&K0.__importStar||function($){if($&&$.__esModule)return $;var J={};if($!=null){for(var Q in $)if(Q!=="default"&&Object.hasOwnProperty.call($,Q))DM(J,$,Q)}return VM(J,$),J},yY=K0&&K0.__importDefault||function($){return $&&$.__esModule?$:{default:$}};Object.defineProperty(K0,"__esModule",{value:!0});K0.deserializeUnchecked=K0.deserialize=K0.serialize=K0.BinaryReader=K0.BinaryWriter=K0.BorshError=K0.baseDecode=K0.baseEncode=void 0;var V8=yY(vJ()),fY=yY(yJ()),HM=zM((hY(),m8(vY))),jM=typeof TextDecoder!=="function"?HM.TextDecoder:TextDecoder,CM=new jM("utf-8",{fatal:!0});function AM($){if(typeof $==="string")$=Buffer.from($,"utf8");return fY.default.encode(Buffer.from($))}K0.baseEncode=AM;function TM($){return Buffer.from(fY.default.decode($))}K0.baseDecode=TM;var pJ=1024;class X1 extends Error{constructor($){super($);this.fieldPath=[],this.originalMessage=$}addToFieldPath($){this.fieldPath.splice(0,0,$),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}K0.BorshError=X1;class uJ{constructor(){this.buf=Buffer.alloc(pJ),this.length=0}maybeResize(){if(this.buf.length<16+this.length)this.buf=Buffer.concat([this.buf,Buffer.alloc(pJ)])}writeU8($){this.maybeResize(),this.buf.writeUInt8($,this.length),this.length+=1}writeU16($){this.maybeResize(),this.buf.writeUInt16LE($,this.length),this.length+=2}writeU32($){this.maybeResize(),this.buf.writeUInt32LE($,this.length),this.length+=4}writeU64($){this.maybeResize(),this.writeBuffer(Buffer.from(new V8.default($).toArray("le",8)))}writeU128($){this.maybeResize(),this.writeBuffer(Buffer.from(new V8.default($).toArray("le",16)))}writeU256($){this.maybeResize(),this.writeBuffer(Buffer.from(new V8.default($).toArray("le",32)))}writeU512($){this.maybeResize(),this.writeBuffer(Buffer.from(new V8.default($).toArray("le",64)))}writeBuffer($){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),$,Buffer.alloc(pJ)]),this.length+=$.length}writeString($){this.maybeResize();let J=Buffer.from($,"utf8");this.writeU32(J.length),this.writeBuffer(J)}writeFixedArray($){this.writeBuffer(Buffer.from($))}writeArray($,J){this.maybeResize(),this.writeU32($.length);for(let Q of $)this.maybeResize(),J(Q)}toArray(){return this.buf.subarray(0,this.length)}}K0.BinaryWriter=uJ;function p1($,J,Q){let G=Q.value;Q.value=function(...Y){try{return G.apply(this,Y)}catch(X){if(X instanceof RangeError){let M=X.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(M)>=0)throw new X1("Reached the end of buffer when deserializing")}throw X}}}class R1{constructor($){this.buf=$,this.offset=0}readU8(){let $=this.buf.readUInt8(this.offset);return this.offset+=1,$}readU16(){let $=this.buf.readUInt16LE(this.offset);return this.offset+=2,$}readU32(){let $=this.buf.readUInt32LE(this.offset);return this.offset+=4,$}readU64(){let $=this.readBuffer(8);return new V8.default($,"le")}readU128(){let $=this.readBuffer(16);return new V8.default($,"le")}readU256(){let $=this.readBuffer(32);return new V8.default($,"le")}readU512(){let $=this.readBuffer(64);return new V8.default($,"le")}readBuffer($){if(this.offset+$>this.buf.length)throw new X1(`Expected buffer length ${$} isn't within bounds`);let J=this.buf.slice(this.offset,this.offset+$);return this.offset+=$,J}readString(){let $=this.readU32(),J=this.readBuffer($);try{return CM.decode(J)}catch(Q){throw new X1(`Error decoding UTF-8 string: ${Q}`)}}readFixedArray($){return new Uint8Array(this.readBuffer($))}readArray($){let J=this.readU32(),Q=Array();for(let G=0;G<J;++G)Q.push($());return Q}}m1([p1],R1.prototype,"readU8",null);m1([p1],R1.prototype,"readU16",null);m1([p1],R1.prototype,"readU32",null);m1([p1],R1.prototype,"readU64",null);m1([p1],R1.prototype,"readU128",null);m1([p1],R1.prototype,"readU256",null);m1([p1],R1.prototype,"readU512",null);m1([p1],R1.prototype,"readString",null);m1([p1],R1.prototype,"readFixedArray",null);m1([p1],R1.prototype,"readArray",null);K0.BinaryReader=R1;function bY($){return $.charAt(0).toUpperCase()+$.slice(1)}function g8($,J,Q,G,Y){try{if(typeof G==="string")Y[`write${bY(G)}`](Q);else if(G instanceof Array)if(typeof G[0]==="number"){if(Q.length!==G[0])throw new X1(`Expecting byte array of length ${G[0]}, but got ${Q.length} bytes`);Y.writeFixedArray(Q)}else if(G.length===2&&typeof G[1]==="number"){if(Q.length!==G[1])throw new X1(`Expecting byte array of length ${G[1]}, but got ${Q.length} bytes`);for(let X=0;X<G[1];X++)g8($,null,Q[X],G[0],Y)}else Y.writeArray(Q,(X)=>{g8($,J,X,G[0],Y)});else if(G.kind!==void 0)switch(G.kind){case"option":{if(Q===null||Q===void 0)Y.writeU8(0);else Y.writeU8(1),g8($,J,Q,G.type,Y);break}case"map":{Y.writeU32(Q.size),Q.forEach((X,M)=>{g8($,J,M,G.key,Y),g8($,J,X,G.value,Y)});break}default:throw new X1(`FieldType ${G} unrecognized`)}else mY($,Q,Y)}catch(X){if(X instanceof X1)X.addToFieldPath(J);throw X}}function mY($,J,Q){if(typeof J.borshSerialize==="function"){J.borshSerialize(Q);return}let G=$.get(J.constructor);if(!G)throw new X1(`Class ${J.constructor.name} is missing in schema`);if(G.kind==="struct")G.fields.map(([Y,X])=>{g8($,Y,J[Y],X,Q)});else if(G.kind==="enum"){let Y=J[G.field];for(let X=0;X<G.values.length;++X){let[M,I]=G.values[X];if(M===Y){Q.writeU8(X),g8($,M,J[M],I,Q);break}}}else throw new X1(`Unexpected schema kind: ${G.kind} for ${J.constructor.name}`)}function RM($,J,Q=uJ){let G=new Q;return mY($,J,G),G.toArray()}K0.serialize=RM;function x8($,J,Q,G){try{if(typeof Q==="string")return G[`read${bY(Q)}`]();if(Q instanceof Array)if(typeof Q[0]==="number")return G.readFixedArray(Q[0]);else if(typeof Q[1]==="number"){let Y=[];for(let X=0;X<Q[1];X++)Y.push(x8($,null,Q[0],G));return Y}else return G.readArray(()=>x8($,J,Q[0],G));if(Q.kind==="option"){if(G.readU8())return x8($,J,Q.type,G);return}if(Q.kind==="map"){let Y=new Map,X=G.readU32();for(let M=0;M<X;M++){let I=x8($,J,Q.key,G),U=x8($,J,Q.value,G);Y.set(I,U)}return Y}return cJ($,Q,G)}catch(Y){if(Y instanceof X1)Y.addToFieldPath(J);throw Y}}function cJ($,J,Q){if(typeof J.borshDeserialize==="function")return J.borshDeserialize(Q);let G=$.get(J);if(!G)throw new X1(`Class ${J.name} is missing in schema`);if(G.kind==="struct"){let Y={};for(let[X,M]of $.get(J).fields)Y[X]=x8($,X,M,Q);return new J(Y)}if(G.kind==="enum"){let Y=Q.readU8();if(Y>=G.values.length)throw new X1(`Enum index: ${Y} is out of range`);let[X,M]=G.values[Y],I=x8($,X,M,Q);return new J({[X]:I})}throw new X1(`Unexpected schema kind: ${G.kind} for ${J.constructor.name}`)}function OM($,J,Q,G=R1){let Y=new G(Q),X=cJ($,J,Y);if(Y.offset<Q.length)throw new X1(`Unexpected ${Q.length-Y.offset} bytes after deserialized data`);return X}K0.deserialize=OM;function NM($,J,Q,G=R1){let Y=new G(Q);return cJ($,J,Y)}K0.deserializeUnchecked=NM});var WQ=c1((uY)=>{Object.defineProperty(uY,"__esModule",{value:!0});uY.s16=uY.s8=uY.nu64be=uY.u48be=uY.u40be=uY.u32be=uY.u24be=uY.u16be=uY.nu64=uY.u48=uY.u40=uY.u32=uY.u24=uY.u16=uY.u8=uY.offset=uY.greedy=uY.Constant=uY.UTF8=uY.CString=uY.Blob=uY.Boolean=uY.BitField=uY.BitStructure=uY.VariantLayout=uY.Union=uY.UnionLayoutDiscriminator=uY.UnionDiscriminator=uY.Structure=uY.Sequence=uY.DoubleBE=uY.Double=uY.FloatBE=uY.Float=uY.NearInt64BE=uY.NearInt64=uY.NearUInt64BE=uY.NearUInt64=uY.IntBE=uY.Int=uY.UIntBE=uY.UInt=uY.OffsetLayout=uY.GreedyCount=uY.ExternalLayout=uY.bindConstructorLayout=uY.nameWithProperty=uY.Layout=uY.uint8ArrayToBuffer=uY.checkUint8Array=void 0;uY.constant=uY.utf8=uY.cstr=uY.blob=uY.unionLayoutDiscriminator=uY.union=uY.seq=uY.bits=uY.struct=uY.f64be=uY.f64=uY.f32be=uY.f32=uY.ns64be=uY.s48be=uY.s40be=uY.s32be=uY.s24be=uY.s16be=uY.ns64=uY.s48=uY.s40=uY.s32=uY.s24=void 0;var dJ=(u8(),m8(c2));function s8($){if(!($ instanceof Uint8Array))throw TypeError("b must be a Uint8Array")}uY.checkUint8Array=s8;function G0($){return s8($),dJ.Buffer.from($.buffer,$.byteOffset,$.length)}uY.uint8ArrayToBuffer=G0;class Z0{constructor($,J){if(!Number.isInteger($))throw TypeError("span must be an integer");this.span=$,this.property=J}makeDestinationObject(){return{}}getSpan($,J){if(0>this.span)throw RangeError("indeterminate span");return this.span}replicate($){let J=Object.create(this.constructor.prototype);return Object.assign(J,this),J.property=$,J}fromArray($){return}}uY.Layout=Z0;function nJ($,J){if(J.property)return $+"["+J.property+"]";return $}uY.nameWithProperty=nJ;function kM($,J){if(typeof $!=="function")throw TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call($,"layout_"))throw Error("Class is already bound to a layout");if(!(J&&J instanceof Z0))throw TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(J,"boundConstructor_"))throw Error("layout is already bound to a constructor");$.layout_=J,J.boundConstructor_=$,J.makeDestinationObject=()=>new $,Object.defineProperty($.prototype,"encode",{value(Q,G){return J.encode(this,Q,G)},writable:!0}),Object.defineProperty($,"decode",{value(Q,G){return J.decode(Q,G)},writable:!0})}uY.bindConstructorLayout=kM;class H1 extends Z0{isCount(){throw Error("ExternalLayout is abstract")}}uY.ExternalLayout=H1;class iJ extends H1{constructor($=1,J){if(!Number.isInteger($)||0>=$)throw TypeError("elementSpan must be a (positive) integer");super(-1,J);this.elementSpan=$}isCount(){return!0}decode($,J=0){s8($);let Q=$.length-J;return Math.floor(Q/this.elementSpan)}encode($,J,Q){return 0}}uY.GreedyCount=iJ;class K$ extends H1{constructor($,J=0,Q){if(!($ instanceof Z0))throw TypeError("layout must be a Layout");if(!Number.isInteger(J))throw TypeError("offset must be integer or undefined");super($.span,Q||$.property);this.layout=$,this.offset=J}isCount(){return this.layout instanceof P1||this.layout instanceof B1}decode($,J=0){return this.layout.decode($,J+this.offset)}encode($,J,Q=0){return this.layout.encode($,J,Q+this.offset)}}uY.OffsetLayout=K$;class P1 extends Z0{constructor($,J){super($,J);if(6<this.span)throw RangeError("span must not exceed 6 bytes")}decode($,J=0){return G0($).readUIntLE(J,this.span)}encode($,J,Q=0){return G0(J).writeUIntLE($,Q,this.span),this.span}}uY.UInt=P1;class B1 extends Z0{constructor($,J){super($,J);if(6<this.span)throw RangeError("span must not exceed 6 bytes")}decode($,J=0){return G0($).readUIntBE(J,this.span)}encode($,J,Q=0){return G0(J).writeUIntBE($,Q,this.span),this.span}}uY.UIntBE=B1;class z8 extends Z0{constructor($,J){super($,J);if(6<this.span)throw RangeError("span must not exceed 6 bytes")}decode($,J=0){return G0($).readIntLE(J,this.span)}encode($,J,Q=0){return G0(J).writeIntLE($,Q,this.span),this.span}}uY.Int=z8;class v8 extends Z0{constructor($,J){super($,J);if(6<this.span)throw RangeError("span must not exceed 6 bytes")}decode($,J=0){return G0($).readIntBE(J,this.span)}encode($,J,Q=0){return G0(J).writeIntBE($,Q,this.span),this.span}}uY.IntBE=v8;var lJ=Math.pow(2,32);function q$($){let J=Math.floor($/lJ),Q=$-J*lJ;return{hi32:J,lo32:Q}}function W$($,J){return $*lJ+J}class rJ extends Z0{constructor($){super(8,$)}decode($,J=0){let Q=G0($),G=Q.readUInt32LE(J),Y=Q.readUInt32LE(J+4);return W$(Y,G)}encode($,J,Q=0){let G=q$($),Y=G0(J);return Y.writeUInt32LE(G.lo32,Q),Y.writeUInt32LE(G.hi32,Q+4),8}}uY.NearUInt64=rJ;class oJ extends Z0{constructor($){super(8,$)}decode($,J=0){let Q=G0($),G=Q.readUInt32BE(J),Y=Q.readUInt32BE(J+4);return W$(G,Y)}encode($,J,Q=0){let G=q$($),Y=G0(J);return Y.writeUInt32BE(G.hi32,Q),Y.writeUInt32BE(G.lo32,Q+4),8}}uY.NearUInt64BE=oJ;class aJ extends Z0{constructor($){super(8,$)}decode($,J=0){let Q=G0($),G=Q.readUInt32LE(J),Y=Q.readInt32LE(J+4);return W$(Y,G)}encode($,J,Q=0){let G=q$($),Y=G0(J);return Y.writeUInt32LE(G.lo32,Q),Y.writeInt32LE(G.hi32,Q+4),8}}uY.NearInt64=aJ;class sJ extends Z0{constructor($){super(8,$)}decode($,J=0){let Q=G0($),G=Q.readInt32BE(J),Y=Q.readUInt32BE(J+4);return W$(G,Y)}encode($,J,Q=0){let G=q$($),Y=G0(J);return Y.writeInt32BE(G.hi32,Q),Y.writeUInt32BE(G.lo32,Q+4),8}}uY.NearInt64BE=sJ;class tJ extends Z0{constructor($){super(4,$)}decode($,J=0){return G0($).readFloatLE(J)}encode($,J,Q=0){return G0(J).writeFloatLE($,Q),4}}uY.Float=tJ;class eJ extends Z0{constructor($){super(4,$)}decode($,J=0){return G0($).readFloatBE(J)}encode($,J,Q=0){return G0(J).writeFloatBE($,Q),4}}uY.FloatBE=eJ;class $Q extends Z0{constructor($){super(8,$)}decode($,J=0){return G0($).readDoubleLE(J)}encode($,J,Q=0){return G0(J).writeDoubleLE($,Q),8}}uY.Double=$Q;class JQ extends Z0{constructor($){super(8,$)}decode($,J=0){return G0($).readDoubleBE(J)}encode($,J,Q=0){return G0(J).writeDoubleBE($,Q),8}}uY.DoubleBE=JQ;class QQ extends Z0{constructor($,J,Q){if(!($ instanceof Z0))throw TypeError("elementLayout must be a Layout");if(!(J instanceof H1&&J.isCount()||Number.isInteger(J)&&0<=J))throw TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let G=-1;if(!(J instanceof H1)&&0<$.span)G=J*$.span;super(G,Q);this.elementLayout=$,this.count=J}getSpan($,J=0){if(0<=this.span)return this.span;let Q=0,G=this.count;if(G instanceof H1)G=G.decode($,J);if(0<this.elementLayout.span)Q=G*this.elementLayout.span;else{let Y=0;while(Y<G)Q+=this.elementLayout.getSpan($,J+Q),++Y}return Q}decode($,J=0){let Q=[],G=0,Y=this.count;if(Y instanceof H1)Y=Y.decode($,J);while(G<Y)Q.push(this.elementLayout.decode($,J)),J+=this.elementLayout.getSpan($,J),G+=1;return Q}encode($,J,Q=0){let G=this.elementLayout,Y=$.reduce((X,M)=>{return X+G.encode(M,J,Q+X)},0);if(this.count instanceof H1)this.count.encode($.length,J,Q);return Y}}uY.Sequence=QQ;class GQ extends Z0{constructor($,J,Q){if(!(Array.isArray($)&&$.reduce((Y,X)=>Y&&X instanceof Z0,!0)))throw TypeError("fields must be array of Layout instances");if(typeof J==="boolean"&&Q===void 0)Q=J,J=void 0;for(let Y of $)if(0>Y.span&&Y.property===void 0)throw Error("fields cannot contain unnamed variable-length layout");let G=-1;try{G=$.reduce((Y,X)=>Y+X.getSpan(),0)}catch(Y){}super(G,J);this.fields=$,this.decodePrefixes=!!Q}getSpan($,J=0){if(0<=this.span)return this.span;let Q=0;try{Q=this.fields.reduce((G,Y)=>{let X=Y.getSpan($,J);return J+=X,G+X},0)}catch(G){throw RangeError("indeterminate span")}return Q}decode($,J=0){s8($);let Q=this.makeDestinationObject();for(let G of this.fields){if(G.property!==void 0)Q[G.property]=G.decode($,J);if(J+=G.getSpan($,J),this.decodePrefixes&&$.length===J)break}return Q}encode($,J,Q=0){let G=Q,Y=0,X=0;for(let M of this.fields){let I=M.span;if(X=0<I?I:0,M.property!==void 0){let U=$[M.property];if(U!==void 0){if(X=M.encode(U,J,Q),0>I)I=M.getSpan(J,Q)}}Y=Q,Q+=I}return Y+X-G}fromArray($){let J=this.makeDestinationObject();for(let Q of this.fields)if(Q.property!==void 0&&0<$.length)J[Q.property]=$.shift();return J}layoutFor($){if(typeof $!=="string")throw TypeError("property must be string");for(let J of this.fields)if(J.property===$)return J;return}offsetOf($){if(typeof $!=="string")throw TypeError("property must be string");let J=0;for(let Q of this.fields){if(Q.property===$)return J;if(0>Q.span)J=-1;else if(0<=J)J+=Q.span}return}}uY.Structure=GQ;class U${constructor($){this.property=$}decode($,J){throw Error("UnionDiscriminator is abstract")}encode($,J,Q){throw Error("UnionDiscriminator is abstract")}}uY.UnionDiscriminator=U$;class T2 extends U${constructor($,J){if(!($ instanceof H1&&$.isCount()))throw TypeError("layout must be an unsigned integer ExternalLayout");super(J||$.property||"variant");this.layout=$}decode($,J){return this.layout.decode($,J)}encode($,J,Q){return this.layout.encode($,J,Q)}}uY.UnionLayoutDiscriminator=T2;class I$ extends Z0{constructor($,J,Q){let G;if($ instanceof P1||$ instanceof B1)G=new T2(new K$($));else if($ instanceof H1&&$.isCount())G=new T2($);else if(!($ instanceof U$))throw TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");else G=$;if(J===void 0)J=null;if(!(J===null||J instanceof Z0))throw TypeError("defaultLayout must be null or a Layout");if(J!==null){if(0>J.span)throw Error("defaultLayout must have constant span");if(J.property===void 0)J=J.replicate("content")}let Y=-1;if(J){if(Y=J.span,0<=Y&&($ instanceof P1||$ instanceof B1))Y+=G.layout.span}super(Y,Q);this.discriminator=G,this.usesPrefixDiscriminator=$ instanceof P1||$ instanceof B1,this.defaultLayout=J,this.registry={};let X=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(M){return X(M)},this.configGetSourceVariant=function(M){X=M.bind(this)}}getSpan($,J=0){if(0<=this.span)return this.span;let Q=this.getVariant($,J);if(!Q)throw Error("unable to determine span for unrecognized variant");return Q.getSpan($,J)}defaultGetSourceVariant($){if(Object.prototype.hasOwnProperty.call($,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call($,this.defaultLayout.property))return;let J=this.registry[$[this.discriminator.property]];if(J&&(!J.layout||J.property&&Object.prototype.hasOwnProperty.call($,J.property)))return J}else for(let J in this.registry){let Q=this.registry[J];if(Q.property&&Object.prototype.hasOwnProperty.call($,Q.property))return Q}throw Error("unable to infer src variant")}decode($,J=0){let Q,G=this.discriminator,Y=G.decode($,J),X=this.registry[Y];if(X===void 0){let M=this.defaultLayout,I=0;if(this.usesPrefixDiscriminator)I=G.layout.span;Q=this.makeDestinationObject(),Q[G.property]=Y,Q[M.property]=M.decode($,J+I)}else Q=X.decode($,J);return Q}encode($,J,Q=0){let G=this.getSourceVariant($);if(G===void 0){let Y=this.discriminator,X=this.defaultLayout,M=0;if(this.usesPrefixDiscriminator)M=Y.layout.span;return Y.encode($[Y.property],J,Q),M+X.encode($[X.property],J,Q+M)}return G.encode($,J,Q)}addVariant($,J,Q){let G=new YQ(this,$,J,Q);return this.registry[$]=G,G}getVariant($,J=0){let Q;if($ instanceof Uint8Array)Q=this.discriminator.decode($,J);else Q=$;return this.registry[Q]}}uY.Union=I$;class YQ extends Z0{constructor($,J,Q,G){if(!($ instanceof I$))throw TypeError("union must be a Union");if(!Number.isInteger(J)||0>J)throw TypeError("variant must be a (non-negative) integer");if(typeof Q==="string"&&G===void 0)G=Q,Q=null;if(Q){if(!(Q instanceof Z0))throw TypeError("layout must be a Layout");if($.defaultLayout!==null&&0<=Q.span&&Q.span>$.defaultLayout.span)throw Error("variant span exceeds span of containing union");if(typeof G!=="string")throw TypeError("variant must have a String property")}let Y=$.span;if(0>$.span){if(Y=Q?Q.span:0,0<=Y&&$.usesPrefixDiscriminator)Y+=$.discriminator.layout.span}super(Y,G);this.union=$,this.variant=J,this.layout=Q||null}getSpan($,J=0){if(0<=this.span)return this.span;let Q=0;if(this.union.usesPrefixDiscriminator)Q=this.union.discriminator.layout.span;let G=0;if(this.layout)G=this.layout.getSpan($,J+Q);return Q+G}decode($,J=0){let Q=this.makeDestinationObject();if(this!==this.union.getVariant($,J))throw Error("variant mismatch");let G=0;if(this.union.usesPrefixDiscriminator)G=this.union.discriminator.layout.span;if(this.layout)Q[this.property]=this.layout.decode($,J+G);else if(this.property)Q[this.property]=!0;else if(this.union.usesPrefixDiscriminator)Q[this.union.discriminator.property]=this.variant;return Q}encode($,J,Q=0){let G=0;if(this.union.usesPrefixDiscriminator)G=this.union.discriminator.layout.span;if(this.layout&&!Object.prototype.hasOwnProperty.call($,this.property))throw TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,J,Q);let Y=G;if(this.layout){if(this.layout.encode($[this.property],J,Q+G),Y+=this.layout.getSpan(J,Q+G),0<=this.union.span&&Y>this.union.span)throw Error("encoded variant overruns containing union")}return Y}fromArray($){if(this.layout)return this.layout.fromArray($);return}}uY.VariantLayout=YQ;function a8($){if(0>$)$+=4294967296;return $}class D$ extends Z0{constructor($,J,Q){if(!($ instanceof P1||$ instanceof B1))throw TypeError("word must be a UInt or UIntBE layout");if(typeof J==="string"&&Q===void 0)Q=J,J=!1;if(4<$.span)throw RangeError("word cannot exceed 32 bits");super($.span,Q);this.word=$,this.msb=!!J,this.fields=[];let G=0;this._packedSetValue=function(Y){return G=a8(Y),this},this._packedGetValue=function(){return G}}decode($,J=0){let Q=this.makeDestinationObject(),G=this.word.decode($,J);this._packedSetValue(G);for(let Y of this.fields)if(Y.property!==void 0)Q[Y.property]=Y.decode($);return Q}encode($,J,Q=0){let G=this.word.decode(J,Q);this._packedSetValue(G);for(let Y of this.fields)if(Y.property!==void 0){let X=$[Y.property];if(X!==void 0)Y.encode(X)}return this.word.encode(this._packedGetValue(),J,Q)}addField($,J){let Q=new V$(this,$,J);return this.fields.push(Q),Q}addBoolean($){let J=new XQ(this,$);return this.fields.push(J),J}fieldFor($){if(typeof $!=="string")throw TypeError("property must be string");for(let J of this.fields)if(J.property===$)return J;return}}uY.BitStructure=D$;class V${constructor($,J,Q){if(!($ instanceof D$))throw TypeError("container must be a BitStructure");if(!Number.isInteger(J)||0>=J)throw TypeError("bits must be positive integer");let G=8*$.span,Y=$.fields.reduce((X,M)=>X+M.bits,0);if(J+Y>G)throw Error("bits too long for span remainder ("+(G-Y)+" of "+G+" remain)");if(this.container=$,this.bits=J,this.valueMask=(1<<J)-1,J===32)this.valueMask=4294967295;if(this.start=Y,this.container.msb)this.start=G-Y-J;this.wordMask=a8(this.valueMask<<this.start),this.property=Q}decode($,J){let Q=this.container._packedGetValue();return a8(Q&this.wordMask)>>>this.start}encode($){if(typeof $!=="number"||!Number.isInteger($)||$!==a8($&this.valueMask))throw TypeError(nJ("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);let J=this.container._packedGetValue(),Q=a8($<<this.start);this.container._packedSetValue(a8(J&~this.wordMask)|Q)}}uY.BitField=V$;class XQ extends V${constructor($,J){super($,1,J)}decode($,J){return!!super.decode($,J)}encode($){if(typeof $==="boolean")$=+$;super.encode($)}}uY.Boolean=XQ;class ZQ extends Z0{constructor($,J){if(!($ instanceof H1&&$.isCount()||Number.isInteger($)&&0<=$))throw TypeError("length must be positive integer or an unsigned integer ExternalLayout");let Q=-1;if(!($ instanceof H1))Q=$;super(Q,J);this.length=$}getSpan($,J){let Q=this.span;if(0>Q)Q=this.length.decode($,J);return Q}decode($,J=0){let Q=this.span;if(0>Q)Q=this.length.decode($,J);return G0($).slice(J,J+Q)}encode($,J,Q){let G=this.length;if(this.length instanceof H1)G=$.length;if(!($ instanceof Uint8Array&&G===$.length))throw TypeError(nJ("Blob.encode",this)+" requires (length "+G+") Uint8Array as src");if(Q+G>J.length)throw RangeError("encoding overruns Uint8Array");let Y=G0($);if(G0(J).write(Y.toString("hex"),Q,G,"hex"),this.length instanceof H1)this.length.encode(G,J,Q);return G}}uY.Blob=ZQ;class MQ extends Z0{constructor($){super(-1,$)}getSpan($,J=0){s8($);let Q=J;while(Q<$.length&&$[Q]!==0)Q+=1;return 1+Q-J}decode($,J=0){let Q=this.getSpan($,J);return G0($).slice(J,J+Q-1).toString("utf-8")}encode($,J,Q=0){if(typeof $!=="string")$=String($);let G=dJ.Buffer.from($,"utf8"),Y=G.length;if(Q+Y>J.length)throw RangeError("encoding overruns Buffer");let X=G0(J);return G.copy(X,Q),X[Q+Y]=0,Y+1}}uY.CString=MQ;class KQ extends Z0{constructor($,J){if(typeof $==="string"&&J===void 0)J=$,$=void 0;if($===void 0)$=-1;else if(!Number.isInteger($))throw TypeError("maxSpan must be an integer");super(-1,J);this.maxSpan=$}getSpan($,J=0){return s8($),$.length-J}decode($,J=0){let Q=this.getSpan($,J);if(0<=this.maxSpan&&this.maxSpan<Q)throw RangeError("text length exceeds maxSpan");return G0($).slice(J,J+Q).toString("utf-8")}encode($,J,Q=0){if(typeof $!=="string")$=String($);let G=dJ.Buffer.from($,"utf8"),Y=G.length;if(0<=this.maxSpan&&this.maxSpan<Y)throw RangeError("text length exceeds maxSpan");if(Q+Y>J.length)throw RangeError("encoding overruns Buffer");return G.copy(G0(J),Q),Y}}uY.UTF8=KQ;class qQ extends Z0{constructor($,J){super(0,J);this.value=$}decode($,J){return this.value}encode($,J,Q){return 0}}uY.Constant=qQ;uY.greedy=($,J)=>new iJ($,J);uY.offset=($,J,Q)=>new K$($,J,Q);uY.u8=($)=>new P1(1,$);uY.u16=($)=>new P1(2,$);uY.u24=($)=>new P1(3,$);uY.u32=($)=>new P1(4,$);uY.u40=($)=>new P1(5,$);uY.u48=($)=>new P1(6,$);uY.nu64=($)=>new rJ($);uY.u16be=($)=>new B1(2,$);uY.u24be=($)=>new B1(3,$);uY.u32be=($)=>new B1(4,$);uY.u40be=($)=>new B1(5,$);uY.u48be=($)=>new B1(6,$);uY.nu64be=($)=>new oJ($);uY.s8=($)=>new z8(1,$);uY.s16=($)=>new z8(2,$);uY.s24=($)=>new z8(3,$);uY.s32=($)=>new z8(4,$);uY.s40=($)=>new z8(5,$);uY.s48=($)=>new z8(6,$);uY.ns64=($)=>new aJ($);uY.s16be=($)=>new v8(2,$);uY.s24be=($)=>new v8(3,$);uY.s32be=($)=>new v8(4,$);uY.s40be=($)=>new v8(5,$);uY.s48be=($)=>new v8(6,$);uY.ns64be=($)=>new sJ($);uY.f32=($)=>new tJ($);uY.f32be=($)=>new eJ($);uY.f64=($)=>new $Q($);uY.f64be=($)=>new JQ($);uY.struct=($,J,Q)=>new GQ($,J,Q);uY.bits=($,J,Q)=>new D$($,J,Q);uY.seq=($,J,Q)=>new QQ($,J,Q);uY.union=($,J,Q)=>new I$($,J,Q);uY.unionLayoutDiscriminator=($,J)=>new T2($,J);uY.blob=($,J)=>new ZQ($,J);uY.cstr=($)=>new MQ($);uY.utf8=($,J)=>new KQ($,J);uY.constant=($,J)=>new qQ($,J)});function N2(){if(!C$){if(C$=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues==="function"&&msCrypto.getRandomValues.bind(msCrypto),!C$)throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported")}return C$(Q4)}var C$,Q4;var TQ=Y1(()=>{Q4=new Uint8Array(16)});var qX;var WX=Y1(()=>{qX=/^(?:[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 G4($){return typeof $==="string"&&qX.test($)}var j8;var k2=Y1(()=>{WX();j8=G4});function Y4($){var J=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,Q=(G1[$[J+0]]+G1[$[J+1]]+G1[$[J+2]]+G1[$[J+3]]+"-"+G1[$[J+4]]+G1[$[J+5]]+"-"+G1[$[J+6]]+G1[$[J+7]]+"-"+G1[$[J+8]]+G1[$[J+9]]+"-"+G1[$[J+10]]+G1[$[J+11]]+G1[$[J+12]]+G1[$[J+13]]+G1[$[J+14]]+G1[$[J+15]]).toLowerCase();if(!j8(Q))throw TypeError("Stringified UUID is invalid");return Q}var G1,P2,C8;var L2=Y1(()=>{k2();G1=[];for(P2=0;P2<256;++P2)G1.push((P2+256).toString(16).substr(1));C8=Y4});function X4($,J,Q){var G=J&&Q||0,Y=J||Array(16);$=$||{};var X=$.node||UX,M=$.clockseq!==void 0?$.clockseq:RQ;if(X==null||M==null){var I=$.random||($.rng||N2)();if(X==null)X=UX=[I[0]|1,I[1],I[2],I[3],I[4],I[5]];if(M==null)M=RQ=(I[6]<<8|I[7])&16383}var U=$.msecs!==void 0?$.msecs:Date.now(),T=$.nsecs!==void 0?$.nsecs:NQ+1,A=U-OQ+(T-NQ)/1e4;if(A<0&&$.clockseq===void 0)M=M+1&16383;if((A<0||U>OQ)&&$.nsecs===void 0)T=0;if(T>=1e4)throw Error("uuid.v1(): Can't create more than 10M uuids/sec");OQ=U,NQ=T,RQ=M,U+=12219292800000;var L=((U&268435455)*1e4+T)%4294967296;Y[G++]=L>>>24&255,Y[G++]=L>>>16&255,Y[G++]=L>>>8&255,Y[G++]=L&255;var N=U/4294967296*1e4&268435455;Y[G++]=N>>>8&255,Y[G++]=N&255,Y[G++]=N>>>24&15|16,Y[G++]=N>>>16&255,Y[G++]=M>>>8|128,Y[G++]=M&255;for(var k=0;k<6;++k)Y[G+k]=X[k];return J||C8(Y)}var UX,RQ,OQ=0,NQ=0,IX;var DX=Y1(()=>{TQ();L2();IX=X4});function Z4($){if(!j8($))throw TypeError("Invalid UUID");var J,Q=new Uint8Array(16);return Q[0]=(J=parseInt($.slice(0,8),16))>>>24,Q[1]=J>>>16&255,Q[2]=J>>>8&255,Q[3]=J&255,Q[4]=(J=parseInt($.slice(9,13),16))>>>8,Q[5]=J&255,Q[6]=(J=parseInt($.slice(14,18),16))>>>8,Q[7]=J&255,Q[8]=(J=parseInt($.slice(19,23),16))>>>8,Q[9]=J&255,Q[10]=(J=parseInt($.slice(24,36),16))/1099511627776&255,Q[11]=J/4294967296&255,Q[12]=J>>>24&255,Q[13]=J>>>16&255,Q[14]=J>>>8&255,Q[15]=J&255,Q}var A$;var kQ=Y1(()=>{k2();A$=Z4});function M4($){$=unescape(encodeURIComponent($));var J=[];for(var Q=0;Q<$.length;++Q)J.push($.charCodeAt(Q));return J}function S2($,J,Q){function G(Y,X,M,I){if(typeof Y==="string")Y=M4(Y);if(typeof X==="string")X=A$(X);if(X.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var U=new Uint8Array(16+Y.length);if(U.set(X),U.set(Y,X.length),U=Q(U),U[6]=U[6]&15|J,U[8]=U[8]&63|128,M){I=I||0;for(var T=0;T<16;++T)M[I+T]=U[T];return M}return C8(U)}try{G.name=$}catch(Y){}return G.DNS=K4,G.URL=q4,G}var K4="6ba7b810-9dad-11d1-80b4-00c04fd430c8",q4="6ba7b811-9dad-11d1-80b4-00c04fd430c8";var PQ=Y1(()=>{L2();kQ()});function W4($){if(typeof $==="string"){var J=unescape(encodeURIComponent($));$=new Uint8Array(J.length);for(var Q=0;Q<J.length;++Q)$[Q]=J.charCodeAt(Q)}return U4(I4(D4($),$.length*8))}function U4($){var J=[],Q=$.length*32,G="0123456789abcdef";for(var Y=0;Y<Q;Y+=8){var X=$[Y>>5]>>>Y%32&255,M=parseInt(G.charAt(X>>>4&15)+G.charAt(X&15),16);J.push(M)}return J}function VX($){return($+64>>>9<<4)+14+1}function I4($,J){$[J>>5]|=128<<J%32,$[VX(J)-1]=J;var Q=1732584193,G=-271733879,Y=-1732584194,X=271733878;for(var M=0;M<$.length;M+=16){var I=Q,U=G,T=Y,A=X;Q=M1(Q,G,Y,X,$[M],7,-680876936),X=M1(X,Q,G,Y,$[M+1],12,-389564586),Y=M1(Y,X,Q,G,$[M+2],17,606105819),G=M1(G,Y,X,Q,$[M+3],22,-1044525330),Q=M1(Q,G,Y,X,$[M+4],7,-176418897),X=M1(X,Q,G,Y,$[M+5],12,1200080426),Y=M1(Y,X,Q,G,$[M+6],17,-1473231341),G=M1(G,Y,X,Q,$[M+7],22,-45705983),Q=M1(Q,G,Y,X,$[M+8],7,1770035416),X=M1(X,Q,G,Y,$[M+9],12,-1958414417),Y=M1(Y,X,Q,G,$[M+10],17,-42063),G=M1(G,Y,X,Q,$[M+11],22,-1990404162),Q=M1(Q,G,Y,X,$[M+12],7,1804603682),X=M1(X,Q,G,Y,$[M+13],12,-40341101),Y=M1(Y,X,Q,G,$[M+14],17,-1502002290),G=M1(G,Y,X,Q,$[M+15],22,1236535329),Q=K1(Q,G,Y,X,$[M+1],5,-165796510),X=K1(X,Q,G,Y,$[M+6],9,-1069501632),Y=K1(Y,X,Q,G,$[M+11],14,643717713),G=K1(G,Y,X,Q,$[M],20,-373897302),Q=K1(Q,G,Y,X,$[M+5],5,-701558691),X=K1(X,Q,G,Y,$[M+10],9,38016083),Y=K1(Y,X,Q,G,$[M+15],14,-660478335),G=K1(G,Y,X,Q,$[M+4],20,-405537848),Q=K1(Q,G,Y,X,$[M+9],5,568446438),X=K1(X,Q,G,Y,$[M+14],9,-1019803690),Y=K1(Y,X,Q,G,$[M+3],14,-187363961),G=K1(G,Y,X,Q,$[M+8],20,1163531501),Q=K1(Q,G,Y,X,$[M+13],5,-1444681467),X=K1(X,Q,G,Y,$[M+2],9,-51403784),Y=K1(Y,X,Q,G,$[M+7],14,1735328473),G=K1(G,Y,X,Q,$[M+12],20,-1926607734),Q=q1(Q,G,Y,X,$[M+5],4,-378558),X=q1(X,Q,G,Y,$[M+8],11,-2022574463),Y=q1(Y,X,Q,G,$[M+11],16,1839030562),G=q1(G,Y,X,Q,$[M+14],23,-35309556),Q=q1(Q,G,Y,X,$[M+1],4,-1530992060),X=q1(X,Q,G,Y,$[M+4],11,1272893353),Y=q1(Y,X,Q,G,$[M+7],16,-155497632),G=q1(G,Y,X,Q,$[M+10],23,-1094730640),Q=q1(Q,G,Y,X,$[M+13],4,681279174),X=q1(X,Q,G,Y,$[M],11,-358537222),Y=q1(Y,X,Q,G,$[M+3],16,-722521979),G=q1(G,Y,X,Q,$[M+6],23,76029189),Q=q1(Q,G,Y,X,$[M+9],4,-640364487),X=q1(X,Q,G,Y,$[M+12],11,-421815835),Y=q1(Y,X,Q,G,$[M+15],16,530742520),G=q1(G,Y,X,Q,$[M+2],23,-995338651),Q=W1(Q,G,Y,X,$[M],6,-198630844),X=W1(X,Q,G,Y,$[M+7],10,1126891415),Y=W1(Y,X,Q,G,$[M+14],15,-1416354905),G=W1(G,Y,X,Q,$[M+5],21,-57434055),Q=W1(Q,G,Y,X,$[M+12],6,1700485571),X=W1(X,Q,G,Y,$[M+3],10,-1894986606),Y=W1(Y,X,Q,G,$[M+10],15,-1051523),G=W1(G,Y,X,Q,$[M+1],21,-2054922799),Q=W1(Q,G,Y,X,$[M+8],6,1873313359),X=W1(X,Q,G,Y,$[M+15],10,-30611744),Y=W1(Y,X,Q,G,$[M+6],15,-1560198380),G=W1(G,Y,X,Q,$[M+13],21,1309151649),Q=W1(Q,G,Y,X,$[M+4],6,-145523070),X=W1(X,Q,G,Y,$[M+11],10,-1120210379),Y=W1(Y,X,Q,G,$[M+2],15,718787259),G=W1(G,Y,X,Q,$[M+9],21,-343485551),Q=A8(Q,I),G=A8(G,U),Y=A8(Y,T),X=A8(X,A)}return[Q,G,Y,X]}function D4($){if($.length===0)return[];var J=$.length*8,Q=new Uint32Array(VX(J));for(var G=0;G<J;G+=8)Q[G>>5]|=($[G/8]&255)<<G%32;return Q}function A8($,J){var Q=($&65535)+(J&65535),G=($>>16)+(J>>16)+(Q>>16);return G<<16|Q&65535}function V4($,J){return $<<J|$>>>32-J}function T$($,J,Q,G,Y,X){return A8(V4(A8(A8(J,$),A8(G,X)),Y),Q)}function M1($,J,Q,G,Y,X,M){return T$(J&Q|~J&G,$,J,Y,X,M)}function K1($,J,Q,G,Y,X,M){return T$(J&G|Q&~G,$,J,Y,X,M)}function q1($,J,Q,G,Y,X,M){return T$(J^Q^G,$,J,Y,X,M)}function W1($,J,Q,G,Y,X,M){return T$(Q^(J|~G),$,J,Y,X,M)}var zX;var HX=Y1(()=>{zX=W4});var z4,jX;var CX=Y1(()=>{PQ();HX();z4=S2("v3",48,zX),jX=z4});function H4($,J,Q){$=$||{};var G=$.random||($.rng||N2)();if(G[6]=G[6]&15|64,G[8]=G[8]&63|128,J){Q=Q||0;for(var Y=0;Y<16;++Y)J[Q+Y]=G[Y];return J}return C8(G)}var AX;var TX=Y1(()=>{TQ();L2();AX=H4});function j4($,J,Q,G){switch($){case 0:return J&Q^~J&G;case 1:return J^Q^G;case 2:return J&Q^J&G^Q&G;case 3:return J^Q^G}}function LQ($,J){return $<<J|$>>>32-J}function C4($){var J=[1518500249,1859775393,2400959708,3395469782],Q=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof $==="string"){var G=unescape(encodeURIComponent($));$=[];for(var Y=0;Y<G.length;++Y)$.push(G.charCodeAt(Y))}else if(!Array.isArray($))$=Array.prototype.slice.call($);$.push(128);var X=$.length/4+2,M=Math.ceil(X/16),I=Array(M);for(var U=0;U<M;++U){var T=new Uint32Array(16);for(var A=0;A<16;++A)T[A]=$[U*64+A*4]<<24|$[U*64+A*4+1]<<16|$[U*64+A*4+2]<<8|$[U*64+A*4+3];I[U]=T}I[M-1][14]=($.length-1)*8/Math.pow(2,32),I[M-1][14]=Math.floor(I[M-1][14]),I[M-1][15]=($.length-1)*8&4294967295;for(var L=0;L<M;++L){var N=new Uint32Array(80);for(var k=0;k<16;++k)N[k]=I[L][k];for(var P=16;P<80;++P)N[P]=LQ(N[P-3]^N[P-8]^N[P-14]^N[P-16],1);var F=Q[0],B=Q[1],_=Q[2],h=Q[3],f=Q[4];for(var c=0;c<80;++c){var s=Math.floor(c/20),o=LQ(F,5)+j4(s,B,_,h)+f+J[s]+N[c]>>>0;f=h,h=_,_=LQ(B,30)>>>0,B=F,F=o}Q[0]=Q[0]+F>>>0,Q[1]=Q[1]+B>>>0,Q[2]=Q[2]+_>>>0,Q[3]=Q[3]+h>>>0,Q[4]=Q[4]+f>>>0}return[Q[0]>>24&255,Q[0]>>16&255,Q[0]>>8&255,Q[0]&255,Q[1]>>24&255,Q[1]>>16&255,Q[1]>>8&255,Q[1]&255,Q[2]>>24&255,Q[2]>>16&255,Q[2]>>8&255,Q[2]&255,Q[3]>>24&255,Q[3]>>16&255,Q[3]>>8&255,Q[3]&255,Q[4]>>24&255,Q[4]>>16&255,Q[4]>>8&255,Q[4]&255]}var RX;var OX=Y1(()=>{RX=C4});var A4,NX;var kX=Y1(()=>{PQ();OX();A4=S2("v5",80,RX),NX=A4});var PX="00000000-0000-0000-0000-000000000000";function R4($){if(!j8($))throw TypeError("Invalid UUID");return parseInt($.substr(14,1),16)}var LX;var SX=Y1(()=>{k2();LX=R4});var SQ={};$J(SQ,{version:()=>LX,validate:()=>j8,v5:()=>NX,v4:()=>AX,v3:()=>jX,v1:()=>IX,stringify:()=>C8,parse:()=>A$,NIL:()=>PX});var EQ=Y1(()=>{DX();CX();TX();kX();SX();k2();L2();kQ()});var BX=c1((R9,EX)=>{var O4=(EQ(),m8(SQ)).v4,N4=function($,J,Q,G){if(typeof $!=="string")throw TypeError($+" must be a string");G=G||{};let Y=typeof G.version==="number"?G.version:2;if(Y!==1&&Y!==2)throw TypeError(Y+" must be 1 or 2");let X={method:$};if(Y===2)X.jsonrpc="2.0";if(J){if(typeof J!=="object"&&!Array.isArray(J))throw TypeError(J+" must be an object, array or omitted");X.params=J}if(typeof Q>"u"){let M=typeof G.generator==="function"?G.generator:function(){return O4()};X.id=M(X,G)}else if(Y===2&&Q===null){if(G.notificationIdNull)X.id=null}else X.id=Q;return X};EX.exports=N4});var FX=c1((O9,wX)=>{var k4=(EQ(),m8(SQ)).v4,P4=BX(),E2=function($,J){if(!(this instanceof E2))return new E2($,J);if(!J)J={};this.options={reviver:typeof J.reviver<"u"?J.reviver:null,replacer:typeof J.replacer<"u"?J.replacer:null,generator:typeof J.generator<"u"?J.generator:function(){return k4()},version:typeof J.version<"u"?J.version:2,notificationIdNull:typeof J.notificationIdNull==="boolean"?J.notificationIdNull:!1},this.callServer=$};wX.exports=E2;E2.prototype.request=function($,J,Q,G){let Y=this,X=null,M=Array.isArray($)&&typeof J==="function";if(this.options.version===1&&M)throw TypeError("JSON-RPC 1.0 does not support batching");if(M||!M&&$&&typeof $==="object"&&typeof J==="function")G=J,X=$;else{if(typeof Q==="function")G=Q,Q=void 0;let T=typeof G==="function";try{X=P4($,J,Q,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(A){if(T){G(A);return}throw A}if(!T)return X}let U;try{U=JSON.stringify(X,this.options.replacer)}catch(T){G(T);return}return this.callServer(U,function(T,A){Y._parseResponse(T,A,G)}),X};E2.prototype._parseResponse=function($,J,Q){if($){Q($);return}if(!J){Q();return}let G;try{G=JSON.parse(J,this.options.reviver)}catch(Y){Q(Y);return}if(Q.length===3)if(Array.isArray(G)){let Y=function(M){return typeof M.error<"u"},X=function(M){return!Y(M)};Q(null,G.filter(Y),G.filter(X));return}else{Q(null,G.error,G.result);return}Q(null,G)}});var gX=c1((N9,BQ)=>{var L4=Object.prototype.hasOwnProperty,j1="~";function B2(){}if(Object.create){if(B2.prototype=Object.create(null),!new B2().__proto__)j1=!1}function S4($,J,Q){this.fn=$,this.context=J,this.once=Q||!1}function _X($,J,Q,G,Y){if(typeof Q!=="function")throw TypeError("The listener must be a function");var X=new S4(Q,G||$,Y),M=j1?j1+J:J;if(!$._events[M])$._events[M]=X,$._eventsCount++;else if(!$._events[M].fn)$._events[M].push(X);else $._events[M]=[$._events[M],X];return $}function R$($,J){if(--$._eventsCount===0)$._events=new B2;else delete $._events[J]}function U1(){this._events=new B2,this._eventsCount=0}U1.prototype.eventNames=function(){var J=[],Q,G;if(this._eventsCount===0)return J;for(G in Q=this._events)if(L4.call(Q,G))J.push(j1?G.slice(1):G);if(Object.getOwnPropertySymbols)return J.concat(Object.getOwnPropertySymbols(Q));return J};U1.prototype.listeners=function(J){var Q=j1?j1+J:J,G=this._events[Q];if(!G)return[];if(G.fn)return[G.fn];for(var Y=0,X=G.length,M=Array(X);Y<X;Y++)M[Y]=G[Y].fn;return M};U1.prototype.listenerCount=function(J){var Q=j1?j1+J:J,G=this._events[Q];if(!G)return 0;if(G.fn)return 1;return G.length};U1.prototype.emit=function(J,Q,G,Y,X,M){var I=j1?j1+J:J;if(!this._events[I])return!1;var U=this._events[I],T=arguments.length,A,L;if(U.fn){if(U.once)this.removeListener(J,U.fn,void 0,!0);switch(T){case 1:return U.fn.call(U.context),!0;case 2:return U.fn.call(U.context,Q),!0;case 3:return U.fn.call(U.context,Q,G),!0;case 4:return U.fn.call(U.context,Q,G,Y),!0;case 5:return U.fn.call(U.context,Q,G,Y,X),!0;case 6:return U.fn.call(U.context,Q,G,Y,X,M),!0}for(L=1,A=Array(T-1);L<T;L++)A[L-1]=arguments[L];U.fn.apply(U.context,A)}else{var N=U.length,k;for(L=0;L<N;L++){if(U[L].once)this.removeListener(J,U[L].fn,void 0,!0);switch(T){case 1:U[L].fn.call(U[L].context);break;case 2:U[L].fn.call(U[L].context,Q);break;case 3:U[L].fn.call(U[L].context,Q,G);break;case 4:U[L].fn.call(U[L].context,Q,G,Y);break;default:if(!A)for(k=1,A=Array(T-1);k<T;k++)A[k-1]=arguments[k];U[L].fn.apply(U[L].context,A)}}}return!0};U1.prototype.on=function(J,Q,G){return _X(this,J,Q,G,!1)};U1.prototype.once=function(J,Q,G){return _X(this,J,Q,G,!0)};U1.prototype.removeListener=function(J,Q,G,Y){var X=j1?j1+J:J;if(!this._events[X])return this;if(!Q)return R$(this,X),this;var M=this._events[X];if(M.fn){if(M.fn===Q&&(!Y||M.once)&&(!G||M.context===G))R$(this,X)}else{for(var I=0,U=[],T=M.length;I<T;I++)if(M[I].fn!==Q||Y&&!M[I].once||G&&M[I].context!==G)U.push(M[I]);if(U.length)this._events[X]=U.length===1?U[0]:U;else R$(this,X)}return this};U1.prototype.removeAllListeners=function(J){var Q;if(J){if(Q=j1?j1+J:J,this._events[Q])R$(this,Q)}else this._events=new B2,this._eventsCount=0;return this};U1.prototype.off=U1.prototype.removeListener;U1.prototype.addListener=U1.prototype.on;U1.prefixed=j1;U1.EventEmitter=U1;if(typeof BQ<"u")BQ.exports=U1});u8();var k8=typeof globalThis==="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function n1($){return $ instanceof Uint8Array||ArrayBuffer.isView($)&&$.constructor.name==="Uint8Array"}function Z8($){if(!Number.isSafeInteger($)||$<0)throw Error("positive integer expected, got "+$)}function J1($,...J){if(!n1($))throw Error("Uint8Array expected");if(J.length>0&&!J.includes($.length))throw Error("Uint8Array expected of length "+J+", got length="+$.length)}function l2($){if(typeof $!=="function"||typeof $.create!=="function")throw Error("Hash should be wrapped by utils.createHasher");Z8($.outputLen),Z8($.blockLen)}function i1($,J=!0){if($.destroyed)throw Error("Hash instance has been destroyed");if(J&&$.finished)throw Error("Hash#digest() has already been called")}function d2($,J){J1($);let Q=J.outputLen;if($.length<Q)throw Error("digestInto() expects output buffer of length at least "+Q)}function mG($){return new Uint32Array($.buffer,$.byteOffset,Math.floor($.byteLength/4))}function S1(...$){for(let J=0;J<$.length;J++)$[J].fill(0)}function n2($){return new DataView($.buffer,$.byteOffset,$.byteLength)}function F1($,J){return $<<32-J|$>>>J}var TZ=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function RZ($){return $<<24&4278190080|$<<8&16711680|$>>>8&65280|$>>>24&255}function OZ($){for(let J=0;J<$.length;J++)$[J]=RZ($[J]);return $}var WJ=TZ?($)=>$:OZ,pG=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),NZ=Array.from({length:256},($,J)=>J.toString(16).padStart(2,"0"));function E1($){if(J1($),pG)return $.toHex();let J="";for(let Q=0;Q<$.length;Q++)J+=NZ[$[Q]];return J}var d1={_0:48,_9:57,A:65,F:70,a:97,f:102};function bG($){if($>=d1._0&&$<=d1._9)return $-d1._0;if($>=d1.A&&$<=d1.F)return $-(d1.A-10);if($>=d1.a&&$<=d1.f)return $-(d1.a-10);return}function P8($){if(typeof $!=="string")throw Error("hex string expected, got "+typeof $);if(pG)return Uint8Array.fromHex($);let J=$.length,Q=J/2;if(J%2)throw Error("hex string expected, got unpadded hex of length "+J);let G=new Uint8Array(Q);for(let Y=0,X=0;Y<Q;Y++,X+=2){let M=bG($.charCodeAt(X)),I=bG($.charCodeAt(X+1));if(M===void 0||I===void 0){let U=$[X]+$[X+1];throw Error('hex string expected, got non-hex character "'+U+'" at index '+X)}G[Y]=M*16+I}return G}function UJ($){if(typeof $!=="string")throw Error("string expected");return new Uint8Array(new TextEncoder().encode($))}function L8($){if(typeof $==="string")$=UJ($);return J1($),$}function D1(...$){let J=0;for(let G=0;G<$.length;G++){let Y=$[G];J1(Y),J+=Y.length}let Q=new Uint8Array(J);for(let G=0,Y=0;G<$.length;G++){let X=$[G];Q.set(X,Y),Y+=X.length}return Q}class S8{}function U2($){let J=(G)=>$().update(L8(G)).digest(),Q=$();return J.outputLen=Q.outputLen,J.blockLen=Q.blockLen,J.create=()=>$(),J}function c8($=32){if(k8&&typeof k8.getRandomValues==="function")return k8.getRandomValues(new Uint8Array($));if(k8&&typeof k8.randomBytes==="function")return Uint8Array.from(k8.randomBytes($));throw Error("crypto.getRandomValues must be defined")}function kZ($,J,Q,G){if(typeof $.setBigUint64==="function")return $.setBigUint64(J,Q,G);let Y=BigInt(32),X=BigInt(4294967295),M=Number(Q>>Y&X),I=Number(Q&X),U=G?4:0,T=G?0:4;$.setUint32(J+U,M,G),$.setUint32(J+T,I,G)}function uG($,J,Q){return $&J^~$&Q}function cG($,J,Q){return $&J^$&Q^J&Q}class i2 extends S8{constructor($,J,Q,G){super();this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=$,this.outputLen=J,this.padOffset=Q,this.isLE=G,this.buffer=new Uint8Array($),this.view=n2(this.buffer)}update($){i1(this),$=L8($),J1($);let{view:J,buffer:Q,blockLen:G}=this,Y=$.length;for(let X=0;X<Y;){let M=Math.min(G-this.pos,Y-X);if(M===G){let I=n2($);for(;G<=Y-X;X+=G)this.process(I,X);continue}if(Q.set($.subarray(X,X+M),this.pos),this.pos+=M,X+=M,this.pos===G)this.process(J,0),this.pos=0}return this.length+=$.length,this.roundClean(),this}digestInto($){i1(this),d2($,this),this.finished=!0;let{buffer:J,view:Q,blockLen:G,isLE:Y}=this,{pos:X}=this;if(J[X++]=128,S1(this.buffer.subarray(X)),this.padOffset>G-X)this.process(Q,0),X=0;for(let A=X;A<G;A++)J[A]=0;kZ(Q,G-8,BigInt(this.length*8),Y),this.process(Q,0);let M=n2($),I=this.outputLen;if(I%4)throw Error("_sha2: outputLen should be aligned to 32bit");let U=I/4,T=this.get();if(U>T.length)throw Error("_sha2: outputLen bigger than state");for(let A=0;A<U;A++)M.setUint32(4*A,T[A],Y)}digest(){let{buffer:$,outputLen:J}=this;this.digestInto($);let Q=$.slice(0,J);return this.destroy(),Q}_cloneInto($){$||($=new this.constructor),$.set(...this.get());let{blockLen:J,buffer:Q,length:G,finished:Y,destroyed:X,pos:M}=this;if($.destroyed=X,$.finished=Y,$.length=G,$.pos=M,G%J)$.buffer.set(Q);return $}clone(){return this._cloneInto()}}var r1=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Q1=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var r2=BigInt(4294967295),lG=BigInt(32);function PZ($,J=!1){if(J)return{h:Number($&r2),l:Number($>>lG&r2)};return{h:Number($>>lG&r2)|0,l:Number($&r2)|0}}function o2($,J=!1){let Q=$.length,G=new Uint32Array(Q),Y=new Uint32Array(Q);for(let X=0;X<Q;X++){let{h:M,l:I}=PZ($[X],J);[G[X],Y[X]]=[M,I]}return[G,Y]}var IJ=($,J,Q)=>$>>>Q,DJ=($,J,Q)=>$<<32-Q|J>>>Q,E8=($,J,Q)=>$>>>Q|J<<32-Q,B8=($,J,Q)=>$<<32-Q|J>>>Q,I2=($,J,Q)=>$<<64-Q|J>>>Q-32,D2=($,J,Q)=>$>>>Q-32|J<<64-Q;var dG=($,J,Q)=>$<<Q|J>>>32-Q,nG=($,J,Q)=>J<<Q|$>>>32-Q,iG=($,J,Q)=>J<<Q-32|$>>>64-Q,rG=($,J,Q)=>$<<Q-32|J>>>64-Q;function f1($,J,Q,G){let Y=(J>>>0)+(G>>>0);return{h:$+Q+(Y/4294967296|0)|0,l:Y|0}}var oG=($,J,Q)=>($>>>0)+(J>>>0)+(Q>>>0),aG=($,J,Q,G)=>J+Q+G+($/4294967296|0)|0,sG=($,J,Q,G)=>($>>>0)+(J>>>0)+(Q>>>0)+(G>>>0),tG=($,J,Q,G,Y)=>J+Q+G+Y+($/4294967296|0)|0,eG=($,J,Q,G,Y)=>($>>>0)+(J>>>0)+(Q>>>0)+(G>>>0)+(Y>>>0),$Y=($,J,Q,G,Y,X)=>J+Q+G+Y+X+($/4294967296|0)|0;var SZ=Uint32Array.from([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]),M8=new Uint32Array(64);class VJ extends i2{constructor($=32){super(64,$,8,!1);this.A=r1[0]|0,this.B=r1[1]|0,this.C=r1[2]|0,this.D=r1[3]|0,this.E=r1[4]|0,this.F=r1[5]|0,this.G=r1[6]|0,this.H=r1[7]|0}get(){let{A:$,B:J,C:Q,D:G,E:Y,F:X,G:M,H:I}=this;return[$,J,Q,G,Y,X,M,I]}set($,J,Q,G,Y,X,M,I){this.A=$|0,this.B=J|0,this.C=Q|0,this.D=G|0,this.E=Y|0,this.F=X|0,this.G=M|0,this.H=I|0}process($,J){for(let A=0;A<16;A++,J+=4)M8[A]=$.getUint32(J,!1);for(let A=16;A<64;A++){let L=M8[A-15],N=M8[A-2],k=F1(L,7)^F1(L,18)^L>>>3,P=F1(N,17)^F1(N,19)^N>>>10;M8[A]=P+M8[A-7]+k+M8[A-16]|0}let{A:Q,B:G,C:Y,D:X,E:M,F:I,G:U,H:T}=this;for(let A=0;A<64;A++){let L=F1(M,6)^F1(M,11)^F1(M,25),N=T+L+uG(M,I,U)+SZ[A]+M8[A]|0,P=(F1(Q,2)^F1(Q,13)^F1(Q,22))+cG(Q,G,Y)|0;T=U,U=I,I=M,M=X+N|0,X=Y,Y=G,G=Q,Q=N+P|0}Q=Q+this.A|0,G=G+this.B|0,Y=Y+this.C|0,X=X+this.D|0,M=M+this.E|0,I=I+this.F|0,U=U+this.G|0,T=T+this.H|0,this.set(Q,G,Y,X,M,I,U,T)}roundClean(){S1(M8)}destroy(){this.set(0,0,0,0,0,0,0,0),S1(this.buffer)}}var JY=(()=>o2(["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(($)=>BigInt($))))(),EZ=(()=>JY[0])(),BZ=(()=>JY[1])(),K8=new Uint32Array(80),q8=new Uint32Array(80);class QY extends i2{constructor($=64){super(128,$,16,!1);this.Ah=Q1[0]|0,this.Al=Q1[1]|0,this.Bh=Q1[2]|0,this.Bl=Q1[3]|0,this.Ch=Q1[4]|0,this.Cl=Q1[5]|0,this.Dh=Q1[6]|0,this.Dl=Q1[7]|0,this.Eh=Q1[8]|0,this.El=Q1[9]|0,this.Fh=Q1[10]|0,this.Fl=Q1[11]|0,this.Gh=Q1[12]|0,this.Gl=Q1[13]|0,this.Hh=Q1[14]|0,this.Hl=Q1[15]|0}get(){let{Ah:$,Al:J,Bh:Q,Bl:G,Ch:Y,Cl:X,Dh:M,Dl:I,Eh:U,El:T,Fh:A,Fl:L,Gh:N,Gl:k,Hh:P,Hl:F}=this;return[$,J,Q,G,Y,X,M,I,U,T,A,L,N,k,P,F]}set($,J,Q,G,Y,X,M,I,U,T,A,L,N,k,P,F){this.Ah=$|0,this.Al=J|0,this.Bh=Q|0,this.Bl=G|0,this.Ch=Y|0,this.Cl=X|0,this.Dh=M|0,this.Dl=I|0,this.Eh=U|0,this.El=T|0,this.Fh=A|0,this.Fl=L|0,this.Gh=N|0,this.Gl=k|0,this.Hh=P|0,this.Hl=F|0}process($,J){for(let h=0;h<16;h++,J+=4)K8[h]=$.getUint32(J),q8[h]=$.getUint32(J+=4);for(let h=16;h<80;h++){let f=K8[h-15]|0,c=q8[h-15]|0,s=E8(f,c,1)^E8(f,c,8)^IJ(f,c,7),o=B8(f,c,1)^B8(f,c,8)^DJ(f,c,7),r=K8[h-2]|0,t=q8[h-2]|0,x=E8(r,t,19)^I2(r,t,61)^IJ(r,t,6),d=B8(r,t,19)^D2(r,t,61)^DJ(r,t,6),l=sG(o,d,q8[h-7],q8[h-16]),w=tG(l,s,x,K8[h-7],K8[h-16]);K8[h]=w|0,q8[h]=l|0}let{Ah:Q,Al:G,Bh:Y,Bl:X,Ch:M,Cl:I,Dh:U,Dl:T,Eh:A,El:L,Fh:N,Fl:k,Gh:P,Gl:F,Hh:B,Hl:_}=this;for(let h=0;h<80;h++){let f=E8(A,L,14)^E8(A,L,18)^I2(A,L,41),c=B8(A,L,14)^B8(A,L,18)^D2(A,L,41),s=A&N^~A&P,o=L&k^~L&F,r=eG(_,c,o,BZ[h],q8[h]),t=$Y(r,B,f,s,EZ[h],K8[h]),x=r|0,d=E8(Q,G,28)^I2(Q,G,34)^I2(Q,G,39),l=B8(Q,G,28)^D2(Q,G,34)^D2(Q,G,39),w=Q&Y^Q&M^Y&M,z=G&X^G&I^X&I;B=P|0,_=F|0,P=N|0,F=k|0,N=A|0,k=L|0,{h:A,l:L}=f1(U|0,T|0,t|0,x|0),U=M|0,T=I|0,M=Y|0,I=X|0,Y=Q|0,X=G|0;let Z=oG(x,l,z);Q=aG(Z,t,d,w),G=Z|0}({h:Q,l:G}=f1(this.Ah|0,this.Al|0,Q|0,G|0)),{h:Y,l:X}=f1(this.Bh|0,this.Bl|0,Y|0,X|0),{h:M,l:I}=f1(this.Ch|0,this.Cl|0,M|0,I|0),{h:U,l:T}=f1(this.Dh|0,this.Dl|0,U|0,T|0),{h:A,l:L}=f1(this.Eh|0,this.El|0,A|0,L|0),{h:N,l:k}=f1(this.Fh|0,this.Fl|0,N|0,k|0),{h:P,l:F}=f1(this.Gh|0,this.Gl|0,P|0,F|0),{h:B,l:_}=f1(this.Hh|0,this.Hl|0,B|0,_|0),this.set(Q,G,Y,X,M,I,U,T,A,L,N,k,P,F,B,_)}roundClean(){S1(K8,q8)}destroy(){S1(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}var a2=U2(()=>new VJ);var GY=U2(()=>new QY);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var jJ=BigInt(0),HJ=BigInt(1);function o1($,J=""){if(typeof $!=="boolean"){let Q=J&&`"${J}"`;throw Error(Q+"expected boolean, got type="+typeof $)}return $}function N1($,J,Q=""){let G=n1($),Y=$?.length,X=J!==void 0;if(!G||X&&Y!==J){let M=Q&&`"${Q}" `,I=X?` of length ${J}`:"",U=G?`length=${Y}`:`type=${typeof $}`;throw Error(M+"expected Uint8Array"+I+", got "+U)}return $}function V2($){let J=$.toString(16);return J.length&1?"0"+J:J}function YY($){if(typeof $!=="string")throw Error("hex string expected, got "+typeof $);return $===""?jJ:BigInt("0x"+$)}function l8($){return YY(E1($))}function a1($){return J1($),YY(E1(Uint8Array.from($).reverse()))}function s2($,J){return P8($.toString(16).padStart(J*2,"0"))}function CJ($,J){return s2($,J).reverse()}function M0($,J,Q){let G;if(typeof J==="string")try{G=P8(J)}catch(X){throw Error($+" must be hex string or Uint8Array, cause: "+X)}else if(n1(J))G=Uint8Array.from(J);else throw Error($+" must be hex string or Uint8Array");let Y=G.length;if(typeof Q==="number"&&Y!==Q)throw Error($+" of length "+Q+" expected, got "+Y);return G}function XY($,J){if($.length!==J.length)return!1;let Q=0;for(let G=0;G<$.length;G++)Q|=$[G]^J[G];return Q===0}function AJ($){return Uint8Array.from($)}var zJ=($)=>typeof $==="bigint"&&jJ<=$;function ZY($,J,Q){return zJ($)&&zJ(J)&&zJ(Q)&&J<=$&&$<Q}function z2($,J,Q,G){if(!ZY(J,Q,G))throw Error("expected valid "+$+": "+Q+" <= n < "+G+", got "+J)}function t2($){let J;for(J=0;$>jJ;$>>=HJ,J+=1);return J}var W8=($)=>(HJ<<BigInt($))-HJ;function MY($,J,Q){if(typeof $!=="number"||$<2)throw Error("hashLen must be a number");if(typeof J!=="number"||J<2)throw Error("qByteLen must be a number");if(typeof Q!=="function")throw Error("hmacFn must be a function");let G=(k)=>new Uint8Array(k),Y=(k)=>Uint8Array.of(k),X=G($),M=G($),I=0,U=()=>{X.fill(1),M.fill(0),I=0},T=(...k)=>Q(M,X,...k),A=(k=G(0))=>{if(M=T(Y(0),k),X=T(),k.length===0)return;M=T(Y(1),k),X=T()},L=()=>{if(I++>=1000)throw Error("drbg: tried 1000 values");let k=0,P=[];while(k<J){X=T();let F=X.slice();P.push(F),k+=X.length}return D1(...P)};return(k,P)=>{U(),A(k);let F=void 0;while(!(F=P(L())))A();return U(),F}}function U8($,J,Q={}){if(!$||typeof $!=="object")throw Error("expected valid options object");function G(Y,X,M){let I=$[Y];if(M&&I===void 0)return;let U=typeof I;if(U!==X||I===null)throw Error(`param "${Y}" is invalid: expected ${X}, got ${U}`)}Object.entries(J).forEach(([Y,X])=>G(Y,X,!1)),Object.entries(Q).forEach(([Y,X])=>G(Y,X,!0))}var TJ=()=>{throw Error("not implemented")};function d8($){let J=new WeakMap;return(Q,...G)=>{let Y=J.get(Q);if(Y!==void 0)return Y;let X=$(Q,...G);return J.set(Q,X),X}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var V1=BigInt(0),e0=BigInt(1),w8=BigInt(2),WY=BigInt(3),UY=BigInt(4),IY=BigInt(5),wZ=BigInt(7),DY=BigInt(8),FZ=BigInt(9),VY=BigInt(16);function z0($,J){let Q=$%J;return Q>=V1?Q:J+Q}function D0($,J,Q){let G=$;while(J-- >V1)G*=G,G%=Q;return G}function KY($,J){if($===V1)throw Error("invert: expected non-zero number");if(J<=V1)throw Error("invert: expected positive modulus, got "+J);let Q=z0($,J),G=J,Y=V1,X=e0,M=e0,I=V1;while(Q!==V1){let T=G/Q,A=G%Q,L=Y-M*T,N=X-I*T;G=Q,Q=A,Y=M,X=I,M=L,I=N}if(G!==e0)throw Error("invert: does not exist");return z0(Y,J)}function RJ($,J,Q){if(!$.eql($.sqr(J),Q))throw Error("Cannot find square root")}function zY($,J){let Q=($.ORDER+e0)/UY,G=$.pow(J,Q);return RJ($,G,J),G}function _Z($,J){let Q=($.ORDER-IY)/DY,G=$.mul(J,w8),Y=$.pow(G,Q),X=$.mul(J,Y),M=$.mul($.mul(X,w8),Y),I=$.mul(X,$.sub(M,$.ONE));return RJ($,I,J),I}function gZ($){let J=k1($),Q=HY($),G=Q(J,J.neg(J.ONE)),Y=Q(J,G),X=Q(J,J.neg(G)),M=($+wZ)/VY;return(I,U)=>{let T=I.pow(U,M),A=I.mul(T,G),L=I.mul(T,Y),N=I.mul(T,X),k=I.eql(I.sqr(A),U),P=I.eql(I.sqr(L),U);T=I.cmov(T,A,k),A=I.cmov(N,L,P);let F=I.eql(I.sqr(A),U),B=I.cmov(T,A,F);return RJ(I,B,U),B}}function HY($){if($<WY)throw Error("sqrt is not defined for small field");let J=$-e0,Q=0;while(J%w8===V1)J/=w8,Q++;let G=w8,Y=k1($);while(qY(Y,G)===1)if(G++>1000)throw Error("Cannot find square root: probably non-prime P");if(Q===1)return zY;let X=Y.pow(G,J),M=(J+e0)/w8;return function(U,T){if(U.is0(T))return T;if(qY(U,T)!==1)throw Error("Cannot find square root");let A=Q,L=U.mul(U.ONE,X),N=U.pow(T,J),k=U.pow(T,M);while(!U.eql(N,U.ONE)){if(U.is0(N))return U.ZERO;let P=1,F=U.sqr(N);while(!U.eql(F,U.ONE))if(P++,F=U.sqr(F),P===A)throw Error("Cannot find square root");let B=e0<<BigInt(A-P-1),_=U.pow(L,B);A=P,L=U.sqr(_),N=U.mul(N,L),k=U.mul(k,_)}return k}}function xZ($){if($%UY===WY)return zY;if($%DY===IY)return _Z;if($%VY===FZ)return gZ($);return HY($)}var s1=($,J)=>(z0($,J)&e0)===e0,vZ=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function OJ($){let J={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},Q=vZ.reduce((G,Y)=>{return G[Y]="function",G},J);return U8($,Q),$}function hZ($,J,Q){if(Q<V1)throw Error("invalid exponent, negatives unsupported");if(Q===V1)return $.ONE;if(Q===e0)return J;let G=$.ONE,Y=J;while(Q>V1){if(Q&e0)G=$.mul(G,Y);Y=$.sqr(Y),Q>>=e0}return G}function H2($,J,Q=!1){let G=Array(J.length).fill(Q?$.ZERO:void 0),Y=J.reduce((M,I,U)=>{if($.is0(I))return M;return G[U]=M,$.mul(M,I)},$.ONE),X=$.inv(Y);return J.reduceRight((M,I,U)=>{if($.is0(I))return M;return G[U]=$.mul(M,G[U]),$.mul(M,I)},X),G}function qY($,J){let Q=($.ORDER-e0)/w8,G=$.pow(J,Q),Y=$.eql(G,$.ONE),X=$.eql(G,$.ZERO),M=$.eql(G,$.neg($.ONE));if(!Y&&!X&&!M)throw Error("invalid Legendre symbol result");return Y?1:X?0:-1}function e2($,J){if(J!==void 0)Z8(J);let Q=J!==void 0?J:$.toString(2).length,G=Math.ceil(Q/8);return{nBitLength:Q,nByteLength:G}}function k1($,J,Q=!1,G={}){if($<=V1)throw Error("invalid field: expected ORDER > 0, got "+$);let Y=void 0,X=void 0,M=!1,I=void 0;if(typeof J==="object"&&J!=null){if(G.sqrt||Q)throw Error("cannot specify opts in two arguments");let N=J;if(N.BITS)Y=N.BITS;if(N.sqrt)X=N.sqrt;if(typeof N.isLE==="boolean")Q=N.isLE;if(typeof N.modFromBytes==="boolean")M=N.modFromBytes;I=N.allowedLengths}else{if(typeof J==="number")Y=J;if(G.sqrt)X=G.sqrt}let{nBitLength:U,nByteLength:T}=e2($,Y);if(T>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");let A,L=Object.freeze({ORDER:$,isLE:Q,BITS:U,BYTES:T,MASK:W8(U),ZERO:V1,ONE:e0,allowedLengths:I,create:(N)=>z0(N,$),isValid:(N)=>{if(typeof N!=="bigint")throw Error("invalid field element: expected bigint, got "+typeof N);return V1<=N&&N<$},is0:(N)=>N===V1,isValidNot0:(N)=>!L.is0(N)&&L.isValid(N),isOdd:(N)=>(N&e0)===e0,neg:(N)=>z0(-N,$),eql:(N,k)=>N===k,sqr:(N)=>z0(N*N,$),add:(N,k)=>z0(N+k,$),sub:(N,k)=>z0(N-k,$),mul:(N,k)=>z0(N*k,$),pow:(N,k)=>hZ(L,N,k),div:(N,k)=>z0(N*KY(k,$),$),sqrN:(N)=>N*N,addN:(N,k)=>N+k,subN:(N,k)=>N-k,mulN:(N,k)=>N*k,inv:(N)=>KY(N,$),sqrt:X||((N)=>{if(!A)A=xZ($);return A(L,N)}),toBytes:(N)=>Q?CJ(N,T):s2(N,T),fromBytes:(N,k=!0)=>{if(I){if(!I.includes(N.length)||N.length>T)throw Error("Field.fromBytes: expected "+I+" bytes, got "+N.length);let F=new Uint8Array(T);F.set(N,Q?0:F.length-N.length),N=F}if(N.length!==T)throw Error("Field.fromBytes: expected "+T+" bytes, got "+N.length);let P=Q?a1(N):l8(N);if(M)P=z0(P,$);if(!k){if(!L.isValid(P))throw Error("invalid field element: outside of range 0..ORDER")}return P},invertBatch:(N)=>H2(L,N),cmov:(N,k,P)=>P?k:N});return Object.freeze(L)}function jY($){if(typeof $!=="bigint")throw Error("field order must be bigint");let J=$.toString(2).length;return Math.ceil(J/8)}function NJ($){let J=jY($);return J+Math.ceil(J/2)}function kJ($,J,Q=!1){let G=$.length,Y=jY(J),X=NJ(J);if(G<16||G<X||G>1024)throw Error("expected "+X+"-1024 bytes of input, got "+G);let M=Q?a1($):l8($),I=z0(M,J-e0)+e0;return Q?CJ(I,Y):s2(I,Y)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var n8=BigInt(0),F8=BigInt(1);function j2($,J){let Q=J.negate();return $?Q:J}function t1($,J){let Q=H2($.Fp,J.map((G)=>G.Z));return J.map((G,Y)=>$.fromAffine(G.toAffine(Q[Y])))}function RY($,J){if(!Number.isSafeInteger($)||$<=0||$>J)throw Error("invalid window size, expected [1.."+J+"], got W="+$)}function PJ($,J){RY($,J);let Q=Math.ceil(J/$)+1,G=2**($-1),Y=2**$,X=W8($),M=BigInt($);return{windows:Q,windowSize:G,mask:X,maxNumber:Y,shiftBy:M}}function CY($,J,Q){let{windowSize:G,mask:Y,maxNumber:X,shiftBy:M}=Q,I=Number($&Y),U=$>>M;if(I>G)I-=X,U+=F8;let T=J*G,A=T+Math.abs(I)-1,L=I===0,N=I<0,k=J%2!==0;return{nextN:U,offset:A,isZero:L,isNeg:N,isNegF:k,offsetF:T}}function yZ($,J){if(!Array.isArray($))throw Error("array expected");$.forEach((Q,G)=>{if(!(Q instanceof J))throw Error("invalid point at index "+G)})}function fZ($,J){if(!Array.isArray($))throw Error("array of scalars expected");$.forEach((Q,G)=>{if(!J.isValid(Q))throw Error("invalid scalar at index "+G)})}var LJ=new WeakMap,OY=new WeakMap;function SJ($){return OY.get($)||1}function AY($){if($!==n8)throw Error("invalid wNAF")}class C2{constructor($,J){this.BASE=$.BASE,this.ZERO=$.ZERO,this.Fn=$.Fn,this.bits=J}_unsafeLadder($,J,Q=this.ZERO){let G=$;while(J>n8){if(J&F8)Q=Q.add(G);G=G.double(),J>>=F8}return Q}precomputeWindow($,J){let{windows:Q,windowSize:G}=PJ(J,this.bits),Y=[],X=$,M=X;for(let I=0;I<Q;I++){M=X,Y.push(M);for(let U=1;U<G;U++)M=M.add(X),Y.push(M);X=M.double()}return Y}wNAF($,J,Q){if(!this.Fn.isValid(Q))throw Error("invalid scalar");let G=this.ZERO,Y=this.BASE,X=PJ($,this.bits);for(let M=0;M<X.windows;M++){let{nextN:I,offset:U,isZero:T,isNeg:A,isNegF:L,offsetF:N}=CY(Q,M,X);if(Q=I,T)Y=Y.add(j2(L,J[N]));else G=G.add(j2(A,J[U]))}return AY(Q),{p:G,f:Y}}wNAFUnsafe($,J,Q,G=this.ZERO){let Y=PJ($,this.bits);for(let X=0;X<Y.windows;X++){if(Q===n8)break;let{nextN:M,offset:I,isZero:U,isNeg:T}=CY(Q,X,Y);if(Q=M,U)continue;else{let A=J[I];G=G.add(T?A.negate():A)}}return AY(Q),G}getPrecomputes($,J,Q){let G=LJ.get(J);if(!G){if(G=this.precomputeWindow(J,$),$!==1){if(typeof Q==="function")G=Q(G);LJ.set(J,G)}}return G}cached($,J,Q){let G=SJ($);return this.wNAF(G,this.getPrecomputes(G,$,Q),J)}unsafe($,J,Q,G){let Y=SJ($);if(Y===1)return this._unsafeLadder($,J,G);return this.wNAFUnsafe(Y,this.getPrecomputes(Y,$,Q),J,G)}createCache($,J){RY(J,this.bits),OY.set($,J),LJ.delete($)}hasCache($){return SJ($)!==1}}function NY($,J,Q,G){let Y=J,X=$.ZERO,M=$.ZERO;while(Q>n8||G>n8){if(Q&F8)X=X.add(Y);if(G&F8)M=M.add(Y);Y=Y.double(),Q>>=F8,G>>=F8}return{p1:X,p2:M}}function i8($,J,Q,G){yZ(Q,$),fZ(G,J);let Y=Q.length,X=G.length;if(Y!==X)throw Error("arrays of points and scalars must have equal length");let M=$.ZERO,I=t2(BigInt(Y)),U=1;if(I>12)U=I-3;else if(I>4)U=I-2;else if(I>0)U=2;let T=W8(U),A=Array(Number(T)+1).fill(M),L=Math.floor((J.BITS-1)/U)*U,N=M;for(let k=L;k>=0;k-=U){A.fill(M);for(let F=0;F<X;F++){let B=G[F],_=Number(B>>BigInt(k)&T);A[_]=A[_].add(Q[F])}let P=M;for(let F=A.length-1,B=M;F>0;F--)B=B.add(A[F]),P=P.add(B);if(N=N.add(P),k!==0)for(let F=0;F<U;F++)N=N.double()}return N}function TY($,J,Q){if(J){if(J.ORDER!==$)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return OJ(J),J}else return k1($,{isLE:Q})}function $$($,J,Q={},G){if(G===void 0)G=$==="edwards";if(!J||typeof J!=="object")throw Error(`expected valid ${$} CURVE object`);for(let U of["p","n","h"]){let T=J[U];if(!(typeof T==="bigint"&&T>n8))throw Error(`CURVE.${U} must be positive bigint`)}let Y=TY(J.p,Q.Fp,G),X=TY(J.n,Q.Fn,G),I=["Gx","Gy","a",$==="weierstrass"?"b":"d"];for(let U of I)if(!Y.isValid(J[U]))throw Error(`CURVE.${U} must be valid field element of CURVE.Fp`);return J=Object.freeze(Object.assign({},J)),{CURVE:J,Fp:Y,Fn:X}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var I8=BigInt(0),$1=BigInt(1),EJ=BigInt(2),bZ=BigInt(8);function mZ($,J,Q,G){let Y=$.sqr(Q),X=$.sqr(G),M=$.add($.mul(J.a,Y),X),I=$.add($.ONE,$.mul(J.d,$.mul(Y,X)));return $.eql(M,I)}function pZ($,J={}){let Q=$$("edwards",$,J,J.FpFnLE),{Fp:G,Fn:Y}=Q,X=Q.CURVE,{h:M}=X;U8(J,{},{uvRatio:"function"});let I=EJ<<BigInt(Y.BYTES*8)-$1,U=(B)=>G.create(B),T=J.uvRatio||((B,_)=>{try{return{isValid:!0,value:G.sqrt(G.div(B,_))}}catch(h){return{isValid:!1,value:I8}}});if(!mZ(G,X,X.Gx,X.Gy))throw Error("bad curve params: generator point");function A(B,_,h=!1){let f=h?$1:I8;return z2("coordinate "+B,_,f,I),_}function L(B){if(!(B instanceof P))throw Error("ExtendedPoint expected")}let N=d8((B,_)=>{let{X:h,Y:f,Z:c}=B,s=B.is0();if(_==null)_=s?bZ:G.inv(c);let o=U(h*_),r=U(f*_),t=G.mul(c,_);if(s)return{x:I8,y:$1};if(t!==$1)throw Error("invZ was invalid");return{x:o,y:r}}),k=d8((B)=>{let{a:_,d:h}=X;if(B.is0())throw Error("bad point: ZERO");let{X:f,Y:c,Z:s,T:o}=B,r=U(f*f),t=U(c*c),x=U(s*s),d=U(x*x),l=U(r*_),w=U(x*U(l+t)),z=U(d+U(h*U(r*t)));if(w!==z)throw Error("bad point: equation left != right (1)");let Z=U(f*c),K=U(s*o);if(Z!==K)throw Error("bad point: equation left != right (2)");return!0});class P{constructor(B,_,h,f){this.X=A("x",B),this.Y=A("y",_),this.Z=A("z",h,!0),this.T=A("t",f),Object.freeze(this)}static CURVE(){return X}static fromAffine(B){if(B instanceof P)throw Error("extended point not allowed");let{x:_,y:h}=B||{};return A("x",_),A("y",h),new P(_,h,$1,U(_*h))}static fromBytes(B,_=!1){let h=G.BYTES,{a:f,d:c}=X;B=AJ(N1(B,h,"point")),o1(_,"zip215");let s=AJ(B),o=B[h-1];s[h-1]=o&-129;let r=a1(s),t=_?I:G.ORDER;z2("point.y",r,I8,t);let x=U(r*r),d=U(x-$1),l=U(c*x-f),{isValid:w,value:z}=T(d,l);if(!w)throw Error("bad point: invalid y coordinate");let Z=(z&$1)===$1,K=(o&128)!==0;if(!_&&z===I8&&K)throw Error("bad point: x=0 and x_0=1");if(K!==Z)z=U(-z);return P.fromAffine({x:z,y:r})}static fromHex(B,_=!1){return P.fromBytes(M0("point",B),_)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(B=8,_=!0){if(F.createCache(this,B),!_)this.multiply(EJ);return this}assertValidity(){k(this)}equals(B){L(B);let{X:_,Y:h,Z:f}=this,{X:c,Y:s,Z:o}=B,r=U(_*o),t=U(c*f),x=U(h*o),d=U(s*f);return r===t&&x===d}is0(){return this.equals(P.ZERO)}negate(){return new P(U(-this.X),this.Y,this.Z,U(-this.T))}double(){let{a:B}=X,{X:_,Y:h,Z:f}=this,c=U(_*_),s=U(h*h),o=U(EJ*U(f*f)),r=U(B*c),t=_+h,x=U(U(t*t)-c-s),d=r+s,l=d-o,w=r-s,z=U(x*l),Z=U(d*w),K=U(x*w),W=U(l*d);return new P(z,Z,W,K)}add(B){L(B);let{a:_,d:h}=X,{X:f,Y:c,Z:s,T:o}=this,{X:r,Y:t,Z:x,T:d}=B,l=U(f*r),w=U(c*t),z=U(o*h*d),Z=U(s*x),K=U((f+c)*(r+t)-l-w),W=Z-z,D=Z+z,V=U(w-_*l),C=U(K*W),R=U(D*V),H=U(K*V),q=U(W*D);return new P(C,R,q,H)}subtract(B){return this.add(B.negate())}multiply(B){if(!Y.isValidNot0(B))throw Error("invalid scalar: expected 1 <= sc < curve.n");let{p:_,f:h}=F.cached(this,B,(f)=>t1(P,f));return t1(P,[_,h])[0]}multiplyUnsafe(B,_=P.ZERO){if(!Y.isValid(B))throw Error("invalid scalar: expected 0 <= sc < curve.n");if(B===I8)return P.ZERO;if(this.is0()||B===$1)return this;return F.unsafe(this,B,(h)=>t1(P,h),_)}isSmallOrder(){return this.multiplyUnsafe(M).is0()}isTorsionFree(){return F.unsafe(this,X.n).is0()}toAffine(B){return N(this,B)}clearCofactor(){if(M===$1)return this;return this.multiplyUnsafe(M)}toBytes(){let{x:B,y:_}=this.toAffine(),h=G.toBytes(_);return h[h.length-1]|=B&$1?128:0,h}toHex(){return E1(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(B){return t1(P,B)}static msm(B,_){return i8(P,Y,B,_)}_setWindowSize(B){this.precompute(B)}toRawBytes(){return this.toBytes()}}P.BASE=new P(X.Gx,X.Gy,$1,U(X.Gx*X.Gy)),P.ZERO=new P(I8,$1,$1,I8),P.Fp=G,P.Fn=Y;let F=new C2(P,Y.BITS);return P.BASE.precompute(8),P}class BJ{constructor($){this.ep=$}static fromBytes($){TJ()}static fromHex($){TJ()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine($){return this.ep.toAffine($)}toHex(){return E1(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add($){return this.assertSame($),this.init(this.ep.add($.ep))}subtract($){return this.assertSame($),this.init(this.ep.subtract($.ep))}multiply($){return this.init(this.ep.multiply($))}multiplyUnsafe($){return this.init(this.ep.multiplyUnsafe($))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute($,J){return this.init(this.ep.precompute($,J))}toRawBytes(){return this.toBytes()}}function uZ($,J,Q={}){if(typeof J!=="function")throw Error('"hash" function param is required');U8(Q,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:G}=Q,{BASE:Y,Fp:X,Fn:M}=$,I=Q.randomBytes||c8,U=Q.adjustScalarBytes||((x)=>x),T=Q.domain||((x,d,l)=>{if(o1(l,"phflag"),d.length||l)throw Error("Contexts/pre-hash are not supported");return x});function A(x){return M.create(a1(x))}function L(x){let d=f.secretKey;x=M0("private key",x,d);let l=M0("hashed private key",J(x),2*d),w=U(l.slice(0,d)),z=l.slice(d,2*d),Z=A(w);return{head:w,prefix:z,scalar:Z}}function N(x){let{head:d,prefix:l,scalar:w}=L(x),z=Y.multiply(w),Z=z.toBytes();return{head:d,prefix:l,scalar:w,point:z,pointBytes:Z}}function k(x){return N(x).pointBytes}function P(x=Uint8Array.of(),...d){let l=D1(...d);return A(J(T(l,M0("context",x),!!G)))}function F(x,d,l={}){if(x=M0("message",x),G)x=G(x);let{prefix:w,scalar:z,pointBytes:Z}=N(d),K=P(l.context,w,x),W=Y.multiply(K).toBytes(),D=P(l.context,W,Z,x),V=M.create(K+D*z);if(!M.isValid(V))throw Error("sign failed: invalid s");let C=D1(W,M.toBytes(V));return N1(C,f.signature,"result")}let B={zip215:!0};function _(x,d,l,w=B){let{context:z,zip215:Z}=w,K=f.signature;if(x=M0("signature",x,K),d=M0("message",d),l=M0("publicKey",l,f.publicKey),Z!==void 0)o1(Z,"zip215");if(G)d=G(d);let W=K/2,D=x.subarray(0,W),V=a1(x.subarray(W,K)),C,R,H;try{C=$.fromBytes(l,Z),R=$.fromBytes(D,Z),H=Y.multiplyUnsafe(V)}catch(v){return!1}if(!Z&&C.isSmallOrder())return!1;let q=P(z,R.toBytes(),C.toBytes(),d);return R.add(C.multiplyUnsafe(q)).subtract(H).clearCofactor().is0()}let h=X.BYTES,f={secretKey:h,publicKey:h,signature:2*h,seed:h};function c(x=I(f.seed)){return N1(x,f.seed,"seed")}function s(x){let d=t.randomSecretKey(x);return{secretKey:d,publicKey:k(d)}}function o(x){return n1(x)&&x.length===M.BYTES}function r(x,d){try{return!!$.fromBytes(x,d)}catch(l){return!1}}let t={getExtendedPublicKey:N,randomSecretKey:c,isValidSecretKey:o,isValidPublicKey:r,toMontgomery(x){let{y:d}=$.fromBytes(x),l=f.publicKey,w=l===32;if(!w&&l!==57)throw Error("only defined for 25519 and 448");let z=w?X.div($1+d,$1-d):X.div(d-$1,d+$1);return X.toBytes(z)},toMontgomerySecret(x){let d=f.secretKey;N1(x,d);let l=J(x.subarray(0,d));return U(l).subarray(0,d)},randomPrivateKey:c,precompute(x=8,d=$.BASE){return d.precompute(x,!1)}};return Object.freeze({keygen:s,getPublicKey:k,sign:F,verify:_,utils:t,Point:$,lengths:f})}function cZ($){let J={a:$.a,d:$.d,p:$.Fp.ORDER,n:$.n,h:$.h,Gx:$.Gx,Gy:$.Gy},Q=$.Fp,G=k1(J.n,$.nBitLength,!0),Y={Fp:Q,Fn:G,uvRatio:$.uvRatio},X={randomBytes:$.randomBytes,adjustScalarBytes:$.adjustScalarBytes,domain:$.domain,prehash:$.prehash,mapToCurve:$.mapToCurve};return{CURVE:J,curveOpts:Y,hash:$.hash,eddsaOpts:X}}function lZ($,J){let Q=J.Point;return Object.assign({},J,{ExtendedPoint:Q,CURVE:$,nBitLength:Q.Fn.BITS,nByteLength:Q.Fn.BYTES})}function kY($){let{CURVE:J,curveOpts:Q,hash:G,eddsaOpts:Y}=cZ($),X=pZ(J,Q),M=uZ(X,G,Y);return lZ($,M)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var dZ=BigInt(0),e1=BigInt(1),PY=BigInt(2),TI=BigInt(3),nZ=BigInt(5),iZ=BigInt(8),r8=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),A2=(()=>({p:r8,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:iZ,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")}))();function rZ($){let J=BigInt(10),Q=BigInt(20),G=BigInt(40),Y=BigInt(80),X=r8,I=$*$%X*$%X,U=D0(I,PY,X)*I%X,T=D0(U,e1,X)*$%X,A=D0(T,nZ,X)*T%X,L=D0(A,J,X)*A%X,N=D0(L,Q,X)*L%X,k=D0(N,G,X)*N%X,P=D0(k,Y,X)*k%X,F=D0(P,Y,X)*k%X,B=D0(F,J,X)*A%X;return{pow_p_5_8:D0(B,PY,X)*$%X,b2:I}}function oZ($){return $[0]&=248,$[31]&=127,$[31]|=64,$}var wJ=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function gJ($,J){let Q=r8,G=z0(J*J*J,Q),Y=z0(G*G*J,Q),X=rZ($*Y).pow_p_5_8,M=z0($*G*X,Q),I=z0(J*M*M,Q),U=M,T=z0(M*wJ,Q),A=I===$,L=I===z0(-$,Q),N=I===z0(-$*wJ,Q);if(A)M=U;if(L||N)M=T;if(s1(M,Q))M=z0(-M,Q);return{isValid:A||L,value:M}}var D8=(()=>k1(A2.p,{isLE:!0}))(),aZ=(()=>k1(A2.n,{isLE:!0}))(),sZ=(()=>({...A2,Fp:D8,hash:GY,adjustScalarBytes:oZ,uvRatio:gJ}))(),T1=(()=>kY(sZ))();var FJ=wJ,tZ=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),eZ=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),$M=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),JM=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),LY=($)=>gJ(e1,$),QM=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),_J=($)=>T1.Point.Fp.create(a1($)&QM);function SY($){let{d:J}=A2,Q=r8,G=(_)=>D8.create(_),Y=G(FJ*$*$),X=G((Y+e1)*$M),M=BigInt(-1),I=G((M-J*Y)*G(Y+J)),{isValid:U,value:T}=gJ(X,I),A=G(T*$);if(!s1(A,Q))A=G(-A);if(!U)T=A;if(!U)M=Y;let L=G(M*(Y-e1)*JM-I),N=T*T,k=G((T+T)*I),P=G(L*tZ),F=G(e1-N),B=G(e1+N);return new T1.Point(G(k*B),G(F*P),G(P*B),G(k*F))}function GM($){J1($,64);let J=_J($.subarray(0,32)),Q=SY(J),G=_J($.subarray(32,64)),Y=SY(G);return new z1(Q.add(Y))}class z1 extends BJ{constructor($){super($)}static fromAffine($){return new z1(T1.Point.fromAffine($))}assertSame($){if(!($ instanceof z1))throw Error("RistrettoPoint expected")}init($){return new z1($)}static hashToCurve($){return GM(M0("ristrettoHash",$,64))}static fromBytes($){J1($,32);let{a:J,d:Q}=A2,G=r8,Y=(f)=>D8.create(f),X=_J($);if(!XY(D8.toBytes(X),$)||s1(X,G))throw Error("invalid ristretto255 encoding 1");let M=Y(X*X),I=Y(e1+J*M),U=Y(e1-J*M),T=Y(I*I),A=Y(U*U),L=Y(J*Q*T-A),{isValid:N,value:k}=LY(Y(L*A)),P=Y(k*U),F=Y(k*P*L),B=Y((X+X)*P);if(s1(B,G))B=Y(-B);let _=Y(I*F),h=Y(B*_);if(!N||s1(h,G)||_===dZ)throw Error("invalid ristretto255 encoding 2");return new z1(new T1.Point(B,_,e1,h))}static fromHex($){return z1.fromBytes(M0("ristrettoHex",$,32))}static msm($,J){return i8(z1,T1.Point.Fn,$,J)}toBytes(){let{X:$,Y:J,Z:Q,T:G}=this.ep,Y=r8,X=(F)=>D8.create(F),M=X(X(Q+J)*X(Q-J)),I=X($*J),U=X(I*I),{value:T}=LY(X(M*U)),A=X(T*M),L=X(T*I),N=X(A*L*G),k;if(s1(G*N,Y)){let F=X(J*FJ),B=X($*FJ);$=F,J=B,k=X(A*eZ)}else k=L;if(s1($*N,Y))J=X(-J);let P=X((Q-J)*k);if(s1(P,Y))P=X(-P);return D8.toBytes(P)}equals($){this.assertSame($);let{X:J,Y:Q}=this.ep,{X:G,Y}=$.ep,X=(U)=>D8.create(U),M=X(J*Y)===X(Q*G),I=X(Q*Y)===X(J*G);return M||I}is0(){return this.equals(z1.ZERO)}}z1.BASE=(()=>new z1(T1.Point.BASE))();z1.ZERO=(()=>new z1(T1.Point.ZERO))();z1.Fp=(()=>D8)();z1.Fn=(()=>aZ)();var uQ=R8(vJ(),1),O1=R8(yJ(),1);var fJ=a2;var X2=R8(pY(),1),O=R8(WQ(),1),M5=R8(WQ(),1);var cK=1,lK=2,dK=3,nK=4,iK=5,rK=6,oK=7,aK=8,sK=9,tK=10,eK=-32700,$q=-32603,Jq=-32602,Qq=-32601,Gq=-32600,Yq=-32016,Xq=-32015,Zq=-32014,Mq=-32013,Kq=-32012,qq=-32011,Wq=-32010,Uq=-32009,Iq=-32008,Dq=-32007,Vq=-32006,zq=-32005,Hq=-32004,jq=-32003,Cq=-32002,Aq=-32001,Tq=2800000,Rq=2800001,Oq=2800002,Nq=2800003,kq=2800004,Pq=2800005,Lq=2800006,Sq=2800007,Eq=2800008,Bq=2800009,wq=2800010,Fq=2800011,_q=3230000,gq=32300001,xq=3230002,vq=3230003,hq=3230004,yq=3610000,fq=3610001,bq=3610002,mq=3610003,pq=3610004,uq=3610005,cq=3610006,lq=3610007,dq=3611000,nq=3704000,iq=3704001,rq=3704002,oq=3704003,aq=3704004,sq=4128000,tq=4128001,eq=4128002,$W=4615000,JW=4615001,QW=4615002,GW=4615003,YW=4615004,XW=4615005,ZW=4615006,MW=4615007,KW=4615008,qW=4615009,WW=4615010,UW=4615011,IW=4615012,DW=4615013,VW=4615014,zW=4615015,HW=4615016,jW=4615017,CW=4615018,AW=4615019,TW=4615020,RW=4615021,OW=4615022,NW=4615023,kW=4615024,PW=4615025,LW=4615026,SW=4615027,EW=4615028,BW=4615029,wW=4615030,FW=4615031,_W=4615032,gW=4615033,xW=4615034,vW=4615035,hW=4615036,yW=4615037,fW=4615038,bW=4615039,mW=4615040,pW=4615041,uW=4615042,cW=4615043,lW=4615044,dW=4615045,nW=4615046,iW=4615047,rW=4615048,oW=4615049,aW=4615050,sW=4615051,tW=4615052,eW=4615053,$6=4615054,J6=5508000,Q6=5508001,G6=5508002,Y6=5508003,X6=5508004,Z6=5508005,M6=5508006,K6=5508007,q6=5508008,W6=5508009,U6=5508010,I6=5508011,D6=5663000,V6=5663001,z6=5663002,H6=5663003,j6=5663004,C6=5663005,A6=5663006,T6=5663007,R6=5663008,O6=5663009,N6=5663010,k6=5663011,P6=5663012,L6=5663013,S6=5663014,E6=5663015,B6=5663016,w6=5663017,F6=5663018,_6=5663019,g6=5663020,x6=7050000,v6=7050001,h6=7050002,y6=7050003,f6=7050004,b6=7050005,m6=7050006,p6=7050007,u6=7050008,c6=7050009,l6=7050010,d6=7050011,n6=7050012,i6=7050013,r6=7050014,o6=7050015,a6=7050016,s6=7050017,t6=7050018,e6=7050019,$U=7050020,JU=7050021,QU=7050022,GU=7050023,YU=7050024,XU=7050025,ZU=7050026,MU=7050027,KU=7050028,qU=7050029,WU=7050030,UU=7050031,IU=7050032,DU=7050033,VU=7050034,zU=7050035,HU=7050036,UQ=8078000,IQ=8078001,dY=8078002,nY=8078003,DQ=8078004,VQ=8078005,zQ=8078006,jU=8078007,CU=8078008,AU=8078009,TU=8078010,HQ=8078011,RU=8078012,iY=8078013,rY=8078014,OU=8078015,NU=8078016,kU=8078017,PU=8078018,LU=8078019,oY=8078020,aY=8078021,SU=8078022,EU=8100000,BU=8100001,wU=8100002,FU=8100003,_U=8190000,gU=8190001,xU=8190002,vU=8190003,hU=8190004,yU=9900000,fU=9900001,bU=9900002,mU=9900003,pU=9900004;var uU={[_q]:"Account not found at address: $address",[hq]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[vq]:"Expected decoded account at address: $address",[xq]:"Failed to decode account data at address: $address",[gq]:"Accounts not found at addresses: $addresses",[Bq]:"Unable to find a viable program address bump seed.",[Oq]:"$putativeAddress is not a base58-encoded address.",[Tq]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[Nq]:"The `CryptoKey` must be an `Ed25519` public key.",[Fq]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[Eq]:"Invalid seeds; point must fall off the Ed25519 curve.",[kq]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[Lq]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[Sq]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[Pq]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[wq]:"Program address cannot end with PDA marker.",[Rq]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[nK]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[cK]:"The network has progressed past the last block for which this transaction could have been committed.",[UQ]:"Codec [$codecDescription] cannot decode empty byte arrays.",[SU]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[oY]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[VQ]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[zQ]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[DQ]:"Encoder and decoder must either both be fixed-size or variable-size.",[CU]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[dY]:"Expected a fixed-size codec, got a variable-size one.",[iY]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[nY]:"Expected a variable-size codec, got a fixed-size one.",[LU]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[IQ]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[PU]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[AU]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[TU]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[OU]:"Invalid literal union variant. Expected one of [$variants], got $value.",[jU]:"Expected [$codecDescription] to have $expected items, got $actual.",[RU]:"Invalid value $value for base $base with alphabet $alphabet.",[NU]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[HQ]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[rY]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[aY]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[kU]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[dq]:"No random values implementation could be found.",[qW]:"instruction requires an uninitialized account",[NW]:"instruction tries to borrow reference for an account which is already borrowed",[kW]:"instruction left account with an outstanding borrowed reference",[RW]:"program other than the account's owner changed the size of the account data",[XW]:"account data too small for instruction",[OW]:"instruction expected an executable account",[nW]:"An account does not have enough lamports to be rent-exempt",[rW]:"Program arithmetic overflowed",[dW]:"Failed to serialize or deserialize account data: $encodedData",[$6]:"Builtin programs must consume compute units",[_W]:"Cross-program invocation call depth too deep",[fW]:"Computational budget exceeded",[LW]:"custom program error: #$code",[jW]:"instruction contains duplicate accounts",[PW]:"instruction modifications of multiply-passed account differ",[wW]:"executable accounts must be rent exempt",[EW]:"instruction changed executable accounts data",[BW]:"instruction changed the balance of an executable account",[CW]:"instruction changed executable bit of an account",[VW]:"instruction modified data of an account it does not own",[DW]:"instruction spent from the balance of an account it does not own",[JW]:"generic instruction error",[aW]:"Provided owner is not allowed",[cW]:"Account is immutable",[lW]:"Incorrect authority provided",[MW]:"incorrect program id for instruction",[ZW]:"insufficient funds for instruction",[YW]:"invalid account data for instruction",[iW]:"Invalid account owner",[QW]:"invalid program argument",[SW]:"program returned invalid error code",[GW]:"invalid instruction data",[yW]:"Failed to reallocate account data",[hW]:"Provided seeds do not result in a valid address",[sW]:"Accounts data allocations exceeded the maximum allowed per transaction",[tW]:"Max accounts exceeded",[eW]:"Max instruction trace length exceeded",[vW]:"Length of the seed is too long for address generation",[gW]:"An account required by the instruction is missing",[KW]:"missing required signature for instruction",[IW]:"instruction illegally modified the program id of an account",[TW]:"insufficient account keys for instruction",[bW]:"Cross-program invocation with unauthorized signer or writable account",[mW]:"Failed to create program execution environment",[uW]:"Program failed to compile",[pW]:"Program failed to complete",[HW]:"instruction modified data of a read-only account",[zW]:"instruction changed the balance of a read-only account",[xW]:"Cross-program invocation reentrancy not allowed for this instruction",[AW]:"instruction modified rent epoch of an account",[UW]:"sum of account balances before and after instruction do not match",[WW]:"instruction requires an initialized account",[$W]:"",[FW]:"Unsupported program id",[oW]:"Unsupported sysvar",[sq]:"The instruction does not have any accounts.",[tq]:"The instruction does not have any data.",[eq]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[iK]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[lK]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[bU]:"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",[pU]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[fU]:"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",[yU]:"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",[mU]:"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",[$q]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[Jq]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[Gq]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[Qq]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[eK]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[Kq]:"$__serverMessage",[Aq]:"$__serverMessage",[Hq]:"$__serverMessage",[Zq]:"$__serverMessage",[Wq]:"$__serverMessage",[Uq]:"$__serverMessage",[Yq]:"Minimum context slot has not been reached",[zq]:"Node is unhealthy; behind by $numSlotsBehind slots",[Iq]:"No snapshot",[Cq]:"Transaction simulation failed",[Dq]:"$__serverMessage",[qq]:"Transaction history is not available from this node",[Vq]:"$__serverMessage",[Mq]:"Transaction signature length mismatch",[jq]:"Transaction signature verification failure",[Xq]:"$__serverMessage",[nq]:"Key pair bytes must be of length 64, got $byteLength.",[iq]:"Expected private key bytes with length 32. Actual length: $actualLength.",[rq]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[aq]:"The provided private key does not match the provided public key.",[oq]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[rK]:"Lamports value must be in the range [0, 2e64-1]",[oK]:"`$value` cannot be parsed as a `BigInt`",[tK]:"$message",[aK]:"`$value` cannot be parsed as a `Number`",[dK]:"No nonce account could be found at address `$nonceAccountAddress`",[_U]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[xU]:"WebSocket was closed before payload could be added to the send buffer",[vU]:"WebSocket connection closed",[hU]:"WebSocket failed to connect",[gU]:"Failed to obtain a subscription id from the server",[FU]:"Could not find an API plan for RPC method: `$method`",[EU]:"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`.",[wU]:"HTTP error ($statusCode): $message",[BU]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[J6]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[Q6]:"The provided value does not implement the `KeyPairSigner` interface",[Y6]:"The provided value does not implement the `MessageModifyingSigner` interface",[X6]:"The provided value does not implement the `MessagePartialSigner` interface",[G6]:"The provided value does not implement any of the `MessageSigner` interfaces",[M6]:"The provided value does not implement the `TransactionModifyingSigner` interface",[K6]:"The provided value does not implement the `TransactionPartialSigner` interface",[q6]:"The provided value does not implement the `TransactionSendingSigner` interface",[Z6]:"The provided value does not implement any of the `TransactionSigner` interfaces",[W6]:"More than one `TransactionSendingSigner` was identified.",[U6]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[I6]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[lq]:"Cannot export a non-extractable key.",[fq]:"No digest implementation could be found.",[yq]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[bq]:`This runtime does not support the generation of Ed25519 key pairs.
|
|
2
|
+
|
|
3
|
+
Install @solana/webcrypto-ed25519-polyfill and call its \`install\` function before generating keys in environments that do not support Ed25519.
|
|
4
|
+
|
|
5
|
+
For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[mq]:"No signature verification implementation could be found.",[pq]:"No key generation implementation could be found.",[uq]:"No signing implementation could be found.",[cq]:"No key export implementation could be found.",[sK]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[a6]:"Transaction processing left an account with an outstanding borrowed reference",[v6]:"Account in use",[h6]:"Account loaded twice",[y6]:"Attempt to debit an account but found no record of a prior credit.",[GU]:"Transaction loads an address table account that doesn't exist",[p6]:"This transaction has already been processed",[u6]:"Blockhash not found",[c6]:"Loader call chain is too deep",[o6]:"Transactions are currently disabled due to cluster maintenance",[WU]:"Transaction contains a duplicate instruction ($index) that is not allowed",[b6]:"Insufficient funds for fee",[UU]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[m6]:"This account may not be used to pay transaction fees",[d6]:"Transaction contains an invalid account reference",[XU]:"Transaction loads an address table account with invalid data",[ZU]:"Transaction address table lookup uses an invalid index",[YU]:"Transaction loads an address table account with an invalid owner",[DU]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[i6]:"This program may not be used for executing instructions",[MU]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[e6]:"Transaction loads a writable account that cannot be written",[IU]:"Transaction exceeded max loaded accounts data size cap",[l6]:"Transaction requires a fee but has no signature present",[f6]:"Attempt to load a program that does not exist",[zU]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[VU]:"ResanitizationNeeded",[r6]:"Transaction failed to sanitize accounts offsets correctly",[n6]:"Transaction did not pass signature verification",[QU]:"Transaction locked too many accounts",[HU]:"Sum of account balances before and after transaction do not match",[x6]:"The transaction failed with the error `$errorName`",[t6]:"Transaction version is unsupported",[JU]:"Transaction would exceed account data limit within the block",[qU]:"Transaction would exceed total account data limit",[$U]:"Transaction would exceed max account limit within the block",[s6]:"Transaction would exceed max Block Cost Limit",[KU]:"Transaction would exceed max Vote Cost Limit",[E6]:"Attempted to sign a transaction with an address that is not a signer for it",[N6]:"Transaction is missing an address at index: $index.",[B6]:"Transaction has no expected signers therefore it cannot be encoded",[g6]:"Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",[z6]:"Transaction does not have a blockhash lifetime",[H6]:"Transaction is not a durable nonce transaction",[C6]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[A6]:"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",[R6]:"No fee payer set in CompiledTransaction",[T6]:"Could not find program address at index $index",[F6]:"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",[_6]:"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",[k6]:"Transaction is missing a fee payer.",[P6]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[S6]:"Transaction first instruction is not advance nonce account instruction.",[L6]:"Transaction with no instructions cannot be durable nonce transaction.",[D6]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[V6]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[w6]:"The transaction message expected the transaction to have $signerAddressesLength signatures, got $signaturesLength.",[O6]:"Transaction is missing signatures for addresses: $addresses.",[j6]:"Transaction version must be in the range [0, 127]. `$actualVersion` given"},J8="i",u1="t";function cU($,J={}){let Q=uU[$];if(Q.length===0)return"";let G;function Y(M){if(G[u1]===2){let I=Q.slice(G[J8]+1,M);X.push(I in J?`${J[I]}`:`$${I}`)}else if(G[u1]===1)X.push(Q.slice(G[J8],M))}let X=[];return Q.split("").forEach((M,I)=>{if(I===0){G={[J8]:0,[u1]:Q[0]==="\\"?0:Q[0]==="$"?2:1};return}let U;switch(G[u1]){case 0:U={[J8]:I,[u1]:1};break;case 1:if(M==="\\")U={[J8]:I,[u1]:0};else if(M==="$")U={[J8]:I,[u1]:2};break;case 2:if(M==="\\")U={[J8]:I,[u1]:0};else if(M==="$")U={[J8]:I,[u1]:2};else if(!M.match(/\w/))U={[J8]:I,[u1]:1};break}if(U){if(G!==U)Y(I);G=U}}),Y(),X.join("")}function lU($,J={}){return cU($,J)}var H8=class extends Error{cause=this.cause;context;constructor(...[$,J]){let Q,G;if(J){let{cause:X,...M}=J;if(X)G={cause:X};if(Object.keys(M).length>0)Q=M}let Y=lU($,Q);super(Y,G);this.context={__code:$,...Q},this.name="SolanaError"}};function dU($,J){return"fixedSize"in J?J.fixedSize:J.getSizeFromValue($)}function sY($){return Object.freeze({...$,encode:(J)=>{let Q=new Uint8Array(dU(J,$));return $.write(J,Q,0),Q}})}function tY($){return Object.freeze({...$,decode:(J,Q=0)=>$.read(J,Q)[0]})}function t8($){return"fixedSize"in $&&typeof $.fixedSize==="number"}function eY($,J){if(t8($)!==t8(J))throw new H8(DQ);if(t8($)&&t8(J)&&$.fixedSize!==J.fixedSize)throw new H8(VQ,{decoderFixedSize:J.fixedSize,encoderFixedSize:$.fixedSize});if(!t8($)&&!t8(J)&&$.maxSize!==J.maxSize)throw new H8(zQ,{decoderMaxSize:J.maxSize,encoderMaxSize:$.maxSize});return{...J,...$,decode:J.decode,encode:$.encode,read:J.read,write:$.write}}function $X($,J,Q=0){if(J.length-Q<=0)throw new H8(UQ,{codecDescription:$})}function JX($,J,Q,G=0){let Y=Q.length-G;if(Y<J)throw new H8(IQ,{bytesLength:Y,codecDescription:$,expected:J})}function nU($,J,Q,G){if(G<J||G>Q)throw new H8(HQ,{codecDescription:$,max:Q,min:J,value:G})}function QX($){return $?.endian===1?!1:!0}function iU($){return sY({fixedSize:$.size,write(J,Q,G){if($.range)nU($.name,$.range[0],$.range[1],J);let Y=new ArrayBuffer($.size);return $.set(new DataView(Y),J,QX($.config)),Q.set(new Uint8Array(Y),G),G+$.size}})}function rU($){return tY({fixedSize:$.size,read(J,Q=0){$X($.name,J,Q),JX($.name,$.size,J,Q);let G=new DataView(oU(J,Q,$.size));return[$.get(G,QX($.config)),Q+$.size]}})}function oU($,J,Q){let G=$.byteOffset+(J??0),Y=Q??$.byteLength;return $.buffer.slice(G,G+Y)}var jQ=($={})=>iU({config:$,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(J,Q,G)=>J.setBigUint64(0,BigInt(Q),G),size:8}),aU=($={})=>rU({config:$,get:(J,Q)=>J.getBigUint64(0,Q),name:"u64",size:8}),GX=($={})=>eY(jQ($),aU($));class XX extends TypeError{constructor($,J){let Q,{message:G,explanation:Y,...X}=$,{path:M}=$,I=M.length===0?G:`At path: ${M.join(".")} -- ${G}`;super(Y??I);if(Y!=null)this.cause=I;Object.assign(this,X),this.name=this.constructor.name,this.failures=()=>{return Q??(Q=[$,...J()])}}}function sU($){return R2($)&&typeof $[Symbol.iterator]==="function"}function R2($){return typeof $==="object"&&$!=null}function z$($){return R2($)&&!Array.isArray($)}function _1($){if(typeof $==="symbol")return $.toString();return typeof $==="string"?JSON.stringify($):`${$}`}function tU($){let{done:J,value:Q}=$.next();return J?void 0:Q}function eU($,J,Q,G){if($===!0)return;else if($===!1)$={};else if(typeof $==="string")$={message:$};let{path:Y,branch:X}=J,{type:M}=Q,{refinement:I,message:U=`Expected a value of type \`${M}\`${I?` with refinement \`${I}\``:""}, but received: \`${_1(G)}\``}=$;return{value:G,type:M,refinement:I,key:Y[Y.length-1],path:Y,branch:X,...$,message:U}}function*YX($,J,Q,G){if(!sU($))$=[$];for(let Y of $){let X=eU(Y,J,Q,G);if(X)yield X}}function*CQ($,J,Q={}){let{path:G=[],branch:Y=[$],coerce:X=!1,mask:M=!1}=Q,I={path:G,branch:Y,mask:M};if(X)$=J.coercer($,I);let U="valid";for(let T of J.validator($,I))T.explanation=Q.message,U="not_valid",yield[T,void 0];for(let[T,A,L]of J.entries($,I)){let N=CQ(A,L,{path:T===void 0?G:[...G,T],branch:T===void 0?Y:[...Y,A],coerce:X,mask:M,message:Q.message});for(let k of N)if(k[0])U=k[0].refinement!=null?"not_refined":"not_valid",yield[k[0],void 0];else if(X){if(A=k[1],T===void 0)$=A;else if($ instanceof Map)$.set(T,A);else if($ instanceof Set)$.add(A);else if(R2($)){if(A!==void 0||T in $)$[T]=A}}}if(U!=="not_valid")for(let T of J.refiner($,I))T.explanation=Q.message,U="not_refined",yield[T,void 0];if(U==="valid")yield[void 0,$]}class g1{constructor($){let{type:J,schema:Q,validator:G,refiner:Y,coercer:X=(I)=>I,entries:M=function*(){}}=$;if(this.type=J,this.schema=Q,this.entries=M,this.coercer=X,G)this.validator=(I,U)=>{let T=G(I,U);return YX(T,U,this,I)};else this.validator=()=>[];if(Y)this.refiner=(I,U)=>{let T=Y(I,U);return YX(T,U,this,I)};else this.refiner=()=>[]}assert($,J){return ZX($,this,J)}create($,J){return e8($,this,J)}is($){return MX($,this)}mask($,J){return $4($,this,J)}validate($,J={}){return O2($,this,J)}}function ZX($,J,Q){let G=O2($,J,{message:Q});if(G[0])throw G[0]}function e8($,J,Q){let G=O2($,J,{coerce:!0,message:Q});if(G[0])throw G[0];else return G[1]}function $4($,J,Q){let G=O2($,J,{coerce:!0,mask:!0,message:Q});if(G[0])throw G[0];else return G[1]}function MX($,J){return!O2($,J)[0]}function O2($,J,Q={}){let G=CQ($,J,Q),Y=tU(G);if(Y[0])return[new XX(Y[0],function*(){for(let M of G)if(M[0])yield M[0]}),void 0];else return[void 0,Y[1]]}function h8($,J){return new g1({type:$,schema:null,validator:J})}function KX(){return h8("any",()=>!0)}function p($){return new g1({type:"array",schema:$,*entries(J){if($&&Array.isArray(J))for(let[Q,G]of J.entries())yield[Q,G,$]},coercer(J){return Array.isArray(J)?J.slice():J},validator(J){return Array.isArray(J)||`Expected an array value, but received: ${_1(J)}`}})}function x1(){return h8("boolean",($)=>{return typeof $==="boolean"})}function H$($){return h8("instance",(J)=>{return J instanceof $||`Expected a \`${$.name}\` instance, but received: ${_1(J)}`})}function V0($){let J=_1($),Q=typeof $;return new g1({type:"literal",schema:Q==="string"||Q==="number"||Q==="boolean"?$:null,validator(G){return G===$||`Expected the literal \`${J}\`, but received: ${_1(G)}`}})}function J4(){return h8("never",()=>!1)}function u($){return new g1({...$,validator:(J,Q)=>J===null||$.validator(J,Q),refiner:(J,Q)=>J===null||$.refiner(J,Q)})}function E(){return h8("number",($)=>{return typeof $==="number"&&!isNaN($)||`Expected a number, but received: ${_1($)}`})}function i($){return new g1({...$,validator:(J,Q)=>J===void 0||$.validator(J,Q),refiner:(J,Q)=>J===void 0||$.refiner(J,Q)})}function AQ($,J){return new g1({type:"record",schema:null,*entries(Q){if(R2(Q))for(let G in Q){let Y=Q[G];yield[G,G,$],yield[G,Y,J]}},validator(Q){return z$(Q)||`Expected an object, but received: ${_1(Q)}`},coercer(Q){return z$(Q)?{...Q}:Q}})}function y(){return h8("string",($)=>{return typeof $==="string"||`Expected a string, but received: ${_1($)}`})}function j$($){let J=J4();return new g1({type:"tuple",schema:null,*entries(Q){if(Array.isArray(Q)){let G=Math.max($.length,Q.length);for(let Y=0;Y<G;Y++)yield[Y,Q[Y],$[Y]||J]}},validator(Q){return Array.isArray(Q)||`Expected an array, but received: ${_1(Q)}`},coercer(Q){return Array.isArray(Q)?Q.slice():Q}})}function g($){let J=Object.keys($);return new g1({type:"type",schema:$,*entries(Q){if(R2(Q))for(let G of J)yield[G,Q[G],$[G]]},validator(Q){return z$(Q)||`Expected an object, but received: ${_1(Q)}`},coercer(Q){return z$(Q)?{...Q}:Q}})}function Z1($){let J=$.map((Q)=>Q.type).join(" | ");return new g1({type:"union",schema:null,coercer(Q,G){for(let Y of $){let[X,M]=Y.validate(Q,{coerce:!0,mask:G.mask});if(!X)return M}return Q},validator(Q,G){let Y=[];for(let X of $){let[...M]=CQ(Q,X,G),[I]=M;if(!I[0])return[];else for(let[U]of M)if(U)Y.push(U)}return[`Expected the value to satisfy a union of \`${J}\`, but received: ${_1(Q)}`,...Y]}})}function y8(){return h8("unknown",()=>!0)}function $2($,J,Q){return new g1({...$,coercer:(G,Y)=>{return MX(G,J)?$.coercer(Q(G,Y),Y):$.coercer(G,Y)}})}var i4=R8(FX(),1);u8();var xX=R8(gX(),1);var E4=BigInt(0),w2=BigInt(1),B4=BigInt(2),w4=BigInt(7),F4=BigInt(256),_4=BigInt(113),yX=[],fX=[],bX=[];for(let $=0,J=w2,Q=1,G=0;$<24;$++){[Q,G]=[G,(2*Q+3*G)%5],yX.push(2*(5*G+Q)),fX.push(($+1)*($+2)/2%64);let Y=E4;for(let X=0;X<7;X++)if(J=(J<<w2^(J>>w4)*_4)%F4,J&B4)Y^=w2<<(w2<<BigInt(X))-w2;bX.push(Y)}var mX=o2(bX,!0),g4=mX[0],x4=mX[1],vX=($,J,Q)=>Q>32?iG($,J,Q):dG($,J,Q),hX=($,J,Q)=>Q>32?rG($,J,Q):nG($,J,Q);function v4($,J=24){let Q=new Uint32Array(10);for(let G=24-J;G<24;G++){for(let M=0;M<10;M++)Q[M]=$[M]^$[M+10]^$[M+20]^$[M+30]^$[M+40];for(let M=0;M<10;M+=2){let I=(M+8)%10,U=(M+2)%10,T=Q[U],A=Q[U+1],L=vX(T,A,1)^Q[I],N=hX(T,A,1)^Q[I+1];for(let k=0;k<50;k+=10)$[M+k]^=L,$[M+k+1]^=N}let Y=$[2],X=$[3];for(let M=0;M<24;M++){let I=fX[M],U=vX(Y,X,I),T=hX(Y,X,I),A=yX[M];Y=$[A],X=$[A+1],$[A]=U,$[A+1]=T}for(let M=0;M<50;M+=10){for(let I=0;I<10;I++)Q[I]=$[M+I];for(let I=0;I<10;I++)$[M+I]^=~Q[(I+2)%10]&Q[(I+4)%10]}$[0]^=g4[G],$[1]^=x4[G]}S1(Q)}class wQ extends S8{constructor($,J,Q,G=!1,Y=24){super();if(this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=$,this.suffix=J,this.outputLen=Q,this.enableXOF=G,this.rounds=Y,Z8(Q),!(0<$&&$<200))throw Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=mG(this.state)}clone(){return this._cloneInto()}keccak(){WJ(this.state32),v4(this.state32,this.rounds),WJ(this.state32),this.posOut=0,this.pos=0}update($){i1(this),$=L8($),J1($);let{blockLen:J,state:Q}=this,G=$.length;for(let Y=0;Y<G;){let X=Math.min(J-this.pos,G-Y);for(let M=0;M<X;M++)Q[this.pos++]^=$[Y++];if(this.pos===J)this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:$,suffix:J,pos:Q,blockLen:G}=this;if($[Q]^=J,(J&128)!==0&&Q===G-1)this.keccak();$[G-1]^=128,this.keccak()}writeInto($){i1(this,!1),J1($),this.finish();let J=this.state,{blockLen:Q}=this;for(let G=0,Y=$.length;G<Y;){if(this.posOut>=Q)this.keccak();let X=Math.min(Q-this.posOut,Y-G);$.set(J.subarray(this.posOut,this.posOut+X),G),this.posOut+=X,G+=X}return $}xofInto($){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto($)}xof($){return Z8($),this.xofInto(new Uint8Array($))}digestInto($){if(d2($,this),this.finished)throw Error("digest() was already called");return this.writeInto($),this.destroy(),$}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,S1(this.state)}_cloneInto($){let{blockLen:J,suffix:Q,outputLen:G,rounds:Y,enableXOF:X}=this;return $||($=new wQ(J,Q,G,X,Y)),$.state32.set(this.state32),$.pos=this.pos,$.posOut=this.posOut,$.finished=this.finished,$.rounds=Y,$.suffix=Q,$.outputLen=G,$.enableXOF=X,$.destroyed=this.destroyed,$}}var h4=($,J,Q)=>U2(()=>new wQ(J,$,Q));var FQ=(()=>h4(1,136,32))();class _Q extends S8{constructor($,J){super();this.finished=!1,this.destroyed=!1,l2($);let Q=L8(J);if(this.iHash=$.create(),typeof this.iHash.update!=="function")throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let G=this.blockLen,Y=new Uint8Array(G);Y.set(Q.length>G?$.create().update(Q).digest():Q);for(let X=0;X<Y.length;X++)Y[X]^=54;this.iHash.update(Y),this.oHash=$.create();for(let X=0;X<Y.length;X++)Y[X]^=106;this.oHash.update(Y),S1(Y)}update($){return i1(this),this.iHash.update($),this}digestInto($){i1(this),J1($,this.outputLen),this.finished=!0,this.iHash.digestInto($),this.oHash.update($),this.oHash.digestInto($),this.destroy()}digest(){let $=new Uint8Array(this.oHash.outputLen);return this.digestInto($),$}_cloneInto($){$||($=Object.create(Object.getPrototypeOf(this),{}));let{oHash:J,iHash:Q,finished:G,destroyed:Y,blockLen:X,outputLen:M}=this;return $=$,$.finished=G,$.destroyed=Y,$.blockLen=X,$.outputLen=M,$.oHash=J._cloneInto($.oHash),$.iHash=Q._cloneInto($.iHash),$}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}var gQ=($,J,Q)=>new _Q($,J).update(Q).digest();gQ.create=($,J)=>new _Q($,J);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var pX=($,J)=>($+($>=0?J:-J)/cX)/J;function y4($,J,Q){let[[G,Y],[X,M]]=J,I=pX(M*$,Q),U=pX(-Y*$,Q),T=$-I*G-U*X,A=-I*Y-U*M,L=T<G8,N=A<G8;if(L)T=-T;if(N)A=-A;let k=W8(Math.ceil(t2(Q)/2))+Q2;if(T<G8||T>=k||A<G8||A>=k)throw Error("splitScalar (endomorphism): failed, k="+$);return{k1neg:L,k1:T,k2neg:N,k2:A}}function vQ($){if(!["compact","recovered","der"].includes($))throw Error('Signature format must be "compact", "recovered", or "der"');return $}function xQ($,J){let Q={};for(let G of Object.keys(J))Q[G]=$[G]===void 0?J[G]:$[G];if(o1(Q.lowS,"lowS"),o1(Q.prehash,"prehash"),Q.format!==void 0)vQ(Q.format);return Q}class uX extends Error{constructor($=""){super($)}}var Q8={Err:uX,_tlv:{encode:($,J)=>{let{Err:Q}=Q8;if($<0||$>256)throw new Q("tlv.encode: wrong tag");if(J.length&1)throw new Q("tlv.encode: unpadded data");let G=J.length/2,Y=V2(G);if(Y.length/2&128)throw new Q("tlv.encode: long form length too big");let X=G>127?V2(Y.length/2|128):"";return V2($)+X+Y+J},decode($,J){let{Err:Q}=Q8,G=0;if($<0||$>256)throw new Q("tlv.encode: wrong tag");if(J.length<2||J[G++]!==$)throw new Q("tlv.decode: wrong tlv");let Y=J[G++],X=!!(Y&128),M=0;if(!X)M=Y;else{let U=Y&127;if(!U)throw new Q("tlv.decode(long): indefinite length not supported");if(U>4)throw new Q("tlv.decode(long): byte length is too big");let T=J.subarray(G,G+U);if(T.length!==U)throw new Q("tlv.decode: length bytes not complete");if(T[0]===0)throw new Q("tlv.decode(long): zero leftmost byte");for(let A of T)M=M<<8|A;if(G+=U,M<128)throw new Q("tlv.decode(long): not minimal encoding")}let I=J.subarray(G,G+M);if(I.length!==M)throw new Q("tlv.decode: wrong value length");return{v:I,l:J.subarray(G+M)}}},_int:{encode($){let{Err:J}=Q8;if($<G8)throw new J("integer: negative integers are not allowed");let Q=V2($);if(Number.parseInt(Q[0],16)&8)Q="00"+Q;if(Q.length&1)throw new J("unexpected DER parsing assertion: unpadded hex");return Q},decode($){let{Err:J}=Q8;if($[0]&128)throw new J("invalid signature integer: negative");if($[0]===0&&!($[1]&128))throw new J("invalid signature integer: unnecessary leading zero");return l8($)}},toSig($){let{Err:J,_int:Q,_tlv:G}=Q8,Y=M0("signature",$),{v:X,l:M}=G.decode(48,Y);if(M.length)throw new J("invalid signature: left bytes after parsing");let{v:I,l:U}=G.decode(2,X),{v:T,l:A}=G.decode(2,U);if(A.length)throw new J("invalid signature: left bytes after parsing");return{r:Q.decode(I),s:Q.decode(T)}},hexFromSig($){let{_tlv:J,_int:Q}=Q8,G=J.encode(2,Q.encode($.r)),Y=J.encode(2,Q.encode($.s)),X=G+Y;return J.encode(48,X)}},G8=BigInt(0),Q2=BigInt(1),cX=BigInt(2),O$=BigInt(3),f4=BigInt(4);function J2($,J){let{BYTES:Q}=$,G;if(typeof J==="bigint")G=J;else{let Y=M0("private key",J);try{G=$.fromBytes(Y)}catch(X){throw Error(`invalid private key: expected ui8a of size ${Q}, got ${typeof J}`)}}if(!$.isValidNot0(G))throw Error("invalid private key: out of range [1..N-1]");return G}function b4($,J={}){let Q=$$("weierstrass",$,J),{Fp:G,Fn:Y}=Q,X=Q.CURVE,{h:M,n:I}=X;U8(J,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});let{endo:U}=J;if(U){if(!G.is0(X.a)||typeof U.beta!=="bigint"||!Array.isArray(U.basises))throw Error('invalid endo: expected "beta": bigint and "basises": array')}let T=dX(G,Y);function A(){if(!G.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function L(w,z,Z){let{x:K,y:W}=z.toAffine(),D=G.toBytes(K);if(o1(Z,"isCompressed"),Z){A();let V=!G.isOdd(W);return D1(lX(V),D)}else return D1(Uint8Array.of(4),D,G.toBytes(W))}function N(w){N1(w,void 0,"Point");let{publicKey:z,publicKeyUncompressed:Z}=T,K=w.length,W=w[0],D=w.subarray(1);if(K===z&&(W===2||W===3)){let V=G.fromBytes(D);if(!G.isValid(V))throw Error("bad point: is not on curve, wrong x");let C=F(V),R;try{R=G.sqrt(C)}catch(j){let v=j instanceof Error?": "+j.message:"";throw Error("bad point: is not on curve, sqrt error"+v)}A();let H=G.isOdd(R);if((W&1)===1!==H)R=G.neg(R);return{x:V,y:R}}else if(K===Z&&W===4){let V=G.BYTES,C=G.fromBytes(D.subarray(0,V)),R=G.fromBytes(D.subarray(V,V*2));if(!B(C,R))throw Error("bad point: is not on curve");return{x:C,y:R}}else throw Error(`bad point: got length ${K}, expected compressed=${z} or uncompressed=${Z}`)}let k=J.toBytes||L,P=J.fromBytes||N;function F(w){let z=G.sqr(w),Z=G.mul(z,w);return G.add(G.add(Z,G.mul(w,X.a)),X.b)}function B(w,z){let Z=G.sqr(z),K=F(w);return G.eql(Z,K)}if(!B(X.Gx,X.Gy))throw Error("bad curve params: generator point");let _=G.mul(G.pow(X.a,O$),f4),h=G.mul(G.sqr(X.b),BigInt(27));if(G.is0(G.add(_,h)))throw Error("bad curve params: a or b");function f(w,z,Z=!1){if(!G.isValid(z)||Z&&G.is0(z))throw Error(`bad point coordinate ${w}`);return z}function c(w){if(!(w instanceof x))throw Error("ProjectivePoint expected")}function s(w){if(!U||!U.basises)throw Error("no endo");return y4(w,U.basises,Y.ORDER)}let o=d8((w,z)=>{let{X:Z,Y:K,Z:W}=w;if(G.eql(W,G.ONE))return{x:Z,y:K};let D=w.is0();if(z==null)z=D?G.ONE:G.inv(W);let V=G.mul(Z,z),C=G.mul(K,z),R=G.mul(W,z);if(D)return{x:G.ZERO,y:G.ZERO};if(!G.eql(R,G.ONE))throw Error("invZ was invalid");return{x:V,y:C}}),r=d8((w)=>{if(w.is0()){if(J.allowInfinityPoint&&!G.is0(w.Y))return;throw Error("bad point: ZERO")}let{x:z,y:Z}=w.toAffine();if(!G.isValid(z)||!G.isValid(Z))throw Error("bad point: x or y not field elements");if(!B(z,Z))throw Error("bad point: equation left != right");if(!w.isTorsionFree())throw Error("bad point: not in prime-order subgroup");return!0});function t(w,z,Z,K,W){return Z=new x(G.mul(Z.X,w),Z.Y,Z.Z),z=j2(K,z),Z=j2(W,Z),z.add(Z)}class x{constructor(w,z,Z){this.X=f("x",w),this.Y=f("y",z,!0),this.Z=f("z",Z),Object.freeze(this)}static CURVE(){return X}static fromAffine(w){let{x:z,y:Z}=w||{};if(!w||!G.isValid(z)||!G.isValid(Z))throw Error("invalid affine point");if(w instanceof x)throw Error("projective point not allowed");if(G.is0(z)&&G.is0(Z))return x.ZERO;return new x(z,Z,G.ONE)}static fromBytes(w){let z=x.fromAffine(P(N1(w,void 0,"point")));return z.assertValidity(),z}static fromHex(w){return x.fromBytes(M0("pointHex",w))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(w=8,z=!0){if(l.createCache(this,w),!z)this.multiply(O$);return this}assertValidity(){r(this)}hasEvenY(){let{y:w}=this.toAffine();if(!G.isOdd)throw Error("Field doesn't support isOdd");return!G.isOdd(w)}equals(w){c(w);let{X:z,Y:Z,Z:K}=this,{X:W,Y:D,Z:V}=w,C=G.eql(G.mul(z,V),G.mul(W,K)),R=G.eql(G.mul(Z,V),G.mul(D,K));return C&&R}negate(){return new x(this.X,G.neg(this.Y),this.Z)}double(){let{a:w,b:z}=X,Z=G.mul(z,O$),{X:K,Y:W,Z:D}=this,V=G.ZERO,C=G.ZERO,R=G.ZERO,H=G.mul(K,K),q=G.mul(W,W),j=G.mul(D,D),v=G.mul(K,W);return v=G.add(v,v),R=G.mul(K,D),R=G.add(R,R),V=G.mul(w,R),C=G.mul(Z,j),C=G.add(V,C),V=G.sub(q,C),C=G.add(q,C),C=G.mul(V,C),V=G.mul(v,V),R=G.mul(Z,R),j=G.mul(w,j),v=G.sub(H,j),v=G.mul(w,v),v=G.add(v,R),R=G.add(H,H),H=G.add(R,H),H=G.add(H,j),H=G.mul(H,v),C=G.add(C,H),j=G.mul(W,D),j=G.add(j,j),H=G.mul(j,v),V=G.sub(V,H),R=G.mul(j,q),R=G.add(R,R),R=G.add(R,R),new x(V,C,R)}add(w){c(w);let{X:z,Y:Z,Z:K}=this,{X:W,Y:D,Z:V}=w,C=G.ZERO,R=G.ZERO,H=G.ZERO,q=X.a,j=G.mul(X.b,O$),v=G.mul(z,W),m=G.mul(Z,D),b=G.mul(K,V),n=G.add(z,Z),a=G.add(W,D);n=G.mul(n,a),a=G.add(v,m),n=G.sub(n,a),a=G.add(z,K);let e=G.add(W,V);return a=G.mul(a,e),e=G.add(v,b),a=G.sub(a,e),e=G.add(Z,K),C=G.add(D,V),e=G.mul(e,C),C=G.add(m,b),e=G.sub(e,C),H=G.mul(q,a),C=G.mul(j,b),H=G.add(C,H),C=G.sub(m,H),H=G.add(m,H),R=G.mul(C,H),m=G.add(v,v),m=G.add(m,v),b=G.mul(q,b),a=G.mul(j,a),m=G.add(m,b),b=G.sub(v,b),b=G.mul(q,b),a=G.add(a,b),v=G.mul(m,a),R=G.add(R,v),v=G.mul(e,a),C=G.mul(n,C),C=G.sub(C,v),v=G.mul(n,m),H=G.mul(e,H),H=G.add(H,v),new x(C,R,H)}subtract(w){return this.add(w.negate())}is0(){return this.equals(x.ZERO)}multiply(w){let{endo:z}=J;if(!Y.isValidNot0(w))throw Error("invalid scalar: out of range");let Z,K,W=(D)=>l.cached(this,D,(V)=>t1(x,V));if(z){let{k1neg:D,k1:V,k2neg:C,k2:R}=s(w),{p:H,f:q}=W(V),{p:j,f:v}=W(R);K=q.add(v),Z=t(z.beta,H,j,D,C)}else{let{p:D,f:V}=W(w);Z=D,K=V}return t1(x,[Z,K])[0]}multiplyUnsafe(w){let{endo:z}=J,Z=this;if(!Y.isValid(w))throw Error("invalid scalar: out of range");if(w===G8||Z.is0())return x.ZERO;if(w===Q2)return Z;if(l.hasCache(this))return this.multiply(w);if(z){let{k1neg:K,k1:W,k2neg:D,k2:V}=s(w),{p1:C,p2:R}=NY(x,Z,W,V);return t(z.beta,C,R,K,D)}else return l.unsafe(Z,w)}multiplyAndAddUnsafe(w,z,Z){let K=this.multiplyUnsafe(z).add(w.multiplyUnsafe(Z));return K.is0()?void 0:K}toAffine(w){return o(this,w)}isTorsionFree(){let{isTorsionFree:w}=J;if(M===Q2)return!0;if(w)return w(x,this);return l.unsafe(this,I).is0()}clearCofactor(){let{clearCofactor:w}=J;if(M===Q2)return this;if(w)return w(x,this);return this.multiplyUnsafe(M)}isSmallOrder(){return this.multiplyUnsafe(M).is0()}toBytes(w=!0){return o1(w,"isCompressed"),this.assertValidity(),k(x,this,w)}toHex(w=!0){return E1(this.toBytes(w))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(w=!0){return this.toBytes(w)}_setWindowSize(w){this.precompute(w)}static normalizeZ(w){return t1(x,w)}static msm(w,z){return i8(x,Y,w,z)}static fromPrivateKey(w){return x.BASE.multiply(J2(Y,w))}}x.BASE=new x(X.Gx,X.Gy,G.ONE),x.ZERO=new x(G.ZERO,G.ONE,G.ZERO),x.Fp=G,x.Fn=Y;let d=Y.BITS,l=new C2(x,J.endo?Math.ceil(d/2):d);return x.BASE.precompute(8),x}function lX($){return Uint8Array.of($?2:3)}function dX($,J){return{secretKey:J.BYTES,publicKey:1+$.BYTES,publicKeyUncompressed:1+2*$.BYTES,publicKeyHasPrefix:!0,signature:2*J.BYTES}}function m4($,J={}){let{Fn:Q}=$,G=J.randomBytes||c8,Y=Object.assign(dX($.Fp,Q),{seed:NJ(Q.ORDER)});function X(k){try{return!!J2(Q,k)}catch(P){return!1}}function M(k,P){let{publicKey:F,publicKeyUncompressed:B}=Y;try{let _=k.length;if(P===!0&&_!==F)return!1;if(P===!1&&_!==B)return!1;return!!$.fromBytes(k)}catch(_){return!1}}function I(k=G(Y.seed)){return kJ(N1(k,Y.seed,"seed"),Q.ORDER)}function U(k,P=!0){return $.BASE.multiply(J2(Q,k)).toBytes(P)}function T(k){let P=I(k);return{secretKey:P,publicKey:U(P)}}function A(k){if(typeof k==="bigint")return!1;if(k instanceof $)return!0;let{secretKey:P,publicKey:F,publicKeyUncompressed:B}=Y;if(Q.allowedLengths||P===F)return;let _=M0("key",k).length;return _===F||_===B}function L(k,P,F=!0){if(A(k)===!0)throw Error("first arg must be private key");if(A(P)===!1)throw Error("second arg must be public key");let B=J2(Q,k);return $.fromHex(P).multiply(B).toBytes(F)}return Object.freeze({getPublicKey:U,getSharedSecret:L,keygen:T,Point:$,utils:{isValidSecretKey:X,isValidPublicKey:M,randomSecretKey:I,isValidPrivateKey:X,randomPrivateKey:I,normPrivateKeyToScalar:(k)=>J2(Q,k),precompute(k=8,P=$.BASE){return P.precompute(k,!1)}},lengths:Y})}function p4($,J,Q={}){l2(J),U8(Q,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let G=Q.randomBytes||c8,Y=Q.hmac||((Z,...K)=>gQ(J,Z,D1(...K))),{Fp:X,Fn:M}=$,{ORDER:I,BITS:U}=M,{keygen:T,getPublicKey:A,getSharedSecret:L,utils:N,lengths:k}=m4($,Q),P={prehash:!1,lowS:typeof Q.lowS==="boolean"?Q.lowS:!1,format:void 0,extraEntropy:!1},F="compact";function B(Z){let K=I>>Q2;return Z>K}function _(Z,K){if(!M.isValidNot0(K))throw Error(`invalid signature ${Z}: out of range 1..Point.Fn.ORDER`);return K}function h(Z,K){vQ(K);let W=k.signature,D=K==="compact"?W:K==="recovered"?W+1:void 0;return N1(Z,D,`${K} signature`)}class f{constructor(Z,K,W){if(this.r=_("r",Z),this.s=_("s",K),W!=null)this.recovery=W;Object.freeze(this)}static fromBytes(Z,K=F){h(Z,K);let W;if(K==="der"){let{r:R,s:H}=Q8.toSig(N1(Z));return new f(R,H)}if(K==="recovered")W=Z[0],K="compact",Z=Z.subarray(1);let D=M.BYTES,V=Z.subarray(0,D),C=Z.subarray(D,D*2);return new f(M.fromBytes(V),M.fromBytes(C),W)}static fromHex(Z,K){return this.fromBytes(P8(Z),K)}addRecoveryBit(Z){return new f(this.r,this.s,Z)}recoverPublicKey(Z){let K=X.ORDER,{r:W,s:D,recovery:V}=this;if(V==null||![0,1,2,3].includes(V))throw Error("recovery id invalid");if(I*cX<K&&V>1)throw Error("recovery id is ambiguous for h>1 curve");let R=V===2||V===3?W+I:W;if(!X.isValid(R))throw Error("recovery id 2 or 3 invalid");let H=X.toBytes(R),q=$.fromBytes(D1(lX((V&1)===0),H)),j=M.inv(R),v=s(M0("msgHash",Z)),m=M.create(-v*j),b=M.create(D*j),n=$.BASE.multiplyUnsafe(m).add(q.multiplyUnsafe(b));if(n.is0())throw Error("point at infinify");return n.assertValidity(),n}hasHighS(){return B(this.s)}toBytes(Z=F){if(vQ(Z),Z==="der")return P8(Q8.hexFromSig(this));let K=M.toBytes(this.r),W=M.toBytes(this.s);if(Z==="recovered"){if(this.recovery==null)throw Error("recovery bit must be present");return D1(Uint8Array.of(this.recovery),K,W)}return D1(K,W)}toHex(Z){return E1(this.toBytes(Z))}assertValidity(){}static fromCompact(Z){return f.fromBytes(M0("sig",Z),"compact")}static fromDER(Z){return f.fromBytes(M0("sig",Z),"der")}normalizeS(){return this.hasHighS()?new f(this.r,M.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return E1(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return E1(this.toBytes("compact"))}}let c=Q.bits2int||function(K){if(K.length>8192)throw Error("input is too large");let W=l8(K),D=K.length*8-U;return D>0?W>>BigInt(D):W},s=Q.bits2int_modN||function(K){return M.create(c(K))},o=W8(U);function r(Z){return z2("num < 2^"+U,Z,G8,o),M.toBytes(Z)}function t(Z,K){return N1(Z,void 0,"message"),K?N1(J(Z),void 0,"prehashed message"):Z}function x(Z,K,W){if(["recovered","canonical"].some((b)=>(b in W)))throw Error("sign() legacy options not supported");let{lowS:D,prehash:V,extraEntropy:C}=xQ(W,P);Z=t(Z,V);let R=s(Z),H=J2(M,K),q=[r(H),r(R)];if(C!=null&&C!==!1){let b=C===!0?G(k.secretKey):C;q.push(M0("extraEntropy",b))}let j=D1(...q),v=R;function m(b){let n=c(b);if(!M.isValidNot0(n))return;let a=M.inv(n),e=$.BASE.multiply(n).toAffine(),C1=M.create(e.x);if(C1===G8)return;let X0=M.create(a*M.create(v+C1*H));if(X0===G8)return;let q0=(e.x===C1?0:2)|Number(e.y&Q2),M2=X0;if(D&&B(X0))M2=M.neg(X0),q0^=1;return new f(C1,M2,q0)}return{seed:j,k2sig:m}}function d(Z,K,W={}){Z=M0("message",Z);let{seed:D,k2sig:V}=x(Z,K,W);return MY(J.outputLen,M.BYTES,Y)(D,V)}function l(Z){let K=void 0,W=typeof Z==="string"||n1(Z),D=!W&&Z!==null&&typeof Z==="object"&&typeof Z.r==="bigint"&&typeof Z.s==="bigint";if(!W&&!D)throw Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(D)K=new f(Z.r,Z.s);else if(W){try{K=f.fromBytes(M0("sig",Z),"der")}catch(V){if(!(V instanceof Q8.Err))throw V}if(!K)try{K=f.fromBytes(M0("sig",Z),"compact")}catch(V){return!1}}if(!K)return!1;return K}function w(Z,K,W,D={}){let{lowS:V,prehash:C,format:R}=xQ(D,P);if(W=M0("publicKey",W),K=t(M0("message",K),C),"strict"in D)throw Error("options.strict was renamed to lowS");let H=R===void 0?l(Z):f.fromBytes(M0("sig",Z),R);if(H===!1)return!1;try{let q=$.fromBytes(W);if(V&&H.hasHighS())return!1;let{r:j,s:v}=H,m=s(K),b=M.inv(v),n=M.create(m*b),a=M.create(j*b),e=$.BASE.multiplyUnsafe(n).add(q.multiplyUnsafe(a));if(e.is0())return!1;return M.create(e.x)===j}catch(q){return!1}}function z(Z,K,W={}){let{prehash:D}=xQ(W,P);return K=t(K,D),f.fromBytes(Z,"recovered").recoverPublicKey(K).toBytes()}return Object.freeze({keygen:T,getPublicKey:A,getSharedSecret:L,utils:N,lengths:k,Point:$,sign:d,verify:w,recoverPublicKey:z,Signature:f,hash:J})}function u4($){let J={a:$.a,b:$.b,p:$.Fp.ORDER,n:$.n,h:$.h,Gx:$.Gx,Gy:$.Gy},Q=$.Fp,G=$.allowedPrivateKeyLengths?Array.from(new Set($.allowedPrivateKeyLengths.map((M)=>Math.ceil(M/2)))):void 0,Y=k1(J.n,{BITS:$.nBitLength,allowedLengths:G,modFromBytes:$.wrapPrivateKey}),X={Fp:Q,Fn:Y,allowInfinityPoint:$.allowInfinityPoint,endo:$.endo,isTorsionFree:$.isTorsionFree,clearCofactor:$.clearCofactor,fromBytes:$.fromBytes,toBytes:$.toBytes};return{CURVE:J,curveOpts:X}}function c4($){let{CURVE:J,curveOpts:Q}=u4($),G={hmac:$.hmac,randomBytes:$.randomBytes,lowS:$.lowS,bits2int:$.bits2int,bits2int_modN:$.bits2int_modN};return{CURVE:J,curveOpts:Q,hash:$.hash,ecdsaOpts:G}}function l4($,J){let Q=J.Point;return Object.assign({},J,{ProjectivePoint:Q,CURVE:Object.assign({},$,e2(Q.Fn.ORDER,Q.Fn.BITS))})}function nX($){let{CURVE:J,curveOpts:Q,hash:G,ecdsaOpts:Y}=c4($),X=b4(J,Q),M=p4(X,G,Y);return l4($,M)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function iX($,J){let Q=(G)=>nX({...$,hash:G});return{...Q(J),create:Q}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var yQ={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},d4={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var rX=BigInt(2);function n4($){let J=yQ.p,Q=BigInt(3),G=BigInt(6),Y=BigInt(11),X=BigInt(22),M=BigInt(23),I=BigInt(44),U=BigInt(88),T=$*$*$%J,A=T*T*$%J,L=D0(A,Q,J)*A%J,N=D0(L,Q,J)*A%J,k=D0(N,rX,J)*T%J,P=D0(k,Y,J)*k%J,F=D0(P,X,J)*P%J,B=D0(F,I,J)*F%J,_=D0(B,U,J)*B%J,h=D0(_,I,J)*F%J,f=D0(h,Q,J)*A%J,c=D0(f,M,J)*P%J,s=D0(c,G,J)*T%J,o=D0(s,rX,J);if(!hQ.eql(hQ.sqr(o),$))throw Error("Cannot find square root");return o}var hQ=k1(yQ.p,{sqrt:n4}),N$=iX({...yQ,Fp:hQ,lowS:!0,endo:d4},a2);var QD=T1.utils.randomPrivateKey,oX=()=>{let $=T1.utils.randomPrivateKey(),J=cQ($),Q=new Uint8Array(64);return Q.set($),Q.set(J,32),{publicKey:J,secretKey:Q}},cQ=T1.getPublicKey;function aX($){try{return T1.ExtendedPoint.fromHex($),!0}catch{return!1}}var K5=($,J)=>T1.sign($,J.slice(0,32)),r4=T1.verify,Y0=($)=>{if(S.isBuffer($))return $;else if($ instanceof Uint8Array)return S.from($.buffer,$.byteOffset,$.byteLength);else return S.from($)};class q5{constructor($){Object.assign(this,$)}encode(){return S.from(X2.serialize(L$,this))}static decode($){return X2.deserialize(L$,this,$)}static decodeUnchecked($){return X2.deserializeUnchecked(L$,this,$)}}var L$=new Map,W5,o4=32,h2=32;function a4($){return $._bn!==void 0}var sX=1;class $0 extends q5{constructor($){super({});if(this._bn=void 0,a4($))this._bn=$._bn;else{if(typeof $==="string"){let J=O1.default.decode($);if(J.length!=h2)throw Error("Invalid public key input");this._bn=new uQ.default(J)}else this._bn=new uQ.default($);if(this._bn.byteLength()>h2)throw Error("Invalid public key input")}}static unique(){let $=new $0(sX);return sX+=1,new $0($.toBuffer())}equals($){return this._bn.eq($._bn)}toBase58(){return O1.default.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){let $=this.toBuffer();return new Uint8Array($.buffer,$.byteOffset,$.byteLength)}toBuffer(){let $=this._bn.toArrayLike(S);if($.length===h2)return $;let J=S.alloc(32);return $.copy(J,32-$.length),J}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed($,J,Q){let G=S.concat([$.toBuffer(),S.from(J),Q.toBuffer()]),Y=fJ(G);return new $0(Y)}static createProgramAddressSync($,J){let Q=S.alloc(0);$.forEach(function(Y){if(Y.length>o4)throw TypeError("Max seed length exceeded");Q=S.concat([Q,Y0(Y)])}),Q=S.concat([Q,J.toBuffer(),S.from("ProgramDerivedAddress")]);let G=fJ(Q);if(aX(G))throw Error("Invalid seeds, address must fall off the curve");return new $0(G)}static async createProgramAddress($,J){return this.createProgramAddressSync($,J)}static findProgramAddressSync($,J){let Q=255,G;while(Q!=0){try{let Y=$.concat(S.from([Q]));G=this.createProgramAddressSync(Y,J)}catch(Y){if(Y instanceof TypeError)throw Y;Q--;continue}return[G,Q]}throw Error("Unable to find a viable program address nonce")}static async findProgramAddress($,J){return this.findProgramAddressSync($,J)}static isOnCurve($){let J=new $0($);return aX(J.toBytes())}}W5=$0;$0.default=new W5("11111111111111111111111111111111");L$.set($0,{kind:"struct",fields:[["_bn","u256"]]});var GD=new $0("BPFLoader1111111111111111111111111111111111"),S$=1232,s4=127,U5=64;class I5 extends Error{constructor($){super(`Signature ${$} has expired: block height exceeded.`);this.signature=void 0,this.signature=$}}Object.defineProperty(I5.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class D5 extends Error{constructor($,J){super(`Transaction was not confirmed in ${J.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${$} using the Solana Explorer or CLI tools.`);this.signature=void 0,this.signature=$}}Object.defineProperty(D5.prototype,"name",{value:"TransactionExpiredTimeoutError"});class V5 extends Error{constructor($){super(`Signature ${$} has expired: the nonce is no longer valid.`);this.signature=void 0,this.signature=$}}Object.defineProperty(V5.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class lQ{constructor($,J){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=$,this.accountKeysFromLookups=J}keySegments(){let $=[this.staticAccountKeys];if(this.accountKeysFromLookups)$.push(this.accountKeysFromLookups.writable),$.push(this.accountKeysFromLookups.readonly);return $}get($){for(let J of this.keySegments())if($<J.length)return J[$];else $-=J.length;return}get length(){return this.keySegments().flat().length}compileInstructions($){if(this.length>256)throw Error("Account index overflow encountered during compilation");let Q=new Map;this.keySegments().flat().forEach((Y,X)=>{Q.set(Y.toBase58(),X)});let G=(Y)=>{let X=Q.get(Y.toBase58());if(X===void 0)throw Error("Encountered an unknown instruction account key during compilation");return X};return $.map((Y)=>{return{programIdIndex:G(Y.programId),accountKeyIndexes:Y.keys.map((X)=>G(X.pubkey)),data:Y.data}})}}var Q0=($="publicKey")=>{return O.blob(32,$)};var G2=($="string")=>{let J=O.struct([O.u32("length"),O.u32("lengthPadding"),O.blob(O.offset(O.u32(),-8),"chars")],$),Q=J.decode.bind(J),G=J.encode.bind(J),Y=J;return Y.decode=(X,M)=>{return Q(X,M).chars.toString()},Y.encode=(X,M,I)=>{let U={chars:S.from(X,"utf8")};return G(U,M,I)},Y.alloc=(X)=>{return O.u32().span+O.u32().span+S.from(X,"utf8").length},Y},t4=($="authorized")=>{return O.struct([Q0("staker"),Q0("withdrawer")],$)},e4=($="lockup")=>{return O.struct([O.ns64("unixTimestamp"),O.ns64("epoch"),Q0("custodian")],$)},$7=($="voteInit")=>{return O.struct([Q0("nodePubkey"),Q0("authorizedVoter"),Q0("authorizedWithdrawer"),O.u8("commission")],$)},J7=($="voteAuthorizeWithSeedArgs")=>{return O.struct([O.u32("voteAuthorizationType"),Q0("currentAuthorityDerivedKeyOwnerPubkey"),G2("currentAuthorityDerivedKeySeed"),Q0("newAuthorized")],$)};function z5($,J){let Q=(Y)=>{if(Y.span>=0)return Y.span;else if(typeof Y.alloc==="function")return Y.alloc(J[Y.property]);else if("count"in Y&&"elementLayout"in Y){let X=J[Y.property];if(Array.isArray(X))return X.length*Q(Y.elementLayout)}else if("fields"in Y)return z5({layout:Y},J[Y.property]);return 0},G=0;return $.layout.fields.forEach((Y)=>{G+=Q(Y)}),G}function g2($){let J=0,Q=0;for(;;){let G=$.shift();if(J|=(G&127)<<Q*7,Q+=1,(G&128)===0)break}return J}function x2($,J){let Q=J;for(;;){let G=Q&127;if(Q>>=7,Q==0){$.push(G);break}else G|=128,$.push(G)}}function s0($,J){if(!$)throw Error(J||"Assertion failed")}class nQ{constructor($,J){this.payer=void 0,this.keyMetaMap=void 0,this.payer=$,this.keyMetaMap=J}static compile($,J){let Q=new Map,G=(X)=>{let M=X.toBase58(),I=Q.get(M);if(I===void 0)I={isSigner:!1,isWritable:!1,isInvoked:!1},Q.set(M,I);return I},Y=G(J);Y.isSigner=!0,Y.isWritable=!0;for(let X of $){G(X.programId).isInvoked=!0;for(let M of X.keys){let I=G(M.pubkey);I.isSigner||=M.isSigner,I.isWritable||=M.isWritable}}return new nQ(J,Q)}getMessageComponents(){let $=[...this.keyMetaMap.entries()];s0($.length<=256,"Max static account keys length exceeded");let J=$.filter(([,I])=>I.isSigner&&I.isWritable),Q=$.filter(([,I])=>I.isSigner&&!I.isWritable),G=$.filter(([,I])=>!I.isSigner&&I.isWritable),Y=$.filter(([,I])=>!I.isSigner&&!I.isWritable),X={numRequiredSignatures:J.length+Q.length,numReadonlySignedAccounts:Q.length,numReadonlyUnsignedAccounts:Y.length};{s0(J.length>0,"Expected at least one writable signer key");let[I]=J[0];s0(I===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}let M=[...J.map(([I])=>new $0(I)),...Q.map(([I])=>new $0(I)),...G.map(([I])=>new $0(I)),...Y.map(([I])=>new $0(I))];return[X,M]}extractTableLookup($){let[J,Q]=this.drainKeysFoundInLookupTable($.state.addresses,(X)=>!X.isSigner&&!X.isInvoked&&X.isWritable),[G,Y]=this.drainKeysFoundInLookupTable($.state.addresses,(X)=>!X.isSigner&&!X.isInvoked&&!X.isWritable);if(J.length===0&&G.length===0)return;return[{accountKey:$.key,writableIndexes:J,readonlyIndexes:G},{writable:Q,readonly:Y}]}drainKeysFoundInLookupTable($,J){let Q=[],G=[];for(let[Y,X]of this.keyMetaMap.entries())if(J(X)){let M=new $0(Y),I=$.findIndex((U)=>U.equals(M));if(I>=0)s0(I<256,"Max lookup table index exceeded"),Q.push(I),G.push(M),this.keyMetaMap.delete(Y)}return[Q,G]}}var H5="Reached end of buffer unexpectedly";function k$($){if($.length===0)throw Error(H5);return $.shift()}function v2($,...J){let[Q]=J;if(J.length===2?Q+(J[1]??0)>$.length:Q>=$.length)throw Error(H5);return $.splice(...J)}class b2{constructor($){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=$.header,this.accountKeys=$.accountKeys.map((J)=>new $0(J)),this.recentBlockhash=$.recentBlockhash,this.instructions=$.instructions,this.instructions.forEach((J)=>this.indexToProgramIds.set(J.programIdIndex,this.accountKeys[J.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(($)=>({programIdIndex:$.programIdIndex,accountKeyIndexes:$.accounts,data:O1.default.decode($.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new lQ(this.staticAccountKeys)}static compile($){let J=nQ.compile($.instructions,$.payerKey),[Q,G]=J.getMessageComponents(),X=new lQ(G).compileInstructions($.instructions).map((M)=>({programIdIndex:M.programIdIndex,accounts:M.accountKeyIndexes,data:O1.default.encode(M.data)}));return new b2({header:Q,accountKeys:G,recentBlockhash:$.recentBlockhash,instructions:X})}isAccountSigner($){return $<this.header.numRequiredSignatures}isAccountWritable($){let J=this.header.numRequiredSignatures;if($>=this.header.numRequiredSignatures){let Q=$-J,Y=this.accountKeys.length-J-this.header.numReadonlyUnsignedAccounts;return Q<Y}else{let Q=J-this.header.numReadonlySignedAccounts;return $<Q}}isProgramId($){return this.indexToProgramIds.has($)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter(($,J)=>!this.isProgramId(J))}serialize(){let $=this.accountKeys.length,J=[];x2(J,$);let Q=this.instructions.map((A)=>{let{accounts:L,programIdIndex:N}=A,k=Array.from(O1.default.decode(A.data)),P=[];x2(P,L.length);let F=[];return x2(F,k.length),{programIdIndex:N,keyIndicesCount:S.from(P),keyIndices:L,dataLength:S.from(F),data:k}}),G=[];x2(G,Q.length);let Y=S.alloc(S$);S.from(G).copy(Y);let X=G.length;Q.forEach((A)=>{let N=O.struct([O.u8("programIdIndex"),O.blob(A.keyIndicesCount.length,"keyIndicesCount"),O.seq(O.u8("keyIndex"),A.keyIndices.length,"keyIndices"),O.blob(A.dataLength.length,"dataLength"),O.seq(O.u8("userdatum"),A.data.length,"data")]).encode(A,Y,X);X+=N}),Y=Y.slice(0,X);let M=O.struct([O.blob(1,"numRequiredSignatures"),O.blob(1,"numReadonlySignedAccounts"),O.blob(1,"numReadonlyUnsignedAccounts"),O.blob(J.length,"keyCount"),O.seq(Q0("key"),$,"keys"),Q0("recentBlockhash")]),I={numRequiredSignatures:S.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:S.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:S.from([this.header.numReadonlyUnsignedAccounts]),keyCount:S.from(J),keys:this.accountKeys.map((A)=>Y0(A.toBytes())),recentBlockhash:O1.default.decode(this.recentBlockhash)},U=S.alloc(2048),T=M.encode(I,U);return Y.copy(U,T),U.slice(0,T+Y.length)}static from($){let J=[...$],Q=k$(J);if(Q!==(Q&s4))throw Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");let G=k$(J),Y=k$(J),X=g2(J),M=[];for(let L=0;L<X;L++){let N=v2(J,0,h2);M.push(new $0(S.from(N)))}let I=v2(J,0,h2),U=g2(J),T=[];for(let L=0;L<U;L++){let N=k$(J),k=g2(J),P=v2(J,0,k),F=g2(J),B=v2(J,0,F),_=O1.default.encode(S.from(B));T.push({programIdIndex:N,accounts:P,data:_})}let A={header:{numRequiredSignatures:Q,numReadonlySignedAccounts:G,numReadonlyUnsignedAccounts:Y},recentBlockhash:O1.default.encode(S.from(I)),accountKeys:M,instructions:T};return new b2(A)}}var Q7=S.alloc(U5).fill(0);class U0{constructor($){if(this.keys=void 0,this.programId=void 0,this.data=S.alloc(0),this.programId=$.programId,this.keys=$.keys,$.data)this.data=$.data}toJSON(){return{keys:this.keys.map(({pubkey:$,isSigner:J,isWritable:Q})=>({pubkey:$.toJSON(),isSigner:J,isWritable:Q})),programId:this.programId.toJSON(),data:[...this.data]}}}class W0{get signature(){if(this.signatures.length>0)return this.signatures[0].signature;return null}constructor($){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,!$)return;if($.feePayer)this.feePayer=$.feePayer;if($.signatures)this.signatures=$.signatures;if(Object.prototype.hasOwnProperty.call($,"nonceInfo")){let{minContextSlot:J,nonceInfo:Q}=$;this.minNonceContextSlot=J,this.nonceInfo=Q}else if(Object.prototype.hasOwnProperty.call($,"lastValidBlockHeight")){let{blockhash:J,lastValidBlockHeight:Q}=$;this.recentBlockhash=J,this.lastValidBlockHeight=Q}else{let{recentBlockhash:J,nonceInfo:Q}=$;if(Q)this.nonceInfo=Q;this.recentBlockhash=J}}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(($)=>$.toJSON()),signers:this.signatures.map(({publicKey:$})=>{return $.toJSON()})}}add(...$){if($.length===0)throw Error("No instructions");return $.forEach((J)=>{if("instructions"in J)this.instructions=this.instructions.concat(J.instructions);else if("data"in J&&"programId"in J&&"keys"in J)this.instructions.push(J);else this.instructions.push(new U0(J))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let $,J;if(this.nonceInfo)if($=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction)J=[this.nonceInfo.nonceInstruction,...this.instructions];else J=this.instructions;else $=this.recentBlockhash,J=this.instructions;if(!$)throw Error("Transaction recentBlockhash required");if(J.length<1)console.warn("No instructions provided");let Q;if(this.feePayer)Q=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)Q=this.signatures[0].publicKey;else throw Error("Transaction fee payer required");for(let P=0;P<J.length;P++)if(J[P].programId===void 0)throw Error(`Transaction instruction index ${P} has undefined program id`);let G=[],Y=[];J.forEach((P)=>{P.keys.forEach((B)=>{Y.push({...B})});let F=P.programId.toString();if(!G.includes(F))G.push(F)}),G.forEach((P)=>{Y.push({pubkey:new $0(P),isSigner:!1,isWritable:!1})});let X=[];Y.forEach((P)=>{let F=P.pubkey.toString(),B=X.findIndex((_)=>{return _.pubkey.toString()===F});if(B>-1)X[B].isWritable=X[B].isWritable||P.isWritable,X[B].isSigner=X[B].isSigner||P.isSigner;else X.push(P)}),X.sort(function(P,F){if(P.isSigner!==F.isSigner)return P.isSigner?-1:1;if(P.isWritable!==F.isWritable)return P.isWritable?-1:1;let B={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return P.pubkey.toBase58().localeCompare(F.pubkey.toBase58(),"en",B)});let M=X.findIndex((P)=>{return P.pubkey.equals(Q)});if(M>-1){let[P]=X.splice(M,1);P.isSigner=!0,P.isWritable=!0,X.unshift(P)}else X.unshift({pubkey:Q,isSigner:!0,isWritable:!0});for(let P of this.signatures){let F=X.findIndex((B)=>{return B.pubkey.equals(P.publicKey)});if(F>-1){if(!X[F].isSigner)X[F].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 Error(`unknown signer: ${P.publicKey.toString()}`)}let I=0,U=0,T=0,A=[],L=[];X.forEach(({pubkey:P,isSigner:F,isWritable:B})=>{if(F){if(A.push(P.toString()),I+=1,!B)U+=1}else if(L.push(P.toString()),!B)T+=1});let N=A.concat(L),k=J.map((P)=>{let{data:F,programId:B}=P;return{programIdIndex:N.indexOf(B.toString()),accounts:P.keys.map((_)=>N.indexOf(_.pubkey.toString())),data:O1.default.encode(F)}});return k.forEach((P)=>{s0(P.programIdIndex>=0),P.accounts.forEach((F)=>s0(F>=0))}),new b2({header:{numRequiredSignatures:I,numReadonlySignedAccounts:U,numReadonlyUnsignedAccounts:T},accountKeys:N,recentBlockhash:$,instructions:k})}_compile(){let $=this.compileMessage(),J=$.accountKeys.slice(0,$.header.numRequiredSignatures);if(this.signatures.length===J.length){if(this.signatures.every((G,Y)=>{return J[Y].equals(G.publicKey)}))return $}return this.signatures=J.map((Q)=>({signature:null,publicKey:Q})),$}serializeMessage(){return this._compile().serialize()}async getEstimatedFee($){return(await $.getFeeForMessage(this.compileMessage())).value}setSigners(...$){if($.length===0)throw Error("No signers");let J=new Set;this.signatures=$.filter((Q)=>{let G=Q.toString();if(J.has(G))return!1;else return J.add(G),!0}).map((Q)=>({signature:null,publicKey:Q}))}sign(...$){if($.length===0)throw Error("No signers");let J=new Set,Q=[];for(let Y of $){let X=Y.publicKey.toString();if(J.has(X))continue;else J.add(X),Q.push(Y)}this.signatures=Q.map((Y)=>({signature:null,publicKey:Y.publicKey}));let G=this._compile();this._partialSign(G,...Q)}partialSign(...$){if($.length===0)throw Error("No signers");let J=new Set,Q=[];for(let Y of $){let X=Y.publicKey.toString();if(J.has(X))continue;else J.add(X),Q.push(Y)}let G=this._compile();this._partialSign(G,...Q)}_partialSign($,...J){let Q=$.serialize();J.forEach((G)=>{let Y=K5(Q,G.secretKey);this._addSignature(G.publicKey,Y0(Y))})}addSignature($,J){this._compile(),this._addSignature($,J)}_addSignature($,J){s0(J.length===64);let Q=this.signatures.findIndex((G)=>$.equals(G.publicKey));if(Q<0)throw Error(`unknown signer: ${$.toString()}`);this.signatures[Q].signature=S.from(J)}verifySignatures($=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),$)}_getMessageSignednessErrors($,J){let Q={};for(let{signature:G,publicKey:Y}of this.signatures)if(G===null){if(J)(Q.missing||=[]).push(Y)}else if(!r4(G,$,Y.toBytes()))(Q.invalid||=[]).push(Y);return Q.invalid||Q.missing?Q:void 0}serialize($){let{requireAllSignatures:J,verifySignatures:Q}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},$),G=this.serializeMessage();if(Q){let Y=this._getMessageSignednessErrors(G,J);if(Y){let X="Signature verification failed.";if(Y.invalid)X+=`
|
|
6
|
+
Invalid signature for public key${Y.invalid.length===1?"":"(s)"} [\`${Y.invalid.map((M)=>M.toBase58()).join("`, `")}\`].`;if(Y.missing)X+=`
|
|
7
|
+
Missing signature for public key${Y.missing.length===1?"":"(s)"} [\`${Y.missing.map((M)=>M.toBase58()).join("`, `")}\`].`;throw Error(X)}}return this._serialize(G)}_serialize($){let{signatures:J}=this,Q=[];x2(Q,J.length);let G=Q.length+J.length*64+$.length,Y=S.alloc(G);return s0(J.length<256),S.from(Q).copy(Y,0),J.forEach(({signature:X},M)=>{if(X!==null)s0(X.length===64,"signature has invalid length"),S.from(X).copy(Y,Q.length+M*64)}),$.copy(Y,Q.length+J.length*64),s0(Y.length<=S$,`Transaction too large: ${Y.length} > ${S$}`),Y}get keys(){return s0(this.instructions.length===1),this.instructions[0].keys.map(($)=>$.pubkey)}get programId(){return s0(this.instructions.length===1),this.instructions[0].programId}get data(){return s0(this.instructions.length===1),this.instructions[0].data}static from($){let J=[...$],Q=g2(J),G=[];for(let Y=0;Y<Q;Y++){let X=v2(J,0,U5);G.push(O1.default.encode(S.from(X)))}return W0.populate(b2.from(J),G)}static populate($,J=[]){let Q=new W0;if(Q.recentBlockhash=$.recentBlockhash,$.header.numRequiredSignatures>0)Q.feePayer=$.accountKeys[0];return J.forEach((G,Y)=>{let X={signature:G==O1.default.encode(Q7)?null:O1.default.decode(G),publicKey:$.accountKeys[Y]};Q.signatures.push(X)}),$.instructions.forEach((G)=>{let Y=G.accounts.map((X)=>{let M=$.accountKeys[X];return{pubkey:M,isSigner:Q.signatures.some((I)=>I.publicKey.toString()===M.toString())||$.isAccountSigner(X),isWritable:$.isAccountWritable(X)}});Q.instructions.push(new U0({keys:Y,programId:$.accountKeys[G.programIdIndex],data:O1.default.decode(G.data)}))}),Q._message=$,Q._json=Q.toJSON(),Q}}var G7=160,Y7=64,X7=G7/Y7,Z7=1000/X7,Y8=new $0("SysvarC1ock11111111111111111111111111111111"),YD=new $0("SysvarEpochSchedu1e111111111111111111111111"),XD=new $0("Sysvar1nstructions1111111111111111111111111"),fQ=new $0("SysvarRecentB1ockHashes11111111111111111111"),m2=new $0("SysvarRent111111111111111111111111111111111"),ZD=new $0("SysvarRewards111111111111111111111111111111"),MD=new $0("SysvarS1otHashes111111111111111111111111111"),KD=new $0("SysvarS1otHistory11111111111111111111111111"),bQ=new $0("SysvarStakeHistory1111111111111111111111111");class j5 extends Error{constructor({action:$,signature:J,transactionMessage:Q,logs:G}){let Y=G?`Logs:
|
|
8
|
+
${JSON.stringify(G.slice(-10),null,2)}. `:"",X="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.",M;switch($){case"send":M=`Transaction ${J} resulted in an error.
|
|
9
|
+
${Q}. `+Y+"\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";break;case"simulate":M=`Simulation failed.
|
|
10
|
+
Message: ${Q}.
|
|
11
|
+
`+Y+"\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";break;default:M=`Unknown action '${((I)=>I)($)}'`}super(M);this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=J,this.transactionMessage=Q,this.transactionLogs=G?G:void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){let $=this.transactionLogs;if($!=null&&typeof $==="object"&&"then"in $)return;return $}async getLogs($){if(!Array.isArray(this.transactionLogs))this.transactionLogs=new Promise((J,Q)=>{$.getTransaction(this.signature).then((G)=>{if(G&&G.meta&&G.meta.logMessages){let Y=G.meta.logMessages;this.transactionLogs=Y,J(Y)}else Q(Error("Log messages not found"))}).catch(Q)});return await this.transactionLogs}}async function tX($,J,Q,G){let Y=G&&{skipPreflight:G.skipPreflight,preflightCommitment:G.preflightCommitment||G.commitment,maxRetries:G.maxRetries,minContextSlot:G.minContextSlot},X=await $.sendTransaction(J,Q,Y),M;if(J.recentBlockhash!=null&&J.lastValidBlockHeight!=null)M=(await $.confirmTransaction({abortSignal:G?.abortSignal,signature:X,blockhash:J.recentBlockhash,lastValidBlockHeight:J.lastValidBlockHeight},G&&G.commitment)).value;else if(J.minNonceContextSlot!=null&&J.nonceInfo!=null){let{nonceInstruction:I}=J.nonceInfo,U=I.keys[0].pubkey;M=(await $.confirmTransaction({abortSignal:G?.abortSignal,minContextSlot:J.minNonceContextSlot,nonceAccountPubkey:U,nonceValue:J.nonceInfo.nonce,signature:X},G&&G.commitment)).value}else{if(G?.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.");M=(await $.confirmTransaction(X,G&&G.commitment)).value}if(M.err){if(X!=null)throw new j5({action:"send",signature:X,transactionMessage:`Status: (${JSON.stringify(M)})`});throw Error(`Transaction ${X} failed (${JSON.stringify(M)})`)}return X}function M7($){return new Promise((J)=>setTimeout(J,$))}function J0($,J){let Q=$.layout.span>=0?$.layout.span:z5($,J),G=S.alloc(Q),Y=Object.assign({instruction:$.index},J);return $.layout.encode(Y,G),G}var K7=O.nu64("lamportsPerSignature"),q7=O.struct([O.u32("version"),O.u32("state"),Q0("authorizedPubkey"),Q0("nonce"),O.struct([K7],"feeCalculator")]),eX=q7.span;function Y2($){let J=M5.blob(8,$),Q=J.decode.bind(J),G=J.encode.bind(J),Y=J,X=GX();return Y.decode=(M,I)=>{let U=Q(M,I);return X.decode(U)},Y.encode=(M,I,U)=>{let T=X.encode(M);return G(T,I,U)},Y}var w1=Object.freeze({Create:{index:0,layout:O.struct([O.u32("instruction"),O.ns64("lamports"),O.ns64("space"),Q0("programId")])},Assign:{index:1,layout:O.struct([O.u32("instruction"),Q0("programId")])},Transfer:{index:2,layout:O.struct([O.u32("instruction"),Y2("lamports")])},CreateWithSeed:{index:3,layout:O.struct([O.u32("instruction"),Q0("base"),G2("seed"),O.ns64("lamports"),O.ns64("space"),Q0("programId")])},AdvanceNonceAccount:{index:4,layout:O.struct([O.u32("instruction")])},WithdrawNonceAccount:{index:5,layout:O.struct([O.u32("instruction"),O.ns64("lamports")])},InitializeNonceAccount:{index:6,layout:O.struct([O.u32("instruction"),Q0("authorized")])},AuthorizeNonceAccount:{index:7,layout:O.struct([O.u32("instruction"),Q0("authorized")])},Allocate:{index:8,layout:O.struct([O.u32("instruction"),O.ns64("space")])},AllocateWithSeed:{index:9,layout:O.struct([O.u32("instruction"),Q0("base"),G2("seed"),O.ns64("space"),Q0("programId")])},AssignWithSeed:{index:10,layout:O.struct([O.u32("instruction"),Q0("base"),G2("seed"),Q0("programId")])},TransferWithSeed:{index:11,layout:O.struct([O.u32("instruction"),Y2("lamports"),G2("seed"),Q0("programId")])},UpgradeNonceAccount:{index:12,layout:O.struct([O.u32("instruction")])}});class I1{constructor(){}static createAccount($){let J=w1.Create,Q=J0(J,{lamports:$.lamports,space:$.space,programId:Y0($.programId.toBuffer())});return new U0({keys:[{pubkey:$.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:$.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:Q})}static transfer($){let J,Q;if("basePubkey"in $){let G=w1.TransferWithSeed;J=J0(G,{lamports:BigInt($.lamports),seed:$.seed,programId:Y0($.programId.toBuffer())}),Q=[{pubkey:$.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:$.basePubkey,isSigner:!0,isWritable:!1},{pubkey:$.toPubkey,isSigner:!1,isWritable:!0}]}else{let G=w1.Transfer;J=J0(G,{lamports:BigInt($.lamports)}),Q=[{pubkey:$.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:$.toPubkey,isSigner:!1,isWritable:!0}]}return new U0({keys:Q,programId:this.programId,data:J})}static assign($){let J,Q;if("basePubkey"in $){let G=w1.AssignWithSeed;J=J0(G,{base:Y0($.basePubkey.toBuffer()),seed:$.seed,programId:Y0($.programId.toBuffer())}),Q=[{pubkey:$.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:$.basePubkey,isSigner:!0,isWritable:!1}]}else{let G=w1.Assign;J=J0(G,{programId:Y0($.programId.toBuffer())}),Q=[{pubkey:$.accountPubkey,isSigner:!0,isWritable:!0}]}return new U0({keys:Q,programId:this.programId,data:J})}static createAccountWithSeed($){let J=w1.CreateWithSeed,Q=J0(J,{base:Y0($.basePubkey.toBuffer()),seed:$.seed,lamports:$.lamports,space:$.space,programId:Y0($.programId.toBuffer())}),G=[{pubkey:$.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:$.newAccountPubkey,isSigner:!1,isWritable:!0}];if(!$.basePubkey.equals($.fromPubkey))G.push({pubkey:$.basePubkey,isSigner:!0,isWritable:!1});return new U0({keys:G,programId:this.programId,data:Q})}static createNonceAccount($){let J=new W0;if("basePubkey"in $&&"seed"in $)J.add(I1.createAccountWithSeed({fromPubkey:$.fromPubkey,newAccountPubkey:$.noncePubkey,basePubkey:$.basePubkey,seed:$.seed,lamports:$.lamports,space:eX,programId:this.programId}));else J.add(I1.createAccount({fromPubkey:$.fromPubkey,newAccountPubkey:$.noncePubkey,lamports:$.lamports,space:eX,programId:this.programId}));let Q={noncePubkey:$.noncePubkey,authorizedPubkey:$.authorizedPubkey};return J.add(this.nonceInitialize(Q)),J}static nonceInitialize($){let J=w1.InitializeNonceAccount,Q=J0(J,{authorized:Y0($.authorizedPubkey.toBuffer())}),G={keys:[{pubkey:$.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:fQ,isSigner:!1,isWritable:!1},{pubkey:m2,isSigner:!1,isWritable:!1}],programId:this.programId,data:Q};return new U0(G)}static nonceAdvance($){let J=w1.AdvanceNonceAccount,Q=J0(J),G={keys:[{pubkey:$.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:fQ,isSigner:!1,isWritable:!1},{pubkey:$.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:Q};return new U0(G)}static nonceWithdraw($){let J=w1.WithdrawNonceAccount,Q=J0(J,{lamports:$.lamports});return new U0({keys:[{pubkey:$.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:$.toPubkey,isSigner:!1,isWritable:!0},{pubkey:fQ,isSigner:!1,isWritable:!1},{pubkey:m2,isSigner:!1,isWritable:!1},{pubkey:$.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:Q})}static nonceAuthorize($){let J=w1.AuthorizeNonceAccount,Q=J0(J,{authorized:Y0($.newAuthorizedPubkey.toBuffer())});return new U0({keys:[{pubkey:$.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:$.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:Q})}static allocate($){let J,Q;if("basePubkey"in $){let G=w1.AllocateWithSeed;J=J0(G,{base:Y0($.basePubkey.toBuffer()),seed:$.seed,space:$.space,programId:Y0($.programId.toBuffer())}),Q=[{pubkey:$.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:$.basePubkey,isSigner:!0,isWritable:!1}]}else{let G=w1.Allocate;J=J0(G,{space:$.space}),Q=[{pubkey:$.accountPubkey,isSigner:!0,isWritable:!0}]}return new U0({keys:Q,programId:this.programId,data:J})}}I1.programId=new $0("11111111111111111111111111111111");var W7=S$-300;class E${constructor(){}static getMinNumSignatures($){return 2*(Math.ceil($/E$.chunkSize)+1+1)}static async load($,J,Q,G,Y){{let A=await $.getMinimumBalanceForRentExemption(Y.length),L=await $.getAccountInfo(Q.publicKey,"confirmed"),N=null;if(L!==null){if(L.executable)return console.error("Program load failed, account is already executable"),!1;if(L.data.length!==Y.length)N=N||new W0,N.add(I1.allocate({accountPubkey:Q.publicKey,space:Y.length}));if(!L.owner.equals(G))N=N||new W0,N.add(I1.assign({accountPubkey:Q.publicKey,programId:G}));if(L.lamports<A)N=N||new W0,N.add(I1.transfer({fromPubkey:J.publicKey,toPubkey:Q.publicKey,lamports:A-L.lamports}))}else N=new W0().add(I1.createAccount({fromPubkey:J.publicKey,newAccountPubkey:Q.publicKey,lamports:A>0?A:1,space:Y.length,programId:G}));if(N!==null)await tX($,N,[J,Q],{commitment:"confirmed"})}let X=O.struct([O.u32("instruction"),O.u32("offset"),O.u32("bytesLength"),O.u32("bytesLengthPadding"),O.seq(O.u8("byte"),O.offset(O.u32(),-8),"bytes")]),M=E$.chunkSize,I=0,U=Y,T=[];while(U.length>0){let A=U.slice(0,M),L=S.alloc(M+16);X.encode({instruction:0,offset:I,bytes:A,bytesLength:0,bytesLengthPadding:0},L);let N=new W0().add({keys:[{pubkey:Q.publicKey,isSigner:!0,isWritable:!0}],programId:G,data:L});if(T.push(tX($,N,[J,Q],{commitment:"confirmed"})),$._rpcEndpoint.includes("solana.com"))await M7(250);I+=M,U=U.slice(M)}await Promise.all(T);{let A=O.struct([O.u32("instruction")]),L=S.alloc(A.span);A.encode({instruction:1},L);let N=new W0().add({keys:[{pubkey:Q.publicKey,isSigner:!0,isWritable:!0},{pubkey:m2,isSigner:!1,isWritable:!1}],programId:G,data:L}),k="processed",P=await $.sendTransaction(N,[J,Q],{preflightCommitment:k}),{context:F,value:B}=await $.confirmTransaction({signature:P,lastValidBlockHeight:N.lastValidBlockHeight,blockhash:N.recentBlockhash},k);if(B.err)throw Error(`Transaction ${P} failed (${JSON.stringify(B)})`);while(!0){try{if(await $.getSlot({commitment:k})>F.slot)break}catch{}await new Promise((_)=>setTimeout(_,Math.round(Z7/2)))}}return!0}}E$.chunkSize=W7;var qD=new $0("BPFLoader2111111111111111111111111111111111");var WD=globalThis.fetch;var UD={index:1,layout:O.struct([O.u32("typeIndex"),Y2("deactivationSlot"),O.nu64("lastExtendedSlot"),O.u8("lastExtendedStartIndex"),O.u8(),O.seq(Q0(),O.offset(O.u8(),-1),"authority")])};var H0=$2(H$($0),y(),($)=>new $0($)),C5=j$([y(),V0("base64")]),iQ=$2(H$(S),C5,($)=>S.from($[0],"base64"));function A5($){return Z1([g({jsonrpc:V0("2.0"),id:y(),result:$}),g({jsonrpc:V0("2.0"),id:y(),error:g({code:y8(),message:y(),data:i(KX())})})])}var U7=A5(y8());function I0($){return $2(A5($),U7,(J)=>{if("error"in J)return J;else return{...J,result:e8(J.result,$)}})}function v1($){return I0(g({context:g({slot:E()}),value:$}))}function w$($){return g({context:g({slot:E()}),value:$})}var I7=g({foundation:E(),foundationTerm:E(),initial:E(),taper:E(),terminal:E()}),ID=I0(p(u(g({epoch:E(),effectiveSlot:E(),amount:E(),postBalance:E(),commission:i(u(E()))})))),D7=p(g({slot:E(),prioritizationFee:E()})),V7=g({total:E(),validator:E(),foundation:E(),epoch:E()}),z7=g({epoch:E(),slotIndex:E(),slotsInEpoch:E(),absoluteSlot:E(),blockHeight:i(E()),transactionCount:i(E())}),H7=g({slotsPerEpoch:E(),leaderScheduleSlotOffset:E(),warmup:x1(),firstNormalEpoch:E(),firstNormalSlot:E()}),j7=AQ(y(),p(E())),f8=u(Z1([g({}),y()])),C7=g({err:f8}),A7=V0("receivedSignature"),DD=g({"solana-core":y(),"feature-set":i(E())}),T7=g({program:y(),programId:H0,parsed:y8()}),R7=g({programId:H0,accounts:p(H0),data:y()}),VD=v1(g({err:u(Z1([g({}),y()])),logs:u(p(y())),accounts:i(u(p(u(g({executable:x1(),owner:y(),lamports:E(),data:p(y()),rentEpoch:i(E())}))))),unitsConsumed:i(E()),returnData:i(u(g({programId:y(),data:j$([y(),V0("base64")])}))),innerInstructions:i(u(p(g({index:E(),instructions:p(Z1([T7,R7]))}))))})),zD=v1(g({byIdentity:AQ(y(),p(E())),range:g({firstSlot:E(),lastSlot:E()})}));var HD=I0(I7),jD=I0(V7),CD=I0(D7),AD=I0(z7),TD=I0(H7),RD=I0(j7),OD=I0(E()),ND=v1(g({total:E(),circulating:E(),nonCirculating:E(),nonCirculatingAccounts:p(H0)})),O7=g({amount:y(),uiAmount:u(E()),decimals:E(),uiAmountString:i(y())}),kD=v1(p(g({address:H0,amount:y(),uiAmount:u(E()),decimals:E(),uiAmountString:i(y())}))),PD=v1(p(g({pubkey:H0,account:g({executable:x1(),owner:H0,lamports:E(),data:iQ,rentEpoch:E()})}))),dQ=g({program:y(),parsed:y8(),space:E()}),LD=v1(p(g({pubkey:H0,account:g({executable:x1(),owner:H0,lamports:E(),data:dQ,rentEpoch:E()})}))),SD=v1(p(g({lamports:E(),address:H0}))),rQ=g({executable:x1(),owner:H0,lamports:E(),data:iQ,rentEpoch:E()}),ED=g({pubkey:H0,account:rQ}),N7=$2(Z1([H$(S),dQ]),Z1([C5,dQ]),($)=>{if(Array.isArray($))return e8($,iQ);else return $}),k7=g({executable:x1(),owner:H0,lamports:E(),data:N7,rentEpoch:E()}),BD=g({pubkey:H0,account:k7}),wD=g({state:Z1([V0("active"),V0("inactive"),V0("activating"),V0("deactivating")]),active:E(),inactive:E()}),FD=I0(p(g({signature:y(),slot:E(),err:f8,memo:u(y()),blockTime:i(u(E()))}))),_D=I0(p(g({signature:y(),slot:E(),err:f8,memo:u(y()),blockTime:i(u(E()))}))),gD=g({subscription:E(),result:w$(rQ)}),P7=g({pubkey:H0,account:rQ}),xD=g({subscription:E(),result:w$(P7)}),L7=g({parent:E(),slot:E(),root:E()}),vD=g({subscription:E(),result:L7}),S7=Z1([g({type:Z1([V0("firstShredReceived"),V0("completed"),V0("optimisticConfirmation"),V0("root")]),slot:E(),timestamp:E()}),g({type:V0("createdBank"),parent:E(),slot:E(),timestamp:E()}),g({type:V0("frozen"),slot:E(),timestamp:E(),stats:g({numTransactionEntries:E(),numSuccessfulTransactions:E(),numFailedTransactions:E(),maxTransactionsPerEntry:E()})}),g({type:V0("dead"),slot:E(),timestamp:E(),err:y()})]),hD=g({subscription:E(),result:S7}),yD=g({subscription:E(),result:w$(Z1([C7,A7]))}),fD=g({subscription:E(),result:E()}),bD=g({pubkey:y(),gossip:u(y()),tpu:u(y()),rpc:u(y()),version:u(y())}),$5=g({votePubkey:y(),nodePubkey:y(),activatedStake:E(),epochVoteAccount:x1(),epochCredits:p(j$([E(),E(),E()])),commission:E(),lastVote:E(),rootSlot:u(E())}),mD=I0(g({current:p($5),delinquent:p($5)})),E7=Z1([V0("processed"),V0("confirmed"),V0("finalized")]),B7=g({slot:E(),confirmations:u(E()),err:f8,confirmationStatus:i(E7)}),pD=v1(p(u(B7))),uD=I0(E()),T5=g({accountKey:H0,writableIndexes:p(E()),readonlyIndexes:p(E())}),oQ=g({signatures:p(y()),message:g({accountKeys:p(y()),header:g({numRequiredSignatures:E(),numReadonlySignedAccounts:E(),numReadonlyUnsignedAccounts:E()}),instructions:p(g({accounts:p(E()),data:y(),programIdIndex:E()})),recentBlockhash:y(),addressTableLookups:i(p(T5))})}),R5=g({pubkey:H0,signer:x1(),writable:x1(),source:i(Z1([V0("transaction"),V0("lookupTable")]))}),O5=g({accountKeys:p(R5),signatures:p(y())}),N5=g({parsed:y8(),program:y(),programId:H0}),k5=g({accounts:p(H0),data:y(),programId:H0}),w7=Z1([k5,N5]),F7=Z1([g({parsed:y8(),program:y(),programId:y()}),g({accounts:p(y()),data:y(),programId:y()})]),P5=$2(w7,F7,($)=>{if("accounts"in $)return e8($,k5);else return e8($,N5)}),L5=g({signatures:p(y()),message:g({accountKeys:p(R5),instructions:p(P5),recentBlockhash:y(),addressTableLookups:i(u(p(T5)))})}),B$=g({accountIndex:E(),mint:y(),owner:i(y()),programId:i(y()),uiTokenAmount:O7}),S5=g({writable:p(H0),readonly:p(H0)}),F$=g({err:f8,fee:E(),innerInstructions:i(u(p(g({index:E(),instructions:p(g({accounts:p(E()),data:y(),programIdIndex:E()}))})))),preBalances:p(E()),postBalances:p(E()),logMessages:i(u(p(y()))),preTokenBalances:i(u(p(B$))),postTokenBalances:i(u(p(B$))),loadedAddresses:i(S5),computeUnitsConsumed:i(E()),costUnits:i(E())}),aQ=g({err:f8,fee:E(),innerInstructions:i(u(p(g({index:E(),instructions:p(P5)})))),preBalances:p(E()),postBalances:p(E()),logMessages:i(u(p(y()))),preTokenBalances:i(u(p(B$))),postTokenBalances:i(u(p(B$))),loadedAddresses:i(S5),computeUnitsConsumed:i(E()),costUnits:i(E())}),Z2=Z1([V0(0),V0("legacy")]),b8=g({pubkey:y(),lamports:E(),postBalance:u(E()),rewardType:u(y()),commission:i(u(E()))}),cD=I0(u(g({blockhash:y(),previousBlockhash:y(),parentSlot:E(),transactions:p(g({transaction:oQ,meta:u(F$),version:i(Z2)})),rewards:i(p(b8)),blockTime:u(E()),blockHeight:u(E())}))),lD=I0(u(g({blockhash:y(),previousBlockhash:y(),parentSlot:E(),rewards:i(p(b8)),blockTime:u(E()),blockHeight:u(E())}))),dD=I0(u(g({blockhash:y(),previousBlockhash:y(),parentSlot:E(),transactions:p(g({transaction:O5,meta:u(F$),version:i(Z2)})),rewards:i(p(b8)),blockTime:u(E()),blockHeight:u(E())}))),nD=I0(u(g({blockhash:y(),previousBlockhash:y(),parentSlot:E(),transactions:p(g({transaction:L5,meta:u(aQ),version:i(Z2)})),rewards:i(p(b8)),blockTime:u(E()),blockHeight:u(E())}))),iD=I0(u(g({blockhash:y(),previousBlockhash:y(),parentSlot:E(),transactions:p(g({transaction:O5,meta:u(aQ),version:i(Z2)})),rewards:i(p(b8)),blockTime:u(E()),blockHeight:u(E())}))),rD=I0(u(g({blockhash:y(),previousBlockhash:y(),parentSlot:E(),rewards:i(p(b8)),blockTime:u(E()),blockHeight:u(E())}))),oD=I0(u(g({blockhash:y(),previousBlockhash:y(),parentSlot:E(),transactions:p(g({transaction:oQ,meta:u(F$)})),rewards:i(p(b8)),blockTime:u(E())}))),aD=I0(u(g({blockhash:y(),previousBlockhash:y(),parentSlot:E(),signatures:p(y()),blockTime:u(E())}))),sD=I0(u(g({slot:E(),meta:u(F$),blockTime:i(u(E())),transaction:oQ,version:i(Z2)}))),tD=I0(u(g({slot:E(),transaction:L5,meta:u(aQ),blockTime:i(u(E())),version:i(Z2)}))),eD=v1(g({blockhash:y(),lastValidBlockHeight:E()})),$V=v1(x1()),_7=g({slot:E(),numTransactions:E(),numSlots:E(),samplePeriodSecs:E()}),JV=I0(p(_7)),QV=v1(u(g({feeCalculator:g({lamportsPerSignature:E()})}))),GV=I0(y()),YV=I0(y()),g7=g({err:f8,logs:p(y()),signature:y()}),XV=g({result:w$(g7),subscription:E()});class y2{constructor($){this._keypair=void 0,this._keypair=$??oX()}static generate(){return new y2(oX())}static fromSecretKey($,J){if($.byteLength!==64)throw Error("bad secret key size");let Q=$.slice(32,64);if(!J||!J.skipValidation){let G=$.slice(0,32),Y=cQ(G);for(let X=0;X<32;X++)if(Q[X]!==Y[X])throw Error("provided secretKey is invalid")}return new y2({publicKey:Q,secretKey:$})}static fromSeed($){let J=cQ($),Q=new Uint8Array(64);return Q.set($),Q.set(J,32),new y2({publicKey:J,secretKey:Q})}get publicKey(){return new $0(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}var F2=Object.freeze({CreateLookupTable:{index:0,layout:O.struct([O.u32("instruction"),Y2("recentSlot"),O.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:O.struct([O.u32("instruction")])},ExtendLookupTable:{index:2,layout:O.struct([O.u32("instruction"),Y2(),O.seq(Q0(),O.offset(O.u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:O.struct([O.u32("instruction")])},CloseLookupTable:{index:4,layout:O.struct([O.u32("instruction")])}});class E5{constructor(){}static createLookupTable($){let[J,Q]=$0.findProgramAddressSync([$.authority.toBuffer(),jQ().encode($.recentSlot)],this.programId),G=F2.CreateLookupTable,Y=J0(G,{recentSlot:BigInt($.recentSlot),bumpSeed:Q}),X=[{pubkey:J,isSigner:!1,isWritable:!0},{pubkey:$.authority,isSigner:!0,isWritable:!1},{pubkey:$.payer,isSigner:!0,isWritable:!0},{pubkey:I1.programId,isSigner:!1,isWritable:!1}];return[new U0({programId:this.programId,keys:X,data:Y}),J]}static freezeLookupTable($){let J=F2.FreezeLookupTable,Q=J0(J),G=[{pubkey:$.lookupTable,isSigner:!1,isWritable:!0},{pubkey:$.authority,isSigner:!0,isWritable:!1}];return new U0({programId:this.programId,keys:G,data:Q})}static extendLookupTable($){let J=F2.ExtendLookupTable,Q=J0(J,{addresses:$.addresses.map((Y)=>Y.toBytes())}),G=[{pubkey:$.lookupTable,isSigner:!1,isWritable:!0},{pubkey:$.authority,isSigner:!0,isWritable:!1}];if($.payer)G.push({pubkey:$.payer,isSigner:!0,isWritable:!0},{pubkey:I1.programId,isSigner:!1,isWritable:!1});return new U0({programId:this.programId,keys:G,data:Q})}static deactivateLookupTable($){let J=F2.DeactivateLookupTable,Q=J0(J),G=[{pubkey:$.lookupTable,isSigner:!1,isWritable:!0},{pubkey:$.authority,isSigner:!0,isWritable:!1}];return new U0({programId:this.programId,keys:G,data:Q})}static closeLookupTable($){let J=F2.CloseLookupTable,Q=J0(J),G=[{pubkey:$.lookupTable,isSigner:!1,isWritable:!0},{pubkey:$.authority,isSigner:!0,isWritable:!1},{pubkey:$.recipient,isSigner:!1,isWritable:!0}];return new U0({programId:this.programId,keys:G,data:Q})}}E5.programId=new $0("AddressLookupTab1e1111111111111111111111111");var P$=Object.freeze({RequestUnits:{index:0,layout:O.struct([O.u8("instruction"),O.u32("units"),O.u32("additionalFee")])},RequestHeapFrame:{index:1,layout:O.struct([O.u8("instruction"),O.u32("bytes")])},SetComputeUnitLimit:{index:2,layout:O.struct([O.u8("instruction"),O.u32("units")])},SetComputeUnitPrice:{index:3,layout:O.struct([O.u8("instruction"),Y2("microLamports")])}});class B5{constructor(){}static requestUnits($){let J=P$.RequestUnits,Q=J0(J,$);return new U0({keys:[],programId:this.programId,data:Q})}static requestHeapFrame($){let J=P$.RequestHeapFrame,Q=J0(J,$);return new U0({keys:[],programId:this.programId,data:Q})}static setComputeUnitLimit($){let J=P$.SetComputeUnitLimit,Q=J0(J,$);return new U0({keys:[],programId:this.programId,data:Q})}static setComputeUnitPrice($){let J=P$.SetComputeUnitPrice,Q=J0(J,{microLamports:BigInt($.microLamports)});return new U0({keys:[],programId:this.programId,data:Q})}}B5.programId=new $0("ComputeBudget111111111111111111111111111111");var J5=64,Q5=32,G5=64,Y5=O.struct([O.u8("numSignatures"),O.u8("padding"),O.u16("signatureOffset"),O.u16("signatureInstructionIndex"),O.u16("publicKeyOffset"),O.u16("publicKeyInstructionIndex"),O.u16("messageDataOffset"),O.u16("messageDataSize"),O.u16("messageInstructionIndex")]);class sQ{constructor(){}static createInstructionWithPublicKey($){let{publicKey:J,message:Q,signature:G,instructionIndex:Y}=$;s0(J.length===Q5,`Public Key must be ${Q5} bytes but received ${J.length} bytes`),s0(G.length===G5,`Signature must be ${G5} bytes but received ${G.length} bytes`);let X=Y5.span,M=X+J.length,I=M+G.length,U=1,T=S.alloc(I+Q.length),A=Y==null?65535:Y;return Y5.encode({numSignatures:U,padding:0,signatureOffset:M,signatureInstructionIndex:A,publicKeyOffset:X,publicKeyInstructionIndex:A,messageDataOffset:I,messageDataSize:Q.length,messageInstructionIndex:A},T),T.fill(J,X),T.fill(G,M),T.fill(Q,I),new U0({keys:[],programId:sQ.programId,data:T})}static createInstructionWithPrivateKey($){let{privateKey:J,message:Q,instructionIndex:G}=$;s0(J.length===J5,`Private key must be ${J5} bytes but received ${J.length} bytes`);try{let Y=y2.fromSecretKey(J),X=Y.publicKey.toBytes(),M=K5(Q,Y.secretKey);return this.createInstructionWithPublicKey({publicKey:X,message:Q,signature:M,instructionIndex:G})}catch(Y){throw Error(`Error creating instruction; ${Y}`)}}}sQ.programId=new $0("Ed25519SigVerify111111111111111111111111111");var x7=($,J)=>{let Q=N$.sign($,J);return[Q.toCompactRawBytes(),Q.recovery]};N$.utils.isValidPrivateKey;var v7=N$.getPublicKey,X5=32,mQ=20,Z5=64,h7=11,pQ=O.struct([O.u8("numSignatures"),O.u16("signatureOffset"),O.u8("signatureInstructionIndex"),O.u16("ethAddressOffset"),O.u8("ethAddressInstructionIndex"),O.u16("messageDataOffset"),O.u16("messageDataSize"),O.u8("messageInstructionIndex"),O.blob(20,"ethAddress"),O.blob(64,"signature"),O.u8("recoveryId")]);class f2{constructor(){}static publicKeyToEthAddress($){s0($.length===Z5,`Public key must be ${Z5} bytes but received ${$.length} bytes`);try{return S.from(FQ(Y0($))).slice(-mQ)}catch(J){throw Error(`Error constructing Ethereum address: ${J}`)}}static createInstructionWithPublicKey($){let{publicKey:J,message:Q,signature:G,recoveryId:Y,instructionIndex:X}=$;return f2.createInstructionWithEthAddress({ethAddress:f2.publicKeyToEthAddress(J),message:Q,signature:G,recoveryId:Y,instructionIndex:X})}static createInstructionWithEthAddress($){let{ethAddress:J,message:Q,signature:G,recoveryId:Y,instructionIndex:X=0}=$,M;if(typeof J==="string")if(J.startsWith("0x"))M=S.from(J.substr(2),"hex");else M=S.from(J,"hex");else M=J;s0(M.length===mQ,`Address must be ${mQ} bytes but received ${M.length} bytes`);let I=1+h7,U=I,T=I+M.length,A=T+G.length+1,L=1,N=S.alloc(pQ.span+Q.length);return pQ.encode({numSignatures:L,signatureOffset:T,signatureInstructionIndex:X,ethAddressOffset:U,ethAddressInstructionIndex:X,messageDataOffset:A,messageDataSize:Q.length,messageInstructionIndex:X,signature:Y0(G),ethAddress:Y0(M),recoveryId:Y},N),N.fill(Y0(Q),pQ.span),new U0({keys:[],programId:f2.programId,data:N})}static createInstructionWithPrivateKey($){let{privateKey:J,message:Q,instructionIndex:G}=$;s0(J.length===X5,`Private key must be ${X5} bytes but received ${J.length} bytes`);try{let Y=Y0(J),X=v7(Y,!1).slice(1),M=S.from(FQ(Y0(Q))),[I,U]=x7(M,Y);return this.createInstructionWithPublicKey({publicKey:X,message:Q,signature:I,recoveryId:U,instructionIndex:G})}catch(Y){throw Error(`Error creating instruction; ${Y}`)}}}f2.programId=new $0("KeccakSecp256k11111111111111111111111111111");var w5,y7=new $0("StakeConfig11111111111111111111111111111111");class _${constructor($,J,Q){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=$,this.epoch=J,this.custodian=Q}}w5=_$;_$.default=new w5(0,0,$0.default);var T8=Object.freeze({Initialize:{index:0,layout:O.struct([O.u32("instruction"),t4(),e4()])},Authorize:{index:1,layout:O.struct([O.u32("instruction"),Q0("newAuthorized"),O.u32("stakeAuthorizationType")])},Delegate:{index:2,layout:O.struct([O.u32("instruction")])},Split:{index:3,layout:O.struct([O.u32("instruction"),O.ns64("lamports")])},Withdraw:{index:4,layout:O.struct([O.u32("instruction"),O.ns64("lamports")])},Deactivate:{index:5,layout:O.struct([O.u32("instruction")])},Merge:{index:7,layout:O.struct([O.u32("instruction")])},AuthorizeWithSeed:{index:8,layout:O.struct([O.u32("instruction"),Q0("newAuthorized"),O.u32("stakeAuthorizationType"),G2("authoritySeed"),Q0("authorityOwner")])}}),ZV=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class tQ{constructor(){}static initialize($){let{stakePubkey:J,authorized:Q,lockup:G}=$,Y=G||_$.default,X=T8.Initialize,M=J0(X,{authorized:{staker:Y0(Q.staker.toBuffer()),withdrawer:Y0(Q.withdrawer.toBuffer())},lockup:{unixTimestamp:Y.unixTimestamp,epoch:Y.epoch,custodian:Y0(Y.custodian.toBuffer())}}),I={keys:[{pubkey:J,isSigner:!1,isWritable:!0},{pubkey:m2,isSigner:!1,isWritable:!1}],programId:this.programId,data:M};return new U0(I)}static createAccountWithSeed($){let J=new W0;J.add(I1.createAccountWithSeed({fromPubkey:$.fromPubkey,newAccountPubkey:$.stakePubkey,basePubkey:$.basePubkey,seed:$.seed,lamports:$.lamports,space:this.space,programId:this.programId}));let{stakePubkey:Q,authorized:G,lockup:Y}=$;return J.add(this.initialize({stakePubkey:Q,authorized:G,lockup:Y}))}static createAccount($){let J=new W0;J.add(I1.createAccount({fromPubkey:$.fromPubkey,newAccountPubkey:$.stakePubkey,lamports:$.lamports,space:this.space,programId:this.programId}));let{stakePubkey:Q,authorized:G,lockup:Y}=$;return J.add(this.initialize({stakePubkey:Q,authorized:G,lockup:Y}))}static delegate($){let{stakePubkey:J,authorizedPubkey:Q,votePubkey:G}=$,Y=T8.Delegate,X=J0(Y);return new W0().add({keys:[{pubkey:J,isSigner:!1,isWritable:!0},{pubkey:G,isSigner:!1,isWritable:!1},{pubkey:Y8,isSigner:!1,isWritable:!1},{pubkey:bQ,isSigner:!1,isWritable:!1},{pubkey:y7,isSigner:!1,isWritable:!1},{pubkey:Q,isSigner:!0,isWritable:!1}],programId:this.programId,data:X})}static authorize($){let{stakePubkey:J,authorizedPubkey:Q,newAuthorizedPubkey:G,stakeAuthorizationType:Y,custodianPubkey:X}=$,M=T8.Authorize,I=J0(M,{newAuthorized:Y0(G.toBuffer()),stakeAuthorizationType:Y.index}),U=[{pubkey:J,isSigner:!1,isWritable:!0},{pubkey:Y8,isSigner:!1,isWritable:!0},{pubkey:Q,isSigner:!0,isWritable:!1}];if(X)U.push({pubkey:X,isSigner:!0,isWritable:!1});return new W0().add({keys:U,programId:this.programId,data:I})}static authorizeWithSeed($){let{stakePubkey:J,authorityBase:Q,authoritySeed:G,authorityOwner:Y,newAuthorizedPubkey:X,stakeAuthorizationType:M,custodianPubkey:I}=$,U=T8.AuthorizeWithSeed,T=J0(U,{newAuthorized:Y0(X.toBuffer()),stakeAuthorizationType:M.index,authoritySeed:G,authorityOwner:Y0(Y.toBuffer())}),A=[{pubkey:J,isSigner:!1,isWritable:!0},{pubkey:Q,isSigner:!0,isWritable:!1},{pubkey:Y8,isSigner:!1,isWritable:!1}];if(I)A.push({pubkey:I,isSigner:!0,isWritable:!1});return new W0().add({keys:A,programId:this.programId,data:T})}static splitInstruction($){let{stakePubkey:J,authorizedPubkey:Q,splitStakePubkey:G,lamports:Y}=$,X=T8.Split,M=J0(X,{lamports:Y});return new U0({keys:[{pubkey:J,isSigner:!1,isWritable:!0},{pubkey:G,isSigner:!1,isWritable:!0},{pubkey:Q,isSigner:!0,isWritable:!1}],programId:this.programId,data:M})}static split($,J){let Q=new W0;return Q.add(I1.createAccount({fromPubkey:$.authorizedPubkey,newAccountPubkey:$.splitStakePubkey,lamports:J,space:this.space,programId:this.programId})),Q.add(this.splitInstruction($))}static splitWithSeed($,J){let{stakePubkey:Q,authorizedPubkey:G,splitStakePubkey:Y,basePubkey:X,seed:M,lamports:I}=$,U=new W0;if(U.add(I1.allocate({accountPubkey:Y,basePubkey:X,seed:M,space:this.space,programId:this.programId})),J&&J>0)U.add(I1.transfer({fromPubkey:$.authorizedPubkey,toPubkey:Y,lamports:J}));return U.add(this.splitInstruction({stakePubkey:Q,authorizedPubkey:G,splitStakePubkey:Y,lamports:I}))}static merge($){let{stakePubkey:J,sourceStakePubKey:Q,authorizedPubkey:G}=$,Y=T8.Merge,X=J0(Y);return new W0().add({keys:[{pubkey:J,isSigner:!1,isWritable:!0},{pubkey:Q,isSigner:!1,isWritable:!0},{pubkey:Y8,isSigner:!1,isWritable:!1},{pubkey:bQ,isSigner:!1,isWritable:!1},{pubkey:G,isSigner:!0,isWritable:!1}],programId:this.programId,data:X})}static withdraw($){let{stakePubkey:J,authorizedPubkey:Q,toPubkey:G,lamports:Y,custodianPubkey:X}=$,M=T8.Withdraw,I=J0(M,{lamports:Y}),U=[{pubkey:J,isSigner:!1,isWritable:!0},{pubkey:G,isSigner:!1,isWritable:!0},{pubkey:Y8,isSigner:!1,isWritable:!1},{pubkey:bQ,isSigner:!1,isWritable:!1},{pubkey:Q,isSigner:!0,isWritable:!1}];if(X)U.push({pubkey:X,isSigner:!0,isWritable:!1});return new W0().add({keys:U,programId:this.programId,data:I})}static deactivate($){let{stakePubkey:J,authorizedPubkey:Q}=$,G=T8.Deactivate,Y=J0(G);return new W0().add({keys:[{pubkey:J,isSigner:!1,isWritable:!0},{pubkey:Y8,isSigner:!1,isWritable:!1},{pubkey:Q,isSigner:!0,isWritable:!1}],programId:this.programId,data:Y})}}tQ.programId=new $0("Stake11111111111111111111111111111111111111");tQ.space=200;var _2=Object.freeze({InitializeAccount:{index:0,layout:O.struct([O.u32("instruction"),$7()])},Authorize:{index:1,layout:O.struct([O.u32("instruction"),Q0("newAuthorized"),O.u32("voteAuthorizationType")])},Withdraw:{index:3,layout:O.struct([O.u32("instruction"),O.ns64("lamports")])},UpdateValidatorIdentity:{index:4,layout:O.struct([O.u32("instruction")])},AuthorizeWithSeed:{index:10,layout:O.struct([O.u32("instruction"),J7()])}}),MV=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class g${constructor(){}static initializeAccount($){let{votePubkey:J,nodePubkey:Q,voteInit:G}=$,Y=_2.InitializeAccount,X=J0(Y,{voteInit:{nodePubkey:Y0(G.nodePubkey.toBuffer()),authorizedVoter:Y0(G.authorizedVoter.toBuffer()),authorizedWithdrawer:Y0(G.authorizedWithdrawer.toBuffer()),commission:G.commission}}),M={keys:[{pubkey:J,isSigner:!1,isWritable:!0},{pubkey:m2,isSigner:!1,isWritable:!1},{pubkey:Y8,isSigner:!1,isWritable:!1},{pubkey:Q,isSigner:!0,isWritable:!1}],programId:this.programId,data:X};return new U0(M)}static createAccount($){let J=new W0;return J.add(I1.createAccount({fromPubkey:$.fromPubkey,newAccountPubkey:$.votePubkey,lamports:$.lamports,space:this.space,programId:this.programId})),J.add(this.initializeAccount({votePubkey:$.votePubkey,nodePubkey:$.voteInit.nodePubkey,voteInit:$.voteInit}))}static authorize($){let{votePubkey:J,authorizedPubkey:Q,newAuthorizedPubkey:G,voteAuthorizationType:Y}=$,X=_2.Authorize,M=J0(X,{newAuthorized:Y0(G.toBuffer()),voteAuthorizationType:Y.index}),I=[{pubkey:J,isSigner:!1,isWritable:!0},{pubkey:Y8,isSigner:!1,isWritable:!1},{pubkey:Q,isSigner:!0,isWritable:!1}];return new W0().add({keys:I,programId:this.programId,data:M})}static authorizeWithSeed($){let{currentAuthorityDerivedKeyBasePubkey:J,currentAuthorityDerivedKeyOwnerPubkey:Q,currentAuthorityDerivedKeySeed:G,newAuthorizedPubkey:Y,voteAuthorizationType:X,votePubkey:M}=$,I=_2.AuthorizeWithSeed,U=J0(I,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:Y0(Q.toBuffer()),currentAuthorityDerivedKeySeed:G,newAuthorized:Y0(Y.toBuffer()),voteAuthorizationType:X.index}}),T=[{pubkey:M,isSigner:!1,isWritable:!0},{pubkey:Y8,isSigner:!1,isWritable:!1},{pubkey:J,isSigner:!0,isWritable:!1}];return new W0().add({keys:T,programId:this.programId,data:U})}static withdraw($){let{votePubkey:J,authorizedWithdrawerPubkey:Q,lamports:G,toPubkey:Y}=$,X=_2.Withdraw,M=J0(X,{lamports:G}),I=[{pubkey:J,isSigner:!1,isWritable:!0},{pubkey:Y,isSigner:!1,isWritable:!0},{pubkey:Q,isSigner:!0,isWritable:!1}];return new W0().add({keys:I,programId:this.programId,data:M})}static safeWithdraw($,J,Q){if($.lamports>J-Q)throw Error("Withdraw will leave vote account with insufficient funds.");return g$.withdraw($)}static updateValidatorIdentity($){let{votePubkey:J,authorizedWithdrawerPubkey:Q,nodePubkey:G}=$,Y=_2.UpdateValidatorIdentity,X=J0(Y),M=[{pubkey:J,isSigner:!1,isWritable:!0},{pubkey:G,isSigner:!0,isWritable:!1},{pubkey:Q,isSigner:!0,isWritable:!1}];return new W0().add({keys:M,programId:this.programId,data:X})}}g$.programId=new $0("Vote111111111111111111111111111111111111111");g$.space=3762;var KV=new $0("Va1idator1nfo111111111111111111111111111111"),qV=g({name:y(),website:i(y()),details:i(y()),iconUrl:i(y()),keybaseUsername:i(y())});var WV=new $0("Vote111111111111111111111111111111111111111"),UV=O.struct([Q0("nodePubkey"),Q0("authorizedWithdrawer"),O.u8("commission"),O.nu64(),O.seq(O.struct([O.nu64("slot"),O.u32("confirmationCount")]),O.offset(O.u32(),-8),"votes"),O.u8("rootSlotValid"),O.nu64("rootSlot"),O.nu64(),O.seq(O.struct([O.nu64("epoch"),Q0("authorizedVoter")]),O.offset(O.u32(),-8),"authorizedVoters"),O.struct([O.seq(O.struct([Q0("authorizedPubkey"),O.nu64("epochOfLastAuthorizedSwitch"),O.nu64("targetEpoch")]),32,"buf"),O.nu64("idx"),O.u8("isEmpty")],"priorVoters"),O.nu64(),O.seq(O.struct([O.nu64("epoch"),O.nu64("credits"),O.nu64("prevCredits")]),O.offset(O.u32(),-8),"epochCredits"),O.struct([O.nu64("slot"),O.nu64("timestamp")],"lastTimestamp")]);class x${siteId;baseUrl;sessionId;pageStart;currentPath;tokenKey;userTokenKey;anonIdKey;autoTrackingActive=!1;originalPushState=null;popstateHandler=null;visibilityHandler=null;constructor($){if(this.siteId=$.siteId,this.baseUrl=$._baseUrl??"https://api.tribe.utopian.build",this.sessionId=Math.random().toString(36).slice(2),this.pageStart=Date.now(),this.currentPath=location.pathname,this.tokenKey=`__tribe_${$.siteId}`,this.userTokenKey=`__tribe_ut_${$.siteId}`,this.anonIdKey=`__tribe_anon_${$.siteId}`,this.handleAuthCallback(),$.autoTrack!==!1)this.startAutoTracking()}static init($){return new x$($)}startAutoTracking(){if(this.autoTrackingActive)return;this.autoTrackingActive=!0,this.sendEvent("pageview"),this.visibilityHandler=()=>{if(document.visibilityState==="hidden")this.sendEvent("leave",{d:Date.now()-this.pageStart})},document.addEventListener("visibilitychange",this.visibilityHandler),this.originalPushState=history.pushState,history.pushState=(...$)=>{this.sendEvent("leave",{d:Date.now()-this.pageStart}),this.originalPushState.apply(history,$),this.pageStart=Date.now(),this.currentPath=location.pathname,this.sendEvent("pageview")},this.popstateHandler=()=>{this.sendEvent("leave",{d:Date.now()-this.pageStart}),this.pageStart=Date.now(),this.currentPath=location.pathname,this.sendEvent("pageview")},window.addEventListener("popstate",this.popstateHandler)}stopAutoTracking(){if(!this.autoTrackingActive)return;if(this.autoTrackingActive=!1,this.visibilityHandler)document.removeEventListener("visibilitychange",this.visibilityHandler),this.visibilityHandler=null;if(this.originalPushState)history.pushState=this.originalPushState,this.originalPushState=null;if(this.popstateHandler)window.removeEventListener("popstate",this.popstateHandler),this.popstateHandler=null}handleAuthCallback(){let $=new URLSearchParams(window.location.search),J=$.get("tribe_token");if(J){localStorage.setItem(this.tokenKey,J),$.delete("tribe_token");let Q=$.toString()?`${window.location.pathname}?${$}${window.location.hash}`:`${window.location.pathname}${window.location.hash}`;window.history.replaceState({},"",Q)}}redirectToLogin($){let J=$?.redirectUrl??window.location.href,Q=new URL(`${this.baseUrl}/auth/login`);Q.searchParams.set("site",this.siteId),Q.searchParams.set("redirect",J),window.location.href=Q.toString()}redirectToRegister($){let J=$?.redirectUrl??window.location.href,Q=new URL(`${this.baseUrl}/auth/register`);Q.searchParams.set("site",this.siteId),Q.searchParams.set("redirect",J),window.location.href=Q.toString()}redirectToSocialLogin($,J){let Q=J?.redirectUrl??window.location.href,G=new URL(`${this.baseUrl}/auth/oauth/${$}`);G.searchParams.set("site",this.siteId),G.searchParams.set("redirect",Q),window.location.href=G.toString()}sendEvent($,J={}){let Q={s:this.siteId,t:$,p:this.currentPath,r:document.referrer||null,sid:this.sessionId,w:screen.width,...J};if(navigator.sendBeacon){let G=new Blob([JSON.stringify(Q)],{type:"application/json"});navigator.sendBeacon(`${this.baseUrl}/collect`,G)}else fetch(`${this.baseUrl}/collect`,{method:"POST",body:JSON.stringify(Q),keepalive:!0,headers:{"Content-Type":"application/json"}}).catch(()=>{})}async gql($,J){let Q=localStorage.getItem(this.tokenKey),G={"Content-Type":"application/json"};if(Q)G.Authorization=`Bearer ${Q}`;else G["X-Tribe-Anonymous-Id"]=this.getAnonymousId();let X=await(await fetch(`${this.baseUrl}/graphql`,{method:"POST",headers:G,body:JSON.stringify({query:$,variables:J})})).json();if(X.errors)throw Error(X.errors[0].message);return X.data}getAnonymousId(){let $=localStorage.getItem(this.anonIdKey);if(!$)$=crypto.randomUUID(),localStorage.setItem(this.anonIdKey,$);return $}async register($,J){let Q=await this.gql(`mutation($siteId: ID!, $email: String!, $password: String!) {
|
|
2
12
|
sdkRegister(siteId: $siteId, email: $email, password: $password) {
|
|
3
13
|
token
|
|
14
|
+
userToken
|
|
4
15
|
user { id email }
|
|
5
16
|
}
|
|
6
|
-
}`,{siteId:this.siteId,email
|
|
17
|
+
}`,{siteId:this.siteId,email:$,password:J});if(localStorage.setItem(this.tokenKey,Q.sdkRegister.token),Q.sdkRegister.userToken)localStorage.setItem(this.userTokenKey,Q.sdkRegister.userToken);return{user:Q.sdkRegister.user,userToken:Q.sdkRegister.userToken}}async login($,J){let Q=await this.gql(`mutation($siteId: ID!, $email: String!, $password: String!) {
|
|
7
18
|
sdkLogin(siteId: $siteId, email: $email, password: $password) {
|
|
8
19
|
token
|
|
20
|
+
userToken
|
|
9
21
|
user { id email }
|
|
10
22
|
}
|
|
11
|
-
}`,{siteId:this.siteId,email
|
|
23
|
+
}`,{siteId:this.siteId,email:$,password:J});if(localStorage.setItem(this.tokenKey,Q.sdkLogin.token),Q.sdkLogin.userToken)localStorage.setItem(this.userTokenKey,Q.sdkLogin.userToken);return{user:Q.sdkLogin.user,userToken:Q.sdkLogin.userToken}}async logout(){try{await this.gql("mutation { sdkLogout }")}catch{}localStorage.removeItem(this.tokenKey),localStorage.removeItem(this.userTokenKey)}async getSession(){if(!localStorage.getItem(this.tokenKey))return null;try{let J=await this.gql("query { sdkSession { userToken user { id email } } }");if(!J.sdkSession)return localStorage.removeItem(this.tokenKey),localStorage.removeItem(this.userTokenKey),null;if(J.sdkSession.userToken)localStorage.setItem(this.userTokenKey,J.sdkSession.userToken);return J.sdkSession}catch{return localStorage.removeItem(this.tokenKey),localStorage.removeItem(this.userTokenKey),null}}getUserToken(){return localStorage.getItem(this.userTokenKey)}track($,J){this.sendEvent("custom",{e:$,ed:J})}async feedback($,J){let Q=this.currentPath;await this.gql(`mutation($siteId: ID!, $message: String!, $type: String, $email: String, $url: String) {
|
|
12
24
|
submitFeedback(siteId: $siteId, message: $message, type: $type, email: $email, url: $url)
|
|
13
|
-
}`,{siteId:this.siteId,message
|
|
25
|
+
}`,{siteId:this.siteId,message:$,url:Q,type:J?.type,email:J?.email})}async getFeatureFlag($){return(await this.gql(`query($siteId: ID!) {
|
|
14
26
|
sdkFeatureFlags(siteId: $siteId) {
|
|
15
27
|
key
|
|
16
28
|
enabled
|
|
17
29
|
}
|
|
18
|
-
}`,{siteId:this.siteId})).sdkFeatureFlags.find((
|
|
30
|
+
}`,{siteId:this.siteId})).sdkFeatureFlags.find((G)=>G.key===$)?.enabled??!1}async getAnnouncements(){let $=await this.gql(`query($siteId: ID!) {
|
|
19
31
|
activeAnnouncements(siteId: $siteId) {
|
|
20
32
|
id
|
|
21
33
|
title
|
|
22
34
|
message
|
|
23
35
|
type
|
|
24
36
|
}
|
|
25
|
-
}`,{siteId:this.siteId}),
|
|
37
|
+
}`,{siteId:this.siteId}),J=`__tribe_dismissed_${this.siteId}`,Q=JSON.parse(localStorage.getItem(J)||"[]");return $.activeAnnouncements.filter((G)=>!Q.includes(G.id))}async ackAnnouncement($){let J=`__tribe_dismissed_${this.siteId}`,Q=JSON.parse(localStorage.getItem(J)||"[]");if(!Q.includes($))Q.push($),localStorage.setItem(J,JSON.stringify(Q));try{await this.gql(`mutation($announcementId: ID!) {
|
|
26
38
|
ackAnnouncement(announcementId: $announcementId)
|
|
27
|
-
}`,{announcementId
|
|
39
|
+
}`,{announcementId:$})}catch{}}async verifyEmail($){await this.gql(`mutation($token: String!) {
|
|
28
40
|
verifyEmail(token: $token)
|
|
29
|
-
}`,{token
|
|
41
|
+
}`,{token:$})}async resendVerification($){await this.gql(`mutation($verifyEmailUrl: String) {
|
|
30
42
|
resendVerification(verifyEmailUrl: $verifyEmailUrl)
|
|
31
|
-
}`,{verifyEmailUrl
|
|
43
|
+
}`,{verifyEmailUrl:$?.verifyEmailUrl})}async forgotPassword($,J){await this.gql(`mutation($siteId: ID!, $email: String!, $resetPasswordUrl: String) {
|
|
32
44
|
forgotPassword(siteId: $siteId, email: $email, resetPasswordUrl: $resetPasswordUrl)
|
|
33
|
-
}`,{siteId:this.siteId,email
|
|
45
|
+
}`,{siteId:this.siteId,email:$,resetPasswordUrl:J?.resetPasswordUrl})}async resetPassword($,J){await this.gql(`mutation($token: String!, $newPassword: String!) {
|
|
34
46
|
resetPassword(token: $token, newPassword: $newPassword)
|
|
35
|
-
}`,{token
|
|
47
|
+
}`,{token:$,newPassword:J})}async requestMagicLink($,J){await this.gql(`mutation($siteId: ID!, $email: String!, $magicLinkUrl: String) {
|
|
36
48
|
requestMagicLink(siteId: $siteId, email: $email, magicLinkUrl: $magicLinkUrl)
|
|
37
|
-
}`,{siteId:this.siteId,email
|
|
49
|
+
}`,{siteId:this.siteId,email:$,magicLinkUrl:J?.magicLinkUrl})}async verifyMagicLink($){let J=await this.gql(`mutation($token: String!) {
|
|
38
50
|
verifyMagicLink(token: $token) {
|
|
39
51
|
token
|
|
52
|
+
userToken
|
|
40
53
|
user { id email }
|
|
41
54
|
}
|
|
42
|
-
}`,{token
|
|
55
|
+
}`,{token:$});if(localStorage.setItem(this.tokenKey,J.verifyMagicLink.token),J.verifyMagicLink.userToken)localStorage.setItem(this.userTokenKey,J.verifyMagicLink.userToken);return{user:J.verifyMagicLink.user,userToken:J.verifyMagicLink.userToken}}async getAuthConfig(){return(await this.gql(`query($siteId: ID!) {
|
|
43
56
|
siteAuthConfig(siteId: $siteId) {
|
|
44
57
|
authEnabled
|
|
58
|
+
accessMode
|
|
45
59
|
magicLinkEnabled
|
|
46
60
|
captchaEnabled
|
|
47
61
|
captchaProvider
|
|
@@ -49,20 +63,24 @@ class A{siteId;baseUrl;sessionId;pageStart;currentPath;tokenKey;anonIdKey;autoTr
|
|
|
49
63
|
captchaRequiredForRegistration
|
|
50
64
|
captchaRequiredForLogin
|
|
51
65
|
breachedPasswordPolicy
|
|
66
|
+
googleEnabled
|
|
67
|
+
githubEnabled
|
|
68
|
+
discordEnabled
|
|
69
|
+
twitterEnabled
|
|
52
70
|
}
|
|
53
|
-
}`,{siteId:this.siteId})).siteAuthConfig}async setRole(
|
|
71
|
+
}`,{siteId:this.siteId})).siteAuthConfig}async setRole($){return(await this.gql(`mutation($role: String!) {
|
|
54
72
|
setRole(role: $role) {
|
|
55
73
|
id
|
|
56
74
|
email
|
|
57
75
|
}
|
|
58
|
-
}`,{role
|
|
76
|
+
}`,{role:$})).setRole}async createApiKey($,J){return(await this.gql(`mutation($name: String!, $scopes: [String!]!) {
|
|
59
77
|
createApiKey(name: $name, scopes: $scopes) {
|
|
60
78
|
id
|
|
61
79
|
key
|
|
62
80
|
name
|
|
63
81
|
scopes
|
|
64
82
|
}
|
|
65
|
-
}`,{name
|
|
83
|
+
}`,{name:$,scopes:J})).createApiKey}async listApiKeys(){return(await this.gql(`query {
|
|
66
84
|
myApiKeys {
|
|
67
85
|
id
|
|
68
86
|
name
|
|
@@ -70,9 +88,9 @@ class A{siteId;baseUrl;sessionId;pageStart;currentPath;tokenKey;anonIdKey;autoTr
|
|
|
70
88
|
scopes
|
|
71
89
|
createdAt
|
|
72
90
|
}
|
|
73
|
-
}`)).myApiKeys}async deleteApiKey(
|
|
91
|
+
}`)).myApiKeys}async deleteApiKey($){await this.gql(`mutation($id: ID!) {
|
|
74
92
|
deleteApiKey(id: $id)
|
|
75
|
-
}`,{id
|
|
93
|
+
}`,{id:$})}async invalidateAllSessions(){await this.gql("mutation { invalidateAllSessions }")}async getActiveDevices(){return(await this.gql(`query {
|
|
76
94
|
sdkActiveDevices {
|
|
77
95
|
id
|
|
78
96
|
browser
|
|
@@ -82,6 +100,27 @@ class A{siteId;baseUrl;sessionId;pageStart;currentPath;tokenKey;anonIdKey;autoTr
|
|
|
82
100
|
createdAt
|
|
83
101
|
isCurrent
|
|
84
102
|
}
|
|
85
|
-
}`)).sdkActiveDevices}async revokeSession(
|
|
103
|
+
}`)).sdkActiveDevices}async revokeSession($){await this.gql(`mutation($sessionId: ID!) {
|
|
86
104
|
sdkRevokeSession(sessionId: $sessionId)
|
|
87
|
-
}`,{sessionId
|
|
105
|
+
}`,{sessionId:$})}async getPaymentConfig(){return(await this.gql(`query($siteId: ID!) {
|
|
106
|
+
sitePaymentConfig(siteId: $siteId) {
|
|
107
|
+
paymentsEnabled
|
|
108
|
+
paymentWalletAddress
|
|
109
|
+
acceptedTokens { mint symbol name logoUrl decimals }
|
|
110
|
+
}
|
|
111
|
+
}`,{siteId:this.siteId})).sitePaymentConfig}async getQrCode($){return(await this.gql(`mutation($siteId: ID!, $mint: String!, $amount: String!, $memo: String, $metadata: JSON) {
|
|
112
|
+
createSitePayment(siteId: $siteId, mint: $mint, amount: $amount, memo: $memo, metadata: $metadata) {
|
|
113
|
+
id
|
|
114
|
+
paymentUrl
|
|
115
|
+
expiresAt
|
|
116
|
+
}
|
|
117
|
+
}`,{siteId:this.siteId,mint:$.mint,amount:$.amount,memo:$.memo,metadata:$.metadata})).createSitePayment}async sendViaPhantom($){let J=window.phantom?.solana;if(!J?.isPhantom)throw Error("Phantom wallet not found");let Q=await this.getQrCode($);if(!J.isConnected)await J.connect();let G=J.publicKey.toBase58(),Y=await this.gql(`mutation($paymentId: ID!, $senderWallet: String!) {
|
|
118
|
+
prepareSitePaymentTransaction(paymentId: $paymentId, senderWallet: $senderWallet) {
|
|
119
|
+
serializedTransaction
|
|
120
|
+
}
|
|
121
|
+
}`,{paymentId:Q.id,senderWallet:G}),X=Uint8Array.from(atob(Y.prepareSitePaymentTransaction.serializedTransaction),(U)=>U.charCodeAt(0)),M=W0.from(X),{signature:I}=await J.signAndSendTransaction(M);return this.verifyPayment(Q.id,I)}async verifyPayment($,J){return(await this.gql(`mutation($paymentId: ID!, $txSignature: String) {
|
|
122
|
+
verifySitePayment(paymentId: $paymentId, txSignature: $txSignature) {
|
|
123
|
+
status
|
|
124
|
+
txSignature
|
|
125
|
+
}
|
|
126
|
+
}`,{paymentId:$,txSignature:J})).verifySitePayment}}var f7="SITE_ID",b7="BASE_URL",m7=new x$({siteId:f7,_baseUrl:b7,autoTrack:!0});window.Tribe=m7;
|