@raydium-io/raydium-sdk-v2
Version:
An SDK for building applications on top of Raydium.
1 lines • 500 kB
JavaScript
var ad=Object.defineProperty,ud=Object.defineProperties;var cd=Object.getOwnPropertyDescriptors;var kr=Object.getOwnPropertySymbols;var fc=Object.prototype.hasOwnProperty,yc=Object.prototype.propertyIsEnumerable;var pc=(i,e,t)=>e in i?ad(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,_=(i,e)=>{for(var t in e||(e={}))fc.call(e,t)&&pc(i,t,e[t]);if(kr)for(var t of kr(e))yc.call(e,t)&&pc(i,t,e[t]);return i},U=(i,e)=>ud(i,cd(e));var Qe=(i,e)=>{var t={};for(var n in i)fc.call(i,n)&&e.indexOf(n)<0&&(t[n]=i[n]);if(i!=null&&kr)for(var n of kr(i))e.indexOf(n)<0&&yc.call(i,n)&&(t[n]=i[n]);return t};import ol from"axios";import{PublicKey as Pc}from"@solana/web3.js";import{get as Ws,set as bc}from"lodash";var ld=(o=>(o[o.Error=0]="Error",o[o.Warning=1]="Warning",o[o.Info=2]="Info",o[o.Debug=3]="Debug",o))(ld||{}),Ds=class{constructor(e){this.logLevel=e.logLevel!==void 0?e.logLevel:0,this.name=e.name}set level(e){this.logLevel=e}get time(){return Date.now().toString()}get moduleName(){return this.name}isLogLevel(e){return e<=this.logLevel}error(...e){return this.isLogLevel(0)?(console.error(this.time,this.name,"sdk logger error",...e),this):this}logWithError(...e){let t=e.map(n=>typeof n=="object"?JSON.stringify(n):n).join(", ");throw new Error(t)}warning(...e){return this.isLogLevel(1)?(console.warn(this.time,this.name,"sdk logger warning",...e),this):this}info(...e){return this.isLogLevel(2)?(console.info(this.time,this.name,"sdk logger info",...e),this):this}debug(...e){return this.isLogLevel(3)?(console.debug(this.time,this.name,"sdk logger debug",...e),this):this}},qs={},gc={};function ke(i){let e=Ws(qs,i);if(!e){let t=Ws(gc,i);e=new Ds({name:i,logLevel:t}),bc(qs,i,e)}return e}function fg(i,e){bc(gc,i,e);let t=Ws(qs,i);t&&(t.level=e)}import{MINT_SIZE as md,TOKEN_PROGRAM_ID as dd,getTransferFeeConfig as pd,unpackMint as fd}from"@solana/spl-token";var Us=ke("Raydium_accountInfo_util");async function dn(i,e,t){let{batchRequest:n,commitment:o="confirmed",chunkCount:r=100}=_({batchRequest:!1},t),s=Gs(e,r),a=new Array(s.length).fill([]);if(n){let c=s.map(m=>{let d=i._buildArgs([m.map(p=>p.toBase58())],o,"base64");return{methodName:"getMultipleAccounts",args:d}}),u=Gs(c,10);a=(await(await Promise.all(u.map(async m=>await i._rpcBatchRequest(m)))).flat()).map(m=>(m.error&&Us.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${m.error.message}`),m.result.value.map(d=>{if(d){let{data:p,executable:f,lamports:y,owner:b,rentEpoch:g}=d;return p.length!==2&&p[1]!=="base64"&&Us.logWithError("info must be base64 encoded, RPC_ERROR"),{data:Buffer.from(p[0],"base64"),executable:f,lamports:y,owner:new Pc(b),rentEpoch:g}}return null})))}else try{a=await Promise.all(s.map(c=>i.getMultipleAccountsInfo(c,o)))}catch(c){c instanceof Error&&Us.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${c.message}`)}return a.flat()}async function De(i,e,t){let n=await dn(i,e.map(o=>o.pubkey),t);return e.map((o,r)=>U(_({},o),{accountInfo:n[r]}))}var yd=(n=>(n[n.Uninitialized=0]="Uninitialized",n[n.Mint=1]="Mint",n[n.Account=2]="Account",n))(yd||{}),Tg=1;async function Eo({connection:i,mints:e,config:t}){var r,s,a;if(e.length===0)return{};let n=await De(i,e.map(c=>({pubkey:It(c)})),t),o={};for(let c of n){if(!c.accountInfo||c.accountInfo.data.length<md){console.log("invalid mint account",c.pubkey.toBase58());continue}let u=fd(c.pubkey,c.accountInfo,(r=c.accountInfo)==null?void 0:r.owner);o[c.pubkey.toString()]=U(_({},u),{programId:((s=c.accountInfo)==null?void 0:s.owner)||dd,feeConfig:(a=pd(u))!=null?a:void 0})}return o[Pc.default.toBase58()]=o[$.toBase58()],o}import tt from"bn.js";var Vo=9e15,Zn=1e9,Xs="0123456789abcdef",Tr="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Ir="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",zs={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Vo,maxE:Vo,crypto:!1},hc,Rn,ge=!0,xr="[DecimalError] ",jn=xr+"Invalid argument: ",Tc=xr+"Precision limit exceeded",Ic=xr+"crypto unavailable",Bc="[object Decimal]",Bt=Math.floor,lt=Math.pow,bd=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,gd=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Pd=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,xc=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,fn=1e7,pe=7,Ad=9007199254740991,wd=Tr.length-1,Ys=Ir.length-1,X={toStringTag:Bc};X.absoluteValue=X.abs=function(){var i=new this.constructor(this);return i.s<0&&(i.s=1),se(i)};X.ceil=function(){return se(new this.constructor(this),this.e+1,2)};X.clampedTo=X.clamp=function(i,e){var t,n=this,o=n.constructor;if(i=new o(i),e=new o(e),!i.s||!e.s)return new o(NaN);if(i.gt(e))throw Error(jn+e);return t=n.cmp(i),t<0?i:n.cmp(e)>0?e:new o(n)};X.comparedTo=X.cmp=function(i){var e,t,n,o,r=this,s=r.d,a=(i=new r.constructor(i)).d,c=r.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(r.e!==i.e)return r.e>i.e^c<0?1:-1;for(n=s.length,o=a.length,e=0,t=n<o?n:o;e<t;++e)if(s[e]!==a[e])return s[e]>a[e]^c<0?1:-1;return n===o?0:n>o^c<0?1:-1};X.cosine=X.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())+pe,n.rounding=1,t=kd(n,Lc(n,t)),n.precision=i,n.rounding=e,se(Rn==2||Rn==3?t.neg():t,i,e,!0)):new n(1):new n(NaN)};X.cubeRoot=X.cbrt=function(){var i,e,t,n,o,r,s,a,c,u,l=this,m=l.constructor;if(!l.isFinite()||l.isZero())return new m(l);for(ge=!1,r=l.s*lt(l.s*l,1/3),!r||Math.abs(r)==1/0?(t=wt(l.d),i=l.e,(r=(i-t.length+1)%3)&&(t+=r==1||r==-2?"0":"00"),r=lt(t,1/3),i=Bt((i+1)/3)-(i%3==(i<0?-1:2)),r==1/0?t="5e"+i:(t=r.toExponential(),t=t.slice(0,t.indexOf("e")+1)+i),n=new m(t),n.s=l.s):n=new m(r.toString()),s=(i=m.precision)+3;;)if(a=n,c=a.times(a).times(a),u=c.plus(l),n=qe(u.plus(l).times(a),u.plus(c),s+2,1),wt(a.d).slice(0,s)===(t=wt(n.d)).slice(0,s))if(t=t.slice(s-3,s+1),t=="9999"||!o&&t=="4999"){if(!o&&(se(a,i+1,0),a.times(a).times(a).eq(l))){n=a;break}s+=4,o=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(se(n,i+1,1),e=!n.times(n).times(n).eq(l));break}return ge=!0,se(n,i,m.rounding,e)};X.decimalPlaces=X.dp=function(){var i,e=this.d,t=NaN;if(e){if(i=e.length-1,t=(i-Bt(this.e/pe))*pe,i=e[i],i)for(;i%10==0;i/=10)t--;t<0&&(t=0)}return t};X.dividedBy=X.div=function(i){return qe(this,new this.constructor(i))};X.dividedToIntegerBy=X.divToInt=function(i){var e=this,t=e.constructor;return se(qe(e,new t(i),0,1,1),t.precision,t.rounding)};X.equals=X.eq=function(i){return this.cmp(i)===0};X.floor=function(){return se(new this.constructor(this),this.e+1,3)};X.greaterThan=X.gt=function(i){return this.cmp(i)>0};X.greaterThanOrEqualTo=X.gte=function(i){var e=this.cmp(i);return e==1||e===0};X.hyperbolicCosine=X.cosh=function(){var i,e,t,n,o,r=this,s=r.constructor,a=new s(1);if(!r.isFinite())return new s(r.s?1/0:NaN);if(r.isZero())return a;t=s.precision,n=s.rounding,s.precision=t+Math.max(r.e,r.sd())+4,s.rounding=1,o=r.d.length,o<32?(i=Math.ceil(o/3),e=(1/Kr(4,i)).toString()):(i=16,e="2.3283064365386962890625e-10"),r=Wo(s,1,r.times(e),new s(1),!0);for(var c,u=i,l=new s(8);u--;)c=r.times(r),r=a.minus(c.times(l.minus(c.times(l))));return se(r,s.precision=t,s.rounding=n,!0)};X.hyperbolicSine=X.sinh=function(){var i,e,t,n,o=this,r=o.constructor;if(!o.isFinite()||o.isZero())return new r(o);if(e=r.precision,t=r.rounding,r.precision=e+Math.max(o.e,o.sd())+4,r.rounding=1,n=o.d.length,n<3)o=Wo(r,2,o,o,!0);else{i=1.4*Math.sqrt(n),i=i>16?16:i|0,o=o.times(1/Kr(5,i)),o=Wo(r,2,o,o,!0);for(var s,a=new r(5),c=new r(16),u=new r(20);i--;)s=o.times(o),o=o.times(a.plus(s.times(c.times(s).plus(u))))}return r.precision=e,r.rounding=t,se(o,e,t,!0)};X.hyperbolicTangent=X.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,qe(t.sinh(),t.cosh(),n.precision=i,n.rounding=e)):new n(t.s)};X.inverseCosine=X.acos=function(){var i,e=this,t=e.constructor,n=e.abs().cmp(1),o=t.precision,r=t.rounding;return n!==-1?n===0?e.isNeg()?pn(t,o,r):new t(0):new t(NaN):e.isZero()?pn(t,o+4,r).times(.5):(t.precision=o+6,t.rounding=1,e=e.asin(),i=pn(t,o+4,r).times(.5),t.precision=o,t.rounding=r,i.minus(e))};X.inverseHyperbolicCosine=X.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,ge=!1,t=t.times(t).minus(1).sqrt().plus(t),ge=!0,n.precision=i,n.rounding=e,t.ln()):new n(t)};X.inverseHyperbolicSine=X.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,ge=!1,t=t.times(t).plus(1).sqrt().plus(t),ge=!0,n.precision=i,n.rounding=e,t.ln())};X.inverseHyperbolicTangent=X.atanh=function(){var i,e,t,n,o=this,r=o.constructor;return o.isFinite()?o.e>=0?new r(o.abs().eq(1)?o.s/0:o.isZero()?o:NaN):(i=r.precision,e=r.rounding,n=o.sd(),Math.max(n,i)<2*-o.e-1?se(new r(o),i,e,!0):(r.precision=t=n-o.e,o=qe(o.plus(1),new r(1).minus(o),t+i,1),r.precision=i+4,r.rounding=1,o=o.ln(),r.precision=i,r.rounding=e,o.times(.5))):new r(NaN)};X.inverseSine=X.asin=function(){var i,e,t,n,o=this,r=o.constructor;return o.isZero()?new r(o):(e=o.abs().cmp(1),t=r.precision,n=r.rounding,e!==-1?e===0?(i=pn(r,t+4,n).times(.5),i.s=o.s,i):new r(NaN):(r.precision=t+6,r.rounding=1,o=o.div(new r(1).minus(o.times(o)).sqrt().plus(1)).atan(),r.precision=t,r.rounding=n,o.times(2)))};X.inverseTangent=X.atan=function(){var i,e,t,n,o,r,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<=Ys)return s=pn(l,m+4,d).times(.25),s.s=u.s,s}else{if(!u.s)return new l(NaN);if(m+4<=Ys)return s=pn(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/pe+2|0),i=t;i;--i)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(ge=!1,e=Math.ceil(a/pe),n=1,c=u.times(u),s=new l(u),o=u;i!==-1;)if(o=o.times(c),r=s.minus(o.div(n+=2)),o=o.times(c),s=r.plus(o.div(n+=2)),s.d[e]!==void 0)for(i=e;s.d[i]===r.d[i]&&i--;);return t&&(s=s.times(2<<t-1)),ge=!0,se(s,l.precision=m,l.rounding=d,!0)};X.isFinite=function(){return!!this.d};X.isInteger=X.isInt=function(){return!!this.d&&Bt(this.e/pe)>this.d.length-2};X.isNaN=function(){return!this.s};X.isNegative=X.isNeg=function(){return this.s<0};X.isPositive=X.isPos=function(){return this.s>0};X.isZero=function(){return!!this.d&&this.d[0]===0};X.lessThan=X.lt=function(i){return this.cmp(i)<0};X.lessThanOrEqualTo=X.lte=function(i){return this.cmp(i)<1};X.logarithm=X.log=function(i){var e,t,n,o,r,s,a,c,u=this,l=u.constructor,m=l.precision,d=l.rounding,p=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)r=!0;else{for(o=t[0];o%10===0;)o/=10;r=o!==1}if(ge=!1,a=m+p,s=Qn(u,a),n=e?Br(l,a+10):Qn(i,a),c=qe(s,n,a,1),mi(c.d,o=m,d))do if(a+=10,s=Qn(u,a),n=e?Br(l,a+10):Qn(i,a),c=qe(s,n,a,1),!r){+wt(c.d).slice(o+1,o+15)+1==1e14&&(c=se(c,m+1,0));break}while(mi(c.d,o+=10,d));return ge=!0,se(c,m,d)};X.minus=X.sub=function(i){var e,t,n,o,r,s,a,c,u,l,m,d,p=this,f=p.constructor;if(i=new f(i),!p.d||!i.d)return!p.s||!i.s?i=new f(NaN):p.d?i.s=-i.s:i=new f(i.d||p.s!==i.s?p:NaN),i;if(p.s!=i.s)return i.s=-i.s,p.plus(i);if(u=p.d,d=i.d,a=f.precision,c=f.rounding,!u[0]||!d[0]){if(d[0])i.s=-i.s;else if(u[0])i=new f(p);else return new f(c===3?-0:0);return ge?se(i,a,c):i}if(t=Bt(i.e/pe),l=Bt(p.e/pe),u=u.slice(),r=l-t,r){for(m=r<0,m?(e=u,r=-r,s=d.length):(e=d,t=l,s=u.length),n=Math.max(Math.ceil(a/pe),s)+2,r>n&&(r=n,e.length=1),e.reverse(),n=r;n--;)e.push(0);e.reverse()}else{for(n=u.length,s=d.length,m=n<s,m&&(s=n),n=0;n<s;n++)if(u[n]!=d[n]){m=u[n]<d[n];break}r=0}for(m&&(e=u,u=d,d=e,i.s=-i.s),s=u.length,n=d.length-s;n>0;--n)u[s++]=0;for(n=d.length;n>r;){if(u[--n]<d[n]){for(o=n;o&&u[--o]===0;)u[o]=fn-1;--u[o],u[n]+=fn}u[n]-=d[n]}for(;u[--s]===0;)u.pop();for(;u[0]===0;u.shift())--t;return u[0]?(i.d=u,i.e=Sr(u,t),ge?se(i,a,c):i):new f(c===3?-0:0)};X.modulo=X.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]?se(new n(t),n.precision,n.rounding):(ge=!1,n.modulo==9?(e=qe(t,i.abs(),0,3,1),e.s*=i.s):e=qe(t,i,0,n.modulo,1),e=e.times(i),ge=!0,t.minus(e))};X.naturalExponential=X.exp=function(){return Hs(this)};X.naturalLogarithm=X.ln=function(){return Qn(this)};X.negated=X.neg=function(){var i=new this.constructor(this);return i.s=-i.s,se(i)};X.plus=X.add=function(i){var e,t,n,o,r,s,a,c,u,l,m=this,d=m.constructor;if(i=new d(i),!m.d||!i.d)return!m.s||!i.s?i=new d(NaN):m.d||(i=new d(i.d||m.s===i.s?m:NaN)),i;if(m.s!=i.s)return i.s=-i.s,m.minus(i);if(u=m.d,l=i.d,a=d.precision,c=d.rounding,!u[0]||!l[0])return l[0]||(i=new d(m)),ge?se(i,a,c):i;if(r=Bt(m.e/pe),n=Bt(i.e/pe),u=u.slice(),o=r-n,o){for(o<0?(t=u,o=-o,s=l.length):(t=l,n=r,s=u.length),r=Math.ceil(a/pe),s=r>s?r+1:s+1,o>s&&(o=s,t.length=1),t.reverse();o--;)t.push(0);t.reverse()}for(s=u.length,o=l.length,s-o<0&&(o=s,t=l,l=u,u=t),e=0;o;)e=(u[--o]=u[o]+l[o]+e)/fn|0,u[o]%=fn;for(e&&(u.unshift(e),++n),s=u.length;u[--s]==0;)u.pop();return i.d=u,i.e=Sr(u,n),ge?se(i,a,c):i};X.precision=X.sd=function(i){var e,t=this;if(i!==void 0&&i!==!!i&&i!==1&&i!==0)throw Error(jn+i);return t.d?(e=Sc(t.d),i&&t.e+1>e&&(e=t.e+1)):e=NaN,e};X.round=function(){var i=this,e=i.constructor;return se(new e(i),i.e+1,e.rounding)};X.sine=X.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())+pe,n.rounding=1,t=Td(n,Lc(n,t)),n.precision=i,n.rounding=e,se(Rn>2?t.neg():t,i,e,!0)):new n(NaN)};X.squareRoot=X.sqrt=function(){var i,e,t,n,o,r,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(ge=!1,u=Math.sqrt(+s),u==0||u==1/0?(e=wt(a),(e.length+c)%2==0&&(e+="0"),u=Math.sqrt(e),c=Bt((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(r=n,n=r.plus(qe(s,r,t+2,1)).times(.5),wt(r.d).slice(0,t)===(e=wt(n.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!o&&e=="4999"){if(!o&&(se(r,c+1,0),r.times(r).eq(s))){n=r;break}t+=4,o=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(se(n,c+1,1),i=!n.times(n).eq(s));break}return ge=!0,se(n,c,l.rounding,i)};X.tangent=X.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=qe(t,new n(1).minus(t.times(t)).sqrt(),i+10,0),n.precision=i,n.rounding=e,se(Rn==2||Rn==4?t.neg():t,i,e,!0)):new n(NaN)};X.times=X.mul=function(i){var e,t,n,o,r,s,a,c,u,l=this,m=l.constructor,d=l.d,p=(i=new m(i)).d;if(i.s*=l.s,!d||!d[0]||!p||!p[0])return new m(!i.s||d&&!d[0]&&!p||p&&!p[0]&&!d?NaN:!d||!p?i.s/0:i.s*0);for(t=Bt(l.e/pe)+Bt(i.e/pe),c=d.length,u=p.length,c<u&&(r=d,d=p,p=r,s=c,c=u,u=s),r=[],s=c+u,n=s;n--;)r.push(0);for(n=u;--n>=0;){for(e=0,o=c+n;o>n;)a=r[o]+p[n]*d[o-n-1]+e,r[o--]=a%fn|0,e=a/fn|0;r[o]=(r[o]+e)%fn|0}for(;!r[--s];)r.pop();return e?++t:r.shift(),i.d=r,i.e=Sr(r,t),ge?se(i,m.precision,m.rounding):i};X.toBinary=function(i,e){return js(this,2,i,e)};X.toDecimalPlaces=X.toDP=function(i,e){var t=this,n=t.constructor;return t=new n(t),i===void 0?t:(Ut(i,0,Zn),e===void 0?e=n.rounding:Ut(e,0,8),se(t,i+t.e+1,e))};X.toExponential=function(i,e){var t,n=this,o=n.constructor;return i===void 0?t=In(n,!0):(Ut(i,0,Zn),e===void 0?e=o.rounding:Ut(e,0,8),n=se(new o(n),i+1,e),t=In(n,!0,i+1)),n.isNeg()&&!n.isZero()?"-"+t:t};X.toFixed=function(i,e){var t,n,o=this,r=o.constructor;return i===void 0?t=In(o):(Ut(i,0,Zn),e===void 0?e=r.rounding:Ut(e,0,8),n=se(new r(o),i+o.e+1,e),t=In(n,!1,i+n.e+1)),o.isNeg()&&!o.isZero()?"-"+t:t};X.toFraction=function(i){var e,t,n,o,r,s,a,c,u,l,m,d,p=this,f=p.d,y=p.constructor;if(!f)return new y(p);if(u=t=new y(1),n=c=new y(0),e=new y(n),r=e.e=Sc(f)-p.e-1,s=r%pe,e.d[0]=lt(10,s<0?pe+s:s),i==null)i=r>0?e:u;else{if(a=new y(i),!a.isInt()||a.lt(u))throw Error(jn+a);i=a.gt(e)?r>0?e:u:a}for(ge=!1,a=new y(wt(f)),l=y.precision,y.precision=r=f.length*pe*2;m=qe(a,e,0,1,1),o=t.plus(m.times(n)),o.cmp(i)!=1;)t=n,n=o,o=u,u=c.plus(m.times(o)),c=o,o=e,e=a.minus(m.times(o)),a=o;return o=qe(i.minus(t),n,0,1,1),c=c.plus(o.times(u)),t=t.plus(o.times(n)),c.s=u.s=p.s,d=qe(u,n,r,1).minus(p).abs().cmp(qe(c,t,r,1).minus(p).abs())<1?[u,n]:[c,t],y.precision=l,ge=!0,d};X.toHexadecimal=X.toHex=function(i,e){return js(this,16,i,e)};X.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:Ut(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]?(ge=!1,t=qe(t,i,0,e,1).times(i),ge=!0,se(t)):(i.s=t.s,t=i),t};X.toNumber=function(){return+this};X.toOctal=function(i,e){return js(this,8,i,e)};X.toPower=X.pow=function(i){var e,t,n,o,r,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(lt(+a,u));if(a=new c(a),a.eq(1))return a;if(n=c.precision,r=c.rounding,i.eq(1))return se(a,n,r);if(e=Bt(i.e/pe),e>=i.d.length-1&&(t=u<0?-u:u)<=Ad)return o=Kc(c,a,t,n),i.s<0?new c(1).div(o):se(o,n,r);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=lt(+a,u),e=t==0||!isFinite(t)?Bt(u*(Math.log("0."+wt(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):(ge=!1,c.rounding=a.s=1,t=Math.min(12,(e+"").length),o=Hs(i.times(Qn(a,n+t)),n),o.d&&(o=se(o,n+5,1),mi(o.d,n,r)&&(e=n+10,o=se(Hs(i.times(Qn(a,e+t)),e),e+5,1),+wt(o.d).slice(n+1,n+15)+1==1e14&&(o=se(o,n+1,0)))),o.s=s,ge=!0,c.rounding=r,se(o,n,r))};X.toPrecision=function(i,e){var t,n=this,o=n.constructor;return i===void 0?t=In(n,n.e<=o.toExpNeg||n.e>=o.toExpPos):(Ut(i,1,Zn),e===void 0?e=o.rounding:Ut(e,0,8),n=se(new o(n),i,e),t=In(n,i<=n.e||n.e<=o.toExpNeg,i)),n.isNeg()&&!n.isZero()?"-"+t:t};X.toSignificantDigits=X.toSD=function(i,e){var t=this,n=t.constructor;return i===void 0?(i=n.precision,e=n.rounding):(Ut(i,1,Zn),e===void 0?e=n.rounding:Ut(e,0,8)),se(new n(t),i,e)};X.toString=function(){var i=this,e=i.constructor,t=In(i,i.e<=e.toExpNeg||i.e>=e.toExpPos);return i.isNeg()&&!i.isZero()?"-"+t:t};X.truncated=X.trunc=function(){return se(new this.constructor(this),this.e+1,1)};X.valueOf=X.toJSON=function(){var i=this,e=i.constructor,t=In(i,i.e<=e.toExpNeg||i.e>=e.toExpPos);return i.isNeg()?"-"+t:t};function wt(i){var e,t,n,o=i.length-1,r="",s=i[0];if(o>0){for(r+=s,e=1;e<o;e++)n=i[e]+"",t=pe-n.length,t&&(r+=Hn(t)),r+=n;s=i[e],n=s+"",t=pe-n.length,t&&(r+=Hn(t))}else if(s===0)return"0";for(;s%10===0;)s/=10;return r+s}function Ut(i,e,t){if(i!==~~i||i<e||i>t)throw Error(jn+i)}function mi(i,e,t,n){var o,r,s,a;for(r=i[0];r>=10;r/=10)--e;return--e<0?(e+=pe,o=0):(o=Math.ceil((e+1)/pe),e%=pe),r=lt(10,pe-e),a=i[o]%r|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==r||t>3&&a+1==r/2)&&(i[o+1]/r/100|0)==lt(10,e-2)-1||(a==r/2||a==0)&&(i[o+1]/r/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==r||!n&&t>3&&a+1==r/2)&&(i[o+1]/r/1e3|0)==lt(10,e-3)-1,s}function hr(i,e,t){for(var n,o=[0],r,s=0,a=i.length;s<a;){for(r=o.length;r--;)o[r]*=e;for(o[0]+=Xs.indexOf(i.charAt(s++)),n=0;n<o.length;n++)o[n]>t-1&&(o[n+1]===void 0&&(o[n+1]=0),o[n+1]+=o[n]/t|0,o[n]%=t)}return o.reverse()}function kd(i,e){var t,n,o;if(e.isZero())return e;n=e.d.length,n<32?(t=Math.ceil(n/3),o=(1/Kr(4,t)).toString()):(t=16,o="2.3283064365386962890625e-10"),i.precision+=t,e=Wo(i,1,e.times(o),new i(1));for(var r=t;r--;){var s=e.times(e);e=s.times(s).minus(s).times(8).plus(1)}return i.precision-=t,e}var qe=function(){function i(n,o,r){var s,a=0,c=n.length;for(n=n.slice();c--;)s=n[c]*o+a,n[c]=s%r|0,a=s/r|0;return a&&n.unshift(a),n}function e(n,o,r,s){var a,c;if(r!=s)c=r>s?1:-1;else for(a=c=0;a<r;a++)if(n[a]!=o[a]){c=n[a]>o[a]?1:-1;break}return c}function t(n,o,r,s){for(var a=0;r--;)n[r]-=a,a=n[r]<o[r]?1:0,n[r]=a*s+n[r]-o[r];for(;!n[0]&&n.length>1;)n.shift()}return function(n,o,r,s,a,c){var u,l,m,d,p,f,y,b,g,P,h,I,T,k,S,x,K,B,C,L,N=n.constructor,O=n.s==o.s?1:-1,R=n.d,v=o.d;if(!R||!R[0]||!v||!v[0])return new N(!n.s||!o.s||(R?v&&R[0]==v[0]:!v)?NaN:R&&R[0]==0||!v?O*0:O/0);for(c?(p=1,l=n.e-o.e):(c=fn,p=pe,l=Bt(n.e/p)-Bt(o.e/p)),C=v.length,K=R.length,g=new N(O),P=g.d=[],m=0;v[m]==(R[m]||0);m++);if(v[m]>(R[m]||0)&&l--,r==null?(k=r=N.precision,s=N.rounding):a?k=r+(n.e-o.e)+1:k=r,k<0)P.push(1),f=!0;else{if(k=k/p+2|0,m=0,C==1){for(d=0,v=v[0],k++;(m<K||d)&&k--;m++)S=d*c+(R[m]||0),P[m]=S/v|0,d=S%v|0;f=d||m<K}else{for(d=c/(v[0]+1)|0,d>1&&(v=i(v,d,c),R=i(R,d,c),C=v.length,K=R.length),x=C,h=R.slice(0,C),I=h.length;I<C;)h[I++]=0;L=v.slice(),L.unshift(0),B=v[0],v[1]>=c/2&&++B;do d=0,u=e(v,h,C,I),u<0?(T=h[0],C!=I&&(T=T*c+(h[1]||0)),d=T/B|0,d>1?(d>=c&&(d=c-1),y=i(v,d,c),b=y.length,I=h.length,u=e(y,h,b,I),u==1&&(d--,t(y,C<b?L:v,b,c))):(d==0&&(u=d=1),y=v.slice()),b=y.length,b<I&&y.unshift(0),t(h,y,I,c),u==-1&&(I=h.length,u=e(v,h,C,I),u<1&&(d++,t(h,C<I?L:v,I,c))),I=h.length):u===0&&(d++,h=[0]),P[m++]=d,u&&h[0]?h[I++]=R[x]||0:(h=[R[x]],I=1);while((x++<K||h[0]!==void 0)&&k--);f=h[0]!==void 0}P[0]||P.shift()}if(p==1)g.e=l,hc=f;else{for(m=1,d=P[0];d>=10;d/=10)m++;g.e=m+l*p-1,se(g,a?r+g.e+1:r,s,f)}return g}}();function se(i,e,t,n){var o,r,s,a,c,u,l,m,d,p=i.constructor;e:if(e!=null){if(m=i.d,!m)return i;for(o=1,a=m[0];a>=10;a/=10)o++;if(r=e-o,r<0)r+=pe,s=e,l=m[d=0],c=l/lt(10,o-s-1)%10|0;else if(d=Math.ceil((r+1)/pe),a=m.length,d>=a)if(n){for(;a++<=d;)m.push(0);l=c=0,o=1,r%=pe,s=r-pe+1}else break e;else{for(l=a=m[d],o=1;a>=10;a/=10)o++;r%=pe,s=r-pe+o,c=s<0?0:l/lt(10,o-s-1)%10|0}if(n=n||e<0||m[d+1]!==void 0||(s<0?l:l%lt(10,o-s-1)),u=t<4?(c||n)&&(t==0||t==(i.s<0?3:2)):c>5||c==5&&(t==4||n||t==6&&(r>0?s>0?l/lt(10,o-s):0:m[d-1])%10&1||t==(i.s<0?8:7)),e<1||!m[0])return m.length=0,u?(e-=i.e+1,m[0]=lt(10,(pe-e%pe)%pe),i.e=-e||0):m[0]=i.e=0,i;if(r==0?(m.length=d,a=1,d--):(m.length=d+1,a=lt(10,pe-r),m[d]=s>0?(l/lt(10,o-s)%lt(10,s)|0)*a:0),u)for(;;)if(d==0){for(r=1,s=m[0];s>=10;s/=10)r++;for(s=m[0]+=a,a=1;s>=10;s/=10)a++;r!=a&&(i.e++,m[0]==fn&&(m[0]=1));break}else{if(m[d]+=a,m[d]!=fn)break;m[d--]=0,a=1}for(r=m.length;m[--r]===0;)m.pop()}return ge&&(i.e>p.maxE?(i.d=null,i.e=NaN):i.e<p.minE&&(i.e=0,i.d=[0])),i}function In(i,e,t){if(!i.isFinite())return Rc(i);var n,o=i.e,r=wt(i.d),s=r.length;return e?(t&&(n=t-s)>0?r=r.charAt(0)+"."+r.slice(1)+Hn(n):s>1&&(r=r.charAt(0)+"."+r.slice(1)),r=r+(i.e<0?"e":"e+")+i.e):o<0?(r="0."+Hn(-o-1)+r,t&&(n=t-s)>0&&(r+=Hn(n))):o>=s?(r+=Hn(o+1-s),t&&(n=t-o-1)>0&&(r=r+"."+Hn(n))):((n=o+1)<s&&(r=r.slice(0,n)+"."+r.slice(n)),t&&(n=t-s)>0&&(o+1===s&&(r+="."),r+=Hn(n))),r}function Sr(i,e){var t=i[0];for(e*=pe;t>=10;t/=10)e++;return e}function Br(i,e,t){if(e>wd)throw ge=!0,t&&(i.precision=t),Error(Tc);return se(new i(Tr),e,1,!0)}function pn(i,e,t){if(e>Ys)throw Error(Tc);return se(new i(Ir),e,t,!0)}function Sc(i){var e=i.length-1,t=e*pe+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 Hn(i){for(var e="";i--;)e+="0";return e}function Kc(i,e,t,n){var o,r=new i(1),s=Math.ceil(n/pe+4);for(ge=!1;;){if(t%2&&(r=r.times(e),wc(r.d,s)&&(o=!0)),t=Bt(t/2),t===0){t=r.d.length-1,o&&r.d[t]===0&&++r.d[t];break}e=e.times(e),wc(e.d,s)}return ge=!0,r}function Ac(i){return i.d[i.d.length-1]&1}function Cc(i,e,t){for(var n,o=new i(e[0]),r=0;++r<e.length;)if(n=new i(e[r]),n.s)o[t](n)&&(o=n);else{o=n;break}return o}function Hs(i,e){var t,n,o,r,s,a,c,u=0,l=0,m=0,d=i.constructor,p=d.rounding,f=d.precision;if(!i.d||!i.d[0]||i.e>17)return new d(i.d?i.d[0]?i.s<0?0:1/0:1:i.s?i.s<0?0:i:0/0);for(e==null?(ge=!1,c=f):c=e,a=new d(.03125);i.e>-2;)i=i.times(a),m+=5;for(n=Math.log(lt(2,m))/Math.LN10*2+5|0,c+=n,t=r=s=new d(1),d.precision=c;;){if(r=se(r.times(i),c,1),t=t.times(++l),a=s.plus(qe(r,t,c,1)),wt(a.d).slice(0,c)===wt(s.d).slice(0,c)){for(o=m;o--;)s=se(s.times(s),c,1);if(e==null)if(u<3&&mi(s.d,c-n,p,u))d.precision=c+=10,t=r=a=new d(1),l=0,u++;else return se(s,d.precision=f,p,ge=!0);else return d.precision=f,s}s=a}}function Qn(i,e){var t,n,o,r,s,a,c,u,l,m,d,p=1,f=10,y=i,b=y.d,g=y.constructor,P=g.rounding,h=g.precision;if(y.s<0||!b||!b[0]||!y.e&&b[0]==1&&b.length==1)return new g(b&&!b[0]?-1/0:y.s!=1?NaN:b?0:y);if(e==null?(ge=!1,l=h):l=e,g.precision=l+=f,t=wt(b),n=t.charAt(0),Math.abs(r=y.e)<15e14){for(;n<7&&n!=1||n==1&&t.charAt(1)>3;)y=y.times(i),t=wt(y.d),n=t.charAt(0),p++;r=y.e,n>1?(y=new g("0."+t),r++):y=new g(n+"."+t.slice(1))}else return u=Br(g,l+2,h).times(r+""),y=Qn(new g(n+"."+t.slice(1)),l-f).plus(u),g.precision=h,e==null?se(y,h,P,ge=!0):y;for(m=y,c=s=y=qe(y.minus(1),y.plus(1),l,1),d=se(y.times(y),l,1),o=3;;){if(s=se(s.times(d),l,1),u=c.plus(qe(s,new g(o),l,1)),wt(u.d).slice(0,l)===wt(c.d).slice(0,l))if(c=c.times(2),r!==0&&(c=c.plus(Br(g,l+2,h).times(r+""))),c=qe(c,new g(p),l,1),e==null)if(mi(c.d,l-f,P,a))g.precision=l+=f,u=s=y=qe(m.minus(1),m.plus(1),l,1),d=se(y.times(y),l,1),o=a=1;else return se(c,g.precision=h,P,ge=!0);else return g.precision=h,c;c=u,o+=2}}function Rc(i){return String(i.s*i.s/0)}function Qs(i,e){var t,n,o;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(o=e.length;e.charCodeAt(o-1)===48;--o);if(e=e.slice(n,o),e){if(o-=n,i.e=t=t-n-1,i.d=[],n=(t+1)%pe,t<0&&(n+=pe),n<o){for(n&&i.d.push(+e.slice(0,n)),o-=pe;n<o;)i.d.push(+e.slice(n,n+=pe));e=e.slice(n),n=pe-e.length}else n-=o;for(;n--;)e+="0";i.d.push(+e),ge&&(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 hd(i,e){var t,n,o,r,s,a,c,u,l;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),xc.test(e))return Qs(i,e)}else if(e==="Infinity"||e==="NaN")return+e||(i.s=NaN),i.e=NaN,i.d=null,i;if(gd.test(e))t=16,e=e.toLowerCase();else if(bd.test(e))t=2;else if(Pd.test(e))t=8;else throw Error(jn+e);for(r=e.search(/p/i),r>0?(c=+e.slice(r+1),e=e.substring(2,r)):e=e.slice(2),r=e.indexOf("."),s=r>=0,n=i.constructor,s&&(e=e.replace(".",""),a=e.length,r=a-r,o=Kc(n,new n(t),r,r*2)),u=hr(e,t,fn),l=u.length-1,r=l;u[r]===0;--r)u.pop();return r<0?new n(i.s*0):(i.e=Sr(u,l),i.d=u,ge=!1,s&&(i=qe(i,o,a*4)),c&&(i=i.times(Math.abs(c)<54?lt(2,c):di.pow(2,c))),ge=!0,i)}function Td(i,e){var t,n=e.d.length;if(n<3)return e.isZero()?e:Wo(i,2,e,e);t=1.4*Math.sqrt(n),t=t>16?16:t|0,e=e.times(1/Kr(5,t)),e=Wo(i,2,e,e);for(var o,r=new i(5),s=new i(16),a=new i(20);t--;)o=e.times(e),e=e.times(r.plus(o.times(s.times(o).minus(a))));return e}function Wo(i,e,t,n,o){var r,s,a,c,u=1,l=i.precision,m=Math.ceil(l/pe);for(ge=!1,c=t.times(t),a=new i(n);;){if(s=qe(a.times(c),new i(e++*e++),l,1),a=o?n.plus(s):n.minus(s),n=qe(s.times(c),new i(e++*e++),l,1),s=a.plus(n),s.d[m]!==void 0){for(r=m;s.d[r]===a.d[r]&&r--;);if(r==-1)break}r=a,a=n,n=s,s=r,u++}return ge=!0,s.d.length=m+1,s}function Kr(i,e){for(var t=i;--e;)t*=i;return t}function Lc(i,e){var t,n=e.s<0,o=pn(i,i.precision,1),r=o.times(.5);if(e=e.abs(),e.lte(r))return Rn=n?4:1,e;if(t=e.divToInt(o),t.isZero())Rn=n?3:2;else{if(e=e.minus(t.times(o)),e.lte(r))return Rn=Ac(t)?n?2:3:n?4:1,e;Rn=Ac(t)?n?1:4:n?3:2}return e.minus(o).abs()}function js(i,e,t,n){var o,r,s,a,c,u,l,m,d,p=i.constructor,f=t!==void 0;if(f?(Ut(t,1,Zn),n===void 0?n=p.rounding:Ut(n,0,8)):(t=p.precision,n=p.rounding),!i.isFinite())l=Rc(i);else{for(l=In(i),s=l.indexOf("."),f?(o=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):o=e,s>=0&&(l=l.replace(".",""),d=new p(1),d.e=l.length-s,d.d=hr(In(d),10,o),d.e=d.d.length),m=hr(l,10,o),r=c=m.length;m[--c]==0;)m.pop();if(!m[0])l=f?"0p+0":"0";else{if(s<0?r--:(i=new p(i),i.d=m,i.e=r,i=qe(i,d,t,n,0,o),m=i.d,r=i.e,u=hc),s=m[t],a=o/2,u=u||m[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&&m[t-1]&1||n===(i.s<0?8:7)),m.length=t,u)for(;++m[--t]>o-1;)m[t]=0,t||(++r,m.unshift(1));for(c=m.length;!m[c-1];--c);for(s=0,l="";s<c;s++)l+=Xs.charAt(m[s]);if(f){if(c>1)if(e==16||e==8){for(s=e==16?4:3,--c;c%s;c++)l+="0";for(m=hr(l,o,e),c=m.length;!m[c-1];--c);for(s=1,l="1.";s<c;s++)l+=Xs.charAt(m[s])}else l=l.charAt(0)+"."+l.slice(1);l=l+(r<0?"p":"p+")+r}else if(r<0){for(;++r;)l="0"+l;l="0."+l}else if(++r>c)for(r-=c;r--;)l+="0";else r<c&&(l=l.slice(0,r)+"."+l.slice(r))}l=(e==16?"0x":e==2?"0b":e==8?"0o":"")+l}return i.s<0?"-"+l:l}function wc(i,e){if(i.length>e)return i.length=e,!0}function Id(i){return new this(i).abs()}function Bd(i){return new this(i).acos()}function xd(i){return new this(i).acosh()}function Sd(i,e){return new this(i).plus(e)}function Kd(i){return new this(i).asin()}function Cd(i){return new this(i).asinh()}function Rd(i){return new this(i).atan()}function Ld(i){return new this(i).atanh()}function Nd(i,e){i=new this(i),e=new this(e);var t,n=this.precision,o=this.rounding,r=n+4;return!i.s||!e.s?t=new this(NaN):!i.d&&!e.d?(t=pn(this,r,1).times(e.s>0?.25:.75),t.s=i.s):!e.d||i.isZero()?(t=e.s<0?pn(this,n,o):new this(0),t.s=i.s):!i.d||e.isZero()?(t=pn(this,r,1).times(.5),t.s=i.s):e.s<0?(this.precision=r,this.rounding=1,t=this.atan(qe(i,e,r,1)),e=pn(this,r,1),this.precision=n,this.rounding=o,t=i.s<0?t.minus(e):t.plus(e)):t=this.atan(qe(i,e,r,1)),t}function Od(i){return new this(i).cbrt()}function Md(i){return se(i=new this(i),i.e+1,2)}function vd(i,e,t){return new this(i).clamp(e,t)}function Fd(i){if(!i||typeof i!="object")throw Error(xr+"Object expected");var e,t,n,o=i.defaults===!0,r=["precision",1,Zn,"rounding",0,8,"toExpNeg",-Vo,0,"toExpPos",0,Vo,"maxE",0,Vo,"minE",-Vo,0,"modulo",0,9];for(e=0;e<r.length;e+=3)if(t=r[e],o&&(this[t]=zs[t]),(n=i[t])!==void 0)if(Bt(n)===n&&n>=r[e+1]&&n<=r[e+2])this[t]=n;else throw Error(jn+t+": "+n);if(t="crypto",o&&(this[t]=zs[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(Ic);else this[t]=!1;else throw Error(jn+t+": "+n);return this}function _d(i){return new this(i).cos()}function Ed(i){return new this(i).cosh()}function Nc(i){var e,t,n;function o(r){var s,a,c,u=this;if(!(u instanceof o))return new o(r);if(u.constructor=o,kc(r)){u.s=r.s,ge?!r.d||r.e>o.maxE?(u.e=NaN,u.d=null):r.e<o.minE?(u.e=0,u.d=[0]):(u.e=r.e,u.d=r.d.slice()):(u.e=r.e,u.d=r.d?r.d.slice():r.d);return}if(c=typeof r,c==="number"){if(r===0){u.s=1/r<0?-1:1,u.e=0,u.d=[0];return}if(r<0?(r=-r,u.s=-1):u.s=1,r===~~r&&r<1e7){for(s=0,a=r;a>=10;a/=10)s++;ge?s>o.maxE?(u.e=NaN,u.d=null):s<o.minE?(u.e=0,u.d=[0]):(u.e=s,u.d=[r]):(u.e=s,u.d=[r]);return}else if(r*0!==0){r||(u.s=NaN),u.e=NaN,u.d=null;return}return Qs(u,r.toString())}else if(c!=="string")throw Error(jn+r);return(a=r.charCodeAt(0))===45?(r=r.slice(1),u.s=-1):(a===43&&(r=r.slice(1)),u.s=1),xc.test(r)?Qs(u,r):hd(u,r)}if(o.prototype=X,o.ROUND_UP=0,o.ROUND_DOWN=1,o.ROUND_CEIL=2,o.ROUND_FLOOR=3,o.ROUND_HALF_UP=4,o.ROUND_HALF_DOWN=5,o.ROUND_HALF_EVEN=6,o.ROUND_HALF_CEIL=7,o.ROUND_HALF_FLOOR=8,o.EUCLID=9,o.config=o.set=Fd,o.clone=Nc,o.isDecimal=kc,o.abs=Id,o.acos=Bd,o.acosh=xd,o.add=Sd,o.asin=Kd,o.asinh=Cd,o.atan=Rd,o.atanh=Ld,o.atan2=Nd,o.cbrt=Od,o.ceil=Md,o.clamp=vd,o.cos=_d,o.cosh=Ed,o.div=Vd,o.exp=Wd,o.floor=Dd,o.hypot=qd,o.ln=Ud,o.log=Gd,o.log10=zd,o.log2=Xd,o.max=Yd,o.min=Hd,o.mod=Qd,o.mul=jd,o.pow=Zd,o.random=$d,o.round=Jd,o.sign=ep,o.sin=tp,o.sinh=np,o.sqrt=op,o.sub=ip,o.sum=rp,o.tan=sp,o.tanh=ap,o.trunc=up,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 o.config(i),o}function Vd(i,e){return new this(i).div(e)}function Wd(i){return new this(i).exp()}function Dd(i){return se(i=new this(i),i.e+1,3)}function qd(){var i,e,t=new this(0);for(ge=!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 ge=!0,new this(1/0);t=e}return ge=!0,t.sqrt()}function kc(i){return i instanceof di||i&&i.toStringTag===Bc||!1}function Ud(i){return new this(i).ln()}function Gd(i,e){return new this(i).log(e)}function Xd(i){return new this(i).log(2)}function zd(i){return new this(i).log(10)}function Yd(){return Cc(this,arguments,"lt")}function Hd(){return Cc(this,arguments,"gt")}function Qd(i,e){return new this(i).mod(e)}function jd(i,e){return new this(i).mul(e)}function Zd(i,e){return new this(i).pow(e)}function $d(i){var e,t,n,o,r=0,s=new this(1),a=[];if(i===void 0?i=this.precision:Ut(i,1,Zn),n=Math.ceil(i/pe),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(n));r<n;)o=e[r],o>=429e7?e[r]=crypto.getRandomValues(new Uint32Array(1))[0]:a[r++]=o%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(n*=4);r<n;)o=e[r]+(e[r+1]<<8)+(e[r+2]<<16)+((e[r+3]&127)<<24),o>=214e7?crypto.randomBytes(4).copy(e,r):(a.push(o%1e7),r+=4);r=n/4}else throw Error(Ic);else for(;r<n;)a[r++]=Math.random()*1e7|0;for(n=a[--r],i%=pe,n&&i&&(o=lt(10,pe-i),a[r]=(n/o|0)*o);a[r]===0;r--)a.pop();if(r<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=pe)a.shift();for(n=1,o=a[0];o>=10;o/=10)n++;n<pe&&(t-=pe-n)}return s.e=t,s.d=a,s}function Jd(i){return se(i=new this(i),i.e+1,this.rounding)}function ep(i){return i=new this(i),i.d?i.d[0]?i.s:0*i.s:i.s||NaN}function tp(i){return new this(i).sin()}function np(i){return new this(i).sinh()}function op(i){return new this(i).sqrt()}function ip(i,e){return new this(i).sub(e)}function rp(){var i=0,e=arguments,t=new this(e[i]);for(ge=!1;t.s&&++i<e.length;)t=t.plus(e[i]);return ge=!0,se(t,this.precision,this.rounding)}function sp(i){return new this(i).tan()}function ap(i){return new this(i).tanh()}function up(i){return se(i=new this(i),i.e+1,1)}X[Symbol.for("nodejs.util.inspect.custom")]=X.toString;X[Symbol.toStringTag]="Decimal";var di=X.constructor=Nc(zs);Tr=new di(Tr);Ir=new di(Ir);var M=di;import yp from"big.js";import $n from"bn.js";import cp from"toformat";var lp=cp,pi=lp;import Rr from"big.js";import mp from"bn.js";import dp from"decimal.js-light";import fi from"bn.js";var Zs=(n=>(n[n.ROUND_DOWN=0]="ROUND_DOWN",n[n.ROUND_HALF_UP=1]="ROUND_HALF_UP",n[n.ROUND_UP=2]="ROUND_UP",n))(Zs||{}),Oc=9007199254740991;function te(i){let e=ke("Raydium_parseBigNumberish");if(i instanceof fi)return i;if(typeof i=="string"){if(i.match(/^-?[0-9]+$/))return new fi(i);e.logWithError(`invalid BigNumberish string: ${i}`)}return typeof i=="number"?(i%1&&e.logWithError(`BigNumberish number underflow: ${i}`),(i>=Oc||i<=-Oc)&&e.logWithError(`BigNumberish number overflow: ${i}`),new fi(String(i))):typeof i=="bigint"?new fi(i.toString()):(e.error(`invalid BigNumberish value: ${i}`),new fi(0))}var Cr=ke("module/fraction"),$s=pi(Rr),yi=pi(dp),pp={[0]:yi.ROUND_DOWN,[1]:yi.ROUND_HALF_UP,[2]:yi.ROUND_UP},fp={[0]:Rr.roundDown,[1]:Rr.roundHalfUp,[2]:Rr.roundUp},Pe=class{constructor(e,t=new mp(1)){this.numerator=te(e),this.denominator=te(t)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new Pe(this.denominator,this.numerator)}add(e){let t=e instanceof Pe?e:new Pe(te(e));return this.denominator.eq(t.denominator)?new Pe(this.numerator.add(t.numerator),this.denominator):new Pe(this.numerator.mul(t.denominator).add(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}sub(e){let t=e instanceof Pe?e:new Pe(te(e));return this.denominator.eq(t.denominator)?new Pe(this.numerator.sub(t.numerator),this.denominator):new Pe(this.numerator.mul(t.denominator).sub(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}mul(e){let t=e instanceof Pe?e:new Pe(te(e));return new Pe(this.numerator.mul(t.numerator),this.denominator.mul(t.denominator))}div(e){let t=e instanceof Pe?e:new Pe(te(e));return new Pe(this.numerator.mul(t.denominator),this.denominator.mul(t.numerator))}toSignificant(e,t={groupSeparator:""},n=1){Number.isInteger(e)||Cr.logWithError(`${e} is not an integer.`),e<=0&&Cr.logWithError(`${e} is not positive.`),yi.set({precision:e+1,rounding:pp[n]});let o=new yi(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(e);return o.toFormat(o.decimalPlaces(),t)}toFixed(e,t={groupSeparator:""},n=1){return Number.isInteger(e)||Cr.logWithError(`${e} is not an integer.`),e<0&&Cr.logWithError(`${e} is negative.`),$s.DP=e,$s.RM=fp[n]||1,new $s(this.numerator.toString()).div(this.denominator.toString()).toFormat(e,t)}isZero(){return this.numerator.isZero()}};var bp=ke("Raydium_amount"),Lr=pi(yp);function Mc(i,e){let t="0",n="0";if(i.includes(".")){let o=i.split(".");o.length===2?([t,n]=o,n=n.padEnd(e,"0")):bp.logWithError(`invalid number string, num: ${i}`)}else t=i;return[t,n.slice(0,e)||n]}var Re=class extends Pe{constructor(t,n,o=!0,r){let s=new $n(0),a=Ao.pow(new $n(t.decimals));if(o)s=te(n);else{let c=new $n(0),u=new $n(0);if(typeof n=="string"||typeof n=="number"||typeof n=="bigint"){let[l,m]=Mc(n.toString(),t.decimals);c=te(l),u=te(m)}c=c.mul(a),s=c.add(u)}super(s,a);this.logger=ke(r||"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 Re(this.token,this.raw.add(t.raw))}subtract(t){return this.token.equals(t.token)||this.logger.logWithError("sub token not equals"),new Re(this.token,this.raw.sub(t.raw))}toSignificant(t=this.token.decimals,n,o=0){return super.toSignificant(t,n,o)}toFixed(t=this.token.decimals,n,o=0){return t>this.token.decimals&&this.logger.logWithError("decimals overflow"),super.toFixed(t,n,o)}toExact(t={groupSeparator:""}){return Lr.DP=this.token.decimals,new Lr(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)}},Po=class extends Pe{constructor(t,n,o=!0,r){let s=new $n(0),a=Ao.pow(new $n(t.decimals));if(o)s=te(n);else{let c=new $n(0),u=new $n(0);if(typeof n=="string"||typeof n=="number"||typeof n=="bigint"){let[l,m]=Mc(n.toString(),t.decimals);c=te(l),u=te(m)}c=c.mul(a),s=c.add(u)}super(s,a);this.logger=ke(r||"TokenAmount"),this.currency=t}get raw(){return this.numerator}isZero(){return this.raw.isZero()}gt(t){return this.currency.equals(t.currency)||this.logger.logWithError("gt currency not equals"),this.raw.gt(t.raw)}lt(t){return this.currency.equals(t.currency)||this.logger.logWithError("lt currency not equals"),this.raw.lt(t.raw)}add(t){return this.currency.equals(t.currency)||this.logger.logWithError("add currency not equals"),new Po(this.currency,this.raw.add(t.raw))}sub(t){return this.currency.equals(t.currency)||this.logger.logWithError("sub currency not equals"),new Po(this.currency,this.raw.sub(t.raw))}toSignificant(t=this.currency.decimals,n,o=0){return super.toSignificant(t,n,o)}toFixed(t=this.currency.decimals,n,o=0){return t>this.currency.decimals&&this.logger.logWithError("decimals overflow"),super.toFixed(t,n,o)}toExact(t={groupSeparator:""}){return Lr.DP=this.currency.decimals,new Lr(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)}};import{PublicKey as gp}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as vc}from"@solana/spl-token";var Bn={chainId:101,address:gp.default.toBase58(),programId:vc.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"https://img-v1.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}},yt={chainId:101,address:"So11111111111111111111111111111111111111112",programId:vc.toBase58(),decimals:9,symbol:"WSOL",name:"Wrapped SOL",logoURI:"https://img-v1.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}};import{PublicKey as oa}from"@solana/web3.js";import{PublicKey as je,SystemProgram as Fc,SYSVAR_RENT_PUBKEY as Pp}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as Ap}from"@solana/spl-token";function w({pubkey:i,isSigner:e=!1,isWritable:t=!0}){return{pubkey:i,isWritable:t,isSigner:e}}var Js=[w({pubkey:Ap,isWritable:!1}),w({pubkey:Fc.programId,isWritable:!1}),w({pubkey:Pp,isWritable:!1})];function ea({publicKey:i,transformSol:e}){let t=ta(i.toString());if(t instanceof je)return e&&t.equals(bt)?$:t;if(e&&t.toString()===bt.toBase58())return $;if(typeof t=="string"){if(t===je.default.toBase58())return je.default;try{return new je(t)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function ta(i){try{return new je(i)}catch{return i}}var Nr=new je("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),xn=new je("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),rt=new je("SysvarRent111111111111111111111111111111111"),na=new je("SysvarC1ock11111111111111111111111111111111"),an=new je("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),Or=new je("Sysvar1nstructions1111111111111111111111111"),Mr=Fc.programId,nP=new je("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),oP=new je("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),iP=new je("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),rP=new je("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),sP=new je("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),aP=new je("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),uP=new je("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),cP=new je("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),lP=new je("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),mP=new je("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),dP=new je("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),$=new je("So11111111111111111111111111111111111111112"),bt=je.default;function It(i){return ea({publicKey:i,transformSol:!0})}var ia=class{constructor({mint:e,decimals:t,symbol:n,name:o,skipMint:r=!1,isToken2022:s=!1}){if(e===bt.toBase58()||e instanceof oa&&bt.equals(e)){this.decimals=yt.decimals,this.symbol=yt.symbol,this.name=yt.name,this.mint=new oa(yt.address),this.isToken2022=!1;return}this.decimals=t,this.symbol=n||e.toString().substring(0,6),this.name=o||e.toString().substring(0,6),this.mint=r?oa.default:ea({publicKey:e}),this.isToken2022=s}equals(e){return this===e?!0:this.mint.equals(e.mint)}},Me=ia;Me.WSOL=new ia(U(_({},yt),{mint:yt.address}));var ra=class{constructor({decimals:e,symbol:t="UNKNOWN",name:n="UNKNOWN"}){this.decimals=e,this.symbol=t,this.name=n}equals(e){return this===e}},bi=ra;bi.SOL=new ra(Bn);function kP(i,e){return i instanceof Me&&e instanceof Me?i.equals(e):i instanceof Me||e instanceof Me?!1:i===e}import wp from"bn.js";var _c=new Pe(new wp(100)),et=class extends Pe{toSignificant(e=5,t,n){return this.mul(_c).toSignificant(e,t,n)}toFixed(e=2,t,n){return this.mul(_c).toFixed(e,t,n)}};var kp=ke("Raydium_price"),gt=class extends Pe{constructor(t){let{baseToken:n,quoteToken:o,numerator:r,denominator:s}=t;super(r,s);this.baseToken=n,this.quoteToken=o,this.scalar=new Pe(sa(n.decimals),sa(o.decimals))}get raw(){return new Pe(this.numerator,this.denominator)}get adjusted(){return super.mul(this.scalar)}invert(){return new gt({baseToken:this.quoteToken,quoteToken:this.baseToken,denominator:this.numerator,numerator:this.denominator})}mul(t){this.quoteToken!==t.baseToken&&kp.logWithError("mul token not equals");let n=super.mul(t);return new gt({baseToken:this.baseToken,quoteToken:t.quoteToken,denominator:n.denominator,numerator:n.numerator})}toSignificant(t=this.quoteToken.decimals,n,o){return this.adjusted.toSignificant(t,n,o)}toFixed(t=this.quoteToken.decimals,n,o){return this.adjusted.toFixed(t,n,o)}};function st(i){if(i instanceof et)return new Pe(i.numerator,i.denominator);if(i instanceof gt)return i.adjusted;if(i instanceof Re)try{return st(i.toExact())}catch{return new Pe(at)}if(i instanceof Pe)return i;let e=String(i),t=wo(e);return new Pe(t.numerator,t.denominator)}function qP(i){var n;if(i instanceof et)return{fr:new Pe(i.numerator,i.denominator)};if(i instanceof gt)return{fr:i.adjusted};if(i instanceof Re)return{fr:st(i.toExact()),decimals:i.token.decimals};if(i instanceof Pe)return{fr:i};let e=String(i),t=wo(e);return{fr:new Pe(t.numerator,t.denominator),decimals:(n=t.dec)==null?void 0:n.length}}function UP(i,e){if(i==null||e==null)return!1;let t=st(i),n=st(e);return t.sub(n).numerator,t.sub(n).numerator.lt(at)}function hp(i,e){if(i==null||e==null)return!1;let t=st(i),n=st(e);return t.sub(n).numerator.gt(at)}function GP(i,e){if(i==null||e==null)return!1;let t=st(i),n=st(e);return t.sub(n).numerator.lte(at)}function XP(i,e){if(i==null||e==null)return!1;let t=st(i),n=st(e);return t.sub(n).numerator.gte(at)}function Tp(i,e){if(i==null||e==null)return!1;let t=st(i),n=st(e);return t.sub(n).numerator.eq(at)}function zP(i,e){if(i==null||e==null)return;let t=st(i),n=st(e);try{return t.div(n)}catch{return t}}function YP(i,e){if(i==null||e==null)return;let t=st(i),n=st(e);return t.sub(n)}function HP(i){return i==null?!1:!Tp(i,0)}function QP(i,e){return hp(e,i)?e:i}function aa(i,e){if(i==null||e==null)return;let t=st(i),n=st(e);return t.mul(n)}function jP(i,e){if(i==null||e==null)return;let t=st(i),n=st(e);return t.add(n)}var at=new tt(0),Vc=new tt(1),uA=new tt(2),cA=new tt(3),lA=new tt(5),Ao=new tt(10),mA=new tt(100),dA=new tt(1e3),pA=new tt(1e4);function sa(i){return Ao.pow(te(i))}function wo(i){var a;if(i===void 0)return{denominator:"1",numerator:"0"};if(i instanceof tt)return{numerator:i.toString(),denominator:"1"};if(i instanceof Pe)return{denominator:i.denominator.toString(),numerator:i.numerator.toString()};let e=String(i),[,t="",n="",o=""]=(a=e.replace(",","").match(/(-?)(\d*)\.?(\d*)/))!=null?a:[],r="1"+"0".repeat(o.length),s=t+(n==="0"?"":n)+o||"0";return{denominator:r,numerator:s,sign:t,int:n,dec:o}}function vr(i,e){let t=i.divmod(e);return t.mod.isZero()?t.div:t.div.isNeg()?t.div.isubn(1):t.div.iaddn(1)}function Ip(i){var n;let[,e="",t=""]=(n=i.toFixed(2).match(/(-?)(\d*)\.?(\d*)/))!=null?n:[];return`${e}${t}`}function Bp(i,e=0){return i instanceof tt?i:new tt(Ip(Wc(i).mul(Ao.pow(new tt(String(e))))))}function Wc(i){if(i instanceof et)return new Pe(i.numerator,i.denominator);if(i instanceof gt)return i.adjusted;if(i instanceof Re)try{return Wc(i.toExact())}catch{return new Pe(at)}if(i instanceof Pe)return i;let e=String(i),t=wo(e);return new Pe(t.numerator,t.denominator)}function gi(i,e,t){return i.mul(e).add(t).sub(new tt(1)).div(t)}function Fr(i,e,t){return i.mul(e).div(t)}function fA(i,e){let{numerator:t,denominator:n}=wo(i);return new et(new tt(t),new tt(n).mul(e!=null&&e.alreadyDecimaled?new tt(100):new tt(1)))}function yA(i){let{token:e,numberPrice:t,decimalDone:n}=i,o=new Me({mint:"",decimals:6,symbol:"usd",name:"usd",skipMint:!0}),{numerator:r,denominator:s}=wo(t),a=n?new tt(r).mul(Ao.pow(new tt(e.decimals))):r,c=new tt(s).mul(Ao.pow(new tt(o.decimals)));return new gt({baseToken:o,denominator:c.toString(),quoteToken:new Me(U(_({},e),{skipMint:!0,mint:""})),numerator:a.toString()})}function Ec(i){let e=new bi({decimals:6,symbol:"usd",name:"usd"}),t=Bp(aa(i,10**e.decimals));return new Po(e,t)}function bA(i,e){return Ec(!e||!i?0:aa(i,e))}function gA(i){if(i==null)return;let{numerator:e,denominator:t}=wo(i.toString());return new Pe(e,t)}function PA(i){return i instanceof M}var Dc=i=>typeof i=="number",qc=i=>i?new Date(i):new Date,xp=i=>qc(i).getTime();function Uc(i,e,t){let n=Dc(e)?e*((t==null?void 0:t.unit)==="s"?1e3:1):e;return new Date(i).getTime()<=n}function Gc(i,e,t){let n=Dc(e)?e*((t==null?void 0:t.unit)==="s"?1e3:1):e;return new Date(i).getTime()>n}function wA(i,e){let n=xp(i)+(e.days?e.days*24*60*60*1e3:0)+(e.hours?e.hours*60*60*1e3:0)+(e.minutes?e.minutes*60*1e3:0)+(e.seconds?e.seconds*1e3:0)+(e.milliseconds?e.milliseconds:0);return qc(n)}function Gs(i,e=1,t=[]){let n=[...i];if(e<=0)return t;for(;n.length;)t.push(n.splice(0,e));return t}function hA(i,...e){return i.filter(t=>e.every(n=>n.includes(t)))}function TA(i,...e){return i.filter(t=>e.every(n=>!n.incl