test-rrr-sdk
Version:
An SDK for building applications on top of Raydium.
1 lines • 202 kB
JavaScript
var _o=Object.create;var Yt=Object.defineProperty,Vo=Object.defineProperties,Do=Object.getOwnPropertyDescriptor,qo=Object.getOwnPropertyDescriptors,Go=Object.getOwnPropertyNames,An=Object.getOwnPropertySymbols,Uo=Object.getPrototypeOf,ti=Object.prototype.hasOwnProperty,tr=Object.prototype.propertyIsEnumerable;var er=(i,e,t)=>e in i?Yt(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,G=(i,e)=>{for(var t in e||(e={}))ti.call(e,t)&&er(i,t,e[t]);if(An)for(var t of An(e))tr.call(e,t)&&er(i,t,e[t]);return i},J=(i,e)=>Vo(i,qo(e));var Kt=(i,e)=>{var t={};for(var n in i)ti.call(i,n)&&e.indexOf(n)<0&&(t[n]=i[n]);if(i!=null&&An)for(var n of An(i))e.indexOf(n)<0&&tr.call(i,n)&&(t[n]=i[n]);return t};var Xo=(i,e)=>{for(var t in e)Yt(i,t,{get:e[t],enumerable:!0})},nr=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Go(e))!ti.call(i,r)&&r!==t&&Yt(i,r,{get:()=>e[r],enumerable:!(n=Do(e,r))||n.enumerable});return i};var le=(i,e,t)=>(t=i!=null?_o(Uo(i)):{},nr(e||!i||!i.__esModule?Yt(t,"default",{value:i,enumerable:!0}):t,i)),zo=i=>nr(Yt({},"__esModule",{value:!0}),i);var tu={};Xo(tu,{default:()=>ei});module.exports=zo(tu);var xt=require("@solana/web3.js"),ce=require("@solana/spl-token"),kn=le(require("bn.js"));var Wt=9e15,kt=1e9,ni="0123456789abcdef",hn="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Tn="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",ii={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Wt,maxE:Wt,crypto:!1},sr,ut,j=!0,In="[DecimalError] ",Pt=In+"Invalid argument: ",ar=In+"Precision limit exceeded",ur=In+"crypto unavailable",cr="[object Decimal]",Ne=Math.floor,Ie=Math.pow,Qo=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Ho=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,jo=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,lr=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,He=1e7,z=7,Zo=9007199254740991,Yo=hn.length-1,ri=Tn.length-1,K={toStringTag:cr};K.absoluteValue=K.abs=function(){var i=new this.constructor(this);return i.s<0&&(i.s=1),D(i)};K.ceil=function(){return D(new this.constructor(this),this.e+1,2)};K.clampedTo=K.clamp=function(i,e){var t,n=this,r=n.constructor;if(i=new r(i),e=new r(e),!i.s||!e.s)return new r(NaN);if(i.gt(e))throw Error(Pt+e);return t=n.cmp(i),t<0?i:n.cmp(e)>0?e:new r(n)};K.comparedTo=K.cmp=function(i){var e,t,n,r,o=this,s=o.d,a=(i=new o.constructor(i)).d,c=o.s,u=i.s;if(!s||!a)return!c||!u?NaN:c!==u?c:s===a?0:!s^c<0?1:-1;if(!s[0]||!a[0])return s[0]?c:a[0]?-u:0;if(c!==u)return c;if(o.e!==i.e)return o.e>i.e^c<0?1:-1;for(n=s.length,r=a.length,e=0,t=n<r?n:r;e<t;++e)if(s[e]!==a[e])return s[e]>a[e]^c<0?1:-1;return n===r?0:n>r^c<0?1:-1};K.cosine=K.cos=function(){var i,e,t=this,n=t.constructor;return t.d?t.d[0]?(i=n.precision,e=n.rounding,n.precision=i+Math.max(t.e,t.sd())+z,n.rounding=1,t=Jo(n,br(n,t)),n.precision=i,n.rounding=e,D(ut==2||ut==3?t.neg():t,i,e,!0)):new n(1):new n(NaN)};K.cubeRoot=K.cbrt=function(){var i,e,t,n,r,o,s,a,c,u,l=this,p=l.constructor;if(!l.isFinite()||l.isZero())return new p(l);for(j=!1,o=l.s*Ie(l.s*l,1/3),!o||Math.abs(o)==1/0?(t=Ce(l.d),i=l.e,(o=(i-t.length+1)%3)&&(t+=o==1||o==-2?"0":"00"),o=Ie(t,1/3),i=Ne((i+1)/3)-(i%3==(i<0?-1:2)),o==1/0?t="5e"+i:(t=o.toExponential(),t=t.slice(0,t.indexOf("e")+1)+i),n=new p(t),n.s=l.s):n=new p(o.toString()),s=(i=p.precision)+3;;)if(a=n,c=a.times(a).times(a),u=c.plus(l),n=pe(u.plus(l).times(a),u.plus(c),s+2,1),Ce(a.d).slice(0,s)===(t=Ce(n.d)).slice(0,s))if(t=t.slice(s-3,s+1),t=="9999"||!r&&t=="4999"){if(!r&&(D(a,i+1,0),a.times(a).times(a).eq(l))){n=a;break}s+=4,r=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(D(n,i+1,1),e=!n.times(n).times(n).eq(l));break}return j=!0,D(n,i,p.rounding,e)};K.decimalPlaces=K.dp=function(){var i,e=this.d,t=NaN;if(e){if(i=e.length-1,t=(i-Ne(this.e/z))*z,i=e[i],i)for(;i%10==0;i/=10)t--;t<0&&(t=0)}return t};K.dividedBy=K.div=function(i){return pe(this,new this.constructor(i))};K.dividedToIntegerBy=K.divToInt=function(i){var e=this,t=e.constructor;return D(pe(e,new t(i),0,1,1),t.precision,t.rounding)};K.equals=K.eq=function(i){return this.cmp(i)===0};K.floor=function(){return D(new this.constructor(this),this.e+1,3)};K.greaterThan=K.gt=function(i){return this.cmp(i)>0};K.greaterThanOrEqualTo=K.gte=function(i){var e=this.cmp(i);return e==1||e===0};K.hyperbolicCosine=K.cosh=function(){var i,e,t,n,r,o=this,s=o.constructor,a=new s(1);if(!o.isFinite())return new s(o.s?1/0:NaN);if(o.isZero())return a;t=s.precision,n=s.rounding,s.precision=t+Math.max(o.e,o.sd())+4,s.rounding=1,r=o.d.length,r<32?(i=Math.ceil(r/3),e=(1/Sn(4,i)).toString()):(i=16,e="2.3283064365386962890625e-10"),o=_t(s,1,o.times(e),new s(1),!0);for(var c,u=i,l=new s(8);u--;)c=o.times(o),o=a.minus(c.times(l.minus(c.times(l))));return D(o,s.precision=t,s.rounding=n,!0)};K.hyperbolicSine=K.sinh=function(){var i,e,t,n,r=this,o=r.constructor;if(!r.isFinite()||r.isZero())return new o(r);if(e=o.precision,t=o.rounding,o.precision=e+Math.max(r.e,r.sd())+4,o.rounding=1,n=r.d.length,n<3)r=_t(o,2,r,r,!0);else{i=1.4*Math.sqrt(n),i=i>16?16:i|0,r=r.times(1/Sn(5,i)),r=_t(o,2,r,r,!0);for(var s,a=new o(5),c=new o(16),u=new o(20);i--;)s=r.times(r),r=r.times(a.plus(s.times(c.times(s).plus(u))))}return o.precision=e,o.rounding=t,D(r,e,t,!0)};K.hyperbolicTangent=K.tanh=function(){var i,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(i=n.precision,e=n.rounding,n.precision=i+7,n.rounding=1,pe(t.sinh(),t.cosh(),n.precision=i,n.rounding=e)):new n(t.s)};K.inverseCosine=K.acos=function(){var i,e=this,t=e.constructor,n=e.abs().cmp(1),r=t.precision,o=t.rounding;return n!==-1?n===0?e.isNeg()?Qe(t,r,o):new t(0):new t(NaN):e.isZero()?Qe(t,r+4,o).times(.5):(t.precision=r+6,t.rounding=1,e=e.asin(),i=Qe(t,r+4,o).times(.5),t.precision=r,t.rounding=o,i.minus(e))};K.inverseHyperbolicCosine=K.acosh=function(){var i,e,t=this,n=t.constructor;return t.lte(1)?new n(t.eq(1)?0:NaN):t.isFinite()?(i=n.precision,e=n.rounding,n.precision=i+Math.max(Math.abs(t.e),t.sd())+4,n.rounding=1,j=!1,t=t.times(t).minus(1).sqrt().plus(t),j=!0,n.precision=i,n.rounding=e,t.ln()):new n(t)};K.inverseHyperbolicSine=K.asinh=function(){var i,e,t=this,n=t.constructor;return!t.isFinite()||t.isZero()?new n(t):(i=n.precision,e=n.rounding,n.precision=i+2*Math.max(Math.abs(t.e),t.sd())+6,n.rounding=1,j=!1,t=t.times(t).plus(1).sqrt().plus(t),j=!0,n.precision=i,n.rounding=e,t.ln())};K.inverseHyperbolicTangent=K.atanh=function(){var i,e,t,n,r=this,o=r.constructor;return r.isFinite()?r.e>=0?new o(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(i=o.precision,e=o.rounding,n=r.sd(),Math.max(n,i)<2*-r.e-1?D(new o(r),i,e,!0):(o.precision=t=n-r.e,r=pe(r.plus(1),new o(1).minus(r),t+i,1),o.precision=i+4,o.rounding=1,r=r.ln(),o.precision=i,o.rounding=e,r.times(.5))):new o(NaN)};K.inverseSine=K.asin=function(){var i,e,t,n,r=this,o=r.constructor;return r.isZero()?new o(r):(e=r.abs().cmp(1),t=o.precision,n=o.rounding,e!==-1?e===0?(i=Qe(o,t+4,n).times(.5),i.s=r.s,i):new o(NaN):(o.precision=t+6,o.rounding=1,r=r.div(new o(1).minus(r.times(r)).sqrt().plus(1)).atan(),o.precision=t,o.rounding=n,r.times(2)))};K.inverseTangent=K.atan=function(){var i,e,t,n,r,o,s,a,c,u=this,l=u.constructor,p=l.precision,m=l.rounding;if(u.isFinite()){if(u.isZero())return new l(u);if(u.abs().eq(1)&&p+4<=ri)return s=Qe(l,p+4,m).times(.25),s.s=u.s,s}else{if(!u.s)return new l(NaN);if(p+4<=ri)return s=Qe(l,p+4,m).times(.5),s.s=u.s,s}for(l.precision=a=p+10,l.rounding=1,t=Math.min(28,a/z+2|0),i=t;i;--i)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(j=!1,e=Math.ceil(a/z),n=1,c=u.times(u),s=new l(u),r=u;i!==-1;)if(r=r.times(c),o=s.minus(r.div(n+=2)),r=r.times(c),s=o.plus(r.div(n+=2)),s.d[e]!==void 0)for(i=e;s.d[i]===o.d[i]&&i--;);return t&&(s=s.times(2<<t-1)),j=!0,D(s,l.precision=p,l.rounding=m,!0)};K.isFinite=function(){return!!this.d};K.isInteger=K.isInt=function(){return!!this.d&&Ne(this.e/z)>this.d.length-2};K.isNaN=function(){return!this.s};K.isNegative=K.isNeg=function(){return this.s<0};K.isPositive=K.isPos=function(){return this.s>0};K.isZero=function(){return!!this.d&&this.d[0]===0};K.lessThan=K.lt=function(i){return this.cmp(i)<0};K.lessThanOrEqualTo=K.lte=function(i){return this.cmp(i)<1};K.logarithm=K.log=function(i){var e,t,n,r,o,s,a,c,u=this,l=u.constructor,p=l.precision,m=l.rounding,d=5;if(i==null)i=new l(10),e=!0;else{if(i=new l(i),t=i.d,i.s<0||!t||!t[0]||i.eq(1))return new l(NaN);e=i.eq(10)}if(t=u.d,u.s<0||!t||!t[0]||u.eq(1))return new l(t&&!t[0]?-1/0:u.s!=1?NaN:t?0:1/0);if(e)if(t.length>1)o=!0;else{for(r=t[0];r%10===0;)r/=10;o=r!==1}if(j=!1,a=p+d,s=gt(u,a),n=e?Bn(l,a+10):gt(i,a),c=pe(s,n,a,1),Jt(c.d,r=p,m))do if(a+=10,s=gt(u,a),n=e?Bn(l,a+10):gt(i,a),c=pe(s,n,a,1),!o){+Ce(c.d).slice(r+1,r+15)+1==1e14&&(c=D(c,p+1,0));break}while(Jt(c.d,r+=10,m));return j=!0,D(c,p,m)};K.minus=K.sub=function(i){var e,t,n,r,o,s,a,c,u,l,p,m,d=this,b=d.constructor;if(i=new b(i),!d.d||!i.d)return!d.s||!i.s?i=new b(NaN):d.d?i.s=-i.s:i=new b(i.d||d.s!==i.s?d:NaN),i;if(d.s!=i.s)return i.s=-i.s,d.plus(i);if(u=d.d,m=i.d,a=b.precision,c=b.rounding,!u[0]||!m[0]){if(m[0])i.s=-i.s;else if(u[0])i=new b(d);else return new b(c===3?-0:0);return j?D(i,a,c):i}if(t=Ne(i.e/z),l=Ne(d.e/z),u=u.slice(),o=l-t,o){for(p=o<0,p?(e=u,o=-o,s=m.length):(e=m,t=l,s=u.length),n=Math.max(Math.ceil(a/z),s)+2,o>n&&(o=n,e.length=1),e.reverse(),n=o;n--;)e.push(0);e.reverse()}else{for(n=u.length,s=m.length,p=n<s,p&&(s=n),n=0;n<s;n++)if(u[n]!=m[n]){p=u[n]<m[n];break}o=0}for(p&&(e=u,u=m,m=e,i.s=-i.s),s=u.length,n=m.length-s;n>0;--n)u[s++]=0;for(n=m.length;n>o;){if(u[--n]<m[n]){for(r=n;r&&u[--r]===0;)u[r]=He-1;--u[r],u[n]+=He}u[n]-=m[n]}for(;u[--s]===0;)u.pop();for(;u[0]===0;u.shift())--t;return u[0]?(i.d=u,i.e=xn(u,t),j?D(i,a,c):i):new b(c===3?-0:0)};K.modulo=K.mod=function(i){var e,t=this,n=t.constructor;return i=new n(i),!t.d||!i.s||i.d&&!i.d[0]?new n(NaN):!i.d||t.d&&!t.d[0]?D(new n(t),n.precision,n.rounding):(j=!1,n.modulo==9?(e=pe(t,i.abs(),0,3,1),e.s*=i.s):e=pe(t,i,0,n.modulo,1),e=e.times(i),j=!0,t.minus(e))};K.naturalExponential=K.exp=function(){return oi(this)};K.naturalLogarithm=K.ln=function(){return gt(this)};K.negated=K.neg=function(){var i=new this.constructor(this);return i.s=-i.s,D(i)};K.plus=K.add=function(i){var e,t,n,r,o,s,a,c,u,l,p=this,m=p.constructor;if(i=new m(i),!p.d||!i.d)return!p.s||!i.s?i=new m(NaN):p.d||(i=new m(i.d||p.s===i.s?p:NaN)),i;if(p.s!=i.s)return i.s=-i.s,p.minus(i);if(u=p.d,l=i.d,a=m.precision,c=m.rounding,!u[0]||!l[0])return l[0]||(i=new m(p)),j?D(i,a,c):i;if(o=Ne(p.e/z),n=Ne(i.e/z),u=u.slice(),r=o-n,r){for(r<0?(t=u,r=-r,s=l.length):(t=l,n=o,s=u.length),o=Math.ceil(a/z),s=o>s?o+1:s+1,r>s&&(r=s,t.length=1),t.reverse();r--;)t.push(0);t.reverse()}for(s=u.length,r=l.length,s-r<0&&(r=s,t=l,l=u,u=t),e=0;r;)e=(u[--r]=u[r]+l[r]+e)/He|0,u[r]%=He;for(e&&(u.unshift(e),++n),s=u.length;u[--s]==0;)u.pop();return i.d=u,i.e=xn(u,n),j?D(i,a,c):i};K.precision=K.sd=function(i){var e,t=this;if(i!==void 0&&i!==!!i&&i!==1&&i!==0)throw Error(Pt+i);return t.d?(e=mr(t.d),i&&t.e+1>e&&(e=t.e+1)):e=NaN,e};K.round=function(){var i=this,e=i.constructor;return D(new e(i),i.e+1,e.rounding)};K.sine=K.sin=function(){var i,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(i=n.precision,e=n.rounding,n.precision=i+Math.max(t.e,t.sd())+z,n.rounding=1,t=es(n,br(n,t)),n.precision=i,n.rounding=e,D(ut>2?t.neg():t,i,e,!0)):new n(NaN)};K.squareRoot=K.sqrt=function(){var i,e,t,n,r,o,s=this,a=s.d,c=s.e,u=s.s,l=s.constructor;if(u!==1||!a||!a[0])return new l(!u||u<0&&(!a||a[0])?NaN:a?s:1/0);for(j=!1,u=Math.sqrt(+s),u==0||u==1/0?(e=Ce(a),(e.length+c)%2==0&&(e+="0"),u=Math.sqrt(e),c=Ne((c+1)/2)-(c<0||c%2),u==1/0?e="5e"+c:(e=u.toExponential(),e=e.slice(0,e.indexOf("e")+1)+c),n=new l(e)):n=new l(u.toString()),t=(c=l.precision)+3;;)if(o=n,n=o.plus(pe(s,o,t+2,1)).times(.5),Ce(o.d).slice(0,t)===(e=Ce(n.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!r&&e=="4999"){if(!r&&(D(o,c+1,0),o.times(o).eq(s))){n=o;break}t+=4,r=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(D(n,c+1,1),i=!n.times(n).eq(s));break}return j=!0,D(n,c,l.rounding,i)};K.tangent=K.tan=function(){var i,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(i=n.precision,e=n.rounding,n.precision=i+10,n.rounding=1,t=t.sin(),t.s=1,t=pe(t,new n(1).minus(t.times(t)).sqrt(),i+10,0),n.precision=i,n.rounding=e,D(ut==2||ut==4?t.neg():t,i,e,!0)):new n(NaN)};K.times=K.mul=function(i){var e,t,n,r,o,s,a,c,u,l=this,p=l.constructor,m=l.d,d=(i=new p(i)).d;if(i.s*=l.s,!m||!m[0]||!d||!d[0])return new p(!i.s||m&&!m[0]&&!d||d&&!d[0]&&!m?NaN:!m||!d?i.s/0:i.s*0);for(t=Ne(l.e/z)+Ne(i.e/z),c=m.length,u=d.length,c<u&&(o=m,m=d,d=o,s=c,c=u,u=s),o=[],s=c+u,n=s;n--;)o.push(0);for(n=u;--n>=0;){for(e=0,r=c+n;r>n;)a=o[r]+d[n]*m[r-n-1]+e,o[r--]=a%He|0,e=a/He|0;o[r]=(o[r]+e)%He|0}for(;!o[--s];)o.pop();return e?++t:o.shift(),i.d=o,i.e=xn(o,t),j?D(i,p.precision,p.rounding):i};K.toBinary=function(i,e){return ai(this,2,i,e)};K.toDecimalPlaces=K.toDP=function(i,e){var t=this,n=t.constructor;return t=new n(t),i===void 0?t:(Oe(i,0,kt),e===void 0?e=n.rounding:Oe(e,0,8),D(t,i+t.e+1,e))};K.toExponential=function(i,e){var t,n=this,r=n.constructor;return i===void 0?t=tt(n,!0):(Oe(i,0,kt),e===void 0?e=r.rounding:Oe(e,0,8),n=D(new r(n),i+1,e),t=tt(n,!0,i+1)),n.isNeg()&&!n.isZero()?"-"+t:t};K.toFixed=function(i,e){var t,n,r=this,o=r.constructor;return i===void 0?t=tt(r):(Oe(i,0,kt),e===void 0?e=o.rounding:Oe(e,0,8),n=D(new o(r),i+r.e+1,e),t=tt(n,!1,i+n.e+1)),r.isNeg()&&!r.isZero()?"-"+t:t};K.toFraction=function(i){var e,t,n,r,o,s,a,c,u,l,p,m,d=this,b=d.d,f=d.constructor;if(!b)return new f(d);if(u=t=new f(1),n=c=new f(0),e=new f(n),o=e.e=mr(b)-d.e-1,s=o%z,e.d[0]=Ie(10,s<0?z+s:s),i==null)i=o>0?e:u;else{if(a=new f(i),!a.isInt()||a.lt(u))throw Error(Pt+a);i=a.gt(e)?o>0?e:u:a}for(j=!1,a=new f(Ce(b)),l=f.precision,f.precision=o=b.length*z*2;p=pe(a,e,0,1,1),r=t.plus(p.times(n)),r.cmp(i)!=1;)t=n,n=r,r=u,u=c.plus(p.times(r)),c=r,r=e,e=a.minus(p.times(r)),a=r;return r=pe(i.minus(t),n,0,1,1),c=c.plus(r.times(u)),t=t.plus(r.times(n)),c.s=u.s=d.s,m=pe(u,n,o,1).minus(d).abs().cmp(pe(c,t,o,1).minus(d).abs())<1?[u,n]:[c,t],f.precision=l,j=!0,m};K.toHexadecimal=K.toHex=function(i,e){return ai(this,16,i,e)};K.toNearest=function(i,e){var t=this,n=t.constructor;if(t=new n(t),i==null){if(!t.d)return t;i=new n(1),e=n.rounding}else{if(i=new n(i),e===void 0?e=n.rounding:Oe(e,0,8),!t.d)return i.s?t:i;if(!i.d)return i.s&&(i.s=t.s),i}return i.d[0]?(j=!1,t=pe(t,i,0,e,1).times(i),j=!0,D(t)):(i.s=t.s,t=i),t};K.toNumber=function(){return+this};K.toOctal=function(i,e){return ai(this,8,i,e)};K.toPower=K.pow=function(i){var e,t,n,r,o,s,a=this,c=a.constructor,u=+(i=new c(i));if(!a.d||!i.d||!a.d[0]||!i.d[0])return new c(Ie(+a,u));if(a=new c(a),a.eq(1))return a;if(n=c.precision,o=c.rounding,i.eq(1))return D(a,n,o);if(e=Ne(i.e/z),e>=i.d.length-1&&(t=u<0?-u:u)<=Zo)return r=pr(c,a,t,n),i.s<0?new c(1).div(r):D(r,n,o);if(s=a.s,s<0){if(e<i.d.length-1)return new c(NaN);if((i.d[e]&1)==0&&(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return t=Ie(+a,u),e=t==0||!isFinite(t)?Ne(u*(Math.log("0."+Ce(a.d))/Math.LN10+a.e+1)):new c(t+"").e,e>c.maxE+1||e<c.minE-1?new c(e>0?s/0:0):(j=!1,c.rounding=a.s=1,t=Math.min(12,(e+"").length),r=oi(i.times(gt(a,n+t)),n),r.d&&(r=D(r,n+5,1),Jt(r.d,n,o)&&(e=n+10,r=D(oi(i.times(gt(a,e+t)),e),e+5,1),+Ce(r.d).slice(n+1,n+15)+1==1e14&&(r=D(r,n+1,0)))),r.s=s,j=!0,c.rounding=o,D(r,n,o))};K.toPrecision=function(i,e){var t,n=this,r=n.constructor;return i===void 0?t=tt(n,n.e<=r.toExpNeg||n.e>=r.toExpPos):(Oe(i,1,kt),e===void 0?e=r.rounding:Oe(e,0,8),n=D(new r(n),i,e),t=tt(n,i<=n.e||n.e<=r.toExpNeg,i)),n.isNeg()&&!n.isZero()?"-"+t:t};K.toSignificantDigits=K.toSD=function(i,e){var t=this,n=t.constructor;return i===void 0?(i=n.precision,e=n.rounding):(Oe(i,1,kt),e===void 0?e=n.rounding:Oe(e,0,8)),D(new n(t),i,e)};K.toString=function(){var i=this,e=i.constructor,t=tt(i,i.e<=e.toExpNeg||i.e>=e.toExpPos);return i.isNeg()&&!i.isZero()?"-"+t:t};K.truncated=K.trunc=function(){return D(new this.constructor(this),this.e+1,1)};K.valueOf=K.toJSON=function(){var i=this,e=i.constructor,t=tt(i,i.e<=e.toExpNeg||i.e>=e.toExpPos);return i.isNeg()?"-"+t:t};function Ce(i){var e,t,n,r=i.length-1,o="",s=i[0];if(r>0){for(o+=s,e=1;e<r;e++)n=i[e]+"",t=z-n.length,t&&(o+=yt(t)),o+=n;s=i[e],n=s+"",t=z-n.length,t&&(o+=yt(t))}else if(s===0)return"0";for(;s%10===0;)s/=10;return o+s}function Oe(i,e,t){if(i!==~~i||i<e||i>t)throw Error(Pt+i)}function Jt(i,e,t,n){var r,o,s,a;for(o=i[0];o>=10;o/=10)--e;return--e<0?(e+=z,r=0):(r=Math.ceil((e+1)/z),e%=z),o=Ie(10,z-e),a=i[r]%o|0,n==null?e<3?(e==0?a=a/100|0:e==1&&(a=a/10|0),s=t<4&&a==99999||t>3&&a==49999||a==5e4||a==0):s=(t<4&&a+1==o||t>3&&a+1==o/2)&&(i[r+1]/o/100|0)==Ie(10,e-2)-1||(a==o/2||a==0)&&(i[r+1]/o/100|0)==0:e<4?(e==0?a=a/1e3|0:e==1?a=a/100|0:e==2&&(a=a/10|0),s=(n||t<4)&&a==9999||!n&&t>3&&a==4999):s=((n||t<4)&&a+1==o||!n&&t>3&&a+1==o/2)&&(i[r+1]/o/1e3|0)==Ie(10,e-3)-1,s}function wn(i,e,t){for(var n,r=[0],o,s=0,a=i.length;s<a;){for(o=r.length;o--;)r[o]*=e;for(r[0]+=ni.indexOf(i.charAt(s++)),n=0;n<r.length;n++)r[n]>t-1&&(r[n+1]===void 0&&(r[n+1]=0),r[n+1]+=r[n]/t|0,r[n]%=t)}return r.reverse()}function Jo(i,e){var t,n,r;if(e.isZero())return e;n=e.d.length,n<32?(t=Math.ceil(n/3),r=(1/Sn(4,t)).toString()):(t=16,r="2.3283064365386962890625e-10"),i.precision+=t,e=_t(i,1,e.times(r),new i(1));for(var o=t;o--;){var s=e.times(e);e=s.times(s).minus(s).times(8).plus(1)}return i.precision-=t,e}var pe=function(){function i(n,r,o){var s,a=0,c=n.length;for(n=n.slice();c--;)s=n[c]*r+a,n[c]=s%o|0,a=s/o|0;return a&&n.unshift(a),n}function e(n,r,o,s){var a,c;if(o!=s)c=o>s?1:-1;else for(a=c=0;a<o;a++)if(n[a]!=r[a]){c=n[a]>r[a]?1:-1;break}return c}function t(n,r,o,s){for(var a=0;o--;)n[o]-=a,a=n[o]<r[o]?1:0,n[o]=a*s+n[o]-r[o];for(;!n[0]&&n.length>1;)n.shift()}return function(n,r,o,s,a,c){var u,l,p,m,d,b,f,y,g,A,w,h,B,k,x,S,R,T,N,V,O=n.constructor,te=n.s==r.s?1:-1,X=n.d,E=r.d;if(!X||!X[0]||!E||!E[0])return new O(!n.s||!r.s||(X?E&&X[0]==E[0]:!E)?NaN:X&&X[0]==0||!E?te*0:te/0);for(c?(d=1,l=n.e-r.e):(c=He,d=z,l=Ne(n.e/d)-Ne(r.e/d)),N=E.length,R=X.length,g=new O(te),A=g.d=[],p=0;E[p]==(X[p]||0);p++);if(E[p]>(X[p]||0)&&l--,o==null?(k=o=O.precision,s=O.rounding):a?k=o+(n.e-r.e)+1:k=o,k<0)A.push(1),b=!0;else{if(k=k/d+2|0,p=0,N==1){for(m=0,E=E[0],k++;(p<R||m)&&k--;p++)x=m*c+(X[p]||0),A[p]=x/E|0,m=x%E|0;b=m||p<R}else{for(m=c/(E[0]+1)|0,m>1&&(E=i(E,m,c),X=i(X,m,c),N=E.length,R=X.length),S=N,w=X.slice(0,N),h=w.length;h<N;)w[h++]=0;V=E.slice(),V.unshift(0),T=E[0],E[1]>=c/2&&++T;do m=0,u=e(E,w,N,h),u<0?(B=w[0],N!=h&&(B=B*c+(w[1]||0)),m=B/T|0,m>1?(m>=c&&(m=c-1),f=i(E,m,c),y=f.length,h=w.length,u=e(f,w,y,h),u==1&&(m--,t(f,N<y?V:E,y,c))):(m==0&&(u=m=1),f=E.slice()),y=f.length,y<h&&f.unshift(0),t(w,f,h,c),u==-1&&(h=w.length,u=e(E,w,N,h),u<1&&(m++,t(w,N<h?V:E,h,c))),h=w.length):u===0&&(m++,w=[0]),A[p++]=m,u&&w[0]?w[h++]=X[S]||0:(w=[X[S]],h=1);while((S++<R||w[0]!==void 0)&&k--);b=w[0]!==void 0}A[0]||A.shift()}if(d==1)g.e=l,sr=b;else{for(p=1,m=A[0];m>=10;m/=10)p++;g.e=p+l*d-1,D(g,a?o+g.e+1:o,s,b)}return g}}();function D(i,e,t,n){var r,o,s,a,c,u,l,p,m,d=i.constructor;e:if(e!=null){if(p=i.d,!p)return i;for(r=1,a=p[0];a>=10;a/=10)r++;if(o=e-r,o<0)o+=z,s=e,l=p[m=0],c=l/Ie(10,r-s-1)%10|0;else if(m=Math.ceil((o+1)/z),a=p.length,m>=a)if(n){for(;a++<=m;)p.push(0);l=c=0,r=1,o%=z,s=o-z+1}else break e;else{for(l=a=p[m],r=1;a>=10;a/=10)r++;o%=z,s=o-z+r,c=s<0?0:l/Ie(10,r-s-1)%10|0}if(n=n||e<0||p[m+1]!==void 0||(s<0?l:l%Ie(10,r-s-1)),u=t<4?(c||n)&&(t==0||t==(i.s<0?3:2)):c>5||c==5&&(t==4||n||t==6&&(o>0?s>0?l/Ie(10,r-s):0:p[m-1])%10&1||t==(i.s<0?8:7)),e<1||!p[0])return p.length=0,u?(e-=i.e+1,p[0]=Ie(10,(z-e%z)%z),i.e=-e||0):p[0]=i.e=0,i;if(o==0?(p.length=m,a=1,m--):(p.length=m+1,a=Ie(10,z-o),p[m]=s>0?(l/Ie(10,r-s)%Ie(10,s)|0)*a:0),u)for(;;)if(m==0){for(o=1,s=p[0];s>=10;s/=10)o++;for(s=p[0]+=a,a=1;s>=10;s/=10)a++;o!=a&&(i.e++,p[0]==He&&(p[0]=1));break}else{if(p[m]+=a,p[m]!=He)break;p[m--]=0,a=1}for(o=p.length;p[--o]===0;)p.pop()}return j&&(i.e>d.maxE?(i.d=null,i.e=NaN):i.e<d.minE&&(i.e=0,i.d=[0])),i}function tt(i,e,t){if(!i.isFinite())return fr(i);var n,r=i.e,o=Ce(i.d),s=o.length;return e?(t&&(n=t-s)>0?o=o.charAt(0)+"."+o.slice(1)+yt(n):s>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(i.e<0?"e":"e+")+i.e):r<0?(o="0."+yt(-r-1)+o,t&&(n=t-s)>0&&(o+=yt(n))):r>=s?(o+=yt(r+1-s),t&&(n=t-r-1)>0&&(o=o+"."+yt(n))):((n=r+1)<s&&(o=o.slice(0,n)+"."+o.slice(n)),t&&(n=t-s)>0&&(r+1===s&&(o+="."),o+=yt(n))),o}function xn(i,e){var t=i[0];for(e*=z;t>=10;t/=10)e++;return e}function Bn(i,e,t){if(e>Yo)throw j=!0,t&&(i.precision=t),Error(ar);return D(new i(hn),e,1,!0)}function Qe(i,e,t){if(e>ri)throw Error(ar);return D(new i(Tn),e,t,!0)}function mr(i){var e=i.length-1,t=e*z+1;if(e=i[e],e){for(;e%10==0;e/=10)t--;for(e=i[0];e>=10;e/=10)t++}return t}function yt(i){for(var e="";i--;)e+="0";return e}function pr(i,e,t,n){var r,o=new i(1),s=Math.ceil(n/z+4);for(j=!1;;){if(t%2&&(o=o.times(e),rr(o.d,s)&&(r=!0)),t=Ne(t/2),t===0){t=o.d.length-1,r&&o.d[t]===0&&++o.d[t];break}e=e.times(e),rr(e.d,s)}return j=!0,o}function ir(i){return i.d[i.d.length-1]&1}function dr(i,e,t){for(var n,r=new i(e[0]),o=0;++o<e.length;)if(n=new i(e[o]),n.s)r[t](n)&&(r=n);else{r=n;break}return r}function oi(i,e){var t,n,r,o,s,a,c,u=0,l=0,p=0,m=i.constructor,d=m.rounding,b=m.precision;if(!i.d||!i.d[0]||i.e>17)return new m(i.d?i.d[0]?i.s<0?0:1/0:1:i.s?i.s<0?0:i:0/0);for(e==null?(j=!1,c=b):c=e,a=new m(.03125);i.e>-2;)i=i.times(a),p+=5;for(n=Math.log(Ie(2,p))/Math.LN10*2+5|0,c+=n,t=o=s=new m(1),m.precision=c;;){if(o=D(o.times(i),c,1),t=t.times(++l),a=s.plus(pe(o,t,c,1)),Ce(a.d).slice(0,c)===Ce(s.d).slice(0,c)){for(r=p;r--;)s=D(s.times(s),c,1);if(e==null)if(u<3&&Jt(s.d,c-n,d,u))m.precision=c+=10,t=o=a=new m(1),l=0,u++;else return D(s,m.precision=b,d,j=!0);else return m.precision=b,s}s=a}}function gt(i,e){var t,n,r,o,s,a,c,u,l,p,m,d=1,b=10,f=i,y=f.d,g=f.constructor,A=g.rounding,w=g.precision;if(f.s<0||!y||!y[0]||!f.e&&y[0]==1&&y.length==1)return new g(y&&!y[0]?-1/0:f.s!=1?NaN:y?0:f);if(e==null?(j=!1,l=w):l=e,g.precision=l+=b,t=Ce(y),n=t.charAt(0),Math.abs(o=f.e)<15e14){for(;n<7&&n!=1||n==1&&t.charAt(1)>3;)f=f.times(i),t=Ce(f.d),n=t.charAt(0),d++;o=f.e,n>1?(f=new g("0."+t),o++):f=new g(n+"."+t.slice(1))}else return u=Bn(g,l+2,w).times(o+""),f=gt(new g(n+"."+t.slice(1)),l-b).plus(u),g.precision=w,e==null?D(f,w,A,j=!0):f;for(p=f,c=s=f=pe(f.minus(1),f.plus(1),l,1),m=D(f.times(f),l,1),r=3;;){if(s=D(s.times(m),l,1),u=c.plus(pe(s,new g(r),l,1)),Ce(u.d).slice(0,l)===Ce(c.d).slice(0,l))if(c=c.times(2),o!==0&&(c=c.plus(Bn(g,l+2,w).times(o+""))),c=pe(c,new g(d),l,1),e==null)if(Jt(c.d,l-b,A,a))g.precision=l+=b,u=s=f=pe(p.minus(1),p.plus(1),l,1),m=D(f.times(f),l,1),r=a=1;else return D(c,g.precision=w,A,j=!0);else return g.precision=w,c;c=u,r+=2}}function fr(i){return String(i.s*i.s/0)}function si(i,e){var t,n,r;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(t<0&&(t=n),t+=+e.slice(n+1),e=e.substring(0,n)):t<0&&(t=e.length),n=0;e.charCodeAt(n)===48;n++);for(r=e.length;e.charCodeAt(r-1)===48;--r);if(e=e.slice(n,r),e){if(r-=n,i.e=t=t-n-1,i.d=[],n=(t+1)%z,t<0&&(n+=z),n<r){for(n&&i.d.push(+e.slice(0,n)),r-=z;n<r;)i.d.push(+e.slice(n,n+=z));e=e.slice(n),n=z-e.length}else n-=r;for(;n--;)e+="0";i.d.push(+e),j&&(i.e>i.constructor.maxE?(i.d=null,i.e=NaN):i.e<i.constructor.minE&&(i.e=0,i.d=[0]))}else i.e=0,i.d=[0];return i}function $o(i,e){var t,n,r,o,s,a,c,u,l;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),lr.test(e))return si(i,e)}else if(e==="Infinity"||e==="NaN")return+e||(i.s=NaN),i.e=NaN,i.d=null,i;if(Ho.test(e))t=16,e=e.toLowerCase();else if(Qo.test(e))t=2;else if(jo.test(e))t=8;else throw Error(Pt+e);for(o=e.search(/p/i),o>0?(c=+e.slice(o+1),e=e.substring(2,o)):e=e.slice(2),o=e.indexOf("."),s=o>=0,n=i.constructor,s&&(e=e.replace(".",""),a=e.length,o=a-o,r=pr(n,new n(t),o,o*2)),u=wn(e,t,He),l=u.length-1,o=l;u[o]===0;--o)u.pop();return o<0?new n(i.s*0):(i.e=xn(u,l),i.d=u,j=!1,s&&(i=pe(i,r,a*4)),c&&(i=i.times(Math.abs(c)<54?Ie(2,c):$t.pow(2,c))),j=!0,i)}function es(i,e){var t,n=e.d.length;if(n<3)return e.isZero()?e:_t(i,2,e,e);t=1.4*Math.sqrt(n),t=t>16?16:t|0,e=e.times(1/Sn(5,t)),e=_t(i,2,e,e);for(var r,o=new i(5),s=new i(16),a=new i(20);t--;)r=e.times(e),e=e.times(o.plus(r.times(s.times(r).minus(a))));return e}function _t(i,e,t,n,r){var o,s,a,c,u=1,l=i.precision,p=Math.ceil(l/z);for(j=!1,c=t.times(t),a=new i(n);;){if(s=pe(a.times(c),new i(e++*e++),l,1),a=r?n.plus(s):n.minus(s),n=pe(s.times(c),new i(e++*e++),l,1),s=a.plus(n),s.d[p]!==void 0){for(o=p;s.d[o]===a.d[o]&&o--;);if(o==-1)break}o=a,a=n,n=s,s=o,u++}return j=!0,s.d.length=p+1,s}function Sn(i,e){for(var t=i;--e;)t*=i;return t}function br(i,e){var t,n=e.s<0,r=Qe(i,i.precision,1),o=r.times(.5);if(e=e.abs(),e.lte(o))return ut=n?4:1,e;if(t=e.divToInt(r),t.isZero())ut=n?3:2;else{if(e=e.minus(t.times(r)),e.lte(o))return ut=ir(t)?n?2:3:n?4:1,e;ut=ir(t)?n?1:4:n?3:2}return e.minus(r).abs()}function ai(i,e,t,n){var r,o,s,a,c,u,l,p,m,d=i.constructor,b=t!==void 0;if(b?(Oe(t,1,kt),n===void 0?n=d.rounding:Oe(n,0,8)):(t=d.precision,n=d.rounding),!i.isFinite())l=fr(i);else{for(l=tt(i),s=l.indexOf("."),b?(r=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):r=e,s>=0&&(l=l.replace(".",""),m=new d(1),m.e=l.length-s,m.d=wn(tt(m),10,r),m.e=m.d.length),p=wn(l,10,r),o=c=p.length;p[--c]==0;)p.pop();if(!p[0])l=b?"0p+0":"0";else{if(s<0?o--:(i=new d(i),i.d=p,i.e=o,i=pe(i,m,t,n,0,r),p=i.d,o=i.e,u=sr),s=p[t],a=r/2,u=u||p[t+1]!==void 0,u=n<4?(s!==void 0||u)&&(n===0||n===(i.s<0?3:2)):s>a||s===a&&(n===4||u||n===6&&p[t-1]&1||n===(i.s<0?8:7)),p.length=t,u)for(;++p[--t]>r-1;)p[t]=0,t||(++o,p.unshift(1));for(c=p.length;!p[c-1];--c);for(s=0,l="";s<c;s++)l+=ni.charAt(p[s]);if(b){if(c>1)if(e==16||e==8){for(s=e==16?4:3,--c;c%s;c++)l+="0";for(p=wn(l,r,e),c=p.length;!p[c-1];--c);for(s=1,l="1.";s<c;s++)l+=ni.charAt(p[s])}else l=l.charAt(0)+"."+l.slice(1);l=l+(o<0?"p":"p+")+o}else if(o<0){for(;++o;)l="0"+l;l="0."+l}else if(++o>c)for(o-=c;o--;)l+="0";else o<c&&(l=l.slice(0,o)+"."+l.slice(o))}l=(e==16?"0x":e==2?"0b":e==8?"0o":"")+l}return i.s<0?"-"+l:l}function rr(i,e){if(i.length>e)return i.length=e,!0}function ts(i){return new this(i).abs()}function ns(i){return new this(i).acos()}function is(i){return new this(i).acosh()}function rs(i,e){return new this(i).plus(e)}function os(i){return new this(i).asin()}function ss(i){return new this(i).asinh()}function as(i){return new this(i).atan()}function us(i){return new this(i).atanh()}function cs(i,e){i=new this(i),e=new this(e);var t,n=this.precision,r=this.rounding,o=n+4;return!i.s||!e.s?t=new this(NaN):!i.d&&!e.d?(t=Qe(this,o,1).times(e.s>0?.25:.75),t.s=i.s):!e.d||i.isZero()?(t=e.s<0?Qe(this,n,r):new this(0),t.s=i.s):!i.d||e.isZero()?(t=Qe(this,o,1).times(.5),t.s=i.s):e.s<0?(this.precision=o,this.rounding=1,t=this.atan(pe(i,e,o,1)),e=Qe(this,o,1),this.precision=n,this.rounding=r,t=i.s<0?t.minus(e):t.plus(e)):t=this.atan(pe(i,e,o,1)),t}function ls(i){return new this(i).cbrt()}function ms(i){return D(i=new this(i),i.e+1,2)}function ps(i,e,t){return new this(i).clamp(e,t)}function ds(i){if(!i||typeof i!="object")throw Error(In+"Object expected");var e,t,n,r=i.defaults===!0,o=["precision",1,kt,"rounding",0,8,"toExpNeg",-Wt,0,"toExpPos",0,Wt,"maxE",0,Wt,"minE",-Wt,0,"modulo",0,9];for(e=0;e<o.length;e+=3)if(t=o[e],r&&(this[t]=ii[t]),(n=i[t])!==void 0)if(Ne(n)===n&&n>=o[e+1]&&n<=o[e+2])this[t]=n;else throw Error(Pt+t+": "+n);if(t="crypto",r&&(this[t]=ii[t]),(n=i[t])!==void 0)if(n===!0||n===!1||n===0||n===1)if(n)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(ur);else this[t]=!1;else throw Error(Pt+t+": "+n);return this}function fs(i){return new this(i).cos()}function bs(i){return new this(i).cosh()}function yr(i){var e,t,n;function r(o){var s,a,c,u=this;if(!(u instanceof r))return new r(o);if(u.constructor=r,or(o)){u.s=o.s,j?!o.d||o.e>r.maxE?(u.e=NaN,u.d=null):o.e<r.minE?(u.e=0,u.d=[0]):(u.e=o.e,u.d=o.d.slice()):(u.e=o.e,u.d=o.d?o.d.slice():o.d);return}if(c=typeof o,c==="number"){if(o===0){u.s=1/o<0?-1:1,u.e=0,u.d=[0];return}if(o<0?(o=-o,u.s=-1):u.s=1,o===~~o&&o<1e7){for(s=0,a=o;a>=10;a/=10)s++;j?s>r.maxE?(u.e=NaN,u.d=null):s<r.minE?(u.e=0,u.d=[0]):(u.e=s,u.d=[o]):(u.e=s,u.d=[o]);return}else if(o*0!==0){o||(u.s=NaN),u.e=NaN,u.d=null;return}return si(u,o.toString())}else if(c!=="string")throw Error(Pt+o);return(a=o.charCodeAt(0))===45?(o=o.slice(1),u.s=-1):(a===43&&(o=o.slice(1)),u.s=1),lr.test(o)?si(u,o):$o(u,o)}if(r.prototype=K,r.ROUND_UP=0,r.ROUND_DOWN=1,r.ROUND_CEIL=2,r.ROUND_FLOOR=3,r.ROUND_HALF_UP=4,r.ROUND_HALF_DOWN=5,r.ROUND_HALF_EVEN=6,r.ROUND_HALF_CEIL=7,r.ROUND_HALF_FLOOR=8,r.EUCLID=9,r.config=r.set=ds,r.clone=yr,r.isDecimal=or,r.abs=ts,r.acos=ns,r.acosh=is,r.add=rs,r.asin=os,r.asinh=ss,r.atan=as,r.atanh=us,r.atan2=cs,r.cbrt=ls,r.ceil=ms,r.clamp=ps,r.cos=fs,r.cosh=bs,r.div=ys,r.exp=gs,r.floor=Ps,r.hypot=ks,r.ln=As,r.log=ws,r.log10=Ts,r.log2=hs,r.max=Bs,r.min=Is,r.mod=xs,r.mul=Ss,r.pow=Ks,r.random=Cs,r.round=Ns,r.sign=Ls,r.sin=Rs,r.sinh=Ms,r.sqrt=Os,r.sub=Es,r.sum=vs,r.tan=Fs,r.tanh=Ws,r.trunc=_s,i===void 0&&(i={}),i&&i.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<n.length;)i.hasOwnProperty(t=n[e++])||(i[t]=this[t]);return r.config(i),r}function ys(i,e){return new this(i).div(e)}function gs(i){return new this(i).exp()}function Ps(i){return D(i=new this(i),i.e+1,3)}function ks(){var i,e,t=new this(0);for(j=!1,i=0;i<arguments.length;)if(e=new this(arguments[i++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return j=!0,new this(1/0);t=e}return j=!0,t.sqrt()}function or(i){return i instanceof $t||i&&i.toStringTag===cr||!1}function As(i){return new this(i).ln()}function ws(i,e){return new this(i).log(e)}function hs(i){return new this(i).log(2)}function Ts(i){return new this(i).log(10)}function Bs(){return dr(this,arguments,"lt")}function Is(){return dr(this,arguments,"gt")}function xs(i,e){return new this(i).mod(e)}function Ss(i,e){return new this(i).mul(e)}function Ks(i,e){return new this(i).pow(e)}function Cs(i){var e,t,n,r,o=0,s=new this(1),a=[];if(i===void 0?i=this.precision:Oe(i,1,kt),n=Math.ceil(i/z),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(n));o<n;)r=e[o],r>=429e7?e[o]=crypto.getRandomValues(new Uint32Array(1))[0]:a[o++]=r%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(n*=4);o<n;)r=e[o]+(e[o+1]<<8)+(e[o+2]<<16)+((e[o+3]&127)<<24),r>=214e7?crypto.randomBytes(4).copy(e,o):(a.push(r%1e7),o+=4);o=n/4}else throw Error(ur);else for(;o<n;)a[o++]=Math.random()*1e7|0;for(n=a[--o],i%=z,n&&i&&(r=Ie(10,z-i),a[o]=(n/r|0)*r);a[o]===0;o--)a.pop();if(o<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=z)a.shift();for(n=1,r=a[0];r>=10;r/=10)n++;n<z&&(t-=z-n)}return s.e=t,s.d=a,s}function Ns(i){return D(i=new this(i),i.e+1,this.rounding)}function Ls(i){return i=new this(i),i.d?i.d[0]?i.s:0*i.s:i.s||NaN}function Rs(i){return new this(i).sin()}function Ms(i){return new this(i).sinh()}function Os(i){return new this(i).sqrt()}function Es(i,e){return new this(i).sub(e)}function vs(){var i=0,e=arguments,t=new this(e[i]);for(j=!1;t.s&&++i<e.length;)t=t.plus(e[i]);return j=!0,D(t,this.precision,this.rounding)}function Fs(i){return new this(i).tan()}function Ws(i){return new this(i).tanh()}function _s(i){return D(i=new this(i),i.e+1,1)}K[Symbol.for("nodejs.util.inspect.custom")]=K.toString;K[Symbol.toStringTag]="Decimal";var $t=K.constructor=yr(ii);hn=new $t(hn);Tn=new $t(Tn);var v=$t;var mi=require("@solana/web3.js");var en=require("lodash");var ui=class{constructor(e){this.logLevel=e.logLevel!==void 0?e.logLevel:0,this.name=e.name}set level(e){this.logLevel=e}get time(){return Date.now().toString()}get moduleName(){return this.name}isLogLevel(e){return e<=this.logLevel}error(...e){return this.isLogLevel(0)?(console.error(this.time,this.name,"sdk logger error",...e),this):this}logWithError(...e){let t=e.map(n=>typeof n=="object"?JSON.stringify(n):n).join(", ");throw new Error(t)}warning(...e){return this.isLogLevel(1)?(console.warn(this.time,this.name,"sdk logger warning",...e),this):this}info(...e){return this.isLogLevel(2)?(console.info(this.time,this.name,"sdk logger info",...e),this):this}debug(...e){return this.isLogLevel(3)?(console.debug(this.time,this.name,"sdk logger debug",...e),this):this}},gr={},Vs={};function de(i){let e=(0,en.get)(gr,i);if(!e){let t=(0,en.get)(Vs,i);e=new ui({name:i,logLevel:t}),(0,en.set)(gr,i,e)}return e}var At=require("@solana/spl-token"),ci=de("Raydium_accountInfo_util");async function ct(i,e,t){let{batchRequest:n,commitment:r="confirmed",chunkCount:o=100}=G({batchRequest:!1},t),s=li(e,o),a=new Array(s.length).fill([]);if(n){let c=s.map(p=>{let m=i._buildArgs([p.map(d=>d.toBase58())],r,"base64");return{methodName:"getMultipleAccounts",args:m}}),u=li(c,10);a=(await(await Promise.all(u.map(async p=>await i._rpcBatchRequest(p)))).flat()).map(p=>(p.error&&ci.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${p.error.message}`),p.result.value.map(m=>{if(m){let{data:d,executable:b,lamports:f,owner:y,rentEpoch:g}=m;return d.length!==2&&d[1]!=="base64"&&ci.logWithError("info must be base64 encoded, RPC_ERROR"),{data:Buffer.from(d[0],"base64"),executable:b,lamports:f,owner:new mi.PublicKey(y),rentEpoch:g}}return null})))}else try{a=await Promise.all(s.map(c=>i.getMultipleAccountsInfo(c,r)))}catch(c){c instanceof Error&&ci.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${c.message}`)}return a.flat()}async function Ct(i,e,t){let n=await ct(i,e.map(r=>r.pubkey),t);return e.map((r,o)=>J(G({},r),{accountInfo:n[o]}))}async function pi({connection:i,mints:e,config:t}){var o,s,a;if(e.length===0)return{};let n=await Ct(i,e.map(c=>({pubkey:nt(c)})),t),r={};for(let c of n){if(!c.accountInfo||c.accountInfo.data.length<At.MINT_SIZE){console.log("invalid mint account",c.pubkey.toBase58());continue}let u=(0,At.unpackMint)(c.pubkey,c.accountInfo,(o=c.accountInfo)==null?void 0:o.owner);r[c.pubkey.toString()]=J(G({},u),{programId:((s=c.accountInfo)==null?void 0:s.owner)||At.TOKEN_PROGRAM_ID,feeConfig:(a=(0,At.getTransferFeeConfig)(u))!=null?a:void 0})}return r[mi.PublicKey.default.toBase58()]=r[je.toBase58()],r}var ot=le(require("bn.js"));var Tr=le(require("big.js")),on=le(require("bn.js"));var Pr=le(require("toformat")),Ds=Pr.default,tn=Ds;var nn=le(require("big.js")),Ar=le(require("bn.js")),wr=le(require("decimal.js-light"));var Vt=le(require("bn.js"));var kr=9007199254740991;function fe(i){let e=de("Raydium_parseBigNumberish");if(i instanceof Vt.default)return i;if(typeof i=="string"){if(i.match(/^-?[0-9]+$/))return new Vt.default(i);e.logWithError(`invalid BigNumberish string: ${i}`)}return typeof i=="number"?(i%1&&e.logWithError(`BigNumberish number underflow: ${i}`),(i>=kr||i<=-kr)&&e.logWithError(`BigNumberish number overflow: ${i}`),new Vt.default(String(i))):typeof i=="bigint"?new Vt.default(i.toString()):(e.error(`invalid BigNumberish value: ${i}`),new Vt.default(0))}var Kn=de("module/fraction"),di=tn(nn.default),rn=tn(wr.default),Gs={[0]:rn.ROUND_DOWN,[1]:rn.ROUND_HALF_UP,[2]:rn.ROUND_UP},Us={[0]:nn.default.roundDown,[1]:nn.default.roundHalfUp,[2]:nn.default.roundUp},se=class{constructor(e,t=new Ar.default(1)){this.numerator=fe(e),this.denominator=fe(t)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new se(this.denominator,this.numerator)}add(e){let t=e instanceof se?e:new se(fe(e));return this.denominator.eq(t.denominator)?new se(this.numerator.add(t.numerator),this.denominator):new se(this.numerator.mul(t.denominator).add(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}sub(e){let t=e instanceof se?e:new se(fe(e));return this.denominator.eq(t.denominator)?new se(this.numerator.sub(t.numerator),this.denominator):new se(this.numerator.mul(t.denominator).sub(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}mul(e){let t=e instanceof se?e:new se(fe(e));return new se(this.numerator.mul(t.numerator),this.denominator.mul(t.denominator))}div(e){let t=e instanceof se?e:new se(fe(e));return new se(this.numerator.mul(t.denominator),this.denominator.mul(t.numerator))}toSignificant(e,t={groupSeparator:""},n=1){Number.isInteger(e)||Kn.logWithError(`${e} is not an integer.`),e<=0&&Kn.logWithError(`${e} is not positive.`),rn.set({precision:e+1,rounding:Gs[n]});let r=new rn(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(e);return r.toFormat(r.decimalPlaces(),t)}toFixed(e,t={groupSeparator:""},n=1){return Number.isInteger(e)||Kn.logWithError(`${e} is not an integer.`),e<0&&Kn.logWithError(`${e} is negative.`),di.DP=e,di.RM=Us[n]||1,new di(this.numerator.toString()).div(this.denominator.toString()).toFormat(e,t)}isZero(){return this.numerator.isZero()}};var Xs=de("Raydium_amount"),hr=tn(Tr.default);function zs(i,e){let t="0",n="0";if(i.includes(".")){let r=i.split(".");r.length===2?([t,n]=r,n=n.padEnd(e,"0")):Xs.logWithError(`invalid number string, num: ${i}`)}else t=i;return[t,n.slice(0,e)||n]}var ye=class extends se{constructor(t,n,r=!0,o){let s=new on.default(0),a=fi.pow(new on.default(t.decimals));if(r)s=fe(n);else{let c=new on.default(0),u=new on.default(0);if(typeof n=="string"||typeof n=="number"||typeof n=="bigint"){let[l,p]=zs(n.toString(),t.decimals);c=fe(l),u=fe(p)}c=c.mul(a),s=c.add(u)}super(s,a);this.logger=de(o||"TokenAmount"),this.token=t}get raw(){return this.numerator}isZero(){return this.raw.isZero()}gt(t){return this.token.equals(t.token)||this.logger.logWithError("gt token not equals"),this.raw.gt(t.raw)}lt(t){return this.token.equals(t.token)||this.logger.logWithError("lt token not equals"),this.raw.lt(t.raw)}add(t){return this.token.equals(t.token)||this.logger.logWithError("add token not equals"),new ye(this.token,this.raw.add(t.raw))}subtract(t){return this.token.equals(t.token)||this.logger.logWithError("sub token not equals"),new ye(this.token,this.raw.sub(t.raw))}toSignificant(t=this.token.decimals,n,r=0){return super.toSignificant(t,n,r)}toFixed(t=this.token.decimals,n,r=0){return t>this.token.decimals&&this.logger.logWithError("decimals overflow"),super.toFixed(t,n,r)}toExact(t={groupSeparator:""}){return hr.DP=this.token.decimals,new hr(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)}};var Br=require("@solana/web3.js"),bi=require("@solana/spl-token"),yi={chainId:101,address:Br.PublicKey.default.toBase58(),programId:bi.TOKEN_PROGRAM_ID.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"https://img-v1.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}},it={chainId:101,address:"So11111111111111111111111111111111111111112",programId:bi.TOKEN_PROGRAM_ID.toBase58(),decimals:9,symbol:"WSOL",name:"Wrapped SOL",logoURI:"https://img-v1.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}};var Nn=require("@solana/web3.js");var me=require("@solana/web3.js"),Ir=require("@solana/spl-token");function C({pubkey:i,isSigner:e=!1,isWritable:t=!0}){return{pubkey:i,isWritable:t,isSigner:e}}var Nu=[C({pubkey:Ir.TOKEN_PROGRAM_ID,isWritable:!1}),C({pubkey:me.SystemProgram.programId,isWritable:!1}),C({pubkey:me.SYSVAR_RENT_PUBKEY,isWritable:!1})];function gi({publicKey:i,transformSol:e}){let t=Pi(i.toString());if(t instanceof me.PublicKey)return e&&t.equals(sn)?je:t;if(e&&t.toString()===sn.toBase58())return je;if(typeof t=="string"){if(t===me.PublicKey.default.toBase58())return me.PublicKey.default;try{return new me.PublicKey(t)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function Pi(i){try{return new me.PublicKey(i)}catch{return i}}var Cn=new me.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),Dt=new me.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),rt=new me.PublicKey("SysvarRent111111111111111111111111111111111"),Lu=new me.PublicKey("SysvarC1ock11111111111111111111111111111111"),wt=new me.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),Ru=new me.PublicKey("Sysvar1nstructions1111111111111111111111111"),Qs=me.SystemProgram.programId,Mu=new me.PublicKey("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),Ou=new me.PublicKey("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),Eu=new me.PublicKey("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),vu=new me.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),Fu=new me.PublicKey("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),Wu=new me.PublicKey("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),_u=new me.PublicKey("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),Vu=new me.PublicKey("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),Du=new me.PublicKey("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),qu=new me.PublicKey("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),Gu=new me.PublicKey("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),je=new me.PublicKey("So11111111111111111111111111111111111111112"),sn=me.PublicKey.default;function nt(i){return gi({publicKey:i,transformSol:!0})}var ki=class{constructor({mint:e,decimals:t,symbol:n,name:r,skipMint:o=!1,isToken2022:s=!1}){if(e===sn.toBase58()||e instanceof Nn.PublicKey&&sn.equals(e)){this.decimals=it.decimals,this.symbol=it.symbol,this.name=it.name,this.mint=new Nn.PublicKey(it.address),this.isToken2022=!1;return}this.decimals=t,this.symbol=n||e.toString().substring(0,6),this.name=r||e.toString().substring(0,6),this.mint=o?Nn.PublicKey.default:gi({publicKey:e}),this.isToken2022=s}equals(e){return this===e?!0:this.mint.equals(e.mint)}},We=ki;We.WSOL=new ki(J(G({},it),{mint:it.address}));var Ai=class{constructor({decimals:e,symbol:t="UNKNOWN",name:n="UNKNOWN"}){this.decimals=e,this.symbol=t,this.name=n}equals(e){return this===e}},Ln=Ai;Ln.SOL=new Ai(yi);var Sr=le(require("bn.js"));var xr=new se(new Sr.default(100)),lt=class extends se{toSignificant(e=5,t,n){return this.mul(xr).toSignificant(e,t,n)}toFixed(e=2,t,n){return this.mul(xr).toFixed(e,t,n)}};var Hs=de("Raydium_price"),Ee=class extends se{constructor(t){let{baseToken:n,quoteToken:r,numerator:o,denominator:s}=t;super(o,s);this.baseToken=n,this.quoteToken=r,this.scalar=new se(wi(n.decimals),wi(r.decimals))}get raw(){return new se(this.numerator,this.denominator)}get adjusted(){return super.mul(this.scalar)}invert(){return new Ee({baseToken:this.quoteToken,quoteToken:this.baseToken,denominator:this.numerator,numerator:this.denominator})}mul(t){this.quoteToken!==t.baseToken&&Hs.logWithError("mul token not equals");let n=super.mul(t);return new Ee({baseToken:this.baseToken,quoteToken:t.quoteToken,denominator:n.denominator,numerator:n.numerator})}toSignificant(t=this.quoteToken.decimals,n,r){return this.adjusted.toSignificant(t,n,r)}toFixed(t=this.quoteToken.decimals,n,r){return this.adjusted.toFixed(t,n,r)}};var Cr=require("@solana/web3.js"),Nr=le(require("bn.js"));function Lr(i){return typeof i=="object"&&i!==null&&![We,ye,Cr.PublicKey,se,Nr.default,Ee,lt].some(e=>typeof e=="object"&&i instanceof e)}function Nt(i){return typeof i=="string"?Pi(i):Array.isArray(i)?i.map(e=>Nt(e)):Lr(i)?Object.fromEntries(Object.entries(i).map(([e,t])=>[e,Nt(t)])):i}var Kr=new ot.default(0),js=new ot.default(1),Mc=new ot.default(2),Oc=new ot.default(3),Ec=new ot.default(5),fi=new ot.default(10),vc=new ot.default(100),Fc=new ot.default(1e3),Wc=new ot.default(1e4);function wi(i){return fi.pow(fe(i))}function li(i,e=1,t=[]){let n=[...i];if(e<=0)return t;for(;n.length;)t.push(n.splice(0,e));return t}var Er=require("@solana/web3.js"),vr=require("@solana/spl-token");var Le=require("@solana/web3.js");var ne={CreateAccount:"CreateAccount",InitAccount:"InitAccount",CreateATA:"CreateATA",CloseAccount:"CloseAccount",TransferAmount:"TransferAmount",InitMint:"InitMint",MintTo:"MintTo",InitMarket:"InitMarket",Util1216OwnerClaim:"Util1216OwnerClaim",SetComputeUnitPrice:"SetComputeUnitPrice",SetComputeUnitLimit:"SetComputeUnitLimit",ClmmCreatePool:"ClmmCreatePool",ClmmOpenPosition:"ClmmOpenPosition",ClmmIncreasePosition:"ClmmIncreasePosition",ClmmDecreasePosition:"ClmmDecreasePosition",ClmmClosePosition:"ClmmClosePosition",ClmmSwapBaseIn:"ClmmSwapBaseIn",ClmmSwapBaseOut:"ClmmSwapBaseOut",ClmmInitReward:"ClmmInitReward",ClmmSetReward:"ClmmSetReward",ClmmCollectReward:"ClmmCollectReward",ClmmLockPosition:"ClmmLockPosition",ClmmHarvestLockPosition:"ClmmHarvestLockPosition",AmmV4Swap:"AmmV4Swap",AmmV4AddLiquidity:"AmmV4AddLiquidity",AmmV4RemoveLiquidity:"AmmV4RemoveLiquidity",AmmV4SimulatePoolInfo:"AmmV4SimulatePoolInfo",AmmV4SwapBaseIn:"AmmV4SwapBaseIn",AmmV4SwapBaseOut:"AmmV4SwapBaseOut",AmmV4CreatePool:"AmmV4CreatePool",AmmV4InitPool:"AmmV4InitPool",AmmV5AddLiquidity:"AmmV5AddLiquidity",AmmV5RemoveLiquidity:"AmmV5RemoveLiquidity",AmmV5SimulatePoolInfo:"AmmV5SimulatePoolInfo",AmmV5SwapBaseIn:"AmmV5SwapBaseIn",AmmV5SwapBaseOut:"AmmV5SwapBaseOut",RouteSwap:"RouteSwap",RouteSwap1:"RouteSwap1",RouteSwap2:"RouteSwap2",FarmV3Deposit:"FarmV3Deposit",FarmV3Withdraw:"FarmV3Withdraw",FarmV3CreateLedger:"FarmV3CreateLedger",FarmV4Withdraw:"FarmV4Withdraw",FarmV5Deposit:"FarmV5Deposit",FarmV5Withdraw:"FarmV5Withdraw",FarmV5CreateLedger:"FarmV5CreateLedger",FarmV6Deposit:"FarmV6Deposit",FarmV6Withdraw:"FarmV6Withdraw",FarmV6Create:"FarmV6Create",FarmV6Restart:"FarmV6Restart",FarmV6CreatorAddReward:"FarmV6CreatorAddReward",FarmV6CreatorWithdraw:"FarmV6CreatorWithdraw",CpmmCreatePool:"CpmmCreatePool",CpmmAddLiquidity:"CpmmAddLiquidity",CpmmWithdrawLiquidity:"CpmmWithdrawLiquidity",CpmmSwapBaseIn:"CpmmSwapBaseIn",CpmmSwapBaseOut:"CpmmSwapBaseOut",CpmmLockLp:"CpmmLockLp",CpmmCollectLockFee:"CpmmCollectLockFee",TransferTip:"TransferTip"};var Mr=require("@solana/spl-token"),Rr=de("Raydium_txUtil"),Or=1644;function Rn(i){let e=[],t=[];return i.microLamports&&(e.push(Le.ComputeBudgetProgram.setComputeUnitPrice({microLamports:i.microLamports})),t.push(ne.SetComputeUnitPrice)),i.units&&(e.push(Le.ComputeBudgetProgram.setComputeUnitLimit({units:i.units})),t.push(ne.SetComputeUnitLimit)),{instructions:e,instructionTypes:t}}async function qt(i,e){var n,r;let t=e!=null?e:"confirmed";return(r=await((n=i.getLatestBlockhash)==null?void 0:n.call(i,{commitment:t})))==null?void 0:r.blockhash}async function Mn(i,e){return i.getSignatureStatuses([e]),new Promise((t,n)=>{let r=setTimeout(n,6e4);i.onSignature(e,o=>{if(clearTimeout(r),!o.err){t("");return}n(Object.assign(o.err,{txId:e}))},"confirmed")})}function Zs(i,e){i.length<1&&Rr.logWithError(`no instructions provided: ${i.toString()}`),e.length<1&&Rr.logWithError(`no signers provided:, ${e.toString()}`);let t=new Le.Transaction;t.recentBlockhash="11111111111111111111111111111111",t.feePayer=e[0],t.add(...i);try{return Buffer.from(t.serialize({verifySignatures:!1})).toString("base64").length<Or}catch{return!1}}function he(i,e){let[t,n]=Le.PublicKey.findProgramAddressSync(i,e);return{publicKey:t,nonce:n}}function an({instructions:i,payer:e,signers:t}){return Zs(i,[e,...t])}function un({instructions:i,payer:e,lookupTableAddressAccount:t,recentBlockhash:n=Le.Keypair.generate().publicKey.toString()}){let o=new Le.TransactionMessage({payerKey:e,recentBlockhash:n,instructions:i}).compileToV0Message(Object.values(t!=null?t:{}));try{return Buffer.from(new Le.VersionedTransaction(o).serialize()).toString("base64").length<Or}catch{return!1}}var Ys=i=>Buffer.isBuffer(i)?i:i instanceof Uint8Array?Buffer.from(i.buffer,i.byteOffset,i.byteLength):Buffer.from(i),Js=i=>{let e=i.serialize({requireAllSignatures:!1,verifySignatures:!1});i instanceof Le.VersionedTransaction&&(e=Ys(e));try{return e instanceof Buffer?e.toString("base64"):Buffer.from(e).toString("base64")}catch{return e.toString("base64")}};function Lt(i){let e=[];return i.forEach(t=>{t instanceof Le.Transaction&&(t.recentBlockhash||(t.recentBlockhash=Mr.TOKEN_PROGRAM_ID.toBase58()),t.feePayer||(t.feePayer=Le.Keypair.generate().publicKey)),e.push(Js(t))}),console.log("simulate tx string:",e),e}function ge(i,e,t){return he([i.toBuffer(),(t!=null?t:vr.TOKEN_PROGRAM_ID).toBuffer(),e.toBuffer()],new Er.PublicKey("ATokenGPvbdGVxr1b2h