snapper-sdk
Version:
An SDK for building applications on top of Snapper.
1 lines • 405 kB
JavaScript
"use strict";var am=Object.create;var Gi=Object.defineProperty;var um=Object.getOwnPropertyDescriptor;var cm=Object.getOwnPropertyNames;var lm=Object.getPrototypeOf,mm=Object.prototype.hasOwnProperty;var dm=(o,e)=>{for(var t in e)Gi(o,t,{get:e[t],enumerable:!0})},Mu=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of cm(e))!mm.call(o,i)&&i!==t&&Gi(o,i,{get:()=>e[i],enumerable:!(n=um(e,i))||n.enumerable});return o};var de=(o,e,t)=>(t=o!=null?am(lm(o)):{},Mu(e||!o||!o.__esModule?Gi(t,"default",{value:o,enumerable:!0}):t,o)),pm=o=>Mu(Gi({},"__esModule",{value:!0}),o);var Zf={};dm(Zf,{ACCOUNT_TYPE_SIZE:()=>ym,ALL_PROGRAM_ID:()=>$d,AMM_CONFIG_SEED:()=>bl,AMM_STABLE:()=>hc,AMM_V4:()=>fr,ANAMint:()=>hd,API_URLS:()=>Me,AccountType:()=>vu,Api:()=>ai,BIT_PRECISION:()=>Ra,BNDivCeil:()=>Lt,BNLayout:()=>Cn,BN_100:()=>Fd,BN_1000:()=>Dd,BN_10000:()=>Wd,BN_FIVE:()=>Ed,BN_ONE:()=>vs,BN_TEN:()=>kn,BN_THREE:()=>vd,BN_TWO:()=>Vd,BN_ZERO:()=>Ue,BitStructure:()=>ap,Blob:()=>ia,CLMM_LOCK_AUTH_ID:()=>uo,CLMM_LOCK_PROGRAM_ID:()=>zn,CLMM_PROGRAM_ID:()=>Bn,CLOCK_PROGRAM_ID:()=>sr,CREATE_CPMM_POOL_AUTH:()=>yr,CREATE_CPMM_POOL_FEE_ACC:()=>Kc,CREATE_CPMM_POOL_PROGRAM:()=>co,Clmm:()=>_o,ClmmConfigLayout:()=>ja,ClmmInstrument:()=>Ie,ConstantProductCurve:()=>Ki,CpmmConfigInfoLayout:()=>hu,CpmmFee:()=>Ci,CpmmPoolInfoLayout:()=>Vi,Currency:()=>ro,CurrencyAmount:()=>Pn,CurveCalculator:()=>Li,DAVEMint:()=>pd,DEVNET_PROGRAM_ID:()=>Jd,DEV_API_URLS:()=>tp,DEV_CREATE_CPMM_POOL_AUTH:()=>Rc,DEV_CREATE_CPMM_POOL_FEE_ACC:()=>Lc,DEV_CREATE_CPMM_POOL_PROGRAM:()=>Cc,DEV_LOCK_CPMM_AUTH:()=>Nc,DEV_LOCK_CPMM_PROGRAM:()=>Oc,DataElement:()=>vl,ETHMint:()=>Td,EXTENSION_TICKARRAY_BITMAP_SIZE:()=>Jr,FARM_LOCK_MINT:()=>Aa,FARM_LOCK_VAULT:()=>wa,FARM_PROGRAM_ID_V3:()=>dr,FARM_PROGRAM_ID_V5:()=>pr,FARM_PROGRAM_ID_V6:()=>Xn,FARM_PROGRAM_TO_VERSION:()=>It,FARM_VERSION_TO_LEDGER_LAYOUT:()=>ka,FARM_VERSION_TO_STATE_LAYOUT:()=>Pa,FEE_DESTINATION_ID:()=>Zd,FEE_RATE_DENOMINATOR:()=>wi,FEE_RATE_DENOMINATOR_VALUE:()=>cs,FETCH_TICKARRAY_COUNT:()=>Il,Fee:()=>yl,Fraction:()=>ie,IDO_ALL_PROGRAM:()=>po,IDO_PROGRAM_ID_V1:()=>Ic,IDO_PROGRAM_ID_V2:()=>Bc,IDO_PROGRAM_ID_V3:()=>xc,IDO_PROGRAM_ID_V4:()=>Sc,INSTRUCTION_PROGRAM_ID:()=>$o,InstructionType:()=>v,JupTokenType:()=>js,LIQUIDITY_FEES_DENOMINATOR:()=>Ti,LIQUIDITY_FEES_NUMERATOR:()=>es,LIQUIDITY_POOL_PROGRAM_ID_V5_MODEL:()=>Qs,LIQUIDITY_VERSION_TO_SERUM_VERSION:()=>Ml,LIQUIDITY_VERSION_TO_STATE_LAYOUT:()=>wf,LOCK_CPMM_AUTH:()=>mo,LOCK_CPMM_PROGRAM:()=>lo,LOCK_LIQUIDITY_SEED:()=>$l,LOG_B_2_X32:()=>La,LOG_B_P_ERR_MARGIN_LOWER_X64:()=>Oa,LOG_B_P_ERR_MARGIN_UPPER_X64:()=>Na,LOOKUP_TABLE_CACHE:()=>ii,Layout:()=>yo,LiquidityMath:()=>fe,LockClPositionLayoutV2:()=>df,LockPositionLayout:()=>mf,LogLevel:()=>_u,Logger:()=>Xi,MARKET_STATE_LAYOUT_V2:()=>fs,MARKET_STATE_LAYOUT_V3:()=>ds,MARKET_VERSION_TO_STATE_LAYOUT:()=>Bu,MAX_BASE64_SIZE:()=>Us,MAX_SQRT_PRICE_X64:()=>St,MAX_SQRT_PRICE_X64_SUB_ONE:()=>Ai,MAX_TICK:()=>lt,MEMO_PROGRAM_ID:()=>Zo,MEMO_PROGRAM_ID2:()=>sn,METADATA_PROGRAM_ID:()=>jt,MIN_SQRT_PRICE_X64:()=>xt,MIN_SQRT_PRICE_X64_ADD_ONE:()=>gi,MIN_TICK:()=>rt,MODEL_DATA_PUBKEY:()=>$n,Market:()=>Ei,MathUtil:()=>ne,MaxU64:()=>jr,MaxUint128:()=>Ca,NEGATIVE_ONE:()=>tn,NRVMint:()=>kd,OBSERVATION_SEED:()=>Tl,ONE:()=>kt,OPEN_BOOK_PROGRAM:()=>kc,OPERATION_SEED:()=>kl,ObservationInfoLayout:()=>Ya,ObservationLayout:()=>xl,OperationLayout:()=>Ha,OptionLayout:()=>xr,Owner:()=>Rt,PAIMint:()=>fd,POOL_LOCK_ID_SEED:()=>qa,POOL_REWARD_VAULT_SEED:()=>wl,POOL_SEED:()=>gl,POOL_TICK_ARRAY_BITMAP_SEED:()=>hl,POOL_VAULT_SEED:()=>Al,POSITION_SEED:()=>Ea,Percent:()=>Re,PoolFetchType:()=>Ys,PoolInfoLayout:()=>Nn,PoolUtils:()=>Oe,PositionInfoLayout:()=>Lo,PositionRewardInfoLayout:()=>Kl,PositionUtils:()=>Ko,Price:()=>je,ProtocolPositionLayout:()=>lf,Q128:()=>bi,Q64:()=>ht,RENT_PROGRAM_ID:()=>ot,Raydium:()=>Ui,RewardInfo:()=>Sl,RoundDirection:()=>lu,Rounding:()=>er,Router:()=>Tc,SERUM_PROGRAMID_TO_VERSION:()=>Tu,SERUM_PROGRAM_ID_V3:()=>oi,SERUM_VERSION_TO_PROGRAMID:()=>Iu,SESSION_KEY:()=>Hs,SOLMint:()=>qe,SOL_INFO:()=>Wt,SPL_MINT_LAYOUT:()=>pf,SRMMint:()=>yd,STORAGE_KEY:()=>gr,SYSTEM_PROGRAM_ID:()=>Un,SqrtPriceMath:()=>ee,StableLayout:()=>Zn,Structure:()=>Sr,SwapMath:()=>On,TICK_ARRAY_BITMAP_SIZE:()=>Ln,TICK_ARRAY_SEED:()=>Pl,TICK_ARRAY_SIZE:()=>Xe,TICK_SPACINGS:()=>tf,TOKEN_WSOL:()=>We,TickArrayBitmap:()=>nn,TickArrayBitmapExtensionLayout:()=>za,TickArrayBitmapExtensionUtils:()=>Ro,TickArrayLayout:()=>Co,TickLayout:()=>Cl,TickMath:()=>Mn,TickQuery:()=>ye,TickUtils:()=>Q,Token:()=>ke,TokenAmount:()=>ge,TxBuilder:()=>ri,TxVersion:()=>Tn,U64Resolution:()=>Io,U64_IGNORE_RANGE:()=>of,UInt:()=>hr,USDCMint:()=>bd,USDHMint:()=>Pd,USDTMint:()=>gd,UTIL1216:()=>Pc,Union:()=>Kr,Voter:()=>ba,VoterDepositEntry:()=>rl,VoterLockup:()=>il,VoterRegistrar:()=>ya,VoterVotingMintConfig:()=>ol,WSOLMint:()=>j,WideBits:()=>ci,WrappedLayout:()=>$t,ZERO:()=>be,_100_PERCENT:()=>Ns,accountMeta:()=>k,add:()=>Md,addComputeBudget:()=>ei,addLiquidityLayout:()=>is,array:()=>qp,associatedLedgerAccountLayout:()=>Lr,bits:()=>Ir,blob:()=>we,bool:()=>Fe,calFarmRewardAmount:()=>Gr,ceilDiv:()=>Hl,checkLegacyTxSize:()=>so,checkV0TxSize:()=>ao,chunkArray:()=>zi,claimLayout:()=>qo,clmmComputeInfoToApiInfo:()=>Xa,closeAccountInstruction:()=>Jt,collectCpFeeInstruction:()=>ku,commonSystemAccountMeta:()=>or,confirmTransaction:()=>ti,cpmmLockPositionInstruction:()=>Jl,createAssociatedLedgerAccountInstruction:()=>Po,createLogger:()=>me,createPoolFeeLayout:()=>Ja,createPoolV4InstructionV2:()=>ru,createPoolV4Layout:()=>Af,createWSolAccountInstructions:()=>en,cstr:()=>_p,currencyEquals:()=>Id,decimalToFraction:()=>dc,decodeBool:()=>Qc,div:()=>Rd,divCeil:()=>Jo,dwLayout:()=>ct,encodeBool:()=>jc,endlessRetry:()=>np,eq:()=>ac,f32:()=>Rp,f32be:()=>Lp,f64:()=>Op,f64be:()=>Np,farmAddRewardLayout:()=>_r,farmLedgerLayoutV3_1:()=>Qp,farmLedgerLayoutV3_2:()=>Ao,farmLedgerLayoutV5_1:()=>jp,farmLedgerLayoutV5_2:()=>pa,farmLedgerLayoutV6_1:()=>fa,farmRewardInfoToConfig:()=>Ta,farmRewardLayout:()=>Nr,farmRewardRestartLayout:()=>Mr,farmRewardTimeInfoLayout:()=>nl,farmStateV3Layout:()=>ma,farmStateV5Layout:()=>da,farmStateV6Layout:()=>go,fetchMultipleFarmInfoAndUpdate:()=>Yp,fetchMultipleInfo:()=>Lf,fetchMultipleMintInfos:()=>qn,findProgramAddress:()=>re,fixedSwapInLayout:()=>ts,fixedSwapOutLayout:()=>ns,floorDiv:()=>mu,forecastTransactionSize:()=>ni,formatLayout:()=>Wl,generatePubKey:()=>ft,getATAAddress:()=>ce,getAssociatedAuthority:()=>ha,getAssociatedConfigId:()=>Bi,getAssociatedLedgerAccount:()=>it,getAssociatedLedgerPoolAccount:()=>wo,getAssociatedOpenOrders:()=>Yl,getAssociatedPoolKeys:()=>cu,getCpLockPda:()=>Mi,getCpmmPdaAmmConfigId:()=>Df,getCpmmPdaPoolId:()=>ms,getCreatePoolKeys:()=>fu,getDate:()=>Ds,getDepositEntryIndex:()=>Xr,getDxByDyBaseIn:()=>nu,getDyByDxBaseIn:()=>tu,getEpochInfo:()=>Yd,getFarmLedgerLayout:()=>Yn,getFarmStateLayout:()=>sl,getLiquidityAssociatedAuthority:()=>as,getLiquidityAssociatedId:()=>_n,getLiquidityFromAmounts:()=>uf,getMax:()=>Nd,getMultipleAccountsInfo:()=>Ct,getMultipleAccountsInfoWithCustomFlags:()=>De,getMultipleLookupTableInfo:()=>br,getPdaAmmConfigId:()=>af,getPdaExBitmapAccount:()=>bt,getPdaLockClPositionIdV2:()=>So,getPdaLockPositionId:()=>$r,getPdaLpMint:()=>Zl,getPdaMetadataKey:()=>Rn,getPdaObservationAccount:()=>Wa,getPdaObservationId:()=>Ni,getPdaOperationAccount:()=>xo,getPdaPersonalPositionAddress:()=>mt,getPdaPoolAuthority:()=>eo,getPdaPoolId:()=>Fa,getPdaPoolRewardVaulId:()=>Da,getPdaPoolVaultId:()=>Zr,getPdaProtocolPositionAddress:()=>Nt,getPdaTickArrayAddress:()=>pe,getPdaUser:()=>Oi,getPdaVault:()=>pu,getRecentBlockHash:()=>Gn,getRegistrarAddress:()=>Er,getSessionKey:()=>_c,getStablePrice:()=>ou,getTime:()=>fc,getTimestamp:()=>_d,getTokenOwnerRecordAddress:()=>Ur,getTransferAmountFee:()=>ep,getTransferAmountFeeV2:()=>Ae,getVoterAddress:()=>Wr,getVoterWeightRecordAddress:()=>qr,getVotingMintAuthority:()=>Dr,getVotingTokenMint:()=>Fr,governanceCreateTokenOwnerRecord:()=>ml,greedy:()=>up,gt:()=>sc,gte:()=>Cd,i128:()=>ua,i16ToBytes:()=>rf,i32ToBytes:()=>Pi,i64:()=>Qn,i8:()=>aa,initPoolLayout:()=>os,initTokenAccountInstruction:()=>Rr,initializeMarket:()=>nm,intersection:()=>zd,isDateAfter:()=>qs,isDateBefore:()=>Ws,isDecimal:()=>pc,isMeaningfulNumber:()=>Od,isNumber:()=>Fs,isValidFarmVersion:()=>Vr,isZero:()=>Bo,jsonInfo2PoolKeys:()=>Se,judgeFarmType:()=>Hp,leadingZeros:()=>Yr,leastSignificantBit:()=>va,liquidityStateV4Layout:()=>No,liquidityStateV5Layout:()=>_l,lt:()=>Sd,lte:()=>Kd,mSOLMint:()=>Ad,makeAMMSwapInstruction:()=>Ii,makeAddLiquidityInstruction:()=>iu,makeAddNewRewardInstruction:()=>Qr,makeClaimInstruction:()=>Wi,makeClaimInstructionV4:()=>gs,makeCpmmCreateAmmConfigInstruction:()=>yu,makeCpmmLockInstruction:()=>Pu,makeCreateCpmmPoolInInstruction:()=>bu,makeCreateFarmInstruction:()=>Ia,makeCreateMarketInstruction:()=>Cu,makeCreatorWithdrawFarmRewardInstruction:()=>Ba,makeDepositCpmmInInstruction:()=>gu,makeDepositInstructionV3:()=>xa,makeDepositInstructionV5:()=>Sa,makeDepositInstructionV6:()=>Ka,makeDepositTokenInstruction:()=>$p,makeDepositWithdrawInstruction:()=>ef,makeInitPoolInstructionV4:()=>Cf,makePurchaseInstruction:()=>jf,makeRestartRewardInstruction:()=>zr,makeSimulatePoolInfoInstruction:()=>su,makeSwapCpmmBaseInInInstruction:()=>_i,makeSwapCpmmBaseOutInInstruction:()=>wu,makeSwapFixedInInstruction:()=>Ul,makeSwapFixedOutInstruction:()=>Gl,makeSwapInstruction:()=>Su,makeTransferInstruction:()=>la,makeWithdrawCpmmInInstruction:()=>Au,makeWithdrawInstructionV3:()=>To,makeWithdrawInstructionV5:()=>ho,makeWithdrawInstructionV6:()=>ko,makeWithdrawTokenInstruction:()=>Jp,minExpirationTime:()=>Ot,mockCreatePoolInfo:()=>nf,mockV3CreatePoolInfo:()=>Ma,modelDataInfoLayout:()=>El,mostSignificantBit:()=>Va,mul:()=>cr,notInnerObject:()=>lr,ns64:()=>Tp,ns64be:()=>Cp,nu64:()=>ra,nu64be:()=>gp,offset:()=>Br,offsetDateTime:()=>Xd,option:()=>vp,parseBigNumberish:()=>Y,parseNumberInfo:()=>hn,parseSimulateLogToJson:()=>Xs,parseSimulateValue:()=>Yt,parseTokenAccountResp:()=>ca,parseTokenInfo:()=>ff,poolTypeV6:()=>cn,printSimulate:()=>In,publicKey:()=>K,purchaseLayout:()=>ys,realFarmStateV3Layout:()=>Jc,realFarmStateV5Layout:()=>el,realFarmV6Layout:()=>tl,recursivelyDecimalToFraction:()=>Vs,removeLiquidityInstruction:()=>ss,removeLiquidityLayout:()=>rs,route1Instruction:()=>Gf,route2Instruction:()=>Xf,routeInstruction:()=>em,rustEnum:()=>Wp,s16:()=>wp,s16be:()=>Ip,s24:()=>Pp,s24be:()=>Bp,s32:()=>$e,s32be:()=>xp,s40:()=>kp,s40be:()=>Sp,s48:()=>hp,s48be:()=>Kp,s8:()=>Ap,seq:()=>z,setLoggerLevel:()=>fm,shakeFractionDecimal:()=>lc,simulateMultipleInstruction:()=>Gs,simulatePoolInfoInstruction:()=>Kf,simulateTransaction:()=>bc,sleep:()=>Ms,solToWSol:()=>wt,solToWSolToken:()=>bf,splAccountLayout:()=>un,splitNumber:()=>Cs,stSOLMint:()=>wd,str:()=>Dp,struct:()=>N,sub:()=>Ld,tagged:()=>Fp,tenExponential:()=>ur,toAmmComputePoolInfo:()=>xi,toApiV3Token:()=>st,toBN:()=>mc,toBuffer:()=>zs,toFeeConfig:()=>ln,toFraction:()=>Es,toFractionWithDecimals:()=>xd,toPercent:()=>qd,toToken:()=>hi,toTokenAmount:()=>Oo,toTokenInfo:()=>yf,toTokenPrice:()=>Ud,toTotalPrice:()=>Gd,toUsdCurrency:()=>_s,trailingZeros:()=>Hr,transformTxToBase64:()=>Hd,tryParsePublicKey:()=>rr,txToBase64:()=>gc,u128:()=>J,u16:()=>Zt,u16ToBytes:()=>_a,u16be:()=>dp,u24:()=>cp,u24be:()=>pp,u32:()=>Je,u32ToBytes:()=>sf,u32be:()=>fp,u40:()=>lp,u40be:()=>yp,u48:()=>mp,u48be:()=>bp,u64:()=>P,u8:()=>E,union:()=>Up,unionArr:()=>Hf,unionLayoutDiscriminator:()=>Mp,uniq:()=>jd,updateFarmPoolInfo:()=>al,updateReqHistory:()=>si,utf8:()=>Vp,validateAndParsePublicKey:()=>ir,validateFarmRewards:()=>vr,vec:()=>Ep,vecU8:()=>Yc,voterStakeRegistryCreateDepositEntry:()=>pl,voterStakeRegistryCreateVoter:()=>dl,voterStakeRegistryDeposit:()=>ul,voterStakeRegistryUpdateVoterWeightRecord:()=>cl,voterStakeRegistryWithdraw:()=>ll,wSolToSolToken:()=>gf,withdrawRewardLayout:()=>Or,xor:()=>Qd,zeros:()=>Gp});module.exports=pm(Zf);var $s=de(require("axios"));var ks=require("@solana/web3.js");var Wn=require("lodash"),_u=(i=>(i[i.Error=0]="Error",i[i.Warning=1]="Warning",i[i.Info=2]="Info",i[i.Debug=3]="Debug",i))(_u||{}),Xi=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}},ws={},Vu={};function me(o){let e=(0,Wn.get)(ws,o);if(!e){let t=(0,Wn.get)(Vu,o);e=new Xi({name:o,logLevel:t}),(0,Wn.set)(ws,o,e)}return e}function fm(o,e){(0,Wn.set)(Vu,o,e);let t=(0,Wn.get)(ws,o);t&&(t.level=e)}var yn=require("@solana/spl-token"),Ps=me("Raydium_accountInfo_util");async function Ct(o,e,t){let{batchRequest:n,commitment:i="confirmed",chunkCount:r=100}={batchRequest:!1,...t},s=zi(e,r),a=new Array(s.length).fill([]);if(n){let u=s.map(m=>{let d=o._buildArgs([m.map(p=>p.toBase58())],i,"base64");return{methodName:"getMultipleAccounts",args:d}}),c=zi(u,10);a=(await(await Promise.all(c.map(async m=>await o._rpcBatchRequest(m)))).flat()).map(m=>(m.error&&Ps.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${m.error.message}`),m.result.value.map(d=>{if(d){let{data:p,executable:y,lamports:f,owner:b,rentEpoch:g}=d;return p.length!==2&&p[1]!=="base64"&&Ps.logWithError("info must be base64 encoded, RPC_ERROR"),{data:Buffer.from(p[0],"base64"),executable:y,lamports:f,owner:new ks.PublicKey(b),rentEpoch:g}}return null})))}else try{a=await Promise.all(s.map(u=>o.getMultipleAccountsInfo(u,i)))}catch(u){u instanceof Error&&Ps.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${u.message}`)}return a.flat()}async function De(o,e,t){let n=await Ct(o,e.map(i=>i.pubkey),t);return e.map((i,r)=>({...i,accountInfo:n[r]}))}var vu=(n=>(n[n.Uninitialized=0]="Uninitialized",n[n.Mint=1]="Mint",n[n.Account=2]="Account",n))(vu||{}),ym=1;async function qn({connection:o,mints:e,config:t}){var r,s,a;if(e.length===0)return{};let n=await De(o,e.map(u=>({pubkey:wt(u)})),t),i={};for(let u of n){if(!u.accountInfo||u.accountInfo.data.length<yn.MINT_SIZE){console.log("invalid mint account",u.pubkey.toBase58());continue}let c=(0,yn.unpackMint)(u.pubkey,u.accountInfo,(r=u.accountInfo)==null?void 0:r.owner);i[u.pubkey.toString()]={...c,programId:((s=u.accountInfo)==null?void 0:s.owner)||yn.TOKEN_PROGRAM_ID,feeConfig:(a=(0,yn.getTransferFeeConfig)(c))!=null?a:void 0}}return i[ks.PublicKey.default.toBase58()]=i[j.toBase58()],i}var Ne=de(require("bn.js"));var no=9e15,wn=1e9,hs="0123456789abcdef",ji="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Yi="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Ts={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-no,maxE:no,crypto:!1},Wu,on,oe=!0,Zi="[DecimalError] ",An=Zi+"Invalid argument: ",qu=Zi+"Precision limit exceeded",Uu=Zi+"crypto unavailable",Gu="[object Decimal]",ut=Math.floor,Qe=Math.pow,bm=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,gm=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Am=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Xu=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Dt=1e7,te=7,wm=9007199254740991,Pm=ji.length-1,Is=Yi.length-1,_={toStringTag:Gu};_.absoluteValue=_.abs=function(){var o=new this.constructor(this);return o.s<0&&(o.s=1),Z(o)};_.ceil=function(){return Z(new this.constructor(this),this.e+1,2)};_.clampedTo=_.clamp=function(o,e){var t,n=this,i=n.constructor;if(o=new i(o),e=new i(e),!o.s||!e.s)return new i(NaN);if(o.gt(e))throw Error(An+e);return t=n.cmp(o),t<0?o:n.cmp(e)>0?e:new i(n)};_.comparedTo=_.cmp=function(o){var e,t,n,i,r=this,s=r.d,a=(o=new r.constructor(o)).d,u=r.s,c=o.s;if(!s||!a)return!u||!c?NaN:u!==c?u:s===a?0:!s^u<0?1:-1;if(!s[0]||!a[0])return s[0]?u:a[0]?-c:0;if(u!==c)return u;if(r.e!==o.e)return r.e>o.e^u<0?1:-1;for(n=s.length,i=a.length,e=0,t=n<i?n:i;e<t;++e)if(s[e]!==a[e])return s[e]>a[e]^u<0?1:-1;return n===i?0:n>i^u<0?1:-1};_.cosine=_.cos=function(){var o,e,t=this,n=t.constructor;return t.d?t.d[0]?(o=n.precision,e=n.rounding,n.precision=o+Math.max(t.e,t.sd())+te,n.rounding=1,t=km(n,Hu(n,t)),n.precision=o,n.rounding=e,Z(on==2||on==3?t.neg():t,o,e,!0)):new n(1):new n(NaN)};_.cubeRoot=_.cbrt=function(){var o,e,t,n,i,r,s,a,u,c,l=this,m=l.constructor;if(!l.isFinite()||l.isZero())return new m(l);for(oe=!1,r=l.s*Qe(l.s*l,1/3),!r||Math.abs(r)==1/0?(t=nt(l.d),o=l.e,(r=(o-t.length+1)%3)&&(t+=r==1||r==-2?"0":"00"),r=Qe(t,1/3),o=ut((o+1)/3)-(o%3==(o<0?-1:2)),r==1/0?t="5e"+o:(t=r.toExponential(),t=t.slice(0,t.indexOf("e")+1)+o),n=new m(t),n.s=l.s):n=new m(r.toString()),s=(o=m.precision)+3;;)if(a=n,u=a.times(a).times(a),c=u.plus(l),n=xe(c.plus(l).times(a),c.plus(u),s+2,1),nt(a.d).slice(0,s)===(t=nt(n.d)).slice(0,s))if(t=t.slice(s-3,s+1),t=="9999"||!i&&t=="4999"){if(!i&&(Z(a,o+1,0),a.times(a).times(a).eq(l))){n=a;break}s+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(Z(n,o+1,1),e=!n.times(n).times(n).eq(l));break}return oe=!0,Z(n,o,m.rounding,e)};_.decimalPlaces=_.dp=function(){var o,e=this.d,t=NaN;if(e){if(o=e.length-1,t=(o-ut(this.e/te))*te,o=e[o],o)for(;o%10==0;o/=10)t--;t<0&&(t=0)}return t};_.dividedBy=_.div=function(o){return xe(this,new this.constructor(o))};_.dividedToIntegerBy=_.divToInt=function(o){var e=this,t=e.constructor;return Z(xe(e,new t(o),0,1,1),t.precision,t.rounding)};_.equals=_.eq=function(o){return this.cmp(o)===0};_.floor=function(){return Z(new this.constructor(this),this.e+1,3)};_.greaterThan=_.gt=function(o){return this.cmp(o)>0};_.greaterThanOrEqualTo=_.gte=function(o){var e=this.cmp(o);return e==1||e===0};_.hyperbolicCosine=_.cosh=function(){var o,e,t,n,i,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,i=r.d.length,i<32?(o=Math.ceil(i/3),e=(1/Ji(4,o)).toString()):(o=16,e="2.3283064365386962890625e-10"),r=oo(s,1,r.times(e),new s(1),!0);for(var u,c=o,l=new s(8);c--;)u=r.times(r),r=a.minus(u.times(l.minus(u.times(l))));return Z(r,s.precision=t,s.rounding=n,!0)};_.hyperbolicSine=_.sinh=function(){var o,e,t,n,i=this,r=i.constructor;if(!i.isFinite()||i.isZero())return new r(i);if(e=r.precision,t=r.rounding,r.precision=e+Math.max(i.e,i.sd())+4,r.rounding=1,n=i.d.length,n<3)i=oo(r,2,i,i,!0);else{o=1.4*Math.sqrt(n),o=o>16?16:o|0,i=i.times(1/Ji(5,o)),i=oo(r,2,i,i,!0);for(var s,a=new r(5),u=new r(16),c=new r(20);o--;)s=i.times(i),i=i.times(a.plus(s.times(u.times(s).plus(c))))}return r.precision=e,r.rounding=t,Z(i,e,t,!0)};_.hyperbolicTangent=_.tanh=function(){var o,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(o=n.precision,e=n.rounding,n.precision=o+7,n.rounding=1,xe(t.sinh(),t.cosh(),n.precision=o,n.rounding=e)):new n(t.s)};_.inverseCosine=_.acos=function(){var o,e=this,t=e.constructor,n=e.abs().cmp(1),i=t.precision,r=t.rounding;return n!==-1?n===0?e.isNeg()?Ft(t,i,r):new t(0):new t(NaN):e.isZero()?Ft(t,i+4,r).times(.5):(t.precision=i+6,t.rounding=1,e=e.asin(),o=Ft(t,i+4,r).times(.5),t.precision=i,t.rounding=r,o.minus(e))};_.inverseHyperbolicCosine=_.acosh=function(){var o,e,t=this,n=t.constructor;return t.lte(1)?new n(t.eq(1)?0:NaN):t.isFinite()?(o=n.precision,e=n.rounding,n.precision=o+Math.max(Math.abs(t.e),t.sd())+4,n.rounding=1,oe=!1,t=t.times(t).minus(1).sqrt().plus(t),oe=!0,n.precision=o,n.rounding=e,t.ln()):new n(t)};_.inverseHyperbolicSine=_.asinh=function(){var o,e,t=this,n=t.constructor;return!t.isFinite()||t.isZero()?new n(t):(o=n.precision,e=n.rounding,n.precision=o+2*Math.max(Math.abs(t.e),t.sd())+6,n.rounding=1,oe=!1,t=t.times(t).plus(1).sqrt().plus(t),oe=!0,n.precision=o,n.rounding=e,t.ln())};_.inverseHyperbolicTangent=_.atanh=function(){var o,e,t,n,i=this,r=i.constructor;return i.isFinite()?i.e>=0?new r(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(o=r.precision,e=r.rounding,n=i.sd(),Math.max(n,o)<2*-i.e-1?Z(new r(i),o,e,!0):(r.precision=t=n-i.e,i=xe(i.plus(1),new r(1).minus(i),t+o,1),r.precision=o+4,r.rounding=1,i=i.ln(),r.precision=o,r.rounding=e,i.times(.5))):new r(NaN)};_.inverseSine=_.asin=function(){var o,e,t,n,i=this,r=i.constructor;return i.isZero()?new r(i):(e=i.abs().cmp(1),t=r.precision,n=r.rounding,e!==-1?e===0?(o=Ft(r,t+4,n).times(.5),o.s=i.s,o):new r(NaN):(r.precision=t+6,r.rounding=1,i=i.div(new r(1).minus(i.times(i)).sqrt().plus(1)).atan(),r.precision=t,r.rounding=n,i.times(2)))};_.inverseTangent=_.atan=function(){var o,e,t,n,i,r,s,a,u,c=this,l=c.constructor,m=l.precision,d=l.rounding;if(c.isFinite()){if(c.isZero())return new l(c);if(c.abs().eq(1)&&m+4<=Is)return s=Ft(l,m+4,d).times(.25),s.s=c.s,s}else{if(!c.s)return new l(NaN);if(m+4<=Is)return s=Ft(l,m+4,d).times(.5),s.s=c.s,s}for(l.precision=a=m+10,l.rounding=1,t=Math.min(28,a/te+2|0),o=t;o;--o)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(oe=!1,e=Math.ceil(a/te),n=1,u=c.times(c),s=new l(c),i=c;o!==-1;)if(i=i.times(u),r=s.minus(i.div(n+=2)),i=i.times(u),s=r.plus(i.div(n+=2)),s.d[e]!==void 0)for(o=e;s.d[o]===r.d[o]&&o--;);return t&&(s=s.times(2<<t-1)),oe=!0,Z(s,l.precision=m,l.rounding=d,!0)};_.isFinite=function(){return!!this.d};_.isInteger=_.isInt=function(){return!!this.d&&ut(this.e/te)>this.d.length-2};_.isNaN=function(){return!this.s};_.isNegative=_.isNeg=function(){return this.s<0};_.isPositive=_.isPos=function(){return this.s>0};_.isZero=function(){return!!this.d&&this.d[0]===0};_.lessThan=_.lt=function(o){return this.cmp(o)<0};_.lessThanOrEqualTo=_.lte=function(o){return this.cmp(o)<1};_.logarithm=_.log=function(o){var e,t,n,i,r,s,a,u,c=this,l=c.constructor,m=l.precision,d=l.rounding,p=5;if(o==null)o=new l(10),e=!0;else{if(o=new l(o),t=o.d,o.s<0||!t||!t[0]||o.eq(1))return new l(NaN);e=o.eq(10)}if(t=c.d,c.s<0||!t||!t[0]||c.eq(1))return new l(t&&!t[0]?-1/0:c.s!=1?NaN:t?0:1/0);if(e)if(t.length>1)r=!0;else{for(i=t[0];i%10===0;)i/=10;r=i!==1}if(oe=!1,a=m+p,s=gn(c,a),n=e?Hi(l,a+10):gn(o,a),u=xe(s,n,a,1),zo(u.d,i=m,d))do if(a+=10,s=gn(c,a),n=e?Hi(l,a+10):gn(o,a),u=xe(s,n,a,1),!r){+nt(u.d).slice(i+1,i+15)+1==1e14&&(u=Z(u,m+1,0));break}while(zo(u.d,i+=10,d));return oe=!0,Z(u,m,d)};_.minus=_.sub=function(o){var e,t,n,i,r,s,a,u,c,l,m,d,p=this,y=p.constructor;if(o=new y(o),!p.d||!o.d)return!p.s||!o.s?o=new y(NaN):p.d?o.s=-o.s:o=new y(o.d||p.s!==o.s?p:NaN),o;if(p.s!=o.s)return o.s=-o.s,p.plus(o);if(c=p.d,d=o.d,a=y.precision,u=y.rounding,!c[0]||!d[0]){if(d[0])o.s=-o.s;else if(c[0])o=new y(p);else return new y(u===3?-0:0);return oe?Z(o,a,u):o}if(t=ut(o.e/te),l=ut(p.e/te),c=c.slice(),r=l-t,r){for(m=r<0,m?(e=c,r=-r,s=d.length):(e=d,t=l,s=c.length),n=Math.max(Math.ceil(a/te),s)+2,r>n&&(r=n,e.length=1),e.reverse(),n=r;n--;)e.push(0);e.reverse()}else{for(n=c.length,s=d.length,m=n<s,m&&(s=n),n=0;n<s;n++)if(c[n]!=d[n]){m=c[n]<d[n];break}r=0}for(m&&(e=c,c=d,d=e,o.s=-o.s),s=c.length,n=d.length-s;n>0;--n)c[s++]=0;for(n=d.length;n>r;){if(c[--n]<d[n]){for(i=n;i&&c[--i]===0;)c[i]=Dt-1;--c[i],c[n]+=Dt}c[n]-=d[n]}for(;c[--s]===0;)c.pop();for(;c[0]===0;c.shift())--t;return c[0]?(o.d=c,o.e=$i(c,t),oe?Z(o,a,u):o):new y(u===3?-0:0)};_.modulo=_.mod=function(o){var e,t=this,n=t.constructor;return o=new n(o),!t.d||!o.s||o.d&&!o.d[0]?new n(NaN):!o.d||t.d&&!t.d[0]?Z(new n(t),n.precision,n.rounding):(oe=!1,n.modulo==9?(e=xe(t,o.abs(),0,3,1),e.s*=o.s):e=xe(t,o,0,n.modulo,1),e=e.times(o),oe=!0,t.minus(e))};_.naturalExponential=_.exp=function(){return Bs(this)};_.naturalLogarithm=_.ln=function(){return gn(this)};_.negated=_.neg=function(){var o=new this.constructor(this);return o.s=-o.s,Z(o)};_.plus=_.add=function(o){var e,t,n,i,r,s,a,u,c,l,m=this,d=m.constructor;if(o=new d(o),!m.d||!o.d)return!m.s||!o.s?o=new d(NaN):m.d||(o=new d(o.d||m.s===o.s?m:NaN)),o;if(m.s!=o.s)return o.s=-o.s,m.minus(o);if(c=m.d,l=o.d,a=d.precision,u=d.rounding,!c[0]||!l[0])return l[0]||(o=new d(m)),oe?Z(o,a,u):o;if(r=ut(m.e/te),n=ut(o.e/te),c=c.slice(),i=r-n,i){for(i<0?(t=c,i=-i,s=l.length):(t=l,n=r,s=c.length),r=Math.ceil(a/te),s=r>s?r+1:s+1,i>s&&(i=s,t.length=1),t.reverse();i--;)t.push(0);t.reverse()}for(s=c.length,i=l.length,s-i<0&&(i=s,t=l,l=c,c=t),e=0;i;)e=(c[--i]=c[i]+l[i]+e)/Dt|0,c[i]%=Dt;for(e&&(c.unshift(e),++n),s=c.length;c[--s]==0;)c.pop();return o.d=c,o.e=$i(c,n),oe?Z(o,a,u):o};_.precision=_.sd=function(o){var e,t=this;if(o!==void 0&&o!==!!o&&o!==1&&o!==0)throw Error(An+o);return t.d?(e=zu(t.d),o&&t.e+1>e&&(e=t.e+1)):e=NaN,e};_.round=function(){var o=this,e=o.constructor;return Z(new e(o),o.e+1,e.rounding)};_.sine=_.sin=function(){var o,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(o=n.precision,e=n.rounding,n.precision=o+Math.max(t.e,t.sd())+te,n.rounding=1,t=Tm(n,Hu(n,t)),n.precision=o,n.rounding=e,Z(on>2?t.neg():t,o,e,!0)):new n(NaN)};_.squareRoot=_.sqrt=function(){var o,e,t,n,i,r,s=this,a=s.d,u=s.e,c=s.s,l=s.constructor;if(c!==1||!a||!a[0])return new l(!c||c<0&&(!a||a[0])?NaN:a?s:1/0);for(oe=!1,c=Math.sqrt(+s),c==0||c==1/0?(e=nt(a),(e.length+u)%2==0&&(e+="0"),c=Math.sqrt(e),u=ut((u+1)/2)-(u<0||u%2),c==1/0?e="5e"+u:(e=c.toExponential(),e=e.slice(0,e.indexOf("e")+1)+u),n=new l(e)):n=new l(c.toString()),t=(u=l.precision)+3;;)if(r=n,n=r.plus(xe(s,r,t+2,1)).times(.5),nt(r.d).slice(0,t)===(e=nt(n.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!i&&e=="4999"){if(!i&&(Z(r,u+1,0),r.times(r).eq(s))){n=r;break}t+=4,i=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(Z(n,u+1,1),o=!n.times(n).eq(s));break}return oe=!0,Z(n,u,l.rounding,o)};_.tangent=_.tan=function(){var o,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(o=n.precision,e=n.rounding,n.precision=o+10,n.rounding=1,t=t.sin(),t.s=1,t=xe(t,new n(1).minus(t.times(t)).sqrt(),o+10,0),n.precision=o,n.rounding=e,Z(on==2||on==4?t.neg():t,o,e,!0)):new n(NaN)};_.times=_.mul=function(o){var e,t,n,i,r,s,a,u,c,l=this,m=l.constructor,d=l.d,p=(o=new m(o)).d;if(o.s*=l.s,!d||!d[0]||!p||!p[0])return new m(!o.s||d&&!d[0]&&!p||p&&!p[0]&&!d?NaN:!d||!p?o.s/0:o.s*0);for(t=ut(l.e/te)+ut(o.e/te),u=d.length,c=p.length,u<c&&(r=d,d=p,p=r,s=u,u=c,c=s),r=[],s=u+c,n=s;n--;)r.push(0);for(n=c;--n>=0;){for(e=0,i=u+n;i>n;)a=r[i]+p[n]*d[i-n-1]+e,r[i--]=a%Dt|0,e=a/Dt|0;r[i]=(r[i]+e)%Dt|0}for(;!r[--s];)r.pop();return e?++t:r.shift(),o.d=r,o.e=$i(r,t),oe?Z(o,m.precision,m.rounding):o};_.toBinary=function(o,e){return Ss(this,2,o,e)};_.toDecimalPlaces=_.toDP=function(o,e){var t=this,n=t.constructor;return t=new n(t),o===void 0?t:(Pt(o,0,wn),e===void 0?e=n.rounding:Pt(e,0,8),Z(t,o+t.e+1,e))};_.toExponential=function(o,e){var t,n=this,i=n.constructor;return o===void 0?t=Qt(n,!0):(Pt(o,0,wn),e===void 0?e=i.rounding:Pt(e,0,8),n=Z(new i(n),o+1,e),t=Qt(n,!0,o+1)),n.isNeg()&&!n.isZero()?"-"+t:t};_.toFixed=function(o,e){var t,n,i=this,r=i.constructor;return o===void 0?t=Qt(i):(Pt(o,0,wn),e===void 0?e=r.rounding:Pt(e,0,8),n=Z(new r(i),o+i.e+1,e),t=Qt(n,!1,o+n.e+1)),i.isNeg()&&!i.isZero()?"-"+t:t};_.toFraction=function(o){var e,t,n,i,r,s,a,u,c,l,m,d,p=this,y=p.d,f=p.constructor;if(!y)return new f(p);if(c=t=new f(1),n=u=new f(0),e=new f(n),r=e.e=zu(y)-p.e-1,s=r%te,e.d[0]=Qe(10,s<0?te+s:s),o==null)o=r>0?e:c;else{if(a=new f(o),!a.isInt()||a.lt(c))throw Error(An+a);o=a.gt(e)?r>0?e:c:a}for(oe=!1,a=new f(nt(y)),l=f.precision,f.precision=r=y.length*te*2;m=xe(a,e,0,1,1),i=t.plus(m.times(n)),i.cmp(o)!=1;)t=n,n=i,i=c,c=u.plus(m.times(i)),u=i,i=e,e=a.minus(m.times(i)),a=i;return i=xe(o.minus(t),n,0,1,1),u=u.plus(i.times(c)),t=t.plus(i.times(n)),u.s=c.s=p.s,d=xe(c,n,r,1).minus(p).abs().cmp(xe(u,t,r,1).minus(p).abs())<1?[c,n]:[u,t],f.precision=l,oe=!0,d};_.toHexadecimal=_.toHex=function(o,e){return Ss(this,16,o,e)};_.toNearest=function(o,e){var t=this,n=t.constructor;if(t=new n(t),o==null){if(!t.d)return t;o=new n(1),e=n.rounding}else{if(o=new n(o),e===void 0?e=n.rounding:Pt(e,0,8),!t.d)return o.s?t:o;if(!o.d)return o.s&&(o.s=t.s),o}return o.d[0]?(oe=!1,t=xe(t,o,0,e,1).times(o),oe=!0,Z(t)):(o.s=t.s,t=o),t};_.toNumber=function(){return+this};_.toOctal=function(o,e){return Ss(this,8,o,e)};_.toPower=_.pow=function(o){var e,t,n,i,r,s,a=this,u=a.constructor,c=+(o=new u(o));if(!a.d||!o.d||!a.d[0]||!o.d[0])return new u(Qe(+a,c));if(a=new u(a),a.eq(1))return a;if(n=u.precision,r=u.rounding,o.eq(1))return Z(a,n,r);if(e=ut(o.e/te),e>=o.d.length-1&&(t=c<0?-c:c)<=wm)return i=Qu(u,a,t,n),o.s<0?new u(1).div(i):Z(i,n,r);if(s=a.s,s<0){if(e<o.d.length-1)return new u(NaN);if((o.d[e]&1)==0&&(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return t=Qe(+a,c),e=t==0||!isFinite(t)?ut(c*(Math.log("0."+nt(a.d))/Math.LN10+a.e+1)):new u(t+"").e,e>u.maxE+1||e<u.minE-1?new u(e>0?s/0:0):(oe=!1,u.rounding=a.s=1,t=Math.min(12,(e+"").length),i=Bs(o.times(gn(a,n+t)),n),i.d&&(i=Z(i,n+5,1),zo(i.d,n,r)&&(e=n+10,i=Z(Bs(o.times(gn(a,e+t)),e),e+5,1),+nt(i.d).slice(n+1,n+15)+1==1e14&&(i=Z(i,n+1,0)))),i.s=s,oe=!0,u.rounding=r,Z(i,n,r))};_.toPrecision=function(o,e){var t,n=this,i=n.constructor;return o===void 0?t=Qt(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(Pt(o,1,wn),e===void 0?e=i.rounding:Pt(e,0,8),n=Z(new i(n),o,e),t=Qt(n,o<=n.e||n.e<=i.toExpNeg,o)),n.isNeg()&&!n.isZero()?"-"+t:t};_.toSignificantDigits=_.toSD=function(o,e){var t=this,n=t.constructor;return o===void 0?(o=n.precision,e=n.rounding):(Pt(o,1,wn),e===void 0?e=n.rounding:Pt(e,0,8)),Z(new n(t),o,e)};_.toString=function(){var o=this,e=o.constructor,t=Qt(o,o.e<=e.toExpNeg||o.e>=e.toExpPos);return o.isNeg()&&!o.isZero()?"-"+t:t};_.truncated=_.trunc=function(){return Z(new this.constructor(this),this.e+1,1)};_.valueOf=_.toJSON=function(){var o=this,e=o.constructor,t=Qt(o,o.e<=e.toExpNeg||o.e>=e.toExpPos);return o.isNeg()?"-"+t:t};function nt(o){var e,t,n,i=o.length-1,r="",s=o[0];if(i>0){for(r+=s,e=1;e<i;e++)n=o[e]+"",t=te-n.length,t&&(r+=bn(t)),r+=n;s=o[e],n=s+"",t=te-n.length,t&&(r+=bn(t))}else if(s===0)return"0";for(;s%10===0;)s/=10;return r+s}function Pt(o,e,t){if(o!==~~o||o<e||o>t)throw Error(An+o)}function zo(o,e,t,n){var i,r,s,a;for(r=o[0];r>=10;r/=10)--e;return--e<0?(e+=te,i=0):(i=Math.ceil((e+1)/te),e%=te),r=Qe(10,te-e),a=o[i]%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)&&(o[i+1]/r/100|0)==Qe(10,e-2)-1||(a==r/2||a==0)&&(o[i+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)&&(o[i+1]/r/1e3|0)==Qe(10,e-3)-1,s}function Qi(o,e,t){for(var n,i=[0],r,s=0,a=o.length;s<a;){for(r=i.length;r--;)i[r]*=e;for(i[0]+=hs.indexOf(o.charAt(s++)),n=0;n<i.length;n++)i[n]>t-1&&(i[n+1]===void 0&&(i[n+1]=0),i[n+1]+=i[n]/t|0,i[n]%=t)}return i.reverse()}function km(o,e){var t,n,i;if(e.isZero())return e;n=e.d.length,n<32?(t=Math.ceil(n/3),i=(1/Ji(4,t)).toString()):(t=16,i="2.3283064365386962890625e-10"),o.precision+=t,e=oo(o,1,e.times(i),new o(1));for(var r=t;r--;){var s=e.times(e);e=s.times(s).minus(s).times(8).plus(1)}return o.precision-=t,e}var xe=function(){function o(n,i,r){var s,a=0,u=n.length;for(n=n.slice();u--;)s=n[u]*i+a,n[u]=s%r|0,a=s/r|0;return a&&n.unshift(a),n}function e(n,i,r,s){var a,u;if(r!=s)u=r>s?1:-1;else for(a=u=0;a<r;a++)if(n[a]!=i[a]){u=n[a]>i[a]?1:-1;break}return u}function t(n,i,r,s){for(var a=0;r--;)n[r]-=a,a=n[r]<i[r]?1:0,n[r]=a*s+n[r]-i[r];for(;!n[0]&&n.length>1;)n.shift()}return function(n,i,r,s,a,u){var c,l,m,d,p,y,f,b,g,A,w,h,I,T,B,x,C,S,R,D,V=n.constructor,$=n.s==i.s?1:-1,H=n.d,W=i.d;if(!H||!H[0]||!W||!W[0])return new V(!n.s||!i.s||(H?W&&H[0]==W[0]:!W)?NaN:H&&H[0]==0||!W?$*0:$/0);for(u?(p=1,l=n.e-i.e):(u=Dt,p=te,l=ut(n.e/p)-ut(i.e/p)),R=W.length,C=H.length,g=new V($),A=g.d=[],m=0;W[m]==(H[m]||0);m++);if(W[m]>(H[m]||0)&&l--,r==null?(T=r=V.precision,s=V.rounding):a?T=r+(n.e-i.e)+1:T=r,T<0)A.push(1),y=!0;else{if(T=T/p+2|0,m=0,R==1){for(d=0,W=W[0],T++;(m<C||d)&&T--;m++)B=d*u+(H[m]||0),A[m]=B/W|0,d=B%W|0;y=d||m<C}else{for(d=u/(W[0]+1)|0,d>1&&(W=o(W,d,u),H=o(H,d,u),R=W.length,C=H.length),x=R,w=H.slice(0,R),h=w.length;h<R;)w[h++]=0;D=W.slice(),D.unshift(0),S=W[0],W[1]>=u/2&&++S;do d=0,c=e(W,w,R,h),c<0?(I=w[0],R!=h&&(I=I*u+(w[1]||0)),d=I/S|0,d>1?(d>=u&&(d=u-1),f=o(W,d,u),b=f.length,h=w.length,c=e(f,w,b,h),c==1&&(d--,t(f,R<b?D:W,b,u))):(d==0&&(c=d=1),f=W.slice()),b=f.length,b<h&&f.unshift(0),t(w,f,h,u),c==-1&&(h=w.length,c=e(W,w,R,h),c<1&&(d++,t(w,R<h?D:W,h,u))),h=w.length):c===0&&(d++,w=[0]),A[m++]=d,c&&w[0]?w[h++]=H[x]||0:(w=[H[x]],h=1);while((x++<C||w[0]!==void 0)&&T--);y=w[0]!==void 0}A[0]||A.shift()}if(p==1)g.e=l,Wu=y;else{for(m=1,d=A[0];d>=10;d/=10)m++;g.e=m+l*p-1,Z(g,a?r+g.e+1:r,s,y)}return g}}();function Z(o,e,t,n){var i,r,s,a,u,c,l,m,d,p=o.constructor;e:if(e!=null){if(m=o.d,!m)return o;for(i=1,a=m[0];a>=10;a/=10)i++;if(r=e-i,r<0)r+=te,s=e,l=m[d=0],u=l/Qe(10,i-s-1)%10|0;else if(d=Math.ceil((r+1)/te),a=m.length,d>=a)if(n){for(;a++<=d;)m.push(0);l=u=0,i=1,r%=te,s=r-te+1}else break e;else{for(l=a=m[d],i=1;a>=10;a/=10)i++;r%=te,s=r-te+i,u=s<0?0:l/Qe(10,i-s-1)%10|0}if(n=n||e<0||m[d+1]!==void 0||(s<0?l:l%Qe(10,i-s-1)),c=t<4?(u||n)&&(t==0||t==(o.s<0?3:2)):u>5||u==5&&(t==4||n||t==6&&(r>0?s>0?l/Qe(10,i-s):0:m[d-1])%10&1||t==(o.s<0?8:7)),e<1||!m[0])return m.length=0,c?(e-=o.e+1,m[0]=Qe(10,(te-e%te)%te),o.e=-e||0):m[0]=o.e=0,o;if(r==0?(m.length=d,a=1,d--):(m.length=d+1,a=Qe(10,te-r),m[d]=s>0?(l/Qe(10,i-s)%Qe(10,s)|0)*a:0),c)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&&(o.e++,m[0]==Dt&&(m[0]=1));break}else{if(m[d]+=a,m[d]!=Dt)break;m[d--]=0,a=1}for(r=m.length;m[--r]===0;)m.pop()}return oe&&(o.e>p.maxE?(o.d=null,o.e=NaN):o.e<p.minE&&(o.e=0,o.d=[0])),o}function Qt(o,e,t){if(!o.isFinite())return Yu(o);var n,i=o.e,r=nt(o.d),s=r.length;return e?(t&&(n=t-s)>0?r=r.charAt(0)+"."+r.slice(1)+bn(n):s>1&&(r=r.charAt(0)+"."+r.slice(1)),r=r+(o.e<0?"e":"e+")+o.e):i<0?(r="0."+bn(-i-1)+r,t&&(n=t-s)>0&&(r+=bn(n))):i>=s?(r+=bn(i+1-s),t&&(n=t-i-1)>0&&(r=r+"."+bn(n))):((n=i+1)<s&&(r=r.slice(0,n)+"."+r.slice(n)),t&&(n=t-s)>0&&(i+1===s&&(r+="."),r+=bn(n))),r}function $i(o,e){var t=o[0];for(e*=te;t>=10;t/=10)e++;return e}function Hi(o,e,t){if(e>Pm)throw oe=!0,t&&(o.precision=t),Error(qu);return Z(new o(ji),e,1,!0)}function Ft(o,e,t){if(e>Is)throw Error(qu);return Z(new o(Yi),e,t,!0)}function zu(o){var e=o.length-1,t=e*te+1;if(e=o[e],e){for(;e%10==0;e/=10)t--;for(e=o[0];e>=10;e/=10)t++}return t}function bn(o){for(var e="";o--;)e+="0";return e}function Qu(o,e,t,n){var i,r=new o(1),s=Math.ceil(n/te+4);for(oe=!1;;){if(t%2&&(r=r.times(e),Fu(r.d,s)&&(i=!0)),t=ut(t/2),t===0){t=r.d.length-1,i&&r.d[t]===0&&++r.d[t];break}e=e.times(e),Fu(e.d,s)}return oe=!0,r}function Eu(o){return o.d[o.d.length-1]&1}function ju(o,e,t){for(var n,i=new o(e[0]),r=0;++r<e.length;)if(n=new o(e[r]),n.s)i[t](n)&&(i=n);else{i=n;break}return i}function Bs(o,e){var t,n,i,r,s,a,u,c=0,l=0,m=0,d=o.constructor,p=d.rounding,y=d.precision;if(!o.d||!o.d[0]||o.e>17)return new d(o.d?o.d[0]?o.s<0?0:1/0:1:o.s?o.s<0?0:o:0/0);for(e==null?(oe=!1,u=y):u=e,a=new d(.03125);o.e>-2;)o=o.times(a),m+=5;for(n=Math.log(Qe(2,m))/Math.LN10*2+5|0,u+=n,t=r=s=new d(1),d.precision=u;;){if(r=Z(r.times(o),u,1),t=t.times(++l),a=s.plus(xe(r,t,u,1)),nt(a.d).slice(0,u)===nt(s.d).slice(0,u)){for(i=m;i--;)s=Z(s.times(s),u,1);if(e==null)if(c<3&&zo(s.d,u-n,p,c))d.precision=u+=10,t=r=a=new d(1),l=0,c++;else return Z(s,d.precision=y,p,oe=!0);else return d.precision=y,s}s=a}}function gn(o,e){var t,n,i,r,s,a,u,c,l,m,d,p=1,y=10,f=o,b=f.d,g=f.constructor,A=g.rounding,w=g.precision;if(f.s<0||!b||!b[0]||!f.e&&b[0]==1&&b.length==1)return new g(b&&!b[0]?-1/0:f.s!=1?NaN:b?0:f);if(e==null?(oe=!1,l=w):l=e,g.precision=l+=y,t=nt(b),n=t.charAt(0),Math.abs(r=f.e)<15e14){for(;n<7&&n!=1||n==1&&t.charAt(1)>3;)f=f.times(o),t=nt(f.d),n=t.charAt(0),p++;r=f.e,n>1?(f=new g("0."+t),r++):f=new g(n+"."+t.slice(1))}else return c=Hi(g,l+2,w).times(r+""),f=gn(new g(n+"."+t.slice(1)),l-y).plus(c),g.precision=w,e==null?Z(f,w,A,oe=!0):f;for(m=f,u=s=f=xe(f.minus(1),f.plus(1),l,1),d=Z(f.times(f),l,1),i=3;;){if(s=Z(s.times(d),l,1),c=u.plus(xe(s,new g(i),l,1)),nt(c.d).slice(0,l)===nt(u.d).slice(0,l))if(u=u.times(2),r!==0&&(u=u.plus(Hi(g,l+2,w).times(r+""))),u=xe(u,new g(p),l,1),e==null)if(zo(u.d,l-y,A,a))g.precision=l+=y,c=s=f=xe(m.minus(1),m.plus(1),l,1),d=Z(f.times(f),l,1),i=a=1;else return Z(u,g.precision=w,A,oe=!0);else return g.precision=w,u;u=c,i+=2}}function Yu(o){return String(o.s*o.s/0)}function xs(o,e){var t,n,i;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(i=e.length;e.charCodeAt(i-1)===48;--i);if(e=e.slice(n,i),e){if(i-=n,o.e=t=t-n-1,o.d=[],n=(t+1)%te,t<0&&(n+=te),n<i){for(n&&o.d.push(+e.slice(0,n)),i-=te;n<i;)o.d.push(+e.slice(n,n+=te));e=e.slice(n),n=te-e.length}else n-=i;for(;n--;)e+="0";o.d.push(+e),oe&&(o.e>o.constructor.maxE?(o.d=null,o.e=NaN):o.e<o.constructor.minE&&(o.e=0,o.d=[0]))}else o.e=0,o.d=[0];return o}function hm(o,e){var t,n,i,r,s,a,u,c,l;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),Xu.test(e))return xs(o,e)}else if(e==="Infinity"||e==="NaN")return+e||(o.s=NaN),o.e=NaN,o.d=null,o;if(gm.test(e))t=16,e=e.toLowerCase();else if(bm.test(e))t=2;else if(Am.test(e))t=8;else throw Error(An+e);for(r=e.search(/p/i),r>0?(u=+e.slice(r+1),e=e.substring(2,r)):e=e.slice(2),r=e.indexOf("."),s=r>=0,n=o.constructor,s&&(e=e.replace(".",""),a=e.length,r=a-r,i=Qu(n,new n(t),r,r*2)),c=Qi(e,t,Dt),l=c.length-1,r=l;c[r]===0;--r)c.pop();return r<0?new n(o.s*0):(o.e=$i(c,l),o.d=c,oe=!1,s&&(o=xe(o,i,a*4)),u&&(o=o.times(Math.abs(u)<54?Qe(2,u):Qo.pow(2,u))),oe=!0,o)}function Tm(o,e){var t,n=e.d.length;if(n<3)return e.isZero()?e:oo(o,2,e,e);t=1.4*Math.sqrt(n),t=t>16?16:t|0,e=e.times(1/Ji(5,t)),e=oo(o,2,e,e);for(var i,r=new o(5),s=new o(16),a=new o(20);t--;)i=e.times(e),e=e.times(r.plus(i.times(s.times(i).minus(a))));return e}function oo(o,e,t,n,i){var r,s,a,u,c=1,l=o.precision,m=Math.ceil(l/te);for(oe=!1,u=t.times(t),a=new o(n);;){if(s=xe(a.times(u),new o(e++*e++),l,1),a=i?n.plus(s):n.minus(s),n=xe(s.times(u),new o(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,c++}return oe=!0,s.d.length=m+1,s}function Ji(o,e){for(var t=o;--e;)t*=o;return t}function Hu(o,e){var t,n=e.s<0,i=Ft(o,o.precision,1),r=i.times(.5);if(e=e.abs(),e.lte(r))return on=n?4:1,e;if(t=e.divToInt(i),t.isZero())on=n?3:2;else{if(e=e.minus(t.times(i)),e.lte(r))return on=Eu(t)?n?2:3:n?4:1,e;on=Eu(t)?n?1:4:n?3:2}return e.minus(i).abs()}function Ss(o,e,t,n){var i,r,s,a,u,c,l,m,d,p=o.constructor,y=t!==void 0;if(y?(Pt(t,1,wn),n===void 0?n=p.rounding:Pt(n,0,8)):(t=p.precision,n=p.rounding),!o.isFinite())l=Yu(o);else{for(l=Qt(o),s=l.indexOf("."),y?(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=Qi(Qt(d),10,i),d.e=d.d.length),m=Qi(l,10,i),r=u=m.length;m[--u]==0;)m.pop();if(!m[0])l=y?"0p+0":"0";else{if(s<0?r--:(o=new p(o),o.d=m,o.e=r,o=xe(o,d,t,n,0,i),m=o.d,r=o.e,c=Wu),s=m[t],a=i/2,c=c||m[t+1]!==void 0,c=n<4?(s!==void 0||c)&&(n===0||n===(o.s<0?3:2)):s>a||s===a&&(n===4||c||n===6&&m[t-1]&1||n===(o.s<0?8:7)),m.length=t,c)for(;++m[--t]>i-1;)m[t]=0,t||(++r,m.unshift(1));for(u=m.length;!m[u-1];--u);for(s=0,l="";s<u;s++)l+=hs.charAt(m[s]);if(y){if(u>1)if(e==16||e==8){for(s=e==16?4:3,--u;u%s;u++)l+="0";for(m=Qi(l,i,e),u=m.length;!m[u-1];--u);for(s=1,l="1.";s<u;s++)l+=hs.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>u)for(r-=u;r--;)l+="0";else r<u&&(l=l.slice(0,r)+"."+l.slice(r))}l=(e==16?"0x":e==2?"0b":e==8?"0o":"")+l}return o.s<0?"-"+l:l}function Fu(o,e){if(o.length>e)return o.length=e,!0}function Im(o){return new this(o).abs()}function Bm(o){return new this(o).acos()}function xm(o){return new this(o).acosh()}function Sm(o,e){return new this(o).plus(e)}function Km(o){return new this(o).asin()}function Cm(o){return new this(o).asinh()}function Rm(o){return new this(o).atan()}function Lm(o){return new this(o).atanh()}function Om(o,e){o=new this(o),e=new this(e);var t,n=this.precision,i=this.rounding,r=n+4;return!o.s||!e.s?t=new this(NaN):!o.d&&!e.d?(t=Ft(this,r,1).times(e.s>0?.25:.75),t.s=o.s):!e.d||o.isZero()?(t=e.s<0?Ft(this,n,i):new this(0),t.s=o.s):!o.d||e.isZero()?(t=Ft(this,r,1).times(.5),t.s=o.s):e.s<0?(this.precision=r,this.rounding=1,t=this.atan(xe(o,e,r,1)),e=Ft(this,r,1),this.precision=n,this.rounding=i,t=o.s<0?t.minus(e):t.plus(e)):t=this.atan(xe(o,e,r,1)),t}function Nm(o){return new this(o).cbrt()}function Mm(o){return Z(o=new this(o),o.e+1,2)}function _m(o,e,t){return new this(o).clamp(e,t)}function Vm(o){if(!o||typeof o!="object")throw Error(Zi+"Object expected");var e,t,n,i=o.defaults===!0,r=["precision",1,wn,"rounding",0,8,"toExpNeg",-no,0,"toExpPos",0,no,"maxE",0,no,"minE",-no,0,"modulo",0,9];for(e=0;e<r.length;e+=3)if(t=r[e],i&&(this[t]=Ts[t]),(n=o[t])!==void 0)if(ut(n)===n&&n>=r[e+1]&&n<=r[e+2])this[t]=n;else throw Error(An+t+": "+n);if(t="crypto",i&&(this[t]=Ts[t]),(n=o[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(Uu);else this[t]=!1;else throw Error(An+t+": "+n);return this}function vm(o){return new this(o).cos()}function Em(o){return new this(o).cosh()}function Zu(o){var e,t,n;function i(r){var s,a,u,c=this;if(!(c instanceof i))return new i(r);if(c.constructor=i,Du(r)){c.s=r.s,oe?!r.d||r.e>i.maxE?(c.e=NaN,c.d=null):r.e<i.minE?(c.e=0,c.d=[0]):(c.e=r.e,c.d=r.d.slice()):(c.e=r.e,c.d=r.d?r.d.slice():r.d);return}if(u=typeof r,u==="number"){if(r===0){c.s=1/r<0?-1:1,c.e=0,c.d=[0];return}if(r<0?(r=-r,c.s=-1):c.s=1,r===~~r&&r<1e7){for(s=0,a=r;a>=10;a/=10)s++;oe?s>i.maxE?(c.e=NaN,c.d=null):s<i.minE?(c.e=0,c.d=[0]):(c.e=s,c.d=[r]):(c.e=s,c.d=[r]);return}else if(r*0!==0){r||(c.s=NaN),c.e=NaN,c.d=null;return}return xs(c,r.toString())}else if(u!=="string")throw Error(An+r);return(a=r.charCodeAt(0))===45?(r=r.slice(1),c.s=-1):(a===43&&(r=r.slice(1)),c.s=1),Xu.test(r)?xs(c,r):hm(c,r)}if(i.prototype=_,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=Vm,i.clone=Zu,i.isDecimal=Du,i.abs=Im,i.acos=Bm,i.acosh=xm,i.add=Sm,i.asin=Km,i.asinh=Cm,i.atan=Rm,i.atanh=Lm,i.atan2=Om,i.cbrt=Nm,i.ceil=Mm,i.clamp=_m,i.cos=vm,i.cosh=Em,i.div=Fm,i.exp=Dm,i.floor=Wm,i.hypot=qm,i.ln=Um,i.log=Gm,i.log10=zm,i.log2=Xm,i.max=Qm,i.min=jm,i.mod=Ym,i.mul=Hm,i.pow=Zm,i.random=$m,i.round=Jm,i.sign=ed,i.sin=td,i.sinh=nd,i.sqrt=od,i.sub=id,i.sum=rd,i.tan=sd,i.tanh=ad,i.trunc=ud,o===void 0&&(o={}),o&&o.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<n.length;)o.hasOwnProperty(t=n[e++])||(o[t]=this[t]);return i.config(o),i}function Fm(o,e){return new this(o).div(e)}function Dm(o){return new this(o).exp()}function Wm(o){return Z(o=new this(o),o.e+1,3)}function qm(){var o,e,t=new this(0);for(oe=!1,o=0;o<arguments.length;)if(e=new this(arguments[o++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return oe=!0,new this(1/0);t=e}return oe=!0,t.sqrt()}function Du(o){return o instanceof Qo||o&&o.toStringTag===Gu||!1}function Um(o){return new this(o).ln()}function Gm(o,e){return new this(o).log(e)}function Xm(o){return new this(o).log(2)}function zm(o){return new this(o).log(10)}function Qm(){return ju(this,arguments,"lt")}function jm(){return ju(this,arguments,"gt")}function Ym(o,e){return new this(o).mod(e)}function Hm(o,e){return new this(o).mul(e)}function Zm(o,e){return new this(o).pow(e)}function $m(o){var e,t,n,i,r=0,s=new this(1),a=[];if(o===void 0?o=this.precision:Pt(o,1,wn),n=Math.ceil(o/te),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(n));r<n;)i=e[r],i>=429e7?e[r]=crypto.getRandomValues(new Uint32Array(1))[0]:a[r++]=i%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(n*=4);r<n;)i=e[r]+(e[r+1]<<8)+(e[r+2]<<16)+((e[r+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(e,r):(a.push(i%1e7),r+=4);r=n/4}else throw Error(Uu);else for(;r<n;)a[r++]=Math.random()*1e7|0;for(n=a[--r],o%=te,n&&o&&(i=Qe(10,te-o),a[r]=(n/i|0)*i);a[r]===0;r--)a.pop();if(r<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=te)a.shift();for(n=1,i=a[0];i>=10;i/=10)n++;n<te&&(t-=te-n)}return s.e=t,s.d=a,s}function Jm(o){return Z(o=new this(o),o.e+1,this.rounding)}function ed(o){return o=new this(o),o.d?o.d[0]?o.s:0*o.s:o.s||NaN}function td(o){return new this(o).sin()}function nd(o){return new this(o).sinh()}function od(o){return new this(o).sqrt()}function id(o,e){return new this(o).sub(e)}function rd(){var o=0,e=arguments,t=new this(e[o]);for(oe=!1;t.s&&++o<e.length;)t=t.plus(e[o]);return oe=!0,Z(t,this.precision,this.rounding)}function sd(o){return new this(o).tan()}function ad(o){return new this(o).tanh()}function ud(o){return Z(o=new this(o),o.e+1,1)}_[Symbol.for("nodejs.util.inspect.custom")]=_.toString;_[Symbol.toStringTag]="Decimal";var Qo=_.constructor=Zu(Ts);ji=new Qo(ji);Yi=new Qo(Yi);var L=Qo;var nc=de(require("big.js")),rn=de(require("bn.js"));var $u=de(require("toformat")),cd=$u.default,jo=cd;var Yo=de(require("big.js")),ec=de(require("bn.js")),tc=de(require("decimal.js-light"));var io=de(require("bn.js"));var er=(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))(er||{}),Ju=9007199254740991;function Y(o){let e=me("Raydium_parseBigNumberish");if(o instanceof io.default)return o;if(typeof o=="string"){if(o.match(/^-?[0-9]+$/))return new io.default(o);e.logWithError(`invalid BigNumberish string: ${o}`)}return typeof o=="number"?(o%1&&e.logWithError(`BigNumberish number underflow: ${o}`),(o>=Ju||o<=-Ju)&&e.logWithError(`BigNumberish number overflow: ${o}`),new io.default(String(o))):typeof o=="bigint"?new io.default(o.toString()):(e.error(`invalid BigNumberish value: ${o}`),new io.default(0))}var tr=me("module/fraction"),Ks=jo(Yo.default),Ho=jo(tc.default),ld={[0]:Ho.ROUND_DOWN,[1]:Ho.ROUND_HALF_UP,[2]:Ho.ROUND_UP},md={[0]:Yo.default.roundDown,[1]:Yo.default.roundHalfUp,[2]:Yo.default.roundUp},ie=class{constructor(e,t=new ec.default(1)){this.numerator=Y(e),this.denominator=Y(t)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new ie(this.denominator,this.numerator)}add(e){let t=e instanceof ie?e:new ie(Y(e));return this.denominator.eq(t.denominator)?new ie(this.numerator.add(t.numerator),this.denominator):new ie(this.numerator.mul(t.denominator).add(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}sub(e){let t=e instanceof ie?e:new ie(Y(e));return this.denominator.eq(t.denominator)?new ie(this.numerator.sub(t.numerator),this.denominator):new ie(this.numerator.mul(t.denominator).sub(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}mul(e){let t=e instanceof ie?e:new ie(Y(e));return new ie(this.numerator.mul(t.numerator),this.denominator.mul(t.denominator))}div(e){let t=e instanceof ie?e:new ie(Y(e));return new ie(this.numerator.mul(t.denominator),this.denominator.mul(t.numerator))}toSignificant(e,t={groupSeparator:""},n=1){Number.isInteger(e)||tr.logWithError(`${e} is not an integer.`),e<=0&&tr.logWithError(`${e} is not positive.`),Ho.set({precision:e+1,rounding:ld[n]});let i=new Ho(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(e);return i.toFormat(i.decimalPlaces(),t)}toFixed(e,t={groupSeparator:""},n=1){return Number.isInteger(e)||tr.logWithError(`${e} is not an integer.`),e<0&&tr.logWithError(`${e} is negative.`),Ks.DP=e,Ks.RM=md[n]||1,new Ks(this.numerator.toString()).div(this.denominator.toString()).toFormat(e,t)}isZero(){return this.numerator.isZero()}};var dd=me("Raydium_amount"),nr=jo(nc.default);function Cs(o,e){let t="0",n="0";if(o.includes(".")){let i=o.split(".");i.le