test-raydium-sdk-v2
Version:
An SDK for building applications on top of Raydium.
1 lines • 158 kB
JavaScript
var mr=Object.defineProperty,fr=Object.defineProperties;var pr=Object.getOwnPropertyDescriptors;var Xt=Object.getOwnPropertySymbols;var ri=Object.prototype.hasOwnProperty,oi=Object.prototype.propertyIsEnumerable;var ii=(i,e,t)=>e in i?mr(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,q=(i,e)=>{for(var t in e||(e={}))ri.call(e,t)&&ii(i,t,e[t]);if(Xt)for(var t of Xt(e))oi.call(e,t)&&ii(i,t,e[t]);return i},ee=(i,e)=>fr(i,pr(e));var zt=(i,e)=>{var t={};for(var n in i)ri.call(i,n)&&e.indexOf(n)<0&&(t[n]=i[n]);if(i!=null&&Xt)for(var n of Xt(i))e.indexOf(n)<0&&oi.call(i,n)&&(t[n]=i[n]);return t};import{PublicKey as G}from"@solana/web3.js";var wt=9e15,nt=1e9,hn="0123456789abcdef",jt="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Zt="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",An={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-wt,maxE:wt,crypto:!1},ui,He,O=!0,Qt="[DecimalError] ",tt=Qt+"Invalid argument: ",li=Qt+"Precision limit exceeded",di=Qt+"crypto unavailable",mi="[object Decimal]",Ae=Math.floor,ue=Math.pow,gr=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,br=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,yr=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,fi=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Oe=1e7,C=7,wr=9007199254740991,hr=jt.length-1,kn=Zt.length-1,P={toStringTag:mi};P.absoluteValue=P.abs=function(){var i=new this.constructor(this);return i.s<0&&(i.s=1),N(i)};P.ceil=function(){return N(new this.constructor(this),this.e+1,2)};P.clampedTo=P.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(tt+e);return t=n.cmp(i),t<0?i:n.cmp(e)>0?e:new r(n)};P.comparedTo=P.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};P.cosine=P.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())+C,n.rounding=1,t=Ar(n,wi(n,t)),n.precision=i,n.rounding=e,N(He==2||He==3?t.neg():t,i,e,!0)):new n(1):new n(NaN)};P.cubeRoot=P.cbrt=function(){var i,e,t,n,r,o,s,a,c,u,l=this,d=l.constructor;if(!l.isFinite()||l.isZero())return new d(l);for(O=!1,o=l.s*ue(l.s*l,1/3),!o||Math.abs(o)==1/0?(t=ge(l.d),i=l.e,(o=(i-t.length+1)%3)&&(t+=o==1||o==-2?"0":"00"),o=ue(t,1/3),i=Ae((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 d(t),n.s=l.s):n=new d(o.toString()),s=(i=d.precision)+3;;)if(a=n,c=a.times(a).times(a),u=c.plus(l),n=Z(u.plus(l).times(a),u.plus(c),s+2,1),ge(a.d).slice(0,s)===(t=ge(n.d)).slice(0,s))if(t=t.slice(s-3,s+1),t=="9999"||!r&&t=="4999"){if(!r&&(N(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")&&(N(n,i+1,1),e=!n.times(n).times(n).eq(l));break}return O=!0,N(n,i,d.rounding,e)};P.decimalPlaces=P.dp=function(){var i,e=this.d,t=NaN;if(e){if(i=e.length-1,t=(i-Ae(this.e/C))*C,i=e[i],i)for(;i%10==0;i/=10)t--;t<0&&(t=0)}return t};P.dividedBy=P.div=function(i){return Z(this,new this.constructor(i))};P.dividedToIntegerBy=P.divToInt=function(i){var e=this,t=e.constructor;return N(Z(e,new t(i),0,1,1),t.precision,t.rounding)};P.equals=P.eq=function(i){return this.cmp(i)===0};P.floor=function(){return N(new this.constructor(this),this.e+1,3)};P.greaterThan=P.gt=function(i){return this.cmp(i)>0};P.greaterThanOrEqualTo=P.gte=function(i){var e=this.cmp(i);return e==1||e===0};P.hyperbolicCosine=P.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/Jt(4,i)).toString()):(i=16,e="2.3283064365386962890625e-10"),o=ht(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 N(o,s.precision=t,s.rounding=n,!0)};P.hyperbolicSine=P.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=ht(o,2,r,r,!0);else{i=1.4*Math.sqrt(n),i=i>16?16:i|0,r=r.times(1/Jt(5,i)),r=ht(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,N(r,e,t,!0)};P.hyperbolicTangent=P.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,Z(t.sinh(),t.cosh(),n.precision=i,n.rounding=e)):new n(t.s)};P.inverseCosine=P.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()?Ee(t,r,o):new t(0):new t(NaN):e.isZero()?Ee(t,r+4,o).times(.5):(t.precision=r+6,t.rounding=1,e=e.asin(),i=Ee(t,r+4,o).times(.5),t.precision=r,t.rounding=o,i.minus(e))};P.inverseHyperbolicCosine=P.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,O=!1,t=t.times(t).minus(1).sqrt().plus(t),O=!0,n.precision=i,n.rounding=e,t.ln()):new n(t)};P.inverseHyperbolicSine=P.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,O=!1,t=t.times(t).plus(1).sqrt().plus(t),O=!0,n.precision=i,n.rounding=e,t.ln())};P.inverseHyperbolicTangent=P.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?N(new o(r),i,e,!0):(o.precision=t=n-r.e,r=Z(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)};P.inverseSine=P.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=Ee(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)))};P.inverseTangent=P.atan=function(){var i,e,t,n,r,o,s,a,c,u=this,l=u.constructor,d=l.precision,m=l.rounding;if(u.isFinite()){if(u.isZero())return new l(u);if(u.abs().eq(1)&&d+4<=kn)return s=Ee(l,d+4,m).times(.25),s.s=u.s,s}else{if(!u.s)return new l(NaN);if(d+4<=kn)return s=Ee(l,d+4,m).times(.5),s.s=u.s,s}for(l.precision=a=d+10,l.rounding=1,t=Math.min(28,a/C+2|0),i=t;i;--i)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(O=!1,e=Math.ceil(a/C),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)),O=!0,N(s,l.precision=d,l.rounding=m,!0)};P.isFinite=function(){return!!this.d};P.isInteger=P.isInt=function(){return!!this.d&&Ae(this.e/C)>this.d.length-2};P.isNaN=function(){return!this.s};P.isNegative=P.isNeg=function(){return this.s<0};P.isPositive=P.isPos=function(){return this.s>0};P.isZero=function(){return!!this.d&&this.d[0]===0};P.lessThan=P.lt=function(i){return this.cmp(i)<0};P.lessThanOrEqualTo=P.lte=function(i){return this.cmp(i)<1};P.logarithm=P.log=function(i){var e,t,n,r,o,s,a,c,u=this,l=u.constructor,d=l.precision,m=l.rounding,f=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(O=!1,a=d+f,s=et(u,a),n=e?Yt(l,a+10):et(i,a),c=Z(s,n,a,1),It(c.d,r=d,m))do if(a+=10,s=et(u,a),n=e?Yt(l,a+10):et(i,a),c=Z(s,n,a,1),!o){+ge(c.d).slice(r+1,r+15)+1==1e14&&(c=N(c,d+1,0));break}while(It(c.d,r+=10,m));return O=!0,N(c,d,m)};P.minus=P.sub=function(i){var e,t,n,r,o,s,a,c,u,l,d,m,f=this,g=f.constructor;if(i=new g(i),!f.d||!i.d)return!f.s||!i.s?i=new g(NaN):f.d?i.s=-i.s:i=new g(i.d||f.s!==i.s?f:NaN),i;if(f.s!=i.s)return i.s=-i.s,f.plus(i);if(u=f.d,m=i.d,a=g.precision,c=g.rounding,!u[0]||!m[0]){if(m[0])i.s=-i.s;else if(u[0])i=new g(f);else return new g(c===3?-0:0);return O?N(i,a,c):i}if(t=Ae(i.e/C),l=Ae(f.e/C),u=u.slice(),o=l-t,o){for(d=o<0,d?(e=u,o=-o,s=m.length):(e=m,t=l,s=u.length),n=Math.max(Math.ceil(a/C),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,d=n<s,d&&(s=n),n=0;n<s;n++)if(u[n]!=m[n]){d=u[n]<m[n];break}o=0}for(d&&(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]=Oe-1;--u[r],u[n]+=Oe}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=$t(u,t),O?N(i,a,c):i):new g(c===3?-0:0)};P.modulo=P.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]?N(new n(t),n.precision,n.rounding):(O=!1,n.modulo==9?(e=Z(t,i.abs(),0,3,1),e.s*=i.s):e=Z(t,i,0,n.modulo,1),e=e.times(i),O=!0,t.minus(e))};P.naturalExponential=P.exp=function(){return Pn(this)};P.naturalLogarithm=P.ln=function(){return et(this)};P.negated=P.neg=function(){var i=new this.constructor(this);return i.s=-i.s,N(i)};P.plus=P.add=function(i){var e,t,n,r,o,s,a,c,u,l,d=this,m=d.constructor;if(i=new m(i),!d.d||!i.d)return!d.s||!i.s?i=new m(NaN):d.d||(i=new m(i.d||d.s===i.s?d:NaN)),i;if(d.s!=i.s)return i.s=-i.s,d.minus(i);if(u=d.d,l=i.d,a=m.precision,c=m.rounding,!u[0]||!l[0])return l[0]||(i=new m(d)),O?N(i,a,c):i;if(o=Ae(d.e/C),n=Ae(i.e/C),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/C),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)/Oe|0,u[r]%=Oe;for(e&&(u.unshift(e),++n),s=u.length;u[--s]==0;)u.pop();return i.d=u,i.e=$t(u,n),O?N(i,a,c):i};P.precision=P.sd=function(i){var e,t=this;if(i!==void 0&&i!==!!i&&i!==1&&i!==0)throw Error(tt+i);return t.d?(e=pi(t.d),i&&t.e+1>e&&(e=t.e+1)):e=NaN,e};P.round=function(){var i=this,e=i.constructor;return N(new e(i),i.e+1,e.rounding)};P.sine=P.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())+C,n.rounding=1,t=Pr(n,wi(n,t)),n.precision=i,n.rounding=e,N(He>2?t.neg():t,i,e,!0)):new n(NaN)};P.squareRoot=P.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(O=!1,u=Math.sqrt(+s),u==0||u==1/0?(e=ge(a),(e.length+c)%2==0&&(e+="0"),u=Math.sqrt(e),c=Ae((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(Z(s,o,t+2,1)).times(.5),ge(o.d).slice(0,t)===(e=ge(n.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!r&&e=="4999"){if(!r&&(N(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")&&(N(n,c+1,1),i=!n.times(n).eq(s));break}return O=!0,N(n,c,l.rounding,i)};P.tangent=P.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=Z(t,new n(1).minus(t.times(t)).sqrt(),i+10,0),n.precision=i,n.rounding=e,N(He==2||He==4?t.neg():t,i,e,!0)):new n(NaN)};P.times=P.mul=function(i){var e,t,n,r,o,s,a,c,u,l=this,d=l.constructor,m=l.d,f=(i=new d(i)).d;if(i.s*=l.s,!m||!m[0]||!f||!f[0])return new d(!i.s||m&&!m[0]&&!f||f&&!f[0]&&!m?NaN:!m||!f?i.s/0:i.s*0);for(t=Ae(l.e/C)+Ae(i.e/C),c=m.length,u=f.length,c<u&&(o=m,m=f,f=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]+f[n]*m[r-n-1]+e,o[r--]=a%Oe|0,e=a/Oe|0;o[r]=(o[r]+e)%Oe|0}for(;!o[--s];)o.pop();return e?++t:o.shift(),i.d=o,i.e=$t(o,t),O?N(i,d.precision,d.rounding):i};P.toBinary=function(i,e){return xn(this,2,i,e)};P.toDecimalPlaces=P.toDP=function(i,e){var t=this,n=t.constructor;return t=new n(t),i===void 0?t:(Ie(i,0,nt),e===void 0?e=n.rounding:Ie(e,0,8),N(t,i+t.e+1,e))};P.toExponential=function(i,e){var t,n=this,r=n.constructor;return i===void 0?t=We(n,!0):(Ie(i,0,nt),e===void 0?e=r.rounding:Ie(e,0,8),n=N(new r(n),i+1,e),t=We(n,!0,i+1)),n.isNeg()&&!n.isZero()?"-"+t:t};P.toFixed=function(i,e){var t,n,r=this,o=r.constructor;return i===void 0?t=We(r):(Ie(i,0,nt),e===void 0?e=o.rounding:Ie(e,0,8),n=N(new o(r),i+r.e+1,e),t=We(n,!1,i+n.e+1)),r.isNeg()&&!r.isZero()?"-"+t:t};P.toFraction=function(i){var e,t,n,r,o,s,a,c,u,l,d,m,f=this,g=f.d,p=f.constructor;if(!g)return new p(f);if(u=t=new p(1),n=c=new p(0),e=new p(n),o=e.e=pi(g)-f.e-1,s=o%C,e.d[0]=ue(10,s<0?C+s:s),i==null)i=o>0?e:u;else{if(a=new p(i),!a.isInt()||a.lt(u))throw Error(tt+a);i=a.gt(e)?o>0?e:u:a}for(O=!1,a=new p(ge(g)),l=p.precision,p.precision=o=g.length*C*2;d=Z(a,e,0,1,1),r=t.plus(d.times(n)),r.cmp(i)!=1;)t=n,n=r,r=u,u=c.plus(d.times(r)),c=r,r=e,e=a.minus(d.times(r)),a=r;return r=Z(i.minus(t),n,0,1,1),c=c.plus(r.times(u)),t=t.plus(r.times(n)),c.s=u.s=f.s,m=Z(u,n,o,1).minus(f).abs().cmp(Z(c,t,o,1).minus(f).abs())<1?[u,n]:[c,t],p.precision=l,O=!0,m};P.toHexadecimal=P.toHex=function(i,e){return xn(this,16,i,e)};P.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:Ie(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]?(O=!1,t=Z(t,i,0,e,1).times(i),O=!0,N(t)):(i.s=t.s,t=i),t};P.toNumber=function(){return+this};P.toOctal=function(i,e){return xn(this,8,i,e)};P.toPower=P.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(ue(+a,u));if(a=new c(a),a.eq(1))return a;if(n=c.precision,o=c.rounding,i.eq(1))return N(a,n,o);if(e=Ae(i.e/C),e>=i.d.length-1&&(t=u<0?-u:u)<=wr)return r=gi(c,a,t,n),i.s<0?new c(1).div(r):N(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=ue(+a,u),e=t==0||!isFinite(t)?Ae(u*(Math.log("0."+ge(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):(O=!1,c.rounding=a.s=1,t=Math.min(12,(e+"").length),r=Pn(i.times(et(a,n+t)),n),r.d&&(r=N(r,n+5,1),It(r.d,n,o)&&(e=n+10,r=N(Pn(i.times(et(a,e+t)),e),e+5,1),+ge(r.d).slice(n+1,n+15)+1==1e14&&(r=N(r,n+1,0)))),r.s=s,O=!0,c.rounding=o,N(r,n,o))};P.toPrecision=function(i,e){var t,n=this,r=n.constructor;return i===void 0?t=We(n,n.e<=r.toExpNeg||n.e>=r.toExpPos):(Ie(i,1,nt),e===void 0?e=r.rounding:Ie(e,0,8),n=N(new r(n),i,e),t=We(n,i<=n.e||n.e<=r.toExpNeg,i)),n.isNeg()&&!n.isZero()?"-"+t:t};P.toSignificantDigits=P.toSD=function(i,e){var t=this,n=t.constructor;return i===void 0?(i=n.precision,e=n.rounding):(Ie(i,1,nt),e===void 0?e=n.rounding:Ie(e,0,8)),N(new n(t),i,e)};P.toString=function(){var i=this,e=i.constructor,t=We(i,i.e<=e.toExpNeg||i.e>=e.toExpPos);return i.isNeg()&&!i.isZero()?"-"+t:t};P.truncated=P.trunc=function(){return N(new this.constructor(this),this.e+1,1)};P.valueOf=P.toJSON=function(){var i=this,e=i.constructor,t=We(i,i.e<=e.toExpNeg||i.e>=e.toExpPos);return i.isNeg()?"-"+t:t};function ge(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=C-n.length,t&&(o+=Je(t)),o+=n;s=i[e],n=s+"",t=C-n.length,t&&(o+=Je(t))}else if(s===0)return"0";for(;s%10===0;)s/=10;return o+s}function Ie(i,e,t){if(i!==~~i||i<e||i>t)throw Error(tt+i)}function It(i,e,t,n){var r,o,s,a;for(o=i[0];o>=10;o/=10)--e;return--e<0?(e+=C,r=0):(r=Math.ceil((e+1)/C),e%=C),o=ue(10,C-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)==ue(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)==ue(10,e-3)-1,s}function Ht(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]+=hn.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 Ar(i,e){var t,n,r;if(e.isZero())return e;n=e.d.length,n<32?(t=Math.ceil(n/3),r=(1/Jt(4,t)).toString()):(t=16,r="2.3283064365386962890625e-10"),i.precision+=t,e=ht(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 Z=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,d,m,f,g,p,b,y,A,w,k,h,T,B,K,D,W,v,me,oe=n.constructor,Be=n.s==r.s?1:-1,J=n.d,H=r.d;if(!J||!J[0]||!H||!H[0])return new oe(!n.s||!r.s||(J?H&&J[0]==H[0]:!H)?NaN:J&&J[0]==0||!H?Be*0:Be/0);for(c?(f=1,l=n.e-r.e):(c=Oe,f=C,l=Ae(n.e/f)-Ae(r.e/f)),v=H.length,D=J.length,y=new oe(Be),A=y.d=[],d=0;H[d]==(J[d]||0);d++);if(H[d]>(J[d]||0)&&l--,o==null?(T=o=oe.precision,s=oe.rounding):a?T=o+(n.e-r.e)+1:T=o,T<0)A.push(1),g=!0;else{if(T=T/f+2|0,d=0,v==1){for(m=0,H=H[0],T++;(d<D||m)&&T--;d++)B=m*c+(J[d]||0),A[d]=B/H|0,m=B%H|0;g=m||d<D}else{for(m=c/(H[0]+1)|0,m>1&&(H=i(H,m,c),J=i(J,m,c),v=H.length,D=J.length),K=v,w=J.slice(0,v),k=w.length;k<v;)w[k++]=0;me=H.slice(),me.unshift(0),W=H[0],H[1]>=c/2&&++W;do m=0,u=e(H,w,v,k),u<0?(h=w[0],v!=k&&(h=h*c+(w[1]||0)),m=h/W|0,m>1?(m>=c&&(m=c-1),p=i(H,m,c),b=p.length,k=w.length,u=e(p,w,b,k),u==1&&(m--,t(p,v<b?me:H,b,c))):(m==0&&(u=m=1),p=H.slice()),b=p.length,b<k&&p.unshift(0),t(w,p,k,c),u==-1&&(k=w.length,u=e(H,w,v,k),u<1&&(m++,t(w,v<k?me:H,k,c))),k=w.length):u===0&&(m++,w=[0]),A[d++]=m,u&&w[0]?w[k++]=J[K]||0:(w=[J[K]],k=1);while((K++<D||w[0]!==void 0)&&T--);g=w[0]!==void 0}A[0]||A.shift()}if(f==1)y.e=l,ui=g;else{for(d=1,m=A[0];m>=10;m/=10)d++;y.e=d+l*f-1,N(y,a?o+y.e+1:o,s,g)}return y}}();function N(i,e,t,n){var r,o,s,a,c,u,l,d,m,f=i.constructor;e:if(e!=null){if(d=i.d,!d)return i;for(r=1,a=d[0];a>=10;a/=10)r++;if(o=e-r,o<0)o+=C,s=e,l=d[m=0],c=l/ue(10,r-s-1)%10|0;else if(m=Math.ceil((o+1)/C),a=d.length,m>=a)if(n){for(;a++<=m;)d.push(0);l=c=0,r=1,o%=C,s=o-C+1}else break e;else{for(l=a=d[m],r=1;a>=10;a/=10)r++;o%=C,s=o-C+r,c=s<0?0:l/ue(10,r-s-1)%10|0}if(n=n||e<0||d[m+1]!==void 0||(s<0?l:l%ue(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/ue(10,r-s):0:d[m-1])%10&1||t==(i.s<0?8:7)),e<1||!d[0])return d.length=0,u?(e-=i.e+1,d[0]=ue(10,(C-e%C)%C),i.e=-e||0):d[0]=i.e=0,i;if(o==0?(d.length=m,a=1,m--):(d.length=m+1,a=ue(10,C-o),d[m]=s>0?(l/ue(10,r-s)%ue(10,s)|0)*a:0),u)for(;;)if(m==0){for(o=1,s=d[0];s>=10;s/=10)o++;for(s=d[0]+=a,a=1;s>=10;s/=10)a++;o!=a&&(i.e++,d[0]==Oe&&(d[0]=1));break}else{if(d[m]+=a,d[m]!=Oe)break;d[m--]=0,a=1}for(o=d.length;d[--o]===0;)d.pop()}return O&&(i.e>f.maxE?(i.d=null,i.e=NaN):i.e<f.minE&&(i.e=0,i.d=[0])),i}function We(i,e,t){if(!i.isFinite())return yi(i);var n,r=i.e,o=ge(i.d),s=o.length;return e?(t&&(n=t-s)>0?o=o.charAt(0)+"."+o.slice(1)+Je(n):s>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(i.e<0?"e":"e+")+i.e):r<0?(o="0."+Je(-r-1)+o,t&&(n=t-s)>0&&(o+=Je(n))):r>=s?(o+=Je(r+1-s),t&&(n=t-r-1)>0&&(o=o+"."+Je(n))):((n=r+1)<s&&(o=o.slice(0,n)+"."+o.slice(n)),t&&(n=t-s)>0&&(r+1===s&&(o+="."),o+=Je(n))),o}function $t(i,e){var t=i[0];for(e*=C;t>=10;t/=10)e++;return e}function Yt(i,e,t){if(e>hr)throw O=!0,t&&(i.precision=t),Error(li);return N(new i(jt),e,1,!0)}function Ee(i,e,t){if(e>kn)throw Error(li);return N(new i(Zt),e,t,!0)}function pi(i){var e=i.length-1,t=e*C+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 Je(i){for(var e="";i--;)e+="0";return e}function gi(i,e,t,n){var r,o=new i(1),s=Math.ceil(n/C+4);for(O=!1;;){if(t%2&&(o=o.times(e),ai(o.d,s)&&(r=!0)),t=Ae(t/2),t===0){t=o.d.length-1,r&&o.d[t]===0&&++o.d[t];break}e=e.times(e),ai(e.d,s)}return O=!0,o}function si(i){return i.d[i.d.length-1]&1}function bi(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 Pn(i,e){var t,n,r,o,s,a,c,u=0,l=0,d=0,m=i.constructor,f=m.rounding,g=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?(O=!1,c=g):c=e,a=new m(.03125);i.e>-2;)i=i.times(a),d+=5;for(n=Math.log(ue(2,d))/Math.LN10*2+5|0,c+=n,t=o=s=new m(1),m.precision=c;;){if(o=N(o.times(i),c,1),t=t.times(++l),a=s.plus(Z(o,t,c,1)),ge(a.d).slice(0,c)===ge(s.d).slice(0,c)){for(r=d;r--;)s=N(s.times(s),c,1);if(e==null)if(u<3&&It(s.d,c-n,f,u))m.precision=c+=10,t=o=a=new m(1),l=0,u++;else return N(s,m.precision=g,f,O=!0);else return m.precision=g,s}s=a}}function et(i,e){var t,n,r,o,s,a,c,u,l,d,m,f=1,g=10,p=i,b=p.d,y=p.constructor,A=y.rounding,w=y.precision;if(p.s<0||!b||!b[0]||!p.e&&b[0]==1&&b.length==1)return new y(b&&!b[0]?-1/0:p.s!=1?NaN:b?0:p);if(e==null?(O=!1,l=w):l=e,y.precision=l+=g,t=ge(b),n=t.charAt(0),Math.abs(o=p.e)<15e14){for(;n<7&&n!=1||n==1&&t.charAt(1)>3;)p=p.times(i),t=ge(p.d),n=t.charAt(0),f++;o=p.e,n>1?(p=new y("0."+t),o++):p=new y(n+"."+t.slice(1))}else return u=Yt(y,l+2,w).times(o+""),p=et(new y(n+"."+t.slice(1)),l-g).plus(u),y.precision=w,e==null?N(p,w,A,O=!0):p;for(d=p,c=s=p=Z(p.minus(1),p.plus(1),l,1),m=N(p.times(p),l,1),r=3;;){if(s=N(s.times(m),l,1),u=c.plus(Z(s,new y(r),l,1)),ge(u.d).slice(0,l)===ge(c.d).slice(0,l))if(c=c.times(2),o!==0&&(c=c.plus(Yt(y,l+2,w).times(o+""))),c=Z(c,new y(f),l,1),e==null)if(It(c.d,l-g,A,a))y.precision=l+=g,u=s=p=Z(d.minus(1),d.plus(1),l,1),m=N(p.times(p),l,1),r=a=1;else return N(c,y.precision=w,A,O=!0);else return y.precision=w,c;c=u,r+=2}}function yi(i){return String(i.s*i.s/0)}function Tn(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)%C,t<0&&(n+=C),n<r){for(n&&i.d.push(+e.slice(0,n)),r-=C;n<r;)i.d.push(+e.slice(n,n+=C));e=e.slice(n),n=C-e.length}else n-=r;for(;n--;)e+="0";i.d.push(+e),O&&(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 kr(i,e){var t,n,r,o,s,a,c,u,l;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),fi.test(e))return Tn(i,e)}else if(e==="Infinity"||e==="NaN")return+e||(i.s=NaN),i.e=NaN,i.d=null,i;if(br.test(e))t=16,e=e.toLowerCase();else if(gr.test(e))t=2;else if(yr.test(e))t=8;else throw Error(tt+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=gi(n,new n(t),o,o*2)),u=Ht(e,t,Oe),l=u.length-1,o=l;u[o]===0;--o)u.pop();return o<0?new n(i.s*0):(i.e=$t(u,l),i.d=u,O=!1,s&&(i=Z(i,r,a*4)),c&&(i=i.times(Math.abs(c)<54?ue(2,c):St.pow(2,c))),O=!0,i)}function Pr(i,e){var t,n=e.d.length;if(n<3)return e.isZero()?e:ht(i,2,e,e);t=1.4*Math.sqrt(n),t=t>16?16:t|0,e=e.times(1/Jt(5,t)),e=ht(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 ht(i,e,t,n,r){var o,s,a,c,u=1,l=i.precision,d=Math.ceil(l/C);for(O=!1,c=t.times(t),a=new i(n);;){if(s=Z(a.times(c),new i(e++*e++),l,1),a=r?n.plus(s):n.minus(s),n=Z(s.times(c),new i(e++*e++),l,1),s=a.plus(n),s.d[d]!==void 0){for(o=d;s.d[o]===a.d[o]&&o--;);if(o==-1)break}o=a,a=n,n=s,s=o,u++}return O=!0,s.d.length=d+1,s}function Jt(i,e){for(var t=i;--e;)t*=i;return t}function wi(i,e){var t,n=e.s<0,r=Ee(i,i.precision,1),o=r.times(.5);if(e=e.abs(),e.lte(o))return He=n?4:1,e;if(t=e.divToInt(r),t.isZero())He=n?3:2;else{if(e=e.minus(t.times(r)),e.lte(o))return He=si(t)?n?2:3:n?4:1,e;He=si(t)?n?1:4:n?3:2}return e.minus(r).abs()}function xn(i,e,t,n){var r,o,s,a,c,u,l,d,m,f=i.constructor,g=t!==void 0;if(g?(Ie(t,1,nt),n===void 0?n=f.rounding:Ie(n,0,8)):(t=f.precision,n=f.rounding),!i.isFinite())l=yi(i);else{for(l=We(i),s=l.indexOf("."),g?(r=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):r=e,s>=0&&(l=l.replace(".",""),m=new f(1),m.e=l.length-s,m.d=Ht(We(m),10,r),m.e=m.d.length),d=Ht(l,10,r),o=c=d.length;d[--c]==0;)d.pop();if(!d[0])l=g?"0p+0":"0";else{if(s<0?o--:(i=new f(i),i.d=d,i.e=o,i=Z(i,m,t,n,0,r),d=i.d,o=i.e,u=ui),s=d[t],a=r/2,u=u||d[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&&d[t-1]&1||n===(i.s<0?8:7)),d.length=t,u)for(;++d[--t]>r-1;)d[t]=0,t||(++o,d.unshift(1));for(c=d.length;!d[c-1];--c);for(s=0,l="";s<c;s++)l+=hn.charAt(d[s]);if(g){if(c>1)if(e==16||e==8){for(s=e==16?4:3,--c;c%s;c++)l+="0";for(d=Ht(l,r,e),c=d.length;!d[c-1];--c);for(s=1,l="1.";s<c;s++)l+=hn.charAt(d[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 ai(i,e){if(i.length>e)return i.length=e,!0}function Tr(i){return new this(i).abs()}function xr(i){return new this(i).acos()}function Br(i){return new this(i).acosh()}function Ir(i,e){return new this(i).plus(e)}function Sr(i){return new this(i).asin()}function Nr(i){return new this(i).asinh()}function Kr(i){return new this(i).atan()}function Cr(i){return new this(i).atanh()}function Lr(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=Ee(this,o,1).times(e.s>0?.25:.75),t.s=i.s):!e.d||i.isZero()?(t=e.s<0?Ee(this,n,r):new this(0),t.s=i.s):!i.d||e.isZero()?(t=Ee(this,o,1).times(.5),t.s=i.s):e.s<0?(this.precision=o,this.rounding=1,t=this.atan(Z(i,e,o,1)),e=Ee(this,o,1),this.precision=n,this.rounding=r,t=i.s<0?t.minus(e):t.plus(e)):t=this.atan(Z(i,e,o,1)),t}function Rr(i){return new this(i).cbrt()}function Mr(i){return N(i=new this(i),i.e+1,2)}function Er(i,e,t){return new this(i).clamp(e,t)}function Or(i){if(!i||typeof i!="object")throw Error(Qt+"Object expected");var e,t,n,r=i.defaults===!0,o=["precision",1,nt,"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]=An[t]),(n=i[t])!==void 0)if(Ae(n)===n&&n>=o[e+1]&&n<=o[e+2])this[t]=n;else throw Error(tt+t+": "+n);if(t="crypto",r&&(this[t]=An[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(di);else this[t]=!1;else throw Error(tt+t+": "+n);return this}function Fr(i){return new this(i).cos()}function Dr(i){return new this(i).cosh()}function hi(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,ci(o)){u.s=o.s,O?!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++;O?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 Tn(u,o.toString())}else if(c!=="string")throw Error(tt+o);return(a=o.charCodeAt(0))===45?(o=o.slice(1),u.s=-1):(a===43&&(o=o.slice(1)),u.s=1),fi.test(o)?Tn(u,o):kr(u,o)}if(r.prototype=P,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=Or,r.clone=hi,r.isDecimal=ci,r.abs=Tr,r.acos=xr,r.acosh=Br,r.add=Ir,r.asin=Sr,r.asinh=Nr,r.atan=Kr,r.atanh=Cr,r.atan2=Lr,r.cbrt=Rr,r.ceil=Mr,r.clamp=Er,r.cos=Fr,r.cosh=Dr,r.div=_r,r.exp=vr,r.floor=qr,r.hypot=Wr,r.ln=Vr,r.log=Ur,r.log10=Xr,r.log2=Gr,r.max=zr,r.min=Hr,r.mod=jr,r.mul=Zr,r.pow=Yr,r.random=Qr,r.round=$r,r.sign=Jr,r.sin=eo,r.sinh=to,r.sqrt=no,r.sub=io,r.sum=ro,r.tan=oo,r.tanh=so,r.trunc=ao,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 _r(i,e){return new this(i).div(e)}function vr(i){return new this(i).exp()}function qr(i){return N(i=new this(i),i.e+1,3)}function Wr(){var i,e,t=new this(0);for(O=!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 O=!0,new this(1/0);t=e}return O=!0,t.sqrt()}function ci(i){return i instanceof St||i&&i.toStringTag===mi||!1}function Vr(i){return new this(i).ln()}function Ur(i,e){return new this(i).log(e)}function Gr(i){return new this(i).log(2)}function Xr(i){return new this(i).log(10)}function zr(){return bi(this,arguments,"lt")}function Hr(){return bi(this,arguments,"gt")}function jr(i,e){return new this(i).mod(e)}function Zr(i,e){return new this(i).mul(e)}function Yr(i,e){return new this(i).pow(e)}function Qr(i){var e,t,n,r,o=0,s=new this(1),a=[];if(i===void 0?i=this.precision:Ie(i,1,nt),n=Math.ceil(i/C),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(di);else for(;o<n;)a[o++]=Math.random()*1e7|0;for(n=a[--o],i%=C,n&&i&&(r=ue(10,C-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-=C)a.shift();for(n=1,r=a[0];r>=10;r/=10)n++;n<C&&(t-=C-n)}return s.e=t,s.d=a,s}function $r(i){return N(i=new this(i),i.e+1,this.rounding)}function Jr(i){return i=new this(i),i.d?i.d[0]?i.s:0*i.s:i.s||NaN}function eo(i){return new this(i).sin()}function to(i){return new this(i).sinh()}function no(i){return new this(i).sqrt()}function io(i,e){return new this(i).sub(e)}function ro(){var i=0,e=arguments,t=new this(e[i]);for(O=!1;t.s&&++i<e.length;)t=t.plus(e[i]);return O=!0,N(t,this.precision,this.rounding)}function oo(i){return new this(i).tan()}function so(i){return new this(i).tanh()}function ao(i){return N(i=new this(i),i.e+1,1)}P[Symbol.for("nodejs.util.inspect.custom")]=P.toString;P[Symbol.toStringTag]="Decimal";var St=P.constructor=hi(An);jt=new St(jt);Zt=new St(Zt);var I=St;import{get as Ai,set as co}from"lodash";import Pi from"dayjs";import uo from"dayjs/plugin/utc";Pi.extend(uo);var Bn=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 Pi().utc().format("YYYY/MM/DD HH:mm:ss UTC")}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}},ki={},lo={};function le(i){let e=Ai(ki,i);if(!e){let t=Ai(lo,i);e=new Bn({name:i,logLevel:t}),co(ki,i,e)}return e}import{PublicKey as dc}from"@solana/web3.js";import fc from"bn.js";import Io from"big.js";import sn from"bn.js";import Se from"bn.js";import{PublicKey as Kn}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as mo}from"@solana/spl-token";import{PublicKey as te,SystemProgram as fo,SYSVAR_RENT_PUBKEY as po}from"@solana/web3.js";function In({pubkey:i,isSigner:e=!1,isWritable:t=!0}){return{pubkey:i,isWritable:t,isSigner:e}}var Ss=[In({pubkey:mo,isWritable:!1}),In({pubkey:fo.programId,isWritable:!1}),In({pubkey:po,isWritable:!1})];function Sn({publicKey:i,transformSol:e}){let t=Ti(i.toString());if(t instanceof te)return e&&t.equals(lt)?Q:t;if(e&&t.toString()===lt.toBase58())return Q;if(typeof t=="string"){if(t===te.default.toBase58())return te.default;try{return new te(t)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function Ti(i){try{return new te(i)}catch{return i}}var en=new te("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),Nt=new te("SysvarRent111111111111111111111111111111111"),Ns=new te("SysvarC1ock11111111111111111111111111111111"),At=new te("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),Ks=new te("Sysvar1nstructions1111111111111111111111111"),Cs=new te("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),Ls=new te("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),Rs=new te("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),Ms=new te("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),Es=new te("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),Os=new te("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),Fs=new te("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),Ds=new te("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),_s=new te("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),vs=new te("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),qs=new te("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),Q=new te("So11111111111111111111111111111111111111112"),lt=te.default;function Nn(i){return Sn({publicKey:i,transformSol:!0})}import{PublicKey as go}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as xi}from"@solana/spl-token";var tn={chainId:101,address:go.default.toBase58(),programId:xi.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"https://img.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}},dt={chainId:101,address:"So11111111111111111111111111111111111111112",programId:xi.toBase58(),decimals:9,symbol:"WSOL",name:"Wrapped SOL",logoURI:"https://img.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}};var Cn=class{constructor({mint:e,decimals:t,symbol:n,name:r,skipMint:o=!1,isToken2022:s=!1}){if(e===lt.toBase58()||e instanceof Kn&<.equals(e)){this.decimals=dt.decimals,this.symbol=dt.symbol,this.name=dt.name,this.mint=new Kn(dt.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?Kn.default:Sn({publicKey:e}),this.isToken2022=s}equals(e){return this===e?!0:this.mint.equals(e.mint)}},je=Cn;je.WSOL=new Cn(ee(q({},dt),{mint:dt.address}));import rn from"big.js";import wo from"bn.js";import ho from"decimal.js-light";import bo from"toformat";var yo=bo,Kt=yo;var nn=le("module/fraction"),Ln=Kt(rn),Ct=Kt(ho),Ao={[0]:Ct.ROUND_DOWN,[1]:Ct.ROUND_HALF_UP,[2]:Ct.ROUND_UP},ko={[0]:rn.roundDown,[1]:rn.roundHalfUp,[2]:rn.roundUp},z=class{constructor(e,t=new wo(1)){this.numerator=be(e),this.denominator=be(t)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new z(this.denominator,this.numerator)}add(e){let t=e instanceof z?e:new z(be(e));return this.denominator.eq(t.denominator)?new z(this.numerator.add(t.numerator),this.denominator):new z(this.numerator.mul(t.denominator).add(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}sub(e){let t=e instanceof z?e:new z(be(e));return this.denominator.eq(t.denominator)?new z(this.numerator.sub(t.numerator),this.denominator):new z(this.numerator.mul(t.denominator).sub(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}mul(e){let t=e instanceof z?e:new z(be(e));return new z(this.numerator.mul(t.numerator),this.denominator.mul(t.denominator))}div(e){let t=e instanceof z?e:new z(be(e));return new z(this.numerator.mul(t.denominator),this.denominator.mul(t.numerator))}toSignificant(e,t={groupSeparator:""},n=1){Number.isInteger(e)||nn.logWithError(`${e} is not an integer.`),e<=0&&nn.logWithError(`${e} is not positive.`),Ct.set({precision:e+1,rounding:Ao[n]});let r=new Ct(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)||nn.logWithError(`${e} is not an integer.`),e<0&&nn.logWithError(`${e} is negative.`),Ln.DP=e,Ln.RM=ko[n]||1,new Ln(this.numerator.toString()).div(this.denominator.toString()).toFormat(e,t)}isZero(){return this.numerator.isZero()}};var To=le("Raydium_price"),Fe=class extends z{constructor(t){let{baseToken:n,quoteToken:r,numerator:o,denominator:s}=t;super(o,s);this.baseToken=n,this.quoteToken=r,this.scalar=new z(Rn(n.decimals),Rn(r.decimals))}get raw(){return new z(this.numerator,this.denominator)}get adjusted(){return super.mul(this.scalar)}invert(){return new Fe({baseToken:this.quoteToken,quoteToken:this.baseToken,denominator:this.numerator,numerator:this.denominator})}mul(t){this.quoteToken!==t.baseToken&&To.logWithError("mul token not equals");let n=super.mul(t);return new Fe({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 Mn=class{constructor({decimals:e,symbol:t="UNKNOWN",name:n="UNKNOWN"}){this.decimals=e,this.symbol=t,this.name=n}equals(e){return this===e}},on=Mn;on.SOL=new Mn(tn);import xo from"bn.js";var Bi=new z(new xo(100)),Ze=class extends z{toSignificant(e=5,t,n){return this.mul(Bi).toSignificant(e,t,n)}toFixed(e=2,t,n){return this.mul(Bi).toFixed(e,t,n)}};var Bo=new Se(0),Fa=new Se(1),Da=new Se(2),_a=new Se(3),va=new Se(5),En=new Se(10),qa=new Se(100),Wa=new Se(1e3),Va=new Se(1e4),Ii=9007199254740991;function be(i){let e=le("Raydium_parseBigNumberish");if(i instanceof Se)return i;if(typeof i=="string"){if(i.match(/^-?[0-9]+$/))return new Se(i);e.logWithError(`invalid BigNumberish string: ${i}`)}return typeof i=="number"?(i%1&&e.logWithError(`BigNumberish number underflow: ${i}`),(i>=Ii||i<=-Ii)&&e.logWithError(`BigNumberish number overflow: ${i}`),new Se(String(i))):typeof i=="bigint"?new Se(i.toString()):(e.error(`invalid BigNumberish value: ${i}`),new Se(0))}function Rn(i){return En.pow(be(i))}var So=le("Raydium_amount"),Si=Kt(Io);function No(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")):So.logWithError(`invalid number string, num: ${i}`)}else t=i;return[t,n.slice(0,e)||n]}var ke=class extends z{constructor(t,n,r=!0,o){let s=new sn(0),a=En.pow(new sn(t.decimals));if(r)s=be(n);else{let c=new sn(0),u=new sn(0);if(typeof n=="string"||typeof n=="number"||typeof n=="bigint"){let[l,d]=No(n.toString(),t.decimals);c=be(l),u=be(d)}c=c.mul(a),s=c.add(u)}super(s,a);this.logger=le(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 ke(this.token,this.raw.add(t.raw))}subtract(t){return this.token.equals(t.token)||this.logger.logWithError("sub token not equals"),new ke(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 Si.DP=this.token.decimals,new Si(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)}};import{PublicKey as Mt,sendAndConfirmTransaction as vn,Transaction as Et,TransactionMessage as Ot,VersionedTransaction as Ft}from"@solana/web3.js";import Fo from"axios";var se={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",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",FarmV5Deposit:"FarmV5Deposit",FarmV5Withdraw:"FarmV5Withdraw",FarmV5CreateLedger:"FarmV5CreateLedger",FarmV6Deposit:"FarmV6Deposit",FarmV6Withdraw:"FarmV6Withdraw",FarmV6Create:"FarmV6Create",FarmV6Restart:"FarmV6Restart",FarmV6CreatorAddReward:"FarmV6CreatorAddReward",FarmV6CreatorWithdraw:"FarmV6CreatorWithdraw"};import{PublicKey as Ko,ComputeBudgetProgram as Ni,Transaction as Ci,TransactionMessage as Co,Keypair as Li,VersionedTransaction as Ri}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as Lo}from"@solana/spl-token";var Ki=le("Raydium_txUtil"),Mi=1644;function an(i){let e=[],t=[];return i.microLamports&&(e.push(Ni.setComputeUnitPrice({microLamports:i.microLamports})),t.push(se.SetComputeUnitPrice)),i.units&&(e.push(Ni.setComputeUnitLimit({units:i.units})),t.push(se.SetComputeUnitLimit)),{instructions:e,instructionTypes:t}}async function kt(i){var e,t;try{return((t=await((e=i.getLatestBlockhash)==null?void 0:e.call(i)))==null?void 0:t.blockhash)||(await i.getRecentBlockhash()).blockhash}catch{return(await i.getRecentBlockhash()).blockhash}}function Ro(i,e){i.length<1&&Ki.logWithError(`no instructions provided: ${i.toString()}`),e.length<1&&Ki.logWithError(`no signers provided:, ${e.toString()}`);let t=new Ci;t.recentBlockhash="11111111111111111111111111111111",t.feePayer=e[0],t.add(...i);try{return Buffer.from(t.serialize({verifySignatures:!1})).toString("base64").length<Mi}catch{return!1}}function Le(i,e){let[t,n]=Ko.findProgramAddressSync(i,e);return{publicKey:t,nonce:n}}function Lt({instructions:i,payer:e,signers:t}){return Ro(i,[e,...t])}function Rt({instructions:i,payer:e,lookupTableAddressAccount:t,recentBlockhash:n=Li.generate().publicKey.toString()}){let o=new Co({payerKey:e,recentBlockhash:n,instructions:i}).compileToV0Message(Object.values(t!=null?t:{}));try{return Buffer.from(new Ri(o).serialize()).toString("base64").length<Mi}catch{return!1}}var Mo=i=>Buffer.isBuffer(i)?i:i instanceof Uint8Array?Buffer.from(i.buffer,i.byteOffset,i.byteLength):Buffer.from(i);function mt(i){let e=[];return i.forEach(t=>{t instanceof Ci&&(t.recentBlockhash||(t.recentBlockhash=Lo.toBase58()),t.feePayer||(t.feePayer=Li.generate().publicKey));let n=t.serialize({requireAllSignatures:!1,verifySignatures:!1});t instanceof Ri&&(n=Mo(n));let r=n.toString("base64");e.push(r)}),console.log("simulate tx string:",e),e}import{PublicKey as Ei,AddressLookupTableAccount as cn}from"@solana/web3.js";import{PublicKey as Eo}from"@solana/web3.js";import{getTransferFeeConfig as Rc,unpackMint as Mc}from"@solana/spl-token";var On=le("Raydium_accountInfo_util");async function it(i,e,t){let{batchRequest:n,commitment:r="confirmed"}=q({batchRequest:!1},t),o=Fn(e,100),s=new Array(o.length).fill([]);if(n){let a=o.map(l=>{let d=i._buildArgs([l.map(m=>m.toBase58())],r,"base64");return{methodName:"getMultipleAccounts",args:d}}),c=Fn(a,10);s=(await(await Promise.all(c.map(async l=>await i._rpcBatchRequest(l)))).flat()).map(l=>(l.error&&On.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${l.error.message}`),l.result.value.map(d=>{if(d){let{data:m,executable:f,lamports:g,owner:p,rentEpoch:b}=d;return m.length!==2&&m[1]!=="base64"&&On.logWithError("info must be base64 encoded, RPC_ERROR"),{data:Buffer.from(m[0],"base64"),executable:f,lamports:g,owner:new Eo(p),rentEpoch:b}}return null})))}else try{s=await Promise.all(o.map(a=>i.getMultipleAccountsInfo(a,r)))}catch(a){a instanceof Error&&On.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${a.message}`)}return s.flat()}async function Dn(i,e,t){let n=await it(i,e.map(r=>r.pubkey),t);return e.map((r,o)=>ee(q({},r),{accountInfo:n[o]}))}async function _n({connection:i,address:e}){let t=await it(i,[...new Set(e.map(r=>r.toString()))].map(r=>new Ei(r))),n={};for(let r=0;r<e.length;r++){let o=t[r],s=e[r];if(!o)continue;let a=new cn({key:s,state:cn.deserialize(o.data)});n[s.toString()]=a,un[s.toString()]=a}return n}var un={"2immgwYNHBbyVQKVGCEkgWpi53bLwWNRMB5G2nbgYV17":new cn({key:new Ei("2immgwYNHBbyVQKVGCEkgWpi53bLwWNRMB5G2nbgYV17"),state:cn.deserialize(Buffer.from("AQAAAP//////////d49+DAAAAAAAAQZMWvw7GUNJdaccNBVnb57OKakxL2BHLYvhRwVILRsgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMGRm/lIRcy/+ytunLDm+e8jOW7xfcSayxDmzpAAAAABt324ddloZPZy+FGzut5rBy0he1fWzeROoz1hX7/AKkG3fbh7nWP3hhCXbzkbM3athr8TYO5DSf+vfko2KGL/AVKU1D4XciC1hSlVnJ4iilt3x6rq9CmBniISTL07vagBqfVFxksXFEhjMlMPUrxf1ja7gibof1E49vZigAAAAAGp9UXGMd0yShWY5hpHV62i164o5tLbVxzVVshAAAAAIyXJY9OJInxuz0QKRSODYMLWhOZ2v8QhASOe9jb6fhZC3BlsePRfEU4nVJ/awTDzVi4bHMaoP21SbbRvAP4KUbIScv+6Yw2LHF/6K0ZjUPibbSWXCirYPGuuVl7zT789IUPLW4CpHr4JNCatp3ELXDLKMv6JJ+37le50lbBJ2LvDQdRqCgtphMF/imcN7mY5YRx2xE1A3MQ+L4QRaYK9u4GRfZP3LsAd00a+IkCpA22UNQMKdq5BFbJuwuOLqc8zxCTDlqxBG8J0HcxtfogQHDK06ukzfaXiNDKAob1MqBHS9lJxDYCwz8gd5DtFqNSTKG5l1zxIaKpDP/sffi2is1H9aKveyXSu5StXElYRl9SD5As0DHE4N0GLnf84/siiKXVyp4Ez121kLcUui/jLLFZEz/BwZK3Ilf9B9OcsEAeDMKAy2vjGSxQODgBz0QwGA+eP4ZjIjrIAQaXENv31QfLlOdXSRCkaybRniDHF4C8YcwhcvsqrOVuTP4B2Na+9wLdtrB31uz2rtlFI5kahdsnp/d1SrASDInYCtTYtdoke4kX+hoKWcEWM4Tle8pTUkUVv4BxS6fje/EzKBE4Qu9N9LMnrw/JNO0hqMVB4rk/2ou4AB1loQ7FZoPwut2o4KZB+0p9xnbrQKw038qjpHar+PyDwvxBRcu5hpHw3dguezeWv+IwvgW5icu8EGkhGa9AkFPPJT7VMSFb8xowveU=","base64"))})};var ln=class{constructor(e){this.instructions=[];this.endInstructions=[];this.lookupTableAddress=[];this.signers=[];this.instructionTypes=[];this.endInstructionTypes=[];this.connection=e.connection,this.feePayer=e.feePayer,this.signAllTransactions=e.signAllTransactions,this.owner=e.owner}get AllTxData(){return{instructions:this.instructions,endInstructions:this.endInstructions,signers:this.signers,instructionTypes:this.instructionTypes,endInstructionTypes:this.endInstructionTypes,lookupTableAddress:this.lookupTableAddress}}get allInstructions(){return[...this.instructions,...this.endInstructions]}async getComputeBudgetConfig(){var n;let e=(await Fo.get(`https://solanacompass.com/api/fees?cacheFreshTime=${3e5}`)).data,{avg:t}=(n=e==null?void 0:e[15])!=null?n:{};if(!!t)return{units:6e5,microLamports:Math.min(Math.ceil(t*1e6/6e5),25e3)}}addCustomComputeBudget(e){if(e){let{instructions:t,instructionTypes:n}=an(e);return this.instructions.unshift(...t),this.instructionTypes.unshift(...n),!0}return!1}async calComputeBudget({config:e,defaultIns:t}){try{let n=e||await this.getComputeBudgetConfig();if(this.addCustomComputeBudget(n))return;t&&this.instructions.unshift(..