UNPKG

test-raydium-sdk-v2

Version:

An SDK for building applications on top of Raydium.

1 lines 62.5 kB
var Ln=Object.defineProperty,En=Object.defineProperties;var Rn=Object.getOwnPropertyDescriptors;var qt=Object.getOwnPropertySymbols;var Fn=Object.prototype.hasOwnProperty,On=Object.prototype.propertyIsEnumerable;var Gt=(n,e,t)=>e in n?Ln(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,se=(n,e)=>{for(var t in e||(e={}))Fn.call(e,t)&&Gt(n,t,e[t]);if(qt)for(var t of qt(e))On.call(e,t)&&Gt(n,t,e[t]);return n},fe=(n,e)=>En(n,Rn(e));import me from"bn.js";import U from"bn.js";var Be=9e15,ye=1e9,lt="0123456789abcdef",ze="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",He="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",mt={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Be,maxE:Be,crypto:!1},Xt,pe,y=!0,Ze="[DecimalError] ",be=Ze+"Invalid argument: ",zt=Ze+"Precision limit exceeded",Ht=Ze+"crypto unavailable",Yt="[object Decimal]",G=Math.floor,O=Math.pow,Dn=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Mn=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,_n=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Zt=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,re=1e7,h=7,vn=9007199254740991,Kn=ze.length-1,dt=He.length-1,f={toStringTag:Yt};f.absoluteValue=f.abs=function(){var n=new this.constructor(this);return n.s<0&&(n.s=1),g(n)};f.ceil=function(){return g(new this.constructor(this),this.e+1,2)};f.clampedTo=f.clamp=function(n,e){var t,r=this,i=r.constructor;if(n=new i(n),e=new i(e),!n.s||!e.s)return new i(NaN);if(n.gt(e))throw Error(be+e);return t=r.cmp(n),t<0?n:r.cmp(e)>0?e:new i(r)};f.comparedTo=f.cmp=function(n){var e,t,r,i,o=this,s=o.d,a=(n=new o.constructor(n)).d,c=o.s,u=n.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!==n.e)return o.e>n.e^c<0?1:-1;for(r=s.length,i=a.length,e=0,t=r<i?r:i;e<t;++e)if(s[e]!==a[e])return s[e]>a[e]^c<0?1:-1;return r===i?0:r>i^c<0?1:-1};f.cosine=f.cos=function(){var n,e,t=this,r=t.constructor;return t.d?t.d[0]?(n=r.precision,e=r.rounding,r.precision=n+Math.max(t.e,t.sd())+h,r.rounding=1,t=qn(r,en(r,t)),r.precision=n,r.rounding=e,g(pe==2||pe==3?t.neg():t,n,e,!0)):new r(1):new r(NaN)};f.cubeRoot=f.cbrt=function(){var n,e,t,r,i,o,s,a,c,u,l=this,m=l.constructor;if(!l.isFinite()||l.isZero())return new m(l);for(y=!1,o=l.s*O(l.s*l,1/3),!o||Math.abs(o)==1/0?(t=v(l.d),n=l.e,(o=(n-t.length+1)%3)&&(t+=o==1||o==-2?"0":"00"),o=O(t,1/3),n=G((n+1)/3)-(n%3==(n<0?-1:2)),o==1/0?t="5e"+n:(t=o.toExponential(),t=t.slice(0,t.indexOf("e")+1)+n),r=new m(t),r.s=l.s):r=new m(o.toString()),s=(n=m.precision)+3;;)if(a=r,c=a.times(a).times(a),u=c.plus(l),r=N(u.plus(l).times(a),u.plus(c),s+2,1),v(a.d).slice(0,s)===(t=v(r.d)).slice(0,s))if(t=t.slice(s-3,s+1),t=="9999"||!i&&t=="4999"){if(!i&&(g(a,n+1,0),a.times(a).times(a).eq(l))){r=a;break}s+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(g(r,n+1,1),e=!r.times(r).times(r).eq(l));break}return y=!0,g(r,n,m.rounding,e)};f.decimalPlaces=f.dp=function(){var n,e=this.d,t=NaN;if(e){if(n=e.length-1,t=(n-G(this.e/h))*h,n=e[n],n)for(;n%10==0;n/=10)t--;t<0&&(t=0)}return t};f.dividedBy=f.div=function(n){return N(this,new this.constructor(n))};f.dividedToIntegerBy=f.divToInt=function(n){var e=this,t=e.constructor;return g(N(e,new t(n),0,1,1),t.precision,t.rounding)};f.equals=f.eq=function(n){return this.cmp(n)===0};f.floor=function(){return g(new this.constructor(this),this.e+1,3)};f.greaterThan=f.gt=function(n){return this.cmp(n)>0};f.greaterThanOrEqualTo=f.gte=function(n){var e=this.cmp(n);return e==1||e===0};f.hyperbolicCosine=f.cosh=function(){var n,e,t,r,i,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,r=s.rounding,s.precision=t+Math.max(o.e,o.sd())+4,s.rounding=1,i=o.d.length,i<32?(n=Math.ceil(i/3),e=(1/Qe(4,n)).toString()):(n=16,e="2.3283064365386962890625e-10"),o=Ie(s,1,o.times(e),new s(1),!0);for(var c,u=n,l=new s(8);u--;)c=o.times(o),o=a.minus(c.times(l.minus(c.times(l))));return g(o,s.precision=t,s.rounding=r,!0)};f.hyperbolicSine=f.sinh=function(){var n,e,t,r,i=this,o=i.constructor;if(!i.isFinite()||i.isZero())return new o(i);if(e=o.precision,t=o.rounding,o.precision=e+Math.max(i.e,i.sd())+4,o.rounding=1,r=i.d.length,r<3)i=Ie(o,2,i,i,!0);else{n=1.4*Math.sqrt(r),n=n>16?16:n|0,i=i.times(1/Qe(5,n)),i=Ie(o,2,i,i,!0);for(var s,a=new o(5),c=new o(16),u=new o(20);n--;)s=i.times(i),i=i.times(a.plus(s.times(c.times(s).plus(u))))}return o.precision=e,o.rounding=t,g(i,e,t,!0)};f.hyperbolicTangent=f.tanh=function(){var n,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+7,r.rounding=1,N(t.sinh(),t.cosh(),r.precision=n,r.rounding=e)):new r(t.s)};f.inverseCosine=f.acos=function(){var n,e=this,t=e.constructor,r=e.abs().cmp(1),i=t.precision,o=t.rounding;return r!==-1?r===0?e.isNeg()?ne(t,i,o):new t(0):new t(NaN):e.isZero()?ne(t,i+4,o).times(.5):(t.precision=i+6,t.rounding=1,e=e.asin(),n=ne(t,i+4,o).times(.5),t.precision=i,t.rounding=o,n.minus(e))};f.inverseHyperbolicCosine=f.acosh=function(){var n,e,t=this,r=t.constructor;return t.lte(1)?new r(t.eq(1)?0:NaN):t.isFinite()?(n=r.precision,e=r.rounding,r.precision=n+Math.max(Math.abs(t.e),t.sd())+4,r.rounding=1,y=!1,t=t.times(t).minus(1).sqrt().plus(t),y=!0,r.precision=n,r.rounding=e,t.ln()):new r(t)};f.inverseHyperbolicSine=f.asinh=function(){var n,e,t=this,r=t.constructor;return!t.isFinite()||t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+2*Math.max(Math.abs(t.e),t.sd())+6,r.rounding=1,y=!1,t=t.times(t).plus(1).sqrt().plus(t),y=!0,r.precision=n,r.rounding=e,t.ln())};f.inverseHyperbolicTangent=f.atanh=function(){var n,e,t,r,i=this,o=i.constructor;return i.isFinite()?i.e>=0?new o(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(n=o.precision,e=o.rounding,r=i.sd(),Math.max(r,n)<2*-i.e-1?g(new o(i),n,e,!0):(o.precision=t=r-i.e,i=N(i.plus(1),new o(1).minus(i),t+n,1),o.precision=n+4,o.rounding=1,i=i.ln(),o.precision=n,o.rounding=e,i.times(.5))):new o(NaN)};f.inverseSine=f.asin=function(){var n,e,t,r,i=this,o=i.constructor;return i.isZero()?new o(i):(e=i.abs().cmp(1),t=o.precision,r=o.rounding,e!==-1?e===0?(n=ne(o,t+4,r).times(.5),n.s=i.s,n):new o(NaN):(o.precision=t+6,o.rounding=1,i=i.div(new o(1).minus(i.times(i)).sqrt().plus(1)).atan(),o.precision=t,o.rounding=r,i.times(2)))};f.inverseTangent=f.atan=function(){var n,e,t,r,i,o,s,a,c,u=this,l=u.constructor,m=l.precision,d=l.rounding;if(u.isFinite()){if(u.isZero())return new l(u);if(u.abs().eq(1)&&m+4<=dt)return s=ne(l,m+4,d).times(.25),s.s=u.s,s}else{if(!u.s)return new l(NaN);if(m+4<=dt)return s=ne(l,m+4,d).times(.5),s.s=u.s,s}for(l.precision=a=m+10,l.rounding=1,t=Math.min(28,a/h+2|0),n=t;n;--n)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(y=!1,e=Math.ceil(a/h),r=1,c=u.times(u),s=new l(u),i=u;n!==-1;)if(i=i.times(c),o=s.minus(i.div(r+=2)),i=i.times(c),s=o.plus(i.div(r+=2)),s.d[e]!==void 0)for(n=e;s.d[n]===o.d[n]&&n--;);return t&&(s=s.times(2<<t-1)),y=!0,g(s,l.precision=m,l.rounding=d,!0)};f.isFinite=function(){return!!this.d};f.isInteger=f.isInt=function(){return!!this.d&&G(this.e/h)>this.d.length-2};f.isNaN=function(){return!this.s};f.isNegative=f.isNeg=function(){return this.s<0};f.isPositive=f.isPos=function(){return this.s>0};f.isZero=function(){return!!this.d&&this.d[0]===0};f.lessThan=f.lt=function(n){return this.cmp(n)<0};f.lessThanOrEqualTo=f.lte=function(n){return this.cmp(n)<1};f.logarithm=f.log=function(n){var e,t,r,i,o,s,a,c,u=this,l=u.constructor,m=l.precision,d=l.rounding,p=5;if(n==null)n=new l(10),e=!0;else{if(n=new l(n),t=n.d,n.s<0||!t||!t[0]||n.eq(1))return new l(NaN);e=n.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(i=t[0];i%10===0;)i/=10;o=i!==1}if(y=!1,a=m+p,s=he(u,a),r=e?Ye(l,a+10):he(n,a),c=N(s,r,a,1),Re(c.d,i=m,d))do if(a+=10,s=he(u,a),r=e?Ye(l,a+10):he(n,a),c=N(s,r,a,1),!o){+v(c.d).slice(i+1,i+15)+1==1e14&&(c=g(c,m+1,0));break}while(Re(c.d,i+=10,d));return y=!0,g(c,m,d)};f.minus=f.sub=function(n){var e,t,r,i,o,s,a,c,u,l,m,d,p=this,w=p.constructor;if(n=new w(n),!p.d||!n.d)return!p.s||!n.s?n=new w(NaN):p.d?n.s=-n.s:n=new w(n.d||p.s!==n.s?p:NaN),n;if(p.s!=n.s)return n.s=-n.s,p.plus(n);if(u=p.d,d=n.d,a=w.precision,c=w.rounding,!u[0]||!d[0]){if(d[0])n.s=-n.s;else if(u[0])n=new w(p);else return new w(c===3?-0:0);return y?g(n,a,c):n}if(t=G(n.e/h),l=G(p.e/h),u=u.slice(),o=l-t,o){for(m=o<0,m?(e=u,o=-o,s=d.length):(e=d,t=l,s=u.length),r=Math.max(Math.ceil(a/h),s)+2,o>r&&(o=r,e.length=1),e.reverse(),r=o;r--;)e.push(0);e.reverse()}else{for(r=u.length,s=d.length,m=r<s,m&&(s=r),r=0;r<s;r++)if(u[r]!=d[r]){m=u[r]<d[r];break}o=0}for(m&&(e=u,u=d,d=e,n.s=-n.s),s=u.length,r=d.length-s;r>0;--r)u[s++]=0;for(r=d.length;r>o;){if(u[--r]<d[r]){for(i=r;i&&u[--i]===0;)u[i]=re-1;--u[i],u[r]+=re}u[r]-=d[r]}for(;u[--s]===0;)u.pop();for(;u[0]===0;u.shift())--t;return u[0]?(n.d=u,n.e=je(u,t),y?g(n,a,c):n):new w(c===3?-0:0)};f.modulo=f.mod=function(n){var e,t=this,r=t.constructor;return n=new r(n),!t.d||!n.s||n.d&&!n.d[0]?new r(NaN):!n.d||t.d&&!t.d[0]?g(new r(t),r.precision,r.rounding):(y=!1,r.modulo==9?(e=N(t,n.abs(),0,3,1),e.s*=n.s):e=N(t,n,0,r.modulo,1),e=e.times(n),y=!0,t.minus(e))};f.naturalExponential=f.exp=function(){return ft(this)};f.naturalLogarithm=f.ln=function(){return he(this)};f.negated=f.neg=function(){var n=new this.constructor(this);return n.s=-n.s,g(n)};f.plus=f.add=function(n){var e,t,r,i,o,s,a,c,u,l,m=this,d=m.constructor;if(n=new d(n),!m.d||!n.d)return!m.s||!n.s?n=new d(NaN):m.d||(n=new d(n.d||m.s===n.s?m:NaN)),n;if(m.s!=n.s)return n.s=-n.s,m.minus(n);if(u=m.d,l=n.d,a=d.precision,c=d.rounding,!u[0]||!l[0])return l[0]||(n=new d(m)),y?g(n,a,c):n;if(o=G(m.e/h),r=G(n.e/h),u=u.slice(),i=o-r,i){for(i<0?(t=u,i=-i,s=l.length):(t=l,r=o,s=u.length),o=Math.ceil(a/h),s=o>s?o+1:s+1,i>s&&(i=s,t.length=1),t.reverse();i--;)t.push(0);t.reverse()}for(s=u.length,i=l.length,s-i<0&&(i=s,t=l,l=u,u=t),e=0;i;)e=(u[--i]=u[i]+l[i]+e)/re|0,u[i]%=re;for(e&&(u.unshift(e),++r),s=u.length;u[--s]==0;)u.pop();return n.d=u,n.e=je(u,r),y?g(n,a,c):n};f.precision=f.sd=function(n){var e,t=this;if(n!==void 0&&n!==!!n&&n!==1&&n!==0)throw Error(be+n);return t.d?(e=jt(t.d),n&&t.e+1>e&&(e=t.e+1)):e=NaN,e};f.round=function(){var n=this,e=n.constructor;return g(new e(n),n.e+1,e.rounding)};f.sine=f.sin=function(){var n,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+Math.max(t.e,t.sd())+h,r.rounding=1,t=Vn(r,en(r,t)),r.precision=n,r.rounding=e,g(pe>2?t.neg():t,n,e,!0)):new r(NaN)};f.squareRoot=f.sqrt=function(){var n,e,t,r,i,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(y=!1,u=Math.sqrt(+s),u==0||u==1/0?(e=v(a),(e.length+c)%2==0&&(e+="0"),u=Math.sqrt(e),c=G((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),r=new l(e)):r=new l(u.toString()),t=(c=l.precision)+3;;)if(o=r,r=o.plus(N(s,o,t+2,1)).times(.5),v(o.d).slice(0,t)===(e=v(r.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!i&&e=="4999"){if(!i&&(g(o,c+1,0),o.times(o).eq(s))){r=o;break}t+=4,i=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(g(r,c+1,1),n=!r.times(r).eq(s));break}return y=!0,g(r,c,l.rounding,n)};f.tangent=f.tan=function(){var n,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+10,r.rounding=1,t=t.sin(),t.s=1,t=N(t,new r(1).minus(t.times(t)).sqrt(),n+10,0),r.precision=n,r.rounding=e,g(pe==2||pe==4?t.neg():t,n,e,!0)):new r(NaN)};f.times=f.mul=function(n){var e,t,r,i,o,s,a,c,u,l=this,m=l.constructor,d=l.d,p=(n=new m(n)).d;if(n.s*=l.s,!d||!d[0]||!p||!p[0])return new m(!n.s||d&&!d[0]&&!p||p&&!p[0]&&!d?NaN:!d||!p?n.s/0:n.s*0);for(t=G(l.e/h)+G(n.e/h),c=d.length,u=p.length,c<u&&(o=d,d=p,p=o,s=c,c=u,u=s),o=[],s=c+u,r=s;r--;)o.push(0);for(r=u;--r>=0;){for(e=0,i=c+r;i>r;)a=o[i]+p[r]*d[i-r-1]+e,o[i--]=a%re|0,e=a/re|0;o[i]=(o[i]+e)%re|0}for(;!o[--s];)o.pop();return e?++t:o.shift(),n.d=o,n.e=je(o,t),y?g(n,m.precision,m.rounding):n};f.toBinary=function(n,e){return gt(this,2,n,e)};f.toDecimalPlaces=f.toDP=function(n,e){var t=this,r=t.constructor;return t=new r(t),n===void 0?t:(z(n,0,ye),e===void 0?e=r.rounding:z(e,0,8),g(t,n+t.e+1,e))};f.toExponential=function(n,e){var t,r=this,i=r.constructor;return n===void 0?t=ae(r,!0):(z(n,0,ye),e===void 0?e=i.rounding:z(e,0,8),r=g(new i(r),n+1,e),t=ae(r,!0,n+1)),r.isNeg()&&!r.isZero()?"-"+t:t};f.toFixed=function(n,e){var t,r,i=this,o=i.constructor;return n===void 0?t=ae(i):(z(n,0,ye),e===void 0?e=o.rounding:z(e,0,8),r=g(new o(i),n+i.e+1,e),t=ae(r,!1,n+r.e+1)),i.isNeg()&&!i.isZero()?"-"+t:t};f.toFraction=function(n){var e,t,r,i,o,s,a,c,u,l,m,d,p=this,w=p.d,b=p.constructor;if(!w)return new b(p);if(u=t=new b(1),r=c=new b(0),e=new b(r),o=e.e=jt(w)-p.e-1,s=o%h,e.d[0]=O(10,s<0?h+s:s),n==null)n=o>0?e:u;else{if(a=new b(n),!a.isInt()||a.lt(u))throw Error(be+a);n=a.gt(e)?o>0?e:u:a}for(y=!1,a=new b(v(w)),l=b.precision,b.precision=o=w.length*h*2;m=N(a,e,0,1,1),i=t.plus(m.times(r)),i.cmp(n)!=1;)t=r,r=i,i=u,u=c.plus(m.times(i)),c=i,i=e,e=a.minus(m.times(i)),a=i;return i=N(n.minus(t),r,0,1,1),c=c.plus(i.times(u)),t=t.plus(i.times(r)),c.s=u.s=p.s,d=N(u,r,o,1).minus(p).abs().cmp(N(c,t,o,1).minus(p).abs())<1?[u,r]:[c,t],b.precision=l,y=!0,d};f.toHexadecimal=f.toHex=function(n,e){return gt(this,16,n,e)};f.toNearest=function(n,e){var t=this,r=t.constructor;if(t=new r(t),n==null){if(!t.d)return t;n=new r(1),e=r.rounding}else{if(n=new r(n),e===void 0?e=r.rounding:z(e,0,8),!t.d)return n.s?t:n;if(!n.d)return n.s&&(n.s=t.s),n}return n.d[0]?(y=!1,t=N(t,n,0,e,1).times(n),y=!0,g(t)):(n.s=t.s,t=n),t};f.toNumber=function(){return+this};f.toOctal=function(n,e){return gt(this,8,n,e)};f.toPower=f.pow=function(n){var e,t,r,i,o,s,a=this,c=a.constructor,u=+(n=new c(n));if(!a.d||!n.d||!a.d[0]||!n.d[0])return new c(O(+a,u));if(a=new c(a),a.eq(1))return a;if(r=c.precision,o=c.rounding,n.eq(1))return g(a,r,o);if(e=G(n.e/h),e>=n.d.length-1&&(t=u<0?-u:u)<=vn)return i=Qt(c,a,t,r),n.s<0?new c(1).div(i):g(i,r,o);if(s=a.s,s<0){if(e<n.d.length-1)return new c(NaN);if((n.d[e]&1)==0&&(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return t=O(+a,u),e=t==0||!isFinite(t)?G(u*(Math.log("0."+v(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):(y=!1,c.rounding=a.s=1,t=Math.min(12,(e+"").length),i=ft(n.times(he(a,r+t)),r),i.d&&(i=g(i,r+5,1),Re(i.d,r,o)&&(e=r+10,i=g(ft(n.times(he(a,e+t)),e),e+5,1),+v(i.d).slice(r+1,r+15)+1==1e14&&(i=g(i,r+1,0)))),i.s=s,y=!0,c.rounding=o,g(i,r,o))};f.toPrecision=function(n,e){var t,r=this,i=r.constructor;return n===void 0?t=ae(r,r.e<=i.toExpNeg||r.e>=i.toExpPos):(z(n,1,ye),e===void 0?e=i.rounding:z(e,0,8),r=g(new i(r),n,e),t=ae(r,n<=r.e||r.e<=i.toExpNeg,n)),r.isNeg()&&!r.isZero()?"-"+t:t};f.toSignificantDigits=f.toSD=function(n,e){var t=this,r=t.constructor;return n===void 0?(n=r.precision,e=r.rounding):(z(n,1,ye),e===void 0?e=r.rounding:z(e,0,8)),g(new r(t),n,e)};f.toString=function(){var n=this,e=n.constructor,t=ae(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()&&!n.isZero()?"-"+t:t};f.truncated=f.trunc=function(){return g(new this.constructor(this),this.e+1,1)};f.valueOf=f.toJSON=function(){var n=this,e=n.constructor,t=ae(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()?"-"+t:t};function v(n){var e,t,r,i=n.length-1,o="",s=n[0];if(i>0){for(o+=s,e=1;e<i;e++)r=n[e]+"",t=h-r.length,t&&(o+=ge(t)),o+=r;s=n[e],r=s+"",t=h-r.length,t&&(o+=ge(t))}else if(s===0)return"0";for(;s%10===0;)s/=10;return o+s}function z(n,e,t){if(n!==~~n||n<e||n>t)throw Error(be+n)}function Re(n,e,t,r){var i,o,s,a;for(o=n[0];o>=10;o/=10)--e;return--e<0?(e+=h,i=0):(i=Math.ceil((e+1)/h),e%=h),o=O(10,h-e),a=n[i]%o|0,r==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)&&(n[i+1]/o/100|0)==O(10,e-2)-1||(a==o/2||a==0)&&(n[i+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=(r||t<4)&&a==9999||!r&&t>3&&a==4999):s=((r||t<4)&&a+1==o||!r&&t>3&&a+1==o/2)&&(n[i+1]/o/1e3|0)==O(10,e-3)-1,s}function Xe(n,e,t){for(var r,i=[0],o,s=0,a=n.length;s<a;){for(o=i.length;o--;)i[o]*=e;for(i[0]+=lt.indexOf(n.charAt(s++)),r=0;r<i.length;r++)i[r]>t-1&&(i[r+1]===void 0&&(i[r+1]=0),i[r+1]+=i[r]/t|0,i[r]%=t)}return i.reverse()}function qn(n,e){var t,r,i;if(e.isZero())return e;r=e.d.length,r<32?(t=Math.ceil(r/3),i=(1/Qe(4,t)).toString()):(t=16,i="2.3283064365386962890625e-10"),n.precision+=t,e=Ie(n,1,e.times(i),new n(1));for(var o=t;o--;){var s=e.times(e);e=s.times(s).minus(s).times(8).plus(1)}return n.precision-=t,e}var N=function(){function n(r,i,o){var s,a=0,c=r.length;for(r=r.slice();c--;)s=r[c]*i+a,r[c]=s%o|0,a=s/o|0;return a&&r.unshift(a),r}function e(r,i,o,s){var a,c;if(o!=s)c=o>s?1:-1;else for(a=c=0;a<o;a++)if(r[a]!=i[a]){c=r[a]>i[a]?1:-1;break}return c}function t(r,i,o,s){for(var a=0;o--;)r[o]-=a,a=r[o]<i[o]?1:0,r[o]=a*s+r[o]-i[o];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,o,s,a,c){var u,l,m,d,p,w,b,F,I,X,B,K,Ge,de,at,Ve,Ee,ut,te,Ue,We=r.constructor,ct=r.s==i.s?1:-1,q=r.d,L=i.d;if(!q||!q[0]||!L||!L[0])return new We(!r.s||!i.s||(q?L&&q[0]==L[0]:!L)?NaN:q&&q[0]==0||!L?ct*0:ct/0);for(c?(p=1,l=r.e-i.e):(c=re,p=h,l=G(r.e/p)-G(i.e/p)),te=L.length,Ee=q.length,I=new We(ct),X=I.d=[],m=0;L[m]==(q[m]||0);m++);if(L[m]>(q[m]||0)&&l--,o==null?(de=o=We.precision,s=We.rounding):a?de=o+(r.e-i.e)+1:de=o,de<0)X.push(1),w=!0;else{if(de=de/p+2|0,m=0,te==1){for(d=0,L=L[0],de++;(m<Ee||d)&&de--;m++)at=d*c+(q[m]||0),X[m]=at/L|0,d=at%L|0;w=d||m<Ee}else{for(d=c/(L[0]+1)|0,d>1&&(L=n(L,d,c),q=n(q,d,c),te=L.length,Ee=q.length),Ve=te,B=q.slice(0,te),K=B.length;K<te;)B[K++]=0;Ue=L.slice(),Ue.unshift(0),ut=L[0],L[1]>=c/2&&++ut;do d=0,u=e(L,B,te,K),u<0?(Ge=B[0],te!=K&&(Ge=Ge*c+(B[1]||0)),d=Ge/ut|0,d>1?(d>=c&&(d=c-1),b=n(L,d,c),F=b.length,K=B.length,u=e(b,B,F,K),u==1&&(d--,t(b,te<F?Ue:L,F,c))):(d==0&&(u=d=1),b=L.slice()),F=b.length,F<K&&b.unshift(0),t(B,b,K,c),u==-1&&(K=B.length,u=e(L,B,te,K),u<1&&(d++,t(B,te<K?Ue:L,K,c))),K=B.length):u===0&&(d++,B=[0]),X[m++]=d,u&&B[0]?B[K++]=q[Ve]||0:(B=[q[Ve]],K=1);while((Ve++<Ee||B[0]!==void 0)&&de--);w=B[0]!==void 0}X[0]||X.shift()}if(p==1)I.e=l,Xt=w;else{for(m=1,d=X[0];d>=10;d/=10)m++;I.e=m+l*p-1,g(I,a?o+I.e+1:o,s,w)}return I}}();function g(n,e,t,r){var i,o,s,a,c,u,l,m,d,p=n.constructor;e:if(e!=null){if(m=n.d,!m)return n;for(i=1,a=m[0];a>=10;a/=10)i++;if(o=e-i,o<0)o+=h,s=e,l=m[d=0],c=l/O(10,i-s-1)%10|0;else if(d=Math.ceil((o+1)/h),a=m.length,d>=a)if(r){for(;a++<=d;)m.push(0);l=c=0,i=1,o%=h,s=o-h+1}else break e;else{for(l=a=m[d],i=1;a>=10;a/=10)i++;o%=h,s=o-h+i,c=s<0?0:l/O(10,i-s-1)%10|0}if(r=r||e<0||m[d+1]!==void 0||(s<0?l:l%O(10,i-s-1)),u=t<4?(c||r)&&(t==0||t==(n.s<0?3:2)):c>5||c==5&&(t==4||r||t==6&&(o>0?s>0?l/O(10,i-s):0:m[d-1])%10&1||t==(n.s<0?8:7)),e<1||!m[0])return m.length=0,u?(e-=n.e+1,m[0]=O(10,(h-e%h)%h),n.e=-e||0):m[0]=n.e=0,n;if(o==0?(m.length=d,a=1,d--):(m.length=d+1,a=O(10,h-o),m[d]=s>0?(l/O(10,i-s)%O(10,s)|0)*a:0),u)for(;;)if(d==0){for(o=1,s=m[0];s>=10;s/=10)o++;for(s=m[0]+=a,a=1;s>=10;s/=10)a++;o!=a&&(n.e++,m[0]==re&&(m[0]=1));break}else{if(m[d]+=a,m[d]!=re)break;m[d--]=0,a=1}for(o=m.length;m[--o]===0;)m.pop()}return y&&(n.e>p.maxE?(n.d=null,n.e=NaN):n.e<p.minE&&(n.e=0,n.d=[0])),n}function ae(n,e,t){if(!n.isFinite())return $t(n);var r,i=n.e,o=v(n.d),s=o.length;return e?(t&&(r=t-s)>0?o=o.charAt(0)+"."+o.slice(1)+ge(r):s>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(n.e<0?"e":"e+")+n.e):i<0?(o="0."+ge(-i-1)+o,t&&(r=t-s)>0&&(o+=ge(r))):i>=s?(o+=ge(i+1-s),t&&(r=t-i-1)>0&&(o=o+"."+ge(r))):((r=i+1)<s&&(o=o.slice(0,r)+"."+o.slice(r)),t&&(r=t-s)>0&&(i+1===s&&(o+="."),o+=ge(r))),o}function je(n,e){var t=n[0];for(e*=h;t>=10;t/=10)e++;return e}function Ye(n,e,t){if(e>Kn)throw y=!0,t&&(n.precision=t),Error(zt);return g(new n(ze),e,1,!0)}function ne(n,e,t){if(e>dt)throw Error(zt);return g(new n(He),e,t,!0)}function jt(n){var e=n.length-1,t=e*h+1;if(e=n[e],e){for(;e%10==0;e/=10)t--;for(e=n[0];e>=10;e/=10)t++}return t}function ge(n){for(var e="";n--;)e+="0";return e}function Qt(n,e,t,r){var i,o=new n(1),s=Math.ceil(r/h+4);for(y=!1;;){if(t%2&&(o=o.times(e),Ut(o.d,s)&&(i=!0)),t=G(t/2),t===0){t=o.d.length-1,i&&o.d[t]===0&&++o.d[t];break}e=e.times(e),Ut(e.d,s)}return y=!0,o}function Vt(n){return n.d[n.d.length-1]&1}function Jt(n,e,t){for(var r,i=new n(e[0]),o=0;++o<e.length;)if(r=new n(e[o]),r.s)i[t](r)&&(i=r);else{i=r;break}return i}function ft(n,e){var t,r,i,o,s,a,c,u=0,l=0,m=0,d=n.constructor,p=d.rounding,w=d.precision;if(!n.d||!n.d[0]||n.e>17)return new d(n.d?n.d[0]?n.s<0?0:1/0:1:n.s?n.s<0?0:n:0/0);for(e==null?(y=!1,c=w):c=e,a=new d(.03125);n.e>-2;)n=n.times(a),m+=5;for(r=Math.log(O(2,m))/Math.LN10*2+5|0,c+=r,t=o=s=new d(1),d.precision=c;;){if(o=g(o.times(n),c,1),t=t.times(++l),a=s.plus(N(o,t,c,1)),v(a.d).slice(0,c)===v(s.d).slice(0,c)){for(i=m;i--;)s=g(s.times(s),c,1);if(e==null)if(u<3&&Re(s.d,c-r,p,u))d.precision=c+=10,t=o=a=new d(1),l=0,u++;else return g(s,d.precision=w,p,y=!0);else return d.precision=w,s}s=a}}function he(n,e){var t,r,i,o,s,a,c,u,l,m,d,p=1,w=10,b=n,F=b.d,I=b.constructor,X=I.rounding,B=I.precision;if(b.s<0||!F||!F[0]||!b.e&&F[0]==1&&F.length==1)return new I(F&&!F[0]?-1/0:b.s!=1?NaN:F?0:b);if(e==null?(y=!1,l=B):l=e,I.precision=l+=w,t=v(F),r=t.charAt(0),Math.abs(o=b.e)<15e14){for(;r<7&&r!=1||r==1&&t.charAt(1)>3;)b=b.times(n),t=v(b.d),r=t.charAt(0),p++;o=b.e,r>1?(b=new I("0."+t),o++):b=new I(r+"."+t.slice(1))}else return u=Ye(I,l+2,B).times(o+""),b=he(new I(r+"."+t.slice(1)),l-w).plus(u),I.precision=B,e==null?g(b,B,X,y=!0):b;for(m=b,c=s=b=N(b.minus(1),b.plus(1),l,1),d=g(b.times(b),l,1),i=3;;){if(s=g(s.times(d),l,1),u=c.plus(N(s,new I(i),l,1)),v(u.d).slice(0,l)===v(c.d).slice(0,l))if(c=c.times(2),o!==0&&(c=c.plus(Ye(I,l+2,B).times(o+""))),c=N(c,new I(p),l,1),e==null)if(Re(c.d,l-w,X,a))I.precision=l+=w,u=s=b=N(m.minus(1),m.plus(1),l,1),d=g(b.times(b),l,1),i=a=1;else return g(c,I.precision=B,X,y=!0);else return I.precision=B,c;c=u,i+=2}}function $t(n){return String(n.s*n.s/0)}function pt(n,e){var t,r,i;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(t<0&&(t=r),t+=+e.slice(r+1),e=e.substring(0,r)):t<0&&(t=e.length),r=0;e.charCodeAt(r)===48;r++);for(i=e.length;e.charCodeAt(i-1)===48;--i);if(e=e.slice(r,i),e){if(i-=r,n.e=t=t-r-1,n.d=[],r=(t+1)%h,t<0&&(r+=h),r<i){for(r&&n.d.push(+e.slice(0,r)),i-=h;r<i;)n.d.push(+e.slice(r,r+=h));e=e.slice(r),r=h-e.length}else r-=i;for(;r--;)e+="0";n.d.push(+e),y&&(n.e>n.constructor.maxE?(n.d=null,n.e=NaN):n.e<n.constructor.minE&&(n.e=0,n.d=[0]))}else n.e=0,n.d=[0];return n}function Gn(n,e){var t,r,i,o,s,a,c,u,l;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),Zt.test(e))return pt(n,e)}else if(e==="Infinity"||e==="NaN")return+e||(n.s=NaN),n.e=NaN,n.d=null,n;if(Mn.test(e))t=16,e=e.toLowerCase();else if(Dn.test(e))t=2;else if(_n.test(e))t=8;else throw Error(be+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,r=n.constructor,s&&(e=e.replace(".",""),a=e.length,o=a-o,i=Qt(r,new r(t),o,o*2)),u=Xe(e,t,re),l=u.length-1,o=l;u[o]===0;--o)u.pop();return o<0?new r(n.s*0):(n.e=je(u,l),n.d=u,y=!1,s&&(n=N(n,i,a*4)),c&&(n=n.times(Math.abs(c)<54?O(2,c):Fe.pow(2,c))),y=!0,n)}function Vn(n,e){var t,r=e.d.length;if(r<3)return e.isZero()?e:Ie(n,2,e,e);t=1.4*Math.sqrt(r),t=t>16?16:t|0,e=e.times(1/Qe(5,t)),e=Ie(n,2,e,e);for(var i,o=new n(5),s=new n(16),a=new n(20);t--;)i=e.times(e),e=e.times(o.plus(i.times(s.times(i).minus(a))));return e}function Ie(n,e,t,r,i){var o,s,a,c,u=1,l=n.precision,m=Math.ceil(l/h);for(y=!1,c=t.times(t),a=new n(r);;){if(s=N(a.times(c),new n(e++*e++),l,1),a=i?r.plus(s):r.minus(s),r=N(s.times(c),new n(e++*e++),l,1),s=a.plus(r),s.d[m]!==void 0){for(o=m;s.d[o]===a.d[o]&&o--;);if(o==-1)break}o=a,a=r,r=s,s=o,u++}return y=!0,s.d.length=m+1,s}function Qe(n,e){for(var t=n;--e;)t*=n;return t}function en(n,e){var t,r=e.s<0,i=ne(n,n.precision,1),o=i.times(.5);if(e=e.abs(),e.lte(o))return pe=r?4:1,e;if(t=e.divToInt(i),t.isZero())pe=r?3:2;else{if(e=e.minus(t.times(i)),e.lte(o))return pe=Vt(t)?r?2:3:r?4:1,e;pe=Vt(t)?r?1:4:r?3:2}return e.minus(i).abs()}function gt(n,e,t,r){var i,o,s,a,c,u,l,m,d,p=n.constructor,w=t!==void 0;if(w?(z(t,1,ye),r===void 0?r=p.rounding:z(r,0,8)):(t=p.precision,r=p.rounding),!n.isFinite())l=$t(n);else{for(l=ae(n),s=l.indexOf("."),w?(i=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):i=e,s>=0&&(l=l.replace(".",""),d=new p(1),d.e=l.length-s,d.d=Xe(ae(d),10,i),d.e=d.d.length),m=Xe(l,10,i),o=c=m.length;m[--c]==0;)m.pop();if(!m[0])l=w?"0p+0":"0";else{if(s<0?o--:(n=new p(n),n.d=m,n.e=o,n=N(n,d,t,r,0,i),m=n.d,o=n.e,u=Xt),s=m[t],a=i/2,u=u||m[t+1]!==void 0,u=r<4?(s!==void 0||u)&&(r===0||r===(n.s<0?3:2)):s>a||s===a&&(r===4||u||r===6&&m[t-1]&1||r===(n.s<0?8:7)),m.length=t,u)for(;++m[--t]>i-1;)m[t]=0,t||(++o,m.unshift(1));for(c=m.length;!m[c-1];--c);for(s=0,l="";s<c;s++)l+=lt.charAt(m[s]);if(w){if(c>1)if(e==16||e==8){for(s=e==16?4:3,--c;c%s;c++)l+="0";for(m=Xe(l,i,e),c=m.length;!m[c-1];--c);for(s=1,l="1.";s<c;s++)l+=lt.charAt(m[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 n.s<0?"-"+l:l}function Ut(n,e){if(n.length>e)return n.length=e,!0}function Un(n){return new this(n).abs()}function Wn(n){return new this(n).acos()}function Xn(n){return new this(n).acosh()}function zn(n,e){return new this(n).plus(e)}function Hn(n){return new this(n).asin()}function Yn(n){return new this(n).asinh()}function Zn(n){return new this(n).atan()}function jn(n){return new this(n).atanh()}function Qn(n,e){n=new this(n),e=new this(e);var t,r=this.precision,i=this.rounding,o=r+4;return!n.s||!e.s?t=new this(NaN):!n.d&&!e.d?(t=ne(this,o,1).times(e.s>0?.25:.75),t.s=n.s):!e.d||n.isZero()?(t=e.s<0?ne(this,r,i):new this(0),t.s=n.s):!n.d||e.isZero()?(t=ne(this,o,1).times(.5),t.s=n.s):e.s<0?(this.precision=o,this.rounding=1,t=this.atan(N(n,e,o,1)),e=ne(this,o,1),this.precision=r,this.rounding=i,t=n.s<0?t.minus(e):t.plus(e)):t=this.atan(N(n,e,o,1)),t}function Jn(n){return new this(n).cbrt()}function $n(n){return g(n=new this(n),n.e+1,2)}function er(n,e,t){return new this(n).clamp(e,t)}function tr(n){if(!n||typeof n!="object")throw Error(Ze+"Object expected");var e,t,r,i=n.defaults===!0,o=["precision",1,ye,"rounding",0,8,"toExpNeg",-Be,0,"toExpPos",0,Be,"maxE",0,Be,"minE",-Be,0,"modulo",0,9];for(e=0;e<o.length;e+=3)if(t=o[e],i&&(this[t]=mt[t]),(r=n[t])!==void 0)if(G(r)===r&&r>=o[e+1]&&r<=o[e+2])this[t]=r;else throw Error(be+t+": "+r);if(t="crypto",i&&(this[t]=mt[t]),(r=n[t])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(Ht);else this[t]=!1;else throw Error(be+t+": "+r);return this}function nr(n){return new this(n).cos()}function rr(n){return new this(n).cosh()}function tn(n){var e,t,r;function i(o){var s,a,c,u=this;if(!(u instanceof i))return new i(o);if(u.constructor=i,Wt(o)){u.s=o.s,y?!o.d||o.e>i.maxE?(u.e=NaN,u.d=null):o.e<i.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++;y?s>i.maxE?(u.e=NaN,u.d=null):s<i.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 pt(u,o.toString())}else if(c!=="string")throw Error(be+o);return(a=o.charCodeAt(0))===45?(o=o.slice(1),u.s=-1):(a===43&&(o=o.slice(1)),u.s=1),Zt.test(o)?pt(u,o):Gn(u,o)}if(i.prototype=f,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=tr,i.clone=tn,i.isDecimal=Wt,i.abs=Un,i.acos=Wn,i.acosh=Xn,i.add=zn,i.asin=Hn,i.asinh=Yn,i.atan=Zn,i.atanh=jn,i.atan2=Qn,i.cbrt=Jn,i.ceil=$n,i.clamp=er,i.cos=nr,i.cosh=rr,i.div=ir,i.exp=or,i.floor=sr,i.hypot=ar,i.ln=ur,i.log=cr,i.log10=mr,i.log2=lr,i.max=dr,i.min=fr,i.mod=pr,i.mul=gr,i.pow=hr,i.random=br,i.round=yr,i.sign=wr,i.sin=Tr,i.sinh=Ar,i.sqrt=xr,i.sub=kr,i.sum=Pr,i.tan=Br,i.tanh=Ir,i.trunc=Nr,n===void 0&&(n={}),n&&n.defaults!==!0)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<r.length;)n.hasOwnProperty(t=r[e++])||(n[t]=this[t]);return i.config(n),i}function ir(n,e){return new this(n).div(e)}function or(n){return new this(n).exp()}function sr(n){return g(n=new this(n),n.e+1,3)}function ar(){var n,e,t=new this(0);for(y=!1,n=0;n<arguments.length;)if(e=new this(arguments[n++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return y=!0,new this(1/0);t=e}return y=!0,t.sqrt()}function Wt(n){return n instanceof Fe||n&&n.toStringTag===Yt||!1}function ur(n){return new this(n).ln()}function cr(n,e){return new this(n).log(e)}function lr(n){return new this(n).log(2)}function mr(n){return new this(n).log(10)}function dr(){return Jt(this,arguments,"lt")}function fr(){return Jt(this,arguments,"gt")}function pr(n,e){return new this(n).mod(e)}function gr(n,e){return new this(n).mul(e)}function hr(n,e){return new this(n).pow(e)}function br(n){var e,t,r,i,o=0,s=new this(1),a=[];if(n===void 0?n=this.precision:z(n,1,ye),r=Math.ceil(n/h),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(r));o<r;)i=e[o],i>=429e7?e[o]=crypto.getRandomValues(new Uint32Array(1))[0]:a[o++]=i%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(r*=4);o<r;)i=e[o]+(e[o+1]<<8)+(e[o+2]<<16)+((e[o+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(e,o):(a.push(i%1e7),o+=4);o=r/4}else throw Error(Ht);else for(;o<r;)a[o++]=Math.random()*1e7|0;for(r=a[--o],n%=h,r&&n&&(i=O(10,h-n),a[o]=(r/i|0)*i);a[o]===0;o--)a.pop();if(o<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=h)a.shift();for(r=1,i=a[0];i>=10;i/=10)r++;r<h&&(t-=h-r)}return s.e=t,s.d=a,s}function yr(n){return g(n=new this(n),n.e+1,this.rounding)}function wr(n){return n=new this(n),n.d?n.d[0]?n.s:0*n.s:n.s||NaN}function Tr(n){return new this(n).sin()}function Ar(n){return new this(n).sinh()}function xr(n){return new this(n).sqrt()}function kr(n,e){return new this(n).sub(e)}function Pr(){var n=0,e=arguments,t=new this(e[n]);for(y=!1;t.s&&++n<e.length;)t=t.plus(e[n]);return y=!0,g(t,this.precision,this.rounding)}function Br(n){return new this(n).tan()}function Ir(n){return new this(n).tanh()}function Nr(n){return g(n=new this(n),n.e+1,1)}f[Symbol.for("nodejs.util.inspect.custom")]=f.toString;f[Symbol.toStringTag]="Decimal";var Fe=f.constructor=tn(mt);ze=new Fe(ze);He=new Fe(He);var M=Fe;import{PublicKey as wt}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as Sr}from"@solana/spl-token";import{PublicKey as E,SystemProgram as Cr,SYSVAR_RENT_PUBKEY as Lr}from"@solana/web3.js";function ht({pubkey:n,isSigner:e=!1,isWritable:t=!0}){return{pubkey:n,isWritable:t,isSigner:e}}var xi=[ht({pubkey:Sr,isWritable:!1}),ht({pubkey:Cr.programId,isWritable:!1}),ht({pubkey:Lr,isWritable:!1})];function nn({publicKey:n,transformSol:e}){let t=rn(n.toString());if(t instanceof E)return e&&t.equals(Ne)?bt:t;if(e&&t.toString()===Ne.toBase58())return bt;if(typeof t=="string"){if(t===E.default.toBase58())return E.default;try{return new E(t)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function rn(n){try{return new E(n)}catch{return n}}var ki=new E("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),Pi=new E("SysvarRent111111111111111111111111111111111"),Bi=new E("SysvarC1ock11111111111111111111111111111111"),Er=new E("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),Ii=new E("Sysvar1nstructions1111111111111111111111111"),Ni=new E("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),Si=new E("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),Ci=new E("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),Li=new E("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),Ei=new E("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),Ri=new E("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),Fi=new E("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),Oi=new E("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),Di=new E("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),Mi=new E("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),_i=new E("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),bt=new E("So11111111111111111111111111111111111111112"),Ne=E.default;import{PublicKey as Rr}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as on}from"@solana/spl-token";var yt={chainId:101,address:Rr.default.toBase58(),programId:on.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"https://img.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}},Ae={chainId:101,address:"So11111111111111111111111111111111111111112",programId:on.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 Tt=class{constructor({mint:e,decimals:t,symbol:r,name:i,skipMint:o=!1,isToken2022:s=!1}){if(e===Ne.toBase58()||e instanceof wt&&Ne.equals(e)){this.decimals=Ae.decimals,this.symbol=Ae.symbol,this.name=Ae.name,this.mint=new wt(Ae.address),this.isToken2022=!1;return}this.decimals=t,this.symbol=r||e.toString().substring(0,6),this.name=i||e.toString().substring(0,6),this.mint=o?wt.default:nn({publicKey:e}),this.isToken2022=s}equals(e){return this===e?!0:this.mint.equals(e.mint)}},xe=Tt;xe.WSOL=new Tt(fe(se({},Ae),{mint:Ae.address}));import{get as sn,set as Fr}from"lodash";import un from"dayjs";import Or from"dayjs/plugin/utc";un.extend(Or);var At=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 un().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(r=>typeof r=="object"?JSON.stringify(r):r).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}},an={},Dr={};function Y(n){let e=sn(an,n);if(!e){let t=sn(Dr,n);e=new At({name:n,logLevel:t}),Fr(an,n,e)}return e}import $e from"big.js";import vr from"bn.js";import Kr from"decimal.js-light";import Mr from"toformat";var _r=Mr,Oe=_r;var Je=Y("module/fraction"),xt=Oe($e),De=Oe(Kr),qr={[0]:De.ROUND_DOWN,[1]:De.ROUND_HALF_UP,[2]:De.ROUND_UP},Gr={[0]:$e.roundDown,[1]:$e.roundHalfUp,[2]:$e.roundUp},k=class{constructor(e,t=new vr(1)){this.numerator=j(e),this.denominator=j(t)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new k(this.denominator,this.numerator)}add(e){let t=e instanceof k?e:new k(j(e));return this.denominator.eq(t.denominator)?new k(this.numerator.add(t.numerator),this.denominator):new k(this.numerator.mul(t.denominator).add(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}sub(e){let t=e instanceof k?e:new k(j(e));return this.denominator.eq(t.denominator)?new k(this.numerator.sub(t.numerator),this.denominator):new k(this.numerator.mul(t.denominator).sub(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}mul(e){let t=e instanceof k?e:new k(j(e));return new k(this.numerator.mul(t.numerator),this.denominator.mul(t.denominator))}div(e){let t=e instanceof k?e:new k(j(e));return new k(this.numerator.mul(t.denominator),this.denominator.mul(t.numerator))}toSignificant(e,t={groupSeparator:""},r=1){Number.isInteger(e)||Je.logWithError(`${e} is not an integer.`),e<=0&&Je.logWithError(`${e} is not positive.`),De.set({precision:e+1,rounding:qr[r]});let i=new De(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(e);return i.toFormat(i.decimalPlaces(),t)}toFixed(e,t={groupSeparator:""},r=1){return Number.isInteger(e)||Je.logWithError(`${e} is not an integer.`),e<0&&Je.logWithError(`${e} is negative.`),xt.DP=e,xt.RM=Gr[r]||1,new xt(this.numerator.toString()).div(this.denominator.toString()).toFormat(e,t)}isZero(){return this.numerator.isZero()}};var Ur=Y("Raydium_price"),ue=class extends k{constructor(t){let{baseToken:r,quoteToken:i,numerator:o,denominator:s}=t;super(o,s);this.baseToken=r,this.quoteToken=i,this.scalar=new k(kt(r.decimals),kt(i.decimals))}get raw(){return new k(this.numerator,this.denominator)}get adjusted(){return super.mul(this.scalar)}invert(){return new ue({baseToken:this.quoteToken,quoteToken:this.baseToken,denominator:this.numerator,numerator:this.denominator})}mul(t){this.quoteToken!==t.baseToken&&Ur.logWithError("mul token not equals");let r=super.mul(t);return new ue({baseToken:this.baseToken,quoteToken:t.quoteToken,denominator:r.denominator,numerator:r.numerator})}toSignificant(t=this.quoteToken.decimals,r,i){return this.adjusted.toSignificant(t,r,i)}toFixed(t=this.quoteToken.decimals,r,i){return this.adjusted.toFixed(t,r,i)}};var Pt=class{constructor({decimals:e,symbol:t="UNKNOWN",name:r="UNKNOWN"}){this.decimals=e,this.symbol=t,this.name=r}equals(e){return this===e}},et=Pt;et.SOL=new Pt(yt);import Wr from"big.js";import tt from"bn.js";var Xr=Y("Raydium_amount"),cn=Oe(Wr);function zr(n,e){let t="0",r="0";if(n.includes(".")){let i=n.split(".");i.length===2?([t,r]=i,r=r.padEnd(e,"0")):Xr.logWithError(`invalid number string, num: ${n}`)}else t=n;return[t,r.slice(0,e)||r]}var ce=class extends k{constructor(t,r,i=!0,o){let s=new tt(0),a=Bt.pow(new tt(t.decimals));if(i)s=j(r);else{let c=new tt(0),u=new tt(0);if(typeof r=="string"||typeof r=="number"||typeof r=="bigint"){let[l,m]=zr(r.toString(),t.decimals);c=j(l),u=j(m)}c=c.mul(a),s=c.add(u)}super(s,a);this.logger=Y(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 ce(this.token,this.raw.add(t.raw))}subtract(t){return this.token.equals(t.token)||this.logger.logWithError("sub token not equals"),new ce(this.token,this.raw.sub(t.raw))}toSignificant(t=this.token.decimals,r,i=0){return super.toSignificant(t,r,i)}toFixed(t=this.token.decimals,r,i=0){return t>this.token.decimals&&this.logger.logWithError("decimals overflow"),super.toFixed(t,r,i)}toExact(t={groupSeparator:""}){return cn.DP=this.token.decimals,new cn(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)}};import Hr from"bn.js";var ln=new k(new Hr(100)),ke=class extends k{toSignificant(e=5,t,r){return this.mul(ln).toSignificant(e,t,r)}toFixed(e=2,t,r){return this.mul(ln).toFixed(e,t,r)}};function Se(n){if(n instanceof ke)return new k(n.numerator,n.denominator);if(n instanceof ue)return n.adjusted;if(n instanceof ce)try{return Se(n.toExact())}catch{return new k(nt)}if(n instanceof k)return n;let e=String(n),t=It(e);return new k(t.numerator,t.denominator)}function mn(n,e){if(n==null||e==null)return!1;let t=Se(n),r=Se(e);return t.sub(r).numerator,t.sub(r).numerator.lt(nt)}function dn(n,e){if(n==null||e==null)return!1;let t=Se(n),r=Se(e);return t.sub(r).numerator.gt(nt)}import{PublicKey as Wo}from"@solana/web3.js";import zo from"bn.js";var nt=new U(0),ls=new U(1),ms=new U(2),ds=new U(3),fs=new U(5),Bt=new U(10),ps=new U(100),gs=new U(1e3),hs=new U(1e4),fn=9007199254740991;function j(n){let e=Y("Raydium_parseBigNumberish");if(n instanceof U)return n;if(typeof n=="string"){if(n.match(/^-?[0-9]+$/))return new U(n);e.logWithError(`invalid BigNumberish string: ${n}`)}return typeof n=="number"?(n%1&&e.logWithError(`BigNumberish number underflow: ${n}`),(n>=fn||n<=-fn)&&e.logWithError(`BigNumberish number overflow: ${n}`),new U(String(n))):typeof n=="bigint"?new U(n.toString()):(e.error(`invalid BigNumberish value: ${n}`),new U(0))}function kt(n){return Bt.pow(j(n))}function It(n){var a;if(n===void 0)return{denominator:"1",numerator:"0"};if(n instanceof U)return{numerator:n.toString(),denominator:"1"};if(n instanceof k)return{denominator:n.denominator.toString(),numerator:n.numerator.toString()};let e=String(n),[,t="",r="",i=""]=(a=e.replace(",","").match(/(-?)(\d*)\.?(\d*)/))!=null?a:[],o="1"+"0".repeat(i.length),s=t+(r==="0"?"":r)+i||"0";return{denominator:o,numerator:s,sign:t,int:r,dec:i}}function rt(n){if(n==null)return;let{numerator:e,denominator:t}=It(n.toString());return new k(e,t)}import{PublicKey as la,sendAndConfirmTransaction as ma,Transaction as fa,TransactionMessage as ga,VersionedTransaction as ha}from"@solana/web3.js";import ya from"axios";import{PublicKey as xs,ComputeBudgetProgram as ks,Transaction as Bs,TransactionMessage as Ns,Keypair as Ss,VersionedTransaction as Ls}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as Rs}from"@solana/spl-token";var Ds=Y("Raydium_txUtil");import{PublicKey as Yr,AddressLookupTableAccount as pn}from"@solana/web3.js";import{PublicKey as Gs}from"@solana/web3.js";import{getTransferFeeConfig as Us,unpackMint as Ws}from"@solana/spl-token";var Hs=Y("Raydium_accountInfo_util");var Zr={"2immgwYNHBbyVQKVGCEkgWpi53bLwWNRMB5G2nbgYV17":new pn({key:new Yr("2immgwYNHBbyVQKVGCEkgWpi53bLwWNRMB5G2nbgYV17"),state:pn.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"))})};import{PublicKey as H}from"@solana/web3.js";var Sa=new H("EhhTKczWMGQt46ynNeRX1WfeagwwJd7ufHvCDjRxjo5Q"),Ca=new H("9KEPoZmtHUrBbhWN1v1KWLMkkvwY6WLtAVUCPRtRjP4z"),La=new H("FarmqiPv5eAj3j1GMdMCMUGXqPUvmquZtMy86QH6rzhG"),Ea=new H("CLaimxFqjHzgTJtAGHU47NPhg6qrc5sCnpC4tBLyABQS"),Ra=new H("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX"),Fa=new H("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin"),Oa=new H("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"),Da=new H("5quBtoiQqxF9Jv6KYKctB59NT3gtJD2Y65kdnB1Uev3h"),Ma=new H("CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK"),_a=new H("routeUGWgWzqBWFcrCfv8tritsqukccJPu3q5GPP3xS"),va=new H("6FJon3QE27qgPVggARueB22hLvoh22VzJpXv4rBEoSLF"),Ka=new H("CC12se5To1CdEuw7fDS27B7Geo5jJyL7t5UK2B44NgiH"),qa=new H("9HzJyW1qZsEiSfMUf6L2jo3CcTKAyBmSyKdwQeYisHrC"),Ga=new H("DropEU8AvevN3UrXWXTMuz3rqnMczQVNjq3kcSdW2SQi");import{PublicKey as Wa}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as Ha}from"@solana/spl-token";import ie from"bn.js";var Me=1e4;function oe(n,e,t,r){if(e===void 0)return{amount:n,fee:void 0,expirationTime:void 0};let i=fe(se({},e),{olderTransferFee:{epoch:BigInt(e.olderTransferFee.epoch),maximumFee:BigInt(e.olderTransferFee.maximumFee),transferFeeBasisPoints:e.olderTransferFee.transferFeeBasisPoints},newerTransferFee:{epoch:BigInt(e.newerTransferFee.epoch),maximumFee:BigInt(e.newerTransferFee.maximumFee),transferFeeBasisPoints:e.newerTransferFee.transferFeeBasisPoints}}),o=t.epoch<i.newerTransferFee.epoch?i.olderTransferFee:i.newerTransferFee,s=new ie(o.maximumFee.toString()),a=t.epoch<i.newerTransferFee.epoch?(Number(i.newerTransferFee.epoch)*t.slotsInEpoch-t.absoluteSlot)*400/1e3:void 0;if(r)if(o.transferFeeBasisPoints===Me){let c=new ie(o.maximumFee.toString());return{amount:n.add(c),fee:c,expirationTime:a}}else{let c=Nt(n.mul(new ie(Me)),new ie(Me-o.transferFeeBasisPoints)),u=new ie(o.maximumFee.toString()),l=c.sub(n).gt(u)?n.add(u):c,m=Nt(l.mul(new ie(o.transferFeeBasisPoints)),new ie(Me)),d=m.gt(s)?s:m;return{amount:l,fee:d,expirationTime:a}}else{let c=Nt(n.mul(new ie(o.transferFeeBasisPoints)),new ie(Me)),u=c.gt(s)?s:c;return{amount:n,fee:u,expirationTime:a}}}function _e(n,e){return n===void 0?e:e===void 0?n:Math.min(n,e)}function Nt(n,e){let{div:t,mod:r}=n.divmod(e);return r.gt(new ie(0))?t.add(new ie(1)):t}import le from"bn.js";var Q=new le(0),we=new le(1),hn=new le(-1),J=new le(1).shln(64),it=new le(1).shln(128),St=J.sub(we),ve=64,bn=it.subn(1),Pe=-443636,Ce=-Pe,Ct=new le("4295048016"),Lt=new le("79226673521066979257578248091"),yn=16,wn="59543866431248",Tn="184467440737095516",An="15793534762490258745",Qr=new le(10).pow(new le(6));var gu=new le("18446744073700000000");import P from"bn.js";var xu=Buffer.from("amm_config","utf8"),ku=Buffer.from("pool","utf8"),Pu=Buffer.from("pool_vault","utf8"),Bu=Buffer.from("pool_reward_vault","utf8"),Iu=Buffer.from("position","utf8"),Nu=Buffer.from("tick_array","utf8"),Su=Buffer.from("operation","utf8"),Cu=Buffer.from("pool_tick_array_bitmap_extension","utf8");import{PublicKey as bl}from"@solana/web3.js";import Al from"bn.js";import nl from"bn.js";import{PublicKey as si}from"@solana/web3.js";import Bn,{isBN as In}from"bn.js";import{bits as Ru,BitStructure as Fu,blob as Jr,Blob as Ou,cstr as Du,f32 as Mu,f32be as _u,f64 as vu,f64be as Ku,greedy as qu,Layout as $r,ns64 as Gu,ns64be as Vu,nu64 as Uu,nu64be as Wu,offset as Xu,s16 as zu,s16be as Hu,s24 as Yu,s24be as Zu,s32 as ei,s32be as ju,s40 as Qu,s40be as Ju,s48 as $u,s48be as ec,s8 as tc,seq as ti,struct as nc,Structure as ni,u16 as ri,u16be as rc,u24 as ic,u24be as oc,u32 as sc,u32be as ac,u40 as uc,u40be as cc,u48 as lc,u48be as mc,u8 as ii,UInt as oi,union as dc,Union as fc,unionLayoutDiscriminator as pc,utf8 as gc}from"@solana/buffer-layout";var Et=$r,xn=ni;var Rt=oi;var kn=ii,Le=ri;var Te=ei;var Pn=ti;var $=Jr;var Ke=class extends Et{constructor(t,r,i){super(t,i);this.blob=$(t),this.signed=r}decode(t,r=0){let i=new Bn(this.blob.decode(t,r),10,"le");return this.signed?i.fromTwos(this.span*8).clone():i}encode(t,r,i=0){return typeof t=="number"&&(t=new Bn(t)),this.signed&&(t=t.toTwos(this.span*8)),this.blob.encode(t.toArrayLike(Buffer,"le",this.span),r,i)}};function ee(n){return new Rt(1,n)}function qe(n){return new Rt(4,n)}function S(n){return new Ke(8,!1,n)}function C(n){return new Ke(16,!1,n)}function Nn(n){return new Ke(16,!0,n)}var ot=class extends Et{constructor(t,r,i,o){super(t.span,o);this.layout=t,this.decoder=r,this.encoder=i}decode(t,r){return this.decoder(this.layout.decode(t,r))}encode(t,r,i){return this.layout.encode(this.encoder(t),r,i)}getSpan(t,r){return this.layout.getSpan(t,r)}};function D(n){return new ot($(32),e=>new si(e),e=>e.toBuffer(),n)}function Sn(n){return new ot(kn(),ai,ui,n)}function ai(n){if(n===0)return!1;if(n===1)return!0;throw new Error("Invalid bool: "+n)}function ui(n){return n?1:0}var Ft=class extends xn{decode(e,t){return super.decode(e,t)}};function Z(n,e,t){return new Ft(n,e,t)}function R(n,e,t){let r,i=typeof e=="number"?e:In(e)?e.toNumber():new Proxy(e,{get(o,s){if(!r){let a=Reflect.get(o,"count");r=In(a)?a.toNumber():a,Reflect.set(o,"count",r)}return Reflect.get(o,s)},set(o,s,a){return s==="count"&&(r=a),Reflect.set(o,s,a)}});return Pn(n,i,t)}var Ot=14;var Gc=Z([$(8),ee("bump"),Le("index"),D(""),qe("protoco