UNPKG

@cobaltx/sdk-v2

Version:

An SDK for building applications on top of CobaltX.

1 lines 426 kB
"use strict";var hm=Object.create;var Jo=Object.defineProperty;var Tm=Object.getOwnPropertyDescriptor;var Im=Object.getOwnPropertyNames;var Bm=Object.getPrototypeOf,xm=Object.prototype.hasOwnProperty;var Sm=(i,e)=>{for(var t in e)Jo(i,t,{get:e[t],enumerable:!0})},zu=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Im(e))!xm.call(i,o)&&o!==t&&Jo(i,o,{get:()=>e[o],enumerable:!(n=Tm(e,o))||n.enumerable});return i};var me=(i,e,t)=>(t=i!=null?hm(Bm(i)):{},zu(e||!i||!i.__esModule?Jo(t,"default",{value:i,enumerable:!0}):t,i)),Km=i=>zu(Jo({},"__esModule",{value:!0}),i);var ob={};Sm(ob,{ACCOUNT_TYPE_SIZE:()=>Lm,ALL_PROGRAM_ID:()=>ft,AMM_CONFIG_SEED:()=>ml,AMM_STABLE:()=>Mc,AMM_V4:()=>pi,API_URLS:()=>Be,AccountType:()=>ju,Api:()=>yo,BIT_PRECISION:()=>Ba,BNDivCeil:()=>Ut,BNLayout:()=>_n,BN_100:()=>Qd,BN_1000:()=>Hd,BN_10000:()=>jd,BN_FIVE:()=>zd,BN_ONE:()=>js,BN_TEN:()=>Rn,BN_THREE:()=>Xd,BN_TWO:()=>Gd,BN_ZERO:()=>We,BONKMint:()=>Ld,BitStructure:()=>cp,Blob:()=>da,CLMM_LOCK_AUTH_ID:()=>fi,CLMM_LOCK_PROGRAM_ID:()=>Yn,CLMM_PROGRAM_ID:()=>wn,CLOCK_PROGRAM_ID:()=>br,CREATE_CPMM_POOL_AUTH:()=>Ir,CREATE_CPMM_POOL_FEE_ACC:()=>Fc,CREATE_CPMM_POOL_PROGRAM:()=>bi,Clmm:()=>Ri,ClmmConfigLayout:()=>Ua,ClmmInstrument:()=>Te,CobaltX:()=>Zo,ConstantProductCurve:()=>Ko,CpmmConfigInfoLayout:()=>iu,CpmmFee:()=>Co,CpmmPoolInfoLayout:()=>No,Currency:()=>li,CurrencyAmount:()=>Ln,CurveCalculator:()=>Ro,DEVNET_PROGRAM_ID:()=>rp,DEV_API_URLS:()=>ap,DEV_CREATE_CPMM_POOL_AUTH:()=>Wc,DEV_CREATE_CPMM_POOL_FEE_ACC:()=>qc,DEV_CREATE_CPMM_POOL_PROGRAM:()=>Dc,DEV_LOCK_CPMM_AUTH:()=>Gc,DEV_LOCK_CPMM_PROGRAM:()=>Uc,DataElement:()=>$l,EXTENSION_TICKARRAY_BITMAP_SIZE:()=>Gr,FARM_LOCK_MINT:()=>mu,FARM_LOCK_VAULT:()=>du,FARM_PROGRAM_ID_V3:()=>kr,FARM_PROGRAM_ID_V4:()=>ra,FARM_PROGRAM_ID_V5:()=>hr,FARM_PROGRAM_ID_V6:()=>jn,FARM_PROGRAM_TO_VERSION:()=>Dt,FARM_VERSION_TO_LEDGER_LAYOUT:()=>fu,FARM_VERSION_TO_STATE_LAYOUT:()=>pu,FEE_DESTINATION_ID:()=>sa,FEE_RATE_DENOMINATOR:()=>Bo,FEE_RATE_DENOMINATOR_VALUE:()=>Hr,FETCH_TICKARRAY_COUNT:()=>wl,Fee:()=>ll,Fraction:()=>se,IDO_ALL_PROGRAM:()=>Ai,IDO_PROGRAM_ID_V1:()=>_c,IDO_PROGRAM_ID_V2:()=>vc,IDO_PROGRAM_ID_V3:()=>Vc,IDO_PROGRAM_ID_V4:()=>Ec,INSTRUCTION_PROGRAM_ID:()=>oo,InstructionType:()=>F,JupTokenType:()=>aa,LIQUIDITY_FEES_DENOMINATOR:()=>Wo,LIQUIDITY_FEES_NUMERATOR:()=>gs,LIQUIDITY_POOL_PROGRAM_ID_V5_MODEL:()=>mo,LIQUIDITY_VERSION_TO_SERUM_VERSION:()=>jl,LIQUIDITY_VERSION_TO_STATE_LAYOUT:()=>Ef,LOCK_CPMM_AUTH:()=>gi,LOCK_CPMM_PROGRAM:()=>yi,LOCK_LIQUIDITY_SEED:()=>Rl,LOG_B_2_X32:()=>xa,LOG_B_P_ERR_MARGIN_LOWER_X64:()=>Sa,LOG_B_P_ERR_MARGIN_UPPER_X64:()=>Ka,LOOKUP_TABLE_CACHE:()=>po,Layout:()=>Pi,LiquidityMath:()=>fe,LockClPositionLayoutV2:()=>pf,LockPositionLayout:()=>df,LogLevel:()=>Qu,Logger:()=>er,MARKET_STATE_LAYOUT_V2:()=>Ss,MARKET_STATE_LAYOUT_V3:()=>Ks,MARKET_VERSION_TO_STATE_LAYOUT:()=>Vu,MAX_BASE64_SIZE:()=>ta,MAX_SQRT_PRICE_X64:()=>Et,MAX_SQRT_PRICE_X64_SUB_ONE:()=>Io,MAX_TICK:()=>bt,MEMO_PROGRAM_ID:()=>io,MEMO_PROGRAM_ID2:()=>Zt,METADATA_PROGRAM_ID:()=>on,MIN_SQRT_PRICE_X64:()=>Vt,MIN_SQRT_PRICE_X64_ADD_ONE:()=>To,MIN_TICK:()=>lt,MODEL_DATA_PUBKEY:()=>oi,Market:()=>Qo,MathUtil:()=>oe,MaxU64:()=>Fr,MaxUint128:()=>Ia,NEGATIVE_ONE:()=>mn,OBSERVATION_SEED:()=>Al,ONE:()=>Lt,OPEN_BOOK_PROGRAM:()=>Tr,OPERATION_SEED:()=>yl,ObservationInfoLayout:()=>Ga,ObservationLayout:()=>kl,OperationLayout:()=>Xa,OptionLayout:()=>Rr,Owner:()=>qt,POOL_LOCK_ID_SEED:()=>Va,POOL_REWARD_VAULT_SEED:()=>fl,POOL_SEED:()=>dl,POOL_TICK_ARRAY_BITMAP_SEED:()=>gl,POOL_VAULT_SEED:()=>pl,POSITION_SEED:()=>Ma,Percent:()=>ve,PoolFetchType:()=>ua,PoolInfoLayout:()=>Wn,PoolUtils:()=>Se,PositionInfoLayout:()=>Li,PositionRewardInfoLayout:()=>Tl,PositionUtils:()=>Si,Price:()=>tt,ProtocolPositionLayout:()=>mf,Q128:()=>ho,Q64:()=>Rt,RENT_PROGRAM_ID:()=>et,RewardInfo:()=>hl,RoundDirection:()=>za,Rounding:()=>cr,Router:()=>Nc,SERUM_PROGRAMID_TO_VERSION:()=>_u,SERUM_PROGRAM_ID_V3:()=>lo,SERUM_VERSION_TO_PROGRAMID:()=>vu,SESSION_KEY:()=>ca,SOLMint:()=>Je,SOL_INFO:()=>Yt,SOL_Mint:()=>Rd,SPL_MINT_LAYOUT:()=>bf,STORAGE_KEY:()=>xr,SYSTEM_PROGRAM_ID:()=>ro,SqrtPriceMath:()=>ne,StableLayout:()=>ii,Structure:()=>Or,SwapMath:()=>Dn,TICK_ARRAY_BITMAP_SIZE:()=>Fn,TICK_ARRAY_SEED:()=>bl,TICK_ARRAY_SIZE:()=>je,TICK_SPACINGS:()=>nf,TOKEN_WSOL:()=>$e,TickArrayBitmap:()=>dn,TickArrayBitmapExtensionLayout:()=>Wa,TickArrayBitmapExtensionUtils:()=>Ci,TickArrayLayout:()=>Ki,TickLayout:()=>Il,TickMath:()=>qn,TickQuery:()=>be,TickUtils:()=>Y,Token:()=>he,TokenAmount:()=>ge,TxBuilder:()=>fo,TxVersion:()=>gn,U64Resolution:()=>Ti,U64_IGNORE_RANGE:()=>rf,UInt:()=>Sr,USDCMint:()=>Kd,USDTMint:()=>Cd,UTIL1216:()=>Oc,Union:()=>Mr,Voter:()=>cu,VoterDepositEntry:()=>Fl,VoterLockup:()=>El,VoterRegistrar:()=>uu,VoterVotingMintConfig:()=>Vl,WSOLMint:()=>j,WideBits:()=>Ao,WrappedLayout:()=>un,ZERO:()=>ye,_100_PERCENT:()=>Xs,accountMeta:()=>A,add:()=>qd,addComputeBudget:()=>ao,addLiquidityLayout:()=>ks,array:()=>Gp,associatedLedgerAccountLayout:()=>Zr,bits:()=>Cr,blob:()=>Pe,bool:()=>Oe,calFarmRewardAmount:()=>ls,ceilDiv:()=>Cl,checkLegacyTxSize:()=>mi,checkV0TxSize:()=>di,chunkArray:()=>tr,claimLayout:()=>qi,clmmComputeInfoToApiInfo:()=>Da,closeAccountInstruction:()=>cn,collectCpFeeInstruction:()=>nu,commonSystemAccountMeta:()=>dr,computeSwap:()=>nb,confirmTransaction:()=>uo,cpmmLockPositionInstruction:()=>Ol,createAssociatedLedgerAccountInstruction:()=>Ei,createLogger:()=>de,createPoolFeeLayout:()=>Bu,createPoolV4InstructionV2:()=>Is,createPoolV4Layout:()=>Vf,createWSolAccountInstructions:()=>ln,cstr:()=>Vp,currencyEquals:()=>Od,decimalToFraction:()=>Ic,decodeBool:()=>$c,div:()=>Ed,divCeil:()=>so,dwLayout:()=>wt,encodeBool:()=>Jc,endlessRetry:()=>up,eq:()=>wc,f32:()=>Op,f32be:()=>Mp,f64:()=>Np,f64be:()=>_p,farmAddRewardLayout:()=>ts,farmLedgerLayoutV3_1:()=>Sf,farmLedgerLayoutV3_2:()=>vi,farmLedgerLayoutV5_1:()=>Kf,farmLedgerLayoutV5_2:()=>su,farmLedgerLayoutV6_1:()=>au,farmRewardInfoToConfig:()=>yu,farmRewardLayout:()=>Jr,farmRewardRestartLayout:()=>es,farmRewardTimeInfoLayout:()=>vl,farmStateV3Layout:()=>ou,farmStateV5Layout:()=>ru,farmStateV6Layout:()=>_i,fetchMultipleFarmInfoAndUpdate:()=>Cf,fetchMultipleInfo:()=>Yf,fetchMultipleMintInfos:()=>Qn,findProgramAddress:()=>ae,fixedSwapInLayout:()=>As,fixedSwapOutLayout:()=>ws,floorDiv:()=>Qa,forecastTransactionSize:()=>co,formatLayout:()=>nm,generatePubKey:()=>Ve,getATAAddress:()=>te,getAssociatedAuthority:()=>bu,getAssociatedConfigId:()=>Uo,getAssociatedLedgerAccount:()=>mt,getAssociatedLedgerPoolAccount:()=>Vi,getAssociatedOpenOrders:()=>lm,getAssociatedPoolKeys:()=>xs,getCpLockPda:()=>Oo,getCpmmPdaAmmConfigId:()=>hf,getCpmmPdaPoolId:()=>Yr,getCreatePoolKeys:()=>Ya,getDate:()=>$s,getDepositEntryIndex:()=>ms,getDxByDyBaseIn:()=>Ku,getDyByDxBaseIn:()=>Su,getEpochInfo:()=>ip,getFarmLedgerLayout:()=>ti,getFarmStateLayout:()=>Dl,getLiquidityAssociatedAuthority:()=>Bs,getLiquidityAssociatedId:()=>Un,getLiquidityFromAmounts:()=>cf,getMax:()=>Wd,getMultipleAccountsInfo:()=>Wt,getMultipleAccountsInfoWithCustomFlags:()=>Xe,getMultipleLookupTableInfo:()=>Br,getPdaAmmConfigId:()=>uf,getPdaExBitmapAccount:()=>Fe,getPdaLockClPositionIdV2:()=>xi,getPdaLockPositionId:()=>Ur,getPdaLpMint:()=>Ll,getPdaMetadataKey:()=>En,getPdaObservationAccount:()=>va,getPdaObservationId:()=>Ni,getPdaOperationAccount:()=>Bi,getPdaPersonalPositionAddress:()=>yt,getPdaPoolAuthority:()=>Jn,getPdaPoolId:()=>Na,getPdaPoolRewardVaulId:()=>_a,getPdaPoolVaultId:()=>qr,getPdaProtocolPositionAddress:()=>Xt,getPdaTickArrayAddress:()=>pe,getPdaVault:()=>ja,getRecentBlockHash:()=>Hn,getRegistrarAddress:()=>os,getSessionKey:()=>zc,getStablePrice:()=>Cu,getTime:()=>xc,getTimestamp:()=>Ud,getTokenOwnerRecordAddress:()=>cs,getTransferAmountFee:()=>sp,getTransferAmountFeeV2:()=>we,getVoterAddress:()=>as,getVoterWeightRecordAddress:()=>us,getVotingMintAuthority:()=>ss,getVotingTokenMint:()=>rs,governanceCreateTokenOwnerRecord:()=>Xl,greedy:()=>lp,gt:()=>Ac,gte:()=>Vd,i128:()=>ya,i16ToBytes:()=>sf,i32ToBytes:()=>xo,i64:()=>Zn,i8:()=>ba,initPoolLayout:()=>Ps,initTokenAccountInstruction:()=>Er,initializeMarket:()=>mm,intersection:()=>ep,isDateAfter:()=>ea,isDateBefore:()=>Js,isDecimal:()=>Bc,isMeaningfulNumber:()=>Dd,isNumber:()=>Zs,isValidFarmVersion:()=>ns,isZero:()=>Ii,jsonInfo2PoolKeys:()=>Ke,judgeFarmType:()=>Lf,leadingZeros:()=>Dr,leastSignificantBit:()=>Oa,liquidityStateV4Layout:()=>zi,liquidityStateV5Layout:()=>Yl,lt:()=>_d,lte:()=>vd,makeAMMSwapInstruction:()=>qo,makeAddLiquidityInstruction:()=>Lu,makeAddNewRewardInstruction:()=>ps,makeClaimInstruction:()=>Do,makeClaimInstructionV4:()=>ys,makeCpmmLockInstruction:()=>tu,makeCreateCpmmPoolInInstruction:()=>Za,makeCreateFarmInstruction:()=>gu,makeCreateMarketInstruction:()=>Xo,makeCreatorWithdrawFarmRewardInstruction:()=>Au,makeDepositCpmmInInstruction:()=>$a,makeDepositInstructionV3:()=>Pu,makeDepositInstructionV5:()=>ku,makeDepositInstructionV6:()=>hu,makeDepositTokenInstruction:()=>Of,makeDepositWithdrawInstruction:()=>Nf,makeInitPoolInstructionV4:()=>Hf,makePurchaseInstruction:()=>_f,makeRestartRewardInstruction:()=>ds,makeSimulatePoolInfoInstruction:()=>Ru,makeSwapCpmmBaseInInInstruction:()=>Mo,makeSwapCpmmBaseOutInInstruction:()=>eu,makeSwapFixedInInstruction:()=>om,makeSwapFixedOutInstruction:()=>rm,makeSwapInstruction:()=>Du,makeTransferInstruction:()=>ha,makeWithdrawCpmmInInstruction:()=>Ja,makeWithdrawInstructionV3:()=>Wi,makeWithdrawInstructionV4:()=>wu,makeWithdrawInstructionV5:()=>Di,makeWithdrawInstructionV6:()=>Fi,makeWithdrawTokenInstruction:()=>Mf,minExpirationTime:()=>Gt,mockCreatePoolInfo:()=>of,mockV3CreatePoolInfo:()=>Ca,modelDataInfoLayout:()=>Jl,mostSignificantBit:()=>Ra,mul:()=>Ar,notInnerObject:()=>wr,ns64:()=>Bp,ns64be:()=>Rp,nu64:()=>pa,nu64be:()=>wp,offset:()=>Lr,offsetDateTime:()=>Jd,option:()=>Fp,parseBigNumberish:()=>Z,parseNumberInfo:()=>On,parseSimulateLogToJson:()=>ia,parseSimulateValue:()=>rn,parseTokenAccountResp:()=>ka,parseTokenInfo:()=>$p,poolTypeV6:()=>hn,printSimulate:()=>Mn,publicKey:()=>O,purchaseLayout:()=>fs,realFarmStateV3Layout:()=>Ml,realFarmStateV5Layout:()=>Nl,realFarmV6Layout:()=>_l,recursivelyDecimalToFraction:()=>Hs,removeLiquidityInstruction:()=>Ts,removeLiquidityLayout:()=>hs,route1Instruction:()=>$f,route2Instruction:()=>Jf,routeInstruction:()=>dm,rustEnum:()=>Up,s16:()=>kp,s16be:()=>xp,s24:()=>hp,s24be:()=>Sp,s32:()=>Ce,s32be:()=>Kp,s40:()=>Tp,s40be:()=>Cp,s48:()=>Ip,s48be:()=>Lp,s8:()=>Pp,seq:()=>Q,setLoggerLevel:()=>Cm,shakeFractionDecimal:()=>hc,simulateMultipleInstruction:()=>na,simulatePoolInfoInstruction:()=>Qf,simulateTransaction:()=>Kc,sleep:()=>zs,solToWSol:()=>at,solToWSolToken:()=>ef,splAccountLayout:()=>Pn,splitNumber:()=>Ws,str:()=>qp,struct:()=>_,sub:()=>Fd,swapBaseInAutoAccount:()=>eb,swapBaseOutAutoAccount:()=>tb,tagged:()=>Wp,tenExponential:()=>gr,toAmmComputePoolInfo:()=>Go,toApiV3Token:()=>ct,toBN:()=>Tc,toBuffer:()=>oa,toFeeConfig:()=>kn,toFraction:()=>Ys,toFractionWithDecimals:()=>Nd,toPercent:()=>Yd,toToken:()=>ko,toTokenAmount:()=>hi,toTokenInfo:()=>Jp,toTokenPrice:()=>Zd,toTotalPrice:()=>$d,toUsdCurrency:()=>Qs,trailingZeros:()=>Wr,transformTxToBase64:()=>op,tryParsePublicKey:()=>fr,txToBase64:()=>Cc,u128:()=>J,u16:()=>an,u16ToBytes:()=>La,u16be:()=>fp,u24:()=>mp,u24be:()=>bp,u32:()=>ot,u32ToBytes:()=>af,u32be:()=>yp,u40:()=>dp,u40be:()=>gp,u48:()=>pp,u48be:()=>Ap,u64:()=>k,u8:()=>D,union:()=>Xp,unionArr:()=>ib,unionLayoutDiscriminator:()=>vp,uniq:()=>np,updateFarmPoolInfo:()=>Wl,updateReqHistory:()=>bo,utf8:()=>Ep,validateAndParsePublicKey:()=>pr,validateFarmRewards:()=>is,vec:()=>Dp,vecU8:()=>el,voterStakeRegistryCreateDepositEntry:()=>Ql,voterStakeRegistryCreateVoter:()=>zl,voterStakeRegistryDeposit:()=>ql,voterStakeRegistryUpdateVoterWeightRecord:()=>Ul,voterStakeRegistryWithdraw:()=>Gl,wSolToSolToken:()=>tf,withdrawRewardLayout:()=>$r,xor:()=>tp,zeros:()=>zp});module.exports=Km(ob);var ma=me(require("axios"));var Bn=require("@solana/spl-token"),Ms=require("@solana/web3.js");var zn=require("lodash"),Qu=(o=>(o[o.Error=0]="Error",o[o.Warning=1]="Warning",o[o.Info=2]="Info",o[o.Debug=3]="Debug",o))(Qu||{}),er=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}},Rs={},Hu={};function de(i){let e=(0,zn.get)(Rs,i);if(!e){let t=(0,zn.get)(Hu,i);e=new er({name:i,logLevel:t}),(0,zn.set)(Rs,i,e)}return e}function Cm(i,e){(0,zn.set)(Hu,i,e);let t=(0,zn.get)(Rs,i);t&&(t.level=e)}var Os=de("CobaltX_accountInfo_util");async function Wt(i,e,t){let{batchRequest:n,commitment:o="confirmed",chunkCount:r=100}={batchRequest:!1,...t},s=tr(e,r),a=new Array(s.length).fill([]);if(n){let u=s.map(m=>{let d=i._buildArgs([m.map(p=>p.toBase58())],o,"base64");return{methodName:"getMultipleAccounts",args:d}}),c=tr(u,10);a=(await(await Promise.all(c.map(async m=>await i._rpcBatchRequest(m)))).flat()).map(m=>(m.error&&Os.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${m.error.message}`),m.result.value.map(d=>{if(d){let{data:p,executable:b,lamports:f,owner:y,rentEpoch:g}=d;return p.length!==2&&p[1]!=="base64"&&Os.logWithError("info must be base64 encoded, RPC_ERROR"),{data:Buffer.from(p[0],"base64"),executable:b,lamports:f,owner:new Ms.PublicKey(y),rentEpoch:g}}return null})))}else try{a=await Promise.all(s.map(u=>i.getMultipleAccountsInfo(u,o)))}catch(u){u instanceof Error&&Os.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${u.message}`)}return a.flat()}async function Xe(i,e,t){let n=await Wt(i,e.map(o=>o.pubkey),t);return e.map((o,r)=>({...o,accountInfo:n[r]}))}var ju=(n=>(n[n.Uninitialized=0]="Uninitialized",n[n.Mint=1]="Mint",n[n.Account=2]="Account",n))(ju||{}),Lm=1;async function Qn({connection:i,mints:e,config:t}){var r,s,a;if(e.length===0)return{};let n=await Xe(i,e.map(u=>({pubkey:at(u)})),t),o={};for(let u of n){if(!u.accountInfo||u.accountInfo.data.length<Bn.MINT_SIZE){console.log("invalid mint account",u.pubkey.toBase58());continue}let c=(0,Bn.unpackMint)(u.pubkey,u.accountInfo,(r=u.accountInfo)==null?void 0:r.owner);o[u.pubkey.toString()]={...c,programId:((s=u.accountInfo)==null?void 0:s.owner)||Bn.TOKEN_PROGRAM_ID,feeConfig:(a=(0,Bn.getTransferFeeConfig)(c))!=null?a:void 0}}return o[Ms.PublicKey.default.toBase58()]=o[j.toBase58()],o}var qe=me(require("bn.js"));var ai=9e15,Cn=1e9,Ns="0123456789abcdef",ir="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",or="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",_s={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-ai,maxE:ai,crypto:!1},Ju,bn,re=!0,sr="[DecimalError] ",Kn=sr+"Invalid argument: ",ec=sr+"Precision limit exceeded",tc=sr+"crypto unavailable",nc="[object Decimal]",pt=Math.floor,Ze=Math.pow,Rm=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Om=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Mm=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,ic=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,jt=1e7,ie=7,Nm=9007199254740991,_m=ir.length-1,vs=or.length-1,E={toStringTag:nc};E.absoluteValue=E.abs=function(){var i=new this.constructor(this);return i.s<0&&(i.s=1),ee(i)};E.ceil=function(){return ee(new this.constructor(this),this.e+1,2)};E.clampedTo=E.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(Kn+e);return t=n.cmp(i),t<0?i:n.cmp(e)>0?e:new o(n)};E.comparedTo=E.cmp=function(i){var e,t,n,o,r=this,s=r.d,a=(i=new r.constructor(i)).d,u=r.s,c=i.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!==i.e)return r.e>i.e^u<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]^u<0?1:-1;return n===o?0:n>o^u<0?1:-1};E.cosine=E.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())+ie,n.rounding=1,t=vm(n,uc(n,t)),n.precision=i,n.rounding=e,ee(bn==2||bn==3?t.neg():t,i,e,!0)):new n(1):new n(NaN)};E.cubeRoot=E.cbrt=function(){var i,e,t,n,o,r,s,a,u,c,l=this,m=l.constructor;if(!l.isFinite()||l.isZero())return new m(l);for(re=!1,r=l.s*Ze(l.s*l,1/3),!r||Math.abs(r)==1/0?(t=ut(l.d),i=l.e,(r=(i-t.length+1)%3)&&(t+=r==1||r==-2?"0":"00"),r=Ze(t,1/3),i=pt((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,u=a.times(a).times(a),c=u.plus(l),n=xe(c.plus(l).times(a),c.plus(u),s+2,1),ut(a.d).slice(0,s)===(t=ut(n.d)).slice(0,s))if(t=t.slice(s-3,s+1),t=="9999"||!o&&t=="4999"){if(!o&&(ee(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")&&(ee(n,i+1,1),e=!n.times(n).times(n).eq(l));break}return re=!0,ee(n,i,m.rounding,e)};E.decimalPlaces=E.dp=function(){var i,e=this.d,t=NaN;if(e){if(i=e.length-1,t=(i-pt(this.e/ie))*ie,i=e[i],i)for(;i%10==0;i/=10)t--;t<0&&(t=0)}return t};E.dividedBy=E.div=function(i){return xe(this,new this.constructor(i))};E.dividedToIntegerBy=E.divToInt=function(i){var e=this,t=e.constructor;return ee(xe(e,new t(i),0,1,1),t.precision,t.rounding)};E.equals=E.eq=function(i){return this.cmp(i)===0};E.floor=function(){return ee(new this.constructor(this),this.e+1,3)};E.greaterThan=E.gt=function(i){return this.cmp(i)>0};E.greaterThanOrEqualTo=E.gte=function(i){var e=this.cmp(i);return e==1||e===0};E.hyperbolicCosine=E.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/ur(4,i)).toString()):(i=16,e="2.3283064365386962890625e-10"),r=ui(s,1,r.times(e),new s(1),!0);for(var u,c=i,l=new s(8);c--;)u=r.times(r),r=a.minus(u.times(l.minus(u.times(l))));return ee(r,s.precision=t,s.rounding=n,!0)};E.hyperbolicSine=E.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=ui(r,2,o,o,!0);else{i=1.4*Math.sqrt(n),i=i>16?16:i|0,o=o.times(1/ur(5,i)),o=ui(r,2,o,o,!0);for(var s,a=new r(5),u=new r(16),c=new r(20);i--;)s=o.times(o),o=o.times(a.plus(s.times(u.times(s).plus(c))))}return r.precision=e,r.rounding=t,ee(o,e,t,!0)};E.hyperbolicTangent=E.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,xe(t.sinh(),t.cosh(),n.precision=i,n.rounding=e)):new n(t.s)};E.inverseCosine=E.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()?Ht(t,o,r):new t(0):new t(NaN):e.isZero()?Ht(t,o+4,r).times(.5):(t.precision=o+6,t.rounding=1,e=e.asin(),i=Ht(t,o+4,r).times(.5),t.precision=o,t.rounding=r,i.minus(e))};E.inverseHyperbolicCosine=E.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,re=!1,t=t.times(t).minus(1).sqrt().plus(t),re=!0,n.precision=i,n.rounding=e,t.ln()):new n(t)};E.inverseHyperbolicSine=E.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,re=!1,t=t.times(t).plus(1).sqrt().plus(t),re=!0,n.precision=i,n.rounding=e,t.ln())};E.inverseHyperbolicTangent=E.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?ee(new r(o),i,e,!0):(r.precision=t=n-o.e,o=xe(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)};E.inverseSine=E.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=Ht(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)))};E.inverseTangent=E.atan=function(){var i,e,t,n,o,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<=vs)return s=Ht(l,m+4,d).times(.25),s.s=c.s,s}else{if(!c.s)return new l(NaN);if(m+4<=vs)return s=Ht(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/ie+2|0),i=t;i;--i)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(re=!1,e=Math.ceil(a/ie),n=1,u=c.times(c),s=new l(c),o=c;i!==-1;)if(o=o.times(u),r=s.minus(o.div(n+=2)),o=o.times(u),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)),re=!0,ee(s,l.precision=m,l.rounding=d,!0)};E.isFinite=function(){return!!this.d};E.isInteger=E.isInt=function(){return!!this.d&&pt(this.e/ie)>this.d.length-2};E.isNaN=function(){return!this.s};E.isNegative=E.isNeg=function(){return this.s<0};E.isPositive=E.isPos=function(){return this.s>0};E.isZero=function(){return!!this.d&&this.d[0]===0};E.lessThan=E.lt=function(i){return this.cmp(i)<0};E.lessThanOrEqualTo=E.lte=function(i){return this.cmp(i)<1};E.logarithm=E.log=function(i){var e,t,n,o,r,s,a,u,c=this,l=c.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=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(o=t[0];o%10===0;)o/=10;r=o!==1}if(re=!1,a=m+p,s=Sn(c,a),n=e?rr(l,a+10):Sn(i,a),u=xe(s,n,a,1),$i(u.d,o=m,d))do if(a+=10,s=Sn(c,a),n=e?rr(l,a+10):Sn(i,a),u=xe(s,n,a,1),!r){+ut(u.d).slice(o+1,o+15)+1==1e14&&(u=ee(u,m+1,0));break}while($i(u.d,o+=10,d));return re=!0,ee(u,m,d)};E.minus=E.sub=function(i){var e,t,n,o,r,s,a,u,c,l,m,d,p=this,b=p.constructor;if(i=new b(i),!p.d||!i.d)return!p.s||!i.s?i=new b(NaN):p.d?i.s=-i.s:i=new b(i.d||p.s!==i.s?p:NaN),i;if(p.s!=i.s)return i.s=-i.s,p.plus(i);if(c=p.d,d=i.d,a=b.precision,u=b.rounding,!c[0]||!d[0]){if(d[0])i.s=-i.s;else if(c[0])i=new b(p);else return new b(u===3?-0:0);return re?ee(i,a,u):i}if(t=pt(i.e/ie),l=pt(p.e/ie),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/ie),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,i.s=-i.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(o=n;o&&c[--o]===0;)c[o]=jt-1;--c[o],c[n]+=jt}c[n]-=d[n]}for(;c[--s]===0;)c.pop();for(;c[0]===0;c.shift())--t;return c[0]?(i.d=c,i.e=ar(c,t),re?ee(i,a,u):i):new b(u===3?-0:0)};E.modulo=E.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]?ee(new n(t),n.precision,n.rounding):(re=!1,n.modulo==9?(e=xe(t,i.abs(),0,3,1),e.s*=i.s):e=xe(t,i,0,n.modulo,1),e=e.times(i),re=!0,t.minus(e))};E.naturalExponential=E.exp=function(){return Vs(this)};E.naturalLogarithm=E.ln=function(){return Sn(this)};E.negated=E.neg=function(){var i=new this.constructor(this);return i.s=-i.s,ee(i)};E.plus=E.add=function(i){var e,t,n,o,r,s,a,u,c,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(c=m.d,l=i.d,a=d.precision,u=d.rounding,!c[0]||!l[0])return l[0]||(i=new d(m)),re?ee(i,a,u):i;if(r=pt(m.e/ie),n=pt(i.e/ie),c=c.slice(),o=r-n,o){for(o<0?(t=c,o=-o,s=l.length):(t=l,n=r,s=c.length),r=Math.ceil(a/ie),s=r>s?r+1:s+1,o>s&&(o=s,t.length=1),t.reverse();o--;)t.push(0);t.reverse()}for(s=c.length,o=l.length,s-o<0&&(o=s,t=l,l=c,c=t),e=0;o;)e=(c[--o]=c[o]+l[o]+e)/jt|0,c[o]%=jt;for(e&&(c.unshift(e),++n),s=c.length;c[--s]==0;)c.pop();return i.d=c,i.e=ar(c,n),re?ee(i,a,u):i};E.precision=E.sd=function(i){var e,t=this;if(i!==void 0&&i!==!!i&&i!==1&&i!==0)throw Error(Kn+i);return t.d?(e=oc(t.d),i&&t.e+1>e&&(e=t.e+1)):e=NaN,e};E.round=function(){var i=this,e=i.constructor;return ee(new e(i),i.e+1,e.rounding)};E.sine=E.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())+ie,n.rounding=1,t=Em(n,uc(n,t)),n.precision=i,n.rounding=e,ee(bn>2?t.neg():t,i,e,!0)):new n(NaN)};E.squareRoot=E.sqrt=function(){var i,e,t,n,o,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(re=!1,c=Math.sqrt(+s),c==0||c==1/0?(e=ut(a),(e.length+u)%2==0&&(e+="0"),c=Math.sqrt(e),u=pt((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),ut(r.d).slice(0,t)===(e=ut(n.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!o&&e=="4999"){if(!o&&(ee(r,u+1,0),r.times(r).eq(s))){n=r;break}t+=4,o=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(ee(n,u+1,1),i=!n.times(n).eq(s));break}return re=!0,ee(n,u,l.rounding,i)};E.tangent=E.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=xe(t,new n(1).minus(t.times(t)).sqrt(),i+10,0),n.precision=i,n.rounding=e,ee(bn==2||bn==4?t.neg():t,i,e,!0)):new n(NaN)};E.times=E.mul=function(i){var e,t,n,o,r,s,a,u,c,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=pt(l.e/ie)+pt(i.e/ie),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,o=u+n;o>n;)a=r[o]+p[n]*d[o-n-1]+e,r[o--]=a%jt|0,e=a/jt|0;r[o]=(r[o]+e)%jt|0}for(;!r[--s];)r.pop();return e?++t:r.shift(),i.d=r,i.e=ar(r,t),re?ee(i,m.precision,m.rounding):i};E.toBinary=function(i,e){return Fs(this,2,i,e)};E.toDecimalPlaces=E.toDP=function(i,e){var t=this,n=t.constructor;return t=new n(t),i===void 0?t:(Ct(i,0,Cn),e===void 0?e=n.rounding:Ct(e,0,8),ee(t,i+t.e+1,e))};E.toExponential=function(i,e){var t,n=this,o=n.constructor;return i===void 0?t=nn(n,!0):(Ct(i,0,Cn),e===void 0?e=o.rounding:Ct(e,0,8),n=ee(new o(n),i+1,e),t=nn(n,!0,i+1)),n.isNeg()&&!n.isZero()?"-"+t:t};E.toFixed=function(i,e){var t,n,o=this,r=o.constructor;return i===void 0?t=nn(o):(Ct(i,0,Cn),e===void 0?e=r.rounding:Ct(e,0,8),n=ee(new r(o),i+o.e+1,e),t=nn(n,!1,i+n.e+1)),o.isNeg()&&!o.isZero()?"-"+t:t};E.toFraction=function(i){var e,t,n,o,r,s,a,u,c,l,m,d,p=this,b=p.d,f=p.constructor;if(!b)return new f(p);if(c=t=new f(1),n=u=new f(0),e=new f(n),r=e.e=oc(b)-p.e-1,s=r%ie,e.d[0]=Ze(10,s<0?ie+s:s),i==null)i=r>0?e:c;else{if(a=new f(i),!a.isInt()||a.lt(c))throw Error(Kn+a);i=a.gt(e)?r>0?e:c:a}for(re=!1,a=new f(ut(b)),l=f.precision,f.precision=r=b.length*ie*2;m=xe(a,e,0,1,1),o=t.plus(m.times(n)),o.cmp(i)!=1;)t=n,n=o,o=c,c=u.plus(m.times(o)),u=o,o=e,e=a.minus(m.times(o)),a=o;return o=xe(i.minus(t),n,0,1,1),u=u.plus(o.times(c)),t=t.plus(o.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,re=!0,d};E.toHexadecimal=E.toHex=function(i,e){return Fs(this,16,i,e)};E.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:Ct(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]?(re=!1,t=xe(t,i,0,e,1).times(i),re=!0,ee(t)):(i.s=t.s,t=i),t};E.toNumber=function(){return+this};E.toOctal=function(i,e){return Fs(this,8,i,e)};E.toPower=E.pow=function(i){var e,t,n,o,r,s,a=this,u=a.constructor,c=+(i=new u(i));if(!a.d||!i.d||!a.d[0]||!i.d[0])return new u(Ze(+a,c));if(a=new u(a),a.eq(1))return a;if(n=u.precision,r=u.rounding,i.eq(1))return ee(a,n,r);if(e=pt(i.e/ie),e>=i.d.length-1&&(t=c<0?-c:c)<=Nm)return o=rc(u,a,t,n),i.s<0?new u(1).div(o):ee(o,n,r);if(s=a.s,s<0){if(e<i.d.length-1)return new u(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=Ze(+a,c),e=t==0||!isFinite(t)?pt(c*(Math.log("0."+ut(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):(re=!1,u.rounding=a.s=1,t=Math.min(12,(e+"").length),o=Vs(i.times(Sn(a,n+t)),n),o.d&&(o=ee(o,n+5,1),$i(o.d,n,r)&&(e=n+10,o=ee(Vs(i.times(Sn(a,e+t)),e),e+5,1),+ut(o.d).slice(n+1,n+15)+1==1e14&&(o=ee(o,n+1,0)))),o.s=s,re=!0,u.rounding=r,ee(o,n,r))};E.toPrecision=function(i,e){var t,n=this,o=n.constructor;return i===void 0?t=nn(n,n.e<=o.toExpNeg||n.e>=o.toExpPos):(Ct(i,1,Cn),e===void 0?e=o.rounding:Ct(e,0,8),n=ee(new o(n),i,e),t=nn(n,i<=n.e||n.e<=o.toExpNeg,i)),n.isNeg()&&!n.isZero()?"-"+t:t};E.toSignificantDigits=E.toSD=function(i,e){var t=this,n=t.constructor;return i===void 0?(i=n.precision,e=n.rounding):(Ct(i,1,Cn),e===void 0?e=n.rounding:Ct(e,0,8)),ee(new n(t),i,e)};E.toString=function(){var i=this,e=i.constructor,t=nn(i,i.e<=e.toExpNeg||i.e>=e.toExpPos);return i.isNeg()&&!i.isZero()?"-"+t:t};E.truncated=E.trunc=function(){return ee(new this.constructor(this),this.e+1,1)};E.valueOf=E.toJSON=function(){var i=this,e=i.constructor,t=nn(i,i.e<=e.toExpNeg||i.e>=e.toExpPos);return i.isNeg()?"-"+t:t};function ut(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=ie-n.length,t&&(r+=xn(t)),r+=n;s=i[e],n=s+"",t=ie-n.length,t&&(r+=xn(t))}else if(s===0)return"0";for(;s%10===0;)s/=10;return r+s}function Ct(i,e,t){if(i!==~~i||i<e||i>t)throw Error(Kn+i)}function $i(i,e,t,n){var o,r,s,a;for(r=i[0];r>=10;r/=10)--e;return--e<0?(e+=ie,o=0):(o=Math.ceil((e+1)/ie),e%=ie),r=Ze(10,ie-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)==Ze(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)==Ze(10,e-3)-1,s}function nr(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]+=Ns.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 vm(i,e){var t,n,o;if(e.isZero())return e;n=e.d.length,n<32?(t=Math.ceil(n/3),o=(1/ur(4,t)).toString()):(t=16,o="2.3283064365386962890625e-10"),i.precision+=t,e=ui(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 xe=function(){function i(n,o,r){var s,a=0,u=n.length;for(n=n.slice();u--;)s=n[u]*o+a,n[u]=s%r|0,a=s/r|0;return a&&n.unshift(a),n}function e(n,o,r,s){var a,u;if(r!=s)u=r>s?1:-1;else for(a=u=0;a<r;a++)if(n[a]!=o[a]){u=n[a]>o[a]?1:-1;break}return u}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,u){var c,l,m,d,p,b,f,y,g,w,P,h,I,T,S,B,L,x,K,V,R=n.constructor,X=n.s==o.s?1:-1,U=n.d,W=o.d;if(!U||!U[0]||!W||!W[0])return new R(!n.s||!o.s||(U?W&&U[0]==W[0]:!W)?NaN:U&&U[0]==0||!W?X*0:X/0);for(u?(p=1,l=n.e-o.e):(u=jt,p=ie,l=pt(n.e/p)-pt(o.e/p)),K=W.length,L=U.length,g=new R(X),w=g.d=[],m=0;W[m]==(U[m]||0);m++);if(W[m]>(U[m]||0)&&l--,r==null?(T=r=R.precision,s=R.rounding):a?T=r+(n.e-o.e)+1:T=r,T<0)w.push(1),b=!0;else{if(T=T/p+2|0,m=0,K==1){for(d=0,W=W[0],T++;(m<L||d)&&T--;m++)S=d*u+(U[m]||0),w[m]=S/W|0,d=S%W|0;b=d||m<L}else{for(d=u/(W[0]+1)|0,d>1&&(W=i(W,d,u),U=i(U,d,u),K=W.length,L=U.length),B=K,P=U.slice(0,K),h=P.length;h<K;)P[h++]=0;V=W.slice(),V.unshift(0),x=W[0],W[1]>=u/2&&++x;do d=0,c=e(W,P,K,h),c<0?(I=P[0],K!=h&&(I=I*u+(P[1]||0)),d=I/x|0,d>1?(d>=u&&(d=u-1),f=i(W,d,u),y=f.length,h=P.length,c=e(f,P,y,h),c==1&&(d--,t(f,K<y?V:W,y,u))):(d==0&&(c=d=1),f=W.slice()),y=f.length,y<h&&f.unshift(0),t(P,f,h,u),c==-1&&(h=P.length,c=e(W,P,K,h),c<1&&(d++,t(P,K<h?V:W,h,u))),h=P.length):c===0&&(d++,P=[0]),w[m++]=d,c&&P[0]?P[h++]=U[B]||0:(P=[U[B]],h=1);while((B++<L||P[0]!==void 0)&&T--);b=P[0]!==void 0}w[0]||w.shift()}if(p==1)g.e=l,Ju=b;else{for(m=1,d=w[0];d>=10;d/=10)m++;g.e=m+l*p-1,ee(g,a?r+g.e+1:r,s,b)}return g}}();function ee(i,e,t,n){var o,r,s,a,u,c,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+=ie,s=e,l=m[d=0],u=l/Ze(10,o-s-1)%10|0;else if(d=Math.ceil((r+1)/ie),a=m.length,d>=a)if(n){for(;a++<=d;)m.push(0);l=u=0,o=1,r%=ie,s=r-ie+1}else break e;else{for(l=a=m[d],o=1;a>=10;a/=10)o++;r%=ie,s=r-ie+o,u=s<0?0:l/Ze(10,o-s-1)%10|0}if(n=n||e<0||m[d+1]!==void 0||(s<0?l:l%Ze(10,o-s-1)),c=t<4?(u||n)&&(t==0||t==(i.s<0?3:2)):u>5||u==5&&(t==4||n||t==6&&(r>0?s>0?l/Ze(10,o-s):0:m[d-1])%10&1||t==(i.s<0?8:7)),e<1||!m[0])return m.length=0,c?(e-=i.e+1,m[0]=Ze(10,(ie-e%ie)%ie),i.e=-e||0):m[0]=i.e=0,i;if(r==0?(m.length=d,a=1,d--):(m.length=d+1,a=Ze(10,ie-r),m[d]=s>0?(l/Ze(10,o-s)%Ze(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&&(i.e++,m[0]==jt&&(m[0]=1));break}else{if(m[d]+=a,m[d]!=jt)break;m[d--]=0,a=1}for(r=m.length;m[--r]===0;)m.pop()}return re&&(i.e>p.maxE?(i.d=null,i.e=NaN):i.e<p.minE&&(i.e=0,i.d=[0])),i}function nn(i,e,t){if(!i.isFinite())return ac(i);var n,o=i.e,r=ut(i.d),s=r.length;return e?(t&&(n=t-s)>0?r=r.charAt(0)+"."+r.slice(1)+xn(n):s>1&&(r=r.charAt(0)+"."+r.slice(1)),r=r+(i.e<0?"e":"e+")+i.e):o<0?(r="0."+xn(-o-1)+r,t&&(n=t-s)>0&&(r+=xn(n))):o>=s?(r+=xn(o+1-s),t&&(n=t-o-1)>0&&(r=r+"."+xn(n))):((n=o+1)<s&&(r=r.slice(0,n)+"."+r.slice(n)),t&&(n=t-s)>0&&(o+1===s&&(r+="."),r+=xn(n))),r}function ar(i,e){var t=i[0];for(e*=ie;t>=10;t/=10)e++;return e}function rr(i,e,t){if(e>_m)throw re=!0,t&&(i.precision=t),Error(ec);return ee(new i(ir),e,1,!0)}function Ht(i,e,t){if(e>vs)throw Error(ec);return ee(new i(or),e,t,!0)}function oc(i){var e=i.length-1,t=e*ie+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 xn(i){for(var e="";i--;)e+="0";return e}function rc(i,e,t,n){var o,r=new i(1),s=Math.ceil(n/ie+4);for(re=!1;;){if(t%2&&(r=r.times(e),Zu(r.d,s)&&(o=!0)),t=pt(t/2),t===0){t=r.d.length-1,o&&r.d[t]===0&&++r.d[t];break}e=e.times(e),Zu(e.d,s)}return re=!0,r}function Yu(i){return i.d[i.d.length-1]&1}function sc(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 Vs(i,e){var t,n,o,r,s,a,u,c=0,l=0,m=0,d=i.constructor,p=d.rounding,b=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?(re=!1,u=b):u=e,a=new d(.03125);i.e>-2;)i=i.times(a),m+=5;for(n=Math.log(Ze(2,m))/Math.LN10*2+5|0,u+=n,t=r=s=new d(1),d.precision=u;;){if(r=ee(r.times(i),u,1),t=t.times(++l),a=s.plus(xe(r,t,u,1)),ut(a.d).slice(0,u)===ut(s.d).slice(0,u)){for(o=m;o--;)s=ee(s.times(s),u,1);if(e==null)if(c<3&&$i(s.d,u-n,p,c))d.precision=u+=10,t=r=a=new d(1),l=0,c++;else return ee(s,d.precision=b,p,re=!0);else return d.precision=b,s}s=a}}function Sn(i,e){var t,n,o,r,s,a,u,c,l,m,d,p=1,b=10,f=i,y=f.d,g=f.constructor,w=g.rounding,P=g.precision;if(f.s<0||!y||!y[0]||!f.e&&y[0]==1&&y.length==1)return new g(y&&!y[0]?-1/0:f.s!=1?NaN:y?0:f);if(e==null?(re=!1,l=P):l=e,g.precision=l+=b,t=ut(y),n=t.charAt(0),Math.abs(r=f.e)<15e14){for(;n<7&&n!=1||n==1&&t.charAt(1)>3;)f=f.times(i),t=ut(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=rr(g,l+2,P).times(r+""),f=Sn(new g(n+"."+t.slice(1)),l-b).plus(c),g.precision=P,e==null?ee(f,P,w,re=!0):f;for(m=f,u=s=f=xe(f.minus(1),f.plus(1),l,1),d=ee(f.times(f),l,1),o=3;;){if(s=ee(s.times(d),l,1),c=u.plus(xe(s,new g(o),l,1)),ut(c.d).slice(0,l)===ut(u.d).slice(0,l))if(u=u.times(2),r!==0&&(u=u.plus(rr(g,l+2,P).times(r+""))),u=xe(u,new g(p),l,1),e==null)if($i(u.d,l-b,w,a))g.precision=l+=b,c=s=f=xe(m.minus(1),m.plus(1),l,1),d=ee(f.times(f),l,1),o=a=1;else return ee(u,g.precision=P,w,re=!0);else return g.precision=P,u;u=c,o+=2}}function ac(i){return String(i.s*i.s/0)}function Es(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)%ie,t<0&&(n+=ie),n<o){for(n&&i.d.push(+e.slice(0,n)),o-=ie;n<o;)i.d.push(+e.slice(n,n+=ie));e=e.slice(n),n=ie-e.length}else n-=o;for(;n--;)e+="0";i.d.push(+e),re&&(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 Vm(i,e){var t,n,o,r,s,a,u,c,l;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),ic.test(e))return Es(i,e)}else if(e==="Infinity"||e==="NaN")return+e||(i.s=NaN),i.e=NaN,i.d=null,i;if(Om.test(e))t=16,e=e.toLowerCase();else if(Rm.test(e))t=2;else if(Mm.test(e))t=8;else throw Error(Kn+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=i.constructor,s&&(e=e.replace(".",""),a=e.length,r=a-r,o=rc(n,new n(t),r,r*2)),c=nr(e,t,jt),l=c.length-1,r=l;c[r]===0;--r)c.pop();return r<0?new n(i.s*0):(i.e=ar(c,l),i.d=c,re=!1,s&&(i=xe(i,o,a*4)),u&&(i=i.times(Math.abs(u)<54?Ze(2,u):Ji.pow(2,u))),re=!0,i)}function Em(i,e){var t,n=e.d.length;if(n<3)return e.isZero()?e:ui(i,2,e,e);t=1.4*Math.sqrt(n),t=t>16?16:t|0,e=e.times(1/ur(5,t)),e=ui(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 ui(i,e,t,n,o){var r,s,a,u,c=1,l=i.precision,m=Math.ceil(l/ie);for(re=!1,u=t.times(t),a=new i(n);;){if(s=xe(a.times(u),new i(e++*e++),l,1),a=o?n.plus(s):n.minus(s),n=xe(s.times(u),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,c++}return re=!0,s.d.length=m+1,s}function ur(i,e){for(var t=i;--e;)t*=i;return t}function uc(i,e){var t,n=e.s<0,o=Ht(i,i.precision,1),r=o.times(.5);if(e=e.abs(),e.lte(r))return bn=n?4:1,e;if(t=e.divToInt(o),t.isZero())bn=n?3:2;else{if(e=e.minus(t.times(o)),e.lte(r))return bn=Yu(t)?n?2:3:n?4:1,e;bn=Yu(t)?n?1:4:n?3:2}return e.minus(o).abs()}function Fs(i,e,t,n){var o,r,s,a,u,c,l,m,d,p=i.constructor,b=t!==void 0;if(b?(Ct(t,1,Cn),n===void 0?n=p.rounding:Ct(n,0,8)):(t=p.precision,n=p.rounding),!i.isFinite())l=ac(i);else{for(l=nn(i),s=l.indexOf("."),b?(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=nr(nn(d),10,o),d.e=d.d.length),m=nr(l,10,o),r=u=m.length;m[--u]==0;)m.pop();if(!m[0])l=b?"0p+0":"0";else{if(s<0?r--:(i=new p(i),i.d=m,i.e=r,i=xe(i,d,t,n,0,o),m=i.d,r=i.e,c=Ju),s=m[t],a=o/2,c=c||m[t+1]!==void 0,c=n<4?(s!==void 0||c)&&(n===0||n===(i.s<0?3:2)):s>a||s===a&&(n===4||c||n===6&&m[t-1]&1||n===(i.s<0?8:7)),m.length=t,c)for(;++m[--t]>o-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+=Ns.charAt(m[s]);if(b){if(u>1)if(e==16||e==8){for(s=e==16?4:3,--u;u%s;u++)l+="0";for(m=nr(l,o,e),u=m.length;!m[u-1];--u);for(s=1,l="1.";s<u;s++)l+=Ns.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 i.s<0?"-"+l:l}function Zu(i,e){if(i.length>e)return i.length=e,!0}function Fm(i){return new this(i).abs()}function Dm(i){return new this(i).acos()}function Wm(i){return new this(i).acosh()}function qm(i,e){return new this(i).plus(e)}function Um(i){return new this(i).asin()}function Gm(i){return new this(i).asinh()}function Xm(i){return new this(i).atan()}function zm(i){return new this(i).atanh()}function Qm(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=Ht(this,r,1).times(e.s>0?.25:.75),t.s=i.s):!e.d||i.isZero()?(t=e.s<0?Ht(this,n,o):new this(0),t.s=i.s):!i.d||e.isZero()?(t=Ht(this,r,1).times(.5),t.s=i.s):e.s<0?(this.precision=r,this.rounding=1,t=this.atan(xe(i,e,r,1)),e=Ht(this,r,1),this.precision=n,this.rounding=o,t=i.s<0?t.minus(e):t.plus(e)):t=this.atan(xe(i,e,r,1)),t}function Hm(i){return new this(i).cbrt()}function jm(i){return ee(i=new this(i),i.e+1,2)}function Ym(i,e,t){return new this(i).clamp(e,t)}function Zm(i){if(!i||typeof i!="object")throw Error(sr+"Object expected");var e,t,n,o=i.defaults===!0,r=["precision",1,Cn,"rounding",0,8,"toExpNeg",-ai,0,"toExpPos",0,ai,"maxE",0,ai,"minE",-ai,0,"modulo",0,9];for(e=0;e<r.length;e+=3)if(t=r[e],o&&(this[t]=_s[t]),(n=i[t])!==void 0)if(pt(n)===n&&n>=r[e+1]&&n<=r[e+2])this[t]=n;else throw Error(Kn+t+": "+n);if(t="crypto",o&&(this[t]=_s[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(tc);else this[t]=!1;else throw Error(Kn+t+": "+n);return this}function $m(i){return new this(i).cos()}function Jm(i){return new this(i).cosh()}function cc(i){var e,t,n;function o(r){var s,a,u,c=this;if(!(c instanceof o))return new o(r);if(c.constructor=o,$u(r)){c.s=r.s,re?!r.d||r.e>o.maxE?(c.e=NaN,c.d=null):r.e<o.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++;re?s>o.maxE?(c.e=NaN,c.d=null):s<o.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 Es(c,r.toString())}else if(u!=="string")throw Error(Kn+r);return(a=r.charCodeAt(0))===45?(r=r.slice(1),c.s=-1):(a===43&&(r=r.slice(1)),c.s=1),ic.test(r)?Es(c,r):Vm(c,r)}if(o.prototype=E,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=Zm,o.clone=cc,o.isDecimal=$u,o.abs=Fm,o.acos=Dm,o.acosh=Wm,o.add=qm,o.asin=Um,o.asinh=Gm,o.atan=Xm,o.atanh=zm,o.atan2=Qm,o.cbrt=Hm,o.ceil=jm,o.clamp=Ym,o.cos=$m,o.cosh=Jm,o.div=ed,o.exp=td,o.floor=nd,o.hypot=id,o.ln=od,o.log=rd,o.log10=ad,o.log2=sd,o.max=ud,o.min=cd,o.mod=ld,o.mul=md,o.pow=dd,o.random=pd,o.round=fd,o.sign=bd,o.sin=yd,o.sinh=gd,o.sqrt=Ad,o.sub=wd,o.sum=Pd,o.tan=kd,o.tanh=hd,o.trunc=Td,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 ed(i,e){return new this(i).div(e)}function td(i){return new this(i).exp()}function nd(i){return ee(i=new this(i),i.e+1,3)}function id(){var i,e,t=new this(0);for(re=!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 re=!0,new this(1/0);t=e}return re=!0,t.sqrt()}function $u(i){return i instanceof Ji||i&&i.toStringTag===nc||!1}function od(i){return new this(i).ln()}function rd(i,e){return new this(i).log(e)}function sd(i){return new this(i).log(2)}function ad(i){return new this(i).log(10)}function ud(){return sc(this,arguments,"lt")}function cd(){return sc(this,arguments,"gt")}function ld(i,e){return new this(i).mod(e)}function md(i,e){return new this(i).mul(e)}function dd(i,e){return new this(i).pow(e)}function pd(i){var e,t,n,o,r=0,s=new this(1),a=[];if(i===void 0?i=this.precision:Ct(i,1,Cn),n=Math.ceil(i/ie),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(tc);else for(;r<n;)a[r++]=Math.random()*1e7|0;for(n=a[--r],i%=ie,n&&i&&(o=Ze(10,ie-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-=ie)a.shift();for(n=1,o=a[0];o>=10;o/=10)n++;n<ie&&(t-=ie-n)}return s.e=t,s.d=a,s}function fd(i){return ee(i=new this(i),i.e+1,this.rounding)}function bd(i){return i=new this(i),i.d?i.d[0]?i.s:0*i.s:i.s||NaN}function yd(i){return new this(i).sin()}function gd(i){return new this(i).sinh()}function Ad(i){return new this(i).sqrt()}function wd(i,e){return new this(i).sub(e)}function Pd(){var i=0,e=arguments,t=new this(e[i]);for(re=!1;t.s&&++i<e.length;)t=t.plus(e[i]);return re=!0,ee(t,this.precision,this.rounding)}function kd(i){return new this(i).tan()}function hd(i){return new this(i).tanh()}function Td(i){return ee(i=new this(i),i.e+1,1)}E[Symbol.for("nodejs.util.inspect.custom")]=E.toString;E[Symbol.toStringTag]="Decimal";var Ji=E.constructor=cc(_s);ir=new Ji(ir);or=new Ji(or);var N=Ji;var fc=me(require("big.js")),yn=me(require("bn.js"));var lc=me(require("toformat")),Id=lc.default,eo=Id;var to=me(require("big.js")),dc=me(require("bn.js")),pc=me(require("decimal.js-light"));var ci=me(require("bn.js"));var cr=(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))(cr||{}),mc=9007199254740991;function Z(i){let e=de("CobaltX_parseBigNumberish");if(i instanceof ci.default)return i;if(typeof i=="string"){if(i.match(/^-?[0-9]+$/))return new ci.default(i);e.logWithError(`invalid BigNumberish string: ${i}`)}return typeof i=="number"?(i%1&&e.logWithError(`BigNumberish number underflow: ${i}`),(i>=mc||i<=-mc)&&e.logWithError(`BigNumberish number overflow: ${i}`),new ci.default(String(i))):typeof i=="bigint"?new ci.default(i.toString()):(e.error(`invalid BigNumberish value: ${i}`),new ci.default(0))}var lr=de("module/fraction"),Ds=eo(to.default),no=eo(pc.default),Bd={[0]:no.ROUND_DOWN,[1]:no.ROUND_HALF_UP,[2]:no.ROUND_UP},xd={[0]:to.default.roundDown,[1]:to.default.roundHalfUp,[2]:to.default.roundUp},se=class{constructor(e,t=new dc.default(1)){this.numerator=Z(e),this.denominator=Z(t)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new se(this.denominator,this.numerator)}add(e){let t=e instanceof se?e:new se(Z(e));return this.denominator.eq(t.denominator)?new se(this.numerator.add(t.numerator),this.denominator):new se(this.numerator.mul(t.denominator).add(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}sub(e){let t=e instanceof se?e:new se(Z(e));return this.denominator.eq(t.denominator)?new se(this.numerator.sub(t.numerator),this.denominator):new se(this.numerator.mul(t.denominator).sub(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}mul(e){let t=e instanceof se?e:new se(Z(e));return new se(this.numerator.mul(t.numerator),this.denominator.mul(t.denominator))}div(e){let t=e instanceof se?e:new se(Z(e));return new se(this.numerator.mul(t.denominator),this.denominator.mul(t.numerator))}toSignificant(e,t={groupSeparator:""},n=1){Number.isInteger(e)||lr.logWithError(`${e} is not an integer.`),e<=0&&lr.logWithError(`${e} is not positive.`),no.set({precision:e+1,rounding:Bd[n]});let o=new no(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)||lr.logWithError(`${e} is not an integer.`),e<0&&lr.logWithError(`${e} is negative.`),Ds.DP=e,Ds.RM=xd[n]||1,new Ds(this.numerator.toString()).div(this.denominator.toString()).toFormat(e,t)}isZero(){return this.numerator.isZero()}};var Sd=de("CobaltX_amount"),mr=eo(fc.default);function Ws(i,e){let t="0",n="0";if(i.includes("."