Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

xrpl-latest.js 2.4MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707
  1. var xrpl;
  2. /******/ (() => { // webpackBootstrap
  3. /******/ var __webpack_modules__ = ({
  4. /***/ "../../node_modules/asn1.js/lib/asn1.js":
  5. /*!**********************************************!*\
  6. !*** ../../node_modules/asn1.js/lib/asn1.js ***!
  7. \**********************************************/
  8. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  9. "use strict";
  10. const asn1 = exports;
  11. asn1.bignum = __webpack_require__(/*! bn.js */ "../../node_modules/diffie-hellman/node_modules/bn.js/lib/bn.js");
  12. asn1.define = (__webpack_require__(/*! ./asn1/api */ "../../node_modules/asn1.js/lib/asn1/api.js").define);
  13. asn1.base = __webpack_require__(/*! ./asn1/base */ "../../node_modules/asn1.js/lib/asn1/base/index.js");
  14. asn1.constants = __webpack_require__(/*! ./asn1/constants */ "../../node_modules/asn1.js/lib/asn1/constants/index.js");
  15. asn1.decoders = __webpack_require__(/*! ./asn1/decoders */ "../../node_modules/asn1.js/lib/asn1/decoders/index.js");
  16. asn1.encoders = __webpack_require__(/*! ./asn1/encoders */ "../../node_modules/asn1.js/lib/asn1/encoders/index.js");
  17. /***/ }),
  18. /***/ "../../node_modules/asn1.js/lib/asn1/api.js":
  19. /*!**************************************************!*\
  20. !*** ../../node_modules/asn1.js/lib/asn1/api.js ***!
  21. \**************************************************/
  22. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  23. "use strict";
  24. const encoders = __webpack_require__(/*! ./encoders */ "../../node_modules/asn1.js/lib/asn1/encoders/index.js");
  25. const decoders = __webpack_require__(/*! ./decoders */ "../../node_modules/asn1.js/lib/asn1/decoders/index.js");
  26. const inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js");
  27. const api = exports;
  28. api.define = function define(name, body) {
  29. return new Entity(name, body);
  30. };
  31. function Entity(name, body) {
  32. this.name = name;
  33. this.body = body;
  34. this.decoders = {};
  35. this.encoders = {};
  36. }
  37. Entity.prototype._createNamed = function createNamed(Base) {
  38. const name = this.name;
  39. function Generated(entity) {
  40. this._initNamed(entity, name);
  41. }
  42. inherits(Generated, Base);
  43. Generated.prototype._initNamed = function _initNamed(entity, name) {
  44. Base.call(this, entity, name);
  45. };
  46. return new Generated(this);
  47. };
  48. Entity.prototype._getDecoder = function _getDecoder(enc) {
  49. enc = enc || 'der';
  50. // Lazily create decoder
  51. if (!this.decoders.hasOwnProperty(enc))
  52. this.decoders[enc] = this._createNamed(decoders[enc]);
  53. return this.decoders[enc];
  54. };
  55. Entity.prototype.decode = function decode(data, enc, options) {
  56. return this._getDecoder(enc).decode(data, options);
  57. };
  58. Entity.prototype._getEncoder = function _getEncoder(enc) {
  59. enc = enc || 'der';
  60. // Lazily create encoder
  61. if (!this.encoders.hasOwnProperty(enc))
  62. this.encoders[enc] = this._createNamed(encoders[enc]);
  63. return this.encoders[enc];
  64. };
  65. Entity.prototype.encode = function encode(data, enc, /* internal */ reporter) {
  66. return this._getEncoder(enc).encode(data, reporter);
  67. };
  68. /***/ }),
  69. /***/ "../../node_modules/asn1.js/lib/asn1/base/buffer.js":
  70. /*!**********************************************************!*\
  71. !*** ../../node_modules/asn1.js/lib/asn1/base/buffer.js ***!
  72. \**********************************************************/
  73. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  74. "use strict";
  75. const inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js");
  76. const Reporter = (__webpack_require__(/*! ../base/reporter */ "../../node_modules/asn1.js/lib/asn1/base/reporter.js").Reporter);
  77. const Buffer = (__webpack_require__(/*! safer-buffer */ "../../node_modules/safer-buffer/safer.js").Buffer);
  78. function DecoderBuffer(base, options) {
  79. Reporter.call(this, options);
  80. if (!Buffer.isBuffer(base)) {
  81. this.error('Input not Buffer');
  82. return;
  83. }
  84. this.base = base;
  85. this.offset = 0;
  86. this.length = base.length;
  87. }
  88. inherits(DecoderBuffer, Reporter);
  89. exports.DecoderBuffer = DecoderBuffer;
  90. DecoderBuffer.isDecoderBuffer = function isDecoderBuffer(data) {
  91. if (data instanceof DecoderBuffer) {
  92. return true;
  93. }
  94. // Or accept compatible API
  95. const isCompatible = typeof data === 'object' &&
  96. Buffer.isBuffer(data.base) &&
  97. data.constructor.name === 'DecoderBuffer' &&
  98. typeof data.offset === 'number' &&
  99. typeof data.length === 'number' &&
  100. typeof data.save === 'function' &&
  101. typeof data.restore === 'function' &&
  102. typeof data.isEmpty === 'function' &&
  103. typeof data.readUInt8 === 'function' &&
  104. typeof data.skip === 'function' &&
  105. typeof data.raw === 'function';
  106. return isCompatible;
  107. };
  108. DecoderBuffer.prototype.save = function save() {
  109. return { offset: this.offset, reporter: Reporter.prototype.save.call(this) };
  110. };
  111. DecoderBuffer.prototype.restore = function restore(save) {
  112. // Return skipped data
  113. const res = new DecoderBuffer(this.base);
  114. res.offset = save.offset;
  115. res.length = this.offset;
  116. this.offset = save.offset;
  117. Reporter.prototype.restore.call(this, save.reporter);
  118. return res;
  119. };
  120. DecoderBuffer.prototype.isEmpty = function isEmpty() {
  121. return this.offset === this.length;
  122. };
  123. DecoderBuffer.prototype.readUInt8 = function readUInt8(fail) {
  124. if (this.offset + 1 <= this.length)
  125. return this.base.readUInt8(this.offset++, true);
  126. else
  127. return this.error(fail || 'DecoderBuffer overrun');
  128. };
  129. DecoderBuffer.prototype.skip = function skip(bytes, fail) {
  130. if (!(this.offset + bytes <= this.length))
  131. return this.error(fail || 'DecoderBuffer overrun');
  132. const res = new DecoderBuffer(this.base);
  133. // Share reporter state
  134. res._reporterState = this._reporterState;
  135. res.offset = this.offset;
  136. res.length = this.offset + bytes;
  137. this.offset += bytes;
  138. return res;
  139. };
  140. DecoderBuffer.prototype.raw = function raw(save) {
  141. return this.base.slice(save ? save.offset : this.offset, this.length);
  142. };
  143. function EncoderBuffer(value, reporter) {
  144. if (Array.isArray(value)) {
  145. this.length = 0;
  146. this.value = value.map(function(item) {
  147. if (!EncoderBuffer.isEncoderBuffer(item))
  148. item = new EncoderBuffer(item, reporter);
  149. this.length += item.length;
  150. return item;
  151. }, this);
  152. } else if (typeof value === 'number') {
  153. if (!(0 <= value && value <= 0xff))
  154. return reporter.error('non-byte EncoderBuffer value');
  155. this.value = value;
  156. this.length = 1;
  157. } else if (typeof value === 'string') {
  158. this.value = value;
  159. this.length = Buffer.byteLength(value);
  160. } else if (Buffer.isBuffer(value)) {
  161. this.value = value;
  162. this.length = value.length;
  163. } else {
  164. return reporter.error('Unsupported type: ' + typeof value);
  165. }
  166. }
  167. exports.EncoderBuffer = EncoderBuffer;
  168. EncoderBuffer.isEncoderBuffer = function isEncoderBuffer(data) {
  169. if (data instanceof EncoderBuffer) {
  170. return true;
  171. }
  172. // Or accept compatible API
  173. const isCompatible = typeof data === 'object' &&
  174. data.constructor.name === 'EncoderBuffer' &&
  175. typeof data.length === 'number' &&
  176. typeof data.join === 'function';
  177. return isCompatible;
  178. };
  179. EncoderBuffer.prototype.join = function join(out, offset) {
  180. if (!out)
  181. out = Buffer.alloc(this.length);
  182. if (!offset)
  183. offset = 0;
  184. if (this.length === 0)
  185. return out;
  186. if (Array.isArray(this.value)) {
  187. this.value.forEach(function(item) {
  188. item.join(out, offset);
  189. offset += item.length;
  190. });
  191. } else {
  192. if (typeof this.value === 'number')
  193. out[offset] = this.value;
  194. else if (typeof this.value === 'string')
  195. out.write(this.value, offset);
  196. else if (Buffer.isBuffer(this.value))
  197. this.value.copy(out, offset);
  198. offset += this.length;
  199. }
  200. return out;
  201. };
  202. /***/ }),
  203. /***/ "../../node_modules/asn1.js/lib/asn1/base/index.js":
  204. /*!*********************************************************!*\
  205. !*** ../../node_modules/asn1.js/lib/asn1/base/index.js ***!
  206. \*********************************************************/
  207. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  208. "use strict";
  209. const base = exports;
  210. base.Reporter = (__webpack_require__(/*! ./reporter */ "../../node_modules/asn1.js/lib/asn1/base/reporter.js").Reporter);
  211. base.DecoderBuffer = (__webpack_require__(/*! ./buffer */ "../../node_modules/asn1.js/lib/asn1/base/buffer.js").DecoderBuffer);
  212. base.EncoderBuffer = (__webpack_require__(/*! ./buffer */ "../../node_modules/asn1.js/lib/asn1/base/buffer.js").EncoderBuffer);
  213. base.Node = __webpack_require__(/*! ./node */ "../../node_modules/asn1.js/lib/asn1/base/node.js");
  214. /***/ }),
  215. /***/ "../../node_modules/asn1.js/lib/asn1/base/node.js":
  216. /*!********************************************************!*\
  217. !*** ../../node_modules/asn1.js/lib/asn1/base/node.js ***!
  218. \********************************************************/
  219. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  220. "use strict";
  221. const Reporter = (__webpack_require__(/*! ../base/reporter */ "../../node_modules/asn1.js/lib/asn1/base/reporter.js").Reporter);
  222. const EncoderBuffer = (__webpack_require__(/*! ../base/buffer */ "../../node_modules/asn1.js/lib/asn1/base/buffer.js").EncoderBuffer);
  223. const DecoderBuffer = (__webpack_require__(/*! ../base/buffer */ "../../node_modules/asn1.js/lib/asn1/base/buffer.js").DecoderBuffer);
  224. const assert = __webpack_require__(/*! minimalistic-assert */ "../../node_modules/minimalistic-assert/index.js");
  225. // Supported tags
  226. const tags = [
  227. 'seq', 'seqof', 'set', 'setof', 'objid', 'bool',
  228. 'gentime', 'utctime', 'null_', 'enum', 'int', 'objDesc',
  229. 'bitstr', 'bmpstr', 'charstr', 'genstr', 'graphstr', 'ia5str', 'iso646str',
  230. 'numstr', 'octstr', 'printstr', 't61str', 'unistr', 'utf8str', 'videostr'
  231. ];
  232. // Public methods list
  233. const methods = [
  234. 'key', 'obj', 'use', 'optional', 'explicit', 'implicit', 'def', 'choice',
  235. 'any', 'contains'
  236. ].concat(tags);
  237. // Overrided methods list
  238. const overrided = [
  239. '_peekTag', '_decodeTag', '_use',
  240. '_decodeStr', '_decodeObjid', '_decodeTime',
  241. '_decodeNull', '_decodeInt', '_decodeBool', '_decodeList',
  242. '_encodeComposite', '_encodeStr', '_encodeObjid', '_encodeTime',
  243. '_encodeNull', '_encodeInt', '_encodeBool'
  244. ];
  245. function Node(enc, parent, name) {
  246. const state = {};
  247. this._baseState = state;
  248. state.name = name;
  249. state.enc = enc;
  250. state.parent = parent || null;
  251. state.children = null;
  252. // State
  253. state.tag = null;
  254. state.args = null;
  255. state.reverseArgs = null;
  256. state.choice = null;
  257. state.optional = false;
  258. state.any = false;
  259. state.obj = false;
  260. state.use = null;
  261. state.useDecoder = null;
  262. state.key = null;
  263. state['default'] = null;
  264. state.explicit = null;
  265. state.implicit = null;
  266. state.contains = null;
  267. // Should create new instance on each method
  268. if (!state.parent) {
  269. state.children = [];
  270. this._wrap();
  271. }
  272. }
  273. module.exports = Node;
  274. const stateProps = [
  275. 'enc', 'parent', 'children', 'tag', 'args', 'reverseArgs', 'choice',
  276. 'optional', 'any', 'obj', 'use', 'alteredUse', 'key', 'default', 'explicit',
  277. 'implicit', 'contains'
  278. ];
  279. Node.prototype.clone = function clone() {
  280. const state = this._baseState;
  281. const cstate = {};
  282. stateProps.forEach(function(prop) {
  283. cstate[prop] = state[prop];
  284. });
  285. const res = new this.constructor(cstate.parent);
  286. res._baseState = cstate;
  287. return res;
  288. };
  289. Node.prototype._wrap = function wrap() {
  290. const state = this._baseState;
  291. methods.forEach(function(method) {
  292. this[method] = function _wrappedMethod() {
  293. const clone = new this.constructor(this);
  294. state.children.push(clone);
  295. return clone[method].apply(clone, arguments);
  296. };
  297. }, this);
  298. };
  299. Node.prototype._init = function init(body) {
  300. const state = this._baseState;
  301. assert(state.parent === null);
  302. body.call(this);
  303. // Filter children
  304. state.children = state.children.filter(function(child) {
  305. return child._baseState.parent === this;
  306. }, this);
  307. assert.equal(state.children.length, 1, 'Root node can have only one child');
  308. };
  309. Node.prototype._useArgs = function useArgs(args) {
  310. const state = this._baseState;
  311. // Filter children and args
  312. const children = args.filter(function(arg) {
  313. return arg instanceof this.constructor;
  314. }, this);
  315. args = args.filter(function(arg) {
  316. return !(arg instanceof this.constructor);
  317. }, this);
  318. if (children.length !== 0) {
  319. assert(state.children === null);
  320. state.children = children;
  321. // Replace parent to maintain backward link
  322. children.forEach(function(child) {
  323. child._baseState.parent = this;
  324. }, this);
  325. }
  326. if (args.length !== 0) {
  327. assert(state.args === null);
  328. state.args = args;
  329. state.reverseArgs = args.map(function(arg) {
  330. if (typeof arg !== 'object' || arg.constructor !== Object)
  331. return arg;
  332. const res = {};
  333. Object.keys(arg).forEach(function(key) {
  334. if (key == (key | 0))
  335. key |= 0;
  336. const value = arg[key];
  337. res[value] = key;
  338. });
  339. return res;
  340. });
  341. }
  342. };
  343. //
  344. // Overrided methods
  345. //
  346. overrided.forEach(function(method) {
  347. Node.prototype[method] = function _overrided() {
  348. const state = this._baseState;
  349. throw new Error(method + ' not implemented for encoding: ' + state.enc);
  350. };
  351. });
  352. //
  353. // Public methods
  354. //
  355. tags.forEach(function(tag) {
  356. Node.prototype[tag] = function _tagMethod() {
  357. const state = this._baseState;
  358. const args = Array.prototype.slice.call(arguments);
  359. assert(state.tag === null);
  360. state.tag = tag;
  361. this._useArgs(args);
  362. return this;
  363. };
  364. });
  365. Node.prototype.use = function use(item) {
  366. assert(item);
  367. const state = this._baseState;
  368. assert(state.use === null);
  369. state.use = item;
  370. return this;
  371. };
  372. Node.prototype.optional = function optional() {
  373. const state = this._baseState;
  374. state.optional = true;
  375. return this;
  376. };
  377. Node.prototype.def = function def(val) {
  378. const state = this._baseState;
  379. assert(state['default'] === null);
  380. state['default'] = val;
  381. state.optional = true;
  382. return this;
  383. };
  384. Node.prototype.explicit = function explicit(num) {
  385. const state = this._baseState;
  386. assert(state.explicit === null && state.implicit === null);
  387. state.explicit = num;
  388. return this;
  389. };
  390. Node.prototype.implicit = function implicit(num) {
  391. const state = this._baseState;
  392. assert(state.explicit === null && state.implicit === null);
  393. state.implicit = num;
  394. return this;
  395. };
  396. Node.prototype.obj = function obj() {
  397. const state = this._baseState;
  398. const args = Array.prototype.slice.call(arguments);
  399. state.obj = true;
  400. if (args.length !== 0)
  401. this._useArgs(args);
  402. return this;
  403. };
  404. Node.prototype.key = function key(newKey) {
  405. const state = this._baseState;
  406. assert(state.key === null);
  407. state.key = newKey;
  408. return this;
  409. };
  410. Node.prototype.any = function any() {
  411. const state = this._baseState;
  412. state.any = true;
  413. return this;
  414. };
  415. Node.prototype.choice = function choice(obj) {
  416. const state = this._baseState;
  417. assert(state.choice === null);
  418. state.choice = obj;
  419. this._useArgs(Object.keys(obj).map(function(key) {
  420. return obj[key];
  421. }));
  422. return this;
  423. };
  424. Node.prototype.contains = function contains(item) {
  425. const state = this._baseState;
  426. assert(state.use === null);
  427. state.contains = item;
  428. return this;
  429. };
  430. //
  431. // Decoding
  432. //
  433. Node.prototype._decode = function decode(input, options) {
  434. const state = this._baseState;
  435. // Decode root node
  436. if (state.parent === null)
  437. return input.wrapResult(state.children[0]._decode(input, options));
  438. let result = state['default'];
  439. let present = true;
  440. let prevKey = null;
  441. if (state.key !== null)
  442. prevKey = input.enterKey(state.key);
  443. // Check if tag is there
  444. if (state.optional) {
  445. let tag = null;
  446. if (state.explicit !== null)
  447. tag = state.explicit;
  448. else if (state.implicit !== null)
  449. tag = state.implicit;
  450. else if (state.tag !== null)
  451. tag = state.tag;
  452. if (tag === null && !state.any) {
  453. // Trial and Error
  454. const save = input.save();
  455. try {
  456. if (state.choice === null)
  457. this._decodeGeneric(state.tag, input, options);
  458. else
  459. this._decodeChoice(input, options);
  460. present = true;
  461. } catch (e) {
  462. present = false;
  463. }
  464. input.restore(save);
  465. } else {
  466. present = this._peekTag(input, tag, state.any);
  467. if (input.isError(present))
  468. return present;
  469. }
  470. }
  471. // Push object on stack
  472. let prevObj;
  473. if (state.obj && present)
  474. prevObj = input.enterObject();
  475. if (present) {
  476. // Unwrap explicit values
  477. if (state.explicit !== null) {
  478. const explicit = this._decodeTag(input, state.explicit);
  479. if (input.isError(explicit))
  480. return explicit;
  481. input = explicit;
  482. }
  483. const start = input.offset;
  484. // Unwrap implicit and normal values
  485. if (state.use === null && state.choice === null) {
  486. let save;
  487. if (state.any)
  488. save = input.save();
  489. const body = this._decodeTag(
  490. input,
  491. state.implicit !== null ? state.implicit : state.tag,
  492. state.any
  493. );
  494. if (input.isError(body))
  495. return body;
  496. if (state.any)
  497. result = input.raw(save);
  498. else
  499. input = body;
  500. }
  501. if (options && options.track && state.tag !== null)
  502. options.track(input.path(), start, input.length, 'tagged');
  503. if (options && options.track && state.tag !== null)
  504. options.track(input.path(), input.offset, input.length, 'content');
  505. // Select proper method for tag
  506. if (state.any) {
  507. // no-op
  508. } else if (state.choice === null) {
  509. result = this._decodeGeneric(state.tag, input, options);
  510. } else {
  511. result = this._decodeChoice(input, options);
  512. }
  513. if (input.isError(result))
  514. return result;
  515. // Decode children
  516. if (!state.any && state.choice === null && state.children !== null) {
  517. state.children.forEach(function decodeChildren(child) {
  518. // NOTE: We are ignoring errors here, to let parser continue with other
  519. // parts of encoded data
  520. child._decode(input, options);
  521. });
  522. }
  523. // Decode contained/encoded by schema, only in bit or octet strings
  524. if (state.contains && (state.tag === 'octstr' || state.tag === 'bitstr')) {
  525. const data = new DecoderBuffer(result);
  526. result = this._getUse(state.contains, input._reporterState.obj)
  527. ._decode(data, options);
  528. }
  529. }
  530. // Pop object
  531. if (state.obj && present)
  532. result = input.leaveObject(prevObj);
  533. // Set key
  534. if (state.key !== null && (result !== null || present === true))
  535. input.leaveKey(prevKey, state.key, result);
  536. else if (prevKey !== null)
  537. input.exitKey(prevKey);
  538. return result;
  539. };
  540. Node.prototype._decodeGeneric = function decodeGeneric(tag, input, options) {
  541. const state = this._baseState;
  542. if (tag === 'seq' || tag === 'set')
  543. return null;
  544. if (tag === 'seqof' || tag === 'setof')
  545. return this._decodeList(input, tag, state.args[0], options);
  546. else if (/str$/.test(tag))
  547. return this._decodeStr(input, tag, options);
  548. else if (tag === 'objid' && state.args)
  549. return this._decodeObjid(input, state.args[0], state.args[1], options);
  550. else if (tag === 'objid')
  551. return this._decodeObjid(input, null, null, options);
  552. else if (tag === 'gentime' || tag === 'utctime')
  553. return this._decodeTime(input, tag, options);
  554. else if (tag === 'null_')
  555. return this._decodeNull(input, options);
  556. else if (tag === 'bool')
  557. return this._decodeBool(input, options);
  558. else if (tag === 'objDesc')
  559. return this._decodeStr(input, tag, options);
  560. else if (tag === 'int' || tag === 'enum')
  561. return this._decodeInt(input, state.args && state.args[0], options);
  562. if (state.use !== null) {
  563. return this._getUse(state.use, input._reporterState.obj)
  564. ._decode(input, options);
  565. } else {
  566. return input.error('unknown tag: ' + tag);
  567. }
  568. };
  569. Node.prototype._getUse = function _getUse(entity, obj) {
  570. const state = this._baseState;
  571. // Create altered use decoder if implicit is set
  572. state.useDecoder = this._use(entity, obj);
  573. assert(state.useDecoder._baseState.parent === null);
  574. state.useDecoder = state.useDecoder._baseState.children[0];
  575. if (state.implicit !== state.useDecoder._baseState.implicit) {
  576. state.useDecoder = state.useDecoder.clone();
  577. state.useDecoder._baseState.implicit = state.implicit;
  578. }
  579. return state.useDecoder;
  580. };
  581. Node.prototype._decodeChoice = function decodeChoice(input, options) {
  582. const state = this._baseState;
  583. let result = null;
  584. let match = false;
  585. Object.keys(state.choice).some(function(key) {
  586. const save = input.save();
  587. const node = state.choice[key];
  588. try {
  589. const value = node._decode(input, options);
  590. if (input.isError(value))
  591. return false;
  592. result = { type: key, value: value };
  593. match = true;
  594. } catch (e) {
  595. input.restore(save);
  596. return false;
  597. }
  598. return true;
  599. }, this);
  600. if (!match)
  601. return input.error('Choice not matched');
  602. return result;
  603. };
  604. //
  605. // Encoding
  606. //
  607. Node.prototype._createEncoderBuffer = function createEncoderBuffer(data) {
  608. return new EncoderBuffer(data, this.reporter);
  609. };
  610. Node.prototype._encode = function encode(data, reporter, parent) {
  611. const state = this._baseState;
  612. if (state['default'] !== null && state['default'] === data)
  613. return;
  614. const result = this._encodeValue(data, reporter, parent);
  615. if (result === undefined)
  616. return;
  617. if (this._skipDefault(result, reporter, parent))
  618. return;
  619. return result;
  620. };
  621. Node.prototype._encodeValue = function encode(data, reporter, parent) {
  622. const state = this._baseState;
  623. // Decode root node
  624. if (state.parent === null)
  625. return state.children[0]._encode(data, reporter || new Reporter());
  626. let result = null;
  627. // Set reporter to share it with a child class
  628. this.reporter = reporter;
  629. // Check if data is there
  630. if (state.optional && data === undefined) {
  631. if (state['default'] !== null)
  632. data = state['default'];
  633. else
  634. return;
  635. }
  636. // Encode children first
  637. let content = null;
  638. let primitive = false;
  639. if (state.any) {
  640. // Anything that was given is translated to buffer
  641. result = this._createEncoderBuffer(data);
  642. } else if (state.choice) {
  643. result = this._encodeChoice(data, reporter);
  644. } else if (state.contains) {
  645. content = this._getUse(state.contains, parent)._encode(data, reporter);
  646. primitive = true;
  647. } else if (state.children) {
  648. content = state.children.map(function(child) {
  649. if (child._baseState.tag === 'null_')
  650. return child._encode(null, reporter, data);
  651. if (child._baseState.key === null)
  652. return reporter.error('Child should have a key');
  653. const prevKey = reporter.enterKey(child._baseState.key);
  654. if (typeof data !== 'object')
  655. return reporter.error('Child expected, but input is not object');
  656. const res = child._encode(data[child._baseState.key], reporter, data);
  657. reporter.leaveKey(prevKey);
  658. return res;
  659. }, this).filter(function(child) {
  660. return child;
  661. });
  662. content = this._createEncoderBuffer(content);
  663. } else {
  664. if (state.tag === 'seqof' || state.tag === 'setof') {
  665. // TODO(indutny): this should be thrown on DSL level
  666. if (!(state.args && state.args.length === 1))
  667. return reporter.error('Too many args for : ' + state.tag);
  668. if (!Array.isArray(data))
  669. return reporter.error('seqof/setof, but data is not Array');
  670. const child = this.clone();
  671. child._baseState.implicit = null;
  672. content = this._createEncoderBuffer(data.map(function(item) {
  673. const state = this._baseState;
  674. return this._getUse(state.args[0], data)._encode(item, reporter);
  675. }, child));
  676. } else if (state.use !== null) {
  677. result = this._getUse(state.use, parent)._encode(data, reporter);
  678. } else {
  679. content = this._encodePrimitive(state.tag, data);
  680. primitive = true;
  681. }
  682. }
  683. // Encode data itself
  684. if (!state.any && state.choice === null) {
  685. const tag = state.implicit !== null ? state.implicit : state.tag;
  686. const cls = state.implicit === null ? 'universal' : 'context';
  687. if (tag === null) {
  688. if (state.use === null)
  689. reporter.error('Tag could be omitted only for .use()');
  690. } else {
  691. if (state.use === null)
  692. result = this._encodeComposite(tag, primitive, cls, content);
  693. }
  694. }
  695. // Wrap in explicit
  696. if (state.explicit !== null)
  697. result = this._encodeComposite(state.explicit, false, 'context', result);
  698. return result;
  699. };
  700. Node.prototype._encodeChoice = function encodeChoice(data, reporter) {
  701. const state = this._baseState;
  702. const node = state.choice[data.type];
  703. if (!node) {
  704. assert(
  705. false,
  706. data.type + ' not found in ' +
  707. JSON.stringify(Object.keys(state.choice)));
  708. }
  709. return node._encode(data.value, reporter);
  710. };
  711. Node.prototype._encodePrimitive = function encodePrimitive(tag, data) {
  712. const state = this._baseState;
  713. if (/str$/.test(tag))
  714. return this._encodeStr(data, tag);
  715. else if (tag === 'objid' && state.args)
  716. return this._encodeObjid(data, state.reverseArgs[0], state.args[1]);
  717. else if (tag === 'objid')
  718. return this._encodeObjid(data, null, null);
  719. else if (tag === 'gentime' || tag === 'utctime')
  720. return this._encodeTime(data, tag);
  721. else if (tag === 'null_')
  722. return this._encodeNull();
  723. else if (tag === 'int' || tag === 'enum')
  724. return this._encodeInt(data, state.args && state.reverseArgs[0]);
  725. else if (tag === 'bool')
  726. return this._encodeBool(data);
  727. else if (tag === 'objDesc')
  728. return this._encodeStr(data, tag);
  729. else
  730. throw new Error('Unsupported tag: ' + tag);
  731. };
  732. Node.prototype._isNumstr = function isNumstr(str) {
  733. return /^[0-9 ]*$/.test(str);
  734. };
  735. Node.prototype._isPrintstr = function isPrintstr(str) {
  736. return /^[A-Za-z0-9 '()+,-./:=?]*$/.test(str);
  737. };
  738. /***/ }),
  739. /***/ "../../node_modules/asn1.js/lib/asn1/base/reporter.js":
  740. /*!************************************************************!*\
  741. !*** ../../node_modules/asn1.js/lib/asn1/base/reporter.js ***!
  742. \************************************************************/
  743. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  744. "use strict";
  745. const inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js");
  746. function Reporter(options) {
  747. this._reporterState = {
  748. obj: null,
  749. path: [],
  750. options: options || {},
  751. errors: []
  752. };
  753. }
  754. exports.Reporter = Reporter;
  755. Reporter.prototype.isError = function isError(obj) {
  756. return obj instanceof ReporterError;
  757. };
  758. Reporter.prototype.save = function save() {
  759. const state = this._reporterState;
  760. return { obj: state.obj, pathLen: state.path.length };
  761. };
  762. Reporter.prototype.restore = function restore(data) {
  763. const state = this._reporterState;
  764. state.obj = data.obj;
  765. state.path = state.path.slice(0, data.pathLen);
  766. };
  767. Reporter.prototype.enterKey = function enterKey(key) {
  768. return this._reporterState.path.push(key);
  769. };
  770. Reporter.prototype.exitKey = function exitKey(index) {
  771. const state = this._reporterState;
  772. state.path = state.path.slice(0, index - 1);
  773. };
  774. Reporter.prototype.leaveKey = function leaveKey(index, key, value) {
  775. const state = this._reporterState;
  776. this.exitKey(index);
  777. if (state.obj !== null)
  778. state.obj[key] = value;
  779. };
  780. Reporter.prototype.path = function path() {
  781. return this._reporterState.path.join('/');
  782. };
  783. Reporter.prototype.enterObject = function enterObject() {
  784. const state = this._reporterState;
  785. const prev = state.obj;
  786. state.obj = {};
  787. return prev;
  788. };
  789. Reporter.prototype.leaveObject = function leaveObject(prev) {
  790. const state = this._reporterState;
  791. const now = state.obj;
  792. state.obj = prev;
  793. return now;
  794. };
  795. Reporter.prototype.error = function error(msg) {
  796. let err;
  797. const state = this._reporterState;
  798. const inherited = msg instanceof ReporterError;
  799. if (inherited) {
  800. err = msg;
  801. } else {
  802. err = new ReporterError(state.path.map(function(elem) {
  803. return '[' + JSON.stringify(elem) + ']';
  804. }).join(''), msg.message || msg, msg.stack);
  805. }
  806. if (!state.options.partial)
  807. throw err;
  808. if (!inherited)
  809. state.errors.push(err);
  810. return err;
  811. };
  812. Reporter.prototype.wrapResult = function wrapResult(result) {
  813. const state = this._reporterState;
  814. if (!state.options.partial)
  815. return result;
  816. return {
  817. result: this.isError(result) ? null : result,
  818. errors: state.errors
  819. };
  820. };
  821. function ReporterError(path, msg) {
  822. this.path = path;
  823. this.rethrow(msg);
  824. }
  825. inherits(ReporterError, Error);
  826. ReporterError.prototype.rethrow = function rethrow(msg) {
  827. this.message = msg + ' at: ' + (this.path || '(shallow)');
  828. if (Error.captureStackTrace)
  829. Error.captureStackTrace(this, ReporterError);
  830. if (!this.stack) {
  831. try {
  832. // IE only adds stack when thrown
  833. throw new Error(this.message);
  834. } catch (e) {
  835. this.stack = e.stack;
  836. }
  837. }
  838. return this;
  839. };
  840. /***/ }),
  841. /***/ "../../node_modules/asn1.js/lib/asn1/constants/der.js":
  842. /*!************************************************************!*\
  843. !*** ../../node_modules/asn1.js/lib/asn1/constants/der.js ***!
  844. \************************************************************/
  845. /***/ ((__unused_webpack_module, exports) => {
  846. "use strict";
  847. // Helper
  848. function reverse(map) {
  849. const res = {};
  850. Object.keys(map).forEach(function(key) {
  851. // Convert key to integer if it is stringified
  852. if ((key | 0) == key)
  853. key = key | 0;
  854. const value = map[key];
  855. res[value] = key;
  856. });
  857. return res;
  858. }
  859. exports.tagClass = {
  860. 0: 'universal',
  861. 1: 'application',
  862. 2: 'context',
  863. 3: 'private'
  864. };
  865. exports.tagClassByName = reverse(exports.tagClass);
  866. exports.tag = {
  867. 0x00: 'end',
  868. 0x01: 'bool',
  869. 0x02: 'int',
  870. 0x03: 'bitstr',
  871. 0x04: 'octstr',
  872. 0x05: 'null_',
  873. 0x06: 'objid',
  874. 0x07: 'objDesc',
  875. 0x08: 'external',
  876. 0x09: 'real',
  877. 0x0a: 'enum',
  878. 0x0b: 'embed',
  879. 0x0c: 'utf8str',
  880. 0x0d: 'relativeOid',
  881. 0x10: 'seq',
  882. 0x11: 'set',
  883. 0x12: 'numstr',
  884. 0x13: 'printstr',
  885. 0x14: 't61str',
  886. 0x15: 'videostr',
  887. 0x16: 'ia5str',
  888. 0x17: 'utctime',
  889. 0x18: 'gentime',
  890. 0x19: 'graphstr',
  891. 0x1a: 'iso646str',
  892. 0x1b: 'genstr',
  893. 0x1c: 'unistr',
  894. 0x1d: 'charstr',
  895. 0x1e: 'bmpstr'
  896. };
  897. exports.tagByName = reverse(exports.tag);
  898. /***/ }),
  899. /***/ "../../node_modules/asn1.js/lib/asn1/constants/index.js":
  900. /*!**************************************************************!*\
  901. !*** ../../node_modules/asn1.js/lib/asn1/constants/index.js ***!
  902. \**************************************************************/
  903. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  904. "use strict";
  905. const constants = exports;
  906. // Helper
  907. constants._reverse = function reverse(map) {
  908. const res = {};
  909. Object.keys(map).forEach(function(key) {
  910. // Convert key to integer if it is stringified
  911. if ((key | 0) == key)
  912. key = key | 0;
  913. const value = map[key];
  914. res[value] = key;
  915. });
  916. return res;
  917. };
  918. constants.der = __webpack_require__(/*! ./der */ "../../node_modules/asn1.js/lib/asn1/constants/der.js");
  919. /***/ }),
  920. /***/ "../../node_modules/asn1.js/lib/asn1/decoders/der.js":
  921. /*!***********************************************************!*\
  922. !*** ../../node_modules/asn1.js/lib/asn1/decoders/der.js ***!
  923. \***********************************************************/
  924. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  925. "use strict";
  926. const inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js");
  927. const bignum = __webpack_require__(/*! bn.js */ "../../node_modules/diffie-hellman/node_modules/bn.js/lib/bn.js");
  928. const DecoderBuffer = (__webpack_require__(/*! ../base/buffer */ "../../node_modules/asn1.js/lib/asn1/base/buffer.js").DecoderBuffer);
  929. const Node = __webpack_require__(/*! ../base/node */ "../../node_modules/asn1.js/lib/asn1/base/node.js");
  930. // Import DER constants
  931. const der = __webpack_require__(/*! ../constants/der */ "../../node_modules/asn1.js/lib/asn1/constants/der.js");
  932. function DERDecoder(entity) {
  933. this.enc = 'der';
  934. this.name = entity.name;
  935. this.entity = entity;
  936. // Construct base tree
  937. this.tree = new DERNode();
  938. this.tree._init(entity.body);
  939. }
  940. module.exports = DERDecoder;
  941. DERDecoder.prototype.decode = function decode(data, options) {
  942. if (!DecoderBuffer.isDecoderBuffer(data)) {
  943. data = new DecoderBuffer(data, options);
  944. }
  945. return this.tree._decode(data, options);
  946. };
  947. // Tree methods
  948. function DERNode(parent) {
  949. Node.call(this, 'der', parent);
  950. }
  951. inherits(DERNode, Node);
  952. DERNode.prototype._peekTag = function peekTag(buffer, tag, any) {
  953. if (buffer.isEmpty())
  954. return false;
  955. const state = buffer.save();
  956. const decodedTag = derDecodeTag(buffer, 'Failed to peek tag: "' + tag + '"');
  957. if (buffer.isError(decodedTag))
  958. return decodedTag;
  959. buffer.restore(state);
  960. return decodedTag.tag === tag || decodedTag.tagStr === tag ||
  961. (decodedTag.tagStr + 'of') === tag || any;
  962. };
  963. DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) {
  964. const decodedTag = derDecodeTag(buffer,
  965. 'Failed to decode tag of "' + tag + '"');
  966. if (buffer.isError(decodedTag))
  967. return decodedTag;
  968. let len = derDecodeLen(buffer,
  969. decodedTag.primitive,
  970. 'Failed to get length of "' + tag + '"');
  971. // Failure
  972. if (buffer.isError(len))
  973. return len;
  974. if (!any &&
  975. decodedTag.tag !== tag &&
  976. decodedTag.tagStr !== tag &&
  977. decodedTag.tagStr + 'of' !== tag) {
  978. return buffer.error('Failed to match tag: "' + tag + '"');
  979. }
  980. if (decodedTag.primitive || len !== null)
  981. return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
  982. // Indefinite length... find END tag
  983. const state = buffer.save();
  984. const res = this._skipUntilEnd(
  985. buffer,
  986. 'Failed to skip indefinite length body: "' + this.tag + '"');
  987. if (buffer.isError(res))
  988. return res;
  989. len = buffer.offset - state.offset;
  990. buffer.restore(state);
  991. return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
  992. };
  993. DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer, fail) {
  994. for (;;) {
  995. const tag = derDecodeTag(buffer, fail);
  996. if (buffer.isError(tag))
  997. return tag;
  998. const len = derDecodeLen(buffer, tag.primitive, fail);
  999. if (buffer.isError(len))
  1000. return len;
  1001. let res;
  1002. if (tag.primitive || len !== null)
  1003. res = buffer.skip(len);
  1004. else
  1005. res = this._skipUntilEnd(buffer, fail);
  1006. // Failure
  1007. if (buffer.isError(res))
  1008. return res;
  1009. if (tag.tagStr === 'end')
  1010. break;
  1011. }
  1012. };
  1013. DERNode.prototype._decodeList = function decodeList(buffer, tag, decoder,
  1014. options) {
  1015. const result = [];
  1016. while (!buffer.isEmpty()) {
  1017. const possibleEnd = this._peekTag(buffer, 'end');
  1018. if (buffer.isError(possibleEnd))
  1019. return possibleEnd;
  1020. const res = decoder.decode(buffer, 'der', options);
  1021. if (buffer.isError(res) && possibleEnd)
  1022. break;
  1023. result.push(res);
  1024. }
  1025. return result;
  1026. };
  1027. DERNode.prototype._decodeStr = function decodeStr(buffer, tag) {
  1028. if (tag === 'bitstr') {
  1029. const unused = buffer.readUInt8();
  1030. if (buffer.isError(unused))
  1031. return unused;
  1032. return { unused: unused, data: buffer.raw() };
  1033. } else if (tag === 'bmpstr') {
  1034. const raw = buffer.raw();
  1035. if (raw.length % 2 === 1)
  1036. return buffer.error('Decoding of string type: bmpstr length mismatch');
  1037. let str = '';
  1038. for (let i = 0; i < raw.length / 2; i++) {
  1039. str += String.fromCharCode(raw.readUInt16BE(i * 2));
  1040. }
  1041. return str;
  1042. } else if (tag === 'numstr') {
  1043. const numstr = buffer.raw().toString('ascii');
  1044. if (!this._isNumstr(numstr)) {
  1045. return buffer.error('Decoding of string type: ' +
  1046. 'numstr unsupported characters');
  1047. }
  1048. return numstr;
  1049. } else if (tag === 'octstr') {
  1050. return buffer.raw();
  1051. } else if (tag === 'objDesc') {
  1052. return buffer.raw();
  1053. } else if (tag === 'printstr') {
  1054. const printstr = buffer.raw().toString('ascii');
  1055. if (!this._isPrintstr(printstr)) {
  1056. return buffer.error('Decoding of string type: ' +
  1057. 'printstr unsupported characters');
  1058. }
  1059. return printstr;
  1060. } else if (/str$/.test(tag)) {
  1061. return buffer.raw().toString();
  1062. } else {
  1063. return buffer.error('Decoding of string type: ' + tag + ' unsupported');
  1064. }
  1065. };
  1066. DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) {
  1067. let result;
  1068. const identifiers = [];
  1069. let ident = 0;
  1070. let subident = 0;
  1071. while (!buffer.isEmpty()) {
  1072. subident = buffer.readUInt8();
  1073. ident <<= 7;
  1074. ident |= subident & 0x7f;
  1075. if ((subident & 0x80) === 0) {
  1076. identifiers.push(ident);
  1077. ident = 0;
  1078. }
  1079. }
  1080. if (subident & 0x80)
  1081. identifiers.push(ident);
  1082. const first = (identifiers[0] / 40) | 0;
  1083. const second = identifiers[0] % 40;
  1084. if (relative)
  1085. result = identifiers;
  1086. else
  1087. result = [first, second].concat(identifiers.slice(1));
  1088. if (values) {
  1089. let tmp = values[result.join(' ')];
  1090. if (tmp === undefined)
  1091. tmp = values[result.join('.')];
  1092. if (tmp !== undefined)
  1093. result = tmp;
  1094. }
  1095. return result;
  1096. };
  1097. DERNode.prototype._decodeTime = function decodeTime(buffer, tag) {
  1098. const str = buffer.raw().toString();
  1099. let year;
  1100. let mon;
  1101. let day;
  1102. let hour;
  1103. let min;
  1104. let sec;
  1105. if (tag === 'gentime') {
  1106. year = str.slice(0, 4) | 0;
  1107. mon = str.slice(4, 6) | 0;
  1108. day = str.slice(6, 8) | 0;
  1109. hour = str.slice(8, 10) | 0;
  1110. min = str.slice(10, 12) | 0;
  1111. sec = str.slice(12, 14) | 0;
  1112. } else if (tag === 'utctime') {
  1113. year = str.slice(0, 2) | 0;
  1114. mon = str.slice(2, 4) | 0;
  1115. day = str.slice(4, 6) | 0;
  1116. hour = str.slice(6, 8) | 0;
  1117. min = str.slice(8, 10) | 0;
  1118. sec = str.slice(10, 12) | 0;
  1119. if (year < 70)
  1120. year = 2000 + year;
  1121. else
  1122. year = 1900 + year;
  1123. } else {
  1124. return buffer.error('Decoding ' + tag + ' time is not supported yet');
  1125. }
  1126. return Date.UTC(year, mon - 1, day, hour, min, sec, 0);
  1127. };
  1128. DERNode.prototype._decodeNull = function decodeNull() {
  1129. return null;
  1130. };
  1131. DERNode.prototype._decodeBool = function decodeBool(buffer) {
  1132. const res = buffer.readUInt8();
  1133. if (buffer.isError(res))
  1134. return res;
  1135. else
  1136. return res !== 0;
  1137. };
  1138. DERNode.prototype._decodeInt = function decodeInt(buffer, values) {
  1139. // Bigint, return as it is (assume big endian)
  1140. const raw = buffer.raw();
  1141. let res = new bignum(raw);
  1142. if (values)
  1143. res = values[res.toString(10)] || res;
  1144. return res;
  1145. };
  1146. DERNode.prototype._use = function use(entity, obj) {
  1147. if (typeof entity === 'function')
  1148. entity = entity(obj);
  1149. return entity._getDecoder('der').tree;
  1150. };
  1151. // Utility methods
  1152. function derDecodeTag(buf, fail) {
  1153. let tag = buf.readUInt8(fail);
  1154. if (buf.isError(tag))
  1155. return tag;
  1156. const cls = der.tagClass[tag >> 6];
  1157. const primitive = (tag & 0x20) === 0;
  1158. // Multi-octet tag - load
  1159. if ((tag & 0x1f) === 0x1f) {
  1160. let oct = tag;
  1161. tag = 0;
  1162. while ((oct & 0x80) === 0x80) {
  1163. oct = buf.readUInt8(fail);
  1164. if (buf.isError(oct))
  1165. return oct;
  1166. tag <<= 7;
  1167. tag |= oct & 0x7f;
  1168. }
  1169. } else {
  1170. tag &= 0x1f;
  1171. }
  1172. const tagStr = der.tag[tag];
  1173. return {
  1174. cls: cls,
  1175. primitive: primitive,
  1176. tag: tag,
  1177. tagStr: tagStr
  1178. };
  1179. }
  1180. function derDecodeLen(buf, primitive, fail) {
  1181. let len = buf.readUInt8(fail);
  1182. if (buf.isError(len))
  1183. return len;
  1184. // Indefinite form
  1185. if (!primitive && len === 0x80)
  1186. return null;
  1187. // Definite form
  1188. if ((len & 0x80) === 0) {
  1189. // Short form
  1190. return len;
  1191. }
  1192. // Long form
  1193. const num = len & 0x7f;
  1194. if (num > 4)
  1195. return buf.error('length octect is too long');
  1196. len = 0;
  1197. for (let i = 0; i < num; i++) {
  1198. len <<= 8;
  1199. const j = buf.readUInt8(fail);
  1200. if (buf.isError(j))
  1201. return j;
  1202. len |= j;
  1203. }
  1204. return len;
  1205. }
  1206. /***/ }),
  1207. /***/ "../../node_modules/asn1.js/lib/asn1/decoders/index.js":
  1208. /*!*************************************************************!*\
  1209. !*** ../../node_modules/asn1.js/lib/asn1/decoders/index.js ***!
  1210. \*************************************************************/
  1211. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1212. "use strict";
  1213. const decoders = exports;
  1214. decoders.der = __webpack_require__(/*! ./der */ "../../node_modules/asn1.js/lib/asn1/decoders/der.js");
  1215. decoders.pem = __webpack_require__(/*! ./pem */ "../../node_modules/asn1.js/lib/asn1/decoders/pem.js");
  1216. /***/ }),
  1217. /***/ "../../node_modules/asn1.js/lib/asn1/decoders/pem.js":
  1218. /*!***********************************************************!*\
  1219. !*** ../../node_modules/asn1.js/lib/asn1/decoders/pem.js ***!
  1220. \***********************************************************/
  1221. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1222. "use strict";
  1223. const inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js");
  1224. const Buffer = (__webpack_require__(/*! safer-buffer */ "../../node_modules/safer-buffer/safer.js").Buffer);
  1225. const DERDecoder = __webpack_require__(/*! ./der */ "../../node_modules/asn1.js/lib/asn1/decoders/der.js");
  1226. function PEMDecoder(entity) {
  1227. DERDecoder.call(this, entity);
  1228. this.enc = 'pem';
  1229. }
  1230. inherits(PEMDecoder, DERDecoder);
  1231. module.exports = PEMDecoder;
  1232. PEMDecoder.prototype.decode = function decode(data, options) {
  1233. const lines = data.toString().split(/[\r\n]+/g);
  1234. const label = options.label.toUpperCase();
  1235. const re = /^-----(BEGIN|END) ([^-]+)-----$/;
  1236. let start = -1;
  1237. let end = -1;
  1238. for (let i = 0; i < lines.length; i++) {
  1239. const match = lines[i].match(re);
  1240. if (match === null)
  1241. continue;
  1242. if (match[2] !== label)
  1243. continue;
  1244. if (start === -1) {
  1245. if (match[1] !== 'BEGIN')
  1246. break;
  1247. start = i;
  1248. } else {
  1249. if (match[1] !== 'END')
  1250. break;
  1251. end = i;
  1252. break;
  1253. }
  1254. }
  1255. if (start === -1 || end === -1)
  1256. throw new Error('PEM section not found for: ' + label);
  1257. const base64 = lines.slice(start + 1, end).join('');
  1258. // Remove excessive symbols
  1259. base64.replace(/[^a-z0-9+/=]+/gi, '');
  1260. const input = Buffer.from(base64, 'base64');
  1261. return DERDecoder.prototype.decode.call(this, input, options);
  1262. };
  1263. /***/ }),
  1264. /***/ "../../node_modules/asn1.js/lib/asn1/encoders/der.js":
  1265. /*!***********************************************************!*\
  1266. !*** ../../node_modules/asn1.js/lib/asn1/encoders/der.js ***!
  1267. \***********************************************************/
  1268. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1269. "use strict";
  1270. const inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js");
  1271. const Buffer = (__webpack_require__(/*! safer-buffer */ "../../node_modules/safer-buffer/safer.js").Buffer);
  1272. const Node = __webpack_require__(/*! ../base/node */ "../../node_modules/asn1.js/lib/asn1/base/node.js");
  1273. // Import DER constants
  1274. const der = __webpack_require__(/*! ../constants/der */ "../../node_modules/asn1.js/lib/asn1/constants/der.js");
  1275. function DEREncoder(entity) {
  1276. this.enc = 'der';
  1277. this.name = entity.name;
  1278. this.entity = entity;
  1279. // Construct base tree
  1280. this.tree = new DERNode();
  1281. this.tree._init(entity.body);
  1282. }
  1283. module.exports = DEREncoder;
  1284. DEREncoder.prototype.encode = function encode(data, reporter) {
  1285. return this.tree._encode(data, reporter).join();
  1286. };
  1287. // Tree methods
  1288. function DERNode(parent) {
  1289. Node.call(this, 'der', parent);
  1290. }
  1291. inherits(DERNode, Node);
  1292. DERNode.prototype._encodeComposite = function encodeComposite(tag,
  1293. primitive,
  1294. cls,
  1295. content) {
  1296. const encodedTag = encodeTag(tag, primitive, cls, this.reporter);
  1297. // Short form
  1298. if (content.length < 0x80) {
  1299. const header = Buffer.alloc(2);
  1300. header[0] = encodedTag;
  1301. header[1] = content.length;
  1302. return this._createEncoderBuffer([ header, content ]);
  1303. }
  1304. // Long form
  1305. // Count octets required to store length
  1306. let lenOctets = 1;
  1307. for (let i = content.length; i >= 0x100; i >>= 8)
  1308. lenOctets++;
  1309. const header = Buffer.alloc(1 + 1 + lenOctets);
  1310. header[0] = encodedTag;
  1311. header[1] = 0x80 | lenOctets;
  1312. for (let i = 1 + lenOctets, j = content.length; j > 0; i--, j >>= 8)
  1313. header[i] = j & 0xff;
  1314. return this._createEncoderBuffer([ header, content ]);
  1315. };
  1316. DERNode.prototype._encodeStr = function encodeStr(str, tag) {
  1317. if (tag === 'bitstr') {
  1318. return this._createEncoderBuffer([ str.unused | 0, str.data ]);
  1319. } else if (tag === 'bmpstr') {
  1320. const buf = Buffer.alloc(str.length * 2);
  1321. for (let i = 0; i < str.length; i++) {
  1322. buf.writeUInt16BE(str.charCodeAt(i), i * 2);
  1323. }
  1324. return this._createEncoderBuffer(buf);
  1325. } else if (tag === 'numstr') {
  1326. if (!this._isNumstr(str)) {
  1327. return this.reporter.error('Encoding of string type: numstr supports ' +
  1328. 'only digits and space');
  1329. }
  1330. return this._createEncoderBuffer(str);
  1331. } else if (tag === 'printstr') {
  1332. if (!this._isPrintstr(str)) {
  1333. return this.reporter.error('Encoding of string type: printstr supports ' +
  1334. 'only latin upper and lower case letters, ' +
  1335. 'digits, space, apostrophe, left and rigth ' +
  1336. 'parenthesis, plus sign, comma, hyphen, ' +
  1337. 'dot, slash, colon, equal sign, ' +
  1338. 'question mark');
  1339. }
  1340. return this._createEncoderBuffer(str);
  1341. } else if (/str$/.test(tag)) {
  1342. return this._createEncoderBuffer(str);
  1343. } else if (tag === 'objDesc') {
  1344. return this._createEncoderBuffer(str);
  1345. } else {
  1346. return this.reporter.error('Encoding of string type: ' + tag +
  1347. ' unsupported');
  1348. }
  1349. };
  1350. DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) {
  1351. if (typeof id === 'string') {
  1352. if (!values)
  1353. return this.reporter.error('string objid given, but no values map found');
  1354. if (!values.hasOwnProperty(id))
  1355. return this.reporter.error('objid not found in values map');
  1356. id = values[id].split(/[\s.]+/g);
  1357. for (let i = 0; i < id.length; i++)
  1358. id[i] |= 0;
  1359. } else if (Array.isArray(id)) {
  1360. id = id.slice();
  1361. for (let i = 0; i < id.length; i++)
  1362. id[i] |= 0;
  1363. }
  1364. if (!Array.isArray(id)) {
  1365. return this.reporter.error('objid() should be either array or string, ' +
  1366. 'got: ' + JSON.stringify(id));
  1367. }
  1368. if (!relative) {
  1369. if (id[1] >= 40)
  1370. return this.reporter.error('Second objid identifier OOB');
  1371. id.splice(0, 2, id[0] * 40 + id[1]);
  1372. }
  1373. // Count number of octets
  1374. let size = 0;
  1375. for (let i = 0; i < id.length; i++) {
  1376. let ident = id[i];
  1377. for (size++; ident >= 0x80; ident >>= 7)
  1378. size++;
  1379. }
  1380. const objid = Buffer.alloc(size);
  1381. let offset = objid.length - 1;
  1382. for (let i = id.length - 1; i >= 0; i--) {
  1383. let ident = id[i];
  1384. objid[offset--] = ident & 0x7f;
  1385. while ((ident >>= 7) > 0)
  1386. objid[offset--] = 0x80 | (ident & 0x7f);
  1387. }
  1388. return this._createEncoderBuffer(objid);
  1389. };
  1390. function two(num) {
  1391. if (num < 10)
  1392. return '0' + num;
  1393. else
  1394. return num;
  1395. }
  1396. DERNode.prototype._encodeTime = function encodeTime(time, tag) {
  1397. let str;
  1398. const date = new Date(time);
  1399. if (tag === 'gentime') {
  1400. str = [
  1401. two(date.getUTCFullYear()),
  1402. two(date.getUTCMonth() + 1),
  1403. two(date.getUTCDate()),
  1404. two(date.getUTCHours()),
  1405. two(date.getUTCMinutes()),
  1406. two(date.getUTCSeconds()),
  1407. 'Z'
  1408. ].join('');
  1409. } else if (tag === 'utctime') {
  1410. str = [
  1411. two(date.getUTCFullYear() % 100),
  1412. two(date.getUTCMonth() + 1),
  1413. two(date.getUTCDate()),
  1414. two(date.getUTCHours()),
  1415. two(date.getUTCMinutes()),
  1416. two(date.getUTCSeconds()),
  1417. 'Z'
  1418. ].join('');
  1419. } else {
  1420. this.reporter.error('Encoding ' + tag + ' time is not supported yet');
  1421. }
  1422. return this._encodeStr(str, 'octstr');
  1423. };
  1424. DERNode.prototype._encodeNull = function encodeNull() {
  1425. return this._createEncoderBuffer('');
  1426. };
  1427. DERNode.prototype._encodeInt = function encodeInt(num, values) {
  1428. if (typeof num === 'string') {
  1429. if (!values)
  1430. return this.reporter.error('String int or enum given, but no values map');
  1431. if (!values.hasOwnProperty(num)) {
  1432. return this.reporter.error('Values map doesn\'t contain: ' +
  1433. JSON.stringify(num));
  1434. }
  1435. num = values[num];
  1436. }
  1437. // Bignum, assume big endian
  1438. if (typeof num !== 'number' && !Buffer.isBuffer(num)) {
  1439. const numArray = num.toArray();
  1440. if (!num.sign && numArray[0] & 0x80) {
  1441. numArray.unshift(0);
  1442. }
  1443. num = Buffer.from(numArray);
  1444. }
  1445. if (Buffer.isBuffer(num)) {
  1446. let size = num.length;
  1447. if (num.length === 0)
  1448. size++;
  1449. const out = Buffer.alloc(size);
  1450. num.copy(out);
  1451. if (num.length === 0)
  1452. out[0] = 0;
  1453. return this._createEncoderBuffer(out);
  1454. }
  1455. if (num < 0x80)
  1456. return this._createEncoderBuffer(num);
  1457. if (num < 0x100)
  1458. return this._createEncoderBuffer([0, num]);
  1459. let size = 1;
  1460. for (let i = num; i >= 0x100; i >>= 8)
  1461. size++;
  1462. const out = new Array(size);
  1463. for (let i = out.length - 1; i >= 0; i--) {
  1464. out[i] = num & 0xff;
  1465. num >>= 8;
  1466. }
  1467. if(out[0] & 0x80) {
  1468. out.unshift(0);
  1469. }
  1470. return this._createEncoderBuffer(Buffer.from(out));
  1471. };
  1472. DERNode.prototype._encodeBool = function encodeBool(value) {
  1473. return this._createEncoderBuffer(value ? 0xff : 0);
  1474. };
  1475. DERNode.prototype._use = function use(entity, obj) {
  1476. if (typeof entity === 'function')
  1477. entity = entity(obj);
  1478. return entity._getEncoder('der').tree;
  1479. };
  1480. DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, parent) {
  1481. const state = this._baseState;
  1482. let i;
  1483. if (state['default'] === null)
  1484. return false;
  1485. const data = dataBuffer.join();
  1486. if (state.defaultBuffer === undefined)
  1487. state.defaultBuffer = this._encodeValue(state['default'], reporter, parent).join();
  1488. if (data.length !== state.defaultBuffer.length)
  1489. return false;
  1490. for (i=0; i < data.length; i++)
  1491. if (data[i] !== state.defaultBuffer[i])
  1492. return false;
  1493. return true;
  1494. };
  1495. // Utility methods
  1496. function encodeTag(tag, primitive, cls, reporter) {
  1497. let res;
  1498. if (tag === 'seqof')
  1499. tag = 'seq';
  1500. else if (tag === 'setof')
  1501. tag = 'set';
  1502. if (der.tagByName.hasOwnProperty(tag))
  1503. res = der.tagByName[tag];
  1504. else if (typeof tag === 'number' && (tag | 0) === tag)
  1505. res = tag;
  1506. else
  1507. return reporter.error('Unknown tag: ' + tag);
  1508. if (res >= 0x1f)
  1509. return reporter.error('Multi-octet tag encoding unsupported');
  1510. if (!primitive)
  1511. res |= 0x20;
  1512. res |= (der.tagClassByName[cls || 'universal'] << 6);
  1513. return res;
  1514. }
  1515. /***/ }),
  1516. /***/ "../../node_modules/asn1.js/lib/asn1/encoders/index.js":
  1517. /*!*************************************************************!*\
  1518. !*** ../../node_modules/asn1.js/lib/asn1/encoders/index.js ***!
  1519. \*************************************************************/
  1520. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1521. "use strict";
  1522. const encoders = exports;
  1523. encoders.der = __webpack_require__(/*! ./der */ "../../node_modules/asn1.js/lib/asn1/encoders/der.js");
  1524. encoders.pem = __webpack_require__(/*! ./pem */ "../../node_modules/asn1.js/lib/asn1/encoders/pem.js");
  1525. /***/ }),
  1526. /***/ "../../node_modules/asn1.js/lib/asn1/encoders/pem.js":
  1527. /*!***********************************************************!*\
  1528. !*** ../../node_modules/asn1.js/lib/asn1/encoders/pem.js ***!
  1529. \***********************************************************/
  1530. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1531. "use strict";
  1532. const inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js");
  1533. const DEREncoder = __webpack_require__(/*! ./der */ "../../node_modules/asn1.js/lib/asn1/encoders/der.js");
  1534. function PEMEncoder(entity) {
  1535. DEREncoder.call(this, entity);
  1536. this.enc = 'pem';
  1537. }
  1538. inherits(PEMEncoder, DEREncoder);
  1539. module.exports = PEMEncoder;
  1540. PEMEncoder.prototype.encode = function encode(data, options) {
  1541. const buf = DEREncoder.prototype.encode.call(this, data);
  1542. const p = buf.toString('base64');
  1543. const out = [ '-----BEGIN ' + options.label + '-----' ];
  1544. for (let i = 0; i < p.length; i += 64)
  1545. out.push(p.slice(i, i + 64));
  1546. out.push('-----END ' + options.label + '-----');
  1547. return out.join('\n');
  1548. };
  1549. /***/ }),
  1550. /***/ "../../node_modules/assert/build/assert.js":
  1551. /*!*************************************************!*\
  1552. !*** ../../node_modules/assert/build/assert.js ***!
  1553. \*************************************************/
  1554. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1555. "use strict";
  1556. /* provided dependency */ var process = __webpack_require__(/*! process/browser */ "../../node_modules/process/browser.js");
  1557. // Currently in sync with Node.js lib/assert.js
  1558. // https://github.com/nodejs/node/commit/2a51ae424a513ec9a6aa3466baa0cc1d55dd4f3b
  1559. // Originally from narwhal.js (http://narwhaljs.org)
  1560. // Copyright (c) 2009 Thomas Robinson <280north.com>
  1561. //
  1562. // Permission is hereby granted, free of charge, to any person obtaining a copy
  1563. // of this software and associated documentation files (the 'Software'), to
  1564. // deal in the Software without restriction, including without limitation the
  1565. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  1566. // sell copies of the Software, and to permit persons to whom the Software is
  1567. // furnished to do so, subject to the following conditions:
  1568. //
  1569. // The above copyright notice and this permission notice shall be included in
  1570. // all copies or substantial portions of the Software.
  1571. //
  1572. // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1573. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1574. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1575. // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  1576. // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  1577. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  1578. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  1579. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1580. var _require = __webpack_require__(/*! ./internal/errors */ "../../node_modules/assert/build/internal/errors.js"),
  1581. _require$codes = _require.codes,
  1582. ERR_AMBIGUOUS_ARGUMENT = _require$codes.ERR_AMBIGUOUS_ARGUMENT,
  1583. ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
  1584. ERR_INVALID_ARG_VALUE = _require$codes.ERR_INVALID_ARG_VALUE,
  1585. ERR_INVALID_RETURN_VALUE = _require$codes.ERR_INVALID_RETURN_VALUE,
  1586. ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS;
  1587. var AssertionError = __webpack_require__(/*! ./internal/assert/assertion_error */ "../../node_modules/assert/build/internal/assert/assertion_error.js");
  1588. var _require2 = __webpack_require__(/*! util/ */ "../../node_modules/util/util.js"),
  1589. inspect = _require2.inspect;
  1590. var _require$types = (__webpack_require__(/*! util/ */ "../../node_modules/util/util.js").types),
  1591. isPromise = _require$types.isPromise,
  1592. isRegExp = _require$types.isRegExp;
  1593. var objectAssign = Object.assign ? Object.assign : (__webpack_require__(/*! es6-object-assign */ "../../node_modules/es6-object-assign/index.js").assign);
  1594. var objectIs = Object.is ? Object.is : __webpack_require__(/*! object-is */ "../../node_modules/object-is/index.js");
  1595. var errorCache = new Map();
  1596. var isDeepEqual;
  1597. var isDeepStrictEqual;
  1598. var parseExpressionAt;
  1599. var findNodeAround;
  1600. var decoder;
  1601. function lazyLoadComparison() {
  1602. var comparison = __webpack_require__(/*! ./internal/util/comparisons */ "../../node_modules/assert/build/internal/util/comparisons.js");
  1603. isDeepEqual = comparison.isDeepEqual;
  1604. isDeepStrictEqual = comparison.isDeepStrictEqual;
  1605. } // Escape control characters but not \n and \t to keep the line breaks and
  1606. // indentation intact.
  1607. // eslint-disable-next-line no-control-regex
  1608. var escapeSequencesRegExp = /[\x00-\x08\x0b\x0c\x0e-\x1f]/g;
  1609. var meta = ["\\u0000", "\\u0001", "\\u0002", "\\u0003", "\\u0004", "\\u0005", "\\u0006", "\\u0007", '\\b', '', '', "\\u000b", '\\f', '', "\\u000e", "\\u000f", "\\u0010", "\\u0011", "\\u0012", "\\u0013", "\\u0014", "\\u0015", "\\u0016", "\\u0017", "\\u0018", "\\u0019", "\\u001a", "\\u001b", "\\u001c", "\\u001d", "\\u001e", "\\u001f"];
  1610. var escapeFn = function escapeFn(str) {
  1611. return meta[str.charCodeAt(0)];
  1612. };
  1613. var warned = false; // The assert module provides functions that throw
  1614. // AssertionError's when particular conditions are not met. The
  1615. // assert module must conform to the following interface.
  1616. var assert = module.exports = ok;
  1617. var NO_EXCEPTION_SENTINEL = {}; // All of the following functions must throw an AssertionError
  1618. // when a corresponding condition is not met, with a message that
  1619. // may be undefined if not provided. All assertion methods provide
  1620. // both the actual and expected values to the assertion error for
  1621. // display purposes.
  1622. function innerFail(obj) {
  1623. if (obj.message instanceof Error) throw obj.message;
  1624. throw new AssertionError(obj);
  1625. }
  1626. function fail(actual, expected, message, operator, stackStartFn) {
  1627. var argsLen = arguments.length;
  1628. var internalMessage;
  1629. if (argsLen === 0) {
  1630. internalMessage = 'Failed';
  1631. } else if (argsLen === 1) {
  1632. message = actual;
  1633. actual = undefined;
  1634. } else {
  1635. if (warned === false) {
  1636. warned = true;
  1637. var warn = process.emitWarning ? process.emitWarning : console.warn.bind(console);
  1638. warn('assert.fail() with more than one argument is deprecated. ' + 'Please use assert.strictEqual() instead or only pass a message.', 'DeprecationWarning', 'DEP0094');
  1639. }
  1640. if (argsLen === 2) operator = '!=';
  1641. }
  1642. if (message instanceof Error) throw message;
  1643. var errArgs = {
  1644. actual: actual,
  1645. expected: expected,
  1646. operator: operator === undefined ? 'fail' : operator,
  1647. stackStartFn: stackStartFn || fail
  1648. };
  1649. if (message !== undefined) {
  1650. errArgs.message = message;
  1651. }
  1652. var err = new AssertionError(errArgs);
  1653. if (internalMessage) {
  1654. err.message = internalMessage;
  1655. err.generatedMessage = true;
  1656. }
  1657. throw err;
  1658. }
  1659. assert.fail = fail; // The AssertionError is defined in internal/error.
  1660. assert.AssertionError = AssertionError;
  1661. function innerOk(fn, argLen, value, message) {
  1662. if (!value) {
  1663. var generatedMessage = false;
  1664. if (argLen === 0) {
  1665. generatedMessage = true;
  1666. message = 'No value argument passed to `assert.ok()`';
  1667. } else if (message instanceof Error) {
  1668. throw message;
  1669. }
  1670. var err = new AssertionError({
  1671. actual: value,
  1672. expected: true,
  1673. message: message,
  1674. operator: '==',
  1675. stackStartFn: fn
  1676. });
  1677. err.generatedMessage = generatedMessage;
  1678. throw err;
  1679. }
  1680. } // Pure assertion tests whether a value is truthy, as determined
  1681. // by !!value.
  1682. function ok() {
  1683. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  1684. args[_key] = arguments[_key];
  1685. }
  1686. innerOk.apply(void 0, [ok, args.length].concat(args));
  1687. }
  1688. assert.ok = ok; // The equality assertion tests shallow, coercive equality with ==.
  1689. /* eslint-disable no-restricted-properties */
  1690. assert.equal = function equal(actual, expected, message) {
  1691. if (arguments.length < 2) {
  1692. throw new ERR_MISSING_ARGS('actual', 'expected');
  1693. } // eslint-disable-next-line eqeqeq
  1694. if (actual != expected) {
  1695. innerFail({
  1696. actual: actual,
  1697. expected: expected,
  1698. message: message,
  1699. operator: '==',
  1700. stackStartFn: equal
  1701. });
  1702. }
  1703. }; // The non-equality assertion tests for whether two objects are not
  1704. // equal with !=.
  1705. assert.notEqual = function notEqual(actual, expected, message) {
  1706. if (arguments.length < 2) {
  1707. throw new ERR_MISSING_ARGS('actual', 'expected');
  1708. } // eslint-disable-next-line eqeqeq
  1709. if (actual == expected) {
  1710. innerFail({
  1711. actual: actual,
  1712. expected: expected,
  1713. message: message,
  1714. operator: '!=',
  1715. stackStartFn: notEqual
  1716. });
  1717. }
  1718. }; // The equivalence assertion tests a deep equality relation.
  1719. assert.deepEqual = function deepEqual(actual, expected, message) {
  1720. if (arguments.length < 2) {
  1721. throw new ERR_MISSING_ARGS('actual', 'expected');
  1722. }
  1723. if (isDeepEqual === undefined) lazyLoadComparison();
  1724. if (!isDeepEqual(actual, expected)) {
  1725. innerFail({
  1726. actual: actual,
  1727. expected: expected,
  1728. message: message,
  1729. operator: 'deepEqual',
  1730. stackStartFn: deepEqual
  1731. });
  1732. }
  1733. }; // The non-equivalence assertion tests for any deep inequality.
  1734. assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
  1735. if (arguments.length < 2) {
  1736. throw new ERR_MISSING_ARGS('actual', 'expected');
  1737. }
  1738. if (isDeepEqual === undefined) lazyLoadComparison();
  1739. if (isDeepEqual(actual, expected)) {
  1740. innerFail({
  1741. actual: actual,
  1742. expected: expected,
  1743. message: message,
  1744. operator: 'notDeepEqual',
  1745. stackStartFn: notDeepEqual
  1746. });
  1747. }
  1748. };
  1749. /* eslint-enable */
  1750. assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {
  1751. if (arguments.length < 2) {
  1752. throw new ERR_MISSING_ARGS('actual', 'expected');
  1753. }
  1754. if (isDeepEqual === undefined) lazyLoadComparison();
  1755. if (!isDeepStrictEqual(actual, expected)) {
  1756. innerFail({
  1757. actual: actual,
  1758. expected: expected,
  1759. message: message,
  1760. operator: 'deepStrictEqual',
  1761. stackStartFn: deepStrictEqual
  1762. });
  1763. }
  1764. };
  1765. assert.notDeepStrictEqual = notDeepStrictEqual;
  1766. function notDeepStrictEqual(actual, expected, message) {
  1767. if (arguments.length < 2) {
  1768. throw new ERR_MISSING_ARGS('actual', 'expected');
  1769. }
  1770. if (isDeepEqual === undefined) lazyLoadComparison();
  1771. if (isDeepStrictEqual(actual, expected)) {
  1772. innerFail({
  1773. actual: actual,
  1774. expected: expected,
  1775. message: message,
  1776. operator: 'notDeepStrictEqual',
  1777. stackStartFn: notDeepStrictEqual
  1778. });
  1779. }
  1780. }
  1781. assert.strictEqual = function strictEqual(actual, expected, message) {
  1782. if (arguments.length < 2) {
  1783. throw new ERR_MISSING_ARGS('actual', 'expected');
  1784. }
  1785. if (!objectIs(actual, expected)) {
  1786. innerFail({
  1787. actual: actual,
  1788. expected: expected,
  1789. message: message,
  1790. operator: 'strictEqual',
  1791. stackStartFn: strictEqual
  1792. });
  1793. }
  1794. };
  1795. assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
  1796. if (arguments.length < 2) {
  1797. throw new ERR_MISSING_ARGS('actual', 'expected');
  1798. }
  1799. if (objectIs(actual, expected)) {
  1800. innerFail({
  1801. actual: actual,
  1802. expected: expected,
  1803. message: message,
  1804. operator: 'notStrictEqual',
  1805. stackStartFn: notStrictEqual
  1806. });
  1807. }
  1808. };
  1809. var Comparison = function Comparison(obj, keys, actual) {
  1810. var _this = this;
  1811. _classCallCheck(this, Comparison);
  1812. keys.forEach(function (key) {
  1813. if (key in obj) {
  1814. if (actual !== undefined && typeof actual[key] === 'string' && isRegExp(obj[key]) && obj[key].test(actual[key])) {
  1815. _this[key] = actual[key];
  1816. } else {
  1817. _this[key] = obj[key];
  1818. }
  1819. }
  1820. });
  1821. };
  1822. function compareExceptionKey(actual, expected, key, message, keys, fn) {
  1823. if (!(key in actual) || !isDeepStrictEqual(actual[key], expected[key])) {
  1824. if (!message) {
  1825. // Create placeholder objects to create a nice output.
  1826. var a = new Comparison(actual, keys);
  1827. var b = new Comparison(expected, keys, actual);
  1828. var err = new AssertionError({
  1829. actual: a,
  1830. expected: b,
  1831. operator: 'deepStrictEqual',
  1832. stackStartFn: fn
  1833. });
  1834. err.actual = actual;
  1835. err.expected = expected;
  1836. err.operator = fn.name;
  1837. throw err;
  1838. }
  1839. innerFail({
  1840. actual: actual,
  1841. expected: expected,
  1842. message: message,
  1843. operator: fn.name,
  1844. stackStartFn: fn
  1845. });
  1846. }
  1847. }
  1848. function expectedException(actual, expected, msg, fn) {
  1849. if (typeof expected !== 'function') {
  1850. if (isRegExp(expected)) return expected.test(actual); // assert.doesNotThrow does not accept objects.
  1851. if (arguments.length === 2) {
  1852. throw new ERR_INVALID_ARG_TYPE('expected', ['Function', 'RegExp'], expected);
  1853. } // Handle primitives properly.
  1854. if (_typeof(actual) !== 'object' || actual === null) {
  1855. var err = new AssertionError({
  1856. actual: actual,
  1857. expected: expected,
  1858. message: msg,
  1859. operator: 'deepStrictEqual',
  1860. stackStartFn: fn
  1861. });
  1862. err.operator = fn.name;
  1863. throw err;
  1864. }
  1865. var keys = Object.keys(expected); // Special handle errors to make sure the name and the message are compared
  1866. // as well.
  1867. if (expected instanceof Error) {
  1868. keys.push('name', 'message');
  1869. } else if (keys.length === 0) {
  1870. throw new ERR_INVALID_ARG_VALUE('error', expected, 'may not be an empty object');
  1871. }
  1872. if (isDeepEqual === undefined) lazyLoadComparison();
  1873. keys.forEach(function (key) {
  1874. if (typeof actual[key] === 'string' && isRegExp(expected[key]) && expected[key].test(actual[key])) {
  1875. return;
  1876. }
  1877. compareExceptionKey(actual, expected, key, msg, keys, fn);
  1878. });
  1879. return true;
  1880. } // Guard instanceof against arrow functions as they don't have a prototype.
  1881. if (expected.prototype !== undefined && actual instanceof expected) {
  1882. return true;
  1883. }
  1884. if (Error.isPrototypeOf(expected)) {
  1885. return false;
  1886. }
  1887. return expected.call({}, actual) === true;
  1888. }
  1889. function getActual(fn) {
  1890. if (typeof fn !== 'function') {
  1891. throw new ERR_INVALID_ARG_TYPE('fn', 'Function', fn);
  1892. }
  1893. try {
  1894. fn();
  1895. } catch (e) {
  1896. return e;
  1897. }
  1898. return NO_EXCEPTION_SENTINEL;
  1899. }
  1900. function checkIsPromise(obj) {
  1901. // Accept native ES6 promises and promises that are implemented in a similar
  1902. // way. Do not accept thenables that use a function as `obj` and that have no
  1903. // `catch` handler.
  1904. // TODO: thenables are checked up until they have the correct methods,
  1905. // but according to documentation, the `then` method should receive
  1906. // the `fulfill` and `reject` arguments as well or it may be never resolved.
  1907. return isPromise(obj) || obj !== null && _typeof(obj) === 'object' && typeof obj.then === 'function' && typeof obj.catch === 'function';
  1908. }
  1909. function waitForActual(promiseFn) {
  1910. return Promise.resolve().then(function () {
  1911. var resultPromise;
  1912. if (typeof promiseFn === 'function') {
  1913. // Return a rejected promise if `promiseFn` throws synchronously.
  1914. resultPromise = promiseFn(); // Fail in case no promise is returned.
  1915. if (!checkIsPromise(resultPromise)) {
  1916. throw new ERR_INVALID_RETURN_VALUE('instance of Promise', 'promiseFn', resultPromise);
  1917. }
  1918. } else if (checkIsPromise(promiseFn)) {
  1919. resultPromise = promiseFn;
  1920. } else {
  1921. throw new ERR_INVALID_ARG_TYPE('promiseFn', ['Function', 'Promise'], promiseFn);
  1922. }
  1923. return Promise.resolve().then(function () {
  1924. return resultPromise;
  1925. }).then(function () {
  1926. return NO_EXCEPTION_SENTINEL;
  1927. }).catch(function (e) {
  1928. return e;
  1929. });
  1930. });
  1931. }
  1932. function expectsError(stackStartFn, actual, error, message) {
  1933. if (typeof error === 'string') {
  1934. if (arguments.length === 4) {
  1935. throw new ERR_INVALID_ARG_TYPE('error', ['Object', 'Error', 'Function', 'RegExp'], error);
  1936. }
  1937. if (_typeof(actual) === 'object' && actual !== null) {
  1938. if (actual.message === error) {
  1939. throw new ERR_AMBIGUOUS_ARGUMENT('error/message', "The error message \"".concat(actual.message, "\" is identical to the message."));
  1940. }
  1941. } else if (actual === error) {
  1942. throw new ERR_AMBIGUOUS_ARGUMENT('error/message', "The error \"".concat(actual, "\" is identical to the message."));
  1943. }
  1944. message = error;
  1945. error = undefined;
  1946. } else if (error != null && _typeof(error) !== 'object' && typeof error !== 'function') {
  1947. throw new ERR_INVALID_ARG_TYPE('error', ['Object', 'Error', 'Function', 'RegExp'], error);
  1948. }
  1949. if (actual === NO_EXCEPTION_SENTINEL) {
  1950. var details = '';
  1951. if (error && error.name) {
  1952. details += " (".concat(error.name, ")");
  1953. }
  1954. details += message ? ": ".concat(message) : '.';
  1955. var fnType = stackStartFn.name === 'rejects' ? 'rejection' : 'exception';
  1956. innerFail({
  1957. actual: undefined,
  1958. expected: error,
  1959. operator: stackStartFn.name,
  1960. message: "Missing expected ".concat(fnType).concat(details),
  1961. stackStartFn: stackStartFn
  1962. });
  1963. }
  1964. if (error && !expectedException(actual, error, message, stackStartFn)) {
  1965. throw actual;
  1966. }
  1967. }
  1968. function expectsNoError(stackStartFn, actual, error, message) {
  1969. if (actual === NO_EXCEPTION_SENTINEL) return;
  1970. if (typeof error === 'string') {
  1971. message = error;
  1972. error = undefined;
  1973. }
  1974. if (!error || expectedException(actual, error)) {
  1975. var details = message ? ": ".concat(message) : '.';
  1976. var fnType = stackStartFn.name === 'doesNotReject' ? 'rejection' : 'exception';
  1977. innerFail({
  1978. actual: actual,
  1979. expected: error,
  1980. operator: stackStartFn.name,
  1981. message: "Got unwanted ".concat(fnType).concat(details, "\n") + "Actual message: \"".concat(actual && actual.message, "\""),
  1982. stackStartFn: stackStartFn
  1983. });
  1984. }
  1985. throw actual;
  1986. }
  1987. assert.throws = function throws(promiseFn) {
  1988. for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  1989. args[_key2 - 1] = arguments[_key2];
  1990. }
  1991. expectsError.apply(void 0, [throws, getActual(promiseFn)].concat(args));
  1992. };
  1993. assert.rejects = function rejects(promiseFn) {
  1994. for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
  1995. args[_key3 - 1] = arguments[_key3];
  1996. }
  1997. return waitForActual(promiseFn).then(function (result) {
  1998. return expectsError.apply(void 0, [rejects, result].concat(args));
  1999. });
  2000. };
  2001. assert.doesNotThrow = function doesNotThrow(fn) {
  2002. for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
  2003. args[_key4 - 1] = arguments[_key4];
  2004. }
  2005. expectsNoError.apply(void 0, [doesNotThrow, getActual(fn)].concat(args));
  2006. };
  2007. assert.doesNotReject = function doesNotReject(fn) {
  2008. for (var _len5 = arguments.length, args = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
  2009. args[_key5 - 1] = arguments[_key5];
  2010. }
  2011. return waitForActual(fn).then(function (result) {
  2012. return expectsNoError.apply(void 0, [doesNotReject, result].concat(args));
  2013. });
  2014. };
  2015. assert.ifError = function ifError(err) {
  2016. if (err !== null && err !== undefined) {
  2017. var message = 'ifError got unwanted exception: ';
  2018. if (_typeof(err) === 'object' && typeof err.message === 'string') {
  2019. if (err.message.length === 0 && err.constructor) {
  2020. message += err.constructor.name;
  2021. } else {
  2022. message += err.message;
  2023. }
  2024. } else {
  2025. message += inspect(err);
  2026. }
  2027. var newErr = new AssertionError({
  2028. actual: err,
  2029. expected: null,
  2030. operator: 'ifError',
  2031. message: message,
  2032. stackStartFn: ifError
  2033. }); // Make sure we actually have a stack trace!
  2034. var origStack = err.stack;
  2035. if (typeof origStack === 'string') {
  2036. // This will remove any duplicated frames from the error frames taken
  2037. // from within `ifError` and add the original error frames to the newly
  2038. // created ones.
  2039. var tmp2 = origStack.split('\n');
  2040. tmp2.shift(); // Filter all frames existing in err.stack.
  2041. var tmp1 = newErr.stack.split('\n');
  2042. for (var i = 0; i < tmp2.length; i++) {
  2043. // Find the first occurrence of the frame.
  2044. var pos = tmp1.indexOf(tmp2[i]);
  2045. if (pos !== -1) {
  2046. // Only keep new frames.
  2047. tmp1 = tmp1.slice(0, pos);
  2048. break;
  2049. }
  2050. }
  2051. newErr.stack = "".concat(tmp1.join('\n'), "\n").concat(tmp2.join('\n'));
  2052. }
  2053. throw newErr;
  2054. }
  2055. }; // Expose a strict only variant of assert
  2056. function strict() {
  2057. for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
  2058. args[_key6] = arguments[_key6];
  2059. }
  2060. innerOk.apply(void 0, [strict, args.length].concat(args));
  2061. }
  2062. assert.strict = objectAssign(strict, assert, {
  2063. equal: assert.strictEqual,
  2064. deepEqual: assert.deepStrictEqual,
  2065. notEqual: assert.notStrictEqual,
  2066. notDeepEqual: assert.notDeepStrictEqual
  2067. });
  2068. assert.strict.strict = assert.strict;
  2069. /***/ }),
  2070. /***/ "../../node_modules/assert/build/internal/assert/assertion_error.js":
  2071. /*!**************************************************************************!*\
  2072. !*** ../../node_modules/assert/build/internal/assert/assertion_error.js ***!
  2073. \**************************************************************************/
  2074. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  2075. "use strict";
  2076. /* provided dependency */ var process = __webpack_require__(/*! process/browser */ "../../node_modules/process/browser.js");
  2077. // Currently in sync with Node.js lib/internal/assert/assertion_error.js
  2078. // https://github.com/nodejs/node/commit/0817840f775032169ddd70c85ac059f18ffcc81c
  2079. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
  2080. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  2081. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2082. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  2083. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2084. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  2085. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  2086. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  2087. function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
  2088. function isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  2089. function _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
  2090. function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
  2091. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  2092. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  2093. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  2094. var _require = __webpack_require__(/*! util/ */ "../../node_modules/util/util.js"),
  2095. inspect = _require.inspect;
  2096. var _require2 = __webpack_require__(/*! ../errors */ "../../node_modules/assert/build/internal/errors.js"),
  2097. ERR_INVALID_ARG_TYPE = _require2.codes.ERR_INVALID_ARG_TYPE; // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
  2098. function endsWith(str, search, this_len) {
  2099. if (this_len === undefined || this_len > str.length) {
  2100. this_len = str.length;
  2101. }
  2102. return str.substring(this_len - search.length, this_len) === search;
  2103. } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat
  2104. function repeat(str, count) {
  2105. count = Math.floor(count);
  2106. if (str.length == 0 || count == 0) return '';
  2107. var maxCount = str.length * count;
  2108. count = Math.floor(Math.log(count) / Math.log(2));
  2109. while (count) {
  2110. str += str;
  2111. count--;
  2112. }
  2113. str += str.substring(0, maxCount - str.length);
  2114. return str;
  2115. }
  2116. var blue = '';
  2117. var green = '';
  2118. var red = '';
  2119. var white = '';
  2120. var kReadableOperator = {
  2121. deepStrictEqual: 'Expected values to be strictly deep-equal:',
  2122. strictEqual: 'Expected values to be strictly equal:',
  2123. strictEqualObject: 'Expected "actual" to be reference-equal to "expected":',
  2124. deepEqual: 'Expected values to be loosely deep-equal:',
  2125. equal: 'Expected values to be loosely equal:',
  2126. notDeepStrictEqual: 'Expected "actual" not to be strictly deep-equal to:',
  2127. notStrictEqual: 'Expected "actual" to be strictly unequal to:',
  2128. notStrictEqualObject: 'Expected "actual" not to be reference-equal to "expected":',
  2129. notDeepEqual: 'Expected "actual" not to be loosely deep-equal to:',
  2130. notEqual: 'Expected "actual" to be loosely unequal to:',
  2131. notIdentical: 'Values identical but not reference-equal:'
  2132. }; // Comparing short primitives should just show === / !== instead of using the
  2133. // diff.
  2134. var kMaxShortLength = 10;
  2135. function copyError(source) {
  2136. var keys = Object.keys(source);
  2137. var target = Object.create(Object.getPrototypeOf(source));
  2138. keys.forEach(function (key) {
  2139. target[key] = source[key];
  2140. });
  2141. Object.defineProperty(target, 'message', {
  2142. value: source.message
  2143. });
  2144. return target;
  2145. }
  2146. function inspectValue(val) {
  2147. // The util.inspect default values could be changed. This makes sure the
  2148. // error messages contain the necessary information nevertheless.
  2149. return inspect(val, {
  2150. compact: false,
  2151. customInspect: false,
  2152. depth: 1000,
  2153. maxArrayLength: Infinity,
  2154. // Assert compares only enumerable properties (with a few exceptions).
  2155. showHidden: false,
  2156. // Having a long line as error is better than wrapping the line for
  2157. // comparison for now.
  2158. // TODO(BridgeAR): `breakLength` should be limited as soon as soon as we
  2159. // have meta information about the inspected properties (i.e., know where
  2160. // in what line the property starts and ends).
  2161. breakLength: Infinity,
  2162. // Assert does not detect proxies currently.
  2163. showProxy: false,
  2164. sorted: true,
  2165. // Inspect getters as we also check them when comparing entries.
  2166. getters: true
  2167. });
  2168. }
  2169. function createErrDiff(actual, expected, operator) {
  2170. var other = '';
  2171. var res = '';
  2172. var lastPos = 0;
  2173. var end = '';
  2174. var skipped = false;
  2175. var actualInspected = inspectValue(actual);
  2176. var actualLines = actualInspected.split('\n');
  2177. var expectedLines = inspectValue(expected).split('\n');
  2178. var i = 0;
  2179. var indicator = ''; // In case both values are objects explicitly mark them as not reference equal
  2180. // for the `strictEqual` operator.
  2181. if (operator === 'strictEqual' && _typeof(actual) === 'object' && _typeof(expected) === 'object' && actual !== null && expected !== null) {
  2182. operator = 'strictEqualObject';
  2183. } // If "actual" and "expected" fit on a single line and they are not strictly
  2184. // equal, check further special handling.
  2185. if (actualLines.length === 1 && expectedLines.length === 1 && actualLines[0] !== expectedLines[0]) {
  2186. var inputLength = actualLines[0].length + expectedLines[0].length; // If the character length of "actual" and "expected" together is less than
  2187. // kMaxShortLength and if neither is an object and at least one of them is
  2188. // not `zero`, use the strict equal comparison to visualize the output.
  2189. if (inputLength <= kMaxShortLength) {
  2190. if ((_typeof(actual) !== 'object' || actual === null) && (_typeof(expected) !== 'object' || expected === null) && (actual !== 0 || expected !== 0)) {
  2191. // -0 === +0
  2192. return "".concat(kReadableOperator[operator], "\n\n") + "".concat(actualLines[0], " !== ").concat(expectedLines[0], "\n");
  2193. }
  2194. } else if (operator !== 'strictEqualObject') {
  2195. // If the stderr is a tty and the input length is lower than the current
  2196. // columns per line, add a mismatch indicator below the output. If it is
  2197. // not a tty, use a default value of 80 characters.
  2198. var maxLength = process.stderr && process.stderr.isTTY ? process.stderr.columns : 80;
  2199. if (inputLength < maxLength) {
  2200. while (actualLines[0][i] === expectedLines[0][i]) {
  2201. i++;
  2202. } // Ignore the first characters.
  2203. if (i > 2) {
  2204. // Add position indicator for the first mismatch in case it is a
  2205. // single line and the input length is less than the column length.
  2206. indicator = "\n ".concat(repeat(' ', i), "^");
  2207. i = 0;
  2208. }
  2209. }
  2210. }
  2211. } // Remove all ending lines that match (this optimizes the output for
  2212. // readability by reducing the number of total changed lines).
  2213. var a = actualLines[actualLines.length - 1];
  2214. var b = expectedLines[expectedLines.length - 1];
  2215. while (a === b) {
  2216. if (i++ < 2) {
  2217. end = "\n ".concat(a).concat(end);
  2218. } else {
  2219. other = a;
  2220. }
  2221. actualLines.pop();
  2222. expectedLines.pop();
  2223. if (actualLines.length === 0 || expectedLines.length === 0) break;
  2224. a = actualLines[actualLines.length - 1];
  2225. b = expectedLines[expectedLines.length - 1];
  2226. }
  2227. var maxLines = Math.max(actualLines.length, expectedLines.length); // Strict equal with identical objects that are not identical by reference.
  2228. // E.g., assert.deepStrictEqual({ a: Symbol() }, { a: Symbol() })
  2229. if (maxLines === 0) {
  2230. // We have to get the result again. The lines were all removed before.
  2231. var _actualLines = actualInspected.split('\n'); // Only remove lines in case it makes sense to collapse those.
  2232. // TODO: Accept env to always show the full error.
  2233. if (_actualLines.length > 30) {
  2234. _actualLines[26] = "".concat(blue, "...").concat(white);
  2235. while (_actualLines.length > 27) {
  2236. _actualLines.pop();
  2237. }
  2238. }
  2239. return "".concat(kReadableOperator.notIdentical, "\n\n").concat(_actualLines.join('\n'), "\n");
  2240. }
  2241. if (i > 3) {
  2242. end = "\n".concat(blue, "...").concat(white).concat(end);
  2243. skipped = true;
  2244. }
  2245. if (other !== '') {
  2246. end = "\n ".concat(other).concat(end);
  2247. other = '';
  2248. }
  2249. var printedLines = 0;
  2250. var msg = kReadableOperator[operator] + "\n".concat(green, "+ actual").concat(white, " ").concat(red, "- expected").concat(white);
  2251. var skippedMsg = " ".concat(blue, "...").concat(white, " Lines skipped");
  2252. for (i = 0; i < maxLines; i++) {
  2253. // Only extra expected lines exist
  2254. var cur = i - lastPos;
  2255. if (actualLines.length < i + 1) {
  2256. // If the last diverging line is more than one line above and the
  2257. // current line is at least line three, add some of the former lines and
  2258. // also add dots to indicate skipped entries.
  2259. if (cur > 1 && i > 2) {
  2260. if (cur > 4) {
  2261. res += "\n".concat(blue, "...").concat(white);
  2262. skipped = true;
  2263. } else if (cur > 3) {
  2264. res += "\n ".concat(expectedLines[i - 2]);
  2265. printedLines++;
  2266. }
  2267. res += "\n ".concat(expectedLines[i - 1]);
  2268. printedLines++;
  2269. } // Mark the current line as the last diverging one.
  2270. lastPos = i; // Add the expected line to the cache.
  2271. other += "\n".concat(red, "-").concat(white, " ").concat(expectedLines[i]);
  2272. printedLines++; // Only extra actual lines exist
  2273. } else if (expectedLines.length < i + 1) {
  2274. // If the last diverging line is more than one line above and the
  2275. // current line is at least line three, add some of the former lines and
  2276. // also add dots to indicate skipped entries.
  2277. if (cur > 1 && i > 2) {
  2278. if (cur > 4) {
  2279. res += "\n".concat(blue, "...").concat(white);
  2280. skipped = true;
  2281. } else if (cur > 3) {
  2282. res += "\n ".concat(actualLines[i - 2]);
  2283. printedLines++;
  2284. }
  2285. res += "\n ".concat(actualLines[i - 1]);
  2286. printedLines++;
  2287. } // Mark the current line as the last diverging one.
  2288. lastPos = i; // Add the actual line to the result.
  2289. res += "\n".concat(green, "+").concat(white, " ").concat(actualLines[i]);
  2290. printedLines++; // Lines diverge
  2291. } else {
  2292. var expectedLine = expectedLines[i];
  2293. var actualLine = actualLines[i]; // If the lines diverge, specifically check for lines that only diverge by
  2294. // a trailing comma. In that case it is actually identical and we should
  2295. // mark it as such.
  2296. var divergingLines = actualLine !== expectedLine && (!endsWith(actualLine, ',') || actualLine.slice(0, -1) !== expectedLine); // If the expected line has a trailing comma but is otherwise identical,
  2297. // add a comma at the end of the actual line. Otherwise the output could
  2298. // look weird as in:
  2299. //
  2300. // [
  2301. // 1 // No comma at the end!
  2302. // + 2
  2303. // ]
  2304. //
  2305. if (divergingLines && endsWith(expectedLine, ',') && expectedLine.slice(0, -1) === actualLine) {
  2306. divergingLines = false;
  2307. actualLine += ',';
  2308. }
  2309. if (divergingLines) {
  2310. // If the last diverging line is more than one line above and the
  2311. // current line is at least line three, add some of the former lines and
  2312. // also add dots to indicate skipped entries.
  2313. if (cur > 1 && i > 2) {
  2314. if (cur > 4) {
  2315. res += "\n".concat(blue, "...").concat(white);
  2316. skipped = true;
  2317. } else if (cur > 3) {
  2318. res += "\n ".concat(actualLines[i - 2]);
  2319. printedLines++;
  2320. }
  2321. res += "\n ".concat(actualLines[i - 1]);
  2322. printedLines++;
  2323. } // Mark the current line as the last diverging one.
  2324. lastPos = i; // Add the actual line to the result and cache the expected diverging
  2325. // line so consecutive diverging lines show up as +++--- and not +-+-+-.
  2326. res += "\n".concat(green, "+").concat(white, " ").concat(actualLine);
  2327. other += "\n".concat(red, "-").concat(white, " ").concat(expectedLine);
  2328. printedLines += 2; // Lines are identical
  2329. } else {
  2330. // Add all cached information to the result before adding other things
  2331. // and reset the cache.
  2332. res += other;
  2333. other = ''; // If the last diverging line is exactly one line above or if it is the
  2334. // very first line, add the line to the result.
  2335. if (cur === 1 || i === 0) {
  2336. res += "\n ".concat(actualLine);
  2337. printedLines++;
  2338. }
  2339. }
  2340. } // Inspected object to big (Show ~20 rows max)
  2341. if (printedLines > 20 && i < maxLines - 2) {
  2342. return "".concat(msg).concat(skippedMsg, "\n").concat(res, "\n").concat(blue, "...").concat(white).concat(other, "\n") + "".concat(blue, "...").concat(white);
  2343. }
  2344. }
  2345. return "".concat(msg).concat(skipped ? skippedMsg : '', "\n").concat(res).concat(other).concat(end).concat(indicator);
  2346. }
  2347. var AssertionError =
  2348. /*#__PURE__*/
  2349. function (_Error) {
  2350. _inherits(AssertionError, _Error);
  2351. function AssertionError(options) {
  2352. var _this;
  2353. _classCallCheck(this, AssertionError);
  2354. if (_typeof(options) !== 'object' || options === null) {
  2355. throw new ERR_INVALID_ARG_TYPE('options', 'Object', options);
  2356. }
  2357. var message = options.message,
  2358. operator = options.operator,
  2359. stackStartFn = options.stackStartFn;
  2360. var actual = options.actual,
  2361. expected = options.expected;
  2362. var limit = Error.stackTraceLimit;
  2363. Error.stackTraceLimit = 0;
  2364. if (message != null) {
  2365. _this = _possibleConstructorReturn(this, _getPrototypeOf(AssertionError).call(this, String(message)));
  2366. } else {
  2367. if (process.stderr && process.stderr.isTTY) {
  2368. // Reset on each call to make sure we handle dynamically set environment
  2369. // variables correct.
  2370. if (process.stderr && process.stderr.getColorDepth && process.stderr.getColorDepth() !== 1) {
  2371. blue = "\x1B[34m";
  2372. green = "\x1B[32m";
  2373. white = "\x1B[39m";
  2374. red = "\x1B[31m";
  2375. } else {
  2376. blue = '';
  2377. green = '';
  2378. white = '';
  2379. red = '';
  2380. }
  2381. } // Prevent the error stack from being visible by duplicating the error
  2382. // in a very close way to the original in case both sides are actually
  2383. // instances of Error.
  2384. if (_typeof(actual) === 'object' && actual !== null && _typeof(expected) === 'object' && expected !== null && 'stack' in actual && actual instanceof Error && 'stack' in expected && expected instanceof Error) {
  2385. actual = copyError(actual);
  2386. expected = copyError(expected);
  2387. }
  2388. if (operator === 'deepStrictEqual' || operator === 'strictEqual') {
  2389. _this = _possibleConstructorReturn(this, _getPrototypeOf(AssertionError).call(this, createErrDiff(actual, expected, operator)));
  2390. } else if (operator === 'notDeepStrictEqual' || operator === 'notStrictEqual') {
  2391. // In case the objects are equal but the operator requires unequal, show
  2392. // the first object and say A equals B
  2393. var base = kReadableOperator[operator];
  2394. var res = inspectValue(actual).split('\n'); // In case "actual" is an object, it should not be reference equal.
  2395. if (operator === 'notStrictEqual' && _typeof(actual) === 'object' && actual !== null) {
  2396. base = kReadableOperator.notStrictEqualObject;
  2397. } // Only remove lines in case it makes sense to collapse those.
  2398. // TODO: Accept env to always show the full error.
  2399. if (res.length > 30) {
  2400. res[26] = "".concat(blue, "...").concat(white);
  2401. while (res.length > 27) {
  2402. res.pop();
  2403. }
  2404. } // Only print a single input.
  2405. if (res.length === 1) {
  2406. _this = _possibleConstructorReturn(this, _getPrototypeOf(AssertionError).call(this, "".concat(base, " ").concat(res[0])));
  2407. } else {
  2408. _this = _possibleConstructorReturn(this, _getPrototypeOf(AssertionError).call(this, "".concat(base, "\n\n").concat(res.join('\n'), "\n")));
  2409. }
  2410. } else {
  2411. var _res = inspectValue(actual);
  2412. var other = '';
  2413. var knownOperators = kReadableOperator[operator];
  2414. if (operator === 'notDeepEqual' || operator === 'notEqual') {
  2415. _res = "".concat(kReadableOperator[operator], "\n\n").concat(_res);
  2416. if (_res.length > 1024) {
  2417. _res = "".concat(_res.slice(0, 1021), "...");
  2418. }
  2419. } else {
  2420. other = "".concat(inspectValue(expected));
  2421. if (_res.length > 512) {
  2422. _res = "".concat(_res.slice(0, 509), "...");
  2423. }
  2424. if (other.length > 512) {
  2425. other = "".concat(other.slice(0, 509), "...");
  2426. }
  2427. if (operator === 'deepEqual' || operator === 'equal') {
  2428. _res = "".concat(knownOperators, "\n\n").concat(_res, "\n\nshould equal\n\n");
  2429. } else {
  2430. other = " ".concat(operator, " ").concat(other);
  2431. }
  2432. }
  2433. _this = _possibleConstructorReturn(this, _getPrototypeOf(AssertionError).call(this, "".concat(_res).concat(other)));
  2434. }
  2435. }
  2436. Error.stackTraceLimit = limit;
  2437. _this.generatedMessage = !message;
  2438. Object.defineProperty(_assertThisInitialized(_this), 'name', {
  2439. value: 'AssertionError [ERR_ASSERTION]',
  2440. enumerable: false,
  2441. writable: true,
  2442. configurable: true
  2443. });
  2444. _this.code = 'ERR_ASSERTION';
  2445. _this.actual = actual;
  2446. _this.expected = expected;
  2447. _this.operator = operator;
  2448. if (Error.captureStackTrace) {
  2449. // eslint-disable-next-line no-restricted-syntax
  2450. Error.captureStackTrace(_assertThisInitialized(_this), stackStartFn);
  2451. } // Create error message including the error code in the name.
  2452. _this.stack; // Reset the name.
  2453. _this.name = 'AssertionError';
  2454. return _possibleConstructorReturn(_this);
  2455. }
  2456. _createClass(AssertionError, [{
  2457. key: "toString",
  2458. value: function toString() {
  2459. return "".concat(this.name, " [").concat(this.code, "]: ").concat(this.message);
  2460. }
  2461. }, {
  2462. key: inspect.custom,
  2463. value: function value(recurseTimes, ctx) {
  2464. // This limits the `actual` and `expected` property default inspection to
  2465. // the minimum depth. Otherwise those values would be too verbose compared
  2466. // to the actual error message which contains a combined view of these two
  2467. // input values.
  2468. return inspect(this, _objectSpread({}, ctx, {
  2469. customInspect: false,
  2470. depth: 0
  2471. }));
  2472. }
  2473. }]);
  2474. return AssertionError;
  2475. }(_wrapNativeSuper(Error));
  2476. module.exports = AssertionError;
  2477. /***/ }),
  2478. /***/ "../../node_modules/assert/build/internal/errors.js":
  2479. /*!**********************************************************!*\
  2480. !*** ../../node_modules/assert/build/internal/errors.js ***!
  2481. \**********************************************************/
  2482. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  2483. "use strict";
  2484. // Currently in sync with Node.js lib/internal/errors.js
  2485. // https://github.com/nodejs/node/commit/3b044962c48fe313905877a96b5d0894a5404f6f
  2486. /* eslint node-core/documented-errors: "error" */
  2487. /* eslint node-core/alphabetize-errors: "error" */
  2488. /* eslint node-core/prefer-util-format-errors: "error" */
  2489. // The whole point behind this internal module is to allow Node.js to no
  2490. // longer be forced to treat every error message change as a semver-major
  2491. // change. The NodeError classes here all expose a `code` property whose
  2492. // value statically and permanently identifies the error. While the error
  2493. // message may change, the code should not.
  2494. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  2495. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2496. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  2497. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  2498. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  2499. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  2500. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  2501. var codes = {}; // Lazy loaded
  2502. var assert;
  2503. var util;
  2504. function createErrorType(code, message, Base) {
  2505. if (!Base) {
  2506. Base = Error;
  2507. }
  2508. function getMessage(arg1, arg2, arg3) {
  2509. if (typeof message === 'string') {
  2510. return message;
  2511. } else {
  2512. return message(arg1, arg2, arg3);
  2513. }
  2514. }
  2515. var NodeError =
  2516. /*#__PURE__*/
  2517. function (_Base) {
  2518. _inherits(NodeError, _Base);
  2519. function NodeError(arg1, arg2, arg3) {
  2520. var _this;
  2521. _classCallCheck(this, NodeError);
  2522. _this = _possibleConstructorReturn(this, _getPrototypeOf(NodeError).call(this, getMessage(arg1, arg2, arg3)));
  2523. _this.code = code;
  2524. return _this;
  2525. }
  2526. return NodeError;
  2527. }(Base);
  2528. codes[code] = NodeError;
  2529. } // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js
  2530. function oneOf(expected, thing) {
  2531. if (Array.isArray(expected)) {
  2532. var len = expected.length;
  2533. expected = expected.map(function (i) {
  2534. return String(i);
  2535. });
  2536. if (len > 2) {
  2537. return "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(', '), ", or ") + expected[len - 1];
  2538. } else if (len === 2) {
  2539. return "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1]);
  2540. } else {
  2541. return "of ".concat(thing, " ").concat(expected[0]);
  2542. }
  2543. } else {
  2544. return "of ".concat(thing, " ").concat(String(expected));
  2545. }
  2546. } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
  2547. function startsWith(str, search, pos) {
  2548. return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
  2549. } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
  2550. function endsWith(str, search, this_len) {
  2551. if (this_len === undefined || this_len > str.length) {
  2552. this_len = str.length;
  2553. }
  2554. return str.substring(this_len - search.length, this_len) === search;
  2555. } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
  2556. function includes(str, search, start) {
  2557. if (typeof start !== 'number') {
  2558. start = 0;
  2559. }
  2560. if (start + search.length > str.length) {
  2561. return false;
  2562. } else {
  2563. return str.indexOf(search, start) !== -1;
  2564. }
  2565. }
  2566. createErrorType('ERR_AMBIGUOUS_ARGUMENT', 'The "%s" argument is ambiguous. %s', TypeError);
  2567. createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) {
  2568. if (assert === undefined) assert = __webpack_require__(/*! ../assert */ "../../node_modules/assert/build/assert.js");
  2569. assert(typeof name === 'string', "'name' must be a string"); // determiner: 'must be' or 'must not be'
  2570. var determiner;
  2571. if (typeof expected === 'string' && startsWith(expected, 'not ')) {
  2572. determiner = 'must not be';
  2573. expected = expected.replace(/^not /, '');
  2574. } else {
  2575. determiner = 'must be';
  2576. }
  2577. var msg;
  2578. if (endsWith(name, ' argument')) {
  2579. // For cases like 'first argument'
  2580. msg = "The ".concat(name, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));
  2581. } else {
  2582. var type = includes(name, '.') ? 'property' : 'argument';
  2583. msg = "The \"".concat(name, "\" ").concat(type, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));
  2584. } // TODO(BridgeAR): Improve the output by showing `null` and similar.
  2585. msg += ". Received type ".concat(_typeof(actual));
  2586. return msg;
  2587. }, TypeError);
  2588. createErrorType('ERR_INVALID_ARG_VALUE', function (name, value) {
  2589. var reason = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'is invalid';
  2590. if (util === undefined) util = __webpack_require__(/*! util/ */ "../../node_modules/util/util.js");
  2591. var inspected = util.inspect(value);
  2592. if (inspected.length > 128) {
  2593. inspected = "".concat(inspected.slice(0, 128), "...");
  2594. }
  2595. return "The argument '".concat(name, "' ").concat(reason, ". Received ").concat(inspected);
  2596. }, TypeError, RangeError);
  2597. createErrorType('ERR_INVALID_RETURN_VALUE', function (input, name, value) {
  2598. var type;
  2599. if (value && value.constructor && value.constructor.name) {
  2600. type = "instance of ".concat(value.constructor.name);
  2601. } else {
  2602. type = "type ".concat(_typeof(value));
  2603. }
  2604. return "Expected ".concat(input, " to be returned from the \"").concat(name, "\"") + " function but got ".concat(type, ".");
  2605. }, TypeError);
  2606. createErrorType('ERR_MISSING_ARGS', function () {
  2607. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  2608. args[_key] = arguments[_key];
  2609. }
  2610. if (assert === undefined) assert = __webpack_require__(/*! ../assert */ "../../node_modules/assert/build/assert.js");
  2611. assert(args.length > 0, 'At least one arg needs to be specified');
  2612. var msg = 'The ';
  2613. var len = args.length;
  2614. args = args.map(function (a) {
  2615. return "\"".concat(a, "\"");
  2616. });
  2617. switch (len) {
  2618. case 1:
  2619. msg += "".concat(args[0], " argument");
  2620. break;
  2621. case 2:
  2622. msg += "".concat(args[0], " and ").concat(args[1], " arguments");
  2623. break;
  2624. default:
  2625. msg += args.slice(0, len - 1).join(', ');
  2626. msg += ", and ".concat(args[len - 1], " arguments");
  2627. break;
  2628. }
  2629. return "".concat(msg, " must be specified");
  2630. }, TypeError);
  2631. module.exports.codes = codes;
  2632. /***/ }),
  2633. /***/ "../../node_modules/assert/build/internal/util/comparisons.js":
  2634. /*!********************************************************************!*\
  2635. !*** ../../node_modules/assert/build/internal/util/comparisons.js ***!
  2636. \********************************************************************/
  2637. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  2638. "use strict";
  2639. // Currently in sync with Node.js lib/internal/util/comparisons.js
  2640. // https://github.com/nodejs/node/commit/112cc7c27551254aa2b17098fb774867f05ed0d9
  2641. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  2642. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  2643. function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  2644. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  2645. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  2646. var regexFlagsSupported = /a/g.flags !== undefined;
  2647. var arrayFromSet = function arrayFromSet(set) {
  2648. var array = [];
  2649. set.forEach(function (value) {
  2650. return array.push(value);
  2651. });
  2652. return array;
  2653. };
  2654. var arrayFromMap = function arrayFromMap(map) {
  2655. var array = [];
  2656. map.forEach(function (value, key) {
  2657. return array.push([key, value]);
  2658. });
  2659. return array;
  2660. };
  2661. var objectIs = Object.is ? Object.is : __webpack_require__(/*! object-is */ "../../node_modules/object-is/index.js");
  2662. var objectGetOwnPropertySymbols = Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols : function () {
  2663. return [];
  2664. };
  2665. var numberIsNaN = Number.isNaN ? Number.isNaN : __webpack_require__(/*! is-nan */ "../../node_modules/is-nan/index.js");
  2666. function uncurryThis(f) {
  2667. return f.call.bind(f);
  2668. }
  2669. var hasOwnProperty = uncurryThis(Object.prototype.hasOwnProperty);
  2670. var propertyIsEnumerable = uncurryThis(Object.prototype.propertyIsEnumerable);
  2671. var objectToString = uncurryThis(Object.prototype.toString);
  2672. var _require$types = (__webpack_require__(/*! util/ */ "../../node_modules/util/util.js").types),
  2673. isAnyArrayBuffer = _require$types.isAnyArrayBuffer,
  2674. isArrayBufferView = _require$types.isArrayBufferView,
  2675. isDate = _require$types.isDate,
  2676. isMap = _require$types.isMap,
  2677. isRegExp = _require$types.isRegExp,
  2678. isSet = _require$types.isSet,
  2679. isNativeError = _require$types.isNativeError,
  2680. isBoxedPrimitive = _require$types.isBoxedPrimitive,
  2681. isNumberObject = _require$types.isNumberObject,
  2682. isStringObject = _require$types.isStringObject,
  2683. isBooleanObject = _require$types.isBooleanObject,
  2684. isBigIntObject = _require$types.isBigIntObject,
  2685. isSymbolObject = _require$types.isSymbolObject,
  2686. isFloat32Array = _require$types.isFloat32Array,
  2687. isFloat64Array = _require$types.isFloat64Array;
  2688. function isNonIndex(key) {
  2689. if (key.length === 0 || key.length > 10) return true;
  2690. for (var i = 0; i < key.length; i++) {
  2691. var code = key.charCodeAt(i);
  2692. if (code < 48 || code > 57) return true;
  2693. } // The maximum size for an array is 2 ** 32 -1.
  2694. return key.length === 10 && key >= Math.pow(2, 32);
  2695. }
  2696. function getOwnNonIndexProperties(value) {
  2697. return Object.keys(value).filter(isNonIndex).concat(objectGetOwnPropertySymbols(value).filter(Object.prototype.propertyIsEnumerable.bind(value)));
  2698. } // Taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js
  2699. // original notice:
  2700. /*!
  2701. * The buffer module from node.js, for the browser.
  2702. *
  2703. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  2704. * @license MIT
  2705. */
  2706. function compare(a, b) {
  2707. if (a === b) {
  2708. return 0;
  2709. }
  2710. var x = a.length;
  2711. var y = b.length;
  2712. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  2713. if (a[i] !== b[i]) {
  2714. x = a[i];
  2715. y = b[i];
  2716. break;
  2717. }
  2718. }
  2719. if (x < y) {
  2720. return -1;
  2721. }
  2722. if (y < x) {
  2723. return 1;
  2724. }
  2725. return 0;
  2726. }
  2727. var ONLY_ENUMERABLE = undefined;
  2728. var kStrict = true;
  2729. var kLoose = false;
  2730. var kNoIterator = 0;
  2731. var kIsArray = 1;
  2732. var kIsSet = 2;
  2733. var kIsMap = 3; // Check if they have the same source and flags
  2734. function areSimilarRegExps(a, b) {
  2735. return regexFlagsSupported ? a.source === b.source && a.flags === b.flags : RegExp.prototype.toString.call(a) === RegExp.prototype.toString.call(b);
  2736. }
  2737. function areSimilarFloatArrays(a, b) {
  2738. if (a.byteLength !== b.byteLength) {
  2739. return false;
  2740. }
  2741. for (var offset = 0; offset < a.byteLength; offset++) {
  2742. if (a[offset] !== b[offset]) {
  2743. return false;
  2744. }
  2745. }
  2746. return true;
  2747. }
  2748. function areSimilarTypedArrays(a, b) {
  2749. if (a.byteLength !== b.byteLength) {
  2750. return false;
  2751. }
  2752. return compare(new Uint8Array(a.buffer, a.byteOffset, a.byteLength), new Uint8Array(b.buffer, b.byteOffset, b.byteLength)) === 0;
  2753. }
  2754. function areEqualArrayBuffers(buf1, buf2) {
  2755. return buf1.byteLength === buf2.byteLength && compare(new Uint8Array(buf1), new Uint8Array(buf2)) === 0;
  2756. }
  2757. function isEqualBoxedPrimitive(val1, val2) {
  2758. if (isNumberObject(val1)) {
  2759. return isNumberObject(val2) && objectIs(Number.prototype.valueOf.call(val1), Number.prototype.valueOf.call(val2));
  2760. }
  2761. if (isStringObject(val1)) {
  2762. return isStringObject(val2) && String.prototype.valueOf.call(val1) === String.prototype.valueOf.call(val2);
  2763. }
  2764. if (isBooleanObject(val1)) {
  2765. return isBooleanObject(val2) && Boolean.prototype.valueOf.call(val1) === Boolean.prototype.valueOf.call(val2);
  2766. }
  2767. if (isBigIntObject(val1)) {
  2768. return isBigIntObject(val2) && BigInt.prototype.valueOf.call(val1) === BigInt.prototype.valueOf.call(val2);
  2769. }
  2770. return isSymbolObject(val2) && Symbol.prototype.valueOf.call(val1) === Symbol.prototype.valueOf.call(val2);
  2771. } // Notes: Type tags are historical [[Class]] properties that can be set by
  2772. // FunctionTemplate::SetClassName() in C++ or Symbol.toStringTag in JS
  2773. // and retrieved using Object.prototype.toString.call(obj) in JS
  2774. // See https://tc39.github.io/ecma262/#sec-object.prototype.tostring
  2775. // for a list of tags pre-defined in the spec.
  2776. // There are some unspecified tags in the wild too (e.g. typed array tags).
  2777. // Since tags can be altered, they only serve fast failures
  2778. //
  2779. // Typed arrays and buffers are checked by comparing the content in their
  2780. // underlying ArrayBuffer. This optimization requires that it's
  2781. // reasonable to interpret their underlying memory in the same way,
  2782. // which is checked by comparing their type tags.
  2783. // (e.g. a Uint8Array and a Uint16Array with the same memory content
  2784. // could still be different because they will be interpreted differently).
  2785. //
  2786. // For strict comparison, objects should have
  2787. // a) The same built-in type tags
  2788. // b) The same prototypes.
  2789. function innerDeepEqual(val1, val2, strict, memos) {
  2790. // All identical values are equivalent, as determined by ===.
  2791. if (val1 === val2) {
  2792. if (val1 !== 0) return true;
  2793. return strict ? objectIs(val1, val2) : true;
  2794. } // Check more closely if val1 and val2 are equal.
  2795. if (strict) {
  2796. if (_typeof(val1) !== 'object') {
  2797. return typeof val1 === 'number' && numberIsNaN(val1) && numberIsNaN(val2);
  2798. }
  2799. if (_typeof(val2) !== 'object' || val1 === null || val2 === null) {
  2800. return false;
  2801. }
  2802. if (Object.getPrototypeOf(val1) !== Object.getPrototypeOf(val2)) {
  2803. return false;
  2804. }
  2805. } else {
  2806. if (val1 === null || _typeof(val1) !== 'object') {
  2807. if (val2 === null || _typeof(val2) !== 'object') {
  2808. // eslint-disable-next-line eqeqeq
  2809. return val1 == val2;
  2810. }
  2811. return false;
  2812. }
  2813. if (val2 === null || _typeof(val2) !== 'object') {
  2814. return false;
  2815. }
  2816. }
  2817. var val1Tag = objectToString(val1);
  2818. var val2Tag = objectToString(val2);
  2819. if (val1Tag !== val2Tag) {
  2820. return false;
  2821. }
  2822. if (Array.isArray(val1)) {
  2823. // Check for sparse arrays and general fast path
  2824. if (val1.length !== val2.length) {
  2825. return false;
  2826. }
  2827. var keys1 = getOwnNonIndexProperties(val1, ONLY_ENUMERABLE);
  2828. var keys2 = getOwnNonIndexProperties(val2, ONLY_ENUMERABLE);
  2829. if (keys1.length !== keys2.length) {
  2830. return false;
  2831. }
  2832. return keyCheck(val1, val2, strict, memos, kIsArray, keys1);
  2833. } // [browserify] This triggers on certain types in IE (Map/Set) so we don't
  2834. // wan't to early return out of the rest of the checks. However we can check
  2835. // if the second value is one of these values and the first isn't.
  2836. if (val1Tag === '[object Object]') {
  2837. // return keyCheck(val1, val2, strict, memos, kNoIterator);
  2838. if (!isMap(val1) && isMap(val2) || !isSet(val1) && isSet(val2)) {
  2839. return false;
  2840. }
  2841. }
  2842. if (isDate(val1)) {
  2843. if (!isDate(val2) || Date.prototype.getTime.call(val1) !== Date.prototype.getTime.call(val2)) {
  2844. return false;
  2845. }
  2846. } else if (isRegExp(val1)) {
  2847. if (!isRegExp(val2) || !areSimilarRegExps(val1, val2)) {
  2848. return false;
  2849. }
  2850. } else if (isNativeError(val1) || val1 instanceof Error) {
  2851. // Do not compare the stack as it might differ even though the error itself
  2852. // is otherwise identical.
  2853. if (val1.message !== val2.message || val1.name !== val2.name) {
  2854. return false;
  2855. }
  2856. } else if (isArrayBufferView(val1)) {
  2857. if (!strict && (isFloat32Array(val1) || isFloat64Array(val1))) {
  2858. if (!areSimilarFloatArrays(val1, val2)) {
  2859. return false;
  2860. }
  2861. } else if (!areSimilarTypedArrays(val1, val2)) {
  2862. return false;
  2863. } // Buffer.compare returns true, so val1.length === val2.length. If they both
  2864. // only contain numeric keys, we don't need to exam further than checking
  2865. // the symbols.
  2866. var _keys = getOwnNonIndexProperties(val1, ONLY_ENUMERABLE);
  2867. var _keys2 = getOwnNonIndexProperties(val2, ONLY_ENUMERABLE);
  2868. if (_keys.length !== _keys2.length) {
  2869. return false;
  2870. }
  2871. return keyCheck(val1, val2, strict, memos, kNoIterator, _keys);
  2872. } else if (isSet(val1)) {
  2873. if (!isSet(val2) || val1.size !== val2.size) {
  2874. return false;
  2875. }
  2876. return keyCheck(val1, val2, strict, memos, kIsSet);
  2877. } else if (isMap(val1)) {
  2878. if (!isMap(val2) || val1.size !== val2.size) {
  2879. return false;
  2880. }
  2881. return keyCheck(val1, val2, strict, memos, kIsMap);
  2882. } else if (isAnyArrayBuffer(val1)) {
  2883. if (!areEqualArrayBuffers(val1, val2)) {
  2884. return false;
  2885. }
  2886. } else if (isBoxedPrimitive(val1) && !isEqualBoxedPrimitive(val1, val2)) {
  2887. return false;
  2888. }
  2889. return keyCheck(val1, val2, strict, memos, kNoIterator);
  2890. }
  2891. function getEnumerables(val, keys) {
  2892. return keys.filter(function (k) {
  2893. return propertyIsEnumerable(val, k);
  2894. });
  2895. }
  2896. function keyCheck(val1, val2, strict, memos, iterationType, aKeys) {
  2897. // For all remaining Object pairs, including Array, objects and Maps,
  2898. // equivalence is determined by having:
  2899. // a) The same number of owned enumerable properties
  2900. // b) The same set of keys/indexes (although not necessarily the same order)
  2901. // c) Equivalent values for every corresponding key/index
  2902. // d) For Sets and Maps, equal contents
  2903. // Note: this accounts for both named and indexed properties on Arrays.
  2904. if (arguments.length === 5) {
  2905. aKeys = Object.keys(val1);
  2906. var bKeys = Object.keys(val2); // The pair must have the same number of owned properties.
  2907. if (aKeys.length !== bKeys.length) {
  2908. return false;
  2909. }
  2910. } // Cheap key test
  2911. var i = 0;
  2912. for (; i < aKeys.length; i++) {
  2913. if (!hasOwnProperty(val2, aKeys[i])) {
  2914. return false;
  2915. }
  2916. }
  2917. if (strict && arguments.length === 5) {
  2918. var symbolKeysA = objectGetOwnPropertySymbols(val1);
  2919. if (symbolKeysA.length !== 0) {
  2920. var count = 0;
  2921. for (i = 0; i < symbolKeysA.length; i++) {
  2922. var key = symbolKeysA[i];
  2923. if (propertyIsEnumerable(val1, key)) {
  2924. if (!propertyIsEnumerable(val2, key)) {
  2925. return false;
  2926. }
  2927. aKeys.push(key);
  2928. count++;
  2929. } else if (propertyIsEnumerable(val2, key)) {
  2930. return false;
  2931. }
  2932. }
  2933. var symbolKeysB = objectGetOwnPropertySymbols(val2);
  2934. if (symbolKeysA.length !== symbolKeysB.length && getEnumerables(val2, symbolKeysB).length !== count) {
  2935. return false;
  2936. }
  2937. } else {
  2938. var _symbolKeysB = objectGetOwnPropertySymbols(val2);
  2939. if (_symbolKeysB.length !== 0 && getEnumerables(val2, _symbolKeysB).length !== 0) {
  2940. return false;
  2941. }
  2942. }
  2943. }
  2944. if (aKeys.length === 0 && (iterationType === kNoIterator || iterationType === kIsArray && val1.length === 0 || val1.size === 0)) {
  2945. return true;
  2946. } // Use memos to handle cycles.
  2947. if (memos === undefined) {
  2948. memos = {
  2949. val1: new Map(),
  2950. val2: new Map(),
  2951. position: 0
  2952. };
  2953. } else {
  2954. // We prevent up to two map.has(x) calls by directly retrieving the value
  2955. // and checking for undefined. The map can only contain numbers, so it is
  2956. // safe to check for undefined only.
  2957. var val2MemoA = memos.val1.get(val1);
  2958. if (val2MemoA !== undefined) {
  2959. var val2MemoB = memos.val2.get(val2);
  2960. if (val2MemoB !== undefined) {
  2961. return val2MemoA === val2MemoB;
  2962. }
  2963. }
  2964. memos.position++;
  2965. }
  2966. memos.val1.set(val1, memos.position);
  2967. memos.val2.set(val2, memos.position);
  2968. var areEq = objEquiv(val1, val2, strict, aKeys, memos, iterationType);
  2969. memos.val1.delete(val1);
  2970. memos.val2.delete(val2);
  2971. return areEq;
  2972. }
  2973. function setHasEqualElement(set, val1, strict, memo) {
  2974. // Go looking.
  2975. var setValues = arrayFromSet(set);
  2976. for (var i = 0; i < setValues.length; i++) {
  2977. var val2 = setValues[i];
  2978. if (innerDeepEqual(val1, val2, strict, memo)) {
  2979. // Remove the matching element to make sure we do not check that again.
  2980. set.delete(val2);
  2981. return true;
  2982. }
  2983. }
  2984. return false;
  2985. } // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness#Loose_equality_using
  2986. // Sadly it is not possible to detect corresponding values properly in case the
  2987. // type is a string, number, bigint or boolean. The reason is that those values
  2988. // can match lots of different string values (e.g., 1n == '+00001').
  2989. function findLooseMatchingPrimitives(prim) {
  2990. switch (_typeof(prim)) {
  2991. case 'undefined':
  2992. return null;
  2993. case 'object':
  2994. // Only pass in null as object!
  2995. return undefined;
  2996. case 'symbol':
  2997. return false;
  2998. case 'string':
  2999. prim = +prim;
  3000. // Loose equal entries exist only if the string is possible to convert to
  3001. // a regular number and not NaN.
  3002. // Fall through
  3003. case 'number':
  3004. if (numberIsNaN(prim)) {
  3005. return false;
  3006. }
  3007. }
  3008. return true;
  3009. }
  3010. function setMightHaveLoosePrim(a, b, prim) {
  3011. var altValue = findLooseMatchingPrimitives(prim);
  3012. if (altValue != null) return altValue;
  3013. return b.has(altValue) && !a.has(altValue);
  3014. }
  3015. function mapMightHaveLoosePrim(a, b, prim, item, memo) {
  3016. var altValue = findLooseMatchingPrimitives(prim);
  3017. if (altValue != null) {
  3018. return altValue;
  3019. }
  3020. var curB = b.get(altValue);
  3021. if (curB === undefined && !b.has(altValue) || !innerDeepEqual(item, curB, false, memo)) {
  3022. return false;
  3023. }
  3024. return !a.has(altValue) && innerDeepEqual(item, curB, false, memo);
  3025. }
  3026. function setEquiv(a, b, strict, memo) {
  3027. // This is a lazily initiated Set of entries which have to be compared
  3028. // pairwise.
  3029. var set = null;
  3030. var aValues = arrayFromSet(a);
  3031. for (var i = 0; i < aValues.length; i++) {
  3032. var val = aValues[i]; // Note: Checking for the objects first improves the performance for object
  3033. // heavy sets but it is a minor slow down for primitives. As they are fast
  3034. // to check this improves the worst case scenario instead.
  3035. if (_typeof(val) === 'object' && val !== null) {
  3036. if (set === null) {
  3037. set = new Set();
  3038. } // If the specified value doesn't exist in the second set its an not null
  3039. // object (or non strict only: a not matching primitive) we'll need to go
  3040. // hunting for something thats deep-(strict-)equal to it. To make this
  3041. // O(n log n) complexity we have to copy these values in a new set first.
  3042. set.add(val);
  3043. } else if (!b.has(val)) {
  3044. if (strict) return false; // Fast path to detect missing string, symbol, undefined and null values.
  3045. if (!setMightHaveLoosePrim(a, b, val)) {
  3046. return false;
  3047. }
  3048. if (set === null) {
  3049. set = new Set();
  3050. }
  3051. set.add(val);
  3052. }
  3053. }
  3054. if (set !== null) {
  3055. var bValues = arrayFromSet(b);
  3056. for (var _i = 0; _i < bValues.length; _i++) {
  3057. var _val = bValues[_i]; // We have to check if a primitive value is already
  3058. // matching and only if it's not, go hunting for it.
  3059. if (_typeof(_val) === 'object' && _val !== null) {
  3060. if (!setHasEqualElement(set, _val, strict, memo)) return false;
  3061. } else if (!strict && !a.has(_val) && !setHasEqualElement(set, _val, strict, memo)) {
  3062. return false;
  3063. }
  3064. }
  3065. return set.size === 0;
  3066. }
  3067. return true;
  3068. }
  3069. function mapHasEqualEntry(set, map, key1, item1, strict, memo) {
  3070. // To be able to handle cases like:
  3071. // Map([[{}, 'a'], [{}, 'b']]) vs Map([[{}, 'b'], [{}, 'a']])
  3072. // ... we need to consider *all* matching keys, not just the first we find.
  3073. var setValues = arrayFromSet(set);
  3074. for (var i = 0; i < setValues.length; i++) {
  3075. var key2 = setValues[i];
  3076. if (innerDeepEqual(key1, key2, strict, memo) && innerDeepEqual(item1, map.get(key2), strict, memo)) {
  3077. set.delete(key2);
  3078. return true;
  3079. }
  3080. }
  3081. return false;
  3082. }
  3083. function mapEquiv(a, b, strict, memo) {
  3084. var set = null;
  3085. var aEntries = arrayFromMap(a);
  3086. for (var i = 0; i < aEntries.length; i++) {
  3087. var _aEntries$i = _slicedToArray(aEntries[i], 2),
  3088. key = _aEntries$i[0],
  3089. item1 = _aEntries$i[1];
  3090. if (_typeof(key) === 'object' && key !== null) {
  3091. if (set === null) {
  3092. set = new Set();
  3093. }
  3094. set.add(key);
  3095. } else {
  3096. // By directly retrieving the value we prevent another b.has(key) check in
  3097. // almost all possible cases.
  3098. var item2 = b.get(key);
  3099. if (item2 === undefined && !b.has(key) || !innerDeepEqual(item1, item2, strict, memo)) {
  3100. if (strict) return false; // Fast path to detect missing string, symbol, undefined and null
  3101. // keys.
  3102. if (!mapMightHaveLoosePrim(a, b, key, item1, memo)) return false;
  3103. if (set === null) {
  3104. set = new Set();
  3105. }
  3106. set.add(key);
  3107. }
  3108. }
  3109. }
  3110. if (set !== null) {
  3111. var bEntries = arrayFromMap(b);
  3112. for (var _i2 = 0; _i2 < bEntries.length; _i2++) {
  3113. var _bEntries$_i = _slicedToArray(bEntries[_i2], 2),
  3114. key = _bEntries$_i[0],
  3115. item = _bEntries$_i[1];
  3116. if (_typeof(key) === 'object' && key !== null) {
  3117. if (!mapHasEqualEntry(set, a, key, item, strict, memo)) return false;
  3118. } else if (!strict && (!a.has(key) || !innerDeepEqual(a.get(key), item, false, memo)) && !mapHasEqualEntry(set, a, key, item, false, memo)) {
  3119. return false;
  3120. }
  3121. }
  3122. return set.size === 0;
  3123. }
  3124. return true;
  3125. }
  3126. function objEquiv(a, b, strict, keys, memos, iterationType) {
  3127. // Sets and maps don't have their entries accessible via normal object
  3128. // properties.
  3129. var i = 0;
  3130. if (iterationType === kIsSet) {
  3131. if (!setEquiv(a, b, strict, memos)) {
  3132. return false;
  3133. }
  3134. } else if (iterationType === kIsMap) {
  3135. if (!mapEquiv(a, b, strict, memos)) {
  3136. return false;
  3137. }
  3138. } else if (iterationType === kIsArray) {
  3139. for (; i < a.length; i++) {
  3140. if (hasOwnProperty(a, i)) {
  3141. if (!hasOwnProperty(b, i) || !innerDeepEqual(a[i], b[i], strict, memos)) {
  3142. return false;
  3143. }
  3144. } else if (hasOwnProperty(b, i)) {
  3145. return false;
  3146. } else {
  3147. // Array is sparse.
  3148. var keysA = Object.keys(a);
  3149. for (; i < keysA.length; i++) {
  3150. var key = keysA[i];
  3151. if (!hasOwnProperty(b, key) || !innerDeepEqual(a[key], b[key], strict, memos)) {
  3152. return false;
  3153. }
  3154. }
  3155. if (keysA.length !== Object.keys(b).length) {
  3156. return false;
  3157. }
  3158. return true;
  3159. }
  3160. }
  3161. } // The pair must have equivalent values for every corresponding key.
  3162. // Possibly expensive deep test:
  3163. for (i = 0; i < keys.length; i++) {
  3164. var _key = keys[i];
  3165. if (!innerDeepEqual(a[_key], b[_key], strict, memos)) {
  3166. return false;
  3167. }
  3168. }
  3169. return true;
  3170. }
  3171. function isDeepEqual(val1, val2) {
  3172. return innerDeepEqual(val1, val2, kLoose);
  3173. }
  3174. function isDeepStrictEqual(val1, val2) {
  3175. return innerDeepEqual(val1, val2, kStrict);
  3176. }
  3177. module.exports = {
  3178. isDeepEqual: isDeepEqual,
  3179. isDeepStrictEqual: isDeepStrictEqual
  3180. };
  3181. /***/ }),
  3182. /***/ "../../node_modules/base-x/src/index.js":
  3183. /*!**********************************************!*\
  3184. !*** ../../node_modules/base-x/src/index.js ***!
  3185. \**********************************************/
  3186. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3187. "use strict";
  3188. // base-x encoding / decoding
  3189. // Copyright (c) 2018 base-x contributors
  3190. // Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
  3191. // Distributed under the MIT software license, see the accompanying
  3192. // file LICENSE or http://www.opensource.org/licenses/mit-license.php.
  3193. // @ts-ignore
  3194. var _Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  3195. function base (ALPHABET) {
  3196. if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
  3197. var BASE_MAP = new Uint8Array(256)
  3198. for (var j = 0; j < BASE_MAP.length; j++) {
  3199. BASE_MAP[j] = 255
  3200. }
  3201. for (var i = 0; i < ALPHABET.length; i++) {
  3202. var x = ALPHABET.charAt(i)
  3203. var xc = x.charCodeAt(0)
  3204. if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
  3205. BASE_MAP[xc] = i
  3206. }
  3207. var BASE = ALPHABET.length
  3208. var LEADER = ALPHABET.charAt(0)
  3209. var FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up
  3210. var iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up
  3211. function encode (source) {
  3212. if (Array.isArray(source) || source instanceof Uint8Array) { source = _Buffer.from(source) }
  3213. if (!_Buffer.isBuffer(source)) { throw new TypeError('Expected Buffer') }
  3214. if (source.length === 0) { return '' }
  3215. // Skip & count leading zeroes.
  3216. var zeroes = 0
  3217. var length = 0
  3218. var pbegin = 0
  3219. var pend = source.length
  3220. while (pbegin !== pend && source[pbegin] === 0) {
  3221. pbegin++
  3222. zeroes++
  3223. }
  3224. // Allocate enough space in big-endian base58 representation.
  3225. var size = ((pend - pbegin) * iFACTOR + 1) >>> 0
  3226. var b58 = new Uint8Array(size)
  3227. // Process the bytes.
  3228. while (pbegin !== pend) {
  3229. var carry = source[pbegin]
  3230. // Apply "b58 = b58 * 256 + ch".
  3231. var i = 0
  3232. for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
  3233. carry += (256 * b58[it1]) >>> 0
  3234. b58[it1] = (carry % BASE) >>> 0
  3235. carry = (carry / BASE) >>> 0
  3236. }
  3237. if (carry !== 0) { throw new Error('Non-zero carry') }
  3238. length = i
  3239. pbegin++
  3240. }
  3241. // Skip leading zeroes in base58 result.
  3242. var it2 = size - length
  3243. while (it2 !== size && b58[it2] === 0) {
  3244. it2++
  3245. }
  3246. // Translate the result into a string.
  3247. var str = LEADER.repeat(zeroes)
  3248. for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]) }
  3249. return str
  3250. }
  3251. function decodeUnsafe (source) {
  3252. if (typeof source !== 'string') { throw new TypeError('Expected String') }
  3253. if (source.length === 0) { return _Buffer.alloc(0) }
  3254. var psz = 0
  3255. // Skip and count leading '1's.
  3256. var zeroes = 0
  3257. var length = 0
  3258. while (source[psz] === LEADER) {
  3259. zeroes++
  3260. psz++
  3261. }
  3262. // Allocate enough space in big-endian base256 representation.
  3263. var size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up.
  3264. var b256 = new Uint8Array(size)
  3265. // Process the characters.
  3266. while (source[psz]) {
  3267. // Decode character
  3268. var carry = BASE_MAP[source.charCodeAt(psz)]
  3269. // Invalid character
  3270. if (carry === 255) { return }
  3271. var i = 0
  3272. for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
  3273. carry += (BASE * b256[it3]) >>> 0
  3274. b256[it3] = (carry % 256) >>> 0
  3275. carry = (carry / 256) >>> 0
  3276. }
  3277. if (carry !== 0) { throw new Error('Non-zero carry') }
  3278. length = i
  3279. psz++
  3280. }
  3281. // Skip leading zeroes in b256.
  3282. var it4 = size - length
  3283. while (it4 !== size && b256[it4] === 0) {
  3284. it4++
  3285. }
  3286. var vch = _Buffer.allocUnsafe(zeroes + (size - it4))
  3287. vch.fill(0x00, 0, zeroes)
  3288. var j = zeroes
  3289. while (it4 !== size) {
  3290. vch[j++] = b256[it4++]
  3291. }
  3292. return vch
  3293. }
  3294. function decode (string) {
  3295. var buffer = decodeUnsafe(string)
  3296. if (buffer) { return buffer }
  3297. throw new Error('Non-base' + BASE + ' character')
  3298. }
  3299. return {
  3300. encode: encode,
  3301. decodeUnsafe: decodeUnsafe,
  3302. decode: decode
  3303. }
  3304. }
  3305. module.exports = base
  3306. /***/ }),
  3307. /***/ "../../node_modules/base64-js/index.js":
  3308. /*!*********************************************!*\
  3309. !*** ../../node_modules/base64-js/index.js ***!
  3310. \*********************************************/
  3311. /***/ ((__unused_webpack_module, exports) => {
  3312. "use strict";
  3313. exports.byteLength = byteLength
  3314. exports.toByteArray = toByteArray
  3315. exports.fromByteArray = fromByteArray
  3316. var lookup = []
  3317. var revLookup = []
  3318. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  3319. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  3320. for (var i = 0, len = code.length; i < len; ++i) {
  3321. lookup[i] = code[i]
  3322. revLookup[code.charCodeAt(i)] = i
  3323. }
  3324. // Support decoding URL-safe base64 strings, as Node.js does.
  3325. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  3326. revLookup['-'.charCodeAt(0)] = 62
  3327. revLookup['_'.charCodeAt(0)] = 63
  3328. function getLens (b64) {
  3329. var len = b64.length
  3330. if (len % 4 > 0) {
  3331. throw new Error('Invalid string. Length must be a multiple of 4')
  3332. }
  3333. // Trim off extra bytes after placeholder bytes are found
  3334. // See: https://github.com/beatgammit/base64-js/issues/42
  3335. var validLen = b64.indexOf('=')
  3336. if (validLen === -1) validLen = len
  3337. var placeHoldersLen = validLen === len
  3338. ? 0
  3339. : 4 - (validLen % 4)
  3340. return [validLen, placeHoldersLen]
  3341. }
  3342. // base64 is 4/3 + up to two characters of the original data
  3343. function byteLength (b64) {
  3344. var lens = getLens(b64)
  3345. var validLen = lens[0]
  3346. var placeHoldersLen = lens[1]
  3347. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  3348. }
  3349. function _byteLength (b64, validLen, placeHoldersLen) {
  3350. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  3351. }
  3352. function toByteArray (b64) {
  3353. var tmp
  3354. var lens = getLens(b64)
  3355. var validLen = lens[0]
  3356. var placeHoldersLen = lens[1]
  3357. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  3358. var curByte = 0
  3359. // if there are placeholders, only get up to the last complete 4 chars
  3360. var len = placeHoldersLen > 0
  3361. ? validLen - 4
  3362. : validLen
  3363. var i
  3364. for (i = 0; i < len; i += 4) {
  3365. tmp =
  3366. (revLookup[b64.charCodeAt(i)] << 18) |
  3367. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  3368. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  3369. revLookup[b64.charCodeAt(i + 3)]
  3370. arr[curByte++] = (tmp >> 16) & 0xFF
  3371. arr[curByte++] = (tmp >> 8) & 0xFF
  3372. arr[curByte++] = tmp & 0xFF
  3373. }
  3374. if (placeHoldersLen === 2) {
  3375. tmp =
  3376. (revLookup[b64.charCodeAt(i)] << 2) |
  3377. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  3378. arr[curByte++] = tmp & 0xFF
  3379. }
  3380. if (placeHoldersLen === 1) {
  3381. tmp =
  3382. (revLookup[b64.charCodeAt(i)] << 10) |
  3383. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  3384. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  3385. arr[curByte++] = (tmp >> 8) & 0xFF
  3386. arr[curByte++] = tmp & 0xFF
  3387. }
  3388. return arr
  3389. }
  3390. function tripletToBase64 (num) {
  3391. return lookup[num >> 18 & 0x3F] +
  3392. lookup[num >> 12 & 0x3F] +
  3393. lookup[num >> 6 & 0x3F] +
  3394. lookup[num & 0x3F]
  3395. }
  3396. function encodeChunk (uint8, start, end) {
  3397. var tmp
  3398. var output = []
  3399. for (var i = start; i < end; i += 3) {
  3400. tmp =
  3401. ((uint8[i] << 16) & 0xFF0000) +
  3402. ((uint8[i + 1] << 8) & 0xFF00) +
  3403. (uint8[i + 2] & 0xFF)
  3404. output.push(tripletToBase64(tmp))
  3405. }
  3406. return output.join('')
  3407. }
  3408. function fromByteArray (uint8) {
  3409. var tmp
  3410. var len = uint8.length
  3411. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  3412. var parts = []
  3413. var maxChunkLength = 16383 // must be multiple of 3
  3414. // go through the array every three bytes, we'll deal with trailing stuff later
  3415. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  3416. parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
  3417. }
  3418. // pad the end with zeros, but make sure to not forget the extra bytes
  3419. if (extraBytes === 1) {
  3420. tmp = uint8[len - 1]
  3421. parts.push(
  3422. lookup[tmp >> 2] +
  3423. lookup[(tmp << 4) & 0x3F] +
  3424. '=='
  3425. )
  3426. } else if (extraBytes === 2) {
  3427. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  3428. parts.push(
  3429. lookup[tmp >> 10] +
  3430. lookup[(tmp >> 4) & 0x3F] +
  3431. lookup[(tmp << 2) & 0x3F] +
  3432. '='
  3433. )
  3434. }
  3435. return parts.join('')
  3436. }
  3437. /***/ }),
  3438. /***/ "../../node_modules/big-integer/BigInteger.js":
  3439. /*!****************************************************!*\
  3440. !*** ../../node_modules/big-integer/BigInteger.js ***!
  3441. \****************************************************/
  3442. /***/ ((module, exports, __webpack_require__) => {
  3443. /* module decorator */ module = __webpack_require__.nmd(module);
  3444. var __WEBPACK_AMD_DEFINE_RESULT__;var bigInt = (function (undefined) {
  3445. "use strict";
  3446. var BASE = 1e7,
  3447. LOG_BASE = 7,
  3448. MAX_INT = 9007199254740992,
  3449. MAX_INT_ARR = smallToArray(MAX_INT),
  3450. DEFAULT_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz";
  3451. var supportsNativeBigInt = typeof BigInt === "function";
  3452. function Integer(v, radix, alphabet, caseSensitive) {
  3453. if (typeof v === "undefined") return Integer[0];
  3454. if (typeof radix !== "undefined") return +radix === 10 && !alphabet ? parseValue(v) : parseBase(v, radix, alphabet, caseSensitive);
  3455. return parseValue(v);
  3456. }
  3457. function BigInteger(value, sign) {
  3458. this.value = value;
  3459. this.sign = sign;
  3460. this.isSmall = false;
  3461. }
  3462. BigInteger.prototype = Object.create(Integer.prototype);
  3463. function SmallInteger(value) {
  3464. this.value = value;
  3465. this.sign = value < 0;
  3466. this.isSmall = true;
  3467. }
  3468. SmallInteger.prototype = Object.create(Integer.prototype);
  3469. function NativeBigInt(value) {
  3470. this.value = value;
  3471. }
  3472. NativeBigInt.prototype = Object.create(Integer.prototype);
  3473. function isPrecise(n) {
  3474. return -MAX_INT < n && n < MAX_INT;
  3475. }
  3476. function smallToArray(n) { // For performance reasons doesn't reference BASE, need to change this function if BASE changes
  3477. if (n < 1e7)
  3478. return [n];
  3479. if (n < 1e14)
  3480. return [n % 1e7, Math.floor(n / 1e7)];
  3481. return [n % 1e7, Math.floor(n / 1e7) % 1e7, Math.floor(n / 1e14)];
  3482. }
  3483. function arrayToSmall(arr) { // If BASE changes this function may need to change
  3484. trim(arr);
  3485. var length = arr.length;
  3486. if (length < 4 && compareAbs(arr, MAX_INT_ARR) < 0) {
  3487. switch (length) {
  3488. case 0: return 0;
  3489. case 1: return arr[0];
  3490. case 2: return arr[0] + arr[1] * BASE;
  3491. default: return arr[0] + (arr[1] + arr[2] * BASE) * BASE;
  3492. }
  3493. }
  3494. return arr;
  3495. }
  3496. function trim(v) {
  3497. var i = v.length;
  3498. while (v[--i] === 0);
  3499. v.length = i + 1;
  3500. }
  3501. function createArray(length) { // function shamelessly stolen from Yaffle's library https://github.com/Yaffle/BigInteger
  3502. var x = new Array(length);
  3503. var i = -1;
  3504. while (++i < length) {
  3505. x[i] = 0;
  3506. }
  3507. return x;
  3508. }
  3509. function truncate(n) {
  3510. if (n > 0) return Math.floor(n);
  3511. return Math.ceil(n);
  3512. }
  3513. function add(a, b) { // assumes a and b are arrays with a.length >= b.length
  3514. var l_a = a.length,
  3515. l_b = b.length,
  3516. r = new Array(l_a),
  3517. carry = 0,
  3518. base = BASE,
  3519. sum, i;
  3520. for (i = 0; i < l_b; i++) {
  3521. sum = a[i] + b[i] + carry;
  3522. carry = sum >= base ? 1 : 0;
  3523. r[i] = sum - carry * base;
  3524. }
  3525. while (i < l_a) {
  3526. sum = a[i] + carry;
  3527. carry = sum === base ? 1 : 0;
  3528. r[i++] = sum - carry * base;
  3529. }
  3530. if (carry > 0) r.push(carry);
  3531. return r;
  3532. }
  3533. function addAny(a, b) {
  3534. if (a.length >= b.length) return add(a, b);
  3535. return add(b, a);
  3536. }
  3537. function addSmall(a, carry) { // assumes a is array, carry is number with 0 <= carry < MAX_INT
  3538. var l = a.length,
  3539. r = new Array(l),
  3540. base = BASE,
  3541. sum, i;
  3542. for (i = 0; i < l; i++) {
  3543. sum = a[i] - base + carry;
  3544. carry = Math.floor(sum / base);
  3545. r[i] = sum - carry * base;
  3546. carry += 1;
  3547. }
  3548. while (carry > 0) {
  3549. r[i++] = carry % base;
  3550. carry = Math.floor(carry / base);
  3551. }
  3552. return r;
  3553. }
  3554. BigInteger.prototype.add = function (v) {
  3555. var n = parseValue(v);
  3556. if (this.sign !== n.sign) {
  3557. return this.subtract(n.negate());
  3558. }
  3559. var a = this.value, b = n.value;
  3560. if (n.isSmall) {
  3561. return new BigInteger(addSmall(a, Math.abs(b)), this.sign);
  3562. }
  3563. return new BigInteger(addAny(a, b), this.sign);
  3564. };
  3565. BigInteger.prototype.plus = BigInteger.prototype.add;
  3566. SmallInteger.prototype.add = function (v) {
  3567. var n = parseValue(v);
  3568. var a = this.value;
  3569. if (a < 0 !== n.sign) {
  3570. return this.subtract(n.negate());
  3571. }
  3572. var b = n.value;
  3573. if (n.isSmall) {
  3574. if (isPrecise(a + b)) return new SmallInteger(a + b);
  3575. b = smallToArray(Math.abs(b));
  3576. }
  3577. return new BigInteger(addSmall(b, Math.abs(a)), a < 0);
  3578. };
  3579. SmallInteger.prototype.plus = SmallInteger.prototype.add;
  3580. NativeBigInt.prototype.add = function (v) {
  3581. return new NativeBigInt(this.value + parseValue(v).value);
  3582. }
  3583. NativeBigInt.prototype.plus = NativeBigInt.prototype.add;
  3584. function subtract(a, b) { // assumes a and b are arrays with a >= b
  3585. var a_l = a.length,
  3586. b_l = b.length,
  3587. r = new Array(a_l),
  3588. borrow = 0,
  3589. base = BASE,
  3590. i, difference;
  3591. for (i = 0; i < b_l; i++) {
  3592. difference = a[i] - borrow - b[i];
  3593. if (difference < 0) {
  3594. difference += base;
  3595. borrow = 1;
  3596. } else borrow = 0;
  3597. r[i] = difference;
  3598. }
  3599. for (i = b_l; i < a_l; i++) {
  3600. difference = a[i] - borrow;
  3601. if (difference < 0) difference += base;
  3602. else {
  3603. r[i++] = difference;
  3604. break;
  3605. }
  3606. r[i] = difference;
  3607. }
  3608. for (; i < a_l; i++) {
  3609. r[i] = a[i];
  3610. }
  3611. trim(r);
  3612. return r;
  3613. }
  3614. function subtractAny(a, b, sign) {
  3615. var value;
  3616. if (compareAbs(a, b) >= 0) {
  3617. value = subtract(a, b);
  3618. } else {
  3619. value = subtract(b, a);
  3620. sign = !sign;
  3621. }
  3622. value = arrayToSmall(value);
  3623. if (typeof value === "number") {
  3624. if (sign) value = -value;
  3625. return new SmallInteger(value);
  3626. }
  3627. return new BigInteger(value, sign);
  3628. }
  3629. function subtractSmall(a, b, sign) { // assumes a is array, b is number with 0 <= b < MAX_INT
  3630. var l = a.length,
  3631. r = new Array(l),
  3632. carry = -b,
  3633. base = BASE,
  3634. i, difference;
  3635. for (i = 0; i < l; i++) {
  3636. difference = a[i] + carry;
  3637. carry = Math.floor(difference / base);
  3638. difference %= base;
  3639. r[i] = difference < 0 ? difference + base : difference;
  3640. }
  3641. r = arrayToSmall(r);
  3642. if (typeof r === "number") {
  3643. if (sign) r = -r;
  3644. return new SmallInteger(r);
  3645. } return new BigInteger(r, sign);
  3646. }
  3647. BigInteger.prototype.subtract = function (v) {
  3648. var n = parseValue(v);
  3649. if (this.sign !== n.sign) {
  3650. return this.add(n.negate());
  3651. }
  3652. var a = this.value, b = n.value;
  3653. if (n.isSmall)
  3654. return subtractSmall(a, Math.abs(b), this.sign);
  3655. return subtractAny(a, b, this.sign);
  3656. };
  3657. BigInteger.prototype.minus = BigInteger.prototype.subtract;
  3658. SmallInteger.prototype.subtract = function (v) {
  3659. var n = parseValue(v);
  3660. var a = this.value;
  3661. if (a < 0 !== n.sign) {
  3662. return this.add(n.negate());
  3663. }
  3664. var b = n.value;
  3665. if (n.isSmall) {
  3666. return new SmallInteger(a - b);
  3667. }
  3668. return subtractSmall(b, Math.abs(a), a >= 0);
  3669. };
  3670. SmallInteger.prototype.minus = SmallInteger.prototype.subtract;
  3671. NativeBigInt.prototype.subtract = function (v) {
  3672. return new NativeBigInt(this.value - parseValue(v).value);
  3673. }
  3674. NativeBigInt.prototype.minus = NativeBigInt.prototype.subtract;
  3675. BigInteger.prototype.negate = function () {
  3676. return new BigInteger(this.value, !this.sign);
  3677. };
  3678. SmallInteger.prototype.negate = function () {
  3679. var sign = this.sign;
  3680. var small = new SmallInteger(-this.value);
  3681. small.sign = !sign;
  3682. return small;
  3683. };
  3684. NativeBigInt.prototype.negate = function () {
  3685. return new NativeBigInt(-this.value);
  3686. }
  3687. BigInteger.prototype.abs = function () {
  3688. return new BigInteger(this.value, false);
  3689. };
  3690. SmallInteger.prototype.abs = function () {
  3691. return new SmallInteger(Math.abs(this.value));
  3692. };
  3693. NativeBigInt.prototype.abs = function () {
  3694. return new NativeBigInt(this.value >= 0 ? this.value : -this.value);
  3695. }
  3696. function multiplyLong(a, b) {
  3697. var a_l = a.length,
  3698. b_l = b.length,
  3699. l = a_l + b_l,
  3700. r = createArray(l),
  3701. base = BASE,
  3702. product, carry, i, a_i, b_j;
  3703. for (i = 0; i < a_l; ++i) {
  3704. a_i = a[i];
  3705. for (var j = 0; j < b_l; ++j) {
  3706. b_j = b[j];
  3707. product = a_i * b_j + r[i + j];
  3708. carry = Math.floor(product / base);
  3709. r[i + j] = product - carry * base;
  3710. r[i + j + 1] += carry;
  3711. }
  3712. }
  3713. trim(r);
  3714. return r;
  3715. }
  3716. function multiplySmall(a, b) { // assumes a is array, b is number with |b| < BASE
  3717. var l = a.length,
  3718. r = new Array(l),
  3719. base = BASE,
  3720. carry = 0,
  3721. product, i;
  3722. for (i = 0; i < l; i++) {
  3723. product = a[i] * b + carry;
  3724. carry = Math.floor(product / base);
  3725. r[i] = product - carry * base;
  3726. }
  3727. while (carry > 0) {
  3728. r[i++] = carry % base;
  3729. carry = Math.floor(carry / base);
  3730. }
  3731. return r;
  3732. }
  3733. function shiftLeft(x, n) {
  3734. var r = [];
  3735. while (n-- > 0) r.push(0);
  3736. return r.concat(x);
  3737. }
  3738. function multiplyKaratsuba(x, y) {
  3739. var n = Math.max(x.length, y.length);
  3740. if (n <= 30) return multiplyLong(x, y);
  3741. n = Math.ceil(n / 2);
  3742. var b = x.slice(n),
  3743. a = x.slice(0, n),
  3744. d = y.slice(n),
  3745. c = y.slice(0, n);
  3746. var ac = multiplyKaratsuba(a, c),
  3747. bd = multiplyKaratsuba(b, d),
  3748. abcd = multiplyKaratsuba(addAny(a, b), addAny(c, d));
  3749. var product = addAny(addAny(ac, shiftLeft(subtract(subtract(abcd, ac), bd), n)), shiftLeft(bd, 2 * n));
  3750. trim(product);
  3751. return product;
  3752. }
  3753. // The following function is derived from a surface fit of a graph plotting the performance difference
  3754. // between long multiplication and karatsuba multiplication versus the lengths of the two arrays.
  3755. function useKaratsuba(l1, l2) {
  3756. return -0.012 * l1 - 0.012 * l2 + 0.000015 * l1 * l2 > 0;
  3757. }
  3758. BigInteger.prototype.multiply = function (v) {
  3759. var n = parseValue(v),
  3760. a = this.value, b = n.value,
  3761. sign = this.sign !== n.sign,
  3762. abs;
  3763. if (n.isSmall) {
  3764. if (b === 0) return Integer[0];
  3765. if (b === 1) return this;
  3766. if (b === -1) return this.negate();
  3767. abs = Math.abs(b);
  3768. if (abs < BASE) {
  3769. return new BigInteger(multiplySmall(a, abs), sign);
  3770. }
  3771. b = smallToArray(abs);
  3772. }
  3773. if (useKaratsuba(a.length, b.length)) // Karatsuba is only faster for certain array sizes
  3774. return new BigInteger(multiplyKaratsuba(a, b), sign);
  3775. return new BigInteger(multiplyLong(a, b), sign);
  3776. };
  3777. BigInteger.prototype.times = BigInteger.prototype.multiply;
  3778. function multiplySmallAndArray(a, b, sign) { // a >= 0
  3779. if (a < BASE) {
  3780. return new BigInteger(multiplySmall(b, a), sign);
  3781. }
  3782. return new BigInteger(multiplyLong(b, smallToArray(a)), sign);
  3783. }
  3784. SmallInteger.prototype._multiplyBySmall = function (a) {
  3785. if (isPrecise(a.value * this.value)) {
  3786. return new SmallInteger(a.value * this.value);
  3787. }
  3788. return multiplySmallAndArray(Math.abs(a.value), smallToArray(Math.abs(this.value)), this.sign !== a.sign);
  3789. };
  3790. BigInteger.prototype._multiplyBySmall = function (a) {
  3791. if (a.value === 0) return Integer[0];
  3792. if (a.value === 1) return this;
  3793. if (a.value === -1) return this.negate();
  3794. return multiplySmallAndArray(Math.abs(a.value), this.value, this.sign !== a.sign);
  3795. };
  3796. SmallInteger.prototype.multiply = function (v) {
  3797. return parseValue(v)._multiplyBySmall(this);
  3798. };
  3799. SmallInteger.prototype.times = SmallInteger.prototype.multiply;
  3800. NativeBigInt.prototype.multiply = function (v) {
  3801. return new NativeBigInt(this.value * parseValue(v).value);
  3802. }
  3803. NativeBigInt.prototype.times = NativeBigInt.prototype.multiply;
  3804. function square(a) {
  3805. //console.assert(2 * BASE * BASE < MAX_INT);
  3806. var l = a.length,
  3807. r = createArray(l + l),
  3808. base = BASE,
  3809. product, carry, i, a_i, a_j;
  3810. for (i = 0; i < l; i++) {
  3811. a_i = a[i];
  3812. carry = 0 - a_i * a_i;
  3813. for (var j = i; j < l; j++) {
  3814. a_j = a[j];
  3815. product = 2 * (a_i * a_j) + r[i + j] + carry;
  3816. carry = Math.floor(product / base);
  3817. r[i + j] = product - carry * base;
  3818. }
  3819. r[i + l] = carry;
  3820. }
  3821. trim(r);
  3822. return r;
  3823. }
  3824. BigInteger.prototype.square = function () {
  3825. return new BigInteger(square(this.value), false);
  3826. };
  3827. SmallInteger.prototype.square = function () {
  3828. var value = this.value * this.value;
  3829. if (isPrecise(value)) return new SmallInteger(value);
  3830. return new BigInteger(square(smallToArray(Math.abs(this.value))), false);
  3831. };
  3832. NativeBigInt.prototype.square = function (v) {
  3833. return new NativeBigInt(this.value * this.value);
  3834. }
  3835. function divMod1(a, b) { // Left over from previous version. Performs faster than divMod2 on smaller input sizes.
  3836. var a_l = a.length,
  3837. b_l = b.length,
  3838. base = BASE,
  3839. result = createArray(b.length),
  3840. divisorMostSignificantDigit = b[b_l - 1],
  3841. // normalization
  3842. lambda = Math.ceil(base / (2 * divisorMostSignificantDigit)),
  3843. remainder = multiplySmall(a, lambda),
  3844. divisor = multiplySmall(b, lambda),
  3845. quotientDigit, shift, carry, borrow, i, l, q;
  3846. if (remainder.length <= a_l) remainder.push(0);
  3847. divisor.push(0);
  3848. divisorMostSignificantDigit = divisor[b_l - 1];
  3849. for (shift = a_l - b_l; shift >= 0; shift--) {
  3850. quotientDigit = base - 1;
  3851. if (remainder[shift + b_l] !== divisorMostSignificantDigit) {
  3852. quotientDigit = Math.floor((remainder[shift + b_l] * base + remainder[shift + b_l - 1]) / divisorMostSignificantDigit);
  3853. }
  3854. // quotientDigit <= base - 1
  3855. carry = 0;
  3856. borrow = 0;
  3857. l = divisor.length;
  3858. for (i = 0; i < l; i++) {
  3859. carry += quotientDigit * divisor[i];
  3860. q = Math.floor(carry / base);
  3861. borrow += remainder[shift + i] - (carry - q * base);
  3862. carry = q;
  3863. if (borrow < 0) {
  3864. remainder[shift + i] = borrow + base;
  3865. borrow = -1;
  3866. } else {
  3867. remainder[shift + i] = borrow;
  3868. borrow = 0;
  3869. }
  3870. }
  3871. while (borrow !== 0) {
  3872. quotientDigit -= 1;
  3873. carry = 0;
  3874. for (i = 0; i < l; i++) {
  3875. carry += remainder[shift + i] - base + divisor[i];
  3876. if (carry < 0) {
  3877. remainder[shift + i] = carry + base;
  3878. carry = 0;
  3879. } else {
  3880. remainder[shift + i] = carry;
  3881. carry = 1;
  3882. }
  3883. }
  3884. borrow += carry;
  3885. }
  3886. result[shift] = quotientDigit;
  3887. }
  3888. // denormalization
  3889. remainder = divModSmall(remainder, lambda)[0];
  3890. return [arrayToSmall(result), arrayToSmall(remainder)];
  3891. }
  3892. function divMod2(a, b) { // Implementation idea shamelessly stolen from Silent Matt's library http://silentmatt.com/biginteger/
  3893. // Performs faster than divMod1 on larger input sizes.
  3894. var a_l = a.length,
  3895. b_l = b.length,
  3896. result = [],
  3897. part = [],
  3898. base = BASE,
  3899. guess, xlen, highx, highy, check;
  3900. while (a_l) {
  3901. part.unshift(a[--a_l]);
  3902. trim(part);
  3903. if (compareAbs(part, b) < 0) {
  3904. result.push(0);
  3905. continue;
  3906. }
  3907. xlen = part.length;
  3908. highx = part[xlen - 1] * base + part[xlen - 2];
  3909. highy = b[b_l - 1] * base + b[b_l - 2];
  3910. if (xlen > b_l) {
  3911. highx = (highx + 1) * base;
  3912. }
  3913. guess = Math.ceil(highx / highy);
  3914. do {
  3915. check = multiplySmall(b, guess);
  3916. if (compareAbs(check, part) <= 0) break;
  3917. guess--;
  3918. } while (guess);
  3919. result.push(guess);
  3920. part = subtract(part, check);
  3921. }
  3922. result.reverse();
  3923. return [arrayToSmall(result), arrayToSmall(part)];
  3924. }
  3925. function divModSmall(value, lambda) {
  3926. var length = value.length,
  3927. quotient = createArray(length),
  3928. base = BASE,
  3929. i, q, remainder, divisor;
  3930. remainder = 0;
  3931. for (i = length - 1; i >= 0; --i) {
  3932. divisor = remainder * base + value[i];
  3933. q = truncate(divisor / lambda);
  3934. remainder = divisor - q * lambda;
  3935. quotient[i] = q | 0;
  3936. }
  3937. return [quotient, remainder | 0];
  3938. }
  3939. function divModAny(self, v) {
  3940. var value, n = parseValue(v);
  3941. if (supportsNativeBigInt) {
  3942. return [new NativeBigInt(self.value / n.value), new NativeBigInt(self.value % n.value)];
  3943. }
  3944. var a = self.value, b = n.value;
  3945. var quotient;
  3946. if (b === 0) throw new Error("Cannot divide by zero");
  3947. if (self.isSmall) {
  3948. if (n.isSmall) {
  3949. return [new SmallInteger(truncate(a / b)), new SmallInteger(a % b)];
  3950. }
  3951. return [Integer[0], self];
  3952. }
  3953. if (n.isSmall) {
  3954. if (b === 1) return [self, Integer[0]];
  3955. if (b == -1) return [self.negate(), Integer[0]];
  3956. var abs = Math.abs(b);
  3957. if (abs < BASE) {
  3958. value = divModSmall(a, abs);
  3959. quotient = arrayToSmall(value[0]);
  3960. var remainder = value[1];
  3961. if (self.sign) remainder = -remainder;
  3962. if (typeof quotient === "number") {
  3963. if (self.sign !== n.sign) quotient = -quotient;
  3964. return [new SmallInteger(quotient), new SmallInteger(remainder)];
  3965. }
  3966. return [new BigInteger(quotient, self.sign !== n.sign), new SmallInteger(remainder)];
  3967. }
  3968. b = smallToArray(abs);
  3969. }
  3970. var comparison = compareAbs(a, b);
  3971. if (comparison === -1) return [Integer[0], self];
  3972. if (comparison === 0) return [Integer[self.sign === n.sign ? 1 : -1], Integer[0]];
  3973. // divMod1 is faster on smaller input sizes
  3974. if (a.length + b.length <= 200)
  3975. value = divMod1(a, b);
  3976. else value = divMod2(a, b);
  3977. quotient = value[0];
  3978. var qSign = self.sign !== n.sign,
  3979. mod = value[1],
  3980. mSign = self.sign;
  3981. if (typeof quotient === "number") {
  3982. if (qSign) quotient = -quotient;
  3983. quotient = new SmallInteger(quotient);
  3984. } else quotient = new BigInteger(quotient, qSign);
  3985. if (typeof mod === "number") {
  3986. if (mSign) mod = -mod;
  3987. mod = new SmallInteger(mod);
  3988. } else mod = new BigInteger(mod, mSign);
  3989. return [quotient, mod];
  3990. }
  3991. BigInteger.prototype.divmod = function (v) {
  3992. var result = divModAny(this, v);
  3993. return {
  3994. quotient: result[0],
  3995. remainder: result[1]
  3996. };
  3997. };
  3998. NativeBigInt.prototype.divmod = SmallInteger.prototype.divmod = BigInteger.prototype.divmod;
  3999. BigInteger.prototype.divide = function (v) {
  4000. return divModAny(this, v)[0];
  4001. };
  4002. NativeBigInt.prototype.over = NativeBigInt.prototype.divide = function (v) {
  4003. return new NativeBigInt(this.value / parseValue(v).value);
  4004. };
  4005. SmallInteger.prototype.over = SmallInteger.prototype.divide = BigInteger.prototype.over = BigInteger.prototype.divide;
  4006. BigInteger.prototype.mod = function (v) {
  4007. return divModAny(this, v)[1];
  4008. };
  4009. NativeBigInt.prototype.mod = NativeBigInt.prototype.remainder = function (v) {
  4010. return new NativeBigInt(this.value % parseValue(v).value);
  4011. };
  4012. SmallInteger.prototype.remainder = SmallInteger.prototype.mod = BigInteger.prototype.remainder = BigInteger.prototype.mod;
  4013. BigInteger.prototype.pow = function (v) {
  4014. var n = parseValue(v),
  4015. a = this.value,
  4016. b = n.value,
  4017. value, x, y;
  4018. if (b === 0) return Integer[1];
  4019. if (a === 0) return Integer[0];
  4020. if (a === 1) return Integer[1];
  4021. if (a === -1) return n.isEven() ? Integer[1] : Integer[-1];
  4022. if (n.sign) {
  4023. return Integer[0];
  4024. }
  4025. if (!n.isSmall) throw new Error("The exponent " + n.toString() + " is too large.");
  4026. if (this.isSmall) {
  4027. if (isPrecise(value = Math.pow(a, b)))
  4028. return new SmallInteger(truncate(value));
  4029. }
  4030. x = this;
  4031. y = Integer[1];
  4032. while (true) {
  4033. if (b & 1 === 1) {
  4034. y = y.times(x);
  4035. --b;
  4036. }
  4037. if (b === 0) break;
  4038. b /= 2;
  4039. x = x.square();
  4040. }
  4041. return y;
  4042. };
  4043. SmallInteger.prototype.pow = BigInteger.prototype.pow;
  4044. NativeBigInt.prototype.pow = function (v) {
  4045. var n = parseValue(v);
  4046. var a = this.value, b = n.value;
  4047. var _0 = BigInt(0), _1 = BigInt(1), _2 = BigInt(2);
  4048. if (b === _0) return Integer[1];
  4049. if (a === _0) return Integer[0];
  4050. if (a === _1) return Integer[1];
  4051. if (a === BigInt(-1)) return n.isEven() ? Integer[1] : Integer[-1];
  4052. if (n.isNegative()) return new NativeBigInt(_0);
  4053. var x = this;
  4054. var y = Integer[1];
  4055. while (true) {
  4056. if ((b & _1) === _1) {
  4057. y = y.times(x);
  4058. --b;
  4059. }
  4060. if (b === _0) break;
  4061. b /= _2;
  4062. x = x.square();
  4063. }
  4064. return y;
  4065. }
  4066. BigInteger.prototype.modPow = function (exp, mod) {
  4067. exp = parseValue(exp);
  4068. mod = parseValue(mod);
  4069. if (mod.isZero()) throw new Error("Cannot take modPow with modulus 0");
  4070. var r = Integer[1],
  4071. base = this.mod(mod);
  4072. if (exp.isNegative()) {
  4073. exp = exp.multiply(Integer[-1]);
  4074. base = base.modInv(mod);
  4075. }
  4076. while (exp.isPositive()) {
  4077. if (base.isZero()) return Integer[0];
  4078. if (exp.isOdd()) r = r.multiply(base).mod(mod);
  4079. exp = exp.divide(2);
  4080. base = base.square().mod(mod);
  4081. }
  4082. return r;
  4083. };
  4084. NativeBigInt.prototype.modPow = SmallInteger.prototype.modPow = BigInteger.prototype.modPow;
  4085. function compareAbs(a, b) {
  4086. if (a.length !== b.length) {
  4087. return a.length > b.length ? 1 : -1;
  4088. }
  4089. for (var i = a.length - 1; i >= 0; i--) {
  4090. if (a[i] !== b[i]) return a[i] > b[i] ? 1 : -1;
  4091. }
  4092. return 0;
  4093. }
  4094. BigInteger.prototype.compareAbs = function (v) {
  4095. var n = parseValue(v),
  4096. a = this.value,
  4097. b = n.value;
  4098. if (n.isSmall) return 1;
  4099. return compareAbs(a, b);
  4100. };
  4101. SmallInteger.prototype.compareAbs = function (v) {
  4102. var n = parseValue(v),
  4103. a = Math.abs(this.value),
  4104. b = n.value;
  4105. if (n.isSmall) {
  4106. b = Math.abs(b);
  4107. return a === b ? 0 : a > b ? 1 : -1;
  4108. }
  4109. return -1;
  4110. };
  4111. NativeBigInt.prototype.compareAbs = function (v) {
  4112. var a = this.value;
  4113. var b = parseValue(v).value;
  4114. a = a >= 0 ? a : -a;
  4115. b = b >= 0 ? b : -b;
  4116. return a === b ? 0 : a > b ? 1 : -1;
  4117. }
  4118. BigInteger.prototype.compare = function (v) {
  4119. // See discussion about comparison with Infinity:
  4120. // https://github.com/peterolson/BigInteger.js/issues/61
  4121. if (v === Infinity) {
  4122. return -1;
  4123. }
  4124. if (v === -Infinity) {
  4125. return 1;
  4126. }
  4127. var n = parseValue(v),
  4128. a = this.value,
  4129. b = n.value;
  4130. if (this.sign !== n.sign) {
  4131. return n.sign ? 1 : -1;
  4132. }
  4133. if (n.isSmall) {
  4134. return this.sign ? -1 : 1;
  4135. }
  4136. return compareAbs(a, b) * (this.sign ? -1 : 1);
  4137. };
  4138. BigInteger.prototype.compareTo = BigInteger.prototype.compare;
  4139. SmallInteger.prototype.compare = function (v) {
  4140. if (v === Infinity) {
  4141. return -1;
  4142. }
  4143. if (v === -Infinity) {
  4144. return 1;
  4145. }
  4146. var n = parseValue(v),
  4147. a = this.value,
  4148. b = n.value;
  4149. if (n.isSmall) {
  4150. return a == b ? 0 : a > b ? 1 : -1;
  4151. }
  4152. if (a < 0 !== n.sign) {
  4153. return a < 0 ? -1 : 1;
  4154. }
  4155. return a < 0 ? 1 : -1;
  4156. };
  4157. SmallInteger.prototype.compareTo = SmallInteger.prototype.compare;
  4158. NativeBigInt.prototype.compare = function (v) {
  4159. if (v === Infinity) {
  4160. return -1;
  4161. }
  4162. if (v === -Infinity) {
  4163. return 1;
  4164. }
  4165. var a = this.value;
  4166. var b = parseValue(v).value;
  4167. return a === b ? 0 : a > b ? 1 : -1;
  4168. }
  4169. NativeBigInt.prototype.compareTo = NativeBigInt.prototype.compare;
  4170. BigInteger.prototype.equals = function (v) {
  4171. return this.compare(v) === 0;
  4172. };
  4173. NativeBigInt.prototype.eq = NativeBigInt.prototype.equals = SmallInteger.prototype.eq = SmallInteger.prototype.equals = BigInteger.prototype.eq = BigInteger.prototype.equals;
  4174. BigInteger.prototype.notEquals = function (v) {
  4175. return this.compare(v) !== 0;
  4176. };
  4177. NativeBigInt.prototype.neq = NativeBigInt.prototype.notEquals = SmallInteger.prototype.neq = SmallInteger.prototype.notEquals = BigInteger.prototype.neq = BigInteger.prototype.notEquals;
  4178. BigInteger.prototype.greater = function (v) {
  4179. return this.compare(v) > 0;
  4180. };
  4181. NativeBigInt.prototype.gt = NativeBigInt.prototype.greater = SmallInteger.prototype.gt = SmallInteger.prototype.greater = BigInteger.prototype.gt = BigInteger.prototype.greater;
  4182. BigInteger.prototype.lesser = function (v) {
  4183. return this.compare(v) < 0;
  4184. };
  4185. NativeBigInt.prototype.lt = NativeBigInt.prototype.lesser = SmallInteger.prototype.lt = SmallInteger.prototype.lesser = BigInteger.prototype.lt = BigInteger.prototype.lesser;
  4186. BigInteger.prototype.greaterOrEquals = function (v) {
  4187. return this.compare(v) >= 0;
  4188. };
  4189. NativeBigInt.prototype.geq = NativeBigInt.prototype.greaterOrEquals = SmallInteger.prototype.geq = SmallInteger.prototype.greaterOrEquals = BigInteger.prototype.geq = BigInteger.prototype.greaterOrEquals;
  4190. BigInteger.prototype.lesserOrEquals = function (v) {
  4191. return this.compare(v) <= 0;
  4192. };
  4193. NativeBigInt.prototype.leq = NativeBigInt.prototype.lesserOrEquals = SmallInteger.prototype.leq = SmallInteger.prototype.lesserOrEquals = BigInteger.prototype.leq = BigInteger.prototype.lesserOrEquals;
  4194. BigInteger.prototype.isEven = function () {
  4195. return (this.value[0] & 1) === 0;
  4196. };
  4197. SmallInteger.prototype.isEven = function () {
  4198. return (this.value & 1) === 0;
  4199. };
  4200. NativeBigInt.prototype.isEven = function () {
  4201. return (this.value & BigInt(1)) === BigInt(0);
  4202. }
  4203. BigInteger.prototype.isOdd = function () {
  4204. return (this.value[0] & 1) === 1;
  4205. };
  4206. SmallInteger.prototype.isOdd = function () {
  4207. return (this.value & 1) === 1;
  4208. };
  4209. NativeBigInt.prototype.isOdd = function () {
  4210. return (this.value & BigInt(1)) === BigInt(1);
  4211. }
  4212. BigInteger.prototype.isPositive = function () {
  4213. return !this.sign;
  4214. };
  4215. SmallInteger.prototype.isPositive = function () {
  4216. return this.value > 0;
  4217. };
  4218. NativeBigInt.prototype.isPositive = SmallInteger.prototype.isPositive;
  4219. BigInteger.prototype.isNegative = function () {
  4220. return this.sign;
  4221. };
  4222. SmallInteger.prototype.isNegative = function () {
  4223. return this.value < 0;
  4224. };
  4225. NativeBigInt.prototype.isNegative = SmallInteger.prototype.isNegative;
  4226. BigInteger.prototype.isUnit = function () {
  4227. return false;
  4228. };
  4229. SmallInteger.prototype.isUnit = function () {
  4230. return Math.abs(this.value) === 1;
  4231. };
  4232. NativeBigInt.prototype.isUnit = function () {
  4233. return this.abs().value === BigInt(1);
  4234. }
  4235. BigInteger.prototype.isZero = function () {
  4236. return false;
  4237. };
  4238. SmallInteger.prototype.isZero = function () {
  4239. return this.value === 0;
  4240. };
  4241. NativeBigInt.prototype.isZero = function () {
  4242. return this.value === BigInt(0);
  4243. }
  4244. BigInteger.prototype.isDivisibleBy = function (v) {
  4245. var n = parseValue(v);
  4246. if (n.isZero()) return false;
  4247. if (n.isUnit()) return true;
  4248. if (n.compareAbs(2) === 0) return this.isEven();
  4249. return this.mod(n).isZero();
  4250. };
  4251. NativeBigInt.prototype.isDivisibleBy = SmallInteger.prototype.isDivisibleBy = BigInteger.prototype.isDivisibleBy;
  4252. function isBasicPrime(v) {
  4253. var n = v.abs();
  4254. if (n.isUnit()) return false;
  4255. if (n.equals(2) || n.equals(3) || n.equals(5)) return true;
  4256. if (n.isEven() || n.isDivisibleBy(3) || n.isDivisibleBy(5)) return false;
  4257. if (n.lesser(49)) return true;
  4258. // we don't know if it's prime: let the other functions figure it out
  4259. }
  4260. function millerRabinTest(n, a) {
  4261. var nPrev = n.prev(),
  4262. b = nPrev,
  4263. r = 0,
  4264. d, t, i, x;
  4265. while (b.isEven()) b = b.divide(2), r++;
  4266. next: for (i = 0; i < a.length; i++) {
  4267. if (n.lesser(a[i])) continue;
  4268. x = bigInt(a[i]).modPow(b, n);
  4269. if (x.isUnit() || x.equals(nPrev)) continue;
  4270. for (d = r - 1; d != 0; d--) {
  4271. x = x.square().mod(n);
  4272. if (x.isUnit()) return false;
  4273. if (x.equals(nPrev)) continue next;
  4274. }
  4275. return false;
  4276. }
  4277. return true;
  4278. }
  4279. // Set "strict" to true to force GRH-supported lower bound of 2*log(N)^2
  4280. BigInteger.prototype.isPrime = function (strict) {
  4281. var isPrime = isBasicPrime(this);
  4282. if (isPrime !== undefined) return isPrime;
  4283. var n = this.abs();
  4284. var bits = n.bitLength();
  4285. if (bits <= 64)
  4286. return millerRabinTest(n, [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]);
  4287. var logN = Math.log(2) * bits.toJSNumber();
  4288. var t = Math.ceil((strict === true) ? (2 * Math.pow(logN, 2)) : logN);
  4289. for (var a = [], i = 0; i < t; i++) {
  4290. a.push(bigInt(i + 2));
  4291. }
  4292. return millerRabinTest(n, a);
  4293. };
  4294. NativeBigInt.prototype.isPrime = SmallInteger.prototype.isPrime = BigInteger.prototype.isPrime;
  4295. BigInteger.prototype.isProbablePrime = function (iterations, rng) {
  4296. var isPrime = isBasicPrime(this);
  4297. if (isPrime !== undefined) return isPrime;
  4298. var n = this.abs();
  4299. var t = iterations === undefined ? 5 : iterations;
  4300. for (var a = [], i = 0; i < t; i++) {
  4301. a.push(bigInt.randBetween(2, n.minus(2), rng));
  4302. }
  4303. return millerRabinTest(n, a);
  4304. };
  4305. NativeBigInt.prototype.isProbablePrime = SmallInteger.prototype.isProbablePrime = BigInteger.prototype.isProbablePrime;
  4306. BigInteger.prototype.modInv = function (n) {
  4307. var t = bigInt.zero, newT = bigInt.one, r = parseValue(n), newR = this.abs(), q, lastT, lastR;
  4308. while (!newR.isZero()) {
  4309. q = r.divide(newR);
  4310. lastT = t;
  4311. lastR = r;
  4312. t = newT;
  4313. r = newR;
  4314. newT = lastT.subtract(q.multiply(newT));
  4315. newR = lastR.subtract(q.multiply(newR));
  4316. }
  4317. if (!r.isUnit()) throw new Error(this.toString() + " and " + n.toString() + " are not co-prime");
  4318. if (t.compare(0) === -1) {
  4319. t = t.add(n);
  4320. }
  4321. if (this.isNegative()) {
  4322. return t.negate();
  4323. }
  4324. return t;
  4325. };
  4326. NativeBigInt.prototype.modInv = SmallInteger.prototype.modInv = BigInteger.prototype.modInv;
  4327. BigInteger.prototype.next = function () {
  4328. var value = this.value;
  4329. if (this.sign) {
  4330. return subtractSmall(value, 1, this.sign);
  4331. }
  4332. return new BigInteger(addSmall(value, 1), this.sign);
  4333. };
  4334. SmallInteger.prototype.next = function () {
  4335. var value = this.value;
  4336. if (value + 1 < MAX_INT) return new SmallInteger(value + 1);
  4337. return new BigInteger(MAX_INT_ARR, false);
  4338. };
  4339. NativeBigInt.prototype.next = function () {
  4340. return new NativeBigInt(this.value + BigInt(1));
  4341. }
  4342. BigInteger.prototype.prev = function () {
  4343. var value = this.value;
  4344. if (this.sign) {
  4345. return new BigInteger(addSmall(value, 1), true);
  4346. }
  4347. return subtractSmall(value, 1, this.sign);
  4348. };
  4349. SmallInteger.prototype.prev = function () {
  4350. var value = this.value;
  4351. if (value - 1 > -MAX_INT) return new SmallInteger(value - 1);
  4352. return new BigInteger(MAX_INT_ARR, true);
  4353. };
  4354. NativeBigInt.prototype.prev = function () {
  4355. return new NativeBigInt(this.value - BigInt(1));
  4356. }
  4357. var powersOfTwo = [1];
  4358. while (2 * powersOfTwo[powersOfTwo.length - 1] <= BASE) powersOfTwo.push(2 * powersOfTwo[powersOfTwo.length - 1]);
  4359. var powers2Length = powersOfTwo.length, highestPower2 = powersOfTwo[powers2Length - 1];
  4360. function shift_isSmall(n) {
  4361. return Math.abs(n) <= BASE;
  4362. }
  4363. BigInteger.prototype.shiftLeft = function (v) {
  4364. var n = parseValue(v).toJSNumber();
  4365. if (!shift_isSmall(n)) {
  4366. throw new Error(String(n) + " is too large for shifting.");
  4367. }
  4368. if (n < 0) return this.shiftRight(-n);
  4369. var result = this;
  4370. if (result.isZero()) return result;
  4371. while (n >= powers2Length) {
  4372. result = result.multiply(highestPower2);
  4373. n -= powers2Length - 1;
  4374. }
  4375. return result.multiply(powersOfTwo[n]);
  4376. };
  4377. NativeBigInt.prototype.shiftLeft = SmallInteger.prototype.shiftLeft = BigInteger.prototype.shiftLeft;
  4378. BigInteger.prototype.shiftRight = function (v) {
  4379. var remQuo;
  4380. var n = parseValue(v).toJSNumber();
  4381. if (!shift_isSmall(n)) {
  4382. throw new Error(String(n) + " is too large for shifting.");
  4383. }
  4384. if (n < 0) return this.shiftLeft(-n);
  4385. var result = this;
  4386. while (n >= powers2Length) {
  4387. if (result.isZero() || (result.isNegative() && result.isUnit())) return result;
  4388. remQuo = divModAny(result, highestPower2);
  4389. result = remQuo[1].isNegative() ? remQuo[0].prev() : remQuo[0];
  4390. n -= powers2Length - 1;
  4391. }
  4392. remQuo = divModAny(result, powersOfTwo[n]);
  4393. return remQuo[1].isNegative() ? remQuo[0].prev() : remQuo[0];
  4394. };
  4395. NativeBigInt.prototype.shiftRight = SmallInteger.prototype.shiftRight = BigInteger.prototype.shiftRight;
  4396. function bitwise(x, y, fn) {
  4397. y = parseValue(y);
  4398. var xSign = x.isNegative(), ySign = y.isNegative();
  4399. var xRem = xSign ? x.not() : x,
  4400. yRem = ySign ? y.not() : y;
  4401. var xDigit = 0, yDigit = 0;
  4402. var xDivMod = null, yDivMod = null;
  4403. var result = [];
  4404. while (!xRem.isZero() || !yRem.isZero()) {
  4405. xDivMod = divModAny(xRem, highestPower2);
  4406. xDigit = xDivMod[1].toJSNumber();
  4407. if (xSign) {
  4408. xDigit = highestPower2 - 1 - xDigit; // two's complement for negative numbers
  4409. }
  4410. yDivMod = divModAny(yRem, highestPower2);
  4411. yDigit = yDivMod[1].toJSNumber();
  4412. if (ySign) {
  4413. yDigit = highestPower2 - 1 - yDigit; // two's complement for negative numbers
  4414. }
  4415. xRem = xDivMod[0];
  4416. yRem = yDivMod[0];
  4417. result.push(fn(xDigit, yDigit));
  4418. }
  4419. var sum = fn(xSign ? 1 : 0, ySign ? 1 : 0) !== 0 ? bigInt(-1) : bigInt(0);
  4420. for (var i = result.length - 1; i >= 0; i -= 1) {
  4421. sum = sum.multiply(highestPower2).add(bigInt(result[i]));
  4422. }
  4423. return sum;
  4424. }
  4425. BigInteger.prototype.not = function () {
  4426. return this.negate().prev();
  4427. };
  4428. NativeBigInt.prototype.not = SmallInteger.prototype.not = BigInteger.prototype.not;
  4429. BigInteger.prototype.and = function (n) {
  4430. return bitwise(this, n, function (a, b) { return a & b; });
  4431. };
  4432. NativeBigInt.prototype.and = SmallInteger.prototype.and = BigInteger.prototype.and;
  4433. BigInteger.prototype.or = function (n) {
  4434. return bitwise(this, n, function (a, b) { return a | b; });
  4435. };
  4436. NativeBigInt.prototype.or = SmallInteger.prototype.or = BigInteger.prototype.or;
  4437. BigInteger.prototype.xor = function (n) {
  4438. return bitwise(this, n, function (a, b) { return a ^ b; });
  4439. };
  4440. NativeBigInt.prototype.xor = SmallInteger.prototype.xor = BigInteger.prototype.xor;
  4441. var LOBMASK_I = 1 << 30, LOBMASK_BI = (BASE & -BASE) * (BASE & -BASE) | LOBMASK_I;
  4442. function roughLOB(n) { // get lowestOneBit (rough)
  4443. // SmallInteger: return Min(lowestOneBit(n), 1 << 30)
  4444. // BigInteger: return Min(lowestOneBit(n), 1 << 14) [BASE=1e7]
  4445. var v = n.value,
  4446. x = typeof v === "number" ? v | LOBMASK_I :
  4447. typeof v === "bigint" ? v | BigInt(LOBMASK_I) :
  4448. v[0] + v[1] * BASE | LOBMASK_BI;
  4449. return x & -x;
  4450. }
  4451. function integerLogarithm(value, base) {
  4452. if (base.compareTo(value) <= 0) {
  4453. var tmp = integerLogarithm(value, base.square(base));
  4454. var p = tmp.p;
  4455. var e = tmp.e;
  4456. var t = p.multiply(base);
  4457. return t.compareTo(value) <= 0 ? { p: t, e: e * 2 + 1 } : { p: p, e: e * 2 };
  4458. }
  4459. return { p: bigInt(1), e: 0 };
  4460. }
  4461. BigInteger.prototype.bitLength = function () {
  4462. var n = this;
  4463. if (n.compareTo(bigInt(0)) < 0) {
  4464. n = n.negate().subtract(bigInt(1));
  4465. }
  4466. if (n.compareTo(bigInt(0)) === 0) {
  4467. return bigInt(0);
  4468. }
  4469. return bigInt(integerLogarithm(n, bigInt(2)).e).add(bigInt(1));
  4470. }
  4471. NativeBigInt.prototype.bitLength = SmallInteger.prototype.bitLength = BigInteger.prototype.bitLength;
  4472. function max(a, b) {
  4473. a = parseValue(a);
  4474. b = parseValue(b);
  4475. return a.greater(b) ? a : b;
  4476. }
  4477. function min(a, b) {
  4478. a = parseValue(a);
  4479. b = parseValue(b);
  4480. return a.lesser(b) ? a : b;
  4481. }
  4482. function gcd(a, b) {
  4483. a = parseValue(a).abs();
  4484. b = parseValue(b).abs();
  4485. if (a.equals(b)) return a;
  4486. if (a.isZero()) return b;
  4487. if (b.isZero()) return a;
  4488. var c = Integer[1], d, t;
  4489. while (a.isEven() && b.isEven()) {
  4490. d = min(roughLOB(a), roughLOB(b));
  4491. a = a.divide(d);
  4492. b = b.divide(d);
  4493. c = c.multiply(d);
  4494. }
  4495. while (a.isEven()) {
  4496. a = a.divide(roughLOB(a));
  4497. }
  4498. do {
  4499. while (b.isEven()) {
  4500. b = b.divide(roughLOB(b));
  4501. }
  4502. if (a.greater(b)) {
  4503. t = b; b = a; a = t;
  4504. }
  4505. b = b.subtract(a);
  4506. } while (!b.isZero());
  4507. return c.isUnit() ? a : a.multiply(c);
  4508. }
  4509. function lcm(a, b) {
  4510. a = parseValue(a).abs();
  4511. b = parseValue(b).abs();
  4512. return a.divide(gcd(a, b)).multiply(b);
  4513. }
  4514. function randBetween(a, b, rng) {
  4515. a = parseValue(a);
  4516. b = parseValue(b);
  4517. var usedRNG = rng || Math.random;
  4518. var low = min(a, b), high = max(a, b);
  4519. var range = high.subtract(low).add(1);
  4520. if (range.isSmall) return low.add(Math.floor(usedRNG() * range));
  4521. var digits = toBase(range, BASE).value;
  4522. var result = [], restricted = true;
  4523. for (var i = 0; i < digits.length; i++) {
  4524. var top = restricted ? digits[i] + (i + 1 < digits.length ? digits[i + 1] / BASE : 0) : BASE;
  4525. var digit = truncate(usedRNG() * top);
  4526. result.push(digit);
  4527. if (digit < digits[i]) restricted = false;
  4528. }
  4529. return low.add(Integer.fromArray(result, BASE, false));
  4530. }
  4531. var parseBase = function (text, base, alphabet, caseSensitive) {
  4532. alphabet = alphabet || DEFAULT_ALPHABET;
  4533. text = String(text);
  4534. if (!caseSensitive) {
  4535. text = text.toLowerCase();
  4536. alphabet = alphabet.toLowerCase();
  4537. }
  4538. var length = text.length;
  4539. var i;
  4540. var absBase = Math.abs(base);
  4541. var alphabetValues = {};
  4542. for (i = 0; i < alphabet.length; i++) {
  4543. alphabetValues[alphabet[i]] = i;
  4544. }
  4545. for (i = 0; i < length; i++) {
  4546. var c = text[i];
  4547. if (c === "-") continue;
  4548. if (c in alphabetValues) {
  4549. if (alphabetValues[c] >= absBase) {
  4550. if (c === "1" && absBase === 1) continue;
  4551. throw new Error(c + " is not a valid digit in base " + base + ".");
  4552. }
  4553. }
  4554. }
  4555. base = parseValue(base);
  4556. var digits = [];
  4557. var isNegative = text[0] === "-";
  4558. for (i = isNegative ? 1 : 0; i < text.length; i++) {
  4559. var c = text[i];
  4560. if (c in alphabetValues) digits.push(parseValue(alphabetValues[c]));
  4561. else if (c === "<") {
  4562. var start = i;
  4563. do { i++; } while (text[i] !== ">" && i < text.length);
  4564. digits.push(parseValue(text.slice(start + 1, i)));
  4565. }
  4566. else throw new Error(c + " is not a valid character");
  4567. }
  4568. return parseBaseFromArray(digits, base, isNegative);
  4569. };
  4570. function parseBaseFromArray(digits, base, isNegative) {
  4571. var val = Integer[0], pow = Integer[1], i;
  4572. for (i = digits.length - 1; i >= 0; i--) {
  4573. val = val.add(digits[i].times(pow));
  4574. pow = pow.times(base);
  4575. }
  4576. return isNegative ? val.negate() : val;
  4577. }
  4578. function stringify(digit, alphabet) {
  4579. alphabet = alphabet || DEFAULT_ALPHABET;
  4580. if (digit < alphabet.length) {
  4581. return alphabet[digit];
  4582. }
  4583. return "<" + digit + ">";
  4584. }
  4585. function toBase(n, base) {
  4586. base = bigInt(base);
  4587. if (base.isZero()) {
  4588. if (n.isZero()) return { value: [0], isNegative: false };
  4589. throw new Error("Cannot convert nonzero numbers to base 0.");
  4590. }
  4591. if (base.equals(-1)) {
  4592. if (n.isZero()) return { value: [0], isNegative: false };
  4593. if (n.isNegative())
  4594. return {
  4595. value: [].concat.apply([], Array.apply(null, Array(-n.toJSNumber()))
  4596. .map(Array.prototype.valueOf, [1, 0])
  4597. ),
  4598. isNegative: false
  4599. };
  4600. var arr = Array.apply(null, Array(n.toJSNumber() - 1))
  4601. .map(Array.prototype.valueOf, [0, 1]);
  4602. arr.unshift([1]);
  4603. return {
  4604. value: [].concat.apply([], arr),
  4605. isNegative: false
  4606. };
  4607. }
  4608. var neg = false;
  4609. if (n.isNegative() && base.isPositive()) {
  4610. neg = true;
  4611. n = n.abs();
  4612. }
  4613. if (base.isUnit()) {
  4614. if (n.isZero()) return { value: [0], isNegative: false };
  4615. return {
  4616. value: Array.apply(null, Array(n.toJSNumber()))
  4617. .map(Number.prototype.valueOf, 1),
  4618. isNegative: neg
  4619. };
  4620. }
  4621. var out = [];
  4622. var left = n, divmod;
  4623. while (left.isNegative() || left.compareAbs(base) >= 0) {
  4624. divmod = left.divmod(base);
  4625. left = divmod.quotient;
  4626. var digit = divmod.remainder;
  4627. if (digit.isNegative()) {
  4628. digit = base.minus(digit).abs();
  4629. left = left.next();
  4630. }
  4631. out.push(digit.toJSNumber());
  4632. }
  4633. out.push(left.toJSNumber());
  4634. return { value: out.reverse(), isNegative: neg };
  4635. }
  4636. function toBaseString(n, base, alphabet) {
  4637. var arr = toBase(n, base);
  4638. return (arr.isNegative ? "-" : "") + arr.value.map(function (x) {
  4639. return stringify(x, alphabet);
  4640. }).join('');
  4641. }
  4642. BigInteger.prototype.toArray = function (radix) {
  4643. return toBase(this, radix);
  4644. };
  4645. SmallInteger.prototype.toArray = function (radix) {
  4646. return toBase(this, radix);
  4647. };
  4648. NativeBigInt.prototype.toArray = function (radix) {
  4649. return toBase(this, radix);
  4650. };
  4651. BigInteger.prototype.toString = function (radix, alphabet) {
  4652. if (radix === undefined) radix = 10;
  4653. if (radix !== 10) return toBaseString(this, radix, alphabet);
  4654. var v = this.value, l = v.length, str = String(v[--l]), zeros = "0000000", digit;
  4655. while (--l >= 0) {
  4656. digit = String(v[l]);
  4657. str += zeros.slice(digit.length) + digit;
  4658. }
  4659. var sign = this.sign ? "-" : "";
  4660. return sign + str;
  4661. };
  4662. SmallInteger.prototype.toString = function (radix, alphabet) {
  4663. if (radix === undefined) radix = 10;
  4664. if (radix != 10) return toBaseString(this, radix, alphabet);
  4665. return String(this.value);
  4666. };
  4667. NativeBigInt.prototype.toString = SmallInteger.prototype.toString;
  4668. NativeBigInt.prototype.toJSON = BigInteger.prototype.toJSON = SmallInteger.prototype.toJSON = function () { return this.toString(); }
  4669. BigInteger.prototype.valueOf = function () {
  4670. return parseInt(this.toString(), 10);
  4671. };
  4672. BigInteger.prototype.toJSNumber = BigInteger.prototype.valueOf;
  4673. SmallInteger.prototype.valueOf = function () {
  4674. return this.value;
  4675. };
  4676. SmallInteger.prototype.toJSNumber = SmallInteger.prototype.valueOf;
  4677. NativeBigInt.prototype.valueOf = NativeBigInt.prototype.toJSNumber = function () {
  4678. return parseInt(this.toString(), 10);
  4679. }
  4680. function parseStringValue(v) {
  4681. if (isPrecise(+v)) {
  4682. var x = +v;
  4683. if (x === truncate(x))
  4684. return supportsNativeBigInt ? new NativeBigInt(BigInt(x)) : new SmallInteger(x);
  4685. throw new Error("Invalid integer: " + v);
  4686. }
  4687. var sign = v[0] === "-";
  4688. if (sign) v = v.slice(1);
  4689. var split = v.split(/e/i);
  4690. if (split.length > 2) throw new Error("Invalid integer: " + split.join("e"));
  4691. if (split.length === 2) {
  4692. var exp = split[1];
  4693. if (exp[0] === "+") exp = exp.slice(1);
  4694. exp = +exp;
  4695. if (exp !== truncate(exp) || !isPrecise(exp)) throw new Error("Invalid integer: " + exp + " is not a valid exponent.");
  4696. var text = split[0];
  4697. var decimalPlace = text.indexOf(".");
  4698. if (decimalPlace >= 0) {
  4699. exp -= text.length - decimalPlace - 1;
  4700. text = text.slice(0, decimalPlace) + text.slice(decimalPlace + 1);
  4701. }
  4702. if (exp < 0) throw new Error("Cannot include negative exponent part for integers");
  4703. text += (new Array(exp + 1)).join("0");
  4704. v = text;
  4705. }
  4706. var isValid = /^([0-9][0-9]*)$/.test(v);
  4707. if (!isValid) throw new Error("Invalid integer: " + v);
  4708. if (supportsNativeBigInt) {
  4709. return new NativeBigInt(BigInt(sign ? "-" + v : v));
  4710. }
  4711. var r = [], max = v.length, l = LOG_BASE, min = max - l;
  4712. while (max > 0) {
  4713. r.push(+v.slice(min, max));
  4714. min -= l;
  4715. if (min < 0) min = 0;
  4716. max -= l;
  4717. }
  4718. trim(r);
  4719. return new BigInteger(r, sign);
  4720. }
  4721. function parseNumberValue(v) {
  4722. if (supportsNativeBigInt) {
  4723. return new NativeBigInt(BigInt(v));
  4724. }
  4725. if (isPrecise(v)) {
  4726. if (v !== truncate(v)) throw new Error(v + " is not an integer.");
  4727. return new SmallInteger(v);
  4728. }
  4729. return parseStringValue(v.toString());
  4730. }
  4731. function parseValue(v) {
  4732. if (typeof v === "number") {
  4733. return parseNumberValue(v);
  4734. }
  4735. if (typeof v === "string") {
  4736. return parseStringValue(v);
  4737. }
  4738. if (typeof v === "bigint") {
  4739. return new NativeBigInt(v);
  4740. }
  4741. return v;
  4742. }
  4743. // Pre-define numbers in range [-999,999]
  4744. for (var i = 0; i < 1000; i++) {
  4745. Integer[i] = parseValue(i);
  4746. if (i > 0) Integer[-i] = parseValue(-i);
  4747. }
  4748. // Backwards compatibility
  4749. Integer.one = Integer[1];
  4750. Integer.zero = Integer[0];
  4751. Integer.minusOne = Integer[-1];
  4752. Integer.max = max;
  4753. Integer.min = min;
  4754. Integer.gcd = gcd;
  4755. Integer.lcm = lcm;
  4756. Integer.isInstance = function (x) { return x instanceof BigInteger || x instanceof SmallInteger || x instanceof NativeBigInt; };
  4757. Integer.randBetween = randBetween;
  4758. Integer.fromArray = function (digits, base, isNegative) {
  4759. return parseBaseFromArray(digits.map(parseValue), parseValue(base || 10), isNegative);
  4760. };
  4761. return Integer;
  4762. })();
  4763. // Node.js check
  4764. if ( true && module.hasOwnProperty("exports")) {
  4765. module.exports = bigInt;
  4766. }
  4767. //amd check
  4768. if (true) {
  4769. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () {
  4770. return bigInt;
  4771. }).call(exports, __webpack_require__, exports, module),
  4772. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  4773. }
  4774. /***/ }),
  4775. /***/ "../../node_modules/bignumber.js/bignumber.js":
  4776. /*!****************************************************!*\
  4777. !*** ../../node_modules/bignumber.js/bignumber.js ***!
  4778. \****************************************************/
  4779. /***/ (function(module, exports, __webpack_require__) {
  4780. var __WEBPACK_AMD_DEFINE_RESULT__;;(function (globalObject) {
  4781. 'use strict';
  4782. /*
  4783. * bignumber.js v9.1.1
  4784. * A JavaScript library for arbitrary-precision arithmetic.
  4785. * https://github.com/MikeMcl/bignumber.js
  4786. * Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com>
  4787. * MIT Licensed.
  4788. *
  4789. * BigNumber.prototype methods | BigNumber methods
  4790. * |
  4791. * absoluteValue abs | clone
  4792. * comparedTo | config set
  4793. * decimalPlaces dp | DECIMAL_PLACES
  4794. * dividedBy div | ROUNDING_MODE
  4795. * dividedToIntegerBy idiv | EXPONENTIAL_AT
  4796. * exponentiatedBy pow | RANGE
  4797. * integerValue | CRYPTO
  4798. * isEqualTo eq | MODULO_MODE
  4799. * isFinite | POW_PRECISION
  4800. * isGreaterThan gt | FORMAT
  4801. * isGreaterThanOrEqualTo gte | ALPHABET
  4802. * isInteger | isBigNumber
  4803. * isLessThan lt | maximum max
  4804. * isLessThanOrEqualTo lte | minimum min
  4805. * isNaN | random
  4806. * isNegative | sum
  4807. * isPositive |
  4808. * isZero |
  4809. * minus |
  4810. * modulo mod |
  4811. * multipliedBy times |
  4812. * negated |
  4813. * plus |
  4814. * precision sd |
  4815. * shiftedBy |
  4816. * squareRoot sqrt |
  4817. * toExponential |
  4818. * toFixed |
  4819. * toFormat |
  4820. * toFraction |
  4821. * toJSON |
  4822. * toNumber |
  4823. * toPrecision |
  4824. * toString |
  4825. * valueOf |
  4826. *
  4827. */
  4828. var BigNumber,
  4829. isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,
  4830. mathceil = Math.ceil,
  4831. mathfloor = Math.floor,
  4832. bignumberError = '[BigNumber Error] ',
  4833. tooManyDigits = bignumberError + 'Number primitive has more than 15 significant digits: ',
  4834. BASE = 1e14,
  4835. LOG_BASE = 14,
  4836. MAX_SAFE_INTEGER = 0x1fffffffffffff, // 2^53 - 1
  4837. // MAX_INT32 = 0x7fffffff, // 2^31 - 1
  4838. POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13],
  4839. SQRT_BASE = 1e7,
  4840. // EDITABLE
  4841. // The limit on the value of DECIMAL_PLACES, TO_EXP_NEG, TO_EXP_POS, MIN_EXP, MAX_EXP, and
  4842. // the arguments to toExponential, toFixed, toFormat, and toPrecision.
  4843. MAX = 1E9; // 0 to MAX_INT32
  4844. /*
  4845. * Create and return a BigNumber constructor.
  4846. */
  4847. function clone(configObject) {
  4848. var div, convertBase, parseNumeric,
  4849. P = BigNumber.prototype = { constructor: BigNumber, toString: null, valueOf: null },
  4850. ONE = new BigNumber(1),
  4851. //----------------------------- EDITABLE CONFIG DEFAULTS -------------------------------
  4852. // The default values below must be integers within the inclusive ranges stated.
  4853. // The values can also be changed at run-time using BigNumber.set.
  4854. // The maximum number of decimal places for operations involving division.
  4855. DECIMAL_PLACES = 20, // 0 to MAX
  4856. // The rounding mode used when rounding to the above decimal places, and when using
  4857. // toExponential, toFixed, toFormat and toPrecision, and round (default value).
  4858. // UP 0 Away from zero.
  4859. // DOWN 1 Towards zero.
  4860. // CEIL 2 Towards +Infinity.
  4861. // FLOOR 3 Towards -Infinity.
  4862. // HALF_UP 4 Towards nearest neighbour. If equidistant, up.
  4863. // HALF_DOWN 5 Towards nearest neighbour. If equidistant, down.
  4864. // HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour.
  4865. // HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity.
  4866. // HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
  4867. ROUNDING_MODE = 4, // 0 to 8
  4868. // EXPONENTIAL_AT : [TO_EXP_NEG , TO_EXP_POS]
  4869. // The exponent value at and beneath which toString returns exponential notation.
  4870. // Number type: -7
  4871. TO_EXP_NEG = -7, // 0 to -MAX
  4872. // The exponent value at and above which toString returns exponential notation.
  4873. // Number type: 21
  4874. TO_EXP_POS = 21, // 0 to MAX
  4875. // RANGE : [MIN_EXP, MAX_EXP]
  4876. // The minimum exponent value, beneath which underflow to zero occurs.
  4877. // Number type: -324 (5e-324)
  4878. MIN_EXP = -1e7, // -1 to -MAX
  4879. // The maximum exponent value, above which overflow to Infinity occurs.
  4880. // Number type: 308 (1.7976931348623157e+308)
  4881. // For MAX_EXP > 1e7, e.g. new BigNumber('1e100000000').plus(1) may be slow.
  4882. MAX_EXP = 1e7, // 1 to MAX
  4883. // Whether to use cryptographically-secure random number generation, if available.
  4884. CRYPTO = false, // true or false
  4885. // The modulo mode used when calculating the modulus: a mod n.
  4886. // The quotient (q = a / n) is calculated according to the corresponding rounding mode.
  4887. // The remainder (r) is calculated as: r = a - n * q.
  4888. //
  4889. // UP 0 The remainder is positive if the dividend is negative, else is negative.
  4890. // DOWN 1 The remainder has the same sign as the dividend.
  4891. // This modulo mode is commonly known as 'truncated division' and is
  4892. // equivalent to (a % n) in JavaScript.
  4893. // FLOOR 3 The remainder has the same sign as the divisor (Python %).
  4894. // HALF_EVEN 6 This modulo mode implements the IEEE 754 remainder function.
  4895. // EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)).
  4896. // The remainder is always positive.
  4897. //
  4898. // The truncated division, floored division, Euclidian division and IEEE 754 remainder
  4899. // modes are commonly used for the modulus operation.
  4900. // Although the other rounding modes can also be used, they may not give useful results.
  4901. MODULO_MODE = 1, // 0 to 9
  4902. // The maximum number of significant digits of the result of the exponentiatedBy operation.
  4903. // If POW_PRECISION is 0, there will be unlimited significant digits.
  4904. POW_PRECISION = 0, // 0 to MAX
  4905. // The format specification used by the BigNumber.prototype.toFormat method.
  4906. FORMAT = {
  4907. prefix: '',
  4908. groupSize: 3,
  4909. secondaryGroupSize: 0,
  4910. groupSeparator: ',',
  4911. decimalSeparator: '.',
  4912. fractionGroupSize: 0,
  4913. fractionGroupSeparator: '\xA0', // non-breaking space
  4914. suffix: ''
  4915. },
  4916. // The alphabet used for base conversion. It must be at least 2 characters long, with no '+',
  4917. // '-', '.', whitespace, or repeated character.
  4918. // '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_'
  4919. ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz',
  4920. alphabetHasNormalDecimalDigits = true;
  4921. //------------------------------------------------------------------------------------------
  4922. // CONSTRUCTOR
  4923. /*
  4924. * The BigNumber constructor and exported function.
  4925. * Create and return a new instance of a BigNumber object.
  4926. *
  4927. * v {number|string|BigNumber} A numeric value.
  4928. * [b] {number} The base of v. Integer, 2 to ALPHABET.length inclusive.
  4929. */
  4930. function BigNumber(v, b) {
  4931. var alphabet, c, caseChanged, e, i, isNum, len, str,
  4932. x = this;
  4933. // Enable constructor call without `new`.
  4934. if (!(x instanceof BigNumber)) return new BigNumber(v, b);
  4935. if (b == null) {
  4936. if (v && v._isBigNumber === true) {
  4937. x.s = v.s;
  4938. if (!v.c || v.e > MAX_EXP) {
  4939. x.c = x.e = null;
  4940. } else if (v.e < MIN_EXP) {
  4941. x.c = [x.e = 0];
  4942. } else {
  4943. x.e = v.e;
  4944. x.c = v.c.slice();
  4945. }
  4946. return;
  4947. }
  4948. if ((isNum = typeof v == 'number') && v * 0 == 0) {
  4949. // Use `1 / n` to handle minus zero also.
  4950. x.s = 1 / v < 0 ? (v = -v, -1) : 1;
  4951. // Fast path for integers, where n < 2147483648 (2**31).
  4952. if (v === ~~v) {
  4953. for (e = 0, i = v; i >= 10; i /= 10, e++);
  4954. if (e > MAX_EXP) {
  4955. x.c = x.e = null;
  4956. } else {
  4957. x.e = e;
  4958. x.c = [v];
  4959. }
  4960. return;
  4961. }
  4962. str = String(v);
  4963. } else {
  4964. if (!isNumeric.test(str = String(v))) return parseNumeric(x, str, isNum);
  4965. x.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1;
  4966. }
  4967. // Decimal point?
  4968. if ((e = str.indexOf('.')) > -1) str = str.replace('.', '');
  4969. // Exponential form?
  4970. if ((i = str.search(/e/i)) > 0) {
  4971. // Determine exponent.
  4972. if (e < 0) e = i;
  4973. e += +str.slice(i + 1);
  4974. str = str.substring(0, i);
  4975. } else if (e < 0) {
  4976. // Integer.
  4977. e = str.length;
  4978. }
  4979. } else {
  4980. // '[BigNumber Error] Base {not a primitive number|not an integer|out of range}: {b}'
  4981. intCheck(b, 2, ALPHABET.length, 'Base');
  4982. // Allow exponential notation to be used with base 10 argument, while
  4983. // also rounding to DECIMAL_PLACES as with other bases.
  4984. if (b == 10 && alphabetHasNormalDecimalDigits) {
  4985. x = new BigNumber(v);
  4986. return round(x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE);
  4987. }
  4988. str = String(v);
  4989. if (isNum = typeof v == 'number') {
  4990. // Avoid potential interpretation of Infinity and NaN as base 44+ values.
  4991. if (v * 0 != 0) return parseNumeric(x, str, isNum, b);
  4992. x.s = 1 / v < 0 ? (str = str.slice(1), -1) : 1;
  4993. // '[BigNumber Error] Number primitive has more than 15 significant digits: {n}'
  4994. if (BigNumber.DEBUG && str.replace(/^0\.0*|\./, '').length > 15) {
  4995. throw Error
  4996. (tooManyDigits + v);
  4997. }
  4998. } else {
  4999. x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;
  5000. }
  5001. alphabet = ALPHABET.slice(0, b);
  5002. e = i = 0;
  5003. // Check that str is a valid base b number.
  5004. // Don't use RegExp, so alphabet can contain special characters.
  5005. for (len = str.length; i < len; i++) {
  5006. if (alphabet.indexOf(c = str.charAt(i)) < 0) {
  5007. if (c == '.') {
  5008. // If '.' is not the first character and it has not be found before.
  5009. if (i > e) {
  5010. e = len;
  5011. continue;
  5012. }
  5013. } else if (!caseChanged) {
  5014. // Allow e.g. hexadecimal 'FF' as well as 'ff'.
  5015. if (str == str.toUpperCase() && (str = str.toLowerCase()) ||
  5016. str == str.toLowerCase() && (str = str.toUpperCase())) {
  5017. caseChanged = true;
  5018. i = -1;
  5019. e = 0;
  5020. continue;
  5021. }
  5022. }
  5023. return parseNumeric(x, String(v), isNum, b);
  5024. }
  5025. }
  5026. // Prevent later check for length on converted number.
  5027. isNum = false;
  5028. str = convertBase(str, b, 10, x.s);
  5029. // Decimal point?
  5030. if ((e = str.indexOf('.')) > -1) str = str.replace('.', '');
  5031. else e = str.length;
  5032. }
  5033. // Determine leading zeros.
  5034. for (i = 0; str.charCodeAt(i) === 48; i++);
  5035. // Determine trailing zeros.
  5036. for (len = str.length; str.charCodeAt(--len) === 48;);
  5037. if (str = str.slice(i, ++len)) {
  5038. len -= i;
  5039. // '[BigNumber Error] Number primitive has more than 15 significant digits: {n}'
  5040. if (isNum && BigNumber.DEBUG &&
  5041. len > 15 && (v > MAX_SAFE_INTEGER || v !== mathfloor(v))) {
  5042. throw Error
  5043. (tooManyDigits + (x.s * v));
  5044. }
  5045. // Overflow?
  5046. if ((e = e - i - 1) > MAX_EXP) {
  5047. // Infinity.
  5048. x.c = x.e = null;
  5049. // Underflow?
  5050. } else if (e < MIN_EXP) {
  5051. // Zero.
  5052. x.c = [x.e = 0];
  5053. } else {
  5054. x.e = e;
  5055. x.c = [];
  5056. // Transform base
  5057. // e is the base 10 exponent.
  5058. // i is where to slice str to get the first element of the coefficient array.
  5059. i = (e + 1) % LOG_BASE;
  5060. if (e < 0) i += LOG_BASE; // i < 1
  5061. if (i < len) {
  5062. if (i) x.c.push(+str.slice(0, i));
  5063. for (len -= LOG_BASE; i < len;) {
  5064. x.c.push(+str.slice(i, i += LOG_BASE));
  5065. }
  5066. i = LOG_BASE - (str = str.slice(i)).length;
  5067. } else {
  5068. i -= len;
  5069. }
  5070. for (; i--; str += '0');
  5071. x.c.push(+str);
  5072. }
  5073. } else {
  5074. // Zero.
  5075. x.c = [x.e = 0];
  5076. }
  5077. }
  5078. // CONSTRUCTOR PROPERTIES
  5079. BigNumber.clone = clone;
  5080. BigNumber.ROUND_UP = 0;
  5081. BigNumber.ROUND_DOWN = 1;
  5082. BigNumber.ROUND_CEIL = 2;
  5083. BigNumber.ROUND_FLOOR = 3;
  5084. BigNumber.ROUND_HALF_UP = 4;
  5085. BigNumber.ROUND_HALF_DOWN = 5;
  5086. BigNumber.ROUND_HALF_EVEN = 6;
  5087. BigNumber.ROUND_HALF_CEIL = 7;
  5088. BigNumber.ROUND_HALF_FLOOR = 8;
  5089. BigNumber.EUCLID = 9;
  5090. /*
  5091. * Configure infrequently-changing library-wide settings.
  5092. *
  5093. * Accept an object with the following optional properties (if the value of a property is
  5094. * a number, it must be an integer within the inclusive range stated):
  5095. *
  5096. * DECIMAL_PLACES {number} 0 to MAX
  5097. * ROUNDING_MODE {number} 0 to 8
  5098. * EXPONENTIAL_AT {number|number[]} -MAX to MAX or [-MAX to 0, 0 to MAX]
  5099. * RANGE {number|number[]} -MAX to MAX (not zero) or [-MAX to -1, 1 to MAX]
  5100. * CRYPTO {boolean} true or false
  5101. * MODULO_MODE {number} 0 to 9
  5102. * POW_PRECISION {number} 0 to MAX
  5103. * ALPHABET {string} A string of two or more unique characters which does
  5104. * not contain '.'.
  5105. * FORMAT {object} An object with some of the following properties:
  5106. * prefix {string}
  5107. * groupSize {number}
  5108. * secondaryGroupSize {number}
  5109. * groupSeparator {string}
  5110. * decimalSeparator {string}
  5111. * fractionGroupSize {number}
  5112. * fractionGroupSeparator {string}
  5113. * suffix {string}
  5114. *
  5115. * (The values assigned to the above FORMAT object properties are not checked for validity.)
  5116. *
  5117. * E.g.
  5118. * BigNumber.config({ DECIMAL_PLACES : 20, ROUNDING_MODE : 4 })
  5119. *
  5120. * Ignore properties/parameters set to null or undefined, except for ALPHABET.
  5121. *
  5122. * Return an object with the properties current values.
  5123. */
  5124. BigNumber.config = BigNumber.set = function (obj) {
  5125. var p, v;
  5126. if (obj != null) {
  5127. if (typeof obj == 'object') {
  5128. // DECIMAL_PLACES {number} Integer, 0 to MAX inclusive.
  5129. // '[BigNumber Error] DECIMAL_PLACES {not a primitive number|not an integer|out of range}: {v}'
  5130. if (obj.hasOwnProperty(p = 'DECIMAL_PLACES')) {
  5131. v = obj[p];
  5132. intCheck(v, 0, MAX, p);
  5133. DECIMAL_PLACES = v;
  5134. }
  5135. // ROUNDING_MODE {number} Integer, 0 to 8 inclusive.
  5136. // '[BigNumber Error] ROUNDING_MODE {not a primitive number|not an integer|out of range}: {v}'
  5137. if (obj.hasOwnProperty(p = 'ROUNDING_MODE')) {
  5138. v = obj[p];
  5139. intCheck(v, 0, 8, p);
  5140. ROUNDING_MODE = v;
  5141. }
  5142. // EXPONENTIAL_AT {number|number[]}
  5143. // Integer, -MAX to MAX inclusive or
  5144. // [integer -MAX to 0 inclusive, 0 to MAX inclusive].
  5145. // '[BigNumber Error] EXPONENTIAL_AT {not a primitive number|not an integer|out of range}: {v}'
  5146. if (obj.hasOwnProperty(p = 'EXPONENTIAL_AT')) {
  5147. v = obj[p];
  5148. if (v && v.pop) {
  5149. intCheck(v[0], -MAX, 0, p);
  5150. intCheck(v[1], 0, MAX, p);
  5151. TO_EXP_NEG = v[0];
  5152. TO_EXP_POS = v[1];
  5153. } else {
  5154. intCheck(v, -MAX, MAX, p);
  5155. TO_EXP_NEG = -(TO_EXP_POS = v < 0 ? -v : v);
  5156. }
  5157. }
  5158. // RANGE {number|number[]} Non-zero integer, -MAX to MAX inclusive or
  5159. // [integer -MAX to -1 inclusive, integer 1 to MAX inclusive].
  5160. // '[BigNumber Error] RANGE {not a primitive number|not an integer|out of range|cannot be zero}: {v}'
  5161. if (obj.hasOwnProperty(p = 'RANGE')) {
  5162. v = obj[p];
  5163. if (v && v.pop) {
  5164. intCheck(v[0], -MAX, -1, p);
  5165. intCheck(v[1], 1, MAX, p);
  5166. MIN_EXP = v[0];
  5167. MAX_EXP = v[1];
  5168. } else {
  5169. intCheck(v, -MAX, MAX, p);
  5170. if (v) {
  5171. MIN_EXP = -(MAX_EXP = v < 0 ? -v : v);
  5172. } else {
  5173. throw Error
  5174. (bignumberError + p + ' cannot be zero: ' + v);
  5175. }
  5176. }
  5177. }
  5178. // CRYPTO {boolean} true or false.
  5179. // '[BigNumber Error] CRYPTO not true or false: {v}'
  5180. // '[BigNumber Error] crypto unavailable'
  5181. if (obj.hasOwnProperty(p = 'CRYPTO')) {
  5182. v = obj[p];
  5183. if (v === !!v) {
  5184. if (v) {
  5185. if (typeof crypto != 'undefined' && crypto &&
  5186. (crypto.getRandomValues || crypto.randomBytes)) {
  5187. CRYPTO = v;
  5188. } else {
  5189. CRYPTO = !v;
  5190. throw Error
  5191. (bignumberError + 'crypto unavailable');
  5192. }
  5193. } else {
  5194. CRYPTO = v;
  5195. }
  5196. } else {
  5197. throw Error
  5198. (bignumberError + p + ' not true or false: ' + v);
  5199. }
  5200. }
  5201. // MODULO_MODE {number} Integer, 0 to 9 inclusive.
  5202. // '[BigNumber Error] MODULO_MODE {not a primitive number|not an integer|out of range}: {v}'
  5203. if (obj.hasOwnProperty(p = 'MODULO_MODE')) {
  5204. v = obj[p];
  5205. intCheck(v, 0, 9, p);
  5206. MODULO_MODE = v;
  5207. }
  5208. // POW_PRECISION {number} Integer, 0 to MAX inclusive.
  5209. // '[BigNumber Error] POW_PRECISION {not a primitive number|not an integer|out of range}: {v}'
  5210. if (obj.hasOwnProperty(p = 'POW_PRECISION')) {
  5211. v = obj[p];
  5212. intCheck(v, 0, MAX, p);
  5213. POW_PRECISION = v;
  5214. }
  5215. // FORMAT {object}
  5216. // '[BigNumber Error] FORMAT not an object: {v}'
  5217. if (obj.hasOwnProperty(p = 'FORMAT')) {
  5218. v = obj[p];
  5219. if (typeof v == 'object') FORMAT = v;
  5220. else throw Error
  5221. (bignumberError + p + ' not an object: ' + v);
  5222. }
  5223. // ALPHABET {string}
  5224. // '[BigNumber Error] ALPHABET invalid: {v}'
  5225. if (obj.hasOwnProperty(p = 'ALPHABET')) {
  5226. v = obj[p];
  5227. // Disallow if less than two characters,
  5228. // or if it contains '+', '-', '.', whitespace, or a repeated character.
  5229. if (typeof v == 'string' && !/^.?$|[+\-.\s]|(.).*\1/.test(v)) {
  5230. alphabetHasNormalDecimalDigits = v.slice(0, 10) == '0123456789';
  5231. ALPHABET = v;
  5232. } else {
  5233. throw Error
  5234. (bignumberError + p + ' invalid: ' + v);
  5235. }
  5236. }
  5237. } else {
  5238. // '[BigNumber Error] Object expected: {v}'
  5239. throw Error
  5240. (bignumberError + 'Object expected: ' + obj);
  5241. }
  5242. }
  5243. return {
  5244. DECIMAL_PLACES: DECIMAL_PLACES,
  5245. ROUNDING_MODE: ROUNDING_MODE,
  5246. EXPONENTIAL_AT: [TO_EXP_NEG, TO_EXP_POS],
  5247. RANGE: [MIN_EXP, MAX_EXP],
  5248. CRYPTO: CRYPTO,
  5249. MODULO_MODE: MODULO_MODE,
  5250. POW_PRECISION: POW_PRECISION,
  5251. FORMAT: FORMAT,
  5252. ALPHABET: ALPHABET
  5253. };
  5254. };
  5255. /*
  5256. * Return true if v is a BigNumber instance, otherwise return false.
  5257. *
  5258. * If BigNumber.DEBUG is true, throw if a BigNumber instance is not well-formed.
  5259. *
  5260. * v {any}
  5261. *
  5262. * '[BigNumber Error] Invalid BigNumber: {v}'
  5263. */
  5264. BigNumber.isBigNumber = function (v) {
  5265. if (!v || v._isBigNumber !== true) return false;
  5266. if (!BigNumber.DEBUG) return true;
  5267. var i, n,
  5268. c = v.c,
  5269. e = v.e,
  5270. s = v.s;
  5271. out: if ({}.toString.call(c) == '[object Array]') {
  5272. if ((s === 1 || s === -1) && e >= -MAX && e <= MAX && e === mathfloor(e)) {
  5273. // If the first element is zero, the BigNumber value must be zero.
  5274. if (c[0] === 0) {
  5275. if (e === 0 && c.length === 1) return true;
  5276. break out;
  5277. }
  5278. // Calculate number of digits that c[0] should have, based on the exponent.
  5279. i = (e + 1) % LOG_BASE;
  5280. if (i < 1) i += LOG_BASE;
  5281. // Calculate number of digits of c[0].
  5282. //if (Math.ceil(Math.log(c[0] + 1) / Math.LN10) == i) {
  5283. if (String(c[0]).length == i) {
  5284. for (i = 0; i < c.length; i++) {
  5285. n = c[i];
  5286. if (n < 0 || n >= BASE || n !== mathfloor(n)) break out;
  5287. }
  5288. // Last element cannot be zero, unless it is the only element.
  5289. if (n !== 0) return true;
  5290. }
  5291. }
  5292. // Infinity/NaN
  5293. } else if (c === null && e === null && (s === null || s === 1 || s === -1)) {
  5294. return true;
  5295. }
  5296. throw Error
  5297. (bignumberError + 'Invalid BigNumber: ' + v);
  5298. };
  5299. /*
  5300. * Return a new BigNumber whose value is the maximum of the arguments.
  5301. *
  5302. * arguments {number|string|BigNumber}
  5303. */
  5304. BigNumber.maximum = BigNumber.max = function () {
  5305. return maxOrMin(arguments, P.lt);
  5306. };
  5307. /*
  5308. * Return a new BigNumber whose value is the minimum of the arguments.
  5309. *
  5310. * arguments {number|string|BigNumber}
  5311. */
  5312. BigNumber.minimum = BigNumber.min = function () {
  5313. return maxOrMin(arguments, P.gt);
  5314. };
  5315. /*
  5316. * Return a new BigNumber with a random value equal to or greater than 0 and less than 1,
  5317. * and with dp, or DECIMAL_PLACES if dp is omitted, decimal places (or less if trailing
  5318. * zeros are produced).
  5319. *
  5320. * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
  5321. *
  5322. * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp}'
  5323. * '[BigNumber Error] crypto unavailable'
  5324. */
  5325. BigNumber.random = (function () {
  5326. var pow2_53 = 0x20000000000000;
  5327. // Return a 53 bit integer n, where 0 <= n < 9007199254740992.
  5328. // Check if Math.random() produces more than 32 bits of randomness.
  5329. // If it does, assume at least 53 bits are produced, otherwise assume at least 30 bits.
  5330. // 0x40000000 is 2^30, 0x800000 is 2^23, 0x1fffff is 2^21 - 1.
  5331. var random53bitInt = (Math.random() * pow2_53) & 0x1fffff
  5332. ? function () { return mathfloor(Math.random() * pow2_53); }
  5333. : function () { return ((Math.random() * 0x40000000 | 0) * 0x800000) +
  5334. (Math.random() * 0x800000 | 0); };
  5335. return function (dp) {
  5336. var a, b, e, k, v,
  5337. i = 0,
  5338. c = [],
  5339. rand = new BigNumber(ONE);
  5340. if (dp == null) dp = DECIMAL_PLACES;
  5341. else intCheck(dp, 0, MAX);
  5342. k = mathceil(dp / LOG_BASE);
  5343. if (CRYPTO) {
  5344. // Browsers supporting crypto.getRandomValues.
  5345. if (crypto.getRandomValues) {
  5346. a = crypto.getRandomValues(new Uint32Array(k *= 2));
  5347. for (; i < k;) {
  5348. // 53 bits:
  5349. // ((Math.pow(2, 32) - 1) * Math.pow(2, 21)).toString(2)
  5350. // 11111 11111111 11111111 11111111 11100000 00000000 00000000
  5351. // ((Math.pow(2, 32) - 1) >>> 11).toString(2)
  5352. // 11111 11111111 11111111
  5353. // 0x20000 is 2^21.
  5354. v = a[i] * 0x20000 + (a[i + 1] >>> 11);
  5355. // Rejection sampling:
  5356. // 0 <= v < 9007199254740992
  5357. // Probability that v >= 9e15, is
  5358. // 7199254740992 / 9007199254740992 ~= 0.0008, i.e. 1 in 1251
  5359. if (v >= 9e15) {
  5360. b = crypto.getRandomValues(new Uint32Array(2));
  5361. a[i] = b[0];
  5362. a[i + 1] = b[1];
  5363. } else {
  5364. // 0 <= v <= 8999999999999999
  5365. // 0 <= (v % 1e14) <= 99999999999999
  5366. c.push(v % 1e14);
  5367. i += 2;
  5368. }
  5369. }
  5370. i = k / 2;
  5371. // Node.js supporting crypto.randomBytes.
  5372. } else if (crypto.randomBytes) {
  5373. // buffer
  5374. a = crypto.randomBytes(k *= 7);
  5375. for (; i < k;) {
  5376. // 0x1000000000000 is 2^48, 0x10000000000 is 2^40
  5377. // 0x100000000 is 2^32, 0x1000000 is 2^24
  5378. // 11111 11111111 11111111 11111111 11111111 11111111 11111111
  5379. // 0 <= v < 9007199254740992
  5380. v = ((a[i] & 31) * 0x1000000000000) + (a[i + 1] * 0x10000000000) +
  5381. (a[i + 2] * 0x100000000) + (a[i + 3] * 0x1000000) +
  5382. (a[i + 4] << 16) + (a[i + 5] << 8) + a[i + 6];
  5383. if (v >= 9e15) {
  5384. crypto.randomBytes(7).copy(a, i);
  5385. } else {
  5386. // 0 <= (v % 1e14) <= 99999999999999
  5387. c.push(v % 1e14);
  5388. i += 7;
  5389. }
  5390. }
  5391. i = k / 7;
  5392. } else {
  5393. CRYPTO = false;
  5394. throw Error
  5395. (bignumberError + 'crypto unavailable');
  5396. }
  5397. }
  5398. // Use Math.random.
  5399. if (!CRYPTO) {
  5400. for (; i < k;) {
  5401. v = random53bitInt();
  5402. if (v < 9e15) c[i++] = v % 1e14;
  5403. }
  5404. }
  5405. k = c[--i];
  5406. dp %= LOG_BASE;
  5407. // Convert trailing digits to zeros according to dp.
  5408. if (k && dp) {
  5409. v = POWS_TEN[LOG_BASE - dp];
  5410. c[i] = mathfloor(k / v) * v;
  5411. }
  5412. // Remove trailing elements which are zero.
  5413. for (; c[i] === 0; c.pop(), i--);
  5414. // Zero?
  5415. if (i < 0) {
  5416. c = [e = 0];
  5417. } else {
  5418. // Remove leading elements which are zero and adjust exponent accordingly.
  5419. for (e = -1 ; c[0] === 0; c.splice(0, 1), e -= LOG_BASE);
  5420. // Count the digits of the first element of c to determine leading zeros, and...
  5421. for (i = 1, v = c[0]; v >= 10; v /= 10, i++);
  5422. // adjust the exponent accordingly.
  5423. if (i < LOG_BASE) e -= LOG_BASE - i;
  5424. }
  5425. rand.e = e;
  5426. rand.c = c;
  5427. return rand;
  5428. };
  5429. })();
  5430. /*
  5431. * Return a BigNumber whose value is the sum of the arguments.
  5432. *
  5433. * arguments {number|string|BigNumber}
  5434. */
  5435. BigNumber.sum = function () {
  5436. var i = 1,
  5437. args = arguments,
  5438. sum = new BigNumber(args[0]);
  5439. for (; i < args.length;) sum = sum.plus(args[i++]);
  5440. return sum;
  5441. };
  5442. // PRIVATE FUNCTIONS
  5443. // Called by BigNumber and BigNumber.prototype.toString.
  5444. convertBase = (function () {
  5445. var decimal = '0123456789';
  5446. /*
  5447. * Convert string of baseIn to an array of numbers of baseOut.
  5448. * Eg. toBaseOut('255', 10, 16) returns [15, 15].
  5449. * Eg. toBaseOut('ff', 16, 10) returns [2, 5, 5].
  5450. */
  5451. function toBaseOut(str, baseIn, baseOut, alphabet) {
  5452. var j,
  5453. arr = [0],
  5454. arrL,
  5455. i = 0,
  5456. len = str.length;
  5457. for (; i < len;) {
  5458. for (arrL = arr.length; arrL--; arr[arrL] *= baseIn);
  5459. arr[0] += alphabet.indexOf(str.charAt(i++));
  5460. for (j = 0; j < arr.length; j++) {
  5461. if (arr[j] > baseOut - 1) {
  5462. if (arr[j + 1] == null) arr[j + 1] = 0;
  5463. arr[j + 1] += arr[j] / baseOut | 0;
  5464. arr[j] %= baseOut;
  5465. }
  5466. }
  5467. }
  5468. return arr.reverse();
  5469. }
  5470. // Convert a numeric string of baseIn to a numeric string of baseOut.
  5471. // If the caller is toString, we are converting from base 10 to baseOut.
  5472. // If the caller is BigNumber, we are converting from baseIn to base 10.
  5473. return function (str, baseIn, baseOut, sign, callerIsToString) {
  5474. var alphabet, d, e, k, r, x, xc, y,
  5475. i = str.indexOf('.'),
  5476. dp = DECIMAL_PLACES,
  5477. rm = ROUNDING_MODE;
  5478. // Non-integer.
  5479. if (i >= 0) {
  5480. k = POW_PRECISION;
  5481. // Unlimited precision.
  5482. POW_PRECISION = 0;
  5483. str = str.replace('.', '');
  5484. y = new BigNumber(baseIn);
  5485. x = y.pow(str.length - i);
  5486. POW_PRECISION = k;
  5487. // Convert str as if an integer, then restore the fraction part by dividing the
  5488. // result by its base raised to a power.
  5489. y.c = toBaseOut(toFixedPoint(coeffToString(x.c), x.e, '0'),
  5490. 10, baseOut, decimal);
  5491. y.e = y.c.length;
  5492. }
  5493. // Convert the number as integer.
  5494. xc = toBaseOut(str, baseIn, baseOut, callerIsToString
  5495. ? (alphabet = ALPHABET, decimal)
  5496. : (alphabet = decimal, ALPHABET));
  5497. // xc now represents str as an integer and converted to baseOut. e is the exponent.
  5498. e = k = xc.length;
  5499. // Remove trailing zeros.
  5500. for (; xc[--k] == 0; xc.pop());
  5501. // Zero?
  5502. if (!xc[0]) return alphabet.charAt(0);
  5503. // Does str represent an integer? If so, no need for the division.
  5504. if (i < 0) {
  5505. --e;
  5506. } else {
  5507. x.c = xc;
  5508. x.e = e;
  5509. // The sign is needed for correct rounding.
  5510. x.s = sign;
  5511. x = div(x, y, dp, rm, baseOut);
  5512. xc = x.c;
  5513. r = x.r;
  5514. e = x.e;
  5515. }
  5516. // xc now represents str converted to baseOut.
  5517. // THe index of the rounding digit.
  5518. d = e + dp + 1;
  5519. // The rounding digit: the digit to the right of the digit that may be rounded up.
  5520. i = xc[d];
  5521. // Look at the rounding digits and mode to determine whether to round up.
  5522. k = baseOut / 2;
  5523. r = r || d < 0 || xc[d + 1] != null;
  5524. r = rm < 4 ? (i != null || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2))
  5525. : i > k || i == k &&(rm == 4 || r || rm == 6 && xc[d - 1] & 1 ||
  5526. rm == (x.s < 0 ? 8 : 7));
  5527. // If the index of the rounding digit is not greater than zero, or xc represents
  5528. // zero, then the result of the base conversion is zero or, if rounding up, a value
  5529. // such as 0.00001.
  5530. if (d < 1 || !xc[0]) {
  5531. // 1^-dp or 0
  5532. str = r ? toFixedPoint(alphabet.charAt(1), -dp, alphabet.charAt(0)) : alphabet.charAt(0);
  5533. } else {
  5534. // Truncate xc to the required number of decimal places.
  5535. xc.length = d;
  5536. // Round up?
  5537. if (r) {
  5538. // Rounding up may mean the previous digit has to be rounded up and so on.
  5539. for (--baseOut; ++xc[--d] > baseOut;) {
  5540. xc[d] = 0;
  5541. if (!d) {
  5542. ++e;
  5543. xc = [1].concat(xc);
  5544. }
  5545. }
  5546. }
  5547. // Determine trailing zeros.
  5548. for (k = xc.length; !xc[--k];);
  5549. // E.g. [4, 11, 15] becomes 4bf.
  5550. for (i = 0, str = ''; i <= k; str += alphabet.charAt(xc[i++]));
  5551. // Add leading zeros, decimal point and trailing zeros as required.
  5552. str = toFixedPoint(str, e, alphabet.charAt(0));
  5553. }
  5554. // The caller will add the sign.
  5555. return str;
  5556. };
  5557. })();
  5558. // Perform division in the specified base. Called by div and convertBase.
  5559. div = (function () {
  5560. // Assume non-zero x and k.
  5561. function multiply(x, k, base) {
  5562. var m, temp, xlo, xhi,
  5563. carry = 0,
  5564. i = x.length,
  5565. klo = k % SQRT_BASE,
  5566. khi = k / SQRT_BASE | 0;
  5567. for (x = x.slice(); i--;) {
  5568. xlo = x[i] % SQRT_BASE;
  5569. xhi = x[i] / SQRT_BASE | 0;
  5570. m = khi * xlo + xhi * klo;
  5571. temp = klo * xlo + ((m % SQRT_BASE) * SQRT_BASE) + carry;
  5572. carry = (temp / base | 0) + (m / SQRT_BASE | 0) + khi * xhi;
  5573. x[i] = temp % base;
  5574. }
  5575. if (carry) x = [carry].concat(x);
  5576. return x;
  5577. }
  5578. function compare(a, b, aL, bL) {
  5579. var i, cmp;
  5580. if (aL != bL) {
  5581. cmp = aL > bL ? 1 : -1;
  5582. } else {
  5583. for (i = cmp = 0; i < aL; i++) {
  5584. if (a[i] != b[i]) {
  5585. cmp = a[i] > b[i] ? 1 : -1;
  5586. break;
  5587. }
  5588. }
  5589. }
  5590. return cmp;
  5591. }
  5592. function subtract(a, b, aL, base) {
  5593. var i = 0;
  5594. // Subtract b from a.
  5595. for (; aL--;) {
  5596. a[aL] -= i;
  5597. i = a[aL] < b[aL] ? 1 : 0;
  5598. a[aL] = i * base + a[aL] - b[aL];
  5599. }
  5600. // Remove leading zeros.
  5601. for (; !a[0] && a.length > 1; a.splice(0, 1));
  5602. }
  5603. // x: dividend, y: divisor.
  5604. return function (x, y, dp, rm, base) {
  5605. var cmp, e, i, more, n, prod, prodL, q, qc, rem, remL, rem0, xi, xL, yc0,
  5606. yL, yz,
  5607. s = x.s == y.s ? 1 : -1,
  5608. xc = x.c,
  5609. yc = y.c;
  5610. // Either NaN, Infinity or 0?
  5611. if (!xc || !xc[0] || !yc || !yc[0]) {
  5612. return new BigNumber(
  5613. // Return NaN if either NaN, or both Infinity or 0.
  5614. !x.s || !y.s || (xc ? yc && xc[0] == yc[0] : !yc) ? NaN :
  5615. // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
  5616. xc && xc[0] == 0 || !yc ? s * 0 : s / 0
  5617. );
  5618. }
  5619. q = new BigNumber(s);
  5620. qc = q.c = [];
  5621. e = x.e - y.e;
  5622. s = dp + e + 1;
  5623. if (!base) {
  5624. base = BASE;
  5625. e = bitFloor(x.e / LOG_BASE) - bitFloor(y.e / LOG_BASE);
  5626. s = s / LOG_BASE | 0;
  5627. }
  5628. // Result exponent may be one less then the current value of e.
  5629. // The coefficients of the BigNumbers from convertBase may have trailing zeros.
  5630. for (i = 0; yc[i] == (xc[i] || 0); i++);
  5631. if (yc[i] > (xc[i] || 0)) e--;
  5632. if (s < 0) {
  5633. qc.push(1);
  5634. more = true;
  5635. } else {
  5636. xL = xc.length;
  5637. yL = yc.length;
  5638. i = 0;
  5639. s += 2;
  5640. // Normalise xc and yc so highest order digit of yc is >= base / 2.
  5641. n = mathfloor(base / (yc[0] + 1));
  5642. // Not necessary, but to handle odd bases where yc[0] == (base / 2) - 1.
  5643. // if (n > 1 || n++ == 1 && yc[0] < base / 2) {
  5644. if (n > 1) {
  5645. yc = multiply(yc, n, base);
  5646. xc = multiply(xc, n, base);
  5647. yL = yc.length;
  5648. xL = xc.length;
  5649. }
  5650. xi = yL;
  5651. rem = xc.slice(0, yL);
  5652. remL = rem.length;
  5653. // Add zeros to make remainder as long as divisor.
  5654. for (; remL < yL; rem[remL++] = 0);
  5655. yz = yc.slice();
  5656. yz = [0].concat(yz);
  5657. yc0 = yc[0];
  5658. if (yc[1] >= base / 2) yc0++;
  5659. // Not necessary, but to prevent trial digit n > base, when using base 3.
  5660. // else if (base == 3 && yc0 == 1) yc0 = 1 + 1e-15;
  5661. do {
  5662. n = 0;
  5663. // Compare divisor and remainder.
  5664. cmp = compare(yc, rem, yL, remL);
  5665. // If divisor < remainder.
  5666. if (cmp < 0) {
  5667. // Calculate trial digit, n.
  5668. rem0 = rem[0];
  5669. if (yL != remL) rem0 = rem0 * base + (rem[1] || 0);
  5670. // n is how many times the divisor goes into the current remainder.
  5671. n = mathfloor(rem0 / yc0);
  5672. // Algorithm:
  5673. // product = divisor multiplied by trial digit (n).
  5674. // Compare product and remainder.
  5675. // If product is greater than remainder:
  5676. // Subtract divisor from product, decrement trial digit.
  5677. // Subtract product from remainder.
  5678. // If product was less than remainder at the last compare:
  5679. // Compare new remainder and divisor.
  5680. // If remainder is greater than divisor:
  5681. // Subtract divisor from remainder, increment trial digit.
  5682. if (n > 1) {
  5683. // n may be > base only when base is 3.
  5684. if (n >= base) n = base - 1;
  5685. // product = divisor * trial digit.
  5686. prod = multiply(yc, n, base);
  5687. prodL = prod.length;
  5688. remL = rem.length;
  5689. // Compare product and remainder.
  5690. // If product > remainder then trial digit n too high.
  5691. // n is 1 too high about 5% of the time, and is not known to have
  5692. // ever been more than 1 too high.
  5693. while (compare(prod, rem, prodL, remL) == 1) {
  5694. n--;
  5695. // Subtract divisor from product.
  5696. subtract(prod, yL < prodL ? yz : yc, prodL, base);
  5697. prodL = prod.length;
  5698. cmp = 1;
  5699. }
  5700. } else {
  5701. // n is 0 or 1, cmp is -1.
  5702. // If n is 0, there is no need to compare yc and rem again below,
  5703. // so change cmp to 1 to avoid it.
  5704. // If n is 1, leave cmp as -1, so yc and rem are compared again.
  5705. if (n == 0) {
  5706. // divisor < remainder, so n must be at least 1.
  5707. cmp = n = 1;
  5708. }
  5709. // product = divisor
  5710. prod = yc.slice();
  5711. prodL = prod.length;
  5712. }
  5713. if (prodL < remL) prod = [0].concat(prod);
  5714. // Subtract product from remainder.
  5715. subtract(rem, prod, remL, base);
  5716. remL = rem.length;
  5717. // If product was < remainder.
  5718. if (cmp == -1) {
  5719. // Compare divisor and new remainder.
  5720. // If divisor < new remainder, subtract divisor from remainder.
  5721. // Trial digit n too low.
  5722. // n is 1 too low about 5% of the time, and very rarely 2 too low.
  5723. while (compare(yc, rem, yL, remL) < 1) {
  5724. n++;
  5725. // Subtract divisor from remainder.
  5726. subtract(rem, yL < remL ? yz : yc, remL, base);
  5727. remL = rem.length;
  5728. }
  5729. }
  5730. } else if (cmp === 0) {
  5731. n++;
  5732. rem = [0];
  5733. } // else cmp === 1 and n will be 0
  5734. // Add the next digit, n, to the result array.
  5735. qc[i++] = n;
  5736. // Update the remainder.
  5737. if (rem[0]) {
  5738. rem[remL++] = xc[xi] || 0;
  5739. } else {
  5740. rem = [xc[xi]];
  5741. remL = 1;
  5742. }
  5743. } while ((xi++ < xL || rem[0] != null) && s--);
  5744. more = rem[0] != null;
  5745. // Leading zero?
  5746. if (!qc[0]) qc.splice(0, 1);
  5747. }
  5748. if (base == BASE) {
  5749. // To calculate q.e, first get the number of digits of qc[0].
  5750. for (i = 1, s = qc[0]; s >= 10; s /= 10, i++);
  5751. round(q, dp + (q.e = i + e * LOG_BASE - 1) + 1, rm, more);
  5752. // Caller is convertBase.
  5753. } else {
  5754. q.e = e;
  5755. q.r = +more;
  5756. }
  5757. return q;
  5758. };
  5759. })();
  5760. /*
  5761. * Return a string representing the value of BigNumber n in fixed-point or exponential
  5762. * notation rounded to the specified decimal places or significant digits.
  5763. *
  5764. * n: a BigNumber.
  5765. * i: the index of the last digit required (i.e. the digit that may be rounded up).
  5766. * rm: the rounding mode.
  5767. * id: 1 (toExponential) or 2 (toPrecision).
  5768. */
  5769. function format(n, i, rm, id) {
  5770. var c0, e, ne, len, str;
  5771. if (rm == null) rm = ROUNDING_MODE;
  5772. else intCheck(rm, 0, 8);
  5773. if (!n.c) return n.toString();
  5774. c0 = n.c[0];
  5775. ne = n.e;
  5776. if (i == null) {
  5777. str = coeffToString(n.c);
  5778. str = id == 1 || id == 2 && (ne <= TO_EXP_NEG || ne >= TO_EXP_POS)
  5779. ? toExponential(str, ne)
  5780. : toFixedPoint(str, ne, '0');
  5781. } else {
  5782. n = round(new BigNumber(n), i, rm);
  5783. // n.e may have changed if the value was rounded up.
  5784. e = n.e;
  5785. str = coeffToString(n.c);
  5786. len = str.length;
  5787. // toPrecision returns exponential notation if the number of significant digits
  5788. // specified is less than the number of digits necessary to represent the integer
  5789. // part of the value in fixed-point notation.
  5790. // Exponential notation.
  5791. if (id == 1 || id == 2 && (i <= e || e <= TO_EXP_NEG)) {
  5792. // Append zeros?
  5793. for (; len < i; str += '0', len++);
  5794. str = toExponential(str, e);
  5795. // Fixed-point notation.
  5796. } else {
  5797. i -= ne;
  5798. str = toFixedPoint(str, e, '0');
  5799. // Append zeros?
  5800. if (e + 1 > len) {
  5801. if (--i > 0) for (str += '.'; i--; str += '0');
  5802. } else {
  5803. i += e - len;
  5804. if (i > 0) {
  5805. if (e + 1 == len) str += '.';
  5806. for (; i--; str += '0');
  5807. }
  5808. }
  5809. }
  5810. }
  5811. return n.s < 0 && c0 ? '-' + str : str;
  5812. }
  5813. // Handle BigNumber.max and BigNumber.min.
  5814. function maxOrMin(args, method) {
  5815. var n,
  5816. i = 1,
  5817. m = new BigNumber(args[0]);
  5818. for (; i < args.length; i++) {
  5819. n = new BigNumber(args[i]);
  5820. // If any number is NaN, return NaN.
  5821. if (!n.s) {
  5822. m = n;
  5823. break;
  5824. } else if (method.call(m, n)) {
  5825. m = n;
  5826. }
  5827. }
  5828. return m;
  5829. }
  5830. /*
  5831. * Strip trailing zeros, calculate base 10 exponent and check against MIN_EXP and MAX_EXP.
  5832. * Called by minus, plus and times.
  5833. */
  5834. function normalise(n, c, e) {
  5835. var i = 1,
  5836. j = c.length;
  5837. // Remove trailing zeros.
  5838. for (; !c[--j]; c.pop());
  5839. // Calculate the base 10 exponent. First get the number of digits of c[0].
  5840. for (j = c[0]; j >= 10; j /= 10, i++);
  5841. // Overflow?
  5842. if ((e = i + e * LOG_BASE - 1) > MAX_EXP) {
  5843. // Infinity.
  5844. n.c = n.e = null;
  5845. // Underflow?
  5846. } else if (e < MIN_EXP) {
  5847. // Zero.
  5848. n.c = [n.e = 0];
  5849. } else {
  5850. n.e = e;
  5851. n.c = c;
  5852. }
  5853. return n;
  5854. }
  5855. // Handle values that fail the validity test in BigNumber.
  5856. parseNumeric = (function () {
  5857. var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i,
  5858. dotAfter = /^([^.]+)\.$/,
  5859. dotBefore = /^\.([^.]+)$/,
  5860. isInfinityOrNaN = /^-?(Infinity|NaN)$/,
  5861. whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
  5862. return function (x, str, isNum, b) {
  5863. var base,
  5864. s = isNum ? str : str.replace(whitespaceOrPlus, '');
  5865. // No exception on ±Infinity or NaN.
  5866. if (isInfinityOrNaN.test(s)) {
  5867. x.s = isNaN(s) ? null : s < 0 ? -1 : 1;
  5868. } else {
  5869. if (!isNum) {
  5870. // basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i
  5871. s = s.replace(basePrefix, function (m, p1, p2) {
  5872. base = (p2 = p2.toLowerCase()) == 'x' ? 16 : p2 == 'b' ? 2 : 8;
  5873. return !b || b == base ? p1 : m;
  5874. });
  5875. if (b) {
  5876. base = b;
  5877. // E.g. '1.' to '1', '.1' to '0.1'
  5878. s = s.replace(dotAfter, '$1').replace(dotBefore, '0.$1');
  5879. }
  5880. if (str != s) return new BigNumber(s, base);
  5881. }
  5882. // '[BigNumber Error] Not a number: {n}'
  5883. // '[BigNumber Error] Not a base {b} number: {n}'
  5884. if (BigNumber.DEBUG) {
  5885. throw Error
  5886. (bignumberError + 'Not a' + (b ? ' base ' + b : '') + ' number: ' + str);
  5887. }
  5888. // NaN
  5889. x.s = null;
  5890. }
  5891. x.c = x.e = null;
  5892. }
  5893. })();
  5894. /*
  5895. * Round x to sd significant digits using rounding mode rm. Check for over/under-flow.
  5896. * If r is truthy, it is known that there are more digits after the rounding digit.
  5897. */
  5898. function round(x, sd, rm, r) {
  5899. var d, i, j, k, n, ni, rd,
  5900. xc = x.c,
  5901. pows10 = POWS_TEN;
  5902. // if x is not Infinity or NaN...
  5903. if (xc) {
  5904. // rd is the rounding digit, i.e. the digit after the digit that may be rounded up.
  5905. // n is a base 1e14 number, the value of the element of array x.c containing rd.
  5906. // ni is the index of n within x.c.
  5907. // d is the number of digits of n.
  5908. // i is the index of rd within n including leading zeros.
  5909. // j is the actual index of rd within n (if < 0, rd is a leading zero).
  5910. out: {
  5911. // Get the number of digits of the first element of xc.
  5912. for (d = 1, k = xc[0]; k >= 10; k /= 10, d++);
  5913. i = sd - d;
  5914. // If the rounding digit is in the first element of xc...
  5915. if (i < 0) {
  5916. i += LOG_BASE;
  5917. j = sd;
  5918. n = xc[ni = 0];
  5919. // Get the rounding digit at index j of n.
  5920. rd = n / pows10[d - j - 1] % 10 | 0;
  5921. } else {
  5922. ni = mathceil((i + 1) / LOG_BASE);
  5923. if (ni >= xc.length) {
  5924. if (r) {
  5925. // Needed by sqrt.
  5926. for (; xc.length <= ni; xc.push(0));
  5927. n = rd = 0;
  5928. d = 1;
  5929. i %= LOG_BASE;
  5930. j = i - LOG_BASE + 1;
  5931. } else {
  5932. break out;
  5933. }
  5934. } else {
  5935. n = k = xc[ni];
  5936. // Get the number of digits of n.
  5937. for (d = 1; k >= 10; k /= 10, d++);
  5938. // Get the index of rd within n.
  5939. i %= LOG_BASE;
  5940. // Get the index of rd within n, adjusted for leading zeros.
  5941. // The number of leading zeros of n is given by LOG_BASE - d.
  5942. j = i - LOG_BASE + d;
  5943. // Get the rounding digit at index j of n.
  5944. rd = j < 0 ? 0 : n / pows10[d - j - 1] % 10 | 0;
  5945. }
  5946. }
  5947. r = r || sd < 0 ||
  5948. // Are there any non-zero digits after the rounding digit?
  5949. // The expression n % pows10[d - j - 1] returns all digits of n to the right
  5950. // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
  5951. xc[ni + 1] != null || (j < 0 ? n : n % pows10[d - j - 1]);
  5952. r = rm < 4
  5953. ? (rd || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2))
  5954. : rd > 5 || rd == 5 && (rm == 4 || r || rm == 6 &&
  5955. // Check whether the digit to the left of the rounding digit is odd.
  5956. ((i > 0 ? j > 0 ? n / pows10[d - j] : 0 : xc[ni - 1]) % 10) & 1 ||
  5957. rm == (x.s < 0 ? 8 : 7));
  5958. if (sd < 1 || !xc[0]) {
  5959. xc.length = 0;
  5960. if (r) {
  5961. // Convert sd to decimal places.
  5962. sd -= x.e + 1;
  5963. // 1, 0.1, 0.01, 0.001, 0.0001 etc.
  5964. xc[0] = pows10[(LOG_BASE - sd % LOG_BASE) % LOG_BASE];
  5965. x.e = -sd || 0;
  5966. } else {
  5967. // Zero.
  5968. xc[0] = x.e = 0;
  5969. }
  5970. return x;
  5971. }
  5972. // Remove excess digits.
  5973. if (i == 0) {
  5974. xc.length = ni;
  5975. k = 1;
  5976. ni--;
  5977. } else {
  5978. xc.length = ni + 1;
  5979. k = pows10[LOG_BASE - i];
  5980. // E.g. 56700 becomes 56000 if 7 is the rounding digit.
  5981. // j > 0 means i > number of leading zeros of n.
  5982. xc[ni] = j > 0 ? mathfloor(n / pows10[d - j] % pows10[j]) * k : 0;
  5983. }
  5984. // Round up?
  5985. if (r) {
  5986. for (; ;) {
  5987. // If the digit to be rounded up is in the first element of xc...
  5988. if (ni == 0) {
  5989. // i will be the length of xc[0] before k is added.
  5990. for (i = 1, j = xc[0]; j >= 10; j /= 10, i++);
  5991. j = xc[0] += k;
  5992. for (k = 1; j >= 10; j /= 10, k++);
  5993. // if i != k the length has increased.
  5994. if (i != k) {
  5995. x.e++;
  5996. if (xc[0] == BASE) xc[0] = 1;
  5997. }
  5998. break;
  5999. } else {
  6000. xc[ni] += k;
  6001. if (xc[ni] != BASE) break;
  6002. xc[ni--] = 0;
  6003. k = 1;
  6004. }
  6005. }
  6006. }
  6007. // Remove trailing zeros.
  6008. for (i = xc.length; xc[--i] === 0; xc.pop());
  6009. }
  6010. // Overflow? Infinity.
  6011. if (x.e > MAX_EXP) {
  6012. x.c = x.e = null;
  6013. // Underflow? Zero.
  6014. } else if (x.e < MIN_EXP) {
  6015. x.c = [x.e = 0];
  6016. }
  6017. }
  6018. return x;
  6019. }
  6020. function valueOf(n) {
  6021. var str,
  6022. e = n.e;
  6023. if (e === null) return n.toString();
  6024. str = coeffToString(n.c);
  6025. str = e <= TO_EXP_NEG || e >= TO_EXP_POS
  6026. ? toExponential(str, e)
  6027. : toFixedPoint(str, e, '0');
  6028. return n.s < 0 ? '-' + str : str;
  6029. }
  6030. // PROTOTYPE/INSTANCE METHODS
  6031. /*
  6032. * Return a new BigNumber whose value is the absolute value of this BigNumber.
  6033. */
  6034. P.absoluteValue = P.abs = function () {
  6035. var x = new BigNumber(this);
  6036. if (x.s < 0) x.s = 1;
  6037. return x;
  6038. };
  6039. /*
  6040. * Return
  6041. * 1 if the value of this BigNumber is greater than the value of BigNumber(y, b),
  6042. * -1 if the value of this BigNumber is less than the value of BigNumber(y, b),
  6043. * 0 if they have the same value,
  6044. * or null if the value of either is NaN.
  6045. */
  6046. P.comparedTo = function (y, b) {
  6047. return compare(this, new BigNumber(y, b));
  6048. };
  6049. /*
  6050. * If dp is undefined or null or true or false, return the number of decimal places of the
  6051. * value of this BigNumber, or null if the value of this BigNumber is ±Infinity or NaN.
  6052. *
  6053. * Otherwise, if dp is a number, return a new BigNumber whose value is the value of this
  6054. * BigNumber rounded to a maximum of dp decimal places using rounding mode rm, or
  6055. * ROUNDING_MODE if rm is omitted.
  6056. *
  6057. * [dp] {number} Decimal places: integer, 0 to MAX inclusive.
  6058. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  6059. *
  6060. * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}'
  6061. */
  6062. P.decimalPlaces = P.dp = function (dp, rm) {
  6063. var c, n, v,
  6064. x = this;
  6065. if (dp != null) {
  6066. intCheck(dp, 0, MAX);
  6067. if (rm == null) rm = ROUNDING_MODE;
  6068. else intCheck(rm, 0, 8);
  6069. return round(new BigNumber(x), dp + x.e + 1, rm);
  6070. }
  6071. if (!(c = x.c)) return null;
  6072. n = ((v = c.length - 1) - bitFloor(this.e / LOG_BASE)) * LOG_BASE;
  6073. // Subtract the number of trailing zeros of the last number.
  6074. if (v = c[v]) for (; v % 10 == 0; v /= 10, n--);
  6075. if (n < 0) n = 0;
  6076. return n;
  6077. };
  6078. /*
  6079. * n / 0 = I
  6080. * n / N = N
  6081. * n / I = 0
  6082. * 0 / n = 0
  6083. * 0 / 0 = N
  6084. * 0 / N = N
  6085. * 0 / I = 0
  6086. * N / n = N
  6087. * N / 0 = N
  6088. * N / N = N
  6089. * N / I = N
  6090. * I / n = I
  6091. * I / 0 = I
  6092. * I / N = N
  6093. * I / I = N
  6094. *
  6095. * Return a new BigNumber whose value is the value of this BigNumber divided by the value of
  6096. * BigNumber(y, b), rounded according to DECIMAL_PLACES and ROUNDING_MODE.
  6097. */
  6098. P.dividedBy = P.div = function (y, b) {
  6099. return div(this, new BigNumber(y, b), DECIMAL_PLACES, ROUNDING_MODE);
  6100. };
  6101. /*
  6102. * Return a new BigNumber whose value is the integer part of dividing the value of this
  6103. * BigNumber by the value of BigNumber(y, b).
  6104. */
  6105. P.dividedToIntegerBy = P.idiv = function (y, b) {
  6106. return div(this, new BigNumber(y, b), 0, 1);
  6107. };
  6108. /*
  6109. * Return a BigNumber whose value is the value of this BigNumber exponentiated by n.
  6110. *
  6111. * If m is present, return the result modulo m.
  6112. * If n is negative round according to DECIMAL_PLACES and ROUNDING_MODE.
  6113. * If POW_PRECISION is non-zero and m is not present, round to POW_PRECISION using ROUNDING_MODE.
  6114. *
  6115. * The modular power operation works efficiently when x, n, and m are integers, otherwise it
  6116. * is equivalent to calculating x.exponentiatedBy(n).modulo(m) with a POW_PRECISION of 0.
  6117. *
  6118. * n {number|string|BigNumber} The exponent. An integer.
  6119. * [m] {number|string|BigNumber} The modulus.
  6120. *
  6121. * '[BigNumber Error] Exponent not an integer: {n}'
  6122. */
  6123. P.exponentiatedBy = P.pow = function (n, m) {
  6124. var half, isModExp, i, k, more, nIsBig, nIsNeg, nIsOdd, y,
  6125. x = this;
  6126. n = new BigNumber(n);
  6127. // Allow NaN and ±Infinity, but not other non-integers.
  6128. if (n.c && !n.isInteger()) {
  6129. throw Error
  6130. (bignumberError + 'Exponent not an integer: ' + valueOf(n));
  6131. }
  6132. if (m != null) m = new BigNumber(m);
  6133. // Exponent of MAX_SAFE_INTEGER is 15.
  6134. nIsBig = n.e > 14;
  6135. // If x is NaN, ±Infinity, ±0 or ±1, or n is ±Infinity, NaN or ±0.
  6136. if (!x.c || !x.c[0] || x.c[0] == 1 && !x.e && x.c.length == 1 || !n.c || !n.c[0]) {
  6137. // The sign of the result of pow when x is negative depends on the evenness of n.
  6138. // If +n overflows to ±Infinity, the evenness of n would be not be known.
  6139. y = new BigNumber(Math.pow(+valueOf(x), nIsBig ? n.s * (2 - isOdd(n)) : +valueOf(n)));
  6140. return m ? y.mod(m) : y;
  6141. }
  6142. nIsNeg = n.s < 0;
  6143. if (m) {
  6144. // x % m returns NaN if abs(m) is zero, or m is NaN.
  6145. if (m.c ? !m.c[0] : !m.s) return new BigNumber(NaN);
  6146. isModExp = !nIsNeg && x.isInteger() && m.isInteger();
  6147. if (isModExp) x = x.mod(m);
  6148. // Overflow to ±Infinity: >=2**1e10 or >=1.0000024**1e15.
  6149. // Underflow to ±0: <=0.79**1e10 or <=0.9999975**1e15.
  6150. } else if (n.e > 9 && (x.e > 0 || x.e < -1 || (x.e == 0
  6151. // [1, 240000000]
  6152. ? x.c[0] > 1 || nIsBig && x.c[1] >= 24e7
  6153. // [80000000000000] [99999750000000]
  6154. : x.c[0] < 8e13 || nIsBig && x.c[0] <= 9999975e7))) {
  6155. // If x is negative and n is odd, k = -0, else k = 0.
  6156. k = x.s < 0 && isOdd(n) ? -0 : 0;
  6157. // If x >= 1, k = ±Infinity.
  6158. if (x.e > -1) k = 1 / k;
  6159. // If n is negative return ±0, else return ±Infinity.
  6160. return new BigNumber(nIsNeg ? 1 / k : k);
  6161. } else if (POW_PRECISION) {
  6162. // Truncating each coefficient array to a length of k after each multiplication
  6163. // equates to truncating significant digits to POW_PRECISION + [28, 41],
  6164. // i.e. there will be a minimum of 28 guard digits retained.
  6165. k = mathceil(POW_PRECISION / LOG_BASE + 2);
  6166. }
  6167. if (nIsBig) {
  6168. half = new BigNumber(0.5);
  6169. if (nIsNeg) n.s = 1;
  6170. nIsOdd = isOdd(n);
  6171. } else {
  6172. i = Math.abs(+valueOf(n));
  6173. nIsOdd = i % 2;
  6174. }
  6175. y = new BigNumber(ONE);
  6176. // Performs 54 loop iterations for n of 9007199254740991.
  6177. for (; ;) {
  6178. if (nIsOdd) {
  6179. y = y.times(x);
  6180. if (!y.c) break;
  6181. if (k) {
  6182. if (y.c.length > k) y.c.length = k;
  6183. } else if (isModExp) {
  6184. y = y.mod(m); //y = y.minus(div(y, m, 0, MODULO_MODE).times(m));
  6185. }
  6186. }
  6187. if (i) {
  6188. i = mathfloor(i / 2);
  6189. if (i === 0) break;
  6190. nIsOdd = i % 2;
  6191. } else {
  6192. n = n.times(half);
  6193. round(n, n.e + 1, 1);
  6194. if (n.e > 14) {
  6195. nIsOdd = isOdd(n);
  6196. } else {
  6197. i = +valueOf(n);
  6198. if (i === 0) break;
  6199. nIsOdd = i % 2;
  6200. }
  6201. }
  6202. x = x.times(x);
  6203. if (k) {
  6204. if (x.c && x.c.length > k) x.c.length = k;
  6205. } else if (isModExp) {
  6206. x = x.mod(m); //x = x.minus(div(x, m, 0, MODULO_MODE).times(m));
  6207. }
  6208. }
  6209. if (isModExp) return y;
  6210. if (nIsNeg) y = ONE.div(y);
  6211. return m ? y.mod(m) : k ? round(y, POW_PRECISION, ROUNDING_MODE, more) : y;
  6212. };
  6213. /*
  6214. * Return a new BigNumber whose value is the value of this BigNumber rounded to an integer
  6215. * using rounding mode rm, or ROUNDING_MODE if rm is omitted.
  6216. *
  6217. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  6218. *
  6219. * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {rm}'
  6220. */
  6221. P.integerValue = function (rm) {
  6222. var n = new BigNumber(this);
  6223. if (rm == null) rm = ROUNDING_MODE;
  6224. else intCheck(rm, 0, 8);
  6225. return round(n, n.e + 1, rm);
  6226. };
  6227. /*
  6228. * Return true if the value of this BigNumber is equal to the value of BigNumber(y, b),
  6229. * otherwise return false.
  6230. */
  6231. P.isEqualTo = P.eq = function (y, b) {
  6232. return compare(this, new BigNumber(y, b)) === 0;
  6233. };
  6234. /*
  6235. * Return true if the value of this BigNumber is a finite number, otherwise return false.
  6236. */
  6237. P.isFinite = function () {
  6238. return !!this.c;
  6239. };
  6240. /*
  6241. * Return true if the value of this BigNumber is greater than the value of BigNumber(y, b),
  6242. * otherwise return false.
  6243. */
  6244. P.isGreaterThan = P.gt = function (y, b) {
  6245. return compare(this, new BigNumber(y, b)) > 0;
  6246. };
  6247. /*
  6248. * Return true if the value of this BigNumber is greater than or equal to the value of
  6249. * BigNumber(y, b), otherwise return false.
  6250. */
  6251. P.isGreaterThanOrEqualTo = P.gte = function (y, b) {
  6252. return (b = compare(this, new BigNumber(y, b))) === 1 || b === 0;
  6253. };
  6254. /*
  6255. * Return true if the value of this BigNumber is an integer, otherwise return false.
  6256. */
  6257. P.isInteger = function () {
  6258. return !!this.c && bitFloor(this.e / LOG_BASE) > this.c.length - 2;
  6259. };
  6260. /*
  6261. * Return true if the value of this BigNumber is less than the value of BigNumber(y, b),
  6262. * otherwise return false.
  6263. */
  6264. P.isLessThan = P.lt = function (y, b) {
  6265. return compare(this, new BigNumber(y, b)) < 0;
  6266. };
  6267. /*
  6268. * Return true if the value of this BigNumber is less than or equal to the value of
  6269. * BigNumber(y, b), otherwise return false.
  6270. */
  6271. P.isLessThanOrEqualTo = P.lte = function (y, b) {
  6272. return (b = compare(this, new BigNumber(y, b))) === -1 || b === 0;
  6273. };
  6274. /*
  6275. * Return true if the value of this BigNumber is NaN, otherwise return false.
  6276. */
  6277. P.isNaN = function () {
  6278. return !this.s;
  6279. };
  6280. /*
  6281. * Return true if the value of this BigNumber is negative, otherwise return false.
  6282. */
  6283. P.isNegative = function () {
  6284. return this.s < 0;
  6285. };
  6286. /*
  6287. * Return true if the value of this BigNumber is positive, otherwise return false.
  6288. */
  6289. P.isPositive = function () {
  6290. return this.s > 0;
  6291. };
  6292. /*
  6293. * Return true if the value of this BigNumber is 0 or -0, otherwise return false.
  6294. */
  6295. P.isZero = function () {
  6296. return !!this.c && this.c[0] == 0;
  6297. };
  6298. /*
  6299. * n - 0 = n
  6300. * n - N = N
  6301. * n - I = -I
  6302. * 0 - n = -n
  6303. * 0 - 0 = 0
  6304. * 0 - N = N
  6305. * 0 - I = -I
  6306. * N - n = N
  6307. * N - 0 = N
  6308. * N - N = N
  6309. * N - I = N
  6310. * I - n = I
  6311. * I - 0 = I
  6312. * I - N = N
  6313. * I - I = N
  6314. *
  6315. * Return a new BigNumber whose value is the value of this BigNumber minus the value of
  6316. * BigNumber(y, b).
  6317. */
  6318. P.minus = function (y, b) {
  6319. var i, j, t, xLTy,
  6320. x = this,
  6321. a = x.s;
  6322. y = new BigNumber(y, b);
  6323. b = y.s;
  6324. // Either NaN?
  6325. if (!a || !b) return new BigNumber(NaN);
  6326. // Signs differ?
  6327. if (a != b) {
  6328. y.s = -b;
  6329. return x.plus(y);
  6330. }
  6331. var xe = x.e / LOG_BASE,
  6332. ye = y.e / LOG_BASE,
  6333. xc = x.c,
  6334. yc = y.c;
  6335. if (!xe || !ye) {
  6336. // Either Infinity?
  6337. if (!xc || !yc) return xc ? (y.s = -b, y) : new BigNumber(yc ? x : NaN);
  6338. // Either zero?
  6339. if (!xc[0] || !yc[0]) {
  6340. // Return y if y is non-zero, x if x is non-zero, or zero if both are zero.
  6341. return yc[0] ? (y.s = -b, y) : new BigNumber(xc[0] ? x :
  6342. // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
  6343. ROUNDING_MODE == 3 ? -0 : 0);
  6344. }
  6345. }
  6346. xe = bitFloor(xe);
  6347. ye = bitFloor(ye);
  6348. xc = xc.slice();
  6349. // Determine which is the bigger number.
  6350. if (a = xe - ye) {
  6351. if (xLTy = a < 0) {
  6352. a = -a;
  6353. t = xc;
  6354. } else {
  6355. ye = xe;
  6356. t = yc;
  6357. }
  6358. t.reverse();
  6359. // Prepend zeros to equalise exponents.
  6360. for (b = a; b--; t.push(0));
  6361. t.reverse();
  6362. } else {
  6363. // Exponents equal. Check digit by digit.
  6364. j = (xLTy = (a = xc.length) < (b = yc.length)) ? a : b;
  6365. for (a = b = 0; b < j; b++) {
  6366. if (xc[b] != yc[b]) {
  6367. xLTy = xc[b] < yc[b];
  6368. break;
  6369. }
  6370. }
  6371. }
  6372. // x < y? Point xc to the array of the bigger number.
  6373. if (xLTy) {
  6374. t = xc;
  6375. xc = yc;
  6376. yc = t;
  6377. y.s = -y.s;
  6378. }
  6379. b = (j = yc.length) - (i = xc.length);
  6380. // Append zeros to xc if shorter.
  6381. // No need to add zeros to yc if shorter as subtract only needs to start at yc.length.
  6382. if (b > 0) for (; b--; xc[i++] = 0);
  6383. b = BASE - 1;
  6384. // Subtract yc from xc.
  6385. for (; j > a;) {
  6386. if (xc[--j] < yc[j]) {
  6387. for (i = j; i && !xc[--i]; xc[i] = b);
  6388. --xc[i];
  6389. xc[j] += BASE;
  6390. }
  6391. xc[j] -= yc[j];
  6392. }
  6393. // Remove leading zeros and adjust exponent accordingly.
  6394. for (; xc[0] == 0; xc.splice(0, 1), --ye);
  6395. // Zero?
  6396. if (!xc[0]) {
  6397. // Following IEEE 754 (2008) 6.3,
  6398. // n - n = +0 but n - n = -0 when rounding towards -Infinity.
  6399. y.s = ROUNDING_MODE == 3 ? -1 : 1;
  6400. y.c = [y.e = 0];
  6401. return y;
  6402. }
  6403. // No need to check for Infinity as +x - +y != Infinity && -x - -y != Infinity
  6404. // for finite x and y.
  6405. return normalise(y, xc, ye);
  6406. };
  6407. /*
  6408. * n % 0 = N
  6409. * n % N = N
  6410. * n % I = n
  6411. * 0 % n = 0
  6412. * -0 % n = -0
  6413. * 0 % 0 = N
  6414. * 0 % N = N
  6415. * 0 % I = 0
  6416. * N % n = N
  6417. * N % 0 = N
  6418. * N % N = N
  6419. * N % I = N
  6420. * I % n = N
  6421. * I % 0 = N
  6422. * I % N = N
  6423. * I % I = N
  6424. *
  6425. * Return a new BigNumber whose value is the value of this BigNumber modulo the value of
  6426. * BigNumber(y, b). The result depends on the value of MODULO_MODE.
  6427. */
  6428. P.modulo = P.mod = function (y, b) {
  6429. var q, s,
  6430. x = this;
  6431. y = new BigNumber(y, b);
  6432. // Return NaN if x is Infinity or NaN, or y is NaN or zero.
  6433. if (!x.c || !y.s || y.c && !y.c[0]) {
  6434. return new BigNumber(NaN);
  6435. // Return x if y is Infinity or x is zero.
  6436. } else if (!y.c || x.c && !x.c[0]) {
  6437. return new BigNumber(x);
  6438. }
  6439. if (MODULO_MODE == 9) {
  6440. // Euclidian division: q = sign(y) * floor(x / abs(y))
  6441. // r = x - qy where 0 <= r < abs(y)
  6442. s = y.s;
  6443. y.s = 1;
  6444. q = div(x, y, 0, 3);
  6445. y.s = s;
  6446. q.s *= s;
  6447. } else {
  6448. q = div(x, y, 0, MODULO_MODE);
  6449. }
  6450. y = x.minus(q.times(y));
  6451. // To match JavaScript %, ensure sign of zero is sign of dividend.
  6452. if (!y.c[0] && MODULO_MODE == 1) y.s = x.s;
  6453. return y;
  6454. };
  6455. /*
  6456. * n * 0 = 0
  6457. * n * N = N
  6458. * n * I = I
  6459. * 0 * n = 0
  6460. * 0 * 0 = 0
  6461. * 0 * N = N
  6462. * 0 * I = N
  6463. * N * n = N
  6464. * N * 0 = N
  6465. * N * N = N
  6466. * N * I = N
  6467. * I * n = I
  6468. * I * 0 = N
  6469. * I * N = N
  6470. * I * I = I
  6471. *
  6472. * Return a new BigNumber whose value is the value of this BigNumber multiplied by the value
  6473. * of BigNumber(y, b).
  6474. */
  6475. P.multipliedBy = P.times = function (y, b) {
  6476. var c, e, i, j, k, m, xcL, xlo, xhi, ycL, ylo, yhi, zc,
  6477. base, sqrtBase,
  6478. x = this,
  6479. xc = x.c,
  6480. yc = (y = new BigNumber(y, b)).c;
  6481. // Either NaN, ±Infinity or ±0?
  6482. if (!xc || !yc || !xc[0] || !yc[0]) {
  6483. // Return NaN if either is NaN, or one is 0 and the other is Infinity.
  6484. if (!x.s || !y.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc) {
  6485. y.c = y.e = y.s = null;
  6486. } else {
  6487. y.s *= x.s;
  6488. // Return ±Infinity if either is ±Infinity.
  6489. if (!xc || !yc) {
  6490. y.c = y.e = null;
  6491. // Return ±0 if either is ±0.
  6492. } else {
  6493. y.c = [0];
  6494. y.e = 0;
  6495. }
  6496. }
  6497. return y;
  6498. }
  6499. e = bitFloor(x.e / LOG_BASE) + bitFloor(y.e / LOG_BASE);
  6500. y.s *= x.s;
  6501. xcL = xc.length;
  6502. ycL = yc.length;
  6503. // Ensure xc points to longer array and xcL to its length.
  6504. if (xcL < ycL) {
  6505. zc = xc;
  6506. xc = yc;
  6507. yc = zc;
  6508. i = xcL;
  6509. xcL = ycL;
  6510. ycL = i;
  6511. }
  6512. // Initialise the result array with zeros.
  6513. for (i = xcL + ycL, zc = []; i--; zc.push(0));
  6514. base = BASE;
  6515. sqrtBase = SQRT_BASE;
  6516. for (i = ycL; --i >= 0;) {
  6517. c = 0;
  6518. ylo = yc[i] % sqrtBase;
  6519. yhi = yc[i] / sqrtBase | 0;
  6520. for (k = xcL, j = i + k; j > i;) {
  6521. xlo = xc[--k] % sqrtBase;
  6522. xhi = xc[k] / sqrtBase | 0;
  6523. m = yhi * xlo + xhi * ylo;
  6524. xlo = ylo * xlo + ((m % sqrtBase) * sqrtBase) + zc[j] + c;
  6525. c = (xlo / base | 0) + (m / sqrtBase | 0) + yhi * xhi;
  6526. zc[j--] = xlo % base;
  6527. }
  6528. zc[j] = c;
  6529. }
  6530. if (c) {
  6531. ++e;
  6532. } else {
  6533. zc.splice(0, 1);
  6534. }
  6535. return normalise(y, zc, e);
  6536. };
  6537. /*
  6538. * Return a new BigNumber whose value is the value of this BigNumber negated,
  6539. * i.e. multiplied by -1.
  6540. */
  6541. P.negated = function () {
  6542. var x = new BigNumber(this);
  6543. x.s = -x.s || null;
  6544. return x;
  6545. };
  6546. /*
  6547. * n + 0 = n
  6548. * n + N = N
  6549. * n + I = I
  6550. * 0 + n = n
  6551. * 0 + 0 = 0
  6552. * 0 + N = N
  6553. * 0 + I = I
  6554. * N + n = N
  6555. * N + 0 = N
  6556. * N + N = N
  6557. * N + I = N
  6558. * I + n = I
  6559. * I + 0 = I
  6560. * I + N = N
  6561. * I + I = I
  6562. *
  6563. * Return a new BigNumber whose value is the value of this BigNumber plus the value of
  6564. * BigNumber(y, b).
  6565. */
  6566. P.plus = function (y, b) {
  6567. var t,
  6568. x = this,
  6569. a = x.s;
  6570. y = new BigNumber(y, b);
  6571. b = y.s;
  6572. // Either NaN?
  6573. if (!a || !b) return new BigNumber(NaN);
  6574. // Signs differ?
  6575. if (a != b) {
  6576. y.s = -b;
  6577. return x.minus(y);
  6578. }
  6579. var xe = x.e / LOG_BASE,
  6580. ye = y.e / LOG_BASE,
  6581. xc = x.c,
  6582. yc = y.c;
  6583. if (!xe || !ye) {
  6584. // Return ±Infinity if either ±Infinity.
  6585. if (!xc || !yc) return new BigNumber(a / 0);
  6586. // Either zero?
  6587. // Return y if y is non-zero, x if x is non-zero, or zero if both are zero.
  6588. if (!xc[0] || !yc[0]) return yc[0] ? y : new BigNumber(xc[0] ? x : a * 0);
  6589. }
  6590. xe = bitFloor(xe);
  6591. ye = bitFloor(ye);
  6592. xc = xc.slice();
  6593. // Prepend zeros to equalise exponents. Faster to use reverse then do unshifts.
  6594. if (a = xe - ye) {
  6595. if (a > 0) {
  6596. ye = xe;
  6597. t = yc;
  6598. } else {
  6599. a = -a;
  6600. t = xc;
  6601. }
  6602. t.reverse();
  6603. for (; a--; t.push(0));
  6604. t.reverse();
  6605. }
  6606. a = xc.length;
  6607. b = yc.length;
  6608. // Point xc to the longer array, and b to the shorter length.
  6609. if (a - b < 0) {
  6610. t = yc;
  6611. yc = xc;
  6612. xc = t;
  6613. b = a;
  6614. }
  6615. // Only start adding at yc.length - 1 as the further digits of xc can be ignored.
  6616. for (a = 0; b;) {
  6617. a = (xc[--b] = xc[b] + yc[b] + a) / BASE | 0;
  6618. xc[b] = BASE === xc[b] ? 0 : xc[b] % BASE;
  6619. }
  6620. if (a) {
  6621. xc = [a].concat(xc);
  6622. ++ye;
  6623. }
  6624. // No need to check for zero, as +x + +y != 0 && -x + -y != 0
  6625. // ye = MAX_EXP + 1 possible
  6626. return normalise(y, xc, ye);
  6627. };
  6628. /*
  6629. * If sd is undefined or null or true or false, return the number of significant digits of
  6630. * the value of this BigNumber, or null if the value of this BigNumber is ±Infinity or NaN.
  6631. * If sd is true include integer-part trailing zeros in the count.
  6632. *
  6633. * Otherwise, if sd is a number, return a new BigNumber whose value is the value of this
  6634. * BigNumber rounded to a maximum of sd significant digits using rounding mode rm, or
  6635. * ROUNDING_MODE if rm is omitted.
  6636. *
  6637. * sd {number|boolean} number: significant digits: integer, 1 to MAX inclusive.
  6638. * boolean: whether to count integer-part trailing zeros: true or false.
  6639. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  6640. *
  6641. * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {sd|rm}'
  6642. */
  6643. P.precision = P.sd = function (sd, rm) {
  6644. var c, n, v,
  6645. x = this;
  6646. if (sd != null && sd !== !!sd) {
  6647. intCheck(sd, 1, MAX);
  6648. if (rm == null) rm = ROUNDING_MODE;
  6649. else intCheck(rm, 0, 8);
  6650. return round(new BigNumber(x), sd, rm);
  6651. }
  6652. if (!(c = x.c)) return null;
  6653. v = c.length - 1;
  6654. n = v * LOG_BASE + 1;
  6655. if (v = c[v]) {
  6656. // Subtract the number of trailing zeros of the last element.
  6657. for (; v % 10 == 0; v /= 10, n--);
  6658. // Add the number of digits of the first element.
  6659. for (v = c[0]; v >= 10; v /= 10, n++);
  6660. }
  6661. if (sd && x.e + 1 > n) n = x.e + 1;
  6662. return n;
  6663. };
  6664. /*
  6665. * Return a new BigNumber whose value is the value of this BigNumber shifted by k places
  6666. * (powers of 10). Shift to the right if n > 0, and to the left if n < 0.
  6667. *
  6668. * k {number} Integer, -MAX_SAFE_INTEGER to MAX_SAFE_INTEGER inclusive.
  6669. *
  6670. * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {k}'
  6671. */
  6672. P.shiftedBy = function (k) {
  6673. intCheck(k, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);
  6674. return this.times('1e' + k);
  6675. };
  6676. /*
  6677. * sqrt(-n) = N
  6678. * sqrt(N) = N
  6679. * sqrt(-I) = N
  6680. * sqrt(I) = I
  6681. * sqrt(0) = 0
  6682. * sqrt(-0) = -0
  6683. *
  6684. * Return a new BigNumber whose value is the square root of the value of this BigNumber,
  6685. * rounded according to DECIMAL_PLACES and ROUNDING_MODE.
  6686. */
  6687. P.squareRoot = P.sqrt = function () {
  6688. var m, n, r, rep, t,
  6689. x = this,
  6690. c = x.c,
  6691. s = x.s,
  6692. e = x.e,
  6693. dp = DECIMAL_PLACES + 4,
  6694. half = new BigNumber('0.5');
  6695. // Negative/NaN/Infinity/zero?
  6696. if (s !== 1 || !c || !c[0]) {
  6697. return new BigNumber(!s || s < 0 && (!c || c[0]) ? NaN : c ? x : 1 / 0);
  6698. }
  6699. // Initial estimate.
  6700. s = Math.sqrt(+valueOf(x));
  6701. // Math.sqrt underflow/overflow?
  6702. // Pass x to Math.sqrt as integer, then adjust the exponent of the result.
  6703. if (s == 0 || s == 1 / 0) {
  6704. n = coeffToString(c);
  6705. if ((n.length + e) % 2 == 0) n += '0';
  6706. s = Math.sqrt(+n);
  6707. e = bitFloor((e + 1) / 2) - (e < 0 || e % 2);
  6708. if (s == 1 / 0) {
  6709. n = '5e' + e;
  6710. } else {
  6711. n = s.toExponential();
  6712. n = n.slice(0, n.indexOf('e') + 1) + e;
  6713. }
  6714. r = new BigNumber(n);
  6715. } else {
  6716. r = new BigNumber(s + '');
  6717. }
  6718. // Check for zero.
  6719. // r could be zero if MIN_EXP is changed after the this value was created.
  6720. // This would cause a division by zero (x/t) and hence Infinity below, which would cause
  6721. // coeffToString to throw.
  6722. if (r.c[0]) {
  6723. e = r.e;
  6724. s = e + dp;
  6725. if (s < 3) s = 0;
  6726. // Newton-Raphson iteration.
  6727. for (; ;) {
  6728. t = r;
  6729. r = half.times(t.plus(div(x, t, dp, 1)));
  6730. if (coeffToString(t.c).slice(0, s) === (n = coeffToString(r.c)).slice(0, s)) {
  6731. // The exponent of r may here be one less than the final result exponent,
  6732. // e.g 0.0009999 (e-4) --> 0.001 (e-3), so adjust s so the rounding digits
  6733. // are indexed correctly.
  6734. if (r.e < e) --s;
  6735. n = n.slice(s - 3, s + 1);
  6736. // The 4th rounding digit may be in error by -1 so if the 4 rounding digits
  6737. // are 9999 or 4999 (i.e. approaching a rounding boundary) continue the
  6738. // iteration.
  6739. if (n == '9999' || !rep && n == '4999') {
  6740. // On the first iteration only, check to see if rounding up gives the
  6741. // exact result as the nines may infinitely repeat.
  6742. if (!rep) {
  6743. round(t, t.e + DECIMAL_PLACES + 2, 0);
  6744. if (t.times(t).eq(x)) {
  6745. r = t;
  6746. break;
  6747. }
  6748. }
  6749. dp += 4;
  6750. s += 4;
  6751. rep = 1;
  6752. } else {
  6753. // If rounding digits are null, 0{0,4} or 50{0,3}, check for exact
  6754. // result. If not, then there are further digits and m will be truthy.
  6755. if (!+n || !+n.slice(1) && n.charAt(0) == '5') {
  6756. // Truncate to the first rounding digit.
  6757. round(r, r.e + DECIMAL_PLACES + 2, 1);
  6758. m = !r.times(r).eq(x);
  6759. }
  6760. break;
  6761. }
  6762. }
  6763. }
  6764. }
  6765. return round(r, r.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m);
  6766. };
  6767. /*
  6768. * Return a string representing the value of this BigNumber in exponential notation and
  6769. * rounded using ROUNDING_MODE to dp fixed decimal places.
  6770. *
  6771. * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
  6772. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  6773. *
  6774. * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}'
  6775. */
  6776. P.toExponential = function (dp, rm) {
  6777. if (dp != null) {
  6778. intCheck(dp, 0, MAX);
  6779. dp++;
  6780. }
  6781. return format(this, dp, rm, 1);
  6782. };
  6783. /*
  6784. * Return a string representing the value of this BigNumber in fixed-point notation rounding
  6785. * to dp fixed decimal places using rounding mode rm, or ROUNDING_MODE if rm is omitted.
  6786. *
  6787. * Note: as with JavaScript's number type, (-0).toFixed(0) is '0',
  6788. * but e.g. (-0.00001).toFixed(0) is '-0'.
  6789. *
  6790. * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
  6791. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  6792. *
  6793. * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}'
  6794. */
  6795. P.toFixed = function (dp, rm) {
  6796. if (dp != null) {
  6797. intCheck(dp, 0, MAX);
  6798. dp = dp + this.e + 1;
  6799. }
  6800. return format(this, dp, rm);
  6801. };
  6802. /*
  6803. * Return a string representing the value of this BigNumber in fixed-point notation rounded
  6804. * using rm or ROUNDING_MODE to dp decimal places, and formatted according to the properties
  6805. * of the format or FORMAT object (see BigNumber.set).
  6806. *
  6807. * The formatting object may contain some or all of the properties shown below.
  6808. *
  6809. * FORMAT = {
  6810. * prefix: '',
  6811. * groupSize: 3,
  6812. * secondaryGroupSize: 0,
  6813. * groupSeparator: ',',
  6814. * decimalSeparator: '.',
  6815. * fractionGroupSize: 0,
  6816. * fractionGroupSeparator: '\xA0', // non-breaking space
  6817. * suffix: ''
  6818. * };
  6819. *
  6820. * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
  6821. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  6822. * [format] {object} Formatting options. See FORMAT pbject above.
  6823. *
  6824. * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}'
  6825. * '[BigNumber Error] Argument not an object: {format}'
  6826. */
  6827. P.toFormat = function (dp, rm, format) {
  6828. var str,
  6829. x = this;
  6830. if (format == null) {
  6831. if (dp != null && rm && typeof rm == 'object') {
  6832. format = rm;
  6833. rm = null;
  6834. } else if (dp && typeof dp == 'object') {
  6835. format = dp;
  6836. dp = rm = null;
  6837. } else {
  6838. format = FORMAT;
  6839. }
  6840. } else if (typeof format != 'object') {
  6841. throw Error
  6842. (bignumberError + 'Argument not an object: ' + format);
  6843. }
  6844. str = x.toFixed(dp, rm);
  6845. if (x.c) {
  6846. var i,
  6847. arr = str.split('.'),
  6848. g1 = +format.groupSize,
  6849. g2 = +format.secondaryGroupSize,
  6850. groupSeparator = format.groupSeparator || '',
  6851. intPart = arr[0],
  6852. fractionPart = arr[1],
  6853. isNeg = x.s < 0,
  6854. intDigits = isNeg ? intPart.slice(1) : intPart,
  6855. len = intDigits.length;
  6856. if (g2) {
  6857. i = g1;
  6858. g1 = g2;
  6859. g2 = i;
  6860. len -= i;
  6861. }
  6862. if (g1 > 0 && len > 0) {
  6863. i = len % g1 || g1;
  6864. intPart = intDigits.substr(0, i);
  6865. for (; i < len; i += g1) intPart += groupSeparator + intDigits.substr(i, g1);
  6866. if (g2 > 0) intPart += groupSeparator + intDigits.slice(i);
  6867. if (isNeg) intPart = '-' + intPart;
  6868. }
  6869. str = fractionPart
  6870. ? intPart + (format.decimalSeparator || '') + ((g2 = +format.fractionGroupSize)
  6871. ? fractionPart.replace(new RegExp('\\d{' + g2 + '}\\B', 'g'),
  6872. '$&' + (format.fractionGroupSeparator || ''))
  6873. : fractionPart)
  6874. : intPart;
  6875. }
  6876. return (format.prefix || '') + str + (format.suffix || '');
  6877. };
  6878. /*
  6879. * Return an array of two BigNumbers representing the value of this BigNumber as a simple
  6880. * fraction with an integer numerator and an integer denominator.
  6881. * The denominator will be a positive non-zero value less than or equal to the specified
  6882. * maximum denominator. If a maximum denominator is not specified, the denominator will be
  6883. * the lowest value necessary to represent the number exactly.
  6884. *
  6885. * [md] {number|string|BigNumber} Integer >= 1, or Infinity. The maximum denominator.
  6886. *
  6887. * '[BigNumber Error] Argument {not an integer|out of range} : {md}'
  6888. */
  6889. P.toFraction = function (md) {
  6890. var d, d0, d1, d2, e, exp, n, n0, n1, q, r, s,
  6891. x = this,
  6892. xc = x.c;
  6893. if (md != null) {
  6894. n = new BigNumber(md);
  6895. // Throw if md is less than one or is not an integer, unless it is Infinity.
  6896. if (!n.isInteger() && (n.c || n.s !== 1) || n.lt(ONE)) {
  6897. throw Error
  6898. (bignumberError + 'Argument ' +
  6899. (n.isInteger() ? 'out of range: ' : 'not an integer: ') + valueOf(n));
  6900. }
  6901. }
  6902. if (!xc) return new BigNumber(x);
  6903. d = new BigNumber(ONE);
  6904. n1 = d0 = new BigNumber(ONE);
  6905. d1 = n0 = new BigNumber(ONE);
  6906. s = coeffToString(xc);
  6907. // Determine initial denominator.
  6908. // d is a power of 10 and the minimum max denominator that specifies the value exactly.
  6909. e = d.e = s.length - x.e - 1;
  6910. d.c[0] = POWS_TEN[(exp = e % LOG_BASE) < 0 ? LOG_BASE + exp : exp];
  6911. md = !md || n.comparedTo(d) > 0 ? (e > 0 ? d : n1) : n;
  6912. exp = MAX_EXP;
  6913. MAX_EXP = 1 / 0;
  6914. n = new BigNumber(s);
  6915. // n0 = d1 = 0
  6916. n0.c[0] = 0;
  6917. for (; ;) {
  6918. q = div(n, d, 0, 1);
  6919. d2 = d0.plus(q.times(d1));
  6920. if (d2.comparedTo(md) == 1) break;
  6921. d0 = d1;
  6922. d1 = d2;
  6923. n1 = n0.plus(q.times(d2 = n1));
  6924. n0 = d2;
  6925. d = n.minus(q.times(d2 = d));
  6926. n = d2;
  6927. }
  6928. d2 = div(md.minus(d0), d1, 0, 1);
  6929. n0 = n0.plus(d2.times(n1));
  6930. d0 = d0.plus(d2.times(d1));
  6931. n0.s = n1.s = x.s;
  6932. e = e * 2;
  6933. // Determine which fraction is closer to x, n0/d0 or n1/d1
  6934. r = div(n1, d1, e, ROUNDING_MODE).minus(x).abs().comparedTo(
  6935. div(n0, d0, e, ROUNDING_MODE).minus(x).abs()) < 1 ? [n1, d1] : [n0, d0];
  6936. MAX_EXP = exp;
  6937. return r;
  6938. };
  6939. /*
  6940. * Return the value of this BigNumber converted to a number primitive.
  6941. */
  6942. P.toNumber = function () {
  6943. return +valueOf(this);
  6944. };
  6945. /*
  6946. * Return a string representing the value of this BigNumber rounded to sd significant digits
  6947. * using rounding mode rm or ROUNDING_MODE. If sd is less than the number of digits
  6948. * necessary to represent the integer part of the value in fixed-point notation, then use
  6949. * exponential notation.
  6950. *
  6951. * [sd] {number} Significant digits. Integer, 1 to MAX inclusive.
  6952. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  6953. *
  6954. * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {sd|rm}'
  6955. */
  6956. P.toPrecision = function (sd, rm) {
  6957. if (sd != null) intCheck(sd, 1, MAX);
  6958. return format(this, sd, rm, 2);
  6959. };
  6960. /*
  6961. * Return a string representing the value of this BigNumber in base b, or base 10 if b is
  6962. * omitted. If a base is specified, including base 10, round according to DECIMAL_PLACES and
  6963. * ROUNDING_MODE. If a base is not specified, and this BigNumber has a positive exponent
  6964. * that is equal to or greater than TO_EXP_POS, or a negative exponent equal to or less than
  6965. * TO_EXP_NEG, return exponential notation.
  6966. *
  6967. * [b] {number} Integer, 2 to ALPHABET.length inclusive.
  6968. *
  6969. * '[BigNumber Error] Base {not a primitive number|not an integer|out of range}: {b}'
  6970. */
  6971. P.toString = function (b) {
  6972. var str,
  6973. n = this,
  6974. s = n.s,
  6975. e = n.e;
  6976. // Infinity or NaN?
  6977. if (e === null) {
  6978. if (s) {
  6979. str = 'Infinity';
  6980. if (s < 0) str = '-' + str;
  6981. } else {
  6982. str = 'NaN';
  6983. }
  6984. } else {
  6985. if (b == null) {
  6986. str = e <= TO_EXP_NEG || e >= TO_EXP_POS
  6987. ? toExponential(coeffToString(n.c), e)
  6988. : toFixedPoint(coeffToString(n.c), e, '0');
  6989. } else if (b === 10 && alphabetHasNormalDecimalDigits) {
  6990. n = round(new BigNumber(n), DECIMAL_PLACES + e + 1, ROUNDING_MODE);
  6991. str = toFixedPoint(coeffToString(n.c), n.e, '0');
  6992. } else {
  6993. intCheck(b, 2, ALPHABET.length, 'Base');
  6994. str = convertBase(toFixedPoint(coeffToString(n.c), e, '0'), 10, b, s, true);
  6995. }
  6996. if (s < 0 && n.c[0]) str = '-' + str;
  6997. }
  6998. return str;
  6999. };
  7000. /*
  7001. * Return as toString, but do not accept a base argument, and include the minus sign for
  7002. * negative zero.
  7003. */
  7004. P.valueOf = P.toJSON = function () {
  7005. return valueOf(this);
  7006. };
  7007. P._isBigNumber = true;
  7008. if (configObject != null) BigNumber.set(configObject);
  7009. return BigNumber;
  7010. }
  7011. // PRIVATE HELPER FUNCTIONS
  7012. // These functions don't need access to variables,
  7013. // e.g. DECIMAL_PLACES, in the scope of the `clone` function above.
  7014. function bitFloor(n) {
  7015. var i = n | 0;
  7016. return n > 0 || n === i ? i : i - 1;
  7017. }
  7018. // Return a coefficient array as a string of base 10 digits.
  7019. function coeffToString(a) {
  7020. var s, z,
  7021. i = 1,
  7022. j = a.length,
  7023. r = a[0] + '';
  7024. for (; i < j;) {
  7025. s = a[i++] + '';
  7026. z = LOG_BASE - s.length;
  7027. for (; z--; s = '0' + s);
  7028. r += s;
  7029. }
  7030. // Determine trailing zeros.
  7031. for (j = r.length; r.charCodeAt(--j) === 48;);
  7032. return r.slice(0, j + 1 || 1);
  7033. }
  7034. // Compare the value of BigNumbers x and y.
  7035. function compare(x, y) {
  7036. var a, b,
  7037. xc = x.c,
  7038. yc = y.c,
  7039. i = x.s,
  7040. j = y.s,
  7041. k = x.e,
  7042. l = y.e;
  7043. // Either NaN?
  7044. if (!i || !j) return null;
  7045. a = xc && !xc[0];
  7046. b = yc && !yc[0];
  7047. // Either zero?
  7048. if (a || b) return a ? b ? 0 : -j : i;
  7049. // Signs differ?
  7050. if (i != j) return i;
  7051. a = i < 0;
  7052. b = k == l;
  7053. // Either Infinity?
  7054. if (!xc || !yc) return b ? 0 : !xc ^ a ? 1 : -1;
  7055. // Compare exponents.
  7056. if (!b) return k > l ^ a ? 1 : -1;
  7057. j = (k = xc.length) < (l = yc.length) ? k : l;
  7058. // Compare digit by digit.
  7059. for (i = 0; i < j; i++) if (xc[i] != yc[i]) return xc[i] > yc[i] ^ a ? 1 : -1;
  7060. // Compare lengths.
  7061. return k == l ? 0 : k > l ^ a ? 1 : -1;
  7062. }
  7063. /*
  7064. * Check that n is a primitive number, an integer, and in range, otherwise throw.
  7065. */
  7066. function intCheck(n, min, max, name) {
  7067. if (n < min || n > max || n !== mathfloor(n)) {
  7068. throw Error
  7069. (bignumberError + (name || 'Argument') + (typeof n == 'number'
  7070. ? n < min || n > max ? ' out of range: ' : ' not an integer: '
  7071. : ' not a primitive number: ') + String(n));
  7072. }
  7073. }
  7074. // Assumes finite n.
  7075. function isOdd(n) {
  7076. var k = n.c.length - 1;
  7077. return bitFloor(n.e / LOG_BASE) == k && n.c[k] % 2 != 0;
  7078. }
  7079. function toExponential(str, e) {
  7080. return (str.length > 1 ? str.charAt(0) + '.' + str.slice(1) : str) +
  7081. (e < 0 ? 'e' : 'e+') + e;
  7082. }
  7083. function toFixedPoint(str, e, z) {
  7084. var len, zs;
  7085. // Negative exponent?
  7086. if (e < 0) {
  7087. // Prepend zeros.
  7088. for (zs = z + '.'; ++e; zs += z);
  7089. str = zs + str;
  7090. // Positive exponent
  7091. } else {
  7092. len = str.length;
  7093. // Append zeros.
  7094. if (++e > len) {
  7095. for (zs = z, e -= len; --e; zs += z);
  7096. str += zs;
  7097. } else if (e < len) {
  7098. str = str.slice(0, e) + '.' + str.slice(e);
  7099. }
  7100. }
  7101. return str;
  7102. }
  7103. // EXPORT
  7104. BigNumber = clone();
  7105. BigNumber['default'] = BigNumber.BigNumber = BigNumber;
  7106. // AMD.
  7107. if (true) {
  7108. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () { return BigNumber; }).call(exports, __webpack_require__, exports, module),
  7109. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  7110. // Node.js and other environments that support module.exports.
  7111. } else {}
  7112. })(this);
  7113. /***/ }),
  7114. /***/ "../../node_modules/bip32/src/bip32.js":
  7115. /*!*********************************************!*\
  7116. !*** ../../node_modules/bip32/src/bip32.js ***!
  7117. \*********************************************/
  7118. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7119. "use strict";
  7120. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js")["Buffer"];
  7121. Object.defineProperty(exports, "__esModule", ({ value: true }));
  7122. const crypto = __webpack_require__(/*! ./crypto */ "../../node_modules/bip32/src/crypto.js");
  7123. const bs58check = __webpack_require__(/*! bs58check */ "../../node_modules/bs58check/index.js");
  7124. const ecc = __webpack_require__(/*! tiny-secp256k1 */ "../../node_modules/tiny-secp256k1/js.js");
  7125. const typeforce = __webpack_require__(/*! typeforce */ "../../node_modules/typeforce/index.js");
  7126. const wif = __webpack_require__(/*! wif */ "../../node_modules/wif/index.js");
  7127. const UINT256_TYPE = typeforce.BufferN(32);
  7128. const NETWORK_TYPE = typeforce.compile({
  7129. wif: typeforce.UInt8,
  7130. bip32: {
  7131. public: typeforce.UInt32,
  7132. private: typeforce.UInt32,
  7133. },
  7134. });
  7135. const BITCOIN = {
  7136. messagePrefix: '\x18Bitcoin Signed Message:\n',
  7137. bech32: 'bc',
  7138. bip32: {
  7139. public: 0x0488b21e,
  7140. private: 0x0488ade4,
  7141. },
  7142. pubKeyHash: 0x00,
  7143. scriptHash: 0x05,
  7144. wif: 0x80,
  7145. };
  7146. const HIGHEST_BIT = 0x80000000;
  7147. const UINT31_MAX = Math.pow(2, 31) - 1;
  7148. function BIP32Path(value) {
  7149. return (typeforce.String(value) && value.match(/^(m\/)?(\d+'?\/)*\d+'?$/) !== null);
  7150. }
  7151. function UInt31(value) {
  7152. return typeforce.UInt32(value) && value <= UINT31_MAX;
  7153. }
  7154. class BIP32 {
  7155. constructor(__D, __Q, chainCode, network, __DEPTH = 0, __INDEX = 0, __PARENT_FINGERPRINT = 0x00000000) {
  7156. this.__D = __D;
  7157. this.__Q = __Q;
  7158. this.chainCode = chainCode;
  7159. this.network = network;
  7160. this.__DEPTH = __DEPTH;
  7161. this.__INDEX = __INDEX;
  7162. this.__PARENT_FINGERPRINT = __PARENT_FINGERPRINT;
  7163. typeforce(NETWORK_TYPE, network);
  7164. this.lowR = false;
  7165. }
  7166. get depth() {
  7167. return this.__DEPTH;
  7168. }
  7169. get index() {
  7170. return this.__INDEX;
  7171. }
  7172. get parentFingerprint() {
  7173. return this.__PARENT_FINGERPRINT;
  7174. }
  7175. get publicKey() {
  7176. if (this.__Q === undefined)
  7177. this.__Q = ecc.pointFromScalar(this.__D, true);
  7178. return this.__Q;
  7179. }
  7180. get privateKey() {
  7181. return this.__D;
  7182. }
  7183. get identifier() {
  7184. return crypto.hash160(this.publicKey);
  7185. }
  7186. get fingerprint() {
  7187. return this.identifier.slice(0, 4);
  7188. }
  7189. get compressed() {
  7190. return true;
  7191. }
  7192. // Private === not neutered
  7193. // Public === neutered
  7194. isNeutered() {
  7195. return this.__D === undefined;
  7196. }
  7197. neutered() {
  7198. return fromPublicKeyLocal(this.publicKey, this.chainCode, this.network, this.depth, this.index, this.parentFingerprint);
  7199. }
  7200. toBase58() {
  7201. const network = this.network;
  7202. const version = !this.isNeutered()
  7203. ? network.bip32.private
  7204. : network.bip32.public;
  7205. const buffer = Buffer.allocUnsafe(78);
  7206. // 4 bytes: version bytes
  7207. buffer.writeUInt32BE(version, 0);
  7208. // 1 byte: depth: 0x00 for master nodes, 0x01 for level-1 descendants, ....
  7209. buffer.writeUInt8(this.depth, 4);
  7210. // 4 bytes: the fingerprint of the parent's key (0x00000000 if master key)
  7211. buffer.writeUInt32BE(this.parentFingerprint, 5);
  7212. // 4 bytes: child number. This is the number i in xi = xpar/i, with xi the key being serialized.
  7213. // This is encoded in big endian. (0x00000000 if master key)
  7214. buffer.writeUInt32BE(this.index, 9);
  7215. // 32 bytes: the chain code
  7216. this.chainCode.copy(buffer, 13);
  7217. // 33 bytes: the public key or private key data
  7218. if (!this.isNeutered()) {
  7219. // 0x00 + k for private keys
  7220. buffer.writeUInt8(0, 45);
  7221. this.privateKey.copy(buffer, 46);
  7222. // 33 bytes: the public key
  7223. }
  7224. else {
  7225. // X9.62 encoding for public keys
  7226. this.publicKey.copy(buffer, 45);
  7227. }
  7228. return bs58check.encode(buffer);
  7229. }
  7230. toWIF() {
  7231. if (!this.privateKey)
  7232. throw new TypeError('Missing private key');
  7233. return wif.encode(this.network.wif, this.privateKey, true);
  7234. }
  7235. // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#child-key-derivation-ckd-functions
  7236. derive(index) {
  7237. typeforce(typeforce.UInt32, index);
  7238. const isHardened = index >= HIGHEST_BIT;
  7239. const data = Buffer.allocUnsafe(37);
  7240. // Hardened child
  7241. if (isHardened) {
  7242. if (this.isNeutered())
  7243. throw new TypeError('Missing private key for hardened child key');
  7244. // data = 0x00 || ser256(kpar) || ser32(index)
  7245. data[0] = 0x00;
  7246. this.privateKey.copy(data, 1);
  7247. data.writeUInt32BE(index, 33);
  7248. // Normal child
  7249. }
  7250. else {
  7251. // data = serP(point(kpar)) || ser32(index)
  7252. // = serP(Kpar) || ser32(index)
  7253. this.publicKey.copy(data, 0);
  7254. data.writeUInt32BE(index, 33);
  7255. }
  7256. const I = crypto.hmacSHA512(this.chainCode, data);
  7257. const IL = I.slice(0, 32);
  7258. const IR = I.slice(32);
  7259. // if parse256(IL) >= n, proceed with the next value for i
  7260. if (!ecc.isPrivate(IL))
  7261. return this.derive(index + 1);
  7262. // Private parent key -> private child key
  7263. let hd;
  7264. if (!this.isNeutered()) {
  7265. // ki = parse256(IL) + kpar (mod n)
  7266. const ki = ecc.privateAdd(this.privateKey, IL);
  7267. // In case ki == 0, proceed with the next value for i
  7268. if (ki == null)
  7269. return this.derive(index + 1);
  7270. hd = fromPrivateKeyLocal(ki, IR, this.network, this.depth + 1, index, this.fingerprint.readUInt32BE(0));
  7271. // Public parent key -> public child key
  7272. }
  7273. else {
  7274. // Ki = point(parse256(IL)) + Kpar
  7275. // = G*IL + Kpar
  7276. const Ki = ecc.pointAddScalar(this.publicKey, IL, true);
  7277. // In case Ki is the point at infinity, proceed with the next value for i
  7278. if (Ki === null)
  7279. return this.derive(index + 1);
  7280. hd = fromPublicKeyLocal(Ki, IR, this.network, this.depth + 1, index, this.fingerprint.readUInt32BE(0));
  7281. }
  7282. return hd;
  7283. }
  7284. deriveHardened(index) {
  7285. typeforce(UInt31, index);
  7286. // Only derives hardened private keys by default
  7287. return this.derive(index + HIGHEST_BIT);
  7288. }
  7289. derivePath(path) {
  7290. typeforce(BIP32Path, path);
  7291. let splitPath = path.split('/');
  7292. if (splitPath[0] === 'm') {
  7293. if (this.parentFingerprint)
  7294. throw new TypeError('Expected master, got child');
  7295. splitPath = splitPath.slice(1);
  7296. }
  7297. return splitPath.reduce((prevHd, indexStr) => {
  7298. let index;
  7299. if (indexStr.slice(-1) === `'`) {
  7300. index = parseInt(indexStr.slice(0, -1), 10);
  7301. return prevHd.deriveHardened(index);
  7302. }
  7303. else {
  7304. index = parseInt(indexStr, 10);
  7305. return prevHd.derive(index);
  7306. }
  7307. }, this);
  7308. }
  7309. sign(hash, lowR) {
  7310. if (!this.privateKey)
  7311. throw new Error('Missing private key');
  7312. if (lowR === undefined)
  7313. lowR = this.lowR;
  7314. if (lowR === false) {
  7315. return ecc.sign(hash, this.privateKey);
  7316. }
  7317. else {
  7318. let sig = ecc.sign(hash, this.privateKey);
  7319. const extraData = Buffer.alloc(32, 0);
  7320. let counter = 0;
  7321. // if first try is lowR, skip the loop
  7322. // for second try and on, add extra entropy counting up
  7323. while (sig[0] > 0x7f) {
  7324. counter++;
  7325. extraData.writeUIntLE(counter, 0, 6);
  7326. sig = ecc.signWithEntropy(hash, this.privateKey, extraData);
  7327. }
  7328. return sig;
  7329. }
  7330. }
  7331. verify(hash, signature) {
  7332. return ecc.verify(hash, this.publicKey, signature);
  7333. }
  7334. }
  7335. function fromBase58(inString, network) {
  7336. const buffer = bs58check.decode(inString);
  7337. if (buffer.length !== 78)
  7338. throw new TypeError('Invalid buffer length');
  7339. network = network || BITCOIN;
  7340. // 4 bytes: version bytes
  7341. const version = buffer.readUInt32BE(0);
  7342. if (version !== network.bip32.private && version !== network.bip32.public)
  7343. throw new TypeError('Invalid network version');
  7344. // 1 byte: depth: 0x00 for master nodes, 0x01 for level-1 descendants, ...
  7345. const depth = buffer[4];
  7346. // 4 bytes: the fingerprint of the parent's key (0x00000000 if master key)
  7347. const parentFingerprint = buffer.readUInt32BE(5);
  7348. if (depth === 0) {
  7349. if (parentFingerprint !== 0x00000000)
  7350. throw new TypeError('Invalid parent fingerprint');
  7351. }
  7352. // 4 bytes: child number. This is the number i in xi = xpar/i, with xi the key being serialized.
  7353. // This is encoded in MSB order. (0x00000000 if master key)
  7354. const index = buffer.readUInt32BE(9);
  7355. if (depth === 0 && index !== 0)
  7356. throw new TypeError('Invalid index');
  7357. // 32 bytes: the chain code
  7358. const chainCode = buffer.slice(13, 45);
  7359. let hd;
  7360. // 33 bytes: private key data (0x00 + k)
  7361. if (version === network.bip32.private) {
  7362. if (buffer.readUInt8(45) !== 0x00)
  7363. throw new TypeError('Invalid private key');
  7364. const k = buffer.slice(46, 78);
  7365. hd = fromPrivateKeyLocal(k, chainCode, network, depth, index, parentFingerprint);
  7366. // 33 bytes: public key data (0x02 + X or 0x03 + X)
  7367. }
  7368. else {
  7369. const X = buffer.slice(45, 78);
  7370. hd = fromPublicKeyLocal(X, chainCode, network, depth, index, parentFingerprint);
  7371. }
  7372. return hd;
  7373. }
  7374. exports.fromBase58 = fromBase58;
  7375. function fromPrivateKey(privateKey, chainCode, network) {
  7376. return fromPrivateKeyLocal(privateKey, chainCode, network);
  7377. }
  7378. exports.fromPrivateKey = fromPrivateKey;
  7379. function fromPrivateKeyLocal(privateKey, chainCode, network, depth, index, parentFingerprint) {
  7380. typeforce({
  7381. privateKey: UINT256_TYPE,
  7382. chainCode: UINT256_TYPE,
  7383. }, { privateKey, chainCode });
  7384. network = network || BITCOIN;
  7385. if (!ecc.isPrivate(privateKey))
  7386. throw new TypeError('Private key not in range [1, n)');
  7387. return new BIP32(privateKey, undefined, chainCode, network, depth, index, parentFingerprint);
  7388. }
  7389. function fromPublicKey(publicKey, chainCode, network) {
  7390. return fromPublicKeyLocal(publicKey, chainCode, network);
  7391. }
  7392. exports.fromPublicKey = fromPublicKey;
  7393. function fromPublicKeyLocal(publicKey, chainCode, network, depth, index, parentFingerprint) {
  7394. typeforce({
  7395. publicKey: typeforce.BufferN(33),
  7396. chainCode: UINT256_TYPE,
  7397. }, { publicKey, chainCode });
  7398. network = network || BITCOIN;
  7399. // verify the X coordinate is a point on the curve
  7400. if (!ecc.isPoint(publicKey))
  7401. throw new TypeError('Point is not on the curve');
  7402. return new BIP32(undefined, publicKey, chainCode, network, depth, index, parentFingerprint);
  7403. }
  7404. function fromSeed(seed, network) {
  7405. typeforce(typeforce.Buffer, seed);
  7406. if (seed.length < 16)
  7407. throw new TypeError('Seed should be at least 128 bits');
  7408. if (seed.length > 64)
  7409. throw new TypeError('Seed should be at most 512 bits');
  7410. network = network || BITCOIN;
  7411. const I = crypto.hmacSHA512(Buffer.from('Bitcoin seed', 'utf8'), seed);
  7412. const IL = I.slice(0, 32);
  7413. const IR = I.slice(32);
  7414. return fromPrivateKey(IL, IR, network);
  7415. }
  7416. exports.fromSeed = fromSeed;
  7417. /***/ }),
  7418. /***/ "../../node_modules/bip32/src/crypto.js":
  7419. /*!**********************************************!*\
  7420. !*** ../../node_modules/bip32/src/crypto.js ***!
  7421. \**********************************************/
  7422. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7423. "use strict";
  7424. Object.defineProperty(exports, "__esModule", ({ value: true }));
  7425. const createHash = __webpack_require__(/*! create-hash */ "../../node_modules/create-hash/browser.js");
  7426. const createHmac = __webpack_require__(/*! create-hmac */ "../../node_modules/create-hmac/browser.js");
  7427. function hash160(buffer) {
  7428. const sha256Hash = createHash('sha256')
  7429. .update(buffer)
  7430. .digest();
  7431. try {
  7432. return createHash('rmd160')
  7433. .update(sha256Hash)
  7434. .digest();
  7435. }
  7436. catch (err) {
  7437. return createHash('ripemd160')
  7438. .update(sha256Hash)
  7439. .digest();
  7440. }
  7441. }
  7442. exports.hash160 = hash160;
  7443. function hmacSHA512(key, data) {
  7444. return createHmac('sha512', key)
  7445. .update(data)
  7446. .digest();
  7447. }
  7448. exports.hmacSHA512 = hmacSHA512;
  7449. /***/ }),
  7450. /***/ "../../node_modules/bip32/src/index.js":
  7451. /*!*********************************************!*\
  7452. !*** ../../node_modules/bip32/src/index.js ***!
  7453. \*********************************************/
  7454. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7455. "use strict";
  7456. Object.defineProperty(exports, "__esModule", ({ value: true }));
  7457. var bip32_1 = __webpack_require__(/*! ./bip32 */ "../../node_modules/bip32/src/bip32.js");
  7458. exports.fromSeed = bip32_1.fromSeed;
  7459. exports.fromBase58 = bip32_1.fromBase58;
  7460. exports.fromPublicKey = bip32_1.fromPublicKey;
  7461. exports.fromPrivateKey = bip32_1.fromPrivateKey;
  7462. /***/ }),
  7463. /***/ "../../node_modules/bip39/src/_wordlists.js":
  7464. /*!**************************************************!*\
  7465. !*** ../../node_modules/bip39/src/_wordlists.js ***!
  7466. \**************************************************/
  7467. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7468. "use strict";
  7469. Object.defineProperty(exports, "__esModule", ({ value: true }));
  7470. // browserify by default only pulls in files that are hard coded in requires
  7471. // In order of last to first in this file, the default wordlist will be chosen
  7472. // based on what is present. (Bundles may remove wordlists they don't need)
  7473. const wordlists = {};
  7474. exports.wordlists = wordlists;
  7475. let _default;
  7476. exports._default = _default;
  7477. try {
  7478. exports._default = _default = __webpack_require__(Object(function webpackMissingModule() { var e = new Error("Cannot find module './wordlists/czech.json'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()));
  7479. wordlists.czech = _default;
  7480. }
  7481. catch (err) { }
  7482. try {
  7483. exports._default = _default = __webpack_require__(Object(function webpackMissingModule() { var e = new Error("Cannot find module './wordlists/chinese_simplified.json'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()));
  7484. wordlists.chinese_simplified = _default;
  7485. }
  7486. catch (err) { }
  7487. try {
  7488. exports._default = _default = __webpack_require__(Object(function webpackMissingModule() { var e = new Error("Cannot find module './wordlists/chinese_traditional.json'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()));
  7489. wordlists.chinese_traditional = _default;
  7490. }
  7491. catch (err) { }
  7492. try {
  7493. exports._default = _default = __webpack_require__(Object(function webpackMissingModule() { var e = new Error("Cannot find module './wordlists/korean.json'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()));
  7494. wordlists.korean = _default;
  7495. }
  7496. catch (err) { }
  7497. try {
  7498. exports._default = _default = __webpack_require__(Object(function webpackMissingModule() { var e = new Error("Cannot find module './wordlists/french.json'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()));
  7499. wordlists.french = _default;
  7500. }
  7501. catch (err) { }
  7502. try {
  7503. exports._default = _default = __webpack_require__(Object(function webpackMissingModule() { var e = new Error("Cannot find module './wordlists/italian.json'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()));
  7504. wordlists.italian = _default;
  7505. }
  7506. catch (err) { }
  7507. try {
  7508. exports._default = _default = __webpack_require__(Object(function webpackMissingModule() { var e = new Error("Cannot find module './wordlists/spanish.json'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()));
  7509. wordlists.spanish = _default;
  7510. }
  7511. catch (err) { }
  7512. try {
  7513. exports._default = _default = __webpack_require__(Object(function webpackMissingModule() { var e = new Error("Cannot find module './wordlists/japanese.json'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()));
  7514. wordlists.japanese = _default;
  7515. wordlists.JA = _default;
  7516. }
  7517. catch (err) { }
  7518. try {
  7519. exports._default = _default = __webpack_require__(Object(function webpackMissingModule() { var e = new Error("Cannot find module './wordlists/portuguese.json'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()));
  7520. wordlists.portuguese = _default;
  7521. }
  7522. catch (err) { }
  7523. try {
  7524. exports._default = _default = __webpack_require__(/*! ./wordlists/english.json */ "../../node_modules/bip39/src/wordlists/english.json");
  7525. wordlists.english = _default;
  7526. wordlists.EN = _default;
  7527. }
  7528. catch (err) { }
  7529. /***/ }),
  7530. /***/ "../../node_modules/bip39/src/index.js":
  7531. /*!*********************************************!*\
  7532. !*** ../../node_modules/bip39/src/index.js ***!
  7533. \*********************************************/
  7534. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7535. "use strict";
  7536. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js")["Buffer"];
  7537. Object.defineProperty(exports, "__esModule", ({ value: true }));
  7538. const createHash = __webpack_require__(/*! create-hash */ "../../node_modules/create-hash/browser.js");
  7539. const pbkdf2_1 = __webpack_require__(/*! pbkdf2 */ "../../node_modules/pbkdf2/browser.js");
  7540. const randomBytes = __webpack_require__(/*! randombytes */ "../../node_modules/randombytes/browser.js");
  7541. const _wordlists_1 = __webpack_require__(/*! ./_wordlists */ "../../node_modules/bip39/src/_wordlists.js");
  7542. let DEFAULT_WORDLIST = _wordlists_1._default;
  7543. const INVALID_MNEMONIC = 'Invalid mnemonic';
  7544. const INVALID_ENTROPY = 'Invalid entropy';
  7545. const INVALID_CHECKSUM = 'Invalid mnemonic checksum';
  7546. const WORDLIST_REQUIRED = 'A wordlist is required but a default could not be found.\n' +
  7547. 'Please pass a 2048 word array explicitly.';
  7548. function pbkdf2Promise(password, saltMixin, iterations, keylen, digest) {
  7549. return Promise.resolve().then(() => new Promise((resolve, reject) => {
  7550. const callback = (err, derivedKey) => {
  7551. if (err) {
  7552. return reject(err);
  7553. }
  7554. else {
  7555. return resolve(derivedKey);
  7556. }
  7557. };
  7558. pbkdf2_1.pbkdf2(password, saltMixin, iterations, keylen, digest, callback);
  7559. }));
  7560. }
  7561. function normalize(str) {
  7562. return (str || '').normalize('NFKD');
  7563. }
  7564. function lpad(str, padString, length) {
  7565. while (str.length < length) {
  7566. str = padString + str;
  7567. }
  7568. return str;
  7569. }
  7570. function binaryToByte(bin) {
  7571. return parseInt(bin, 2);
  7572. }
  7573. function bytesToBinary(bytes) {
  7574. return bytes.map((x) => lpad(x.toString(2), '0', 8)).join('');
  7575. }
  7576. function deriveChecksumBits(entropyBuffer) {
  7577. const ENT = entropyBuffer.length * 8;
  7578. const CS = ENT / 32;
  7579. const hash = createHash('sha256')
  7580. .update(entropyBuffer)
  7581. .digest();
  7582. return bytesToBinary(Array.from(hash)).slice(0, CS);
  7583. }
  7584. function salt(password) {
  7585. return 'mnemonic' + (password || '');
  7586. }
  7587. function mnemonicToSeedSync(mnemonic, password) {
  7588. const mnemonicBuffer = Buffer.from(normalize(mnemonic), 'utf8');
  7589. const saltBuffer = Buffer.from(salt(normalize(password)), 'utf8');
  7590. return pbkdf2_1.pbkdf2Sync(mnemonicBuffer, saltBuffer, 2048, 64, 'sha512');
  7591. }
  7592. exports.mnemonicToSeedSync = mnemonicToSeedSync;
  7593. function mnemonicToSeed(mnemonic, password) {
  7594. return Promise.resolve().then(() => {
  7595. const mnemonicBuffer = Buffer.from(normalize(mnemonic), 'utf8');
  7596. const saltBuffer = Buffer.from(salt(normalize(password)), 'utf8');
  7597. return pbkdf2Promise(mnemonicBuffer, saltBuffer, 2048, 64, 'sha512');
  7598. });
  7599. }
  7600. exports.mnemonicToSeed = mnemonicToSeed;
  7601. function mnemonicToEntropy(mnemonic, wordlist) {
  7602. wordlist = wordlist || DEFAULT_WORDLIST;
  7603. if (!wordlist) {
  7604. throw new Error(WORDLIST_REQUIRED);
  7605. }
  7606. const words = normalize(mnemonic).split(' ');
  7607. if (words.length % 3 !== 0) {
  7608. throw new Error(INVALID_MNEMONIC);
  7609. }
  7610. // convert word indices to 11 bit binary strings
  7611. const bits = words
  7612. .map((word) => {
  7613. const index = wordlist.indexOf(word);
  7614. if (index === -1) {
  7615. throw new Error(INVALID_MNEMONIC);
  7616. }
  7617. return lpad(index.toString(2), '0', 11);
  7618. })
  7619. .join('');
  7620. // split the binary string into ENT/CS
  7621. const dividerIndex = Math.floor(bits.length / 33) * 32;
  7622. const entropyBits = bits.slice(0, dividerIndex);
  7623. const checksumBits = bits.slice(dividerIndex);
  7624. // calculate the checksum and compare
  7625. const entropyBytes = entropyBits.match(/(.{1,8})/g).map(binaryToByte);
  7626. if (entropyBytes.length < 16) {
  7627. throw new Error(INVALID_ENTROPY);
  7628. }
  7629. if (entropyBytes.length > 32) {
  7630. throw new Error(INVALID_ENTROPY);
  7631. }
  7632. if (entropyBytes.length % 4 !== 0) {
  7633. throw new Error(INVALID_ENTROPY);
  7634. }
  7635. const entropy = Buffer.from(entropyBytes);
  7636. const newChecksum = deriveChecksumBits(entropy);
  7637. if (newChecksum !== checksumBits) {
  7638. throw new Error(INVALID_CHECKSUM);
  7639. }
  7640. return entropy.toString('hex');
  7641. }
  7642. exports.mnemonicToEntropy = mnemonicToEntropy;
  7643. function entropyToMnemonic(entropy, wordlist) {
  7644. if (!Buffer.isBuffer(entropy)) {
  7645. entropy = Buffer.from(entropy, 'hex');
  7646. }
  7647. wordlist = wordlist || DEFAULT_WORDLIST;
  7648. if (!wordlist) {
  7649. throw new Error(WORDLIST_REQUIRED);
  7650. }
  7651. // 128 <= ENT <= 256
  7652. if (entropy.length < 16) {
  7653. throw new TypeError(INVALID_ENTROPY);
  7654. }
  7655. if (entropy.length > 32) {
  7656. throw new TypeError(INVALID_ENTROPY);
  7657. }
  7658. if (entropy.length % 4 !== 0) {
  7659. throw new TypeError(INVALID_ENTROPY);
  7660. }
  7661. const entropyBits = bytesToBinary(Array.from(entropy));
  7662. const checksumBits = deriveChecksumBits(entropy);
  7663. const bits = entropyBits + checksumBits;
  7664. const chunks = bits.match(/(.{1,11})/g);
  7665. const words = chunks.map((binary) => {
  7666. const index = binaryToByte(binary);
  7667. return wordlist[index];
  7668. });
  7669. return wordlist[0] === '\u3042\u3044\u3053\u304f\u3057\u3093' // Japanese wordlist
  7670. ? words.join('\u3000')
  7671. : words.join(' ');
  7672. }
  7673. exports.entropyToMnemonic = entropyToMnemonic;
  7674. function generateMnemonic(strength, rng, wordlist) {
  7675. strength = strength || 128;
  7676. if (strength % 32 !== 0) {
  7677. throw new TypeError(INVALID_ENTROPY);
  7678. }
  7679. rng = rng || randomBytes;
  7680. return entropyToMnemonic(rng(strength / 8), wordlist);
  7681. }
  7682. exports.generateMnemonic = generateMnemonic;
  7683. function validateMnemonic(mnemonic, wordlist) {
  7684. try {
  7685. mnemonicToEntropy(mnemonic, wordlist);
  7686. }
  7687. catch (e) {
  7688. return false;
  7689. }
  7690. return true;
  7691. }
  7692. exports.validateMnemonic = validateMnemonic;
  7693. function setDefaultWordlist(language) {
  7694. const result = _wordlists_1.wordlists[language];
  7695. if (result) {
  7696. DEFAULT_WORDLIST = result;
  7697. }
  7698. else {
  7699. throw new Error('Could not find wordlist for language "' + language + '"');
  7700. }
  7701. }
  7702. exports.setDefaultWordlist = setDefaultWordlist;
  7703. function getDefaultWordlist() {
  7704. if (!DEFAULT_WORDLIST) {
  7705. throw new Error('No Default Wordlist set');
  7706. }
  7707. return Object.keys(_wordlists_1.wordlists).filter((lang) => {
  7708. if (lang === 'JA' || lang === 'EN') {
  7709. return false;
  7710. }
  7711. return _wordlists_1.wordlists[lang].every((word, index) => word === DEFAULT_WORDLIST[index]);
  7712. })[0];
  7713. }
  7714. exports.getDefaultWordlist = getDefaultWordlist;
  7715. var _wordlists_2 = __webpack_require__(/*! ./_wordlists */ "../../node_modules/bip39/src/_wordlists.js");
  7716. exports.wordlists = _wordlists_2.wordlists;
  7717. /***/ }),
  7718. /***/ "../../node_modules/bn.js/lib/bn.js":
  7719. /*!******************************************!*\
  7720. !*** ../../node_modules/bn.js/lib/bn.js ***!
  7721. \******************************************/
  7722. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  7723. /* module decorator */ module = __webpack_require__.nmd(module);
  7724. (function (module, exports) {
  7725. 'use strict';
  7726. // Utils
  7727. function assert (val, msg) {
  7728. if (!val) throw new Error(msg || 'Assertion failed');
  7729. }
  7730. // Could use `inherits` module, but don't want to move from single file
  7731. // architecture yet.
  7732. function inherits (ctor, superCtor) {
  7733. ctor.super_ = superCtor;
  7734. var TempCtor = function () {};
  7735. TempCtor.prototype = superCtor.prototype;
  7736. ctor.prototype = new TempCtor();
  7737. ctor.prototype.constructor = ctor;
  7738. }
  7739. // BN
  7740. function BN (number, base, endian) {
  7741. if (BN.isBN(number)) {
  7742. return number;
  7743. }
  7744. this.negative = 0;
  7745. this.words = null;
  7746. this.length = 0;
  7747. // Reduction context
  7748. this.red = null;
  7749. if (number !== null) {
  7750. if (base === 'le' || base === 'be') {
  7751. endian = base;
  7752. base = 10;
  7753. }
  7754. this._init(number || 0, base || 10, endian || 'be');
  7755. }
  7756. }
  7757. if (typeof module === 'object') {
  7758. module.exports = BN;
  7759. } else {
  7760. exports.BN = BN;
  7761. }
  7762. BN.BN = BN;
  7763. BN.wordSize = 26;
  7764. var Buffer;
  7765. try {
  7766. if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') {
  7767. Buffer = window.Buffer;
  7768. } else {
  7769. Buffer = (__webpack_require__(/*! buffer */ "?2e65").Buffer);
  7770. }
  7771. } catch (e) {
  7772. }
  7773. BN.isBN = function isBN (num) {
  7774. if (num instanceof BN) {
  7775. return true;
  7776. }
  7777. return num !== null && typeof num === 'object' &&
  7778. num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
  7779. };
  7780. BN.max = function max (left, right) {
  7781. if (left.cmp(right) > 0) return left;
  7782. return right;
  7783. };
  7784. BN.min = function min (left, right) {
  7785. if (left.cmp(right) < 0) return left;
  7786. return right;
  7787. };
  7788. BN.prototype._init = function init (number, base, endian) {
  7789. if (typeof number === 'number') {
  7790. return this._initNumber(number, base, endian);
  7791. }
  7792. if (typeof number === 'object') {
  7793. return this._initArray(number, base, endian);
  7794. }
  7795. if (base === 'hex') {
  7796. base = 16;
  7797. }
  7798. assert(base === (base | 0) && base >= 2 && base <= 36);
  7799. number = number.toString().replace(/\s+/g, '');
  7800. var start = 0;
  7801. if (number[0] === '-') {
  7802. start++;
  7803. this.negative = 1;
  7804. }
  7805. if (start < number.length) {
  7806. if (base === 16) {
  7807. this._parseHex(number, start, endian);
  7808. } else {
  7809. this._parseBase(number, base, start);
  7810. if (endian === 'le') {
  7811. this._initArray(this.toArray(), base, endian);
  7812. }
  7813. }
  7814. }
  7815. };
  7816. BN.prototype._initNumber = function _initNumber (number, base, endian) {
  7817. if (number < 0) {
  7818. this.negative = 1;
  7819. number = -number;
  7820. }
  7821. if (number < 0x4000000) {
  7822. this.words = [number & 0x3ffffff];
  7823. this.length = 1;
  7824. } else if (number < 0x10000000000000) {
  7825. this.words = [
  7826. number & 0x3ffffff,
  7827. (number / 0x4000000) & 0x3ffffff
  7828. ];
  7829. this.length = 2;
  7830. } else {
  7831. assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
  7832. this.words = [
  7833. number & 0x3ffffff,
  7834. (number / 0x4000000) & 0x3ffffff,
  7835. 1
  7836. ];
  7837. this.length = 3;
  7838. }
  7839. if (endian !== 'le') return;
  7840. // Reverse the bytes
  7841. this._initArray(this.toArray(), base, endian);
  7842. };
  7843. BN.prototype._initArray = function _initArray (number, base, endian) {
  7844. // Perhaps a Uint8Array
  7845. assert(typeof number.length === 'number');
  7846. if (number.length <= 0) {
  7847. this.words = [0];
  7848. this.length = 1;
  7849. return this;
  7850. }
  7851. this.length = Math.ceil(number.length / 3);
  7852. this.words = new Array(this.length);
  7853. for (var i = 0; i < this.length; i++) {
  7854. this.words[i] = 0;
  7855. }
  7856. var j, w;
  7857. var off = 0;
  7858. if (endian === 'be') {
  7859. for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
  7860. w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);
  7861. this.words[j] |= (w << off) & 0x3ffffff;
  7862. this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
  7863. off += 24;
  7864. if (off >= 26) {
  7865. off -= 26;
  7866. j++;
  7867. }
  7868. }
  7869. } else if (endian === 'le') {
  7870. for (i = 0, j = 0; i < number.length; i += 3) {
  7871. w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);
  7872. this.words[j] |= (w << off) & 0x3ffffff;
  7873. this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
  7874. off += 24;
  7875. if (off >= 26) {
  7876. off -= 26;
  7877. j++;
  7878. }
  7879. }
  7880. }
  7881. return this._strip();
  7882. };
  7883. function parseHex4Bits (string, index) {
  7884. var c = string.charCodeAt(index);
  7885. // '0' - '9'
  7886. if (c >= 48 && c <= 57) {
  7887. return c - 48;
  7888. // 'A' - 'F'
  7889. } else if (c >= 65 && c <= 70) {
  7890. return c - 55;
  7891. // 'a' - 'f'
  7892. } else if (c >= 97 && c <= 102) {
  7893. return c - 87;
  7894. } else {
  7895. assert(false, 'Invalid character in ' + string);
  7896. }
  7897. }
  7898. function parseHexByte (string, lowerBound, index) {
  7899. var r = parseHex4Bits(string, index);
  7900. if (index - 1 >= lowerBound) {
  7901. r |= parseHex4Bits(string, index - 1) << 4;
  7902. }
  7903. return r;
  7904. }
  7905. BN.prototype._parseHex = function _parseHex (number, start, endian) {
  7906. // Create possibly bigger array to ensure that it fits the number
  7907. this.length = Math.ceil((number.length - start) / 6);
  7908. this.words = new Array(this.length);
  7909. for (var i = 0; i < this.length; i++) {
  7910. this.words[i] = 0;
  7911. }
  7912. // 24-bits chunks
  7913. var off = 0;
  7914. var j = 0;
  7915. var w;
  7916. if (endian === 'be') {
  7917. for (i = number.length - 1; i >= start; i -= 2) {
  7918. w = parseHexByte(number, start, i) << off;
  7919. this.words[j] |= w & 0x3ffffff;
  7920. if (off >= 18) {
  7921. off -= 18;
  7922. j += 1;
  7923. this.words[j] |= w >>> 26;
  7924. } else {
  7925. off += 8;
  7926. }
  7927. }
  7928. } else {
  7929. var parseLength = number.length - start;
  7930. for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) {
  7931. w = parseHexByte(number, start, i) << off;
  7932. this.words[j] |= w & 0x3ffffff;
  7933. if (off >= 18) {
  7934. off -= 18;
  7935. j += 1;
  7936. this.words[j] |= w >>> 26;
  7937. } else {
  7938. off += 8;
  7939. }
  7940. }
  7941. }
  7942. this._strip();
  7943. };
  7944. function parseBase (str, start, end, mul) {
  7945. var r = 0;
  7946. var b = 0;
  7947. var len = Math.min(str.length, end);
  7948. for (var i = start; i < len; i++) {
  7949. var c = str.charCodeAt(i) - 48;
  7950. r *= mul;
  7951. // 'a'
  7952. if (c >= 49) {
  7953. b = c - 49 + 0xa;
  7954. // 'A'
  7955. } else if (c >= 17) {
  7956. b = c - 17 + 0xa;
  7957. // '0' - '9'
  7958. } else {
  7959. b = c;
  7960. }
  7961. assert(c >= 0 && b < mul, 'Invalid character');
  7962. r += b;
  7963. }
  7964. return r;
  7965. }
  7966. BN.prototype._parseBase = function _parseBase (number, base, start) {
  7967. // Initialize as zero
  7968. this.words = [0];
  7969. this.length = 1;
  7970. // Find length of limb in base
  7971. for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {
  7972. limbLen++;
  7973. }
  7974. limbLen--;
  7975. limbPow = (limbPow / base) | 0;
  7976. var total = number.length - start;
  7977. var mod = total % limbLen;
  7978. var end = Math.min(total, total - mod) + start;
  7979. var word = 0;
  7980. for (var i = start; i < end; i += limbLen) {
  7981. word = parseBase(number, i, i + limbLen, base);
  7982. this.imuln(limbPow);
  7983. if (this.words[0] + word < 0x4000000) {
  7984. this.words[0] += word;
  7985. } else {
  7986. this._iaddn(word);
  7987. }
  7988. }
  7989. if (mod !== 0) {
  7990. var pow = 1;
  7991. word = parseBase(number, i, number.length, base);
  7992. for (i = 0; i < mod; i++) {
  7993. pow *= base;
  7994. }
  7995. this.imuln(pow);
  7996. if (this.words[0] + word < 0x4000000) {
  7997. this.words[0] += word;
  7998. } else {
  7999. this._iaddn(word);
  8000. }
  8001. }
  8002. this._strip();
  8003. };
  8004. BN.prototype.copy = function copy (dest) {
  8005. dest.words = new Array(this.length);
  8006. for (var i = 0; i < this.length; i++) {
  8007. dest.words[i] = this.words[i];
  8008. }
  8009. dest.length = this.length;
  8010. dest.negative = this.negative;
  8011. dest.red = this.red;
  8012. };
  8013. function move (dest, src) {
  8014. dest.words = src.words;
  8015. dest.length = src.length;
  8016. dest.negative = src.negative;
  8017. dest.red = src.red;
  8018. }
  8019. BN.prototype._move = function _move (dest) {
  8020. move(dest, this);
  8021. };
  8022. BN.prototype.clone = function clone () {
  8023. var r = new BN(null);
  8024. this.copy(r);
  8025. return r;
  8026. };
  8027. BN.prototype._expand = function _expand (size) {
  8028. while (this.length < size) {
  8029. this.words[this.length++] = 0;
  8030. }
  8031. return this;
  8032. };
  8033. // Remove leading `0` from `this`
  8034. BN.prototype._strip = function strip () {
  8035. while (this.length > 1 && this.words[this.length - 1] === 0) {
  8036. this.length--;
  8037. }
  8038. return this._normSign();
  8039. };
  8040. BN.prototype._normSign = function _normSign () {
  8041. // -0 = 0
  8042. if (this.length === 1 && this.words[0] === 0) {
  8043. this.negative = 0;
  8044. }
  8045. return this;
  8046. };
  8047. // Check Symbol.for because not everywhere where Symbol defined
  8048. // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol#Browser_compatibility
  8049. if (typeof Symbol !== 'undefined' && typeof Symbol.for === 'function') {
  8050. try {
  8051. BN.prototype[Symbol.for('nodejs.util.inspect.custom')] = inspect;
  8052. } catch (e) {
  8053. BN.prototype.inspect = inspect;
  8054. }
  8055. } else {
  8056. BN.prototype.inspect = inspect;
  8057. }
  8058. function inspect () {
  8059. return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
  8060. }
  8061. /*
  8062. var zeros = [];
  8063. var groupSizes = [];
  8064. var groupBases = [];
  8065. var s = '';
  8066. var i = -1;
  8067. while (++i < BN.wordSize) {
  8068. zeros[i] = s;
  8069. s += '0';
  8070. }
  8071. groupSizes[0] = 0;
  8072. groupSizes[1] = 0;
  8073. groupBases[0] = 0;
  8074. groupBases[1] = 0;
  8075. var base = 2 - 1;
  8076. while (++base < 36 + 1) {
  8077. var groupSize = 0;
  8078. var groupBase = 1;
  8079. while (groupBase < (1 << BN.wordSize) / base) {
  8080. groupBase *= base;
  8081. groupSize += 1;
  8082. }
  8083. groupSizes[base] = groupSize;
  8084. groupBases[base] = groupBase;
  8085. }
  8086. */
  8087. var zeros = [
  8088. '',
  8089. '0',
  8090. '00',
  8091. '000',
  8092. '0000',
  8093. '00000',
  8094. '000000',
  8095. '0000000',
  8096. '00000000',
  8097. '000000000',
  8098. '0000000000',
  8099. '00000000000',
  8100. '000000000000',
  8101. '0000000000000',
  8102. '00000000000000',
  8103. '000000000000000',
  8104. '0000000000000000',
  8105. '00000000000000000',
  8106. '000000000000000000',
  8107. '0000000000000000000',
  8108. '00000000000000000000',
  8109. '000000000000000000000',
  8110. '0000000000000000000000',
  8111. '00000000000000000000000',
  8112. '000000000000000000000000',
  8113. '0000000000000000000000000'
  8114. ];
  8115. var groupSizes = [
  8116. 0, 0,
  8117. 25, 16, 12, 11, 10, 9, 8,
  8118. 8, 7, 7, 7, 7, 6, 6,
  8119. 6, 6, 6, 6, 6, 5, 5,
  8120. 5, 5, 5, 5, 5, 5, 5,
  8121. 5, 5, 5, 5, 5, 5, 5
  8122. ];
  8123. var groupBases = [
  8124. 0, 0,
  8125. 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,
  8126. 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,
  8127. 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,
  8128. 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,
  8129. 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176
  8130. ];
  8131. BN.prototype.toString = function toString (base, padding) {
  8132. base = base || 10;
  8133. padding = padding | 0 || 1;
  8134. var out;
  8135. if (base === 16 || base === 'hex') {
  8136. out = '';
  8137. var off = 0;
  8138. var carry = 0;
  8139. for (var i = 0; i < this.length; i++) {
  8140. var w = this.words[i];
  8141. var word = (((w << off) | carry) & 0xffffff).toString(16);
  8142. carry = (w >>> (24 - off)) & 0xffffff;
  8143. off += 2;
  8144. if (off >= 26) {
  8145. off -= 26;
  8146. i--;
  8147. }
  8148. if (carry !== 0 || i !== this.length - 1) {
  8149. out = zeros[6 - word.length] + word + out;
  8150. } else {
  8151. out = word + out;
  8152. }
  8153. }
  8154. if (carry !== 0) {
  8155. out = carry.toString(16) + out;
  8156. }
  8157. while (out.length % padding !== 0) {
  8158. out = '0' + out;
  8159. }
  8160. if (this.negative !== 0) {
  8161. out = '-' + out;
  8162. }
  8163. return out;
  8164. }
  8165. if (base === (base | 0) && base >= 2 && base <= 36) {
  8166. // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));
  8167. var groupSize = groupSizes[base];
  8168. // var groupBase = Math.pow(base, groupSize);
  8169. var groupBase = groupBases[base];
  8170. out = '';
  8171. var c = this.clone();
  8172. c.negative = 0;
  8173. while (!c.isZero()) {
  8174. var r = c.modrn(groupBase).toString(base);
  8175. c = c.idivn(groupBase);
  8176. if (!c.isZero()) {
  8177. out = zeros[groupSize - r.length] + r + out;
  8178. } else {
  8179. out = r + out;
  8180. }
  8181. }
  8182. if (this.isZero()) {
  8183. out = '0' + out;
  8184. }
  8185. while (out.length % padding !== 0) {
  8186. out = '0' + out;
  8187. }
  8188. if (this.negative !== 0) {
  8189. out = '-' + out;
  8190. }
  8191. return out;
  8192. }
  8193. assert(false, 'Base should be between 2 and 36');
  8194. };
  8195. BN.prototype.toNumber = function toNumber () {
  8196. var ret = this.words[0];
  8197. if (this.length === 2) {
  8198. ret += this.words[1] * 0x4000000;
  8199. } else if (this.length === 3 && this.words[2] === 0x01) {
  8200. // NOTE: at this stage it is known that the top bit is set
  8201. ret += 0x10000000000000 + (this.words[1] * 0x4000000);
  8202. } else if (this.length > 2) {
  8203. assert(false, 'Number can only safely store up to 53 bits');
  8204. }
  8205. return (this.negative !== 0) ? -ret : ret;
  8206. };
  8207. BN.prototype.toJSON = function toJSON () {
  8208. return this.toString(16, 2);
  8209. };
  8210. if (Buffer) {
  8211. BN.prototype.toBuffer = function toBuffer (endian, length) {
  8212. return this.toArrayLike(Buffer, endian, length);
  8213. };
  8214. }
  8215. BN.prototype.toArray = function toArray (endian, length) {
  8216. return this.toArrayLike(Array, endian, length);
  8217. };
  8218. var allocate = function allocate (ArrayType, size) {
  8219. if (ArrayType.allocUnsafe) {
  8220. return ArrayType.allocUnsafe(size);
  8221. }
  8222. return new ArrayType(size);
  8223. };
  8224. BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {
  8225. this._strip();
  8226. var byteLength = this.byteLength();
  8227. var reqLength = length || Math.max(1, byteLength);
  8228. assert(byteLength <= reqLength, 'byte array longer than desired length');
  8229. assert(reqLength > 0, 'Requested array length <= 0');
  8230. var res = allocate(ArrayType, reqLength);
  8231. var postfix = endian === 'le' ? 'LE' : 'BE';
  8232. this['_toArrayLike' + postfix](res, byteLength);
  8233. return res;
  8234. };
  8235. BN.prototype._toArrayLikeLE = function _toArrayLikeLE (res, byteLength) {
  8236. var position = 0;
  8237. var carry = 0;
  8238. for (var i = 0, shift = 0; i < this.length; i++) {
  8239. var word = (this.words[i] << shift) | carry;
  8240. res[position++] = word & 0xff;
  8241. if (position < res.length) {
  8242. res[position++] = (word >> 8) & 0xff;
  8243. }
  8244. if (position < res.length) {
  8245. res[position++] = (word >> 16) & 0xff;
  8246. }
  8247. if (shift === 6) {
  8248. if (position < res.length) {
  8249. res[position++] = (word >> 24) & 0xff;
  8250. }
  8251. carry = 0;
  8252. shift = 0;
  8253. } else {
  8254. carry = word >>> 24;
  8255. shift += 2;
  8256. }
  8257. }
  8258. if (position < res.length) {
  8259. res[position++] = carry;
  8260. while (position < res.length) {
  8261. res[position++] = 0;
  8262. }
  8263. }
  8264. };
  8265. BN.prototype._toArrayLikeBE = function _toArrayLikeBE (res, byteLength) {
  8266. var position = res.length - 1;
  8267. var carry = 0;
  8268. for (var i = 0, shift = 0; i < this.length; i++) {
  8269. var word = (this.words[i] << shift) | carry;
  8270. res[position--] = word & 0xff;
  8271. if (position >= 0) {
  8272. res[position--] = (word >> 8) & 0xff;
  8273. }
  8274. if (position >= 0) {
  8275. res[position--] = (word >> 16) & 0xff;
  8276. }
  8277. if (shift === 6) {
  8278. if (position >= 0) {
  8279. res[position--] = (word >> 24) & 0xff;
  8280. }
  8281. carry = 0;
  8282. shift = 0;
  8283. } else {
  8284. carry = word >>> 24;
  8285. shift += 2;
  8286. }
  8287. }
  8288. if (position >= 0) {
  8289. res[position--] = carry;
  8290. while (position >= 0) {
  8291. res[position--] = 0;
  8292. }
  8293. }
  8294. };
  8295. if (Math.clz32) {
  8296. BN.prototype._countBits = function _countBits (w) {
  8297. return 32 - Math.clz32(w);
  8298. };
  8299. } else {
  8300. BN.prototype._countBits = function _countBits (w) {
  8301. var t = w;
  8302. var r = 0;
  8303. if (t >= 0x1000) {
  8304. r += 13;
  8305. t >>>= 13;
  8306. }
  8307. if (t >= 0x40) {
  8308. r += 7;
  8309. t >>>= 7;
  8310. }
  8311. if (t >= 0x8) {
  8312. r += 4;
  8313. t >>>= 4;
  8314. }
  8315. if (t >= 0x02) {
  8316. r += 2;
  8317. t >>>= 2;
  8318. }
  8319. return r + t;
  8320. };
  8321. }
  8322. BN.prototype._zeroBits = function _zeroBits (w) {
  8323. // Short-cut
  8324. if (w === 0) return 26;
  8325. var t = w;
  8326. var r = 0;
  8327. if ((t & 0x1fff) === 0) {
  8328. r += 13;
  8329. t >>>= 13;
  8330. }
  8331. if ((t & 0x7f) === 0) {
  8332. r += 7;
  8333. t >>>= 7;
  8334. }
  8335. if ((t & 0xf) === 0) {
  8336. r += 4;
  8337. t >>>= 4;
  8338. }
  8339. if ((t & 0x3) === 0) {
  8340. r += 2;
  8341. t >>>= 2;
  8342. }
  8343. if ((t & 0x1) === 0) {
  8344. r++;
  8345. }
  8346. return r;
  8347. };
  8348. // Return number of used bits in a BN
  8349. BN.prototype.bitLength = function bitLength () {
  8350. var w = this.words[this.length - 1];
  8351. var hi = this._countBits(w);
  8352. return (this.length - 1) * 26 + hi;
  8353. };
  8354. function toBitArray (num) {
  8355. var w = new Array(num.bitLength());
  8356. for (var bit = 0; bit < w.length; bit++) {
  8357. var off = (bit / 26) | 0;
  8358. var wbit = bit % 26;
  8359. w[bit] = (num.words[off] >>> wbit) & 0x01;
  8360. }
  8361. return w;
  8362. }
  8363. // Number of trailing zero bits
  8364. BN.prototype.zeroBits = function zeroBits () {
  8365. if (this.isZero()) return 0;
  8366. var r = 0;
  8367. for (var i = 0; i < this.length; i++) {
  8368. var b = this._zeroBits(this.words[i]);
  8369. r += b;
  8370. if (b !== 26) break;
  8371. }
  8372. return r;
  8373. };
  8374. BN.prototype.byteLength = function byteLength () {
  8375. return Math.ceil(this.bitLength() / 8);
  8376. };
  8377. BN.prototype.toTwos = function toTwos (width) {
  8378. if (this.negative !== 0) {
  8379. return this.abs().inotn(width).iaddn(1);
  8380. }
  8381. return this.clone();
  8382. };
  8383. BN.prototype.fromTwos = function fromTwos (width) {
  8384. if (this.testn(width - 1)) {
  8385. return this.notn(width).iaddn(1).ineg();
  8386. }
  8387. return this.clone();
  8388. };
  8389. BN.prototype.isNeg = function isNeg () {
  8390. return this.negative !== 0;
  8391. };
  8392. // Return negative clone of `this`
  8393. BN.prototype.neg = function neg () {
  8394. return this.clone().ineg();
  8395. };
  8396. BN.prototype.ineg = function ineg () {
  8397. if (!this.isZero()) {
  8398. this.negative ^= 1;
  8399. }
  8400. return this;
  8401. };
  8402. // Or `num` with `this` in-place
  8403. BN.prototype.iuor = function iuor (num) {
  8404. while (this.length < num.length) {
  8405. this.words[this.length++] = 0;
  8406. }
  8407. for (var i = 0; i < num.length; i++) {
  8408. this.words[i] = this.words[i] | num.words[i];
  8409. }
  8410. return this._strip();
  8411. };
  8412. BN.prototype.ior = function ior (num) {
  8413. assert((this.negative | num.negative) === 0);
  8414. return this.iuor(num);
  8415. };
  8416. // Or `num` with `this`
  8417. BN.prototype.or = function or (num) {
  8418. if (this.length > num.length) return this.clone().ior(num);
  8419. return num.clone().ior(this);
  8420. };
  8421. BN.prototype.uor = function uor (num) {
  8422. if (this.length > num.length) return this.clone().iuor(num);
  8423. return num.clone().iuor(this);
  8424. };
  8425. // And `num` with `this` in-place
  8426. BN.prototype.iuand = function iuand (num) {
  8427. // b = min-length(num, this)
  8428. var b;
  8429. if (this.length > num.length) {
  8430. b = num;
  8431. } else {
  8432. b = this;
  8433. }
  8434. for (var i = 0; i < b.length; i++) {
  8435. this.words[i] = this.words[i] & num.words[i];
  8436. }
  8437. this.length = b.length;
  8438. return this._strip();
  8439. };
  8440. BN.prototype.iand = function iand (num) {
  8441. assert((this.negative | num.negative) === 0);
  8442. return this.iuand(num);
  8443. };
  8444. // And `num` with `this`
  8445. BN.prototype.and = function and (num) {
  8446. if (this.length > num.length) return this.clone().iand(num);
  8447. return num.clone().iand(this);
  8448. };
  8449. BN.prototype.uand = function uand (num) {
  8450. if (this.length > num.length) return this.clone().iuand(num);
  8451. return num.clone().iuand(this);
  8452. };
  8453. // Xor `num` with `this` in-place
  8454. BN.prototype.iuxor = function iuxor (num) {
  8455. // a.length > b.length
  8456. var a;
  8457. var b;
  8458. if (this.length > num.length) {
  8459. a = this;
  8460. b = num;
  8461. } else {
  8462. a = num;
  8463. b = this;
  8464. }
  8465. for (var i = 0; i < b.length; i++) {
  8466. this.words[i] = a.words[i] ^ b.words[i];
  8467. }
  8468. if (this !== a) {
  8469. for (; i < a.length; i++) {
  8470. this.words[i] = a.words[i];
  8471. }
  8472. }
  8473. this.length = a.length;
  8474. return this._strip();
  8475. };
  8476. BN.prototype.ixor = function ixor (num) {
  8477. assert((this.negative | num.negative) === 0);
  8478. return this.iuxor(num);
  8479. };
  8480. // Xor `num` with `this`
  8481. BN.prototype.xor = function xor (num) {
  8482. if (this.length > num.length) return this.clone().ixor(num);
  8483. return num.clone().ixor(this);
  8484. };
  8485. BN.prototype.uxor = function uxor (num) {
  8486. if (this.length > num.length) return this.clone().iuxor(num);
  8487. return num.clone().iuxor(this);
  8488. };
  8489. // Not ``this`` with ``width`` bitwidth
  8490. BN.prototype.inotn = function inotn (width) {
  8491. assert(typeof width === 'number' && width >= 0);
  8492. var bytesNeeded = Math.ceil(width / 26) | 0;
  8493. var bitsLeft = width % 26;
  8494. // Extend the buffer with leading zeroes
  8495. this._expand(bytesNeeded);
  8496. if (bitsLeft > 0) {
  8497. bytesNeeded--;
  8498. }
  8499. // Handle complete words
  8500. for (var i = 0; i < bytesNeeded; i++) {
  8501. this.words[i] = ~this.words[i] & 0x3ffffff;
  8502. }
  8503. // Handle the residue
  8504. if (bitsLeft > 0) {
  8505. this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));
  8506. }
  8507. // And remove leading zeroes
  8508. return this._strip();
  8509. };
  8510. BN.prototype.notn = function notn (width) {
  8511. return this.clone().inotn(width);
  8512. };
  8513. // Set `bit` of `this`
  8514. BN.prototype.setn = function setn (bit, val) {
  8515. assert(typeof bit === 'number' && bit >= 0);
  8516. var off = (bit / 26) | 0;
  8517. var wbit = bit % 26;
  8518. this._expand(off + 1);
  8519. if (val) {
  8520. this.words[off] = this.words[off] | (1 << wbit);
  8521. } else {
  8522. this.words[off] = this.words[off] & ~(1 << wbit);
  8523. }
  8524. return this._strip();
  8525. };
  8526. // Add `num` to `this` in-place
  8527. BN.prototype.iadd = function iadd (num) {
  8528. var r;
  8529. // negative + positive
  8530. if (this.negative !== 0 && num.negative === 0) {
  8531. this.negative = 0;
  8532. r = this.isub(num);
  8533. this.negative ^= 1;
  8534. return this._normSign();
  8535. // positive + negative
  8536. } else if (this.negative === 0 && num.negative !== 0) {
  8537. num.negative = 0;
  8538. r = this.isub(num);
  8539. num.negative = 1;
  8540. return r._normSign();
  8541. }
  8542. // a.length > b.length
  8543. var a, b;
  8544. if (this.length > num.length) {
  8545. a = this;
  8546. b = num;
  8547. } else {
  8548. a = num;
  8549. b = this;
  8550. }
  8551. var carry = 0;
  8552. for (var i = 0; i < b.length; i++) {
  8553. r = (a.words[i] | 0) + (b.words[i] | 0) + carry;
  8554. this.words[i] = r & 0x3ffffff;
  8555. carry = r >>> 26;
  8556. }
  8557. for (; carry !== 0 && i < a.length; i++) {
  8558. r = (a.words[i] | 0) + carry;
  8559. this.words[i] = r & 0x3ffffff;
  8560. carry = r >>> 26;
  8561. }
  8562. this.length = a.length;
  8563. if (carry !== 0) {
  8564. this.words[this.length] = carry;
  8565. this.length++;
  8566. // Copy the rest of the words
  8567. } else if (a !== this) {
  8568. for (; i < a.length; i++) {
  8569. this.words[i] = a.words[i];
  8570. }
  8571. }
  8572. return this;
  8573. };
  8574. // Add `num` to `this`
  8575. BN.prototype.add = function add (num) {
  8576. var res;
  8577. if (num.negative !== 0 && this.negative === 0) {
  8578. num.negative = 0;
  8579. res = this.sub(num);
  8580. num.negative ^= 1;
  8581. return res;
  8582. } else if (num.negative === 0 && this.negative !== 0) {
  8583. this.negative = 0;
  8584. res = num.sub(this);
  8585. this.negative = 1;
  8586. return res;
  8587. }
  8588. if (this.length > num.length) return this.clone().iadd(num);
  8589. return num.clone().iadd(this);
  8590. };
  8591. // Subtract `num` from `this` in-place
  8592. BN.prototype.isub = function isub (num) {
  8593. // this - (-num) = this + num
  8594. if (num.negative !== 0) {
  8595. num.negative = 0;
  8596. var r = this.iadd(num);
  8597. num.negative = 1;
  8598. return r._normSign();
  8599. // -this - num = -(this + num)
  8600. } else if (this.negative !== 0) {
  8601. this.negative = 0;
  8602. this.iadd(num);
  8603. this.negative = 1;
  8604. return this._normSign();
  8605. }
  8606. // At this point both numbers are positive
  8607. var cmp = this.cmp(num);
  8608. // Optimization - zeroify
  8609. if (cmp === 0) {
  8610. this.negative = 0;
  8611. this.length = 1;
  8612. this.words[0] = 0;
  8613. return this;
  8614. }
  8615. // a > b
  8616. var a, b;
  8617. if (cmp > 0) {
  8618. a = this;
  8619. b = num;
  8620. } else {
  8621. a = num;
  8622. b = this;
  8623. }
  8624. var carry = 0;
  8625. for (var i = 0; i < b.length; i++) {
  8626. r = (a.words[i] | 0) - (b.words[i] | 0) + carry;
  8627. carry = r >> 26;
  8628. this.words[i] = r & 0x3ffffff;
  8629. }
  8630. for (; carry !== 0 && i < a.length; i++) {
  8631. r = (a.words[i] | 0) + carry;
  8632. carry = r >> 26;
  8633. this.words[i] = r & 0x3ffffff;
  8634. }
  8635. // Copy rest of the words
  8636. if (carry === 0 && i < a.length && a !== this) {
  8637. for (; i < a.length; i++) {
  8638. this.words[i] = a.words[i];
  8639. }
  8640. }
  8641. this.length = Math.max(this.length, i);
  8642. if (a !== this) {
  8643. this.negative = 1;
  8644. }
  8645. return this._strip();
  8646. };
  8647. // Subtract `num` from `this`
  8648. BN.prototype.sub = function sub (num) {
  8649. return this.clone().isub(num);
  8650. };
  8651. function smallMulTo (self, num, out) {
  8652. out.negative = num.negative ^ self.negative;
  8653. var len = (self.length + num.length) | 0;
  8654. out.length = len;
  8655. len = (len - 1) | 0;
  8656. // Peel one iteration (compiler can't do it, because of code complexity)
  8657. var a = self.words[0] | 0;
  8658. var b = num.words[0] | 0;
  8659. var r = a * b;
  8660. var lo = r & 0x3ffffff;
  8661. var carry = (r / 0x4000000) | 0;
  8662. out.words[0] = lo;
  8663. for (var k = 1; k < len; k++) {
  8664. // Sum all words with the same `i + j = k` and accumulate `ncarry`,
  8665. // note that ncarry could be >= 0x3ffffff
  8666. var ncarry = carry >>> 26;
  8667. var rword = carry & 0x3ffffff;
  8668. var maxJ = Math.min(k, num.length - 1);
  8669. for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
  8670. var i = (k - j) | 0;
  8671. a = self.words[i] | 0;
  8672. b = num.words[j] | 0;
  8673. r = a * b + rword;
  8674. ncarry += (r / 0x4000000) | 0;
  8675. rword = r & 0x3ffffff;
  8676. }
  8677. out.words[k] = rword | 0;
  8678. carry = ncarry | 0;
  8679. }
  8680. if (carry !== 0) {
  8681. out.words[k] = carry | 0;
  8682. } else {
  8683. out.length--;
  8684. }
  8685. return out._strip();
  8686. }
  8687. // TODO(indutny): it may be reasonable to omit it for users who don't need
  8688. // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit
  8689. // multiplication (like elliptic secp256k1).
  8690. var comb10MulTo = function comb10MulTo (self, num, out) {
  8691. var a = self.words;
  8692. var b = num.words;
  8693. var o = out.words;
  8694. var c = 0;
  8695. var lo;
  8696. var mid;
  8697. var hi;
  8698. var a0 = a[0] | 0;
  8699. var al0 = a0 & 0x1fff;
  8700. var ah0 = a0 >>> 13;
  8701. var a1 = a[1] | 0;
  8702. var al1 = a1 & 0x1fff;
  8703. var ah1 = a1 >>> 13;
  8704. var a2 = a[2] | 0;
  8705. var al2 = a2 & 0x1fff;
  8706. var ah2 = a2 >>> 13;
  8707. var a3 = a[3] | 0;
  8708. var al3 = a3 & 0x1fff;
  8709. var ah3 = a3 >>> 13;
  8710. var a4 = a[4] | 0;
  8711. var al4 = a4 & 0x1fff;
  8712. var ah4 = a4 >>> 13;
  8713. var a5 = a[5] | 0;
  8714. var al5 = a5 & 0x1fff;
  8715. var ah5 = a5 >>> 13;
  8716. var a6 = a[6] | 0;
  8717. var al6 = a6 & 0x1fff;
  8718. var ah6 = a6 >>> 13;
  8719. var a7 = a[7] | 0;
  8720. var al7 = a7 & 0x1fff;
  8721. var ah7 = a7 >>> 13;
  8722. var a8 = a[8] | 0;
  8723. var al8 = a8 & 0x1fff;
  8724. var ah8 = a8 >>> 13;
  8725. var a9 = a[9] | 0;
  8726. var al9 = a9 & 0x1fff;
  8727. var ah9 = a9 >>> 13;
  8728. var b0 = b[0] | 0;
  8729. var bl0 = b0 & 0x1fff;
  8730. var bh0 = b0 >>> 13;
  8731. var b1 = b[1] | 0;
  8732. var bl1 = b1 & 0x1fff;
  8733. var bh1 = b1 >>> 13;
  8734. var b2 = b[2] | 0;
  8735. var bl2 = b2 & 0x1fff;
  8736. var bh2 = b2 >>> 13;
  8737. var b3 = b[3] | 0;
  8738. var bl3 = b3 & 0x1fff;
  8739. var bh3 = b3 >>> 13;
  8740. var b4 = b[4] | 0;
  8741. var bl4 = b4 & 0x1fff;
  8742. var bh4 = b4 >>> 13;
  8743. var b5 = b[5] | 0;
  8744. var bl5 = b5 & 0x1fff;
  8745. var bh5 = b5 >>> 13;
  8746. var b6 = b[6] | 0;
  8747. var bl6 = b6 & 0x1fff;
  8748. var bh6 = b6 >>> 13;
  8749. var b7 = b[7] | 0;
  8750. var bl7 = b7 & 0x1fff;
  8751. var bh7 = b7 >>> 13;
  8752. var b8 = b[8] | 0;
  8753. var bl8 = b8 & 0x1fff;
  8754. var bh8 = b8 >>> 13;
  8755. var b9 = b[9] | 0;
  8756. var bl9 = b9 & 0x1fff;
  8757. var bh9 = b9 >>> 13;
  8758. out.negative = self.negative ^ num.negative;
  8759. out.length = 19;
  8760. /* k = 0 */
  8761. lo = Math.imul(al0, bl0);
  8762. mid = Math.imul(al0, bh0);
  8763. mid = (mid + Math.imul(ah0, bl0)) | 0;
  8764. hi = Math.imul(ah0, bh0);
  8765. var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  8766. c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;
  8767. w0 &= 0x3ffffff;
  8768. /* k = 1 */
  8769. lo = Math.imul(al1, bl0);
  8770. mid = Math.imul(al1, bh0);
  8771. mid = (mid + Math.imul(ah1, bl0)) | 0;
  8772. hi = Math.imul(ah1, bh0);
  8773. lo = (lo + Math.imul(al0, bl1)) | 0;
  8774. mid = (mid + Math.imul(al0, bh1)) | 0;
  8775. mid = (mid + Math.imul(ah0, bl1)) | 0;
  8776. hi = (hi + Math.imul(ah0, bh1)) | 0;
  8777. var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  8778. c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;
  8779. w1 &= 0x3ffffff;
  8780. /* k = 2 */
  8781. lo = Math.imul(al2, bl0);
  8782. mid = Math.imul(al2, bh0);
  8783. mid = (mid + Math.imul(ah2, bl0)) | 0;
  8784. hi = Math.imul(ah2, bh0);
  8785. lo = (lo + Math.imul(al1, bl1)) | 0;
  8786. mid = (mid + Math.imul(al1, bh1)) | 0;
  8787. mid = (mid + Math.imul(ah1, bl1)) | 0;
  8788. hi = (hi + Math.imul(ah1, bh1)) | 0;
  8789. lo = (lo + Math.imul(al0, bl2)) | 0;
  8790. mid = (mid + Math.imul(al0, bh2)) | 0;
  8791. mid = (mid + Math.imul(ah0, bl2)) | 0;
  8792. hi = (hi + Math.imul(ah0, bh2)) | 0;
  8793. var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  8794. c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;
  8795. w2 &= 0x3ffffff;
  8796. /* k = 3 */
  8797. lo = Math.imul(al3, bl0);
  8798. mid = Math.imul(al3, bh0);
  8799. mid = (mid + Math.imul(ah3, bl0)) | 0;
  8800. hi = Math.imul(ah3, bh0);
  8801. lo = (lo + Math.imul(al2, bl1)) | 0;
  8802. mid = (mid + Math.imul(al2, bh1)) | 0;
  8803. mid = (mid + Math.imul(ah2, bl1)) | 0;
  8804. hi = (hi + Math.imul(ah2, bh1)) | 0;
  8805. lo = (lo + Math.imul(al1, bl2)) | 0;
  8806. mid = (mid + Math.imul(al1, bh2)) | 0;
  8807. mid = (mid + Math.imul(ah1, bl2)) | 0;
  8808. hi = (hi + Math.imul(ah1, bh2)) | 0;
  8809. lo = (lo + Math.imul(al0, bl3)) | 0;
  8810. mid = (mid + Math.imul(al0, bh3)) | 0;
  8811. mid = (mid + Math.imul(ah0, bl3)) | 0;
  8812. hi = (hi + Math.imul(ah0, bh3)) | 0;
  8813. var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  8814. c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;
  8815. w3 &= 0x3ffffff;
  8816. /* k = 4 */
  8817. lo = Math.imul(al4, bl0);
  8818. mid = Math.imul(al4, bh0);
  8819. mid = (mid + Math.imul(ah4, bl0)) | 0;
  8820. hi = Math.imul(ah4, bh0);
  8821. lo = (lo + Math.imul(al3, bl1)) | 0;
  8822. mid = (mid + Math.imul(al3, bh1)) | 0;
  8823. mid = (mid + Math.imul(ah3, bl1)) | 0;
  8824. hi = (hi + Math.imul(ah3, bh1)) | 0;
  8825. lo = (lo + Math.imul(al2, bl2)) | 0;
  8826. mid = (mid + Math.imul(al2, bh2)) | 0;
  8827. mid = (mid + Math.imul(ah2, bl2)) | 0;
  8828. hi = (hi + Math.imul(ah2, bh2)) | 0;
  8829. lo = (lo + Math.imul(al1, bl3)) | 0;
  8830. mid = (mid + Math.imul(al1, bh3)) | 0;
  8831. mid = (mid + Math.imul(ah1, bl3)) | 0;
  8832. hi = (hi + Math.imul(ah1, bh3)) | 0;
  8833. lo = (lo + Math.imul(al0, bl4)) | 0;
  8834. mid = (mid + Math.imul(al0, bh4)) | 0;
  8835. mid = (mid + Math.imul(ah0, bl4)) | 0;
  8836. hi = (hi + Math.imul(ah0, bh4)) | 0;
  8837. var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  8838. c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;
  8839. w4 &= 0x3ffffff;
  8840. /* k = 5 */
  8841. lo = Math.imul(al5, bl0);
  8842. mid = Math.imul(al5, bh0);
  8843. mid = (mid + Math.imul(ah5, bl0)) | 0;
  8844. hi = Math.imul(ah5, bh0);
  8845. lo = (lo + Math.imul(al4, bl1)) | 0;
  8846. mid = (mid + Math.imul(al4, bh1)) | 0;
  8847. mid = (mid + Math.imul(ah4, bl1)) | 0;
  8848. hi = (hi + Math.imul(ah4, bh1)) | 0;
  8849. lo = (lo + Math.imul(al3, bl2)) | 0;
  8850. mid = (mid + Math.imul(al3, bh2)) | 0;
  8851. mid = (mid + Math.imul(ah3, bl2)) | 0;
  8852. hi = (hi + Math.imul(ah3, bh2)) | 0;
  8853. lo = (lo + Math.imul(al2, bl3)) | 0;
  8854. mid = (mid + Math.imul(al2, bh3)) | 0;
  8855. mid = (mid + Math.imul(ah2, bl3)) | 0;
  8856. hi = (hi + Math.imul(ah2, bh3)) | 0;
  8857. lo = (lo + Math.imul(al1, bl4)) | 0;
  8858. mid = (mid + Math.imul(al1, bh4)) | 0;
  8859. mid = (mid + Math.imul(ah1, bl4)) | 0;
  8860. hi = (hi + Math.imul(ah1, bh4)) | 0;
  8861. lo = (lo + Math.imul(al0, bl5)) | 0;
  8862. mid = (mid + Math.imul(al0, bh5)) | 0;
  8863. mid = (mid + Math.imul(ah0, bl5)) | 0;
  8864. hi = (hi + Math.imul(ah0, bh5)) | 0;
  8865. var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  8866. c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;
  8867. w5 &= 0x3ffffff;
  8868. /* k = 6 */
  8869. lo = Math.imul(al6, bl0);
  8870. mid = Math.imul(al6, bh0);
  8871. mid = (mid + Math.imul(ah6, bl0)) | 0;
  8872. hi = Math.imul(ah6, bh0);
  8873. lo = (lo + Math.imul(al5, bl1)) | 0;
  8874. mid = (mid + Math.imul(al5, bh1)) | 0;
  8875. mid = (mid + Math.imul(ah5, bl1)) | 0;
  8876. hi = (hi + Math.imul(ah5, bh1)) | 0;
  8877. lo = (lo + Math.imul(al4, bl2)) | 0;
  8878. mid = (mid + Math.imul(al4, bh2)) | 0;
  8879. mid = (mid + Math.imul(ah4, bl2)) | 0;
  8880. hi = (hi + Math.imul(ah4, bh2)) | 0;
  8881. lo = (lo + Math.imul(al3, bl3)) | 0;
  8882. mid = (mid + Math.imul(al3, bh3)) | 0;
  8883. mid = (mid + Math.imul(ah3, bl3)) | 0;
  8884. hi = (hi + Math.imul(ah3, bh3)) | 0;
  8885. lo = (lo + Math.imul(al2, bl4)) | 0;
  8886. mid = (mid + Math.imul(al2, bh4)) | 0;
  8887. mid = (mid + Math.imul(ah2, bl4)) | 0;
  8888. hi = (hi + Math.imul(ah2, bh4)) | 0;
  8889. lo = (lo + Math.imul(al1, bl5)) | 0;
  8890. mid = (mid + Math.imul(al1, bh5)) | 0;
  8891. mid = (mid + Math.imul(ah1, bl5)) | 0;
  8892. hi = (hi + Math.imul(ah1, bh5)) | 0;
  8893. lo = (lo + Math.imul(al0, bl6)) | 0;
  8894. mid = (mid + Math.imul(al0, bh6)) | 0;
  8895. mid = (mid + Math.imul(ah0, bl6)) | 0;
  8896. hi = (hi + Math.imul(ah0, bh6)) | 0;
  8897. var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  8898. c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;
  8899. w6 &= 0x3ffffff;
  8900. /* k = 7 */
  8901. lo = Math.imul(al7, bl0);
  8902. mid = Math.imul(al7, bh0);
  8903. mid = (mid + Math.imul(ah7, bl0)) | 0;
  8904. hi = Math.imul(ah7, bh0);
  8905. lo = (lo + Math.imul(al6, bl1)) | 0;
  8906. mid = (mid + Math.imul(al6, bh1)) | 0;
  8907. mid = (mid + Math.imul(ah6, bl1)) | 0;
  8908. hi = (hi + Math.imul(ah6, bh1)) | 0;
  8909. lo = (lo + Math.imul(al5, bl2)) | 0;
  8910. mid = (mid + Math.imul(al5, bh2)) | 0;
  8911. mid = (mid + Math.imul(ah5, bl2)) | 0;
  8912. hi = (hi + Math.imul(ah5, bh2)) | 0;
  8913. lo = (lo + Math.imul(al4, bl3)) | 0;
  8914. mid = (mid + Math.imul(al4, bh3)) | 0;
  8915. mid = (mid + Math.imul(ah4, bl3)) | 0;
  8916. hi = (hi + Math.imul(ah4, bh3)) | 0;
  8917. lo = (lo + Math.imul(al3, bl4)) | 0;
  8918. mid = (mid + Math.imul(al3, bh4)) | 0;
  8919. mid = (mid + Math.imul(ah3, bl4)) | 0;
  8920. hi = (hi + Math.imul(ah3, bh4)) | 0;
  8921. lo = (lo + Math.imul(al2, bl5)) | 0;
  8922. mid = (mid + Math.imul(al2, bh5)) | 0;
  8923. mid = (mid + Math.imul(ah2, bl5)) | 0;
  8924. hi = (hi + Math.imul(ah2, bh5)) | 0;
  8925. lo = (lo + Math.imul(al1, bl6)) | 0;
  8926. mid = (mid + Math.imul(al1, bh6)) | 0;
  8927. mid = (mid + Math.imul(ah1, bl6)) | 0;
  8928. hi = (hi + Math.imul(ah1, bh6)) | 0;
  8929. lo = (lo + Math.imul(al0, bl7)) | 0;
  8930. mid = (mid + Math.imul(al0, bh7)) | 0;
  8931. mid = (mid + Math.imul(ah0, bl7)) | 0;
  8932. hi = (hi + Math.imul(ah0, bh7)) | 0;
  8933. var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  8934. c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;
  8935. w7 &= 0x3ffffff;
  8936. /* k = 8 */
  8937. lo = Math.imul(al8, bl0);
  8938. mid = Math.imul(al8, bh0);
  8939. mid = (mid + Math.imul(ah8, bl0)) | 0;
  8940. hi = Math.imul(ah8, bh0);
  8941. lo = (lo + Math.imul(al7, bl1)) | 0;
  8942. mid = (mid + Math.imul(al7, bh1)) | 0;
  8943. mid = (mid + Math.imul(ah7, bl1)) | 0;
  8944. hi = (hi + Math.imul(ah7, bh1)) | 0;
  8945. lo = (lo + Math.imul(al6, bl2)) | 0;
  8946. mid = (mid + Math.imul(al6, bh2)) | 0;
  8947. mid = (mid + Math.imul(ah6, bl2)) | 0;
  8948. hi = (hi + Math.imul(ah6, bh2)) | 0;
  8949. lo = (lo + Math.imul(al5, bl3)) | 0;
  8950. mid = (mid + Math.imul(al5, bh3)) | 0;
  8951. mid = (mid + Math.imul(ah5, bl3)) | 0;
  8952. hi = (hi + Math.imul(ah5, bh3)) | 0;
  8953. lo = (lo + Math.imul(al4, bl4)) | 0;
  8954. mid = (mid + Math.imul(al4, bh4)) | 0;
  8955. mid = (mid + Math.imul(ah4, bl4)) | 0;
  8956. hi = (hi + Math.imul(ah4, bh4)) | 0;
  8957. lo = (lo + Math.imul(al3, bl5)) | 0;
  8958. mid = (mid + Math.imul(al3, bh5)) | 0;
  8959. mid = (mid + Math.imul(ah3, bl5)) | 0;
  8960. hi = (hi + Math.imul(ah3, bh5)) | 0;
  8961. lo = (lo + Math.imul(al2, bl6)) | 0;
  8962. mid = (mid + Math.imul(al2, bh6)) | 0;
  8963. mid = (mid + Math.imul(ah2, bl6)) | 0;
  8964. hi = (hi + Math.imul(ah2, bh6)) | 0;
  8965. lo = (lo + Math.imul(al1, bl7)) | 0;
  8966. mid = (mid + Math.imul(al1, bh7)) | 0;
  8967. mid = (mid + Math.imul(ah1, bl7)) | 0;
  8968. hi = (hi + Math.imul(ah1, bh7)) | 0;
  8969. lo = (lo + Math.imul(al0, bl8)) | 0;
  8970. mid = (mid + Math.imul(al0, bh8)) | 0;
  8971. mid = (mid + Math.imul(ah0, bl8)) | 0;
  8972. hi = (hi + Math.imul(ah0, bh8)) | 0;
  8973. var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  8974. c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;
  8975. w8 &= 0x3ffffff;
  8976. /* k = 9 */
  8977. lo = Math.imul(al9, bl0);
  8978. mid = Math.imul(al9, bh0);
  8979. mid = (mid + Math.imul(ah9, bl0)) | 0;
  8980. hi = Math.imul(ah9, bh0);
  8981. lo = (lo + Math.imul(al8, bl1)) | 0;
  8982. mid = (mid + Math.imul(al8, bh1)) | 0;
  8983. mid = (mid + Math.imul(ah8, bl1)) | 0;
  8984. hi = (hi + Math.imul(ah8, bh1)) | 0;
  8985. lo = (lo + Math.imul(al7, bl2)) | 0;
  8986. mid = (mid + Math.imul(al7, bh2)) | 0;
  8987. mid = (mid + Math.imul(ah7, bl2)) | 0;
  8988. hi = (hi + Math.imul(ah7, bh2)) | 0;
  8989. lo = (lo + Math.imul(al6, bl3)) | 0;
  8990. mid = (mid + Math.imul(al6, bh3)) | 0;
  8991. mid = (mid + Math.imul(ah6, bl3)) | 0;
  8992. hi = (hi + Math.imul(ah6, bh3)) | 0;
  8993. lo = (lo + Math.imul(al5, bl4)) | 0;
  8994. mid = (mid + Math.imul(al5, bh4)) | 0;
  8995. mid = (mid + Math.imul(ah5, bl4)) | 0;
  8996. hi = (hi + Math.imul(ah5, bh4)) | 0;
  8997. lo = (lo + Math.imul(al4, bl5)) | 0;
  8998. mid = (mid + Math.imul(al4, bh5)) | 0;
  8999. mid = (mid + Math.imul(ah4, bl5)) | 0;
  9000. hi = (hi + Math.imul(ah4, bh5)) | 0;
  9001. lo = (lo + Math.imul(al3, bl6)) | 0;
  9002. mid = (mid + Math.imul(al3, bh6)) | 0;
  9003. mid = (mid + Math.imul(ah3, bl6)) | 0;
  9004. hi = (hi + Math.imul(ah3, bh6)) | 0;
  9005. lo = (lo + Math.imul(al2, bl7)) | 0;
  9006. mid = (mid + Math.imul(al2, bh7)) | 0;
  9007. mid = (mid + Math.imul(ah2, bl7)) | 0;
  9008. hi = (hi + Math.imul(ah2, bh7)) | 0;
  9009. lo = (lo + Math.imul(al1, bl8)) | 0;
  9010. mid = (mid + Math.imul(al1, bh8)) | 0;
  9011. mid = (mid + Math.imul(ah1, bl8)) | 0;
  9012. hi = (hi + Math.imul(ah1, bh8)) | 0;
  9013. lo = (lo + Math.imul(al0, bl9)) | 0;
  9014. mid = (mid + Math.imul(al0, bh9)) | 0;
  9015. mid = (mid + Math.imul(ah0, bl9)) | 0;
  9016. hi = (hi + Math.imul(ah0, bh9)) | 0;
  9017. var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  9018. c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;
  9019. w9 &= 0x3ffffff;
  9020. /* k = 10 */
  9021. lo = Math.imul(al9, bl1);
  9022. mid = Math.imul(al9, bh1);
  9023. mid = (mid + Math.imul(ah9, bl1)) | 0;
  9024. hi = Math.imul(ah9, bh1);
  9025. lo = (lo + Math.imul(al8, bl2)) | 0;
  9026. mid = (mid + Math.imul(al8, bh2)) | 0;
  9027. mid = (mid + Math.imul(ah8, bl2)) | 0;
  9028. hi = (hi + Math.imul(ah8, bh2)) | 0;
  9029. lo = (lo + Math.imul(al7, bl3)) | 0;
  9030. mid = (mid + Math.imul(al7, bh3)) | 0;
  9031. mid = (mid + Math.imul(ah7, bl3)) | 0;
  9032. hi = (hi + Math.imul(ah7, bh3)) | 0;
  9033. lo = (lo + Math.imul(al6, bl4)) | 0;
  9034. mid = (mid + Math.imul(al6, bh4)) | 0;
  9035. mid = (mid + Math.imul(ah6, bl4)) | 0;
  9036. hi = (hi + Math.imul(ah6, bh4)) | 0;
  9037. lo = (lo + Math.imul(al5, bl5)) | 0;
  9038. mid = (mid + Math.imul(al5, bh5)) | 0;
  9039. mid = (mid + Math.imul(ah5, bl5)) | 0;
  9040. hi = (hi + Math.imul(ah5, bh5)) | 0;
  9041. lo = (lo + Math.imul(al4, bl6)) | 0;
  9042. mid = (mid + Math.imul(al4, bh6)) | 0;
  9043. mid = (mid + Math.imul(ah4, bl6)) | 0;
  9044. hi = (hi + Math.imul(ah4, bh6)) | 0;
  9045. lo = (lo + Math.imul(al3, bl7)) | 0;
  9046. mid = (mid + Math.imul(al3, bh7)) | 0;
  9047. mid = (mid + Math.imul(ah3, bl7)) | 0;
  9048. hi = (hi + Math.imul(ah3, bh7)) | 0;
  9049. lo = (lo + Math.imul(al2, bl8)) | 0;
  9050. mid = (mid + Math.imul(al2, bh8)) | 0;
  9051. mid = (mid + Math.imul(ah2, bl8)) | 0;
  9052. hi = (hi + Math.imul(ah2, bh8)) | 0;
  9053. lo = (lo + Math.imul(al1, bl9)) | 0;
  9054. mid = (mid + Math.imul(al1, bh9)) | 0;
  9055. mid = (mid + Math.imul(ah1, bl9)) | 0;
  9056. hi = (hi + Math.imul(ah1, bh9)) | 0;
  9057. var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  9058. c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;
  9059. w10 &= 0x3ffffff;
  9060. /* k = 11 */
  9061. lo = Math.imul(al9, bl2);
  9062. mid = Math.imul(al9, bh2);
  9063. mid = (mid + Math.imul(ah9, bl2)) | 0;
  9064. hi = Math.imul(ah9, bh2);
  9065. lo = (lo + Math.imul(al8, bl3)) | 0;
  9066. mid = (mid + Math.imul(al8, bh3)) | 0;
  9067. mid = (mid + Math.imul(ah8, bl3)) | 0;
  9068. hi = (hi + Math.imul(ah8, bh3)) | 0;
  9069. lo = (lo + Math.imul(al7, bl4)) | 0;
  9070. mid = (mid + Math.imul(al7, bh4)) | 0;
  9071. mid = (mid + Math.imul(ah7, bl4)) | 0;
  9072. hi = (hi + Math.imul(ah7, bh4)) | 0;
  9073. lo = (lo + Math.imul(al6, bl5)) | 0;
  9074. mid = (mid + Math.imul(al6, bh5)) | 0;
  9075. mid = (mid + Math.imul(ah6, bl5)) | 0;
  9076. hi = (hi + Math.imul(ah6, bh5)) | 0;
  9077. lo = (lo + Math.imul(al5, bl6)) | 0;
  9078. mid = (mid + Math.imul(al5, bh6)) | 0;
  9079. mid = (mid + Math.imul(ah5, bl6)) | 0;
  9080. hi = (hi + Math.imul(ah5, bh6)) | 0;
  9081. lo = (lo + Math.imul(al4, bl7)) | 0;
  9082. mid = (mid + Math.imul(al4, bh7)) | 0;
  9083. mid = (mid + Math.imul(ah4, bl7)) | 0;
  9084. hi = (hi + Math.imul(ah4, bh7)) | 0;
  9085. lo = (lo + Math.imul(al3, bl8)) | 0;
  9086. mid = (mid + Math.imul(al3, bh8)) | 0;
  9087. mid = (mid + Math.imul(ah3, bl8)) | 0;
  9088. hi = (hi + Math.imul(ah3, bh8)) | 0;
  9089. lo = (lo + Math.imul(al2, bl9)) | 0;
  9090. mid = (mid + Math.imul(al2, bh9)) | 0;
  9091. mid = (mid + Math.imul(ah2, bl9)) | 0;
  9092. hi = (hi + Math.imul(ah2, bh9)) | 0;
  9093. var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  9094. c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;
  9095. w11 &= 0x3ffffff;
  9096. /* k = 12 */
  9097. lo = Math.imul(al9, bl3);
  9098. mid = Math.imul(al9, bh3);
  9099. mid = (mid + Math.imul(ah9, bl3)) | 0;
  9100. hi = Math.imul(ah9, bh3);
  9101. lo = (lo + Math.imul(al8, bl4)) | 0;
  9102. mid = (mid + Math.imul(al8, bh4)) | 0;
  9103. mid = (mid + Math.imul(ah8, bl4)) | 0;
  9104. hi = (hi + Math.imul(ah8, bh4)) | 0;
  9105. lo = (lo + Math.imul(al7, bl5)) | 0;
  9106. mid = (mid + Math.imul(al7, bh5)) | 0;
  9107. mid = (mid + Math.imul(ah7, bl5)) | 0;
  9108. hi = (hi + Math.imul(ah7, bh5)) | 0;
  9109. lo = (lo + Math.imul(al6, bl6)) | 0;
  9110. mid = (mid + Math.imul(al6, bh6)) | 0;
  9111. mid = (mid + Math.imul(ah6, bl6)) | 0;
  9112. hi = (hi + Math.imul(ah6, bh6)) | 0;
  9113. lo = (lo + Math.imul(al5, bl7)) | 0;
  9114. mid = (mid + Math.imul(al5, bh7)) | 0;
  9115. mid = (mid + Math.imul(ah5, bl7)) | 0;
  9116. hi = (hi + Math.imul(ah5, bh7)) | 0;
  9117. lo = (lo + Math.imul(al4, bl8)) | 0;
  9118. mid = (mid + Math.imul(al4, bh8)) | 0;
  9119. mid = (mid + Math.imul(ah4, bl8)) | 0;
  9120. hi = (hi + Math.imul(ah4, bh8)) | 0;
  9121. lo = (lo + Math.imul(al3, bl9)) | 0;
  9122. mid = (mid + Math.imul(al3, bh9)) | 0;
  9123. mid = (mid + Math.imul(ah3, bl9)) | 0;
  9124. hi = (hi + Math.imul(ah3, bh9)) | 0;
  9125. var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  9126. c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;
  9127. w12 &= 0x3ffffff;
  9128. /* k = 13 */
  9129. lo = Math.imul(al9, bl4);
  9130. mid = Math.imul(al9, bh4);
  9131. mid = (mid + Math.imul(ah9, bl4)) | 0;
  9132. hi = Math.imul(ah9, bh4);
  9133. lo = (lo + Math.imul(al8, bl5)) | 0;
  9134. mid = (mid + Math.imul(al8, bh5)) | 0;
  9135. mid = (mid + Math.imul(ah8, bl5)) | 0;
  9136. hi = (hi + Math.imul(ah8, bh5)) | 0;
  9137. lo = (lo + Math.imul(al7, bl6)) | 0;
  9138. mid = (mid + Math.imul(al7, bh6)) | 0;
  9139. mid = (mid + Math.imul(ah7, bl6)) | 0;
  9140. hi = (hi + Math.imul(ah7, bh6)) | 0;
  9141. lo = (lo + Math.imul(al6, bl7)) | 0;
  9142. mid = (mid + Math.imul(al6, bh7)) | 0;
  9143. mid = (mid + Math.imul(ah6, bl7)) | 0;
  9144. hi = (hi + Math.imul(ah6, bh7)) | 0;
  9145. lo = (lo + Math.imul(al5, bl8)) | 0;
  9146. mid = (mid + Math.imul(al5, bh8)) | 0;
  9147. mid = (mid + Math.imul(ah5, bl8)) | 0;
  9148. hi = (hi + Math.imul(ah5, bh8)) | 0;
  9149. lo = (lo + Math.imul(al4, bl9)) | 0;
  9150. mid = (mid + Math.imul(al4, bh9)) | 0;
  9151. mid = (mid + Math.imul(ah4, bl9)) | 0;
  9152. hi = (hi + Math.imul(ah4, bh9)) | 0;
  9153. var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  9154. c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;
  9155. w13 &= 0x3ffffff;
  9156. /* k = 14 */
  9157. lo = Math.imul(al9, bl5);
  9158. mid = Math.imul(al9, bh5);
  9159. mid = (mid + Math.imul(ah9, bl5)) | 0;
  9160. hi = Math.imul(ah9, bh5);
  9161. lo = (lo + Math.imul(al8, bl6)) | 0;
  9162. mid = (mid + Math.imul(al8, bh6)) | 0;
  9163. mid = (mid + Math.imul(ah8, bl6)) | 0;
  9164. hi = (hi + Math.imul(ah8, bh6)) | 0;
  9165. lo = (lo + Math.imul(al7, bl7)) | 0;
  9166. mid = (mid + Math.imul(al7, bh7)) | 0;
  9167. mid = (mid + Math.imul(ah7, bl7)) | 0;
  9168. hi = (hi + Math.imul(ah7, bh7)) | 0;
  9169. lo = (lo + Math.imul(al6, bl8)) | 0;
  9170. mid = (mid + Math.imul(al6, bh8)) | 0;
  9171. mid = (mid + Math.imul(ah6, bl8)) | 0;
  9172. hi = (hi + Math.imul(ah6, bh8)) | 0;
  9173. lo = (lo + Math.imul(al5, bl9)) | 0;
  9174. mid = (mid + Math.imul(al5, bh9)) | 0;
  9175. mid = (mid + Math.imul(ah5, bl9)) | 0;
  9176. hi = (hi + Math.imul(ah5, bh9)) | 0;
  9177. var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  9178. c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;
  9179. w14 &= 0x3ffffff;
  9180. /* k = 15 */
  9181. lo = Math.imul(al9, bl6);
  9182. mid = Math.imul(al9, bh6);
  9183. mid = (mid + Math.imul(ah9, bl6)) | 0;
  9184. hi = Math.imul(ah9, bh6);
  9185. lo = (lo + Math.imul(al8, bl7)) | 0;
  9186. mid = (mid + Math.imul(al8, bh7)) | 0;
  9187. mid = (mid + Math.imul(ah8, bl7)) | 0;
  9188. hi = (hi + Math.imul(ah8, bh7)) | 0;
  9189. lo = (lo + Math.imul(al7, bl8)) | 0;
  9190. mid = (mid + Math.imul(al7, bh8)) | 0;
  9191. mid = (mid + Math.imul(ah7, bl8)) | 0;
  9192. hi = (hi + Math.imul(ah7, bh8)) | 0;
  9193. lo = (lo + Math.imul(al6, bl9)) | 0;
  9194. mid = (mid + Math.imul(al6, bh9)) | 0;
  9195. mid = (mid + Math.imul(ah6, bl9)) | 0;
  9196. hi = (hi + Math.imul(ah6, bh9)) | 0;
  9197. var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  9198. c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;
  9199. w15 &= 0x3ffffff;
  9200. /* k = 16 */
  9201. lo = Math.imul(al9, bl7);
  9202. mid = Math.imul(al9, bh7);
  9203. mid = (mid + Math.imul(ah9, bl7)) | 0;
  9204. hi = Math.imul(ah9, bh7);
  9205. lo = (lo + Math.imul(al8, bl8)) | 0;
  9206. mid = (mid + Math.imul(al8, bh8)) | 0;
  9207. mid = (mid + Math.imul(ah8, bl8)) | 0;
  9208. hi = (hi + Math.imul(ah8, bh8)) | 0;
  9209. lo = (lo + Math.imul(al7, bl9)) | 0;
  9210. mid = (mid + Math.imul(al7, bh9)) | 0;
  9211. mid = (mid + Math.imul(ah7, bl9)) | 0;
  9212. hi = (hi + Math.imul(ah7, bh9)) | 0;
  9213. var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  9214. c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;
  9215. w16 &= 0x3ffffff;
  9216. /* k = 17 */
  9217. lo = Math.imul(al9, bl8);
  9218. mid = Math.imul(al9, bh8);
  9219. mid = (mid + Math.imul(ah9, bl8)) | 0;
  9220. hi = Math.imul(ah9, bh8);
  9221. lo = (lo + Math.imul(al8, bl9)) | 0;
  9222. mid = (mid + Math.imul(al8, bh9)) | 0;
  9223. mid = (mid + Math.imul(ah8, bl9)) | 0;
  9224. hi = (hi + Math.imul(ah8, bh9)) | 0;
  9225. var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  9226. c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;
  9227. w17 &= 0x3ffffff;
  9228. /* k = 18 */
  9229. lo = Math.imul(al9, bl9);
  9230. mid = Math.imul(al9, bh9);
  9231. mid = (mid + Math.imul(ah9, bl9)) | 0;
  9232. hi = Math.imul(ah9, bh9);
  9233. var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  9234. c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;
  9235. w18 &= 0x3ffffff;
  9236. o[0] = w0;
  9237. o[1] = w1;
  9238. o[2] = w2;
  9239. o[3] = w3;
  9240. o[4] = w4;
  9241. o[5] = w5;
  9242. o[6] = w6;
  9243. o[7] = w7;
  9244. o[8] = w8;
  9245. o[9] = w9;
  9246. o[10] = w10;
  9247. o[11] = w11;
  9248. o[12] = w12;
  9249. o[13] = w13;
  9250. o[14] = w14;
  9251. o[15] = w15;
  9252. o[16] = w16;
  9253. o[17] = w17;
  9254. o[18] = w18;
  9255. if (c !== 0) {
  9256. o[19] = c;
  9257. out.length++;
  9258. }
  9259. return out;
  9260. };
  9261. // Polyfill comb
  9262. if (!Math.imul) {
  9263. comb10MulTo = smallMulTo;
  9264. }
  9265. function bigMulTo (self, num, out) {
  9266. out.negative = num.negative ^ self.negative;
  9267. out.length = self.length + num.length;
  9268. var carry = 0;
  9269. var hncarry = 0;
  9270. for (var k = 0; k < out.length - 1; k++) {
  9271. // Sum all words with the same `i + j = k` and accumulate `ncarry`,
  9272. // note that ncarry could be >= 0x3ffffff
  9273. var ncarry = hncarry;
  9274. hncarry = 0;
  9275. var rword = carry & 0x3ffffff;
  9276. var maxJ = Math.min(k, num.length - 1);
  9277. for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
  9278. var i = k - j;
  9279. var a = self.words[i] | 0;
  9280. var b = num.words[j] | 0;
  9281. var r = a * b;
  9282. var lo = r & 0x3ffffff;
  9283. ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;
  9284. lo = (lo + rword) | 0;
  9285. rword = lo & 0x3ffffff;
  9286. ncarry = (ncarry + (lo >>> 26)) | 0;
  9287. hncarry += ncarry >>> 26;
  9288. ncarry &= 0x3ffffff;
  9289. }
  9290. out.words[k] = rword;
  9291. carry = ncarry;
  9292. ncarry = hncarry;
  9293. }
  9294. if (carry !== 0) {
  9295. out.words[k] = carry;
  9296. } else {
  9297. out.length--;
  9298. }
  9299. return out._strip();
  9300. }
  9301. function jumboMulTo (self, num, out) {
  9302. // Temporary disable, see https://github.com/indutny/bn.js/issues/211
  9303. // var fftm = new FFTM();
  9304. // return fftm.mulp(self, num, out);
  9305. return bigMulTo(self, num, out);
  9306. }
  9307. BN.prototype.mulTo = function mulTo (num, out) {
  9308. var res;
  9309. var len = this.length + num.length;
  9310. if (this.length === 10 && num.length === 10) {
  9311. res = comb10MulTo(this, num, out);
  9312. } else if (len < 63) {
  9313. res = smallMulTo(this, num, out);
  9314. } else if (len < 1024) {
  9315. res = bigMulTo(this, num, out);
  9316. } else {
  9317. res = jumboMulTo(this, num, out);
  9318. }
  9319. return res;
  9320. };
  9321. // Cooley-Tukey algorithm for FFT
  9322. // slightly revisited to rely on looping instead of recursion
  9323. function FFTM (x, y) {
  9324. this.x = x;
  9325. this.y = y;
  9326. }
  9327. FFTM.prototype.makeRBT = function makeRBT (N) {
  9328. var t = new Array(N);
  9329. var l = BN.prototype._countBits(N) - 1;
  9330. for (var i = 0; i < N; i++) {
  9331. t[i] = this.revBin(i, l, N);
  9332. }
  9333. return t;
  9334. };
  9335. // Returns binary-reversed representation of `x`
  9336. FFTM.prototype.revBin = function revBin (x, l, N) {
  9337. if (x === 0 || x === N - 1) return x;
  9338. var rb = 0;
  9339. for (var i = 0; i < l; i++) {
  9340. rb |= (x & 1) << (l - i - 1);
  9341. x >>= 1;
  9342. }
  9343. return rb;
  9344. };
  9345. // Performs "tweedling" phase, therefore 'emulating'
  9346. // behaviour of the recursive algorithm
  9347. FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {
  9348. for (var i = 0; i < N; i++) {
  9349. rtws[i] = rws[rbt[i]];
  9350. itws[i] = iws[rbt[i]];
  9351. }
  9352. };
  9353. FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {
  9354. this.permute(rbt, rws, iws, rtws, itws, N);
  9355. for (var s = 1; s < N; s <<= 1) {
  9356. var l = s << 1;
  9357. var rtwdf = Math.cos(2 * Math.PI / l);
  9358. var itwdf = Math.sin(2 * Math.PI / l);
  9359. for (var p = 0; p < N; p += l) {
  9360. var rtwdf_ = rtwdf;
  9361. var itwdf_ = itwdf;
  9362. for (var j = 0; j < s; j++) {
  9363. var re = rtws[p + j];
  9364. var ie = itws[p + j];
  9365. var ro = rtws[p + j + s];
  9366. var io = itws[p + j + s];
  9367. var rx = rtwdf_ * ro - itwdf_ * io;
  9368. io = rtwdf_ * io + itwdf_ * ro;
  9369. ro = rx;
  9370. rtws[p + j] = re + ro;
  9371. itws[p + j] = ie + io;
  9372. rtws[p + j + s] = re - ro;
  9373. itws[p + j + s] = ie - io;
  9374. /* jshint maxdepth : false */
  9375. if (j !== l) {
  9376. rx = rtwdf * rtwdf_ - itwdf * itwdf_;
  9377. itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
  9378. rtwdf_ = rx;
  9379. }
  9380. }
  9381. }
  9382. }
  9383. };
  9384. FFTM.prototype.guessLen13b = function guessLen13b (n, m) {
  9385. var N = Math.max(m, n) | 1;
  9386. var odd = N & 1;
  9387. var i = 0;
  9388. for (N = N / 2 | 0; N; N = N >>> 1) {
  9389. i++;
  9390. }
  9391. return 1 << i + 1 + odd;
  9392. };
  9393. FFTM.prototype.conjugate = function conjugate (rws, iws, N) {
  9394. if (N <= 1) return;
  9395. for (var i = 0; i < N / 2; i++) {
  9396. var t = rws[i];
  9397. rws[i] = rws[N - i - 1];
  9398. rws[N - i - 1] = t;
  9399. t = iws[i];
  9400. iws[i] = -iws[N - i - 1];
  9401. iws[N - i - 1] = -t;
  9402. }
  9403. };
  9404. FFTM.prototype.normalize13b = function normalize13b (ws, N) {
  9405. var carry = 0;
  9406. for (var i = 0; i < N / 2; i++) {
  9407. var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +
  9408. Math.round(ws[2 * i] / N) +
  9409. carry;
  9410. ws[i] = w & 0x3ffffff;
  9411. if (w < 0x4000000) {
  9412. carry = 0;
  9413. } else {
  9414. carry = w / 0x4000000 | 0;
  9415. }
  9416. }
  9417. return ws;
  9418. };
  9419. FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {
  9420. var carry = 0;
  9421. for (var i = 0; i < len; i++) {
  9422. carry = carry + (ws[i] | 0);
  9423. rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;
  9424. rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;
  9425. }
  9426. // Pad with zeroes
  9427. for (i = 2 * len; i < N; ++i) {
  9428. rws[i] = 0;
  9429. }
  9430. assert(carry === 0);
  9431. assert((carry & ~0x1fff) === 0);
  9432. };
  9433. FFTM.prototype.stub = function stub (N) {
  9434. var ph = new Array(N);
  9435. for (var i = 0; i < N; i++) {
  9436. ph[i] = 0;
  9437. }
  9438. return ph;
  9439. };
  9440. FFTM.prototype.mulp = function mulp (x, y, out) {
  9441. var N = 2 * this.guessLen13b(x.length, y.length);
  9442. var rbt = this.makeRBT(N);
  9443. var _ = this.stub(N);
  9444. var rws = new Array(N);
  9445. var rwst = new Array(N);
  9446. var iwst = new Array(N);
  9447. var nrws = new Array(N);
  9448. var nrwst = new Array(N);
  9449. var niwst = new Array(N);
  9450. var rmws = out.words;
  9451. rmws.length = N;
  9452. this.convert13b(x.words, x.length, rws, N);
  9453. this.convert13b(y.words, y.length, nrws, N);
  9454. this.transform(rws, _, rwst, iwst, N, rbt);
  9455. this.transform(nrws, _, nrwst, niwst, N, rbt);
  9456. for (var i = 0; i < N; i++) {
  9457. var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];
  9458. iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];
  9459. rwst[i] = rx;
  9460. }
  9461. this.conjugate(rwst, iwst, N);
  9462. this.transform(rwst, iwst, rmws, _, N, rbt);
  9463. this.conjugate(rmws, _, N);
  9464. this.normalize13b(rmws, N);
  9465. out.negative = x.negative ^ y.negative;
  9466. out.length = x.length + y.length;
  9467. return out._strip();
  9468. };
  9469. // Multiply `this` by `num`
  9470. BN.prototype.mul = function mul (num) {
  9471. var out = new BN(null);
  9472. out.words = new Array(this.length + num.length);
  9473. return this.mulTo(num, out);
  9474. };
  9475. // Multiply employing FFT
  9476. BN.prototype.mulf = function mulf (num) {
  9477. var out = new BN(null);
  9478. out.words = new Array(this.length + num.length);
  9479. return jumboMulTo(this, num, out);
  9480. };
  9481. // In-place Multiplication
  9482. BN.prototype.imul = function imul (num) {
  9483. return this.clone().mulTo(num, this);
  9484. };
  9485. BN.prototype.imuln = function imuln (num) {
  9486. var isNegNum = num < 0;
  9487. if (isNegNum) num = -num;
  9488. assert(typeof num === 'number');
  9489. assert(num < 0x4000000);
  9490. // Carry
  9491. var carry = 0;
  9492. for (var i = 0; i < this.length; i++) {
  9493. var w = (this.words[i] | 0) * num;
  9494. var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);
  9495. carry >>= 26;
  9496. carry += (w / 0x4000000) | 0;
  9497. // NOTE: lo is 27bit maximum
  9498. carry += lo >>> 26;
  9499. this.words[i] = lo & 0x3ffffff;
  9500. }
  9501. if (carry !== 0) {
  9502. this.words[i] = carry;
  9503. this.length++;
  9504. }
  9505. return isNegNum ? this.ineg() : this;
  9506. };
  9507. BN.prototype.muln = function muln (num) {
  9508. return this.clone().imuln(num);
  9509. };
  9510. // `this` * `this`
  9511. BN.prototype.sqr = function sqr () {
  9512. return this.mul(this);
  9513. };
  9514. // `this` * `this` in-place
  9515. BN.prototype.isqr = function isqr () {
  9516. return this.imul(this.clone());
  9517. };
  9518. // Math.pow(`this`, `num`)
  9519. BN.prototype.pow = function pow (num) {
  9520. var w = toBitArray(num);
  9521. if (w.length === 0) return new BN(1);
  9522. // Skip leading zeroes
  9523. var res = this;
  9524. for (var i = 0; i < w.length; i++, res = res.sqr()) {
  9525. if (w[i] !== 0) break;
  9526. }
  9527. if (++i < w.length) {
  9528. for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {
  9529. if (w[i] === 0) continue;
  9530. res = res.mul(q);
  9531. }
  9532. }
  9533. return res;
  9534. };
  9535. // Shift-left in-place
  9536. BN.prototype.iushln = function iushln (bits) {
  9537. assert(typeof bits === 'number' && bits >= 0);
  9538. var r = bits % 26;
  9539. var s = (bits - r) / 26;
  9540. var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);
  9541. var i;
  9542. if (r !== 0) {
  9543. var carry = 0;
  9544. for (i = 0; i < this.length; i++) {
  9545. var newCarry = this.words[i] & carryMask;
  9546. var c = ((this.words[i] | 0) - newCarry) << r;
  9547. this.words[i] = c | carry;
  9548. carry = newCarry >>> (26 - r);
  9549. }
  9550. if (carry) {
  9551. this.words[i] = carry;
  9552. this.length++;
  9553. }
  9554. }
  9555. if (s !== 0) {
  9556. for (i = this.length - 1; i >= 0; i--) {
  9557. this.words[i + s] = this.words[i];
  9558. }
  9559. for (i = 0; i < s; i++) {
  9560. this.words[i] = 0;
  9561. }
  9562. this.length += s;
  9563. }
  9564. return this._strip();
  9565. };
  9566. BN.prototype.ishln = function ishln (bits) {
  9567. // TODO(indutny): implement me
  9568. assert(this.negative === 0);
  9569. return this.iushln(bits);
  9570. };
  9571. // Shift-right in-place
  9572. // NOTE: `hint` is a lowest bit before trailing zeroes
  9573. // NOTE: if `extended` is present - it will be filled with destroyed bits
  9574. BN.prototype.iushrn = function iushrn (bits, hint, extended) {
  9575. assert(typeof bits === 'number' && bits >= 0);
  9576. var h;
  9577. if (hint) {
  9578. h = (hint - (hint % 26)) / 26;
  9579. } else {
  9580. h = 0;
  9581. }
  9582. var r = bits % 26;
  9583. var s = Math.min((bits - r) / 26, this.length);
  9584. var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
  9585. var maskedWords = extended;
  9586. h -= s;
  9587. h = Math.max(0, h);
  9588. // Extended mode, copy masked part
  9589. if (maskedWords) {
  9590. for (var i = 0; i < s; i++) {
  9591. maskedWords.words[i] = this.words[i];
  9592. }
  9593. maskedWords.length = s;
  9594. }
  9595. if (s === 0) {
  9596. // No-op, we should not move anything at all
  9597. } else if (this.length > s) {
  9598. this.length -= s;
  9599. for (i = 0; i < this.length; i++) {
  9600. this.words[i] = this.words[i + s];
  9601. }
  9602. } else {
  9603. this.words[0] = 0;
  9604. this.length = 1;
  9605. }
  9606. var carry = 0;
  9607. for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {
  9608. var word = this.words[i] | 0;
  9609. this.words[i] = (carry << (26 - r)) | (word >>> r);
  9610. carry = word & mask;
  9611. }
  9612. // Push carried bits as a mask
  9613. if (maskedWords && carry !== 0) {
  9614. maskedWords.words[maskedWords.length++] = carry;
  9615. }
  9616. if (this.length === 0) {
  9617. this.words[0] = 0;
  9618. this.length = 1;
  9619. }
  9620. return this._strip();
  9621. };
  9622. BN.prototype.ishrn = function ishrn (bits, hint, extended) {
  9623. // TODO(indutny): implement me
  9624. assert(this.negative === 0);
  9625. return this.iushrn(bits, hint, extended);
  9626. };
  9627. // Shift-left
  9628. BN.prototype.shln = function shln (bits) {
  9629. return this.clone().ishln(bits);
  9630. };
  9631. BN.prototype.ushln = function ushln (bits) {
  9632. return this.clone().iushln(bits);
  9633. };
  9634. // Shift-right
  9635. BN.prototype.shrn = function shrn (bits) {
  9636. return this.clone().ishrn(bits);
  9637. };
  9638. BN.prototype.ushrn = function ushrn (bits) {
  9639. return this.clone().iushrn(bits);
  9640. };
  9641. // Test if n bit is set
  9642. BN.prototype.testn = function testn (bit) {
  9643. assert(typeof bit === 'number' && bit >= 0);
  9644. var r = bit % 26;
  9645. var s = (bit - r) / 26;
  9646. var q = 1 << r;
  9647. // Fast case: bit is much higher than all existing words
  9648. if (this.length <= s) return false;
  9649. // Check bit and return
  9650. var w = this.words[s];
  9651. return !!(w & q);
  9652. };
  9653. // Return only lowers bits of number (in-place)
  9654. BN.prototype.imaskn = function imaskn (bits) {
  9655. assert(typeof bits === 'number' && bits >= 0);
  9656. var r = bits % 26;
  9657. var s = (bits - r) / 26;
  9658. assert(this.negative === 0, 'imaskn works only with positive numbers');
  9659. if (this.length <= s) {
  9660. return this;
  9661. }
  9662. if (r !== 0) {
  9663. s++;
  9664. }
  9665. this.length = Math.min(s, this.length);
  9666. if (r !== 0) {
  9667. var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
  9668. this.words[this.length - 1] &= mask;
  9669. }
  9670. return this._strip();
  9671. };
  9672. // Return only lowers bits of number
  9673. BN.prototype.maskn = function maskn (bits) {
  9674. return this.clone().imaskn(bits);
  9675. };
  9676. // Add plain number `num` to `this`
  9677. BN.prototype.iaddn = function iaddn (num) {
  9678. assert(typeof num === 'number');
  9679. assert(num < 0x4000000);
  9680. if (num < 0) return this.isubn(-num);
  9681. // Possible sign change
  9682. if (this.negative !== 0) {
  9683. if (this.length === 1 && (this.words[0] | 0) <= num) {
  9684. this.words[0] = num - (this.words[0] | 0);
  9685. this.negative = 0;
  9686. return this;
  9687. }
  9688. this.negative = 0;
  9689. this.isubn(num);
  9690. this.negative = 1;
  9691. return this;
  9692. }
  9693. // Add without checks
  9694. return this._iaddn(num);
  9695. };
  9696. BN.prototype._iaddn = function _iaddn (num) {
  9697. this.words[0] += num;
  9698. // Carry
  9699. for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {
  9700. this.words[i] -= 0x4000000;
  9701. if (i === this.length - 1) {
  9702. this.words[i + 1] = 1;
  9703. } else {
  9704. this.words[i + 1]++;
  9705. }
  9706. }
  9707. this.length = Math.max(this.length, i + 1);
  9708. return this;
  9709. };
  9710. // Subtract plain number `num` from `this`
  9711. BN.prototype.isubn = function isubn (num) {
  9712. assert(typeof num === 'number');
  9713. assert(num < 0x4000000);
  9714. if (num < 0) return this.iaddn(-num);
  9715. if (this.negative !== 0) {
  9716. this.negative = 0;
  9717. this.iaddn(num);
  9718. this.negative = 1;
  9719. return this;
  9720. }
  9721. this.words[0] -= num;
  9722. if (this.length === 1 && this.words[0] < 0) {
  9723. this.words[0] = -this.words[0];
  9724. this.negative = 1;
  9725. } else {
  9726. // Carry
  9727. for (var i = 0; i < this.length && this.words[i] < 0; i++) {
  9728. this.words[i] += 0x4000000;
  9729. this.words[i + 1] -= 1;
  9730. }
  9731. }
  9732. return this._strip();
  9733. };
  9734. BN.prototype.addn = function addn (num) {
  9735. return this.clone().iaddn(num);
  9736. };
  9737. BN.prototype.subn = function subn (num) {
  9738. return this.clone().isubn(num);
  9739. };
  9740. BN.prototype.iabs = function iabs () {
  9741. this.negative = 0;
  9742. return this;
  9743. };
  9744. BN.prototype.abs = function abs () {
  9745. return this.clone().iabs();
  9746. };
  9747. BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {
  9748. var len = num.length + shift;
  9749. var i;
  9750. this._expand(len);
  9751. var w;
  9752. var carry = 0;
  9753. for (i = 0; i < num.length; i++) {
  9754. w = (this.words[i + shift] | 0) + carry;
  9755. var right = (num.words[i] | 0) * mul;
  9756. w -= right & 0x3ffffff;
  9757. carry = (w >> 26) - ((right / 0x4000000) | 0);
  9758. this.words[i + shift] = w & 0x3ffffff;
  9759. }
  9760. for (; i < this.length - shift; i++) {
  9761. w = (this.words[i + shift] | 0) + carry;
  9762. carry = w >> 26;
  9763. this.words[i + shift] = w & 0x3ffffff;
  9764. }
  9765. if (carry === 0) return this._strip();
  9766. // Subtraction overflow
  9767. assert(carry === -1);
  9768. carry = 0;
  9769. for (i = 0; i < this.length; i++) {
  9770. w = -(this.words[i] | 0) + carry;
  9771. carry = w >> 26;
  9772. this.words[i] = w & 0x3ffffff;
  9773. }
  9774. this.negative = 1;
  9775. return this._strip();
  9776. };
  9777. BN.prototype._wordDiv = function _wordDiv (num, mode) {
  9778. var shift = this.length - num.length;
  9779. var a = this.clone();
  9780. var b = num;
  9781. // Normalize
  9782. var bhi = b.words[b.length - 1] | 0;
  9783. var bhiBits = this._countBits(bhi);
  9784. shift = 26 - bhiBits;
  9785. if (shift !== 0) {
  9786. b = b.ushln(shift);
  9787. a.iushln(shift);
  9788. bhi = b.words[b.length - 1] | 0;
  9789. }
  9790. // Initialize quotient
  9791. var m = a.length - b.length;
  9792. var q;
  9793. if (mode !== 'mod') {
  9794. q = new BN(null);
  9795. q.length = m + 1;
  9796. q.words = new Array(q.length);
  9797. for (var i = 0; i < q.length; i++) {
  9798. q.words[i] = 0;
  9799. }
  9800. }
  9801. var diff = a.clone()._ishlnsubmul(b, 1, m);
  9802. if (diff.negative === 0) {
  9803. a = diff;
  9804. if (q) {
  9805. q.words[m] = 1;
  9806. }
  9807. }
  9808. for (var j = m - 1; j >= 0; j--) {
  9809. var qj = (a.words[b.length + j] | 0) * 0x4000000 +
  9810. (a.words[b.length + j - 1] | 0);
  9811. // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
  9812. // (0x7ffffff)
  9813. qj = Math.min((qj / bhi) | 0, 0x3ffffff);
  9814. a._ishlnsubmul(b, qj, j);
  9815. while (a.negative !== 0) {
  9816. qj--;
  9817. a.negative = 0;
  9818. a._ishlnsubmul(b, 1, j);
  9819. if (!a.isZero()) {
  9820. a.negative ^= 1;
  9821. }
  9822. }
  9823. if (q) {
  9824. q.words[j] = qj;
  9825. }
  9826. }
  9827. if (q) {
  9828. q._strip();
  9829. }
  9830. a._strip();
  9831. // Denormalize
  9832. if (mode !== 'div' && shift !== 0) {
  9833. a.iushrn(shift);
  9834. }
  9835. return {
  9836. div: q || null,
  9837. mod: a
  9838. };
  9839. };
  9840. // NOTE: 1) `mode` can be set to `mod` to request mod only,
  9841. // to `div` to request div only, or be absent to
  9842. // request both div & mod
  9843. // 2) `positive` is true if unsigned mod is requested
  9844. BN.prototype.divmod = function divmod (num, mode, positive) {
  9845. assert(!num.isZero());
  9846. if (this.isZero()) {
  9847. return {
  9848. div: new BN(0),
  9849. mod: new BN(0)
  9850. };
  9851. }
  9852. var div, mod, res;
  9853. if (this.negative !== 0 && num.negative === 0) {
  9854. res = this.neg().divmod(num, mode);
  9855. if (mode !== 'mod') {
  9856. div = res.div.neg();
  9857. }
  9858. if (mode !== 'div') {
  9859. mod = res.mod.neg();
  9860. if (positive && mod.negative !== 0) {
  9861. mod.iadd(num);
  9862. }
  9863. }
  9864. return {
  9865. div: div,
  9866. mod: mod
  9867. };
  9868. }
  9869. if (this.negative === 0 && num.negative !== 0) {
  9870. res = this.divmod(num.neg(), mode);
  9871. if (mode !== 'mod') {
  9872. div = res.div.neg();
  9873. }
  9874. return {
  9875. div: div,
  9876. mod: res.mod
  9877. };
  9878. }
  9879. if ((this.negative & num.negative) !== 0) {
  9880. res = this.neg().divmod(num.neg(), mode);
  9881. if (mode !== 'div') {
  9882. mod = res.mod.neg();
  9883. if (positive && mod.negative !== 0) {
  9884. mod.isub(num);
  9885. }
  9886. }
  9887. return {
  9888. div: res.div,
  9889. mod: mod
  9890. };
  9891. }
  9892. // Both numbers are positive at this point
  9893. // Strip both numbers to approximate shift value
  9894. if (num.length > this.length || this.cmp(num) < 0) {
  9895. return {
  9896. div: new BN(0),
  9897. mod: this
  9898. };
  9899. }
  9900. // Very short reduction
  9901. if (num.length === 1) {
  9902. if (mode === 'div') {
  9903. return {
  9904. div: this.divn(num.words[0]),
  9905. mod: null
  9906. };
  9907. }
  9908. if (mode === 'mod') {
  9909. return {
  9910. div: null,
  9911. mod: new BN(this.modrn(num.words[0]))
  9912. };
  9913. }
  9914. return {
  9915. div: this.divn(num.words[0]),
  9916. mod: new BN(this.modrn(num.words[0]))
  9917. };
  9918. }
  9919. return this._wordDiv(num, mode);
  9920. };
  9921. // Find `this` / `num`
  9922. BN.prototype.div = function div (num) {
  9923. return this.divmod(num, 'div', false).div;
  9924. };
  9925. // Find `this` % `num`
  9926. BN.prototype.mod = function mod (num) {
  9927. return this.divmod(num, 'mod', false).mod;
  9928. };
  9929. BN.prototype.umod = function umod (num) {
  9930. return this.divmod(num, 'mod', true).mod;
  9931. };
  9932. // Find Round(`this` / `num`)
  9933. BN.prototype.divRound = function divRound (num) {
  9934. var dm = this.divmod(num);
  9935. // Fast case - exact division
  9936. if (dm.mod.isZero()) return dm.div;
  9937. var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
  9938. var half = num.ushrn(1);
  9939. var r2 = num.andln(1);
  9940. var cmp = mod.cmp(half);
  9941. // Round down
  9942. if (cmp < 0 || (r2 === 1 && cmp === 0)) return dm.div;
  9943. // Round up
  9944. return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
  9945. };
  9946. BN.prototype.modrn = function modrn (num) {
  9947. var isNegNum = num < 0;
  9948. if (isNegNum) num = -num;
  9949. assert(num <= 0x3ffffff);
  9950. var p = (1 << 26) % num;
  9951. var acc = 0;
  9952. for (var i = this.length - 1; i >= 0; i--) {
  9953. acc = (p * acc + (this.words[i] | 0)) % num;
  9954. }
  9955. return isNegNum ? -acc : acc;
  9956. };
  9957. // WARNING: DEPRECATED
  9958. BN.prototype.modn = function modn (num) {
  9959. return this.modrn(num);
  9960. };
  9961. // In-place division by number
  9962. BN.prototype.idivn = function idivn (num) {
  9963. var isNegNum = num < 0;
  9964. if (isNegNum) num = -num;
  9965. assert(num <= 0x3ffffff);
  9966. var carry = 0;
  9967. for (var i = this.length - 1; i >= 0; i--) {
  9968. var w = (this.words[i] | 0) + carry * 0x4000000;
  9969. this.words[i] = (w / num) | 0;
  9970. carry = w % num;
  9971. }
  9972. this._strip();
  9973. return isNegNum ? this.ineg() : this;
  9974. };
  9975. BN.prototype.divn = function divn (num) {
  9976. return this.clone().idivn(num);
  9977. };
  9978. BN.prototype.egcd = function egcd (p) {
  9979. assert(p.negative === 0);
  9980. assert(!p.isZero());
  9981. var x = this;
  9982. var y = p.clone();
  9983. if (x.negative !== 0) {
  9984. x = x.umod(p);
  9985. } else {
  9986. x = x.clone();
  9987. }
  9988. // A * x + B * y = x
  9989. var A = new BN(1);
  9990. var B = new BN(0);
  9991. // C * x + D * y = y
  9992. var C = new BN(0);
  9993. var D = new BN(1);
  9994. var g = 0;
  9995. while (x.isEven() && y.isEven()) {
  9996. x.iushrn(1);
  9997. y.iushrn(1);
  9998. ++g;
  9999. }
  10000. var yp = y.clone();
  10001. var xp = x.clone();
  10002. while (!x.isZero()) {
  10003. for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
  10004. if (i > 0) {
  10005. x.iushrn(i);
  10006. while (i-- > 0) {
  10007. if (A.isOdd() || B.isOdd()) {
  10008. A.iadd(yp);
  10009. B.isub(xp);
  10010. }
  10011. A.iushrn(1);
  10012. B.iushrn(1);
  10013. }
  10014. }
  10015. for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
  10016. if (j > 0) {
  10017. y.iushrn(j);
  10018. while (j-- > 0) {
  10019. if (C.isOdd() || D.isOdd()) {
  10020. C.iadd(yp);
  10021. D.isub(xp);
  10022. }
  10023. C.iushrn(1);
  10024. D.iushrn(1);
  10025. }
  10026. }
  10027. if (x.cmp(y) >= 0) {
  10028. x.isub(y);
  10029. A.isub(C);
  10030. B.isub(D);
  10031. } else {
  10032. y.isub(x);
  10033. C.isub(A);
  10034. D.isub(B);
  10035. }
  10036. }
  10037. return {
  10038. a: C,
  10039. b: D,
  10040. gcd: y.iushln(g)
  10041. };
  10042. };
  10043. // This is reduced incarnation of the binary EEA
  10044. // above, designated to invert members of the
  10045. // _prime_ fields F(p) at a maximal speed
  10046. BN.prototype._invmp = function _invmp (p) {
  10047. assert(p.negative === 0);
  10048. assert(!p.isZero());
  10049. var a = this;
  10050. var b = p.clone();
  10051. if (a.negative !== 0) {
  10052. a = a.umod(p);
  10053. } else {
  10054. a = a.clone();
  10055. }
  10056. var x1 = new BN(1);
  10057. var x2 = new BN(0);
  10058. var delta = b.clone();
  10059. while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
  10060. for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
  10061. if (i > 0) {
  10062. a.iushrn(i);
  10063. while (i-- > 0) {
  10064. if (x1.isOdd()) {
  10065. x1.iadd(delta);
  10066. }
  10067. x1.iushrn(1);
  10068. }
  10069. }
  10070. for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
  10071. if (j > 0) {
  10072. b.iushrn(j);
  10073. while (j-- > 0) {
  10074. if (x2.isOdd()) {
  10075. x2.iadd(delta);
  10076. }
  10077. x2.iushrn(1);
  10078. }
  10079. }
  10080. if (a.cmp(b) >= 0) {
  10081. a.isub(b);
  10082. x1.isub(x2);
  10083. } else {
  10084. b.isub(a);
  10085. x2.isub(x1);
  10086. }
  10087. }
  10088. var res;
  10089. if (a.cmpn(1) === 0) {
  10090. res = x1;
  10091. } else {
  10092. res = x2;
  10093. }
  10094. if (res.cmpn(0) < 0) {
  10095. res.iadd(p);
  10096. }
  10097. return res;
  10098. };
  10099. BN.prototype.gcd = function gcd (num) {
  10100. if (this.isZero()) return num.abs();
  10101. if (num.isZero()) return this.abs();
  10102. var a = this.clone();
  10103. var b = num.clone();
  10104. a.negative = 0;
  10105. b.negative = 0;
  10106. // Remove common factor of two
  10107. for (var shift = 0; a.isEven() && b.isEven(); shift++) {
  10108. a.iushrn(1);
  10109. b.iushrn(1);
  10110. }
  10111. do {
  10112. while (a.isEven()) {
  10113. a.iushrn(1);
  10114. }
  10115. while (b.isEven()) {
  10116. b.iushrn(1);
  10117. }
  10118. var r = a.cmp(b);
  10119. if (r < 0) {
  10120. // Swap `a` and `b` to make `a` always bigger than `b`
  10121. var t = a;
  10122. a = b;
  10123. b = t;
  10124. } else if (r === 0 || b.cmpn(1) === 0) {
  10125. break;
  10126. }
  10127. a.isub(b);
  10128. } while (true);
  10129. return b.iushln(shift);
  10130. };
  10131. // Invert number in the field F(num)
  10132. BN.prototype.invm = function invm (num) {
  10133. return this.egcd(num).a.umod(num);
  10134. };
  10135. BN.prototype.isEven = function isEven () {
  10136. return (this.words[0] & 1) === 0;
  10137. };
  10138. BN.prototype.isOdd = function isOdd () {
  10139. return (this.words[0] & 1) === 1;
  10140. };
  10141. // And first word and num
  10142. BN.prototype.andln = function andln (num) {
  10143. return this.words[0] & num;
  10144. };
  10145. // Increment at the bit position in-line
  10146. BN.prototype.bincn = function bincn (bit) {
  10147. assert(typeof bit === 'number');
  10148. var r = bit % 26;
  10149. var s = (bit - r) / 26;
  10150. var q = 1 << r;
  10151. // Fast case: bit is much higher than all existing words
  10152. if (this.length <= s) {
  10153. this._expand(s + 1);
  10154. this.words[s] |= q;
  10155. return this;
  10156. }
  10157. // Add bit and propagate, if needed
  10158. var carry = q;
  10159. for (var i = s; carry !== 0 && i < this.length; i++) {
  10160. var w = this.words[i] | 0;
  10161. w += carry;
  10162. carry = w >>> 26;
  10163. w &= 0x3ffffff;
  10164. this.words[i] = w;
  10165. }
  10166. if (carry !== 0) {
  10167. this.words[i] = carry;
  10168. this.length++;
  10169. }
  10170. return this;
  10171. };
  10172. BN.prototype.isZero = function isZero () {
  10173. return this.length === 1 && this.words[0] === 0;
  10174. };
  10175. BN.prototype.cmpn = function cmpn (num) {
  10176. var negative = num < 0;
  10177. if (this.negative !== 0 && !negative) return -1;
  10178. if (this.negative === 0 && negative) return 1;
  10179. this._strip();
  10180. var res;
  10181. if (this.length > 1) {
  10182. res = 1;
  10183. } else {
  10184. if (negative) {
  10185. num = -num;
  10186. }
  10187. assert(num <= 0x3ffffff, 'Number is too big');
  10188. var w = this.words[0] | 0;
  10189. res = w === num ? 0 : w < num ? -1 : 1;
  10190. }
  10191. if (this.negative !== 0) return -res | 0;
  10192. return res;
  10193. };
  10194. // Compare two numbers and return:
  10195. // 1 - if `this` > `num`
  10196. // 0 - if `this` == `num`
  10197. // -1 - if `this` < `num`
  10198. BN.prototype.cmp = function cmp (num) {
  10199. if (this.negative !== 0 && num.negative === 0) return -1;
  10200. if (this.negative === 0 && num.negative !== 0) return 1;
  10201. var res = this.ucmp(num);
  10202. if (this.negative !== 0) return -res | 0;
  10203. return res;
  10204. };
  10205. // Unsigned comparison
  10206. BN.prototype.ucmp = function ucmp (num) {
  10207. // At this point both numbers have the same sign
  10208. if (this.length > num.length) return 1;
  10209. if (this.length < num.length) return -1;
  10210. var res = 0;
  10211. for (var i = this.length - 1; i >= 0; i--) {
  10212. var a = this.words[i] | 0;
  10213. var b = num.words[i] | 0;
  10214. if (a === b) continue;
  10215. if (a < b) {
  10216. res = -1;
  10217. } else if (a > b) {
  10218. res = 1;
  10219. }
  10220. break;
  10221. }
  10222. return res;
  10223. };
  10224. BN.prototype.gtn = function gtn (num) {
  10225. return this.cmpn(num) === 1;
  10226. };
  10227. BN.prototype.gt = function gt (num) {
  10228. return this.cmp(num) === 1;
  10229. };
  10230. BN.prototype.gten = function gten (num) {
  10231. return this.cmpn(num) >= 0;
  10232. };
  10233. BN.prototype.gte = function gte (num) {
  10234. return this.cmp(num) >= 0;
  10235. };
  10236. BN.prototype.ltn = function ltn (num) {
  10237. return this.cmpn(num) === -1;
  10238. };
  10239. BN.prototype.lt = function lt (num) {
  10240. return this.cmp(num) === -1;
  10241. };
  10242. BN.prototype.lten = function lten (num) {
  10243. return this.cmpn(num) <= 0;
  10244. };
  10245. BN.prototype.lte = function lte (num) {
  10246. return this.cmp(num) <= 0;
  10247. };
  10248. BN.prototype.eqn = function eqn (num) {
  10249. return this.cmpn(num) === 0;
  10250. };
  10251. BN.prototype.eq = function eq (num) {
  10252. return this.cmp(num) === 0;
  10253. };
  10254. //
  10255. // A reduce context, could be using montgomery or something better, depending
  10256. // on the `m` itself.
  10257. //
  10258. BN.red = function red (num) {
  10259. return new Red(num);
  10260. };
  10261. BN.prototype.toRed = function toRed (ctx) {
  10262. assert(!this.red, 'Already a number in reduction context');
  10263. assert(this.negative === 0, 'red works only with positives');
  10264. return ctx.convertTo(this)._forceRed(ctx);
  10265. };
  10266. BN.prototype.fromRed = function fromRed () {
  10267. assert(this.red, 'fromRed works only with numbers in reduction context');
  10268. return this.red.convertFrom(this);
  10269. };
  10270. BN.prototype._forceRed = function _forceRed (ctx) {
  10271. this.red = ctx;
  10272. return this;
  10273. };
  10274. BN.prototype.forceRed = function forceRed (ctx) {
  10275. assert(!this.red, 'Already a number in reduction context');
  10276. return this._forceRed(ctx);
  10277. };
  10278. BN.prototype.redAdd = function redAdd (num) {
  10279. assert(this.red, 'redAdd works only with red numbers');
  10280. return this.red.add(this, num);
  10281. };
  10282. BN.prototype.redIAdd = function redIAdd (num) {
  10283. assert(this.red, 'redIAdd works only with red numbers');
  10284. return this.red.iadd(this, num);
  10285. };
  10286. BN.prototype.redSub = function redSub (num) {
  10287. assert(this.red, 'redSub works only with red numbers');
  10288. return this.red.sub(this, num);
  10289. };
  10290. BN.prototype.redISub = function redISub (num) {
  10291. assert(this.red, 'redISub works only with red numbers');
  10292. return this.red.isub(this, num);
  10293. };
  10294. BN.prototype.redShl = function redShl (num) {
  10295. assert(this.red, 'redShl works only with red numbers');
  10296. return this.red.shl(this, num);
  10297. };
  10298. BN.prototype.redMul = function redMul (num) {
  10299. assert(this.red, 'redMul works only with red numbers');
  10300. this.red._verify2(this, num);
  10301. return this.red.mul(this, num);
  10302. };
  10303. BN.prototype.redIMul = function redIMul (num) {
  10304. assert(this.red, 'redMul works only with red numbers');
  10305. this.red._verify2(this, num);
  10306. return this.red.imul(this, num);
  10307. };
  10308. BN.prototype.redSqr = function redSqr () {
  10309. assert(this.red, 'redSqr works only with red numbers');
  10310. this.red._verify1(this);
  10311. return this.red.sqr(this);
  10312. };
  10313. BN.prototype.redISqr = function redISqr () {
  10314. assert(this.red, 'redISqr works only with red numbers');
  10315. this.red._verify1(this);
  10316. return this.red.isqr(this);
  10317. };
  10318. // Square root over p
  10319. BN.prototype.redSqrt = function redSqrt () {
  10320. assert(this.red, 'redSqrt works only with red numbers');
  10321. this.red._verify1(this);
  10322. return this.red.sqrt(this);
  10323. };
  10324. BN.prototype.redInvm = function redInvm () {
  10325. assert(this.red, 'redInvm works only with red numbers');
  10326. this.red._verify1(this);
  10327. return this.red.invm(this);
  10328. };
  10329. // Return negative clone of `this` % `red modulo`
  10330. BN.prototype.redNeg = function redNeg () {
  10331. assert(this.red, 'redNeg works only with red numbers');
  10332. this.red._verify1(this);
  10333. return this.red.neg(this);
  10334. };
  10335. BN.prototype.redPow = function redPow (num) {
  10336. assert(this.red && !num.red, 'redPow(normalNum)');
  10337. this.red._verify1(this);
  10338. return this.red.pow(this, num);
  10339. };
  10340. // Prime numbers with efficient reduction
  10341. var primes = {
  10342. k256: null,
  10343. p224: null,
  10344. p192: null,
  10345. p25519: null
  10346. };
  10347. // Pseudo-Mersenne prime
  10348. function MPrime (name, p) {
  10349. // P = 2 ^ N - K
  10350. this.name = name;
  10351. this.p = new BN(p, 16);
  10352. this.n = this.p.bitLength();
  10353. this.k = new BN(1).iushln(this.n).isub(this.p);
  10354. this.tmp = this._tmp();
  10355. }
  10356. MPrime.prototype._tmp = function _tmp () {
  10357. var tmp = new BN(null);
  10358. tmp.words = new Array(Math.ceil(this.n / 13));
  10359. return tmp;
  10360. };
  10361. MPrime.prototype.ireduce = function ireduce (num) {
  10362. // Assumes that `num` is less than `P^2`
  10363. // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)
  10364. var r = num;
  10365. var rlen;
  10366. do {
  10367. this.split(r, this.tmp);
  10368. r = this.imulK(r);
  10369. r = r.iadd(this.tmp);
  10370. rlen = r.bitLength();
  10371. } while (rlen > this.n);
  10372. var cmp = rlen < this.n ? -1 : r.ucmp(this.p);
  10373. if (cmp === 0) {
  10374. r.words[0] = 0;
  10375. r.length = 1;
  10376. } else if (cmp > 0) {
  10377. r.isub(this.p);
  10378. } else {
  10379. if (r.strip !== undefined) {
  10380. // r is a BN v4 instance
  10381. r.strip();
  10382. } else {
  10383. // r is a BN v5 instance
  10384. r._strip();
  10385. }
  10386. }
  10387. return r;
  10388. };
  10389. MPrime.prototype.split = function split (input, out) {
  10390. input.iushrn(this.n, 0, out);
  10391. };
  10392. MPrime.prototype.imulK = function imulK (num) {
  10393. return num.imul(this.k);
  10394. };
  10395. function K256 () {
  10396. MPrime.call(
  10397. this,
  10398. 'k256',
  10399. 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');
  10400. }
  10401. inherits(K256, MPrime);
  10402. K256.prototype.split = function split (input, output) {
  10403. // 256 = 9 * 26 + 22
  10404. var mask = 0x3fffff;
  10405. var outLen = Math.min(input.length, 9);
  10406. for (var i = 0; i < outLen; i++) {
  10407. output.words[i] = input.words[i];
  10408. }
  10409. output.length = outLen;
  10410. if (input.length <= 9) {
  10411. input.words[0] = 0;
  10412. input.length = 1;
  10413. return;
  10414. }
  10415. // Shift by 9 limbs
  10416. var prev = input.words[9];
  10417. output.words[output.length++] = prev & mask;
  10418. for (i = 10; i < input.length; i++) {
  10419. var next = input.words[i] | 0;
  10420. input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);
  10421. prev = next;
  10422. }
  10423. prev >>>= 22;
  10424. input.words[i - 10] = prev;
  10425. if (prev === 0 && input.length > 10) {
  10426. input.length -= 10;
  10427. } else {
  10428. input.length -= 9;
  10429. }
  10430. };
  10431. K256.prototype.imulK = function imulK (num) {
  10432. // K = 0x1000003d1 = [ 0x40, 0x3d1 ]
  10433. num.words[num.length] = 0;
  10434. num.words[num.length + 1] = 0;
  10435. num.length += 2;
  10436. // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
  10437. var lo = 0;
  10438. for (var i = 0; i < num.length; i++) {
  10439. var w = num.words[i] | 0;
  10440. lo += w * 0x3d1;
  10441. num.words[i] = lo & 0x3ffffff;
  10442. lo = w * 0x40 + ((lo / 0x4000000) | 0);
  10443. }
  10444. // Fast length reduction
  10445. if (num.words[num.length - 1] === 0) {
  10446. num.length--;
  10447. if (num.words[num.length - 1] === 0) {
  10448. num.length--;
  10449. }
  10450. }
  10451. return num;
  10452. };
  10453. function P224 () {
  10454. MPrime.call(
  10455. this,
  10456. 'p224',
  10457. 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');
  10458. }
  10459. inherits(P224, MPrime);
  10460. function P192 () {
  10461. MPrime.call(
  10462. this,
  10463. 'p192',
  10464. 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');
  10465. }
  10466. inherits(P192, MPrime);
  10467. function P25519 () {
  10468. // 2 ^ 255 - 19
  10469. MPrime.call(
  10470. this,
  10471. '25519',
  10472. '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');
  10473. }
  10474. inherits(P25519, MPrime);
  10475. P25519.prototype.imulK = function imulK (num) {
  10476. // K = 0x13
  10477. var carry = 0;
  10478. for (var i = 0; i < num.length; i++) {
  10479. var hi = (num.words[i] | 0) * 0x13 + carry;
  10480. var lo = hi & 0x3ffffff;
  10481. hi >>>= 26;
  10482. num.words[i] = lo;
  10483. carry = hi;
  10484. }
  10485. if (carry !== 0) {
  10486. num.words[num.length++] = carry;
  10487. }
  10488. return num;
  10489. };
  10490. // Exported mostly for testing purposes, use plain name instead
  10491. BN._prime = function prime (name) {
  10492. // Cached version of prime
  10493. if (primes[name]) return primes[name];
  10494. var prime;
  10495. if (name === 'k256') {
  10496. prime = new K256();
  10497. } else if (name === 'p224') {
  10498. prime = new P224();
  10499. } else if (name === 'p192') {
  10500. prime = new P192();
  10501. } else if (name === 'p25519') {
  10502. prime = new P25519();
  10503. } else {
  10504. throw new Error('Unknown prime ' + name);
  10505. }
  10506. primes[name] = prime;
  10507. return prime;
  10508. };
  10509. //
  10510. // Base reduction engine
  10511. //
  10512. function Red (m) {
  10513. if (typeof m === 'string') {
  10514. var prime = BN._prime(m);
  10515. this.m = prime.p;
  10516. this.prime = prime;
  10517. } else {
  10518. assert(m.gtn(1), 'modulus must be greater than 1');
  10519. this.m = m;
  10520. this.prime = null;
  10521. }
  10522. }
  10523. Red.prototype._verify1 = function _verify1 (a) {
  10524. assert(a.negative === 0, 'red works only with positives');
  10525. assert(a.red, 'red works only with red numbers');
  10526. };
  10527. Red.prototype._verify2 = function _verify2 (a, b) {
  10528. assert((a.negative | b.negative) === 0, 'red works only with positives');
  10529. assert(a.red && a.red === b.red,
  10530. 'red works only with red numbers');
  10531. };
  10532. Red.prototype.imod = function imod (a) {
  10533. if (this.prime) return this.prime.ireduce(a)._forceRed(this);
  10534. move(a, a.umod(this.m)._forceRed(this));
  10535. return a;
  10536. };
  10537. Red.prototype.neg = function neg (a) {
  10538. if (a.isZero()) {
  10539. return a.clone();
  10540. }
  10541. return this.m.sub(a)._forceRed(this);
  10542. };
  10543. Red.prototype.add = function add (a, b) {
  10544. this._verify2(a, b);
  10545. var res = a.add(b);
  10546. if (res.cmp(this.m) >= 0) {
  10547. res.isub(this.m);
  10548. }
  10549. return res._forceRed(this);
  10550. };
  10551. Red.prototype.iadd = function iadd (a, b) {
  10552. this._verify2(a, b);
  10553. var res = a.iadd(b);
  10554. if (res.cmp(this.m) >= 0) {
  10555. res.isub(this.m);
  10556. }
  10557. return res;
  10558. };
  10559. Red.prototype.sub = function sub (a, b) {
  10560. this._verify2(a, b);
  10561. var res = a.sub(b);
  10562. if (res.cmpn(0) < 0) {
  10563. res.iadd(this.m);
  10564. }
  10565. return res._forceRed(this);
  10566. };
  10567. Red.prototype.isub = function isub (a, b) {
  10568. this._verify2(a, b);
  10569. var res = a.isub(b);
  10570. if (res.cmpn(0) < 0) {
  10571. res.iadd(this.m);
  10572. }
  10573. return res;
  10574. };
  10575. Red.prototype.shl = function shl (a, num) {
  10576. this._verify1(a);
  10577. return this.imod(a.ushln(num));
  10578. };
  10579. Red.prototype.imul = function imul (a, b) {
  10580. this._verify2(a, b);
  10581. return this.imod(a.imul(b));
  10582. };
  10583. Red.prototype.mul = function mul (a, b) {
  10584. this._verify2(a, b);
  10585. return this.imod(a.mul(b));
  10586. };
  10587. Red.prototype.isqr = function isqr (a) {
  10588. return this.imul(a, a.clone());
  10589. };
  10590. Red.prototype.sqr = function sqr (a) {
  10591. return this.mul(a, a);
  10592. };
  10593. Red.prototype.sqrt = function sqrt (a) {
  10594. if (a.isZero()) return a.clone();
  10595. var mod3 = this.m.andln(3);
  10596. assert(mod3 % 2 === 1);
  10597. // Fast case
  10598. if (mod3 === 3) {
  10599. var pow = this.m.add(new BN(1)).iushrn(2);
  10600. return this.pow(a, pow);
  10601. }
  10602. // Tonelli-Shanks algorithm (Totally unoptimized and slow)
  10603. //
  10604. // Find Q and S, that Q * 2 ^ S = (P - 1)
  10605. var q = this.m.subn(1);
  10606. var s = 0;
  10607. while (!q.isZero() && q.andln(1) === 0) {
  10608. s++;
  10609. q.iushrn(1);
  10610. }
  10611. assert(!q.isZero());
  10612. var one = new BN(1).toRed(this);
  10613. var nOne = one.redNeg();
  10614. // Find quadratic non-residue
  10615. // NOTE: Max is such because of generalized Riemann hypothesis.
  10616. var lpow = this.m.subn(1).iushrn(1);
  10617. var z = this.m.bitLength();
  10618. z = new BN(2 * z * z).toRed(this);
  10619. while (this.pow(z, lpow).cmp(nOne) !== 0) {
  10620. z.redIAdd(nOne);
  10621. }
  10622. var c = this.pow(z, q);
  10623. var r = this.pow(a, q.addn(1).iushrn(1));
  10624. var t = this.pow(a, q);
  10625. var m = s;
  10626. while (t.cmp(one) !== 0) {
  10627. var tmp = t;
  10628. for (var i = 0; tmp.cmp(one) !== 0; i++) {
  10629. tmp = tmp.redSqr();
  10630. }
  10631. assert(i < m);
  10632. var b = this.pow(c, new BN(1).iushln(m - i - 1));
  10633. r = r.redMul(b);
  10634. c = b.redSqr();
  10635. t = t.redMul(c);
  10636. m = i;
  10637. }
  10638. return r;
  10639. };
  10640. Red.prototype.invm = function invm (a) {
  10641. var inv = a._invmp(this.m);
  10642. if (inv.negative !== 0) {
  10643. inv.negative = 0;
  10644. return this.imod(inv).redNeg();
  10645. } else {
  10646. return this.imod(inv);
  10647. }
  10648. };
  10649. Red.prototype.pow = function pow (a, num) {
  10650. if (num.isZero()) return new BN(1).toRed(this);
  10651. if (num.cmpn(1) === 0) return a.clone();
  10652. var windowSize = 4;
  10653. var wnd = new Array(1 << windowSize);
  10654. wnd[0] = new BN(1).toRed(this);
  10655. wnd[1] = a;
  10656. for (var i = 2; i < wnd.length; i++) {
  10657. wnd[i] = this.mul(wnd[i - 1], a);
  10658. }
  10659. var res = wnd[0];
  10660. var current = 0;
  10661. var currentLen = 0;
  10662. var start = num.bitLength() % 26;
  10663. if (start === 0) {
  10664. start = 26;
  10665. }
  10666. for (i = num.length - 1; i >= 0; i--) {
  10667. var word = num.words[i];
  10668. for (var j = start - 1; j >= 0; j--) {
  10669. var bit = (word >> j) & 1;
  10670. if (res !== wnd[0]) {
  10671. res = this.sqr(res);
  10672. }
  10673. if (bit === 0 && current === 0) {
  10674. currentLen = 0;
  10675. continue;
  10676. }
  10677. current <<= 1;
  10678. current |= bit;
  10679. currentLen++;
  10680. if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;
  10681. res = this.mul(res, wnd[current]);
  10682. currentLen = 0;
  10683. current = 0;
  10684. }
  10685. start = 26;
  10686. }
  10687. return res;
  10688. };
  10689. Red.prototype.convertTo = function convertTo (num) {
  10690. var r = num.umod(this.m);
  10691. return r === num ? r.clone() : r;
  10692. };
  10693. Red.prototype.convertFrom = function convertFrom (num) {
  10694. var res = num.clone();
  10695. res.red = null;
  10696. return res;
  10697. };
  10698. //
  10699. // Montgomery method engine
  10700. //
  10701. BN.mont = function mont (num) {
  10702. return new Mont(num);
  10703. };
  10704. function Mont (m) {
  10705. Red.call(this, m);
  10706. this.shift = this.m.bitLength();
  10707. if (this.shift % 26 !== 0) {
  10708. this.shift += 26 - (this.shift % 26);
  10709. }
  10710. this.r = new BN(1).iushln(this.shift);
  10711. this.r2 = this.imod(this.r.sqr());
  10712. this.rinv = this.r._invmp(this.m);
  10713. this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
  10714. this.minv = this.minv.umod(this.r);
  10715. this.minv = this.r.sub(this.minv);
  10716. }
  10717. inherits(Mont, Red);
  10718. Mont.prototype.convertTo = function convertTo (num) {
  10719. return this.imod(num.ushln(this.shift));
  10720. };
  10721. Mont.prototype.convertFrom = function convertFrom (num) {
  10722. var r = this.imod(num.mul(this.rinv));
  10723. r.red = null;
  10724. return r;
  10725. };
  10726. Mont.prototype.imul = function imul (a, b) {
  10727. if (a.isZero() || b.isZero()) {
  10728. a.words[0] = 0;
  10729. a.length = 1;
  10730. return a;
  10731. }
  10732. var t = a.imul(b);
  10733. var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
  10734. var u = t.isub(c).iushrn(this.shift);
  10735. var res = u;
  10736. if (u.cmp(this.m) >= 0) {
  10737. res = u.isub(this.m);
  10738. } else if (u.cmpn(0) < 0) {
  10739. res = u.iadd(this.m);
  10740. }
  10741. return res._forceRed(this);
  10742. };
  10743. Mont.prototype.mul = function mul (a, b) {
  10744. if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);
  10745. var t = a.mul(b);
  10746. var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
  10747. var u = t.isub(c).iushrn(this.shift);
  10748. var res = u;
  10749. if (u.cmp(this.m) >= 0) {
  10750. res = u.isub(this.m);
  10751. } else if (u.cmpn(0) < 0) {
  10752. res = u.iadd(this.m);
  10753. }
  10754. return res._forceRed(this);
  10755. };
  10756. Mont.prototype.invm = function invm (a) {
  10757. // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R
  10758. var res = this.imod(a._invmp(this.m).mul(this.r2));
  10759. return res._forceRed(this);
  10760. };
  10761. })( false || module, this);
  10762. /***/ }),
  10763. /***/ "../../node_modules/brorand/index.js":
  10764. /*!*******************************************!*\
  10765. !*** ../../node_modules/brorand/index.js ***!
  10766. \*******************************************/
  10767. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  10768. var r;
  10769. module.exports = function rand(len) {
  10770. if (!r)
  10771. r = new Rand(null);
  10772. return r.generate(len);
  10773. };
  10774. function Rand(rand) {
  10775. this.rand = rand;
  10776. }
  10777. module.exports.Rand = Rand;
  10778. Rand.prototype.generate = function generate(len) {
  10779. return this._rand(len);
  10780. };
  10781. // Emulate crypto API using randy
  10782. Rand.prototype._rand = function _rand(n) {
  10783. if (this.rand.getBytes)
  10784. return this.rand.getBytes(n);
  10785. var res = new Uint8Array(n);
  10786. for (var i = 0; i < res.length; i++)
  10787. res[i] = this.rand.getByte();
  10788. return res;
  10789. };
  10790. if (typeof self === 'object') {
  10791. if (self.crypto && self.crypto.getRandomValues) {
  10792. // Modern browsers
  10793. Rand.prototype._rand = function _rand(n) {
  10794. var arr = new Uint8Array(n);
  10795. self.crypto.getRandomValues(arr);
  10796. return arr;
  10797. };
  10798. } else if (self.msCrypto && self.msCrypto.getRandomValues) {
  10799. // IE
  10800. Rand.prototype._rand = function _rand(n) {
  10801. var arr = new Uint8Array(n);
  10802. self.msCrypto.getRandomValues(arr);
  10803. return arr;
  10804. };
  10805. // Safari's WebWorkers do not have `crypto`
  10806. } else if (typeof window === 'object') {
  10807. // Old junk
  10808. Rand.prototype._rand = function() {
  10809. throw new Error('Not implemented yet');
  10810. };
  10811. }
  10812. } else {
  10813. // Node.js or Web worker with no crypto support
  10814. try {
  10815. var crypto = __webpack_require__(/*! crypto */ "?0749");
  10816. if (typeof crypto.randomBytes !== 'function')
  10817. throw new Error('Not supported');
  10818. Rand.prototype._rand = function _rand(n) {
  10819. return crypto.randomBytes(n);
  10820. };
  10821. } catch (e) {
  10822. }
  10823. }
  10824. /***/ }),
  10825. /***/ "../../node_modules/browserify-aes/aes.js":
  10826. /*!************************************************!*\
  10827. !*** ../../node_modules/browserify-aes/aes.js ***!
  10828. \************************************************/
  10829. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  10830. // based on the aes implimentation in triple sec
  10831. // https://github.com/keybase/triplesec
  10832. // which is in turn based on the one from crypto-js
  10833. // https://code.google.com/p/crypto-js/
  10834. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  10835. function asUInt32Array (buf) {
  10836. if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf)
  10837. var len = (buf.length / 4) | 0
  10838. var out = new Array(len)
  10839. for (var i = 0; i < len; i++) {
  10840. out[i] = buf.readUInt32BE(i * 4)
  10841. }
  10842. return out
  10843. }
  10844. function scrubVec (v) {
  10845. for (var i = 0; i < v.length; v++) {
  10846. v[i] = 0
  10847. }
  10848. }
  10849. function cryptBlock (M, keySchedule, SUB_MIX, SBOX, nRounds) {
  10850. var SUB_MIX0 = SUB_MIX[0]
  10851. var SUB_MIX1 = SUB_MIX[1]
  10852. var SUB_MIX2 = SUB_MIX[2]
  10853. var SUB_MIX3 = SUB_MIX[3]
  10854. var s0 = M[0] ^ keySchedule[0]
  10855. var s1 = M[1] ^ keySchedule[1]
  10856. var s2 = M[2] ^ keySchedule[2]
  10857. var s3 = M[3] ^ keySchedule[3]
  10858. var t0, t1, t2, t3
  10859. var ksRow = 4
  10860. for (var round = 1; round < nRounds; round++) {
  10861. t0 = SUB_MIX0[s0 >>> 24] ^ SUB_MIX1[(s1 >>> 16) & 0xff] ^ SUB_MIX2[(s2 >>> 8) & 0xff] ^ SUB_MIX3[s3 & 0xff] ^ keySchedule[ksRow++]
  10862. t1 = SUB_MIX0[s1 >>> 24] ^ SUB_MIX1[(s2 >>> 16) & 0xff] ^ SUB_MIX2[(s3 >>> 8) & 0xff] ^ SUB_MIX3[s0 & 0xff] ^ keySchedule[ksRow++]
  10863. t2 = SUB_MIX0[s2 >>> 24] ^ SUB_MIX1[(s3 >>> 16) & 0xff] ^ SUB_MIX2[(s0 >>> 8) & 0xff] ^ SUB_MIX3[s1 & 0xff] ^ keySchedule[ksRow++]
  10864. t3 = SUB_MIX0[s3 >>> 24] ^ SUB_MIX1[(s0 >>> 16) & 0xff] ^ SUB_MIX2[(s1 >>> 8) & 0xff] ^ SUB_MIX3[s2 & 0xff] ^ keySchedule[ksRow++]
  10865. s0 = t0
  10866. s1 = t1
  10867. s2 = t2
  10868. s3 = t3
  10869. }
  10870. t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++]
  10871. t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++]
  10872. t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++]
  10873. t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++]
  10874. t0 = t0 >>> 0
  10875. t1 = t1 >>> 0
  10876. t2 = t2 >>> 0
  10877. t3 = t3 >>> 0
  10878. return [t0, t1, t2, t3]
  10879. }
  10880. // AES constants
  10881. var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36]
  10882. var G = (function () {
  10883. // Compute double table
  10884. var d = new Array(256)
  10885. for (var j = 0; j < 256; j++) {
  10886. if (j < 128) {
  10887. d[j] = j << 1
  10888. } else {
  10889. d[j] = (j << 1) ^ 0x11b
  10890. }
  10891. }
  10892. var SBOX = []
  10893. var INV_SBOX = []
  10894. var SUB_MIX = [[], [], [], []]
  10895. var INV_SUB_MIX = [[], [], [], []]
  10896. // Walk GF(2^8)
  10897. var x = 0
  10898. var xi = 0
  10899. for (var i = 0; i < 256; ++i) {
  10900. // Compute sbox
  10901. var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4)
  10902. sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63
  10903. SBOX[x] = sx
  10904. INV_SBOX[sx] = x
  10905. // Compute multiplication
  10906. var x2 = d[x]
  10907. var x4 = d[x2]
  10908. var x8 = d[x4]
  10909. // Compute sub bytes, mix columns tables
  10910. var t = (d[sx] * 0x101) ^ (sx * 0x1010100)
  10911. SUB_MIX[0][x] = (t << 24) | (t >>> 8)
  10912. SUB_MIX[1][x] = (t << 16) | (t >>> 16)
  10913. SUB_MIX[2][x] = (t << 8) | (t >>> 24)
  10914. SUB_MIX[3][x] = t
  10915. // Compute inv sub bytes, inv mix columns tables
  10916. t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100)
  10917. INV_SUB_MIX[0][sx] = (t << 24) | (t >>> 8)
  10918. INV_SUB_MIX[1][sx] = (t << 16) | (t >>> 16)
  10919. INV_SUB_MIX[2][sx] = (t << 8) | (t >>> 24)
  10920. INV_SUB_MIX[3][sx] = t
  10921. if (x === 0) {
  10922. x = xi = 1
  10923. } else {
  10924. x = x2 ^ d[d[d[x8 ^ x2]]]
  10925. xi ^= d[d[xi]]
  10926. }
  10927. }
  10928. return {
  10929. SBOX: SBOX,
  10930. INV_SBOX: INV_SBOX,
  10931. SUB_MIX: SUB_MIX,
  10932. INV_SUB_MIX: INV_SUB_MIX
  10933. }
  10934. })()
  10935. function AES (key) {
  10936. this._key = asUInt32Array(key)
  10937. this._reset()
  10938. }
  10939. AES.blockSize = 4 * 4
  10940. AES.keySize = 256 / 8
  10941. AES.prototype.blockSize = AES.blockSize
  10942. AES.prototype.keySize = AES.keySize
  10943. AES.prototype._reset = function () {
  10944. var keyWords = this._key
  10945. var keySize = keyWords.length
  10946. var nRounds = keySize + 6
  10947. var ksRows = (nRounds + 1) * 4
  10948. var keySchedule = []
  10949. for (var k = 0; k < keySize; k++) {
  10950. keySchedule[k] = keyWords[k]
  10951. }
  10952. for (k = keySize; k < ksRows; k++) {
  10953. var t = keySchedule[k - 1]
  10954. if (k % keySize === 0) {
  10955. t = (t << 8) | (t >>> 24)
  10956. t =
  10957. (G.SBOX[t >>> 24] << 24) |
  10958. (G.SBOX[(t >>> 16) & 0xff] << 16) |
  10959. (G.SBOX[(t >>> 8) & 0xff] << 8) |
  10960. (G.SBOX[t & 0xff])
  10961. t ^= RCON[(k / keySize) | 0] << 24
  10962. } else if (keySize > 6 && k % keySize === 4) {
  10963. t =
  10964. (G.SBOX[t >>> 24] << 24) |
  10965. (G.SBOX[(t >>> 16) & 0xff] << 16) |
  10966. (G.SBOX[(t >>> 8) & 0xff] << 8) |
  10967. (G.SBOX[t & 0xff])
  10968. }
  10969. keySchedule[k] = keySchedule[k - keySize] ^ t
  10970. }
  10971. var invKeySchedule = []
  10972. for (var ik = 0; ik < ksRows; ik++) {
  10973. var ksR = ksRows - ik
  10974. var tt = keySchedule[ksR - (ik % 4 ? 0 : 4)]
  10975. if (ik < 4 || ksR <= 4) {
  10976. invKeySchedule[ik] = tt
  10977. } else {
  10978. invKeySchedule[ik] =
  10979. G.INV_SUB_MIX[0][G.SBOX[tt >>> 24]] ^
  10980. G.INV_SUB_MIX[1][G.SBOX[(tt >>> 16) & 0xff]] ^
  10981. G.INV_SUB_MIX[2][G.SBOX[(tt >>> 8) & 0xff]] ^
  10982. G.INV_SUB_MIX[3][G.SBOX[tt & 0xff]]
  10983. }
  10984. }
  10985. this._nRounds = nRounds
  10986. this._keySchedule = keySchedule
  10987. this._invKeySchedule = invKeySchedule
  10988. }
  10989. AES.prototype.encryptBlockRaw = function (M) {
  10990. M = asUInt32Array(M)
  10991. return cryptBlock(M, this._keySchedule, G.SUB_MIX, G.SBOX, this._nRounds)
  10992. }
  10993. AES.prototype.encryptBlock = function (M) {
  10994. var out = this.encryptBlockRaw(M)
  10995. var buf = Buffer.allocUnsafe(16)
  10996. buf.writeUInt32BE(out[0], 0)
  10997. buf.writeUInt32BE(out[1], 4)
  10998. buf.writeUInt32BE(out[2], 8)
  10999. buf.writeUInt32BE(out[3], 12)
  11000. return buf
  11001. }
  11002. AES.prototype.decryptBlock = function (M) {
  11003. M = asUInt32Array(M)
  11004. // swap
  11005. var m1 = M[1]
  11006. M[1] = M[3]
  11007. M[3] = m1
  11008. var out = cryptBlock(M, this._invKeySchedule, G.INV_SUB_MIX, G.INV_SBOX, this._nRounds)
  11009. var buf = Buffer.allocUnsafe(16)
  11010. buf.writeUInt32BE(out[0], 0)
  11011. buf.writeUInt32BE(out[3], 4)
  11012. buf.writeUInt32BE(out[2], 8)
  11013. buf.writeUInt32BE(out[1], 12)
  11014. return buf
  11015. }
  11016. AES.prototype.scrub = function () {
  11017. scrubVec(this._keySchedule)
  11018. scrubVec(this._invKeySchedule)
  11019. scrubVec(this._key)
  11020. }
  11021. module.exports.AES = AES
  11022. /***/ }),
  11023. /***/ "../../node_modules/browserify-aes/authCipher.js":
  11024. /*!*******************************************************!*\
  11025. !*** ../../node_modules/browserify-aes/authCipher.js ***!
  11026. \*******************************************************/
  11027. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  11028. var aes = __webpack_require__(/*! ./aes */ "../../node_modules/browserify-aes/aes.js")
  11029. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  11030. var Transform = __webpack_require__(/*! cipher-base */ "../../node_modules/cipher-base/index.js")
  11031. var inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js")
  11032. var GHASH = __webpack_require__(/*! ./ghash */ "../../node_modules/browserify-aes/ghash.js")
  11033. var xor = __webpack_require__(/*! buffer-xor */ "../../node_modules/buffer-xor/index.js")
  11034. var incr32 = __webpack_require__(/*! ./incr32 */ "../../node_modules/browserify-aes/incr32.js")
  11035. function xorTest (a, b) {
  11036. var out = 0
  11037. if (a.length !== b.length) out++
  11038. var len = Math.min(a.length, b.length)
  11039. for (var i = 0; i < len; ++i) {
  11040. out += (a[i] ^ b[i])
  11041. }
  11042. return out
  11043. }
  11044. function calcIv (self, iv, ck) {
  11045. if (iv.length === 12) {
  11046. self._finID = Buffer.concat([iv, Buffer.from([0, 0, 0, 1])])
  11047. return Buffer.concat([iv, Buffer.from([0, 0, 0, 2])])
  11048. }
  11049. var ghash = new GHASH(ck)
  11050. var len = iv.length
  11051. var toPad = len % 16
  11052. ghash.update(iv)
  11053. if (toPad) {
  11054. toPad = 16 - toPad
  11055. ghash.update(Buffer.alloc(toPad, 0))
  11056. }
  11057. ghash.update(Buffer.alloc(8, 0))
  11058. var ivBits = len * 8
  11059. var tail = Buffer.alloc(8)
  11060. tail.writeUIntBE(ivBits, 0, 8)
  11061. ghash.update(tail)
  11062. self._finID = ghash.state
  11063. var out = Buffer.from(self._finID)
  11064. incr32(out)
  11065. return out
  11066. }
  11067. function StreamCipher (mode, key, iv, decrypt) {
  11068. Transform.call(this)
  11069. var h = Buffer.alloc(4, 0)
  11070. this._cipher = new aes.AES(key)
  11071. var ck = this._cipher.encryptBlock(h)
  11072. this._ghash = new GHASH(ck)
  11073. iv = calcIv(this, iv, ck)
  11074. this._prev = Buffer.from(iv)
  11075. this._cache = Buffer.allocUnsafe(0)
  11076. this._secCache = Buffer.allocUnsafe(0)
  11077. this._decrypt = decrypt
  11078. this._alen = 0
  11079. this._len = 0
  11080. this._mode = mode
  11081. this._authTag = null
  11082. this._called = false
  11083. }
  11084. inherits(StreamCipher, Transform)
  11085. StreamCipher.prototype._update = function (chunk) {
  11086. if (!this._called && this._alen) {
  11087. var rump = 16 - (this._alen % 16)
  11088. if (rump < 16) {
  11089. rump = Buffer.alloc(rump, 0)
  11090. this._ghash.update(rump)
  11091. }
  11092. }
  11093. this._called = true
  11094. var out = this._mode.encrypt(this, chunk)
  11095. if (this._decrypt) {
  11096. this._ghash.update(chunk)
  11097. } else {
  11098. this._ghash.update(out)
  11099. }
  11100. this._len += chunk.length
  11101. return out
  11102. }
  11103. StreamCipher.prototype._final = function () {
  11104. if (this._decrypt && !this._authTag) throw new Error('Unsupported state or unable to authenticate data')
  11105. var tag = xor(this._ghash.final(this._alen * 8, this._len * 8), this._cipher.encryptBlock(this._finID))
  11106. if (this._decrypt && xorTest(tag, this._authTag)) throw new Error('Unsupported state or unable to authenticate data')
  11107. this._authTag = tag
  11108. this._cipher.scrub()
  11109. }
  11110. StreamCipher.prototype.getAuthTag = function getAuthTag () {
  11111. if (this._decrypt || !Buffer.isBuffer(this._authTag)) throw new Error('Attempting to get auth tag in unsupported state')
  11112. return this._authTag
  11113. }
  11114. StreamCipher.prototype.setAuthTag = function setAuthTag (tag) {
  11115. if (!this._decrypt) throw new Error('Attempting to set auth tag in unsupported state')
  11116. this._authTag = tag
  11117. }
  11118. StreamCipher.prototype.setAAD = function setAAD (buf) {
  11119. if (this._called) throw new Error('Attempting to set AAD in unsupported state')
  11120. this._ghash.update(buf)
  11121. this._alen += buf.length
  11122. }
  11123. module.exports = StreamCipher
  11124. /***/ }),
  11125. /***/ "../../node_modules/browserify-aes/browser.js":
  11126. /*!****************************************************!*\
  11127. !*** ../../node_modules/browserify-aes/browser.js ***!
  11128. \****************************************************/
  11129. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  11130. var ciphers = __webpack_require__(/*! ./encrypter */ "../../node_modules/browserify-aes/encrypter.js")
  11131. var deciphers = __webpack_require__(/*! ./decrypter */ "../../node_modules/browserify-aes/decrypter.js")
  11132. var modes = __webpack_require__(/*! ./modes/list.json */ "../../node_modules/browserify-aes/modes/list.json")
  11133. function getCiphers () {
  11134. return Object.keys(modes)
  11135. }
  11136. exports.createCipher = exports.Cipher = ciphers.createCipher
  11137. exports.createCipheriv = exports.Cipheriv = ciphers.createCipheriv
  11138. exports.createDecipher = exports.Decipher = deciphers.createDecipher
  11139. exports.createDecipheriv = exports.Decipheriv = deciphers.createDecipheriv
  11140. exports.listCiphers = exports.getCiphers = getCiphers
  11141. /***/ }),
  11142. /***/ "../../node_modules/browserify-aes/decrypter.js":
  11143. /*!******************************************************!*\
  11144. !*** ../../node_modules/browserify-aes/decrypter.js ***!
  11145. \******************************************************/
  11146. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  11147. var AuthCipher = __webpack_require__(/*! ./authCipher */ "../../node_modules/browserify-aes/authCipher.js")
  11148. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  11149. var MODES = __webpack_require__(/*! ./modes */ "../../node_modules/browserify-aes/modes/index.js")
  11150. var StreamCipher = __webpack_require__(/*! ./streamCipher */ "../../node_modules/browserify-aes/streamCipher.js")
  11151. var Transform = __webpack_require__(/*! cipher-base */ "../../node_modules/cipher-base/index.js")
  11152. var aes = __webpack_require__(/*! ./aes */ "../../node_modules/browserify-aes/aes.js")
  11153. var ebtk = __webpack_require__(/*! evp_bytestokey */ "../../node_modules/evp_bytestokey/index.js")
  11154. var inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js")
  11155. function Decipher (mode, key, iv) {
  11156. Transform.call(this)
  11157. this._cache = new Splitter()
  11158. this._last = void 0
  11159. this._cipher = new aes.AES(key)
  11160. this._prev = Buffer.from(iv)
  11161. this._mode = mode
  11162. this._autopadding = true
  11163. }
  11164. inherits(Decipher, Transform)
  11165. Decipher.prototype._update = function (data) {
  11166. this._cache.add(data)
  11167. var chunk
  11168. var thing
  11169. var out = []
  11170. while ((chunk = this._cache.get(this._autopadding))) {
  11171. thing = this._mode.decrypt(this, chunk)
  11172. out.push(thing)
  11173. }
  11174. return Buffer.concat(out)
  11175. }
  11176. Decipher.prototype._final = function () {
  11177. var chunk = this._cache.flush()
  11178. if (this._autopadding) {
  11179. return unpad(this._mode.decrypt(this, chunk))
  11180. } else if (chunk) {
  11181. throw new Error('data not multiple of block length')
  11182. }
  11183. }
  11184. Decipher.prototype.setAutoPadding = function (setTo) {
  11185. this._autopadding = !!setTo
  11186. return this
  11187. }
  11188. function Splitter () {
  11189. this.cache = Buffer.allocUnsafe(0)
  11190. }
  11191. Splitter.prototype.add = function (data) {
  11192. this.cache = Buffer.concat([this.cache, data])
  11193. }
  11194. Splitter.prototype.get = function (autoPadding) {
  11195. var out
  11196. if (autoPadding) {
  11197. if (this.cache.length > 16) {
  11198. out = this.cache.slice(0, 16)
  11199. this.cache = this.cache.slice(16)
  11200. return out
  11201. }
  11202. } else {
  11203. if (this.cache.length >= 16) {
  11204. out = this.cache.slice(0, 16)
  11205. this.cache = this.cache.slice(16)
  11206. return out
  11207. }
  11208. }
  11209. return null
  11210. }
  11211. Splitter.prototype.flush = function () {
  11212. if (this.cache.length) return this.cache
  11213. }
  11214. function unpad (last) {
  11215. var padded = last[15]
  11216. if (padded < 1 || padded > 16) {
  11217. throw new Error('unable to decrypt data')
  11218. }
  11219. var i = -1
  11220. while (++i < padded) {
  11221. if (last[(i + (16 - padded))] !== padded) {
  11222. throw new Error('unable to decrypt data')
  11223. }
  11224. }
  11225. if (padded === 16) return
  11226. return last.slice(0, 16 - padded)
  11227. }
  11228. function createDecipheriv (suite, password, iv) {
  11229. var config = MODES[suite.toLowerCase()]
  11230. if (!config) throw new TypeError('invalid suite type')
  11231. if (typeof iv === 'string') iv = Buffer.from(iv)
  11232. if (config.mode !== 'GCM' && iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length)
  11233. if (typeof password === 'string') password = Buffer.from(password)
  11234. if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length)
  11235. if (config.type === 'stream') {
  11236. return new StreamCipher(config.module, password, iv, true)
  11237. } else if (config.type === 'auth') {
  11238. return new AuthCipher(config.module, password, iv, true)
  11239. }
  11240. return new Decipher(config.module, password, iv)
  11241. }
  11242. function createDecipher (suite, password) {
  11243. var config = MODES[suite.toLowerCase()]
  11244. if (!config) throw new TypeError('invalid suite type')
  11245. var keys = ebtk(password, false, config.key, config.iv)
  11246. return createDecipheriv(suite, keys.key, keys.iv)
  11247. }
  11248. exports.createDecipher = createDecipher
  11249. exports.createDecipheriv = createDecipheriv
  11250. /***/ }),
  11251. /***/ "../../node_modules/browserify-aes/encrypter.js":
  11252. /*!******************************************************!*\
  11253. !*** ../../node_modules/browserify-aes/encrypter.js ***!
  11254. \******************************************************/
  11255. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  11256. var MODES = __webpack_require__(/*! ./modes */ "../../node_modules/browserify-aes/modes/index.js")
  11257. var AuthCipher = __webpack_require__(/*! ./authCipher */ "../../node_modules/browserify-aes/authCipher.js")
  11258. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  11259. var StreamCipher = __webpack_require__(/*! ./streamCipher */ "../../node_modules/browserify-aes/streamCipher.js")
  11260. var Transform = __webpack_require__(/*! cipher-base */ "../../node_modules/cipher-base/index.js")
  11261. var aes = __webpack_require__(/*! ./aes */ "../../node_modules/browserify-aes/aes.js")
  11262. var ebtk = __webpack_require__(/*! evp_bytestokey */ "../../node_modules/evp_bytestokey/index.js")
  11263. var inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js")
  11264. function Cipher (mode, key, iv) {
  11265. Transform.call(this)
  11266. this._cache = new Splitter()
  11267. this._cipher = new aes.AES(key)
  11268. this._prev = Buffer.from(iv)
  11269. this._mode = mode
  11270. this._autopadding = true
  11271. }
  11272. inherits(Cipher, Transform)
  11273. Cipher.prototype._update = function (data) {
  11274. this._cache.add(data)
  11275. var chunk
  11276. var thing
  11277. var out = []
  11278. while ((chunk = this._cache.get())) {
  11279. thing = this._mode.encrypt(this, chunk)
  11280. out.push(thing)
  11281. }
  11282. return Buffer.concat(out)
  11283. }
  11284. var PADDING = Buffer.alloc(16, 0x10)
  11285. Cipher.prototype._final = function () {
  11286. var chunk = this._cache.flush()
  11287. if (this._autopadding) {
  11288. chunk = this._mode.encrypt(this, chunk)
  11289. this._cipher.scrub()
  11290. return chunk
  11291. }
  11292. if (!chunk.equals(PADDING)) {
  11293. this._cipher.scrub()
  11294. throw new Error('data not multiple of block length')
  11295. }
  11296. }
  11297. Cipher.prototype.setAutoPadding = function (setTo) {
  11298. this._autopadding = !!setTo
  11299. return this
  11300. }
  11301. function Splitter () {
  11302. this.cache = Buffer.allocUnsafe(0)
  11303. }
  11304. Splitter.prototype.add = function (data) {
  11305. this.cache = Buffer.concat([this.cache, data])
  11306. }
  11307. Splitter.prototype.get = function () {
  11308. if (this.cache.length > 15) {
  11309. var out = this.cache.slice(0, 16)
  11310. this.cache = this.cache.slice(16)
  11311. return out
  11312. }
  11313. return null
  11314. }
  11315. Splitter.prototype.flush = function () {
  11316. var len = 16 - this.cache.length
  11317. var padBuff = Buffer.allocUnsafe(len)
  11318. var i = -1
  11319. while (++i < len) {
  11320. padBuff.writeUInt8(len, i)
  11321. }
  11322. return Buffer.concat([this.cache, padBuff])
  11323. }
  11324. function createCipheriv (suite, password, iv) {
  11325. var config = MODES[suite.toLowerCase()]
  11326. if (!config) throw new TypeError('invalid suite type')
  11327. if (typeof password === 'string') password = Buffer.from(password)
  11328. if (password.length !== config.key / 8) throw new TypeError('invalid key length ' + password.length)
  11329. if (typeof iv === 'string') iv = Buffer.from(iv)
  11330. if (config.mode !== 'GCM' && iv.length !== config.iv) throw new TypeError('invalid iv length ' + iv.length)
  11331. if (config.type === 'stream') {
  11332. return new StreamCipher(config.module, password, iv)
  11333. } else if (config.type === 'auth') {
  11334. return new AuthCipher(config.module, password, iv)
  11335. }
  11336. return new Cipher(config.module, password, iv)
  11337. }
  11338. function createCipher (suite, password) {
  11339. var config = MODES[suite.toLowerCase()]
  11340. if (!config) throw new TypeError('invalid suite type')
  11341. var keys = ebtk(password, false, config.key, config.iv)
  11342. return createCipheriv(suite, keys.key, keys.iv)
  11343. }
  11344. exports.createCipheriv = createCipheriv
  11345. exports.createCipher = createCipher
  11346. /***/ }),
  11347. /***/ "../../node_modules/browserify-aes/ghash.js":
  11348. /*!**************************************************!*\
  11349. !*** ../../node_modules/browserify-aes/ghash.js ***!
  11350. \**************************************************/
  11351. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  11352. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  11353. var ZEROES = Buffer.alloc(16, 0)
  11354. function toArray (buf) {
  11355. return [
  11356. buf.readUInt32BE(0),
  11357. buf.readUInt32BE(4),
  11358. buf.readUInt32BE(8),
  11359. buf.readUInt32BE(12)
  11360. ]
  11361. }
  11362. function fromArray (out) {
  11363. var buf = Buffer.allocUnsafe(16)
  11364. buf.writeUInt32BE(out[0] >>> 0, 0)
  11365. buf.writeUInt32BE(out[1] >>> 0, 4)
  11366. buf.writeUInt32BE(out[2] >>> 0, 8)
  11367. buf.writeUInt32BE(out[3] >>> 0, 12)
  11368. return buf
  11369. }
  11370. function GHASH (key) {
  11371. this.h = key
  11372. this.state = Buffer.alloc(16, 0)
  11373. this.cache = Buffer.allocUnsafe(0)
  11374. }
  11375. // from http://bitwiseshiftleft.github.io/sjcl/doc/symbols/src/core_gcm.js.html
  11376. // by Juho Vähä-Herttua
  11377. GHASH.prototype.ghash = function (block) {
  11378. var i = -1
  11379. while (++i < block.length) {
  11380. this.state[i] ^= block[i]
  11381. }
  11382. this._multiply()
  11383. }
  11384. GHASH.prototype._multiply = function () {
  11385. var Vi = toArray(this.h)
  11386. var Zi = [0, 0, 0, 0]
  11387. var j, xi, lsbVi
  11388. var i = -1
  11389. while (++i < 128) {
  11390. xi = (this.state[~~(i / 8)] & (1 << (7 - (i % 8)))) !== 0
  11391. if (xi) {
  11392. // Z_i+1 = Z_i ^ V_i
  11393. Zi[0] ^= Vi[0]
  11394. Zi[1] ^= Vi[1]
  11395. Zi[2] ^= Vi[2]
  11396. Zi[3] ^= Vi[3]
  11397. }
  11398. // Store the value of LSB(V_i)
  11399. lsbVi = (Vi[3] & 1) !== 0
  11400. // V_i+1 = V_i >> 1
  11401. for (j = 3; j > 0; j--) {
  11402. Vi[j] = (Vi[j] >>> 1) | ((Vi[j - 1] & 1) << 31)
  11403. }
  11404. Vi[0] = Vi[0] >>> 1
  11405. // If LSB(V_i) is 1, V_i+1 = (V_i >> 1) ^ R
  11406. if (lsbVi) {
  11407. Vi[0] = Vi[0] ^ (0xe1 << 24)
  11408. }
  11409. }
  11410. this.state = fromArray(Zi)
  11411. }
  11412. GHASH.prototype.update = function (buf) {
  11413. this.cache = Buffer.concat([this.cache, buf])
  11414. var chunk
  11415. while (this.cache.length >= 16) {
  11416. chunk = this.cache.slice(0, 16)
  11417. this.cache = this.cache.slice(16)
  11418. this.ghash(chunk)
  11419. }
  11420. }
  11421. GHASH.prototype.final = function (abl, bl) {
  11422. if (this.cache.length) {
  11423. this.ghash(Buffer.concat([this.cache, ZEROES], 16))
  11424. }
  11425. this.ghash(fromArray([0, abl, 0, bl]))
  11426. return this.state
  11427. }
  11428. module.exports = GHASH
  11429. /***/ }),
  11430. /***/ "../../node_modules/browserify-aes/incr32.js":
  11431. /*!***************************************************!*\
  11432. !*** ../../node_modules/browserify-aes/incr32.js ***!
  11433. \***************************************************/
  11434. /***/ ((module) => {
  11435. function incr32 (iv) {
  11436. var len = iv.length
  11437. var item
  11438. while (len--) {
  11439. item = iv.readUInt8(len)
  11440. if (item === 255) {
  11441. iv.writeUInt8(0, len)
  11442. } else {
  11443. item++
  11444. iv.writeUInt8(item, len)
  11445. break
  11446. }
  11447. }
  11448. }
  11449. module.exports = incr32
  11450. /***/ }),
  11451. /***/ "../../node_modules/browserify-aes/modes/cbc.js":
  11452. /*!******************************************************!*\
  11453. !*** ../../node_modules/browserify-aes/modes/cbc.js ***!
  11454. \******************************************************/
  11455. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  11456. var xor = __webpack_require__(/*! buffer-xor */ "../../node_modules/buffer-xor/index.js")
  11457. exports.encrypt = function (self, block) {
  11458. var data = xor(block, self._prev)
  11459. self._prev = self._cipher.encryptBlock(data)
  11460. return self._prev
  11461. }
  11462. exports.decrypt = function (self, block) {
  11463. var pad = self._prev
  11464. self._prev = block
  11465. var out = self._cipher.decryptBlock(block)
  11466. return xor(out, pad)
  11467. }
  11468. /***/ }),
  11469. /***/ "../../node_modules/browserify-aes/modes/cfb.js":
  11470. /*!******************************************************!*\
  11471. !*** ../../node_modules/browserify-aes/modes/cfb.js ***!
  11472. \******************************************************/
  11473. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  11474. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  11475. var xor = __webpack_require__(/*! buffer-xor */ "../../node_modules/buffer-xor/index.js")
  11476. function encryptStart (self, data, decrypt) {
  11477. var len = data.length
  11478. var out = xor(data, self._cache)
  11479. self._cache = self._cache.slice(len)
  11480. self._prev = Buffer.concat([self._prev, decrypt ? data : out])
  11481. return out
  11482. }
  11483. exports.encrypt = function (self, data, decrypt) {
  11484. var out = Buffer.allocUnsafe(0)
  11485. var len
  11486. while (data.length) {
  11487. if (self._cache.length === 0) {
  11488. self._cache = self._cipher.encryptBlock(self._prev)
  11489. self._prev = Buffer.allocUnsafe(0)
  11490. }
  11491. if (self._cache.length <= data.length) {
  11492. len = self._cache.length
  11493. out = Buffer.concat([out, encryptStart(self, data.slice(0, len), decrypt)])
  11494. data = data.slice(len)
  11495. } else {
  11496. out = Buffer.concat([out, encryptStart(self, data, decrypt)])
  11497. break
  11498. }
  11499. }
  11500. return out
  11501. }
  11502. /***/ }),
  11503. /***/ "../../node_modules/browserify-aes/modes/cfb1.js":
  11504. /*!*******************************************************!*\
  11505. !*** ../../node_modules/browserify-aes/modes/cfb1.js ***!
  11506. \*******************************************************/
  11507. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  11508. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  11509. function encryptByte (self, byteParam, decrypt) {
  11510. var pad
  11511. var i = -1
  11512. var len = 8
  11513. var out = 0
  11514. var bit, value
  11515. while (++i < len) {
  11516. pad = self._cipher.encryptBlock(self._prev)
  11517. bit = (byteParam & (1 << (7 - i))) ? 0x80 : 0
  11518. value = pad[0] ^ bit
  11519. out += ((value & 0x80) >> (i % 8))
  11520. self._prev = shiftIn(self._prev, decrypt ? bit : value)
  11521. }
  11522. return out
  11523. }
  11524. function shiftIn (buffer, value) {
  11525. var len = buffer.length
  11526. var i = -1
  11527. var out = Buffer.allocUnsafe(buffer.length)
  11528. buffer = Buffer.concat([buffer, Buffer.from([value])])
  11529. while (++i < len) {
  11530. out[i] = buffer[i] << 1 | buffer[i + 1] >> (7)
  11531. }
  11532. return out
  11533. }
  11534. exports.encrypt = function (self, chunk, decrypt) {
  11535. var len = chunk.length
  11536. var out = Buffer.allocUnsafe(len)
  11537. var i = -1
  11538. while (++i < len) {
  11539. out[i] = encryptByte(self, chunk[i], decrypt)
  11540. }
  11541. return out
  11542. }
  11543. /***/ }),
  11544. /***/ "../../node_modules/browserify-aes/modes/cfb8.js":
  11545. /*!*******************************************************!*\
  11546. !*** ../../node_modules/browserify-aes/modes/cfb8.js ***!
  11547. \*******************************************************/
  11548. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  11549. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  11550. function encryptByte (self, byteParam, decrypt) {
  11551. var pad = self._cipher.encryptBlock(self._prev)
  11552. var out = pad[0] ^ byteParam
  11553. self._prev = Buffer.concat([
  11554. self._prev.slice(1),
  11555. Buffer.from([decrypt ? byteParam : out])
  11556. ])
  11557. return out
  11558. }
  11559. exports.encrypt = function (self, chunk, decrypt) {
  11560. var len = chunk.length
  11561. var out = Buffer.allocUnsafe(len)
  11562. var i = -1
  11563. while (++i < len) {
  11564. out[i] = encryptByte(self, chunk[i], decrypt)
  11565. }
  11566. return out
  11567. }
  11568. /***/ }),
  11569. /***/ "../../node_modules/browserify-aes/modes/ctr.js":
  11570. /*!******************************************************!*\
  11571. !*** ../../node_modules/browserify-aes/modes/ctr.js ***!
  11572. \******************************************************/
  11573. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  11574. var xor = __webpack_require__(/*! buffer-xor */ "../../node_modules/buffer-xor/index.js")
  11575. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  11576. var incr32 = __webpack_require__(/*! ../incr32 */ "../../node_modules/browserify-aes/incr32.js")
  11577. function getBlock (self) {
  11578. var out = self._cipher.encryptBlockRaw(self._prev)
  11579. incr32(self._prev)
  11580. return out
  11581. }
  11582. var blockSize = 16
  11583. exports.encrypt = function (self, chunk) {
  11584. var chunkNum = Math.ceil(chunk.length / blockSize)
  11585. var start = self._cache.length
  11586. self._cache = Buffer.concat([
  11587. self._cache,
  11588. Buffer.allocUnsafe(chunkNum * blockSize)
  11589. ])
  11590. for (var i = 0; i < chunkNum; i++) {
  11591. var out = getBlock(self)
  11592. var offset = start + i * blockSize
  11593. self._cache.writeUInt32BE(out[0], offset + 0)
  11594. self._cache.writeUInt32BE(out[1], offset + 4)
  11595. self._cache.writeUInt32BE(out[2], offset + 8)
  11596. self._cache.writeUInt32BE(out[3], offset + 12)
  11597. }
  11598. var pad = self._cache.slice(0, chunk.length)
  11599. self._cache = self._cache.slice(chunk.length)
  11600. return xor(chunk, pad)
  11601. }
  11602. /***/ }),
  11603. /***/ "../../node_modules/browserify-aes/modes/ecb.js":
  11604. /*!******************************************************!*\
  11605. !*** ../../node_modules/browserify-aes/modes/ecb.js ***!
  11606. \******************************************************/
  11607. /***/ ((__unused_webpack_module, exports) => {
  11608. exports.encrypt = function (self, block) {
  11609. return self._cipher.encryptBlock(block)
  11610. }
  11611. exports.decrypt = function (self, block) {
  11612. return self._cipher.decryptBlock(block)
  11613. }
  11614. /***/ }),
  11615. /***/ "../../node_modules/browserify-aes/modes/index.js":
  11616. /*!********************************************************!*\
  11617. !*** ../../node_modules/browserify-aes/modes/index.js ***!
  11618. \********************************************************/
  11619. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  11620. var modeModules = {
  11621. ECB: __webpack_require__(/*! ./ecb */ "../../node_modules/browserify-aes/modes/ecb.js"),
  11622. CBC: __webpack_require__(/*! ./cbc */ "../../node_modules/browserify-aes/modes/cbc.js"),
  11623. CFB: __webpack_require__(/*! ./cfb */ "../../node_modules/browserify-aes/modes/cfb.js"),
  11624. CFB8: __webpack_require__(/*! ./cfb8 */ "../../node_modules/browserify-aes/modes/cfb8.js"),
  11625. CFB1: __webpack_require__(/*! ./cfb1 */ "../../node_modules/browserify-aes/modes/cfb1.js"),
  11626. OFB: __webpack_require__(/*! ./ofb */ "../../node_modules/browserify-aes/modes/ofb.js"),
  11627. CTR: __webpack_require__(/*! ./ctr */ "../../node_modules/browserify-aes/modes/ctr.js"),
  11628. GCM: __webpack_require__(/*! ./ctr */ "../../node_modules/browserify-aes/modes/ctr.js")
  11629. }
  11630. var modes = __webpack_require__(/*! ./list.json */ "../../node_modules/browserify-aes/modes/list.json")
  11631. for (var key in modes) {
  11632. modes[key].module = modeModules[modes[key].mode]
  11633. }
  11634. module.exports = modes
  11635. /***/ }),
  11636. /***/ "../../node_modules/browserify-aes/modes/ofb.js":
  11637. /*!******************************************************!*\
  11638. !*** ../../node_modules/browserify-aes/modes/ofb.js ***!
  11639. \******************************************************/
  11640. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  11641. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js")["Buffer"];
  11642. var xor = __webpack_require__(/*! buffer-xor */ "../../node_modules/buffer-xor/index.js")
  11643. function getBlock (self) {
  11644. self._prev = self._cipher.encryptBlock(self._prev)
  11645. return self._prev
  11646. }
  11647. exports.encrypt = function (self, chunk) {
  11648. while (self._cache.length < chunk.length) {
  11649. self._cache = Buffer.concat([self._cache, getBlock(self)])
  11650. }
  11651. var pad = self._cache.slice(0, chunk.length)
  11652. self._cache = self._cache.slice(chunk.length)
  11653. return xor(chunk, pad)
  11654. }
  11655. /***/ }),
  11656. /***/ "../../node_modules/browserify-aes/streamCipher.js":
  11657. /*!*********************************************************!*\
  11658. !*** ../../node_modules/browserify-aes/streamCipher.js ***!
  11659. \*********************************************************/
  11660. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  11661. var aes = __webpack_require__(/*! ./aes */ "../../node_modules/browserify-aes/aes.js")
  11662. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  11663. var Transform = __webpack_require__(/*! cipher-base */ "../../node_modules/cipher-base/index.js")
  11664. var inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js")
  11665. function StreamCipher (mode, key, iv, decrypt) {
  11666. Transform.call(this)
  11667. this._cipher = new aes.AES(key)
  11668. this._prev = Buffer.from(iv)
  11669. this._cache = Buffer.allocUnsafe(0)
  11670. this._secCache = Buffer.allocUnsafe(0)
  11671. this._decrypt = decrypt
  11672. this._mode = mode
  11673. }
  11674. inherits(StreamCipher, Transform)
  11675. StreamCipher.prototype._update = function (chunk) {
  11676. return this._mode.encrypt(this, chunk, this._decrypt)
  11677. }
  11678. StreamCipher.prototype._final = function () {
  11679. this._cipher.scrub()
  11680. }
  11681. module.exports = StreamCipher
  11682. /***/ }),
  11683. /***/ "../../node_modules/browserify-cipher/browser.js":
  11684. /*!*******************************************************!*\
  11685. !*** ../../node_modules/browserify-cipher/browser.js ***!
  11686. \*******************************************************/
  11687. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  11688. var DES = __webpack_require__(/*! browserify-des */ "../../node_modules/browserify-des/index.js")
  11689. var aes = __webpack_require__(/*! browserify-aes/browser */ "../../node_modules/browserify-aes/browser.js")
  11690. var aesModes = __webpack_require__(/*! browserify-aes/modes */ "../../node_modules/browserify-aes/modes/index.js")
  11691. var desModes = __webpack_require__(/*! browserify-des/modes */ "../../node_modules/browserify-des/modes.js")
  11692. var ebtk = __webpack_require__(/*! evp_bytestokey */ "../../node_modules/evp_bytestokey/index.js")
  11693. function createCipher (suite, password) {
  11694. suite = suite.toLowerCase()
  11695. var keyLen, ivLen
  11696. if (aesModes[suite]) {
  11697. keyLen = aesModes[suite].key
  11698. ivLen = aesModes[suite].iv
  11699. } else if (desModes[suite]) {
  11700. keyLen = desModes[suite].key * 8
  11701. ivLen = desModes[suite].iv
  11702. } else {
  11703. throw new TypeError('invalid suite type')
  11704. }
  11705. var keys = ebtk(password, false, keyLen, ivLen)
  11706. return createCipheriv(suite, keys.key, keys.iv)
  11707. }
  11708. function createDecipher (suite, password) {
  11709. suite = suite.toLowerCase()
  11710. var keyLen, ivLen
  11711. if (aesModes[suite]) {
  11712. keyLen = aesModes[suite].key
  11713. ivLen = aesModes[suite].iv
  11714. } else if (desModes[suite]) {
  11715. keyLen = desModes[suite].key * 8
  11716. ivLen = desModes[suite].iv
  11717. } else {
  11718. throw new TypeError('invalid suite type')
  11719. }
  11720. var keys = ebtk(password, false, keyLen, ivLen)
  11721. return createDecipheriv(suite, keys.key, keys.iv)
  11722. }
  11723. function createCipheriv (suite, key, iv) {
  11724. suite = suite.toLowerCase()
  11725. if (aesModes[suite]) return aes.createCipheriv(suite, key, iv)
  11726. if (desModes[suite]) return new DES({ key: key, iv: iv, mode: suite })
  11727. throw new TypeError('invalid suite type')
  11728. }
  11729. function createDecipheriv (suite, key, iv) {
  11730. suite = suite.toLowerCase()
  11731. if (aesModes[suite]) return aes.createDecipheriv(suite, key, iv)
  11732. if (desModes[suite]) return new DES({ key: key, iv: iv, mode: suite, decrypt: true })
  11733. throw new TypeError('invalid suite type')
  11734. }
  11735. function getCiphers () {
  11736. return Object.keys(desModes).concat(aes.getCiphers())
  11737. }
  11738. exports.createCipher = exports.Cipher = createCipher
  11739. exports.createCipheriv = exports.Cipheriv = createCipheriv
  11740. exports.createDecipher = exports.Decipher = createDecipher
  11741. exports.createDecipheriv = exports.Decipheriv = createDecipheriv
  11742. exports.listCiphers = exports.getCiphers = getCiphers
  11743. /***/ }),
  11744. /***/ "../../node_modules/browserify-des/index.js":
  11745. /*!**************************************************!*\
  11746. !*** ../../node_modules/browserify-des/index.js ***!
  11747. \**************************************************/
  11748. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  11749. var CipherBase = __webpack_require__(/*! cipher-base */ "../../node_modules/cipher-base/index.js")
  11750. var des = __webpack_require__(/*! des.js */ "../../node_modules/des.js/lib/des.js")
  11751. var inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js")
  11752. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  11753. var modes = {
  11754. 'des-ede3-cbc': des.CBC.instantiate(des.EDE),
  11755. 'des-ede3': des.EDE,
  11756. 'des-ede-cbc': des.CBC.instantiate(des.EDE),
  11757. 'des-ede': des.EDE,
  11758. 'des-cbc': des.CBC.instantiate(des.DES),
  11759. 'des-ecb': des.DES
  11760. }
  11761. modes.des = modes['des-cbc']
  11762. modes.des3 = modes['des-ede3-cbc']
  11763. module.exports = DES
  11764. inherits(DES, CipherBase)
  11765. function DES (opts) {
  11766. CipherBase.call(this)
  11767. var modeName = opts.mode.toLowerCase()
  11768. var mode = modes[modeName]
  11769. var type
  11770. if (opts.decrypt) {
  11771. type = 'decrypt'
  11772. } else {
  11773. type = 'encrypt'
  11774. }
  11775. var key = opts.key
  11776. if (!Buffer.isBuffer(key)) {
  11777. key = Buffer.from(key)
  11778. }
  11779. if (modeName === 'des-ede' || modeName === 'des-ede-cbc') {
  11780. key = Buffer.concat([key, key.slice(0, 8)])
  11781. }
  11782. var iv = opts.iv
  11783. if (!Buffer.isBuffer(iv)) {
  11784. iv = Buffer.from(iv)
  11785. }
  11786. this._des = mode.create({
  11787. key: key,
  11788. iv: iv,
  11789. type: type
  11790. })
  11791. }
  11792. DES.prototype._update = function (data) {
  11793. return Buffer.from(this._des.update(data))
  11794. }
  11795. DES.prototype._final = function () {
  11796. return Buffer.from(this._des.final())
  11797. }
  11798. /***/ }),
  11799. /***/ "../../node_modules/browserify-des/modes.js":
  11800. /*!**************************************************!*\
  11801. !*** ../../node_modules/browserify-des/modes.js ***!
  11802. \**************************************************/
  11803. /***/ ((__unused_webpack_module, exports) => {
  11804. exports["des-ecb"] = {
  11805. key: 8,
  11806. iv: 0
  11807. }
  11808. exports["des-cbc"] = exports.des = {
  11809. key: 8,
  11810. iv: 8
  11811. }
  11812. exports["des-ede3-cbc"] = exports.des3 = {
  11813. key: 24,
  11814. iv: 8
  11815. }
  11816. exports["des-ede3"] = {
  11817. key: 24,
  11818. iv: 0
  11819. }
  11820. exports["des-ede-cbc"] = {
  11821. key: 16,
  11822. iv: 8
  11823. }
  11824. exports["des-ede"] = {
  11825. key: 16,
  11826. iv: 0
  11827. }
  11828. /***/ }),
  11829. /***/ "../../node_modules/browserify-rsa/index.js":
  11830. /*!**************************************************!*\
  11831. !*** ../../node_modules/browserify-rsa/index.js ***!
  11832. \**************************************************/
  11833. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  11834. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js")["Buffer"];
  11835. var BN = __webpack_require__(/*! bn.js */ "../../node_modules/bn.js/lib/bn.js")
  11836. var randomBytes = __webpack_require__(/*! randombytes */ "../../node_modules/randombytes/browser.js")
  11837. function blind (priv) {
  11838. var r = getr(priv)
  11839. var blinder = r.toRed(BN.mont(priv.modulus)).redPow(new BN(priv.publicExponent)).fromRed()
  11840. return { blinder: blinder, unblinder: r.invm(priv.modulus) }
  11841. }
  11842. function getr (priv) {
  11843. var len = priv.modulus.byteLength()
  11844. var r
  11845. do {
  11846. r = new BN(randomBytes(len))
  11847. } while (r.cmp(priv.modulus) >= 0 || !r.umod(priv.prime1) || !r.umod(priv.prime2))
  11848. return r
  11849. }
  11850. function crt (msg, priv) {
  11851. var blinds = blind(priv)
  11852. var len = priv.modulus.byteLength()
  11853. var blinded = new BN(msg).mul(blinds.blinder).umod(priv.modulus)
  11854. var c1 = blinded.toRed(BN.mont(priv.prime1))
  11855. var c2 = blinded.toRed(BN.mont(priv.prime2))
  11856. var qinv = priv.coefficient
  11857. var p = priv.prime1
  11858. var q = priv.prime2
  11859. var m1 = c1.redPow(priv.exponent1).fromRed()
  11860. var m2 = c2.redPow(priv.exponent2).fromRed()
  11861. var h = m1.isub(m2).imul(qinv).umod(p).imul(q)
  11862. return m2.iadd(h).imul(blinds.unblinder).umod(priv.modulus).toArrayLike(Buffer, 'be', len)
  11863. }
  11864. crt.getr = getr
  11865. module.exports = crt
  11866. /***/ }),
  11867. /***/ "../../node_modules/browserify-sign/algos.js":
  11868. /*!***************************************************!*\
  11869. !*** ../../node_modules/browserify-sign/algos.js ***!
  11870. \***************************************************/
  11871. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  11872. module.exports = __webpack_require__(/*! ./browser/algorithms.json */ "../../node_modules/browserify-sign/browser/algorithms.json")
  11873. /***/ }),
  11874. /***/ "../../node_modules/browserify-sign/browser/index.js":
  11875. /*!***********************************************************!*\
  11876. !*** ../../node_modules/browserify-sign/browser/index.js ***!
  11877. \***********************************************************/
  11878. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  11879. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  11880. var createHash = __webpack_require__(/*! create-hash */ "../../node_modules/create-hash/browser.js")
  11881. var stream = __webpack_require__(/*! readable-stream */ "../../node_modules/readable-stream/readable-browser.js")
  11882. var inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js")
  11883. var sign = __webpack_require__(/*! ./sign */ "../../node_modules/browserify-sign/browser/sign.js")
  11884. var verify = __webpack_require__(/*! ./verify */ "../../node_modules/browserify-sign/browser/verify.js")
  11885. var algorithms = __webpack_require__(/*! ./algorithms.json */ "../../node_modules/browserify-sign/browser/algorithms.json")
  11886. Object.keys(algorithms).forEach(function (key) {
  11887. algorithms[key].id = Buffer.from(algorithms[key].id, 'hex')
  11888. algorithms[key.toLowerCase()] = algorithms[key]
  11889. })
  11890. function Sign (algorithm) {
  11891. stream.Writable.call(this)
  11892. var data = algorithms[algorithm]
  11893. if (!data) throw new Error('Unknown message digest')
  11894. this._hashType = data.hash
  11895. this._hash = createHash(data.hash)
  11896. this._tag = data.id
  11897. this._signType = data.sign
  11898. }
  11899. inherits(Sign, stream.Writable)
  11900. Sign.prototype._write = function _write (data, _, done) {
  11901. this._hash.update(data)
  11902. done()
  11903. }
  11904. Sign.prototype.update = function update (data, enc) {
  11905. if (typeof data === 'string') data = Buffer.from(data, enc)
  11906. this._hash.update(data)
  11907. return this
  11908. }
  11909. Sign.prototype.sign = function signMethod (key, enc) {
  11910. this.end()
  11911. var hash = this._hash.digest()
  11912. var sig = sign(hash, key, this._hashType, this._signType, this._tag)
  11913. return enc ? sig.toString(enc) : sig
  11914. }
  11915. function Verify (algorithm) {
  11916. stream.Writable.call(this)
  11917. var data = algorithms[algorithm]
  11918. if (!data) throw new Error('Unknown message digest')
  11919. this._hash = createHash(data.hash)
  11920. this._tag = data.id
  11921. this._signType = data.sign
  11922. }
  11923. inherits(Verify, stream.Writable)
  11924. Verify.prototype._write = function _write (data, _, done) {
  11925. this._hash.update(data)
  11926. done()
  11927. }
  11928. Verify.prototype.update = function update (data, enc) {
  11929. if (typeof data === 'string') data = Buffer.from(data, enc)
  11930. this._hash.update(data)
  11931. return this
  11932. }
  11933. Verify.prototype.verify = function verifyMethod (key, sig, enc) {
  11934. if (typeof sig === 'string') sig = Buffer.from(sig, enc)
  11935. this.end()
  11936. var hash = this._hash.digest()
  11937. return verify(sig, hash, key, this._signType, this._tag)
  11938. }
  11939. function createSign (algorithm) {
  11940. return new Sign(algorithm)
  11941. }
  11942. function createVerify (algorithm) {
  11943. return new Verify(algorithm)
  11944. }
  11945. module.exports = {
  11946. Sign: createSign,
  11947. Verify: createVerify,
  11948. createSign: createSign,
  11949. createVerify: createVerify
  11950. }
  11951. /***/ }),
  11952. /***/ "../../node_modules/browserify-sign/browser/sign.js":
  11953. /*!**********************************************************!*\
  11954. !*** ../../node_modules/browserify-sign/browser/sign.js ***!
  11955. \**********************************************************/
  11956. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  11957. // much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js
  11958. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  11959. var createHmac = __webpack_require__(/*! create-hmac */ "../../node_modules/create-hmac/browser.js")
  11960. var crt = __webpack_require__(/*! browserify-rsa */ "../../node_modules/browserify-rsa/index.js")
  11961. var EC = (__webpack_require__(/*! elliptic */ "../../node_modules/elliptic/lib/elliptic.js").ec)
  11962. var BN = __webpack_require__(/*! bn.js */ "../../node_modules/bn.js/lib/bn.js")
  11963. var parseKeys = __webpack_require__(/*! parse-asn1 */ "../../node_modules/parse-asn1/index.js")
  11964. var curves = __webpack_require__(/*! ./curves.json */ "../../node_modules/browserify-sign/browser/curves.json")
  11965. function sign (hash, key, hashType, signType, tag) {
  11966. var priv = parseKeys(key)
  11967. if (priv.curve) {
  11968. // rsa keys can be interpreted as ecdsa ones in openssl
  11969. if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type')
  11970. return ecSign(hash, priv)
  11971. } else if (priv.type === 'dsa') {
  11972. if (signType !== 'dsa') throw new Error('wrong private key type')
  11973. return dsaSign(hash, priv, hashType)
  11974. } else {
  11975. if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type')
  11976. }
  11977. hash = Buffer.concat([tag, hash])
  11978. var len = priv.modulus.byteLength()
  11979. var pad = [0, 1]
  11980. while (hash.length + pad.length + 1 < len) pad.push(0xff)
  11981. pad.push(0x00)
  11982. var i = -1
  11983. while (++i < hash.length) pad.push(hash[i])
  11984. var out = crt(pad, priv)
  11985. return out
  11986. }
  11987. function ecSign (hash, priv) {
  11988. var curveId = curves[priv.curve.join('.')]
  11989. if (!curveId) throw new Error('unknown curve ' + priv.curve.join('.'))
  11990. var curve = new EC(curveId)
  11991. var key = curve.keyFromPrivate(priv.privateKey)
  11992. var out = key.sign(hash)
  11993. return Buffer.from(out.toDER())
  11994. }
  11995. function dsaSign (hash, priv, algo) {
  11996. var x = priv.params.priv_key
  11997. var p = priv.params.p
  11998. var q = priv.params.q
  11999. var g = priv.params.g
  12000. var r = new BN(0)
  12001. var k
  12002. var H = bits2int(hash, q).mod(q)
  12003. var s = false
  12004. var kv = getKey(x, q, hash, algo)
  12005. while (s === false) {
  12006. k = makeKey(q, kv, algo)
  12007. r = makeR(g, k, p, q)
  12008. s = k.invm(q).imul(H.add(x.mul(r))).mod(q)
  12009. if (s.cmpn(0) === 0) {
  12010. s = false
  12011. r = new BN(0)
  12012. }
  12013. }
  12014. return toDER(r, s)
  12015. }
  12016. function toDER (r, s) {
  12017. r = r.toArray()
  12018. s = s.toArray()
  12019. // Pad values
  12020. if (r[0] & 0x80) r = [0].concat(r)
  12021. if (s[0] & 0x80) s = [0].concat(s)
  12022. var total = r.length + s.length + 4
  12023. var res = [0x30, total, 0x02, r.length]
  12024. res = res.concat(r, [0x02, s.length], s)
  12025. return Buffer.from(res)
  12026. }
  12027. function getKey (x, q, hash, algo) {
  12028. x = Buffer.from(x.toArray())
  12029. if (x.length < q.byteLength()) {
  12030. var zeros = Buffer.alloc(q.byteLength() - x.length)
  12031. x = Buffer.concat([zeros, x])
  12032. }
  12033. var hlen = hash.length
  12034. var hbits = bits2octets(hash, q)
  12035. var v = Buffer.alloc(hlen)
  12036. v.fill(1)
  12037. var k = Buffer.alloc(hlen)
  12038. k = createHmac(algo, k).update(v).update(Buffer.from([0])).update(x).update(hbits).digest()
  12039. v = createHmac(algo, k).update(v).digest()
  12040. k = createHmac(algo, k).update(v).update(Buffer.from([1])).update(x).update(hbits).digest()
  12041. v = createHmac(algo, k).update(v).digest()
  12042. return { k: k, v: v }
  12043. }
  12044. function bits2int (obits, q) {
  12045. var bits = new BN(obits)
  12046. var shift = (obits.length << 3) - q.bitLength()
  12047. if (shift > 0) bits.ishrn(shift)
  12048. return bits
  12049. }
  12050. function bits2octets (bits, q) {
  12051. bits = bits2int(bits, q)
  12052. bits = bits.mod(q)
  12053. var out = Buffer.from(bits.toArray())
  12054. if (out.length < q.byteLength()) {
  12055. var zeros = Buffer.alloc(q.byteLength() - out.length)
  12056. out = Buffer.concat([zeros, out])
  12057. }
  12058. return out
  12059. }
  12060. function makeKey (q, kv, algo) {
  12061. var t
  12062. var k
  12063. do {
  12064. t = Buffer.alloc(0)
  12065. while (t.length * 8 < q.bitLength()) {
  12066. kv.v = createHmac(algo, kv.k).update(kv.v).digest()
  12067. t = Buffer.concat([t, kv.v])
  12068. }
  12069. k = bits2int(t, q)
  12070. kv.k = createHmac(algo, kv.k).update(kv.v).update(Buffer.from([0])).digest()
  12071. kv.v = createHmac(algo, kv.k).update(kv.v).digest()
  12072. } while (k.cmp(q) !== -1)
  12073. return k
  12074. }
  12075. function makeR (g, k, p, q) {
  12076. return g.toRed(BN.mont(p)).redPow(k).fromRed().mod(q)
  12077. }
  12078. module.exports = sign
  12079. module.exports.getKey = getKey
  12080. module.exports.makeKey = makeKey
  12081. /***/ }),
  12082. /***/ "../../node_modules/browserify-sign/browser/verify.js":
  12083. /*!************************************************************!*\
  12084. !*** ../../node_modules/browserify-sign/browser/verify.js ***!
  12085. \************************************************************/
  12086. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  12087. // much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js
  12088. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  12089. var BN = __webpack_require__(/*! bn.js */ "../../node_modules/bn.js/lib/bn.js")
  12090. var EC = (__webpack_require__(/*! elliptic */ "../../node_modules/elliptic/lib/elliptic.js").ec)
  12091. var parseKeys = __webpack_require__(/*! parse-asn1 */ "../../node_modules/parse-asn1/index.js")
  12092. var curves = __webpack_require__(/*! ./curves.json */ "../../node_modules/browserify-sign/browser/curves.json")
  12093. function verify (sig, hash, key, signType, tag) {
  12094. var pub = parseKeys(key)
  12095. if (pub.type === 'ec') {
  12096. // rsa keys can be interpreted as ecdsa ones in openssl
  12097. if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type')
  12098. return ecVerify(sig, hash, pub)
  12099. } else if (pub.type === 'dsa') {
  12100. if (signType !== 'dsa') throw new Error('wrong public key type')
  12101. return dsaVerify(sig, hash, pub)
  12102. } else {
  12103. if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type')
  12104. }
  12105. hash = Buffer.concat([tag, hash])
  12106. var len = pub.modulus.byteLength()
  12107. var pad = [1]
  12108. var padNum = 0
  12109. while (hash.length + pad.length + 2 < len) {
  12110. pad.push(0xff)
  12111. padNum++
  12112. }
  12113. pad.push(0x00)
  12114. var i = -1
  12115. while (++i < hash.length) {
  12116. pad.push(hash[i])
  12117. }
  12118. pad = Buffer.from(pad)
  12119. var red = BN.mont(pub.modulus)
  12120. sig = new BN(sig).toRed(red)
  12121. sig = sig.redPow(new BN(pub.publicExponent))
  12122. sig = Buffer.from(sig.fromRed().toArray())
  12123. var out = padNum < 8 ? 1 : 0
  12124. len = Math.min(sig.length, pad.length)
  12125. if (sig.length !== pad.length) out = 1
  12126. i = -1
  12127. while (++i < len) out |= sig[i] ^ pad[i]
  12128. return out === 0
  12129. }
  12130. function ecVerify (sig, hash, pub) {
  12131. var curveId = curves[pub.data.algorithm.curve.join('.')]
  12132. if (!curveId) throw new Error('unknown curve ' + pub.data.algorithm.curve.join('.'))
  12133. var curve = new EC(curveId)
  12134. var pubkey = pub.data.subjectPrivateKey.data
  12135. return curve.verify(hash, sig, pubkey)
  12136. }
  12137. function dsaVerify (sig, hash, pub) {
  12138. var p = pub.data.p
  12139. var q = pub.data.q
  12140. var g = pub.data.g
  12141. var y = pub.data.pub_key
  12142. var unpacked = parseKeys.signature.decode(sig, 'der')
  12143. var s = unpacked.s
  12144. var r = unpacked.r
  12145. checkValue(s, q)
  12146. checkValue(r, q)
  12147. var montp = BN.mont(p)
  12148. var w = s.invm(q)
  12149. var v = g.toRed(montp)
  12150. .redPow(new BN(hash).mul(w).mod(q))
  12151. .fromRed()
  12152. .mul(y.toRed(montp).redPow(r.mul(w).mod(q)).fromRed())
  12153. .mod(p)
  12154. .mod(q)
  12155. return v.cmp(r) === 0
  12156. }
  12157. function checkValue (b, q) {
  12158. if (b.cmpn(0) <= 0) throw new Error('invalid sig')
  12159. if (b.cmp(q) >= q) throw new Error('invalid sig')
  12160. }
  12161. module.exports = verify
  12162. /***/ }),
  12163. /***/ "../../node_modules/bs58/index.js":
  12164. /*!****************************************!*\
  12165. !*** ../../node_modules/bs58/index.js ***!
  12166. \****************************************/
  12167. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  12168. var basex = __webpack_require__(/*! base-x */ "../../node_modules/base-x/src/index.js")
  12169. var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
  12170. module.exports = basex(ALPHABET)
  12171. /***/ }),
  12172. /***/ "../../node_modules/bs58check/base.js":
  12173. /*!********************************************!*\
  12174. !*** ../../node_modules/bs58check/base.js ***!
  12175. \********************************************/
  12176. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  12177. "use strict";
  12178. var base58 = __webpack_require__(/*! bs58 */ "../../node_modules/bs58/index.js")
  12179. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  12180. module.exports = function (checksumFn) {
  12181. // Encode a buffer as a base58-check encoded string
  12182. function encode (payload) {
  12183. var checksum = checksumFn(payload)
  12184. return base58.encode(Buffer.concat([
  12185. payload,
  12186. checksum
  12187. ], payload.length + 4))
  12188. }
  12189. function decodeRaw (buffer) {
  12190. var payload = buffer.slice(0, -4)
  12191. var checksum = buffer.slice(-4)
  12192. var newChecksum = checksumFn(payload)
  12193. if (checksum[0] ^ newChecksum[0] |
  12194. checksum[1] ^ newChecksum[1] |
  12195. checksum[2] ^ newChecksum[2] |
  12196. checksum[3] ^ newChecksum[3]) return
  12197. return payload
  12198. }
  12199. // Decode a base58-check encoded string to a buffer, no result if checksum is wrong
  12200. function decodeUnsafe (string) {
  12201. var buffer = base58.decodeUnsafe(string)
  12202. if (!buffer) return
  12203. return decodeRaw(buffer)
  12204. }
  12205. function decode (string) {
  12206. var buffer = base58.decode(string)
  12207. var payload = decodeRaw(buffer, checksumFn)
  12208. if (!payload) throw new Error('Invalid checksum')
  12209. return payload
  12210. }
  12211. return {
  12212. encode: encode,
  12213. decode: decode,
  12214. decodeUnsafe: decodeUnsafe
  12215. }
  12216. }
  12217. /***/ }),
  12218. /***/ "../../node_modules/bs58check/index.js":
  12219. /*!*********************************************!*\
  12220. !*** ../../node_modules/bs58check/index.js ***!
  12221. \*********************************************/
  12222. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  12223. "use strict";
  12224. var createHash = __webpack_require__(/*! create-hash */ "../../node_modules/create-hash/browser.js")
  12225. var bs58checkBase = __webpack_require__(/*! ./base */ "../../node_modules/bs58check/base.js")
  12226. // SHA256(SHA256(buffer))
  12227. function sha256x2 (buffer) {
  12228. var tmp = createHash('sha256').update(buffer).digest()
  12229. return createHash('sha256').update(tmp).digest()
  12230. }
  12231. module.exports = bs58checkBase(sha256x2)
  12232. /***/ }),
  12233. /***/ "../../node_modules/buffer-xor/index.js":
  12234. /*!**********************************************!*\
  12235. !*** ../../node_modules/buffer-xor/index.js ***!
  12236. \**********************************************/
  12237. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  12238. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js")["Buffer"];
  12239. module.exports = function xor (a, b) {
  12240. var length = Math.min(a.length, b.length)
  12241. var buffer = new Buffer(length)
  12242. for (var i = 0; i < length; ++i) {
  12243. buffer[i] = a[i] ^ b[i]
  12244. }
  12245. return buffer
  12246. }
  12247. /***/ }),
  12248. /***/ "../../node_modules/buffer/index.js":
  12249. /*!******************************************!*\
  12250. !*** ../../node_modules/buffer/index.js ***!
  12251. \******************************************/
  12252. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  12253. "use strict";
  12254. /*!
  12255. * The buffer module from node.js, for the browser.
  12256. *
  12257. * @author Feross Aboukhadijeh <https://feross.org>
  12258. * @license MIT
  12259. */
  12260. /* eslint-disable no-proto */
  12261. const base64 = __webpack_require__(/*! base64-js */ "../../node_modules/base64-js/index.js")
  12262. const ieee754 = __webpack_require__(/*! ieee754 */ "../../node_modules/ieee754/index.js")
  12263. const customInspectSymbol =
  12264. (typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation
  12265. ? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
  12266. : null
  12267. exports.Buffer = Buffer
  12268. exports.SlowBuffer = SlowBuffer
  12269. exports.INSPECT_MAX_BYTES = 50
  12270. const K_MAX_LENGTH = 0x7fffffff
  12271. exports.kMaxLength = K_MAX_LENGTH
  12272. /**
  12273. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  12274. * === true Use Uint8Array implementation (fastest)
  12275. * === false Print warning and recommend using `buffer` v4.x which has an Object
  12276. * implementation (most compatible, even IE6)
  12277. *
  12278. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  12279. * Opera 11.6+, iOS 4.2+.
  12280. *
  12281. * We report that the browser does not support typed arrays if the are not subclassable
  12282. * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
  12283. * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
  12284. * for __proto__ and has a buggy typed array implementation.
  12285. */
  12286. Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
  12287. if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
  12288. typeof console.error === 'function') {
  12289. console.error(
  12290. 'This browser lacks typed array (Uint8Array) support which is required by ' +
  12291. '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
  12292. )
  12293. }
  12294. function typedArraySupport () {
  12295. // Can typed array instances can be augmented?
  12296. try {
  12297. const arr = new Uint8Array(1)
  12298. const proto = { foo: function () { return 42 } }
  12299. Object.setPrototypeOf(proto, Uint8Array.prototype)
  12300. Object.setPrototypeOf(arr, proto)
  12301. return arr.foo() === 42
  12302. } catch (e) {
  12303. return false
  12304. }
  12305. }
  12306. Object.defineProperty(Buffer.prototype, 'parent', {
  12307. enumerable: true,
  12308. get: function () {
  12309. if (!Buffer.isBuffer(this)) return undefined
  12310. return this.buffer
  12311. }
  12312. })
  12313. Object.defineProperty(Buffer.prototype, 'offset', {
  12314. enumerable: true,
  12315. get: function () {
  12316. if (!Buffer.isBuffer(this)) return undefined
  12317. return this.byteOffset
  12318. }
  12319. })
  12320. function createBuffer (length) {
  12321. if (length > K_MAX_LENGTH) {
  12322. throw new RangeError('The value "' + length + '" is invalid for option "size"')
  12323. }
  12324. // Return an augmented `Uint8Array` instance
  12325. const buf = new Uint8Array(length)
  12326. Object.setPrototypeOf(buf, Buffer.prototype)
  12327. return buf
  12328. }
  12329. /**
  12330. * The Buffer constructor returns instances of `Uint8Array` that have their
  12331. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  12332. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  12333. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  12334. * returns a single octet.
  12335. *
  12336. * The `Uint8Array` prototype remains unmodified.
  12337. */
  12338. function Buffer (arg, encodingOrOffset, length) {
  12339. // Common case.
  12340. if (typeof arg === 'number') {
  12341. if (typeof encodingOrOffset === 'string') {
  12342. throw new TypeError(
  12343. 'The "string" argument must be of type string. Received type number'
  12344. )
  12345. }
  12346. return allocUnsafe(arg)
  12347. }
  12348. return from(arg, encodingOrOffset, length)
  12349. }
  12350. Buffer.poolSize = 8192 // not used by this implementation
  12351. function from (value, encodingOrOffset, length) {
  12352. if (typeof value === 'string') {
  12353. return fromString(value, encodingOrOffset)
  12354. }
  12355. if (ArrayBuffer.isView(value)) {
  12356. return fromArrayView(value)
  12357. }
  12358. if (value == null) {
  12359. throw new TypeError(
  12360. 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
  12361. 'or Array-like Object. Received type ' + (typeof value)
  12362. )
  12363. }
  12364. if (isInstance(value, ArrayBuffer) ||
  12365. (value && isInstance(value.buffer, ArrayBuffer))) {
  12366. return fromArrayBuffer(value, encodingOrOffset, length)
  12367. }
  12368. if (typeof SharedArrayBuffer !== 'undefined' &&
  12369. (isInstance(value, SharedArrayBuffer) ||
  12370. (value && isInstance(value.buffer, SharedArrayBuffer)))) {
  12371. return fromArrayBuffer(value, encodingOrOffset, length)
  12372. }
  12373. if (typeof value === 'number') {
  12374. throw new TypeError(
  12375. 'The "value" argument must not be of type number. Received type number'
  12376. )
  12377. }
  12378. const valueOf = value.valueOf && value.valueOf()
  12379. if (valueOf != null && valueOf !== value) {
  12380. return Buffer.from(valueOf, encodingOrOffset, length)
  12381. }
  12382. const b = fromObject(value)
  12383. if (b) return b
  12384. if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
  12385. typeof value[Symbol.toPrimitive] === 'function') {
  12386. return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length)
  12387. }
  12388. throw new TypeError(
  12389. 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
  12390. 'or Array-like Object. Received type ' + (typeof value)
  12391. )
  12392. }
  12393. /**
  12394. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  12395. * if value is a number.
  12396. * Buffer.from(str[, encoding])
  12397. * Buffer.from(array)
  12398. * Buffer.from(buffer)
  12399. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  12400. **/
  12401. Buffer.from = function (value, encodingOrOffset, length) {
  12402. return from(value, encodingOrOffset, length)
  12403. }
  12404. // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
  12405. // https://github.com/feross/buffer/pull/148
  12406. Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype)
  12407. Object.setPrototypeOf(Buffer, Uint8Array)
  12408. function assertSize (size) {
  12409. if (typeof size !== 'number') {
  12410. throw new TypeError('"size" argument must be of type number')
  12411. } else if (size < 0) {
  12412. throw new RangeError('The value "' + size + '" is invalid for option "size"')
  12413. }
  12414. }
  12415. function alloc (size, fill, encoding) {
  12416. assertSize(size)
  12417. if (size <= 0) {
  12418. return createBuffer(size)
  12419. }
  12420. if (fill !== undefined) {
  12421. // Only pay attention to encoding if it's a string. This
  12422. // prevents accidentally sending in a number that would
  12423. // be interpreted as a start offset.
  12424. return typeof encoding === 'string'
  12425. ? createBuffer(size).fill(fill, encoding)
  12426. : createBuffer(size).fill(fill)
  12427. }
  12428. return createBuffer(size)
  12429. }
  12430. /**
  12431. * Creates a new filled Buffer instance.
  12432. * alloc(size[, fill[, encoding]])
  12433. **/
  12434. Buffer.alloc = function (size, fill, encoding) {
  12435. return alloc(size, fill, encoding)
  12436. }
  12437. function allocUnsafe (size) {
  12438. assertSize(size)
  12439. return createBuffer(size < 0 ? 0 : checked(size) | 0)
  12440. }
  12441. /**
  12442. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  12443. * */
  12444. Buffer.allocUnsafe = function (size) {
  12445. return allocUnsafe(size)
  12446. }
  12447. /**
  12448. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  12449. */
  12450. Buffer.allocUnsafeSlow = function (size) {
  12451. return allocUnsafe(size)
  12452. }
  12453. function fromString (string, encoding) {
  12454. if (typeof encoding !== 'string' || encoding === '') {
  12455. encoding = 'utf8'
  12456. }
  12457. if (!Buffer.isEncoding(encoding)) {
  12458. throw new TypeError('Unknown encoding: ' + encoding)
  12459. }
  12460. const length = byteLength(string, encoding) | 0
  12461. let buf = createBuffer(length)
  12462. const actual = buf.write(string, encoding)
  12463. if (actual !== length) {
  12464. // Writing a hex string, for example, that contains invalid characters will
  12465. // cause everything after the first invalid character to be ignored. (e.g.
  12466. // 'abxxcd' will be treated as 'ab')
  12467. buf = buf.slice(0, actual)
  12468. }
  12469. return buf
  12470. }
  12471. function fromArrayLike (array) {
  12472. const length = array.length < 0 ? 0 : checked(array.length) | 0
  12473. const buf = createBuffer(length)
  12474. for (let i = 0; i < length; i += 1) {
  12475. buf[i] = array[i] & 255
  12476. }
  12477. return buf
  12478. }
  12479. function fromArrayView (arrayView) {
  12480. if (isInstance(arrayView, Uint8Array)) {
  12481. const copy = new Uint8Array(arrayView)
  12482. return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength)
  12483. }
  12484. return fromArrayLike(arrayView)
  12485. }
  12486. function fromArrayBuffer (array, byteOffset, length) {
  12487. if (byteOffset < 0 || array.byteLength < byteOffset) {
  12488. throw new RangeError('"offset" is outside of buffer bounds')
  12489. }
  12490. if (array.byteLength < byteOffset + (length || 0)) {
  12491. throw new RangeError('"length" is outside of buffer bounds')
  12492. }
  12493. let buf
  12494. if (byteOffset === undefined && length === undefined) {
  12495. buf = new Uint8Array(array)
  12496. } else if (length === undefined) {
  12497. buf = new Uint8Array(array, byteOffset)
  12498. } else {
  12499. buf = new Uint8Array(array, byteOffset, length)
  12500. }
  12501. // Return an augmented `Uint8Array` instance
  12502. Object.setPrototypeOf(buf, Buffer.prototype)
  12503. return buf
  12504. }
  12505. function fromObject (obj) {
  12506. if (Buffer.isBuffer(obj)) {
  12507. const len = checked(obj.length) | 0
  12508. const buf = createBuffer(len)
  12509. if (buf.length === 0) {
  12510. return buf
  12511. }
  12512. obj.copy(buf, 0, 0, len)
  12513. return buf
  12514. }
  12515. if (obj.length !== undefined) {
  12516. if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
  12517. return createBuffer(0)
  12518. }
  12519. return fromArrayLike(obj)
  12520. }
  12521. if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
  12522. return fromArrayLike(obj.data)
  12523. }
  12524. }
  12525. function checked (length) {
  12526. // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
  12527. // length is NaN (which is otherwise coerced to zero.)
  12528. if (length >= K_MAX_LENGTH) {
  12529. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  12530. 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
  12531. }
  12532. return length | 0
  12533. }
  12534. function SlowBuffer (length) {
  12535. if (+length != length) { // eslint-disable-line eqeqeq
  12536. length = 0
  12537. }
  12538. return Buffer.alloc(+length)
  12539. }
  12540. Buffer.isBuffer = function isBuffer (b) {
  12541. return b != null && b._isBuffer === true &&
  12542. b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
  12543. }
  12544. Buffer.compare = function compare (a, b) {
  12545. if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)
  12546. if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)
  12547. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  12548. throw new TypeError(
  12549. 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
  12550. )
  12551. }
  12552. if (a === b) return 0
  12553. let x = a.length
  12554. let y = b.length
  12555. for (let i = 0, len = Math.min(x, y); i < len; ++i) {
  12556. if (a[i] !== b[i]) {
  12557. x = a[i]
  12558. y = b[i]
  12559. break
  12560. }
  12561. }
  12562. if (x < y) return -1
  12563. if (y < x) return 1
  12564. return 0
  12565. }
  12566. Buffer.isEncoding = function isEncoding (encoding) {
  12567. switch (String(encoding).toLowerCase()) {
  12568. case 'hex':
  12569. case 'utf8':
  12570. case 'utf-8':
  12571. case 'ascii':
  12572. case 'latin1':
  12573. case 'binary':
  12574. case 'base64':
  12575. case 'ucs2':
  12576. case 'ucs-2':
  12577. case 'utf16le':
  12578. case 'utf-16le':
  12579. return true
  12580. default:
  12581. return false
  12582. }
  12583. }
  12584. Buffer.concat = function concat (list, length) {
  12585. if (!Array.isArray(list)) {
  12586. throw new TypeError('"list" argument must be an Array of Buffers')
  12587. }
  12588. if (list.length === 0) {
  12589. return Buffer.alloc(0)
  12590. }
  12591. let i
  12592. if (length === undefined) {
  12593. length = 0
  12594. for (i = 0; i < list.length; ++i) {
  12595. length += list[i].length
  12596. }
  12597. }
  12598. const buffer = Buffer.allocUnsafe(length)
  12599. let pos = 0
  12600. for (i = 0; i < list.length; ++i) {
  12601. let buf = list[i]
  12602. if (isInstance(buf, Uint8Array)) {
  12603. if (pos + buf.length > buffer.length) {
  12604. if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf)
  12605. buf.copy(buffer, pos)
  12606. } else {
  12607. Uint8Array.prototype.set.call(
  12608. buffer,
  12609. buf,
  12610. pos
  12611. )
  12612. }
  12613. } else if (!Buffer.isBuffer(buf)) {
  12614. throw new TypeError('"list" argument must be an Array of Buffers')
  12615. } else {
  12616. buf.copy(buffer, pos)
  12617. }
  12618. pos += buf.length
  12619. }
  12620. return buffer
  12621. }
  12622. function byteLength (string, encoding) {
  12623. if (Buffer.isBuffer(string)) {
  12624. return string.length
  12625. }
  12626. if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
  12627. return string.byteLength
  12628. }
  12629. if (typeof string !== 'string') {
  12630. throw new TypeError(
  12631. 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
  12632. 'Received type ' + typeof string
  12633. )
  12634. }
  12635. const len = string.length
  12636. const mustMatch = (arguments.length > 2 && arguments[2] === true)
  12637. if (!mustMatch && len === 0) return 0
  12638. // Use a for loop to avoid recursion
  12639. let loweredCase = false
  12640. for (;;) {
  12641. switch (encoding) {
  12642. case 'ascii':
  12643. case 'latin1':
  12644. case 'binary':
  12645. return len
  12646. case 'utf8':
  12647. case 'utf-8':
  12648. return utf8ToBytes(string).length
  12649. case 'ucs2':
  12650. case 'ucs-2':
  12651. case 'utf16le':
  12652. case 'utf-16le':
  12653. return len * 2
  12654. case 'hex':
  12655. return len >>> 1
  12656. case 'base64':
  12657. return base64ToBytes(string).length
  12658. default:
  12659. if (loweredCase) {
  12660. return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
  12661. }
  12662. encoding = ('' + encoding).toLowerCase()
  12663. loweredCase = true
  12664. }
  12665. }
  12666. }
  12667. Buffer.byteLength = byteLength
  12668. function slowToString (encoding, start, end) {
  12669. let loweredCase = false
  12670. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  12671. // property of a typed array.
  12672. // This behaves neither like String nor Uint8Array in that we set start/end
  12673. // to their upper/lower bounds if the value passed is out of range.
  12674. // undefined is handled specially as per ECMA-262 6th Edition,
  12675. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  12676. if (start === undefined || start < 0) {
  12677. start = 0
  12678. }
  12679. // Return early if start > this.length. Done here to prevent potential uint32
  12680. // coercion fail below.
  12681. if (start > this.length) {
  12682. return ''
  12683. }
  12684. if (end === undefined || end > this.length) {
  12685. end = this.length
  12686. }
  12687. if (end <= 0) {
  12688. return ''
  12689. }
  12690. // Force coercion to uint32. This will also coerce falsey/NaN values to 0.
  12691. end >>>= 0
  12692. start >>>= 0
  12693. if (end <= start) {
  12694. return ''
  12695. }
  12696. if (!encoding) encoding = 'utf8'
  12697. while (true) {
  12698. switch (encoding) {
  12699. case 'hex':
  12700. return hexSlice(this, start, end)
  12701. case 'utf8':
  12702. case 'utf-8':
  12703. return utf8Slice(this, start, end)
  12704. case 'ascii':
  12705. return asciiSlice(this, start, end)
  12706. case 'latin1':
  12707. case 'binary':
  12708. return latin1Slice(this, start, end)
  12709. case 'base64':
  12710. return base64Slice(this, start, end)
  12711. case 'ucs2':
  12712. case 'ucs-2':
  12713. case 'utf16le':
  12714. case 'utf-16le':
  12715. return utf16leSlice(this, start, end)
  12716. default:
  12717. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  12718. encoding = (encoding + '').toLowerCase()
  12719. loweredCase = true
  12720. }
  12721. }
  12722. }
  12723. // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
  12724. // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
  12725. // reliably in a browserify context because there could be multiple different
  12726. // copies of the 'buffer' package in use. This method works even for Buffer
  12727. // instances that were created from another copy of the `buffer` package.
  12728. // See: https://github.com/feross/buffer/issues/154
  12729. Buffer.prototype._isBuffer = true
  12730. function swap (b, n, m) {
  12731. const i = b[n]
  12732. b[n] = b[m]
  12733. b[m] = i
  12734. }
  12735. Buffer.prototype.swap16 = function swap16 () {
  12736. const len = this.length
  12737. if (len % 2 !== 0) {
  12738. throw new RangeError('Buffer size must be a multiple of 16-bits')
  12739. }
  12740. for (let i = 0; i < len; i += 2) {
  12741. swap(this, i, i + 1)
  12742. }
  12743. return this
  12744. }
  12745. Buffer.prototype.swap32 = function swap32 () {
  12746. const len = this.length
  12747. if (len % 4 !== 0) {
  12748. throw new RangeError('Buffer size must be a multiple of 32-bits')
  12749. }
  12750. for (let i = 0; i < len; i += 4) {
  12751. swap(this, i, i + 3)
  12752. swap(this, i + 1, i + 2)
  12753. }
  12754. return this
  12755. }
  12756. Buffer.prototype.swap64 = function swap64 () {
  12757. const len = this.length
  12758. if (len % 8 !== 0) {
  12759. throw new RangeError('Buffer size must be a multiple of 64-bits')
  12760. }
  12761. for (let i = 0; i < len; i += 8) {
  12762. swap(this, i, i + 7)
  12763. swap(this, i + 1, i + 6)
  12764. swap(this, i + 2, i + 5)
  12765. swap(this, i + 3, i + 4)
  12766. }
  12767. return this
  12768. }
  12769. Buffer.prototype.toString = function toString () {
  12770. const length = this.length
  12771. if (length === 0) return ''
  12772. if (arguments.length === 0) return utf8Slice(this, 0, length)
  12773. return slowToString.apply(this, arguments)
  12774. }
  12775. Buffer.prototype.toLocaleString = Buffer.prototype.toString
  12776. Buffer.prototype.equals = function equals (b) {
  12777. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  12778. if (this === b) return true
  12779. return Buffer.compare(this, b) === 0
  12780. }
  12781. Buffer.prototype.inspect = function inspect () {
  12782. let str = ''
  12783. const max = exports.INSPECT_MAX_BYTES
  12784. str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()
  12785. if (this.length > max) str += ' ... '
  12786. return '<Buffer ' + str + '>'
  12787. }
  12788. if (customInspectSymbol) {
  12789. Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect
  12790. }
  12791. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  12792. if (isInstance(target, Uint8Array)) {
  12793. target = Buffer.from(target, target.offset, target.byteLength)
  12794. }
  12795. if (!Buffer.isBuffer(target)) {
  12796. throw new TypeError(
  12797. 'The "target" argument must be one of type Buffer or Uint8Array. ' +
  12798. 'Received type ' + (typeof target)
  12799. )
  12800. }
  12801. if (start === undefined) {
  12802. start = 0
  12803. }
  12804. if (end === undefined) {
  12805. end = target ? target.length : 0
  12806. }
  12807. if (thisStart === undefined) {
  12808. thisStart = 0
  12809. }
  12810. if (thisEnd === undefined) {
  12811. thisEnd = this.length
  12812. }
  12813. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  12814. throw new RangeError('out of range index')
  12815. }
  12816. if (thisStart >= thisEnd && start >= end) {
  12817. return 0
  12818. }
  12819. if (thisStart >= thisEnd) {
  12820. return -1
  12821. }
  12822. if (start >= end) {
  12823. return 1
  12824. }
  12825. start >>>= 0
  12826. end >>>= 0
  12827. thisStart >>>= 0
  12828. thisEnd >>>= 0
  12829. if (this === target) return 0
  12830. let x = thisEnd - thisStart
  12831. let y = end - start
  12832. const len = Math.min(x, y)
  12833. const thisCopy = this.slice(thisStart, thisEnd)
  12834. const targetCopy = target.slice(start, end)
  12835. for (let i = 0; i < len; ++i) {
  12836. if (thisCopy[i] !== targetCopy[i]) {
  12837. x = thisCopy[i]
  12838. y = targetCopy[i]
  12839. break
  12840. }
  12841. }
  12842. if (x < y) return -1
  12843. if (y < x) return 1
  12844. return 0
  12845. }
  12846. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  12847. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  12848. //
  12849. // Arguments:
  12850. // - buffer - a Buffer to search
  12851. // - val - a string, Buffer, or number
  12852. // - byteOffset - an index into `buffer`; will be clamped to an int32
  12853. // - encoding - an optional encoding, relevant is val is a string
  12854. // - dir - true for indexOf, false for lastIndexOf
  12855. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  12856. // Empty buffer means no match
  12857. if (buffer.length === 0) return -1
  12858. // Normalize byteOffset
  12859. if (typeof byteOffset === 'string') {
  12860. encoding = byteOffset
  12861. byteOffset = 0
  12862. } else if (byteOffset > 0x7fffffff) {
  12863. byteOffset = 0x7fffffff
  12864. } else if (byteOffset < -0x80000000) {
  12865. byteOffset = -0x80000000
  12866. }
  12867. byteOffset = +byteOffset // Coerce to Number.
  12868. if (numberIsNaN(byteOffset)) {
  12869. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  12870. byteOffset = dir ? 0 : (buffer.length - 1)
  12871. }
  12872. // Normalize byteOffset: negative offsets start from the end of the buffer
  12873. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  12874. if (byteOffset >= buffer.length) {
  12875. if (dir) return -1
  12876. else byteOffset = buffer.length - 1
  12877. } else if (byteOffset < 0) {
  12878. if (dir) byteOffset = 0
  12879. else return -1
  12880. }
  12881. // Normalize val
  12882. if (typeof val === 'string') {
  12883. val = Buffer.from(val, encoding)
  12884. }
  12885. // Finally, search either indexOf (if dir is true) or lastIndexOf
  12886. if (Buffer.isBuffer(val)) {
  12887. // Special case: looking for empty string/buffer always fails
  12888. if (val.length === 0) {
  12889. return -1
  12890. }
  12891. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  12892. } else if (typeof val === 'number') {
  12893. val = val & 0xFF // Search for a byte value [0-255]
  12894. if (typeof Uint8Array.prototype.indexOf === 'function') {
  12895. if (dir) {
  12896. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  12897. } else {
  12898. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  12899. }
  12900. }
  12901. return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)
  12902. }
  12903. throw new TypeError('val must be string, number or Buffer')
  12904. }
  12905. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  12906. let indexSize = 1
  12907. let arrLength = arr.length
  12908. let valLength = val.length
  12909. if (encoding !== undefined) {
  12910. encoding = String(encoding).toLowerCase()
  12911. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  12912. encoding === 'utf16le' || encoding === 'utf-16le') {
  12913. if (arr.length < 2 || val.length < 2) {
  12914. return -1
  12915. }
  12916. indexSize = 2
  12917. arrLength /= 2
  12918. valLength /= 2
  12919. byteOffset /= 2
  12920. }
  12921. }
  12922. function read (buf, i) {
  12923. if (indexSize === 1) {
  12924. return buf[i]
  12925. } else {
  12926. return buf.readUInt16BE(i * indexSize)
  12927. }
  12928. }
  12929. let i
  12930. if (dir) {
  12931. let foundIndex = -1
  12932. for (i = byteOffset; i < arrLength; i++) {
  12933. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  12934. if (foundIndex === -1) foundIndex = i
  12935. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  12936. } else {
  12937. if (foundIndex !== -1) i -= i - foundIndex
  12938. foundIndex = -1
  12939. }
  12940. }
  12941. } else {
  12942. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  12943. for (i = byteOffset; i >= 0; i--) {
  12944. let found = true
  12945. for (let j = 0; j < valLength; j++) {
  12946. if (read(arr, i + j) !== read(val, j)) {
  12947. found = false
  12948. break
  12949. }
  12950. }
  12951. if (found) return i
  12952. }
  12953. }
  12954. return -1
  12955. }
  12956. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  12957. return this.indexOf(val, byteOffset, encoding) !== -1
  12958. }
  12959. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  12960. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  12961. }
  12962. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  12963. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  12964. }
  12965. function hexWrite (buf, string, offset, length) {
  12966. offset = Number(offset) || 0
  12967. const remaining = buf.length - offset
  12968. if (!length) {
  12969. length = remaining
  12970. } else {
  12971. length = Number(length)
  12972. if (length > remaining) {
  12973. length = remaining
  12974. }
  12975. }
  12976. const strLen = string.length
  12977. if (length > strLen / 2) {
  12978. length = strLen / 2
  12979. }
  12980. let i
  12981. for (i = 0; i < length; ++i) {
  12982. const parsed = parseInt(string.substr(i * 2, 2), 16)
  12983. if (numberIsNaN(parsed)) return i
  12984. buf[offset + i] = parsed
  12985. }
  12986. return i
  12987. }
  12988. function utf8Write (buf, string, offset, length) {
  12989. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  12990. }
  12991. function asciiWrite (buf, string, offset, length) {
  12992. return blitBuffer(asciiToBytes(string), buf, offset, length)
  12993. }
  12994. function base64Write (buf, string, offset, length) {
  12995. return blitBuffer(base64ToBytes(string), buf, offset, length)
  12996. }
  12997. function ucs2Write (buf, string, offset, length) {
  12998. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  12999. }
  13000. Buffer.prototype.write = function write (string, offset, length, encoding) {
  13001. // Buffer#write(string)
  13002. if (offset === undefined) {
  13003. encoding = 'utf8'
  13004. length = this.length
  13005. offset = 0
  13006. // Buffer#write(string, encoding)
  13007. } else if (length === undefined && typeof offset === 'string') {
  13008. encoding = offset
  13009. length = this.length
  13010. offset = 0
  13011. // Buffer#write(string, offset[, length][, encoding])
  13012. } else if (isFinite(offset)) {
  13013. offset = offset >>> 0
  13014. if (isFinite(length)) {
  13015. length = length >>> 0
  13016. if (encoding === undefined) encoding = 'utf8'
  13017. } else {
  13018. encoding = length
  13019. length = undefined
  13020. }
  13021. } else {
  13022. throw new Error(
  13023. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  13024. )
  13025. }
  13026. const remaining = this.length - offset
  13027. if (length === undefined || length > remaining) length = remaining
  13028. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  13029. throw new RangeError('Attempt to write outside buffer bounds')
  13030. }
  13031. if (!encoding) encoding = 'utf8'
  13032. let loweredCase = false
  13033. for (;;) {
  13034. switch (encoding) {
  13035. case 'hex':
  13036. return hexWrite(this, string, offset, length)
  13037. case 'utf8':
  13038. case 'utf-8':
  13039. return utf8Write(this, string, offset, length)
  13040. case 'ascii':
  13041. case 'latin1':
  13042. case 'binary':
  13043. return asciiWrite(this, string, offset, length)
  13044. case 'base64':
  13045. // Warning: maxLength not taken into account in base64Write
  13046. return base64Write(this, string, offset, length)
  13047. case 'ucs2':
  13048. case 'ucs-2':
  13049. case 'utf16le':
  13050. case 'utf-16le':
  13051. return ucs2Write(this, string, offset, length)
  13052. default:
  13053. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  13054. encoding = ('' + encoding).toLowerCase()
  13055. loweredCase = true
  13056. }
  13057. }
  13058. }
  13059. Buffer.prototype.toJSON = function toJSON () {
  13060. return {
  13061. type: 'Buffer',
  13062. data: Array.prototype.slice.call(this._arr || this, 0)
  13063. }
  13064. }
  13065. function base64Slice (buf, start, end) {
  13066. if (start === 0 && end === buf.length) {
  13067. return base64.fromByteArray(buf)
  13068. } else {
  13069. return base64.fromByteArray(buf.slice(start, end))
  13070. }
  13071. }
  13072. function utf8Slice (buf, start, end) {
  13073. end = Math.min(buf.length, end)
  13074. const res = []
  13075. let i = start
  13076. while (i < end) {
  13077. const firstByte = buf[i]
  13078. let codePoint = null
  13079. let bytesPerSequence = (firstByte > 0xEF)
  13080. ? 4
  13081. : (firstByte > 0xDF)
  13082. ? 3
  13083. : (firstByte > 0xBF)
  13084. ? 2
  13085. : 1
  13086. if (i + bytesPerSequence <= end) {
  13087. let secondByte, thirdByte, fourthByte, tempCodePoint
  13088. switch (bytesPerSequence) {
  13089. case 1:
  13090. if (firstByte < 0x80) {
  13091. codePoint = firstByte
  13092. }
  13093. break
  13094. case 2:
  13095. secondByte = buf[i + 1]
  13096. if ((secondByte & 0xC0) === 0x80) {
  13097. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  13098. if (tempCodePoint > 0x7F) {
  13099. codePoint = tempCodePoint
  13100. }
  13101. }
  13102. break
  13103. case 3:
  13104. secondByte = buf[i + 1]
  13105. thirdByte = buf[i + 2]
  13106. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  13107. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  13108. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  13109. codePoint = tempCodePoint
  13110. }
  13111. }
  13112. break
  13113. case 4:
  13114. secondByte = buf[i + 1]
  13115. thirdByte = buf[i + 2]
  13116. fourthByte = buf[i + 3]
  13117. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  13118. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  13119. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  13120. codePoint = tempCodePoint
  13121. }
  13122. }
  13123. }
  13124. }
  13125. if (codePoint === null) {
  13126. // we did not generate a valid codePoint so insert a
  13127. // replacement char (U+FFFD) and advance only 1 byte
  13128. codePoint = 0xFFFD
  13129. bytesPerSequence = 1
  13130. } else if (codePoint > 0xFFFF) {
  13131. // encode to utf16 (surrogate pair dance)
  13132. codePoint -= 0x10000
  13133. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  13134. codePoint = 0xDC00 | codePoint & 0x3FF
  13135. }
  13136. res.push(codePoint)
  13137. i += bytesPerSequence
  13138. }
  13139. return decodeCodePointsArray(res)
  13140. }
  13141. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  13142. // the lowest limit is Chrome, with 0x10000 args.
  13143. // We go 1 magnitude less, for safety
  13144. const MAX_ARGUMENTS_LENGTH = 0x1000
  13145. function decodeCodePointsArray (codePoints) {
  13146. const len = codePoints.length
  13147. if (len <= MAX_ARGUMENTS_LENGTH) {
  13148. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  13149. }
  13150. // Decode in chunks to avoid "call stack size exceeded".
  13151. let res = ''
  13152. let i = 0
  13153. while (i < len) {
  13154. res += String.fromCharCode.apply(
  13155. String,
  13156. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  13157. )
  13158. }
  13159. return res
  13160. }
  13161. function asciiSlice (buf, start, end) {
  13162. let ret = ''
  13163. end = Math.min(buf.length, end)
  13164. for (let i = start; i < end; ++i) {
  13165. ret += String.fromCharCode(buf[i] & 0x7F)
  13166. }
  13167. return ret
  13168. }
  13169. function latin1Slice (buf, start, end) {
  13170. let ret = ''
  13171. end = Math.min(buf.length, end)
  13172. for (let i = start; i < end; ++i) {
  13173. ret += String.fromCharCode(buf[i])
  13174. }
  13175. return ret
  13176. }
  13177. function hexSlice (buf, start, end) {
  13178. const len = buf.length
  13179. if (!start || start < 0) start = 0
  13180. if (!end || end < 0 || end > len) end = len
  13181. let out = ''
  13182. for (let i = start; i < end; ++i) {
  13183. out += hexSliceLookupTable[buf[i]]
  13184. }
  13185. return out
  13186. }
  13187. function utf16leSlice (buf, start, end) {
  13188. const bytes = buf.slice(start, end)
  13189. let res = ''
  13190. // If bytes.length is odd, the last 8 bits must be ignored (same as node.js)
  13191. for (let i = 0; i < bytes.length - 1; i += 2) {
  13192. res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
  13193. }
  13194. return res
  13195. }
  13196. Buffer.prototype.slice = function slice (start, end) {
  13197. const len = this.length
  13198. start = ~~start
  13199. end = end === undefined ? len : ~~end
  13200. if (start < 0) {
  13201. start += len
  13202. if (start < 0) start = 0
  13203. } else if (start > len) {
  13204. start = len
  13205. }
  13206. if (end < 0) {
  13207. end += len
  13208. if (end < 0) end = 0
  13209. } else if (end > len) {
  13210. end = len
  13211. }
  13212. if (end < start) end = start
  13213. const newBuf = this.subarray(start, end)
  13214. // Return an augmented `Uint8Array` instance
  13215. Object.setPrototypeOf(newBuf, Buffer.prototype)
  13216. return newBuf
  13217. }
  13218. /*
  13219. * Need to make sure that buffer isn't trying to write out of bounds.
  13220. */
  13221. function checkOffset (offset, ext, length) {
  13222. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  13223. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  13224. }
  13225. Buffer.prototype.readUintLE =
  13226. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  13227. offset = offset >>> 0
  13228. byteLength = byteLength >>> 0
  13229. if (!noAssert) checkOffset(offset, byteLength, this.length)
  13230. let val = this[offset]
  13231. let mul = 1
  13232. let i = 0
  13233. while (++i < byteLength && (mul *= 0x100)) {
  13234. val += this[offset + i] * mul
  13235. }
  13236. return val
  13237. }
  13238. Buffer.prototype.readUintBE =
  13239. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  13240. offset = offset >>> 0
  13241. byteLength = byteLength >>> 0
  13242. if (!noAssert) {
  13243. checkOffset(offset, byteLength, this.length)
  13244. }
  13245. let val = this[offset + --byteLength]
  13246. let mul = 1
  13247. while (byteLength > 0 && (mul *= 0x100)) {
  13248. val += this[offset + --byteLength] * mul
  13249. }
  13250. return val
  13251. }
  13252. Buffer.prototype.readUint8 =
  13253. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  13254. offset = offset >>> 0
  13255. if (!noAssert) checkOffset(offset, 1, this.length)
  13256. return this[offset]
  13257. }
  13258. Buffer.prototype.readUint16LE =
  13259. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  13260. offset = offset >>> 0
  13261. if (!noAssert) checkOffset(offset, 2, this.length)
  13262. return this[offset] | (this[offset + 1] << 8)
  13263. }
  13264. Buffer.prototype.readUint16BE =
  13265. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  13266. offset = offset >>> 0
  13267. if (!noAssert) checkOffset(offset, 2, this.length)
  13268. return (this[offset] << 8) | this[offset + 1]
  13269. }
  13270. Buffer.prototype.readUint32LE =
  13271. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  13272. offset = offset >>> 0
  13273. if (!noAssert) checkOffset(offset, 4, this.length)
  13274. return ((this[offset]) |
  13275. (this[offset + 1] << 8) |
  13276. (this[offset + 2] << 16)) +
  13277. (this[offset + 3] * 0x1000000)
  13278. }
  13279. Buffer.prototype.readUint32BE =
  13280. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  13281. offset = offset >>> 0
  13282. if (!noAssert) checkOffset(offset, 4, this.length)
  13283. return (this[offset] * 0x1000000) +
  13284. ((this[offset + 1] << 16) |
  13285. (this[offset + 2] << 8) |
  13286. this[offset + 3])
  13287. }
  13288. Buffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE (offset) {
  13289. offset = offset >>> 0
  13290. validateNumber(offset, 'offset')
  13291. const first = this[offset]
  13292. const last = this[offset + 7]
  13293. if (first === undefined || last === undefined) {
  13294. boundsError(offset, this.length - 8)
  13295. }
  13296. const lo = first +
  13297. this[++offset] * 2 ** 8 +
  13298. this[++offset] * 2 ** 16 +
  13299. this[++offset] * 2 ** 24
  13300. const hi = this[++offset] +
  13301. this[++offset] * 2 ** 8 +
  13302. this[++offset] * 2 ** 16 +
  13303. last * 2 ** 24
  13304. return BigInt(lo) + (BigInt(hi) << BigInt(32))
  13305. })
  13306. Buffer.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE (offset) {
  13307. offset = offset >>> 0
  13308. validateNumber(offset, 'offset')
  13309. const first = this[offset]
  13310. const last = this[offset + 7]
  13311. if (first === undefined || last === undefined) {
  13312. boundsError(offset, this.length - 8)
  13313. }
  13314. const hi = first * 2 ** 24 +
  13315. this[++offset] * 2 ** 16 +
  13316. this[++offset] * 2 ** 8 +
  13317. this[++offset]
  13318. const lo = this[++offset] * 2 ** 24 +
  13319. this[++offset] * 2 ** 16 +
  13320. this[++offset] * 2 ** 8 +
  13321. last
  13322. return (BigInt(hi) << BigInt(32)) + BigInt(lo)
  13323. })
  13324. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  13325. offset = offset >>> 0
  13326. byteLength = byteLength >>> 0
  13327. if (!noAssert) checkOffset(offset, byteLength, this.length)
  13328. let val = this[offset]
  13329. let mul = 1
  13330. let i = 0
  13331. while (++i < byteLength && (mul *= 0x100)) {
  13332. val += this[offset + i] * mul
  13333. }
  13334. mul *= 0x80
  13335. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  13336. return val
  13337. }
  13338. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  13339. offset = offset >>> 0
  13340. byteLength = byteLength >>> 0
  13341. if (!noAssert) checkOffset(offset, byteLength, this.length)
  13342. let i = byteLength
  13343. let mul = 1
  13344. let val = this[offset + --i]
  13345. while (i > 0 && (mul *= 0x100)) {
  13346. val += this[offset + --i] * mul
  13347. }
  13348. mul *= 0x80
  13349. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  13350. return val
  13351. }
  13352. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  13353. offset = offset >>> 0
  13354. if (!noAssert) checkOffset(offset, 1, this.length)
  13355. if (!(this[offset] & 0x80)) return (this[offset])
  13356. return ((0xff - this[offset] + 1) * -1)
  13357. }
  13358. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  13359. offset = offset >>> 0
  13360. if (!noAssert) checkOffset(offset, 2, this.length)
  13361. const val = this[offset] | (this[offset + 1] << 8)
  13362. return (val & 0x8000) ? val | 0xFFFF0000 : val
  13363. }
  13364. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  13365. offset = offset >>> 0
  13366. if (!noAssert) checkOffset(offset, 2, this.length)
  13367. const val = this[offset + 1] | (this[offset] << 8)
  13368. return (val & 0x8000) ? val | 0xFFFF0000 : val
  13369. }
  13370. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  13371. offset = offset >>> 0
  13372. if (!noAssert) checkOffset(offset, 4, this.length)
  13373. return (this[offset]) |
  13374. (this[offset + 1] << 8) |
  13375. (this[offset + 2] << 16) |
  13376. (this[offset + 3] << 24)
  13377. }
  13378. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  13379. offset = offset >>> 0
  13380. if (!noAssert) checkOffset(offset, 4, this.length)
  13381. return (this[offset] << 24) |
  13382. (this[offset + 1] << 16) |
  13383. (this[offset + 2] << 8) |
  13384. (this[offset + 3])
  13385. }
  13386. Buffer.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE (offset) {
  13387. offset = offset >>> 0
  13388. validateNumber(offset, 'offset')
  13389. const first = this[offset]
  13390. const last = this[offset + 7]
  13391. if (first === undefined || last === undefined) {
  13392. boundsError(offset, this.length - 8)
  13393. }
  13394. const val = this[offset + 4] +
  13395. this[offset + 5] * 2 ** 8 +
  13396. this[offset + 6] * 2 ** 16 +
  13397. (last << 24) // Overflow
  13398. return (BigInt(val) << BigInt(32)) +
  13399. BigInt(first +
  13400. this[++offset] * 2 ** 8 +
  13401. this[++offset] * 2 ** 16 +
  13402. this[++offset] * 2 ** 24)
  13403. })
  13404. Buffer.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE (offset) {
  13405. offset = offset >>> 0
  13406. validateNumber(offset, 'offset')
  13407. const first = this[offset]
  13408. const last = this[offset + 7]
  13409. if (first === undefined || last === undefined) {
  13410. boundsError(offset, this.length - 8)
  13411. }
  13412. const val = (first << 24) + // Overflow
  13413. this[++offset] * 2 ** 16 +
  13414. this[++offset] * 2 ** 8 +
  13415. this[++offset]
  13416. return (BigInt(val) << BigInt(32)) +
  13417. BigInt(this[++offset] * 2 ** 24 +
  13418. this[++offset] * 2 ** 16 +
  13419. this[++offset] * 2 ** 8 +
  13420. last)
  13421. })
  13422. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  13423. offset = offset >>> 0
  13424. if (!noAssert) checkOffset(offset, 4, this.length)
  13425. return ieee754.read(this, offset, true, 23, 4)
  13426. }
  13427. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  13428. offset = offset >>> 0
  13429. if (!noAssert) checkOffset(offset, 4, this.length)
  13430. return ieee754.read(this, offset, false, 23, 4)
  13431. }
  13432. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  13433. offset = offset >>> 0
  13434. if (!noAssert) checkOffset(offset, 8, this.length)
  13435. return ieee754.read(this, offset, true, 52, 8)
  13436. }
  13437. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  13438. offset = offset >>> 0
  13439. if (!noAssert) checkOffset(offset, 8, this.length)
  13440. return ieee754.read(this, offset, false, 52, 8)
  13441. }
  13442. function checkInt (buf, value, offset, ext, max, min) {
  13443. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  13444. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  13445. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  13446. }
  13447. Buffer.prototype.writeUintLE =
  13448. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  13449. value = +value
  13450. offset = offset >>> 0
  13451. byteLength = byteLength >>> 0
  13452. if (!noAssert) {
  13453. const maxBytes = Math.pow(2, 8 * byteLength) - 1
  13454. checkInt(this, value, offset, byteLength, maxBytes, 0)
  13455. }
  13456. let mul = 1
  13457. let i = 0
  13458. this[offset] = value & 0xFF
  13459. while (++i < byteLength && (mul *= 0x100)) {
  13460. this[offset + i] = (value / mul) & 0xFF
  13461. }
  13462. return offset + byteLength
  13463. }
  13464. Buffer.prototype.writeUintBE =
  13465. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  13466. value = +value
  13467. offset = offset >>> 0
  13468. byteLength = byteLength >>> 0
  13469. if (!noAssert) {
  13470. const maxBytes = Math.pow(2, 8 * byteLength) - 1
  13471. checkInt(this, value, offset, byteLength, maxBytes, 0)
  13472. }
  13473. let i = byteLength - 1
  13474. let mul = 1
  13475. this[offset + i] = value & 0xFF
  13476. while (--i >= 0 && (mul *= 0x100)) {
  13477. this[offset + i] = (value / mul) & 0xFF
  13478. }
  13479. return offset + byteLength
  13480. }
  13481. Buffer.prototype.writeUint8 =
  13482. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  13483. value = +value
  13484. offset = offset >>> 0
  13485. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  13486. this[offset] = (value & 0xff)
  13487. return offset + 1
  13488. }
  13489. Buffer.prototype.writeUint16LE =
  13490. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  13491. value = +value
  13492. offset = offset >>> 0
  13493. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  13494. this[offset] = (value & 0xff)
  13495. this[offset + 1] = (value >>> 8)
  13496. return offset + 2
  13497. }
  13498. Buffer.prototype.writeUint16BE =
  13499. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  13500. value = +value
  13501. offset = offset >>> 0
  13502. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  13503. this[offset] = (value >>> 8)
  13504. this[offset + 1] = (value & 0xff)
  13505. return offset + 2
  13506. }
  13507. Buffer.prototype.writeUint32LE =
  13508. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  13509. value = +value
  13510. offset = offset >>> 0
  13511. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  13512. this[offset + 3] = (value >>> 24)
  13513. this[offset + 2] = (value >>> 16)
  13514. this[offset + 1] = (value >>> 8)
  13515. this[offset] = (value & 0xff)
  13516. return offset + 4
  13517. }
  13518. Buffer.prototype.writeUint32BE =
  13519. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  13520. value = +value
  13521. offset = offset >>> 0
  13522. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  13523. this[offset] = (value >>> 24)
  13524. this[offset + 1] = (value >>> 16)
  13525. this[offset + 2] = (value >>> 8)
  13526. this[offset + 3] = (value & 0xff)
  13527. return offset + 4
  13528. }
  13529. function wrtBigUInt64LE (buf, value, offset, min, max) {
  13530. checkIntBI(value, min, max, buf, offset, 7)
  13531. let lo = Number(value & BigInt(0xffffffff))
  13532. buf[offset++] = lo
  13533. lo = lo >> 8
  13534. buf[offset++] = lo
  13535. lo = lo >> 8
  13536. buf[offset++] = lo
  13537. lo = lo >> 8
  13538. buf[offset++] = lo
  13539. let hi = Number(value >> BigInt(32) & BigInt(0xffffffff))
  13540. buf[offset++] = hi
  13541. hi = hi >> 8
  13542. buf[offset++] = hi
  13543. hi = hi >> 8
  13544. buf[offset++] = hi
  13545. hi = hi >> 8
  13546. buf[offset++] = hi
  13547. return offset
  13548. }
  13549. function wrtBigUInt64BE (buf, value, offset, min, max) {
  13550. checkIntBI(value, min, max, buf, offset, 7)
  13551. let lo = Number(value & BigInt(0xffffffff))
  13552. buf[offset + 7] = lo
  13553. lo = lo >> 8
  13554. buf[offset + 6] = lo
  13555. lo = lo >> 8
  13556. buf[offset + 5] = lo
  13557. lo = lo >> 8
  13558. buf[offset + 4] = lo
  13559. let hi = Number(value >> BigInt(32) & BigInt(0xffffffff))
  13560. buf[offset + 3] = hi
  13561. hi = hi >> 8
  13562. buf[offset + 2] = hi
  13563. hi = hi >> 8
  13564. buf[offset + 1] = hi
  13565. hi = hi >> 8
  13566. buf[offset] = hi
  13567. return offset + 8
  13568. }
  13569. Buffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE (value, offset = 0) {
  13570. return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
  13571. })
  13572. Buffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE (value, offset = 0) {
  13573. return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
  13574. })
  13575. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  13576. value = +value
  13577. offset = offset >>> 0
  13578. if (!noAssert) {
  13579. const limit = Math.pow(2, (8 * byteLength) - 1)
  13580. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  13581. }
  13582. let i = 0
  13583. let mul = 1
  13584. let sub = 0
  13585. this[offset] = value & 0xFF
  13586. while (++i < byteLength && (mul *= 0x100)) {
  13587. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  13588. sub = 1
  13589. }
  13590. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  13591. }
  13592. return offset + byteLength
  13593. }
  13594. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  13595. value = +value
  13596. offset = offset >>> 0
  13597. if (!noAssert) {
  13598. const limit = Math.pow(2, (8 * byteLength) - 1)
  13599. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  13600. }
  13601. let i = byteLength - 1
  13602. let mul = 1
  13603. let sub = 0
  13604. this[offset + i] = value & 0xFF
  13605. while (--i >= 0 && (mul *= 0x100)) {
  13606. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  13607. sub = 1
  13608. }
  13609. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  13610. }
  13611. return offset + byteLength
  13612. }
  13613. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  13614. value = +value
  13615. offset = offset >>> 0
  13616. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  13617. if (value < 0) value = 0xff + value + 1
  13618. this[offset] = (value & 0xff)
  13619. return offset + 1
  13620. }
  13621. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  13622. value = +value
  13623. offset = offset >>> 0
  13624. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  13625. this[offset] = (value & 0xff)
  13626. this[offset + 1] = (value >>> 8)
  13627. return offset + 2
  13628. }
  13629. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  13630. value = +value
  13631. offset = offset >>> 0
  13632. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  13633. this[offset] = (value >>> 8)
  13634. this[offset + 1] = (value & 0xff)
  13635. return offset + 2
  13636. }
  13637. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  13638. value = +value
  13639. offset = offset >>> 0
  13640. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  13641. this[offset] = (value & 0xff)
  13642. this[offset + 1] = (value >>> 8)
  13643. this[offset + 2] = (value >>> 16)
  13644. this[offset + 3] = (value >>> 24)
  13645. return offset + 4
  13646. }
  13647. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  13648. value = +value
  13649. offset = offset >>> 0
  13650. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  13651. if (value < 0) value = 0xffffffff + value + 1
  13652. this[offset] = (value >>> 24)
  13653. this[offset + 1] = (value >>> 16)
  13654. this[offset + 2] = (value >>> 8)
  13655. this[offset + 3] = (value & 0xff)
  13656. return offset + 4
  13657. }
  13658. Buffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE (value, offset = 0) {
  13659. return wrtBigUInt64LE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
  13660. })
  13661. Buffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE (value, offset = 0) {
  13662. return wrtBigUInt64BE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
  13663. })
  13664. function checkIEEE754 (buf, value, offset, ext, max, min) {
  13665. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  13666. if (offset < 0) throw new RangeError('Index out of range')
  13667. }
  13668. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  13669. value = +value
  13670. offset = offset >>> 0
  13671. if (!noAssert) {
  13672. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  13673. }
  13674. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  13675. return offset + 4
  13676. }
  13677. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  13678. return writeFloat(this, value, offset, true, noAssert)
  13679. }
  13680. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  13681. return writeFloat(this, value, offset, false, noAssert)
  13682. }
  13683. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  13684. value = +value
  13685. offset = offset >>> 0
  13686. if (!noAssert) {
  13687. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  13688. }
  13689. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  13690. return offset + 8
  13691. }
  13692. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  13693. return writeDouble(this, value, offset, true, noAssert)
  13694. }
  13695. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  13696. return writeDouble(this, value, offset, false, noAssert)
  13697. }
  13698. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  13699. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  13700. if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
  13701. if (!start) start = 0
  13702. if (!end && end !== 0) end = this.length
  13703. if (targetStart >= target.length) targetStart = target.length
  13704. if (!targetStart) targetStart = 0
  13705. if (end > 0 && end < start) end = start
  13706. // Copy 0 bytes; we're done
  13707. if (end === start) return 0
  13708. if (target.length === 0 || this.length === 0) return 0
  13709. // Fatal error conditions
  13710. if (targetStart < 0) {
  13711. throw new RangeError('targetStart out of bounds')
  13712. }
  13713. if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
  13714. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  13715. // Are we oob?
  13716. if (end > this.length) end = this.length
  13717. if (target.length - targetStart < end - start) {
  13718. end = target.length - targetStart + start
  13719. }
  13720. const len = end - start
  13721. if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
  13722. // Use built-in when available, missing from IE11
  13723. this.copyWithin(targetStart, start, end)
  13724. } else {
  13725. Uint8Array.prototype.set.call(
  13726. target,
  13727. this.subarray(start, end),
  13728. targetStart
  13729. )
  13730. }
  13731. return len
  13732. }
  13733. // Usage:
  13734. // buffer.fill(number[, offset[, end]])
  13735. // buffer.fill(buffer[, offset[, end]])
  13736. // buffer.fill(string[, offset[, end]][, encoding])
  13737. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  13738. // Handle string cases:
  13739. if (typeof val === 'string') {
  13740. if (typeof start === 'string') {
  13741. encoding = start
  13742. start = 0
  13743. end = this.length
  13744. } else if (typeof end === 'string') {
  13745. encoding = end
  13746. end = this.length
  13747. }
  13748. if (encoding !== undefined && typeof encoding !== 'string') {
  13749. throw new TypeError('encoding must be a string')
  13750. }
  13751. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  13752. throw new TypeError('Unknown encoding: ' + encoding)
  13753. }
  13754. if (val.length === 1) {
  13755. const code = val.charCodeAt(0)
  13756. if ((encoding === 'utf8' && code < 128) ||
  13757. encoding === 'latin1') {
  13758. // Fast path: If `val` fits into a single byte, use that numeric value.
  13759. val = code
  13760. }
  13761. }
  13762. } else if (typeof val === 'number') {
  13763. val = val & 255
  13764. } else if (typeof val === 'boolean') {
  13765. val = Number(val)
  13766. }
  13767. // Invalid ranges are not set to a default, so can range check early.
  13768. if (start < 0 || this.length < start || this.length < end) {
  13769. throw new RangeError('Out of range index')
  13770. }
  13771. if (end <= start) {
  13772. return this
  13773. }
  13774. start = start >>> 0
  13775. end = end === undefined ? this.length : end >>> 0
  13776. if (!val) val = 0
  13777. let i
  13778. if (typeof val === 'number') {
  13779. for (i = start; i < end; ++i) {
  13780. this[i] = val
  13781. }
  13782. } else {
  13783. const bytes = Buffer.isBuffer(val)
  13784. ? val
  13785. : Buffer.from(val, encoding)
  13786. const len = bytes.length
  13787. if (len === 0) {
  13788. throw new TypeError('The value "' + val +
  13789. '" is invalid for argument "value"')
  13790. }
  13791. for (i = 0; i < end - start; ++i) {
  13792. this[i + start] = bytes[i % len]
  13793. }
  13794. }
  13795. return this
  13796. }
  13797. // CUSTOM ERRORS
  13798. // =============
  13799. // Simplified versions from Node, changed for Buffer-only usage
  13800. const errors = {}
  13801. function E (sym, getMessage, Base) {
  13802. errors[sym] = class NodeError extends Base {
  13803. constructor () {
  13804. super()
  13805. Object.defineProperty(this, 'message', {
  13806. value: getMessage.apply(this, arguments),
  13807. writable: true,
  13808. configurable: true
  13809. })
  13810. // Add the error code to the name to include it in the stack trace.
  13811. this.name = `${this.name} [${sym}]`
  13812. // Access the stack to generate the error message including the error code
  13813. // from the name.
  13814. this.stack // eslint-disable-line no-unused-expressions
  13815. // Reset the name to the actual name.
  13816. delete this.name
  13817. }
  13818. get code () {
  13819. return sym
  13820. }
  13821. set code (value) {
  13822. Object.defineProperty(this, 'code', {
  13823. configurable: true,
  13824. enumerable: true,
  13825. value,
  13826. writable: true
  13827. })
  13828. }
  13829. toString () {
  13830. return `${this.name} [${sym}]: ${this.message}`
  13831. }
  13832. }
  13833. }
  13834. E('ERR_BUFFER_OUT_OF_BOUNDS',
  13835. function (name) {
  13836. if (name) {
  13837. return `${name} is outside of buffer bounds`
  13838. }
  13839. return 'Attempt to access memory outside buffer bounds'
  13840. }, RangeError)
  13841. E('ERR_INVALID_ARG_TYPE',
  13842. function (name, actual) {
  13843. return `The "${name}" argument must be of type number. Received type ${typeof actual}`
  13844. }, TypeError)
  13845. E('ERR_OUT_OF_RANGE',
  13846. function (str, range, input) {
  13847. let msg = `The value of "${str}" is out of range.`
  13848. let received = input
  13849. if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
  13850. received = addNumericalSeparator(String(input))
  13851. } else if (typeof input === 'bigint') {
  13852. received = String(input)
  13853. if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
  13854. received = addNumericalSeparator(received)
  13855. }
  13856. received += 'n'
  13857. }
  13858. msg += ` It must be ${range}. Received ${received}`
  13859. return msg
  13860. }, RangeError)
  13861. function addNumericalSeparator (val) {
  13862. let res = ''
  13863. let i = val.length
  13864. const start = val[0] === '-' ? 1 : 0
  13865. for (; i >= start + 4; i -= 3) {
  13866. res = `_${val.slice(i - 3, i)}${res}`
  13867. }
  13868. return `${val.slice(0, i)}${res}`
  13869. }
  13870. // CHECK FUNCTIONS
  13871. // ===============
  13872. function checkBounds (buf, offset, byteLength) {
  13873. validateNumber(offset, 'offset')
  13874. if (buf[offset] === undefined || buf[offset + byteLength] === undefined) {
  13875. boundsError(offset, buf.length - (byteLength + 1))
  13876. }
  13877. }
  13878. function checkIntBI (value, min, max, buf, offset, byteLength) {
  13879. if (value > max || value < min) {
  13880. const n = typeof min === 'bigint' ? 'n' : ''
  13881. let range
  13882. if (byteLength > 3) {
  13883. if (min === 0 || min === BigInt(0)) {
  13884. range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`
  13885. } else {
  13886. range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` +
  13887. `${(byteLength + 1) * 8 - 1}${n}`
  13888. }
  13889. } else {
  13890. range = `>= ${min}${n} and <= ${max}${n}`
  13891. }
  13892. throw new errors.ERR_OUT_OF_RANGE('value', range, value)
  13893. }
  13894. checkBounds(buf, offset, byteLength)
  13895. }
  13896. function validateNumber (value, name) {
  13897. if (typeof value !== 'number') {
  13898. throw new errors.ERR_INVALID_ARG_TYPE(name, 'number', value)
  13899. }
  13900. }
  13901. function boundsError (value, length, type) {
  13902. if (Math.floor(value) !== value) {
  13903. validateNumber(value, type)
  13904. throw new errors.ERR_OUT_OF_RANGE(type || 'offset', 'an integer', value)
  13905. }
  13906. if (length < 0) {
  13907. throw new errors.ERR_BUFFER_OUT_OF_BOUNDS()
  13908. }
  13909. throw new errors.ERR_OUT_OF_RANGE(type || 'offset',
  13910. `>= ${type ? 1 : 0} and <= ${length}`,
  13911. value)
  13912. }
  13913. // HELPER FUNCTIONS
  13914. // ================
  13915. const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
  13916. function base64clean (str) {
  13917. // Node takes equal signs as end of the Base64 encoding
  13918. str = str.split('=')[0]
  13919. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  13920. str = str.trim().replace(INVALID_BASE64_RE, '')
  13921. // Node converts strings with length < 2 to ''
  13922. if (str.length < 2) return ''
  13923. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  13924. while (str.length % 4 !== 0) {
  13925. str = str + '='
  13926. }
  13927. return str
  13928. }
  13929. function utf8ToBytes (string, units) {
  13930. units = units || Infinity
  13931. let codePoint
  13932. const length = string.length
  13933. let leadSurrogate = null
  13934. const bytes = []
  13935. for (let i = 0; i < length; ++i) {
  13936. codePoint = string.charCodeAt(i)
  13937. // is surrogate component
  13938. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  13939. // last char was a lead
  13940. if (!leadSurrogate) {
  13941. // no lead yet
  13942. if (codePoint > 0xDBFF) {
  13943. // unexpected trail
  13944. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  13945. continue
  13946. } else if (i + 1 === length) {
  13947. // unpaired lead
  13948. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  13949. continue
  13950. }
  13951. // valid lead
  13952. leadSurrogate = codePoint
  13953. continue
  13954. }
  13955. // 2 leads in a row
  13956. if (codePoint < 0xDC00) {
  13957. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  13958. leadSurrogate = codePoint
  13959. continue
  13960. }
  13961. // valid surrogate pair
  13962. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  13963. } else if (leadSurrogate) {
  13964. // valid bmp char, but last char was a lead
  13965. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  13966. }
  13967. leadSurrogate = null
  13968. // encode utf8
  13969. if (codePoint < 0x80) {
  13970. if ((units -= 1) < 0) break
  13971. bytes.push(codePoint)
  13972. } else if (codePoint < 0x800) {
  13973. if ((units -= 2) < 0) break
  13974. bytes.push(
  13975. codePoint >> 0x6 | 0xC0,
  13976. codePoint & 0x3F | 0x80
  13977. )
  13978. } else if (codePoint < 0x10000) {
  13979. if ((units -= 3) < 0) break
  13980. bytes.push(
  13981. codePoint >> 0xC | 0xE0,
  13982. codePoint >> 0x6 & 0x3F | 0x80,
  13983. codePoint & 0x3F | 0x80
  13984. )
  13985. } else if (codePoint < 0x110000) {
  13986. if ((units -= 4) < 0) break
  13987. bytes.push(
  13988. codePoint >> 0x12 | 0xF0,
  13989. codePoint >> 0xC & 0x3F | 0x80,
  13990. codePoint >> 0x6 & 0x3F | 0x80,
  13991. codePoint & 0x3F | 0x80
  13992. )
  13993. } else {
  13994. throw new Error('Invalid code point')
  13995. }
  13996. }
  13997. return bytes
  13998. }
  13999. function asciiToBytes (str) {
  14000. const byteArray = []
  14001. for (let i = 0; i < str.length; ++i) {
  14002. // Node's code seems to be doing this and not & 0x7F..
  14003. byteArray.push(str.charCodeAt(i) & 0xFF)
  14004. }
  14005. return byteArray
  14006. }
  14007. function utf16leToBytes (str, units) {
  14008. let c, hi, lo
  14009. const byteArray = []
  14010. for (let i = 0; i < str.length; ++i) {
  14011. if ((units -= 2) < 0) break
  14012. c = str.charCodeAt(i)
  14013. hi = c >> 8
  14014. lo = c % 256
  14015. byteArray.push(lo)
  14016. byteArray.push(hi)
  14017. }
  14018. return byteArray
  14019. }
  14020. function base64ToBytes (str) {
  14021. return base64.toByteArray(base64clean(str))
  14022. }
  14023. function blitBuffer (src, dst, offset, length) {
  14024. let i
  14025. for (i = 0; i < length; ++i) {
  14026. if ((i + offset >= dst.length) || (i >= src.length)) break
  14027. dst[i + offset] = src[i]
  14028. }
  14029. return i
  14030. }
  14031. // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
  14032. // the `instanceof` check but they should be treated as of that type.
  14033. // See: https://github.com/feross/buffer/issues/166
  14034. function isInstance (obj, type) {
  14035. return obj instanceof type ||
  14036. (obj != null && obj.constructor != null && obj.constructor.name != null &&
  14037. obj.constructor.name === type.name)
  14038. }
  14039. function numberIsNaN (obj) {
  14040. // For IE11 support
  14041. return obj !== obj // eslint-disable-line no-self-compare
  14042. }
  14043. // Create lookup table for `toString('hex')`
  14044. // See: https://github.com/feross/buffer/issues/219
  14045. const hexSliceLookupTable = (function () {
  14046. const alphabet = '0123456789abcdef'
  14047. const table = new Array(256)
  14048. for (let i = 0; i < 16; ++i) {
  14049. const i16 = i * 16
  14050. for (let j = 0; j < 16; ++j) {
  14051. table[i16 + j] = alphabet[i] + alphabet[j]
  14052. }
  14053. }
  14054. return table
  14055. })()
  14056. // Return not function with Error if BigInt not supported
  14057. function defineBigIntMethod (fn) {
  14058. return typeof BigInt === 'undefined' ? BufferBigIntNotDefined : fn
  14059. }
  14060. function BufferBigIntNotDefined () {
  14061. throw new Error('BigInt not supported')
  14062. }
  14063. /***/ }),
  14064. /***/ "../../node_modules/builtin-status-codes/browser.js":
  14065. /*!**********************************************************!*\
  14066. !*** ../../node_modules/builtin-status-codes/browser.js ***!
  14067. \**********************************************************/
  14068. /***/ ((module) => {
  14069. module.exports = {
  14070. "100": "Continue",
  14071. "101": "Switching Protocols",
  14072. "102": "Processing",
  14073. "200": "OK",
  14074. "201": "Created",
  14075. "202": "Accepted",
  14076. "203": "Non-Authoritative Information",
  14077. "204": "No Content",
  14078. "205": "Reset Content",
  14079. "206": "Partial Content",
  14080. "207": "Multi-Status",
  14081. "208": "Already Reported",
  14082. "226": "IM Used",
  14083. "300": "Multiple Choices",
  14084. "301": "Moved Permanently",
  14085. "302": "Found",
  14086. "303": "See Other",
  14087. "304": "Not Modified",
  14088. "305": "Use Proxy",
  14089. "307": "Temporary Redirect",
  14090. "308": "Permanent Redirect",
  14091. "400": "Bad Request",
  14092. "401": "Unauthorized",
  14093. "402": "Payment Required",
  14094. "403": "Forbidden",
  14095. "404": "Not Found",
  14096. "405": "Method Not Allowed",
  14097. "406": "Not Acceptable",
  14098. "407": "Proxy Authentication Required",
  14099. "408": "Request Timeout",
  14100. "409": "Conflict",
  14101. "410": "Gone",
  14102. "411": "Length Required",
  14103. "412": "Precondition Failed",
  14104. "413": "Payload Too Large",
  14105. "414": "URI Too Long",
  14106. "415": "Unsupported Media Type",
  14107. "416": "Range Not Satisfiable",
  14108. "417": "Expectation Failed",
  14109. "418": "I'm a teapot",
  14110. "421": "Misdirected Request",
  14111. "422": "Unprocessable Entity",
  14112. "423": "Locked",
  14113. "424": "Failed Dependency",
  14114. "425": "Unordered Collection",
  14115. "426": "Upgrade Required",
  14116. "428": "Precondition Required",
  14117. "429": "Too Many Requests",
  14118. "431": "Request Header Fields Too Large",
  14119. "451": "Unavailable For Legal Reasons",
  14120. "500": "Internal Server Error",
  14121. "501": "Not Implemented",
  14122. "502": "Bad Gateway",
  14123. "503": "Service Unavailable",
  14124. "504": "Gateway Timeout",
  14125. "505": "HTTP Version Not Supported",
  14126. "506": "Variant Also Negotiates",
  14127. "507": "Insufficient Storage",
  14128. "508": "Loop Detected",
  14129. "509": "Bandwidth Limit Exceeded",
  14130. "510": "Not Extended",
  14131. "511": "Network Authentication Required"
  14132. }
  14133. /***/ }),
  14134. /***/ "../../node_modules/call-bind/callBound.js":
  14135. /*!*************************************************!*\
  14136. !*** ../../node_modules/call-bind/callBound.js ***!
  14137. \*************************************************/
  14138. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  14139. "use strict";
  14140. var GetIntrinsic = __webpack_require__(/*! get-intrinsic */ "../../node_modules/get-intrinsic/index.js");
  14141. var callBind = __webpack_require__(/*! ./ */ "../../node_modules/call-bind/index.js");
  14142. var $indexOf = callBind(GetIntrinsic('String.prototype.indexOf'));
  14143. module.exports = function callBoundIntrinsic(name, allowMissing) {
  14144. var intrinsic = GetIntrinsic(name, !!allowMissing);
  14145. if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) {
  14146. return callBind(intrinsic);
  14147. }
  14148. return intrinsic;
  14149. };
  14150. /***/ }),
  14151. /***/ "../../node_modules/call-bind/index.js":
  14152. /*!*********************************************!*\
  14153. !*** ../../node_modules/call-bind/index.js ***!
  14154. \*********************************************/
  14155. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  14156. "use strict";
  14157. var bind = __webpack_require__(/*! function-bind */ "../../node_modules/function-bind/index.js");
  14158. var GetIntrinsic = __webpack_require__(/*! get-intrinsic */ "../../node_modules/get-intrinsic/index.js");
  14159. var $apply = GetIntrinsic('%Function.prototype.apply%');
  14160. var $call = GetIntrinsic('%Function.prototype.call%');
  14161. var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply);
  14162. var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true);
  14163. var $defineProperty = GetIntrinsic('%Object.defineProperty%', true);
  14164. var $max = GetIntrinsic('%Math.max%');
  14165. if ($defineProperty) {
  14166. try {
  14167. $defineProperty({}, 'a', { value: 1 });
  14168. } catch (e) {
  14169. // IE 8 has a broken defineProperty
  14170. $defineProperty = null;
  14171. }
  14172. }
  14173. module.exports = function callBind(originalFunction) {
  14174. var func = $reflectApply(bind, $call, arguments);
  14175. if ($gOPD && $defineProperty) {
  14176. var desc = $gOPD(func, 'length');
  14177. if (desc.configurable) {
  14178. // original length, plus the receiver, minus any additional arguments (after the receiver)
  14179. $defineProperty(
  14180. func,
  14181. 'length',
  14182. { value: 1 + $max(0, originalFunction.length - (arguments.length - 1)) }
  14183. );
  14184. }
  14185. }
  14186. return func;
  14187. };
  14188. var applyBind = function applyBind() {
  14189. return $reflectApply(bind, $apply, arguments);
  14190. };
  14191. if ($defineProperty) {
  14192. $defineProperty(module.exports, 'apply', { value: applyBind });
  14193. } else {
  14194. module.exports.apply = applyBind;
  14195. }
  14196. /***/ }),
  14197. /***/ "../../node_modules/cipher-base/index.js":
  14198. /*!***********************************************!*\
  14199. !*** ../../node_modules/cipher-base/index.js ***!
  14200. \***********************************************/
  14201. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  14202. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  14203. var Transform = (__webpack_require__(/*! stream */ "../../node_modules/stream-browserify/index.js").Transform)
  14204. var StringDecoder = (__webpack_require__(/*! string_decoder */ "../../node_modules/string_decoder/lib/string_decoder.js").StringDecoder)
  14205. var inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js")
  14206. function CipherBase (hashMode) {
  14207. Transform.call(this)
  14208. this.hashMode = typeof hashMode === 'string'
  14209. if (this.hashMode) {
  14210. this[hashMode] = this._finalOrDigest
  14211. } else {
  14212. this.final = this._finalOrDigest
  14213. }
  14214. if (this._final) {
  14215. this.__final = this._final
  14216. this._final = null
  14217. }
  14218. this._decoder = null
  14219. this._encoding = null
  14220. }
  14221. inherits(CipherBase, Transform)
  14222. CipherBase.prototype.update = function (data, inputEnc, outputEnc) {
  14223. if (typeof data === 'string') {
  14224. data = Buffer.from(data, inputEnc)
  14225. }
  14226. var outData = this._update(data)
  14227. if (this.hashMode) return this
  14228. if (outputEnc) {
  14229. outData = this._toString(outData, outputEnc)
  14230. }
  14231. return outData
  14232. }
  14233. CipherBase.prototype.setAutoPadding = function () {}
  14234. CipherBase.prototype.getAuthTag = function () {
  14235. throw new Error('trying to get auth tag in unsupported state')
  14236. }
  14237. CipherBase.prototype.setAuthTag = function () {
  14238. throw new Error('trying to set auth tag in unsupported state')
  14239. }
  14240. CipherBase.prototype.setAAD = function () {
  14241. throw new Error('trying to set aad in unsupported state')
  14242. }
  14243. CipherBase.prototype._transform = function (data, _, next) {
  14244. var err
  14245. try {
  14246. if (this.hashMode) {
  14247. this._update(data)
  14248. } else {
  14249. this.push(this._update(data))
  14250. }
  14251. } catch (e) {
  14252. err = e
  14253. } finally {
  14254. next(err)
  14255. }
  14256. }
  14257. CipherBase.prototype._flush = function (done) {
  14258. var err
  14259. try {
  14260. this.push(this.__final())
  14261. } catch (e) {
  14262. err = e
  14263. }
  14264. done(err)
  14265. }
  14266. CipherBase.prototype._finalOrDigest = function (outputEnc) {
  14267. var outData = this.__final() || Buffer.alloc(0)
  14268. if (outputEnc) {
  14269. outData = this._toString(outData, outputEnc, true)
  14270. }
  14271. return outData
  14272. }
  14273. CipherBase.prototype._toString = function (value, enc, fin) {
  14274. if (!this._decoder) {
  14275. this._decoder = new StringDecoder(enc)
  14276. this._encoding = enc
  14277. }
  14278. if (this._encoding !== enc) throw new Error('can\'t switch encodings')
  14279. var out = this._decoder.write(value)
  14280. if (fin) {
  14281. out += this._decoder.end()
  14282. }
  14283. return out
  14284. }
  14285. module.exports = CipherBase
  14286. /***/ }),
  14287. /***/ "../../node_modules/create-ecdh/browser.js":
  14288. /*!*************************************************!*\
  14289. !*** ../../node_modules/create-ecdh/browser.js ***!
  14290. \*************************************************/
  14291. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  14292. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js")["Buffer"];
  14293. var elliptic = __webpack_require__(/*! elliptic */ "../../node_modules/elliptic/lib/elliptic.js")
  14294. var BN = __webpack_require__(/*! bn.js */ "../../node_modules/diffie-hellman/node_modules/bn.js/lib/bn.js")
  14295. module.exports = function createECDH (curve) {
  14296. return new ECDH(curve)
  14297. }
  14298. var aliases = {
  14299. secp256k1: {
  14300. name: 'secp256k1',
  14301. byteLength: 32
  14302. },
  14303. secp224r1: {
  14304. name: 'p224',
  14305. byteLength: 28
  14306. },
  14307. prime256v1: {
  14308. name: 'p256',
  14309. byteLength: 32
  14310. },
  14311. prime192v1: {
  14312. name: 'p192',
  14313. byteLength: 24
  14314. },
  14315. ed25519: {
  14316. name: 'ed25519',
  14317. byteLength: 32
  14318. },
  14319. secp384r1: {
  14320. name: 'p384',
  14321. byteLength: 48
  14322. },
  14323. secp521r1: {
  14324. name: 'p521',
  14325. byteLength: 66
  14326. }
  14327. }
  14328. aliases.p224 = aliases.secp224r1
  14329. aliases.p256 = aliases.secp256r1 = aliases.prime256v1
  14330. aliases.p192 = aliases.secp192r1 = aliases.prime192v1
  14331. aliases.p384 = aliases.secp384r1
  14332. aliases.p521 = aliases.secp521r1
  14333. function ECDH (curve) {
  14334. this.curveType = aliases[curve]
  14335. if (!this.curveType) {
  14336. this.curveType = {
  14337. name: curve
  14338. }
  14339. }
  14340. this.curve = new elliptic.ec(this.curveType.name) // eslint-disable-line new-cap
  14341. this.keys = void 0
  14342. }
  14343. ECDH.prototype.generateKeys = function (enc, format) {
  14344. this.keys = this.curve.genKeyPair()
  14345. return this.getPublicKey(enc, format)
  14346. }
  14347. ECDH.prototype.computeSecret = function (other, inenc, enc) {
  14348. inenc = inenc || 'utf8'
  14349. if (!Buffer.isBuffer(other)) {
  14350. other = new Buffer(other, inenc)
  14351. }
  14352. var otherPub = this.curve.keyFromPublic(other).getPublic()
  14353. var out = otherPub.mul(this.keys.getPrivate()).getX()
  14354. return formatReturnValue(out, enc, this.curveType.byteLength)
  14355. }
  14356. ECDH.prototype.getPublicKey = function (enc, format) {
  14357. var key = this.keys.getPublic(format === 'compressed', true)
  14358. if (format === 'hybrid') {
  14359. if (key[key.length - 1] % 2) {
  14360. key[0] = 7
  14361. } else {
  14362. key[0] = 6
  14363. }
  14364. }
  14365. return formatReturnValue(key, enc)
  14366. }
  14367. ECDH.prototype.getPrivateKey = function (enc) {
  14368. return formatReturnValue(this.keys.getPrivate(), enc)
  14369. }
  14370. ECDH.prototype.setPublicKey = function (pub, enc) {
  14371. enc = enc || 'utf8'
  14372. if (!Buffer.isBuffer(pub)) {
  14373. pub = new Buffer(pub, enc)
  14374. }
  14375. this.keys._importPublic(pub)
  14376. return this
  14377. }
  14378. ECDH.prototype.setPrivateKey = function (priv, enc) {
  14379. enc = enc || 'utf8'
  14380. if (!Buffer.isBuffer(priv)) {
  14381. priv = new Buffer(priv, enc)
  14382. }
  14383. var _priv = new BN(priv)
  14384. _priv = _priv.toString(16)
  14385. this.keys = this.curve.genKeyPair()
  14386. this.keys._importPrivate(_priv)
  14387. return this
  14388. }
  14389. function formatReturnValue (bn, enc, len) {
  14390. if (!Array.isArray(bn)) {
  14391. bn = bn.toArray()
  14392. }
  14393. var buf = new Buffer(bn)
  14394. if (len && buf.length < len) {
  14395. var zeros = new Buffer(len - buf.length)
  14396. zeros.fill(0)
  14397. buf = Buffer.concat([zeros, buf])
  14398. }
  14399. if (!enc) {
  14400. return buf
  14401. } else {
  14402. return buf.toString(enc)
  14403. }
  14404. }
  14405. /***/ }),
  14406. /***/ "../../node_modules/create-hash/browser.js":
  14407. /*!*************************************************!*\
  14408. !*** ../../node_modules/create-hash/browser.js ***!
  14409. \*************************************************/
  14410. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  14411. "use strict";
  14412. var inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js")
  14413. var MD5 = __webpack_require__(/*! md5.js */ "../../node_modules/md5.js/index.js")
  14414. var RIPEMD160 = __webpack_require__(/*! ripemd160 */ "../../node_modules/ripemd160/index.js")
  14415. var sha = __webpack_require__(/*! sha.js */ "../../node_modules/sha.js/index.js")
  14416. var Base = __webpack_require__(/*! cipher-base */ "../../node_modules/cipher-base/index.js")
  14417. function Hash (hash) {
  14418. Base.call(this, 'digest')
  14419. this._hash = hash
  14420. }
  14421. inherits(Hash, Base)
  14422. Hash.prototype._update = function (data) {
  14423. this._hash.update(data)
  14424. }
  14425. Hash.prototype._final = function () {
  14426. return this._hash.digest()
  14427. }
  14428. module.exports = function createHash (alg) {
  14429. alg = alg.toLowerCase()
  14430. if (alg === 'md5') return new MD5()
  14431. if (alg === 'rmd160' || alg === 'ripemd160') return new RIPEMD160()
  14432. return new Hash(sha(alg))
  14433. }
  14434. /***/ }),
  14435. /***/ "../../node_modules/create-hash/md5.js":
  14436. /*!*********************************************!*\
  14437. !*** ../../node_modules/create-hash/md5.js ***!
  14438. \*********************************************/
  14439. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  14440. var MD5 = __webpack_require__(/*! md5.js */ "../../node_modules/md5.js/index.js")
  14441. module.exports = function (buffer) {
  14442. return new MD5().update(buffer).digest()
  14443. }
  14444. /***/ }),
  14445. /***/ "../../node_modules/create-hmac/browser.js":
  14446. /*!*************************************************!*\
  14447. !*** ../../node_modules/create-hmac/browser.js ***!
  14448. \*************************************************/
  14449. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  14450. "use strict";
  14451. var inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js")
  14452. var Legacy = __webpack_require__(/*! ./legacy */ "../../node_modules/create-hmac/legacy.js")
  14453. var Base = __webpack_require__(/*! cipher-base */ "../../node_modules/cipher-base/index.js")
  14454. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  14455. var md5 = __webpack_require__(/*! create-hash/md5 */ "../../node_modules/create-hash/md5.js")
  14456. var RIPEMD160 = __webpack_require__(/*! ripemd160 */ "../../node_modules/ripemd160/index.js")
  14457. var sha = __webpack_require__(/*! sha.js */ "../../node_modules/sha.js/index.js")
  14458. var ZEROS = Buffer.alloc(128)
  14459. function Hmac (alg, key) {
  14460. Base.call(this, 'digest')
  14461. if (typeof key === 'string') {
  14462. key = Buffer.from(key)
  14463. }
  14464. var blocksize = (alg === 'sha512' || alg === 'sha384') ? 128 : 64
  14465. this._alg = alg
  14466. this._key = key
  14467. if (key.length > blocksize) {
  14468. var hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg)
  14469. key = hash.update(key).digest()
  14470. } else if (key.length < blocksize) {
  14471. key = Buffer.concat([key, ZEROS], blocksize)
  14472. }
  14473. var ipad = this._ipad = Buffer.allocUnsafe(blocksize)
  14474. var opad = this._opad = Buffer.allocUnsafe(blocksize)
  14475. for (var i = 0; i < blocksize; i++) {
  14476. ipad[i] = key[i] ^ 0x36
  14477. opad[i] = key[i] ^ 0x5C
  14478. }
  14479. this._hash = alg === 'rmd160' ? new RIPEMD160() : sha(alg)
  14480. this._hash.update(ipad)
  14481. }
  14482. inherits(Hmac, Base)
  14483. Hmac.prototype._update = function (data) {
  14484. this._hash.update(data)
  14485. }
  14486. Hmac.prototype._final = function () {
  14487. var h = this._hash.digest()
  14488. var hash = this._alg === 'rmd160' ? new RIPEMD160() : sha(this._alg)
  14489. return hash.update(this._opad).update(h).digest()
  14490. }
  14491. module.exports = function createHmac (alg, key) {
  14492. alg = alg.toLowerCase()
  14493. if (alg === 'rmd160' || alg === 'ripemd160') {
  14494. return new Hmac('rmd160', key)
  14495. }
  14496. if (alg === 'md5') {
  14497. return new Legacy(md5, key)
  14498. }
  14499. return new Hmac(alg, key)
  14500. }
  14501. /***/ }),
  14502. /***/ "../../node_modules/create-hmac/legacy.js":
  14503. /*!************************************************!*\
  14504. !*** ../../node_modules/create-hmac/legacy.js ***!
  14505. \************************************************/
  14506. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  14507. "use strict";
  14508. var inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js")
  14509. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  14510. var Base = __webpack_require__(/*! cipher-base */ "../../node_modules/cipher-base/index.js")
  14511. var ZEROS = Buffer.alloc(128)
  14512. var blocksize = 64
  14513. function Hmac (alg, key) {
  14514. Base.call(this, 'digest')
  14515. if (typeof key === 'string') {
  14516. key = Buffer.from(key)
  14517. }
  14518. this._alg = alg
  14519. this._key = key
  14520. if (key.length > blocksize) {
  14521. key = alg(key)
  14522. } else if (key.length < blocksize) {
  14523. key = Buffer.concat([key, ZEROS], blocksize)
  14524. }
  14525. var ipad = this._ipad = Buffer.allocUnsafe(blocksize)
  14526. var opad = this._opad = Buffer.allocUnsafe(blocksize)
  14527. for (var i = 0; i < blocksize; i++) {
  14528. ipad[i] = key[i] ^ 0x36
  14529. opad[i] = key[i] ^ 0x5C
  14530. }
  14531. this._hash = [ipad]
  14532. }
  14533. inherits(Hmac, Base)
  14534. Hmac.prototype._update = function (data) {
  14535. this._hash.push(data)
  14536. }
  14537. Hmac.prototype._final = function () {
  14538. var h = this._alg(Buffer.concat(this._hash))
  14539. return this._alg(Buffer.concat([this._opad, h]))
  14540. }
  14541. module.exports = Hmac
  14542. /***/ }),
  14543. /***/ "../../node_modules/crypto-browserify/index.js":
  14544. /*!*****************************************************!*\
  14545. !*** ../../node_modules/crypto-browserify/index.js ***!
  14546. \*****************************************************/
  14547. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14548. "use strict";
  14549. exports.randomBytes = exports.rng = exports.pseudoRandomBytes = exports.prng = __webpack_require__(/*! randombytes */ "../../node_modules/randombytes/browser.js")
  14550. exports.createHash = exports.Hash = __webpack_require__(/*! create-hash */ "../../node_modules/create-hash/browser.js")
  14551. exports.createHmac = exports.Hmac = __webpack_require__(/*! create-hmac */ "../../node_modules/create-hmac/browser.js")
  14552. var algos = __webpack_require__(/*! browserify-sign/algos */ "../../node_modules/browserify-sign/algos.js")
  14553. var algoKeys = Object.keys(algos)
  14554. var hashes = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160'].concat(algoKeys)
  14555. exports.getHashes = function () {
  14556. return hashes
  14557. }
  14558. var p = __webpack_require__(/*! pbkdf2 */ "../../node_modules/pbkdf2/browser.js")
  14559. exports.pbkdf2 = p.pbkdf2
  14560. exports.pbkdf2Sync = p.pbkdf2Sync
  14561. var aes = __webpack_require__(/*! browserify-cipher */ "../../node_modules/browserify-cipher/browser.js")
  14562. exports.Cipher = aes.Cipher
  14563. exports.createCipher = aes.createCipher
  14564. exports.Cipheriv = aes.Cipheriv
  14565. exports.createCipheriv = aes.createCipheriv
  14566. exports.Decipher = aes.Decipher
  14567. exports.createDecipher = aes.createDecipher
  14568. exports.Decipheriv = aes.Decipheriv
  14569. exports.createDecipheriv = aes.createDecipheriv
  14570. exports.getCiphers = aes.getCiphers
  14571. exports.listCiphers = aes.listCiphers
  14572. var dh = __webpack_require__(/*! diffie-hellman */ "../../node_modules/diffie-hellman/browser.js")
  14573. exports.DiffieHellmanGroup = dh.DiffieHellmanGroup
  14574. exports.createDiffieHellmanGroup = dh.createDiffieHellmanGroup
  14575. exports.getDiffieHellman = dh.getDiffieHellman
  14576. exports.createDiffieHellman = dh.createDiffieHellman
  14577. exports.DiffieHellman = dh.DiffieHellman
  14578. var sign = __webpack_require__(/*! browserify-sign */ "../../node_modules/browserify-sign/browser/index.js")
  14579. exports.createSign = sign.createSign
  14580. exports.Sign = sign.Sign
  14581. exports.createVerify = sign.createVerify
  14582. exports.Verify = sign.Verify
  14583. exports.createECDH = __webpack_require__(/*! create-ecdh */ "../../node_modules/create-ecdh/browser.js")
  14584. var publicEncrypt = __webpack_require__(/*! public-encrypt */ "../../node_modules/public-encrypt/browser.js")
  14585. exports.publicEncrypt = publicEncrypt.publicEncrypt
  14586. exports.privateEncrypt = publicEncrypt.privateEncrypt
  14587. exports.publicDecrypt = publicEncrypt.publicDecrypt
  14588. exports.privateDecrypt = publicEncrypt.privateDecrypt
  14589. // the least I can do is make error messages for the rest of the node.js/crypto api.
  14590. // ;[
  14591. // 'createCredentials'
  14592. // ].forEach(function (name) {
  14593. // exports[name] = function () {
  14594. // throw new Error([
  14595. // 'sorry, ' + name + ' is not implemented yet',
  14596. // 'we accept pull requests',
  14597. // 'https://github.com/crypto-browserify/crypto-browserify'
  14598. // ].join('\n'))
  14599. // }
  14600. // })
  14601. var rf = __webpack_require__(/*! randomfill */ "../../node_modules/randomfill/browser.js")
  14602. exports.randomFill = rf.randomFill
  14603. exports.randomFillSync = rf.randomFillSync
  14604. exports.createCredentials = function () {
  14605. throw new Error([
  14606. 'sorry, createCredentials is not implemented yet',
  14607. 'we accept pull requests',
  14608. 'https://github.com/crypto-browserify/crypto-browserify'
  14609. ].join('\n'))
  14610. }
  14611. exports.constants = {
  14612. 'DH_CHECK_P_NOT_SAFE_PRIME': 2,
  14613. 'DH_CHECK_P_NOT_PRIME': 1,
  14614. 'DH_UNABLE_TO_CHECK_GENERATOR': 4,
  14615. 'DH_NOT_SUITABLE_GENERATOR': 8,
  14616. 'NPN_ENABLED': 1,
  14617. 'ALPN_ENABLED': 1,
  14618. 'RSA_PKCS1_PADDING': 1,
  14619. 'RSA_SSLV23_PADDING': 2,
  14620. 'RSA_NO_PADDING': 3,
  14621. 'RSA_PKCS1_OAEP_PADDING': 4,
  14622. 'RSA_X931_PADDING': 5,
  14623. 'RSA_PKCS1_PSS_PADDING': 6,
  14624. 'POINT_CONVERSION_COMPRESSED': 2,
  14625. 'POINT_CONVERSION_UNCOMPRESSED': 4,
  14626. 'POINT_CONVERSION_HYBRID': 6
  14627. }
  14628. /***/ }),
  14629. /***/ "../../node_modules/decimal.js/decimal.js":
  14630. /*!************************************************!*\
  14631. !*** ../../node_modules/decimal.js/decimal.js ***!
  14632. \************************************************/
  14633. /***/ (function(module, exports, __webpack_require__) {
  14634. var __WEBPACK_AMD_DEFINE_RESULT__;;(function (globalScope) {
  14635. 'use strict';
  14636. /*!
  14637. * decimal.js v10.4.3
  14638. * An arbitrary-precision Decimal type for JavaScript.
  14639. * https://github.com/MikeMcl/decimal.js
  14640. * Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com>
  14641. * MIT Licence
  14642. */
  14643. // ----------------------------------- EDITABLE DEFAULTS ------------------------------------ //
  14644. // The maximum exponent magnitude.
  14645. // The limit on the value of `toExpNeg`, `toExpPos`, `minE` and `maxE`.
  14646. var EXP_LIMIT = 9e15, // 0 to 9e15
  14647. // The limit on the value of `precision`, and on the value of the first argument to
  14648. // `toDecimalPlaces`, `toExponential`, `toFixed`, `toPrecision` and `toSignificantDigits`.
  14649. MAX_DIGITS = 1e9, // 0 to 1e9
  14650. // Base conversion alphabet.
  14651. NUMERALS = '0123456789abcdef',
  14652. // The natural logarithm of 10 (1025 digits).
  14653. LN10 = '2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058',
  14654. // Pi (1025 digits).
  14655. PI = '3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789',
  14656. // The initial configuration properties of the Decimal constructor.
  14657. DEFAULTS = {
  14658. // These values must be integers within the stated ranges (inclusive).
  14659. // Most of these values can be changed at run-time using the `Decimal.config` method.
  14660. // The maximum number of significant digits of the result of a calculation or base conversion.
  14661. // E.g. `Decimal.config({ precision: 20 });`
  14662. precision: 20, // 1 to MAX_DIGITS
  14663. // The rounding mode used when rounding to `precision`.
  14664. //
  14665. // ROUND_UP 0 Away from zero.
  14666. // ROUND_DOWN 1 Towards zero.
  14667. // ROUND_CEIL 2 Towards +Infinity.
  14668. // ROUND_FLOOR 3 Towards -Infinity.
  14669. // ROUND_HALF_UP 4 Towards nearest neighbour. If equidistant, up.
  14670. // ROUND_HALF_DOWN 5 Towards nearest neighbour. If equidistant, down.
  14671. // ROUND_HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour.
  14672. // ROUND_HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity.
  14673. // ROUND_HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
  14674. //
  14675. // E.g.
  14676. // `Decimal.rounding = 4;`
  14677. // `Decimal.rounding = Decimal.ROUND_HALF_UP;`
  14678. rounding: 4, // 0 to 8
  14679. // The modulo mode used when calculating the modulus: a mod n.
  14680. // The quotient (q = a / n) is calculated according to the corresponding rounding mode.
  14681. // The remainder (r) is calculated as: r = a - n * q.
  14682. //
  14683. // UP 0 The remainder is positive if the dividend is negative, else is negative.
  14684. // DOWN 1 The remainder has the same sign as the dividend (JavaScript %).
  14685. // FLOOR 3 The remainder has the same sign as the divisor (Python %).
  14686. // HALF_EVEN 6 The IEEE 754 remainder function.
  14687. // EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)). Always positive.
  14688. //
  14689. // Truncated division (1), floored division (3), the IEEE 754 remainder (6), and Euclidian
  14690. // division (9) are commonly used for the modulus operation. The other rounding modes can also
  14691. // be used, but they may not give useful results.
  14692. modulo: 1, // 0 to 9
  14693. // The exponent value at and beneath which `toString` returns exponential notation.
  14694. // JavaScript numbers: -7
  14695. toExpNeg: -7, // 0 to -EXP_LIMIT
  14696. // The exponent value at and above which `toString` returns exponential notation.
  14697. // JavaScript numbers: 21
  14698. toExpPos: 21, // 0 to EXP_LIMIT
  14699. // The minimum exponent value, beneath which underflow to zero occurs.
  14700. // JavaScript numbers: -324 (5e-324)
  14701. minE: -EXP_LIMIT, // -1 to -EXP_LIMIT
  14702. // The maximum exponent value, above which overflow to Infinity occurs.
  14703. // JavaScript numbers: 308 (1.7976931348623157e+308)
  14704. maxE: EXP_LIMIT, // 1 to EXP_LIMIT
  14705. // Whether to use cryptographically-secure random number generation, if available.
  14706. crypto: false // true/false
  14707. },
  14708. // ----------------------------------- END OF EDITABLE DEFAULTS ------------------------------- //
  14709. Decimal, inexact, noConflict, quadrant,
  14710. external = true,
  14711. decimalError = '[DecimalError] ',
  14712. invalidArgument = decimalError + 'Invalid argument: ',
  14713. precisionLimitExceeded = decimalError + 'Precision limit exceeded',
  14714. cryptoUnavailable = decimalError + 'crypto unavailable',
  14715. tag = '[object Decimal]',
  14716. mathfloor = Math.floor,
  14717. mathpow = Math.pow,
  14718. isBinary = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,
  14719. isHex = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,
  14720. isOctal = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,
  14721. isDecimal = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,
  14722. BASE = 1e7,
  14723. LOG_BASE = 7,
  14724. MAX_SAFE_INTEGER = 9007199254740991,
  14725. LN10_PRECISION = LN10.length - 1,
  14726. PI_PRECISION = PI.length - 1,
  14727. // Decimal.prototype object
  14728. P = { toStringTag: tag };
  14729. // Decimal prototype methods
  14730. /*
  14731. * absoluteValue abs
  14732. * ceil
  14733. * clampedTo clamp
  14734. * comparedTo cmp
  14735. * cosine cos
  14736. * cubeRoot cbrt
  14737. * decimalPlaces dp
  14738. * dividedBy div
  14739. * dividedToIntegerBy divToInt
  14740. * equals eq
  14741. * floor
  14742. * greaterThan gt
  14743. * greaterThanOrEqualTo gte
  14744. * hyperbolicCosine cosh
  14745. * hyperbolicSine sinh
  14746. * hyperbolicTangent tanh
  14747. * inverseCosine acos
  14748. * inverseHyperbolicCosine acosh
  14749. * inverseHyperbolicSine asinh
  14750. * inverseHyperbolicTangent atanh
  14751. * inverseSine asin
  14752. * inverseTangent atan
  14753. * isFinite
  14754. * isInteger isInt
  14755. * isNaN
  14756. * isNegative isNeg
  14757. * isPositive isPos
  14758. * isZero
  14759. * lessThan lt
  14760. * lessThanOrEqualTo lte
  14761. * logarithm log
  14762. * [maximum] [max]
  14763. * [minimum] [min]
  14764. * minus sub
  14765. * modulo mod
  14766. * naturalExponential exp
  14767. * naturalLogarithm ln
  14768. * negated neg
  14769. * plus add
  14770. * precision sd
  14771. * round
  14772. * sine sin
  14773. * squareRoot sqrt
  14774. * tangent tan
  14775. * times mul
  14776. * toBinary
  14777. * toDecimalPlaces toDP
  14778. * toExponential
  14779. * toFixed
  14780. * toFraction
  14781. * toHexadecimal toHex
  14782. * toNearest
  14783. * toNumber
  14784. * toOctal
  14785. * toPower pow
  14786. * toPrecision
  14787. * toSignificantDigits toSD
  14788. * toString
  14789. * truncated trunc
  14790. * valueOf toJSON
  14791. */
  14792. /*
  14793. * Return a new Decimal whose value is the absolute value of this Decimal.
  14794. *
  14795. */
  14796. P.absoluteValue = P.abs = function () {
  14797. var x = new this.constructor(this);
  14798. if (x.s < 0) x.s = 1;
  14799. return finalise(x);
  14800. };
  14801. /*
  14802. * Return a new Decimal whose value is the value of this Decimal rounded to a whole number in the
  14803. * direction of positive Infinity.
  14804. *
  14805. */
  14806. P.ceil = function () {
  14807. return finalise(new this.constructor(this), this.e + 1, 2);
  14808. };
  14809. /*
  14810. * Return a new Decimal whose value is the value of this Decimal clamped to the range
  14811. * delineated by `min` and `max`.
  14812. *
  14813. * min {number|string|Decimal}
  14814. * max {number|string|Decimal}
  14815. *
  14816. */
  14817. P.clampedTo = P.clamp = function (min, max) {
  14818. var k,
  14819. x = this,
  14820. Ctor = x.constructor;
  14821. min = new Ctor(min);
  14822. max = new Ctor(max);
  14823. if (!min.s || !max.s) return new Ctor(NaN);
  14824. if (min.gt(max)) throw Error(invalidArgument + max);
  14825. k = x.cmp(min);
  14826. return k < 0 ? min : x.cmp(max) > 0 ? max : new Ctor(x);
  14827. };
  14828. /*
  14829. * Return
  14830. * 1 if the value of this Decimal is greater than the value of `y`,
  14831. * -1 if the value of this Decimal is less than the value of `y`,
  14832. * 0 if they have the same value,
  14833. * NaN if the value of either Decimal is NaN.
  14834. *
  14835. */
  14836. P.comparedTo = P.cmp = function (y) {
  14837. var i, j, xdL, ydL,
  14838. x = this,
  14839. xd = x.d,
  14840. yd = (y = new x.constructor(y)).d,
  14841. xs = x.s,
  14842. ys = y.s;
  14843. // Either NaN or ±Infinity?
  14844. if (!xd || !yd) {
  14845. return !xs || !ys ? NaN : xs !== ys ? xs : xd === yd ? 0 : !xd ^ xs < 0 ? 1 : -1;
  14846. }
  14847. // Either zero?
  14848. if (!xd[0] || !yd[0]) return xd[0] ? xs : yd[0] ? -ys : 0;
  14849. // Signs differ?
  14850. if (xs !== ys) return xs;
  14851. // Compare exponents.
  14852. if (x.e !== y.e) return x.e > y.e ^ xs < 0 ? 1 : -1;
  14853. xdL = xd.length;
  14854. ydL = yd.length;
  14855. // Compare digit by digit.
  14856. for (i = 0, j = xdL < ydL ? xdL : ydL; i < j; ++i) {
  14857. if (xd[i] !== yd[i]) return xd[i] > yd[i] ^ xs < 0 ? 1 : -1;
  14858. }
  14859. // Compare lengths.
  14860. return xdL === ydL ? 0 : xdL > ydL ^ xs < 0 ? 1 : -1;
  14861. };
  14862. /*
  14863. * Return a new Decimal whose value is the cosine of the value in radians of this Decimal.
  14864. *
  14865. * Domain: [-Infinity, Infinity]
  14866. * Range: [-1, 1]
  14867. *
  14868. * cos(0) = 1
  14869. * cos(-0) = 1
  14870. * cos(Infinity) = NaN
  14871. * cos(-Infinity) = NaN
  14872. * cos(NaN) = NaN
  14873. *
  14874. */
  14875. P.cosine = P.cos = function () {
  14876. var pr, rm,
  14877. x = this,
  14878. Ctor = x.constructor;
  14879. if (!x.d) return new Ctor(NaN);
  14880. // cos(0) = cos(-0) = 1
  14881. if (!x.d[0]) return new Ctor(1);
  14882. pr = Ctor.precision;
  14883. rm = Ctor.rounding;
  14884. Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
  14885. Ctor.rounding = 1;
  14886. x = cosine(Ctor, toLessThanHalfPi(Ctor, x));
  14887. Ctor.precision = pr;
  14888. Ctor.rounding = rm;
  14889. return finalise(quadrant == 2 || quadrant == 3 ? x.neg() : x, pr, rm, true);
  14890. };
  14891. /*
  14892. *
  14893. * Return a new Decimal whose value is the cube root of the value of this Decimal, rounded to
  14894. * `precision` significant digits using rounding mode `rounding`.
  14895. *
  14896. * cbrt(0) = 0
  14897. * cbrt(-0) = -0
  14898. * cbrt(1) = 1
  14899. * cbrt(-1) = -1
  14900. * cbrt(N) = N
  14901. * cbrt(-I) = -I
  14902. * cbrt(I) = I
  14903. *
  14904. * Math.cbrt(x) = (x < 0 ? -Math.pow(-x, 1/3) : Math.pow(x, 1/3))
  14905. *
  14906. */
  14907. P.cubeRoot = P.cbrt = function () {
  14908. var e, m, n, r, rep, s, sd, t, t3, t3plusx,
  14909. x = this,
  14910. Ctor = x.constructor;
  14911. if (!x.isFinite() || x.isZero()) return new Ctor(x);
  14912. external = false;
  14913. // Initial estimate.
  14914. s = x.s * mathpow(x.s * x, 1 / 3);
  14915. // Math.cbrt underflow/overflow?
  14916. // Pass x to Math.pow as integer, then adjust the exponent of the result.
  14917. if (!s || Math.abs(s) == 1 / 0) {
  14918. n = digitsToString(x.d);
  14919. e = x.e;
  14920. // Adjust n exponent so it is a multiple of 3 away from x exponent.
  14921. if (s = (e - n.length + 1) % 3) n += (s == 1 || s == -2 ? '0' : '00');
  14922. s = mathpow(n, 1 / 3);
  14923. // Rarely, e may be one less than the result exponent value.
  14924. e = mathfloor((e + 1) / 3) - (e % 3 == (e < 0 ? -1 : 2));
  14925. if (s == 1 / 0) {
  14926. n = '5e' + e;
  14927. } else {
  14928. n = s.toExponential();
  14929. n = n.slice(0, n.indexOf('e') + 1) + e;
  14930. }
  14931. r = new Ctor(n);
  14932. r.s = x.s;
  14933. } else {
  14934. r = new Ctor(s.toString());
  14935. }
  14936. sd = (e = Ctor.precision) + 3;
  14937. // Halley's method.
  14938. // TODO? Compare Newton's method.
  14939. for (;;) {
  14940. t = r;
  14941. t3 = t.times(t).times(t);
  14942. t3plusx = t3.plus(x);
  14943. r = divide(t3plusx.plus(x).times(t), t3plusx.plus(t3), sd + 2, 1);
  14944. // TODO? Replace with for-loop and checkRoundingDigits.
  14945. if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
  14946. n = n.slice(sd - 3, sd + 1);
  14947. // The 4th rounding digit may be in error by -1 so if the 4 rounding digits are 9999 or 4999
  14948. // , i.e. approaching a rounding boundary, continue the iteration.
  14949. if (n == '9999' || !rep && n == '4999') {
  14950. // On the first iteration only, check to see if rounding up gives the exact result as the
  14951. // nines may infinitely repeat.
  14952. if (!rep) {
  14953. finalise(t, e + 1, 0);
  14954. if (t.times(t).times(t).eq(x)) {
  14955. r = t;
  14956. break;
  14957. }
  14958. }
  14959. sd += 4;
  14960. rep = 1;
  14961. } else {
  14962. // If the rounding digits are null, 0{0,4} or 50{0,3}, check for an exact result.
  14963. // If not, then there are further digits and m will be truthy.
  14964. if (!+n || !+n.slice(1) && n.charAt(0) == '5') {
  14965. // Truncate to the first rounding digit.
  14966. finalise(r, e + 1, 1);
  14967. m = !r.times(r).times(r).eq(x);
  14968. }
  14969. break;
  14970. }
  14971. }
  14972. }
  14973. external = true;
  14974. return finalise(r, e, Ctor.rounding, m);
  14975. };
  14976. /*
  14977. * Return the number of decimal places of the value of this Decimal.
  14978. *
  14979. */
  14980. P.decimalPlaces = P.dp = function () {
  14981. var w,
  14982. d = this.d,
  14983. n = NaN;
  14984. if (d) {
  14985. w = d.length - 1;
  14986. n = (w - mathfloor(this.e / LOG_BASE)) * LOG_BASE;
  14987. // Subtract the number of trailing zeros of the last word.
  14988. w = d[w];
  14989. if (w) for (; w % 10 == 0; w /= 10) n--;
  14990. if (n < 0) n = 0;
  14991. }
  14992. return n;
  14993. };
  14994. /*
  14995. * n / 0 = I
  14996. * n / N = N
  14997. * n / I = 0
  14998. * 0 / n = 0
  14999. * 0 / 0 = N
  15000. * 0 / N = N
  15001. * 0 / I = 0
  15002. * N / n = N
  15003. * N / 0 = N
  15004. * N / N = N
  15005. * N / I = N
  15006. * I / n = I
  15007. * I / 0 = I
  15008. * I / N = N
  15009. * I / I = N
  15010. *
  15011. * Return a new Decimal whose value is the value of this Decimal divided by `y`, rounded to
  15012. * `precision` significant digits using rounding mode `rounding`.
  15013. *
  15014. */
  15015. P.dividedBy = P.div = function (y) {
  15016. return divide(this, new this.constructor(y));
  15017. };
  15018. /*
  15019. * Return a new Decimal whose value is the integer part of dividing the value of this Decimal
  15020. * by the value of `y`, rounded to `precision` significant digits using rounding mode `rounding`.
  15021. *
  15022. */
  15023. P.dividedToIntegerBy = P.divToInt = function (y) {
  15024. var x = this,
  15025. Ctor = x.constructor;
  15026. return finalise(divide(x, new Ctor(y), 0, 1, 1), Ctor.precision, Ctor.rounding);
  15027. };
  15028. /*
  15029. * Return true if the value of this Decimal is equal to the value of `y`, otherwise return false.
  15030. *
  15031. */
  15032. P.equals = P.eq = function (y) {
  15033. return this.cmp(y) === 0;
  15034. };
  15035. /*
  15036. * Return a new Decimal whose value is the value of this Decimal rounded to a whole number in the
  15037. * direction of negative Infinity.
  15038. *
  15039. */
  15040. P.floor = function () {
  15041. return finalise(new this.constructor(this), this.e + 1, 3);
  15042. };
  15043. /*
  15044. * Return true if the value of this Decimal is greater than the value of `y`, otherwise return
  15045. * false.
  15046. *
  15047. */
  15048. P.greaterThan = P.gt = function (y) {
  15049. return this.cmp(y) > 0;
  15050. };
  15051. /*
  15052. * Return true if the value of this Decimal is greater than or equal to the value of `y`,
  15053. * otherwise return false.
  15054. *
  15055. */
  15056. P.greaterThanOrEqualTo = P.gte = function (y) {
  15057. var k = this.cmp(y);
  15058. return k == 1 || k === 0;
  15059. };
  15060. /*
  15061. * Return a new Decimal whose value is the hyperbolic cosine of the value in radians of this
  15062. * Decimal.
  15063. *
  15064. * Domain: [-Infinity, Infinity]
  15065. * Range: [1, Infinity]
  15066. *
  15067. * cosh(x) = 1 + x^2/2! + x^4/4! + x^6/6! + ...
  15068. *
  15069. * cosh(0) = 1
  15070. * cosh(-0) = 1
  15071. * cosh(Infinity) = Infinity
  15072. * cosh(-Infinity) = Infinity
  15073. * cosh(NaN) = NaN
  15074. *
  15075. * x time taken (ms) result
  15076. * 1000 9 9.8503555700852349694e+433
  15077. * 10000 25 4.4034091128314607936e+4342
  15078. * 100000 171 1.4033316802130615897e+43429
  15079. * 1000000 3817 1.5166076984010437725e+434294
  15080. * 10000000 abandoned after 2 minute wait
  15081. *
  15082. * TODO? Compare performance of cosh(x) = 0.5 * (exp(x) + exp(-x))
  15083. *
  15084. */
  15085. P.hyperbolicCosine = P.cosh = function () {
  15086. var k, n, pr, rm, len,
  15087. x = this,
  15088. Ctor = x.constructor,
  15089. one = new Ctor(1);
  15090. if (!x.isFinite()) return new Ctor(x.s ? 1 / 0 : NaN);
  15091. if (x.isZero()) return one;
  15092. pr = Ctor.precision;
  15093. rm = Ctor.rounding;
  15094. Ctor.precision = pr + Math.max(x.e, x.sd()) + 4;
  15095. Ctor.rounding = 1;
  15096. len = x.d.length;
  15097. // Argument reduction: cos(4x) = 1 - 8cos^2(x) + 8cos^4(x) + 1
  15098. // i.e. cos(x) = 1 - cos^2(x/4)(8 - 8cos^2(x/4))
  15099. // Estimate the optimum number of times to use the argument reduction.
  15100. // TODO? Estimation reused from cosine() and may not be optimal here.
  15101. if (len < 32) {
  15102. k = Math.ceil(len / 3);
  15103. n = (1 / tinyPow(4, k)).toString();
  15104. } else {
  15105. k = 16;
  15106. n = '2.3283064365386962890625e-10';
  15107. }
  15108. x = taylorSeries(Ctor, 1, x.times(n), new Ctor(1), true);
  15109. // Reverse argument reduction
  15110. var cosh2_x,
  15111. i = k,
  15112. d8 = new Ctor(8);
  15113. for (; i--;) {
  15114. cosh2_x = x.times(x);
  15115. x = one.minus(cosh2_x.times(d8.minus(cosh2_x.times(d8))));
  15116. }
  15117. return finalise(x, Ctor.precision = pr, Ctor.rounding = rm, true);
  15118. };
  15119. /*
  15120. * Return a new Decimal whose value is the hyperbolic sine of the value in radians of this
  15121. * Decimal.
  15122. *
  15123. * Domain: [-Infinity, Infinity]
  15124. * Range: [-Infinity, Infinity]
  15125. *
  15126. * sinh(x) = x + x^3/3! + x^5/5! + x^7/7! + ...
  15127. *
  15128. * sinh(0) = 0
  15129. * sinh(-0) = -0
  15130. * sinh(Infinity) = Infinity
  15131. * sinh(-Infinity) = -Infinity
  15132. * sinh(NaN) = NaN
  15133. *
  15134. * x time taken (ms)
  15135. * 10 2 ms
  15136. * 100 5 ms
  15137. * 1000 14 ms
  15138. * 10000 82 ms
  15139. * 100000 886 ms 1.4033316802130615897e+43429
  15140. * 200000 2613 ms
  15141. * 300000 5407 ms
  15142. * 400000 8824 ms
  15143. * 500000 13026 ms 8.7080643612718084129e+217146
  15144. * 1000000 48543 ms
  15145. *
  15146. * TODO? Compare performance of sinh(x) = 0.5 * (exp(x) - exp(-x))
  15147. *
  15148. */
  15149. P.hyperbolicSine = P.sinh = function () {
  15150. var k, pr, rm, len,
  15151. x = this,
  15152. Ctor = x.constructor;
  15153. if (!x.isFinite() || x.isZero()) return new Ctor(x);
  15154. pr = Ctor.precision;
  15155. rm = Ctor.rounding;
  15156. Ctor.precision = pr + Math.max(x.e, x.sd()) + 4;
  15157. Ctor.rounding = 1;
  15158. len = x.d.length;
  15159. if (len < 3) {
  15160. x = taylorSeries(Ctor, 2, x, x, true);
  15161. } else {
  15162. // Alternative argument reduction: sinh(3x) = sinh(x)(3 + 4sinh^2(x))
  15163. // i.e. sinh(x) = sinh(x/3)(3 + 4sinh^2(x/3))
  15164. // 3 multiplications and 1 addition
  15165. // Argument reduction: sinh(5x) = sinh(x)(5 + sinh^2(x)(20 + 16sinh^2(x)))
  15166. // i.e. sinh(x) = sinh(x/5)(5 + sinh^2(x/5)(20 + 16sinh^2(x/5)))
  15167. // 4 multiplications and 2 additions
  15168. // Estimate the optimum number of times to use the argument reduction.
  15169. k = 1.4 * Math.sqrt(len);
  15170. k = k > 16 ? 16 : k | 0;
  15171. x = x.times(1 / tinyPow(5, k));
  15172. x = taylorSeries(Ctor, 2, x, x, true);
  15173. // Reverse argument reduction
  15174. var sinh2_x,
  15175. d5 = new Ctor(5),
  15176. d16 = new Ctor(16),
  15177. d20 = new Ctor(20);
  15178. for (; k--;) {
  15179. sinh2_x = x.times(x);
  15180. x = x.times(d5.plus(sinh2_x.times(d16.times(sinh2_x).plus(d20))));
  15181. }
  15182. }
  15183. Ctor.precision = pr;
  15184. Ctor.rounding = rm;
  15185. return finalise(x, pr, rm, true);
  15186. };
  15187. /*
  15188. * Return a new Decimal whose value is the hyperbolic tangent of the value in radians of this
  15189. * Decimal.
  15190. *
  15191. * Domain: [-Infinity, Infinity]
  15192. * Range: [-1, 1]
  15193. *
  15194. * tanh(x) = sinh(x) / cosh(x)
  15195. *
  15196. * tanh(0) = 0
  15197. * tanh(-0) = -0
  15198. * tanh(Infinity) = 1
  15199. * tanh(-Infinity) = -1
  15200. * tanh(NaN) = NaN
  15201. *
  15202. */
  15203. P.hyperbolicTangent = P.tanh = function () {
  15204. var pr, rm,
  15205. x = this,
  15206. Ctor = x.constructor;
  15207. if (!x.isFinite()) return new Ctor(x.s);
  15208. if (x.isZero()) return new Ctor(x);
  15209. pr = Ctor.precision;
  15210. rm = Ctor.rounding;
  15211. Ctor.precision = pr + 7;
  15212. Ctor.rounding = 1;
  15213. return divide(x.sinh(), x.cosh(), Ctor.precision = pr, Ctor.rounding = rm);
  15214. };
  15215. /*
  15216. * Return a new Decimal whose value is the arccosine (inverse cosine) in radians of the value of
  15217. * this Decimal.
  15218. *
  15219. * Domain: [-1, 1]
  15220. * Range: [0, pi]
  15221. *
  15222. * acos(x) = pi/2 - asin(x)
  15223. *
  15224. * acos(0) = pi/2
  15225. * acos(-0) = pi/2
  15226. * acos(1) = 0
  15227. * acos(-1) = pi
  15228. * acos(1/2) = pi/3
  15229. * acos(-1/2) = 2*pi/3
  15230. * acos(|x| > 1) = NaN
  15231. * acos(NaN) = NaN
  15232. *
  15233. */
  15234. P.inverseCosine = P.acos = function () {
  15235. var halfPi,
  15236. x = this,
  15237. Ctor = x.constructor,
  15238. k = x.abs().cmp(1),
  15239. pr = Ctor.precision,
  15240. rm = Ctor.rounding;
  15241. if (k !== -1) {
  15242. return k === 0
  15243. // |x| is 1
  15244. ? x.isNeg() ? getPi(Ctor, pr, rm) : new Ctor(0)
  15245. // |x| > 1 or x is NaN
  15246. : new Ctor(NaN);
  15247. }
  15248. if (x.isZero()) return getPi(Ctor, pr + 4, rm).times(0.5);
  15249. // TODO? Special case acos(0.5) = pi/3 and acos(-0.5) = 2*pi/3
  15250. Ctor.precision = pr + 6;
  15251. Ctor.rounding = 1;
  15252. x = x.asin();
  15253. halfPi = getPi(Ctor, pr + 4, rm).times(0.5);
  15254. Ctor.precision = pr;
  15255. Ctor.rounding = rm;
  15256. return halfPi.minus(x);
  15257. };
  15258. /*
  15259. * Return a new Decimal whose value is the inverse of the hyperbolic cosine in radians of the
  15260. * value of this Decimal.
  15261. *
  15262. * Domain: [1, Infinity]
  15263. * Range: [0, Infinity]
  15264. *
  15265. * acosh(x) = ln(x + sqrt(x^2 - 1))
  15266. *
  15267. * acosh(x < 1) = NaN
  15268. * acosh(NaN) = NaN
  15269. * acosh(Infinity) = Infinity
  15270. * acosh(-Infinity) = NaN
  15271. * acosh(0) = NaN
  15272. * acosh(-0) = NaN
  15273. * acosh(1) = 0
  15274. * acosh(-1) = NaN
  15275. *
  15276. */
  15277. P.inverseHyperbolicCosine = P.acosh = function () {
  15278. var pr, rm,
  15279. x = this,
  15280. Ctor = x.constructor;
  15281. if (x.lte(1)) return new Ctor(x.eq(1) ? 0 : NaN);
  15282. if (!x.isFinite()) return new Ctor(x);
  15283. pr = Ctor.precision;
  15284. rm = Ctor.rounding;
  15285. Ctor.precision = pr + Math.max(Math.abs(x.e), x.sd()) + 4;
  15286. Ctor.rounding = 1;
  15287. external = false;
  15288. x = x.times(x).minus(1).sqrt().plus(x);
  15289. external = true;
  15290. Ctor.precision = pr;
  15291. Ctor.rounding = rm;
  15292. return x.ln();
  15293. };
  15294. /*
  15295. * Return a new Decimal whose value is the inverse of the hyperbolic sine in radians of the value
  15296. * of this Decimal.
  15297. *
  15298. * Domain: [-Infinity, Infinity]
  15299. * Range: [-Infinity, Infinity]
  15300. *
  15301. * asinh(x) = ln(x + sqrt(x^2 + 1))
  15302. *
  15303. * asinh(NaN) = NaN
  15304. * asinh(Infinity) = Infinity
  15305. * asinh(-Infinity) = -Infinity
  15306. * asinh(0) = 0
  15307. * asinh(-0) = -0
  15308. *
  15309. */
  15310. P.inverseHyperbolicSine = P.asinh = function () {
  15311. var pr, rm,
  15312. x = this,
  15313. Ctor = x.constructor;
  15314. if (!x.isFinite() || x.isZero()) return new Ctor(x);
  15315. pr = Ctor.precision;
  15316. rm = Ctor.rounding;
  15317. Ctor.precision = pr + 2 * Math.max(Math.abs(x.e), x.sd()) + 6;
  15318. Ctor.rounding = 1;
  15319. external = false;
  15320. x = x.times(x).plus(1).sqrt().plus(x);
  15321. external = true;
  15322. Ctor.precision = pr;
  15323. Ctor.rounding = rm;
  15324. return x.ln();
  15325. };
  15326. /*
  15327. * Return a new Decimal whose value is the inverse of the hyperbolic tangent in radians of the
  15328. * value of this Decimal.
  15329. *
  15330. * Domain: [-1, 1]
  15331. * Range: [-Infinity, Infinity]
  15332. *
  15333. * atanh(x) = 0.5 * ln((1 + x) / (1 - x))
  15334. *
  15335. * atanh(|x| > 1) = NaN
  15336. * atanh(NaN) = NaN
  15337. * atanh(Infinity) = NaN
  15338. * atanh(-Infinity) = NaN
  15339. * atanh(0) = 0
  15340. * atanh(-0) = -0
  15341. * atanh(1) = Infinity
  15342. * atanh(-1) = -Infinity
  15343. *
  15344. */
  15345. P.inverseHyperbolicTangent = P.atanh = function () {
  15346. var pr, rm, wpr, xsd,
  15347. x = this,
  15348. Ctor = x.constructor;
  15349. if (!x.isFinite()) return new Ctor(NaN);
  15350. if (x.e >= 0) return new Ctor(x.abs().eq(1) ? x.s / 0 : x.isZero() ? x : NaN);
  15351. pr = Ctor.precision;
  15352. rm = Ctor.rounding;
  15353. xsd = x.sd();
  15354. if (Math.max(xsd, pr) < 2 * -x.e - 1) return finalise(new Ctor(x), pr, rm, true);
  15355. Ctor.precision = wpr = xsd - x.e;
  15356. x = divide(x.plus(1), new Ctor(1).minus(x), wpr + pr, 1);
  15357. Ctor.precision = pr + 4;
  15358. Ctor.rounding = 1;
  15359. x = x.ln();
  15360. Ctor.precision = pr;
  15361. Ctor.rounding = rm;
  15362. return x.times(0.5);
  15363. };
  15364. /*
  15365. * Return a new Decimal whose value is the arcsine (inverse sine) in radians of the value of this
  15366. * Decimal.
  15367. *
  15368. * Domain: [-Infinity, Infinity]
  15369. * Range: [-pi/2, pi/2]
  15370. *
  15371. * asin(x) = 2*atan(x/(1 + sqrt(1 - x^2)))
  15372. *
  15373. * asin(0) = 0
  15374. * asin(-0) = -0
  15375. * asin(1/2) = pi/6
  15376. * asin(-1/2) = -pi/6
  15377. * asin(1) = pi/2
  15378. * asin(-1) = -pi/2
  15379. * asin(|x| > 1) = NaN
  15380. * asin(NaN) = NaN
  15381. *
  15382. * TODO? Compare performance of Taylor series.
  15383. *
  15384. */
  15385. P.inverseSine = P.asin = function () {
  15386. var halfPi, k,
  15387. pr, rm,
  15388. x = this,
  15389. Ctor = x.constructor;
  15390. if (x.isZero()) return new Ctor(x);
  15391. k = x.abs().cmp(1);
  15392. pr = Ctor.precision;
  15393. rm = Ctor.rounding;
  15394. if (k !== -1) {
  15395. // |x| is 1
  15396. if (k === 0) {
  15397. halfPi = getPi(Ctor, pr + 4, rm).times(0.5);
  15398. halfPi.s = x.s;
  15399. return halfPi;
  15400. }
  15401. // |x| > 1 or x is NaN
  15402. return new Ctor(NaN);
  15403. }
  15404. // TODO? Special case asin(1/2) = pi/6 and asin(-1/2) = -pi/6
  15405. Ctor.precision = pr + 6;
  15406. Ctor.rounding = 1;
  15407. x = x.div(new Ctor(1).minus(x.times(x)).sqrt().plus(1)).atan();
  15408. Ctor.precision = pr;
  15409. Ctor.rounding = rm;
  15410. return x.times(2);
  15411. };
  15412. /*
  15413. * Return a new Decimal whose value is the arctangent (inverse tangent) in radians of the value
  15414. * of this Decimal.
  15415. *
  15416. * Domain: [-Infinity, Infinity]
  15417. * Range: [-pi/2, pi/2]
  15418. *
  15419. * atan(x) = x - x^3/3 + x^5/5 - x^7/7 + ...
  15420. *
  15421. * atan(0) = 0
  15422. * atan(-0) = -0
  15423. * atan(1) = pi/4
  15424. * atan(-1) = -pi/4
  15425. * atan(Infinity) = pi/2
  15426. * atan(-Infinity) = -pi/2
  15427. * atan(NaN) = NaN
  15428. *
  15429. */
  15430. P.inverseTangent = P.atan = function () {
  15431. var i, j, k, n, px, t, r, wpr, x2,
  15432. x = this,
  15433. Ctor = x.constructor,
  15434. pr = Ctor.precision,
  15435. rm = Ctor.rounding;
  15436. if (!x.isFinite()) {
  15437. if (!x.s) return new Ctor(NaN);
  15438. if (pr + 4 <= PI_PRECISION) {
  15439. r = getPi(Ctor, pr + 4, rm).times(0.5);
  15440. r.s = x.s;
  15441. return r;
  15442. }
  15443. } else if (x.isZero()) {
  15444. return new Ctor(x);
  15445. } else if (x.abs().eq(1) && pr + 4 <= PI_PRECISION) {
  15446. r = getPi(Ctor, pr + 4, rm).times(0.25);
  15447. r.s = x.s;
  15448. return r;
  15449. }
  15450. Ctor.precision = wpr = pr + 10;
  15451. Ctor.rounding = 1;
  15452. // TODO? if (x >= 1 && pr <= PI_PRECISION) atan(x) = halfPi * x.s - atan(1 / x);
  15453. // Argument reduction
  15454. // Ensure |x| < 0.42
  15455. // atan(x) = 2 * atan(x / (1 + sqrt(1 + x^2)))
  15456. k = Math.min(28, wpr / LOG_BASE + 2 | 0);
  15457. for (i = k; i; --i) x = x.div(x.times(x).plus(1).sqrt().plus(1));
  15458. external = false;
  15459. j = Math.ceil(wpr / LOG_BASE);
  15460. n = 1;
  15461. x2 = x.times(x);
  15462. r = new Ctor(x);
  15463. px = x;
  15464. // atan(x) = x - x^3/3 + x^5/5 - x^7/7 + ...
  15465. for (; i !== -1;) {
  15466. px = px.times(x2);
  15467. t = r.minus(px.div(n += 2));
  15468. px = px.times(x2);
  15469. r = t.plus(px.div(n += 2));
  15470. if (r.d[j] !== void 0) for (i = j; r.d[i] === t.d[i] && i--;);
  15471. }
  15472. if (k) r = r.times(2 << (k - 1));
  15473. external = true;
  15474. return finalise(r, Ctor.precision = pr, Ctor.rounding = rm, true);
  15475. };
  15476. /*
  15477. * Return true if the value of this Decimal is a finite number, otherwise return false.
  15478. *
  15479. */
  15480. P.isFinite = function () {
  15481. return !!this.d;
  15482. };
  15483. /*
  15484. * Return true if the value of this Decimal is an integer, otherwise return false.
  15485. *
  15486. */
  15487. P.isInteger = P.isInt = function () {
  15488. return !!this.d && mathfloor(this.e / LOG_BASE) > this.d.length - 2;
  15489. };
  15490. /*
  15491. * Return true if the value of this Decimal is NaN, otherwise return false.
  15492. *
  15493. */
  15494. P.isNaN = function () {
  15495. return !this.s;
  15496. };
  15497. /*
  15498. * Return true if the value of this Decimal is negative, otherwise return false.
  15499. *
  15500. */
  15501. P.isNegative = P.isNeg = function () {
  15502. return this.s < 0;
  15503. };
  15504. /*
  15505. * Return true if the value of this Decimal is positive, otherwise return false.
  15506. *
  15507. */
  15508. P.isPositive = P.isPos = function () {
  15509. return this.s > 0;
  15510. };
  15511. /*
  15512. * Return true if the value of this Decimal is 0 or -0, otherwise return false.
  15513. *
  15514. */
  15515. P.isZero = function () {
  15516. return !!this.d && this.d[0] === 0;
  15517. };
  15518. /*
  15519. * Return true if the value of this Decimal is less than `y`, otherwise return false.
  15520. *
  15521. */
  15522. P.lessThan = P.lt = function (y) {
  15523. return this.cmp(y) < 0;
  15524. };
  15525. /*
  15526. * Return true if the value of this Decimal is less than or equal to `y`, otherwise return false.
  15527. *
  15528. */
  15529. P.lessThanOrEqualTo = P.lte = function (y) {
  15530. return this.cmp(y) < 1;
  15531. };
  15532. /*
  15533. * Return the logarithm of the value of this Decimal to the specified base, rounded to `precision`
  15534. * significant digits using rounding mode `rounding`.
  15535. *
  15536. * If no base is specified, return log[10](arg).
  15537. *
  15538. * log[base](arg) = ln(arg) / ln(base)
  15539. *
  15540. * The result will always be correctly rounded if the base of the log is 10, and 'almost always'
  15541. * otherwise:
  15542. *
  15543. * Depending on the rounding mode, the result may be incorrectly rounded if the first fifteen
  15544. * rounding digits are [49]99999999999999 or [50]00000000000000. In that case, the maximum error
  15545. * between the result and the correctly rounded result will be one ulp (unit in the last place).
  15546. *
  15547. * log[-b](a) = NaN
  15548. * log[0](a) = NaN
  15549. * log[1](a) = NaN
  15550. * log[NaN](a) = NaN
  15551. * log[Infinity](a) = NaN
  15552. * log[b](0) = -Infinity
  15553. * log[b](-0) = -Infinity
  15554. * log[b](-a) = NaN
  15555. * log[b](1) = 0
  15556. * log[b](Infinity) = Infinity
  15557. * log[b](NaN) = NaN
  15558. *
  15559. * [base] {number|string|Decimal} The base of the logarithm.
  15560. *
  15561. */
  15562. P.logarithm = P.log = function (base) {
  15563. var isBase10, d, denominator, k, inf, num, sd, r,
  15564. arg = this,
  15565. Ctor = arg.constructor,
  15566. pr = Ctor.precision,
  15567. rm = Ctor.rounding,
  15568. guard = 5;
  15569. // Default base is 10.
  15570. if (base == null) {
  15571. base = new Ctor(10);
  15572. isBase10 = true;
  15573. } else {
  15574. base = new Ctor(base);
  15575. d = base.d;
  15576. // Return NaN if base is negative, or non-finite, or is 0 or 1.
  15577. if (base.s < 0 || !d || !d[0] || base.eq(1)) return new Ctor(NaN);
  15578. isBase10 = base.eq(10);
  15579. }
  15580. d = arg.d;
  15581. // Is arg negative, non-finite, 0 or 1?
  15582. if (arg.s < 0 || !d || !d[0] || arg.eq(1)) {
  15583. return new Ctor(d && !d[0] ? -1 / 0 : arg.s != 1 ? NaN : d ? 0 : 1 / 0);
  15584. }
  15585. // The result will have a non-terminating decimal expansion if base is 10 and arg is not an
  15586. // integer power of 10.
  15587. if (isBase10) {
  15588. if (d.length > 1) {
  15589. inf = true;
  15590. } else {
  15591. for (k = d[0]; k % 10 === 0;) k /= 10;
  15592. inf = k !== 1;
  15593. }
  15594. }
  15595. external = false;
  15596. sd = pr + guard;
  15597. num = naturalLogarithm(arg, sd);
  15598. denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
  15599. // The result will have 5 rounding digits.
  15600. r = divide(num, denominator, sd, 1);
  15601. // If at a rounding boundary, i.e. the result's rounding digits are [49]9999 or [50]0000,
  15602. // calculate 10 further digits.
  15603. //
  15604. // If the result is known to have an infinite decimal expansion, repeat this until it is clear
  15605. // that the result is above or below the boundary. Otherwise, if after calculating the 10
  15606. // further digits, the last 14 are nines, round up and assume the result is exact.
  15607. // Also assume the result is exact if the last 14 are zero.
  15608. //
  15609. // Example of a result that will be incorrectly rounded:
  15610. // log[1048576](4503599627370502) = 2.60000000000000009610279511444746...
  15611. // The above result correctly rounded using ROUND_CEIL to 1 decimal place should be 2.7, but it
  15612. // will be given as 2.6 as there are 15 zeros immediately after the requested decimal place, so
  15613. // the exact result would be assumed to be 2.6, which rounded using ROUND_CEIL to 1 decimal
  15614. // place is still 2.6.
  15615. if (checkRoundingDigits(r.d, k = pr, rm)) {
  15616. do {
  15617. sd += 10;
  15618. num = naturalLogarithm(arg, sd);
  15619. denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
  15620. r = divide(num, denominator, sd, 1);
  15621. if (!inf) {
  15622. // Check for 14 nines from the 2nd rounding digit, as the first may be 4.
  15623. if (+digitsToString(r.d).slice(k + 1, k + 15) + 1 == 1e14) {
  15624. r = finalise(r, pr + 1, 0);
  15625. }
  15626. break;
  15627. }
  15628. } while (checkRoundingDigits(r.d, k += 10, rm));
  15629. }
  15630. external = true;
  15631. return finalise(r, pr, rm);
  15632. };
  15633. /*
  15634. * Return a new Decimal whose value is the maximum of the arguments and the value of this Decimal.
  15635. *
  15636. * arguments {number|string|Decimal}
  15637. *
  15638. P.max = function () {
  15639. Array.prototype.push.call(arguments, this);
  15640. return maxOrMin(this.constructor, arguments, 'lt');
  15641. };
  15642. */
  15643. /*
  15644. * Return a new Decimal whose value is the minimum of the arguments and the value of this Decimal.
  15645. *
  15646. * arguments {number|string|Decimal}
  15647. *
  15648. P.min = function () {
  15649. Array.prototype.push.call(arguments, this);
  15650. return maxOrMin(this.constructor, arguments, 'gt');
  15651. };
  15652. */
  15653. /*
  15654. * n - 0 = n
  15655. * n - N = N
  15656. * n - I = -I
  15657. * 0 - n = -n
  15658. * 0 - 0 = 0
  15659. * 0 - N = N
  15660. * 0 - I = -I
  15661. * N - n = N
  15662. * N - 0 = N
  15663. * N - N = N
  15664. * N - I = N
  15665. * I - n = I
  15666. * I - 0 = I
  15667. * I - N = N
  15668. * I - I = N
  15669. *
  15670. * Return a new Decimal whose value is the value of this Decimal minus `y`, rounded to `precision`
  15671. * significant digits using rounding mode `rounding`.
  15672. *
  15673. */
  15674. P.minus = P.sub = function (y) {
  15675. var d, e, i, j, k, len, pr, rm, xd, xe, xLTy, yd,
  15676. x = this,
  15677. Ctor = x.constructor;
  15678. y = new Ctor(y);
  15679. // If either is not finite...
  15680. if (!x.d || !y.d) {
  15681. // Return NaN if either is NaN.
  15682. if (!x.s || !y.s) y = new Ctor(NaN);
  15683. // Return y negated if x is finite and y is ±Infinity.
  15684. else if (x.d) y.s = -y.s;
  15685. // Return x if y is finite and x is ±Infinity.
  15686. // Return x if both are ±Infinity with different signs.
  15687. // Return NaN if both are ±Infinity with the same sign.
  15688. else y = new Ctor(y.d || x.s !== y.s ? x : NaN);
  15689. return y;
  15690. }
  15691. // If signs differ...
  15692. if (x.s != y.s) {
  15693. y.s = -y.s;
  15694. return x.plus(y);
  15695. }
  15696. xd = x.d;
  15697. yd = y.d;
  15698. pr = Ctor.precision;
  15699. rm = Ctor.rounding;
  15700. // If either is zero...
  15701. if (!xd[0] || !yd[0]) {
  15702. // Return y negated if x is zero and y is non-zero.
  15703. if (yd[0]) y.s = -y.s;
  15704. // Return x if y is zero and x is non-zero.
  15705. else if (xd[0]) y = new Ctor(x);
  15706. // Return zero if both are zero.
  15707. // From IEEE 754 (2008) 6.3: 0 - 0 = -0 - -0 = -0 when rounding to -Infinity.
  15708. else return new Ctor(rm === 3 ? -0 : 0);
  15709. return external ? finalise(y, pr, rm) : y;
  15710. }
  15711. // x and y are finite, non-zero numbers with the same sign.
  15712. // Calculate base 1e7 exponents.
  15713. e = mathfloor(y.e / LOG_BASE);
  15714. xe = mathfloor(x.e / LOG_BASE);
  15715. xd = xd.slice();
  15716. k = xe - e;
  15717. // If base 1e7 exponents differ...
  15718. if (k) {
  15719. xLTy = k < 0;
  15720. if (xLTy) {
  15721. d = xd;
  15722. k = -k;
  15723. len = yd.length;
  15724. } else {
  15725. d = yd;
  15726. e = xe;
  15727. len = xd.length;
  15728. }
  15729. // Numbers with massively different exponents would result in a very high number of
  15730. // zeros needing to be prepended, but this can be avoided while still ensuring correct
  15731. // rounding by limiting the number of zeros to `Math.ceil(pr / LOG_BASE) + 2`.
  15732. i = Math.max(Math.ceil(pr / LOG_BASE), len) + 2;
  15733. if (k > i) {
  15734. k = i;
  15735. d.length = 1;
  15736. }
  15737. // Prepend zeros to equalise exponents.
  15738. d.reverse();
  15739. for (i = k; i--;) d.push(0);
  15740. d.reverse();
  15741. // Base 1e7 exponents equal.
  15742. } else {
  15743. // Check digits to determine which is the bigger number.
  15744. i = xd.length;
  15745. len = yd.length;
  15746. xLTy = i < len;
  15747. if (xLTy) len = i;
  15748. for (i = 0; i < len; i++) {
  15749. if (xd[i] != yd[i]) {
  15750. xLTy = xd[i] < yd[i];
  15751. break;
  15752. }
  15753. }
  15754. k = 0;
  15755. }
  15756. if (xLTy) {
  15757. d = xd;
  15758. xd = yd;
  15759. yd = d;
  15760. y.s = -y.s;
  15761. }
  15762. len = xd.length;
  15763. // Append zeros to `xd` if shorter.
  15764. // Don't add zeros to `yd` if shorter as subtraction only needs to start at `yd` length.
  15765. for (i = yd.length - len; i > 0; --i) xd[len++] = 0;
  15766. // Subtract yd from xd.
  15767. for (i = yd.length; i > k;) {
  15768. if (xd[--i] < yd[i]) {
  15769. for (j = i; j && xd[--j] === 0;) xd[j] = BASE - 1;
  15770. --xd[j];
  15771. xd[i] += BASE;
  15772. }
  15773. xd[i] -= yd[i];
  15774. }
  15775. // Remove trailing zeros.
  15776. for (; xd[--len] === 0;) xd.pop();
  15777. // Remove leading zeros and adjust exponent accordingly.
  15778. for (; xd[0] === 0; xd.shift()) --e;
  15779. // Zero?
  15780. if (!xd[0]) return new Ctor(rm === 3 ? -0 : 0);
  15781. y.d = xd;
  15782. y.e = getBase10Exponent(xd, e);
  15783. return external ? finalise(y, pr, rm) : y;
  15784. };
  15785. /*
  15786. * n % 0 = N
  15787. * n % N = N
  15788. * n % I = n
  15789. * 0 % n = 0
  15790. * -0 % n = -0
  15791. * 0 % 0 = N
  15792. * 0 % N = N
  15793. * 0 % I = 0
  15794. * N % n = N
  15795. * N % 0 = N
  15796. * N % N = N
  15797. * N % I = N
  15798. * I % n = N
  15799. * I % 0 = N
  15800. * I % N = N
  15801. * I % I = N
  15802. *
  15803. * Return a new Decimal whose value is the value of this Decimal modulo `y`, rounded to
  15804. * `precision` significant digits using rounding mode `rounding`.
  15805. *
  15806. * The result depends on the modulo mode.
  15807. *
  15808. */
  15809. P.modulo = P.mod = function (y) {
  15810. var q,
  15811. x = this,
  15812. Ctor = x.constructor;
  15813. y = new Ctor(y);
  15814. // Return NaN if x is ±Infinity or NaN, or y is NaN or ±0.
  15815. if (!x.d || !y.s || y.d && !y.d[0]) return new Ctor(NaN);
  15816. // Return x if y is ±Infinity or x is ±0.
  15817. if (!y.d || x.d && !x.d[0]) {
  15818. return finalise(new Ctor(x), Ctor.precision, Ctor.rounding);
  15819. }
  15820. // Prevent rounding of intermediate calculations.
  15821. external = false;
  15822. if (Ctor.modulo == 9) {
  15823. // Euclidian division: q = sign(y) * floor(x / abs(y))
  15824. // result = x - q * y where 0 <= result < abs(y)
  15825. q = divide(x, y.abs(), 0, 3, 1);
  15826. q.s *= y.s;
  15827. } else {
  15828. q = divide(x, y, 0, Ctor.modulo, 1);
  15829. }
  15830. q = q.times(y);
  15831. external = true;
  15832. return x.minus(q);
  15833. };
  15834. /*
  15835. * Return a new Decimal whose value is the natural exponential of the value of this Decimal,
  15836. * i.e. the base e raised to the power the value of this Decimal, rounded to `precision`
  15837. * significant digits using rounding mode `rounding`.
  15838. *
  15839. */
  15840. P.naturalExponential = P.exp = function () {
  15841. return naturalExponential(this);
  15842. };
  15843. /*
  15844. * Return a new Decimal whose value is the natural logarithm of the value of this Decimal,
  15845. * rounded to `precision` significant digits using rounding mode `rounding`.
  15846. *
  15847. */
  15848. P.naturalLogarithm = P.ln = function () {
  15849. return naturalLogarithm(this);
  15850. };
  15851. /*
  15852. * Return a new Decimal whose value is the value of this Decimal negated, i.e. as if multiplied by
  15853. * -1.
  15854. *
  15855. */
  15856. P.negated = P.neg = function () {
  15857. var x = new this.constructor(this);
  15858. x.s = -x.s;
  15859. return finalise(x);
  15860. };
  15861. /*
  15862. * n + 0 = n
  15863. * n + N = N
  15864. * n + I = I
  15865. * 0 + n = n
  15866. * 0 + 0 = 0
  15867. * 0 + N = N
  15868. * 0 + I = I
  15869. * N + n = N
  15870. * N + 0 = N
  15871. * N + N = N
  15872. * N + I = N
  15873. * I + n = I
  15874. * I + 0 = I
  15875. * I + N = N
  15876. * I + I = I
  15877. *
  15878. * Return a new Decimal whose value is the value of this Decimal plus `y`, rounded to `precision`
  15879. * significant digits using rounding mode `rounding`.
  15880. *
  15881. */
  15882. P.plus = P.add = function (y) {
  15883. var carry, d, e, i, k, len, pr, rm, xd, yd,
  15884. x = this,
  15885. Ctor = x.constructor;
  15886. y = new Ctor(y);
  15887. // If either is not finite...
  15888. if (!x.d || !y.d) {
  15889. // Return NaN if either is NaN.
  15890. if (!x.s || !y.s) y = new Ctor(NaN);
  15891. // Return x if y is finite and x is ±Infinity.
  15892. // Return x if both are ±Infinity with the same sign.
  15893. // Return NaN if both are ±Infinity with different signs.
  15894. // Return y if x is finite and y is ±Infinity.
  15895. else if (!x.d) y = new Ctor(y.d || x.s === y.s ? x : NaN);
  15896. return y;
  15897. }
  15898. // If signs differ...
  15899. if (x.s != y.s) {
  15900. y.s = -y.s;
  15901. return x.minus(y);
  15902. }
  15903. xd = x.d;
  15904. yd = y.d;
  15905. pr = Ctor.precision;
  15906. rm = Ctor.rounding;
  15907. // If either is zero...
  15908. if (!xd[0] || !yd[0]) {
  15909. // Return x if y is zero.
  15910. // Return y if y is non-zero.
  15911. if (!yd[0]) y = new Ctor(x);
  15912. return external ? finalise(y, pr, rm) : y;
  15913. }
  15914. // x and y are finite, non-zero numbers with the same sign.
  15915. // Calculate base 1e7 exponents.
  15916. k = mathfloor(x.e / LOG_BASE);
  15917. e = mathfloor(y.e / LOG_BASE);
  15918. xd = xd.slice();
  15919. i = k - e;
  15920. // If base 1e7 exponents differ...
  15921. if (i) {
  15922. if (i < 0) {
  15923. d = xd;
  15924. i = -i;
  15925. len = yd.length;
  15926. } else {
  15927. d = yd;
  15928. e = k;
  15929. len = xd.length;
  15930. }
  15931. // Limit number of zeros prepended to max(ceil(pr / LOG_BASE), len) + 1.
  15932. k = Math.ceil(pr / LOG_BASE);
  15933. len = k > len ? k + 1 : len + 1;
  15934. if (i > len) {
  15935. i = len;
  15936. d.length = 1;
  15937. }
  15938. // Prepend zeros to equalise exponents. Note: Faster to use reverse then do unshifts.
  15939. d.reverse();
  15940. for (; i--;) d.push(0);
  15941. d.reverse();
  15942. }
  15943. len = xd.length;
  15944. i = yd.length;
  15945. // If yd is longer than xd, swap xd and yd so xd points to the longer array.
  15946. if (len - i < 0) {
  15947. i = len;
  15948. d = yd;
  15949. yd = xd;
  15950. xd = d;
  15951. }
  15952. // Only start adding at yd.length - 1 as the further digits of xd can be left as they are.
  15953. for (carry = 0; i;) {
  15954. carry = (xd[--i] = xd[i] + yd[i] + carry) / BASE | 0;
  15955. xd[i] %= BASE;
  15956. }
  15957. if (carry) {
  15958. xd.unshift(carry);
  15959. ++e;
  15960. }
  15961. // Remove trailing zeros.
  15962. // No need to check for zero, as +x + +y != 0 && -x + -y != 0
  15963. for (len = xd.length; xd[--len] == 0;) xd.pop();
  15964. y.d = xd;
  15965. y.e = getBase10Exponent(xd, e);
  15966. return external ? finalise(y, pr, rm) : y;
  15967. };
  15968. /*
  15969. * Return the number of significant digits of the value of this Decimal.
  15970. *
  15971. * [z] {boolean|number} Whether to count integer-part trailing zeros: true, false, 1 or 0.
  15972. *
  15973. */
  15974. P.precision = P.sd = function (z) {
  15975. var k,
  15976. x = this;
  15977. if (z !== void 0 && z !== !!z && z !== 1 && z !== 0) throw Error(invalidArgument + z);
  15978. if (x.d) {
  15979. k = getPrecision(x.d);
  15980. if (z && x.e + 1 > k) k = x.e + 1;
  15981. } else {
  15982. k = NaN;
  15983. }
  15984. return k;
  15985. };
  15986. /*
  15987. * Return a new Decimal whose value is the value of this Decimal rounded to a whole number using
  15988. * rounding mode `rounding`.
  15989. *
  15990. */
  15991. P.round = function () {
  15992. var x = this,
  15993. Ctor = x.constructor;
  15994. return finalise(new Ctor(x), x.e + 1, Ctor.rounding);
  15995. };
  15996. /*
  15997. * Return a new Decimal whose value is the sine of the value in radians of this Decimal.
  15998. *
  15999. * Domain: [-Infinity, Infinity]
  16000. * Range: [-1, 1]
  16001. *
  16002. * sin(x) = x - x^3/3! + x^5/5! - ...
  16003. *
  16004. * sin(0) = 0
  16005. * sin(-0) = -0
  16006. * sin(Infinity) = NaN
  16007. * sin(-Infinity) = NaN
  16008. * sin(NaN) = NaN
  16009. *
  16010. */
  16011. P.sine = P.sin = function () {
  16012. var pr, rm,
  16013. x = this,
  16014. Ctor = x.constructor;
  16015. if (!x.isFinite()) return new Ctor(NaN);
  16016. if (x.isZero()) return new Ctor(x);
  16017. pr = Ctor.precision;
  16018. rm = Ctor.rounding;
  16019. Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
  16020. Ctor.rounding = 1;
  16021. x = sine(Ctor, toLessThanHalfPi(Ctor, x));
  16022. Ctor.precision = pr;
  16023. Ctor.rounding = rm;
  16024. return finalise(quadrant > 2 ? x.neg() : x, pr, rm, true);
  16025. };
  16026. /*
  16027. * Return a new Decimal whose value is the square root of this Decimal, rounded to `precision`
  16028. * significant digits using rounding mode `rounding`.
  16029. *
  16030. * sqrt(-n) = N
  16031. * sqrt(N) = N
  16032. * sqrt(-I) = N
  16033. * sqrt(I) = I
  16034. * sqrt(0) = 0
  16035. * sqrt(-0) = -0
  16036. *
  16037. */
  16038. P.squareRoot = P.sqrt = function () {
  16039. var m, n, sd, r, rep, t,
  16040. x = this,
  16041. d = x.d,
  16042. e = x.e,
  16043. s = x.s,
  16044. Ctor = x.constructor;
  16045. // Negative/NaN/Infinity/zero?
  16046. if (s !== 1 || !d || !d[0]) {
  16047. return new Ctor(!s || s < 0 && (!d || d[0]) ? NaN : d ? x : 1 / 0);
  16048. }
  16049. external = false;
  16050. // Initial estimate.
  16051. s = Math.sqrt(+x);
  16052. // Math.sqrt underflow/overflow?
  16053. // Pass x to Math.sqrt as integer, then adjust the exponent of the result.
  16054. if (s == 0 || s == 1 / 0) {
  16055. n = digitsToString(d);
  16056. if ((n.length + e) % 2 == 0) n += '0';
  16057. s = Math.sqrt(n);
  16058. e = mathfloor((e + 1) / 2) - (e < 0 || e % 2);
  16059. if (s == 1 / 0) {
  16060. n = '5e' + e;
  16061. } else {
  16062. n = s.toExponential();
  16063. n = n.slice(0, n.indexOf('e') + 1) + e;
  16064. }
  16065. r = new Ctor(n);
  16066. } else {
  16067. r = new Ctor(s.toString());
  16068. }
  16069. sd = (e = Ctor.precision) + 3;
  16070. // Newton-Raphson iteration.
  16071. for (;;) {
  16072. t = r;
  16073. r = t.plus(divide(x, t, sd + 2, 1)).times(0.5);
  16074. // TODO? Replace with for-loop and checkRoundingDigits.
  16075. if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
  16076. n = n.slice(sd - 3, sd + 1);
  16077. // The 4th rounding digit may be in error by -1 so if the 4 rounding digits are 9999 or
  16078. // 4999, i.e. approaching a rounding boundary, continue the iteration.
  16079. if (n == '9999' || !rep && n == '4999') {
  16080. // On the first iteration only, check to see if rounding up gives the exact result as the
  16081. // nines may infinitely repeat.
  16082. if (!rep) {
  16083. finalise(t, e + 1, 0);
  16084. if (t.times(t).eq(x)) {
  16085. r = t;
  16086. break;
  16087. }
  16088. }
  16089. sd += 4;
  16090. rep = 1;
  16091. } else {
  16092. // If the rounding digits are null, 0{0,4} or 50{0,3}, check for an exact result.
  16093. // If not, then there are further digits and m will be truthy.
  16094. if (!+n || !+n.slice(1) && n.charAt(0) == '5') {
  16095. // Truncate to the first rounding digit.
  16096. finalise(r, e + 1, 1);
  16097. m = !r.times(r).eq(x);
  16098. }
  16099. break;
  16100. }
  16101. }
  16102. }
  16103. external = true;
  16104. return finalise(r, e, Ctor.rounding, m);
  16105. };
  16106. /*
  16107. * Return a new Decimal whose value is the tangent of the value in radians of this Decimal.
  16108. *
  16109. * Domain: [-Infinity, Infinity]
  16110. * Range: [-Infinity, Infinity]
  16111. *
  16112. * tan(0) = 0
  16113. * tan(-0) = -0
  16114. * tan(Infinity) = NaN
  16115. * tan(-Infinity) = NaN
  16116. * tan(NaN) = NaN
  16117. *
  16118. */
  16119. P.tangent = P.tan = function () {
  16120. var pr, rm,
  16121. x = this,
  16122. Ctor = x.constructor;
  16123. if (!x.isFinite()) return new Ctor(NaN);
  16124. if (x.isZero()) return new Ctor(x);
  16125. pr = Ctor.precision;
  16126. rm = Ctor.rounding;
  16127. Ctor.precision = pr + 10;
  16128. Ctor.rounding = 1;
  16129. x = x.sin();
  16130. x.s = 1;
  16131. x = divide(x, new Ctor(1).minus(x.times(x)).sqrt(), pr + 10, 0);
  16132. Ctor.precision = pr;
  16133. Ctor.rounding = rm;
  16134. return finalise(quadrant == 2 || quadrant == 4 ? x.neg() : x, pr, rm, true);
  16135. };
  16136. /*
  16137. * n * 0 = 0
  16138. * n * N = N
  16139. * n * I = I
  16140. * 0 * n = 0
  16141. * 0 * 0 = 0
  16142. * 0 * N = N
  16143. * 0 * I = N
  16144. * N * n = N
  16145. * N * 0 = N
  16146. * N * N = N
  16147. * N * I = N
  16148. * I * n = I
  16149. * I * 0 = N
  16150. * I * N = N
  16151. * I * I = I
  16152. *
  16153. * Return a new Decimal whose value is this Decimal times `y`, rounded to `precision` significant
  16154. * digits using rounding mode `rounding`.
  16155. *
  16156. */
  16157. P.times = P.mul = function (y) {
  16158. var carry, e, i, k, r, rL, t, xdL, ydL,
  16159. x = this,
  16160. Ctor = x.constructor,
  16161. xd = x.d,
  16162. yd = (y = new Ctor(y)).d;
  16163. y.s *= x.s;
  16164. // If either is NaN, ±Infinity or ±0...
  16165. if (!xd || !xd[0] || !yd || !yd[0]) {
  16166. return new Ctor(!y.s || xd && !xd[0] && !yd || yd && !yd[0] && !xd
  16167. // Return NaN if either is NaN.
  16168. // Return NaN if x is ±0 and y is ±Infinity, or y is ±0 and x is ±Infinity.
  16169. ? NaN
  16170. // Return ±Infinity if either is ±Infinity.
  16171. // Return ±0 if either is ±0.
  16172. : !xd || !yd ? y.s / 0 : y.s * 0);
  16173. }
  16174. e = mathfloor(x.e / LOG_BASE) + mathfloor(y.e / LOG_BASE);
  16175. xdL = xd.length;
  16176. ydL = yd.length;
  16177. // Ensure xd points to the longer array.
  16178. if (xdL < ydL) {
  16179. r = xd;
  16180. xd = yd;
  16181. yd = r;
  16182. rL = xdL;
  16183. xdL = ydL;
  16184. ydL = rL;
  16185. }
  16186. // Initialise the result array with zeros.
  16187. r = [];
  16188. rL = xdL + ydL;
  16189. for (i = rL; i--;) r.push(0);
  16190. // Multiply!
  16191. for (i = ydL; --i >= 0;) {
  16192. carry = 0;
  16193. for (k = xdL + i; k > i;) {
  16194. t = r[k] + yd[i] * xd[k - i - 1] + carry;
  16195. r[k--] = t % BASE | 0;
  16196. carry = t / BASE | 0;
  16197. }
  16198. r[k] = (r[k] + carry) % BASE | 0;
  16199. }
  16200. // Remove trailing zeros.
  16201. for (; !r[--rL];) r.pop();
  16202. if (carry) ++e;
  16203. else r.shift();
  16204. y.d = r;
  16205. y.e = getBase10Exponent(r, e);
  16206. return external ? finalise(y, Ctor.precision, Ctor.rounding) : y;
  16207. };
  16208. /*
  16209. * Return a string representing the value of this Decimal in base 2, round to `sd` significant
  16210. * digits using rounding mode `rm`.
  16211. *
  16212. * If the optional `sd` argument is present then return binary exponential notation.
  16213. *
  16214. * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive.
  16215. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  16216. *
  16217. */
  16218. P.toBinary = function (sd, rm) {
  16219. return toStringBinary(this, 2, sd, rm);
  16220. };
  16221. /*
  16222. * Return a new Decimal whose value is the value of this Decimal rounded to a maximum of `dp`
  16223. * decimal places using rounding mode `rm` or `rounding` if `rm` is omitted.
  16224. *
  16225. * If `dp` is omitted, return a new Decimal whose value is the value of this Decimal.
  16226. *
  16227. * [dp] {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive.
  16228. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  16229. *
  16230. */
  16231. P.toDecimalPlaces = P.toDP = function (dp, rm) {
  16232. var x = this,
  16233. Ctor = x.constructor;
  16234. x = new Ctor(x);
  16235. if (dp === void 0) return x;
  16236. checkInt32(dp, 0, MAX_DIGITS);
  16237. if (rm === void 0) rm = Ctor.rounding;
  16238. else checkInt32(rm, 0, 8);
  16239. return finalise(x, dp + x.e + 1, rm);
  16240. };
  16241. /*
  16242. * Return a string representing the value of this Decimal in exponential notation rounded to
  16243. * `dp` fixed decimal places using rounding mode `rounding`.
  16244. *
  16245. * [dp] {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive.
  16246. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  16247. *
  16248. */
  16249. P.toExponential = function (dp, rm) {
  16250. var str,
  16251. x = this,
  16252. Ctor = x.constructor;
  16253. if (dp === void 0) {
  16254. str = finiteToString(x, true);
  16255. } else {
  16256. checkInt32(dp, 0, MAX_DIGITS);
  16257. if (rm === void 0) rm = Ctor.rounding;
  16258. else checkInt32(rm, 0, 8);
  16259. x = finalise(new Ctor(x), dp + 1, rm);
  16260. str = finiteToString(x, true, dp + 1);
  16261. }
  16262. return x.isNeg() && !x.isZero() ? '-' + str : str;
  16263. };
  16264. /*
  16265. * Return a string representing the value of this Decimal in normal (fixed-point) notation to
  16266. * `dp` fixed decimal places and rounded using rounding mode `rm` or `rounding` if `rm` is
  16267. * omitted.
  16268. *
  16269. * As with JavaScript numbers, (-0).toFixed(0) is '0', but e.g. (-0.00001).toFixed(0) is '-0'.
  16270. *
  16271. * [dp] {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive.
  16272. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  16273. *
  16274. * (-0).toFixed(0) is '0', but (-0.1).toFixed(0) is '-0'.
  16275. * (-0).toFixed(1) is '0.0', but (-0.01).toFixed(1) is '-0.0'.
  16276. * (-0).toFixed(3) is '0.000'.
  16277. * (-0.5).toFixed(0) is '-0'.
  16278. *
  16279. */
  16280. P.toFixed = function (dp, rm) {
  16281. var str, y,
  16282. x = this,
  16283. Ctor = x.constructor;
  16284. if (dp === void 0) {
  16285. str = finiteToString(x);
  16286. } else {
  16287. checkInt32(dp, 0, MAX_DIGITS);
  16288. if (rm === void 0) rm = Ctor.rounding;
  16289. else checkInt32(rm, 0, 8);
  16290. y = finalise(new Ctor(x), dp + x.e + 1, rm);
  16291. str = finiteToString(y, false, dp + y.e + 1);
  16292. }
  16293. // To determine whether to add the minus sign look at the value before it was rounded,
  16294. // i.e. look at `x` rather than `y`.
  16295. return x.isNeg() && !x.isZero() ? '-' + str : str;
  16296. };
  16297. /*
  16298. * Return an array representing the value of this Decimal as a simple fraction with an integer
  16299. * numerator and an integer denominator.
  16300. *
  16301. * The denominator will be a positive non-zero value less than or equal to the specified maximum
  16302. * denominator. If a maximum denominator is not specified, the denominator will be the lowest
  16303. * value necessary to represent the number exactly.
  16304. *
  16305. * [maxD] {number|string|Decimal} Maximum denominator. Integer >= 1 and < Infinity.
  16306. *
  16307. */
  16308. P.toFraction = function (maxD) {
  16309. var d, d0, d1, d2, e, k, n, n0, n1, pr, q, r,
  16310. x = this,
  16311. xd = x.d,
  16312. Ctor = x.constructor;
  16313. if (!xd) return new Ctor(x);
  16314. n1 = d0 = new Ctor(1);
  16315. d1 = n0 = new Ctor(0);
  16316. d = new Ctor(d1);
  16317. e = d.e = getPrecision(xd) - x.e - 1;
  16318. k = e % LOG_BASE;
  16319. d.d[0] = mathpow(10, k < 0 ? LOG_BASE + k : k);
  16320. if (maxD == null) {
  16321. // d is 10**e, the minimum max-denominator needed.
  16322. maxD = e > 0 ? d : n1;
  16323. } else {
  16324. n = new Ctor(maxD);
  16325. if (!n.isInt() || n.lt(n1)) throw Error(invalidArgument + n);
  16326. maxD = n.gt(d) ? (e > 0 ? d : n1) : n;
  16327. }
  16328. external = false;
  16329. n = new Ctor(digitsToString(xd));
  16330. pr = Ctor.precision;
  16331. Ctor.precision = e = xd.length * LOG_BASE * 2;
  16332. for (;;) {
  16333. q = divide(n, d, 0, 1, 1);
  16334. d2 = d0.plus(q.times(d1));
  16335. if (d2.cmp(maxD) == 1) break;
  16336. d0 = d1;
  16337. d1 = d2;
  16338. d2 = n1;
  16339. n1 = n0.plus(q.times(d2));
  16340. n0 = d2;
  16341. d2 = d;
  16342. d = n.minus(q.times(d2));
  16343. n = d2;
  16344. }
  16345. d2 = divide(maxD.minus(d0), d1, 0, 1, 1);
  16346. n0 = n0.plus(d2.times(n1));
  16347. d0 = d0.plus(d2.times(d1));
  16348. n0.s = n1.s = x.s;
  16349. // Determine which fraction is closer to x, n0/d0 or n1/d1?
  16350. r = divide(n1, d1, e, 1).minus(x).abs().cmp(divide(n0, d0, e, 1).minus(x).abs()) < 1
  16351. ? [n1, d1] : [n0, d0];
  16352. Ctor.precision = pr;
  16353. external = true;
  16354. return r;
  16355. };
  16356. /*
  16357. * Return a string representing the value of this Decimal in base 16, round to `sd` significant
  16358. * digits using rounding mode `rm`.
  16359. *
  16360. * If the optional `sd` argument is present then return binary exponential notation.
  16361. *
  16362. * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive.
  16363. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  16364. *
  16365. */
  16366. P.toHexadecimal = P.toHex = function (sd, rm) {
  16367. return toStringBinary(this, 16, sd, rm);
  16368. };
  16369. /*
  16370. * Returns a new Decimal whose value is the nearest multiple of `y` in the direction of rounding
  16371. * mode `rm`, or `Decimal.rounding` if `rm` is omitted, to the value of this Decimal.
  16372. *
  16373. * The return value will always have the same sign as this Decimal, unless either this Decimal
  16374. * or `y` is NaN, in which case the return value will be also be NaN.
  16375. *
  16376. * The return value is not affected by the value of `precision`.
  16377. *
  16378. * y {number|string|Decimal} The magnitude to round to a multiple of.
  16379. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  16380. *
  16381. * 'toNearest() rounding mode not an integer: {rm}'
  16382. * 'toNearest() rounding mode out of range: {rm}'
  16383. *
  16384. */
  16385. P.toNearest = function (y, rm) {
  16386. var x = this,
  16387. Ctor = x.constructor;
  16388. x = new Ctor(x);
  16389. if (y == null) {
  16390. // If x is not finite, return x.
  16391. if (!x.d) return x;
  16392. y = new Ctor(1);
  16393. rm = Ctor.rounding;
  16394. } else {
  16395. y = new Ctor(y);
  16396. if (rm === void 0) {
  16397. rm = Ctor.rounding;
  16398. } else {
  16399. checkInt32(rm, 0, 8);
  16400. }
  16401. // If x is not finite, return x if y is not NaN, else NaN.
  16402. if (!x.d) return y.s ? x : y;
  16403. // If y is not finite, return Infinity with the sign of x if y is Infinity, else NaN.
  16404. if (!y.d) {
  16405. if (y.s) y.s = x.s;
  16406. return y;
  16407. }
  16408. }
  16409. // If y is not zero, calculate the nearest multiple of y to x.
  16410. if (y.d[0]) {
  16411. external = false;
  16412. x = divide(x, y, 0, rm, 1).times(y);
  16413. external = true;
  16414. finalise(x);
  16415. // If y is zero, return zero with the sign of x.
  16416. } else {
  16417. y.s = x.s;
  16418. x = y;
  16419. }
  16420. return x;
  16421. };
  16422. /*
  16423. * Return the value of this Decimal converted to a number primitive.
  16424. * Zero keeps its sign.
  16425. *
  16426. */
  16427. P.toNumber = function () {
  16428. return +this;
  16429. };
  16430. /*
  16431. * Return a string representing the value of this Decimal in base 8, round to `sd` significant
  16432. * digits using rounding mode `rm`.
  16433. *
  16434. * If the optional `sd` argument is present then return binary exponential notation.
  16435. *
  16436. * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive.
  16437. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  16438. *
  16439. */
  16440. P.toOctal = function (sd, rm) {
  16441. return toStringBinary(this, 8, sd, rm);
  16442. };
  16443. /*
  16444. * Return a new Decimal whose value is the value of this Decimal raised to the power `y`, rounded
  16445. * to `precision` significant digits using rounding mode `rounding`.
  16446. *
  16447. * ECMAScript compliant.
  16448. *
  16449. * pow(x, NaN) = NaN
  16450. * pow(x, ±0) = 1
  16451. * pow(NaN, non-zero) = NaN
  16452. * pow(abs(x) > 1, +Infinity) = +Infinity
  16453. * pow(abs(x) > 1, -Infinity) = +0
  16454. * pow(abs(x) == 1, ±Infinity) = NaN
  16455. * pow(abs(x) < 1, +Infinity) = +0
  16456. * pow(abs(x) < 1, -Infinity) = +Infinity
  16457. * pow(+Infinity, y > 0) = +Infinity
  16458. * pow(+Infinity, y < 0) = +0
  16459. * pow(-Infinity, odd integer > 0) = -Infinity
  16460. * pow(-Infinity, even integer > 0) = +Infinity
  16461. * pow(-Infinity, odd integer < 0) = -0
  16462. * pow(-Infinity, even integer < 0) = +0
  16463. * pow(+0, y > 0) = +0
  16464. * pow(+0, y < 0) = +Infinity
  16465. * pow(-0, odd integer > 0) = -0
  16466. * pow(-0, even integer > 0) = +0
  16467. * pow(-0, odd integer < 0) = -Infinity
  16468. * pow(-0, even integer < 0) = +Infinity
  16469. * pow(finite x < 0, finite non-integer) = NaN
  16470. *
  16471. * For non-integer or very large exponents pow(x, y) is calculated using
  16472. *
  16473. * x^y = exp(y*ln(x))
  16474. *
  16475. * Assuming the first 15 rounding digits are each equally likely to be any digit 0-9, the
  16476. * probability of an incorrectly rounded result
  16477. * P([49]9{14} | [50]0{14}) = 2 * 0.2 * 10^-14 = 4e-15 = 1/2.5e+14
  16478. * i.e. 1 in 250,000,000,000,000
  16479. *
  16480. * If a result is incorrectly rounded the maximum error will be 1 ulp (unit in last place).
  16481. *
  16482. * y {number|string|Decimal} The power to which to raise this Decimal.
  16483. *
  16484. */
  16485. P.toPower = P.pow = function (y) {
  16486. var e, k, pr, r, rm, s,
  16487. x = this,
  16488. Ctor = x.constructor,
  16489. yn = +(y = new Ctor(y));
  16490. // Either ±Infinity, NaN or ±0?
  16491. if (!x.d || !y.d || !x.d[0] || !y.d[0]) return new Ctor(mathpow(+x, yn));
  16492. x = new Ctor(x);
  16493. if (x.eq(1)) return x;
  16494. pr = Ctor.precision;
  16495. rm = Ctor.rounding;
  16496. if (y.eq(1)) return finalise(x, pr, rm);
  16497. // y exponent
  16498. e = mathfloor(y.e / LOG_BASE);
  16499. // If y is a small integer use the 'exponentiation by squaring' algorithm.
  16500. if (e >= y.d.length - 1 && (k = yn < 0 ? -yn : yn) <= MAX_SAFE_INTEGER) {
  16501. r = intPow(Ctor, x, k, pr);
  16502. return y.s < 0 ? new Ctor(1).div(r) : finalise(r, pr, rm);
  16503. }
  16504. s = x.s;
  16505. // if x is negative
  16506. if (s < 0) {
  16507. // if y is not an integer
  16508. if (e < y.d.length - 1) return new Ctor(NaN);
  16509. // Result is positive if x is negative and the last digit of integer y is even.
  16510. if ((y.d[e] & 1) == 0) s = 1;
  16511. // if x.eq(-1)
  16512. if (x.e == 0 && x.d[0] == 1 && x.d.length == 1) {
  16513. x.s = s;
  16514. return x;
  16515. }
  16516. }
  16517. // Estimate result exponent.
  16518. // x^y = 10^e, where e = y * log10(x)
  16519. // log10(x) = log10(x_significand) + x_exponent
  16520. // log10(x_significand) = ln(x_significand) / ln(10)
  16521. k = mathpow(+x, yn);
  16522. e = k == 0 || !isFinite(k)
  16523. ? mathfloor(yn * (Math.log('0.' + digitsToString(x.d)) / Math.LN10 + x.e + 1))
  16524. : new Ctor(k + '').e;
  16525. // Exponent estimate may be incorrect e.g. x: 0.999999999999999999, y: 2.29, e: 0, r.e: -1.
  16526. // Overflow/underflow?
  16527. if (e > Ctor.maxE + 1 || e < Ctor.minE - 1) return new Ctor(e > 0 ? s / 0 : 0);
  16528. external = false;
  16529. Ctor.rounding = x.s = 1;
  16530. // Estimate the extra guard digits needed to ensure five correct rounding digits from
  16531. // naturalLogarithm(x). Example of failure without these extra digits (precision: 10):
  16532. // new Decimal(2.32456).pow('2087987436534566.46411')
  16533. // should be 1.162377823e+764914905173815, but is 1.162355823e+764914905173815
  16534. k = Math.min(12, (e + '').length);
  16535. // r = x^y = exp(y*ln(x))
  16536. r = naturalExponential(y.times(naturalLogarithm(x, pr + k)), pr);
  16537. // r may be Infinity, e.g. (0.9999999999999999).pow(-1e+40)
  16538. if (r.d) {
  16539. // Truncate to the required precision plus five rounding digits.
  16540. r = finalise(r, pr + 5, 1);
  16541. // If the rounding digits are [49]9999 or [50]0000 increase the precision by 10 and recalculate
  16542. // the result.
  16543. if (checkRoundingDigits(r.d, pr, rm)) {
  16544. e = pr + 10;
  16545. // Truncate to the increased precision plus five rounding digits.
  16546. r = finalise(naturalExponential(y.times(naturalLogarithm(x, e + k)), e), e + 5, 1);
  16547. // Check for 14 nines from the 2nd rounding digit (the first rounding digit may be 4 or 9).
  16548. if (+digitsToString(r.d).slice(pr + 1, pr + 15) + 1 == 1e14) {
  16549. r = finalise(r, pr + 1, 0);
  16550. }
  16551. }
  16552. }
  16553. r.s = s;
  16554. external = true;
  16555. Ctor.rounding = rm;
  16556. return finalise(r, pr, rm);
  16557. };
  16558. /*
  16559. * Return a string representing the value of this Decimal rounded to `sd` significant digits
  16560. * using rounding mode `rounding`.
  16561. *
  16562. * Return exponential notation if `sd` is less than the number of digits necessary to represent
  16563. * the integer part of the value in normal notation.
  16564. *
  16565. * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive.
  16566. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  16567. *
  16568. */
  16569. P.toPrecision = function (sd, rm) {
  16570. var str,
  16571. x = this,
  16572. Ctor = x.constructor;
  16573. if (sd === void 0) {
  16574. str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
  16575. } else {
  16576. checkInt32(sd, 1, MAX_DIGITS);
  16577. if (rm === void 0) rm = Ctor.rounding;
  16578. else checkInt32(rm, 0, 8);
  16579. x = finalise(new Ctor(x), sd, rm);
  16580. str = finiteToString(x, sd <= x.e || x.e <= Ctor.toExpNeg, sd);
  16581. }
  16582. return x.isNeg() && !x.isZero() ? '-' + str : str;
  16583. };
  16584. /*
  16585. * Return a new Decimal whose value is the value of this Decimal rounded to a maximum of `sd`
  16586. * significant digits using rounding mode `rm`, or to `precision` and `rounding` respectively if
  16587. * omitted.
  16588. *
  16589. * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive.
  16590. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  16591. *
  16592. * 'toSD() digits out of range: {sd}'
  16593. * 'toSD() digits not an integer: {sd}'
  16594. * 'toSD() rounding mode not an integer: {rm}'
  16595. * 'toSD() rounding mode out of range: {rm}'
  16596. *
  16597. */
  16598. P.toSignificantDigits = P.toSD = function (sd, rm) {
  16599. var x = this,
  16600. Ctor = x.constructor;
  16601. if (sd === void 0) {
  16602. sd = Ctor.precision;
  16603. rm = Ctor.rounding;
  16604. } else {
  16605. checkInt32(sd, 1, MAX_DIGITS);
  16606. if (rm === void 0) rm = Ctor.rounding;
  16607. else checkInt32(rm, 0, 8);
  16608. }
  16609. return finalise(new Ctor(x), sd, rm);
  16610. };
  16611. /*
  16612. * Return a string representing the value of this Decimal.
  16613. *
  16614. * Return exponential notation if this Decimal has a positive exponent equal to or greater than
  16615. * `toExpPos`, or a negative exponent equal to or less than `toExpNeg`.
  16616. *
  16617. */
  16618. P.toString = function () {
  16619. var x = this,
  16620. Ctor = x.constructor,
  16621. str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
  16622. return x.isNeg() && !x.isZero() ? '-' + str : str;
  16623. };
  16624. /*
  16625. * Return a new Decimal whose value is the value of this Decimal truncated to a whole number.
  16626. *
  16627. */
  16628. P.truncated = P.trunc = function () {
  16629. return finalise(new this.constructor(this), this.e + 1, 1);
  16630. };
  16631. /*
  16632. * Return a string representing the value of this Decimal.
  16633. * Unlike `toString`, negative zero will include the minus sign.
  16634. *
  16635. */
  16636. P.valueOf = P.toJSON = function () {
  16637. var x = this,
  16638. Ctor = x.constructor,
  16639. str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
  16640. return x.isNeg() ? '-' + str : str;
  16641. };
  16642. // Helper functions for Decimal.prototype (P) and/or Decimal methods, and their callers.
  16643. /*
  16644. * digitsToString P.cubeRoot, P.logarithm, P.squareRoot, P.toFraction, P.toPower,
  16645. * finiteToString, naturalExponential, naturalLogarithm
  16646. * checkInt32 P.toDecimalPlaces, P.toExponential, P.toFixed, P.toNearest,
  16647. * P.toPrecision, P.toSignificantDigits, toStringBinary, random
  16648. * checkRoundingDigits P.logarithm, P.toPower, naturalExponential, naturalLogarithm
  16649. * convertBase toStringBinary, parseOther
  16650. * cos P.cos
  16651. * divide P.atanh, P.cubeRoot, P.dividedBy, P.dividedToIntegerBy,
  16652. * P.logarithm, P.modulo, P.squareRoot, P.tan, P.tanh, P.toFraction,
  16653. * P.toNearest, toStringBinary, naturalExponential, naturalLogarithm,
  16654. * taylorSeries, atan2, parseOther
  16655. * finalise P.absoluteValue, P.atan, P.atanh, P.ceil, P.cos, P.cosh,
  16656. * P.cubeRoot, P.dividedToIntegerBy, P.floor, P.logarithm, P.minus,
  16657. * P.modulo, P.negated, P.plus, P.round, P.sin, P.sinh, P.squareRoot,
  16658. * P.tan, P.times, P.toDecimalPlaces, P.toExponential, P.toFixed,
  16659. * P.toNearest, P.toPower, P.toPrecision, P.toSignificantDigits,
  16660. * P.truncated, divide, getLn10, getPi, naturalExponential,
  16661. * naturalLogarithm, ceil, floor, round, trunc
  16662. * finiteToString P.toExponential, P.toFixed, P.toPrecision, P.toString, P.valueOf,
  16663. * toStringBinary
  16664. * getBase10Exponent P.minus, P.plus, P.times, parseOther
  16665. * getLn10 P.logarithm, naturalLogarithm
  16666. * getPi P.acos, P.asin, P.atan, toLessThanHalfPi, atan2
  16667. * getPrecision P.precision, P.toFraction
  16668. * getZeroString digitsToString, finiteToString
  16669. * intPow P.toPower, parseOther
  16670. * isOdd toLessThanHalfPi
  16671. * maxOrMin max, min
  16672. * naturalExponential P.naturalExponential, P.toPower
  16673. * naturalLogarithm P.acosh, P.asinh, P.atanh, P.logarithm, P.naturalLogarithm,
  16674. * P.toPower, naturalExponential
  16675. * nonFiniteToString finiteToString, toStringBinary
  16676. * parseDecimal Decimal
  16677. * parseOther Decimal
  16678. * sin P.sin
  16679. * taylorSeries P.cosh, P.sinh, cos, sin
  16680. * toLessThanHalfPi P.cos, P.sin
  16681. * toStringBinary P.toBinary, P.toHexadecimal, P.toOctal
  16682. * truncate intPow
  16683. *
  16684. * Throws: P.logarithm, P.precision, P.toFraction, checkInt32, getLn10, getPi,
  16685. * naturalLogarithm, config, parseOther, random, Decimal
  16686. */
  16687. function digitsToString(d) {
  16688. var i, k, ws,
  16689. indexOfLastWord = d.length - 1,
  16690. str = '',
  16691. w = d[0];
  16692. if (indexOfLastWord > 0) {
  16693. str += w;
  16694. for (i = 1; i < indexOfLastWord; i++) {
  16695. ws = d[i] + '';
  16696. k = LOG_BASE - ws.length;
  16697. if (k) str += getZeroString(k);
  16698. str += ws;
  16699. }
  16700. w = d[i];
  16701. ws = w + '';
  16702. k = LOG_BASE - ws.length;
  16703. if (k) str += getZeroString(k);
  16704. } else if (w === 0) {
  16705. return '0';
  16706. }
  16707. // Remove trailing zeros of last w.
  16708. for (; w % 10 === 0;) w /= 10;
  16709. return str + w;
  16710. }
  16711. function checkInt32(i, min, max) {
  16712. if (i !== ~~i || i < min || i > max) {
  16713. throw Error(invalidArgument + i);
  16714. }
  16715. }
  16716. /*
  16717. * Check 5 rounding digits if `repeating` is null, 4 otherwise.
  16718. * `repeating == null` if caller is `log` or `pow`,
  16719. * `repeating != null` if caller is `naturalLogarithm` or `naturalExponential`.
  16720. */
  16721. function checkRoundingDigits(d, i, rm, repeating) {
  16722. var di, k, r, rd;
  16723. // Get the length of the first word of the array d.
  16724. for (k = d[0]; k >= 10; k /= 10) --i;
  16725. // Is the rounding digit in the first word of d?
  16726. if (--i < 0) {
  16727. i += LOG_BASE;
  16728. di = 0;
  16729. } else {
  16730. di = Math.ceil((i + 1) / LOG_BASE);
  16731. i %= LOG_BASE;
  16732. }
  16733. // i is the index (0 - 6) of the rounding digit.
  16734. // E.g. if within the word 3487563 the first rounding digit is 5,
  16735. // then i = 4, k = 1000, rd = 3487563 % 1000 = 563
  16736. k = mathpow(10, LOG_BASE - i);
  16737. rd = d[di] % k | 0;
  16738. if (repeating == null) {
  16739. if (i < 3) {
  16740. if (i == 0) rd = rd / 100 | 0;
  16741. else if (i == 1) rd = rd / 10 | 0;
  16742. r = rm < 4 && rd == 99999 || rm > 3 && rd == 49999 || rd == 50000 || rd == 0;
  16743. } else {
  16744. r = (rm < 4 && rd + 1 == k || rm > 3 && rd + 1 == k / 2) &&
  16745. (d[di + 1] / k / 100 | 0) == mathpow(10, i - 2) - 1 ||
  16746. (rd == k / 2 || rd == 0) && (d[di + 1] / k / 100 | 0) == 0;
  16747. }
  16748. } else {
  16749. if (i < 4) {
  16750. if (i == 0) rd = rd / 1000 | 0;
  16751. else if (i == 1) rd = rd / 100 | 0;
  16752. else if (i == 2) rd = rd / 10 | 0;
  16753. r = (repeating || rm < 4) && rd == 9999 || !repeating && rm > 3 && rd == 4999;
  16754. } else {
  16755. r = ((repeating || rm < 4) && rd + 1 == k ||
  16756. (!repeating && rm > 3) && rd + 1 == k / 2) &&
  16757. (d[di + 1] / k / 1000 | 0) == mathpow(10, i - 3) - 1;
  16758. }
  16759. }
  16760. return r;
  16761. }
  16762. // Convert string of `baseIn` to an array of numbers of `baseOut`.
  16763. // Eg. convertBase('255', 10, 16) returns [15, 15].
  16764. // Eg. convertBase('ff', 16, 10) returns [2, 5, 5].
  16765. function convertBase(str, baseIn, baseOut) {
  16766. var j,
  16767. arr = [0],
  16768. arrL,
  16769. i = 0,
  16770. strL = str.length;
  16771. for (; i < strL;) {
  16772. for (arrL = arr.length; arrL--;) arr[arrL] *= baseIn;
  16773. arr[0] += NUMERALS.indexOf(str.charAt(i++));
  16774. for (j = 0; j < arr.length; j++) {
  16775. if (arr[j] > baseOut - 1) {
  16776. if (arr[j + 1] === void 0) arr[j + 1] = 0;
  16777. arr[j + 1] += arr[j] / baseOut | 0;
  16778. arr[j] %= baseOut;
  16779. }
  16780. }
  16781. }
  16782. return arr.reverse();
  16783. }
  16784. /*
  16785. * cos(x) = 1 - x^2/2! + x^4/4! - ...
  16786. * |x| < pi/2
  16787. *
  16788. */
  16789. function cosine(Ctor, x) {
  16790. var k, len, y;
  16791. if (x.isZero()) return x;
  16792. // Argument reduction: cos(4x) = 8*(cos^4(x) - cos^2(x)) + 1
  16793. // i.e. cos(x) = 8*(cos^4(x/4) - cos^2(x/4)) + 1
  16794. // Estimate the optimum number of times to use the argument reduction.
  16795. len = x.d.length;
  16796. if (len < 32) {
  16797. k = Math.ceil(len / 3);
  16798. y = (1 / tinyPow(4, k)).toString();
  16799. } else {
  16800. k = 16;
  16801. y = '2.3283064365386962890625e-10';
  16802. }
  16803. Ctor.precision += k;
  16804. x = taylorSeries(Ctor, 1, x.times(y), new Ctor(1));
  16805. // Reverse argument reduction
  16806. for (var i = k; i--;) {
  16807. var cos2x = x.times(x);
  16808. x = cos2x.times(cos2x).minus(cos2x).times(8).plus(1);
  16809. }
  16810. Ctor.precision -= k;
  16811. return x;
  16812. }
  16813. /*
  16814. * Perform division in the specified base.
  16815. */
  16816. var divide = (function () {
  16817. // Assumes non-zero x and k, and hence non-zero result.
  16818. function multiplyInteger(x, k, base) {
  16819. var temp,
  16820. carry = 0,
  16821. i = x.length;
  16822. for (x = x.slice(); i--;) {
  16823. temp = x[i] * k + carry;
  16824. x[i] = temp % base | 0;
  16825. carry = temp / base | 0;
  16826. }
  16827. if (carry) x.unshift(carry);
  16828. return x;
  16829. }
  16830. function compare(a, b, aL, bL) {
  16831. var i, r;
  16832. if (aL != bL) {
  16833. r = aL > bL ? 1 : -1;
  16834. } else {
  16835. for (i = r = 0; i < aL; i++) {
  16836. if (a[i] != b[i]) {
  16837. r = a[i] > b[i] ? 1 : -1;
  16838. break;
  16839. }
  16840. }
  16841. }
  16842. return r;
  16843. }
  16844. function subtract(a, b, aL, base) {
  16845. var i = 0;
  16846. // Subtract b from a.
  16847. for (; aL--;) {
  16848. a[aL] -= i;
  16849. i = a[aL] < b[aL] ? 1 : 0;
  16850. a[aL] = i * base + a[aL] - b[aL];
  16851. }
  16852. // Remove leading zeros.
  16853. for (; !a[0] && a.length > 1;) a.shift();
  16854. }
  16855. return function (x, y, pr, rm, dp, base) {
  16856. var cmp, e, i, k, logBase, more, prod, prodL, q, qd, rem, remL, rem0, sd, t, xi, xL, yd0,
  16857. yL, yz,
  16858. Ctor = x.constructor,
  16859. sign = x.s == y.s ? 1 : -1,
  16860. xd = x.d,
  16861. yd = y.d;
  16862. // Either NaN, Infinity or 0?
  16863. if (!xd || !xd[0] || !yd || !yd[0]) {
  16864. return new Ctor(// Return NaN if either NaN, or both Infinity or 0.
  16865. !x.s || !y.s || (xd ? yd && xd[0] == yd[0] : !yd) ? NaN :
  16866. // Return ±0 if x is 0 or y is ±Infinity, or return ±Infinity as y is 0.
  16867. xd && xd[0] == 0 || !yd ? sign * 0 : sign / 0);
  16868. }
  16869. if (base) {
  16870. logBase = 1;
  16871. e = x.e - y.e;
  16872. } else {
  16873. base = BASE;
  16874. logBase = LOG_BASE;
  16875. e = mathfloor(x.e / logBase) - mathfloor(y.e / logBase);
  16876. }
  16877. yL = yd.length;
  16878. xL = xd.length;
  16879. q = new Ctor(sign);
  16880. qd = q.d = [];
  16881. // Result exponent may be one less than e.
  16882. // The digit array of a Decimal from toStringBinary may have trailing zeros.
  16883. for (i = 0; yd[i] == (xd[i] || 0); i++);
  16884. if (yd[i] > (xd[i] || 0)) e--;
  16885. if (pr == null) {
  16886. sd = pr = Ctor.precision;
  16887. rm = Ctor.rounding;
  16888. } else if (dp) {
  16889. sd = pr + (x.e - y.e) + 1;
  16890. } else {
  16891. sd = pr;
  16892. }
  16893. if (sd < 0) {
  16894. qd.push(1);
  16895. more = true;
  16896. } else {
  16897. // Convert precision in number of base 10 digits to base 1e7 digits.
  16898. sd = sd / logBase + 2 | 0;
  16899. i = 0;
  16900. // divisor < 1e7
  16901. if (yL == 1) {
  16902. k = 0;
  16903. yd = yd[0];
  16904. sd++;
  16905. // k is the carry.
  16906. for (; (i < xL || k) && sd--; i++) {
  16907. t = k * base + (xd[i] || 0);
  16908. qd[i] = t / yd | 0;
  16909. k = t % yd | 0;
  16910. }
  16911. more = k || i < xL;
  16912. // divisor >= 1e7
  16913. } else {
  16914. // Normalise xd and yd so highest order digit of yd is >= base/2
  16915. k = base / (yd[0] + 1) | 0;
  16916. if (k > 1) {
  16917. yd = multiplyInteger(yd, k, base);
  16918. xd = multiplyInteger(xd, k, base);
  16919. yL = yd.length;
  16920. xL = xd.length;
  16921. }
  16922. xi = yL;
  16923. rem = xd.slice(0, yL);
  16924. remL = rem.length;
  16925. // Add zeros to make remainder as long as divisor.
  16926. for (; remL < yL;) rem[remL++] = 0;
  16927. yz = yd.slice();
  16928. yz.unshift(0);
  16929. yd0 = yd[0];
  16930. if (yd[1] >= base / 2) ++yd0;
  16931. do {
  16932. k = 0;
  16933. // Compare divisor and remainder.
  16934. cmp = compare(yd, rem, yL, remL);
  16935. // If divisor < remainder.
  16936. if (cmp < 0) {
  16937. // Calculate trial digit, k.
  16938. rem0 = rem[0];
  16939. if (yL != remL) rem0 = rem0 * base + (rem[1] || 0);
  16940. // k will be how many times the divisor goes into the current remainder.
  16941. k = rem0 / yd0 | 0;
  16942. // Algorithm:
  16943. // 1. product = divisor * trial digit (k)
  16944. // 2. if product > remainder: product -= divisor, k--
  16945. // 3. remainder -= product
  16946. // 4. if product was < remainder at 2:
  16947. // 5. compare new remainder and divisor
  16948. // 6. If remainder > divisor: remainder -= divisor, k++
  16949. if (k > 1) {
  16950. if (k >= base) k = base - 1;
  16951. // product = divisor * trial digit.
  16952. prod = multiplyInteger(yd, k, base);
  16953. prodL = prod.length;
  16954. remL = rem.length;
  16955. // Compare product and remainder.
  16956. cmp = compare(prod, rem, prodL, remL);
  16957. // product > remainder.
  16958. if (cmp == 1) {
  16959. k--;
  16960. // Subtract divisor from product.
  16961. subtract(prod, yL < prodL ? yz : yd, prodL, base);
  16962. }
  16963. } else {
  16964. // cmp is -1.
  16965. // If k is 0, there is no need to compare yd and rem again below, so change cmp to 1
  16966. // to avoid it. If k is 1 there is a need to compare yd and rem again below.
  16967. if (k == 0) cmp = k = 1;
  16968. prod = yd.slice();
  16969. }
  16970. prodL = prod.length;
  16971. if (prodL < remL) prod.unshift(0);
  16972. // Subtract product from remainder.
  16973. subtract(rem, prod, remL, base);
  16974. // If product was < previous remainder.
  16975. if (cmp == -1) {
  16976. remL = rem.length;
  16977. // Compare divisor and new remainder.
  16978. cmp = compare(yd, rem, yL, remL);
  16979. // If divisor < new remainder, subtract divisor from remainder.
  16980. if (cmp < 1) {
  16981. k++;
  16982. // Subtract divisor from remainder.
  16983. subtract(rem, yL < remL ? yz : yd, remL, base);
  16984. }
  16985. }
  16986. remL = rem.length;
  16987. } else if (cmp === 0) {
  16988. k++;
  16989. rem = [0];
  16990. } // if cmp === 1, k will be 0
  16991. // Add the next digit, k, to the result array.
  16992. qd[i++] = k;
  16993. // Update the remainder.
  16994. if (cmp && rem[0]) {
  16995. rem[remL++] = xd[xi] || 0;
  16996. } else {
  16997. rem = [xd[xi]];
  16998. remL = 1;
  16999. }
  17000. } while ((xi++ < xL || rem[0] !== void 0) && sd--);
  17001. more = rem[0] !== void 0;
  17002. }
  17003. // Leading zero?
  17004. if (!qd[0]) qd.shift();
  17005. }
  17006. // logBase is 1 when divide is being used for base conversion.
  17007. if (logBase == 1) {
  17008. q.e = e;
  17009. inexact = more;
  17010. } else {
  17011. // To calculate q.e, first get the number of digits of qd[0].
  17012. for (i = 1, k = qd[0]; k >= 10; k /= 10) i++;
  17013. q.e = i + e * logBase - 1;
  17014. finalise(q, dp ? pr + q.e + 1 : pr, rm, more);
  17015. }
  17016. return q;
  17017. };
  17018. })();
  17019. /*
  17020. * Round `x` to `sd` significant digits using rounding mode `rm`.
  17021. * Check for over/under-flow.
  17022. */
  17023. function finalise(x, sd, rm, isTruncated) {
  17024. var digits, i, j, k, rd, roundUp, w, xd, xdi,
  17025. Ctor = x.constructor;
  17026. // Don't round if sd is null or undefined.
  17027. out: if (sd != null) {
  17028. xd = x.d;
  17029. // Infinity/NaN.
  17030. if (!xd) return x;
  17031. // rd: the rounding digit, i.e. the digit after the digit that may be rounded up.
  17032. // w: the word of xd containing rd, a base 1e7 number.
  17033. // xdi: the index of w within xd.
  17034. // digits: the number of digits of w.
  17035. // i: what would be the index of rd within w if all the numbers were 7 digits long (i.e. if
  17036. // they had leading zeros)
  17037. // j: if > 0, the actual index of rd within w (if < 0, rd is a leading zero).
  17038. // Get the length of the first word of the digits array xd.
  17039. for (digits = 1, k = xd[0]; k >= 10; k /= 10) digits++;
  17040. i = sd - digits;
  17041. // Is the rounding digit in the first word of xd?
  17042. if (i < 0) {
  17043. i += LOG_BASE;
  17044. j = sd;
  17045. w = xd[xdi = 0];
  17046. // Get the rounding digit at index j of w.
  17047. rd = w / mathpow(10, digits - j - 1) % 10 | 0;
  17048. } else {
  17049. xdi = Math.ceil((i + 1) / LOG_BASE);
  17050. k = xd.length;
  17051. if (xdi >= k) {
  17052. if (isTruncated) {
  17053. // Needed by `naturalExponential`, `naturalLogarithm` and `squareRoot`.
  17054. for (; k++ <= xdi;) xd.push(0);
  17055. w = rd = 0;
  17056. digits = 1;
  17057. i %= LOG_BASE;
  17058. j = i - LOG_BASE + 1;
  17059. } else {
  17060. break out;
  17061. }
  17062. } else {
  17063. w = k = xd[xdi];
  17064. // Get the number of digits of w.
  17065. for (digits = 1; k >= 10; k /= 10) digits++;
  17066. // Get the index of rd within w.
  17067. i %= LOG_BASE;
  17068. // Get the index of rd within w, adjusted for leading zeros.
  17069. // The number of leading zeros of w is given by LOG_BASE - digits.
  17070. j = i - LOG_BASE + digits;
  17071. // Get the rounding digit at index j of w.
  17072. rd = j < 0 ? 0 : w / mathpow(10, digits - j - 1) % 10 | 0;
  17073. }
  17074. }
  17075. // Are there any non-zero digits after the rounding digit?
  17076. isTruncated = isTruncated || sd < 0 ||
  17077. xd[xdi + 1] !== void 0 || (j < 0 ? w : w % mathpow(10, digits - j - 1));
  17078. // The expression `w % mathpow(10, digits - j - 1)` returns all the digits of w to the right
  17079. // of the digit at (left-to-right) index j, e.g. if w is 908714 and j is 2, the expression
  17080. // will give 714.
  17081. roundUp = rm < 4
  17082. ? (rd || isTruncated) && (rm == 0 || rm == (x.s < 0 ? 3 : 2))
  17083. : rd > 5 || rd == 5 && (rm == 4 || isTruncated || rm == 6 &&
  17084. // Check whether the digit to the left of the rounding digit is odd.
  17085. ((i > 0 ? j > 0 ? w / mathpow(10, digits - j) : 0 : xd[xdi - 1]) % 10) & 1 ||
  17086. rm == (x.s < 0 ? 8 : 7));
  17087. if (sd < 1 || !xd[0]) {
  17088. xd.length = 0;
  17089. if (roundUp) {
  17090. // Convert sd to decimal places.
  17091. sd -= x.e + 1;
  17092. // 1, 0.1, 0.01, 0.001, 0.0001 etc.
  17093. xd[0] = mathpow(10, (LOG_BASE - sd % LOG_BASE) % LOG_BASE);
  17094. x.e = -sd || 0;
  17095. } else {
  17096. // Zero.
  17097. xd[0] = x.e = 0;
  17098. }
  17099. return x;
  17100. }
  17101. // Remove excess digits.
  17102. if (i == 0) {
  17103. xd.length = xdi;
  17104. k = 1;
  17105. xdi--;
  17106. } else {
  17107. xd.length = xdi + 1;
  17108. k = mathpow(10, LOG_BASE - i);
  17109. // E.g. 56700 becomes 56000 if 7 is the rounding digit.
  17110. // j > 0 means i > number of leading zeros of w.
  17111. xd[xdi] = j > 0 ? (w / mathpow(10, digits - j) % mathpow(10, j) | 0) * k : 0;
  17112. }
  17113. if (roundUp) {
  17114. for (;;) {
  17115. // Is the digit to be rounded up in the first word of xd?
  17116. if (xdi == 0) {
  17117. // i will be the length of xd[0] before k is added.
  17118. for (i = 1, j = xd[0]; j >= 10; j /= 10) i++;
  17119. j = xd[0] += k;
  17120. for (k = 1; j >= 10; j /= 10) k++;
  17121. // if i != k the length has increased.
  17122. if (i != k) {
  17123. x.e++;
  17124. if (xd[0] == BASE) xd[0] = 1;
  17125. }
  17126. break;
  17127. } else {
  17128. xd[xdi] += k;
  17129. if (xd[xdi] != BASE) break;
  17130. xd[xdi--] = 0;
  17131. k = 1;
  17132. }
  17133. }
  17134. }
  17135. // Remove trailing zeros.
  17136. for (i = xd.length; xd[--i] === 0;) xd.pop();
  17137. }
  17138. if (external) {
  17139. // Overflow?
  17140. if (x.e > Ctor.maxE) {
  17141. // Infinity.
  17142. x.d = null;
  17143. x.e = NaN;
  17144. // Underflow?
  17145. } else if (x.e < Ctor.minE) {
  17146. // Zero.
  17147. x.e = 0;
  17148. x.d = [0];
  17149. // Ctor.underflow = true;
  17150. } // else Ctor.underflow = false;
  17151. }
  17152. return x;
  17153. }
  17154. function finiteToString(x, isExp, sd) {
  17155. if (!x.isFinite()) return nonFiniteToString(x);
  17156. var k,
  17157. e = x.e,
  17158. str = digitsToString(x.d),
  17159. len = str.length;
  17160. if (isExp) {
  17161. if (sd && (k = sd - len) > 0) {
  17162. str = str.charAt(0) + '.' + str.slice(1) + getZeroString(k);
  17163. } else if (len > 1) {
  17164. str = str.charAt(0) + '.' + str.slice(1);
  17165. }
  17166. str = str + (x.e < 0 ? 'e' : 'e+') + x.e;
  17167. } else if (e < 0) {
  17168. str = '0.' + getZeroString(-e - 1) + str;
  17169. if (sd && (k = sd - len) > 0) str += getZeroString(k);
  17170. } else if (e >= len) {
  17171. str += getZeroString(e + 1 - len);
  17172. if (sd && (k = sd - e - 1) > 0) str = str + '.' + getZeroString(k);
  17173. } else {
  17174. if ((k = e + 1) < len) str = str.slice(0, k) + '.' + str.slice(k);
  17175. if (sd && (k = sd - len) > 0) {
  17176. if (e + 1 === len) str += '.';
  17177. str += getZeroString(k);
  17178. }
  17179. }
  17180. return str;
  17181. }
  17182. // Calculate the base 10 exponent from the base 1e7 exponent.
  17183. function getBase10Exponent(digits, e) {
  17184. var w = digits[0];
  17185. // Add the number of digits of the first word of the digits array.
  17186. for ( e *= LOG_BASE; w >= 10; w /= 10) e++;
  17187. return e;
  17188. }
  17189. function getLn10(Ctor, sd, pr) {
  17190. if (sd > LN10_PRECISION) {
  17191. // Reset global state in case the exception is caught.
  17192. external = true;
  17193. if (pr) Ctor.precision = pr;
  17194. throw Error(precisionLimitExceeded);
  17195. }
  17196. return finalise(new Ctor(LN10), sd, 1, true);
  17197. }
  17198. function getPi(Ctor, sd, rm) {
  17199. if (sd > PI_PRECISION) throw Error(precisionLimitExceeded);
  17200. return finalise(new Ctor(PI), sd, rm, true);
  17201. }
  17202. function getPrecision(digits) {
  17203. var w = digits.length - 1,
  17204. len = w * LOG_BASE + 1;
  17205. w = digits[w];
  17206. // If non-zero...
  17207. if (w) {
  17208. // Subtract the number of trailing zeros of the last word.
  17209. for (; w % 10 == 0; w /= 10) len--;
  17210. // Add the number of digits of the first word.
  17211. for (w = digits[0]; w >= 10; w /= 10) len++;
  17212. }
  17213. return len;
  17214. }
  17215. function getZeroString(k) {
  17216. var zs = '';
  17217. for (; k--;) zs += '0';
  17218. return zs;
  17219. }
  17220. /*
  17221. * Return a new Decimal whose value is the value of Decimal `x` to the power `n`, where `n` is an
  17222. * integer of type number.
  17223. *
  17224. * Implements 'exponentiation by squaring'. Called by `pow` and `parseOther`.
  17225. *
  17226. */
  17227. function intPow(Ctor, x, n, pr) {
  17228. var isTruncated,
  17229. r = new Ctor(1),
  17230. // Max n of 9007199254740991 takes 53 loop iterations.
  17231. // Maximum digits array length; leaves [28, 34] guard digits.
  17232. k = Math.ceil(pr / LOG_BASE + 4);
  17233. external = false;
  17234. for (;;) {
  17235. if (n % 2) {
  17236. r = r.times(x);
  17237. if (truncate(r.d, k)) isTruncated = true;
  17238. }
  17239. n = mathfloor(n / 2);
  17240. if (n === 0) {
  17241. // To ensure correct rounding when r.d is truncated, increment the last word if it is zero.
  17242. n = r.d.length - 1;
  17243. if (isTruncated && r.d[n] === 0) ++r.d[n];
  17244. break;
  17245. }
  17246. x = x.times(x);
  17247. truncate(x.d, k);
  17248. }
  17249. external = true;
  17250. return r;
  17251. }
  17252. function isOdd(n) {
  17253. return n.d[n.d.length - 1] & 1;
  17254. }
  17255. /*
  17256. * Handle `max` and `min`. `ltgt` is 'lt' or 'gt'.
  17257. */
  17258. function maxOrMin(Ctor, args, ltgt) {
  17259. var y,
  17260. x = new Ctor(args[0]),
  17261. i = 0;
  17262. for (; ++i < args.length;) {
  17263. y = new Ctor(args[i]);
  17264. if (!y.s) {
  17265. x = y;
  17266. break;
  17267. } else if (x[ltgt](y)) {
  17268. x = y;
  17269. }
  17270. }
  17271. return x;
  17272. }
  17273. /*
  17274. * Return a new Decimal whose value is the natural exponential of `x` rounded to `sd` significant
  17275. * digits.
  17276. *
  17277. * Taylor/Maclaurin series.
  17278. *
  17279. * exp(x) = x^0/0! + x^1/1! + x^2/2! + x^3/3! + ...
  17280. *
  17281. * Argument reduction:
  17282. * Repeat x = x / 32, k += 5, until |x| < 0.1
  17283. * exp(x) = exp(x / 2^k)^(2^k)
  17284. *
  17285. * Previously, the argument was initially reduced by
  17286. * exp(x) = exp(r) * 10^k where r = x - k * ln10, k = floor(x / ln10)
  17287. * to first put r in the range [0, ln10], before dividing by 32 until |x| < 0.1, but this was
  17288. * found to be slower than just dividing repeatedly by 32 as above.
  17289. *
  17290. * Max integer argument: exp('20723265836946413') = 6.3e+9000000000000000
  17291. * Min integer argument: exp('-20723265836946411') = 1.2e-9000000000000000
  17292. * (Math object integer min/max: Math.exp(709) = 8.2e+307, Math.exp(-745) = 5e-324)
  17293. *
  17294. * exp(Infinity) = Infinity
  17295. * exp(-Infinity) = 0
  17296. * exp(NaN) = NaN
  17297. * exp(±0) = 1
  17298. *
  17299. * exp(x) is non-terminating for any finite, non-zero x.
  17300. *
  17301. * The result will always be correctly rounded.
  17302. *
  17303. */
  17304. function naturalExponential(x, sd) {
  17305. var denominator, guard, j, pow, sum, t, wpr,
  17306. rep = 0,
  17307. i = 0,
  17308. k = 0,
  17309. Ctor = x.constructor,
  17310. rm = Ctor.rounding,
  17311. pr = Ctor.precision;
  17312. // 0/NaN/Infinity?
  17313. if (!x.d || !x.d[0] || x.e > 17) {
  17314. return new Ctor(x.d
  17315. ? !x.d[0] ? 1 : x.s < 0 ? 0 : 1 / 0
  17316. : x.s ? x.s < 0 ? 0 : x : 0 / 0);
  17317. }
  17318. if (sd == null) {
  17319. external = false;
  17320. wpr = pr;
  17321. } else {
  17322. wpr = sd;
  17323. }
  17324. t = new Ctor(0.03125);
  17325. // while abs(x) >= 0.1
  17326. while (x.e > -2) {
  17327. // x = x / 2^5
  17328. x = x.times(t);
  17329. k += 5;
  17330. }
  17331. // Use 2 * log10(2^k) + 5 (empirically derived) to estimate the increase in precision
  17332. // necessary to ensure the first 4 rounding digits are correct.
  17333. guard = Math.log(mathpow(2, k)) / Math.LN10 * 2 + 5 | 0;
  17334. wpr += guard;
  17335. denominator = pow = sum = new Ctor(1);
  17336. Ctor.precision = wpr;
  17337. for (;;) {
  17338. pow = finalise(pow.times(x), wpr, 1);
  17339. denominator = denominator.times(++i);
  17340. t = sum.plus(divide(pow, denominator, wpr, 1));
  17341. if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum.d).slice(0, wpr)) {
  17342. j = k;
  17343. while (j--) sum = finalise(sum.times(sum), wpr, 1);
  17344. // Check to see if the first 4 rounding digits are [49]999.
  17345. // If so, repeat the summation with a higher precision, otherwise
  17346. // e.g. with precision: 18, rounding: 1
  17347. // exp(18.404272462595034083567793919843761) = 98372560.1229999999 (should be 98372560.123)
  17348. // `wpr - guard` is the index of first rounding digit.
  17349. if (sd == null) {
  17350. if (rep < 3 && checkRoundingDigits(sum.d, wpr - guard, rm, rep)) {
  17351. Ctor.precision = wpr += 10;
  17352. denominator = pow = t = new Ctor(1);
  17353. i = 0;
  17354. rep++;
  17355. } else {
  17356. return finalise(sum, Ctor.precision = pr, rm, external = true);
  17357. }
  17358. } else {
  17359. Ctor.precision = pr;
  17360. return sum;
  17361. }
  17362. }
  17363. sum = t;
  17364. }
  17365. }
  17366. /*
  17367. * Return a new Decimal whose value is the natural logarithm of `x` rounded to `sd` significant
  17368. * digits.
  17369. *
  17370. * ln(-n) = NaN
  17371. * ln(0) = -Infinity
  17372. * ln(-0) = -Infinity
  17373. * ln(1) = 0
  17374. * ln(Infinity) = Infinity
  17375. * ln(-Infinity) = NaN
  17376. * ln(NaN) = NaN
  17377. *
  17378. * ln(n) (n != 1) is non-terminating.
  17379. *
  17380. */
  17381. function naturalLogarithm(y, sd) {
  17382. var c, c0, denominator, e, numerator, rep, sum, t, wpr, x1, x2,
  17383. n = 1,
  17384. guard = 10,
  17385. x = y,
  17386. xd = x.d,
  17387. Ctor = x.constructor,
  17388. rm = Ctor.rounding,
  17389. pr = Ctor.precision;
  17390. // Is x negative or Infinity, NaN, 0 or 1?
  17391. if (x.s < 0 || !xd || !xd[0] || !x.e && xd[0] == 1 && xd.length == 1) {
  17392. return new Ctor(xd && !xd[0] ? -1 / 0 : x.s != 1 ? NaN : xd ? 0 : x);
  17393. }
  17394. if (sd == null) {
  17395. external = false;
  17396. wpr = pr;
  17397. } else {
  17398. wpr = sd;
  17399. }
  17400. Ctor.precision = wpr += guard;
  17401. c = digitsToString(xd);
  17402. c0 = c.charAt(0);
  17403. if (Math.abs(e = x.e) < 1.5e15) {
  17404. // Argument reduction.
  17405. // The series converges faster the closer the argument is to 1, so using
  17406. // ln(a^b) = b * ln(a), ln(a) = ln(a^b) / b
  17407. // multiply the argument by itself until the leading digits of the significand are 7, 8, 9,
  17408. // 10, 11, 12 or 13, recording the number of multiplications so the sum of the series can
  17409. // later be divided by this number, then separate out the power of 10 using
  17410. // ln(a*10^b) = ln(a) + b*ln(10).
  17411. // max n is 21 (gives 0.9, 1.0 or 1.1) (9e15 / 21 = 4.2e14).
  17412. //while (c0 < 9 && c0 != 1 || c0 == 1 && c.charAt(1) > 1) {
  17413. // max n is 6 (gives 0.7 - 1.3)
  17414. while (c0 < 7 && c0 != 1 || c0 == 1 && c.charAt(1) > 3) {
  17415. x = x.times(y);
  17416. c = digitsToString(x.d);
  17417. c0 = c.charAt(0);
  17418. n++;
  17419. }
  17420. e = x.e;
  17421. if (c0 > 1) {
  17422. x = new Ctor('0.' + c);
  17423. e++;
  17424. } else {
  17425. x = new Ctor(c0 + '.' + c.slice(1));
  17426. }
  17427. } else {
  17428. // The argument reduction method above may result in overflow if the argument y is a massive
  17429. // number with exponent >= 1500000000000000 (9e15 / 6 = 1.5e15), so instead recall this
  17430. // function using ln(x*10^e) = ln(x) + e*ln(10).
  17431. t = getLn10(Ctor, wpr + 2, pr).times(e + '');
  17432. x = naturalLogarithm(new Ctor(c0 + '.' + c.slice(1)), wpr - guard).plus(t);
  17433. Ctor.precision = pr;
  17434. return sd == null ? finalise(x, pr, rm, external = true) : x;
  17435. }
  17436. // x1 is x reduced to a value near 1.
  17437. x1 = x;
  17438. // Taylor series.
  17439. // ln(y) = ln((1 + x)/(1 - x)) = 2(x + x^3/3 + x^5/5 + x^7/7 + ...)
  17440. // where x = (y - 1)/(y + 1) (|x| < 1)
  17441. sum = numerator = x = divide(x.minus(1), x.plus(1), wpr, 1);
  17442. x2 = finalise(x.times(x), wpr, 1);
  17443. denominator = 3;
  17444. for (;;) {
  17445. numerator = finalise(numerator.times(x2), wpr, 1);
  17446. t = sum.plus(divide(numerator, new Ctor(denominator), wpr, 1));
  17447. if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum.d).slice(0, wpr)) {
  17448. sum = sum.times(2);
  17449. // Reverse the argument reduction. Check that e is not 0 because, besides preventing an
  17450. // unnecessary calculation, -0 + 0 = +0 and to ensure correct rounding -0 needs to stay -0.
  17451. if (e !== 0) sum = sum.plus(getLn10(Ctor, wpr + 2, pr).times(e + ''));
  17452. sum = divide(sum, new Ctor(n), wpr, 1);
  17453. // Is rm > 3 and the first 4 rounding digits 4999, or rm < 4 (or the summation has
  17454. // been repeated previously) and the first 4 rounding digits 9999?
  17455. // If so, restart the summation with a higher precision, otherwise
  17456. // e.g. with precision: 12, rounding: 1
  17457. // ln(135520028.6126091714265381533) = 18.7246299999 when it should be 18.72463.
  17458. // `wpr - guard` is the index of first rounding digit.
  17459. if (sd == null) {
  17460. if (checkRoundingDigits(sum.d, wpr - guard, rm, rep)) {
  17461. Ctor.precision = wpr += guard;
  17462. t = numerator = x = divide(x1.minus(1), x1.plus(1), wpr, 1);
  17463. x2 = finalise(x.times(x), wpr, 1);
  17464. denominator = rep = 1;
  17465. } else {
  17466. return finalise(sum, Ctor.precision = pr, rm, external = true);
  17467. }
  17468. } else {
  17469. Ctor.precision = pr;
  17470. return sum;
  17471. }
  17472. }
  17473. sum = t;
  17474. denominator += 2;
  17475. }
  17476. }
  17477. // ±Infinity, NaN.
  17478. function nonFiniteToString(x) {
  17479. // Unsigned.
  17480. return String(x.s * x.s / 0);
  17481. }
  17482. /*
  17483. * Parse the value of a new Decimal `x` from string `str`.
  17484. */
  17485. function parseDecimal(x, str) {
  17486. var e, i, len;
  17487. // Decimal point?
  17488. if ((e = str.indexOf('.')) > -1) str = str.replace('.', '');
  17489. // Exponential form?
  17490. if ((i = str.search(/e/i)) > 0) {
  17491. // Determine exponent.
  17492. if (e < 0) e = i;
  17493. e += +str.slice(i + 1);
  17494. str = str.substring(0, i);
  17495. } else if (e < 0) {
  17496. // Integer.
  17497. e = str.length;
  17498. }
  17499. // Determine leading zeros.
  17500. for (i = 0; str.charCodeAt(i) === 48; i++);
  17501. // Determine trailing zeros.
  17502. for (len = str.length; str.charCodeAt(len - 1) === 48; --len);
  17503. str = str.slice(i, len);
  17504. if (str) {
  17505. len -= i;
  17506. x.e = e = e - i - 1;
  17507. x.d = [];
  17508. // Transform base
  17509. // e is the base 10 exponent.
  17510. // i is where to slice str to get the first word of the digits array.
  17511. i = (e + 1) % LOG_BASE;
  17512. if (e < 0) i += LOG_BASE;
  17513. if (i < len) {
  17514. if (i) x.d.push(+str.slice(0, i));
  17515. for (len -= LOG_BASE; i < len;) x.d.push(+str.slice(i, i += LOG_BASE));
  17516. str = str.slice(i);
  17517. i = LOG_BASE - str.length;
  17518. } else {
  17519. i -= len;
  17520. }
  17521. for (; i--;) str += '0';
  17522. x.d.push(+str);
  17523. if (external) {
  17524. // Overflow?
  17525. if (x.e > x.constructor.maxE) {
  17526. // Infinity.
  17527. x.d = null;
  17528. x.e = NaN;
  17529. // Underflow?
  17530. } else if (x.e < x.constructor.minE) {
  17531. // Zero.
  17532. x.e = 0;
  17533. x.d = [0];
  17534. // x.constructor.underflow = true;
  17535. } // else x.constructor.underflow = false;
  17536. }
  17537. } else {
  17538. // Zero.
  17539. x.e = 0;
  17540. x.d = [0];
  17541. }
  17542. return x;
  17543. }
  17544. /*
  17545. * Parse the value of a new Decimal `x` from a string `str`, which is not a decimal value.
  17546. */
  17547. function parseOther(x, str) {
  17548. var base, Ctor, divisor, i, isFloat, len, p, xd, xe;
  17549. if (str.indexOf('_') > -1) {
  17550. str = str.replace(/(\d)_(?=\d)/g, '$1');
  17551. if (isDecimal.test(str)) return parseDecimal(x, str);
  17552. } else if (str === 'Infinity' || str === 'NaN') {
  17553. if (!+str) x.s = NaN;
  17554. x.e = NaN;
  17555. x.d = null;
  17556. return x;
  17557. }
  17558. if (isHex.test(str)) {
  17559. base = 16;
  17560. str = str.toLowerCase();
  17561. } else if (isBinary.test(str)) {
  17562. base = 2;
  17563. } else if (isOctal.test(str)) {
  17564. base = 8;
  17565. } else {
  17566. throw Error(invalidArgument + str);
  17567. }
  17568. // Is there a binary exponent part?
  17569. i = str.search(/p/i);
  17570. if (i > 0) {
  17571. p = +str.slice(i + 1);
  17572. str = str.substring(2, i);
  17573. } else {
  17574. str = str.slice(2);
  17575. }
  17576. // Convert `str` as an integer then divide the result by `base` raised to a power such that the
  17577. // fraction part will be restored.
  17578. i = str.indexOf('.');
  17579. isFloat = i >= 0;
  17580. Ctor = x.constructor;
  17581. if (isFloat) {
  17582. str = str.replace('.', '');
  17583. len = str.length;
  17584. i = len - i;
  17585. // log[10](16) = 1.2041... , log[10](88) = 1.9444....
  17586. divisor = intPow(Ctor, new Ctor(base), i, i * 2);
  17587. }
  17588. xd = convertBase(str, base, BASE);
  17589. xe = xd.length - 1;
  17590. // Remove trailing zeros.
  17591. for (i = xe; xd[i] === 0; --i) xd.pop();
  17592. if (i < 0) return new Ctor(x.s * 0);
  17593. x.e = getBase10Exponent(xd, xe);
  17594. x.d = xd;
  17595. external = false;
  17596. // At what precision to perform the division to ensure exact conversion?
  17597. // maxDecimalIntegerPartDigitCount = ceil(log[10](b) * otherBaseIntegerPartDigitCount)
  17598. // log[10](2) = 0.30103, log[10](8) = 0.90309, log[10](16) = 1.20412
  17599. // E.g. ceil(1.2 * 3) = 4, so up to 4 decimal digits are needed to represent 3 hex int digits.
  17600. // maxDecimalFractionPartDigitCount = {Hex:4|Oct:3|Bin:1} * otherBaseFractionPartDigitCount
  17601. // Therefore using 4 * the number of digits of str will always be enough.
  17602. if (isFloat) x = divide(x, divisor, len * 4);
  17603. // Multiply by the binary exponent part if present.
  17604. if (p) x = x.times(Math.abs(p) < 54 ? mathpow(2, p) : Decimal.pow(2, p));
  17605. external = true;
  17606. return x;
  17607. }
  17608. /*
  17609. * sin(x) = x - x^3/3! + x^5/5! - ...
  17610. * |x| < pi/2
  17611. *
  17612. */
  17613. function sine(Ctor, x) {
  17614. var k,
  17615. len = x.d.length;
  17616. if (len < 3) {
  17617. return x.isZero() ? x : taylorSeries(Ctor, 2, x, x);
  17618. }
  17619. // Argument reduction: sin(5x) = 16*sin^5(x) - 20*sin^3(x) + 5*sin(x)
  17620. // i.e. sin(x) = 16*sin^5(x/5) - 20*sin^3(x/5) + 5*sin(x/5)
  17621. // and sin(x) = sin(x/5)(5 + sin^2(x/5)(16sin^2(x/5) - 20))
  17622. // Estimate the optimum number of times to use the argument reduction.
  17623. k = 1.4 * Math.sqrt(len);
  17624. k = k > 16 ? 16 : k | 0;
  17625. x = x.times(1 / tinyPow(5, k));
  17626. x = taylorSeries(Ctor, 2, x, x);
  17627. // Reverse argument reduction
  17628. var sin2_x,
  17629. d5 = new Ctor(5),
  17630. d16 = new Ctor(16),
  17631. d20 = new Ctor(20);
  17632. for (; k--;) {
  17633. sin2_x = x.times(x);
  17634. x = x.times(d5.plus(sin2_x.times(d16.times(sin2_x).minus(d20))));
  17635. }
  17636. return x;
  17637. }
  17638. // Calculate Taylor series for `cos`, `cosh`, `sin` and `sinh`.
  17639. function taylorSeries(Ctor, n, x, y, isHyperbolic) {
  17640. var j, t, u, x2,
  17641. i = 1,
  17642. pr = Ctor.precision,
  17643. k = Math.ceil(pr / LOG_BASE);
  17644. external = false;
  17645. x2 = x.times(x);
  17646. u = new Ctor(y);
  17647. for (;;) {
  17648. t = divide(u.times(x2), new Ctor(n++ * n++), pr, 1);
  17649. u = isHyperbolic ? y.plus(t) : y.minus(t);
  17650. y = divide(t.times(x2), new Ctor(n++ * n++), pr, 1);
  17651. t = u.plus(y);
  17652. if (t.d[k] !== void 0) {
  17653. for (j = k; t.d[j] === u.d[j] && j--;);
  17654. if (j == -1) break;
  17655. }
  17656. j = u;
  17657. u = y;
  17658. y = t;
  17659. t = j;
  17660. i++;
  17661. }
  17662. external = true;
  17663. t.d.length = k + 1;
  17664. return t;
  17665. }
  17666. // Exponent e must be positive and non-zero.
  17667. function tinyPow(b, e) {
  17668. var n = b;
  17669. while (--e) n *= b;
  17670. return n;
  17671. }
  17672. // Return the absolute value of `x` reduced to less than or equal to half pi.
  17673. function toLessThanHalfPi(Ctor, x) {
  17674. var t,
  17675. isNeg = x.s < 0,
  17676. pi = getPi(Ctor, Ctor.precision, 1),
  17677. halfPi = pi.times(0.5);
  17678. x = x.abs();
  17679. if (x.lte(halfPi)) {
  17680. quadrant = isNeg ? 4 : 1;
  17681. return x;
  17682. }
  17683. t = x.divToInt(pi);
  17684. if (t.isZero()) {
  17685. quadrant = isNeg ? 3 : 2;
  17686. } else {
  17687. x = x.minus(t.times(pi));
  17688. // 0 <= x < pi
  17689. if (x.lte(halfPi)) {
  17690. quadrant = isOdd(t) ? (isNeg ? 2 : 3) : (isNeg ? 4 : 1);
  17691. return x;
  17692. }
  17693. quadrant = isOdd(t) ? (isNeg ? 1 : 4) : (isNeg ? 3 : 2);
  17694. }
  17695. return x.minus(pi).abs();
  17696. }
  17697. /*
  17698. * Return the value of Decimal `x` as a string in base `baseOut`.
  17699. *
  17700. * If the optional `sd` argument is present include a binary exponent suffix.
  17701. */
  17702. function toStringBinary(x, baseOut, sd, rm) {
  17703. var base, e, i, k, len, roundUp, str, xd, y,
  17704. Ctor = x.constructor,
  17705. isExp = sd !== void 0;
  17706. if (isExp) {
  17707. checkInt32(sd, 1, MAX_DIGITS);
  17708. if (rm === void 0) rm = Ctor.rounding;
  17709. else checkInt32(rm, 0, 8);
  17710. } else {
  17711. sd = Ctor.precision;
  17712. rm = Ctor.rounding;
  17713. }
  17714. if (!x.isFinite()) {
  17715. str = nonFiniteToString(x);
  17716. } else {
  17717. str = finiteToString(x);
  17718. i = str.indexOf('.');
  17719. // Use exponential notation according to `toExpPos` and `toExpNeg`? No, but if required:
  17720. // maxBinaryExponent = floor((decimalExponent + 1) * log[2](10))
  17721. // minBinaryExponent = floor(decimalExponent * log[2](10))
  17722. // log[2](10) = 3.321928094887362347870319429489390175864
  17723. if (isExp) {
  17724. base = 2;
  17725. if (baseOut == 16) {
  17726. sd = sd * 4 - 3;
  17727. } else if (baseOut == 8) {
  17728. sd = sd * 3 - 2;
  17729. }
  17730. } else {
  17731. base = baseOut;
  17732. }
  17733. // Convert the number as an integer then divide the result by its base raised to a power such
  17734. // that the fraction part will be restored.
  17735. // Non-integer.
  17736. if (i >= 0) {
  17737. str = str.replace('.', '');
  17738. y = new Ctor(1);
  17739. y.e = str.length - i;
  17740. y.d = convertBase(finiteToString(y), 10, base);
  17741. y.e = y.d.length;
  17742. }
  17743. xd = convertBase(str, 10, base);
  17744. e = len = xd.length;
  17745. // Remove trailing zeros.
  17746. for (; xd[--len] == 0;) xd.pop();
  17747. if (!xd[0]) {
  17748. str = isExp ? '0p+0' : '0';
  17749. } else {
  17750. if (i < 0) {
  17751. e--;
  17752. } else {
  17753. x = new Ctor(x);
  17754. x.d = xd;
  17755. x.e = e;
  17756. x = divide(x, y, sd, rm, 0, base);
  17757. xd = x.d;
  17758. e = x.e;
  17759. roundUp = inexact;
  17760. }
  17761. // The rounding digit, i.e. the digit after the digit that may be rounded up.
  17762. i = xd[sd];
  17763. k = base / 2;
  17764. roundUp = roundUp || xd[sd + 1] !== void 0;
  17765. roundUp = rm < 4
  17766. ? (i !== void 0 || roundUp) && (rm === 0 || rm === (x.s < 0 ? 3 : 2))
  17767. : i > k || i === k && (rm === 4 || roundUp || rm === 6 && xd[sd - 1] & 1 ||
  17768. rm === (x.s < 0 ? 8 : 7));
  17769. xd.length = sd;
  17770. if (roundUp) {
  17771. // Rounding up may mean the previous digit has to be rounded up and so on.
  17772. for (; ++xd[--sd] > base - 1;) {
  17773. xd[sd] = 0;
  17774. if (!sd) {
  17775. ++e;
  17776. xd.unshift(1);
  17777. }
  17778. }
  17779. }
  17780. // Determine trailing zeros.
  17781. for (len = xd.length; !xd[len - 1]; --len);
  17782. // E.g. [4, 11, 15] becomes 4bf.
  17783. for (i = 0, str = ''; i < len; i++) str += NUMERALS.charAt(xd[i]);
  17784. // Add binary exponent suffix?
  17785. if (isExp) {
  17786. if (len > 1) {
  17787. if (baseOut == 16 || baseOut == 8) {
  17788. i = baseOut == 16 ? 4 : 3;
  17789. for (--len; len % i; len++) str += '0';
  17790. xd = convertBase(str, base, baseOut);
  17791. for (len = xd.length; !xd[len - 1]; --len);
  17792. // xd[0] will always be be 1
  17793. for (i = 1, str = '1.'; i < len; i++) str += NUMERALS.charAt(xd[i]);
  17794. } else {
  17795. str = str.charAt(0) + '.' + str.slice(1);
  17796. }
  17797. }
  17798. str = str + (e < 0 ? 'p' : 'p+') + e;
  17799. } else if (e < 0) {
  17800. for (; ++e;) str = '0' + str;
  17801. str = '0.' + str;
  17802. } else {
  17803. if (++e > len) for (e -= len; e-- ;) str += '0';
  17804. else if (e < len) str = str.slice(0, e) + '.' + str.slice(e);
  17805. }
  17806. }
  17807. str = (baseOut == 16 ? '0x' : baseOut == 2 ? '0b' : baseOut == 8 ? '0o' : '') + str;
  17808. }
  17809. return x.s < 0 ? '-' + str : str;
  17810. }
  17811. // Does not strip trailing zeros.
  17812. function truncate(arr, len) {
  17813. if (arr.length > len) {
  17814. arr.length = len;
  17815. return true;
  17816. }
  17817. }
  17818. // Decimal methods
  17819. /*
  17820. * abs
  17821. * acos
  17822. * acosh
  17823. * add
  17824. * asin
  17825. * asinh
  17826. * atan
  17827. * atanh
  17828. * atan2
  17829. * cbrt
  17830. * ceil
  17831. * clamp
  17832. * clone
  17833. * config
  17834. * cos
  17835. * cosh
  17836. * div
  17837. * exp
  17838. * floor
  17839. * hypot
  17840. * ln
  17841. * log
  17842. * log2
  17843. * log10
  17844. * max
  17845. * min
  17846. * mod
  17847. * mul
  17848. * pow
  17849. * random
  17850. * round
  17851. * set
  17852. * sign
  17853. * sin
  17854. * sinh
  17855. * sqrt
  17856. * sub
  17857. * sum
  17858. * tan
  17859. * tanh
  17860. * trunc
  17861. */
  17862. /*
  17863. * Return a new Decimal whose value is the absolute value of `x`.
  17864. *
  17865. * x {number|string|Decimal}
  17866. *
  17867. */
  17868. function abs(x) {
  17869. return new this(x).abs();
  17870. }
  17871. /*
  17872. * Return a new Decimal whose value is the arccosine in radians of `x`.
  17873. *
  17874. * x {number|string|Decimal}
  17875. *
  17876. */
  17877. function acos(x) {
  17878. return new this(x).acos();
  17879. }
  17880. /*
  17881. * Return a new Decimal whose value is the inverse of the hyperbolic cosine of `x`, rounded to
  17882. * `precision` significant digits using rounding mode `rounding`.
  17883. *
  17884. * x {number|string|Decimal} A value in radians.
  17885. *
  17886. */
  17887. function acosh(x) {
  17888. return new this(x).acosh();
  17889. }
  17890. /*
  17891. * Return a new Decimal whose value is the sum of `x` and `y`, rounded to `precision` significant
  17892. * digits using rounding mode `rounding`.
  17893. *
  17894. * x {number|string|Decimal}
  17895. * y {number|string|Decimal}
  17896. *
  17897. */
  17898. function add(x, y) {
  17899. return new this(x).plus(y);
  17900. }
  17901. /*
  17902. * Return a new Decimal whose value is the arcsine in radians of `x`, rounded to `precision`
  17903. * significant digits using rounding mode `rounding`.
  17904. *
  17905. * x {number|string|Decimal}
  17906. *
  17907. */
  17908. function asin(x) {
  17909. return new this(x).asin();
  17910. }
  17911. /*
  17912. * Return a new Decimal whose value is the inverse of the hyperbolic sine of `x`, rounded to
  17913. * `precision` significant digits using rounding mode `rounding`.
  17914. *
  17915. * x {number|string|Decimal} A value in radians.
  17916. *
  17917. */
  17918. function asinh(x) {
  17919. return new this(x).asinh();
  17920. }
  17921. /*
  17922. * Return a new Decimal whose value is the arctangent in radians of `x`, rounded to `precision`
  17923. * significant digits using rounding mode `rounding`.
  17924. *
  17925. * x {number|string|Decimal}
  17926. *
  17927. */
  17928. function atan(x) {
  17929. return new this(x).atan();
  17930. }
  17931. /*
  17932. * Return a new Decimal whose value is the inverse of the hyperbolic tangent of `x`, rounded to
  17933. * `precision` significant digits using rounding mode `rounding`.
  17934. *
  17935. * x {number|string|Decimal} A value in radians.
  17936. *
  17937. */
  17938. function atanh(x) {
  17939. return new this(x).atanh();
  17940. }
  17941. /*
  17942. * Return a new Decimal whose value is the arctangent in radians of `y/x` in the range -pi to pi
  17943. * (inclusive), rounded to `precision` significant digits using rounding mode `rounding`.
  17944. *
  17945. * Domain: [-Infinity, Infinity]
  17946. * Range: [-pi, pi]
  17947. *
  17948. * y {number|string|Decimal} The y-coordinate.
  17949. * x {number|string|Decimal} The x-coordinate.
  17950. *
  17951. * atan2(±0, -0) = ±pi
  17952. * atan2(±0, +0) = ±0
  17953. * atan2(±0, -x) = ±pi for x > 0
  17954. * atan2(±0, x) = ±0 for x > 0
  17955. * atan2(-y, ±0) = -pi/2 for y > 0
  17956. * atan2(y, ±0) = pi/2 for y > 0
  17957. * atan2(±y, -Infinity) = ±pi for finite y > 0
  17958. * atan2(±y, +Infinity) = ±0 for finite y > 0
  17959. * atan2(±Infinity, x) = ±pi/2 for finite x
  17960. * atan2(±Infinity, -Infinity) = ±3*pi/4
  17961. * atan2(±Infinity, +Infinity) = ±pi/4
  17962. * atan2(NaN, x) = NaN
  17963. * atan2(y, NaN) = NaN
  17964. *
  17965. */
  17966. function atan2(y, x) {
  17967. y = new this(y);
  17968. x = new this(x);
  17969. var r,
  17970. pr = this.precision,
  17971. rm = this.rounding,
  17972. wpr = pr + 4;
  17973. // Either NaN
  17974. if (!y.s || !x.s) {
  17975. r = new this(NaN);
  17976. // Both ±Infinity
  17977. } else if (!y.d && !x.d) {
  17978. r = getPi(this, wpr, 1).times(x.s > 0 ? 0.25 : 0.75);
  17979. r.s = y.s;
  17980. // x is ±Infinity or y is ±0
  17981. } else if (!x.d || y.isZero()) {
  17982. r = x.s < 0 ? getPi(this, pr, rm) : new this(0);
  17983. r.s = y.s;
  17984. // y is ±Infinity or x is ±0
  17985. } else if (!y.d || x.isZero()) {
  17986. r = getPi(this, wpr, 1).times(0.5);
  17987. r.s = y.s;
  17988. // Both non-zero and finite
  17989. } else if (x.s < 0) {
  17990. this.precision = wpr;
  17991. this.rounding = 1;
  17992. r = this.atan(divide(y, x, wpr, 1));
  17993. x = getPi(this, wpr, 1);
  17994. this.precision = pr;
  17995. this.rounding = rm;
  17996. r = y.s < 0 ? r.minus(x) : r.plus(x);
  17997. } else {
  17998. r = this.atan(divide(y, x, wpr, 1));
  17999. }
  18000. return r;
  18001. }
  18002. /*
  18003. * Return a new Decimal whose value is the cube root of `x`, rounded to `precision` significant
  18004. * digits using rounding mode `rounding`.
  18005. *
  18006. * x {number|string|Decimal}
  18007. *
  18008. */
  18009. function cbrt(x) {
  18010. return new this(x).cbrt();
  18011. }
  18012. /*
  18013. * Return a new Decimal whose value is `x` rounded to an integer using `ROUND_CEIL`.
  18014. *
  18015. * x {number|string|Decimal}
  18016. *
  18017. */
  18018. function ceil(x) {
  18019. return finalise(x = new this(x), x.e + 1, 2);
  18020. }
  18021. /*
  18022. * Return a new Decimal whose value is `x` clamped to the range delineated by `min` and `max`.
  18023. *
  18024. * x {number|string|Decimal}
  18025. * min {number|string|Decimal}
  18026. * max {number|string|Decimal}
  18027. *
  18028. */
  18029. function clamp(x, min, max) {
  18030. return new this(x).clamp(min, max);
  18031. }
  18032. /*
  18033. * Configure global settings for a Decimal constructor.
  18034. *
  18035. * `obj` is an object with one or more of the following properties,
  18036. *
  18037. * precision {number}
  18038. * rounding {number}
  18039. * toExpNeg {number}
  18040. * toExpPos {number}
  18041. * maxE {number}
  18042. * minE {number}
  18043. * modulo {number}
  18044. * crypto {boolean|number}
  18045. * defaults {true}
  18046. *
  18047. * E.g. Decimal.config({ precision: 20, rounding: 4 })
  18048. *
  18049. */
  18050. function config(obj) {
  18051. if (!obj || typeof obj !== 'object') throw Error(decimalError + 'Object expected');
  18052. var i, p, v,
  18053. useDefaults = obj.defaults === true,
  18054. ps = [
  18055. 'precision', 1, MAX_DIGITS,
  18056. 'rounding', 0, 8,
  18057. 'toExpNeg', -EXP_LIMIT, 0,
  18058. 'toExpPos', 0, EXP_LIMIT,
  18059. 'maxE', 0, EXP_LIMIT,
  18060. 'minE', -EXP_LIMIT, 0,
  18061. 'modulo', 0, 9
  18062. ];
  18063. for (i = 0; i < ps.length; i += 3) {
  18064. if (p = ps[i], useDefaults) this[p] = DEFAULTS[p];
  18065. if ((v = obj[p]) !== void 0) {
  18066. if (mathfloor(v) === v && v >= ps[i + 1] && v <= ps[i + 2]) this[p] = v;
  18067. else throw Error(invalidArgument + p + ': ' + v);
  18068. }
  18069. }
  18070. if (p = 'crypto', useDefaults) this[p] = DEFAULTS[p];
  18071. if ((v = obj[p]) !== void 0) {
  18072. if (v === true || v === false || v === 0 || v === 1) {
  18073. if (v) {
  18074. if (typeof crypto != 'undefined' && crypto &&
  18075. (crypto.getRandomValues || crypto.randomBytes)) {
  18076. this[p] = true;
  18077. } else {
  18078. throw Error(cryptoUnavailable);
  18079. }
  18080. } else {
  18081. this[p] = false;
  18082. }
  18083. } else {
  18084. throw Error(invalidArgument + p + ': ' + v);
  18085. }
  18086. }
  18087. return this;
  18088. }
  18089. /*
  18090. * Return a new Decimal whose value is the cosine of `x`, rounded to `precision` significant
  18091. * digits using rounding mode `rounding`.
  18092. *
  18093. * x {number|string|Decimal} A value in radians.
  18094. *
  18095. */
  18096. function cos(x) {
  18097. return new this(x).cos();
  18098. }
  18099. /*
  18100. * Return a new Decimal whose value is the hyperbolic cosine of `x`, rounded to precision
  18101. * significant digits using rounding mode `rounding`.
  18102. *
  18103. * x {number|string|Decimal} A value in radians.
  18104. *
  18105. */
  18106. function cosh(x) {
  18107. return new this(x).cosh();
  18108. }
  18109. /*
  18110. * Create and return a Decimal constructor with the same configuration properties as this Decimal
  18111. * constructor.
  18112. *
  18113. */
  18114. function clone(obj) {
  18115. var i, p, ps;
  18116. /*
  18117. * The Decimal constructor and exported function.
  18118. * Return a new Decimal instance.
  18119. *
  18120. * v {number|string|Decimal} A numeric value.
  18121. *
  18122. */
  18123. function Decimal(v) {
  18124. var e, i, t,
  18125. x = this;
  18126. // Decimal called without new.
  18127. if (!(x instanceof Decimal)) return new Decimal(v);
  18128. // Retain a reference to this Decimal constructor, and shadow Decimal.prototype.constructor
  18129. // which points to Object.
  18130. x.constructor = Decimal;
  18131. // Duplicate.
  18132. if (isDecimalInstance(v)) {
  18133. x.s = v.s;
  18134. if (external) {
  18135. if (!v.d || v.e > Decimal.maxE) {
  18136. // Infinity.
  18137. x.e = NaN;
  18138. x.d = null;
  18139. } else if (v.e < Decimal.minE) {
  18140. // Zero.
  18141. x.e = 0;
  18142. x.d = [0];
  18143. } else {
  18144. x.e = v.e;
  18145. x.d = v.d.slice();
  18146. }
  18147. } else {
  18148. x.e = v.e;
  18149. x.d = v.d ? v.d.slice() : v.d;
  18150. }
  18151. return;
  18152. }
  18153. t = typeof v;
  18154. if (t === 'number') {
  18155. if (v === 0) {
  18156. x.s = 1 / v < 0 ? -1 : 1;
  18157. x.e = 0;
  18158. x.d = [0];
  18159. return;
  18160. }
  18161. if (v < 0) {
  18162. v = -v;
  18163. x.s = -1;
  18164. } else {
  18165. x.s = 1;
  18166. }
  18167. // Fast path for small integers.
  18168. if (v === ~~v && v < 1e7) {
  18169. for (e = 0, i = v; i >= 10; i /= 10) e++;
  18170. if (external) {
  18171. if (e > Decimal.maxE) {
  18172. x.e = NaN;
  18173. x.d = null;
  18174. } else if (e < Decimal.minE) {
  18175. x.e = 0;
  18176. x.d = [0];
  18177. } else {
  18178. x.e = e;
  18179. x.d = [v];
  18180. }
  18181. } else {
  18182. x.e = e;
  18183. x.d = [v];
  18184. }
  18185. return;
  18186. // Infinity, NaN.
  18187. } else if (v * 0 !== 0) {
  18188. if (!v) x.s = NaN;
  18189. x.e = NaN;
  18190. x.d = null;
  18191. return;
  18192. }
  18193. return parseDecimal(x, v.toString());
  18194. } else if (t !== 'string') {
  18195. throw Error(invalidArgument + v);
  18196. }
  18197. // Minus sign?
  18198. if ((i = v.charCodeAt(0)) === 45) {
  18199. v = v.slice(1);
  18200. x.s = -1;
  18201. } else {
  18202. // Plus sign?
  18203. if (i === 43) v = v.slice(1);
  18204. x.s = 1;
  18205. }
  18206. return isDecimal.test(v) ? parseDecimal(x, v) : parseOther(x, v);
  18207. }
  18208. Decimal.prototype = P;
  18209. Decimal.ROUND_UP = 0;
  18210. Decimal.ROUND_DOWN = 1;
  18211. Decimal.ROUND_CEIL = 2;
  18212. Decimal.ROUND_FLOOR = 3;
  18213. Decimal.ROUND_HALF_UP = 4;
  18214. Decimal.ROUND_HALF_DOWN = 5;
  18215. Decimal.ROUND_HALF_EVEN = 6;
  18216. Decimal.ROUND_HALF_CEIL = 7;
  18217. Decimal.ROUND_HALF_FLOOR = 8;
  18218. Decimal.EUCLID = 9;
  18219. Decimal.config = Decimal.set = config;
  18220. Decimal.clone = clone;
  18221. Decimal.isDecimal = isDecimalInstance;
  18222. Decimal.abs = abs;
  18223. Decimal.acos = acos;
  18224. Decimal.acosh = acosh; // ES6
  18225. Decimal.add = add;
  18226. Decimal.asin = asin;
  18227. Decimal.asinh = asinh; // ES6
  18228. Decimal.atan = atan;
  18229. Decimal.atanh = atanh; // ES6
  18230. Decimal.atan2 = atan2;
  18231. Decimal.cbrt = cbrt; // ES6
  18232. Decimal.ceil = ceil;
  18233. Decimal.clamp = clamp;
  18234. Decimal.cos = cos;
  18235. Decimal.cosh = cosh; // ES6
  18236. Decimal.div = div;
  18237. Decimal.exp = exp;
  18238. Decimal.floor = floor;
  18239. Decimal.hypot = hypot; // ES6
  18240. Decimal.ln = ln;
  18241. Decimal.log = log;
  18242. Decimal.log10 = log10; // ES6
  18243. Decimal.log2 = log2; // ES6
  18244. Decimal.max = max;
  18245. Decimal.min = min;
  18246. Decimal.mod = mod;
  18247. Decimal.mul = mul;
  18248. Decimal.pow = pow;
  18249. Decimal.random = random;
  18250. Decimal.round = round;
  18251. Decimal.sign = sign; // ES6
  18252. Decimal.sin = sin;
  18253. Decimal.sinh = sinh; // ES6
  18254. Decimal.sqrt = sqrt;
  18255. Decimal.sub = sub;
  18256. Decimal.sum = sum;
  18257. Decimal.tan = tan;
  18258. Decimal.tanh = tanh; // ES6
  18259. Decimal.trunc = trunc; // ES6
  18260. if (obj === void 0) obj = {};
  18261. if (obj) {
  18262. if (obj.defaults !== true) {
  18263. ps = ['precision', 'rounding', 'toExpNeg', 'toExpPos', 'maxE', 'minE', 'modulo', 'crypto'];
  18264. for (i = 0; i < ps.length;) if (!obj.hasOwnProperty(p = ps[i++])) obj[p] = this[p];
  18265. }
  18266. }
  18267. Decimal.config(obj);
  18268. return Decimal;
  18269. }
  18270. /*
  18271. * Return a new Decimal whose value is `x` divided by `y`, rounded to `precision` significant
  18272. * digits using rounding mode `rounding`.
  18273. *
  18274. * x {number|string|Decimal}
  18275. * y {number|string|Decimal}
  18276. *
  18277. */
  18278. function div(x, y) {
  18279. return new this(x).div(y);
  18280. }
  18281. /*
  18282. * Return a new Decimal whose value is the natural exponential of `x`, rounded to `precision`
  18283. * significant digits using rounding mode `rounding`.
  18284. *
  18285. * x {number|string|Decimal} The power to which to raise the base of the natural log.
  18286. *
  18287. */
  18288. function exp(x) {
  18289. return new this(x).exp();
  18290. }
  18291. /*
  18292. * Return a new Decimal whose value is `x` round to an integer using `ROUND_FLOOR`.
  18293. *
  18294. * x {number|string|Decimal}
  18295. *
  18296. */
  18297. function floor(x) {
  18298. return finalise(x = new this(x), x.e + 1, 3);
  18299. }
  18300. /*
  18301. * Return a new Decimal whose value is the square root of the sum of the squares of the arguments,
  18302. * rounded to `precision` significant digits using rounding mode `rounding`.
  18303. *
  18304. * hypot(a, b, ...) = sqrt(a^2 + b^2 + ...)
  18305. *
  18306. * arguments {number|string|Decimal}
  18307. *
  18308. */
  18309. function hypot() {
  18310. var i, n,
  18311. t = new this(0);
  18312. external = false;
  18313. for (i = 0; i < arguments.length;) {
  18314. n = new this(arguments[i++]);
  18315. if (!n.d) {
  18316. if (n.s) {
  18317. external = true;
  18318. return new this(1 / 0);
  18319. }
  18320. t = n;
  18321. } else if (t.d) {
  18322. t = t.plus(n.times(n));
  18323. }
  18324. }
  18325. external = true;
  18326. return t.sqrt();
  18327. }
  18328. /*
  18329. * Return true if object is a Decimal instance (where Decimal is any Decimal constructor),
  18330. * otherwise return false.
  18331. *
  18332. */
  18333. function isDecimalInstance(obj) {
  18334. return obj instanceof Decimal || obj && obj.toStringTag === tag || false;
  18335. }
  18336. /*
  18337. * Return a new Decimal whose value is the natural logarithm of `x`, rounded to `precision`
  18338. * significant digits using rounding mode `rounding`.
  18339. *
  18340. * x {number|string|Decimal}
  18341. *
  18342. */
  18343. function ln(x) {
  18344. return new this(x).ln();
  18345. }
  18346. /*
  18347. * Return a new Decimal whose value is the log of `x` to the base `y`, or to base 10 if no base
  18348. * is specified, rounded to `precision` significant digits using rounding mode `rounding`.
  18349. *
  18350. * log[y](x)
  18351. *
  18352. * x {number|string|Decimal} The argument of the logarithm.
  18353. * y {number|string|Decimal} The base of the logarithm.
  18354. *
  18355. */
  18356. function log(x, y) {
  18357. return new this(x).log(y);
  18358. }
  18359. /*
  18360. * Return a new Decimal whose value is the base 2 logarithm of `x`, rounded to `precision`
  18361. * significant digits using rounding mode `rounding`.
  18362. *
  18363. * x {number|string|Decimal}
  18364. *
  18365. */
  18366. function log2(x) {
  18367. return new this(x).log(2);
  18368. }
  18369. /*
  18370. * Return a new Decimal whose value is the base 10 logarithm of `x`, rounded to `precision`
  18371. * significant digits using rounding mode `rounding`.
  18372. *
  18373. * x {number|string|Decimal}
  18374. *
  18375. */
  18376. function log10(x) {
  18377. return new this(x).log(10);
  18378. }
  18379. /*
  18380. * Return a new Decimal whose value is the maximum of the arguments.
  18381. *
  18382. * arguments {number|string|Decimal}
  18383. *
  18384. */
  18385. function max() {
  18386. return maxOrMin(this, arguments, 'lt');
  18387. }
  18388. /*
  18389. * Return a new Decimal whose value is the minimum of the arguments.
  18390. *
  18391. * arguments {number|string|Decimal}
  18392. *
  18393. */
  18394. function min() {
  18395. return maxOrMin(this, arguments, 'gt');
  18396. }
  18397. /*
  18398. * Return a new Decimal whose value is `x` modulo `y`, rounded to `precision` significant digits
  18399. * using rounding mode `rounding`.
  18400. *
  18401. * x {number|string|Decimal}
  18402. * y {number|string|Decimal}
  18403. *
  18404. */
  18405. function mod(x, y) {
  18406. return new this(x).mod(y);
  18407. }
  18408. /*
  18409. * Return a new Decimal whose value is `x` multiplied by `y`, rounded to `precision` significant
  18410. * digits using rounding mode `rounding`.
  18411. *
  18412. * x {number|string|Decimal}
  18413. * y {number|string|Decimal}
  18414. *
  18415. */
  18416. function mul(x, y) {
  18417. return new this(x).mul(y);
  18418. }
  18419. /*
  18420. * Return a new Decimal whose value is `x` raised to the power `y`, rounded to precision
  18421. * significant digits using rounding mode `rounding`.
  18422. *
  18423. * x {number|string|Decimal} The base.
  18424. * y {number|string|Decimal} The exponent.
  18425. *
  18426. */
  18427. function pow(x, y) {
  18428. return new this(x).pow(y);
  18429. }
  18430. /*
  18431. * Returns a new Decimal with a random value equal to or greater than 0 and less than 1, and with
  18432. * `sd`, or `Decimal.precision` if `sd` is omitted, significant digits (or less if trailing zeros
  18433. * are produced).
  18434. *
  18435. * [sd] {number} Significant digits. Integer, 0 to MAX_DIGITS inclusive.
  18436. *
  18437. */
  18438. function random(sd) {
  18439. var d, e, k, n,
  18440. i = 0,
  18441. r = new this(1),
  18442. rd = [];
  18443. if (sd === void 0) sd = this.precision;
  18444. else checkInt32(sd, 1, MAX_DIGITS);
  18445. k = Math.ceil(sd / LOG_BASE);
  18446. if (!this.crypto) {
  18447. for (; i < k;) rd[i++] = Math.random() * 1e7 | 0;
  18448. // Browsers supporting crypto.getRandomValues.
  18449. } else if (crypto.getRandomValues) {
  18450. d = crypto.getRandomValues(new Uint32Array(k));
  18451. for (; i < k;) {
  18452. n = d[i];
  18453. // 0 <= n < 4294967296
  18454. // Probability n >= 4.29e9, is 4967296 / 4294967296 = 0.00116 (1 in 865).
  18455. if (n >= 4.29e9) {
  18456. d[i] = crypto.getRandomValues(new Uint32Array(1))[0];
  18457. } else {
  18458. // 0 <= n <= 4289999999
  18459. // 0 <= (n % 1e7) <= 9999999
  18460. rd[i++] = n % 1e7;
  18461. }
  18462. }
  18463. // Node.js supporting crypto.randomBytes.
  18464. } else if (crypto.randomBytes) {
  18465. // buffer
  18466. d = crypto.randomBytes(k *= 4);
  18467. for (; i < k;) {
  18468. // 0 <= n < 2147483648
  18469. n = d[i] + (d[i + 1] << 8) + (d[i + 2] << 16) + ((d[i + 3] & 0x7f) << 24);
  18470. // Probability n >= 2.14e9, is 7483648 / 2147483648 = 0.0035 (1 in 286).
  18471. if (n >= 2.14e9) {
  18472. crypto.randomBytes(4).copy(d, i);
  18473. } else {
  18474. // 0 <= n <= 2139999999
  18475. // 0 <= (n % 1e7) <= 9999999
  18476. rd.push(n % 1e7);
  18477. i += 4;
  18478. }
  18479. }
  18480. i = k / 4;
  18481. } else {
  18482. throw Error(cryptoUnavailable);
  18483. }
  18484. k = rd[--i];
  18485. sd %= LOG_BASE;
  18486. // Convert trailing digits to zeros according to sd.
  18487. if (k && sd) {
  18488. n = mathpow(10, LOG_BASE - sd);
  18489. rd[i] = (k / n | 0) * n;
  18490. }
  18491. // Remove trailing words which are zero.
  18492. for (; rd[i] === 0; i--) rd.pop();
  18493. // Zero?
  18494. if (i < 0) {
  18495. e = 0;
  18496. rd = [0];
  18497. } else {
  18498. e = -1;
  18499. // Remove leading words which are zero and adjust exponent accordingly.
  18500. for (; rd[0] === 0; e -= LOG_BASE) rd.shift();
  18501. // Count the digits of the first word of rd to determine leading zeros.
  18502. for (k = 1, n = rd[0]; n >= 10; n /= 10) k++;
  18503. // Adjust the exponent for leading zeros of the first word of rd.
  18504. if (k < LOG_BASE) e -= LOG_BASE - k;
  18505. }
  18506. r.e = e;
  18507. r.d = rd;
  18508. return r;
  18509. }
  18510. /*
  18511. * Return a new Decimal whose value is `x` rounded to an integer using rounding mode `rounding`.
  18512. *
  18513. * To emulate `Math.round`, set rounding to 7 (ROUND_HALF_CEIL).
  18514. *
  18515. * x {number|string|Decimal}
  18516. *
  18517. */
  18518. function round(x) {
  18519. return finalise(x = new this(x), x.e + 1, this.rounding);
  18520. }
  18521. /*
  18522. * Return
  18523. * 1 if x > 0,
  18524. * -1 if x < 0,
  18525. * 0 if x is 0,
  18526. * -0 if x is -0,
  18527. * NaN otherwise
  18528. *
  18529. * x {number|string|Decimal}
  18530. *
  18531. */
  18532. function sign(x) {
  18533. x = new this(x);
  18534. return x.d ? (x.d[0] ? x.s : 0 * x.s) : x.s || NaN;
  18535. }
  18536. /*
  18537. * Return a new Decimal whose value is the sine of `x`, rounded to `precision` significant digits
  18538. * using rounding mode `rounding`.
  18539. *
  18540. * x {number|string|Decimal} A value in radians.
  18541. *
  18542. */
  18543. function sin(x) {
  18544. return new this(x).sin();
  18545. }
  18546. /*
  18547. * Return a new Decimal whose value is the hyperbolic sine of `x`, rounded to `precision`
  18548. * significant digits using rounding mode `rounding`.
  18549. *
  18550. * x {number|string|Decimal} A value in radians.
  18551. *
  18552. */
  18553. function sinh(x) {
  18554. return new this(x).sinh();
  18555. }
  18556. /*
  18557. * Return a new Decimal whose value is the square root of `x`, rounded to `precision` significant
  18558. * digits using rounding mode `rounding`.
  18559. *
  18560. * x {number|string|Decimal}
  18561. *
  18562. */
  18563. function sqrt(x) {
  18564. return new this(x).sqrt();
  18565. }
  18566. /*
  18567. * Return a new Decimal whose value is `x` minus `y`, rounded to `precision` significant digits
  18568. * using rounding mode `rounding`.
  18569. *
  18570. * x {number|string|Decimal}
  18571. * y {number|string|Decimal}
  18572. *
  18573. */
  18574. function sub(x, y) {
  18575. return new this(x).sub(y);
  18576. }
  18577. /*
  18578. * Return a new Decimal whose value is the sum of the arguments, rounded to `precision`
  18579. * significant digits using rounding mode `rounding`.
  18580. *
  18581. * Only the result is rounded, not the intermediate calculations.
  18582. *
  18583. * arguments {number|string|Decimal}
  18584. *
  18585. */
  18586. function sum() {
  18587. var i = 0,
  18588. args = arguments,
  18589. x = new this(args[i]);
  18590. external = false;
  18591. for (; x.s && ++i < args.length;) x = x.plus(args[i]);
  18592. external = true;
  18593. return finalise(x, this.precision, this.rounding);
  18594. }
  18595. /*
  18596. * Return a new Decimal whose value is the tangent of `x`, rounded to `precision` significant
  18597. * digits using rounding mode `rounding`.
  18598. *
  18599. * x {number|string|Decimal} A value in radians.
  18600. *
  18601. */
  18602. function tan(x) {
  18603. return new this(x).tan();
  18604. }
  18605. /*
  18606. * Return a new Decimal whose value is the hyperbolic tangent of `x`, rounded to `precision`
  18607. * significant digits using rounding mode `rounding`.
  18608. *
  18609. * x {number|string|Decimal} A value in radians.
  18610. *
  18611. */
  18612. function tanh(x) {
  18613. return new this(x).tanh();
  18614. }
  18615. /*
  18616. * Return a new Decimal whose value is `x` truncated to an integer.
  18617. *
  18618. * x {number|string|Decimal}
  18619. *
  18620. */
  18621. function trunc(x) {
  18622. return finalise(x = new this(x), x.e + 1, 1);
  18623. }
  18624. // Create and configure initial Decimal constructor.
  18625. Decimal = clone(DEFAULTS);
  18626. Decimal.prototype.constructor = Decimal;
  18627. Decimal['default'] = Decimal.Decimal = Decimal;
  18628. // Create the internal constants from their string values.
  18629. LN10 = new Decimal(LN10);
  18630. PI = new Decimal(PI);
  18631. // Export.
  18632. // AMD.
  18633. if (true) {
  18634. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () {
  18635. return Decimal;
  18636. }).call(exports, __webpack_require__, exports, module),
  18637. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  18638. // Node and other environments that support module.exports.
  18639. } else {}
  18640. })(this);
  18641. /***/ }),
  18642. /***/ "../../node_modules/define-properties/index.js":
  18643. /*!*****************************************************!*\
  18644. !*** ../../node_modules/define-properties/index.js ***!
  18645. \*****************************************************/
  18646. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  18647. "use strict";
  18648. var keys = __webpack_require__(/*! object-keys */ "../../node_modules/object-keys/index.js");
  18649. var hasSymbols = typeof Symbol === 'function' && typeof Symbol('foo') === 'symbol';
  18650. var toStr = Object.prototype.toString;
  18651. var concat = Array.prototype.concat;
  18652. var origDefineProperty = Object.defineProperty;
  18653. var isFunction = function (fn) {
  18654. return typeof fn === 'function' && toStr.call(fn) === '[object Function]';
  18655. };
  18656. var hasPropertyDescriptors = __webpack_require__(/*! has-property-descriptors */ "../../node_modules/has-property-descriptors/index.js")();
  18657. var supportsDescriptors = origDefineProperty && hasPropertyDescriptors;
  18658. var defineProperty = function (object, name, value, predicate) {
  18659. if (name in object && (!isFunction(predicate) || !predicate())) {
  18660. return;
  18661. }
  18662. if (supportsDescriptors) {
  18663. origDefineProperty(object, name, {
  18664. configurable: true,
  18665. enumerable: false,
  18666. value: value,
  18667. writable: true
  18668. });
  18669. } else {
  18670. object[name] = value; // eslint-disable-line no-param-reassign
  18671. }
  18672. };
  18673. var defineProperties = function (object, map) {
  18674. var predicates = arguments.length > 2 ? arguments[2] : {};
  18675. var props = keys(map);
  18676. if (hasSymbols) {
  18677. props = concat.call(props, Object.getOwnPropertySymbols(map));
  18678. }
  18679. for (var i = 0; i < props.length; i += 1) {
  18680. defineProperty(object, props[i], map[props[i]], predicates[props[i]]);
  18681. }
  18682. };
  18683. defineProperties.supportsDescriptors = !!supportsDescriptors;
  18684. module.exports = defineProperties;
  18685. /***/ }),
  18686. /***/ "../../node_modules/des.js/lib/des.js":
  18687. /*!********************************************!*\
  18688. !*** ../../node_modules/des.js/lib/des.js ***!
  18689. \********************************************/
  18690. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  18691. "use strict";
  18692. exports.utils = __webpack_require__(/*! ./des/utils */ "../../node_modules/des.js/lib/des/utils.js");
  18693. exports.Cipher = __webpack_require__(/*! ./des/cipher */ "../../node_modules/des.js/lib/des/cipher.js");
  18694. exports.DES = __webpack_require__(/*! ./des/des */ "../../node_modules/des.js/lib/des/des.js");
  18695. exports.CBC = __webpack_require__(/*! ./des/cbc */ "../../node_modules/des.js/lib/des/cbc.js");
  18696. exports.EDE = __webpack_require__(/*! ./des/ede */ "../../node_modules/des.js/lib/des/ede.js");
  18697. /***/ }),
  18698. /***/ "../../node_modules/des.js/lib/des/cbc.js":
  18699. /*!************************************************!*\
  18700. !*** ../../node_modules/des.js/lib/des/cbc.js ***!
  18701. \************************************************/
  18702. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  18703. "use strict";
  18704. var assert = __webpack_require__(/*! minimalistic-assert */ "../../node_modules/minimalistic-assert/index.js");
  18705. var inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js");
  18706. var proto = {};
  18707. function CBCState(iv) {
  18708. assert.equal(iv.length, 8, 'Invalid IV length');
  18709. this.iv = new Array(8);
  18710. for (var i = 0; i < this.iv.length; i++)
  18711. this.iv[i] = iv[i];
  18712. }
  18713. function instantiate(Base) {
  18714. function CBC(options) {
  18715. Base.call(this, options);
  18716. this._cbcInit();
  18717. }
  18718. inherits(CBC, Base);
  18719. var keys = Object.keys(proto);
  18720. for (var i = 0; i < keys.length; i++) {
  18721. var key = keys[i];
  18722. CBC.prototype[key] = proto[key];
  18723. }
  18724. CBC.create = function create(options) {
  18725. return new CBC(options);
  18726. };
  18727. return CBC;
  18728. }
  18729. exports.instantiate = instantiate;
  18730. proto._cbcInit = function _cbcInit() {
  18731. var state = new CBCState(this.options.iv);
  18732. this._cbcState = state;
  18733. };
  18734. proto._update = function _update(inp, inOff, out, outOff) {
  18735. var state = this._cbcState;
  18736. var superProto = this.constructor.super_.prototype;
  18737. var iv = state.iv;
  18738. if (this.type === 'encrypt') {
  18739. for (var i = 0; i < this.blockSize; i++)
  18740. iv[i] ^= inp[inOff + i];
  18741. superProto._update.call(this, iv, 0, out, outOff);
  18742. for (var i = 0; i < this.blockSize; i++)
  18743. iv[i] = out[outOff + i];
  18744. } else {
  18745. superProto._update.call(this, inp, inOff, out, outOff);
  18746. for (var i = 0; i < this.blockSize; i++)
  18747. out[outOff + i] ^= iv[i];
  18748. for (var i = 0; i < this.blockSize; i++)
  18749. iv[i] = inp[inOff + i];
  18750. }
  18751. };
  18752. /***/ }),
  18753. /***/ "../../node_modules/des.js/lib/des/cipher.js":
  18754. /*!***************************************************!*\
  18755. !*** ../../node_modules/des.js/lib/des/cipher.js ***!
  18756. \***************************************************/
  18757. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  18758. "use strict";
  18759. var assert = __webpack_require__(/*! minimalistic-assert */ "../../node_modules/minimalistic-assert/index.js");
  18760. function Cipher(options) {
  18761. this.options = options;
  18762. this.type = this.options.type;
  18763. this.blockSize = 8;
  18764. this._init();
  18765. this.buffer = new Array(this.blockSize);
  18766. this.bufferOff = 0;
  18767. }
  18768. module.exports = Cipher;
  18769. Cipher.prototype._init = function _init() {
  18770. // Might be overrided
  18771. };
  18772. Cipher.prototype.update = function update(data) {
  18773. if (data.length === 0)
  18774. return [];
  18775. if (this.type === 'decrypt')
  18776. return this._updateDecrypt(data);
  18777. else
  18778. return this._updateEncrypt(data);
  18779. };
  18780. Cipher.prototype._buffer = function _buffer(data, off) {
  18781. // Append data to buffer
  18782. var min = Math.min(this.buffer.length - this.bufferOff, data.length - off);
  18783. for (var i = 0; i < min; i++)
  18784. this.buffer[this.bufferOff + i] = data[off + i];
  18785. this.bufferOff += min;
  18786. // Shift next
  18787. return min;
  18788. };
  18789. Cipher.prototype._flushBuffer = function _flushBuffer(out, off) {
  18790. this._update(this.buffer, 0, out, off);
  18791. this.bufferOff = 0;
  18792. return this.blockSize;
  18793. };
  18794. Cipher.prototype._updateEncrypt = function _updateEncrypt(data) {
  18795. var inputOff = 0;
  18796. var outputOff = 0;
  18797. var count = ((this.bufferOff + data.length) / this.blockSize) | 0;
  18798. var out = new Array(count * this.blockSize);
  18799. if (this.bufferOff !== 0) {
  18800. inputOff += this._buffer(data, inputOff);
  18801. if (this.bufferOff === this.buffer.length)
  18802. outputOff += this._flushBuffer(out, outputOff);
  18803. }
  18804. // Write blocks
  18805. var max = data.length - ((data.length - inputOff) % this.blockSize);
  18806. for (; inputOff < max; inputOff += this.blockSize) {
  18807. this._update(data, inputOff, out, outputOff);
  18808. outputOff += this.blockSize;
  18809. }
  18810. // Queue rest
  18811. for (; inputOff < data.length; inputOff++, this.bufferOff++)
  18812. this.buffer[this.bufferOff] = data[inputOff];
  18813. return out;
  18814. };
  18815. Cipher.prototype._updateDecrypt = function _updateDecrypt(data) {
  18816. var inputOff = 0;
  18817. var outputOff = 0;
  18818. var count = Math.ceil((this.bufferOff + data.length) / this.blockSize) - 1;
  18819. var out = new Array(count * this.blockSize);
  18820. // TODO(indutny): optimize it, this is far from optimal
  18821. for (; count > 0; count--) {
  18822. inputOff += this._buffer(data, inputOff);
  18823. outputOff += this._flushBuffer(out, outputOff);
  18824. }
  18825. // Buffer rest of the input
  18826. inputOff += this._buffer(data, inputOff);
  18827. return out;
  18828. };
  18829. Cipher.prototype.final = function final(buffer) {
  18830. var first;
  18831. if (buffer)
  18832. first = this.update(buffer);
  18833. var last;
  18834. if (this.type === 'encrypt')
  18835. last = this._finalEncrypt();
  18836. else
  18837. last = this._finalDecrypt();
  18838. if (first)
  18839. return first.concat(last);
  18840. else
  18841. return last;
  18842. };
  18843. Cipher.prototype._pad = function _pad(buffer, off) {
  18844. if (off === 0)
  18845. return false;
  18846. while (off < buffer.length)
  18847. buffer[off++] = 0;
  18848. return true;
  18849. };
  18850. Cipher.prototype._finalEncrypt = function _finalEncrypt() {
  18851. if (!this._pad(this.buffer, this.bufferOff))
  18852. return [];
  18853. var out = new Array(this.blockSize);
  18854. this._update(this.buffer, 0, out, 0);
  18855. return out;
  18856. };
  18857. Cipher.prototype._unpad = function _unpad(buffer) {
  18858. return buffer;
  18859. };
  18860. Cipher.prototype._finalDecrypt = function _finalDecrypt() {
  18861. assert.equal(this.bufferOff, this.blockSize, 'Not enough data to decrypt');
  18862. var out = new Array(this.blockSize);
  18863. this._flushBuffer(out, 0);
  18864. return this._unpad(out);
  18865. };
  18866. /***/ }),
  18867. /***/ "../../node_modules/des.js/lib/des/des.js":
  18868. /*!************************************************!*\
  18869. !*** ../../node_modules/des.js/lib/des/des.js ***!
  18870. \************************************************/
  18871. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  18872. "use strict";
  18873. var assert = __webpack_require__(/*! minimalistic-assert */ "../../node_modules/minimalistic-assert/index.js");
  18874. var inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js");
  18875. var utils = __webpack_require__(/*! ./utils */ "../../node_modules/des.js/lib/des/utils.js");
  18876. var Cipher = __webpack_require__(/*! ./cipher */ "../../node_modules/des.js/lib/des/cipher.js");
  18877. function DESState() {
  18878. this.tmp = new Array(2);
  18879. this.keys = null;
  18880. }
  18881. function DES(options) {
  18882. Cipher.call(this, options);
  18883. var state = new DESState();
  18884. this._desState = state;
  18885. this.deriveKeys(state, options.key);
  18886. }
  18887. inherits(DES, Cipher);
  18888. module.exports = DES;
  18889. DES.create = function create(options) {
  18890. return new DES(options);
  18891. };
  18892. var shiftTable = [
  18893. 1, 1, 2, 2, 2, 2, 2, 2,
  18894. 1, 2, 2, 2, 2, 2, 2, 1
  18895. ];
  18896. DES.prototype.deriveKeys = function deriveKeys(state, key) {
  18897. state.keys = new Array(16 * 2);
  18898. assert.equal(key.length, this.blockSize, 'Invalid key length');
  18899. var kL = utils.readUInt32BE(key, 0);
  18900. var kR = utils.readUInt32BE(key, 4);
  18901. utils.pc1(kL, kR, state.tmp, 0);
  18902. kL = state.tmp[0];
  18903. kR = state.tmp[1];
  18904. for (var i = 0; i < state.keys.length; i += 2) {
  18905. var shift = shiftTable[i >>> 1];
  18906. kL = utils.r28shl(kL, shift);
  18907. kR = utils.r28shl(kR, shift);
  18908. utils.pc2(kL, kR, state.keys, i);
  18909. }
  18910. };
  18911. DES.prototype._update = function _update(inp, inOff, out, outOff) {
  18912. var state = this._desState;
  18913. var l = utils.readUInt32BE(inp, inOff);
  18914. var r = utils.readUInt32BE(inp, inOff + 4);
  18915. // Initial Permutation
  18916. utils.ip(l, r, state.tmp, 0);
  18917. l = state.tmp[0];
  18918. r = state.tmp[1];
  18919. if (this.type === 'encrypt')
  18920. this._encrypt(state, l, r, state.tmp, 0);
  18921. else
  18922. this._decrypt(state, l, r, state.tmp, 0);
  18923. l = state.tmp[0];
  18924. r = state.tmp[1];
  18925. utils.writeUInt32BE(out, l, outOff);
  18926. utils.writeUInt32BE(out, r, outOff + 4);
  18927. };
  18928. DES.prototype._pad = function _pad(buffer, off) {
  18929. var value = buffer.length - off;
  18930. for (var i = off; i < buffer.length; i++)
  18931. buffer[i] = value;
  18932. return true;
  18933. };
  18934. DES.prototype._unpad = function _unpad(buffer) {
  18935. var pad = buffer[buffer.length - 1];
  18936. for (var i = buffer.length - pad; i < buffer.length; i++)
  18937. assert.equal(buffer[i], pad);
  18938. return buffer.slice(0, buffer.length - pad);
  18939. };
  18940. DES.prototype._encrypt = function _encrypt(state, lStart, rStart, out, off) {
  18941. var l = lStart;
  18942. var r = rStart;
  18943. // Apply f() x16 times
  18944. for (var i = 0; i < state.keys.length; i += 2) {
  18945. var keyL = state.keys[i];
  18946. var keyR = state.keys[i + 1];
  18947. // f(r, k)
  18948. utils.expand(r, state.tmp, 0);
  18949. keyL ^= state.tmp[0];
  18950. keyR ^= state.tmp[1];
  18951. var s = utils.substitute(keyL, keyR);
  18952. var f = utils.permute(s);
  18953. var t = r;
  18954. r = (l ^ f) >>> 0;
  18955. l = t;
  18956. }
  18957. // Reverse Initial Permutation
  18958. utils.rip(r, l, out, off);
  18959. };
  18960. DES.prototype._decrypt = function _decrypt(state, lStart, rStart, out, off) {
  18961. var l = rStart;
  18962. var r = lStart;
  18963. // Apply f() x16 times
  18964. for (var i = state.keys.length - 2; i >= 0; i -= 2) {
  18965. var keyL = state.keys[i];
  18966. var keyR = state.keys[i + 1];
  18967. // f(r, k)
  18968. utils.expand(l, state.tmp, 0);
  18969. keyL ^= state.tmp[0];
  18970. keyR ^= state.tmp[1];
  18971. var s = utils.substitute(keyL, keyR);
  18972. var f = utils.permute(s);
  18973. var t = l;
  18974. l = (r ^ f) >>> 0;
  18975. r = t;
  18976. }
  18977. // Reverse Initial Permutation
  18978. utils.rip(l, r, out, off);
  18979. };
  18980. /***/ }),
  18981. /***/ "../../node_modules/des.js/lib/des/ede.js":
  18982. /*!************************************************!*\
  18983. !*** ../../node_modules/des.js/lib/des/ede.js ***!
  18984. \************************************************/
  18985. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  18986. "use strict";
  18987. var assert = __webpack_require__(/*! minimalistic-assert */ "../../node_modules/minimalistic-assert/index.js");
  18988. var inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js");
  18989. var Cipher = __webpack_require__(/*! ./cipher */ "../../node_modules/des.js/lib/des/cipher.js");
  18990. var DES = __webpack_require__(/*! ./des */ "../../node_modules/des.js/lib/des/des.js");
  18991. function EDEState(type, key) {
  18992. assert.equal(key.length, 24, 'Invalid key length');
  18993. var k1 = key.slice(0, 8);
  18994. var k2 = key.slice(8, 16);
  18995. var k3 = key.slice(16, 24);
  18996. if (type === 'encrypt') {
  18997. this.ciphers = [
  18998. DES.create({ type: 'encrypt', key: k1 }),
  18999. DES.create({ type: 'decrypt', key: k2 }),
  19000. DES.create({ type: 'encrypt', key: k3 })
  19001. ];
  19002. } else {
  19003. this.ciphers = [
  19004. DES.create({ type: 'decrypt', key: k3 }),
  19005. DES.create({ type: 'encrypt', key: k2 }),
  19006. DES.create({ type: 'decrypt', key: k1 })
  19007. ];
  19008. }
  19009. }
  19010. function EDE(options) {
  19011. Cipher.call(this, options);
  19012. var state = new EDEState(this.type, this.options.key);
  19013. this._edeState = state;
  19014. }
  19015. inherits(EDE, Cipher);
  19016. module.exports = EDE;
  19017. EDE.create = function create(options) {
  19018. return new EDE(options);
  19019. };
  19020. EDE.prototype._update = function _update(inp, inOff, out, outOff) {
  19021. var state = this._edeState;
  19022. state.ciphers[0]._update(inp, inOff, out, outOff);
  19023. state.ciphers[1]._update(out, outOff, out, outOff);
  19024. state.ciphers[2]._update(out, outOff, out, outOff);
  19025. };
  19026. EDE.prototype._pad = DES.prototype._pad;
  19027. EDE.prototype._unpad = DES.prototype._unpad;
  19028. /***/ }),
  19029. /***/ "../../node_modules/des.js/lib/des/utils.js":
  19030. /*!**************************************************!*\
  19031. !*** ../../node_modules/des.js/lib/des/utils.js ***!
  19032. \**************************************************/
  19033. /***/ ((__unused_webpack_module, exports) => {
  19034. "use strict";
  19035. exports.readUInt32BE = function readUInt32BE(bytes, off) {
  19036. var res = (bytes[0 + off] << 24) |
  19037. (bytes[1 + off] << 16) |
  19038. (bytes[2 + off] << 8) |
  19039. bytes[3 + off];
  19040. return res >>> 0;
  19041. };
  19042. exports.writeUInt32BE = function writeUInt32BE(bytes, value, off) {
  19043. bytes[0 + off] = value >>> 24;
  19044. bytes[1 + off] = (value >>> 16) & 0xff;
  19045. bytes[2 + off] = (value >>> 8) & 0xff;
  19046. bytes[3 + off] = value & 0xff;
  19047. };
  19048. exports.ip = function ip(inL, inR, out, off) {
  19049. var outL = 0;
  19050. var outR = 0;
  19051. for (var i = 6; i >= 0; i -= 2) {
  19052. for (var j = 0; j <= 24; j += 8) {
  19053. outL <<= 1;
  19054. outL |= (inR >>> (j + i)) & 1;
  19055. }
  19056. for (var j = 0; j <= 24; j += 8) {
  19057. outL <<= 1;
  19058. outL |= (inL >>> (j + i)) & 1;
  19059. }
  19060. }
  19061. for (var i = 6; i >= 0; i -= 2) {
  19062. for (var j = 1; j <= 25; j += 8) {
  19063. outR <<= 1;
  19064. outR |= (inR >>> (j + i)) & 1;
  19065. }
  19066. for (var j = 1; j <= 25; j += 8) {
  19067. outR <<= 1;
  19068. outR |= (inL >>> (j + i)) & 1;
  19069. }
  19070. }
  19071. out[off + 0] = outL >>> 0;
  19072. out[off + 1] = outR >>> 0;
  19073. };
  19074. exports.rip = function rip(inL, inR, out, off) {
  19075. var outL = 0;
  19076. var outR = 0;
  19077. for (var i = 0; i < 4; i++) {
  19078. for (var j = 24; j >= 0; j -= 8) {
  19079. outL <<= 1;
  19080. outL |= (inR >>> (j + i)) & 1;
  19081. outL <<= 1;
  19082. outL |= (inL >>> (j + i)) & 1;
  19083. }
  19084. }
  19085. for (var i = 4; i < 8; i++) {
  19086. for (var j = 24; j >= 0; j -= 8) {
  19087. outR <<= 1;
  19088. outR |= (inR >>> (j + i)) & 1;
  19089. outR <<= 1;
  19090. outR |= (inL >>> (j + i)) & 1;
  19091. }
  19092. }
  19093. out[off + 0] = outL >>> 0;
  19094. out[off + 1] = outR >>> 0;
  19095. };
  19096. exports.pc1 = function pc1(inL, inR, out, off) {
  19097. var outL = 0;
  19098. var outR = 0;
  19099. // 7, 15, 23, 31, 39, 47, 55, 63
  19100. // 6, 14, 22, 30, 39, 47, 55, 63
  19101. // 5, 13, 21, 29, 39, 47, 55, 63
  19102. // 4, 12, 20, 28
  19103. for (var i = 7; i >= 5; i--) {
  19104. for (var j = 0; j <= 24; j += 8) {
  19105. outL <<= 1;
  19106. outL |= (inR >> (j + i)) & 1;
  19107. }
  19108. for (var j = 0; j <= 24; j += 8) {
  19109. outL <<= 1;
  19110. outL |= (inL >> (j + i)) & 1;
  19111. }
  19112. }
  19113. for (var j = 0; j <= 24; j += 8) {
  19114. outL <<= 1;
  19115. outL |= (inR >> (j + i)) & 1;
  19116. }
  19117. // 1, 9, 17, 25, 33, 41, 49, 57
  19118. // 2, 10, 18, 26, 34, 42, 50, 58
  19119. // 3, 11, 19, 27, 35, 43, 51, 59
  19120. // 36, 44, 52, 60
  19121. for (var i = 1; i <= 3; i++) {
  19122. for (var j = 0; j <= 24; j += 8) {
  19123. outR <<= 1;
  19124. outR |= (inR >> (j + i)) & 1;
  19125. }
  19126. for (var j = 0; j <= 24; j += 8) {
  19127. outR <<= 1;
  19128. outR |= (inL >> (j + i)) & 1;
  19129. }
  19130. }
  19131. for (var j = 0; j <= 24; j += 8) {
  19132. outR <<= 1;
  19133. outR |= (inL >> (j + i)) & 1;
  19134. }
  19135. out[off + 0] = outL >>> 0;
  19136. out[off + 1] = outR >>> 0;
  19137. };
  19138. exports.r28shl = function r28shl(num, shift) {
  19139. return ((num << shift) & 0xfffffff) | (num >>> (28 - shift));
  19140. };
  19141. var pc2table = [
  19142. // inL => outL
  19143. 14, 11, 17, 4, 27, 23, 25, 0,
  19144. 13, 22, 7, 18, 5, 9, 16, 24,
  19145. 2, 20, 12, 21, 1, 8, 15, 26,
  19146. // inR => outR
  19147. 15, 4, 25, 19, 9, 1, 26, 16,
  19148. 5, 11, 23, 8, 12, 7, 17, 0,
  19149. 22, 3, 10, 14, 6, 20, 27, 24
  19150. ];
  19151. exports.pc2 = function pc2(inL, inR, out, off) {
  19152. var outL = 0;
  19153. var outR = 0;
  19154. var len = pc2table.length >>> 1;
  19155. for (var i = 0; i < len; i++) {
  19156. outL <<= 1;
  19157. outL |= (inL >>> pc2table[i]) & 0x1;
  19158. }
  19159. for (var i = len; i < pc2table.length; i++) {
  19160. outR <<= 1;
  19161. outR |= (inR >>> pc2table[i]) & 0x1;
  19162. }
  19163. out[off + 0] = outL >>> 0;
  19164. out[off + 1] = outR >>> 0;
  19165. };
  19166. exports.expand = function expand(r, out, off) {
  19167. var outL = 0;
  19168. var outR = 0;
  19169. outL = ((r & 1) << 5) | (r >>> 27);
  19170. for (var i = 23; i >= 15; i -= 4) {
  19171. outL <<= 6;
  19172. outL |= (r >>> i) & 0x3f;
  19173. }
  19174. for (var i = 11; i >= 3; i -= 4) {
  19175. outR |= (r >>> i) & 0x3f;
  19176. outR <<= 6;
  19177. }
  19178. outR |= ((r & 0x1f) << 1) | (r >>> 31);
  19179. out[off + 0] = outL >>> 0;
  19180. out[off + 1] = outR >>> 0;
  19181. };
  19182. var sTable = [
  19183. 14, 0, 4, 15, 13, 7, 1, 4, 2, 14, 15, 2, 11, 13, 8, 1,
  19184. 3, 10, 10, 6, 6, 12, 12, 11, 5, 9, 9, 5, 0, 3, 7, 8,
  19185. 4, 15, 1, 12, 14, 8, 8, 2, 13, 4, 6, 9, 2, 1, 11, 7,
  19186. 15, 5, 12, 11, 9, 3, 7, 14, 3, 10, 10, 0, 5, 6, 0, 13,
  19187. 15, 3, 1, 13, 8, 4, 14, 7, 6, 15, 11, 2, 3, 8, 4, 14,
  19188. 9, 12, 7, 0, 2, 1, 13, 10, 12, 6, 0, 9, 5, 11, 10, 5,
  19189. 0, 13, 14, 8, 7, 10, 11, 1, 10, 3, 4, 15, 13, 4, 1, 2,
  19190. 5, 11, 8, 6, 12, 7, 6, 12, 9, 0, 3, 5, 2, 14, 15, 9,
  19191. 10, 13, 0, 7, 9, 0, 14, 9, 6, 3, 3, 4, 15, 6, 5, 10,
  19192. 1, 2, 13, 8, 12, 5, 7, 14, 11, 12, 4, 11, 2, 15, 8, 1,
  19193. 13, 1, 6, 10, 4, 13, 9, 0, 8, 6, 15, 9, 3, 8, 0, 7,
  19194. 11, 4, 1, 15, 2, 14, 12, 3, 5, 11, 10, 5, 14, 2, 7, 12,
  19195. 7, 13, 13, 8, 14, 11, 3, 5, 0, 6, 6, 15, 9, 0, 10, 3,
  19196. 1, 4, 2, 7, 8, 2, 5, 12, 11, 1, 12, 10, 4, 14, 15, 9,
  19197. 10, 3, 6, 15, 9, 0, 0, 6, 12, 10, 11, 1, 7, 13, 13, 8,
  19198. 15, 9, 1, 4, 3, 5, 14, 11, 5, 12, 2, 7, 8, 2, 4, 14,
  19199. 2, 14, 12, 11, 4, 2, 1, 12, 7, 4, 10, 7, 11, 13, 6, 1,
  19200. 8, 5, 5, 0, 3, 15, 15, 10, 13, 3, 0, 9, 14, 8, 9, 6,
  19201. 4, 11, 2, 8, 1, 12, 11, 7, 10, 1, 13, 14, 7, 2, 8, 13,
  19202. 15, 6, 9, 15, 12, 0, 5, 9, 6, 10, 3, 4, 0, 5, 14, 3,
  19203. 12, 10, 1, 15, 10, 4, 15, 2, 9, 7, 2, 12, 6, 9, 8, 5,
  19204. 0, 6, 13, 1, 3, 13, 4, 14, 14, 0, 7, 11, 5, 3, 11, 8,
  19205. 9, 4, 14, 3, 15, 2, 5, 12, 2, 9, 8, 5, 12, 15, 3, 10,
  19206. 7, 11, 0, 14, 4, 1, 10, 7, 1, 6, 13, 0, 11, 8, 6, 13,
  19207. 4, 13, 11, 0, 2, 11, 14, 7, 15, 4, 0, 9, 8, 1, 13, 10,
  19208. 3, 14, 12, 3, 9, 5, 7, 12, 5, 2, 10, 15, 6, 8, 1, 6,
  19209. 1, 6, 4, 11, 11, 13, 13, 8, 12, 1, 3, 4, 7, 10, 14, 7,
  19210. 10, 9, 15, 5, 6, 0, 8, 15, 0, 14, 5, 2, 9, 3, 2, 12,
  19211. 13, 1, 2, 15, 8, 13, 4, 8, 6, 10, 15, 3, 11, 7, 1, 4,
  19212. 10, 12, 9, 5, 3, 6, 14, 11, 5, 0, 0, 14, 12, 9, 7, 2,
  19213. 7, 2, 11, 1, 4, 14, 1, 7, 9, 4, 12, 10, 14, 8, 2, 13,
  19214. 0, 15, 6, 12, 10, 9, 13, 0, 15, 3, 3, 5, 5, 6, 8, 11
  19215. ];
  19216. exports.substitute = function substitute(inL, inR) {
  19217. var out = 0;
  19218. for (var i = 0; i < 4; i++) {
  19219. var b = (inL >>> (18 - i * 6)) & 0x3f;
  19220. var sb = sTable[i * 0x40 + b];
  19221. out <<= 4;
  19222. out |= sb;
  19223. }
  19224. for (var i = 0; i < 4; i++) {
  19225. var b = (inR >>> (18 - i * 6)) & 0x3f;
  19226. var sb = sTable[4 * 0x40 + i * 0x40 + b];
  19227. out <<= 4;
  19228. out |= sb;
  19229. }
  19230. return out >>> 0;
  19231. };
  19232. var permuteTable = [
  19233. 16, 25, 12, 11, 3, 20, 4, 15, 31, 17, 9, 6, 27, 14, 1, 22,
  19234. 30, 24, 8, 18, 0, 5, 29, 23, 13, 19, 2, 26, 10, 21, 28, 7
  19235. ];
  19236. exports.permute = function permute(num) {
  19237. var out = 0;
  19238. for (var i = 0; i < permuteTable.length; i++) {
  19239. out <<= 1;
  19240. out |= (num >>> permuteTable[i]) & 0x1;
  19241. }
  19242. return out >>> 0;
  19243. };
  19244. exports.padSplit = function padSplit(num, size, group) {
  19245. var str = num.toString(2);
  19246. while (str.length < size)
  19247. str = '0' + str;
  19248. var out = [];
  19249. for (var i = 0; i < size; i += group)
  19250. out.push(str.slice(i, i + group));
  19251. return out.join(' ');
  19252. };
  19253. /***/ }),
  19254. /***/ "../../node_modules/diffie-hellman/browser.js":
  19255. /*!****************************************************!*\
  19256. !*** ../../node_modules/diffie-hellman/browser.js ***!
  19257. \****************************************************/
  19258. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  19259. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js")["Buffer"];
  19260. var generatePrime = __webpack_require__(/*! ./lib/generatePrime */ "../../node_modules/diffie-hellman/lib/generatePrime.js")
  19261. var primes = __webpack_require__(/*! ./lib/primes.json */ "../../node_modules/diffie-hellman/lib/primes.json")
  19262. var DH = __webpack_require__(/*! ./lib/dh */ "../../node_modules/diffie-hellman/lib/dh.js")
  19263. function getDiffieHellman (mod) {
  19264. var prime = new Buffer(primes[mod].prime, 'hex')
  19265. var gen = new Buffer(primes[mod].gen, 'hex')
  19266. return new DH(prime, gen)
  19267. }
  19268. var ENCODINGS = {
  19269. 'binary': true, 'hex': true, 'base64': true
  19270. }
  19271. function createDiffieHellman (prime, enc, generator, genc) {
  19272. if (Buffer.isBuffer(enc) || ENCODINGS[enc] === undefined) {
  19273. return createDiffieHellman(prime, 'binary', enc, generator)
  19274. }
  19275. enc = enc || 'binary'
  19276. genc = genc || 'binary'
  19277. generator = generator || new Buffer([2])
  19278. if (!Buffer.isBuffer(generator)) {
  19279. generator = new Buffer(generator, genc)
  19280. }
  19281. if (typeof prime === 'number') {
  19282. return new DH(generatePrime(prime, generator), generator, true)
  19283. }
  19284. if (!Buffer.isBuffer(prime)) {
  19285. prime = new Buffer(prime, enc)
  19286. }
  19287. return new DH(prime, generator, true)
  19288. }
  19289. exports.DiffieHellmanGroup = exports.createDiffieHellmanGroup = exports.getDiffieHellman = getDiffieHellman
  19290. exports.createDiffieHellman = exports.DiffieHellman = createDiffieHellman
  19291. /***/ }),
  19292. /***/ "../../node_modules/diffie-hellman/lib/dh.js":
  19293. /*!***************************************************!*\
  19294. !*** ../../node_modules/diffie-hellman/lib/dh.js ***!
  19295. \***************************************************/
  19296. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  19297. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js")["Buffer"];
  19298. var BN = __webpack_require__(/*! bn.js */ "../../node_modules/diffie-hellman/node_modules/bn.js/lib/bn.js");
  19299. var MillerRabin = __webpack_require__(/*! miller-rabin */ "../../node_modules/miller-rabin/lib/mr.js");
  19300. var millerRabin = new MillerRabin();
  19301. var TWENTYFOUR = new BN(24);
  19302. var ELEVEN = new BN(11);
  19303. var TEN = new BN(10);
  19304. var THREE = new BN(3);
  19305. var SEVEN = new BN(7);
  19306. var primes = __webpack_require__(/*! ./generatePrime */ "../../node_modules/diffie-hellman/lib/generatePrime.js");
  19307. var randomBytes = __webpack_require__(/*! randombytes */ "../../node_modules/randombytes/browser.js");
  19308. module.exports = DH;
  19309. function setPublicKey(pub, enc) {
  19310. enc = enc || 'utf8';
  19311. if (!Buffer.isBuffer(pub)) {
  19312. pub = new Buffer(pub, enc);
  19313. }
  19314. this._pub = new BN(pub);
  19315. return this;
  19316. }
  19317. function setPrivateKey(priv, enc) {
  19318. enc = enc || 'utf8';
  19319. if (!Buffer.isBuffer(priv)) {
  19320. priv = new Buffer(priv, enc);
  19321. }
  19322. this._priv = new BN(priv);
  19323. return this;
  19324. }
  19325. var primeCache = {};
  19326. function checkPrime(prime, generator) {
  19327. var gen = generator.toString('hex');
  19328. var hex = [gen, prime.toString(16)].join('_');
  19329. if (hex in primeCache) {
  19330. return primeCache[hex];
  19331. }
  19332. var error = 0;
  19333. if (prime.isEven() ||
  19334. !primes.simpleSieve ||
  19335. !primes.fermatTest(prime) ||
  19336. !millerRabin.test(prime)) {
  19337. //not a prime so +1
  19338. error += 1;
  19339. if (gen === '02' || gen === '05') {
  19340. // we'd be able to check the generator
  19341. // it would fail so +8
  19342. error += 8;
  19343. } else {
  19344. //we wouldn't be able to test the generator
  19345. // so +4
  19346. error += 4;
  19347. }
  19348. primeCache[hex] = error;
  19349. return error;
  19350. }
  19351. if (!millerRabin.test(prime.shrn(1))) {
  19352. //not a safe prime
  19353. error += 2;
  19354. }
  19355. var rem;
  19356. switch (gen) {
  19357. case '02':
  19358. if (prime.mod(TWENTYFOUR).cmp(ELEVEN)) {
  19359. // unsuidable generator
  19360. error += 8;
  19361. }
  19362. break;
  19363. case '05':
  19364. rem = prime.mod(TEN);
  19365. if (rem.cmp(THREE) && rem.cmp(SEVEN)) {
  19366. // prime mod 10 needs to equal 3 or 7
  19367. error += 8;
  19368. }
  19369. break;
  19370. default:
  19371. error += 4;
  19372. }
  19373. primeCache[hex] = error;
  19374. return error;
  19375. }
  19376. function DH(prime, generator, malleable) {
  19377. this.setGenerator(generator);
  19378. this.__prime = new BN(prime);
  19379. this._prime = BN.mont(this.__prime);
  19380. this._primeLen = prime.length;
  19381. this._pub = undefined;
  19382. this._priv = undefined;
  19383. this._primeCode = undefined;
  19384. if (malleable) {
  19385. this.setPublicKey = setPublicKey;
  19386. this.setPrivateKey = setPrivateKey;
  19387. } else {
  19388. this._primeCode = 8;
  19389. }
  19390. }
  19391. Object.defineProperty(DH.prototype, 'verifyError', {
  19392. enumerable: true,
  19393. get: function () {
  19394. if (typeof this._primeCode !== 'number') {
  19395. this._primeCode = checkPrime(this.__prime, this.__gen);
  19396. }
  19397. return this._primeCode;
  19398. }
  19399. });
  19400. DH.prototype.generateKeys = function () {
  19401. if (!this._priv) {
  19402. this._priv = new BN(randomBytes(this._primeLen));
  19403. }
  19404. this._pub = this._gen.toRed(this._prime).redPow(this._priv).fromRed();
  19405. return this.getPublicKey();
  19406. };
  19407. DH.prototype.computeSecret = function (other) {
  19408. other = new BN(other);
  19409. other = other.toRed(this._prime);
  19410. var secret = other.redPow(this._priv).fromRed();
  19411. var out = new Buffer(secret.toArray());
  19412. var prime = this.getPrime();
  19413. if (out.length < prime.length) {
  19414. var front = new Buffer(prime.length - out.length);
  19415. front.fill(0);
  19416. out = Buffer.concat([front, out]);
  19417. }
  19418. return out;
  19419. };
  19420. DH.prototype.getPublicKey = function getPublicKey(enc) {
  19421. return formatReturnValue(this._pub, enc);
  19422. };
  19423. DH.prototype.getPrivateKey = function getPrivateKey(enc) {
  19424. return formatReturnValue(this._priv, enc);
  19425. };
  19426. DH.prototype.getPrime = function (enc) {
  19427. return formatReturnValue(this.__prime, enc);
  19428. };
  19429. DH.prototype.getGenerator = function (enc) {
  19430. return formatReturnValue(this._gen, enc);
  19431. };
  19432. DH.prototype.setGenerator = function (gen, enc) {
  19433. enc = enc || 'utf8';
  19434. if (!Buffer.isBuffer(gen)) {
  19435. gen = new Buffer(gen, enc);
  19436. }
  19437. this.__gen = gen;
  19438. this._gen = new BN(gen);
  19439. return this;
  19440. };
  19441. function formatReturnValue(bn, enc) {
  19442. var buf = new Buffer(bn.toArray());
  19443. if (!enc) {
  19444. return buf;
  19445. } else {
  19446. return buf.toString(enc);
  19447. }
  19448. }
  19449. /***/ }),
  19450. /***/ "../../node_modules/diffie-hellman/lib/generatePrime.js":
  19451. /*!**************************************************************!*\
  19452. !*** ../../node_modules/diffie-hellman/lib/generatePrime.js ***!
  19453. \**************************************************************/
  19454. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  19455. var randomBytes = __webpack_require__(/*! randombytes */ "../../node_modules/randombytes/browser.js");
  19456. module.exports = findPrime;
  19457. findPrime.simpleSieve = simpleSieve;
  19458. findPrime.fermatTest = fermatTest;
  19459. var BN = __webpack_require__(/*! bn.js */ "../../node_modules/diffie-hellman/node_modules/bn.js/lib/bn.js");
  19460. var TWENTYFOUR = new BN(24);
  19461. var MillerRabin = __webpack_require__(/*! miller-rabin */ "../../node_modules/miller-rabin/lib/mr.js");
  19462. var millerRabin = new MillerRabin();
  19463. var ONE = new BN(1);
  19464. var TWO = new BN(2);
  19465. var FIVE = new BN(5);
  19466. var SIXTEEN = new BN(16);
  19467. var EIGHT = new BN(8);
  19468. var TEN = new BN(10);
  19469. var THREE = new BN(3);
  19470. var SEVEN = new BN(7);
  19471. var ELEVEN = new BN(11);
  19472. var FOUR = new BN(4);
  19473. var TWELVE = new BN(12);
  19474. var primes = null;
  19475. function _getPrimes() {
  19476. if (primes !== null)
  19477. return primes;
  19478. var limit = 0x100000;
  19479. var res = [];
  19480. res[0] = 2;
  19481. for (var i = 1, k = 3; k < limit; k += 2) {
  19482. var sqrt = Math.ceil(Math.sqrt(k));
  19483. for (var j = 0; j < i && res[j] <= sqrt; j++)
  19484. if (k % res[j] === 0)
  19485. break;
  19486. if (i !== j && res[j] <= sqrt)
  19487. continue;
  19488. res[i++] = k;
  19489. }
  19490. primes = res;
  19491. return res;
  19492. }
  19493. function simpleSieve(p) {
  19494. var primes = _getPrimes();
  19495. for (var i = 0; i < primes.length; i++)
  19496. if (p.modn(primes[i]) === 0) {
  19497. if (p.cmpn(primes[i]) === 0) {
  19498. return true;
  19499. } else {
  19500. return false;
  19501. }
  19502. }
  19503. return true;
  19504. }
  19505. function fermatTest(p) {
  19506. var red = BN.mont(p);
  19507. return TWO.toRed(red).redPow(p.subn(1)).fromRed().cmpn(1) === 0;
  19508. }
  19509. function findPrime(bits, gen) {
  19510. if (bits < 16) {
  19511. // this is what openssl does
  19512. if (gen === 2 || gen === 5) {
  19513. return new BN([0x8c, 0x7b]);
  19514. } else {
  19515. return new BN([0x8c, 0x27]);
  19516. }
  19517. }
  19518. gen = new BN(gen);
  19519. var num, n2;
  19520. while (true) {
  19521. num = new BN(randomBytes(Math.ceil(bits / 8)));
  19522. while (num.bitLength() > bits) {
  19523. num.ishrn(1);
  19524. }
  19525. if (num.isEven()) {
  19526. num.iadd(ONE);
  19527. }
  19528. if (!num.testn(1)) {
  19529. num.iadd(TWO);
  19530. }
  19531. if (!gen.cmp(TWO)) {
  19532. while (num.mod(TWENTYFOUR).cmp(ELEVEN)) {
  19533. num.iadd(FOUR);
  19534. }
  19535. } else if (!gen.cmp(FIVE)) {
  19536. while (num.mod(TEN).cmp(THREE)) {
  19537. num.iadd(FOUR);
  19538. }
  19539. }
  19540. n2 = num.shrn(1);
  19541. if (simpleSieve(n2) && simpleSieve(num) &&
  19542. fermatTest(n2) && fermatTest(num) &&
  19543. millerRabin.test(n2) && millerRabin.test(num)) {
  19544. return num;
  19545. }
  19546. }
  19547. }
  19548. /***/ }),
  19549. /***/ "../../node_modules/diffie-hellman/node_modules/bn.js/lib/bn.js":
  19550. /*!**********************************************************************!*\
  19551. !*** ../../node_modules/diffie-hellman/node_modules/bn.js/lib/bn.js ***!
  19552. \**********************************************************************/
  19553. /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
  19554. /* module decorator */ module = __webpack_require__.nmd(module);
  19555. (function (module, exports) {
  19556. 'use strict';
  19557. // Utils
  19558. function assert (val, msg) {
  19559. if (!val) throw new Error(msg || 'Assertion failed');
  19560. }
  19561. // Could use `inherits` module, but don't want to move from single file
  19562. // architecture yet.
  19563. function inherits (ctor, superCtor) {
  19564. ctor.super_ = superCtor;
  19565. var TempCtor = function () {};
  19566. TempCtor.prototype = superCtor.prototype;
  19567. ctor.prototype = new TempCtor();
  19568. ctor.prototype.constructor = ctor;
  19569. }
  19570. // BN
  19571. function BN (number, base, endian) {
  19572. if (BN.isBN(number)) {
  19573. return number;
  19574. }
  19575. this.negative = 0;
  19576. this.words = null;
  19577. this.length = 0;
  19578. // Reduction context
  19579. this.red = null;
  19580. if (number !== null) {
  19581. if (base === 'le' || base === 'be') {
  19582. endian = base;
  19583. base = 10;
  19584. }
  19585. this._init(number || 0, base || 10, endian || 'be');
  19586. }
  19587. }
  19588. if (typeof module === 'object') {
  19589. module.exports = BN;
  19590. } else {
  19591. exports.BN = BN;
  19592. }
  19593. BN.BN = BN;
  19594. BN.wordSize = 26;
  19595. var Buffer;
  19596. try {
  19597. if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') {
  19598. Buffer = window.Buffer;
  19599. } else {
  19600. Buffer = (__webpack_require__(/*! buffer */ "?7dc1").Buffer);
  19601. }
  19602. } catch (e) {
  19603. }
  19604. BN.isBN = function isBN (num) {
  19605. if (num instanceof BN) {
  19606. return true;
  19607. }
  19608. return num !== null && typeof num === 'object' &&
  19609. num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
  19610. };
  19611. BN.max = function max (left, right) {
  19612. if (left.cmp(right) > 0) return left;
  19613. return right;
  19614. };
  19615. BN.min = function min (left, right) {
  19616. if (left.cmp(right) < 0) return left;
  19617. return right;
  19618. };
  19619. BN.prototype._init = function init (number, base, endian) {
  19620. if (typeof number === 'number') {
  19621. return this._initNumber(number, base, endian);
  19622. }
  19623. if (typeof number === 'object') {
  19624. return this._initArray(number, base, endian);
  19625. }
  19626. if (base === 'hex') {
  19627. base = 16;
  19628. }
  19629. assert(base === (base | 0) && base >= 2 && base <= 36);
  19630. number = number.toString().replace(/\s+/g, '');
  19631. var start = 0;
  19632. if (number[0] === '-') {
  19633. start++;
  19634. this.negative = 1;
  19635. }
  19636. if (start < number.length) {
  19637. if (base === 16) {
  19638. this._parseHex(number, start, endian);
  19639. } else {
  19640. this._parseBase(number, base, start);
  19641. if (endian === 'le') {
  19642. this._initArray(this.toArray(), base, endian);
  19643. }
  19644. }
  19645. }
  19646. };
  19647. BN.prototype._initNumber = function _initNumber (number, base, endian) {
  19648. if (number < 0) {
  19649. this.negative = 1;
  19650. number = -number;
  19651. }
  19652. if (number < 0x4000000) {
  19653. this.words = [ number & 0x3ffffff ];
  19654. this.length = 1;
  19655. } else if (number < 0x10000000000000) {
  19656. this.words = [
  19657. number & 0x3ffffff,
  19658. (number / 0x4000000) & 0x3ffffff
  19659. ];
  19660. this.length = 2;
  19661. } else {
  19662. assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
  19663. this.words = [
  19664. number & 0x3ffffff,
  19665. (number / 0x4000000) & 0x3ffffff,
  19666. 1
  19667. ];
  19668. this.length = 3;
  19669. }
  19670. if (endian !== 'le') return;
  19671. // Reverse the bytes
  19672. this._initArray(this.toArray(), base, endian);
  19673. };
  19674. BN.prototype._initArray = function _initArray (number, base, endian) {
  19675. // Perhaps a Uint8Array
  19676. assert(typeof number.length === 'number');
  19677. if (number.length <= 0) {
  19678. this.words = [ 0 ];
  19679. this.length = 1;
  19680. return this;
  19681. }
  19682. this.length = Math.ceil(number.length / 3);
  19683. this.words = new Array(this.length);
  19684. for (var i = 0; i < this.length; i++) {
  19685. this.words[i] = 0;
  19686. }
  19687. var j, w;
  19688. var off = 0;
  19689. if (endian === 'be') {
  19690. for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
  19691. w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);
  19692. this.words[j] |= (w << off) & 0x3ffffff;
  19693. this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
  19694. off += 24;
  19695. if (off >= 26) {
  19696. off -= 26;
  19697. j++;
  19698. }
  19699. }
  19700. } else if (endian === 'le') {
  19701. for (i = 0, j = 0; i < number.length; i += 3) {
  19702. w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);
  19703. this.words[j] |= (w << off) & 0x3ffffff;
  19704. this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
  19705. off += 24;
  19706. if (off >= 26) {
  19707. off -= 26;
  19708. j++;
  19709. }
  19710. }
  19711. }
  19712. return this.strip();
  19713. };
  19714. function parseHex4Bits (string, index) {
  19715. var c = string.charCodeAt(index);
  19716. // 'A' - 'F'
  19717. if (c >= 65 && c <= 70) {
  19718. return c - 55;
  19719. // 'a' - 'f'
  19720. } else if (c >= 97 && c <= 102) {
  19721. return c - 87;
  19722. // '0' - '9'
  19723. } else {
  19724. return (c - 48) & 0xf;
  19725. }
  19726. }
  19727. function parseHexByte (string, lowerBound, index) {
  19728. var r = parseHex4Bits(string, index);
  19729. if (index - 1 >= lowerBound) {
  19730. r |= parseHex4Bits(string, index - 1) << 4;
  19731. }
  19732. return r;
  19733. }
  19734. BN.prototype._parseHex = function _parseHex (number, start, endian) {
  19735. // Create possibly bigger array to ensure that it fits the number
  19736. this.length = Math.ceil((number.length - start) / 6);
  19737. this.words = new Array(this.length);
  19738. for (var i = 0; i < this.length; i++) {
  19739. this.words[i] = 0;
  19740. }
  19741. // 24-bits chunks
  19742. var off = 0;
  19743. var j = 0;
  19744. var w;
  19745. if (endian === 'be') {
  19746. for (i = number.length - 1; i >= start; i -= 2) {
  19747. w = parseHexByte(number, start, i) << off;
  19748. this.words[j] |= w & 0x3ffffff;
  19749. if (off >= 18) {
  19750. off -= 18;
  19751. j += 1;
  19752. this.words[j] |= w >>> 26;
  19753. } else {
  19754. off += 8;
  19755. }
  19756. }
  19757. } else {
  19758. var parseLength = number.length - start;
  19759. for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) {
  19760. w = parseHexByte(number, start, i) << off;
  19761. this.words[j] |= w & 0x3ffffff;
  19762. if (off >= 18) {
  19763. off -= 18;
  19764. j += 1;
  19765. this.words[j] |= w >>> 26;
  19766. } else {
  19767. off += 8;
  19768. }
  19769. }
  19770. }
  19771. this.strip();
  19772. };
  19773. function parseBase (str, start, end, mul) {
  19774. var r = 0;
  19775. var len = Math.min(str.length, end);
  19776. for (var i = start; i < len; i++) {
  19777. var c = str.charCodeAt(i) - 48;
  19778. r *= mul;
  19779. // 'a'
  19780. if (c >= 49) {
  19781. r += c - 49 + 0xa;
  19782. // 'A'
  19783. } else if (c >= 17) {
  19784. r += c - 17 + 0xa;
  19785. // '0' - '9'
  19786. } else {
  19787. r += c;
  19788. }
  19789. }
  19790. return r;
  19791. }
  19792. BN.prototype._parseBase = function _parseBase (number, base, start) {
  19793. // Initialize as zero
  19794. this.words = [ 0 ];
  19795. this.length = 1;
  19796. // Find length of limb in base
  19797. for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {
  19798. limbLen++;
  19799. }
  19800. limbLen--;
  19801. limbPow = (limbPow / base) | 0;
  19802. var total = number.length - start;
  19803. var mod = total % limbLen;
  19804. var end = Math.min(total, total - mod) + start;
  19805. var word = 0;
  19806. for (var i = start; i < end; i += limbLen) {
  19807. word = parseBase(number, i, i + limbLen, base);
  19808. this.imuln(limbPow);
  19809. if (this.words[0] + word < 0x4000000) {
  19810. this.words[0] += word;
  19811. } else {
  19812. this._iaddn(word);
  19813. }
  19814. }
  19815. if (mod !== 0) {
  19816. var pow = 1;
  19817. word = parseBase(number, i, number.length, base);
  19818. for (i = 0; i < mod; i++) {
  19819. pow *= base;
  19820. }
  19821. this.imuln(pow);
  19822. if (this.words[0] + word < 0x4000000) {
  19823. this.words[0] += word;
  19824. } else {
  19825. this._iaddn(word);
  19826. }
  19827. }
  19828. this.strip();
  19829. };
  19830. BN.prototype.copy = function copy (dest) {
  19831. dest.words = new Array(this.length);
  19832. for (var i = 0; i < this.length; i++) {
  19833. dest.words[i] = this.words[i];
  19834. }
  19835. dest.length = this.length;
  19836. dest.negative = this.negative;
  19837. dest.red = this.red;
  19838. };
  19839. BN.prototype.clone = function clone () {
  19840. var r = new BN(null);
  19841. this.copy(r);
  19842. return r;
  19843. };
  19844. BN.prototype._expand = function _expand (size) {
  19845. while (this.length < size) {
  19846. this.words[this.length++] = 0;
  19847. }
  19848. return this;
  19849. };
  19850. // Remove leading `0` from `this`
  19851. BN.prototype.strip = function strip () {
  19852. while (this.length > 1 && this.words[this.length - 1] === 0) {
  19853. this.length--;
  19854. }
  19855. return this._normSign();
  19856. };
  19857. BN.prototype._normSign = function _normSign () {
  19858. // -0 = 0
  19859. if (this.length === 1 && this.words[0] === 0) {
  19860. this.negative = 0;
  19861. }
  19862. return this;
  19863. };
  19864. BN.prototype.inspect = function inspect () {
  19865. return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
  19866. };
  19867. /*
  19868. var zeros = [];
  19869. var groupSizes = [];
  19870. var groupBases = [];
  19871. var s = '';
  19872. var i = -1;
  19873. while (++i < BN.wordSize) {
  19874. zeros[i] = s;
  19875. s += '0';
  19876. }
  19877. groupSizes[0] = 0;
  19878. groupSizes[1] = 0;
  19879. groupBases[0] = 0;
  19880. groupBases[1] = 0;
  19881. var base = 2 - 1;
  19882. while (++base < 36 + 1) {
  19883. var groupSize = 0;
  19884. var groupBase = 1;
  19885. while (groupBase < (1 << BN.wordSize) / base) {
  19886. groupBase *= base;
  19887. groupSize += 1;
  19888. }
  19889. groupSizes[base] = groupSize;
  19890. groupBases[base] = groupBase;
  19891. }
  19892. */
  19893. var zeros = [
  19894. '',
  19895. '0',
  19896. '00',
  19897. '000',
  19898. '0000',
  19899. '00000',
  19900. '000000',
  19901. '0000000',
  19902. '00000000',
  19903. '000000000',
  19904. '0000000000',
  19905. '00000000000',
  19906. '000000000000',
  19907. '0000000000000',
  19908. '00000000000000',
  19909. '000000000000000',
  19910. '0000000000000000',
  19911. '00000000000000000',
  19912. '000000000000000000',
  19913. '0000000000000000000',
  19914. '00000000000000000000',
  19915. '000000000000000000000',
  19916. '0000000000000000000000',
  19917. '00000000000000000000000',
  19918. '000000000000000000000000',
  19919. '0000000000000000000000000'
  19920. ];
  19921. var groupSizes = [
  19922. 0, 0,
  19923. 25, 16, 12, 11, 10, 9, 8,
  19924. 8, 7, 7, 7, 7, 6, 6,
  19925. 6, 6, 6, 6, 6, 5, 5,
  19926. 5, 5, 5, 5, 5, 5, 5,
  19927. 5, 5, 5, 5, 5, 5, 5
  19928. ];
  19929. var groupBases = [
  19930. 0, 0,
  19931. 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,
  19932. 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,
  19933. 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,
  19934. 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,
  19935. 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176
  19936. ];
  19937. BN.prototype.toString = function toString (base, padding) {
  19938. base = base || 10;
  19939. padding = padding | 0 || 1;
  19940. var out;
  19941. if (base === 16 || base === 'hex') {
  19942. out = '';
  19943. var off = 0;
  19944. var carry = 0;
  19945. for (var i = 0; i < this.length; i++) {
  19946. var w = this.words[i];
  19947. var word = (((w << off) | carry) & 0xffffff).toString(16);
  19948. carry = (w >>> (24 - off)) & 0xffffff;
  19949. if (carry !== 0 || i !== this.length - 1) {
  19950. out = zeros[6 - word.length] + word + out;
  19951. } else {
  19952. out = word + out;
  19953. }
  19954. off += 2;
  19955. if (off >= 26) {
  19956. off -= 26;
  19957. i--;
  19958. }
  19959. }
  19960. if (carry !== 0) {
  19961. out = carry.toString(16) + out;
  19962. }
  19963. while (out.length % padding !== 0) {
  19964. out = '0' + out;
  19965. }
  19966. if (this.negative !== 0) {
  19967. out = '-' + out;
  19968. }
  19969. return out;
  19970. }
  19971. if (base === (base | 0) && base >= 2 && base <= 36) {
  19972. // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));
  19973. var groupSize = groupSizes[base];
  19974. // var groupBase = Math.pow(base, groupSize);
  19975. var groupBase = groupBases[base];
  19976. out = '';
  19977. var c = this.clone();
  19978. c.negative = 0;
  19979. while (!c.isZero()) {
  19980. var r = c.modn(groupBase).toString(base);
  19981. c = c.idivn(groupBase);
  19982. if (!c.isZero()) {
  19983. out = zeros[groupSize - r.length] + r + out;
  19984. } else {
  19985. out = r + out;
  19986. }
  19987. }
  19988. if (this.isZero()) {
  19989. out = '0' + out;
  19990. }
  19991. while (out.length % padding !== 0) {
  19992. out = '0' + out;
  19993. }
  19994. if (this.negative !== 0) {
  19995. out = '-' + out;
  19996. }
  19997. return out;
  19998. }
  19999. assert(false, 'Base should be between 2 and 36');
  20000. };
  20001. BN.prototype.toNumber = function toNumber () {
  20002. var ret = this.words[0];
  20003. if (this.length === 2) {
  20004. ret += this.words[1] * 0x4000000;
  20005. } else if (this.length === 3 && this.words[2] === 0x01) {
  20006. // NOTE: at this stage it is known that the top bit is set
  20007. ret += 0x10000000000000 + (this.words[1] * 0x4000000);
  20008. } else if (this.length > 2) {
  20009. assert(false, 'Number can only safely store up to 53 bits');
  20010. }
  20011. return (this.negative !== 0) ? -ret : ret;
  20012. };
  20013. BN.prototype.toJSON = function toJSON () {
  20014. return this.toString(16);
  20015. };
  20016. BN.prototype.toBuffer = function toBuffer (endian, length) {
  20017. assert(typeof Buffer !== 'undefined');
  20018. return this.toArrayLike(Buffer, endian, length);
  20019. };
  20020. BN.prototype.toArray = function toArray (endian, length) {
  20021. return this.toArrayLike(Array, endian, length);
  20022. };
  20023. BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {
  20024. var byteLength = this.byteLength();
  20025. var reqLength = length || Math.max(1, byteLength);
  20026. assert(byteLength <= reqLength, 'byte array longer than desired length');
  20027. assert(reqLength > 0, 'Requested array length <= 0');
  20028. this.strip();
  20029. var littleEndian = endian === 'le';
  20030. var res = new ArrayType(reqLength);
  20031. var b, i;
  20032. var q = this.clone();
  20033. if (!littleEndian) {
  20034. // Assume big-endian
  20035. for (i = 0; i < reqLength - byteLength; i++) {
  20036. res[i] = 0;
  20037. }
  20038. for (i = 0; !q.isZero(); i++) {
  20039. b = q.andln(0xff);
  20040. q.iushrn(8);
  20041. res[reqLength - i - 1] = b;
  20042. }
  20043. } else {
  20044. for (i = 0; !q.isZero(); i++) {
  20045. b = q.andln(0xff);
  20046. q.iushrn(8);
  20047. res[i] = b;
  20048. }
  20049. for (; i < reqLength; i++) {
  20050. res[i] = 0;
  20051. }
  20052. }
  20053. return res;
  20054. };
  20055. if (Math.clz32) {
  20056. BN.prototype._countBits = function _countBits (w) {
  20057. return 32 - Math.clz32(w);
  20058. };
  20059. } else {
  20060. BN.prototype._countBits = function _countBits (w) {
  20061. var t = w;
  20062. var r = 0;
  20063. if (t >= 0x1000) {
  20064. r += 13;
  20065. t >>>= 13;
  20066. }
  20067. if (t >= 0x40) {
  20068. r += 7;
  20069. t >>>= 7;
  20070. }
  20071. if (t >= 0x8) {
  20072. r += 4;
  20073. t >>>= 4;
  20074. }
  20075. if (t >= 0x02) {
  20076. r += 2;
  20077. t >>>= 2;
  20078. }
  20079. return r + t;
  20080. };
  20081. }
  20082. BN.prototype._zeroBits = function _zeroBits (w) {
  20083. // Short-cut
  20084. if (w === 0) return 26;
  20085. var t = w;
  20086. var r = 0;
  20087. if ((t & 0x1fff) === 0) {
  20088. r += 13;
  20089. t >>>= 13;
  20090. }
  20091. if ((t & 0x7f) === 0) {
  20092. r += 7;
  20093. t >>>= 7;
  20094. }
  20095. if ((t & 0xf) === 0) {
  20096. r += 4;
  20097. t >>>= 4;
  20098. }
  20099. if ((t & 0x3) === 0) {
  20100. r += 2;
  20101. t >>>= 2;
  20102. }
  20103. if ((t & 0x1) === 0) {
  20104. r++;
  20105. }
  20106. return r;
  20107. };
  20108. // Return number of used bits in a BN
  20109. BN.prototype.bitLength = function bitLength () {
  20110. var w = this.words[this.length - 1];
  20111. var hi = this._countBits(w);
  20112. return (this.length - 1) * 26 + hi;
  20113. };
  20114. function toBitArray (num) {
  20115. var w = new Array(num.bitLength());
  20116. for (var bit = 0; bit < w.length; bit++) {
  20117. var off = (bit / 26) | 0;
  20118. var wbit = bit % 26;
  20119. w[bit] = (num.words[off] & (1 << wbit)) >>> wbit;
  20120. }
  20121. return w;
  20122. }
  20123. // Number of trailing zero bits
  20124. BN.prototype.zeroBits = function zeroBits () {
  20125. if (this.isZero()) return 0;
  20126. var r = 0;
  20127. for (var i = 0; i < this.length; i++) {
  20128. var b = this._zeroBits(this.words[i]);
  20129. r += b;
  20130. if (b !== 26) break;
  20131. }
  20132. return r;
  20133. };
  20134. BN.prototype.byteLength = function byteLength () {
  20135. return Math.ceil(this.bitLength() / 8);
  20136. };
  20137. BN.prototype.toTwos = function toTwos (width) {
  20138. if (this.negative !== 0) {
  20139. return this.abs().inotn(width).iaddn(1);
  20140. }
  20141. return this.clone();
  20142. };
  20143. BN.prototype.fromTwos = function fromTwos (width) {
  20144. if (this.testn(width - 1)) {
  20145. return this.notn(width).iaddn(1).ineg();
  20146. }
  20147. return this.clone();
  20148. };
  20149. BN.prototype.isNeg = function isNeg () {
  20150. return this.negative !== 0;
  20151. };
  20152. // Return negative clone of `this`
  20153. BN.prototype.neg = function neg () {
  20154. return this.clone().ineg();
  20155. };
  20156. BN.prototype.ineg = function ineg () {
  20157. if (!this.isZero()) {
  20158. this.negative ^= 1;
  20159. }
  20160. return this;
  20161. };
  20162. // Or `num` with `this` in-place
  20163. BN.prototype.iuor = function iuor (num) {
  20164. while (this.length < num.length) {
  20165. this.words[this.length++] = 0;
  20166. }
  20167. for (var i = 0; i < num.length; i++) {
  20168. this.words[i] = this.words[i] | num.words[i];
  20169. }
  20170. return this.strip();
  20171. };
  20172. BN.prototype.ior = function ior (num) {
  20173. assert((this.negative | num.negative) === 0);
  20174. return this.iuor(num);
  20175. };
  20176. // Or `num` with `this`
  20177. BN.prototype.or = function or (num) {
  20178. if (this.length > num.length) return this.clone().ior(num);
  20179. return num.clone().ior(this);
  20180. };
  20181. BN.prototype.uor = function uor (num) {
  20182. if (this.length > num.length) return this.clone().iuor(num);
  20183. return num.clone().iuor(this);
  20184. };
  20185. // And `num` with `this` in-place
  20186. BN.prototype.iuand = function iuand (num) {
  20187. // b = min-length(num, this)
  20188. var b;
  20189. if (this.length > num.length) {
  20190. b = num;
  20191. } else {
  20192. b = this;
  20193. }
  20194. for (var i = 0; i < b.length; i++) {
  20195. this.words[i] = this.words[i] & num.words[i];
  20196. }
  20197. this.length = b.length;
  20198. return this.strip();
  20199. };
  20200. BN.prototype.iand = function iand (num) {
  20201. assert((this.negative | num.negative) === 0);
  20202. return this.iuand(num);
  20203. };
  20204. // And `num` with `this`
  20205. BN.prototype.and = function and (num) {
  20206. if (this.length > num.length) return this.clone().iand(num);
  20207. return num.clone().iand(this);
  20208. };
  20209. BN.prototype.uand = function uand (num) {
  20210. if (this.length > num.length) return this.clone().iuand(num);
  20211. return num.clone().iuand(this);
  20212. };
  20213. // Xor `num` with `this` in-place
  20214. BN.prototype.iuxor = function iuxor (num) {
  20215. // a.length > b.length
  20216. var a;
  20217. var b;
  20218. if (this.length > num.length) {
  20219. a = this;
  20220. b = num;
  20221. } else {
  20222. a = num;
  20223. b = this;
  20224. }
  20225. for (var i = 0; i < b.length; i++) {
  20226. this.words[i] = a.words[i] ^ b.words[i];
  20227. }
  20228. if (this !== a) {
  20229. for (; i < a.length; i++) {
  20230. this.words[i] = a.words[i];
  20231. }
  20232. }
  20233. this.length = a.length;
  20234. return this.strip();
  20235. };
  20236. BN.prototype.ixor = function ixor (num) {
  20237. assert((this.negative | num.negative) === 0);
  20238. return this.iuxor(num);
  20239. };
  20240. // Xor `num` with `this`
  20241. BN.prototype.xor = function xor (num) {
  20242. if (this.length > num.length) return this.clone().ixor(num);
  20243. return num.clone().ixor(this);
  20244. };
  20245. BN.prototype.uxor = function uxor (num) {
  20246. if (this.length > num.length) return this.clone().iuxor(num);
  20247. return num.clone().iuxor(this);
  20248. };
  20249. // Not ``this`` with ``width`` bitwidth
  20250. BN.prototype.inotn = function inotn (width) {
  20251. assert(typeof width === 'number' && width >= 0);
  20252. var bytesNeeded = Math.ceil(width / 26) | 0;
  20253. var bitsLeft = width % 26;
  20254. // Extend the buffer with leading zeroes
  20255. this._expand(bytesNeeded);
  20256. if (bitsLeft > 0) {
  20257. bytesNeeded--;
  20258. }
  20259. // Handle complete words
  20260. for (var i = 0; i < bytesNeeded; i++) {
  20261. this.words[i] = ~this.words[i] & 0x3ffffff;
  20262. }
  20263. // Handle the residue
  20264. if (bitsLeft > 0) {
  20265. this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));
  20266. }
  20267. // And remove leading zeroes
  20268. return this.strip();
  20269. };
  20270. BN.prototype.notn = function notn (width) {
  20271. return this.clone().inotn(width);
  20272. };
  20273. // Set `bit` of `this`
  20274. BN.prototype.setn = function setn (bit, val) {
  20275. assert(typeof bit === 'number' && bit >= 0);
  20276. var off = (bit / 26) | 0;
  20277. var wbit = bit % 26;
  20278. this._expand(off + 1);
  20279. if (val) {
  20280. this.words[off] = this.words[off] | (1 << wbit);
  20281. } else {
  20282. this.words[off] = this.words[off] & ~(1 << wbit);
  20283. }
  20284. return this.strip();
  20285. };
  20286. // Add `num` to `this` in-place
  20287. BN.prototype.iadd = function iadd (num) {
  20288. var r;
  20289. // negative + positive
  20290. if (this.negative !== 0 && num.negative === 0) {
  20291. this.negative = 0;
  20292. r = this.isub(num);
  20293. this.negative ^= 1;
  20294. return this._normSign();
  20295. // positive + negative
  20296. } else if (this.negative === 0 && num.negative !== 0) {
  20297. num.negative = 0;
  20298. r = this.isub(num);
  20299. num.negative = 1;
  20300. return r._normSign();
  20301. }
  20302. // a.length > b.length
  20303. var a, b;
  20304. if (this.length > num.length) {
  20305. a = this;
  20306. b = num;
  20307. } else {
  20308. a = num;
  20309. b = this;
  20310. }
  20311. var carry = 0;
  20312. for (var i = 0; i < b.length; i++) {
  20313. r = (a.words[i] | 0) + (b.words[i] | 0) + carry;
  20314. this.words[i] = r & 0x3ffffff;
  20315. carry = r >>> 26;
  20316. }
  20317. for (; carry !== 0 && i < a.length; i++) {
  20318. r = (a.words[i] | 0) + carry;
  20319. this.words[i] = r & 0x3ffffff;
  20320. carry = r >>> 26;
  20321. }
  20322. this.length = a.length;
  20323. if (carry !== 0) {
  20324. this.words[this.length] = carry;
  20325. this.length++;
  20326. // Copy the rest of the words
  20327. } else if (a !== this) {
  20328. for (; i < a.length; i++) {
  20329. this.words[i] = a.words[i];
  20330. }
  20331. }
  20332. return this;
  20333. };
  20334. // Add `num` to `this`
  20335. BN.prototype.add = function add (num) {
  20336. var res;
  20337. if (num.negative !== 0 && this.negative === 0) {
  20338. num.negative = 0;
  20339. res = this.sub(num);
  20340. num.negative ^= 1;
  20341. return res;
  20342. } else if (num.negative === 0 && this.negative !== 0) {
  20343. this.negative = 0;
  20344. res = num.sub(this);
  20345. this.negative = 1;
  20346. return res;
  20347. }
  20348. if (this.length > num.length) return this.clone().iadd(num);
  20349. return num.clone().iadd(this);
  20350. };
  20351. // Subtract `num` from `this` in-place
  20352. BN.prototype.isub = function isub (num) {
  20353. // this - (-num) = this + num
  20354. if (num.negative !== 0) {
  20355. num.negative = 0;
  20356. var r = this.iadd(num);
  20357. num.negative = 1;
  20358. return r._normSign();
  20359. // -this - num = -(this + num)
  20360. } else if (this.negative !== 0) {
  20361. this.negative = 0;
  20362. this.iadd(num);
  20363. this.negative = 1;
  20364. return this._normSign();
  20365. }
  20366. // At this point both numbers are positive
  20367. var cmp = this.cmp(num);
  20368. // Optimization - zeroify
  20369. if (cmp === 0) {
  20370. this.negative = 0;
  20371. this.length = 1;
  20372. this.words[0] = 0;
  20373. return this;
  20374. }
  20375. // a > b
  20376. var a, b;
  20377. if (cmp > 0) {
  20378. a = this;
  20379. b = num;
  20380. } else {
  20381. a = num;
  20382. b = this;
  20383. }
  20384. var carry = 0;
  20385. for (var i = 0; i < b.length; i++) {
  20386. r = (a.words[i] | 0) - (b.words[i] | 0) + carry;
  20387. carry = r >> 26;
  20388. this.words[i] = r & 0x3ffffff;
  20389. }
  20390. for (; carry !== 0 && i < a.length; i++) {
  20391. r = (a.words[i] | 0) + carry;
  20392. carry = r >> 26;
  20393. this.words[i] = r & 0x3ffffff;
  20394. }
  20395. // Copy rest of the words
  20396. if (carry === 0 && i < a.length && a !== this) {
  20397. for (; i < a.length; i++) {
  20398. this.words[i] = a.words[i];
  20399. }
  20400. }
  20401. this.length = Math.max(this.length, i);
  20402. if (a !== this) {
  20403. this.negative = 1;
  20404. }
  20405. return this.strip();
  20406. };
  20407. // Subtract `num` from `this`
  20408. BN.prototype.sub = function sub (num) {
  20409. return this.clone().isub(num);
  20410. };
  20411. function smallMulTo (self, num, out) {
  20412. out.negative = num.negative ^ self.negative;
  20413. var len = (self.length + num.length) | 0;
  20414. out.length = len;
  20415. len = (len - 1) | 0;
  20416. // Peel one iteration (compiler can't do it, because of code complexity)
  20417. var a = self.words[0] | 0;
  20418. var b = num.words[0] | 0;
  20419. var r = a * b;
  20420. var lo = r & 0x3ffffff;
  20421. var carry = (r / 0x4000000) | 0;
  20422. out.words[0] = lo;
  20423. for (var k = 1; k < len; k++) {
  20424. // Sum all words with the same `i + j = k` and accumulate `ncarry`,
  20425. // note that ncarry could be >= 0x3ffffff
  20426. var ncarry = carry >>> 26;
  20427. var rword = carry & 0x3ffffff;
  20428. var maxJ = Math.min(k, num.length - 1);
  20429. for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
  20430. var i = (k - j) | 0;
  20431. a = self.words[i] | 0;
  20432. b = num.words[j] | 0;
  20433. r = a * b + rword;
  20434. ncarry += (r / 0x4000000) | 0;
  20435. rword = r & 0x3ffffff;
  20436. }
  20437. out.words[k] = rword | 0;
  20438. carry = ncarry | 0;
  20439. }
  20440. if (carry !== 0) {
  20441. out.words[k] = carry | 0;
  20442. } else {
  20443. out.length--;
  20444. }
  20445. return out.strip();
  20446. }
  20447. // TODO(indutny): it may be reasonable to omit it for users who don't need
  20448. // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit
  20449. // multiplication (like elliptic secp256k1).
  20450. var comb10MulTo = function comb10MulTo (self, num, out) {
  20451. var a = self.words;
  20452. var b = num.words;
  20453. var o = out.words;
  20454. var c = 0;
  20455. var lo;
  20456. var mid;
  20457. var hi;
  20458. var a0 = a[0] | 0;
  20459. var al0 = a0 & 0x1fff;
  20460. var ah0 = a0 >>> 13;
  20461. var a1 = a[1] | 0;
  20462. var al1 = a1 & 0x1fff;
  20463. var ah1 = a1 >>> 13;
  20464. var a2 = a[2] | 0;
  20465. var al2 = a2 & 0x1fff;
  20466. var ah2 = a2 >>> 13;
  20467. var a3 = a[3] | 0;
  20468. var al3 = a3 & 0x1fff;
  20469. var ah3 = a3 >>> 13;
  20470. var a4 = a[4] | 0;
  20471. var al4 = a4 & 0x1fff;
  20472. var ah4 = a4 >>> 13;
  20473. var a5 = a[5] | 0;
  20474. var al5 = a5 & 0x1fff;
  20475. var ah5 = a5 >>> 13;
  20476. var a6 = a[6] | 0;
  20477. var al6 = a6 & 0x1fff;
  20478. var ah6 = a6 >>> 13;
  20479. var a7 = a[7] | 0;
  20480. var al7 = a7 & 0x1fff;
  20481. var ah7 = a7 >>> 13;
  20482. var a8 = a[8] | 0;
  20483. var al8 = a8 & 0x1fff;
  20484. var ah8 = a8 >>> 13;
  20485. var a9 = a[9] | 0;
  20486. var al9 = a9 & 0x1fff;
  20487. var ah9 = a9 >>> 13;
  20488. var b0 = b[0] | 0;
  20489. var bl0 = b0 & 0x1fff;
  20490. var bh0 = b0 >>> 13;
  20491. var b1 = b[1] | 0;
  20492. var bl1 = b1 & 0x1fff;
  20493. var bh1 = b1 >>> 13;
  20494. var b2 = b[2] | 0;
  20495. var bl2 = b2 & 0x1fff;
  20496. var bh2 = b2 >>> 13;
  20497. var b3 = b[3] | 0;
  20498. var bl3 = b3 & 0x1fff;
  20499. var bh3 = b3 >>> 13;
  20500. var b4 = b[4] | 0;
  20501. var bl4 = b4 & 0x1fff;
  20502. var bh4 = b4 >>> 13;
  20503. var b5 = b[5] | 0;
  20504. var bl5 = b5 & 0x1fff;
  20505. var bh5 = b5 >>> 13;
  20506. var b6 = b[6] | 0;
  20507. var bl6 = b6 & 0x1fff;
  20508. var bh6 = b6 >>> 13;
  20509. var b7 = b[7] | 0;
  20510. var bl7 = b7 & 0x1fff;
  20511. var bh7 = b7 >>> 13;
  20512. var b8 = b[8] | 0;
  20513. var bl8 = b8 & 0x1fff;
  20514. var bh8 = b8 >>> 13;
  20515. var b9 = b[9] | 0;
  20516. var bl9 = b9 & 0x1fff;
  20517. var bh9 = b9 >>> 13;
  20518. out.negative = self.negative ^ num.negative;
  20519. out.length = 19;
  20520. /* k = 0 */
  20521. lo = Math.imul(al0, bl0);
  20522. mid = Math.imul(al0, bh0);
  20523. mid = (mid + Math.imul(ah0, bl0)) | 0;
  20524. hi = Math.imul(ah0, bh0);
  20525. var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  20526. c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;
  20527. w0 &= 0x3ffffff;
  20528. /* k = 1 */
  20529. lo = Math.imul(al1, bl0);
  20530. mid = Math.imul(al1, bh0);
  20531. mid = (mid + Math.imul(ah1, bl0)) | 0;
  20532. hi = Math.imul(ah1, bh0);
  20533. lo = (lo + Math.imul(al0, bl1)) | 0;
  20534. mid = (mid + Math.imul(al0, bh1)) | 0;
  20535. mid = (mid + Math.imul(ah0, bl1)) | 0;
  20536. hi = (hi + Math.imul(ah0, bh1)) | 0;
  20537. var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  20538. c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;
  20539. w1 &= 0x3ffffff;
  20540. /* k = 2 */
  20541. lo = Math.imul(al2, bl0);
  20542. mid = Math.imul(al2, bh0);
  20543. mid = (mid + Math.imul(ah2, bl0)) | 0;
  20544. hi = Math.imul(ah2, bh0);
  20545. lo = (lo + Math.imul(al1, bl1)) | 0;
  20546. mid = (mid + Math.imul(al1, bh1)) | 0;
  20547. mid = (mid + Math.imul(ah1, bl1)) | 0;
  20548. hi = (hi + Math.imul(ah1, bh1)) | 0;
  20549. lo = (lo + Math.imul(al0, bl2)) | 0;
  20550. mid = (mid + Math.imul(al0, bh2)) | 0;
  20551. mid = (mid + Math.imul(ah0, bl2)) | 0;
  20552. hi = (hi + Math.imul(ah0, bh2)) | 0;
  20553. var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  20554. c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;
  20555. w2 &= 0x3ffffff;
  20556. /* k = 3 */
  20557. lo = Math.imul(al3, bl0);
  20558. mid = Math.imul(al3, bh0);
  20559. mid = (mid + Math.imul(ah3, bl0)) | 0;
  20560. hi = Math.imul(ah3, bh0);
  20561. lo = (lo + Math.imul(al2, bl1)) | 0;
  20562. mid = (mid + Math.imul(al2, bh1)) | 0;
  20563. mid = (mid + Math.imul(ah2, bl1)) | 0;
  20564. hi = (hi + Math.imul(ah2, bh1)) | 0;
  20565. lo = (lo + Math.imul(al1, bl2)) | 0;
  20566. mid = (mid + Math.imul(al1, bh2)) | 0;
  20567. mid = (mid + Math.imul(ah1, bl2)) | 0;
  20568. hi = (hi + Math.imul(ah1, bh2)) | 0;
  20569. lo = (lo + Math.imul(al0, bl3)) | 0;
  20570. mid = (mid + Math.imul(al0, bh3)) | 0;
  20571. mid = (mid + Math.imul(ah0, bl3)) | 0;
  20572. hi = (hi + Math.imul(ah0, bh3)) | 0;
  20573. var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  20574. c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;
  20575. w3 &= 0x3ffffff;
  20576. /* k = 4 */
  20577. lo = Math.imul(al4, bl0);
  20578. mid = Math.imul(al4, bh0);
  20579. mid = (mid + Math.imul(ah4, bl0)) | 0;
  20580. hi = Math.imul(ah4, bh0);
  20581. lo = (lo + Math.imul(al3, bl1)) | 0;
  20582. mid = (mid + Math.imul(al3, bh1)) | 0;
  20583. mid = (mid + Math.imul(ah3, bl1)) | 0;
  20584. hi = (hi + Math.imul(ah3, bh1)) | 0;
  20585. lo = (lo + Math.imul(al2, bl2)) | 0;
  20586. mid = (mid + Math.imul(al2, bh2)) | 0;
  20587. mid = (mid + Math.imul(ah2, bl2)) | 0;
  20588. hi = (hi + Math.imul(ah2, bh2)) | 0;
  20589. lo = (lo + Math.imul(al1, bl3)) | 0;
  20590. mid = (mid + Math.imul(al1, bh3)) | 0;
  20591. mid = (mid + Math.imul(ah1, bl3)) | 0;
  20592. hi = (hi + Math.imul(ah1, bh3)) | 0;
  20593. lo = (lo + Math.imul(al0, bl4)) | 0;
  20594. mid = (mid + Math.imul(al0, bh4)) | 0;
  20595. mid = (mid + Math.imul(ah0, bl4)) | 0;
  20596. hi = (hi + Math.imul(ah0, bh4)) | 0;
  20597. var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  20598. c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;
  20599. w4 &= 0x3ffffff;
  20600. /* k = 5 */
  20601. lo = Math.imul(al5, bl0);
  20602. mid = Math.imul(al5, bh0);
  20603. mid = (mid + Math.imul(ah5, bl0)) | 0;
  20604. hi = Math.imul(ah5, bh0);
  20605. lo = (lo + Math.imul(al4, bl1)) | 0;
  20606. mid = (mid + Math.imul(al4, bh1)) | 0;
  20607. mid = (mid + Math.imul(ah4, bl1)) | 0;
  20608. hi = (hi + Math.imul(ah4, bh1)) | 0;
  20609. lo = (lo + Math.imul(al3, bl2)) | 0;
  20610. mid = (mid + Math.imul(al3, bh2)) | 0;
  20611. mid = (mid + Math.imul(ah3, bl2)) | 0;
  20612. hi = (hi + Math.imul(ah3, bh2)) | 0;
  20613. lo = (lo + Math.imul(al2, bl3)) | 0;
  20614. mid = (mid + Math.imul(al2, bh3)) | 0;
  20615. mid = (mid + Math.imul(ah2, bl3)) | 0;
  20616. hi = (hi + Math.imul(ah2, bh3)) | 0;
  20617. lo = (lo + Math.imul(al1, bl4)) | 0;
  20618. mid = (mid + Math.imul(al1, bh4)) | 0;
  20619. mid = (mid + Math.imul(ah1, bl4)) | 0;
  20620. hi = (hi + Math.imul(ah1, bh4)) | 0;
  20621. lo = (lo + Math.imul(al0, bl5)) | 0;
  20622. mid = (mid + Math.imul(al0, bh5)) | 0;
  20623. mid = (mid + Math.imul(ah0, bl5)) | 0;
  20624. hi = (hi + Math.imul(ah0, bh5)) | 0;
  20625. var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  20626. c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;
  20627. w5 &= 0x3ffffff;
  20628. /* k = 6 */
  20629. lo = Math.imul(al6, bl0);
  20630. mid = Math.imul(al6, bh0);
  20631. mid = (mid + Math.imul(ah6, bl0)) | 0;
  20632. hi = Math.imul(ah6, bh0);
  20633. lo = (lo + Math.imul(al5, bl1)) | 0;
  20634. mid = (mid + Math.imul(al5, bh1)) | 0;
  20635. mid = (mid + Math.imul(ah5, bl1)) | 0;
  20636. hi = (hi + Math.imul(ah5, bh1)) | 0;
  20637. lo = (lo + Math.imul(al4, bl2)) | 0;
  20638. mid = (mid + Math.imul(al4, bh2)) | 0;
  20639. mid = (mid + Math.imul(ah4, bl2)) | 0;
  20640. hi = (hi + Math.imul(ah4, bh2)) | 0;
  20641. lo = (lo + Math.imul(al3, bl3)) | 0;
  20642. mid = (mid + Math.imul(al3, bh3)) | 0;
  20643. mid = (mid + Math.imul(ah3, bl3)) | 0;
  20644. hi = (hi + Math.imul(ah3, bh3)) | 0;
  20645. lo = (lo + Math.imul(al2, bl4)) | 0;
  20646. mid = (mid + Math.imul(al2, bh4)) | 0;
  20647. mid = (mid + Math.imul(ah2, bl4)) | 0;
  20648. hi = (hi + Math.imul(ah2, bh4)) | 0;
  20649. lo = (lo + Math.imul(al1, bl5)) | 0;
  20650. mid = (mid + Math.imul(al1, bh5)) | 0;
  20651. mid = (mid + Math.imul(ah1, bl5)) | 0;
  20652. hi = (hi + Math.imul(ah1, bh5)) | 0;
  20653. lo = (lo + Math.imul(al0, bl6)) | 0;
  20654. mid = (mid + Math.imul(al0, bh6)) | 0;
  20655. mid = (mid + Math.imul(ah0, bl6)) | 0;
  20656. hi = (hi + Math.imul(ah0, bh6)) | 0;
  20657. var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  20658. c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;
  20659. w6 &= 0x3ffffff;
  20660. /* k = 7 */
  20661. lo = Math.imul(al7, bl0);
  20662. mid = Math.imul(al7, bh0);
  20663. mid = (mid + Math.imul(ah7, bl0)) | 0;
  20664. hi = Math.imul(ah7, bh0);
  20665. lo = (lo + Math.imul(al6, bl1)) | 0;
  20666. mid = (mid + Math.imul(al6, bh1)) | 0;
  20667. mid = (mid + Math.imul(ah6, bl1)) | 0;
  20668. hi = (hi + Math.imul(ah6, bh1)) | 0;
  20669. lo = (lo + Math.imul(al5, bl2)) | 0;
  20670. mid = (mid + Math.imul(al5, bh2)) | 0;
  20671. mid = (mid + Math.imul(ah5, bl2)) | 0;
  20672. hi = (hi + Math.imul(ah5, bh2)) | 0;
  20673. lo = (lo + Math.imul(al4, bl3)) | 0;
  20674. mid = (mid + Math.imul(al4, bh3)) | 0;
  20675. mid = (mid + Math.imul(ah4, bl3)) | 0;
  20676. hi = (hi + Math.imul(ah4, bh3)) | 0;
  20677. lo = (lo + Math.imul(al3, bl4)) | 0;
  20678. mid = (mid + Math.imul(al3, bh4)) | 0;
  20679. mid = (mid + Math.imul(ah3, bl4)) | 0;
  20680. hi = (hi + Math.imul(ah3, bh4)) | 0;
  20681. lo = (lo + Math.imul(al2, bl5)) | 0;
  20682. mid = (mid + Math.imul(al2, bh5)) | 0;
  20683. mid = (mid + Math.imul(ah2, bl5)) | 0;
  20684. hi = (hi + Math.imul(ah2, bh5)) | 0;
  20685. lo = (lo + Math.imul(al1, bl6)) | 0;
  20686. mid = (mid + Math.imul(al1, bh6)) | 0;
  20687. mid = (mid + Math.imul(ah1, bl6)) | 0;
  20688. hi = (hi + Math.imul(ah1, bh6)) | 0;
  20689. lo = (lo + Math.imul(al0, bl7)) | 0;
  20690. mid = (mid + Math.imul(al0, bh7)) | 0;
  20691. mid = (mid + Math.imul(ah0, bl7)) | 0;
  20692. hi = (hi + Math.imul(ah0, bh7)) | 0;
  20693. var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  20694. c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;
  20695. w7 &= 0x3ffffff;
  20696. /* k = 8 */
  20697. lo = Math.imul(al8, bl0);
  20698. mid = Math.imul(al8, bh0);
  20699. mid = (mid + Math.imul(ah8, bl0)) | 0;
  20700. hi = Math.imul(ah8, bh0);
  20701. lo = (lo + Math.imul(al7, bl1)) | 0;
  20702. mid = (mid + Math.imul(al7, bh1)) | 0;
  20703. mid = (mid + Math.imul(ah7, bl1)) | 0;
  20704. hi = (hi + Math.imul(ah7, bh1)) | 0;
  20705. lo = (lo + Math.imul(al6, bl2)) | 0;
  20706. mid = (mid + Math.imul(al6, bh2)) | 0;
  20707. mid = (mid + Math.imul(ah6, bl2)) | 0;
  20708. hi = (hi + Math.imul(ah6, bh2)) | 0;
  20709. lo = (lo + Math.imul(al5, bl3)) | 0;
  20710. mid = (mid + Math.imul(al5, bh3)) | 0;
  20711. mid = (mid + Math.imul(ah5, bl3)) | 0;
  20712. hi = (hi + Math.imul(ah5, bh3)) | 0;
  20713. lo = (lo + Math.imul(al4, bl4)) | 0;
  20714. mid = (mid + Math.imul(al4, bh4)) | 0;
  20715. mid = (mid + Math.imul(ah4, bl4)) | 0;
  20716. hi = (hi + Math.imul(ah4, bh4)) | 0;
  20717. lo = (lo + Math.imul(al3, bl5)) | 0;
  20718. mid = (mid + Math.imul(al3, bh5)) | 0;
  20719. mid = (mid + Math.imul(ah3, bl5)) | 0;
  20720. hi = (hi + Math.imul(ah3, bh5)) | 0;
  20721. lo = (lo + Math.imul(al2, bl6)) | 0;
  20722. mid = (mid + Math.imul(al2, bh6)) | 0;
  20723. mid = (mid + Math.imul(ah2, bl6)) | 0;
  20724. hi = (hi + Math.imul(ah2, bh6)) | 0;
  20725. lo = (lo + Math.imul(al1, bl7)) | 0;
  20726. mid = (mid + Math.imul(al1, bh7)) | 0;
  20727. mid = (mid + Math.imul(ah1, bl7)) | 0;
  20728. hi = (hi + Math.imul(ah1, bh7)) | 0;
  20729. lo = (lo + Math.imul(al0, bl8)) | 0;
  20730. mid = (mid + Math.imul(al0, bh8)) | 0;
  20731. mid = (mid + Math.imul(ah0, bl8)) | 0;
  20732. hi = (hi + Math.imul(ah0, bh8)) | 0;
  20733. var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  20734. c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;
  20735. w8 &= 0x3ffffff;
  20736. /* k = 9 */
  20737. lo = Math.imul(al9, bl0);
  20738. mid = Math.imul(al9, bh0);
  20739. mid = (mid + Math.imul(ah9, bl0)) | 0;
  20740. hi = Math.imul(ah9, bh0);
  20741. lo = (lo + Math.imul(al8, bl1)) | 0;
  20742. mid = (mid + Math.imul(al8, bh1)) | 0;
  20743. mid = (mid + Math.imul(ah8, bl1)) | 0;
  20744. hi = (hi + Math.imul(ah8, bh1)) | 0;
  20745. lo = (lo + Math.imul(al7, bl2)) | 0;
  20746. mid = (mid + Math.imul(al7, bh2)) | 0;
  20747. mid = (mid + Math.imul(ah7, bl2)) | 0;
  20748. hi = (hi + Math.imul(ah7, bh2)) | 0;
  20749. lo = (lo + Math.imul(al6, bl3)) | 0;
  20750. mid = (mid + Math.imul(al6, bh3)) | 0;
  20751. mid = (mid + Math.imul(ah6, bl3)) | 0;
  20752. hi = (hi + Math.imul(ah6, bh3)) | 0;
  20753. lo = (lo + Math.imul(al5, bl4)) | 0;
  20754. mid = (mid + Math.imul(al5, bh4)) | 0;
  20755. mid = (mid + Math.imul(ah5, bl4)) | 0;
  20756. hi = (hi + Math.imul(ah5, bh4)) | 0;
  20757. lo = (lo + Math.imul(al4, bl5)) | 0;
  20758. mid = (mid + Math.imul(al4, bh5)) | 0;
  20759. mid = (mid + Math.imul(ah4, bl5)) | 0;
  20760. hi = (hi + Math.imul(ah4, bh5)) | 0;
  20761. lo = (lo + Math.imul(al3, bl6)) | 0;
  20762. mid = (mid + Math.imul(al3, bh6)) | 0;
  20763. mid = (mid + Math.imul(ah3, bl6)) | 0;
  20764. hi = (hi + Math.imul(ah3, bh6)) | 0;
  20765. lo = (lo + Math.imul(al2, bl7)) | 0;
  20766. mid = (mid + Math.imul(al2, bh7)) | 0;
  20767. mid = (mid + Math.imul(ah2, bl7)) | 0;
  20768. hi = (hi + Math.imul(ah2, bh7)) | 0;
  20769. lo = (lo + Math.imul(al1, bl8)) | 0;
  20770. mid = (mid + Math.imul(al1, bh8)) | 0;
  20771. mid = (mid + Math.imul(ah1, bl8)) | 0;
  20772. hi = (hi + Math.imul(ah1, bh8)) | 0;
  20773. lo = (lo + Math.imul(al0, bl9)) | 0;
  20774. mid = (mid + Math.imul(al0, bh9)) | 0;
  20775. mid = (mid + Math.imul(ah0, bl9)) | 0;
  20776. hi = (hi + Math.imul(ah0, bh9)) | 0;
  20777. var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  20778. c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;
  20779. w9 &= 0x3ffffff;
  20780. /* k = 10 */
  20781. lo = Math.imul(al9, bl1);
  20782. mid = Math.imul(al9, bh1);
  20783. mid = (mid + Math.imul(ah9, bl1)) | 0;
  20784. hi = Math.imul(ah9, bh1);
  20785. lo = (lo + Math.imul(al8, bl2)) | 0;
  20786. mid = (mid + Math.imul(al8, bh2)) | 0;
  20787. mid = (mid + Math.imul(ah8, bl2)) | 0;
  20788. hi = (hi + Math.imul(ah8, bh2)) | 0;
  20789. lo = (lo + Math.imul(al7, bl3)) | 0;
  20790. mid = (mid + Math.imul(al7, bh3)) | 0;
  20791. mid = (mid + Math.imul(ah7, bl3)) | 0;
  20792. hi = (hi + Math.imul(ah7, bh3)) | 0;
  20793. lo = (lo + Math.imul(al6, bl4)) | 0;
  20794. mid = (mid + Math.imul(al6, bh4)) | 0;
  20795. mid = (mid + Math.imul(ah6, bl4)) | 0;
  20796. hi = (hi + Math.imul(ah6, bh4)) | 0;
  20797. lo = (lo + Math.imul(al5, bl5)) | 0;
  20798. mid = (mid + Math.imul(al5, bh5)) | 0;
  20799. mid = (mid + Math.imul(ah5, bl5)) | 0;
  20800. hi = (hi + Math.imul(ah5, bh5)) | 0;
  20801. lo = (lo + Math.imul(al4, bl6)) | 0;
  20802. mid = (mid + Math.imul(al4, bh6)) | 0;
  20803. mid = (mid + Math.imul(ah4, bl6)) | 0;
  20804. hi = (hi + Math.imul(ah4, bh6)) | 0;
  20805. lo = (lo + Math.imul(al3, bl7)) | 0;
  20806. mid = (mid + Math.imul(al3, bh7)) | 0;
  20807. mid = (mid + Math.imul(ah3, bl7)) | 0;
  20808. hi = (hi + Math.imul(ah3, bh7)) | 0;
  20809. lo = (lo + Math.imul(al2, bl8)) | 0;
  20810. mid = (mid + Math.imul(al2, bh8)) | 0;
  20811. mid = (mid + Math.imul(ah2, bl8)) | 0;
  20812. hi = (hi + Math.imul(ah2, bh8)) | 0;
  20813. lo = (lo + Math.imul(al1, bl9)) | 0;
  20814. mid = (mid + Math.imul(al1, bh9)) | 0;
  20815. mid = (mid + Math.imul(ah1, bl9)) | 0;
  20816. hi = (hi + Math.imul(ah1, bh9)) | 0;
  20817. var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  20818. c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;
  20819. w10 &= 0x3ffffff;
  20820. /* k = 11 */
  20821. lo = Math.imul(al9, bl2);
  20822. mid = Math.imul(al9, bh2);
  20823. mid = (mid + Math.imul(ah9, bl2)) | 0;
  20824. hi = Math.imul(ah9, bh2);
  20825. lo = (lo + Math.imul(al8, bl3)) | 0;
  20826. mid = (mid + Math.imul(al8, bh3)) | 0;
  20827. mid = (mid + Math.imul(ah8, bl3)) | 0;
  20828. hi = (hi + Math.imul(ah8, bh3)) | 0;
  20829. lo = (lo + Math.imul(al7, bl4)) | 0;
  20830. mid = (mid + Math.imul(al7, bh4)) | 0;
  20831. mid = (mid + Math.imul(ah7, bl4)) | 0;
  20832. hi = (hi + Math.imul(ah7, bh4)) | 0;
  20833. lo = (lo + Math.imul(al6, bl5)) | 0;
  20834. mid = (mid + Math.imul(al6, bh5)) | 0;
  20835. mid = (mid + Math.imul(ah6, bl5)) | 0;
  20836. hi = (hi + Math.imul(ah6, bh5)) | 0;
  20837. lo = (lo + Math.imul(al5, bl6)) | 0;
  20838. mid = (mid + Math.imul(al5, bh6)) | 0;
  20839. mid = (mid + Math.imul(ah5, bl6)) | 0;
  20840. hi = (hi + Math.imul(ah5, bh6)) | 0;
  20841. lo = (lo + Math.imul(al4, bl7)) | 0;
  20842. mid = (mid + Math.imul(al4, bh7)) | 0;
  20843. mid = (mid + Math.imul(ah4, bl7)) | 0;
  20844. hi = (hi + Math.imul(ah4, bh7)) | 0;
  20845. lo = (lo + Math.imul(al3, bl8)) | 0;
  20846. mid = (mid + Math.imul(al3, bh8)) | 0;
  20847. mid = (mid + Math.imul(ah3, bl8)) | 0;
  20848. hi = (hi + Math.imul(ah3, bh8)) | 0;
  20849. lo = (lo + Math.imul(al2, bl9)) | 0;
  20850. mid = (mid + Math.imul(al2, bh9)) | 0;
  20851. mid = (mid + Math.imul(ah2, bl9)) | 0;
  20852. hi = (hi + Math.imul(ah2, bh9)) | 0;
  20853. var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  20854. c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;
  20855. w11 &= 0x3ffffff;
  20856. /* k = 12 */
  20857. lo = Math.imul(al9, bl3);
  20858. mid = Math.imul(al9, bh3);
  20859. mid = (mid + Math.imul(ah9, bl3)) | 0;
  20860. hi = Math.imul(ah9, bh3);
  20861. lo = (lo + Math.imul(al8, bl4)) | 0;
  20862. mid = (mid + Math.imul(al8, bh4)) | 0;
  20863. mid = (mid + Math.imul(ah8, bl4)) | 0;
  20864. hi = (hi + Math.imul(ah8, bh4)) | 0;
  20865. lo = (lo + Math.imul(al7, bl5)) | 0;
  20866. mid = (mid + Math.imul(al7, bh5)) | 0;
  20867. mid = (mid + Math.imul(ah7, bl5)) | 0;
  20868. hi = (hi + Math.imul(ah7, bh5)) | 0;
  20869. lo = (lo + Math.imul(al6, bl6)) | 0;
  20870. mid = (mid + Math.imul(al6, bh6)) | 0;
  20871. mid = (mid + Math.imul(ah6, bl6)) | 0;
  20872. hi = (hi + Math.imul(ah6, bh6)) | 0;
  20873. lo = (lo + Math.imul(al5, bl7)) | 0;
  20874. mid = (mid + Math.imul(al5, bh7)) | 0;
  20875. mid = (mid + Math.imul(ah5, bl7)) | 0;
  20876. hi = (hi + Math.imul(ah5, bh7)) | 0;
  20877. lo = (lo + Math.imul(al4, bl8)) | 0;
  20878. mid = (mid + Math.imul(al4, bh8)) | 0;
  20879. mid = (mid + Math.imul(ah4, bl8)) | 0;
  20880. hi = (hi + Math.imul(ah4, bh8)) | 0;
  20881. lo = (lo + Math.imul(al3, bl9)) | 0;
  20882. mid = (mid + Math.imul(al3, bh9)) | 0;
  20883. mid = (mid + Math.imul(ah3, bl9)) | 0;
  20884. hi = (hi + Math.imul(ah3, bh9)) | 0;
  20885. var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  20886. c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;
  20887. w12 &= 0x3ffffff;
  20888. /* k = 13 */
  20889. lo = Math.imul(al9, bl4);
  20890. mid = Math.imul(al9, bh4);
  20891. mid = (mid + Math.imul(ah9, bl4)) | 0;
  20892. hi = Math.imul(ah9, bh4);
  20893. lo = (lo + Math.imul(al8, bl5)) | 0;
  20894. mid = (mid + Math.imul(al8, bh5)) | 0;
  20895. mid = (mid + Math.imul(ah8, bl5)) | 0;
  20896. hi = (hi + Math.imul(ah8, bh5)) | 0;
  20897. lo = (lo + Math.imul(al7, bl6)) | 0;
  20898. mid = (mid + Math.imul(al7, bh6)) | 0;
  20899. mid = (mid + Math.imul(ah7, bl6)) | 0;
  20900. hi = (hi + Math.imul(ah7, bh6)) | 0;
  20901. lo = (lo + Math.imul(al6, bl7)) | 0;
  20902. mid = (mid + Math.imul(al6, bh7)) | 0;
  20903. mid = (mid + Math.imul(ah6, bl7)) | 0;
  20904. hi = (hi + Math.imul(ah6, bh7)) | 0;
  20905. lo = (lo + Math.imul(al5, bl8)) | 0;
  20906. mid = (mid + Math.imul(al5, bh8)) | 0;
  20907. mid = (mid + Math.imul(ah5, bl8)) | 0;
  20908. hi = (hi + Math.imul(ah5, bh8)) | 0;
  20909. lo = (lo + Math.imul(al4, bl9)) | 0;
  20910. mid = (mid + Math.imul(al4, bh9)) | 0;
  20911. mid = (mid + Math.imul(ah4, bl9)) | 0;
  20912. hi = (hi + Math.imul(ah4, bh9)) | 0;
  20913. var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  20914. c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;
  20915. w13 &= 0x3ffffff;
  20916. /* k = 14 */
  20917. lo = Math.imul(al9, bl5);
  20918. mid = Math.imul(al9, bh5);
  20919. mid = (mid + Math.imul(ah9, bl5)) | 0;
  20920. hi = Math.imul(ah9, bh5);
  20921. lo = (lo + Math.imul(al8, bl6)) | 0;
  20922. mid = (mid + Math.imul(al8, bh6)) | 0;
  20923. mid = (mid + Math.imul(ah8, bl6)) | 0;
  20924. hi = (hi + Math.imul(ah8, bh6)) | 0;
  20925. lo = (lo + Math.imul(al7, bl7)) | 0;
  20926. mid = (mid + Math.imul(al7, bh7)) | 0;
  20927. mid = (mid + Math.imul(ah7, bl7)) | 0;
  20928. hi = (hi + Math.imul(ah7, bh7)) | 0;
  20929. lo = (lo + Math.imul(al6, bl8)) | 0;
  20930. mid = (mid + Math.imul(al6, bh8)) | 0;
  20931. mid = (mid + Math.imul(ah6, bl8)) | 0;
  20932. hi = (hi + Math.imul(ah6, bh8)) | 0;
  20933. lo = (lo + Math.imul(al5, bl9)) | 0;
  20934. mid = (mid + Math.imul(al5, bh9)) | 0;
  20935. mid = (mid + Math.imul(ah5, bl9)) | 0;
  20936. hi = (hi + Math.imul(ah5, bh9)) | 0;
  20937. var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  20938. c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;
  20939. w14 &= 0x3ffffff;
  20940. /* k = 15 */
  20941. lo = Math.imul(al9, bl6);
  20942. mid = Math.imul(al9, bh6);
  20943. mid = (mid + Math.imul(ah9, bl6)) | 0;
  20944. hi = Math.imul(ah9, bh6);
  20945. lo = (lo + Math.imul(al8, bl7)) | 0;
  20946. mid = (mid + Math.imul(al8, bh7)) | 0;
  20947. mid = (mid + Math.imul(ah8, bl7)) | 0;
  20948. hi = (hi + Math.imul(ah8, bh7)) | 0;
  20949. lo = (lo + Math.imul(al7, bl8)) | 0;
  20950. mid = (mid + Math.imul(al7, bh8)) | 0;
  20951. mid = (mid + Math.imul(ah7, bl8)) | 0;
  20952. hi = (hi + Math.imul(ah7, bh8)) | 0;
  20953. lo = (lo + Math.imul(al6, bl9)) | 0;
  20954. mid = (mid + Math.imul(al6, bh9)) | 0;
  20955. mid = (mid + Math.imul(ah6, bl9)) | 0;
  20956. hi = (hi + Math.imul(ah6, bh9)) | 0;
  20957. var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  20958. c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;
  20959. w15 &= 0x3ffffff;
  20960. /* k = 16 */
  20961. lo = Math.imul(al9, bl7);
  20962. mid = Math.imul(al9, bh7);
  20963. mid = (mid + Math.imul(ah9, bl7)) | 0;
  20964. hi = Math.imul(ah9, bh7);
  20965. lo = (lo + Math.imul(al8, bl8)) | 0;
  20966. mid = (mid + Math.imul(al8, bh8)) | 0;
  20967. mid = (mid + Math.imul(ah8, bl8)) | 0;
  20968. hi = (hi + Math.imul(ah8, bh8)) | 0;
  20969. lo = (lo + Math.imul(al7, bl9)) | 0;
  20970. mid = (mid + Math.imul(al7, bh9)) | 0;
  20971. mid = (mid + Math.imul(ah7, bl9)) | 0;
  20972. hi = (hi + Math.imul(ah7, bh9)) | 0;
  20973. var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  20974. c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;
  20975. w16 &= 0x3ffffff;
  20976. /* k = 17 */
  20977. lo = Math.imul(al9, bl8);
  20978. mid = Math.imul(al9, bh8);
  20979. mid = (mid + Math.imul(ah9, bl8)) | 0;
  20980. hi = Math.imul(ah9, bh8);
  20981. lo = (lo + Math.imul(al8, bl9)) | 0;
  20982. mid = (mid + Math.imul(al8, bh9)) | 0;
  20983. mid = (mid + Math.imul(ah8, bl9)) | 0;
  20984. hi = (hi + Math.imul(ah8, bh9)) | 0;
  20985. var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  20986. c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;
  20987. w17 &= 0x3ffffff;
  20988. /* k = 18 */
  20989. lo = Math.imul(al9, bl9);
  20990. mid = Math.imul(al9, bh9);
  20991. mid = (mid + Math.imul(ah9, bl9)) | 0;
  20992. hi = Math.imul(ah9, bh9);
  20993. var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  20994. c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;
  20995. w18 &= 0x3ffffff;
  20996. o[0] = w0;
  20997. o[1] = w1;
  20998. o[2] = w2;
  20999. o[3] = w3;
  21000. o[4] = w4;
  21001. o[5] = w5;
  21002. o[6] = w6;
  21003. o[7] = w7;
  21004. o[8] = w8;
  21005. o[9] = w9;
  21006. o[10] = w10;
  21007. o[11] = w11;
  21008. o[12] = w12;
  21009. o[13] = w13;
  21010. o[14] = w14;
  21011. o[15] = w15;
  21012. o[16] = w16;
  21013. o[17] = w17;
  21014. o[18] = w18;
  21015. if (c !== 0) {
  21016. o[19] = c;
  21017. out.length++;
  21018. }
  21019. return out;
  21020. };
  21021. // Polyfill comb
  21022. if (!Math.imul) {
  21023. comb10MulTo = smallMulTo;
  21024. }
  21025. function bigMulTo (self, num, out) {
  21026. out.negative = num.negative ^ self.negative;
  21027. out.length = self.length + num.length;
  21028. var carry = 0;
  21029. var hncarry = 0;
  21030. for (var k = 0; k < out.length - 1; k++) {
  21031. // Sum all words with the same `i + j = k` and accumulate `ncarry`,
  21032. // note that ncarry could be >= 0x3ffffff
  21033. var ncarry = hncarry;
  21034. hncarry = 0;
  21035. var rword = carry & 0x3ffffff;
  21036. var maxJ = Math.min(k, num.length - 1);
  21037. for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
  21038. var i = k - j;
  21039. var a = self.words[i] | 0;
  21040. var b = num.words[j] | 0;
  21041. var r = a * b;
  21042. var lo = r & 0x3ffffff;
  21043. ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;
  21044. lo = (lo + rword) | 0;
  21045. rword = lo & 0x3ffffff;
  21046. ncarry = (ncarry + (lo >>> 26)) | 0;
  21047. hncarry += ncarry >>> 26;
  21048. ncarry &= 0x3ffffff;
  21049. }
  21050. out.words[k] = rword;
  21051. carry = ncarry;
  21052. ncarry = hncarry;
  21053. }
  21054. if (carry !== 0) {
  21055. out.words[k] = carry;
  21056. } else {
  21057. out.length--;
  21058. }
  21059. return out.strip();
  21060. }
  21061. function jumboMulTo (self, num, out) {
  21062. var fftm = new FFTM();
  21063. return fftm.mulp(self, num, out);
  21064. }
  21065. BN.prototype.mulTo = function mulTo (num, out) {
  21066. var res;
  21067. var len = this.length + num.length;
  21068. if (this.length === 10 && num.length === 10) {
  21069. res = comb10MulTo(this, num, out);
  21070. } else if (len < 63) {
  21071. res = smallMulTo(this, num, out);
  21072. } else if (len < 1024) {
  21073. res = bigMulTo(this, num, out);
  21074. } else {
  21075. res = jumboMulTo(this, num, out);
  21076. }
  21077. return res;
  21078. };
  21079. // Cooley-Tukey algorithm for FFT
  21080. // slightly revisited to rely on looping instead of recursion
  21081. function FFTM (x, y) {
  21082. this.x = x;
  21083. this.y = y;
  21084. }
  21085. FFTM.prototype.makeRBT = function makeRBT (N) {
  21086. var t = new Array(N);
  21087. var l = BN.prototype._countBits(N) - 1;
  21088. for (var i = 0; i < N; i++) {
  21089. t[i] = this.revBin(i, l, N);
  21090. }
  21091. return t;
  21092. };
  21093. // Returns binary-reversed representation of `x`
  21094. FFTM.prototype.revBin = function revBin (x, l, N) {
  21095. if (x === 0 || x === N - 1) return x;
  21096. var rb = 0;
  21097. for (var i = 0; i < l; i++) {
  21098. rb |= (x & 1) << (l - i - 1);
  21099. x >>= 1;
  21100. }
  21101. return rb;
  21102. };
  21103. // Performs "tweedling" phase, therefore 'emulating'
  21104. // behaviour of the recursive algorithm
  21105. FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {
  21106. for (var i = 0; i < N; i++) {
  21107. rtws[i] = rws[rbt[i]];
  21108. itws[i] = iws[rbt[i]];
  21109. }
  21110. };
  21111. FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {
  21112. this.permute(rbt, rws, iws, rtws, itws, N);
  21113. for (var s = 1; s < N; s <<= 1) {
  21114. var l = s << 1;
  21115. var rtwdf = Math.cos(2 * Math.PI / l);
  21116. var itwdf = Math.sin(2 * Math.PI / l);
  21117. for (var p = 0; p < N; p += l) {
  21118. var rtwdf_ = rtwdf;
  21119. var itwdf_ = itwdf;
  21120. for (var j = 0; j < s; j++) {
  21121. var re = rtws[p + j];
  21122. var ie = itws[p + j];
  21123. var ro = rtws[p + j + s];
  21124. var io = itws[p + j + s];
  21125. var rx = rtwdf_ * ro - itwdf_ * io;
  21126. io = rtwdf_ * io + itwdf_ * ro;
  21127. ro = rx;
  21128. rtws[p + j] = re + ro;
  21129. itws[p + j] = ie + io;
  21130. rtws[p + j + s] = re - ro;
  21131. itws[p + j + s] = ie - io;
  21132. /* jshint maxdepth : false */
  21133. if (j !== l) {
  21134. rx = rtwdf * rtwdf_ - itwdf * itwdf_;
  21135. itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
  21136. rtwdf_ = rx;
  21137. }
  21138. }
  21139. }
  21140. }
  21141. };
  21142. FFTM.prototype.guessLen13b = function guessLen13b (n, m) {
  21143. var N = Math.max(m, n) | 1;
  21144. var odd = N & 1;
  21145. var i = 0;
  21146. for (N = N / 2 | 0; N; N = N >>> 1) {
  21147. i++;
  21148. }
  21149. return 1 << i + 1 + odd;
  21150. };
  21151. FFTM.prototype.conjugate = function conjugate (rws, iws, N) {
  21152. if (N <= 1) return;
  21153. for (var i = 0; i < N / 2; i++) {
  21154. var t = rws[i];
  21155. rws[i] = rws[N - i - 1];
  21156. rws[N - i - 1] = t;
  21157. t = iws[i];
  21158. iws[i] = -iws[N - i - 1];
  21159. iws[N - i - 1] = -t;
  21160. }
  21161. };
  21162. FFTM.prototype.normalize13b = function normalize13b (ws, N) {
  21163. var carry = 0;
  21164. for (var i = 0; i < N / 2; i++) {
  21165. var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +
  21166. Math.round(ws[2 * i] / N) +
  21167. carry;
  21168. ws[i] = w & 0x3ffffff;
  21169. if (w < 0x4000000) {
  21170. carry = 0;
  21171. } else {
  21172. carry = w / 0x4000000 | 0;
  21173. }
  21174. }
  21175. return ws;
  21176. };
  21177. FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {
  21178. var carry = 0;
  21179. for (var i = 0; i < len; i++) {
  21180. carry = carry + (ws[i] | 0);
  21181. rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;
  21182. rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;
  21183. }
  21184. // Pad with zeroes
  21185. for (i = 2 * len; i < N; ++i) {
  21186. rws[i] = 0;
  21187. }
  21188. assert(carry === 0);
  21189. assert((carry & ~0x1fff) === 0);
  21190. };
  21191. FFTM.prototype.stub = function stub (N) {
  21192. var ph = new Array(N);
  21193. for (var i = 0; i < N; i++) {
  21194. ph[i] = 0;
  21195. }
  21196. return ph;
  21197. };
  21198. FFTM.prototype.mulp = function mulp (x, y, out) {
  21199. var N = 2 * this.guessLen13b(x.length, y.length);
  21200. var rbt = this.makeRBT(N);
  21201. var _ = this.stub(N);
  21202. var rws = new Array(N);
  21203. var rwst = new Array(N);
  21204. var iwst = new Array(N);
  21205. var nrws = new Array(N);
  21206. var nrwst = new Array(N);
  21207. var niwst = new Array(N);
  21208. var rmws = out.words;
  21209. rmws.length = N;
  21210. this.convert13b(x.words, x.length, rws, N);
  21211. this.convert13b(y.words, y.length, nrws, N);
  21212. this.transform(rws, _, rwst, iwst, N, rbt);
  21213. this.transform(nrws, _, nrwst, niwst, N, rbt);
  21214. for (var i = 0; i < N; i++) {
  21215. var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];
  21216. iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];
  21217. rwst[i] = rx;
  21218. }
  21219. this.conjugate(rwst, iwst, N);
  21220. this.transform(rwst, iwst, rmws, _, N, rbt);
  21221. this.conjugate(rmws, _, N);
  21222. this.normalize13b(rmws, N);
  21223. out.negative = x.negative ^ y.negative;
  21224. out.length = x.length + y.length;
  21225. return out.strip();
  21226. };
  21227. // Multiply `this` by `num`
  21228. BN.prototype.mul = function mul (num) {
  21229. var out = new BN(null);
  21230. out.words = new Array(this.length + num.length);
  21231. return this.mulTo(num, out);
  21232. };
  21233. // Multiply employing FFT
  21234. BN.prototype.mulf = function mulf (num) {
  21235. var out = new BN(null);
  21236. out.words = new Array(this.length + num.length);
  21237. return jumboMulTo(this, num, out);
  21238. };
  21239. // In-place Multiplication
  21240. BN.prototype.imul = function imul (num) {
  21241. return this.clone().mulTo(num, this);
  21242. };
  21243. BN.prototype.imuln = function imuln (num) {
  21244. assert(typeof num === 'number');
  21245. assert(num < 0x4000000);
  21246. // Carry
  21247. var carry = 0;
  21248. for (var i = 0; i < this.length; i++) {
  21249. var w = (this.words[i] | 0) * num;
  21250. var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);
  21251. carry >>= 26;
  21252. carry += (w / 0x4000000) | 0;
  21253. // NOTE: lo is 27bit maximum
  21254. carry += lo >>> 26;
  21255. this.words[i] = lo & 0x3ffffff;
  21256. }
  21257. if (carry !== 0) {
  21258. this.words[i] = carry;
  21259. this.length++;
  21260. }
  21261. return this;
  21262. };
  21263. BN.prototype.muln = function muln (num) {
  21264. return this.clone().imuln(num);
  21265. };
  21266. // `this` * `this`
  21267. BN.prototype.sqr = function sqr () {
  21268. return this.mul(this);
  21269. };
  21270. // `this` * `this` in-place
  21271. BN.prototype.isqr = function isqr () {
  21272. return this.imul(this.clone());
  21273. };
  21274. // Math.pow(`this`, `num`)
  21275. BN.prototype.pow = function pow (num) {
  21276. var w = toBitArray(num);
  21277. if (w.length === 0) return new BN(1);
  21278. // Skip leading zeroes
  21279. var res = this;
  21280. for (var i = 0; i < w.length; i++, res = res.sqr()) {
  21281. if (w[i] !== 0) break;
  21282. }
  21283. if (++i < w.length) {
  21284. for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {
  21285. if (w[i] === 0) continue;
  21286. res = res.mul(q);
  21287. }
  21288. }
  21289. return res;
  21290. };
  21291. // Shift-left in-place
  21292. BN.prototype.iushln = function iushln (bits) {
  21293. assert(typeof bits === 'number' && bits >= 0);
  21294. var r = bits % 26;
  21295. var s = (bits - r) / 26;
  21296. var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);
  21297. var i;
  21298. if (r !== 0) {
  21299. var carry = 0;
  21300. for (i = 0; i < this.length; i++) {
  21301. var newCarry = this.words[i] & carryMask;
  21302. var c = ((this.words[i] | 0) - newCarry) << r;
  21303. this.words[i] = c | carry;
  21304. carry = newCarry >>> (26 - r);
  21305. }
  21306. if (carry) {
  21307. this.words[i] = carry;
  21308. this.length++;
  21309. }
  21310. }
  21311. if (s !== 0) {
  21312. for (i = this.length - 1; i >= 0; i--) {
  21313. this.words[i + s] = this.words[i];
  21314. }
  21315. for (i = 0; i < s; i++) {
  21316. this.words[i] = 0;
  21317. }
  21318. this.length += s;
  21319. }
  21320. return this.strip();
  21321. };
  21322. BN.prototype.ishln = function ishln (bits) {
  21323. // TODO(indutny): implement me
  21324. assert(this.negative === 0);
  21325. return this.iushln(bits);
  21326. };
  21327. // Shift-right in-place
  21328. // NOTE: `hint` is a lowest bit before trailing zeroes
  21329. // NOTE: if `extended` is present - it will be filled with destroyed bits
  21330. BN.prototype.iushrn = function iushrn (bits, hint, extended) {
  21331. assert(typeof bits === 'number' && bits >= 0);
  21332. var h;
  21333. if (hint) {
  21334. h = (hint - (hint % 26)) / 26;
  21335. } else {
  21336. h = 0;
  21337. }
  21338. var r = bits % 26;
  21339. var s = Math.min((bits - r) / 26, this.length);
  21340. var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
  21341. var maskedWords = extended;
  21342. h -= s;
  21343. h = Math.max(0, h);
  21344. // Extended mode, copy masked part
  21345. if (maskedWords) {
  21346. for (var i = 0; i < s; i++) {
  21347. maskedWords.words[i] = this.words[i];
  21348. }
  21349. maskedWords.length = s;
  21350. }
  21351. if (s === 0) {
  21352. // No-op, we should not move anything at all
  21353. } else if (this.length > s) {
  21354. this.length -= s;
  21355. for (i = 0; i < this.length; i++) {
  21356. this.words[i] = this.words[i + s];
  21357. }
  21358. } else {
  21359. this.words[0] = 0;
  21360. this.length = 1;
  21361. }
  21362. var carry = 0;
  21363. for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {
  21364. var word = this.words[i] | 0;
  21365. this.words[i] = (carry << (26 - r)) | (word >>> r);
  21366. carry = word & mask;
  21367. }
  21368. // Push carried bits as a mask
  21369. if (maskedWords && carry !== 0) {
  21370. maskedWords.words[maskedWords.length++] = carry;
  21371. }
  21372. if (this.length === 0) {
  21373. this.words[0] = 0;
  21374. this.length = 1;
  21375. }
  21376. return this.strip();
  21377. };
  21378. BN.prototype.ishrn = function ishrn (bits, hint, extended) {
  21379. // TODO(indutny): implement me
  21380. assert(this.negative === 0);
  21381. return this.iushrn(bits, hint, extended);
  21382. };
  21383. // Shift-left
  21384. BN.prototype.shln = function shln (bits) {
  21385. return this.clone().ishln(bits);
  21386. };
  21387. BN.prototype.ushln = function ushln (bits) {
  21388. return this.clone().iushln(bits);
  21389. };
  21390. // Shift-right
  21391. BN.prototype.shrn = function shrn (bits) {
  21392. return this.clone().ishrn(bits);
  21393. };
  21394. BN.prototype.ushrn = function ushrn (bits) {
  21395. return this.clone().iushrn(bits);
  21396. };
  21397. // Test if n bit is set
  21398. BN.prototype.testn = function testn (bit) {
  21399. assert(typeof bit === 'number' && bit >= 0);
  21400. var r = bit % 26;
  21401. var s = (bit - r) / 26;
  21402. var q = 1 << r;
  21403. // Fast case: bit is much higher than all existing words
  21404. if (this.length <= s) return false;
  21405. // Check bit and return
  21406. var w = this.words[s];
  21407. return !!(w & q);
  21408. };
  21409. // Return only lowers bits of number (in-place)
  21410. BN.prototype.imaskn = function imaskn (bits) {
  21411. assert(typeof bits === 'number' && bits >= 0);
  21412. var r = bits % 26;
  21413. var s = (bits - r) / 26;
  21414. assert(this.negative === 0, 'imaskn works only with positive numbers');
  21415. if (this.length <= s) {
  21416. return this;
  21417. }
  21418. if (r !== 0) {
  21419. s++;
  21420. }
  21421. this.length = Math.min(s, this.length);
  21422. if (r !== 0) {
  21423. var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
  21424. this.words[this.length - 1] &= mask;
  21425. }
  21426. return this.strip();
  21427. };
  21428. // Return only lowers bits of number
  21429. BN.prototype.maskn = function maskn (bits) {
  21430. return this.clone().imaskn(bits);
  21431. };
  21432. // Add plain number `num` to `this`
  21433. BN.prototype.iaddn = function iaddn (num) {
  21434. assert(typeof num === 'number');
  21435. assert(num < 0x4000000);
  21436. if (num < 0) return this.isubn(-num);
  21437. // Possible sign change
  21438. if (this.negative !== 0) {
  21439. if (this.length === 1 && (this.words[0] | 0) < num) {
  21440. this.words[0] = num - (this.words[0] | 0);
  21441. this.negative = 0;
  21442. return this;
  21443. }
  21444. this.negative = 0;
  21445. this.isubn(num);
  21446. this.negative = 1;
  21447. return this;
  21448. }
  21449. // Add without checks
  21450. return this._iaddn(num);
  21451. };
  21452. BN.prototype._iaddn = function _iaddn (num) {
  21453. this.words[0] += num;
  21454. // Carry
  21455. for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {
  21456. this.words[i] -= 0x4000000;
  21457. if (i === this.length - 1) {
  21458. this.words[i + 1] = 1;
  21459. } else {
  21460. this.words[i + 1]++;
  21461. }
  21462. }
  21463. this.length = Math.max(this.length, i + 1);
  21464. return this;
  21465. };
  21466. // Subtract plain number `num` from `this`
  21467. BN.prototype.isubn = function isubn (num) {
  21468. assert(typeof num === 'number');
  21469. assert(num < 0x4000000);
  21470. if (num < 0) return this.iaddn(-num);
  21471. if (this.negative !== 0) {
  21472. this.negative = 0;
  21473. this.iaddn(num);
  21474. this.negative = 1;
  21475. return this;
  21476. }
  21477. this.words[0] -= num;
  21478. if (this.length === 1 && this.words[0] < 0) {
  21479. this.words[0] = -this.words[0];
  21480. this.negative = 1;
  21481. } else {
  21482. // Carry
  21483. for (var i = 0; i < this.length && this.words[i] < 0; i++) {
  21484. this.words[i] += 0x4000000;
  21485. this.words[i + 1] -= 1;
  21486. }
  21487. }
  21488. return this.strip();
  21489. };
  21490. BN.prototype.addn = function addn (num) {
  21491. return this.clone().iaddn(num);
  21492. };
  21493. BN.prototype.subn = function subn (num) {
  21494. return this.clone().isubn(num);
  21495. };
  21496. BN.prototype.iabs = function iabs () {
  21497. this.negative = 0;
  21498. return this;
  21499. };
  21500. BN.prototype.abs = function abs () {
  21501. return this.clone().iabs();
  21502. };
  21503. BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {
  21504. var len = num.length + shift;
  21505. var i;
  21506. this._expand(len);
  21507. var w;
  21508. var carry = 0;
  21509. for (i = 0; i < num.length; i++) {
  21510. w = (this.words[i + shift] | 0) + carry;
  21511. var right = (num.words[i] | 0) * mul;
  21512. w -= right & 0x3ffffff;
  21513. carry = (w >> 26) - ((right / 0x4000000) | 0);
  21514. this.words[i + shift] = w & 0x3ffffff;
  21515. }
  21516. for (; i < this.length - shift; i++) {
  21517. w = (this.words[i + shift] | 0) + carry;
  21518. carry = w >> 26;
  21519. this.words[i + shift] = w & 0x3ffffff;
  21520. }
  21521. if (carry === 0) return this.strip();
  21522. // Subtraction overflow
  21523. assert(carry === -1);
  21524. carry = 0;
  21525. for (i = 0; i < this.length; i++) {
  21526. w = -(this.words[i] | 0) + carry;
  21527. carry = w >> 26;
  21528. this.words[i] = w & 0x3ffffff;
  21529. }
  21530. this.negative = 1;
  21531. return this.strip();
  21532. };
  21533. BN.prototype._wordDiv = function _wordDiv (num, mode) {
  21534. var shift = this.length - num.length;
  21535. var a = this.clone();
  21536. var b = num;
  21537. // Normalize
  21538. var bhi = b.words[b.length - 1] | 0;
  21539. var bhiBits = this._countBits(bhi);
  21540. shift = 26 - bhiBits;
  21541. if (shift !== 0) {
  21542. b = b.ushln(shift);
  21543. a.iushln(shift);
  21544. bhi = b.words[b.length - 1] | 0;
  21545. }
  21546. // Initialize quotient
  21547. var m = a.length - b.length;
  21548. var q;
  21549. if (mode !== 'mod') {
  21550. q = new BN(null);
  21551. q.length = m + 1;
  21552. q.words = new Array(q.length);
  21553. for (var i = 0; i < q.length; i++) {
  21554. q.words[i] = 0;
  21555. }
  21556. }
  21557. var diff = a.clone()._ishlnsubmul(b, 1, m);
  21558. if (diff.negative === 0) {
  21559. a = diff;
  21560. if (q) {
  21561. q.words[m] = 1;
  21562. }
  21563. }
  21564. for (var j = m - 1; j >= 0; j--) {
  21565. var qj = (a.words[b.length + j] | 0) * 0x4000000 +
  21566. (a.words[b.length + j - 1] | 0);
  21567. // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
  21568. // (0x7ffffff)
  21569. qj = Math.min((qj / bhi) | 0, 0x3ffffff);
  21570. a._ishlnsubmul(b, qj, j);
  21571. while (a.negative !== 0) {
  21572. qj--;
  21573. a.negative = 0;
  21574. a._ishlnsubmul(b, 1, j);
  21575. if (!a.isZero()) {
  21576. a.negative ^= 1;
  21577. }
  21578. }
  21579. if (q) {
  21580. q.words[j] = qj;
  21581. }
  21582. }
  21583. if (q) {
  21584. q.strip();
  21585. }
  21586. a.strip();
  21587. // Denormalize
  21588. if (mode !== 'div' && shift !== 0) {
  21589. a.iushrn(shift);
  21590. }
  21591. return {
  21592. div: q || null,
  21593. mod: a
  21594. };
  21595. };
  21596. // NOTE: 1) `mode` can be set to `mod` to request mod only,
  21597. // to `div` to request div only, or be absent to
  21598. // request both div & mod
  21599. // 2) `positive` is true if unsigned mod is requested
  21600. BN.prototype.divmod = function divmod (num, mode, positive) {
  21601. assert(!num.isZero());
  21602. if (this.isZero()) {
  21603. return {
  21604. div: new BN(0),
  21605. mod: new BN(0)
  21606. };
  21607. }
  21608. var div, mod, res;
  21609. if (this.negative !== 0 && num.negative === 0) {
  21610. res = this.neg().divmod(num, mode);
  21611. if (mode !== 'mod') {
  21612. div = res.div.neg();
  21613. }
  21614. if (mode !== 'div') {
  21615. mod = res.mod.neg();
  21616. if (positive && mod.negative !== 0) {
  21617. mod.iadd(num);
  21618. }
  21619. }
  21620. return {
  21621. div: div,
  21622. mod: mod
  21623. };
  21624. }
  21625. if (this.negative === 0 && num.negative !== 0) {
  21626. res = this.divmod(num.neg(), mode);
  21627. if (mode !== 'mod') {
  21628. div = res.div.neg();
  21629. }
  21630. return {
  21631. div: div,
  21632. mod: res.mod
  21633. };
  21634. }
  21635. if ((this.negative & num.negative) !== 0) {
  21636. res = this.neg().divmod(num.neg(), mode);
  21637. if (mode !== 'div') {
  21638. mod = res.mod.neg();
  21639. if (positive && mod.negative !== 0) {
  21640. mod.isub(num);
  21641. }
  21642. }
  21643. return {
  21644. div: res.div,
  21645. mod: mod
  21646. };
  21647. }
  21648. // Both numbers are positive at this point
  21649. // Strip both numbers to approximate shift value
  21650. if (num.length > this.length || this.cmp(num) < 0) {
  21651. return {
  21652. div: new BN(0),
  21653. mod: this
  21654. };
  21655. }
  21656. // Very short reduction
  21657. if (num.length === 1) {
  21658. if (mode === 'div') {
  21659. return {
  21660. div: this.divn(num.words[0]),
  21661. mod: null
  21662. };
  21663. }
  21664. if (mode === 'mod') {
  21665. return {
  21666. div: null,
  21667. mod: new BN(this.modn(num.words[0]))
  21668. };
  21669. }
  21670. return {
  21671. div: this.divn(num.words[0]),
  21672. mod: new BN(this.modn(num.words[0]))
  21673. };
  21674. }
  21675. return this._wordDiv(num, mode);
  21676. };
  21677. // Find `this` / `num`
  21678. BN.prototype.div = function div (num) {
  21679. return this.divmod(num, 'div', false).div;
  21680. };
  21681. // Find `this` % `num`
  21682. BN.prototype.mod = function mod (num) {
  21683. return this.divmod(num, 'mod', false).mod;
  21684. };
  21685. BN.prototype.umod = function umod (num) {
  21686. return this.divmod(num, 'mod', true).mod;
  21687. };
  21688. // Find Round(`this` / `num`)
  21689. BN.prototype.divRound = function divRound (num) {
  21690. var dm = this.divmod(num);
  21691. // Fast case - exact division
  21692. if (dm.mod.isZero()) return dm.div;
  21693. var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
  21694. var half = num.ushrn(1);
  21695. var r2 = num.andln(1);
  21696. var cmp = mod.cmp(half);
  21697. // Round down
  21698. if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;
  21699. // Round up
  21700. return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
  21701. };
  21702. BN.prototype.modn = function modn (num) {
  21703. assert(num <= 0x3ffffff);
  21704. var p = (1 << 26) % num;
  21705. var acc = 0;
  21706. for (var i = this.length - 1; i >= 0; i--) {
  21707. acc = (p * acc + (this.words[i] | 0)) % num;
  21708. }
  21709. return acc;
  21710. };
  21711. // In-place division by number
  21712. BN.prototype.idivn = function idivn (num) {
  21713. assert(num <= 0x3ffffff);
  21714. var carry = 0;
  21715. for (var i = this.length - 1; i >= 0; i--) {
  21716. var w = (this.words[i] | 0) + carry * 0x4000000;
  21717. this.words[i] = (w / num) | 0;
  21718. carry = w % num;
  21719. }
  21720. return this.strip();
  21721. };
  21722. BN.prototype.divn = function divn (num) {
  21723. return this.clone().idivn(num);
  21724. };
  21725. BN.prototype.egcd = function egcd (p) {
  21726. assert(p.negative === 0);
  21727. assert(!p.isZero());
  21728. var x = this;
  21729. var y = p.clone();
  21730. if (x.negative !== 0) {
  21731. x = x.umod(p);
  21732. } else {
  21733. x = x.clone();
  21734. }
  21735. // A * x + B * y = x
  21736. var A = new BN(1);
  21737. var B = new BN(0);
  21738. // C * x + D * y = y
  21739. var C = new BN(0);
  21740. var D = new BN(1);
  21741. var g = 0;
  21742. while (x.isEven() && y.isEven()) {
  21743. x.iushrn(1);
  21744. y.iushrn(1);
  21745. ++g;
  21746. }
  21747. var yp = y.clone();
  21748. var xp = x.clone();
  21749. while (!x.isZero()) {
  21750. for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
  21751. if (i > 0) {
  21752. x.iushrn(i);
  21753. while (i-- > 0) {
  21754. if (A.isOdd() || B.isOdd()) {
  21755. A.iadd(yp);
  21756. B.isub(xp);
  21757. }
  21758. A.iushrn(1);
  21759. B.iushrn(1);
  21760. }
  21761. }
  21762. for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
  21763. if (j > 0) {
  21764. y.iushrn(j);
  21765. while (j-- > 0) {
  21766. if (C.isOdd() || D.isOdd()) {
  21767. C.iadd(yp);
  21768. D.isub(xp);
  21769. }
  21770. C.iushrn(1);
  21771. D.iushrn(1);
  21772. }
  21773. }
  21774. if (x.cmp(y) >= 0) {
  21775. x.isub(y);
  21776. A.isub(C);
  21777. B.isub(D);
  21778. } else {
  21779. y.isub(x);
  21780. C.isub(A);
  21781. D.isub(B);
  21782. }
  21783. }
  21784. return {
  21785. a: C,
  21786. b: D,
  21787. gcd: y.iushln(g)
  21788. };
  21789. };
  21790. // This is reduced incarnation of the binary EEA
  21791. // above, designated to invert members of the
  21792. // _prime_ fields F(p) at a maximal speed
  21793. BN.prototype._invmp = function _invmp (p) {
  21794. assert(p.negative === 0);
  21795. assert(!p.isZero());
  21796. var a = this;
  21797. var b = p.clone();
  21798. if (a.negative !== 0) {
  21799. a = a.umod(p);
  21800. } else {
  21801. a = a.clone();
  21802. }
  21803. var x1 = new BN(1);
  21804. var x2 = new BN(0);
  21805. var delta = b.clone();
  21806. while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
  21807. for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
  21808. if (i > 0) {
  21809. a.iushrn(i);
  21810. while (i-- > 0) {
  21811. if (x1.isOdd()) {
  21812. x1.iadd(delta);
  21813. }
  21814. x1.iushrn(1);
  21815. }
  21816. }
  21817. for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
  21818. if (j > 0) {
  21819. b.iushrn(j);
  21820. while (j-- > 0) {
  21821. if (x2.isOdd()) {
  21822. x2.iadd(delta);
  21823. }
  21824. x2.iushrn(1);
  21825. }
  21826. }
  21827. if (a.cmp(b) >= 0) {
  21828. a.isub(b);
  21829. x1.isub(x2);
  21830. } else {
  21831. b.isub(a);
  21832. x2.isub(x1);
  21833. }
  21834. }
  21835. var res;
  21836. if (a.cmpn(1) === 0) {
  21837. res = x1;
  21838. } else {
  21839. res = x2;
  21840. }
  21841. if (res.cmpn(0) < 0) {
  21842. res.iadd(p);
  21843. }
  21844. return res;
  21845. };
  21846. BN.prototype.gcd = function gcd (num) {
  21847. if (this.isZero()) return num.abs();
  21848. if (num.isZero()) return this.abs();
  21849. var a = this.clone();
  21850. var b = num.clone();
  21851. a.negative = 0;
  21852. b.negative = 0;
  21853. // Remove common factor of two
  21854. for (var shift = 0; a.isEven() && b.isEven(); shift++) {
  21855. a.iushrn(1);
  21856. b.iushrn(1);
  21857. }
  21858. do {
  21859. while (a.isEven()) {
  21860. a.iushrn(1);
  21861. }
  21862. while (b.isEven()) {
  21863. b.iushrn(1);
  21864. }
  21865. var r = a.cmp(b);
  21866. if (r < 0) {
  21867. // Swap `a` and `b` to make `a` always bigger than `b`
  21868. var t = a;
  21869. a = b;
  21870. b = t;
  21871. } else if (r === 0 || b.cmpn(1) === 0) {
  21872. break;
  21873. }
  21874. a.isub(b);
  21875. } while (true);
  21876. return b.iushln(shift);
  21877. };
  21878. // Invert number in the field F(num)
  21879. BN.prototype.invm = function invm (num) {
  21880. return this.egcd(num).a.umod(num);
  21881. };
  21882. BN.prototype.isEven = function isEven () {
  21883. return (this.words[0] & 1) === 0;
  21884. };
  21885. BN.prototype.isOdd = function isOdd () {
  21886. return (this.words[0] & 1) === 1;
  21887. };
  21888. // And first word and num
  21889. BN.prototype.andln = function andln (num) {
  21890. return this.words[0] & num;
  21891. };
  21892. // Increment at the bit position in-line
  21893. BN.prototype.bincn = function bincn (bit) {
  21894. assert(typeof bit === 'number');
  21895. var r = bit % 26;
  21896. var s = (bit - r) / 26;
  21897. var q = 1 << r;
  21898. // Fast case: bit is much higher than all existing words
  21899. if (this.length <= s) {
  21900. this._expand(s + 1);
  21901. this.words[s] |= q;
  21902. return this;
  21903. }
  21904. // Add bit and propagate, if needed
  21905. var carry = q;
  21906. for (var i = s; carry !== 0 && i < this.length; i++) {
  21907. var w = this.words[i] | 0;
  21908. w += carry;
  21909. carry = w >>> 26;
  21910. w &= 0x3ffffff;
  21911. this.words[i] = w;
  21912. }
  21913. if (carry !== 0) {
  21914. this.words[i] = carry;
  21915. this.length++;
  21916. }
  21917. return this;
  21918. };
  21919. BN.prototype.isZero = function isZero () {
  21920. return this.length === 1 && this.words[0] === 0;
  21921. };
  21922. BN.prototype.cmpn = function cmpn (num) {
  21923. var negative = num < 0;
  21924. if (this.negative !== 0 && !negative) return -1;
  21925. if (this.negative === 0 && negative) return 1;
  21926. this.strip();
  21927. var res;
  21928. if (this.length > 1) {
  21929. res = 1;
  21930. } else {
  21931. if (negative) {
  21932. num = -num;
  21933. }
  21934. assert(num <= 0x3ffffff, 'Number is too big');
  21935. var w = this.words[0] | 0;
  21936. res = w === num ? 0 : w < num ? -1 : 1;
  21937. }
  21938. if (this.negative !== 0) return -res | 0;
  21939. return res;
  21940. };
  21941. // Compare two numbers and return:
  21942. // 1 - if `this` > `num`
  21943. // 0 - if `this` == `num`
  21944. // -1 - if `this` < `num`
  21945. BN.prototype.cmp = function cmp (num) {
  21946. if (this.negative !== 0 && num.negative === 0) return -1;
  21947. if (this.negative === 0 && num.negative !== 0) return 1;
  21948. var res = this.ucmp(num);
  21949. if (this.negative !== 0) return -res | 0;
  21950. return res;
  21951. };
  21952. // Unsigned comparison
  21953. BN.prototype.ucmp = function ucmp (num) {
  21954. // At this point both numbers have the same sign
  21955. if (this.length > num.length) return 1;
  21956. if (this.length < num.length) return -1;
  21957. var res = 0;
  21958. for (var i = this.length - 1; i >= 0; i--) {
  21959. var a = this.words[i] | 0;
  21960. var b = num.words[i] | 0;
  21961. if (a === b) continue;
  21962. if (a < b) {
  21963. res = -1;
  21964. } else if (a > b) {
  21965. res = 1;
  21966. }
  21967. break;
  21968. }
  21969. return res;
  21970. };
  21971. BN.prototype.gtn = function gtn (num) {
  21972. return this.cmpn(num) === 1;
  21973. };
  21974. BN.prototype.gt = function gt (num) {
  21975. return this.cmp(num) === 1;
  21976. };
  21977. BN.prototype.gten = function gten (num) {
  21978. return this.cmpn(num) >= 0;
  21979. };
  21980. BN.prototype.gte = function gte (num) {
  21981. return this.cmp(num) >= 0;
  21982. };
  21983. BN.prototype.ltn = function ltn (num) {
  21984. return this.cmpn(num) === -1;
  21985. };
  21986. BN.prototype.lt = function lt (num) {
  21987. return this.cmp(num) === -1;
  21988. };
  21989. BN.prototype.lten = function lten (num) {
  21990. return this.cmpn(num) <= 0;
  21991. };
  21992. BN.prototype.lte = function lte (num) {
  21993. return this.cmp(num) <= 0;
  21994. };
  21995. BN.prototype.eqn = function eqn (num) {
  21996. return this.cmpn(num) === 0;
  21997. };
  21998. BN.prototype.eq = function eq (num) {
  21999. return this.cmp(num) === 0;
  22000. };
  22001. //
  22002. // A reduce context, could be using montgomery or something better, depending
  22003. // on the `m` itself.
  22004. //
  22005. BN.red = function red (num) {
  22006. return new Red(num);
  22007. };
  22008. BN.prototype.toRed = function toRed (ctx) {
  22009. assert(!this.red, 'Already a number in reduction context');
  22010. assert(this.negative === 0, 'red works only with positives');
  22011. return ctx.convertTo(this)._forceRed(ctx);
  22012. };
  22013. BN.prototype.fromRed = function fromRed () {
  22014. assert(this.red, 'fromRed works only with numbers in reduction context');
  22015. return this.red.convertFrom(this);
  22016. };
  22017. BN.prototype._forceRed = function _forceRed (ctx) {
  22018. this.red = ctx;
  22019. return this;
  22020. };
  22021. BN.prototype.forceRed = function forceRed (ctx) {
  22022. assert(!this.red, 'Already a number in reduction context');
  22023. return this._forceRed(ctx);
  22024. };
  22025. BN.prototype.redAdd = function redAdd (num) {
  22026. assert(this.red, 'redAdd works only with red numbers');
  22027. return this.red.add(this, num);
  22028. };
  22029. BN.prototype.redIAdd = function redIAdd (num) {
  22030. assert(this.red, 'redIAdd works only with red numbers');
  22031. return this.red.iadd(this, num);
  22032. };
  22033. BN.prototype.redSub = function redSub (num) {
  22034. assert(this.red, 'redSub works only with red numbers');
  22035. return this.red.sub(this, num);
  22036. };
  22037. BN.prototype.redISub = function redISub (num) {
  22038. assert(this.red, 'redISub works only with red numbers');
  22039. return this.red.isub(this, num);
  22040. };
  22041. BN.prototype.redShl = function redShl (num) {
  22042. assert(this.red, 'redShl works only with red numbers');
  22043. return this.red.shl(this, num);
  22044. };
  22045. BN.prototype.redMul = function redMul (num) {
  22046. assert(this.red, 'redMul works only with red numbers');
  22047. this.red._verify2(this, num);
  22048. return this.red.mul(this, num);
  22049. };
  22050. BN.prototype.redIMul = function redIMul (num) {
  22051. assert(this.red, 'redMul works only with red numbers');
  22052. this.red._verify2(this, num);
  22053. return this.red.imul(this, num);
  22054. };
  22055. BN.prototype.redSqr = function redSqr () {
  22056. assert(this.red, 'redSqr works only with red numbers');
  22057. this.red._verify1(this);
  22058. return this.red.sqr(this);
  22059. };
  22060. BN.prototype.redISqr = function redISqr () {
  22061. assert(this.red, 'redISqr works only with red numbers');
  22062. this.red._verify1(this);
  22063. return this.red.isqr(this);
  22064. };
  22065. // Square root over p
  22066. BN.prototype.redSqrt = function redSqrt () {
  22067. assert(this.red, 'redSqrt works only with red numbers');
  22068. this.red._verify1(this);
  22069. return this.red.sqrt(this);
  22070. };
  22071. BN.prototype.redInvm = function redInvm () {
  22072. assert(this.red, 'redInvm works only with red numbers');
  22073. this.red._verify1(this);
  22074. return this.red.invm(this);
  22075. };
  22076. // Return negative clone of `this` % `red modulo`
  22077. BN.prototype.redNeg = function redNeg () {
  22078. assert(this.red, 'redNeg works only with red numbers');
  22079. this.red._verify1(this);
  22080. return this.red.neg(this);
  22081. };
  22082. BN.prototype.redPow = function redPow (num) {
  22083. assert(this.red && !num.red, 'redPow(normalNum)');
  22084. this.red._verify1(this);
  22085. return this.red.pow(this, num);
  22086. };
  22087. // Prime numbers with efficient reduction
  22088. var primes = {
  22089. k256: null,
  22090. p224: null,
  22091. p192: null,
  22092. p25519: null
  22093. };
  22094. // Pseudo-Mersenne prime
  22095. function MPrime (name, p) {
  22096. // P = 2 ^ N - K
  22097. this.name = name;
  22098. this.p = new BN(p, 16);
  22099. this.n = this.p.bitLength();
  22100. this.k = new BN(1).iushln(this.n).isub(this.p);
  22101. this.tmp = this._tmp();
  22102. }
  22103. MPrime.prototype._tmp = function _tmp () {
  22104. var tmp = new BN(null);
  22105. tmp.words = new Array(Math.ceil(this.n / 13));
  22106. return tmp;
  22107. };
  22108. MPrime.prototype.ireduce = function ireduce (num) {
  22109. // Assumes that `num` is less than `P^2`
  22110. // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)
  22111. var r = num;
  22112. var rlen;
  22113. do {
  22114. this.split(r, this.tmp);
  22115. r = this.imulK(r);
  22116. r = r.iadd(this.tmp);
  22117. rlen = r.bitLength();
  22118. } while (rlen > this.n);
  22119. var cmp = rlen < this.n ? -1 : r.ucmp(this.p);
  22120. if (cmp === 0) {
  22121. r.words[0] = 0;
  22122. r.length = 1;
  22123. } else if (cmp > 0) {
  22124. r.isub(this.p);
  22125. } else {
  22126. if (r.strip !== undefined) {
  22127. // r is BN v4 instance
  22128. r.strip();
  22129. } else {
  22130. // r is BN v5 instance
  22131. r._strip();
  22132. }
  22133. }
  22134. return r;
  22135. };
  22136. MPrime.prototype.split = function split (input, out) {
  22137. input.iushrn(this.n, 0, out);
  22138. };
  22139. MPrime.prototype.imulK = function imulK (num) {
  22140. return num.imul(this.k);
  22141. };
  22142. function K256 () {
  22143. MPrime.call(
  22144. this,
  22145. 'k256',
  22146. 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');
  22147. }
  22148. inherits(K256, MPrime);
  22149. K256.prototype.split = function split (input, output) {
  22150. // 256 = 9 * 26 + 22
  22151. var mask = 0x3fffff;
  22152. var outLen = Math.min(input.length, 9);
  22153. for (var i = 0; i < outLen; i++) {
  22154. output.words[i] = input.words[i];
  22155. }
  22156. output.length = outLen;
  22157. if (input.length <= 9) {
  22158. input.words[0] = 0;
  22159. input.length = 1;
  22160. return;
  22161. }
  22162. // Shift by 9 limbs
  22163. var prev = input.words[9];
  22164. output.words[output.length++] = prev & mask;
  22165. for (i = 10; i < input.length; i++) {
  22166. var next = input.words[i] | 0;
  22167. input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);
  22168. prev = next;
  22169. }
  22170. prev >>>= 22;
  22171. input.words[i - 10] = prev;
  22172. if (prev === 0 && input.length > 10) {
  22173. input.length -= 10;
  22174. } else {
  22175. input.length -= 9;
  22176. }
  22177. };
  22178. K256.prototype.imulK = function imulK (num) {
  22179. // K = 0x1000003d1 = [ 0x40, 0x3d1 ]
  22180. num.words[num.length] = 0;
  22181. num.words[num.length + 1] = 0;
  22182. num.length += 2;
  22183. // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
  22184. var lo = 0;
  22185. for (var i = 0; i < num.length; i++) {
  22186. var w = num.words[i] | 0;
  22187. lo += w * 0x3d1;
  22188. num.words[i] = lo & 0x3ffffff;
  22189. lo = w * 0x40 + ((lo / 0x4000000) | 0);
  22190. }
  22191. // Fast length reduction
  22192. if (num.words[num.length - 1] === 0) {
  22193. num.length--;
  22194. if (num.words[num.length - 1] === 0) {
  22195. num.length--;
  22196. }
  22197. }
  22198. return num;
  22199. };
  22200. function P224 () {
  22201. MPrime.call(
  22202. this,
  22203. 'p224',
  22204. 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');
  22205. }
  22206. inherits(P224, MPrime);
  22207. function P192 () {
  22208. MPrime.call(
  22209. this,
  22210. 'p192',
  22211. 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');
  22212. }
  22213. inherits(P192, MPrime);
  22214. function P25519 () {
  22215. // 2 ^ 255 - 19
  22216. MPrime.call(
  22217. this,
  22218. '25519',
  22219. '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');
  22220. }
  22221. inherits(P25519, MPrime);
  22222. P25519.prototype.imulK = function imulK (num) {
  22223. // K = 0x13
  22224. var carry = 0;
  22225. for (var i = 0; i < num.length; i++) {
  22226. var hi = (num.words[i] | 0) * 0x13 + carry;
  22227. var lo = hi & 0x3ffffff;
  22228. hi >>>= 26;
  22229. num.words[i] = lo;
  22230. carry = hi;
  22231. }
  22232. if (carry !== 0) {
  22233. num.words[num.length++] = carry;
  22234. }
  22235. return num;
  22236. };
  22237. // Exported mostly for testing purposes, use plain name instead
  22238. BN._prime = function prime (name) {
  22239. // Cached version of prime
  22240. if (primes[name]) return primes[name];
  22241. var prime;
  22242. if (name === 'k256') {
  22243. prime = new K256();
  22244. } else if (name === 'p224') {
  22245. prime = new P224();
  22246. } else if (name === 'p192') {
  22247. prime = new P192();
  22248. } else if (name === 'p25519') {
  22249. prime = new P25519();
  22250. } else {
  22251. throw new Error('Unknown prime ' + name);
  22252. }
  22253. primes[name] = prime;
  22254. return prime;
  22255. };
  22256. //
  22257. // Base reduction engine
  22258. //
  22259. function Red (m) {
  22260. if (typeof m === 'string') {
  22261. var prime = BN._prime(m);
  22262. this.m = prime.p;
  22263. this.prime = prime;
  22264. } else {
  22265. assert(m.gtn(1), 'modulus must be greater than 1');
  22266. this.m = m;
  22267. this.prime = null;
  22268. }
  22269. }
  22270. Red.prototype._verify1 = function _verify1 (a) {
  22271. assert(a.negative === 0, 'red works only with positives');
  22272. assert(a.red, 'red works only with red numbers');
  22273. };
  22274. Red.prototype._verify2 = function _verify2 (a, b) {
  22275. assert((a.negative | b.negative) === 0, 'red works only with positives');
  22276. assert(a.red && a.red === b.red,
  22277. 'red works only with red numbers');
  22278. };
  22279. Red.prototype.imod = function imod (a) {
  22280. if (this.prime) return this.prime.ireduce(a)._forceRed(this);
  22281. return a.umod(this.m)._forceRed(this);
  22282. };
  22283. Red.prototype.neg = function neg (a) {
  22284. if (a.isZero()) {
  22285. return a.clone();
  22286. }
  22287. return this.m.sub(a)._forceRed(this);
  22288. };
  22289. Red.prototype.add = function add (a, b) {
  22290. this._verify2(a, b);
  22291. var res = a.add(b);
  22292. if (res.cmp(this.m) >= 0) {
  22293. res.isub(this.m);
  22294. }
  22295. return res._forceRed(this);
  22296. };
  22297. Red.prototype.iadd = function iadd (a, b) {
  22298. this._verify2(a, b);
  22299. var res = a.iadd(b);
  22300. if (res.cmp(this.m) >= 0) {
  22301. res.isub(this.m);
  22302. }
  22303. return res;
  22304. };
  22305. Red.prototype.sub = function sub (a, b) {
  22306. this._verify2(a, b);
  22307. var res = a.sub(b);
  22308. if (res.cmpn(0) < 0) {
  22309. res.iadd(this.m);
  22310. }
  22311. return res._forceRed(this);
  22312. };
  22313. Red.prototype.isub = function isub (a, b) {
  22314. this._verify2(a, b);
  22315. var res = a.isub(b);
  22316. if (res.cmpn(0) < 0) {
  22317. res.iadd(this.m);
  22318. }
  22319. return res;
  22320. };
  22321. Red.prototype.shl = function shl (a, num) {
  22322. this._verify1(a);
  22323. return this.imod(a.ushln(num));
  22324. };
  22325. Red.prototype.imul = function imul (a, b) {
  22326. this._verify2(a, b);
  22327. return this.imod(a.imul(b));
  22328. };
  22329. Red.prototype.mul = function mul (a, b) {
  22330. this._verify2(a, b);
  22331. return this.imod(a.mul(b));
  22332. };
  22333. Red.prototype.isqr = function isqr (a) {
  22334. return this.imul(a, a.clone());
  22335. };
  22336. Red.prototype.sqr = function sqr (a) {
  22337. return this.mul(a, a);
  22338. };
  22339. Red.prototype.sqrt = function sqrt (a) {
  22340. if (a.isZero()) return a.clone();
  22341. var mod3 = this.m.andln(3);
  22342. assert(mod3 % 2 === 1);
  22343. // Fast case
  22344. if (mod3 === 3) {
  22345. var pow = this.m.add(new BN(1)).iushrn(2);
  22346. return this.pow(a, pow);
  22347. }
  22348. // Tonelli-Shanks algorithm (Totally unoptimized and slow)
  22349. //
  22350. // Find Q and S, that Q * 2 ^ S = (P - 1)
  22351. var q = this.m.subn(1);
  22352. var s = 0;
  22353. while (!q.isZero() && q.andln(1) === 0) {
  22354. s++;
  22355. q.iushrn(1);
  22356. }
  22357. assert(!q.isZero());
  22358. var one = new BN(1).toRed(this);
  22359. var nOne = one.redNeg();
  22360. // Find quadratic non-residue
  22361. // NOTE: Max is such because of generalized Riemann hypothesis.
  22362. var lpow = this.m.subn(1).iushrn(1);
  22363. var z = this.m.bitLength();
  22364. z = new BN(2 * z * z).toRed(this);
  22365. while (this.pow(z, lpow).cmp(nOne) !== 0) {
  22366. z.redIAdd(nOne);
  22367. }
  22368. var c = this.pow(z, q);
  22369. var r = this.pow(a, q.addn(1).iushrn(1));
  22370. var t = this.pow(a, q);
  22371. var m = s;
  22372. while (t.cmp(one) !== 0) {
  22373. var tmp = t;
  22374. for (var i = 0; tmp.cmp(one) !== 0; i++) {
  22375. tmp = tmp.redSqr();
  22376. }
  22377. assert(i < m);
  22378. var b = this.pow(c, new BN(1).iushln(m - i - 1));
  22379. r = r.redMul(b);
  22380. c = b.redSqr();
  22381. t = t.redMul(c);
  22382. m = i;
  22383. }
  22384. return r;
  22385. };
  22386. Red.prototype.invm = function invm (a) {
  22387. var inv = a._invmp(this.m);
  22388. if (inv.negative !== 0) {
  22389. inv.negative = 0;
  22390. return this.imod(inv).redNeg();
  22391. } else {
  22392. return this.imod(inv);
  22393. }
  22394. };
  22395. Red.prototype.pow = function pow (a, num) {
  22396. if (num.isZero()) return new BN(1).toRed(this);
  22397. if (num.cmpn(1) === 0) return a.clone();
  22398. var windowSize = 4;
  22399. var wnd = new Array(1 << windowSize);
  22400. wnd[0] = new BN(1).toRed(this);
  22401. wnd[1] = a;
  22402. for (var i = 2; i < wnd.length; i++) {
  22403. wnd[i] = this.mul(wnd[i - 1], a);
  22404. }
  22405. var res = wnd[0];
  22406. var current = 0;
  22407. var currentLen = 0;
  22408. var start = num.bitLength() % 26;
  22409. if (start === 0) {
  22410. start = 26;
  22411. }
  22412. for (i = num.length - 1; i >= 0; i--) {
  22413. var word = num.words[i];
  22414. for (var j = start - 1; j >= 0; j--) {
  22415. var bit = (word >> j) & 1;
  22416. if (res !== wnd[0]) {
  22417. res = this.sqr(res);
  22418. }
  22419. if (bit === 0 && current === 0) {
  22420. currentLen = 0;
  22421. continue;
  22422. }
  22423. current <<= 1;
  22424. current |= bit;
  22425. currentLen++;
  22426. if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;
  22427. res = this.mul(res, wnd[current]);
  22428. currentLen = 0;
  22429. current = 0;
  22430. }
  22431. start = 26;
  22432. }
  22433. return res;
  22434. };
  22435. Red.prototype.convertTo = function convertTo (num) {
  22436. var r = num.umod(this.m);
  22437. return r === num ? r.clone() : r;
  22438. };
  22439. Red.prototype.convertFrom = function convertFrom (num) {
  22440. var res = num.clone();
  22441. res.red = null;
  22442. return res;
  22443. };
  22444. //
  22445. // Montgomery method engine
  22446. //
  22447. BN.mont = function mont (num) {
  22448. return new Mont(num);
  22449. };
  22450. function Mont (m) {
  22451. Red.call(this, m);
  22452. this.shift = this.m.bitLength();
  22453. if (this.shift % 26 !== 0) {
  22454. this.shift += 26 - (this.shift % 26);
  22455. }
  22456. this.r = new BN(1).iushln(this.shift);
  22457. this.r2 = this.imod(this.r.sqr());
  22458. this.rinv = this.r._invmp(this.m);
  22459. this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
  22460. this.minv = this.minv.umod(this.r);
  22461. this.minv = this.r.sub(this.minv);
  22462. }
  22463. inherits(Mont, Red);
  22464. Mont.prototype.convertTo = function convertTo (num) {
  22465. return this.imod(num.ushln(this.shift));
  22466. };
  22467. Mont.prototype.convertFrom = function convertFrom (num) {
  22468. var r = this.imod(num.mul(this.rinv));
  22469. r.red = null;
  22470. return r;
  22471. };
  22472. Mont.prototype.imul = function imul (a, b) {
  22473. if (a.isZero() || b.isZero()) {
  22474. a.words[0] = 0;
  22475. a.length = 1;
  22476. return a;
  22477. }
  22478. var t = a.imul(b);
  22479. var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
  22480. var u = t.isub(c).iushrn(this.shift);
  22481. var res = u;
  22482. if (u.cmp(this.m) >= 0) {
  22483. res = u.isub(this.m);
  22484. } else if (u.cmpn(0) < 0) {
  22485. res = u.iadd(this.m);
  22486. }
  22487. return res._forceRed(this);
  22488. };
  22489. Mont.prototype.mul = function mul (a, b) {
  22490. if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);
  22491. var t = a.mul(b);
  22492. var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
  22493. var u = t.isub(c).iushrn(this.shift);
  22494. var res = u;
  22495. if (u.cmp(this.m) >= 0) {
  22496. res = u.isub(this.m);
  22497. } else if (u.cmpn(0) < 0) {
  22498. res = u.iadd(this.m);
  22499. }
  22500. return res._forceRed(this);
  22501. };
  22502. Mont.prototype.invm = function invm (a) {
  22503. // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R
  22504. var res = this.imod(a._invmp(this.m).mul(this.r2));
  22505. return res._forceRed(this);
  22506. };
  22507. })( false || module, this);
  22508. /***/ }),
  22509. /***/ "../../node_modules/elliptic/lib/elliptic.js":
  22510. /*!***************************************************!*\
  22511. !*** ../../node_modules/elliptic/lib/elliptic.js ***!
  22512. \***************************************************/
  22513. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  22514. "use strict";
  22515. var elliptic = exports;
  22516. elliptic.version = (__webpack_require__(/*! ../package.json */ "../../node_modules/elliptic/package.json").version);
  22517. elliptic.utils = __webpack_require__(/*! ./elliptic/utils */ "../../node_modules/elliptic/lib/elliptic/utils.js");
  22518. elliptic.rand = __webpack_require__(/*! brorand */ "../../node_modules/brorand/index.js");
  22519. elliptic.curve = __webpack_require__(/*! ./elliptic/curve */ "../../node_modules/elliptic/lib/elliptic/curve/index.js");
  22520. elliptic.curves = __webpack_require__(/*! ./elliptic/curves */ "../../node_modules/elliptic/lib/elliptic/curves.js");
  22521. // Protocols
  22522. elliptic.ec = __webpack_require__(/*! ./elliptic/ec */ "../../node_modules/elliptic/lib/elliptic/ec/index.js");
  22523. elliptic.eddsa = __webpack_require__(/*! ./elliptic/eddsa */ "../../node_modules/elliptic/lib/elliptic/eddsa/index.js");
  22524. /***/ }),
  22525. /***/ "../../node_modules/elliptic/lib/elliptic/curve/base.js":
  22526. /*!**************************************************************!*\
  22527. !*** ../../node_modules/elliptic/lib/elliptic/curve/base.js ***!
  22528. \**************************************************************/
  22529. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  22530. "use strict";
  22531. var BN = __webpack_require__(/*! bn.js */ "../../node_modules/diffie-hellman/node_modules/bn.js/lib/bn.js");
  22532. var utils = __webpack_require__(/*! ../utils */ "../../node_modules/elliptic/lib/elliptic/utils.js");
  22533. var getNAF = utils.getNAF;
  22534. var getJSF = utils.getJSF;
  22535. var assert = utils.assert;
  22536. function BaseCurve(type, conf) {
  22537. this.type = type;
  22538. this.p = new BN(conf.p, 16);
  22539. // Use Montgomery, when there is no fast reduction for the prime
  22540. this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p);
  22541. // Useful for many curves
  22542. this.zero = new BN(0).toRed(this.red);
  22543. this.one = new BN(1).toRed(this.red);
  22544. this.two = new BN(2).toRed(this.red);
  22545. // Curve configuration, optional
  22546. this.n = conf.n && new BN(conf.n, 16);
  22547. this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed);
  22548. // Temporary arrays
  22549. this._wnafT1 = new Array(4);
  22550. this._wnafT2 = new Array(4);
  22551. this._wnafT3 = new Array(4);
  22552. this._wnafT4 = new Array(4);
  22553. this._bitLength = this.n ? this.n.bitLength() : 0;
  22554. // Generalized Greg Maxwell's trick
  22555. var adjustCount = this.n && this.p.div(this.n);
  22556. if (!adjustCount || adjustCount.cmpn(100) > 0) {
  22557. this.redN = null;
  22558. } else {
  22559. this._maxwellTrick = true;
  22560. this.redN = this.n.toRed(this.red);
  22561. }
  22562. }
  22563. module.exports = BaseCurve;
  22564. BaseCurve.prototype.point = function point() {
  22565. throw new Error('Not implemented');
  22566. };
  22567. BaseCurve.prototype.validate = function validate() {
  22568. throw new Error('Not implemented');
  22569. };
  22570. BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) {
  22571. assert(p.precomputed);
  22572. var doubles = p._getDoubles();
  22573. var naf = getNAF(k, 1, this._bitLength);
  22574. var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1);
  22575. I /= 3;
  22576. // Translate into more windowed form
  22577. var repr = [];
  22578. var j;
  22579. var nafW;
  22580. for (j = 0; j < naf.length; j += doubles.step) {
  22581. nafW = 0;
  22582. for (var l = j + doubles.step - 1; l >= j; l--)
  22583. nafW = (nafW << 1) + naf[l];
  22584. repr.push(nafW);
  22585. }
  22586. var a = this.jpoint(null, null, null);
  22587. var b = this.jpoint(null, null, null);
  22588. for (var i = I; i > 0; i--) {
  22589. for (j = 0; j < repr.length; j++) {
  22590. nafW = repr[j];
  22591. if (nafW === i)
  22592. b = b.mixedAdd(doubles.points[j]);
  22593. else if (nafW === -i)
  22594. b = b.mixedAdd(doubles.points[j].neg());
  22595. }
  22596. a = a.add(b);
  22597. }
  22598. return a.toP();
  22599. };
  22600. BaseCurve.prototype._wnafMul = function _wnafMul(p, k) {
  22601. var w = 4;
  22602. // Precompute window
  22603. var nafPoints = p._getNAFPoints(w);
  22604. w = nafPoints.wnd;
  22605. var wnd = nafPoints.points;
  22606. // Get NAF form
  22607. var naf = getNAF(k, w, this._bitLength);
  22608. // Add `this`*(N+1) for every w-NAF index
  22609. var acc = this.jpoint(null, null, null);
  22610. for (var i = naf.length - 1; i >= 0; i--) {
  22611. // Count zeroes
  22612. for (var l = 0; i >= 0 && naf[i] === 0; i--)
  22613. l++;
  22614. if (i >= 0)
  22615. l++;
  22616. acc = acc.dblp(l);
  22617. if (i < 0)
  22618. break;
  22619. var z = naf[i];
  22620. assert(z !== 0);
  22621. if (p.type === 'affine') {
  22622. // J +- P
  22623. if (z > 0)
  22624. acc = acc.mixedAdd(wnd[(z - 1) >> 1]);
  22625. else
  22626. acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg());
  22627. } else {
  22628. // J +- J
  22629. if (z > 0)
  22630. acc = acc.add(wnd[(z - 1) >> 1]);
  22631. else
  22632. acc = acc.add(wnd[(-z - 1) >> 1].neg());
  22633. }
  22634. }
  22635. return p.type === 'affine' ? acc.toP() : acc;
  22636. };
  22637. BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW,
  22638. points,
  22639. coeffs,
  22640. len,
  22641. jacobianResult) {
  22642. var wndWidth = this._wnafT1;
  22643. var wnd = this._wnafT2;
  22644. var naf = this._wnafT3;
  22645. // Fill all arrays
  22646. var max = 0;
  22647. var i;
  22648. var j;
  22649. var p;
  22650. for (i = 0; i < len; i++) {
  22651. p = points[i];
  22652. var nafPoints = p._getNAFPoints(defW);
  22653. wndWidth[i] = nafPoints.wnd;
  22654. wnd[i] = nafPoints.points;
  22655. }
  22656. // Comb small window NAFs
  22657. for (i = len - 1; i >= 1; i -= 2) {
  22658. var a = i - 1;
  22659. var b = i;
  22660. if (wndWidth[a] !== 1 || wndWidth[b] !== 1) {
  22661. naf[a] = getNAF(coeffs[a], wndWidth[a], this._bitLength);
  22662. naf[b] = getNAF(coeffs[b], wndWidth[b], this._bitLength);
  22663. max = Math.max(naf[a].length, max);
  22664. max = Math.max(naf[b].length, max);
  22665. continue;
  22666. }
  22667. var comb = [
  22668. points[a], /* 1 */
  22669. null, /* 3 */
  22670. null, /* 5 */
  22671. points[b], /* 7 */
  22672. ];
  22673. // Try to avoid Projective points, if possible
  22674. if (points[a].y.cmp(points[b].y) === 0) {
  22675. comb[1] = points[a].add(points[b]);
  22676. comb[2] = points[a].toJ().mixedAdd(points[b].neg());
  22677. } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) {
  22678. comb[1] = points[a].toJ().mixedAdd(points[b]);
  22679. comb[2] = points[a].add(points[b].neg());
  22680. } else {
  22681. comb[1] = points[a].toJ().mixedAdd(points[b]);
  22682. comb[2] = points[a].toJ().mixedAdd(points[b].neg());
  22683. }
  22684. var index = [
  22685. -3, /* -1 -1 */
  22686. -1, /* -1 0 */
  22687. -5, /* -1 1 */
  22688. -7, /* 0 -1 */
  22689. 0, /* 0 0 */
  22690. 7, /* 0 1 */
  22691. 5, /* 1 -1 */
  22692. 1, /* 1 0 */
  22693. 3, /* 1 1 */
  22694. ];
  22695. var jsf = getJSF(coeffs[a], coeffs[b]);
  22696. max = Math.max(jsf[0].length, max);
  22697. naf[a] = new Array(max);
  22698. naf[b] = new Array(max);
  22699. for (j = 0; j < max; j++) {
  22700. var ja = jsf[0][j] | 0;
  22701. var jb = jsf[1][j] | 0;
  22702. naf[a][j] = index[(ja + 1) * 3 + (jb + 1)];
  22703. naf[b][j] = 0;
  22704. wnd[a] = comb;
  22705. }
  22706. }
  22707. var acc = this.jpoint(null, null, null);
  22708. var tmp = this._wnafT4;
  22709. for (i = max; i >= 0; i--) {
  22710. var k = 0;
  22711. while (i >= 0) {
  22712. var zero = true;
  22713. for (j = 0; j < len; j++) {
  22714. tmp[j] = naf[j][i] | 0;
  22715. if (tmp[j] !== 0)
  22716. zero = false;
  22717. }
  22718. if (!zero)
  22719. break;
  22720. k++;
  22721. i--;
  22722. }
  22723. if (i >= 0)
  22724. k++;
  22725. acc = acc.dblp(k);
  22726. if (i < 0)
  22727. break;
  22728. for (j = 0; j < len; j++) {
  22729. var z = tmp[j];
  22730. p;
  22731. if (z === 0)
  22732. continue;
  22733. else if (z > 0)
  22734. p = wnd[j][(z - 1) >> 1];
  22735. else if (z < 0)
  22736. p = wnd[j][(-z - 1) >> 1].neg();
  22737. if (p.type === 'affine')
  22738. acc = acc.mixedAdd(p);
  22739. else
  22740. acc = acc.add(p);
  22741. }
  22742. }
  22743. // Zeroify references
  22744. for (i = 0; i < len; i++)
  22745. wnd[i] = null;
  22746. if (jacobianResult)
  22747. return acc;
  22748. else
  22749. return acc.toP();
  22750. };
  22751. function BasePoint(curve, type) {
  22752. this.curve = curve;
  22753. this.type = type;
  22754. this.precomputed = null;
  22755. }
  22756. BaseCurve.BasePoint = BasePoint;
  22757. BasePoint.prototype.eq = function eq(/*other*/) {
  22758. throw new Error('Not implemented');
  22759. };
  22760. BasePoint.prototype.validate = function validate() {
  22761. return this.curve.validate(this);
  22762. };
  22763. BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
  22764. bytes = utils.toArray(bytes, enc);
  22765. var len = this.p.byteLength();
  22766. // uncompressed, hybrid-odd, hybrid-even
  22767. if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) &&
  22768. bytes.length - 1 === 2 * len) {
  22769. if (bytes[0] === 0x06)
  22770. assert(bytes[bytes.length - 1] % 2 === 0);
  22771. else if (bytes[0] === 0x07)
  22772. assert(bytes[bytes.length - 1] % 2 === 1);
  22773. var res = this.point(bytes.slice(1, 1 + len),
  22774. bytes.slice(1 + len, 1 + 2 * len));
  22775. return res;
  22776. } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) &&
  22777. bytes.length - 1 === len) {
  22778. return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03);
  22779. }
  22780. throw new Error('Unknown point format');
  22781. };
  22782. BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) {
  22783. return this.encode(enc, true);
  22784. };
  22785. BasePoint.prototype._encode = function _encode(compact) {
  22786. var len = this.curve.p.byteLength();
  22787. var x = this.getX().toArray('be', len);
  22788. if (compact)
  22789. return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x);
  22790. return [ 0x04 ].concat(x, this.getY().toArray('be', len));
  22791. };
  22792. BasePoint.prototype.encode = function encode(enc, compact) {
  22793. return utils.encode(this._encode(compact), enc);
  22794. };
  22795. BasePoint.prototype.precompute = function precompute(power) {
  22796. if (this.precomputed)
  22797. return this;
  22798. var precomputed = {
  22799. doubles: null,
  22800. naf: null,
  22801. beta: null,
  22802. };
  22803. precomputed.naf = this._getNAFPoints(8);
  22804. precomputed.doubles = this._getDoubles(4, power);
  22805. precomputed.beta = this._getBeta();
  22806. this.precomputed = precomputed;
  22807. return this;
  22808. };
  22809. BasePoint.prototype._hasDoubles = function _hasDoubles(k) {
  22810. if (!this.precomputed)
  22811. return false;
  22812. var doubles = this.precomputed.doubles;
  22813. if (!doubles)
  22814. return false;
  22815. return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step);
  22816. };
  22817. BasePoint.prototype._getDoubles = function _getDoubles(step, power) {
  22818. if (this.precomputed && this.precomputed.doubles)
  22819. return this.precomputed.doubles;
  22820. var doubles = [ this ];
  22821. var acc = this;
  22822. for (var i = 0; i < power; i += step) {
  22823. for (var j = 0; j < step; j++)
  22824. acc = acc.dbl();
  22825. doubles.push(acc);
  22826. }
  22827. return {
  22828. step: step,
  22829. points: doubles,
  22830. };
  22831. };
  22832. BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) {
  22833. if (this.precomputed && this.precomputed.naf)
  22834. return this.precomputed.naf;
  22835. var res = [ this ];
  22836. var max = (1 << wnd) - 1;
  22837. var dbl = max === 1 ? null : this.dbl();
  22838. for (var i = 1; i < max; i++)
  22839. res[i] = res[i - 1].add(dbl);
  22840. return {
  22841. wnd: wnd,
  22842. points: res,
  22843. };
  22844. };
  22845. BasePoint.prototype._getBeta = function _getBeta() {
  22846. return null;
  22847. };
  22848. BasePoint.prototype.dblp = function dblp(k) {
  22849. var r = this;
  22850. for (var i = 0; i < k; i++)
  22851. r = r.dbl();
  22852. return r;
  22853. };
  22854. /***/ }),
  22855. /***/ "../../node_modules/elliptic/lib/elliptic/curve/edwards.js":
  22856. /*!*****************************************************************!*\
  22857. !*** ../../node_modules/elliptic/lib/elliptic/curve/edwards.js ***!
  22858. \*****************************************************************/
  22859. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  22860. "use strict";
  22861. var utils = __webpack_require__(/*! ../utils */ "../../node_modules/elliptic/lib/elliptic/utils.js");
  22862. var BN = __webpack_require__(/*! bn.js */ "../../node_modules/diffie-hellman/node_modules/bn.js/lib/bn.js");
  22863. var inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js");
  22864. var Base = __webpack_require__(/*! ./base */ "../../node_modules/elliptic/lib/elliptic/curve/base.js");
  22865. var assert = utils.assert;
  22866. function EdwardsCurve(conf) {
  22867. // NOTE: Important as we are creating point in Base.call()
  22868. this.twisted = (conf.a | 0) !== 1;
  22869. this.mOneA = this.twisted && (conf.a | 0) === -1;
  22870. this.extended = this.mOneA;
  22871. Base.call(this, 'edwards', conf);
  22872. this.a = new BN(conf.a, 16).umod(this.red.m);
  22873. this.a = this.a.toRed(this.red);
  22874. this.c = new BN(conf.c, 16).toRed(this.red);
  22875. this.c2 = this.c.redSqr();
  22876. this.d = new BN(conf.d, 16).toRed(this.red);
  22877. this.dd = this.d.redAdd(this.d);
  22878. assert(!this.twisted || this.c.fromRed().cmpn(1) === 0);
  22879. this.oneC = (conf.c | 0) === 1;
  22880. }
  22881. inherits(EdwardsCurve, Base);
  22882. module.exports = EdwardsCurve;
  22883. EdwardsCurve.prototype._mulA = function _mulA(num) {
  22884. if (this.mOneA)
  22885. return num.redNeg();
  22886. else
  22887. return this.a.redMul(num);
  22888. };
  22889. EdwardsCurve.prototype._mulC = function _mulC(num) {
  22890. if (this.oneC)
  22891. return num;
  22892. else
  22893. return this.c.redMul(num);
  22894. };
  22895. // Just for compatibility with Short curve
  22896. EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) {
  22897. return this.point(x, y, z, t);
  22898. };
  22899. EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) {
  22900. x = new BN(x, 16);
  22901. if (!x.red)
  22902. x = x.toRed(this.red);
  22903. var x2 = x.redSqr();
  22904. var rhs = this.c2.redSub(this.a.redMul(x2));
  22905. var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2));
  22906. var y2 = rhs.redMul(lhs.redInvm());
  22907. var y = y2.redSqrt();
  22908. if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
  22909. throw new Error('invalid point');
  22910. var isOdd = y.fromRed().isOdd();
  22911. if (odd && !isOdd || !odd && isOdd)
  22912. y = y.redNeg();
  22913. return this.point(x, y);
  22914. };
  22915. EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) {
  22916. y = new BN(y, 16);
  22917. if (!y.red)
  22918. y = y.toRed(this.red);
  22919. // x^2 = (y^2 - c^2) / (c^2 d y^2 - a)
  22920. var y2 = y.redSqr();
  22921. var lhs = y2.redSub(this.c2);
  22922. var rhs = y2.redMul(this.d).redMul(this.c2).redSub(this.a);
  22923. var x2 = lhs.redMul(rhs.redInvm());
  22924. if (x2.cmp(this.zero) === 0) {
  22925. if (odd)
  22926. throw new Error('invalid point');
  22927. else
  22928. return this.point(this.zero, y);
  22929. }
  22930. var x = x2.redSqrt();
  22931. if (x.redSqr().redSub(x2).cmp(this.zero) !== 0)
  22932. throw new Error('invalid point');
  22933. if (x.fromRed().isOdd() !== odd)
  22934. x = x.redNeg();
  22935. return this.point(x, y);
  22936. };
  22937. EdwardsCurve.prototype.validate = function validate(point) {
  22938. if (point.isInfinity())
  22939. return true;
  22940. // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2)
  22941. point.normalize();
  22942. var x2 = point.x.redSqr();
  22943. var y2 = point.y.redSqr();
  22944. var lhs = x2.redMul(this.a).redAdd(y2);
  22945. var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2)));
  22946. return lhs.cmp(rhs) === 0;
  22947. };
  22948. function Point(curve, x, y, z, t) {
  22949. Base.BasePoint.call(this, curve, 'projective');
  22950. if (x === null && y === null && z === null) {
  22951. this.x = this.curve.zero;
  22952. this.y = this.curve.one;
  22953. this.z = this.curve.one;
  22954. this.t = this.curve.zero;
  22955. this.zOne = true;
  22956. } else {
  22957. this.x = new BN(x, 16);
  22958. this.y = new BN(y, 16);
  22959. this.z = z ? new BN(z, 16) : this.curve.one;
  22960. this.t = t && new BN(t, 16);
  22961. if (!this.x.red)
  22962. this.x = this.x.toRed(this.curve.red);
  22963. if (!this.y.red)
  22964. this.y = this.y.toRed(this.curve.red);
  22965. if (!this.z.red)
  22966. this.z = this.z.toRed(this.curve.red);
  22967. if (this.t && !this.t.red)
  22968. this.t = this.t.toRed(this.curve.red);
  22969. this.zOne = this.z === this.curve.one;
  22970. // Use extended coordinates
  22971. if (this.curve.extended && !this.t) {
  22972. this.t = this.x.redMul(this.y);
  22973. if (!this.zOne)
  22974. this.t = this.t.redMul(this.z.redInvm());
  22975. }
  22976. }
  22977. }
  22978. inherits(Point, Base.BasePoint);
  22979. EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
  22980. return Point.fromJSON(this, obj);
  22981. };
  22982. EdwardsCurve.prototype.point = function point(x, y, z, t) {
  22983. return new Point(this, x, y, z, t);
  22984. };
  22985. Point.fromJSON = function fromJSON(curve, obj) {
  22986. return new Point(curve, obj[0], obj[1], obj[2]);
  22987. };
  22988. Point.prototype.inspect = function inspect() {
  22989. if (this.isInfinity())
  22990. return '<EC Point Infinity>';
  22991. return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
  22992. ' y: ' + this.y.fromRed().toString(16, 2) +
  22993. ' z: ' + this.z.fromRed().toString(16, 2) + '>';
  22994. };
  22995. Point.prototype.isInfinity = function isInfinity() {
  22996. // XXX This code assumes that zero is always zero in red
  22997. return this.x.cmpn(0) === 0 &&
  22998. (this.y.cmp(this.z) === 0 ||
  22999. (this.zOne && this.y.cmp(this.curve.c) === 0));
  23000. };
  23001. Point.prototype._extDbl = function _extDbl() {
  23002. // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
  23003. // #doubling-dbl-2008-hwcd
  23004. // 4M + 4S
  23005. // A = X1^2
  23006. var a = this.x.redSqr();
  23007. // B = Y1^2
  23008. var b = this.y.redSqr();
  23009. // C = 2 * Z1^2
  23010. var c = this.z.redSqr();
  23011. c = c.redIAdd(c);
  23012. // D = a * A
  23013. var d = this.curve._mulA(a);
  23014. // E = (X1 + Y1)^2 - A - B
  23015. var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b);
  23016. // G = D + B
  23017. var g = d.redAdd(b);
  23018. // F = G - C
  23019. var f = g.redSub(c);
  23020. // H = D - B
  23021. var h = d.redSub(b);
  23022. // X3 = E * F
  23023. var nx = e.redMul(f);
  23024. // Y3 = G * H
  23025. var ny = g.redMul(h);
  23026. // T3 = E * H
  23027. var nt = e.redMul(h);
  23028. // Z3 = F * G
  23029. var nz = f.redMul(g);
  23030. return this.curve.point(nx, ny, nz, nt);
  23031. };
  23032. Point.prototype._projDbl = function _projDbl() {
  23033. // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
  23034. // #doubling-dbl-2008-bbjlp
  23035. // #doubling-dbl-2007-bl
  23036. // and others
  23037. // Generally 3M + 4S or 2M + 4S
  23038. // B = (X1 + Y1)^2
  23039. var b = this.x.redAdd(this.y).redSqr();
  23040. // C = X1^2
  23041. var c = this.x.redSqr();
  23042. // D = Y1^2
  23043. var d = this.y.redSqr();
  23044. var nx;
  23045. var ny;
  23046. var nz;
  23047. var e;
  23048. var h;
  23049. var j;
  23050. if (this.curve.twisted) {
  23051. // E = a * C
  23052. e = this.curve._mulA(c);
  23053. // F = E + D
  23054. var f = e.redAdd(d);
  23055. if (this.zOne) {
  23056. // X3 = (B - C - D) * (F - 2)
  23057. nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two));
  23058. // Y3 = F * (E - D)
  23059. ny = f.redMul(e.redSub(d));
  23060. // Z3 = F^2 - 2 * F
  23061. nz = f.redSqr().redSub(f).redSub(f);
  23062. } else {
  23063. // H = Z1^2
  23064. h = this.z.redSqr();
  23065. // J = F - 2 * H
  23066. j = f.redSub(h).redISub(h);
  23067. // X3 = (B-C-D)*J
  23068. nx = b.redSub(c).redISub(d).redMul(j);
  23069. // Y3 = F * (E - D)
  23070. ny = f.redMul(e.redSub(d));
  23071. // Z3 = F * J
  23072. nz = f.redMul(j);
  23073. }
  23074. } else {
  23075. // E = C + D
  23076. e = c.redAdd(d);
  23077. // H = (c * Z1)^2
  23078. h = this.curve._mulC(this.z).redSqr();
  23079. // J = E - 2 * H
  23080. j = e.redSub(h).redSub(h);
  23081. // X3 = c * (B - E) * J
  23082. nx = this.curve._mulC(b.redISub(e)).redMul(j);
  23083. // Y3 = c * E * (C - D)
  23084. ny = this.curve._mulC(e).redMul(c.redISub(d));
  23085. // Z3 = E * J
  23086. nz = e.redMul(j);
  23087. }
  23088. return this.curve.point(nx, ny, nz);
  23089. };
  23090. Point.prototype.dbl = function dbl() {
  23091. if (this.isInfinity())
  23092. return this;
  23093. // Double in extended coordinates
  23094. if (this.curve.extended)
  23095. return this._extDbl();
  23096. else
  23097. return this._projDbl();
  23098. };
  23099. Point.prototype._extAdd = function _extAdd(p) {
  23100. // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
  23101. // #addition-add-2008-hwcd-3
  23102. // 8M
  23103. // A = (Y1 - X1) * (Y2 - X2)
  23104. var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x));
  23105. // B = (Y1 + X1) * (Y2 + X2)
  23106. var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x));
  23107. // C = T1 * k * T2
  23108. var c = this.t.redMul(this.curve.dd).redMul(p.t);
  23109. // D = Z1 * 2 * Z2
  23110. var d = this.z.redMul(p.z.redAdd(p.z));
  23111. // E = B - A
  23112. var e = b.redSub(a);
  23113. // F = D - C
  23114. var f = d.redSub(c);
  23115. // G = D + C
  23116. var g = d.redAdd(c);
  23117. // H = B + A
  23118. var h = b.redAdd(a);
  23119. // X3 = E * F
  23120. var nx = e.redMul(f);
  23121. // Y3 = G * H
  23122. var ny = g.redMul(h);
  23123. // T3 = E * H
  23124. var nt = e.redMul(h);
  23125. // Z3 = F * G
  23126. var nz = f.redMul(g);
  23127. return this.curve.point(nx, ny, nz, nt);
  23128. };
  23129. Point.prototype._projAdd = function _projAdd(p) {
  23130. // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
  23131. // #addition-add-2008-bbjlp
  23132. // #addition-add-2007-bl
  23133. // 10M + 1S
  23134. // A = Z1 * Z2
  23135. var a = this.z.redMul(p.z);
  23136. // B = A^2
  23137. var b = a.redSqr();
  23138. // C = X1 * X2
  23139. var c = this.x.redMul(p.x);
  23140. // D = Y1 * Y2
  23141. var d = this.y.redMul(p.y);
  23142. // E = d * C * D
  23143. var e = this.curve.d.redMul(c).redMul(d);
  23144. // F = B - E
  23145. var f = b.redSub(e);
  23146. // G = B + E
  23147. var g = b.redAdd(e);
  23148. // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D)
  23149. var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d);
  23150. var nx = a.redMul(f).redMul(tmp);
  23151. var ny;
  23152. var nz;
  23153. if (this.curve.twisted) {
  23154. // Y3 = A * G * (D - a * C)
  23155. ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c)));
  23156. // Z3 = F * G
  23157. nz = f.redMul(g);
  23158. } else {
  23159. // Y3 = A * G * (D - C)
  23160. ny = a.redMul(g).redMul(d.redSub(c));
  23161. // Z3 = c * F * G
  23162. nz = this.curve._mulC(f).redMul(g);
  23163. }
  23164. return this.curve.point(nx, ny, nz);
  23165. };
  23166. Point.prototype.add = function add(p) {
  23167. if (this.isInfinity())
  23168. return p;
  23169. if (p.isInfinity())
  23170. return this;
  23171. if (this.curve.extended)
  23172. return this._extAdd(p);
  23173. else
  23174. return this._projAdd(p);
  23175. };
  23176. Point.prototype.mul = function mul(k) {
  23177. if (this._hasDoubles(k))
  23178. return this.curve._fixedNafMul(this, k);
  23179. else
  23180. return this.curve._wnafMul(this, k);
  23181. };
  23182. Point.prototype.mulAdd = function mulAdd(k1, p, k2) {
  23183. return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false);
  23184. };
  23185. Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) {
  23186. return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true);
  23187. };
  23188. Point.prototype.normalize = function normalize() {
  23189. if (this.zOne)
  23190. return this;
  23191. // Normalize coordinates
  23192. var zi = this.z.redInvm();
  23193. this.x = this.x.redMul(zi);
  23194. this.y = this.y.redMul(zi);
  23195. if (this.t)
  23196. this.t = this.t.redMul(zi);
  23197. this.z = this.curve.one;
  23198. this.zOne = true;
  23199. return this;
  23200. };
  23201. Point.prototype.neg = function neg() {
  23202. return this.curve.point(this.x.redNeg(),
  23203. this.y,
  23204. this.z,
  23205. this.t && this.t.redNeg());
  23206. };
  23207. Point.prototype.getX = function getX() {
  23208. this.normalize();
  23209. return this.x.fromRed();
  23210. };
  23211. Point.prototype.getY = function getY() {
  23212. this.normalize();
  23213. return this.y.fromRed();
  23214. };
  23215. Point.prototype.eq = function eq(other) {
  23216. return this === other ||
  23217. this.getX().cmp(other.getX()) === 0 &&
  23218. this.getY().cmp(other.getY()) === 0;
  23219. };
  23220. Point.prototype.eqXToP = function eqXToP(x) {
  23221. var rx = x.toRed(this.curve.red).redMul(this.z);
  23222. if (this.x.cmp(rx) === 0)
  23223. return true;
  23224. var xc = x.clone();
  23225. var t = this.curve.redN.redMul(this.z);
  23226. for (;;) {
  23227. xc.iadd(this.curve.n);
  23228. if (xc.cmp(this.curve.p) >= 0)
  23229. return false;
  23230. rx.redIAdd(t);
  23231. if (this.x.cmp(rx) === 0)
  23232. return true;
  23233. }
  23234. };
  23235. // Compatibility with BaseCurve
  23236. Point.prototype.toP = Point.prototype.normalize;
  23237. Point.prototype.mixedAdd = Point.prototype.add;
  23238. /***/ }),
  23239. /***/ "../../node_modules/elliptic/lib/elliptic/curve/index.js":
  23240. /*!***************************************************************!*\
  23241. !*** ../../node_modules/elliptic/lib/elliptic/curve/index.js ***!
  23242. \***************************************************************/
  23243. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  23244. "use strict";
  23245. var curve = exports;
  23246. curve.base = __webpack_require__(/*! ./base */ "../../node_modules/elliptic/lib/elliptic/curve/base.js");
  23247. curve.short = __webpack_require__(/*! ./short */ "../../node_modules/elliptic/lib/elliptic/curve/short.js");
  23248. curve.mont = __webpack_require__(/*! ./mont */ "../../node_modules/elliptic/lib/elliptic/curve/mont.js");
  23249. curve.edwards = __webpack_require__(/*! ./edwards */ "../../node_modules/elliptic/lib/elliptic/curve/edwards.js");
  23250. /***/ }),
  23251. /***/ "../../node_modules/elliptic/lib/elliptic/curve/mont.js":
  23252. /*!**************************************************************!*\
  23253. !*** ../../node_modules/elliptic/lib/elliptic/curve/mont.js ***!
  23254. \**************************************************************/
  23255. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  23256. "use strict";
  23257. var BN = __webpack_require__(/*! bn.js */ "../../node_modules/diffie-hellman/node_modules/bn.js/lib/bn.js");
  23258. var inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js");
  23259. var Base = __webpack_require__(/*! ./base */ "../../node_modules/elliptic/lib/elliptic/curve/base.js");
  23260. var utils = __webpack_require__(/*! ../utils */ "../../node_modules/elliptic/lib/elliptic/utils.js");
  23261. function MontCurve(conf) {
  23262. Base.call(this, 'mont', conf);
  23263. this.a = new BN(conf.a, 16).toRed(this.red);
  23264. this.b = new BN(conf.b, 16).toRed(this.red);
  23265. this.i4 = new BN(4).toRed(this.red).redInvm();
  23266. this.two = new BN(2).toRed(this.red);
  23267. this.a24 = this.i4.redMul(this.a.redAdd(this.two));
  23268. }
  23269. inherits(MontCurve, Base);
  23270. module.exports = MontCurve;
  23271. MontCurve.prototype.validate = function validate(point) {
  23272. var x = point.normalize().x;
  23273. var x2 = x.redSqr();
  23274. var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x);
  23275. var y = rhs.redSqrt();
  23276. return y.redSqr().cmp(rhs) === 0;
  23277. };
  23278. function Point(curve, x, z) {
  23279. Base.BasePoint.call(this, curve, 'projective');
  23280. if (x === null && z === null) {
  23281. this.x = this.curve.one;
  23282. this.z = this.curve.zero;
  23283. } else {
  23284. this.x = new BN(x, 16);
  23285. this.z = new BN(z, 16);
  23286. if (!this.x.red)
  23287. this.x = this.x.toRed(this.curve.red);
  23288. if (!this.z.red)
  23289. this.z = this.z.toRed(this.curve.red);
  23290. }
  23291. }
  23292. inherits(Point, Base.BasePoint);
  23293. MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
  23294. return this.point(utils.toArray(bytes, enc), 1);
  23295. };
  23296. MontCurve.prototype.point = function point(x, z) {
  23297. return new Point(this, x, z);
  23298. };
  23299. MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
  23300. return Point.fromJSON(this, obj);
  23301. };
  23302. Point.prototype.precompute = function precompute() {
  23303. // No-op
  23304. };
  23305. Point.prototype._encode = function _encode() {
  23306. return this.getX().toArray('be', this.curve.p.byteLength());
  23307. };
  23308. Point.fromJSON = function fromJSON(curve, obj) {
  23309. return new Point(curve, obj[0], obj[1] || curve.one);
  23310. };
  23311. Point.prototype.inspect = function inspect() {
  23312. if (this.isInfinity())
  23313. return '<EC Point Infinity>';
  23314. return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
  23315. ' z: ' + this.z.fromRed().toString(16, 2) + '>';
  23316. };
  23317. Point.prototype.isInfinity = function isInfinity() {
  23318. // XXX This code assumes that zero is always zero in red
  23319. return this.z.cmpn(0) === 0;
  23320. };
  23321. Point.prototype.dbl = function dbl() {
  23322. // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3
  23323. // 2M + 2S + 4A
  23324. // A = X1 + Z1
  23325. var a = this.x.redAdd(this.z);
  23326. // AA = A^2
  23327. var aa = a.redSqr();
  23328. // B = X1 - Z1
  23329. var b = this.x.redSub(this.z);
  23330. // BB = B^2
  23331. var bb = b.redSqr();
  23332. // C = AA - BB
  23333. var c = aa.redSub(bb);
  23334. // X3 = AA * BB
  23335. var nx = aa.redMul(bb);
  23336. // Z3 = C * (BB + A24 * C)
  23337. var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c)));
  23338. return this.curve.point(nx, nz);
  23339. };
  23340. Point.prototype.add = function add() {
  23341. throw new Error('Not supported on Montgomery curve');
  23342. };
  23343. Point.prototype.diffAdd = function diffAdd(p, diff) {
  23344. // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3
  23345. // 4M + 2S + 6A
  23346. // A = X2 + Z2
  23347. var a = this.x.redAdd(this.z);
  23348. // B = X2 - Z2
  23349. var b = this.x.redSub(this.z);
  23350. // C = X3 + Z3
  23351. var c = p.x.redAdd(p.z);
  23352. // D = X3 - Z3
  23353. var d = p.x.redSub(p.z);
  23354. // DA = D * A
  23355. var da = d.redMul(a);
  23356. // CB = C * B
  23357. var cb = c.redMul(b);
  23358. // X5 = Z1 * (DA + CB)^2
  23359. var nx = diff.z.redMul(da.redAdd(cb).redSqr());
  23360. // Z5 = X1 * (DA - CB)^2
  23361. var nz = diff.x.redMul(da.redISub(cb).redSqr());
  23362. return this.curve.point(nx, nz);
  23363. };
  23364. Point.prototype.mul = function mul(k) {
  23365. var t = k.clone();
  23366. var a = this; // (N / 2) * Q + Q
  23367. var b = this.curve.point(null, null); // (N / 2) * Q
  23368. var c = this; // Q
  23369. for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1))
  23370. bits.push(t.andln(1));
  23371. for (var i = bits.length - 1; i >= 0; i--) {
  23372. if (bits[i] === 0) {
  23373. // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q
  23374. a = a.diffAdd(b, c);
  23375. // N * Q = 2 * ((N / 2) * Q + Q))
  23376. b = b.dbl();
  23377. } else {
  23378. // N * Q = ((N / 2) * Q + Q) + ((N / 2) * Q)
  23379. b = a.diffAdd(b, c);
  23380. // N * Q + Q = 2 * ((N / 2) * Q + Q)
  23381. a = a.dbl();
  23382. }
  23383. }
  23384. return b;
  23385. };
  23386. Point.prototype.mulAdd = function mulAdd() {
  23387. throw new Error('Not supported on Montgomery curve');
  23388. };
  23389. Point.prototype.jumlAdd = function jumlAdd() {
  23390. throw new Error('Not supported on Montgomery curve');
  23391. };
  23392. Point.prototype.eq = function eq(other) {
  23393. return this.getX().cmp(other.getX()) === 0;
  23394. };
  23395. Point.prototype.normalize = function normalize() {
  23396. this.x = this.x.redMul(this.z.redInvm());
  23397. this.z = this.curve.one;
  23398. return this;
  23399. };
  23400. Point.prototype.getX = function getX() {
  23401. // Normalize coordinates
  23402. this.normalize();
  23403. return this.x.fromRed();
  23404. };
  23405. /***/ }),
  23406. /***/ "../../node_modules/elliptic/lib/elliptic/curve/short.js":
  23407. /*!***************************************************************!*\
  23408. !*** ../../node_modules/elliptic/lib/elliptic/curve/short.js ***!
  23409. \***************************************************************/
  23410. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  23411. "use strict";
  23412. var utils = __webpack_require__(/*! ../utils */ "../../node_modules/elliptic/lib/elliptic/utils.js");
  23413. var BN = __webpack_require__(/*! bn.js */ "../../node_modules/diffie-hellman/node_modules/bn.js/lib/bn.js");
  23414. var inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js");
  23415. var Base = __webpack_require__(/*! ./base */ "../../node_modules/elliptic/lib/elliptic/curve/base.js");
  23416. var assert = utils.assert;
  23417. function ShortCurve(conf) {
  23418. Base.call(this, 'short', conf);
  23419. this.a = new BN(conf.a, 16).toRed(this.red);
  23420. this.b = new BN(conf.b, 16).toRed(this.red);
  23421. this.tinv = this.two.redInvm();
  23422. this.zeroA = this.a.fromRed().cmpn(0) === 0;
  23423. this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0;
  23424. // If the curve is endomorphic, precalculate beta and lambda
  23425. this.endo = this._getEndomorphism(conf);
  23426. this._endoWnafT1 = new Array(4);
  23427. this._endoWnafT2 = new Array(4);
  23428. }
  23429. inherits(ShortCurve, Base);
  23430. module.exports = ShortCurve;
  23431. ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) {
  23432. // No efficient endomorphism
  23433. if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)
  23434. return;
  23435. // Compute beta and lambda, that lambda * P = (beta * Px; Py)
  23436. var beta;
  23437. var lambda;
  23438. if (conf.beta) {
  23439. beta = new BN(conf.beta, 16).toRed(this.red);
  23440. } else {
  23441. var betas = this._getEndoRoots(this.p);
  23442. // Choose the smallest beta
  23443. beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1];
  23444. beta = beta.toRed(this.red);
  23445. }
  23446. if (conf.lambda) {
  23447. lambda = new BN(conf.lambda, 16);
  23448. } else {
  23449. // Choose the lambda that is matching selected beta
  23450. var lambdas = this._getEndoRoots(this.n);
  23451. if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) {
  23452. lambda = lambdas[0];
  23453. } else {
  23454. lambda = lambdas[1];
  23455. assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0);
  23456. }
  23457. }
  23458. // Get basis vectors, used for balanced length-two representation
  23459. var basis;
  23460. if (conf.basis) {
  23461. basis = conf.basis.map(function(vec) {
  23462. return {
  23463. a: new BN(vec.a, 16),
  23464. b: new BN(vec.b, 16),
  23465. };
  23466. });
  23467. } else {
  23468. basis = this._getEndoBasis(lambda);
  23469. }
  23470. return {
  23471. beta: beta,
  23472. lambda: lambda,
  23473. basis: basis,
  23474. };
  23475. };
  23476. ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) {
  23477. // Find roots of for x^2 + x + 1 in F
  23478. // Root = (-1 +- Sqrt(-3)) / 2
  23479. //
  23480. var red = num === this.p ? this.red : BN.mont(num);
  23481. var tinv = new BN(2).toRed(red).redInvm();
  23482. var ntinv = tinv.redNeg();
  23483. var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv);
  23484. var l1 = ntinv.redAdd(s).fromRed();
  23485. var l2 = ntinv.redSub(s).fromRed();
  23486. return [ l1, l2 ];
  23487. };
  23488. ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) {
  23489. // aprxSqrt >= sqrt(this.n)
  23490. var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2));
  23491. // 3.74
  23492. // Run EGCD, until r(L + 1) < aprxSqrt
  23493. var u = lambda;
  23494. var v = this.n.clone();
  23495. var x1 = new BN(1);
  23496. var y1 = new BN(0);
  23497. var x2 = new BN(0);
  23498. var y2 = new BN(1);
  23499. // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n)
  23500. var a0;
  23501. var b0;
  23502. // First vector
  23503. var a1;
  23504. var b1;
  23505. // Second vector
  23506. var a2;
  23507. var b2;
  23508. var prevR;
  23509. var i = 0;
  23510. var r;
  23511. var x;
  23512. while (u.cmpn(0) !== 0) {
  23513. var q = v.div(u);
  23514. r = v.sub(q.mul(u));
  23515. x = x2.sub(q.mul(x1));
  23516. var y = y2.sub(q.mul(y1));
  23517. if (!a1 && r.cmp(aprxSqrt) < 0) {
  23518. a0 = prevR.neg();
  23519. b0 = x1;
  23520. a1 = r.neg();
  23521. b1 = x;
  23522. } else if (a1 && ++i === 2) {
  23523. break;
  23524. }
  23525. prevR = r;
  23526. v = u;
  23527. u = r;
  23528. x2 = x1;
  23529. x1 = x;
  23530. y2 = y1;
  23531. y1 = y;
  23532. }
  23533. a2 = r.neg();
  23534. b2 = x;
  23535. var len1 = a1.sqr().add(b1.sqr());
  23536. var len2 = a2.sqr().add(b2.sqr());
  23537. if (len2.cmp(len1) >= 0) {
  23538. a2 = a0;
  23539. b2 = b0;
  23540. }
  23541. // Normalize signs
  23542. if (a1.negative) {
  23543. a1 = a1.neg();
  23544. b1 = b1.neg();
  23545. }
  23546. if (a2.negative) {
  23547. a2 = a2.neg();
  23548. b2 = b2.neg();
  23549. }
  23550. return [
  23551. { a: a1, b: b1 },
  23552. { a: a2, b: b2 },
  23553. ];
  23554. };
  23555. ShortCurve.prototype._endoSplit = function _endoSplit(k) {
  23556. var basis = this.endo.basis;
  23557. var v1 = basis[0];
  23558. var v2 = basis[1];
  23559. var c1 = v2.b.mul(k).divRound(this.n);
  23560. var c2 = v1.b.neg().mul(k).divRound(this.n);
  23561. var p1 = c1.mul(v1.a);
  23562. var p2 = c2.mul(v2.a);
  23563. var q1 = c1.mul(v1.b);
  23564. var q2 = c2.mul(v2.b);
  23565. // Calculate answer
  23566. var k1 = k.sub(p1).sub(p2);
  23567. var k2 = q1.add(q2).neg();
  23568. return { k1: k1, k2: k2 };
  23569. };
  23570. ShortCurve.prototype.pointFromX = function pointFromX(x, odd) {
  23571. x = new BN(x, 16);
  23572. if (!x.red)
  23573. x = x.toRed(this.red);
  23574. var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b);
  23575. var y = y2.redSqrt();
  23576. if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
  23577. throw new Error('invalid point');
  23578. // XXX Is there any way to tell if the number is odd without converting it
  23579. // to non-red form?
  23580. var isOdd = y.fromRed().isOdd();
  23581. if (odd && !isOdd || !odd && isOdd)
  23582. y = y.redNeg();
  23583. return this.point(x, y);
  23584. };
  23585. ShortCurve.prototype.validate = function validate(point) {
  23586. if (point.inf)
  23587. return true;
  23588. var x = point.x;
  23589. var y = point.y;
  23590. var ax = this.a.redMul(x);
  23591. var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b);
  23592. return y.redSqr().redISub(rhs).cmpn(0) === 0;
  23593. };
  23594. ShortCurve.prototype._endoWnafMulAdd =
  23595. function _endoWnafMulAdd(points, coeffs, jacobianResult) {
  23596. var npoints = this._endoWnafT1;
  23597. var ncoeffs = this._endoWnafT2;
  23598. for (var i = 0; i < points.length; i++) {
  23599. var split = this._endoSplit(coeffs[i]);
  23600. var p = points[i];
  23601. var beta = p._getBeta();
  23602. if (split.k1.negative) {
  23603. split.k1.ineg();
  23604. p = p.neg(true);
  23605. }
  23606. if (split.k2.negative) {
  23607. split.k2.ineg();
  23608. beta = beta.neg(true);
  23609. }
  23610. npoints[i * 2] = p;
  23611. npoints[i * 2 + 1] = beta;
  23612. ncoeffs[i * 2] = split.k1;
  23613. ncoeffs[i * 2 + 1] = split.k2;
  23614. }
  23615. var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult);
  23616. // Clean-up references to points and coefficients
  23617. for (var j = 0; j < i * 2; j++) {
  23618. npoints[j] = null;
  23619. ncoeffs[j] = null;
  23620. }
  23621. return res;
  23622. };
  23623. function Point(curve, x, y, isRed) {
  23624. Base.BasePoint.call(this, curve, 'affine');
  23625. if (x === null && y === null) {
  23626. this.x = null;
  23627. this.y = null;
  23628. this.inf = true;
  23629. } else {
  23630. this.x = new BN(x, 16);
  23631. this.y = new BN(y, 16);
  23632. // Force redgomery representation when loading from JSON
  23633. if (isRed) {
  23634. this.x.forceRed(this.curve.red);
  23635. this.y.forceRed(this.curve.red);
  23636. }
  23637. if (!this.x.red)
  23638. this.x = this.x.toRed(this.curve.red);
  23639. if (!this.y.red)
  23640. this.y = this.y.toRed(this.curve.red);
  23641. this.inf = false;
  23642. }
  23643. }
  23644. inherits(Point, Base.BasePoint);
  23645. ShortCurve.prototype.point = function point(x, y, isRed) {
  23646. return new Point(this, x, y, isRed);
  23647. };
  23648. ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) {
  23649. return Point.fromJSON(this, obj, red);
  23650. };
  23651. Point.prototype._getBeta = function _getBeta() {
  23652. if (!this.curve.endo)
  23653. return;
  23654. var pre = this.precomputed;
  23655. if (pre && pre.beta)
  23656. return pre.beta;
  23657. var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y);
  23658. if (pre) {
  23659. var curve = this.curve;
  23660. var endoMul = function(p) {
  23661. return curve.point(p.x.redMul(curve.endo.beta), p.y);
  23662. };
  23663. pre.beta = beta;
  23664. beta.precomputed = {
  23665. beta: null,
  23666. naf: pre.naf && {
  23667. wnd: pre.naf.wnd,
  23668. points: pre.naf.points.map(endoMul),
  23669. },
  23670. doubles: pre.doubles && {
  23671. step: pre.doubles.step,
  23672. points: pre.doubles.points.map(endoMul),
  23673. },
  23674. };
  23675. }
  23676. return beta;
  23677. };
  23678. Point.prototype.toJSON = function toJSON() {
  23679. if (!this.precomputed)
  23680. return [ this.x, this.y ];
  23681. return [ this.x, this.y, this.precomputed && {
  23682. doubles: this.precomputed.doubles && {
  23683. step: this.precomputed.doubles.step,
  23684. points: this.precomputed.doubles.points.slice(1),
  23685. },
  23686. naf: this.precomputed.naf && {
  23687. wnd: this.precomputed.naf.wnd,
  23688. points: this.precomputed.naf.points.slice(1),
  23689. },
  23690. } ];
  23691. };
  23692. Point.fromJSON = function fromJSON(curve, obj, red) {
  23693. if (typeof obj === 'string')
  23694. obj = JSON.parse(obj);
  23695. var res = curve.point(obj[0], obj[1], red);
  23696. if (!obj[2])
  23697. return res;
  23698. function obj2point(obj) {
  23699. return curve.point(obj[0], obj[1], red);
  23700. }
  23701. var pre = obj[2];
  23702. res.precomputed = {
  23703. beta: null,
  23704. doubles: pre.doubles && {
  23705. step: pre.doubles.step,
  23706. points: [ res ].concat(pre.doubles.points.map(obj2point)),
  23707. },
  23708. naf: pre.naf && {
  23709. wnd: pre.naf.wnd,
  23710. points: [ res ].concat(pre.naf.points.map(obj2point)),
  23711. },
  23712. };
  23713. return res;
  23714. };
  23715. Point.prototype.inspect = function inspect() {
  23716. if (this.isInfinity())
  23717. return '<EC Point Infinity>';
  23718. return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
  23719. ' y: ' + this.y.fromRed().toString(16, 2) + '>';
  23720. };
  23721. Point.prototype.isInfinity = function isInfinity() {
  23722. return this.inf;
  23723. };
  23724. Point.prototype.add = function add(p) {
  23725. // O + P = P
  23726. if (this.inf)
  23727. return p;
  23728. // P + O = P
  23729. if (p.inf)
  23730. return this;
  23731. // P + P = 2P
  23732. if (this.eq(p))
  23733. return this.dbl();
  23734. // P + (-P) = O
  23735. if (this.neg().eq(p))
  23736. return this.curve.point(null, null);
  23737. // P + Q = O
  23738. if (this.x.cmp(p.x) === 0)
  23739. return this.curve.point(null, null);
  23740. var c = this.y.redSub(p.y);
  23741. if (c.cmpn(0) !== 0)
  23742. c = c.redMul(this.x.redSub(p.x).redInvm());
  23743. var nx = c.redSqr().redISub(this.x).redISub(p.x);
  23744. var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
  23745. return this.curve.point(nx, ny);
  23746. };
  23747. Point.prototype.dbl = function dbl() {
  23748. if (this.inf)
  23749. return this;
  23750. // 2P = O
  23751. var ys1 = this.y.redAdd(this.y);
  23752. if (ys1.cmpn(0) === 0)
  23753. return this.curve.point(null, null);
  23754. var a = this.curve.a;
  23755. var x2 = this.x.redSqr();
  23756. var dyinv = ys1.redInvm();
  23757. var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv);
  23758. var nx = c.redSqr().redISub(this.x.redAdd(this.x));
  23759. var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
  23760. return this.curve.point(nx, ny);
  23761. };
  23762. Point.prototype.getX = function getX() {
  23763. return this.x.fromRed();
  23764. };
  23765. Point.prototype.getY = function getY() {
  23766. return this.y.fromRed();
  23767. };
  23768. Point.prototype.mul = function mul(k) {
  23769. k = new BN(k, 16);
  23770. if (this.isInfinity())
  23771. return this;
  23772. else if (this._hasDoubles(k))
  23773. return this.curve._fixedNafMul(this, k);
  23774. else if (this.curve.endo)
  23775. return this.curve._endoWnafMulAdd([ this ], [ k ]);
  23776. else
  23777. return this.curve._wnafMul(this, k);
  23778. };
  23779. Point.prototype.mulAdd = function mulAdd(k1, p2, k2) {
  23780. var points = [ this, p2 ];
  23781. var coeffs = [ k1, k2 ];
  23782. if (this.curve.endo)
  23783. return this.curve._endoWnafMulAdd(points, coeffs);
  23784. else
  23785. return this.curve._wnafMulAdd(1, points, coeffs, 2);
  23786. };
  23787. Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) {
  23788. var points = [ this, p2 ];
  23789. var coeffs = [ k1, k2 ];
  23790. if (this.curve.endo)
  23791. return this.curve._endoWnafMulAdd(points, coeffs, true);
  23792. else
  23793. return this.curve._wnafMulAdd(1, points, coeffs, 2, true);
  23794. };
  23795. Point.prototype.eq = function eq(p) {
  23796. return this === p ||
  23797. this.inf === p.inf &&
  23798. (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0);
  23799. };
  23800. Point.prototype.neg = function neg(_precompute) {
  23801. if (this.inf)
  23802. return this;
  23803. var res = this.curve.point(this.x, this.y.redNeg());
  23804. if (_precompute && this.precomputed) {
  23805. var pre = this.precomputed;
  23806. var negate = function(p) {
  23807. return p.neg();
  23808. };
  23809. res.precomputed = {
  23810. naf: pre.naf && {
  23811. wnd: pre.naf.wnd,
  23812. points: pre.naf.points.map(negate),
  23813. },
  23814. doubles: pre.doubles && {
  23815. step: pre.doubles.step,
  23816. points: pre.doubles.points.map(negate),
  23817. },
  23818. };
  23819. }
  23820. return res;
  23821. };
  23822. Point.prototype.toJ = function toJ() {
  23823. if (this.inf)
  23824. return this.curve.jpoint(null, null, null);
  23825. var res = this.curve.jpoint(this.x, this.y, this.curve.one);
  23826. return res;
  23827. };
  23828. function JPoint(curve, x, y, z) {
  23829. Base.BasePoint.call(this, curve, 'jacobian');
  23830. if (x === null && y === null && z === null) {
  23831. this.x = this.curve.one;
  23832. this.y = this.curve.one;
  23833. this.z = new BN(0);
  23834. } else {
  23835. this.x = new BN(x, 16);
  23836. this.y = new BN(y, 16);
  23837. this.z = new BN(z, 16);
  23838. }
  23839. if (!this.x.red)
  23840. this.x = this.x.toRed(this.curve.red);
  23841. if (!this.y.red)
  23842. this.y = this.y.toRed(this.curve.red);
  23843. if (!this.z.red)
  23844. this.z = this.z.toRed(this.curve.red);
  23845. this.zOne = this.z === this.curve.one;
  23846. }
  23847. inherits(JPoint, Base.BasePoint);
  23848. ShortCurve.prototype.jpoint = function jpoint(x, y, z) {
  23849. return new JPoint(this, x, y, z);
  23850. };
  23851. JPoint.prototype.toP = function toP() {
  23852. if (this.isInfinity())
  23853. return this.curve.point(null, null);
  23854. var zinv = this.z.redInvm();
  23855. var zinv2 = zinv.redSqr();
  23856. var ax = this.x.redMul(zinv2);
  23857. var ay = this.y.redMul(zinv2).redMul(zinv);
  23858. return this.curve.point(ax, ay);
  23859. };
  23860. JPoint.prototype.neg = function neg() {
  23861. return this.curve.jpoint(this.x, this.y.redNeg(), this.z);
  23862. };
  23863. JPoint.prototype.add = function add(p) {
  23864. // O + P = P
  23865. if (this.isInfinity())
  23866. return p;
  23867. // P + O = P
  23868. if (p.isInfinity())
  23869. return this;
  23870. // 12M + 4S + 7A
  23871. var pz2 = p.z.redSqr();
  23872. var z2 = this.z.redSqr();
  23873. var u1 = this.x.redMul(pz2);
  23874. var u2 = p.x.redMul(z2);
  23875. var s1 = this.y.redMul(pz2.redMul(p.z));
  23876. var s2 = p.y.redMul(z2.redMul(this.z));
  23877. var h = u1.redSub(u2);
  23878. var r = s1.redSub(s2);
  23879. if (h.cmpn(0) === 0) {
  23880. if (r.cmpn(0) !== 0)
  23881. return this.curve.jpoint(null, null, null);
  23882. else
  23883. return this.dbl();
  23884. }
  23885. var h2 = h.redSqr();
  23886. var h3 = h2.redMul(h);
  23887. var v = u1.redMul(h2);
  23888. var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
  23889. var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
  23890. var nz = this.z.redMul(p.z).redMul(h);
  23891. return this.curve.jpoint(nx, ny, nz);
  23892. };
  23893. JPoint.prototype.mixedAdd = function mixedAdd(p) {
  23894. // O + P = P
  23895. if (this.isInfinity())
  23896. return p.toJ();
  23897. // P + O = P
  23898. if (p.isInfinity())
  23899. return this;
  23900. // 8M + 3S + 7A
  23901. var z2 = this.z.redSqr();
  23902. var u1 = this.x;
  23903. var u2 = p.x.redMul(z2);
  23904. var s1 = this.y;
  23905. var s2 = p.y.redMul(z2).redMul(this.z);
  23906. var h = u1.redSub(u2);
  23907. var r = s1.redSub(s2);
  23908. if (h.cmpn(0) === 0) {
  23909. if (r.cmpn(0) !== 0)
  23910. return this.curve.jpoint(null, null, null);
  23911. else
  23912. return this.dbl();
  23913. }
  23914. var h2 = h.redSqr();
  23915. var h3 = h2.redMul(h);
  23916. var v = u1.redMul(h2);
  23917. var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
  23918. var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
  23919. var nz = this.z.redMul(h);
  23920. return this.curve.jpoint(nx, ny, nz);
  23921. };
  23922. JPoint.prototype.dblp = function dblp(pow) {
  23923. if (pow === 0)
  23924. return this;
  23925. if (this.isInfinity())
  23926. return this;
  23927. if (!pow)
  23928. return this.dbl();
  23929. var i;
  23930. if (this.curve.zeroA || this.curve.threeA) {
  23931. var r = this;
  23932. for (i = 0; i < pow; i++)
  23933. r = r.dbl();
  23934. return r;
  23935. }
  23936. // 1M + 2S + 1A + N * (4S + 5M + 8A)
  23937. // N = 1 => 6M + 6S + 9A
  23938. var a = this.curve.a;
  23939. var tinv = this.curve.tinv;
  23940. var jx = this.x;
  23941. var jy = this.y;
  23942. var jz = this.z;
  23943. var jz4 = jz.redSqr().redSqr();
  23944. // Reuse results
  23945. var jyd = jy.redAdd(jy);
  23946. for (i = 0; i < pow; i++) {
  23947. var jx2 = jx.redSqr();
  23948. var jyd2 = jyd.redSqr();
  23949. var jyd4 = jyd2.redSqr();
  23950. var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
  23951. var t1 = jx.redMul(jyd2);
  23952. var nx = c.redSqr().redISub(t1.redAdd(t1));
  23953. var t2 = t1.redISub(nx);
  23954. var dny = c.redMul(t2);
  23955. dny = dny.redIAdd(dny).redISub(jyd4);
  23956. var nz = jyd.redMul(jz);
  23957. if (i + 1 < pow)
  23958. jz4 = jz4.redMul(jyd4);
  23959. jx = nx;
  23960. jz = nz;
  23961. jyd = dny;
  23962. }
  23963. return this.curve.jpoint(jx, jyd.redMul(tinv), jz);
  23964. };
  23965. JPoint.prototype.dbl = function dbl() {
  23966. if (this.isInfinity())
  23967. return this;
  23968. if (this.curve.zeroA)
  23969. return this._zeroDbl();
  23970. else if (this.curve.threeA)
  23971. return this._threeDbl();
  23972. else
  23973. return this._dbl();
  23974. };
  23975. JPoint.prototype._zeroDbl = function _zeroDbl() {
  23976. var nx;
  23977. var ny;
  23978. var nz;
  23979. // Z = 1
  23980. if (this.zOne) {
  23981. // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
  23982. // #doubling-mdbl-2007-bl
  23983. // 1M + 5S + 14A
  23984. // XX = X1^2
  23985. var xx = this.x.redSqr();
  23986. // YY = Y1^2
  23987. var yy = this.y.redSqr();
  23988. // YYYY = YY^2
  23989. var yyyy = yy.redSqr();
  23990. // S = 2 * ((X1 + YY)^2 - XX - YYYY)
  23991. var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
  23992. s = s.redIAdd(s);
  23993. // M = 3 * XX + a; a = 0
  23994. var m = xx.redAdd(xx).redIAdd(xx);
  23995. // T = M ^ 2 - 2*S
  23996. var t = m.redSqr().redISub(s).redISub(s);
  23997. // 8 * YYYY
  23998. var yyyy8 = yyyy.redIAdd(yyyy);
  23999. yyyy8 = yyyy8.redIAdd(yyyy8);
  24000. yyyy8 = yyyy8.redIAdd(yyyy8);
  24001. // X3 = T
  24002. nx = t;
  24003. // Y3 = M * (S - T) - 8 * YYYY
  24004. ny = m.redMul(s.redISub(t)).redISub(yyyy8);
  24005. // Z3 = 2*Y1
  24006. nz = this.y.redAdd(this.y);
  24007. } else {
  24008. // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
  24009. // #doubling-dbl-2009-l
  24010. // 2M + 5S + 13A
  24011. // A = X1^2
  24012. var a = this.x.redSqr();
  24013. // B = Y1^2
  24014. var b = this.y.redSqr();
  24015. // C = B^2
  24016. var c = b.redSqr();
  24017. // D = 2 * ((X1 + B)^2 - A - C)
  24018. var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c);
  24019. d = d.redIAdd(d);
  24020. // E = 3 * A
  24021. var e = a.redAdd(a).redIAdd(a);
  24022. // F = E^2
  24023. var f = e.redSqr();
  24024. // 8 * C
  24025. var c8 = c.redIAdd(c);
  24026. c8 = c8.redIAdd(c8);
  24027. c8 = c8.redIAdd(c8);
  24028. // X3 = F - 2 * D
  24029. nx = f.redISub(d).redISub(d);
  24030. // Y3 = E * (D - X3) - 8 * C
  24031. ny = e.redMul(d.redISub(nx)).redISub(c8);
  24032. // Z3 = 2 * Y1 * Z1
  24033. nz = this.y.redMul(this.z);
  24034. nz = nz.redIAdd(nz);
  24035. }
  24036. return this.curve.jpoint(nx, ny, nz);
  24037. };
  24038. JPoint.prototype._threeDbl = function _threeDbl() {
  24039. var nx;
  24040. var ny;
  24041. var nz;
  24042. // Z = 1
  24043. if (this.zOne) {
  24044. // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html
  24045. // #doubling-mdbl-2007-bl
  24046. // 1M + 5S + 15A
  24047. // XX = X1^2
  24048. var xx = this.x.redSqr();
  24049. // YY = Y1^2
  24050. var yy = this.y.redSqr();
  24051. // YYYY = YY^2
  24052. var yyyy = yy.redSqr();
  24053. // S = 2 * ((X1 + YY)^2 - XX - YYYY)
  24054. var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
  24055. s = s.redIAdd(s);
  24056. // M = 3 * XX + a
  24057. var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a);
  24058. // T = M^2 - 2 * S
  24059. var t = m.redSqr().redISub(s).redISub(s);
  24060. // X3 = T
  24061. nx = t;
  24062. // Y3 = M * (S - T) - 8 * YYYY
  24063. var yyyy8 = yyyy.redIAdd(yyyy);
  24064. yyyy8 = yyyy8.redIAdd(yyyy8);
  24065. yyyy8 = yyyy8.redIAdd(yyyy8);
  24066. ny = m.redMul(s.redISub(t)).redISub(yyyy8);
  24067. // Z3 = 2 * Y1
  24068. nz = this.y.redAdd(this.y);
  24069. } else {
  24070. // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b
  24071. // 3M + 5S
  24072. // delta = Z1^2
  24073. var delta = this.z.redSqr();
  24074. // gamma = Y1^2
  24075. var gamma = this.y.redSqr();
  24076. // beta = X1 * gamma
  24077. var beta = this.x.redMul(gamma);
  24078. // alpha = 3 * (X1 - delta) * (X1 + delta)
  24079. var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta));
  24080. alpha = alpha.redAdd(alpha).redIAdd(alpha);
  24081. // X3 = alpha^2 - 8 * beta
  24082. var beta4 = beta.redIAdd(beta);
  24083. beta4 = beta4.redIAdd(beta4);
  24084. var beta8 = beta4.redAdd(beta4);
  24085. nx = alpha.redSqr().redISub(beta8);
  24086. // Z3 = (Y1 + Z1)^2 - gamma - delta
  24087. nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta);
  24088. // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2
  24089. var ggamma8 = gamma.redSqr();
  24090. ggamma8 = ggamma8.redIAdd(ggamma8);
  24091. ggamma8 = ggamma8.redIAdd(ggamma8);
  24092. ggamma8 = ggamma8.redIAdd(ggamma8);
  24093. ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8);
  24094. }
  24095. return this.curve.jpoint(nx, ny, nz);
  24096. };
  24097. JPoint.prototype._dbl = function _dbl() {
  24098. var a = this.curve.a;
  24099. // 4M + 6S + 10A
  24100. var jx = this.x;
  24101. var jy = this.y;
  24102. var jz = this.z;
  24103. var jz4 = jz.redSqr().redSqr();
  24104. var jx2 = jx.redSqr();
  24105. var jy2 = jy.redSqr();
  24106. var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
  24107. var jxd4 = jx.redAdd(jx);
  24108. jxd4 = jxd4.redIAdd(jxd4);
  24109. var t1 = jxd4.redMul(jy2);
  24110. var nx = c.redSqr().redISub(t1.redAdd(t1));
  24111. var t2 = t1.redISub(nx);
  24112. var jyd8 = jy2.redSqr();
  24113. jyd8 = jyd8.redIAdd(jyd8);
  24114. jyd8 = jyd8.redIAdd(jyd8);
  24115. jyd8 = jyd8.redIAdd(jyd8);
  24116. var ny = c.redMul(t2).redISub(jyd8);
  24117. var nz = jy.redAdd(jy).redMul(jz);
  24118. return this.curve.jpoint(nx, ny, nz);
  24119. };
  24120. JPoint.prototype.trpl = function trpl() {
  24121. if (!this.curve.zeroA)
  24122. return this.dbl().add(this);
  24123. // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl
  24124. // 5M + 10S + ...
  24125. // XX = X1^2
  24126. var xx = this.x.redSqr();
  24127. // YY = Y1^2
  24128. var yy = this.y.redSqr();
  24129. // ZZ = Z1^2
  24130. var zz = this.z.redSqr();
  24131. // YYYY = YY^2
  24132. var yyyy = yy.redSqr();
  24133. // M = 3 * XX + a * ZZ2; a = 0
  24134. var m = xx.redAdd(xx).redIAdd(xx);
  24135. // MM = M^2
  24136. var mm = m.redSqr();
  24137. // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM
  24138. var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
  24139. e = e.redIAdd(e);
  24140. e = e.redAdd(e).redIAdd(e);
  24141. e = e.redISub(mm);
  24142. // EE = E^2
  24143. var ee = e.redSqr();
  24144. // T = 16*YYYY
  24145. var t = yyyy.redIAdd(yyyy);
  24146. t = t.redIAdd(t);
  24147. t = t.redIAdd(t);
  24148. t = t.redIAdd(t);
  24149. // U = (M + E)^2 - MM - EE - T
  24150. var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t);
  24151. // X3 = 4 * (X1 * EE - 4 * YY * U)
  24152. var yyu4 = yy.redMul(u);
  24153. yyu4 = yyu4.redIAdd(yyu4);
  24154. yyu4 = yyu4.redIAdd(yyu4);
  24155. var nx = this.x.redMul(ee).redISub(yyu4);
  24156. nx = nx.redIAdd(nx);
  24157. nx = nx.redIAdd(nx);
  24158. // Y3 = 8 * Y1 * (U * (T - U) - E * EE)
  24159. var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee)));
  24160. ny = ny.redIAdd(ny);
  24161. ny = ny.redIAdd(ny);
  24162. ny = ny.redIAdd(ny);
  24163. // Z3 = (Z1 + E)^2 - ZZ - EE
  24164. var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee);
  24165. return this.curve.jpoint(nx, ny, nz);
  24166. };
  24167. JPoint.prototype.mul = function mul(k, kbase) {
  24168. k = new BN(k, kbase);
  24169. return this.curve._wnafMul(this, k);
  24170. };
  24171. JPoint.prototype.eq = function eq(p) {
  24172. if (p.type === 'affine')
  24173. return this.eq(p.toJ());
  24174. if (this === p)
  24175. return true;
  24176. // x1 * z2^2 == x2 * z1^2
  24177. var z2 = this.z.redSqr();
  24178. var pz2 = p.z.redSqr();
  24179. if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0)
  24180. return false;
  24181. // y1 * z2^3 == y2 * z1^3
  24182. var z3 = z2.redMul(this.z);
  24183. var pz3 = pz2.redMul(p.z);
  24184. return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0;
  24185. };
  24186. JPoint.prototype.eqXToP = function eqXToP(x) {
  24187. var zs = this.z.redSqr();
  24188. var rx = x.toRed(this.curve.red).redMul(zs);
  24189. if (this.x.cmp(rx) === 0)
  24190. return true;
  24191. var xc = x.clone();
  24192. var t = this.curve.redN.redMul(zs);
  24193. for (;;) {
  24194. xc.iadd(this.curve.n);
  24195. if (xc.cmp(this.curve.p) >= 0)
  24196. return false;
  24197. rx.redIAdd(t);
  24198. if (this.x.cmp(rx) === 0)
  24199. return true;
  24200. }
  24201. };
  24202. JPoint.prototype.inspect = function inspect() {
  24203. if (this.isInfinity())
  24204. return '<EC JPoint Infinity>';
  24205. return '<EC JPoint x: ' + this.x.toString(16, 2) +
  24206. ' y: ' + this.y.toString(16, 2) +
  24207. ' z: ' + this.z.toString(16, 2) + '>';
  24208. };
  24209. JPoint.prototype.isInfinity = function isInfinity() {
  24210. // XXX This code assumes that zero is always zero in red
  24211. return this.z.cmpn(0) === 0;
  24212. };
  24213. /***/ }),
  24214. /***/ "../../node_modules/elliptic/lib/elliptic/curves.js":
  24215. /*!**********************************************************!*\
  24216. !*** ../../node_modules/elliptic/lib/elliptic/curves.js ***!
  24217. \**********************************************************/
  24218. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  24219. "use strict";
  24220. var curves = exports;
  24221. var hash = __webpack_require__(/*! hash.js */ "../../node_modules/hash.js/lib/hash.js");
  24222. var curve = __webpack_require__(/*! ./curve */ "../../node_modules/elliptic/lib/elliptic/curve/index.js");
  24223. var utils = __webpack_require__(/*! ./utils */ "../../node_modules/elliptic/lib/elliptic/utils.js");
  24224. var assert = utils.assert;
  24225. function PresetCurve(options) {
  24226. if (options.type === 'short')
  24227. this.curve = new curve.short(options);
  24228. else if (options.type === 'edwards')
  24229. this.curve = new curve.edwards(options);
  24230. else
  24231. this.curve = new curve.mont(options);
  24232. this.g = this.curve.g;
  24233. this.n = this.curve.n;
  24234. this.hash = options.hash;
  24235. assert(this.g.validate(), 'Invalid curve');
  24236. assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O');
  24237. }
  24238. curves.PresetCurve = PresetCurve;
  24239. function defineCurve(name, options) {
  24240. Object.defineProperty(curves, name, {
  24241. configurable: true,
  24242. enumerable: true,
  24243. get: function() {
  24244. var curve = new PresetCurve(options);
  24245. Object.defineProperty(curves, name, {
  24246. configurable: true,
  24247. enumerable: true,
  24248. value: curve,
  24249. });
  24250. return curve;
  24251. },
  24252. });
  24253. }
  24254. defineCurve('p192', {
  24255. type: 'short',
  24256. prime: 'p192',
  24257. p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff',
  24258. a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc',
  24259. b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1',
  24260. n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831',
  24261. hash: hash.sha256,
  24262. gRed: false,
  24263. g: [
  24264. '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012',
  24265. '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811',
  24266. ],
  24267. });
  24268. defineCurve('p224', {
  24269. type: 'short',
  24270. prime: 'p224',
  24271. p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001',
  24272. a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe',
  24273. b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4',
  24274. n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d',
  24275. hash: hash.sha256,
  24276. gRed: false,
  24277. g: [
  24278. 'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21',
  24279. 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34',
  24280. ],
  24281. });
  24282. defineCurve('p256', {
  24283. type: 'short',
  24284. prime: null,
  24285. p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff',
  24286. a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc',
  24287. b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b',
  24288. n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551',
  24289. hash: hash.sha256,
  24290. gRed: false,
  24291. g: [
  24292. '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296',
  24293. '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5',
  24294. ],
  24295. });
  24296. defineCurve('p384', {
  24297. type: 'short',
  24298. prime: null,
  24299. p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  24300. 'fffffffe ffffffff 00000000 00000000 ffffffff',
  24301. a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  24302. 'fffffffe ffffffff 00000000 00000000 fffffffc',
  24303. b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' +
  24304. '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef',
  24305. n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' +
  24306. 'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973',
  24307. hash: hash.sha384,
  24308. gRed: false,
  24309. g: [
  24310. 'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' +
  24311. '5502f25d bf55296c 3a545e38 72760ab7',
  24312. '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' +
  24313. '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f',
  24314. ],
  24315. });
  24316. defineCurve('p521', {
  24317. type: 'short',
  24318. prime: null,
  24319. p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  24320. 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  24321. 'ffffffff ffffffff ffffffff ffffffff ffffffff',
  24322. a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  24323. 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  24324. 'ffffffff ffffffff ffffffff ffffffff fffffffc',
  24325. b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' +
  24326. '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' +
  24327. '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00',
  24328. n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  24329. 'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' +
  24330. 'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409',
  24331. hash: hash.sha512,
  24332. gRed: false,
  24333. g: [
  24334. '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' +
  24335. '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' +
  24336. 'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66',
  24337. '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' +
  24338. '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' +
  24339. '3fad0761 353c7086 a272c240 88be9476 9fd16650',
  24340. ],
  24341. });
  24342. defineCurve('curve25519', {
  24343. type: 'mont',
  24344. prime: 'p25519',
  24345. p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
  24346. a: '76d06',
  24347. b: '1',
  24348. n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
  24349. hash: hash.sha256,
  24350. gRed: false,
  24351. g: [
  24352. '9',
  24353. ],
  24354. });
  24355. defineCurve('ed25519', {
  24356. type: 'edwards',
  24357. prime: 'p25519',
  24358. p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
  24359. a: '-1',
  24360. c: '1',
  24361. // -121665 * (121666^(-1)) (mod P)
  24362. d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3',
  24363. n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
  24364. hash: hash.sha256,
  24365. gRed: false,
  24366. g: [
  24367. '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a',
  24368. // 4/5
  24369. '6666666666666666666666666666666666666666666666666666666666666658',
  24370. ],
  24371. });
  24372. var pre;
  24373. try {
  24374. pre = __webpack_require__(/*! ./precomputed/secp256k1 */ "../../node_modules/elliptic/lib/elliptic/precomputed/secp256k1.js");
  24375. } catch (e) {
  24376. pre = undefined;
  24377. }
  24378. defineCurve('secp256k1', {
  24379. type: 'short',
  24380. prime: 'k256',
  24381. p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f',
  24382. a: '0',
  24383. b: '7',
  24384. n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141',
  24385. h: '1',
  24386. hash: hash.sha256,
  24387. // Precomputed endomorphism
  24388. beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee',
  24389. lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72',
  24390. basis: [
  24391. {
  24392. a: '3086d221a7d46bcde86c90e49284eb15',
  24393. b: '-e4437ed6010e88286f547fa90abfe4c3',
  24394. },
  24395. {
  24396. a: '114ca50f7a8e2f3f657c1108d9d44cfd8',
  24397. b: '3086d221a7d46bcde86c90e49284eb15',
  24398. },
  24399. ],
  24400. gRed: false,
  24401. g: [
  24402. '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
  24403. '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8',
  24404. pre,
  24405. ],
  24406. });
  24407. /***/ }),
  24408. /***/ "../../node_modules/elliptic/lib/elliptic/ec/index.js":
  24409. /*!************************************************************!*\
  24410. !*** ../../node_modules/elliptic/lib/elliptic/ec/index.js ***!
  24411. \************************************************************/
  24412. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  24413. "use strict";
  24414. var BN = __webpack_require__(/*! bn.js */ "../../node_modules/diffie-hellman/node_modules/bn.js/lib/bn.js");
  24415. var HmacDRBG = __webpack_require__(/*! hmac-drbg */ "../../node_modules/hmac-drbg/lib/hmac-drbg.js");
  24416. var utils = __webpack_require__(/*! ../utils */ "../../node_modules/elliptic/lib/elliptic/utils.js");
  24417. var curves = __webpack_require__(/*! ../curves */ "../../node_modules/elliptic/lib/elliptic/curves.js");
  24418. var rand = __webpack_require__(/*! brorand */ "../../node_modules/brorand/index.js");
  24419. var assert = utils.assert;
  24420. var KeyPair = __webpack_require__(/*! ./key */ "../../node_modules/elliptic/lib/elliptic/ec/key.js");
  24421. var Signature = __webpack_require__(/*! ./signature */ "../../node_modules/elliptic/lib/elliptic/ec/signature.js");
  24422. function EC(options) {
  24423. if (!(this instanceof EC))
  24424. return new EC(options);
  24425. // Shortcut `elliptic.ec(curve-name)`
  24426. if (typeof options === 'string') {
  24427. assert(Object.prototype.hasOwnProperty.call(curves, options),
  24428. 'Unknown curve ' + options);
  24429. options = curves[options];
  24430. }
  24431. // Shortcut for `elliptic.ec(elliptic.curves.curveName)`
  24432. if (options instanceof curves.PresetCurve)
  24433. options = { curve: options };
  24434. this.curve = options.curve.curve;
  24435. this.n = this.curve.n;
  24436. this.nh = this.n.ushrn(1);
  24437. this.g = this.curve.g;
  24438. // Point on curve
  24439. this.g = options.curve.g;
  24440. this.g.precompute(options.curve.n.bitLength() + 1);
  24441. // Hash for function for DRBG
  24442. this.hash = options.hash || options.curve.hash;
  24443. }
  24444. module.exports = EC;
  24445. EC.prototype.keyPair = function keyPair(options) {
  24446. return new KeyPair(this, options);
  24447. };
  24448. EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) {
  24449. return KeyPair.fromPrivate(this, priv, enc);
  24450. };
  24451. EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) {
  24452. return KeyPair.fromPublic(this, pub, enc);
  24453. };
  24454. EC.prototype.genKeyPair = function genKeyPair(options) {
  24455. if (!options)
  24456. options = {};
  24457. // Instantiate Hmac_DRBG
  24458. var drbg = new HmacDRBG({
  24459. hash: this.hash,
  24460. pers: options.pers,
  24461. persEnc: options.persEnc || 'utf8',
  24462. entropy: options.entropy || rand(this.hash.hmacStrength),
  24463. entropyEnc: options.entropy && options.entropyEnc || 'utf8',
  24464. nonce: this.n.toArray(),
  24465. });
  24466. var bytes = this.n.byteLength();
  24467. var ns2 = this.n.sub(new BN(2));
  24468. for (;;) {
  24469. var priv = new BN(drbg.generate(bytes));
  24470. if (priv.cmp(ns2) > 0)
  24471. continue;
  24472. priv.iaddn(1);
  24473. return this.keyFromPrivate(priv);
  24474. }
  24475. };
  24476. EC.prototype._truncateToN = function _truncateToN(msg, truncOnly) {
  24477. var delta = msg.byteLength() * 8 - this.n.bitLength();
  24478. if (delta > 0)
  24479. msg = msg.ushrn(delta);
  24480. if (!truncOnly && msg.cmp(this.n) >= 0)
  24481. return msg.sub(this.n);
  24482. else
  24483. return msg;
  24484. };
  24485. EC.prototype.sign = function sign(msg, key, enc, options) {
  24486. if (typeof enc === 'object') {
  24487. options = enc;
  24488. enc = null;
  24489. }
  24490. if (!options)
  24491. options = {};
  24492. key = this.keyFromPrivate(key, enc);
  24493. msg = this._truncateToN(new BN(msg, 16));
  24494. // Zero-extend key to provide enough entropy
  24495. var bytes = this.n.byteLength();
  24496. var bkey = key.getPrivate().toArray('be', bytes);
  24497. // Zero-extend nonce to have the same byte size as N
  24498. var nonce = msg.toArray('be', bytes);
  24499. // Instantiate Hmac_DRBG
  24500. var drbg = new HmacDRBG({
  24501. hash: this.hash,
  24502. entropy: bkey,
  24503. nonce: nonce,
  24504. pers: options.pers,
  24505. persEnc: options.persEnc || 'utf8',
  24506. });
  24507. // Number of bytes to generate
  24508. var ns1 = this.n.sub(new BN(1));
  24509. for (var iter = 0; ; iter++) {
  24510. var k = options.k ?
  24511. options.k(iter) :
  24512. new BN(drbg.generate(this.n.byteLength()));
  24513. k = this._truncateToN(k, true);
  24514. if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0)
  24515. continue;
  24516. var kp = this.g.mul(k);
  24517. if (kp.isInfinity())
  24518. continue;
  24519. var kpX = kp.getX();
  24520. var r = kpX.umod(this.n);
  24521. if (r.cmpn(0) === 0)
  24522. continue;
  24523. var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg));
  24524. s = s.umod(this.n);
  24525. if (s.cmpn(0) === 0)
  24526. continue;
  24527. var recoveryParam = (kp.getY().isOdd() ? 1 : 0) |
  24528. (kpX.cmp(r) !== 0 ? 2 : 0);
  24529. // Use complement of `s`, if it is > `n / 2`
  24530. if (options.canonical && s.cmp(this.nh) > 0) {
  24531. s = this.n.sub(s);
  24532. recoveryParam ^= 1;
  24533. }
  24534. return new Signature({ r: r, s: s, recoveryParam: recoveryParam });
  24535. }
  24536. };
  24537. EC.prototype.verify = function verify(msg, signature, key, enc) {
  24538. msg = this._truncateToN(new BN(msg, 16));
  24539. key = this.keyFromPublic(key, enc);
  24540. signature = new Signature(signature, 'hex');
  24541. // Perform primitive values validation
  24542. var r = signature.r;
  24543. var s = signature.s;
  24544. if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0)
  24545. return false;
  24546. if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0)
  24547. return false;
  24548. // Validate signature
  24549. var sinv = s.invm(this.n);
  24550. var u1 = sinv.mul(msg).umod(this.n);
  24551. var u2 = sinv.mul(r).umod(this.n);
  24552. var p;
  24553. if (!this.curve._maxwellTrick) {
  24554. p = this.g.mulAdd(u1, key.getPublic(), u2);
  24555. if (p.isInfinity())
  24556. return false;
  24557. return p.getX().umod(this.n).cmp(r) === 0;
  24558. }
  24559. // NOTE: Greg Maxwell's trick, inspired by:
  24560. // https://git.io/vad3K
  24561. p = this.g.jmulAdd(u1, key.getPublic(), u2);
  24562. if (p.isInfinity())
  24563. return false;
  24564. // Compare `p.x` of Jacobian point with `r`,
  24565. // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the
  24566. // inverse of `p.z^2`
  24567. return p.eqXToP(r);
  24568. };
  24569. EC.prototype.recoverPubKey = function(msg, signature, j, enc) {
  24570. assert((3 & j) === j, 'The recovery param is more than two bits');
  24571. signature = new Signature(signature, enc);
  24572. var n = this.n;
  24573. var e = new BN(msg);
  24574. var r = signature.r;
  24575. var s = signature.s;
  24576. // A set LSB signifies that the y-coordinate is odd
  24577. var isYOdd = j & 1;
  24578. var isSecondKey = j >> 1;
  24579. if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey)
  24580. throw new Error('Unable to find sencond key candinate');
  24581. // 1.1. Let x = r + jn.
  24582. if (isSecondKey)
  24583. r = this.curve.pointFromX(r.add(this.curve.n), isYOdd);
  24584. else
  24585. r = this.curve.pointFromX(r, isYOdd);
  24586. var rInv = signature.r.invm(n);
  24587. var s1 = n.sub(e).mul(rInv).umod(n);
  24588. var s2 = s.mul(rInv).umod(n);
  24589. // 1.6.1 Compute Q = r^-1 (sR - eG)
  24590. // Q = r^-1 (sR + -eG)
  24591. return this.g.mulAdd(s1, r, s2);
  24592. };
  24593. EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) {
  24594. signature = new Signature(signature, enc);
  24595. if (signature.recoveryParam !== null)
  24596. return signature.recoveryParam;
  24597. for (var i = 0; i < 4; i++) {
  24598. var Qprime;
  24599. try {
  24600. Qprime = this.recoverPubKey(e, signature, i);
  24601. } catch (e) {
  24602. continue;
  24603. }
  24604. if (Qprime.eq(Q))
  24605. return i;
  24606. }
  24607. throw new Error('Unable to find valid recovery factor');
  24608. };
  24609. /***/ }),
  24610. /***/ "../../node_modules/elliptic/lib/elliptic/ec/key.js":
  24611. /*!**********************************************************!*\
  24612. !*** ../../node_modules/elliptic/lib/elliptic/ec/key.js ***!
  24613. \**********************************************************/
  24614. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  24615. "use strict";
  24616. var BN = __webpack_require__(/*! bn.js */ "../../node_modules/diffie-hellman/node_modules/bn.js/lib/bn.js");
  24617. var utils = __webpack_require__(/*! ../utils */ "../../node_modules/elliptic/lib/elliptic/utils.js");
  24618. var assert = utils.assert;
  24619. function KeyPair(ec, options) {
  24620. this.ec = ec;
  24621. this.priv = null;
  24622. this.pub = null;
  24623. // KeyPair(ec, { priv: ..., pub: ... })
  24624. if (options.priv)
  24625. this._importPrivate(options.priv, options.privEnc);
  24626. if (options.pub)
  24627. this._importPublic(options.pub, options.pubEnc);
  24628. }
  24629. module.exports = KeyPair;
  24630. KeyPair.fromPublic = function fromPublic(ec, pub, enc) {
  24631. if (pub instanceof KeyPair)
  24632. return pub;
  24633. return new KeyPair(ec, {
  24634. pub: pub,
  24635. pubEnc: enc,
  24636. });
  24637. };
  24638. KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) {
  24639. if (priv instanceof KeyPair)
  24640. return priv;
  24641. return new KeyPair(ec, {
  24642. priv: priv,
  24643. privEnc: enc,
  24644. });
  24645. };
  24646. KeyPair.prototype.validate = function validate() {
  24647. var pub = this.getPublic();
  24648. if (pub.isInfinity())
  24649. return { result: false, reason: 'Invalid public key' };
  24650. if (!pub.validate())
  24651. return { result: false, reason: 'Public key is not a point' };
  24652. if (!pub.mul(this.ec.curve.n).isInfinity())
  24653. return { result: false, reason: 'Public key * N != O' };
  24654. return { result: true, reason: null };
  24655. };
  24656. KeyPair.prototype.getPublic = function getPublic(compact, enc) {
  24657. // compact is optional argument
  24658. if (typeof compact === 'string') {
  24659. enc = compact;
  24660. compact = null;
  24661. }
  24662. if (!this.pub)
  24663. this.pub = this.ec.g.mul(this.priv);
  24664. if (!enc)
  24665. return this.pub;
  24666. return this.pub.encode(enc, compact);
  24667. };
  24668. KeyPair.prototype.getPrivate = function getPrivate(enc) {
  24669. if (enc === 'hex')
  24670. return this.priv.toString(16, 2);
  24671. else
  24672. return this.priv;
  24673. };
  24674. KeyPair.prototype._importPrivate = function _importPrivate(key, enc) {
  24675. this.priv = new BN(key, enc || 16);
  24676. // Ensure that the priv won't be bigger than n, otherwise we may fail
  24677. // in fixed multiplication method
  24678. this.priv = this.priv.umod(this.ec.curve.n);
  24679. };
  24680. KeyPair.prototype._importPublic = function _importPublic(key, enc) {
  24681. if (key.x || key.y) {
  24682. // Montgomery points only have an `x` coordinate.
  24683. // Weierstrass/Edwards points on the other hand have both `x` and
  24684. // `y` coordinates.
  24685. if (this.ec.curve.type === 'mont') {
  24686. assert(key.x, 'Need x coordinate');
  24687. } else if (this.ec.curve.type === 'short' ||
  24688. this.ec.curve.type === 'edwards') {
  24689. assert(key.x && key.y, 'Need both x and y coordinate');
  24690. }
  24691. this.pub = this.ec.curve.point(key.x, key.y);
  24692. return;
  24693. }
  24694. this.pub = this.ec.curve.decodePoint(key, enc);
  24695. };
  24696. // ECDH
  24697. KeyPair.prototype.derive = function derive(pub) {
  24698. if(!pub.validate()) {
  24699. assert(pub.validate(), 'public point not validated');
  24700. }
  24701. return pub.mul(this.priv).getX();
  24702. };
  24703. // ECDSA
  24704. KeyPair.prototype.sign = function sign(msg, enc, options) {
  24705. return this.ec.sign(msg, this, enc, options);
  24706. };
  24707. KeyPair.prototype.verify = function verify(msg, signature) {
  24708. return this.ec.verify(msg, signature, this);
  24709. };
  24710. KeyPair.prototype.inspect = function inspect() {
  24711. return '<Key priv: ' + (this.priv && this.priv.toString(16, 2)) +
  24712. ' pub: ' + (this.pub && this.pub.inspect()) + ' >';
  24713. };
  24714. /***/ }),
  24715. /***/ "../../node_modules/elliptic/lib/elliptic/ec/signature.js":
  24716. /*!****************************************************************!*\
  24717. !*** ../../node_modules/elliptic/lib/elliptic/ec/signature.js ***!
  24718. \****************************************************************/
  24719. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  24720. "use strict";
  24721. var BN = __webpack_require__(/*! bn.js */ "../../node_modules/diffie-hellman/node_modules/bn.js/lib/bn.js");
  24722. var utils = __webpack_require__(/*! ../utils */ "../../node_modules/elliptic/lib/elliptic/utils.js");
  24723. var assert = utils.assert;
  24724. function Signature(options, enc) {
  24725. if (options instanceof Signature)
  24726. return options;
  24727. if (this._importDER(options, enc))
  24728. return;
  24729. assert(options.r && options.s, 'Signature without r or s');
  24730. this.r = new BN(options.r, 16);
  24731. this.s = new BN(options.s, 16);
  24732. if (options.recoveryParam === undefined)
  24733. this.recoveryParam = null;
  24734. else
  24735. this.recoveryParam = options.recoveryParam;
  24736. }
  24737. module.exports = Signature;
  24738. function Position() {
  24739. this.place = 0;
  24740. }
  24741. function getLength(buf, p) {
  24742. var initial = buf[p.place++];
  24743. if (!(initial & 0x80)) {
  24744. return initial;
  24745. }
  24746. var octetLen = initial & 0xf;
  24747. // Indefinite length or overflow
  24748. if (octetLen === 0 || octetLen > 4) {
  24749. return false;
  24750. }
  24751. var val = 0;
  24752. for (var i = 0, off = p.place; i < octetLen; i++, off++) {
  24753. val <<= 8;
  24754. val |= buf[off];
  24755. val >>>= 0;
  24756. }
  24757. // Leading zeroes
  24758. if (val <= 0x7f) {
  24759. return false;
  24760. }
  24761. p.place = off;
  24762. return val;
  24763. }
  24764. function rmPadding(buf) {
  24765. var i = 0;
  24766. var len = buf.length - 1;
  24767. while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) {
  24768. i++;
  24769. }
  24770. if (i === 0) {
  24771. return buf;
  24772. }
  24773. return buf.slice(i);
  24774. }
  24775. Signature.prototype._importDER = function _importDER(data, enc) {
  24776. data = utils.toArray(data, enc);
  24777. var p = new Position();
  24778. if (data[p.place++] !== 0x30) {
  24779. return false;
  24780. }
  24781. var len = getLength(data, p);
  24782. if (len === false) {
  24783. return false;
  24784. }
  24785. if ((len + p.place) !== data.length) {
  24786. return false;
  24787. }
  24788. if (data[p.place++] !== 0x02) {
  24789. return false;
  24790. }
  24791. var rlen = getLength(data, p);
  24792. if (rlen === false) {
  24793. return false;
  24794. }
  24795. var r = data.slice(p.place, rlen + p.place);
  24796. p.place += rlen;
  24797. if (data[p.place++] !== 0x02) {
  24798. return false;
  24799. }
  24800. var slen = getLength(data, p);
  24801. if (slen === false) {
  24802. return false;
  24803. }
  24804. if (data.length !== slen + p.place) {
  24805. return false;
  24806. }
  24807. var s = data.slice(p.place, slen + p.place);
  24808. if (r[0] === 0) {
  24809. if (r[1] & 0x80) {
  24810. r = r.slice(1);
  24811. } else {
  24812. // Leading zeroes
  24813. return false;
  24814. }
  24815. }
  24816. if (s[0] === 0) {
  24817. if (s[1] & 0x80) {
  24818. s = s.slice(1);
  24819. } else {
  24820. // Leading zeroes
  24821. return false;
  24822. }
  24823. }
  24824. this.r = new BN(r);
  24825. this.s = new BN(s);
  24826. this.recoveryParam = null;
  24827. return true;
  24828. };
  24829. function constructLength(arr, len) {
  24830. if (len < 0x80) {
  24831. arr.push(len);
  24832. return;
  24833. }
  24834. var octets = 1 + (Math.log(len) / Math.LN2 >>> 3);
  24835. arr.push(octets | 0x80);
  24836. while (--octets) {
  24837. arr.push((len >>> (octets << 3)) & 0xff);
  24838. }
  24839. arr.push(len);
  24840. }
  24841. Signature.prototype.toDER = function toDER(enc) {
  24842. var r = this.r.toArray();
  24843. var s = this.s.toArray();
  24844. // Pad values
  24845. if (r[0] & 0x80)
  24846. r = [ 0 ].concat(r);
  24847. // Pad values
  24848. if (s[0] & 0x80)
  24849. s = [ 0 ].concat(s);
  24850. r = rmPadding(r);
  24851. s = rmPadding(s);
  24852. while (!s[0] && !(s[1] & 0x80)) {
  24853. s = s.slice(1);
  24854. }
  24855. var arr = [ 0x02 ];
  24856. constructLength(arr, r.length);
  24857. arr = arr.concat(r);
  24858. arr.push(0x02);
  24859. constructLength(arr, s.length);
  24860. var backHalf = arr.concat(s);
  24861. var res = [ 0x30 ];
  24862. constructLength(res, backHalf.length);
  24863. res = res.concat(backHalf);
  24864. return utils.encode(res, enc);
  24865. };
  24866. /***/ }),
  24867. /***/ "../../node_modules/elliptic/lib/elliptic/eddsa/index.js":
  24868. /*!***************************************************************!*\
  24869. !*** ../../node_modules/elliptic/lib/elliptic/eddsa/index.js ***!
  24870. \***************************************************************/
  24871. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  24872. "use strict";
  24873. var hash = __webpack_require__(/*! hash.js */ "../../node_modules/hash.js/lib/hash.js");
  24874. var curves = __webpack_require__(/*! ../curves */ "../../node_modules/elliptic/lib/elliptic/curves.js");
  24875. var utils = __webpack_require__(/*! ../utils */ "../../node_modules/elliptic/lib/elliptic/utils.js");
  24876. var assert = utils.assert;
  24877. var parseBytes = utils.parseBytes;
  24878. var KeyPair = __webpack_require__(/*! ./key */ "../../node_modules/elliptic/lib/elliptic/eddsa/key.js");
  24879. var Signature = __webpack_require__(/*! ./signature */ "../../node_modules/elliptic/lib/elliptic/eddsa/signature.js");
  24880. function EDDSA(curve) {
  24881. assert(curve === 'ed25519', 'only tested with ed25519 so far');
  24882. if (!(this instanceof EDDSA))
  24883. return new EDDSA(curve);
  24884. curve = curves[curve].curve;
  24885. this.curve = curve;
  24886. this.g = curve.g;
  24887. this.g.precompute(curve.n.bitLength() + 1);
  24888. this.pointClass = curve.point().constructor;
  24889. this.encodingLength = Math.ceil(curve.n.bitLength() / 8);
  24890. this.hash = hash.sha512;
  24891. }
  24892. module.exports = EDDSA;
  24893. /**
  24894. * @param {Array|String} message - message bytes
  24895. * @param {Array|String|KeyPair} secret - secret bytes or a keypair
  24896. * @returns {Signature} - signature
  24897. */
  24898. EDDSA.prototype.sign = function sign(message, secret) {
  24899. message = parseBytes(message);
  24900. var key = this.keyFromSecret(secret);
  24901. var r = this.hashInt(key.messagePrefix(), message);
  24902. var R = this.g.mul(r);
  24903. var Rencoded = this.encodePoint(R);
  24904. var s_ = this.hashInt(Rencoded, key.pubBytes(), message)
  24905. .mul(key.priv());
  24906. var S = r.add(s_).umod(this.curve.n);
  24907. return this.makeSignature({ R: R, S: S, Rencoded: Rencoded });
  24908. };
  24909. /**
  24910. * @param {Array} message - message bytes
  24911. * @param {Array|String|Signature} sig - sig bytes
  24912. * @param {Array|String|Point|KeyPair} pub - public key
  24913. * @returns {Boolean} - true if public key matches sig of message
  24914. */
  24915. EDDSA.prototype.verify = function verify(message, sig, pub) {
  24916. message = parseBytes(message);
  24917. sig = this.makeSignature(sig);
  24918. var key = this.keyFromPublic(pub);
  24919. var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message);
  24920. var SG = this.g.mul(sig.S());
  24921. var RplusAh = sig.R().add(key.pub().mul(h));
  24922. return RplusAh.eq(SG);
  24923. };
  24924. EDDSA.prototype.hashInt = function hashInt() {
  24925. var hash = this.hash();
  24926. for (var i = 0; i < arguments.length; i++)
  24927. hash.update(arguments[i]);
  24928. return utils.intFromLE(hash.digest()).umod(this.curve.n);
  24929. };
  24930. EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) {
  24931. return KeyPair.fromPublic(this, pub);
  24932. };
  24933. EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) {
  24934. return KeyPair.fromSecret(this, secret);
  24935. };
  24936. EDDSA.prototype.makeSignature = function makeSignature(sig) {
  24937. if (sig instanceof Signature)
  24938. return sig;
  24939. return new Signature(this, sig);
  24940. };
  24941. /**
  24942. * * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2
  24943. *
  24944. * EDDSA defines methods for encoding and decoding points and integers. These are
  24945. * helper convenience methods, that pass along to utility functions implied
  24946. * parameters.
  24947. *
  24948. */
  24949. EDDSA.prototype.encodePoint = function encodePoint(point) {
  24950. var enc = point.getY().toArray('le', this.encodingLength);
  24951. enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0;
  24952. return enc;
  24953. };
  24954. EDDSA.prototype.decodePoint = function decodePoint(bytes) {
  24955. bytes = utils.parseBytes(bytes);
  24956. var lastIx = bytes.length - 1;
  24957. var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80);
  24958. var xIsOdd = (bytes[lastIx] & 0x80) !== 0;
  24959. var y = utils.intFromLE(normed);
  24960. return this.curve.pointFromY(y, xIsOdd);
  24961. };
  24962. EDDSA.prototype.encodeInt = function encodeInt(num) {
  24963. return num.toArray('le', this.encodingLength);
  24964. };
  24965. EDDSA.prototype.decodeInt = function decodeInt(bytes) {
  24966. return utils.intFromLE(bytes);
  24967. };
  24968. EDDSA.prototype.isPoint = function isPoint(val) {
  24969. return val instanceof this.pointClass;
  24970. };
  24971. /***/ }),
  24972. /***/ "../../node_modules/elliptic/lib/elliptic/eddsa/key.js":
  24973. /*!*************************************************************!*\
  24974. !*** ../../node_modules/elliptic/lib/elliptic/eddsa/key.js ***!
  24975. \*************************************************************/
  24976. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  24977. "use strict";
  24978. var utils = __webpack_require__(/*! ../utils */ "../../node_modules/elliptic/lib/elliptic/utils.js");
  24979. var assert = utils.assert;
  24980. var parseBytes = utils.parseBytes;
  24981. var cachedProperty = utils.cachedProperty;
  24982. /**
  24983. * @param {EDDSA} eddsa - instance
  24984. * @param {Object} params - public/private key parameters
  24985. *
  24986. * @param {Array<Byte>} [params.secret] - secret seed bytes
  24987. * @param {Point} [params.pub] - public key point (aka `A` in eddsa terms)
  24988. * @param {Array<Byte>} [params.pub] - public key point encoded as bytes
  24989. *
  24990. */
  24991. function KeyPair(eddsa, params) {
  24992. this.eddsa = eddsa;
  24993. this._secret = parseBytes(params.secret);
  24994. if (eddsa.isPoint(params.pub))
  24995. this._pub = params.pub;
  24996. else
  24997. this._pubBytes = parseBytes(params.pub);
  24998. }
  24999. KeyPair.fromPublic = function fromPublic(eddsa, pub) {
  25000. if (pub instanceof KeyPair)
  25001. return pub;
  25002. return new KeyPair(eddsa, { pub: pub });
  25003. };
  25004. KeyPair.fromSecret = function fromSecret(eddsa, secret) {
  25005. if (secret instanceof KeyPair)
  25006. return secret;
  25007. return new KeyPair(eddsa, { secret: secret });
  25008. };
  25009. KeyPair.prototype.secret = function secret() {
  25010. return this._secret;
  25011. };
  25012. cachedProperty(KeyPair, 'pubBytes', function pubBytes() {
  25013. return this.eddsa.encodePoint(this.pub());
  25014. });
  25015. cachedProperty(KeyPair, 'pub', function pub() {
  25016. if (this._pubBytes)
  25017. return this.eddsa.decodePoint(this._pubBytes);
  25018. return this.eddsa.g.mul(this.priv());
  25019. });
  25020. cachedProperty(KeyPair, 'privBytes', function privBytes() {
  25021. var eddsa = this.eddsa;
  25022. var hash = this.hash();
  25023. var lastIx = eddsa.encodingLength - 1;
  25024. var a = hash.slice(0, eddsa.encodingLength);
  25025. a[0] &= 248;
  25026. a[lastIx] &= 127;
  25027. a[lastIx] |= 64;
  25028. return a;
  25029. });
  25030. cachedProperty(KeyPair, 'priv', function priv() {
  25031. return this.eddsa.decodeInt(this.privBytes());
  25032. });
  25033. cachedProperty(KeyPair, 'hash', function hash() {
  25034. return this.eddsa.hash().update(this.secret()).digest();
  25035. });
  25036. cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() {
  25037. return this.hash().slice(this.eddsa.encodingLength);
  25038. });
  25039. KeyPair.prototype.sign = function sign(message) {
  25040. assert(this._secret, 'KeyPair can only verify');
  25041. return this.eddsa.sign(message, this);
  25042. };
  25043. KeyPair.prototype.verify = function verify(message, sig) {
  25044. return this.eddsa.verify(message, sig, this);
  25045. };
  25046. KeyPair.prototype.getSecret = function getSecret(enc) {
  25047. assert(this._secret, 'KeyPair is public only');
  25048. return utils.encode(this.secret(), enc);
  25049. };
  25050. KeyPair.prototype.getPublic = function getPublic(enc) {
  25051. return utils.encode(this.pubBytes(), enc);
  25052. };
  25053. module.exports = KeyPair;
  25054. /***/ }),
  25055. /***/ "../../node_modules/elliptic/lib/elliptic/eddsa/signature.js":
  25056. /*!*******************************************************************!*\
  25057. !*** ../../node_modules/elliptic/lib/elliptic/eddsa/signature.js ***!
  25058. \*******************************************************************/
  25059. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  25060. "use strict";
  25061. var BN = __webpack_require__(/*! bn.js */ "../../node_modules/diffie-hellman/node_modules/bn.js/lib/bn.js");
  25062. var utils = __webpack_require__(/*! ../utils */ "../../node_modules/elliptic/lib/elliptic/utils.js");
  25063. var assert = utils.assert;
  25064. var cachedProperty = utils.cachedProperty;
  25065. var parseBytes = utils.parseBytes;
  25066. /**
  25067. * @param {EDDSA} eddsa - eddsa instance
  25068. * @param {Array<Bytes>|Object} sig -
  25069. * @param {Array<Bytes>|Point} [sig.R] - R point as Point or bytes
  25070. * @param {Array<Bytes>|bn} [sig.S] - S scalar as bn or bytes
  25071. * @param {Array<Bytes>} [sig.Rencoded] - R point encoded
  25072. * @param {Array<Bytes>} [sig.Sencoded] - S scalar encoded
  25073. */
  25074. function Signature(eddsa, sig) {
  25075. this.eddsa = eddsa;
  25076. if (typeof sig !== 'object')
  25077. sig = parseBytes(sig);
  25078. if (Array.isArray(sig)) {
  25079. sig = {
  25080. R: sig.slice(0, eddsa.encodingLength),
  25081. S: sig.slice(eddsa.encodingLength),
  25082. };
  25083. }
  25084. assert(sig.R && sig.S, 'Signature without R or S');
  25085. if (eddsa.isPoint(sig.R))
  25086. this._R = sig.R;
  25087. if (sig.S instanceof BN)
  25088. this._S = sig.S;
  25089. this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded;
  25090. this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded;
  25091. }
  25092. cachedProperty(Signature, 'S', function S() {
  25093. return this.eddsa.decodeInt(this.Sencoded());
  25094. });
  25095. cachedProperty(Signature, 'R', function R() {
  25096. return this.eddsa.decodePoint(this.Rencoded());
  25097. });
  25098. cachedProperty(Signature, 'Rencoded', function Rencoded() {
  25099. return this.eddsa.encodePoint(this.R());
  25100. });
  25101. cachedProperty(Signature, 'Sencoded', function Sencoded() {
  25102. return this.eddsa.encodeInt(this.S());
  25103. });
  25104. Signature.prototype.toBytes = function toBytes() {
  25105. return this.Rencoded().concat(this.Sencoded());
  25106. };
  25107. Signature.prototype.toHex = function toHex() {
  25108. return utils.encode(this.toBytes(), 'hex').toUpperCase();
  25109. };
  25110. module.exports = Signature;
  25111. /***/ }),
  25112. /***/ "../../node_modules/elliptic/lib/elliptic/precomputed/secp256k1.js":
  25113. /*!*************************************************************************!*\
  25114. !*** ../../node_modules/elliptic/lib/elliptic/precomputed/secp256k1.js ***!
  25115. \*************************************************************************/
  25116. /***/ ((module) => {
  25117. module.exports = {
  25118. doubles: {
  25119. step: 4,
  25120. points: [
  25121. [
  25122. 'e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a',
  25123. 'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821',
  25124. ],
  25125. [
  25126. '8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508',
  25127. '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf',
  25128. ],
  25129. [
  25130. '175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739',
  25131. 'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695',
  25132. ],
  25133. [
  25134. '363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640',
  25135. '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9',
  25136. ],
  25137. [
  25138. '8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c',
  25139. '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36',
  25140. ],
  25141. [
  25142. '723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda',
  25143. '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f',
  25144. ],
  25145. [
  25146. 'eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa',
  25147. '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999',
  25148. ],
  25149. [
  25150. '100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0',
  25151. 'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09',
  25152. ],
  25153. [
  25154. 'e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d',
  25155. '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d',
  25156. ],
  25157. [
  25158. 'feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d',
  25159. 'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088',
  25160. ],
  25161. [
  25162. 'da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1',
  25163. '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d',
  25164. ],
  25165. [
  25166. '53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0',
  25167. '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8',
  25168. ],
  25169. [
  25170. '8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047',
  25171. '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a',
  25172. ],
  25173. [
  25174. '385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862',
  25175. '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453',
  25176. ],
  25177. [
  25178. '6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7',
  25179. '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160',
  25180. ],
  25181. [
  25182. '3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd',
  25183. '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0',
  25184. ],
  25185. [
  25186. '85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83',
  25187. '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6',
  25188. ],
  25189. [
  25190. '948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a',
  25191. '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589',
  25192. ],
  25193. [
  25194. '6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8',
  25195. 'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17',
  25196. ],
  25197. [
  25198. 'e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d',
  25199. '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda',
  25200. ],
  25201. [
  25202. 'e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725',
  25203. '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd',
  25204. ],
  25205. [
  25206. '213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754',
  25207. '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2',
  25208. ],
  25209. [
  25210. '4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c',
  25211. '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6',
  25212. ],
  25213. [
  25214. 'fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6',
  25215. '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f',
  25216. ],
  25217. [
  25218. '76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39',
  25219. 'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01',
  25220. ],
  25221. [
  25222. 'c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891',
  25223. '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3',
  25224. ],
  25225. [
  25226. 'd895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b',
  25227. 'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f',
  25228. ],
  25229. [
  25230. 'b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03',
  25231. '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7',
  25232. ],
  25233. [
  25234. 'e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d',
  25235. 'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78',
  25236. ],
  25237. [
  25238. 'a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070',
  25239. '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1',
  25240. ],
  25241. [
  25242. '90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4',
  25243. 'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150',
  25244. ],
  25245. [
  25246. '8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da',
  25247. '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82',
  25248. ],
  25249. [
  25250. 'e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11',
  25251. '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc',
  25252. ],
  25253. [
  25254. '8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e',
  25255. 'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b',
  25256. ],
  25257. [
  25258. 'e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41',
  25259. '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51',
  25260. ],
  25261. [
  25262. 'b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef',
  25263. '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45',
  25264. ],
  25265. [
  25266. 'd68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8',
  25267. 'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120',
  25268. ],
  25269. [
  25270. '324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d',
  25271. '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84',
  25272. ],
  25273. [
  25274. '4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96',
  25275. '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d',
  25276. ],
  25277. [
  25278. '9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd',
  25279. 'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d',
  25280. ],
  25281. [
  25282. '6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5',
  25283. '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8',
  25284. ],
  25285. [
  25286. 'a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266',
  25287. '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8',
  25288. ],
  25289. [
  25290. '7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71',
  25291. '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac',
  25292. ],
  25293. [
  25294. '928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac',
  25295. 'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f',
  25296. ],
  25297. [
  25298. '85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751',
  25299. '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962',
  25300. ],
  25301. [
  25302. 'ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e',
  25303. '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907',
  25304. ],
  25305. [
  25306. '827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241',
  25307. 'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec',
  25308. ],
  25309. [
  25310. 'eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3',
  25311. 'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d',
  25312. ],
  25313. [
  25314. 'e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f',
  25315. '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414',
  25316. ],
  25317. [
  25318. '1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19',
  25319. 'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd',
  25320. ],
  25321. [
  25322. '146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be',
  25323. 'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0',
  25324. ],
  25325. [
  25326. 'fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9',
  25327. '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811',
  25328. ],
  25329. [
  25330. 'da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2',
  25331. '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1',
  25332. ],
  25333. [
  25334. 'a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13',
  25335. '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c',
  25336. ],
  25337. [
  25338. '174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c',
  25339. 'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73',
  25340. ],
  25341. [
  25342. '959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba',
  25343. '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd',
  25344. ],
  25345. [
  25346. 'd2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151',
  25347. 'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405',
  25348. ],
  25349. [
  25350. '64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073',
  25351. 'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589',
  25352. ],
  25353. [
  25354. '8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458',
  25355. '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e',
  25356. ],
  25357. [
  25358. '13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b',
  25359. '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27',
  25360. ],
  25361. [
  25362. 'bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366',
  25363. 'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1',
  25364. ],
  25365. [
  25366. '8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa',
  25367. '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482',
  25368. ],
  25369. [
  25370. '8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0',
  25371. '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945',
  25372. ],
  25373. [
  25374. 'dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787',
  25375. '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573',
  25376. ],
  25377. [
  25378. 'f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e',
  25379. 'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82',
  25380. ],
  25381. ],
  25382. },
  25383. naf: {
  25384. wnd: 7,
  25385. points: [
  25386. [
  25387. 'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9',
  25388. '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672',
  25389. ],
  25390. [
  25391. '2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4',
  25392. 'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6',
  25393. ],
  25394. [
  25395. '5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc',
  25396. '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da',
  25397. ],
  25398. [
  25399. 'acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe',
  25400. 'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37',
  25401. ],
  25402. [
  25403. '774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb',
  25404. 'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b',
  25405. ],
  25406. [
  25407. 'f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8',
  25408. 'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81',
  25409. ],
  25410. [
  25411. 'd7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e',
  25412. '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58',
  25413. ],
  25414. [
  25415. 'defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34',
  25416. '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77',
  25417. ],
  25418. [
  25419. '2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c',
  25420. '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a',
  25421. ],
  25422. [
  25423. '352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5',
  25424. '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c',
  25425. ],
  25426. [
  25427. '2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f',
  25428. '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67',
  25429. ],
  25430. [
  25431. '9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714',
  25432. '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402',
  25433. ],
  25434. [
  25435. 'daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729',
  25436. 'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55',
  25437. ],
  25438. [
  25439. 'c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db',
  25440. '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482',
  25441. ],
  25442. [
  25443. '6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4',
  25444. 'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82',
  25445. ],
  25446. [
  25447. '1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5',
  25448. 'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396',
  25449. ],
  25450. [
  25451. '605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479',
  25452. '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49',
  25453. ],
  25454. [
  25455. '62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d',
  25456. '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf',
  25457. ],
  25458. [
  25459. '80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f',
  25460. '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a',
  25461. ],
  25462. [
  25463. '7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb',
  25464. 'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7',
  25465. ],
  25466. [
  25467. 'd528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9',
  25468. 'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933',
  25469. ],
  25470. [
  25471. '49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963',
  25472. '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a',
  25473. ],
  25474. [
  25475. '77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74',
  25476. '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6',
  25477. ],
  25478. [
  25479. 'f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530',
  25480. 'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37',
  25481. ],
  25482. [
  25483. '463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b',
  25484. '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e',
  25485. ],
  25486. [
  25487. 'f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247',
  25488. 'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6',
  25489. ],
  25490. [
  25491. 'caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1',
  25492. 'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476',
  25493. ],
  25494. [
  25495. '2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120',
  25496. '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40',
  25497. ],
  25498. [
  25499. '7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435',
  25500. '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61',
  25501. ],
  25502. [
  25503. '754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18',
  25504. '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683',
  25505. ],
  25506. [
  25507. 'e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8',
  25508. '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5',
  25509. ],
  25510. [
  25511. '186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb',
  25512. '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b',
  25513. ],
  25514. [
  25515. 'df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f',
  25516. '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417',
  25517. ],
  25518. [
  25519. '5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143',
  25520. 'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868',
  25521. ],
  25522. [
  25523. '290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba',
  25524. 'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a',
  25525. ],
  25526. [
  25527. 'af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45',
  25528. 'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6',
  25529. ],
  25530. [
  25531. '766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a',
  25532. '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996',
  25533. ],
  25534. [
  25535. '59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e',
  25536. 'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e',
  25537. ],
  25538. [
  25539. 'f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8',
  25540. 'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d',
  25541. ],
  25542. [
  25543. '7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c',
  25544. '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2',
  25545. ],
  25546. [
  25547. '948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519',
  25548. 'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e',
  25549. ],
  25550. [
  25551. '7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab',
  25552. '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437',
  25553. ],
  25554. [
  25555. '3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca',
  25556. 'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311',
  25557. ],
  25558. [
  25559. 'd3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf',
  25560. '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4',
  25561. ],
  25562. [
  25563. '1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610',
  25564. '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575',
  25565. ],
  25566. [
  25567. '733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4',
  25568. 'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d',
  25569. ],
  25570. [
  25571. '15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c',
  25572. 'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d',
  25573. ],
  25574. [
  25575. 'a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940',
  25576. 'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629',
  25577. ],
  25578. [
  25579. 'e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980',
  25580. 'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06',
  25581. ],
  25582. [
  25583. '311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3',
  25584. '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374',
  25585. ],
  25586. [
  25587. '34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf',
  25588. '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee',
  25589. ],
  25590. [
  25591. 'f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63',
  25592. '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1',
  25593. ],
  25594. [
  25595. 'd7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448',
  25596. 'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b',
  25597. ],
  25598. [
  25599. '32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf',
  25600. '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661',
  25601. ],
  25602. [
  25603. '7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5',
  25604. '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6',
  25605. ],
  25606. [
  25607. 'ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6',
  25608. '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e',
  25609. ],
  25610. [
  25611. '16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5',
  25612. '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d',
  25613. ],
  25614. [
  25615. 'eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99',
  25616. 'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc',
  25617. ],
  25618. [
  25619. '78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51',
  25620. 'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4',
  25621. ],
  25622. [
  25623. '494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5',
  25624. '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c',
  25625. ],
  25626. [
  25627. 'a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5',
  25628. '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b',
  25629. ],
  25630. [
  25631. 'c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997',
  25632. '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913',
  25633. ],
  25634. [
  25635. '841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881',
  25636. '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154',
  25637. ],
  25638. [
  25639. '5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5',
  25640. '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865',
  25641. ],
  25642. [
  25643. '36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66',
  25644. 'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc',
  25645. ],
  25646. [
  25647. '336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726',
  25648. 'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224',
  25649. ],
  25650. [
  25651. '8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede',
  25652. '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e',
  25653. ],
  25654. [
  25655. '1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94',
  25656. '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6',
  25657. ],
  25658. [
  25659. '85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31',
  25660. '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511',
  25661. ],
  25662. [
  25663. '29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51',
  25664. 'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b',
  25665. ],
  25666. [
  25667. 'a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252',
  25668. 'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2',
  25669. ],
  25670. [
  25671. '4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5',
  25672. 'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c',
  25673. ],
  25674. [
  25675. 'd24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b',
  25676. '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3',
  25677. ],
  25678. [
  25679. 'ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4',
  25680. '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d',
  25681. ],
  25682. [
  25683. 'af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f',
  25684. '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700',
  25685. ],
  25686. [
  25687. 'e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889',
  25688. '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4',
  25689. ],
  25690. [
  25691. '591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246',
  25692. 'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196',
  25693. ],
  25694. [
  25695. '11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984',
  25696. '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4',
  25697. ],
  25698. [
  25699. '3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a',
  25700. 'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257',
  25701. ],
  25702. [
  25703. 'cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030',
  25704. 'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13',
  25705. ],
  25706. [
  25707. 'c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197',
  25708. '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096',
  25709. ],
  25710. [
  25711. 'c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593',
  25712. 'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38',
  25713. ],
  25714. [
  25715. 'a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef',
  25716. '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f',
  25717. ],
  25718. [
  25719. '347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38',
  25720. '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448',
  25721. ],
  25722. [
  25723. 'da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a',
  25724. '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a',
  25725. ],
  25726. [
  25727. 'c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111',
  25728. '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4',
  25729. ],
  25730. [
  25731. '4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502',
  25732. '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437',
  25733. ],
  25734. [
  25735. '3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea',
  25736. 'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7',
  25737. ],
  25738. [
  25739. 'cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26',
  25740. '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d',
  25741. ],
  25742. [
  25743. 'b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986',
  25744. '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a',
  25745. ],
  25746. [
  25747. 'd4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e',
  25748. '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54',
  25749. ],
  25750. [
  25751. '48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4',
  25752. '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77',
  25753. ],
  25754. [
  25755. 'dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda',
  25756. 'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517',
  25757. ],
  25758. [
  25759. '6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859',
  25760. 'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10',
  25761. ],
  25762. [
  25763. 'e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f',
  25764. 'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125',
  25765. ],
  25766. [
  25767. 'eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c',
  25768. '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e',
  25769. ],
  25770. [
  25771. '13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942',
  25772. 'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1',
  25773. ],
  25774. [
  25775. 'ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a',
  25776. '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2',
  25777. ],
  25778. [
  25779. 'b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80',
  25780. '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423',
  25781. ],
  25782. [
  25783. 'ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d',
  25784. '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8',
  25785. ],
  25786. [
  25787. '8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1',
  25788. 'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758',
  25789. ],
  25790. [
  25791. '52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63',
  25792. 'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375',
  25793. ],
  25794. [
  25795. 'e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352',
  25796. '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d',
  25797. ],
  25798. [
  25799. '7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193',
  25800. 'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec',
  25801. ],
  25802. [
  25803. '5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00',
  25804. '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0',
  25805. ],
  25806. [
  25807. '32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58',
  25808. 'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c',
  25809. ],
  25810. [
  25811. 'e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7',
  25812. 'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4',
  25813. ],
  25814. [
  25815. '8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8',
  25816. 'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f',
  25817. ],
  25818. [
  25819. '4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e',
  25820. '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649',
  25821. ],
  25822. [
  25823. '3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d',
  25824. 'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826',
  25825. ],
  25826. [
  25827. '674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b',
  25828. '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5',
  25829. ],
  25830. [
  25831. 'd32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f',
  25832. 'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87',
  25833. ],
  25834. [
  25835. '30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6',
  25836. '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b',
  25837. ],
  25838. [
  25839. 'be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297',
  25840. '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc',
  25841. ],
  25842. [
  25843. '93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a',
  25844. '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c',
  25845. ],
  25846. [
  25847. 'b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c',
  25848. 'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f',
  25849. ],
  25850. [
  25851. 'd5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52',
  25852. '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a',
  25853. ],
  25854. [
  25855. 'd3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb',
  25856. 'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46',
  25857. ],
  25858. [
  25859. '463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065',
  25860. 'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f',
  25861. ],
  25862. [
  25863. '7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917',
  25864. '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03',
  25865. ],
  25866. [
  25867. '74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9',
  25868. 'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08',
  25869. ],
  25870. [
  25871. '30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3',
  25872. '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8',
  25873. ],
  25874. [
  25875. '9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57',
  25876. '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373',
  25877. ],
  25878. [
  25879. '176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66',
  25880. 'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3',
  25881. ],
  25882. [
  25883. '75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8',
  25884. '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8',
  25885. ],
  25886. [
  25887. '809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721',
  25888. '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1',
  25889. ],
  25890. [
  25891. '1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180',
  25892. '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9',
  25893. ],
  25894. ],
  25895. },
  25896. };
  25897. /***/ }),
  25898. /***/ "../../node_modules/elliptic/lib/elliptic/utils.js":
  25899. /*!*********************************************************!*\
  25900. !*** ../../node_modules/elliptic/lib/elliptic/utils.js ***!
  25901. \*********************************************************/
  25902. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  25903. "use strict";
  25904. var utils = exports;
  25905. var BN = __webpack_require__(/*! bn.js */ "../../node_modules/diffie-hellman/node_modules/bn.js/lib/bn.js");
  25906. var minAssert = __webpack_require__(/*! minimalistic-assert */ "../../node_modules/minimalistic-assert/index.js");
  25907. var minUtils = __webpack_require__(/*! minimalistic-crypto-utils */ "../../node_modules/minimalistic-crypto-utils/lib/utils.js");
  25908. utils.assert = minAssert;
  25909. utils.toArray = minUtils.toArray;
  25910. utils.zero2 = minUtils.zero2;
  25911. utils.toHex = minUtils.toHex;
  25912. utils.encode = minUtils.encode;
  25913. // Represent num in a w-NAF form
  25914. function getNAF(num, w, bits) {
  25915. var naf = new Array(Math.max(num.bitLength(), bits) + 1);
  25916. naf.fill(0);
  25917. var ws = 1 << (w + 1);
  25918. var k = num.clone();
  25919. for (var i = 0; i < naf.length; i++) {
  25920. var z;
  25921. var mod = k.andln(ws - 1);
  25922. if (k.isOdd()) {
  25923. if (mod > (ws >> 1) - 1)
  25924. z = (ws >> 1) - mod;
  25925. else
  25926. z = mod;
  25927. k.isubn(z);
  25928. } else {
  25929. z = 0;
  25930. }
  25931. naf[i] = z;
  25932. k.iushrn(1);
  25933. }
  25934. return naf;
  25935. }
  25936. utils.getNAF = getNAF;
  25937. // Represent k1, k2 in a Joint Sparse Form
  25938. function getJSF(k1, k2) {
  25939. var jsf = [
  25940. [],
  25941. [],
  25942. ];
  25943. k1 = k1.clone();
  25944. k2 = k2.clone();
  25945. var d1 = 0;
  25946. var d2 = 0;
  25947. var m8;
  25948. while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) {
  25949. // First phase
  25950. var m14 = (k1.andln(3) + d1) & 3;
  25951. var m24 = (k2.andln(3) + d2) & 3;
  25952. if (m14 === 3)
  25953. m14 = -1;
  25954. if (m24 === 3)
  25955. m24 = -1;
  25956. var u1;
  25957. if ((m14 & 1) === 0) {
  25958. u1 = 0;
  25959. } else {
  25960. m8 = (k1.andln(7) + d1) & 7;
  25961. if ((m8 === 3 || m8 === 5) && m24 === 2)
  25962. u1 = -m14;
  25963. else
  25964. u1 = m14;
  25965. }
  25966. jsf[0].push(u1);
  25967. var u2;
  25968. if ((m24 & 1) === 0) {
  25969. u2 = 0;
  25970. } else {
  25971. m8 = (k2.andln(7) + d2) & 7;
  25972. if ((m8 === 3 || m8 === 5) && m14 === 2)
  25973. u2 = -m24;
  25974. else
  25975. u2 = m24;
  25976. }
  25977. jsf[1].push(u2);
  25978. // Second phase
  25979. if (2 * d1 === u1 + 1)
  25980. d1 = 1 - d1;
  25981. if (2 * d2 === u2 + 1)
  25982. d2 = 1 - d2;
  25983. k1.iushrn(1);
  25984. k2.iushrn(1);
  25985. }
  25986. return jsf;
  25987. }
  25988. utils.getJSF = getJSF;
  25989. function cachedProperty(obj, name, computer) {
  25990. var key = '_' + name;
  25991. obj.prototype[name] = function cachedProperty() {
  25992. return this[key] !== undefined ? this[key] :
  25993. this[key] = computer.call(this);
  25994. };
  25995. }
  25996. utils.cachedProperty = cachedProperty;
  25997. function parseBytes(bytes) {
  25998. return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') :
  25999. bytes;
  26000. }
  26001. utils.parseBytes = parseBytes;
  26002. function intFromLE(bytes) {
  26003. return new BN(bytes, 'hex', 'le');
  26004. }
  26005. utils.intFromLE = intFromLE;
  26006. /***/ }),
  26007. /***/ "../../node_modules/es6-object-assign/index.js":
  26008. /*!*****************************************************!*\
  26009. !*** ../../node_modules/es6-object-assign/index.js ***!
  26010. \*****************************************************/
  26011. /***/ ((module) => {
  26012. "use strict";
  26013. /**
  26014. * Code refactored from Mozilla Developer Network:
  26015. * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
  26016. */
  26017. function assign(target, firstSource) {
  26018. if (target === undefined || target === null) {
  26019. throw new TypeError('Cannot convert first argument to object');
  26020. }
  26021. var to = Object(target);
  26022. for (var i = 1; i < arguments.length; i++) {
  26023. var nextSource = arguments[i];
  26024. if (nextSource === undefined || nextSource === null) {
  26025. continue;
  26026. }
  26027. var keysArray = Object.keys(Object(nextSource));
  26028. for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) {
  26029. var nextKey = keysArray[nextIndex];
  26030. var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
  26031. if (desc !== undefined && desc.enumerable) {
  26032. to[nextKey] = nextSource[nextKey];
  26033. }
  26034. }
  26035. }
  26036. return to;
  26037. }
  26038. function polyfill() {
  26039. if (!Object.assign) {
  26040. Object.defineProperty(Object, 'assign', {
  26041. enumerable: false,
  26042. configurable: true,
  26043. writable: true,
  26044. value: assign
  26045. });
  26046. }
  26047. }
  26048. module.exports = {
  26049. assign: assign,
  26050. polyfill: polyfill
  26051. };
  26052. /***/ }),
  26053. /***/ "../../node_modules/events/events.js":
  26054. /*!*******************************************!*\
  26055. !*** ../../node_modules/events/events.js ***!
  26056. \*******************************************/
  26057. /***/ ((module) => {
  26058. "use strict";
  26059. // Copyright Joyent, Inc. and other Node contributors.
  26060. //
  26061. // Permission is hereby granted, free of charge, to any person obtaining a
  26062. // copy of this software and associated documentation files (the
  26063. // "Software"), to deal in the Software without restriction, including
  26064. // without limitation the rights to use, copy, modify, merge, publish,
  26065. // distribute, sublicense, and/or sell copies of the Software, and to permit
  26066. // persons to whom the Software is furnished to do so, subject to the
  26067. // following conditions:
  26068. //
  26069. // The above copyright notice and this permission notice shall be included
  26070. // in all copies or substantial portions of the Software.
  26071. //
  26072. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  26073. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26074. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  26075. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  26076. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  26077. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  26078. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  26079. var R = typeof Reflect === 'object' ? Reflect : null
  26080. var ReflectApply = R && typeof R.apply === 'function'
  26081. ? R.apply
  26082. : function ReflectApply(target, receiver, args) {
  26083. return Function.prototype.apply.call(target, receiver, args);
  26084. }
  26085. var ReflectOwnKeys
  26086. if (R && typeof R.ownKeys === 'function') {
  26087. ReflectOwnKeys = R.ownKeys
  26088. } else if (Object.getOwnPropertySymbols) {
  26089. ReflectOwnKeys = function ReflectOwnKeys(target) {
  26090. return Object.getOwnPropertyNames(target)
  26091. .concat(Object.getOwnPropertySymbols(target));
  26092. };
  26093. } else {
  26094. ReflectOwnKeys = function ReflectOwnKeys(target) {
  26095. return Object.getOwnPropertyNames(target);
  26096. };
  26097. }
  26098. function ProcessEmitWarning(warning) {
  26099. if (console && console.warn) console.warn(warning);
  26100. }
  26101. var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {
  26102. return value !== value;
  26103. }
  26104. function EventEmitter() {
  26105. EventEmitter.init.call(this);
  26106. }
  26107. module.exports = EventEmitter;
  26108. module.exports.once = once;
  26109. // Backwards-compat with node 0.10.x
  26110. EventEmitter.EventEmitter = EventEmitter;
  26111. EventEmitter.prototype._events = undefined;
  26112. EventEmitter.prototype._eventsCount = 0;
  26113. EventEmitter.prototype._maxListeners = undefined;
  26114. // By default EventEmitters will print a warning if more than 10 listeners are
  26115. // added to it. This is a useful default which helps finding memory leaks.
  26116. var defaultMaxListeners = 10;
  26117. function checkListener(listener) {
  26118. if (typeof listener !== 'function') {
  26119. throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
  26120. }
  26121. }
  26122. Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
  26123. enumerable: true,
  26124. get: function() {
  26125. return defaultMaxListeners;
  26126. },
  26127. set: function(arg) {
  26128. if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {
  26129. throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.');
  26130. }
  26131. defaultMaxListeners = arg;
  26132. }
  26133. });
  26134. EventEmitter.init = function() {
  26135. if (this._events === undefined ||
  26136. this._events === Object.getPrototypeOf(this)._events) {
  26137. this._events = Object.create(null);
  26138. this._eventsCount = 0;
  26139. }
  26140. this._maxListeners = this._maxListeners || undefined;
  26141. };
  26142. // Obviously not all Emitters should be limited to 10. This function allows
  26143. // that to be increased. Set to zero for unlimited.
  26144. EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
  26145. if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {
  26146. throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.');
  26147. }
  26148. this._maxListeners = n;
  26149. return this;
  26150. };
  26151. function _getMaxListeners(that) {
  26152. if (that._maxListeners === undefined)
  26153. return EventEmitter.defaultMaxListeners;
  26154. return that._maxListeners;
  26155. }
  26156. EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
  26157. return _getMaxListeners(this);
  26158. };
  26159. EventEmitter.prototype.emit = function emit(type) {
  26160. var args = [];
  26161. for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
  26162. var doError = (type === 'error');
  26163. var events = this._events;
  26164. if (events !== undefined)
  26165. doError = (doError && events.error === undefined);
  26166. else if (!doError)
  26167. return false;
  26168. // If there is no 'error' event listener then throw.
  26169. if (doError) {
  26170. var er;
  26171. if (args.length > 0)
  26172. er = args[0];
  26173. if (er instanceof Error) {
  26174. // Note: The comments on the `throw` lines are intentional, they show
  26175. // up in Node's output if this results in an unhandled exception.
  26176. throw er; // Unhandled 'error' event
  26177. }
  26178. // At least give some kind of context to the user
  26179. var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));
  26180. err.context = er;
  26181. throw err; // Unhandled 'error' event
  26182. }
  26183. var handler = events[type];
  26184. if (handler === undefined)
  26185. return false;
  26186. if (typeof handler === 'function') {
  26187. ReflectApply(handler, this, args);
  26188. } else {
  26189. var len = handler.length;
  26190. var listeners = arrayClone(handler, len);
  26191. for (var i = 0; i < len; ++i)
  26192. ReflectApply(listeners[i], this, args);
  26193. }
  26194. return true;
  26195. };
  26196. function _addListener(target, type, listener, prepend) {
  26197. var m;
  26198. var events;
  26199. var existing;
  26200. checkListener(listener);
  26201. events = target._events;
  26202. if (events === undefined) {
  26203. events = target._events = Object.create(null);
  26204. target._eventsCount = 0;
  26205. } else {
  26206. // To avoid recursion in the case that type === "newListener"! Before
  26207. // adding it to the listeners, first emit "newListener".
  26208. if (events.newListener !== undefined) {
  26209. target.emit('newListener', type,
  26210. listener.listener ? listener.listener : listener);
  26211. // Re-assign `events` because a newListener handler could have caused the
  26212. // this._events to be assigned to a new object
  26213. events = target._events;
  26214. }
  26215. existing = events[type];
  26216. }
  26217. if (existing === undefined) {
  26218. // Optimize the case of one listener. Don't need the extra array object.
  26219. existing = events[type] = listener;
  26220. ++target._eventsCount;
  26221. } else {
  26222. if (typeof existing === 'function') {
  26223. // Adding the second element, need to change to array.
  26224. existing = events[type] =
  26225. prepend ? [listener, existing] : [existing, listener];
  26226. // If we've already got an array, just append.
  26227. } else if (prepend) {
  26228. existing.unshift(listener);
  26229. } else {
  26230. existing.push(listener);
  26231. }
  26232. // Check for listener leak
  26233. m = _getMaxListeners(target);
  26234. if (m > 0 && existing.length > m && !existing.warned) {
  26235. existing.warned = true;
  26236. // No error code for this since it is a Warning
  26237. // eslint-disable-next-line no-restricted-syntax
  26238. var w = new Error('Possible EventEmitter memory leak detected. ' +
  26239. existing.length + ' ' + String(type) + ' listeners ' +
  26240. 'added. Use emitter.setMaxListeners() to ' +
  26241. 'increase limit');
  26242. w.name = 'MaxListenersExceededWarning';
  26243. w.emitter = target;
  26244. w.type = type;
  26245. w.count = existing.length;
  26246. ProcessEmitWarning(w);
  26247. }
  26248. }
  26249. return target;
  26250. }
  26251. EventEmitter.prototype.addListener = function addListener(type, listener) {
  26252. return _addListener(this, type, listener, false);
  26253. };
  26254. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  26255. EventEmitter.prototype.prependListener =
  26256. function prependListener(type, listener) {
  26257. return _addListener(this, type, listener, true);
  26258. };
  26259. function onceWrapper() {
  26260. if (!this.fired) {
  26261. this.target.removeListener(this.type, this.wrapFn);
  26262. this.fired = true;
  26263. if (arguments.length === 0)
  26264. return this.listener.call(this.target);
  26265. return this.listener.apply(this.target, arguments);
  26266. }
  26267. }
  26268. function _onceWrap(target, type, listener) {
  26269. var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
  26270. var wrapped = onceWrapper.bind(state);
  26271. wrapped.listener = listener;
  26272. state.wrapFn = wrapped;
  26273. return wrapped;
  26274. }
  26275. EventEmitter.prototype.once = function once(type, listener) {
  26276. checkListener(listener);
  26277. this.on(type, _onceWrap(this, type, listener));
  26278. return this;
  26279. };
  26280. EventEmitter.prototype.prependOnceListener =
  26281. function prependOnceListener(type, listener) {
  26282. checkListener(listener);
  26283. this.prependListener(type, _onceWrap(this, type, listener));
  26284. return this;
  26285. };
  26286. // Emits a 'removeListener' event if and only if the listener was removed.
  26287. EventEmitter.prototype.removeListener =
  26288. function removeListener(type, listener) {
  26289. var list, events, position, i, originalListener;
  26290. checkListener(listener);
  26291. events = this._events;
  26292. if (events === undefined)
  26293. return this;
  26294. list = events[type];
  26295. if (list === undefined)
  26296. return this;
  26297. if (list === listener || list.listener === listener) {
  26298. if (--this._eventsCount === 0)
  26299. this._events = Object.create(null);
  26300. else {
  26301. delete events[type];
  26302. if (events.removeListener)
  26303. this.emit('removeListener', type, list.listener || listener);
  26304. }
  26305. } else if (typeof list !== 'function') {
  26306. position = -1;
  26307. for (i = list.length - 1; i >= 0; i--) {
  26308. if (list[i] === listener || list[i].listener === listener) {
  26309. originalListener = list[i].listener;
  26310. position = i;
  26311. break;
  26312. }
  26313. }
  26314. if (position < 0)
  26315. return this;
  26316. if (position === 0)
  26317. list.shift();
  26318. else {
  26319. spliceOne(list, position);
  26320. }
  26321. if (list.length === 1)
  26322. events[type] = list[0];
  26323. if (events.removeListener !== undefined)
  26324. this.emit('removeListener', type, originalListener || listener);
  26325. }
  26326. return this;
  26327. };
  26328. EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
  26329. EventEmitter.prototype.removeAllListeners =
  26330. function removeAllListeners(type) {
  26331. var listeners, events, i;
  26332. events = this._events;
  26333. if (events === undefined)
  26334. return this;
  26335. // not listening for removeListener, no need to emit
  26336. if (events.removeListener === undefined) {
  26337. if (arguments.length === 0) {
  26338. this._events = Object.create(null);
  26339. this._eventsCount = 0;
  26340. } else if (events[type] !== undefined) {
  26341. if (--this._eventsCount === 0)
  26342. this._events = Object.create(null);
  26343. else
  26344. delete events[type];
  26345. }
  26346. return this;
  26347. }
  26348. // emit removeListener for all listeners on all events
  26349. if (arguments.length === 0) {
  26350. var keys = Object.keys(events);
  26351. var key;
  26352. for (i = 0; i < keys.length; ++i) {
  26353. key = keys[i];
  26354. if (key === 'removeListener') continue;
  26355. this.removeAllListeners(key);
  26356. }
  26357. this.removeAllListeners('removeListener');
  26358. this._events = Object.create(null);
  26359. this._eventsCount = 0;
  26360. return this;
  26361. }
  26362. listeners = events[type];
  26363. if (typeof listeners === 'function') {
  26364. this.removeListener(type, listeners);
  26365. } else if (listeners !== undefined) {
  26366. // LIFO order
  26367. for (i = listeners.length - 1; i >= 0; i--) {
  26368. this.removeListener(type, listeners[i]);
  26369. }
  26370. }
  26371. return this;
  26372. };
  26373. function _listeners(target, type, unwrap) {
  26374. var events = target._events;
  26375. if (events === undefined)
  26376. return [];
  26377. var evlistener = events[type];
  26378. if (evlistener === undefined)
  26379. return [];
  26380. if (typeof evlistener === 'function')
  26381. return unwrap ? [evlistener.listener || evlistener] : [evlistener];
  26382. return unwrap ?
  26383. unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
  26384. }
  26385. EventEmitter.prototype.listeners = function listeners(type) {
  26386. return _listeners(this, type, true);
  26387. };
  26388. EventEmitter.prototype.rawListeners = function rawListeners(type) {
  26389. return _listeners(this, type, false);
  26390. };
  26391. EventEmitter.listenerCount = function(emitter, type) {
  26392. if (typeof emitter.listenerCount === 'function') {
  26393. return emitter.listenerCount(type);
  26394. } else {
  26395. return listenerCount.call(emitter, type);
  26396. }
  26397. };
  26398. EventEmitter.prototype.listenerCount = listenerCount;
  26399. function listenerCount(type) {
  26400. var events = this._events;
  26401. if (events !== undefined) {
  26402. var evlistener = events[type];
  26403. if (typeof evlistener === 'function') {
  26404. return 1;
  26405. } else if (evlistener !== undefined) {
  26406. return evlistener.length;
  26407. }
  26408. }
  26409. return 0;
  26410. }
  26411. EventEmitter.prototype.eventNames = function eventNames() {
  26412. return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
  26413. };
  26414. function arrayClone(arr, n) {
  26415. var copy = new Array(n);
  26416. for (var i = 0; i < n; ++i)
  26417. copy[i] = arr[i];
  26418. return copy;
  26419. }
  26420. function spliceOne(list, index) {
  26421. for (; index + 1 < list.length; index++)
  26422. list[index] = list[index + 1];
  26423. list.pop();
  26424. }
  26425. function unwrapListeners(arr) {
  26426. var ret = new Array(arr.length);
  26427. for (var i = 0; i < ret.length; ++i) {
  26428. ret[i] = arr[i].listener || arr[i];
  26429. }
  26430. return ret;
  26431. }
  26432. function once(emitter, name) {
  26433. return new Promise(function (resolve, reject) {
  26434. function errorListener(err) {
  26435. emitter.removeListener(name, resolver);
  26436. reject(err);
  26437. }
  26438. function resolver() {
  26439. if (typeof emitter.removeListener === 'function') {
  26440. emitter.removeListener('error', errorListener);
  26441. }
  26442. resolve([].slice.call(arguments));
  26443. };
  26444. eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });
  26445. if (name !== 'error') {
  26446. addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });
  26447. }
  26448. });
  26449. }
  26450. function addErrorHandlerIfEventEmitter(emitter, handler, flags) {
  26451. if (typeof emitter.on === 'function') {
  26452. eventTargetAgnosticAddListener(emitter, 'error', handler, flags);
  26453. }
  26454. }
  26455. function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
  26456. if (typeof emitter.on === 'function') {
  26457. if (flags.once) {
  26458. emitter.once(name, listener);
  26459. } else {
  26460. emitter.on(name, listener);
  26461. }
  26462. } else if (typeof emitter.addEventListener === 'function') {
  26463. // EventTarget does not have `error` event semantics like Node
  26464. // EventEmitters, we do not listen for `error` events here.
  26465. emitter.addEventListener(name, function wrapListener(arg) {
  26466. // IE does not have builtin `{ once: true }` support so we
  26467. // have to do it manually.
  26468. if (flags.once) {
  26469. emitter.removeEventListener(name, wrapListener);
  26470. }
  26471. listener(arg);
  26472. });
  26473. } else {
  26474. throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter);
  26475. }
  26476. }
  26477. /***/ }),
  26478. /***/ "../../node_modules/evp_bytestokey/index.js":
  26479. /*!**************************************************!*\
  26480. !*** ../../node_modules/evp_bytestokey/index.js ***!
  26481. \**************************************************/
  26482. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  26483. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  26484. var MD5 = __webpack_require__(/*! md5.js */ "../../node_modules/md5.js/index.js")
  26485. /* eslint-disable camelcase */
  26486. function EVP_BytesToKey (password, salt, keyBits, ivLen) {
  26487. if (!Buffer.isBuffer(password)) password = Buffer.from(password, 'binary')
  26488. if (salt) {
  26489. if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, 'binary')
  26490. if (salt.length !== 8) throw new RangeError('salt should be Buffer with 8 byte length')
  26491. }
  26492. var keyLen = keyBits / 8
  26493. var key = Buffer.alloc(keyLen)
  26494. var iv = Buffer.alloc(ivLen || 0)
  26495. var tmp = Buffer.alloc(0)
  26496. while (keyLen > 0 || ivLen > 0) {
  26497. var hash = new MD5()
  26498. hash.update(tmp)
  26499. hash.update(password)
  26500. if (salt) hash.update(salt)
  26501. tmp = hash.digest()
  26502. var used = 0
  26503. if (keyLen > 0) {
  26504. var keyStart = key.length - keyLen
  26505. used = Math.min(keyLen, tmp.length)
  26506. tmp.copy(key, keyStart, 0, used)
  26507. keyLen -= used
  26508. }
  26509. if (used < tmp.length && ivLen > 0) {
  26510. var ivStart = iv.length - ivLen
  26511. var length = Math.min(ivLen, tmp.length - used)
  26512. tmp.copy(iv, ivStart, used, used + length)
  26513. ivLen -= length
  26514. }
  26515. }
  26516. tmp.fill(0)
  26517. return { key: key, iv: iv }
  26518. }
  26519. module.exports = EVP_BytesToKey
  26520. /***/ }),
  26521. /***/ "../../node_modules/for-each/index.js":
  26522. /*!********************************************!*\
  26523. !*** ../../node_modules/for-each/index.js ***!
  26524. \********************************************/
  26525. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  26526. "use strict";
  26527. var isCallable = __webpack_require__(/*! is-callable */ "../../node_modules/is-callable/index.js");
  26528. var toStr = Object.prototype.toString;
  26529. var hasOwnProperty = Object.prototype.hasOwnProperty;
  26530. var forEachArray = function forEachArray(array, iterator, receiver) {
  26531. for (var i = 0, len = array.length; i < len; i++) {
  26532. if (hasOwnProperty.call(array, i)) {
  26533. if (receiver == null) {
  26534. iterator(array[i], i, array);
  26535. } else {
  26536. iterator.call(receiver, array[i], i, array);
  26537. }
  26538. }
  26539. }
  26540. };
  26541. var forEachString = function forEachString(string, iterator, receiver) {
  26542. for (var i = 0, len = string.length; i < len; i++) {
  26543. // no such thing as a sparse string.
  26544. if (receiver == null) {
  26545. iterator(string.charAt(i), i, string);
  26546. } else {
  26547. iterator.call(receiver, string.charAt(i), i, string);
  26548. }
  26549. }
  26550. };
  26551. var forEachObject = function forEachObject(object, iterator, receiver) {
  26552. for (var k in object) {
  26553. if (hasOwnProperty.call(object, k)) {
  26554. if (receiver == null) {
  26555. iterator(object[k], k, object);
  26556. } else {
  26557. iterator.call(receiver, object[k], k, object);
  26558. }
  26559. }
  26560. }
  26561. };
  26562. var forEach = function forEach(list, iterator, thisArg) {
  26563. if (!isCallable(iterator)) {
  26564. throw new TypeError('iterator must be a function');
  26565. }
  26566. var receiver;
  26567. if (arguments.length >= 3) {
  26568. receiver = thisArg;
  26569. }
  26570. if (toStr.call(list) === '[object Array]') {
  26571. forEachArray(list, iterator, receiver);
  26572. } else if (typeof list === 'string') {
  26573. forEachString(list, iterator, receiver);
  26574. } else {
  26575. forEachObject(list, iterator, receiver);
  26576. }
  26577. };
  26578. module.exports = forEach;
  26579. /***/ }),
  26580. /***/ "../../node_modules/function-bind/implementation.js":
  26581. /*!**********************************************************!*\
  26582. !*** ../../node_modules/function-bind/implementation.js ***!
  26583. \**********************************************************/
  26584. /***/ ((module) => {
  26585. "use strict";
  26586. /* eslint no-invalid-this: 1 */
  26587. var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
  26588. var slice = Array.prototype.slice;
  26589. var toStr = Object.prototype.toString;
  26590. var funcType = '[object Function]';
  26591. module.exports = function bind(that) {
  26592. var target = this;
  26593. if (typeof target !== 'function' || toStr.call(target) !== funcType) {
  26594. throw new TypeError(ERROR_MESSAGE + target);
  26595. }
  26596. var args = slice.call(arguments, 1);
  26597. var bound;
  26598. var binder = function () {
  26599. if (this instanceof bound) {
  26600. var result = target.apply(
  26601. this,
  26602. args.concat(slice.call(arguments))
  26603. );
  26604. if (Object(result) === result) {
  26605. return result;
  26606. }
  26607. return this;
  26608. } else {
  26609. return target.apply(
  26610. that,
  26611. args.concat(slice.call(arguments))
  26612. );
  26613. }
  26614. };
  26615. var boundLength = Math.max(0, target.length - args.length);
  26616. var boundArgs = [];
  26617. for (var i = 0; i < boundLength; i++) {
  26618. boundArgs.push('$' + i);
  26619. }
  26620. bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
  26621. if (target.prototype) {
  26622. var Empty = function Empty() {};
  26623. Empty.prototype = target.prototype;
  26624. bound.prototype = new Empty();
  26625. Empty.prototype = null;
  26626. }
  26627. return bound;
  26628. };
  26629. /***/ }),
  26630. /***/ "../../node_modules/function-bind/index.js":
  26631. /*!*************************************************!*\
  26632. !*** ../../node_modules/function-bind/index.js ***!
  26633. \*************************************************/
  26634. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  26635. "use strict";
  26636. var implementation = __webpack_require__(/*! ./implementation */ "../../node_modules/function-bind/implementation.js");
  26637. module.exports = Function.prototype.bind || implementation;
  26638. /***/ }),
  26639. /***/ "../../node_modules/get-intrinsic/index.js":
  26640. /*!*************************************************!*\
  26641. !*** ../../node_modules/get-intrinsic/index.js ***!
  26642. \*************************************************/
  26643. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  26644. "use strict";
  26645. var undefined;
  26646. var $SyntaxError = SyntaxError;
  26647. var $Function = Function;
  26648. var $TypeError = TypeError;
  26649. // eslint-disable-next-line consistent-return
  26650. var getEvalledConstructor = function (expressionSyntax) {
  26651. try {
  26652. return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')();
  26653. } catch (e) {}
  26654. };
  26655. var $gOPD = Object.getOwnPropertyDescriptor;
  26656. if ($gOPD) {
  26657. try {
  26658. $gOPD({}, '');
  26659. } catch (e) {
  26660. $gOPD = null; // this is IE 8, which has a broken gOPD
  26661. }
  26662. }
  26663. var throwTypeError = function () {
  26664. throw new $TypeError();
  26665. };
  26666. var ThrowTypeError = $gOPD
  26667. ? (function () {
  26668. try {
  26669. // eslint-disable-next-line no-unused-expressions, no-caller, no-restricted-properties
  26670. arguments.callee; // IE 8 does not throw here
  26671. return throwTypeError;
  26672. } catch (calleeThrows) {
  26673. try {
  26674. // IE 8 throws on Object.getOwnPropertyDescriptor(arguments, '')
  26675. return $gOPD(arguments, 'callee').get;
  26676. } catch (gOPDthrows) {
  26677. return throwTypeError;
  26678. }
  26679. }
  26680. }())
  26681. : throwTypeError;
  26682. var hasSymbols = __webpack_require__(/*! has-symbols */ "../../node_modules/has-symbols/index.js")();
  26683. var getProto = Object.getPrototypeOf || function (x) { return x.__proto__; }; // eslint-disable-line no-proto
  26684. var needsEval = {};
  26685. var TypedArray = typeof Uint8Array === 'undefined' ? undefined : getProto(Uint8Array);
  26686. var INTRINSICS = {
  26687. '%AggregateError%': typeof AggregateError === 'undefined' ? undefined : AggregateError,
  26688. '%Array%': Array,
  26689. '%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined : ArrayBuffer,
  26690. '%ArrayIteratorPrototype%': hasSymbols ? getProto([][Symbol.iterator]()) : undefined,
  26691. '%AsyncFromSyncIteratorPrototype%': undefined,
  26692. '%AsyncFunction%': needsEval,
  26693. '%AsyncGenerator%': needsEval,
  26694. '%AsyncGeneratorFunction%': needsEval,
  26695. '%AsyncIteratorPrototype%': needsEval,
  26696. '%Atomics%': typeof Atomics === 'undefined' ? undefined : Atomics,
  26697. '%BigInt%': typeof BigInt === 'undefined' ? undefined : BigInt,
  26698. '%BigInt64Array%': typeof BigInt64Array === 'undefined' ? undefined : BigInt64Array,
  26699. '%BigUint64Array%': typeof BigUint64Array === 'undefined' ? undefined : BigUint64Array,
  26700. '%Boolean%': Boolean,
  26701. '%DataView%': typeof DataView === 'undefined' ? undefined : DataView,
  26702. '%Date%': Date,
  26703. '%decodeURI%': decodeURI,
  26704. '%decodeURIComponent%': decodeURIComponent,
  26705. '%encodeURI%': encodeURI,
  26706. '%encodeURIComponent%': encodeURIComponent,
  26707. '%Error%': Error,
  26708. '%eval%': eval, // eslint-disable-line no-eval
  26709. '%EvalError%': EvalError,
  26710. '%Float32Array%': typeof Float32Array === 'undefined' ? undefined : Float32Array,
  26711. '%Float64Array%': typeof Float64Array === 'undefined' ? undefined : Float64Array,
  26712. '%FinalizationRegistry%': typeof FinalizationRegistry === 'undefined' ? undefined : FinalizationRegistry,
  26713. '%Function%': $Function,
  26714. '%GeneratorFunction%': needsEval,
  26715. '%Int8Array%': typeof Int8Array === 'undefined' ? undefined : Int8Array,
  26716. '%Int16Array%': typeof Int16Array === 'undefined' ? undefined : Int16Array,
  26717. '%Int32Array%': typeof Int32Array === 'undefined' ? undefined : Int32Array,
  26718. '%isFinite%': isFinite,
  26719. '%isNaN%': isNaN,
  26720. '%IteratorPrototype%': hasSymbols ? getProto(getProto([][Symbol.iterator]())) : undefined,
  26721. '%JSON%': typeof JSON === 'object' ? JSON : undefined,
  26722. '%Map%': typeof Map === 'undefined' ? undefined : Map,
  26723. '%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols ? undefined : getProto(new Map()[Symbol.iterator]()),
  26724. '%Math%': Math,
  26725. '%Number%': Number,
  26726. '%Object%': Object,
  26727. '%parseFloat%': parseFloat,
  26728. '%parseInt%': parseInt,
  26729. '%Promise%': typeof Promise === 'undefined' ? undefined : Promise,
  26730. '%Proxy%': typeof Proxy === 'undefined' ? undefined : Proxy,
  26731. '%RangeError%': RangeError,
  26732. '%ReferenceError%': ReferenceError,
  26733. '%Reflect%': typeof Reflect === 'undefined' ? undefined : Reflect,
  26734. '%RegExp%': RegExp,
  26735. '%Set%': typeof Set === 'undefined' ? undefined : Set,
  26736. '%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols ? undefined : getProto(new Set()[Symbol.iterator]()),
  26737. '%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined : SharedArrayBuffer,
  26738. '%String%': String,
  26739. '%StringIteratorPrototype%': hasSymbols ? getProto(''[Symbol.iterator]()) : undefined,
  26740. '%Symbol%': hasSymbols ? Symbol : undefined,
  26741. '%SyntaxError%': $SyntaxError,
  26742. '%ThrowTypeError%': ThrowTypeError,
  26743. '%TypedArray%': TypedArray,
  26744. '%TypeError%': $TypeError,
  26745. '%Uint8Array%': typeof Uint8Array === 'undefined' ? undefined : Uint8Array,
  26746. '%Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined : Uint8ClampedArray,
  26747. '%Uint16Array%': typeof Uint16Array === 'undefined' ? undefined : Uint16Array,
  26748. '%Uint32Array%': typeof Uint32Array === 'undefined' ? undefined : Uint32Array,
  26749. '%URIError%': URIError,
  26750. '%WeakMap%': typeof WeakMap === 'undefined' ? undefined : WeakMap,
  26751. '%WeakRef%': typeof WeakRef === 'undefined' ? undefined : WeakRef,
  26752. '%WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet
  26753. };
  26754. try {
  26755. null.error; // eslint-disable-line no-unused-expressions
  26756. } catch (e) {
  26757. // https://github.com/tc39/proposal-shadowrealm/pull/384#issuecomment-1364264229
  26758. var errorProto = getProto(getProto(e));
  26759. INTRINSICS['%Error.prototype%'] = errorProto;
  26760. }
  26761. var doEval = function doEval(name) {
  26762. var value;
  26763. if (name === '%AsyncFunction%') {
  26764. value = getEvalledConstructor('async function () {}');
  26765. } else if (name === '%GeneratorFunction%') {
  26766. value = getEvalledConstructor('function* () {}');
  26767. } else if (name === '%AsyncGeneratorFunction%') {
  26768. value = getEvalledConstructor('async function* () {}');
  26769. } else if (name === '%AsyncGenerator%') {
  26770. var fn = doEval('%AsyncGeneratorFunction%');
  26771. if (fn) {
  26772. value = fn.prototype;
  26773. }
  26774. } else if (name === '%AsyncIteratorPrototype%') {
  26775. var gen = doEval('%AsyncGenerator%');
  26776. if (gen) {
  26777. value = getProto(gen.prototype);
  26778. }
  26779. }
  26780. INTRINSICS[name] = value;
  26781. return value;
  26782. };
  26783. var LEGACY_ALIASES = {
  26784. '%ArrayBufferPrototype%': ['ArrayBuffer', 'prototype'],
  26785. '%ArrayPrototype%': ['Array', 'prototype'],
  26786. '%ArrayProto_entries%': ['Array', 'prototype', 'entries'],
  26787. '%ArrayProto_forEach%': ['Array', 'prototype', 'forEach'],
  26788. '%ArrayProto_keys%': ['Array', 'prototype', 'keys'],
  26789. '%ArrayProto_values%': ['Array', 'prototype', 'values'],
  26790. '%AsyncFunctionPrototype%': ['AsyncFunction', 'prototype'],
  26791. '%AsyncGenerator%': ['AsyncGeneratorFunction', 'prototype'],
  26792. '%AsyncGeneratorPrototype%': ['AsyncGeneratorFunction', 'prototype', 'prototype'],
  26793. '%BooleanPrototype%': ['Boolean', 'prototype'],
  26794. '%DataViewPrototype%': ['DataView', 'prototype'],
  26795. '%DatePrototype%': ['Date', 'prototype'],
  26796. '%ErrorPrototype%': ['Error', 'prototype'],
  26797. '%EvalErrorPrototype%': ['EvalError', 'prototype'],
  26798. '%Float32ArrayPrototype%': ['Float32Array', 'prototype'],
  26799. '%Float64ArrayPrototype%': ['Float64Array', 'prototype'],
  26800. '%FunctionPrototype%': ['Function', 'prototype'],
  26801. '%Generator%': ['GeneratorFunction', 'prototype'],
  26802. '%GeneratorPrototype%': ['GeneratorFunction', 'prototype', 'prototype'],
  26803. '%Int8ArrayPrototype%': ['Int8Array', 'prototype'],
  26804. '%Int16ArrayPrototype%': ['Int16Array', 'prototype'],
  26805. '%Int32ArrayPrototype%': ['Int32Array', 'prototype'],
  26806. '%JSONParse%': ['JSON', 'parse'],
  26807. '%JSONStringify%': ['JSON', 'stringify'],
  26808. '%MapPrototype%': ['Map', 'prototype'],
  26809. '%NumberPrototype%': ['Number', 'prototype'],
  26810. '%ObjectPrototype%': ['Object', 'prototype'],
  26811. '%ObjProto_toString%': ['Object', 'prototype', 'toString'],
  26812. '%ObjProto_valueOf%': ['Object', 'prototype', 'valueOf'],
  26813. '%PromisePrototype%': ['Promise', 'prototype'],
  26814. '%PromiseProto_then%': ['Promise', 'prototype', 'then'],
  26815. '%Promise_all%': ['Promise', 'all'],
  26816. '%Promise_reject%': ['Promise', 'reject'],
  26817. '%Promise_resolve%': ['Promise', 'resolve'],
  26818. '%RangeErrorPrototype%': ['RangeError', 'prototype'],
  26819. '%ReferenceErrorPrototype%': ['ReferenceError', 'prototype'],
  26820. '%RegExpPrototype%': ['RegExp', 'prototype'],
  26821. '%SetPrototype%': ['Set', 'prototype'],
  26822. '%SharedArrayBufferPrototype%': ['SharedArrayBuffer', 'prototype'],
  26823. '%StringPrototype%': ['String', 'prototype'],
  26824. '%SymbolPrototype%': ['Symbol', 'prototype'],
  26825. '%SyntaxErrorPrototype%': ['SyntaxError', 'prototype'],
  26826. '%TypedArrayPrototype%': ['TypedArray', 'prototype'],
  26827. '%TypeErrorPrototype%': ['TypeError', 'prototype'],
  26828. '%Uint8ArrayPrototype%': ['Uint8Array', 'prototype'],
  26829. '%Uint8ClampedArrayPrototype%': ['Uint8ClampedArray', 'prototype'],
  26830. '%Uint16ArrayPrototype%': ['Uint16Array', 'prototype'],
  26831. '%Uint32ArrayPrototype%': ['Uint32Array', 'prototype'],
  26832. '%URIErrorPrototype%': ['URIError', 'prototype'],
  26833. '%WeakMapPrototype%': ['WeakMap', 'prototype'],
  26834. '%WeakSetPrototype%': ['WeakSet', 'prototype']
  26835. };
  26836. var bind = __webpack_require__(/*! function-bind */ "../../node_modules/function-bind/index.js");
  26837. var hasOwn = __webpack_require__(/*! has */ "../../node_modules/has/src/index.js");
  26838. var $concat = bind.call(Function.call, Array.prototype.concat);
  26839. var $spliceApply = bind.call(Function.apply, Array.prototype.splice);
  26840. var $replace = bind.call(Function.call, String.prototype.replace);
  26841. var $strSlice = bind.call(Function.call, String.prototype.slice);
  26842. var $exec = bind.call(Function.call, RegExp.prototype.exec);
  26843. /* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */
  26844. var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
  26845. var reEscapeChar = /\\(\\)?/g; /** Used to match backslashes in property paths. */
  26846. var stringToPath = function stringToPath(string) {
  26847. var first = $strSlice(string, 0, 1);
  26848. var last = $strSlice(string, -1);
  26849. if (first === '%' && last !== '%') {
  26850. throw new $SyntaxError('invalid intrinsic syntax, expected closing `%`');
  26851. } else if (last === '%' && first !== '%') {
  26852. throw new $SyntaxError('invalid intrinsic syntax, expected opening `%`');
  26853. }
  26854. var result = [];
  26855. $replace(string, rePropName, function (match, number, quote, subString) {
  26856. result[result.length] = quote ? $replace(subString, reEscapeChar, '$1') : number || match;
  26857. });
  26858. return result;
  26859. };
  26860. /* end adaptation */
  26861. var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
  26862. var intrinsicName = name;
  26863. var alias;
  26864. if (hasOwn(LEGACY_ALIASES, intrinsicName)) {
  26865. alias = LEGACY_ALIASES[intrinsicName];
  26866. intrinsicName = '%' + alias[0] + '%';
  26867. }
  26868. if (hasOwn(INTRINSICS, intrinsicName)) {
  26869. var value = INTRINSICS[intrinsicName];
  26870. if (value === needsEval) {
  26871. value = doEval(intrinsicName);
  26872. }
  26873. if (typeof value === 'undefined' && !allowMissing) {
  26874. throw new $TypeError('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
  26875. }
  26876. return {
  26877. alias: alias,
  26878. name: intrinsicName,
  26879. value: value
  26880. };
  26881. }
  26882. throw new $SyntaxError('intrinsic ' + name + ' does not exist!');
  26883. };
  26884. module.exports = function GetIntrinsic(name, allowMissing) {
  26885. if (typeof name !== 'string' || name.length === 0) {
  26886. throw new $TypeError('intrinsic name must be a non-empty string');
  26887. }
  26888. if (arguments.length > 1 && typeof allowMissing !== 'boolean') {
  26889. throw new $TypeError('"allowMissing" argument must be a boolean');
  26890. }
  26891. if ($exec(/^%?[^%]*%?$/, name) === null) {
  26892. throw new $SyntaxError('`%` may not be present anywhere but at the beginning and end of the intrinsic name');
  26893. }
  26894. var parts = stringToPath(name);
  26895. var intrinsicBaseName = parts.length > 0 ? parts[0] : '';
  26896. var intrinsic = getBaseIntrinsic('%' + intrinsicBaseName + '%', allowMissing);
  26897. var intrinsicRealName = intrinsic.name;
  26898. var value = intrinsic.value;
  26899. var skipFurtherCaching = false;
  26900. var alias = intrinsic.alias;
  26901. if (alias) {
  26902. intrinsicBaseName = alias[0];
  26903. $spliceApply(parts, $concat([0, 1], alias));
  26904. }
  26905. for (var i = 1, isOwn = true; i < parts.length; i += 1) {
  26906. var part = parts[i];
  26907. var first = $strSlice(part, 0, 1);
  26908. var last = $strSlice(part, -1);
  26909. if (
  26910. (
  26911. (first === '"' || first === "'" || first === '`')
  26912. || (last === '"' || last === "'" || last === '`')
  26913. )
  26914. && first !== last
  26915. ) {
  26916. throw new $SyntaxError('property names with quotes must have matching quotes');
  26917. }
  26918. if (part === 'constructor' || !isOwn) {
  26919. skipFurtherCaching = true;
  26920. }
  26921. intrinsicBaseName += '.' + part;
  26922. intrinsicRealName = '%' + intrinsicBaseName + '%';
  26923. if (hasOwn(INTRINSICS, intrinsicRealName)) {
  26924. value = INTRINSICS[intrinsicRealName];
  26925. } else if (value != null) {
  26926. if (!(part in value)) {
  26927. if (!allowMissing) {
  26928. throw new $TypeError('base intrinsic for ' + name + ' exists, but the property is not available.');
  26929. }
  26930. return void undefined;
  26931. }
  26932. if ($gOPD && (i + 1) >= parts.length) {
  26933. var desc = $gOPD(value, part);
  26934. isOwn = !!desc;
  26935. // By convention, when a data property is converted to an accessor
  26936. // property to emulate a data property that does not suffer from
  26937. // the override mistake, that accessor's getter is marked with
  26938. // an `originalValue` property. Here, when we detect this, we
  26939. // uphold the illusion by pretending to see that original data
  26940. // property, i.e., returning the value rather than the getter
  26941. // itself.
  26942. if (isOwn && 'get' in desc && !('originalValue' in desc.get)) {
  26943. value = desc.get;
  26944. } else {
  26945. value = value[part];
  26946. }
  26947. } else {
  26948. isOwn = hasOwn(value, part);
  26949. value = value[part];
  26950. }
  26951. if (isOwn && !skipFurtherCaching) {
  26952. INTRINSICS[intrinsicRealName] = value;
  26953. }
  26954. }
  26955. }
  26956. return value;
  26957. };
  26958. /***/ }),
  26959. /***/ "../../node_modules/gopd/index.js":
  26960. /*!****************************************!*\
  26961. !*** ../../node_modules/gopd/index.js ***!
  26962. \****************************************/
  26963. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  26964. "use strict";
  26965. var GetIntrinsic = __webpack_require__(/*! get-intrinsic */ "../../node_modules/get-intrinsic/index.js");
  26966. var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true);
  26967. if ($gOPD) {
  26968. try {
  26969. $gOPD([], 'length');
  26970. } catch (e) {
  26971. // IE 8 has a broken gOPD
  26972. $gOPD = null;
  26973. }
  26974. }
  26975. module.exports = $gOPD;
  26976. /***/ }),
  26977. /***/ "../../node_modules/has-property-descriptors/index.js":
  26978. /*!************************************************************!*\
  26979. !*** ../../node_modules/has-property-descriptors/index.js ***!
  26980. \************************************************************/
  26981. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  26982. "use strict";
  26983. var GetIntrinsic = __webpack_require__(/*! get-intrinsic */ "../../node_modules/get-intrinsic/index.js");
  26984. var $defineProperty = GetIntrinsic('%Object.defineProperty%', true);
  26985. var hasPropertyDescriptors = function hasPropertyDescriptors() {
  26986. if ($defineProperty) {
  26987. try {
  26988. $defineProperty({}, 'a', { value: 1 });
  26989. return true;
  26990. } catch (e) {
  26991. // IE 8 has a broken defineProperty
  26992. return false;
  26993. }
  26994. }
  26995. return false;
  26996. };
  26997. hasPropertyDescriptors.hasArrayLengthDefineBug = function hasArrayLengthDefineBug() {
  26998. // node v0.6 has a bug where array lengths can be Set but not Defined
  26999. if (!hasPropertyDescriptors()) {
  27000. return null;
  27001. }
  27002. try {
  27003. return $defineProperty([], 'length', { value: 1 }).length !== 1;
  27004. } catch (e) {
  27005. // In Firefox 4-22, defining length on an array throws an exception.
  27006. return true;
  27007. }
  27008. };
  27009. module.exports = hasPropertyDescriptors;
  27010. /***/ }),
  27011. /***/ "../../node_modules/has-symbols/index.js":
  27012. /*!***********************************************!*\
  27013. !*** ../../node_modules/has-symbols/index.js ***!
  27014. \***********************************************/
  27015. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  27016. "use strict";
  27017. var origSymbol = typeof Symbol !== 'undefined' && Symbol;
  27018. var hasSymbolSham = __webpack_require__(/*! ./shams */ "../../node_modules/has-symbols/shams.js");
  27019. module.exports = function hasNativeSymbols() {
  27020. if (typeof origSymbol !== 'function') { return false; }
  27021. if (typeof Symbol !== 'function') { return false; }
  27022. if (typeof origSymbol('foo') !== 'symbol') { return false; }
  27023. if (typeof Symbol('bar') !== 'symbol') { return false; }
  27024. return hasSymbolSham();
  27025. };
  27026. /***/ }),
  27027. /***/ "../../node_modules/has-symbols/shams.js":
  27028. /*!***********************************************!*\
  27029. !*** ../../node_modules/has-symbols/shams.js ***!
  27030. \***********************************************/
  27031. /***/ ((module) => {
  27032. "use strict";
  27033. /* eslint complexity: [2, 18], max-statements: [2, 33] */
  27034. module.exports = function hasSymbols() {
  27035. if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
  27036. if (typeof Symbol.iterator === 'symbol') { return true; }
  27037. var obj = {};
  27038. var sym = Symbol('test');
  27039. var symObj = Object(sym);
  27040. if (typeof sym === 'string') { return false; }
  27041. if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
  27042. if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }
  27043. // temp disabled per https://github.com/ljharb/object.assign/issues/17
  27044. // if (sym instanceof Symbol) { return false; }
  27045. // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
  27046. // if (!(symObj instanceof Symbol)) { return false; }
  27047. // if (typeof Symbol.prototype.toString !== 'function') { return false; }
  27048. // if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }
  27049. var symVal = 42;
  27050. obj[sym] = symVal;
  27051. for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax, no-unreachable-loop
  27052. if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
  27053. if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
  27054. var syms = Object.getOwnPropertySymbols(obj);
  27055. if (syms.length !== 1 || syms[0] !== sym) { return false; }
  27056. if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
  27057. if (typeof Object.getOwnPropertyDescriptor === 'function') {
  27058. var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
  27059. if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
  27060. }
  27061. return true;
  27062. };
  27063. /***/ }),
  27064. /***/ "../../node_modules/has-tostringtag/shams.js":
  27065. /*!***************************************************!*\
  27066. !*** ../../node_modules/has-tostringtag/shams.js ***!
  27067. \***************************************************/
  27068. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  27069. "use strict";
  27070. var hasSymbols = __webpack_require__(/*! has-symbols/shams */ "../../node_modules/has-symbols/shams.js");
  27071. module.exports = function hasToStringTagShams() {
  27072. return hasSymbols() && !!Symbol.toStringTag;
  27073. };
  27074. /***/ }),
  27075. /***/ "../../node_modules/has/src/index.js":
  27076. /*!*******************************************!*\
  27077. !*** ../../node_modules/has/src/index.js ***!
  27078. \*******************************************/
  27079. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  27080. "use strict";
  27081. var bind = __webpack_require__(/*! function-bind */ "../../node_modules/function-bind/index.js");
  27082. module.exports = bind.call(Function.call, Object.prototype.hasOwnProperty);
  27083. /***/ }),
  27084. /***/ "../../node_modules/hash-base/index.js":
  27085. /*!*********************************************!*\
  27086. !*** ../../node_modules/hash-base/index.js ***!
  27087. \*********************************************/
  27088. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  27089. "use strict";
  27090. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  27091. var Transform = (__webpack_require__(/*! readable-stream */ "../../node_modules/readable-stream/readable-browser.js").Transform)
  27092. var inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js")
  27093. function throwIfNotStringOrBuffer (val, prefix) {
  27094. if (!Buffer.isBuffer(val) && typeof val !== 'string') {
  27095. throw new TypeError(prefix + ' must be a string or a buffer')
  27096. }
  27097. }
  27098. function HashBase (blockSize) {
  27099. Transform.call(this)
  27100. this._block = Buffer.allocUnsafe(blockSize)
  27101. this._blockSize = blockSize
  27102. this._blockOffset = 0
  27103. this._length = [0, 0, 0, 0]
  27104. this._finalized = false
  27105. }
  27106. inherits(HashBase, Transform)
  27107. HashBase.prototype._transform = function (chunk, encoding, callback) {
  27108. var error = null
  27109. try {
  27110. this.update(chunk, encoding)
  27111. } catch (err) {
  27112. error = err
  27113. }
  27114. callback(error)
  27115. }
  27116. HashBase.prototype._flush = function (callback) {
  27117. var error = null
  27118. try {
  27119. this.push(this.digest())
  27120. } catch (err) {
  27121. error = err
  27122. }
  27123. callback(error)
  27124. }
  27125. HashBase.prototype.update = function (data, encoding) {
  27126. throwIfNotStringOrBuffer(data, 'Data')
  27127. if (this._finalized) throw new Error('Digest already called')
  27128. if (!Buffer.isBuffer(data)) data = Buffer.from(data, encoding)
  27129. // consume data
  27130. var block = this._block
  27131. var offset = 0
  27132. while (this._blockOffset + data.length - offset >= this._blockSize) {
  27133. for (var i = this._blockOffset; i < this._blockSize;) block[i++] = data[offset++]
  27134. this._update()
  27135. this._blockOffset = 0
  27136. }
  27137. while (offset < data.length) block[this._blockOffset++] = data[offset++]
  27138. // update length
  27139. for (var j = 0, carry = data.length * 8; carry > 0; ++j) {
  27140. this._length[j] += carry
  27141. carry = (this._length[j] / 0x0100000000) | 0
  27142. if (carry > 0) this._length[j] -= 0x0100000000 * carry
  27143. }
  27144. return this
  27145. }
  27146. HashBase.prototype._update = function () {
  27147. throw new Error('_update is not implemented')
  27148. }
  27149. HashBase.prototype.digest = function (encoding) {
  27150. if (this._finalized) throw new Error('Digest already called')
  27151. this._finalized = true
  27152. var digest = this._digest()
  27153. if (encoding !== undefined) digest = digest.toString(encoding)
  27154. // reset state
  27155. this._block.fill(0)
  27156. this._blockOffset = 0
  27157. for (var i = 0; i < 4; ++i) this._length[i] = 0
  27158. return digest
  27159. }
  27160. HashBase.prototype._digest = function () {
  27161. throw new Error('_digest is not implemented')
  27162. }
  27163. module.exports = HashBase
  27164. /***/ }),
  27165. /***/ "../../node_modules/hash.js/lib/hash.js":
  27166. /*!**********************************************!*\
  27167. !*** ../../node_modules/hash.js/lib/hash.js ***!
  27168. \**********************************************/
  27169. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  27170. var hash = exports;
  27171. hash.utils = __webpack_require__(/*! ./hash/utils */ "../../node_modules/hash.js/lib/hash/utils.js");
  27172. hash.common = __webpack_require__(/*! ./hash/common */ "../../node_modules/hash.js/lib/hash/common.js");
  27173. hash.sha = __webpack_require__(/*! ./hash/sha */ "../../node_modules/hash.js/lib/hash/sha.js");
  27174. hash.ripemd = __webpack_require__(/*! ./hash/ripemd */ "../../node_modules/hash.js/lib/hash/ripemd.js");
  27175. hash.hmac = __webpack_require__(/*! ./hash/hmac */ "../../node_modules/hash.js/lib/hash/hmac.js");
  27176. // Proxy hash functions to the main object
  27177. hash.sha1 = hash.sha.sha1;
  27178. hash.sha256 = hash.sha.sha256;
  27179. hash.sha224 = hash.sha.sha224;
  27180. hash.sha384 = hash.sha.sha384;
  27181. hash.sha512 = hash.sha.sha512;
  27182. hash.ripemd160 = hash.ripemd.ripemd160;
  27183. /***/ }),
  27184. /***/ "../../node_modules/hash.js/lib/hash/common.js":
  27185. /*!*****************************************************!*\
  27186. !*** ../../node_modules/hash.js/lib/hash/common.js ***!
  27187. \*****************************************************/
  27188. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  27189. "use strict";
  27190. var utils = __webpack_require__(/*! ./utils */ "../../node_modules/hash.js/lib/hash/utils.js");
  27191. var assert = __webpack_require__(/*! minimalistic-assert */ "../../node_modules/minimalistic-assert/index.js");
  27192. function BlockHash() {
  27193. this.pending = null;
  27194. this.pendingTotal = 0;
  27195. this.blockSize = this.constructor.blockSize;
  27196. this.outSize = this.constructor.outSize;
  27197. this.hmacStrength = this.constructor.hmacStrength;
  27198. this.padLength = this.constructor.padLength / 8;
  27199. this.endian = 'big';
  27200. this._delta8 = this.blockSize / 8;
  27201. this._delta32 = this.blockSize / 32;
  27202. }
  27203. exports.BlockHash = BlockHash;
  27204. BlockHash.prototype.update = function update(msg, enc) {
  27205. // Convert message to array, pad it, and join into 32bit blocks
  27206. msg = utils.toArray(msg, enc);
  27207. if (!this.pending)
  27208. this.pending = msg;
  27209. else
  27210. this.pending = this.pending.concat(msg);
  27211. this.pendingTotal += msg.length;
  27212. // Enough data, try updating
  27213. if (this.pending.length >= this._delta8) {
  27214. msg = this.pending;
  27215. // Process pending data in blocks
  27216. var r = msg.length % this._delta8;
  27217. this.pending = msg.slice(msg.length - r, msg.length);
  27218. if (this.pending.length === 0)
  27219. this.pending = null;
  27220. msg = utils.join32(msg, 0, msg.length - r, this.endian);
  27221. for (var i = 0; i < msg.length; i += this._delta32)
  27222. this._update(msg, i, i + this._delta32);
  27223. }
  27224. return this;
  27225. };
  27226. BlockHash.prototype.digest = function digest(enc) {
  27227. this.update(this._pad());
  27228. assert(this.pending === null);
  27229. return this._digest(enc);
  27230. };
  27231. BlockHash.prototype._pad = function pad() {
  27232. var len = this.pendingTotal;
  27233. var bytes = this._delta8;
  27234. var k = bytes - ((len + this.padLength) % bytes);
  27235. var res = new Array(k + this.padLength);
  27236. res[0] = 0x80;
  27237. for (var i = 1; i < k; i++)
  27238. res[i] = 0;
  27239. // Append length
  27240. len <<= 3;
  27241. if (this.endian === 'big') {
  27242. for (var t = 8; t < this.padLength; t++)
  27243. res[i++] = 0;
  27244. res[i++] = 0;
  27245. res[i++] = 0;
  27246. res[i++] = 0;
  27247. res[i++] = 0;
  27248. res[i++] = (len >>> 24) & 0xff;
  27249. res[i++] = (len >>> 16) & 0xff;
  27250. res[i++] = (len >>> 8) & 0xff;
  27251. res[i++] = len & 0xff;
  27252. } else {
  27253. res[i++] = len & 0xff;
  27254. res[i++] = (len >>> 8) & 0xff;
  27255. res[i++] = (len >>> 16) & 0xff;
  27256. res[i++] = (len >>> 24) & 0xff;
  27257. res[i++] = 0;
  27258. res[i++] = 0;
  27259. res[i++] = 0;
  27260. res[i++] = 0;
  27261. for (t = 8; t < this.padLength; t++)
  27262. res[i++] = 0;
  27263. }
  27264. return res;
  27265. };
  27266. /***/ }),
  27267. /***/ "../../node_modules/hash.js/lib/hash/hmac.js":
  27268. /*!***************************************************!*\
  27269. !*** ../../node_modules/hash.js/lib/hash/hmac.js ***!
  27270. \***************************************************/
  27271. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  27272. "use strict";
  27273. var utils = __webpack_require__(/*! ./utils */ "../../node_modules/hash.js/lib/hash/utils.js");
  27274. var assert = __webpack_require__(/*! minimalistic-assert */ "../../node_modules/minimalistic-assert/index.js");
  27275. function Hmac(hash, key, enc) {
  27276. if (!(this instanceof Hmac))
  27277. return new Hmac(hash, key, enc);
  27278. this.Hash = hash;
  27279. this.blockSize = hash.blockSize / 8;
  27280. this.outSize = hash.outSize / 8;
  27281. this.inner = null;
  27282. this.outer = null;
  27283. this._init(utils.toArray(key, enc));
  27284. }
  27285. module.exports = Hmac;
  27286. Hmac.prototype._init = function init(key) {
  27287. // Shorten key, if needed
  27288. if (key.length > this.blockSize)
  27289. key = new this.Hash().update(key).digest();
  27290. assert(key.length <= this.blockSize);
  27291. // Add padding to key
  27292. for (var i = key.length; i < this.blockSize; i++)
  27293. key.push(0);
  27294. for (i = 0; i < key.length; i++)
  27295. key[i] ^= 0x36;
  27296. this.inner = new this.Hash().update(key);
  27297. // 0x36 ^ 0x5c = 0x6a
  27298. for (i = 0; i < key.length; i++)
  27299. key[i] ^= 0x6a;
  27300. this.outer = new this.Hash().update(key);
  27301. };
  27302. Hmac.prototype.update = function update(msg, enc) {
  27303. this.inner.update(msg, enc);
  27304. return this;
  27305. };
  27306. Hmac.prototype.digest = function digest(enc) {
  27307. this.outer.update(this.inner.digest());
  27308. return this.outer.digest(enc);
  27309. };
  27310. /***/ }),
  27311. /***/ "../../node_modules/hash.js/lib/hash/ripemd.js":
  27312. /*!*****************************************************!*\
  27313. !*** ../../node_modules/hash.js/lib/hash/ripemd.js ***!
  27314. \*****************************************************/
  27315. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  27316. "use strict";
  27317. var utils = __webpack_require__(/*! ./utils */ "../../node_modules/hash.js/lib/hash/utils.js");
  27318. var common = __webpack_require__(/*! ./common */ "../../node_modules/hash.js/lib/hash/common.js");
  27319. var rotl32 = utils.rotl32;
  27320. var sum32 = utils.sum32;
  27321. var sum32_3 = utils.sum32_3;
  27322. var sum32_4 = utils.sum32_4;
  27323. var BlockHash = common.BlockHash;
  27324. function RIPEMD160() {
  27325. if (!(this instanceof RIPEMD160))
  27326. return new RIPEMD160();
  27327. BlockHash.call(this);
  27328. this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ];
  27329. this.endian = 'little';
  27330. }
  27331. utils.inherits(RIPEMD160, BlockHash);
  27332. exports.ripemd160 = RIPEMD160;
  27333. RIPEMD160.blockSize = 512;
  27334. RIPEMD160.outSize = 160;
  27335. RIPEMD160.hmacStrength = 192;
  27336. RIPEMD160.padLength = 64;
  27337. RIPEMD160.prototype._update = function update(msg, start) {
  27338. var A = this.h[0];
  27339. var B = this.h[1];
  27340. var C = this.h[2];
  27341. var D = this.h[3];
  27342. var E = this.h[4];
  27343. var Ah = A;
  27344. var Bh = B;
  27345. var Ch = C;
  27346. var Dh = D;
  27347. var Eh = E;
  27348. for (var j = 0; j < 80; j++) {
  27349. var T = sum32(
  27350. rotl32(
  27351. sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)),
  27352. s[j]),
  27353. E);
  27354. A = E;
  27355. E = D;
  27356. D = rotl32(C, 10);
  27357. C = B;
  27358. B = T;
  27359. T = sum32(
  27360. rotl32(
  27361. sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)),
  27362. sh[j]),
  27363. Eh);
  27364. Ah = Eh;
  27365. Eh = Dh;
  27366. Dh = rotl32(Ch, 10);
  27367. Ch = Bh;
  27368. Bh = T;
  27369. }
  27370. T = sum32_3(this.h[1], C, Dh);
  27371. this.h[1] = sum32_3(this.h[2], D, Eh);
  27372. this.h[2] = sum32_3(this.h[3], E, Ah);
  27373. this.h[3] = sum32_3(this.h[4], A, Bh);
  27374. this.h[4] = sum32_3(this.h[0], B, Ch);
  27375. this.h[0] = T;
  27376. };
  27377. RIPEMD160.prototype._digest = function digest(enc) {
  27378. if (enc === 'hex')
  27379. return utils.toHex32(this.h, 'little');
  27380. else
  27381. return utils.split32(this.h, 'little');
  27382. };
  27383. function f(j, x, y, z) {
  27384. if (j <= 15)
  27385. return x ^ y ^ z;
  27386. else if (j <= 31)
  27387. return (x & y) | ((~x) & z);
  27388. else if (j <= 47)
  27389. return (x | (~y)) ^ z;
  27390. else if (j <= 63)
  27391. return (x & z) | (y & (~z));
  27392. else
  27393. return x ^ (y | (~z));
  27394. }
  27395. function K(j) {
  27396. if (j <= 15)
  27397. return 0x00000000;
  27398. else if (j <= 31)
  27399. return 0x5a827999;
  27400. else if (j <= 47)
  27401. return 0x6ed9eba1;
  27402. else if (j <= 63)
  27403. return 0x8f1bbcdc;
  27404. else
  27405. return 0xa953fd4e;
  27406. }
  27407. function Kh(j) {
  27408. if (j <= 15)
  27409. return 0x50a28be6;
  27410. else if (j <= 31)
  27411. return 0x5c4dd124;
  27412. else if (j <= 47)
  27413. return 0x6d703ef3;
  27414. else if (j <= 63)
  27415. return 0x7a6d76e9;
  27416. else
  27417. return 0x00000000;
  27418. }
  27419. var r = [
  27420. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
  27421. 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
  27422. 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
  27423. 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
  27424. 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
  27425. ];
  27426. var rh = [
  27427. 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
  27428. 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
  27429. 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
  27430. 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
  27431. 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
  27432. ];
  27433. var s = [
  27434. 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
  27435. 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
  27436. 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
  27437. 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
  27438. 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
  27439. ];
  27440. var sh = [
  27441. 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
  27442. 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
  27443. 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
  27444. 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
  27445. 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
  27446. ];
  27447. /***/ }),
  27448. /***/ "../../node_modules/hash.js/lib/hash/sha.js":
  27449. /*!**************************************************!*\
  27450. !*** ../../node_modules/hash.js/lib/hash/sha.js ***!
  27451. \**************************************************/
  27452. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  27453. "use strict";
  27454. exports.sha1 = __webpack_require__(/*! ./sha/1 */ "../../node_modules/hash.js/lib/hash/sha/1.js");
  27455. exports.sha224 = __webpack_require__(/*! ./sha/224 */ "../../node_modules/hash.js/lib/hash/sha/224.js");
  27456. exports.sha256 = __webpack_require__(/*! ./sha/256 */ "../../node_modules/hash.js/lib/hash/sha/256.js");
  27457. exports.sha384 = __webpack_require__(/*! ./sha/384 */ "../../node_modules/hash.js/lib/hash/sha/384.js");
  27458. exports.sha512 = __webpack_require__(/*! ./sha/512 */ "../../node_modules/hash.js/lib/hash/sha/512.js");
  27459. /***/ }),
  27460. /***/ "../../node_modules/hash.js/lib/hash/sha/1.js":
  27461. /*!****************************************************!*\
  27462. !*** ../../node_modules/hash.js/lib/hash/sha/1.js ***!
  27463. \****************************************************/
  27464. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  27465. "use strict";
  27466. var utils = __webpack_require__(/*! ../utils */ "../../node_modules/hash.js/lib/hash/utils.js");
  27467. var common = __webpack_require__(/*! ../common */ "../../node_modules/hash.js/lib/hash/common.js");
  27468. var shaCommon = __webpack_require__(/*! ./common */ "../../node_modules/hash.js/lib/hash/sha/common.js");
  27469. var rotl32 = utils.rotl32;
  27470. var sum32 = utils.sum32;
  27471. var sum32_5 = utils.sum32_5;
  27472. var ft_1 = shaCommon.ft_1;
  27473. var BlockHash = common.BlockHash;
  27474. var sha1_K = [
  27475. 0x5A827999, 0x6ED9EBA1,
  27476. 0x8F1BBCDC, 0xCA62C1D6
  27477. ];
  27478. function SHA1() {
  27479. if (!(this instanceof SHA1))
  27480. return new SHA1();
  27481. BlockHash.call(this);
  27482. this.h = [
  27483. 0x67452301, 0xefcdab89, 0x98badcfe,
  27484. 0x10325476, 0xc3d2e1f0 ];
  27485. this.W = new Array(80);
  27486. }
  27487. utils.inherits(SHA1, BlockHash);
  27488. module.exports = SHA1;
  27489. SHA1.blockSize = 512;
  27490. SHA1.outSize = 160;
  27491. SHA1.hmacStrength = 80;
  27492. SHA1.padLength = 64;
  27493. SHA1.prototype._update = function _update(msg, start) {
  27494. var W = this.W;
  27495. for (var i = 0; i < 16; i++)
  27496. W[i] = msg[start + i];
  27497. for(; i < W.length; i++)
  27498. W[i] = rotl32(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);
  27499. var a = this.h[0];
  27500. var b = this.h[1];
  27501. var c = this.h[2];
  27502. var d = this.h[3];
  27503. var e = this.h[4];
  27504. for (i = 0; i < W.length; i++) {
  27505. var s = ~~(i / 20);
  27506. var t = sum32_5(rotl32(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]);
  27507. e = d;
  27508. d = c;
  27509. c = rotl32(b, 30);
  27510. b = a;
  27511. a = t;
  27512. }
  27513. this.h[0] = sum32(this.h[0], a);
  27514. this.h[1] = sum32(this.h[1], b);
  27515. this.h[2] = sum32(this.h[2], c);
  27516. this.h[3] = sum32(this.h[3], d);
  27517. this.h[4] = sum32(this.h[4], e);
  27518. };
  27519. SHA1.prototype._digest = function digest(enc) {
  27520. if (enc === 'hex')
  27521. return utils.toHex32(this.h, 'big');
  27522. else
  27523. return utils.split32(this.h, 'big');
  27524. };
  27525. /***/ }),
  27526. /***/ "../../node_modules/hash.js/lib/hash/sha/224.js":
  27527. /*!******************************************************!*\
  27528. !*** ../../node_modules/hash.js/lib/hash/sha/224.js ***!
  27529. \******************************************************/
  27530. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  27531. "use strict";
  27532. var utils = __webpack_require__(/*! ../utils */ "../../node_modules/hash.js/lib/hash/utils.js");
  27533. var SHA256 = __webpack_require__(/*! ./256 */ "../../node_modules/hash.js/lib/hash/sha/256.js");
  27534. function SHA224() {
  27535. if (!(this instanceof SHA224))
  27536. return new SHA224();
  27537. SHA256.call(this);
  27538. this.h = [
  27539. 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
  27540. 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ];
  27541. }
  27542. utils.inherits(SHA224, SHA256);
  27543. module.exports = SHA224;
  27544. SHA224.blockSize = 512;
  27545. SHA224.outSize = 224;
  27546. SHA224.hmacStrength = 192;
  27547. SHA224.padLength = 64;
  27548. SHA224.prototype._digest = function digest(enc) {
  27549. // Just truncate output
  27550. if (enc === 'hex')
  27551. return utils.toHex32(this.h.slice(0, 7), 'big');
  27552. else
  27553. return utils.split32(this.h.slice(0, 7), 'big');
  27554. };
  27555. /***/ }),
  27556. /***/ "../../node_modules/hash.js/lib/hash/sha/256.js":
  27557. /*!******************************************************!*\
  27558. !*** ../../node_modules/hash.js/lib/hash/sha/256.js ***!
  27559. \******************************************************/
  27560. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  27561. "use strict";
  27562. var utils = __webpack_require__(/*! ../utils */ "../../node_modules/hash.js/lib/hash/utils.js");
  27563. var common = __webpack_require__(/*! ../common */ "../../node_modules/hash.js/lib/hash/common.js");
  27564. var shaCommon = __webpack_require__(/*! ./common */ "../../node_modules/hash.js/lib/hash/sha/common.js");
  27565. var assert = __webpack_require__(/*! minimalistic-assert */ "../../node_modules/minimalistic-assert/index.js");
  27566. var sum32 = utils.sum32;
  27567. var sum32_4 = utils.sum32_4;
  27568. var sum32_5 = utils.sum32_5;
  27569. var ch32 = shaCommon.ch32;
  27570. var maj32 = shaCommon.maj32;
  27571. var s0_256 = shaCommon.s0_256;
  27572. var s1_256 = shaCommon.s1_256;
  27573. var g0_256 = shaCommon.g0_256;
  27574. var g1_256 = shaCommon.g1_256;
  27575. var BlockHash = common.BlockHash;
  27576. var sha256_K = [
  27577. 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
  27578. 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
  27579. 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
  27580. 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
  27581. 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
  27582. 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
  27583. 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
  27584. 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
  27585. 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
  27586. 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
  27587. 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
  27588. 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
  27589. 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
  27590. 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
  27591. 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
  27592. 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
  27593. ];
  27594. function SHA256() {
  27595. if (!(this instanceof SHA256))
  27596. return new SHA256();
  27597. BlockHash.call(this);
  27598. this.h = [
  27599. 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
  27600. 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
  27601. ];
  27602. this.k = sha256_K;
  27603. this.W = new Array(64);
  27604. }
  27605. utils.inherits(SHA256, BlockHash);
  27606. module.exports = SHA256;
  27607. SHA256.blockSize = 512;
  27608. SHA256.outSize = 256;
  27609. SHA256.hmacStrength = 192;
  27610. SHA256.padLength = 64;
  27611. SHA256.prototype._update = function _update(msg, start) {
  27612. var W = this.W;
  27613. for (var i = 0; i < 16; i++)
  27614. W[i] = msg[start + i];
  27615. for (; i < W.length; i++)
  27616. W[i] = sum32_4(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]);
  27617. var a = this.h[0];
  27618. var b = this.h[1];
  27619. var c = this.h[2];
  27620. var d = this.h[3];
  27621. var e = this.h[4];
  27622. var f = this.h[5];
  27623. var g = this.h[6];
  27624. var h = this.h[7];
  27625. assert(this.k.length === W.length);
  27626. for (i = 0; i < W.length; i++) {
  27627. var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]);
  27628. var T2 = sum32(s0_256(a), maj32(a, b, c));
  27629. h = g;
  27630. g = f;
  27631. f = e;
  27632. e = sum32(d, T1);
  27633. d = c;
  27634. c = b;
  27635. b = a;
  27636. a = sum32(T1, T2);
  27637. }
  27638. this.h[0] = sum32(this.h[0], a);
  27639. this.h[1] = sum32(this.h[1], b);
  27640. this.h[2] = sum32(this.h[2], c);
  27641. this.h[3] = sum32(this.h[3], d);
  27642. this.h[4] = sum32(this.h[4], e);
  27643. this.h[5] = sum32(this.h[5], f);
  27644. this.h[6] = sum32(this.h[6], g);
  27645. this.h[7] = sum32(this.h[7], h);
  27646. };
  27647. SHA256.prototype._digest = function digest(enc) {
  27648. if (enc === 'hex')
  27649. return utils.toHex32(this.h, 'big');
  27650. else
  27651. return utils.split32(this.h, 'big');
  27652. };
  27653. /***/ }),
  27654. /***/ "../../node_modules/hash.js/lib/hash/sha/384.js":
  27655. /*!******************************************************!*\
  27656. !*** ../../node_modules/hash.js/lib/hash/sha/384.js ***!
  27657. \******************************************************/
  27658. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  27659. "use strict";
  27660. var utils = __webpack_require__(/*! ../utils */ "../../node_modules/hash.js/lib/hash/utils.js");
  27661. var SHA512 = __webpack_require__(/*! ./512 */ "../../node_modules/hash.js/lib/hash/sha/512.js");
  27662. function SHA384() {
  27663. if (!(this instanceof SHA384))
  27664. return new SHA384();
  27665. SHA512.call(this);
  27666. this.h = [
  27667. 0xcbbb9d5d, 0xc1059ed8,
  27668. 0x629a292a, 0x367cd507,
  27669. 0x9159015a, 0x3070dd17,
  27670. 0x152fecd8, 0xf70e5939,
  27671. 0x67332667, 0xffc00b31,
  27672. 0x8eb44a87, 0x68581511,
  27673. 0xdb0c2e0d, 0x64f98fa7,
  27674. 0x47b5481d, 0xbefa4fa4 ];
  27675. }
  27676. utils.inherits(SHA384, SHA512);
  27677. module.exports = SHA384;
  27678. SHA384.blockSize = 1024;
  27679. SHA384.outSize = 384;
  27680. SHA384.hmacStrength = 192;
  27681. SHA384.padLength = 128;
  27682. SHA384.prototype._digest = function digest(enc) {
  27683. if (enc === 'hex')
  27684. return utils.toHex32(this.h.slice(0, 12), 'big');
  27685. else
  27686. return utils.split32(this.h.slice(0, 12), 'big');
  27687. };
  27688. /***/ }),
  27689. /***/ "../../node_modules/hash.js/lib/hash/sha/512.js":
  27690. /*!******************************************************!*\
  27691. !*** ../../node_modules/hash.js/lib/hash/sha/512.js ***!
  27692. \******************************************************/
  27693. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  27694. "use strict";
  27695. var utils = __webpack_require__(/*! ../utils */ "../../node_modules/hash.js/lib/hash/utils.js");
  27696. var common = __webpack_require__(/*! ../common */ "../../node_modules/hash.js/lib/hash/common.js");
  27697. var assert = __webpack_require__(/*! minimalistic-assert */ "../../node_modules/minimalistic-assert/index.js");
  27698. var rotr64_hi = utils.rotr64_hi;
  27699. var rotr64_lo = utils.rotr64_lo;
  27700. var shr64_hi = utils.shr64_hi;
  27701. var shr64_lo = utils.shr64_lo;
  27702. var sum64 = utils.sum64;
  27703. var sum64_hi = utils.sum64_hi;
  27704. var sum64_lo = utils.sum64_lo;
  27705. var sum64_4_hi = utils.sum64_4_hi;
  27706. var sum64_4_lo = utils.sum64_4_lo;
  27707. var sum64_5_hi = utils.sum64_5_hi;
  27708. var sum64_5_lo = utils.sum64_5_lo;
  27709. var BlockHash = common.BlockHash;
  27710. var sha512_K = [
  27711. 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
  27712. 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
  27713. 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
  27714. 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
  27715. 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
  27716. 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
  27717. 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
  27718. 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
  27719. 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
  27720. 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
  27721. 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
  27722. 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
  27723. 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
  27724. 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
  27725. 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
  27726. 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
  27727. 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
  27728. 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
  27729. 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
  27730. 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
  27731. 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
  27732. 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
  27733. 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
  27734. 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
  27735. 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
  27736. 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
  27737. 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
  27738. 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
  27739. 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
  27740. 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
  27741. 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
  27742. 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
  27743. 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
  27744. 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
  27745. 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
  27746. 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
  27747. 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
  27748. 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
  27749. 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
  27750. 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
  27751. ];
  27752. function SHA512() {
  27753. if (!(this instanceof SHA512))
  27754. return new SHA512();
  27755. BlockHash.call(this);
  27756. this.h = [
  27757. 0x6a09e667, 0xf3bcc908,
  27758. 0xbb67ae85, 0x84caa73b,
  27759. 0x3c6ef372, 0xfe94f82b,
  27760. 0xa54ff53a, 0x5f1d36f1,
  27761. 0x510e527f, 0xade682d1,
  27762. 0x9b05688c, 0x2b3e6c1f,
  27763. 0x1f83d9ab, 0xfb41bd6b,
  27764. 0x5be0cd19, 0x137e2179 ];
  27765. this.k = sha512_K;
  27766. this.W = new Array(160);
  27767. }
  27768. utils.inherits(SHA512, BlockHash);
  27769. module.exports = SHA512;
  27770. SHA512.blockSize = 1024;
  27771. SHA512.outSize = 512;
  27772. SHA512.hmacStrength = 192;
  27773. SHA512.padLength = 128;
  27774. SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) {
  27775. var W = this.W;
  27776. // 32 x 32bit words
  27777. for (var i = 0; i < 32; i++)
  27778. W[i] = msg[start + i];
  27779. for (; i < W.length; i += 2) {
  27780. var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 2
  27781. var c0_lo = g1_512_lo(W[i - 4], W[i - 3]);
  27782. var c1_hi = W[i - 14]; // i - 7
  27783. var c1_lo = W[i - 13];
  27784. var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 15
  27785. var c2_lo = g0_512_lo(W[i - 30], W[i - 29]);
  27786. var c3_hi = W[i - 32]; // i - 16
  27787. var c3_lo = W[i - 31];
  27788. W[i] = sum64_4_hi(
  27789. c0_hi, c0_lo,
  27790. c1_hi, c1_lo,
  27791. c2_hi, c2_lo,
  27792. c3_hi, c3_lo);
  27793. W[i + 1] = sum64_4_lo(
  27794. c0_hi, c0_lo,
  27795. c1_hi, c1_lo,
  27796. c2_hi, c2_lo,
  27797. c3_hi, c3_lo);
  27798. }
  27799. };
  27800. SHA512.prototype._update = function _update(msg, start) {
  27801. this._prepareBlock(msg, start);
  27802. var W = this.W;
  27803. var ah = this.h[0];
  27804. var al = this.h[1];
  27805. var bh = this.h[2];
  27806. var bl = this.h[3];
  27807. var ch = this.h[4];
  27808. var cl = this.h[5];
  27809. var dh = this.h[6];
  27810. var dl = this.h[7];
  27811. var eh = this.h[8];
  27812. var el = this.h[9];
  27813. var fh = this.h[10];
  27814. var fl = this.h[11];
  27815. var gh = this.h[12];
  27816. var gl = this.h[13];
  27817. var hh = this.h[14];
  27818. var hl = this.h[15];
  27819. assert(this.k.length === W.length);
  27820. for (var i = 0; i < W.length; i += 2) {
  27821. var c0_hi = hh;
  27822. var c0_lo = hl;
  27823. var c1_hi = s1_512_hi(eh, el);
  27824. var c1_lo = s1_512_lo(eh, el);
  27825. var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl);
  27826. var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl);
  27827. var c3_hi = this.k[i];
  27828. var c3_lo = this.k[i + 1];
  27829. var c4_hi = W[i];
  27830. var c4_lo = W[i + 1];
  27831. var T1_hi = sum64_5_hi(
  27832. c0_hi, c0_lo,
  27833. c1_hi, c1_lo,
  27834. c2_hi, c2_lo,
  27835. c3_hi, c3_lo,
  27836. c4_hi, c4_lo);
  27837. var T1_lo = sum64_5_lo(
  27838. c0_hi, c0_lo,
  27839. c1_hi, c1_lo,
  27840. c2_hi, c2_lo,
  27841. c3_hi, c3_lo,
  27842. c4_hi, c4_lo);
  27843. c0_hi = s0_512_hi(ah, al);
  27844. c0_lo = s0_512_lo(ah, al);
  27845. c1_hi = maj64_hi(ah, al, bh, bl, ch, cl);
  27846. c1_lo = maj64_lo(ah, al, bh, bl, ch, cl);
  27847. var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo);
  27848. var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo);
  27849. hh = gh;
  27850. hl = gl;
  27851. gh = fh;
  27852. gl = fl;
  27853. fh = eh;
  27854. fl = el;
  27855. eh = sum64_hi(dh, dl, T1_hi, T1_lo);
  27856. el = sum64_lo(dl, dl, T1_hi, T1_lo);
  27857. dh = ch;
  27858. dl = cl;
  27859. ch = bh;
  27860. cl = bl;
  27861. bh = ah;
  27862. bl = al;
  27863. ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo);
  27864. al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo);
  27865. }
  27866. sum64(this.h, 0, ah, al);
  27867. sum64(this.h, 2, bh, bl);
  27868. sum64(this.h, 4, ch, cl);
  27869. sum64(this.h, 6, dh, dl);
  27870. sum64(this.h, 8, eh, el);
  27871. sum64(this.h, 10, fh, fl);
  27872. sum64(this.h, 12, gh, gl);
  27873. sum64(this.h, 14, hh, hl);
  27874. };
  27875. SHA512.prototype._digest = function digest(enc) {
  27876. if (enc === 'hex')
  27877. return utils.toHex32(this.h, 'big');
  27878. else
  27879. return utils.split32(this.h, 'big');
  27880. };
  27881. function ch64_hi(xh, xl, yh, yl, zh) {
  27882. var r = (xh & yh) ^ ((~xh) & zh);
  27883. if (r < 0)
  27884. r += 0x100000000;
  27885. return r;
  27886. }
  27887. function ch64_lo(xh, xl, yh, yl, zh, zl) {
  27888. var r = (xl & yl) ^ ((~xl) & zl);
  27889. if (r < 0)
  27890. r += 0x100000000;
  27891. return r;
  27892. }
  27893. function maj64_hi(xh, xl, yh, yl, zh) {
  27894. var r = (xh & yh) ^ (xh & zh) ^ (yh & zh);
  27895. if (r < 0)
  27896. r += 0x100000000;
  27897. return r;
  27898. }
  27899. function maj64_lo(xh, xl, yh, yl, zh, zl) {
  27900. var r = (xl & yl) ^ (xl & zl) ^ (yl & zl);
  27901. if (r < 0)
  27902. r += 0x100000000;
  27903. return r;
  27904. }
  27905. function s0_512_hi(xh, xl) {
  27906. var c0_hi = rotr64_hi(xh, xl, 28);
  27907. var c1_hi = rotr64_hi(xl, xh, 2); // 34
  27908. var c2_hi = rotr64_hi(xl, xh, 7); // 39
  27909. var r = c0_hi ^ c1_hi ^ c2_hi;
  27910. if (r < 0)
  27911. r += 0x100000000;
  27912. return r;
  27913. }
  27914. function s0_512_lo(xh, xl) {
  27915. var c0_lo = rotr64_lo(xh, xl, 28);
  27916. var c1_lo = rotr64_lo(xl, xh, 2); // 34
  27917. var c2_lo = rotr64_lo(xl, xh, 7); // 39
  27918. var r = c0_lo ^ c1_lo ^ c2_lo;
  27919. if (r < 0)
  27920. r += 0x100000000;
  27921. return r;
  27922. }
  27923. function s1_512_hi(xh, xl) {
  27924. var c0_hi = rotr64_hi(xh, xl, 14);
  27925. var c1_hi = rotr64_hi(xh, xl, 18);
  27926. var c2_hi = rotr64_hi(xl, xh, 9); // 41
  27927. var r = c0_hi ^ c1_hi ^ c2_hi;
  27928. if (r < 0)
  27929. r += 0x100000000;
  27930. return r;
  27931. }
  27932. function s1_512_lo(xh, xl) {
  27933. var c0_lo = rotr64_lo(xh, xl, 14);
  27934. var c1_lo = rotr64_lo(xh, xl, 18);
  27935. var c2_lo = rotr64_lo(xl, xh, 9); // 41
  27936. var r = c0_lo ^ c1_lo ^ c2_lo;
  27937. if (r < 0)
  27938. r += 0x100000000;
  27939. return r;
  27940. }
  27941. function g0_512_hi(xh, xl) {
  27942. var c0_hi = rotr64_hi(xh, xl, 1);
  27943. var c1_hi = rotr64_hi(xh, xl, 8);
  27944. var c2_hi = shr64_hi(xh, xl, 7);
  27945. var r = c0_hi ^ c1_hi ^ c2_hi;
  27946. if (r < 0)
  27947. r += 0x100000000;
  27948. return r;
  27949. }
  27950. function g0_512_lo(xh, xl) {
  27951. var c0_lo = rotr64_lo(xh, xl, 1);
  27952. var c1_lo = rotr64_lo(xh, xl, 8);
  27953. var c2_lo = shr64_lo(xh, xl, 7);
  27954. var r = c0_lo ^ c1_lo ^ c2_lo;
  27955. if (r < 0)
  27956. r += 0x100000000;
  27957. return r;
  27958. }
  27959. function g1_512_hi(xh, xl) {
  27960. var c0_hi = rotr64_hi(xh, xl, 19);
  27961. var c1_hi = rotr64_hi(xl, xh, 29); // 61
  27962. var c2_hi = shr64_hi(xh, xl, 6);
  27963. var r = c0_hi ^ c1_hi ^ c2_hi;
  27964. if (r < 0)
  27965. r += 0x100000000;
  27966. return r;
  27967. }
  27968. function g1_512_lo(xh, xl) {
  27969. var c0_lo = rotr64_lo(xh, xl, 19);
  27970. var c1_lo = rotr64_lo(xl, xh, 29); // 61
  27971. var c2_lo = shr64_lo(xh, xl, 6);
  27972. var r = c0_lo ^ c1_lo ^ c2_lo;
  27973. if (r < 0)
  27974. r += 0x100000000;
  27975. return r;
  27976. }
  27977. /***/ }),
  27978. /***/ "../../node_modules/hash.js/lib/hash/sha/common.js":
  27979. /*!*********************************************************!*\
  27980. !*** ../../node_modules/hash.js/lib/hash/sha/common.js ***!
  27981. \*********************************************************/
  27982. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  27983. "use strict";
  27984. var utils = __webpack_require__(/*! ../utils */ "../../node_modules/hash.js/lib/hash/utils.js");
  27985. var rotr32 = utils.rotr32;
  27986. function ft_1(s, x, y, z) {
  27987. if (s === 0)
  27988. return ch32(x, y, z);
  27989. if (s === 1 || s === 3)
  27990. return p32(x, y, z);
  27991. if (s === 2)
  27992. return maj32(x, y, z);
  27993. }
  27994. exports.ft_1 = ft_1;
  27995. function ch32(x, y, z) {
  27996. return (x & y) ^ ((~x) & z);
  27997. }
  27998. exports.ch32 = ch32;
  27999. function maj32(x, y, z) {
  28000. return (x & y) ^ (x & z) ^ (y & z);
  28001. }
  28002. exports.maj32 = maj32;
  28003. function p32(x, y, z) {
  28004. return x ^ y ^ z;
  28005. }
  28006. exports.p32 = p32;
  28007. function s0_256(x) {
  28008. return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
  28009. }
  28010. exports.s0_256 = s0_256;
  28011. function s1_256(x) {
  28012. return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);
  28013. }
  28014. exports.s1_256 = s1_256;
  28015. function g0_256(x) {
  28016. return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3);
  28017. }
  28018. exports.g0_256 = g0_256;
  28019. function g1_256(x) {
  28020. return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10);
  28021. }
  28022. exports.g1_256 = g1_256;
  28023. /***/ }),
  28024. /***/ "../../node_modules/hash.js/lib/hash/utils.js":
  28025. /*!****************************************************!*\
  28026. !*** ../../node_modules/hash.js/lib/hash/utils.js ***!
  28027. \****************************************************/
  28028. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  28029. "use strict";
  28030. var assert = __webpack_require__(/*! minimalistic-assert */ "../../node_modules/minimalistic-assert/index.js");
  28031. var inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js");
  28032. exports.inherits = inherits;
  28033. function isSurrogatePair(msg, i) {
  28034. if ((msg.charCodeAt(i) & 0xFC00) !== 0xD800) {
  28035. return false;
  28036. }
  28037. if (i < 0 || i + 1 >= msg.length) {
  28038. return false;
  28039. }
  28040. return (msg.charCodeAt(i + 1) & 0xFC00) === 0xDC00;
  28041. }
  28042. function toArray(msg, enc) {
  28043. if (Array.isArray(msg))
  28044. return msg.slice();
  28045. if (!msg)
  28046. return [];
  28047. var res = [];
  28048. if (typeof msg === 'string') {
  28049. if (!enc) {
  28050. // Inspired by stringToUtf8ByteArray() in closure-library by Google
  28051. // https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt.js#L117-L143
  28052. // Apache License 2.0
  28053. // https://github.com/google/closure-library/blob/master/LICENSE
  28054. var p = 0;
  28055. for (var i = 0; i < msg.length; i++) {
  28056. var c = msg.charCodeAt(i);
  28057. if (c < 128) {
  28058. res[p++] = c;
  28059. } else if (c < 2048) {
  28060. res[p++] = (c >> 6) | 192;
  28061. res[p++] = (c & 63) | 128;
  28062. } else if (isSurrogatePair(msg, i)) {
  28063. c = 0x10000 + ((c & 0x03FF) << 10) + (msg.charCodeAt(++i) & 0x03FF);
  28064. res[p++] = (c >> 18) | 240;
  28065. res[p++] = ((c >> 12) & 63) | 128;
  28066. res[p++] = ((c >> 6) & 63) | 128;
  28067. res[p++] = (c & 63) | 128;
  28068. } else {
  28069. res[p++] = (c >> 12) | 224;
  28070. res[p++] = ((c >> 6) & 63) | 128;
  28071. res[p++] = (c & 63) | 128;
  28072. }
  28073. }
  28074. } else if (enc === 'hex') {
  28075. msg = msg.replace(/[^a-z0-9]+/ig, '');
  28076. if (msg.length % 2 !== 0)
  28077. msg = '0' + msg;
  28078. for (i = 0; i < msg.length; i += 2)
  28079. res.push(parseInt(msg[i] + msg[i + 1], 16));
  28080. }
  28081. } else {
  28082. for (i = 0; i < msg.length; i++)
  28083. res[i] = msg[i] | 0;
  28084. }
  28085. return res;
  28086. }
  28087. exports.toArray = toArray;
  28088. function toHex(msg) {
  28089. var res = '';
  28090. for (var i = 0; i < msg.length; i++)
  28091. res += zero2(msg[i].toString(16));
  28092. return res;
  28093. }
  28094. exports.toHex = toHex;
  28095. function htonl(w) {
  28096. var res = (w >>> 24) |
  28097. ((w >>> 8) & 0xff00) |
  28098. ((w << 8) & 0xff0000) |
  28099. ((w & 0xff) << 24);
  28100. return res >>> 0;
  28101. }
  28102. exports.htonl = htonl;
  28103. function toHex32(msg, endian) {
  28104. var res = '';
  28105. for (var i = 0; i < msg.length; i++) {
  28106. var w = msg[i];
  28107. if (endian === 'little')
  28108. w = htonl(w);
  28109. res += zero8(w.toString(16));
  28110. }
  28111. return res;
  28112. }
  28113. exports.toHex32 = toHex32;
  28114. function zero2(word) {
  28115. if (word.length === 1)
  28116. return '0' + word;
  28117. else
  28118. return word;
  28119. }
  28120. exports.zero2 = zero2;
  28121. function zero8(word) {
  28122. if (word.length === 7)
  28123. return '0' + word;
  28124. else if (word.length === 6)
  28125. return '00' + word;
  28126. else if (word.length === 5)
  28127. return '000' + word;
  28128. else if (word.length === 4)
  28129. return '0000' + word;
  28130. else if (word.length === 3)
  28131. return '00000' + word;
  28132. else if (word.length === 2)
  28133. return '000000' + word;
  28134. else if (word.length === 1)
  28135. return '0000000' + word;
  28136. else
  28137. return word;
  28138. }
  28139. exports.zero8 = zero8;
  28140. function join32(msg, start, end, endian) {
  28141. var len = end - start;
  28142. assert(len % 4 === 0);
  28143. var res = new Array(len / 4);
  28144. for (var i = 0, k = start; i < res.length; i++, k += 4) {
  28145. var w;
  28146. if (endian === 'big')
  28147. w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];
  28148. else
  28149. w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];
  28150. res[i] = w >>> 0;
  28151. }
  28152. return res;
  28153. }
  28154. exports.join32 = join32;
  28155. function split32(msg, endian) {
  28156. var res = new Array(msg.length * 4);
  28157. for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
  28158. var m = msg[i];
  28159. if (endian === 'big') {
  28160. res[k] = m >>> 24;
  28161. res[k + 1] = (m >>> 16) & 0xff;
  28162. res[k + 2] = (m >>> 8) & 0xff;
  28163. res[k + 3] = m & 0xff;
  28164. } else {
  28165. res[k + 3] = m >>> 24;
  28166. res[k + 2] = (m >>> 16) & 0xff;
  28167. res[k + 1] = (m >>> 8) & 0xff;
  28168. res[k] = m & 0xff;
  28169. }
  28170. }
  28171. return res;
  28172. }
  28173. exports.split32 = split32;
  28174. function rotr32(w, b) {
  28175. return (w >>> b) | (w << (32 - b));
  28176. }
  28177. exports.rotr32 = rotr32;
  28178. function rotl32(w, b) {
  28179. return (w << b) | (w >>> (32 - b));
  28180. }
  28181. exports.rotl32 = rotl32;
  28182. function sum32(a, b) {
  28183. return (a + b) >>> 0;
  28184. }
  28185. exports.sum32 = sum32;
  28186. function sum32_3(a, b, c) {
  28187. return (a + b + c) >>> 0;
  28188. }
  28189. exports.sum32_3 = sum32_3;
  28190. function sum32_4(a, b, c, d) {
  28191. return (a + b + c + d) >>> 0;
  28192. }
  28193. exports.sum32_4 = sum32_4;
  28194. function sum32_5(a, b, c, d, e) {
  28195. return (a + b + c + d + e) >>> 0;
  28196. }
  28197. exports.sum32_5 = sum32_5;
  28198. function sum64(buf, pos, ah, al) {
  28199. var bh = buf[pos];
  28200. var bl = buf[pos + 1];
  28201. var lo = (al + bl) >>> 0;
  28202. var hi = (lo < al ? 1 : 0) + ah + bh;
  28203. buf[pos] = hi >>> 0;
  28204. buf[pos + 1] = lo;
  28205. }
  28206. exports.sum64 = sum64;
  28207. function sum64_hi(ah, al, bh, bl) {
  28208. var lo = (al + bl) >>> 0;
  28209. var hi = (lo < al ? 1 : 0) + ah + bh;
  28210. return hi >>> 0;
  28211. }
  28212. exports.sum64_hi = sum64_hi;
  28213. function sum64_lo(ah, al, bh, bl) {
  28214. var lo = al + bl;
  28215. return lo >>> 0;
  28216. }
  28217. exports.sum64_lo = sum64_lo;
  28218. function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) {
  28219. var carry = 0;
  28220. var lo = al;
  28221. lo = (lo + bl) >>> 0;
  28222. carry += lo < al ? 1 : 0;
  28223. lo = (lo + cl) >>> 0;
  28224. carry += lo < cl ? 1 : 0;
  28225. lo = (lo + dl) >>> 0;
  28226. carry += lo < dl ? 1 : 0;
  28227. var hi = ah + bh + ch + dh + carry;
  28228. return hi >>> 0;
  28229. }
  28230. exports.sum64_4_hi = sum64_4_hi;
  28231. function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) {
  28232. var lo = al + bl + cl + dl;
  28233. return lo >>> 0;
  28234. }
  28235. exports.sum64_4_lo = sum64_4_lo;
  28236. function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
  28237. var carry = 0;
  28238. var lo = al;
  28239. lo = (lo + bl) >>> 0;
  28240. carry += lo < al ? 1 : 0;
  28241. lo = (lo + cl) >>> 0;
  28242. carry += lo < cl ? 1 : 0;
  28243. lo = (lo + dl) >>> 0;
  28244. carry += lo < dl ? 1 : 0;
  28245. lo = (lo + el) >>> 0;
  28246. carry += lo < el ? 1 : 0;
  28247. var hi = ah + bh + ch + dh + eh + carry;
  28248. return hi >>> 0;
  28249. }
  28250. exports.sum64_5_hi = sum64_5_hi;
  28251. function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
  28252. var lo = al + bl + cl + dl + el;
  28253. return lo >>> 0;
  28254. }
  28255. exports.sum64_5_lo = sum64_5_lo;
  28256. function rotr64_hi(ah, al, num) {
  28257. var r = (al << (32 - num)) | (ah >>> num);
  28258. return r >>> 0;
  28259. }
  28260. exports.rotr64_hi = rotr64_hi;
  28261. function rotr64_lo(ah, al, num) {
  28262. var r = (ah << (32 - num)) | (al >>> num);
  28263. return r >>> 0;
  28264. }
  28265. exports.rotr64_lo = rotr64_lo;
  28266. function shr64_hi(ah, al, num) {
  28267. return ah >>> num;
  28268. }
  28269. exports.shr64_hi = shr64_hi;
  28270. function shr64_lo(ah, al, num) {
  28271. var r = (ah << (32 - num)) | (al >>> num);
  28272. return r >>> 0;
  28273. }
  28274. exports.shr64_lo = shr64_lo;
  28275. /***/ }),
  28276. /***/ "../../node_modules/hmac-drbg/lib/hmac-drbg.js":
  28277. /*!*****************************************************!*\
  28278. !*** ../../node_modules/hmac-drbg/lib/hmac-drbg.js ***!
  28279. \*****************************************************/
  28280. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  28281. "use strict";
  28282. var hash = __webpack_require__(/*! hash.js */ "../../node_modules/hash.js/lib/hash.js");
  28283. var utils = __webpack_require__(/*! minimalistic-crypto-utils */ "../../node_modules/minimalistic-crypto-utils/lib/utils.js");
  28284. var assert = __webpack_require__(/*! minimalistic-assert */ "../../node_modules/minimalistic-assert/index.js");
  28285. function HmacDRBG(options) {
  28286. if (!(this instanceof HmacDRBG))
  28287. return new HmacDRBG(options);
  28288. this.hash = options.hash;
  28289. this.predResist = !!options.predResist;
  28290. this.outLen = this.hash.outSize;
  28291. this.minEntropy = options.minEntropy || this.hash.hmacStrength;
  28292. this._reseed = null;
  28293. this.reseedInterval = null;
  28294. this.K = null;
  28295. this.V = null;
  28296. var entropy = utils.toArray(options.entropy, options.entropyEnc || 'hex');
  28297. var nonce = utils.toArray(options.nonce, options.nonceEnc || 'hex');
  28298. var pers = utils.toArray(options.pers, options.persEnc || 'hex');
  28299. assert(entropy.length >= (this.minEntropy / 8),
  28300. 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
  28301. this._init(entropy, nonce, pers);
  28302. }
  28303. module.exports = HmacDRBG;
  28304. HmacDRBG.prototype._init = function init(entropy, nonce, pers) {
  28305. var seed = entropy.concat(nonce).concat(pers);
  28306. this.K = new Array(this.outLen / 8);
  28307. this.V = new Array(this.outLen / 8);
  28308. for (var i = 0; i < this.V.length; i++) {
  28309. this.K[i] = 0x00;
  28310. this.V[i] = 0x01;
  28311. }
  28312. this._update(seed);
  28313. this._reseed = 1;
  28314. this.reseedInterval = 0x1000000000000; // 2^48
  28315. };
  28316. HmacDRBG.prototype._hmac = function hmac() {
  28317. return new hash.hmac(this.hash, this.K);
  28318. };
  28319. HmacDRBG.prototype._update = function update(seed) {
  28320. var kmac = this._hmac()
  28321. .update(this.V)
  28322. .update([ 0x00 ]);
  28323. if (seed)
  28324. kmac = kmac.update(seed);
  28325. this.K = kmac.digest();
  28326. this.V = this._hmac().update(this.V).digest();
  28327. if (!seed)
  28328. return;
  28329. this.K = this._hmac()
  28330. .update(this.V)
  28331. .update([ 0x01 ])
  28332. .update(seed)
  28333. .digest();
  28334. this.V = this._hmac().update(this.V).digest();
  28335. };
  28336. HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc) {
  28337. // Optional entropy enc
  28338. if (typeof entropyEnc !== 'string') {
  28339. addEnc = add;
  28340. add = entropyEnc;
  28341. entropyEnc = null;
  28342. }
  28343. entropy = utils.toArray(entropy, entropyEnc);
  28344. add = utils.toArray(add, addEnc);
  28345. assert(entropy.length >= (this.minEntropy / 8),
  28346. 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
  28347. this._update(entropy.concat(add || []));
  28348. this._reseed = 1;
  28349. };
  28350. HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) {
  28351. if (this._reseed > this.reseedInterval)
  28352. throw new Error('Reseed is required');
  28353. // Optional encoding
  28354. if (typeof enc !== 'string') {
  28355. addEnc = add;
  28356. add = enc;
  28357. enc = null;
  28358. }
  28359. // Optional additional data
  28360. if (add) {
  28361. add = utils.toArray(add, addEnc || 'hex');
  28362. this._update(add);
  28363. }
  28364. var temp = [];
  28365. while (temp.length < len) {
  28366. this.V = this._hmac().update(this.V).digest();
  28367. temp = temp.concat(this.V);
  28368. }
  28369. var res = temp.slice(0, len);
  28370. this._update(add);
  28371. this._reseed++;
  28372. return utils.encode(res, enc);
  28373. };
  28374. /***/ }),
  28375. /***/ "../../node_modules/https-browserify/index.js":
  28376. /*!****************************************************!*\
  28377. !*** ../../node_modules/https-browserify/index.js ***!
  28378. \****************************************************/
  28379. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  28380. var http = __webpack_require__(/*! http */ "../../node_modules/stream-http/index.js")
  28381. var url = __webpack_require__(/*! url */ "../../node_modules/url/url.js")
  28382. var https = module.exports
  28383. for (var key in http) {
  28384. if (http.hasOwnProperty(key)) https[key] = http[key]
  28385. }
  28386. https.request = function (params, cb) {
  28387. params = validateParams(params)
  28388. return http.request.call(this, params, cb)
  28389. }
  28390. https.get = function (params, cb) {
  28391. params = validateParams(params)
  28392. return http.get.call(this, params, cb)
  28393. }
  28394. function validateParams (params) {
  28395. if (typeof params === 'string') {
  28396. params = url.parse(params)
  28397. }
  28398. if (!params.protocol) {
  28399. params.protocol = 'https:'
  28400. }
  28401. if (params.protocol !== 'https:') {
  28402. throw new Error('Protocol "' + params.protocol + '" not supported. Expected "https:"')
  28403. }
  28404. return params
  28405. }
  28406. /***/ }),
  28407. /***/ "../../node_modules/ieee754/index.js":
  28408. /*!*******************************************!*\
  28409. !*** ../../node_modules/ieee754/index.js ***!
  28410. \*******************************************/
  28411. /***/ ((__unused_webpack_module, exports) => {
  28412. /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
  28413. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  28414. var e, m
  28415. var eLen = (nBytes * 8) - mLen - 1
  28416. var eMax = (1 << eLen) - 1
  28417. var eBias = eMax >> 1
  28418. var nBits = -7
  28419. var i = isLE ? (nBytes - 1) : 0
  28420. var d = isLE ? -1 : 1
  28421. var s = buffer[offset + i]
  28422. i += d
  28423. e = s & ((1 << (-nBits)) - 1)
  28424. s >>= (-nBits)
  28425. nBits += eLen
  28426. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  28427. m = e & ((1 << (-nBits)) - 1)
  28428. e >>= (-nBits)
  28429. nBits += mLen
  28430. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  28431. if (e === 0) {
  28432. e = 1 - eBias
  28433. } else if (e === eMax) {
  28434. return m ? NaN : ((s ? -1 : 1) * Infinity)
  28435. } else {
  28436. m = m + Math.pow(2, mLen)
  28437. e = e - eBias
  28438. }
  28439. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  28440. }
  28441. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  28442. var e, m, c
  28443. var eLen = (nBytes * 8) - mLen - 1
  28444. var eMax = (1 << eLen) - 1
  28445. var eBias = eMax >> 1
  28446. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  28447. var i = isLE ? 0 : (nBytes - 1)
  28448. var d = isLE ? 1 : -1
  28449. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  28450. value = Math.abs(value)
  28451. if (isNaN(value) || value === Infinity) {
  28452. m = isNaN(value) ? 1 : 0
  28453. e = eMax
  28454. } else {
  28455. e = Math.floor(Math.log(value) / Math.LN2)
  28456. if (value * (c = Math.pow(2, -e)) < 1) {
  28457. e--
  28458. c *= 2
  28459. }
  28460. if (e + eBias >= 1) {
  28461. value += rt / c
  28462. } else {
  28463. value += rt * Math.pow(2, 1 - eBias)
  28464. }
  28465. if (value * c >= 2) {
  28466. e++
  28467. c /= 2
  28468. }
  28469. if (e + eBias >= eMax) {
  28470. m = 0
  28471. e = eMax
  28472. } else if (e + eBias >= 1) {
  28473. m = ((value * c) - 1) * Math.pow(2, mLen)
  28474. e = e + eBias
  28475. } else {
  28476. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  28477. e = 0
  28478. }
  28479. }
  28480. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  28481. e = (e << mLen) | m
  28482. eLen += mLen
  28483. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  28484. buffer[offset + i - d] |= s * 128
  28485. }
  28486. /***/ }),
  28487. /***/ "../../node_modules/inherits/inherits_browser.js":
  28488. /*!*******************************************************!*\
  28489. !*** ../../node_modules/inherits/inherits_browser.js ***!
  28490. \*******************************************************/
  28491. /***/ ((module) => {
  28492. if (typeof Object.create === 'function') {
  28493. // implementation from standard node.js 'util' module
  28494. module.exports = function inherits(ctor, superCtor) {
  28495. if (superCtor) {
  28496. ctor.super_ = superCtor
  28497. ctor.prototype = Object.create(superCtor.prototype, {
  28498. constructor: {
  28499. value: ctor,
  28500. enumerable: false,
  28501. writable: true,
  28502. configurable: true
  28503. }
  28504. })
  28505. }
  28506. };
  28507. } else {
  28508. // old school shim for old browsers
  28509. module.exports = function inherits(ctor, superCtor) {
  28510. if (superCtor) {
  28511. ctor.super_ = superCtor
  28512. var TempCtor = function () {}
  28513. TempCtor.prototype = superCtor.prototype
  28514. ctor.prototype = new TempCtor()
  28515. ctor.prototype.constructor = ctor
  28516. }
  28517. }
  28518. }
  28519. /***/ }),
  28520. /***/ "../../node_modules/is-arguments/index.js":
  28521. /*!************************************************!*\
  28522. !*** ../../node_modules/is-arguments/index.js ***!
  28523. \************************************************/
  28524. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  28525. "use strict";
  28526. var hasToStringTag = __webpack_require__(/*! has-tostringtag/shams */ "../../node_modules/has-tostringtag/shams.js")();
  28527. var callBound = __webpack_require__(/*! call-bind/callBound */ "../../node_modules/call-bind/callBound.js");
  28528. var $toString = callBound('Object.prototype.toString');
  28529. var isStandardArguments = function isArguments(value) {
  28530. if (hasToStringTag && value && typeof value === 'object' && Symbol.toStringTag in value) {
  28531. return false;
  28532. }
  28533. return $toString(value) === '[object Arguments]';
  28534. };
  28535. var isLegacyArguments = function isArguments(value) {
  28536. if (isStandardArguments(value)) {
  28537. return true;
  28538. }
  28539. return value !== null &&
  28540. typeof value === 'object' &&
  28541. typeof value.length === 'number' &&
  28542. value.length >= 0 &&
  28543. $toString(value) !== '[object Array]' &&
  28544. $toString(value.callee) === '[object Function]';
  28545. };
  28546. var supportsStandardArguments = (function () {
  28547. return isStandardArguments(arguments);
  28548. }());
  28549. isStandardArguments.isLegacyArguments = isLegacyArguments; // for tests
  28550. module.exports = supportsStandardArguments ? isStandardArguments : isLegacyArguments;
  28551. /***/ }),
  28552. /***/ "../../node_modules/is-callable/index.js":
  28553. /*!***********************************************!*\
  28554. !*** ../../node_modules/is-callable/index.js ***!
  28555. \***********************************************/
  28556. /***/ ((module) => {
  28557. "use strict";
  28558. var fnToStr = Function.prototype.toString;
  28559. var reflectApply = typeof Reflect === 'object' && Reflect !== null && Reflect.apply;
  28560. var badArrayLike;
  28561. var isCallableMarker;
  28562. if (typeof reflectApply === 'function' && typeof Object.defineProperty === 'function') {
  28563. try {
  28564. badArrayLike = Object.defineProperty({}, 'length', {
  28565. get: function () {
  28566. throw isCallableMarker;
  28567. }
  28568. });
  28569. isCallableMarker = {};
  28570. // eslint-disable-next-line no-throw-literal
  28571. reflectApply(function () { throw 42; }, null, badArrayLike);
  28572. } catch (_) {
  28573. if (_ !== isCallableMarker) {
  28574. reflectApply = null;
  28575. }
  28576. }
  28577. } else {
  28578. reflectApply = null;
  28579. }
  28580. var constructorRegex = /^\s*class\b/;
  28581. var isES6ClassFn = function isES6ClassFunction(value) {
  28582. try {
  28583. var fnStr = fnToStr.call(value);
  28584. return constructorRegex.test(fnStr);
  28585. } catch (e) {
  28586. return false; // not a function
  28587. }
  28588. };
  28589. var tryFunctionObject = function tryFunctionToStr(value) {
  28590. try {
  28591. if (isES6ClassFn(value)) { return false; }
  28592. fnToStr.call(value);
  28593. return true;
  28594. } catch (e) {
  28595. return false;
  28596. }
  28597. };
  28598. var toStr = Object.prototype.toString;
  28599. var objectClass = '[object Object]';
  28600. var fnClass = '[object Function]';
  28601. var genClass = '[object GeneratorFunction]';
  28602. var ddaClass = '[object HTMLAllCollection]'; // IE 11
  28603. var ddaClass2 = '[object HTML document.all class]';
  28604. var ddaClass3 = '[object HTMLCollection]'; // IE 9-10
  28605. var hasToStringTag = typeof Symbol === 'function' && !!Symbol.toStringTag; // better: use `has-tostringtag`
  28606. var isIE68 = !(0 in [,]); // eslint-disable-line no-sparse-arrays, comma-spacing
  28607. var isDDA = function isDocumentDotAll() { return false; };
  28608. if (typeof document === 'object') {
  28609. // Firefox 3 canonicalizes DDA to undefined when it's not accessed directly
  28610. var all = document.all;
  28611. if (toStr.call(all) === toStr.call(document.all)) {
  28612. isDDA = function isDocumentDotAll(value) {
  28613. /* globals document: false */
  28614. // in IE 6-8, typeof document.all is "object" and it's truthy
  28615. if ((isIE68 || !value) && (typeof value === 'undefined' || typeof value === 'object')) {
  28616. try {
  28617. var str = toStr.call(value);
  28618. return (
  28619. str === ddaClass
  28620. || str === ddaClass2
  28621. || str === ddaClass3 // opera 12.16
  28622. || str === objectClass // IE 6-8
  28623. ) && value('') == null; // eslint-disable-line eqeqeq
  28624. } catch (e) { /**/ }
  28625. }
  28626. return false;
  28627. };
  28628. }
  28629. }
  28630. module.exports = reflectApply
  28631. ? function isCallable(value) {
  28632. if (isDDA(value)) { return true; }
  28633. if (!value) { return false; }
  28634. if (typeof value !== 'function' && typeof value !== 'object') { return false; }
  28635. try {
  28636. reflectApply(value, null, badArrayLike);
  28637. } catch (e) {
  28638. if (e !== isCallableMarker) { return false; }
  28639. }
  28640. return !isES6ClassFn(value) && tryFunctionObject(value);
  28641. }
  28642. : function isCallable(value) {
  28643. if (isDDA(value)) { return true; }
  28644. if (!value) { return false; }
  28645. if (typeof value !== 'function' && typeof value !== 'object') { return false; }
  28646. if (hasToStringTag) { return tryFunctionObject(value); }
  28647. if (isES6ClassFn(value)) { return false; }
  28648. var strClass = toStr.call(value);
  28649. if (strClass !== fnClass && strClass !== genClass && !(/^\[object HTML/).test(strClass)) { return false; }
  28650. return tryFunctionObject(value);
  28651. };
  28652. /***/ }),
  28653. /***/ "../../node_modules/is-generator-function/index.js":
  28654. /*!*********************************************************!*\
  28655. !*** ../../node_modules/is-generator-function/index.js ***!
  28656. \*********************************************************/
  28657. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  28658. "use strict";
  28659. var toStr = Object.prototype.toString;
  28660. var fnToStr = Function.prototype.toString;
  28661. var isFnRegex = /^\s*(?:function)?\*/;
  28662. var hasToStringTag = __webpack_require__(/*! has-tostringtag/shams */ "../../node_modules/has-tostringtag/shams.js")();
  28663. var getProto = Object.getPrototypeOf;
  28664. var getGeneratorFunc = function () { // eslint-disable-line consistent-return
  28665. if (!hasToStringTag) {
  28666. return false;
  28667. }
  28668. try {
  28669. return Function('return function*() {}')();
  28670. } catch (e) {
  28671. }
  28672. };
  28673. var GeneratorFunction;
  28674. module.exports = function isGeneratorFunction(fn) {
  28675. if (typeof fn !== 'function') {
  28676. return false;
  28677. }
  28678. if (isFnRegex.test(fnToStr.call(fn))) {
  28679. return true;
  28680. }
  28681. if (!hasToStringTag) {
  28682. var str = toStr.call(fn);
  28683. return str === '[object GeneratorFunction]';
  28684. }
  28685. if (!getProto) {
  28686. return false;
  28687. }
  28688. if (typeof GeneratorFunction === 'undefined') {
  28689. var generatorFunc = getGeneratorFunc();
  28690. GeneratorFunction = generatorFunc ? getProto(generatorFunc) : false;
  28691. }
  28692. return getProto(fn) === GeneratorFunction;
  28693. };
  28694. /***/ }),
  28695. /***/ "../../node_modules/is-nan/implementation.js":
  28696. /*!***************************************************!*\
  28697. !*** ../../node_modules/is-nan/implementation.js ***!
  28698. \***************************************************/
  28699. /***/ ((module) => {
  28700. "use strict";
  28701. /* http://www.ecma-international.org/ecma-262/6.0/#sec-number.isnan */
  28702. module.exports = function isNaN(value) {
  28703. return value !== value;
  28704. };
  28705. /***/ }),
  28706. /***/ "../../node_modules/is-nan/index.js":
  28707. /*!******************************************!*\
  28708. !*** ../../node_modules/is-nan/index.js ***!
  28709. \******************************************/
  28710. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  28711. "use strict";
  28712. var callBind = __webpack_require__(/*! call-bind */ "../../node_modules/call-bind/index.js");
  28713. var define = __webpack_require__(/*! define-properties */ "../../node_modules/define-properties/index.js");
  28714. var implementation = __webpack_require__(/*! ./implementation */ "../../node_modules/is-nan/implementation.js");
  28715. var getPolyfill = __webpack_require__(/*! ./polyfill */ "../../node_modules/is-nan/polyfill.js");
  28716. var shim = __webpack_require__(/*! ./shim */ "../../node_modules/is-nan/shim.js");
  28717. var polyfill = callBind(getPolyfill(), Number);
  28718. /* http://www.ecma-international.org/ecma-262/6.0/#sec-number.isnan */
  28719. define(polyfill, {
  28720. getPolyfill: getPolyfill,
  28721. implementation: implementation,
  28722. shim: shim
  28723. });
  28724. module.exports = polyfill;
  28725. /***/ }),
  28726. /***/ "../../node_modules/is-nan/polyfill.js":
  28727. /*!*********************************************!*\
  28728. !*** ../../node_modules/is-nan/polyfill.js ***!
  28729. \*********************************************/
  28730. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  28731. "use strict";
  28732. var implementation = __webpack_require__(/*! ./implementation */ "../../node_modules/is-nan/implementation.js");
  28733. module.exports = function getPolyfill() {
  28734. if (Number.isNaN && Number.isNaN(NaN) && !Number.isNaN('a')) {
  28735. return Number.isNaN;
  28736. }
  28737. return implementation;
  28738. };
  28739. /***/ }),
  28740. /***/ "../../node_modules/is-nan/shim.js":
  28741. /*!*****************************************!*\
  28742. !*** ../../node_modules/is-nan/shim.js ***!
  28743. \*****************************************/
  28744. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  28745. "use strict";
  28746. var define = __webpack_require__(/*! define-properties */ "../../node_modules/define-properties/index.js");
  28747. var getPolyfill = __webpack_require__(/*! ./polyfill */ "../../node_modules/is-nan/polyfill.js");
  28748. /* http://www.ecma-international.org/ecma-262/6.0/#sec-number.isnan */
  28749. module.exports = function shimNumberIsNaN() {
  28750. var polyfill = getPolyfill();
  28751. define(Number, { isNaN: polyfill }, {
  28752. isNaN: function testIsNaN() {
  28753. return Number.isNaN !== polyfill;
  28754. }
  28755. });
  28756. return polyfill;
  28757. };
  28758. /***/ }),
  28759. /***/ "../../node_modules/is-typed-array/index.js":
  28760. /*!**************************************************!*\
  28761. !*** ../../node_modules/is-typed-array/index.js ***!
  28762. \**************************************************/
  28763. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  28764. "use strict";
  28765. var forEach = __webpack_require__(/*! for-each */ "../../node_modules/for-each/index.js");
  28766. var availableTypedArrays = __webpack_require__(/*! available-typed-arrays */ "../../node_modules/available-typed-arrays/index.js");
  28767. var callBound = __webpack_require__(/*! call-bind/callBound */ "../../node_modules/call-bind/callBound.js");
  28768. var $toString = callBound('Object.prototype.toString');
  28769. var hasToStringTag = __webpack_require__(/*! has-tostringtag/shams */ "../../node_modules/has-tostringtag/shams.js")();
  28770. var gOPD = __webpack_require__(/*! gopd */ "../../node_modules/gopd/index.js");
  28771. var g = typeof globalThis === 'undefined' ? __webpack_require__.g : globalThis;
  28772. var typedArrays = availableTypedArrays();
  28773. var $indexOf = callBound('Array.prototype.indexOf', true) || function indexOf(array, value) {
  28774. for (var i = 0; i < array.length; i += 1) {
  28775. if (array[i] === value) {
  28776. return i;
  28777. }
  28778. }
  28779. return -1;
  28780. };
  28781. var $slice = callBound('String.prototype.slice');
  28782. var toStrTags = {};
  28783. var getPrototypeOf = Object.getPrototypeOf; // require('getprototypeof');
  28784. if (hasToStringTag && gOPD && getPrototypeOf) {
  28785. forEach(typedArrays, function (typedArray) {
  28786. var arr = new g[typedArray]();
  28787. if (Symbol.toStringTag in arr) {
  28788. var proto = getPrototypeOf(arr);
  28789. var descriptor = gOPD(proto, Symbol.toStringTag);
  28790. if (!descriptor) {
  28791. var superProto = getPrototypeOf(proto);
  28792. descriptor = gOPD(superProto, Symbol.toStringTag);
  28793. }
  28794. toStrTags[typedArray] = descriptor.get;
  28795. }
  28796. });
  28797. }
  28798. var tryTypedArrays = function tryAllTypedArrays(value) {
  28799. var anyTrue = false;
  28800. forEach(toStrTags, function (getter, typedArray) {
  28801. if (!anyTrue) {
  28802. try {
  28803. anyTrue = getter.call(value) === typedArray;
  28804. } catch (e) { /**/ }
  28805. }
  28806. });
  28807. return anyTrue;
  28808. };
  28809. module.exports = function isTypedArray(value) {
  28810. if (!value || typeof value !== 'object') { return false; }
  28811. if (!hasToStringTag || !(Symbol.toStringTag in value)) {
  28812. var tag = $slice($toString(value), 8, -1);
  28813. return $indexOf(typedArrays, tag) > -1;
  28814. }
  28815. if (!gOPD) { return false; }
  28816. return tryTypedArrays(value);
  28817. };
  28818. /***/ }),
  28819. /***/ "../../node_modules/lodash/_DataView.js":
  28820. /*!**********************************************!*\
  28821. !*** ../../node_modules/lodash/_DataView.js ***!
  28822. \**********************************************/
  28823. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  28824. var getNative = __webpack_require__(/*! ./_getNative */ "../../node_modules/lodash/_getNative.js"),
  28825. root = __webpack_require__(/*! ./_root */ "../../node_modules/lodash/_root.js");
  28826. /* Built-in method references that are verified to be native. */
  28827. var DataView = getNative(root, 'DataView');
  28828. module.exports = DataView;
  28829. /***/ }),
  28830. /***/ "../../node_modules/lodash/_Hash.js":
  28831. /*!******************************************!*\
  28832. !*** ../../node_modules/lodash/_Hash.js ***!
  28833. \******************************************/
  28834. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  28835. var hashClear = __webpack_require__(/*! ./_hashClear */ "../../node_modules/lodash/_hashClear.js"),
  28836. hashDelete = __webpack_require__(/*! ./_hashDelete */ "../../node_modules/lodash/_hashDelete.js"),
  28837. hashGet = __webpack_require__(/*! ./_hashGet */ "../../node_modules/lodash/_hashGet.js"),
  28838. hashHas = __webpack_require__(/*! ./_hashHas */ "../../node_modules/lodash/_hashHas.js"),
  28839. hashSet = __webpack_require__(/*! ./_hashSet */ "../../node_modules/lodash/_hashSet.js");
  28840. /**
  28841. * Creates a hash object.
  28842. *
  28843. * @private
  28844. * @constructor
  28845. * @param {Array} [entries] The key-value pairs to cache.
  28846. */
  28847. function Hash(entries) {
  28848. var index = -1,
  28849. length = entries == null ? 0 : entries.length;
  28850. this.clear();
  28851. while (++index < length) {
  28852. var entry = entries[index];
  28853. this.set(entry[0], entry[1]);
  28854. }
  28855. }
  28856. // Add methods to `Hash`.
  28857. Hash.prototype.clear = hashClear;
  28858. Hash.prototype['delete'] = hashDelete;
  28859. Hash.prototype.get = hashGet;
  28860. Hash.prototype.has = hashHas;
  28861. Hash.prototype.set = hashSet;
  28862. module.exports = Hash;
  28863. /***/ }),
  28864. /***/ "../../node_modules/lodash/_ListCache.js":
  28865. /*!***********************************************!*\
  28866. !*** ../../node_modules/lodash/_ListCache.js ***!
  28867. \***********************************************/
  28868. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  28869. var listCacheClear = __webpack_require__(/*! ./_listCacheClear */ "../../node_modules/lodash/_listCacheClear.js"),
  28870. listCacheDelete = __webpack_require__(/*! ./_listCacheDelete */ "../../node_modules/lodash/_listCacheDelete.js"),
  28871. listCacheGet = __webpack_require__(/*! ./_listCacheGet */ "../../node_modules/lodash/_listCacheGet.js"),
  28872. listCacheHas = __webpack_require__(/*! ./_listCacheHas */ "../../node_modules/lodash/_listCacheHas.js"),
  28873. listCacheSet = __webpack_require__(/*! ./_listCacheSet */ "../../node_modules/lodash/_listCacheSet.js");
  28874. /**
  28875. * Creates an list cache object.
  28876. *
  28877. * @private
  28878. * @constructor
  28879. * @param {Array} [entries] The key-value pairs to cache.
  28880. */
  28881. function ListCache(entries) {
  28882. var index = -1,
  28883. length = entries == null ? 0 : entries.length;
  28884. this.clear();
  28885. while (++index < length) {
  28886. var entry = entries[index];
  28887. this.set(entry[0], entry[1]);
  28888. }
  28889. }
  28890. // Add methods to `ListCache`.
  28891. ListCache.prototype.clear = listCacheClear;
  28892. ListCache.prototype['delete'] = listCacheDelete;
  28893. ListCache.prototype.get = listCacheGet;
  28894. ListCache.prototype.has = listCacheHas;
  28895. ListCache.prototype.set = listCacheSet;
  28896. module.exports = ListCache;
  28897. /***/ }),
  28898. /***/ "../../node_modules/lodash/_Map.js":
  28899. /*!*****************************************!*\
  28900. !*** ../../node_modules/lodash/_Map.js ***!
  28901. \*****************************************/
  28902. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  28903. var getNative = __webpack_require__(/*! ./_getNative */ "../../node_modules/lodash/_getNative.js"),
  28904. root = __webpack_require__(/*! ./_root */ "../../node_modules/lodash/_root.js");
  28905. /* Built-in method references that are verified to be native. */
  28906. var Map = getNative(root, 'Map');
  28907. module.exports = Map;
  28908. /***/ }),
  28909. /***/ "../../node_modules/lodash/_MapCache.js":
  28910. /*!**********************************************!*\
  28911. !*** ../../node_modules/lodash/_MapCache.js ***!
  28912. \**********************************************/
  28913. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  28914. var mapCacheClear = __webpack_require__(/*! ./_mapCacheClear */ "../../node_modules/lodash/_mapCacheClear.js"),
  28915. mapCacheDelete = __webpack_require__(/*! ./_mapCacheDelete */ "../../node_modules/lodash/_mapCacheDelete.js"),
  28916. mapCacheGet = __webpack_require__(/*! ./_mapCacheGet */ "../../node_modules/lodash/_mapCacheGet.js"),
  28917. mapCacheHas = __webpack_require__(/*! ./_mapCacheHas */ "../../node_modules/lodash/_mapCacheHas.js"),
  28918. mapCacheSet = __webpack_require__(/*! ./_mapCacheSet */ "../../node_modules/lodash/_mapCacheSet.js");
  28919. /**
  28920. * Creates a map cache object to store key-value pairs.
  28921. *
  28922. * @private
  28923. * @constructor
  28924. * @param {Array} [entries] The key-value pairs to cache.
  28925. */
  28926. function MapCache(entries) {
  28927. var index = -1,
  28928. length = entries == null ? 0 : entries.length;
  28929. this.clear();
  28930. while (++index < length) {
  28931. var entry = entries[index];
  28932. this.set(entry[0], entry[1]);
  28933. }
  28934. }
  28935. // Add methods to `MapCache`.
  28936. MapCache.prototype.clear = mapCacheClear;
  28937. MapCache.prototype['delete'] = mapCacheDelete;
  28938. MapCache.prototype.get = mapCacheGet;
  28939. MapCache.prototype.has = mapCacheHas;
  28940. MapCache.prototype.set = mapCacheSet;
  28941. module.exports = MapCache;
  28942. /***/ }),
  28943. /***/ "../../node_modules/lodash/_Promise.js":
  28944. /*!*********************************************!*\
  28945. !*** ../../node_modules/lodash/_Promise.js ***!
  28946. \*********************************************/
  28947. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  28948. var getNative = __webpack_require__(/*! ./_getNative */ "../../node_modules/lodash/_getNative.js"),
  28949. root = __webpack_require__(/*! ./_root */ "../../node_modules/lodash/_root.js");
  28950. /* Built-in method references that are verified to be native. */
  28951. var Promise = getNative(root, 'Promise');
  28952. module.exports = Promise;
  28953. /***/ }),
  28954. /***/ "../../node_modules/lodash/_Set.js":
  28955. /*!*****************************************!*\
  28956. !*** ../../node_modules/lodash/_Set.js ***!
  28957. \*****************************************/
  28958. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  28959. var getNative = __webpack_require__(/*! ./_getNative */ "../../node_modules/lodash/_getNative.js"),
  28960. root = __webpack_require__(/*! ./_root */ "../../node_modules/lodash/_root.js");
  28961. /* Built-in method references that are verified to be native. */
  28962. var Set = getNative(root, 'Set');
  28963. module.exports = Set;
  28964. /***/ }),
  28965. /***/ "../../node_modules/lodash/_SetCache.js":
  28966. /*!**********************************************!*\
  28967. !*** ../../node_modules/lodash/_SetCache.js ***!
  28968. \**********************************************/
  28969. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  28970. var MapCache = __webpack_require__(/*! ./_MapCache */ "../../node_modules/lodash/_MapCache.js"),
  28971. setCacheAdd = __webpack_require__(/*! ./_setCacheAdd */ "../../node_modules/lodash/_setCacheAdd.js"),
  28972. setCacheHas = __webpack_require__(/*! ./_setCacheHas */ "../../node_modules/lodash/_setCacheHas.js");
  28973. /**
  28974. *
  28975. * Creates an array cache object to store unique values.
  28976. *
  28977. * @private
  28978. * @constructor
  28979. * @param {Array} [values] The values to cache.
  28980. */
  28981. function SetCache(values) {
  28982. var index = -1,
  28983. length = values == null ? 0 : values.length;
  28984. this.__data__ = new MapCache;
  28985. while (++index < length) {
  28986. this.add(values[index]);
  28987. }
  28988. }
  28989. // Add methods to `SetCache`.
  28990. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  28991. SetCache.prototype.has = setCacheHas;
  28992. module.exports = SetCache;
  28993. /***/ }),
  28994. /***/ "../../node_modules/lodash/_Stack.js":
  28995. /*!*******************************************!*\
  28996. !*** ../../node_modules/lodash/_Stack.js ***!
  28997. \*******************************************/
  28998. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  28999. var ListCache = __webpack_require__(/*! ./_ListCache */ "../../node_modules/lodash/_ListCache.js"),
  29000. stackClear = __webpack_require__(/*! ./_stackClear */ "../../node_modules/lodash/_stackClear.js"),
  29001. stackDelete = __webpack_require__(/*! ./_stackDelete */ "../../node_modules/lodash/_stackDelete.js"),
  29002. stackGet = __webpack_require__(/*! ./_stackGet */ "../../node_modules/lodash/_stackGet.js"),
  29003. stackHas = __webpack_require__(/*! ./_stackHas */ "../../node_modules/lodash/_stackHas.js"),
  29004. stackSet = __webpack_require__(/*! ./_stackSet */ "../../node_modules/lodash/_stackSet.js");
  29005. /**
  29006. * Creates a stack cache object to store key-value pairs.
  29007. *
  29008. * @private
  29009. * @constructor
  29010. * @param {Array} [entries] The key-value pairs to cache.
  29011. */
  29012. function Stack(entries) {
  29013. var data = this.__data__ = new ListCache(entries);
  29014. this.size = data.size;
  29015. }
  29016. // Add methods to `Stack`.
  29017. Stack.prototype.clear = stackClear;
  29018. Stack.prototype['delete'] = stackDelete;
  29019. Stack.prototype.get = stackGet;
  29020. Stack.prototype.has = stackHas;
  29021. Stack.prototype.set = stackSet;
  29022. module.exports = Stack;
  29023. /***/ }),
  29024. /***/ "../../node_modules/lodash/_Symbol.js":
  29025. /*!********************************************!*\
  29026. !*** ../../node_modules/lodash/_Symbol.js ***!
  29027. \********************************************/
  29028. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  29029. var root = __webpack_require__(/*! ./_root */ "../../node_modules/lodash/_root.js");
  29030. /** Built-in value references. */
  29031. var Symbol = root.Symbol;
  29032. module.exports = Symbol;
  29033. /***/ }),
  29034. /***/ "../../node_modules/lodash/_Uint8Array.js":
  29035. /*!************************************************!*\
  29036. !*** ../../node_modules/lodash/_Uint8Array.js ***!
  29037. \************************************************/
  29038. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  29039. var root = __webpack_require__(/*! ./_root */ "../../node_modules/lodash/_root.js");
  29040. /** Built-in value references. */
  29041. var Uint8Array = root.Uint8Array;
  29042. module.exports = Uint8Array;
  29043. /***/ }),
  29044. /***/ "../../node_modules/lodash/_WeakMap.js":
  29045. /*!*********************************************!*\
  29046. !*** ../../node_modules/lodash/_WeakMap.js ***!
  29047. \*********************************************/
  29048. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  29049. var getNative = __webpack_require__(/*! ./_getNative */ "../../node_modules/lodash/_getNative.js"),
  29050. root = __webpack_require__(/*! ./_root */ "../../node_modules/lodash/_root.js");
  29051. /* Built-in method references that are verified to be native. */
  29052. var WeakMap = getNative(root, 'WeakMap');
  29053. module.exports = WeakMap;
  29054. /***/ }),
  29055. /***/ "../../node_modules/lodash/_arrayAggregator.js":
  29056. /*!*****************************************************!*\
  29057. !*** ../../node_modules/lodash/_arrayAggregator.js ***!
  29058. \*****************************************************/
  29059. /***/ ((module) => {
  29060. /**
  29061. * A specialized version of `baseAggregator` for arrays.
  29062. *
  29063. * @private
  29064. * @param {Array} [array] The array to iterate over.
  29065. * @param {Function} setter The function to set `accumulator` values.
  29066. * @param {Function} iteratee The iteratee to transform keys.
  29067. * @param {Object} accumulator The initial aggregated object.
  29068. * @returns {Function} Returns `accumulator`.
  29069. */
  29070. function arrayAggregator(array, setter, iteratee, accumulator) {
  29071. var index = -1,
  29072. length = array == null ? 0 : array.length;
  29073. while (++index < length) {
  29074. var value = array[index];
  29075. setter(accumulator, value, iteratee(value), array);
  29076. }
  29077. return accumulator;
  29078. }
  29079. module.exports = arrayAggregator;
  29080. /***/ }),
  29081. /***/ "../../node_modules/lodash/_arrayFilter.js":
  29082. /*!*************************************************!*\
  29083. !*** ../../node_modules/lodash/_arrayFilter.js ***!
  29084. \*************************************************/
  29085. /***/ ((module) => {
  29086. /**
  29087. * A specialized version of `_.filter` for arrays without support for
  29088. * iteratee shorthands.
  29089. *
  29090. * @private
  29091. * @param {Array} [array] The array to iterate over.
  29092. * @param {Function} predicate The function invoked per iteration.
  29093. * @returns {Array} Returns the new filtered array.
  29094. */
  29095. function arrayFilter(array, predicate) {
  29096. var index = -1,
  29097. length = array == null ? 0 : array.length,
  29098. resIndex = 0,
  29099. result = [];
  29100. while (++index < length) {
  29101. var value = array[index];
  29102. if (predicate(value, index, array)) {
  29103. result[resIndex++] = value;
  29104. }
  29105. }
  29106. return result;
  29107. }
  29108. module.exports = arrayFilter;
  29109. /***/ }),
  29110. /***/ "../../node_modules/lodash/_arrayLikeKeys.js":
  29111. /*!***************************************************!*\
  29112. !*** ../../node_modules/lodash/_arrayLikeKeys.js ***!
  29113. \***************************************************/
  29114. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  29115. var baseTimes = __webpack_require__(/*! ./_baseTimes */ "../../node_modules/lodash/_baseTimes.js"),
  29116. isArguments = __webpack_require__(/*! ./isArguments */ "../../node_modules/lodash/isArguments.js"),
  29117. isArray = __webpack_require__(/*! ./isArray */ "../../node_modules/lodash/isArray.js"),
  29118. isBuffer = __webpack_require__(/*! ./isBuffer */ "../../node_modules/lodash/isBuffer.js"),
  29119. isIndex = __webpack_require__(/*! ./_isIndex */ "../../node_modules/lodash/_isIndex.js"),
  29120. isTypedArray = __webpack_require__(/*! ./isTypedArray */ "../../node_modules/lodash/isTypedArray.js");
  29121. /** Used for built-in method references. */
  29122. var objectProto = Object.prototype;
  29123. /** Used to check objects for own properties. */
  29124. var hasOwnProperty = objectProto.hasOwnProperty;
  29125. /**
  29126. * Creates an array of the enumerable property names of the array-like `value`.
  29127. *
  29128. * @private
  29129. * @param {*} value The value to query.
  29130. * @param {boolean} inherited Specify returning inherited property names.
  29131. * @returns {Array} Returns the array of property names.
  29132. */
  29133. function arrayLikeKeys(value, inherited) {
  29134. var isArr = isArray(value),
  29135. isArg = !isArr && isArguments(value),
  29136. isBuff = !isArr && !isArg && isBuffer(value),
  29137. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  29138. skipIndexes = isArr || isArg || isBuff || isType,
  29139. result = skipIndexes ? baseTimes(value.length, String) : [],
  29140. length = result.length;
  29141. for (var key in value) {
  29142. if ((inherited || hasOwnProperty.call(value, key)) &&
  29143. !(skipIndexes && (
  29144. // Safari 9 has enumerable `arguments.length` in strict mode.
  29145. key == 'length' ||
  29146. // Node.js 0.10 has enumerable non-index properties on buffers.
  29147. (isBuff && (key == 'offset' || key == 'parent')) ||
  29148. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  29149. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  29150. // Skip index properties.
  29151. isIndex(key, length)
  29152. ))) {
  29153. result.push(key);
  29154. }
  29155. }
  29156. return result;
  29157. }
  29158. module.exports = arrayLikeKeys;
  29159. /***/ }),
  29160. /***/ "../../node_modules/lodash/_arrayMap.js":
  29161. /*!**********************************************!*\
  29162. !*** ../../node_modules/lodash/_arrayMap.js ***!
  29163. \**********************************************/
  29164. /***/ ((module) => {
  29165. /**
  29166. * A specialized version of `_.map` for arrays without support for iteratee
  29167. * shorthands.
  29168. *
  29169. * @private
  29170. * @param {Array} [array] The array to iterate over.
  29171. * @param {Function} iteratee The function invoked per iteration.
  29172. * @returns {Array} Returns the new mapped array.
  29173. */
  29174. function arrayMap(array, iteratee) {
  29175. var index = -1,
  29176. length = array == null ? 0 : array.length,
  29177. result = Array(length);
  29178. while (++index < length) {
  29179. result[index] = iteratee(array[index], index, array);
  29180. }
  29181. return result;
  29182. }
  29183. module.exports = arrayMap;
  29184. /***/ }),
  29185. /***/ "../../node_modules/lodash/_arrayPush.js":
  29186. /*!***********************************************!*\
  29187. !*** ../../node_modules/lodash/_arrayPush.js ***!
  29188. \***********************************************/
  29189. /***/ ((module) => {
  29190. /**
  29191. * Appends the elements of `values` to `array`.
  29192. *
  29193. * @private
  29194. * @param {Array} array The array to modify.
  29195. * @param {Array} values The values to append.
  29196. * @returns {Array} Returns `array`.
  29197. */
  29198. function arrayPush(array, values) {
  29199. var index = -1,
  29200. length = values.length,
  29201. offset = array.length;
  29202. while (++index < length) {
  29203. array[offset + index] = values[index];
  29204. }
  29205. return array;
  29206. }
  29207. module.exports = arrayPush;
  29208. /***/ }),
  29209. /***/ "../../node_modules/lodash/_arraySome.js":
  29210. /*!***********************************************!*\
  29211. !*** ../../node_modules/lodash/_arraySome.js ***!
  29212. \***********************************************/
  29213. /***/ ((module) => {
  29214. /**
  29215. * A specialized version of `_.some` for arrays without support for iteratee
  29216. * shorthands.
  29217. *
  29218. * @private
  29219. * @param {Array} [array] The array to iterate over.
  29220. * @param {Function} predicate The function invoked per iteration.
  29221. * @returns {boolean} Returns `true` if any element passes the predicate check,
  29222. * else `false`.
  29223. */
  29224. function arraySome(array, predicate) {
  29225. var index = -1,
  29226. length = array == null ? 0 : array.length;
  29227. while (++index < length) {
  29228. if (predicate(array[index], index, array)) {
  29229. return true;
  29230. }
  29231. }
  29232. return false;
  29233. }
  29234. module.exports = arraySome;
  29235. /***/ }),
  29236. /***/ "../../node_modules/lodash/_assignValue.js":
  29237. /*!*************************************************!*\
  29238. !*** ../../node_modules/lodash/_assignValue.js ***!
  29239. \*************************************************/
  29240. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  29241. var baseAssignValue = __webpack_require__(/*! ./_baseAssignValue */ "../../node_modules/lodash/_baseAssignValue.js"),
  29242. eq = __webpack_require__(/*! ./eq */ "../../node_modules/lodash/eq.js");
  29243. /** Used for built-in method references. */
  29244. var objectProto = Object.prototype;
  29245. /** Used to check objects for own properties. */
  29246. var hasOwnProperty = objectProto.hasOwnProperty;
  29247. /**
  29248. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  29249. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  29250. * for equality comparisons.
  29251. *
  29252. * @private
  29253. * @param {Object} object The object to modify.
  29254. * @param {string} key The key of the property to assign.
  29255. * @param {*} value The value to assign.
  29256. */
  29257. function assignValue(object, key, value) {
  29258. var objValue = object[key];
  29259. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  29260. (value === undefined && !(key in object))) {
  29261. baseAssignValue(object, key, value);
  29262. }
  29263. }
  29264. module.exports = assignValue;
  29265. /***/ }),
  29266. /***/ "../../node_modules/lodash/_assocIndexOf.js":
  29267. /*!**************************************************!*\
  29268. !*** ../../node_modules/lodash/_assocIndexOf.js ***!
  29269. \**************************************************/
  29270. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  29271. var eq = __webpack_require__(/*! ./eq */ "../../node_modules/lodash/eq.js");
  29272. /**
  29273. * Gets the index at which the `key` is found in `array` of key-value pairs.
  29274. *
  29275. * @private
  29276. * @param {Array} array The array to inspect.
  29277. * @param {*} key The key to search for.
  29278. * @returns {number} Returns the index of the matched value, else `-1`.
  29279. */
  29280. function assocIndexOf(array, key) {
  29281. var length = array.length;
  29282. while (length--) {
  29283. if (eq(array[length][0], key)) {
  29284. return length;
  29285. }
  29286. }
  29287. return -1;
  29288. }
  29289. module.exports = assocIndexOf;
  29290. /***/ }),
  29291. /***/ "../../node_modules/lodash/_baseAggregator.js":
  29292. /*!****************************************************!*\
  29293. !*** ../../node_modules/lodash/_baseAggregator.js ***!
  29294. \****************************************************/
  29295. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  29296. var baseEach = __webpack_require__(/*! ./_baseEach */ "../../node_modules/lodash/_baseEach.js");
  29297. /**
  29298. * Aggregates elements of `collection` on `accumulator` with keys transformed
  29299. * by `iteratee` and values set by `setter`.
  29300. *
  29301. * @private
  29302. * @param {Array|Object} collection The collection to iterate over.
  29303. * @param {Function} setter The function to set `accumulator` values.
  29304. * @param {Function} iteratee The iteratee to transform keys.
  29305. * @param {Object} accumulator The initial aggregated object.
  29306. * @returns {Function} Returns `accumulator`.
  29307. */
  29308. function baseAggregator(collection, setter, iteratee, accumulator) {
  29309. baseEach(collection, function(value, key, collection) {
  29310. setter(accumulator, value, iteratee(value), collection);
  29311. });
  29312. return accumulator;
  29313. }
  29314. module.exports = baseAggregator;
  29315. /***/ }),
  29316. /***/ "../../node_modules/lodash/_baseAssignValue.js":
  29317. /*!*****************************************************!*\
  29318. !*** ../../node_modules/lodash/_baseAssignValue.js ***!
  29319. \*****************************************************/
  29320. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  29321. var defineProperty = __webpack_require__(/*! ./_defineProperty */ "../../node_modules/lodash/_defineProperty.js");
  29322. /**
  29323. * The base implementation of `assignValue` and `assignMergeValue` without
  29324. * value checks.
  29325. *
  29326. * @private
  29327. * @param {Object} object The object to modify.
  29328. * @param {string} key The key of the property to assign.
  29329. * @param {*} value The value to assign.
  29330. */
  29331. function baseAssignValue(object, key, value) {
  29332. if (key == '__proto__' && defineProperty) {
  29333. defineProperty(object, key, {
  29334. 'configurable': true,
  29335. 'enumerable': true,
  29336. 'value': value,
  29337. 'writable': true
  29338. });
  29339. } else {
  29340. object[key] = value;
  29341. }
  29342. }
  29343. module.exports = baseAssignValue;
  29344. /***/ }),
  29345. /***/ "../../node_modules/lodash/_baseEach.js":
  29346. /*!**********************************************!*\
  29347. !*** ../../node_modules/lodash/_baseEach.js ***!
  29348. \**********************************************/
  29349. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  29350. var baseForOwn = __webpack_require__(/*! ./_baseForOwn */ "../../node_modules/lodash/_baseForOwn.js"),
  29351. createBaseEach = __webpack_require__(/*! ./_createBaseEach */ "../../node_modules/lodash/_createBaseEach.js");
  29352. /**
  29353. * The base implementation of `_.forEach` without support for iteratee shorthands.
  29354. *
  29355. * @private
  29356. * @param {Array|Object} collection The collection to iterate over.
  29357. * @param {Function} iteratee The function invoked per iteration.
  29358. * @returns {Array|Object} Returns `collection`.
  29359. */
  29360. var baseEach = createBaseEach(baseForOwn);
  29361. module.exports = baseEach;
  29362. /***/ }),
  29363. /***/ "../../node_modules/lodash/_baseFlatten.js":
  29364. /*!*************************************************!*\
  29365. !*** ../../node_modules/lodash/_baseFlatten.js ***!
  29366. \*************************************************/
  29367. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  29368. var arrayPush = __webpack_require__(/*! ./_arrayPush */ "../../node_modules/lodash/_arrayPush.js"),
  29369. isFlattenable = __webpack_require__(/*! ./_isFlattenable */ "../../node_modules/lodash/_isFlattenable.js");
  29370. /**
  29371. * The base implementation of `_.flatten` with support for restricting flattening.
  29372. *
  29373. * @private
  29374. * @param {Array} array The array to flatten.
  29375. * @param {number} depth The maximum recursion depth.
  29376. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  29377. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  29378. * @param {Array} [result=[]] The initial result value.
  29379. * @returns {Array} Returns the new flattened array.
  29380. */
  29381. function baseFlatten(array, depth, predicate, isStrict, result) {
  29382. var index = -1,
  29383. length = array.length;
  29384. predicate || (predicate = isFlattenable);
  29385. result || (result = []);
  29386. while (++index < length) {
  29387. var value = array[index];
  29388. if (depth > 0 && predicate(value)) {
  29389. if (depth > 1) {
  29390. // Recursively flatten arrays (susceptible to call stack limits).
  29391. baseFlatten(value, depth - 1, predicate, isStrict, result);
  29392. } else {
  29393. arrayPush(result, value);
  29394. }
  29395. } else if (!isStrict) {
  29396. result[result.length] = value;
  29397. }
  29398. }
  29399. return result;
  29400. }
  29401. module.exports = baseFlatten;
  29402. /***/ }),
  29403. /***/ "../../node_modules/lodash/_baseFor.js":
  29404. /*!*********************************************!*\
  29405. !*** ../../node_modules/lodash/_baseFor.js ***!
  29406. \*********************************************/
  29407. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  29408. var createBaseFor = __webpack_require__(/*! ./_createBaseFor */ "../../node_modules/lodash/_createBaseFor.js");
  29409. /**
  29410. * The base implementation of `baseForOwn` which iterates over `object`
  29411. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  29412. * Iteratee functions may exit iteration early by explicitly returning `false`.
  29413. *
  29414. * @private
  29415. * @param {Object} object The object to iterate over.
  29416. * @param {Function} iteratee The function invoked per iteration.
  29417. * @param {Function} keysFunc The function to get the keys of `object`.
  29418. * @returns {Object} Returns `object`.
  29419. */
  29420. var baseFor = createBaseFor();
  29421. module.exports = baseFor;
  29422. /***/ }),
  29423. /***/ "../../node_modules/lodash/_baseForOwn.js":
  29424. /*!************************************************!*\
  29425. !*** ../../node_modules/lodash/_baseForOwn.js ***!
  29426. \************************************************/
  29427. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  29428. var baseFor = __webpack_require__(/*! ./_baseFor */ "../../node_modules/lodash/_baseFor.js"),
  29429. keys = __webpack_require__(/*! ./keys */ "../../node_modules/lodash/keys.js");
  29430. /**
  29431. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  29432. *
  29433. * @private
  29434. * @param {Object} object The object to iterate over.
  29435. * @param {Function} iteratee The function invoked per iteration.
  29436. * @returns {Object} Returns `object`.
  29437. */
  29438. function baseForOwn(object, iteratee) {
  29439. return object && baseFor(object, iteratee, keys);
  29440. }
  29441. module.exports = baseForOwn;
  29442. /***/ }),
  29443. /***/ "../../node_modules/lodash/_baseGet.js":
  29444. /*!*********************************************!*\
  29445. !*** ../../node_modules/lodash/_baseGet.js ***!
  29446. \*********************************************/
  29447. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  29448. var castPath = __webpack_require__(/*! ./_castPath */ "../../node_modules/lodash/_castPath.js"),
  29449. toKey = __webpack_require__(/*! ./_toKey */ "../../node_modules/lodash/_toKey.js");
  29450. /**
  29451. * The base implementation of `_.get` without support for default values.
  29452. *
  29453. * @private
  29454. * @param {Object} object The object to query.
  29455. * @param {Array|string} path The path of the property to get.
  29456. * @returns {*} Returns the resolved value.
  29457. */
  29458. function baseGet(object, path) {
  29459. path = castPath(path, object);
  29460. var index = 0,
  29461. length = path.length;
  29462. while (object != null && index < length) {
  29463. object = object[toKey(path[index++])];
  29464. }
  29465. return (index && index == length) ? object : undefined;
  29466. }
  29467. module.exports = baseGet;
  29468. /***/ }),
  29469. /***/ "../../node_modules/lodash/_baseGetAllKeys.js":
  29470. /*!****************************************************!*\
  29471. !*** ../../node_modules/lodash/_baseGetAllKeys.js ***!
  29472. \****************************************************/
  29473. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  29474. var arrayPush = __webpack_require__(/*! ./_arrayPush */ "../../node_modules/lodash/_arrayPush.js"),
  29475. isArray = __webpack_require__(/*! ./isArray */ "../../node_modules/lodash/isArray.js");
  29476. /**
  29477. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  29478. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  29479. * symbols of `object`.
  29480. *
  29481. * @private
  29482. * @param {Object} object The object to query.
  29483. * @param {Function} keysFunc The function to get the keys of `object`.
  29484. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  29485. * @returns {Array} Returns the array of property names and symbols.
  29486. */
  29487. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  29488. var result = keysFunc(object);
  29489. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  29490. }
  29491. module.exports = baseGetAllKeys;
  29492. /***/ }),
  29493. /***/ "../../node_modules/lodash/_baseGetTag.js":
  29494. /*!************************************************!*\
  29495. !*** ../../node_modules/lodash/_baseGetTag.js ***!
  29496. \************************************************/
  29497. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  29498. var Symbol = __webpack_require__(/*! ./_Symbol */ "../../node_modules/lodash/_Symbol.js"),
  29499. getRawTag = __webpack_require__(/*! ./_getRawTag */ "../../node_modules/lodash/_getRawTag.js"),
  29500. objectToString = __webpack_require__(/*! ./_objectToString */ "../../node_modules/lodash/_objectToString.js");
  29501. /** `Object#toString` result references. */
  29502. var nullTag = '[object Null]',
  29503. undefinedTag = '[object Undefined]';
  29504. /** Built-in value references. */
  29505. var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  29506. /**
  29507. * The base implementation of `getTag` without fallbacks for buggy environments.
  29508. *
  29509. * @private
  29510. * @param {*} value The value to query.
  29511. * @returns {string} Returns the `toStringTag`.
  29512. */
  29513. function baseGetTag(value) {
  29514. if (value == null) {
  29515. return value === undefined ? undefinedTag : nullTag;
  29516. }
  29517. return (symToStringTag && symToStringTag in Object(value))
  29518. ? getRawTag(value)
  29519. : objectToString(value);
  29520. }
  29521. module.exports = baseGetTag;
  29522. /***/ }),
  29523. /***/ "../../node_modules/lodash/_baseHasIn.js":
  29524. /*!***********************************************!*\
  29525. !*** ../../node_modules/lodash/_baseHasIn.js ***!
  29526. \***********************************************/
  29527. /***/ ((module) => {
  29528. /**
  29529. * The base implementation of `_.hasIn` without support for deep paths.
  29530. *
  29531. * @private
  29532. * @param {Object} [object] The object to query.
  29533. * @param {Array|string} key The key to check.
  29534. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  29535. */
  29536. function baseHasIn(object, key) {
  29537. return object != null && key in Object(object);
  29538. }
  29539. module.exports = baseHasIn;
  29540. /***/ }),
  29541. /***/ "../../node_modules/lodash/_baseIsArguments.js":
  29542. /*!*****************************************************!*\
  29543. !*** ../../node_modules/lodash/_baseIsArguments.js ***!
  29544. \*****************************************************/
  29545. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  29546. var baseGetTag = __webpack_require__(/*! ./_baseGetTag */ "../../node_modules/lodash/_baseGetTag.js"),
  29547. isObjectLike = __webpack_require__(/*! ./isObjectLike */ "../../node_modules/lodash/isObjectLike.js");
  29548. /** `Object#toString` result references. */
  29549. var argsTag = '[object Arguments]';
  29550. /**
  29551. * The base implementation of `_.isArguments`.
  29552. *
  29553. * @private
  29554. * @param {*} value The value to check.
  29555. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  29556. */
  29557. function baseIsArguments(value) {
  29558. return isObjectLike(value) && baseGetTag(value) == argsTag;
  29559. }
  29560. module.exports = baseIsArguments;
  29561. /***/ }),
  29562. /***/ "../../node_modules/lodash/_baseIsEqual.js":
  29563. /*!*************************************************!*\
  29564. !*** ../../node_modules/lodash/_baseIsEqual.js ***!
  29565. \*************************************************/
  29566. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  29567. var baseIsEqualDeep = __webpack_require__(/*! ./_baseIsEqualDeep */ "../../node_modules/lodash/_baseIsEqualDeep.js"),
  29568. isObjectLike = __webpack_require__(/*! ./isObjectLike */ "../../node_modules/lodash/isObjectLike.js");
  29569. /**
  29570. * The base implementation of `_.isEqual` which supports partial comparisons
  29571. * and tracks traversed objects.
  29572. *
  29573. * @private
  29574. * @param {*} value The value to compare.
  29575. * @param {*} other The other value to compare.
  29576. * @param {boolean} bitmask The bitmask flags.
  29577. * 1 - Unordered comparison
  29578. * 2 - Partial comparison
  29579. * @param {Function} [customizer] The function to customize comparisons.
  29580. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  29581. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  29582. */
  29583. function baseIsEqual(value, other, bitmask, customizer, stack) {
  29584. if (value === other) {
  29585. return true;
  29586. }
  29587. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  29588. return value !== value && other !== other;
  29589. }
  29590. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  29591. }
  29592. module.exports = baseIsEqual;
  29593. /***/ }),
  29594. /***/ "../../node_modules/lodash/_baseIsEqualDeep.js":
  29595. /*!*****************************************************!*\
  29596. !*** ../../node_modules/lodash/_baseIsEqualDeep.js ***!
  29597. \*****************************************************/
  29598. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  29599. var Stack = __webpack_require__(/*! ./_Stack */ "../../node_modules/lodash/_Stack.js"),
  29600. equalArrays = __webpack_require__(/*! ./_equalArrays */ "../../node_modules/lodash/_equalArrays.js"),
  29601. equalByTag = __webpack_require__(/*! ./_equalByTag */ "../../node_modules/lodash/_equalByTag.js"),
  29602. equalObjects = __webpack_require__(/*! ./_equalObjects */ "../../node_modules/lodash/_equalObjects.js"),
  29603. getTag = __webpack_require__(/*! ./_getTag */ "../../node_modules/lodash/_getTag.js"),
  29604. isArray = __webpack_require__(/*! ./isArray */ "../../node_modules/lodash/isArray.js"),
  29605. isBuffer = __webpack_require__(/*! ./isBuffer */ "../../node_modules/lodash/isBuffer.js"),
  29606. isTypedArray = __webpack_require__(/*! ./isTypedArray */ "../../node_modules/lodash/isTypedArray.js");
  29607. /** Used to compose bitmasks for value comparisons. */
  29608. var COMPARE_PARTIAL_FLAG = 1;
  29609. /** `Object#toString` result references. */
  29610. var argsTag = '[object Arguments]',
  29611. arrayTag = '[object Array]',
  29612. objectTag = '[object Object]';
  29613. /** Used for built-in method references. */
  29614. var objectProto = Object.prototype;
  29615. /** Used to check objects for own properties. */
  29616. var hasOwnProperty = objectProto.hasOwnProperty;
  29617. /**
  29618. * A specialized version of `baseIsEqual` for arrays and objects which performs
  29619. * deep comparisons and tracks traversed objects enabling objects with circular
  29620. * references to be compared.
  29621. *
  29622. * @private
  29623. * @param {Object} object The object to compare.
  29624. * @param {Object} other The other object to compare.
  29625. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  29626. * @param {Function} customizer The function to customize comparisons.
  29627. * @param {Function} equalFunc The function to determine equivalents of values.
  29628. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  29629. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  29630. */
  29631. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  29632. var objIsArr = isArray(object),
  29633. othIsArr = isArray(other),
  29634. objTag = objIsArr ? arrayTag : getTag(object),
  29635. othTag = othIsArr ? arrayTag : getTag(other);
  29636. objTag = objTag == argsTag ? objectTag : objTag;
  29637. othTag = othTag == argsTag ? objectTag : othTag;
  29638. var objIsObj = objTag == objectTag,
  29639. othIsObj = othTag == objectTag,
  29640. isSameTag = objTag == othTag;
  29641. if (isSameTag && isBuffer(object)) {
  29642. if (!isBuffer(other)) {
  29643. return false;
  29644. }
  29645. objIsArr = true;
  29646. objIsObj = false;
  29647. }
  29648. if (isSameTag && !objIsObj) {
  29649. stack || (stack = new Stack);
  29650. return (objIsArr || isTypedArray(object))
  29651. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  29652. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  29653. }
  29654. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  29655. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  29656. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  29657. if (objIsWrapped || othIsWrapped) {
  29658. var objUnwrapped = objIsWrapped ? object.value() : object,
  29659. othUnwrapped = othIsWrapped ? other.value() : other;
  29660. stack || (stack = new Stack);
  29661. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  29662. }
  29663. }
  29664. if (!isSameTag) {
  29665. return false;
  29666. }
  29667. stack || (stack = new Stack);
  29668. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  29669. }
  29670. module.exports = baseIsEqualDeep;
  29671. /***/ }),
  29672. /***/ "../../node_modules/lodash/_baseIsMatch.js":
  29673. /*!*************************************************!*\
  29674. !*** ../../node_modules/lodash/_baseIsMatch.js ***!
  29675. \*************************************************/
  29676. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  29677. var Stack = __webpack_require__(/*! ./_Stack */ "../../node_modules/lodash/_Stack.js"),
  29678. baseIsEqual = __webpack_require__(/*! ./_baseIsEqual */ "../../node_modules/lodash/_baseIsEqual.js");
  29679. /** Used to compose bitmasks for value comparisons. */
  29680. var COMPARE_PARTIAL_FLAG = 1,
  29681. COMPARE_UNORDERED_FLAG = 2;
  29682. /**
  29683. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  29684. *
  29685. * @private
  29686. * @param {Object} object The object to inspect.
  29687. * @param {Object} source The object of property values to match.
  29688. * @param {Array} matchData The property names, values, and compare flags to match.
  29689. * @param {Function} [customizer] The function to customize comparisons.
  29690. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  29691. */
  29692. function baseIsMatch(object, source, matchData, customizer) {
  29693. var index = matchData.length,
  29694. length = index,
  29695. noCustomizer = !customizer;
  29696. if (object == null) {
  29697. return !length;
  29698. }
  29699. object = Object(object);
  29700. while (index--) {
  29701. var data = matchData[index];
  29702. if ((noCustomizer && data[2])
  29703. ? data[1] !== object[data[0]]
  29704. : !(data[0] in object)
  29705. ) {
  29706. return false;
  29707. }
  29708. }
  29709. while (++index < length) {
  29710. data = matchData[index];
  29711. var key = data[0],
  29712. objValue = object[key],
  29713. srcValue = data[1];
  29714. if (noCustomizer && data[2]) {
  29715. if (objValue === undefined && !(key in object)) {
  29716. return false;
  29717. }
  29718. } else {
  29719. var stack = new Stack;
  29720. if (customizer) {
  29721. var result = customizer(objValue, srcValue, key, object, source, stack);
  29722. }
  29723. if (!(result === undefined
  29724. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  29725. : result
  29726. )) {
  29727. return false;
  29728. }
  29729. }
  29730. }
  29731. return true;
  29732. }
  29733. module.exports = baseIsMatch;
  29734. /***/ }),
  29735. /***/ "../../node_modules/lodash/_baseIsNative.js":
  29736. /*!**************************************************!*\
  29737. !*** ../../node_modules/lodash/_baseIsNative.js ***!
  29738. \**************************************************/
  29739. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  29740. var isFunction = __webpack_require__(/*! ./isFunction */ "../../node_modules/lodash/isFunction.js"),
  29741. isMasked = __webpack_require__(/*! ./_isMasked */ "../../node_modules/lodash/_isMasked.js"),
  29742. isObject = __webpack_require__(/*! ./isObject */ "../../node_modules/lodash/isObject.js"),
  29743. toSource = __webpack_require__(/*! ./_toSource */ "../../node_modules/lodash/_toSource.js");
  29744. /**
  29745. * Used to match `RegExp`
  29746. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  29747. */
  29748. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  29749. /** Used to detect host constructors (Safari). */
  29750. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  29751. /** Used for built-in method references. */
  29752. var funcProto = Function.prototype,
  29753. objectProto = Object.prototype;
  29754. /** Used to resolve the decompiled source of functions. */
  29755. var funcToString = funcProto.toString;
  29756. /** Used to check objects for own properties. */
  29757. var hasOwnProperty = objectProto.hasOwnProperty;
  29758. /** Used to detect if a method is native. */
  29759. var reIsNative = RegExp('^' +
  29760. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  29761. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  29762. );
  29763. /**
  29764. * The base implementation of `_.isNative` without bad shim checks.
  29765. *
  29766. * @private
  29767. * @param {*} value The value to check.
  29768. * @returns {boolean} Returns `true` if `value` is a native function,
  29769. * else `false`.
  29770. */
  29771. function baseIsNative(value) {
  29772. if (!isObject(value) || isMasked(value)) {
  29773. return false;
  29774. }
  29775. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  29776. return pattern.test(toSource(value));
  29777. }
  29778. module.exports = baseIsNative;
  29779. /***/ }),
  29780. /***/ "../../node_modules/lodash/_baseIsTypedArray.js":
  29781. /*!******************************************************!*\
  29782. !*** ../../node_modules/lodash/_baseIsTypedArray.js ***!
  29783. \******************************************************/
  29784. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  29785. var baseGetTag = __webpack_require__(/*! ./_baseGetTag */ "../../node_modules/lodash/_baseGetTag.js"),
  29786. isLength = __webpack_require__(/*! ./isLength */ "../../node_modules/lodash/isLength.js"),
  29787. isObjectLike = __webpack_require__(/*! ./isObjectLike */ "../../node_modules/lodash/isObjectLike.js");
  29788. /** `Object#toString` result references. */
  29789. var argsTag = '[object Arguments]',
  29790. arrayTag = '[object Array]',
  29791. boolTag = '[object Boolean]',
  29792. dateTag = '[object Date]',
  29793. errorTag = '[object Error]',
  29794. funcTag = '[object Function]',
  29795. mapTag = '[object Map]',
  29796. numberTag = '[object Number]',
  29797. objectTag = '[object Object]',
  29798. regexpTag = '[object RegExp]',
  29799. setTag = '[object Set]',
  29800. stringTag = '[object String]',
  29801. weakMapTag = '[object WeakMap]';
  29802. var arrayBufferTag = '[object ArrayBuffer]',
  29803. dataViewTag = '[object DataView]',
  29804. float32Tag = '[object Float32Array]',
  29805. float64Tag = '[object Float64Array]',
  29806. int8Tag = '[object Int8Array]',
  29807. int16Tag = '[object Int16Array]',
  29808. int32Tag = '[object Int32Array]',
  29809. uint8Tag = '[object Uint8Array]',
  29810. uint8ClampedTag = '[object Uint8ClampedArray]',
  29811. uint16Tag = '[object Uint16Array]',
  29812. uint32Tag = '[object Uint32Array]';
  29813. /** Used to identify `toStringTag` values of typed arrays. */
  29814. var typedArrayTags = {};
  29815. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  29816. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  29817. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  29818. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  29819. typedArrayTags[uint32Tag] = true;
  29820. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  29821. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  29822. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  29823. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  29824. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  29825. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  29826. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  29827. typedArrayTags[weakMapTag] = false;
  29828. /**
  29829. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  29830. *
  29831. * @private
  29832. * @param {*} value The value to check.
  29833. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  29834. */
  29835. function baseIsTypedArray(value) {
  29836. return isObjectLike(value) &&
  29837. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  29838. }
  29839. module.exports = baseIsTypedArray;
  29840. /***/ }),
  29841. /***/ "../../node_modules/lodash/_baseIteratee.js":
  29842. /*!**************************************************!*\
  29843. !*** ../../node_modules/lodash/_baseIteratee.js ***!
  29844. \**************************************************/
  29845. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  29846. var baseMatches = __webpack_require__(/*! ./_baseMatches */ "../../node_modules/lodash/_baseMatches.js"),
  29847. baseMatchesProperty = __webpack_require__(/*! ./_baseMatchesProperty */ "../../node_modules/lodash/_baseMatchesProperty.js"),
  29848. identity = __webpack_require__(/*! ./identity */ "../../node_modules/lodash/identity.js"),
  29849. isArray = __webpack_require__(/*! ./isArray */ "../../node_modules/lodash/isArray.js"),
  29850. property = __webpack_require__(/*! ./property */ "../../node_modules/lodash/property.js");
  29851. /**
  29852. * The base implementation of `_.iteratee`.
  29853. *
  29854. * @private
  29855. * @param {*} [value=_.identity] The value to convert to an iteratee.
  29856. * @returns {Function} Returns the iteratee.
  29857. */
  29858. function baseIteratee(value) {
  29859. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  29860. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  29861. if (typeof value == 'function') {
  29862. return value;
  29863. }
  29864. if (value == null) {
  29865. return identity;
  29866. }
  29867. if (typeof value == 'object') {
  29868. return isArray(value)
  29869. ? baseMatchesProperty(value[0], value[1])
  29870. : baseMatches(value);
  29871. }
  29872. return property(value);
  29873. }
  29874. module.exports = baseIteratee;
  29875. /***/ }),
  29876. /***/ "../../node_modules/lodash/_baseKeys.js":
  29877. /*!**********************************************!*\
  29878. !*** ../../node_modules/lodash/_baseKeys.js ***!
  29879. \**********************************************/
  29880. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  29881. var isPrototype = __webpack_require__(/*! ./_isPrototype */ "../../node_modules/lodash/_isPrototype.js"),
  29882. nativeKeys = __webpack_require__(/*! ./_nativeKeys */ "../../node_modules/lodash/_nativeKeys.js");
  29883. /** Used for built-in method references. */
  29884. var objectProto = Object.prototype;
  29885. /** Used to check objects for own properties. */
  29886. var hasOwnProperty = objectProto.hasOwnProperty;
  29887. /**
  29888. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  29889. *
  29890. * @private
  29891. * @param {Object} object The object to query.
  29892. * @returns {Array} Returns the array of property names.
  29893. */
  29894. function baseKeys(object) {
  29895. if (!isPrototype(object)) {
  29896. return nativeKeys(object);
  29897. }
  29898. var result = [];
  29899. for (var key in Object(object)) {
  29900. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  29901. result.push(key);
  29902. }
  29903. }
  29904. return result;
  29905. }
  29906. module.exports = baseKeys;
  29907. /***/ }),
  29908. /***/ "../../node_modules/lodash/_baseKeysIn.js":
  29909. /*!************************************************!*\
  29910. !*** ../../node_modules/lodash/_baseKeysIn.js ***!
  29911. \************************************************/
  29912. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  29913. var isObject = __webpack_require__(/*! ./isObject */ "../../node_modules/lodash/isObject.js"),
  29914. isPrototype = __webpack_require__(/*! ./_isPrototype */ "../../node_modules/lodash/_isPrototype.js"),
  29915. nativeKeysIn = __webpack_require__(/*! ./_nativeKeysIn */ "../../node_modules/lodash/_nativeKeysIn.js");
  29916. /** Used for built-in method references. */
  29917. var objectProto = Object.prototype;
  29918. /** Used to check objects for own properties. */
  29919. var hasOwnProperty = objectProto.hasOwnProperty;
  29920. /**
  29921. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  29922. *
  29923. * @private
  29924. * @param {Object} object The object to query.
  29925. * @returns {Array} Returns the array of property names.
  29926. */
  29927. function baseKeysIn(object) {
  29928. if (!isObject(object)) {
  29929. return nativeKeysIn(object);
  29930. }
  29931. var isProto = isPrototype(object),
  29932. result = [];
  29933. for (var key in object) {
  29934. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  29935. result.push(key);
  29936. }
  29937. }
  29938. return result;
  29939. }
  29940. module.exports = baseKeysIn;
  29941. /***/ }),
  29942. /***/ "../../node_modules/lodash/_baseMap.js":
  29943. /*!*********************************************!*\
  29944. !*** ../../node_modules/lodash/_baseMap.js ***!
  29945. \*********************************************/
  29946. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  29947. var baseEach = __webpack_require__(/*! ./_baseEach */ "../../node_modules/lodash/_baseEach.js"),
  29948. isArrayLike = __webpack_require__(/*! ./isArrayLike */ "../../node_modules/lodash/isArrayLike.js");
  29949. /**
  29950. * The base implementation of `_.map` without support for iteratee shorthands.
  29951. *
  29952. * @private
  29953. * @param {Array|Object} collection The collection to iterate over.
  29954. * @param {Function} iteratee The function invoked per iteration.
  29955. * @returns {Array} Returns the new mapped array.
  29956. */
  29957. function baseMap(collection, iteratee) {
  29958. var index = -1,
  29959. result = isArrayLike(collection) ? Array(collection.length) : [];
  29960. baseEach(collection, function(value, key, collection) {
  29961. result[++index] = iteratee(value, key, collection);
  29962. });
  29963. return result;
  29964. }
  29965. module.exports = baseMap;
  29966. /***/ }),
  29967. /***/ "../../node_modules/lodash/_baseMatches.js":
  29968. /*!*************************************************!*\
  29969. !*** ../../node_modules/lodash/_baseMatches.js ***!
  29970. \*************************************************/
  29971. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  29972. var baseIsMatch = __webpack_require__(/*! ./_baseIsMatch */ "../../node_modules/lodash/_baseIsMatch.js"),
  29973. getMatchData = __webpack_require__(/*! ./_getMatchData */ "../../node_modules/lodash/_getMatchData.js"),
  29974. matchesStrictComparable = __webpack_require__(/*! ./_matchesStrictComparable */ "../../node_modules/lodash/_matchesStrictComparable.js");
  29975. /**
  29976. * The base implementation of `_.matches` which doesn't clone `source`.
  29977. *
  29978. * @private
  29979. * @param {Object} source The object of property values to match.
  29980. * @returns {Function} Returns the new spec function.
  29981. */
  29982. function baseMatches(source) {
  29983. var matchData = getMatchData(source);
  29984. if (matchData.length == 1 && matchData[0][2]) {
  29985. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  29986. }
  29987. return function(object) {
  29988. return object === source || baseIsMatch(object, source, matchData);
  29989. };
  29990. }
  29991. module.exports = baseMatches;
  29992. /***/ }),
  29993. /***/ "../../node_modules/lodash/_baseMatchesProperty.js":
  29994. /*!*********************************************************!*\
  29995. !*** ../../node_modules/lodash/_baseMatchesProperty.js ***!
  29996. \*********************************************************/
  29997. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  29998. var baseIsEqual = __webpack_require__(/*! ./_baseIsEqual */ "../../node_modules/lodash/_baseIsEqual.js"),
  29999. get = __webpack_require__(/*! ./get */ "../../node_modules/lodash/get.js"),
  30000. hasIn = __webpack_require__(/*! ./hasIn */ "../../node_modules/lodash/hasIn.js"),
  30001. isKey = __webpack_require__(/*! ./_isKey */ "../../node_modules/lodash/_isKey.js"),
  30002. isStrictComparable = __webpack_require__(/*! ./_isStrictComparable */ "../../node_modules/lodash/_isStrictComparable.js"),
  30003. matchesStrictComparable = __webpack_require__(/*! ./_matchesStrictComparable */ "../../node_modules/lodash/_matchesStrictComparable.js"),
  30004. toKey = __webpack_require__(/*! ./_toKey */ "../../node_modules/lodash/_toKey.js");
  30005. /** Used to compose bitmasks for value comparisons. */
  30006. var COMPARE_PARTIAL_FLAG = 1,
  30007. COMPARE_UNORDERED_FLAG = 2;
  30008. /**
  30009. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  30010. *
  30011. * @private
  30012. * @param {string} path The path of the property to get.
  30013. * @param {*} srcValue The value to match.
  30014. * @returns {Function} Returns the new spec function.
  30015. */
  30016. function baseMatchesProperty(path, srcValue) {
  30017. if (isKey(path) && isStrictComparable(srcValue)) {
  30018. return matchesStrictComparable(toKey(path), srcValue);
  30019. }
  30020. return function(object) {
  30021. var objValue = get(object, path);
  30022. return (objValue === undefined && objValue === srcValue)
  30023. ? hasIn(object, path)
  30024. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  30025. };
  30026. }
  30027. module.exports = baseMatchesProperty;
  30028. /***/ }),
  30029. /***/ "../../node_modules/lodash/_basePickBy.js":
  30030. /*!************************************************!*\
  30031. !*** ../../node_modules/lodash/_basePickBy.js ***!
  30032. \************************************************/
  30033. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  30034. var baseGet = __webpack_require__(/*! ./_baseGet */ "../../node_modules/lodash/_baseGet.js"),
  30035. baseSet = __webpack_require__(/*! ./_baseSet */ "../../node_modules/lodash/_baseSet.js"),
  30036. castPath = __webpack_require__(/*! ./_castPath */ "../../node_modules/lodash/_castPath.js");
  30037. /**
  30038. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  30039. *
  30040. * @private
  30041. * @param {Object} object The source object.
  30042. * @param {string[]} paths The property paths to pick.
  30043. * @param {Function} predicate The function invoked per property.
  30044. * @returns {Object} Returns the new object.
  30045. */
  30046. function basePickBy(object, paths, predicate) {
  30047. var index = -1,
  30048. length = paths.length,
  30049. result = {};
  30050. while (++index < length) {
  30051. var path = paths[index],
  30052. value = baseGet(object, path);
  30053. if (predicate(value, path)) {
  30054. baseSet(result, castPath(path, object), value);
  30055. }
  30056. }
  30057. return result;
  30058. }
  30059. module.exports = basePickBy;
  30060. /***/ }),
  30061. /***/ "../../node_modules/lodash/_baseProperty.js":
  30062. /*!**************************************************!*\
  30063. !*** ../../node_modules/lodash/_baseProperty.js ***!
  30064. \**************************************************/
  30065. /***/ ((module) => {
  30066. /**
  30067. * The base implementation of `_.property` without support for deep paths.
  30068. *
  30069. * @private
  30070. * @param {string} key The key of the property to get.
  30071. * @returns {Function} Returns the new accessor function.
  30072. */
  30073. function baseProperty(key) {
  30074. return function(object) {
  30075. return object == null ? undefined : object[key];
  30076. };
  30077. }
  30078. module.exports = baseProperty;
  30079. /***/ }),
  30080. /***/ "../../node_modules/lodash/_basePropertyDeep.js":
  30081. /*!******************************************************!*\
  30082. !*** ../../node_modules/lodash/_basePropertyDeep.js ***!
  30083. \******************************************************/
  30084. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  30085. var baseGet = __webpack_require__(/*! ./_baseGet */ "../../node_modules/lodash/_baseGet.js");
  30086. /**
  30087. * A specialized version of `baseProperty` which supports deep paths.
  30088. *
  30089. * @private
  30090. * @param {Array|string} path The path of the property to get.
  30091. * @returns {Function} Returns the new accessor function.
  30092. */
  30093. function basePropertyDeep(path) {
  30094. return function(object) {
  30095. return baseGet(object, path);
  30096. };
  30097. }
  30098. module.exports = basePropertyDeep;
  30099. /***/ }),
  30100. /***/ "../../node_modules/lodash/_baseSet.js":
  30101. /*!*********************************************!*\
  30102. !*** ../../node_modules/lodash/_baseSet.js ***!
  30103. \*********************************************/
  30104. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  30105. var assignValue = __webpack_require__(/*! ./_assignValue */ "../../node_modules/lodash/_assignValue.js"),
  30106. castPath = __webpack_require__(/*! ./_castPath */ "../../node_modules/lodash/_castPath.js"),
  30107. isIndex = __webpack_require__(/*! ./_isIndex */ "../../node_modules/lodash/_isIndex.js"),
  30108. isObject = __webpack_require__(/*! ./isObject */ "../../node_modules/lodash/isObject.js"),
  30109. toKey = __webpack_require__(/*! ./_toKey */ "../../node_modules/lodash/_toKey.js");
  30110. /**
  30111. * The base implementation of `_.set`.
  30112. *
  30113. * @private
  30114. * @param {Object} object The object to modify.
  30115. * @param {Array|string} path The path of the property to set.
  30116. * @param {*} value The value to set.
  30117. * @param {Function} [customizer] The function to customize path creation.
  30118. * @returns {Object} Returns `object`.
  30119. */
  30120. function baseSet(object, path, value, customizer) {
  30121. if (!isObject(object)) {
  30122. return object;
  30123. }
  30124. path = castPath(path, object);
  30125. var index = -1,
  30126. length = path.length,
  30127. lastIndex = length - 1,
  30128. nested = object;
  30129. while (nested != null && ++index < length) {
  30130. var key = toKey(path[index]),
  30131. newValue = value;
  30132. if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
  30133. return object;
  30134. }
  30135. if (index != lastIndex) {
  30136. var objValue = nested[key];
  30137. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  30138. if (newValue === undefined) {
  30139. newValue = isObject(objValue)
  30140. ? objValue
  30141. : (isIndex(path[index + 1]) ? [] : {});
  30142. }
  30143. }
  30144. assignValue(nested, key, newValue);
  30145. nested = nested[key];
  30146. }
  30147. return object;
  30148. }
  30149. module.exports = baseSet;
  30150. /***/ }),
  30151. /***/ "../../node_modules/lodash/_baseTimes.js":
  30152. /*!***********************************************!*\
  30153. !*** ../../node_modules/lodash/_baseTimes.js ***!
  30154. \***********************************************/
  30155. /***/ ((module) => {
  30156. /**
  30157. * The base implementation of `_.times` without support for iteratee shorthands
  30158. * or max array length checks.
  30159. *
  30160. * @private
  30161. * @param {number} n The number of times to invoke `iteratee`.
  30162. * @param {Function} iteratee The function invoked per iteration.
  30163. * @returns {Array} Returns the array of results.
  30164. */
  30165. function baseTimes(n, iteratee) {
  30166. var index = -1,
  30167. result = Array(n);
  30168. while (++index < n) {
  30169. result[index] = iteratee(index);
  30170. }
  30171. return result;
  30172. }
  30173. module.exports = baseTimes;
  30174. /***/ }),
  30175. /***/ "../../node_modules/lodash/_baseToString.js":
  30176. /*!**************************************************!*\
  30177. !*** ../../node_modules/lodash/_baseToString.js ***!
  30178. \**************************************************/
  30179. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  30180. var Symbol = __webpack_require__(/*! ./_Symbol */ "../../node_modules/lodash/_Symbol.js"),
  30181. arrayMap = __webpack_require__(/*! ./_arrayMap */ "../../node_modules/lodash/_arrayMap.js"),
  30182. isArray = __webpack_require__(/*! ./isArray */ "../../node_modules/lodash/isArray.js"),
  30183. isSymbol = __webpack_require__(/*! ./isSymbol */ "../../node_modules/lodash/isSymbol.js");
  30184. /** Used as references for various `Number` constants. */
  30185. var INFINITY = 1 / 0;
  30186. /** Used to convert symbols to primitives and strings. */
  30187. var symbolProto = Symbol ? Symbol.prototype : undefined,
  30188. symbolToString = symbolProto ? symbolProto.toString : undefined;
  30189. /**
  30190. * The base implementation of `_.toString` which doesn't convert nullish
  30191. * values to empty strings.
  30192. *
  30193. * @private
  30194. * @param {*} value The value to process.
  30195. * @returns {string} Returns the string.
  30196. */
  30197. function baseToString(value) {
  30198. // Exit early for strings to avoid a performance hit in some environments.
  30199. if (typeof value == 'string') {
  30200. return value;
  30201. }
  30202. if (isArray(value)) {
  30203. // Recursively convert values (susceptible to call stack limits).
  30204. return arrayMap(value, baseToString) + '';
  30205. }
  30206. if (isSymbol(value)) {
  30207. return symbolToString ? symbolToString.call(value) : '';
  30208. }
  30209. var result = (value + '');
  30210. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  30211. }
  30212. module.exports = baseToString;
  30213. /***/ }),
  30214. /***/ "../../node_modules/lodash/_baseUnary.js":
  30215. /*!***********************************************!*\
  30216. !*** ../../node_modules/lodash/_baseUnary.js ***!
  30217. \***********************************************/
  30218. /***/ ((module) => {
  30219. /**
  30220. * The base implementation of `_.unary` without support for storing metadata.
  30221. *
  30222. * @private
  30223. * @param {Function} func The function to cap arguments for.
  30224. * @returns {Function} Returns the new capped function.
  30225. */
  30226. function baseUnary(func) {
  30227. return function(value) {
  30228. return func(value);
  30229. };
  30230. }
  30231. module.exports = baseUnary;
  30232. /***/ }),
  30233. /***/ "../../node_modules/lodash/_cacheHas.js":
  30234. /*!**********************************************!*\
  30235. !*** ../../node_modules/lodash/_cacheHas.js ***!
  30236. \**********************************************/
  30237. /***/ ((module) => {
  30238. /**
  30239. * Checks if a `cache` value for `key` exists.
  30240. *
  30241. * @private
  30242. * @param {Object} cache The cache to query.
  30243. * @param {string} key The key of the entry to check.
  30244. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  30245. */
  30246. function cacheHas(cache, key) {
  30247. return cache.has(key);
  30248. }
  30249. module.exports = cacheHas;
  30250. /***/ }),
  30251. /***/ "../../node_modules/lodash/_castPath.js":
  30252. /*!**********************************************!*\
  30253. !*** ../../node_modules/lodash/_castPath.js ***!
  30254. \**********************************************/
  30255. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  30256. var isArray = __webpack_require__(/*! ./isArray */ "../../node_modules/lodash/isArray.js"),
  30257. isKey = __webpack_require__(/*! ./_isKey */ "../../node_modules/lodash/_isKey.js"),
  30258. stringToPath = __webpack_require__(/*! ./_stringToPath */ "../../node_modules/lodash/_stringToPath.js"),
  30259. toString = __webpack_require__(/*! ./toString */ "../../node_modules/lodash/toString.js");
  30260. /**
  30261. * Casts `value` to a path array if it's not one.
  30262. *
  30263. * @private
  30264. * @param {*} value The value to inspect.
  30265. * @param {Object} [object] The object to query keys on.
  30266. * @returns {Array} Returns the cast property path array.
  30267. */
  30268. function castPath(value, object) {
  30269. if (isArray(value)) {
  30270. return value;
  30271. }
  30272. return isKey(value, object) ? [value] : stringToPath(toString(value));
  30273. }
  30274. module.exports = castPath;
  30275. /***/ }),
  30276. /***/ "../../node_modules/lodash/_coreJsData.js":
  30277. /*!************************************************!*\
  30278. !*** ../../node_modules/lodash/_coreJsData.js ***!
  30279. \************************************************/
  30280. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  30281. var root = __webpack_require__(/*! ./_root */ "../../node_modules/lodash/_root.js");
  30282. /** Used to detect overreaching core-js shims. */
  30283. var coreJsData = root['__core-js_shared__'];
  30284. module.exports = coreJsData;
  30285. /***/ }),
  30286. /***/ "../../node_modules/lodash/_createAggregator.js":
  30287. /*!******************************************************!*\
  30288. !*** ../../node_modules/lodash/_createAggregator.js ***!
  30289. \******************************************************/
  30290. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  30291. var arrayAggregator = __webpack_require__(/*! ./_arrayAggregator */ "../../node_modules/lodash/_arrayAggregator.js"),
  30292. baseAggregator = __webpack_require__(/*! ./_baseAggregator */ "../../node_modules/lodash/_baseAggregator.js"),
  30293. baseIteratee = __webpack_require__(/*! ./_baseIteratee */ "../../node_modules/lodash/_baseIteratee.js"),
  30294. isArray = __webpack_require__(/*! ./isArray */ "../../node_modules/lodash/isArray.js");
  30295. /**
  30296. * Creates a function like `_.groupBy`.
  30297. *
  30298. * @private
  30299. * @param {Function} setter The function to set accumulator values.
  30300. * @param {Function} [initializer] The accumulator object initializer.
  30301. * @returns {Function} Returns the new aggregator function.
  30302. */
  30303. function createAggregator(setter, initializer) {
  30304. return function(collection, iteratee) {
  30305. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  30306. accumulator = initializer ? initializer() : {};
  30307. return func(collection, setter, baseIteratee(iteratee, 2), accumulator);
  30308. };
  30309. }
  30310. module.exports = createAggregator;
  30311. /***/ }),
  30312. /***/ "../../node_modules/lodash/_createBaseEach.js":
  30313. /*!****************************************************!*\
  30314. !*** ../../node_modules/lodash/_createBaseEach.js ***!
  30315. \****************************************************/
  30316. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  30317. var isArrayLike = __webpack_require__(/*! ./isArrayLike */ "../../node_modules/lodash/isArrayLike.js");
  30318. /**
  30319. * Creates a `baseEach` or `baseEachRight` function.
  30320. *
  30321. * @private
  30322. * @param {Function} eachFunc The function to iterate over a collection.
  30323. * @param {boolean} [fromRight] Specify iterating from right to left.
  30324. * @returns {Function} Returns the new base function.
  30325. */
  30326. function createBaseEach(eachFunc, fromRight) {
  30327. return function(collection, iteratee) {
  30328. if (collection == null) {
  30329. return collection;
  30330. }
  30331. if (!isArrayLike(collection)) {
  30332. return eachFunc(collection, iteratee);
  30333. }
  30334. var length = collection.length,
  30335. index = fromRight ? length : -1,
  30336. iterable = Object(collection);
  30337. while ((fromRight ? index-- : ++index < length)) {
  30338. if (iteratee(iterable[index], index, iterable) === false) {
  30339. break;
  30340. }
  30341. }
  30342. return collection;
  30343. };
  30344. }
  30345. module.exports = createBaseEach;
  30346. /***/ }),
  30347. /***/ "../../node_modules/lodash/_createBaseFor.js":
  30348. /*!***************************************************!*\
  30349. !*** ../../node_modules/lodash/_createBaseFor.js ***!
  30350. \***************************************************/
  30351. /***/ ((module) => {
  30352. /**
  30353. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  30354. *
  30355. * @private
  30356. * @param {boolean} [fromRight] Specify iterating from right to left.
  30357. * @returns {Function} Returns the new base function.
  30358. */
  30359. function createBaseFor(fromRight) {
  30360. return function(object, iteratee, keysFunc) {
  30361. var index = -1,
  30362. iterable = Object(object),
  30363. props = keysFunc(object),
  30364. length = props.length;
  30365. while (length--) {
  30366. var key = props[fromRight ? length : ++index];
  30367. if (iteratee(iterable[key], key, iterable) === false) {
  30368. break;
  30369. }
  30370. }
  30371. return object;
  30372. };
  30373. }
  30374. module.exports = createBaseFor;
  30375. /***/ }),
  30376. /***/ "../../node_modules/lodash/_defineProperty.js":
  30377. /*!****************************************************!*\
  30378. !*** ../../node_modules/lodash/_defineProperty.js ***!
  30379. \****************************************************/
  30380. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  30381. var getNative = __webpack_require__(/*! ./_getNative */ "../../node_modules/lodash/_getNative.js");
  30382. var defineProperty = (function() {
  30383. try {
  30384. var func = getNative(Object, 'defineProperty');
  30385. func({}, '', {});
  30386. return func;
  30387. } catch (e) {}
  30388. }());
  30389. module.exports = defineProperty;
  30390. /***/ }),
  30391. /***/ "../../node_modules/lodash/_equalArrays.js":
  30392. /*!*************************************************!*\
  30393. !*** ../../node_modules/lodash/_equalArrays.js ***!
  30394. \*************************************************/
  30395. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  30396. var SetCache = __webpack_require__(/*! ./_SetCache */ "../../node_modules/lodash/_SetCache.js"),
  30397. arraySome = __webpack_require__(/*! ./_arraySome */ "../../node_modules/lodash/_arraySome.js"),
  30398. cacheHas = __webpack_require__(/*! ./_cacheHas */ "../../node_modules/lodash/_cacheHas.js");
  30399. /** Used to compose bitmasks for value comparisons. */
  30400. var COMPARE_PARTIAL_FLAG = 1,
  30401. COMPARE_UNORDERED_FLAG = 2;
  30402. /**
  30403. * A specialized version of `baseIsEqualDeep` for arrays with support for
  30404. * partial deep comparisons.
  30405. *
  30406. * @private
  30407. * @param {Array} array The array to compare.
  30408. * @param {Array} other The other array to compare.
  30409. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  30410. * @param {Function} customizer The function to customize comparisons.
  30411. * @param {Function} equalFunc The function to determine equivalents of values.
  30412. * @param {Object} stack Tracks traversed `array` and `other` objects.
  30413. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  30414. */
  30415. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  30416. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  30417. arrLength = array.length,
  30418. othLength = other.length;
  30419. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  30420. return false;
  30421. }
  30422. // Check that cyclic values are equal.
  30423. var arrStacked = stack.get(array);
  30424. var othStacked = stack.get(other);
  30425. if (arrStacked && othStacked) {
  30426. return arrStacked == other && othStacked == array;
  30427. }
  30428. var index = -1,
  30429. result = true,
  30430. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  30431. stack.set(array, other);
  30432. stack.set(other, array);
  30433. // Ignore non-index properties.
  30434. while (++index < arrLength) {
  30435. var arrValue = array[index],
  30436. othValue = other[index];
  30437. if (customizer) {
  30438. var compared = isPartial
  30439. ? customizer(othValue, arrValue, index, other, array, stack)
  30440. : customizer(arrValue, othValue, index, array, other, stack);
  30441. }
  30442. if (compared !== undefined) {
  30443. if (compared) {
  30444. continue;
  30445. }
  30446. result = false;
  30447. break;
  30448. }
  30449. // Recursively compare arrays (susceptible to call stack limits).
  30450. if (seen) {
  30451. if (!arraySome(other, function(othValue, othIndex) {
  30452. if (!cacheHas(seen, othIndex) &&
  30453. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  30454. return seen.push(othIndex);
  30455. }
  30456. })) {
  30457. result = false;
  30458. break;
  30459. }
  30460. } else if (!(
  30461. arrValue === othValue ||
  30462. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  30463. )) {
  30464. result = false;
  30465. break;
  30466. }
  30467. }
  30468. stack['delete'](array);
  30469. stack['delete'](other);
  30470. return result;
  30471. }
  30472. module.exports = equalArrays;
  30473. /***/ }),
  30474. /***/ "../../node_modules/lodash/_equalByTag.js":
  30475. /*!************************************************!*\
  30476. !*** ../../node_modules/lodash/_equalByTag.js ***!
  30477. \************************************************/
  30478. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  30479. var Symbol = __webpack_require__(/*! ./_Symbol */ "../../node_modules/lodash/_Symbol.js"),
  30480. Uint8Array = __webpack_require__(/*! ./_Uint8Array */ "../../node_modules/lodash/_Uint8Array.js"),
  30481. eq = __webpack_require__(/*! ./eq */ "../../node_modules/lodash/eq.js"),
  30482. equalArrays = __webpack_require__(/*! ./_equalArrays */ "../../node_modules/lodash/_equalArrays.js"),
  30483. mapToArray = __webpack_require__(/*! ./_mapToArray */ "../../node_modules/lodash/_mapToArray.js"),
  30484. setToArray = __webpack_require__(/*! ./_setToArray */ "../../node_modules/lodash/_setToArray.js");
  30485. /** Used to compose bitmasks for value comparisons. */
  30486. var COMPARE_PARTIAL_FLAG = 1,
  30487. COMPARE_UNORDERED_FLAG = 2;
  30488. /** `Object#toString` result references. */
  30489. var boolTag = '[object Boolean]',
  30490. dateTag = '[object Date]',
  30491. errorTag = '[object Error]',
  30492. mapTag = '[object Map]',
  30493. numberTag = '[object Number]',
  30494. regexpTag = '[object RegExp]',
  30495. setTag = '[object Set]',
  30496. stringTag = '[object String]',
  30497. symbolTag = '[object Symbol]';
  30498. var arrayBufferTag = '[object ArrayBuffer]',
  30499. dataViewTag = '[object DataView]';
  30500. /** Used to convert symbols to primitives and strings. */
  30501. var symbolProto = Symbol ? Symbol.prototype : undefined,
  30502. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
  30503. /**
  30504. * A specialized version of `baseIsEqualDeep` for comparing objects of
  30505. * the same `toStringTag`.
  30506. *
  30507. * **Note:** This function only supports comparing values with tags of
  30508. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  30509. *
  30510. * @private
  30511. * @param {Object} object The object to compare.
  30512. * @param {Object} other The other object to compare.
  30513. * @param {string} tag The `toStringTag` of the objects to compare.
  30514. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  30515. * @param {Function} customizer The function to customize comparisons.
  30516. * @param {Function} equalFunc The function to determine equivalents of values.
  30517. * @param {Object} stack Tracks traversed `object` and `other` objects.
  30518. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  30519. */
  30520. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  30521. switch (tag) {
  30522. case dataViewTag:
  30523. if ((object.byteLength != other.byteLength) ||
  30524. (object.byteOffset != other.byteOffset)) {
  30525. return false;
  30526. }
  30527. object = object.buffer;
  30528. other = other.buffer;
  30529. case arrayBufferTag:
  30530. if ((object.byteLength != other.byteLength) ||
  30531. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  30532. return false;
  30533. }
  30534. return true;
  30535. case boolTag:
  30536. case dateTag:
  30537. case numberTag:
  30538. // Coerce booleans to `1` or `0` and dates to milliseconds.
  30539. // Invalid dates are coerced to `NaN`.
  30540. return eq(+object, +other);
  30541. case errorTag:
  30542. return object.name == other.name && object.message == other.message;
  30543. case regexpTag:
  30544. case stringTag:
  30545. // Coerce regexes to strings and treat strings, primitives and objects,
  30546. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  30547. // for more details.
  30548. return object == (other + '');
  30549. case mapTag:
  30550. var convert = mapToArray;
  30551. case setTag:
  30552. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  30553. convert || (convert = setToArray);
  30554. if (object.size != other.size && !isPartial) {
  30555. return false;
  30556. }
  30557. // Assume cyclic values are equal.
  30558. var stacked = stack.get(object);
  30559. if (stacked) {
  30560. return stacked == other;
  30561. }
  30562. bitmask |= COMPARE_UNORDERED_FLAG;
  30563. // Recursively compare objects (susceptible to call stack limits).
  30564. stack.set(object, other);
  30565. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  30566. stack['delete'](object);
  30567. return result;
  30568. case symbolTag:
  30569. if (symbolValueOf) {
  30570. return symbolValueOf.call(object) == symbolValueOf.call(other);
  30571. }
  30572. }
  30573. return false;
  30574. }
  30575. module.exports = equalByTag;
  30576. /***/ }),
  30577. /***/ "../../node_modules/lodash/_equalObjects.js":
  30578. /*!**************************************************!*\
  30579. !*** ../../node_modules/lodash/_equalObjects.js ***!
  30580. \**************************************************/
  30581. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  30582. var getAllKeys = __webpack_require__(/*! ./_getAllKeys */ "../../node_modules/lodash/_getAllKeys.js");
  30583. /** Used to compose bitmasks for value comparisons. */
  30584. var COMPARE_PARTIAL_FLAG = 1;
  30585. /** Used for built-in method references. */
  30586. var objectProto = Object.prototype;
  30587. /** Used to check objects for own properties. */
  30588. var hasOwnProperty = objectProto.hasOwnProperty;
  30589. /**
  30590. * A specialized version of `baseIsEqualDeep` for objects with support for
  30591. * partial deep comparisons.
  30592. *
  30593. * @private
  30594. * @param {Object} object The object to compare.
  30595. * @param {Object} other The other object to compare.
  30596. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  30597. * @param {Function} customizer The function to customize comparisons.
  30598. * @param {Function} equalFunc The function to determine equivalents of values.
  30599. * @param {Object} stack Tracks traversed `object` and `other` objects.
  30600. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  30601. */
  30602. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  30603. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  30604. objProps = getAllKeys(object),
  30605. objLength = objProps.length,
  30606. othProps = getAllKeys(other),
  30607. othLength = othProps.length;
  30608. if (objLength != othLength && !isPartial) {
  30609. return false;
  30610. }
  30611. var index = objLength;
  30612. while (index--) {
  30613. var key = objProps[index];
  30614. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  30615. return false;
  30616. }
  30617. }
  30618. // Check that cyclic values are equal.
  30619. var objStacked = stack.get(object);
  30620. var othStacked = stack.get(other);
  30621. if (objStacked && othStacked) {
  30622. return objStacked == other && othStacked == object;
  30623. }
  30624. var result = true;
  30625. stack.set(object, other);
  30626. stack.set(other, object);
  30627. var skipCtor = isPartial;
  30628. while (++index < objLength) {
  30629. key = objProps[index];
  30630. var objValue = object[key],
  30631. othValue = other[key];
  30632. if (customizer) {
  30633. var compared = isPartial
  30634. ? customizer(othValue, objValue, key, other, object, stack)
  30635. : customizer(objValue, othValue, key, object, other, stack);
  30636. }
  30637. // Recursively compare objects (susceptible to call stack limits).
  30638. if (!(compared === undefined
  30639. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  30640. : compared
  30641. )) {
  30642. result = false;
  30643. break;
  30644. }
  30645. skipCtor || (skipCtor = key == 'constructor');
  30646. }
  30647. if (result && !skipCtor) {
  30648. var objCtor = object.constructor,
  30649. othCtor = other.constructor;
  30650. // Non `Object` object instances with different constructors are not equal.
  30651. if (objCtor != othCtor &&
  30652. ('constructor' in object && 'constructor' in other) &&
  30653. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  30654. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  30655. result = false;
  30656. }
  30657. }
  30658. stack['delete'](object);
  30659. stack['delete'](other);
  30660. return result;
  30661. }
  30662. module.exports = equalObjects;
  30663. /***/ }),
  30664. /***/ "../../node_modules/lodash/_freeGlobal.js":
  30665. /*!************************************************!*\
  30666. !*** ../../node_modules/lodash/_freeGlobal.js ***!
  30667. \************************************************/
  30668. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  30669. /** Detect free variable `global` from Node.js. */
  30670. var freeGlobal = typeof __webpack_require__.g == 'object' && __webpack_require__.g && __webpack_require__.g.Object === Object && __webpack_require__.g;
  30671. module.exports = freeGlobal;
  30672. /***/ }),
  30673. /***/ "../../node_modules/lodash/_getAllKeys.js":
  30674. /*!************************************************!*\
  30675. !*** ../../node_modules/lodash/_getAllKeys.js ***!
  30676. \************************************************/
  30677. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  30678. var baseGetAllKeys = __webpack_require__(/*! ./_baseGetAllKeys */ "../../node_modules/lodash/_baseGetAllKeys.js"),
  30679. getSymbols = __webpack_require__(/*! ./_getSymbols */ "../../node_modules/lodash/_getSymbols.js"),
  30680. keys = __webpack_require__(/*! ./keys */ "../../node_modules/lodash/keys.js");
  30681. /**
  30682. * Creates an array of own enumerable property names and symbols of `object`.
  30683. *
  30684. * @private
  30685. * @param {Object} object The object to query.
  30686. * @returns {Array} Returns the array of property names and symbols.
  30687. */
  30688. function getAllKeys(object) {
  30689. return baseGetAllKeys(object, keys, getSymbols);
  30690. }
  30691. module.exports = getAllKeys;
  30692. /***/ }),
  30693. /***/ "../../node_modules/lodash/_getAllKeysIn.js":
  30694. /*!**************************************************!*\
  30695. !*** ../../node_modules/lodash/_getAllKeysIn.js ***!
  30696. \**************************************************/
  30697. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  30698. var baseGetAllKeys = __webpack_require__(/*! ./_baseGetAllKeys */ "../../node_modules/lodash/_baseGetAllKeys.js"),
  30699. getSymbolsIn = __webpack_require__(/*! ./_getSymbolsIn */ "../../node_modules/lodash/_getSymbolsIn.js"),
  30700. keysIn = __webpack_require__(/*! ./keysIn */ "../../node_modules/lodash/keysIn.js");
  30701. /**
  30702. * Creates an array of own and inherited enumerable property names and
  30703. * symbols of `object`.
  30704. *
  30705. * @private
  30706. * @param {Object} object The object to query.
  30707. * @returns {Array} Returns the array of property names and symbols.
  30708. */
  30709. function getAllKeysIn(object) {
  30710. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  30711. }
  30712. module.exports = getAllKeysIn;
  30713. /***/ }),
  30714. /***/ "../../node_modules/lodash/_getMapData.js":
  30715. /*!************************************************!*\
  30716. !*** ../../node_modules/lodash/_getMapData.js ***!
  30717. \************************************************/
  30718. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  30719. var isKeyable = __webpack_require__(/*! ./_isKeyable */ "../../node_modules/lodash/_isKeyable.js");
  30720. /**
  30721. * Gets the data for `map`.
  30722. *
  30723. * @private
  30724. * @param {Object} map The map to query.
  30725. * @param {string} key The reference key.
  30726. * @returns {*} Returns the map data.
  30727. */
  30728. function getMapData(map, key) {
  30729. var data = map.__data__;
  30730. return isKeyable(key)
  30731. ? data[typeof key == 'string' ? 'string' : 'hash']
  30732. : data.map;
  30733. }
  30734. module.exports = getMapData;
  30735. /***/ }),
  30736. /***/ "../../node_modules/lodash/_getMatchData.js":
  30737. /*!**************************************************!*\
  30738. !*** ../../node_modules/lodash/_getMatchData.js ***!
  30739. \**************************************************/
  30740. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  30741. var isStrictComparable = __webpack_require__(/*! ./_isStrictComparable */ "../../node_modules/lodash/_isStrictComparable.js"),
  30742. keys = __webpack_require__(/*! ./keys */ "../../node_modules/lodash/keys.js");
  30743. /**
  30744. * Gets the property names, values, and compare flags of `object`.
  30745. *
  30746. * @private
  30747. * @param {Object} object The object to query.
  30748. * @returns {Array} Returns the match data of `object`.
  30749. */
  30750. function getMatchData(object) {
  30751. var result = keys(object),
  30752. length = result.length;
  30753. while (length--) {
  30754. var key = result[length],
  30755. value = object[key];
  30756. result[length] = [key, value, isStrictComparable(value)];
  30757. }
  30758. return result;
  30759. }
  30760. module.exports = getMatchData;
  30761. /***/ }),
  30762. /***/ "../../node_modules/lodash/_getNative.js":
  30763. /*!***********************************************!*\
  30764. !*** ../../node_modules/lodash/_getNative.js ***!
  30765. \***********************************************/
  30766. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  30767. var baseIsNative = __webpack_require__(/*! ./_baseIsNative */ "../../node_modules/lodash/_baseIsNative.js"),
  30768. getValue = __webpack_require__(/*! ./_getValue */ "../../node_modules/lodash/_getValue.js");
  30769. /**
  30770. * Gets the native function at `key` of `object`.
  30771. *
  30772. * @private
  30773. * @param {Object} object The object to query.
  30774. * @param {string} key The key of the method to get.
  30775. * @returns {*} Returns the function if it's native, else `undefined`.
  30776. */
  30777. function getNative(object, key) {
  30778. var value = getValue(object, key);
  30779. return baseIsNative(value) ? value : undefined;
  30780. }
  30781. module.exports = getNative;
  30782. /***/ }),
  30783. /***/ "../../node_modules/lodash/_getPrototype.js":
  30784. /*!**************************************************!*\
  30785. !*** ../../node_modules/lodash/_getPrototype.js ***!
  30786. \**************************************************/
  30787. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  30788. var overArg = __webpack_require__(/*! ./_overArg */ "../../node_modules/lodash/_overArg.js");
  30789. /** Built-in value references. */
  30790. var getPrototype = overArg(Object.getPrototypeOf, Object);
  30791. module.exports = getPrototype;
  30792. /***/ }),
  30793. /***/ "../../node_modules/lodash/_getRawTag.js":
  30794. /*!***********************************************!*\
  30795. !*** ../../node_modules/lodash/_getRawTag.js ***!
  30796. \***********************************************/
  30797. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  30798. var Symbol = __webpack_require__(/*! ./_Symbol */ "../../node_modules/lodash/_Symbol.js");
  30799. /** Used for built-in method references. */
  30800. var objectProto = Object.prototype;
  30801. /** Used to check objects for own properties. */
  30802. var hasOwnProperty = objectProto.hasOwnProperty;
  30803. /**
  30804. * Used to resolve the
  30805. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  30806. * of values.
  30807. */
  30808. var nativeObjectToString = objectProto.toString;
  30809. /** Built-in value references. */
  30810. var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  30811. /**
  30812. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  30813. *
  30814. * @private
  30815. * @param {*} value The value to query.
  30816. * @returns {string} Returns the raw `toStringTag`.
  30817. */
  30818. function getRawTag(value) {
  30819. var isOwn = hasOwnProperty.call(value, symToStringTag),
  30820. tag = value[symToStringTag];
  30821. try {
  30822. value[symToStringTag] = undefined;
  30823. var unmasked = true;
  30824. } catch (e) {}
  30825. var result = nativeObjectToString.call(value);
  30826. if (unmasked) {
  30827. if (isOwn) {
  30828. value[symToStringTag] = tag;
  30829. } else {
  30830. delete value[symToStringTag];
  30831. }
  30832. }
  30833. return result;
  30834. }
  30835. module.exports = getRawTag;
  30836. /***/ }),
  30837. /***/ "../../node_modules/lodash/_getSymbols.js":
  30838. /*!************************************************!*\
  30839. !*** ../../node_modules/lodash/_getSymbols.js ***!
  30840. \************************************************/
  30841. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  30842. var arrayFilter = __webpack_require__(/*! ./_arrayFilter */ "../../node_modules/lodash/_arrayFilter.js"),
  30843. stubArray = __webpack_require__(/*! ./stubArray */ "../../node_modules/lodash/stubArray.js");
  30844. /** Used for built-in method references. */
  30845. var objectProto = Object.prototype;
  30846. /** Built-in value references. */
  30847. var propertyIsEnumerable = objectProto.propertyIsEnumerable;
  30848. /* Built-in method references for those with the same name as other `lodash` methods. */
  30849. var nativeGetSymbols = Object.getOwnPropertySymbols;
  30850. /**
  30851. * Creates an array of the own enumerable symbols of `object`.
  30852. *
  30853. * @private
  30854. * @param {Object} object The object to query.
  30855. * @returns {Array} Returns the array of symbols.
  30856. */
  30857. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  30858. if (object == null) {
  30859. return [];
  30860. }
  30861. object = Object(object);
  30862. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  30863. return propertyIsEnumerable.call(object, symbol);
  30864. });
  30865. };
  30866. module.exports = getSymbols;
  30867. /***/ }),
  30868. /***/ "../../node_modules/lodash/_getSymbolsIn.js":
  30869. /*!**************************************************!*\
  30870. !*** ../../node_modules/lodash/_getSymbolsIn.js ***!
  30871. \**************************************************/
  30872. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  30873. var arrayPush = __webpack_require__(/*! ./_arrayPush */ "../../node_modules/lodash/_arrayPush.js"),
  30874. getPrototype = __webpack_require__(/*! ./_getPrototype */ "../../node_modules/lodash/_getPrototype.js"),
  30875. getSymbols = __webpack_require__(/*! ./_getSymbols */ "../../node_modules/lodash/_getSymbols.js"),
  30876. stubArray = __webpack_require__(/*! ./stubArray */ "../../node_modules/lodash/stubArray.js");
  30877. /* Built-in method references for those with the same name as other `lodash` methods. */
  30878. var nativeGetSymbols = Object.getOwnPropertySymbols;
  30879. /**
  30880. * Creates an array of the own and inherited enumerable symbols of `object`.
  30881. *
  30882. * @private
  30883. * @param {Object} object The object to query.
  30884. * @returns {Array} Returns the array of symbols.
  30885. */
  30886. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  30887. var result = [];
  30888. while (object) {
  30889. arrayPush(result, getSymbols(object));
  30890. object = getPrototype(object);
  30891. }
  30892. return result;
  30893. };
  30894. module.exports = getSymbolsIn;
  30895. /***/ }),
  30896. /***/ "../../node_modules/lodash/_getTag.js":
  30897. /*!********************************************!*\
  30898. !*** ../../node_modules/lodash/_getTag.js ***!
  30899. \********************************************/
  30900. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  30901. var DataView = __webpack_require__(/*! ./_DataView */ "../../node_modules/lodash/_DataView.js"),
  30902. Map = __webpack_require__(/*! ./_Map */ "../../node_modules/lodash/_Map.js"),
  30903. Promise = __webpack_require__(/*! ./_Promise */ "../../node_modules/lodash/_Promise.js"),
  30904. Set = __webpack_require__(/*! ./_Set */ "../../node_modules/lodash/_Set.js"),
  30905. WeakMap = __webpack_require__(/*! ./_WeakMap */ "../../node_modules/lodash/_WeakMap.js"),
  30906. baseGetTag = __webpack_require__(/*! ./_baseGetTag */ "../../node_modules/lodash/_baseGetTag.js"),
  30907. toSource = __webpack_require__(/*! ./_toSource */ "../../node_modules/lodash/_toSource.js");
  30908. /** `Object#toString` result references. */
  30909. var mapTag = '[object Map]',
  30910. objectTag = '[object Object]',
  30911. promiseTag = '[object Promise]',
  30912. setTag = '[object Set]',
  30913. weakMapTag = '[object WeakMap]';
  30914. var dataViewTag = '[object DataView]';
  30915. /** Used to detect maps, sets, and weakmaps. */
  30916. var dataViewCtorString = toSource(DataView),
  30917. mapCtorString = toSource(Map),
  30918. promiseCtorString = toSource(Promise),
  30919. setCtorString = toSource(Set),
  30920. weakMapCtorString = toSource(WeakMap);
  30921. /**
  30922. * Gets the `toStringTag` of `value`.
  30923. *
  30924. * @private
  30925. * @param {*} value The value to query.
  30926. * @returns {string} Returns the `toStringTag`.
  30927. */
  30928. var getTag = baseGetTag;
  30929. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  30930. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  30931. (Map && getTag(new Map) != mapTag) ||
  30932. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  30933. (Set && getTag(new Set) != setTag) ||
  30934. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  30935. getTag = function(value) {
  30936. var result = baseGetTag(value),
  30937. Ctor = result == objectTag ? value.constructor : undefined,
  30938. ctorString = Ctor ? toSource(Ctor) : '';
  30939. if (ctorString) {
  30940. switch (ctorString) {
  30941. case dataViewCtorString: return dataViewTag;
  30942. case mapCtorString: return mapTag;
  30943. case promiseCtorString: return promiseTag;
  30944. case setCtorString: return setTag;
  30945. case weakMapCtorString: return weakMapTag;
  30946. }
  30947. }
  30948. return result;
  30949. };
  30950. }
  30951. module.exports = getTag;
  30952. /***/ }),
  30953. /***/ "../../node_modules/lodash/_getValue.js":
  30954. /*!**********************************************!*\
  30955. !*** ../../node_modules/lodash/_getValue.js ***!
  30956. \**********************************************/
  30957. /***/ ((module) => {
  30958. /**
  30959. * Gets the value at `key` of `object`.
  30960. *
  30961. * @private
  30962. * @param {Object} [object] The object to query.
  30963. * @param {string} key The key of the property to get.
  30964. * @returns {*} Returns the property value.
  30965. */
  30966. function getValue(object, key) {
  30967. return object == null ? undefined : object[key];
  30968. }
  30969. module.exports = getValue;
  30970. /***/ }),
  30971. /***/ "../../node_modules/lodash/_hasPath.js":
  30972. /*!*********************************************!*\
  30973. !*** ../../node_modules/lodash/_hasPath.js ***!
  30974. \*********************************************/
  30975. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  30976. var castPath = __webpack_require__(/*! ./_castPath */ "../../node_modules/lodash/_castPath.js"),
  30977. isArguments = __webpack_require__(/*! ./isArguments */ "../../node_modules/lodash/isArguments.js"),
  30978. isArray = __webpack_require__(/*! ./isArray */ "../../node_modules/lodash/isArray.js"),
  30979. isIndex = __webpack_require__(/*! ./_isIndex */ "../../node_modules/lodash/_isIndex.js"),
  30980. isLength = __webpack_require__(/*! ./isLength */ "../../node_modules/lodash/isLength.js"),
  30981. toKey = __webpack_require__(/*! ./_toKey */ "../../node_modules/lodash/_toKey.js");
  30982. /**
  30983. * Checks if `path` exists on `object`.
  30984. *
  30985. * @private
  30986. * @param {Object} object The object to query.
  30987. * @param {Array|string} path The path to check.
  30988. * @param {Function} hasFunc The function to check properties.
  30989. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  30990. */
  30991. function hasPath(object, path, hasFunc) {
  30992. path = castPath(path, object);
  30993. var index = -1,
  30994. length = path.length,
  30995. result = false;
  30996. while (++index < length) {
  30997. var key = toKey(path[index]);
  30998. if (!(result = object != null && hasFunc(object, key))) {
  30999. break;
  31000. }
  31001. object = object[key];
  31002. }
  31003. if (result || ++index != length) {
  31004. return result;
  31005. }
  31006. length = object == null ? 0 : object.length;
  31007. return !!length && isLength(length) && isIndex(key, length) &&
  31008. (isArray(object) || isArguments(object));
  31009. }
  31010. module.exports = hasPath;
  31011. /***/ }),
  31012. /***/ "../../node_modules/lodash/_hashClear.js":
  31013. /*!***********************************************!*\
  31014. !*** ../../node_modules/lodash/_hashClear.js ***!
  31015. \***********************************************/
  31016. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  31017. var nativeCreate = __webpack_require__(/*! ./_nativeCreate */ "../../node_modules/lodash/_nativeCreate.js");
  31018. /**
  31019. * Removes all key-value entries from the hash.
  31020. *
  31021. * @private
  31022. * @name clear
  31023. * @memberOf Hash
  31024. */
  31025. function hashClear() {
  31026. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  31027. this.size = 0;
  31028. }
  31029. module.exports = hashClear;
  31030. /***/ }),
  31031. /***/ "../../node_modules/lodash/_hashDelete.js":
  31032. /*!************************************************!*\
  31033. !*** ../../node_modules/lodash/_hashDelete.js ***!
  31034. \************************************************/
  31035. /***/ ((module) => {
  31036. /**
  31037. * Removes `key` and its value from the hash.
  31038. *
  31039. * @private
  31040. * @name delete
  31041. * @memberOf Hash
  31042. * @param {Object} hash The hash to modify.
  31043. * @param {string} key The key of the value to remove.
  31044. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  31045. */
  31046. function hashDelete(key) {
  31047. var result = this.has(key) && delete this.__data__[key];
  31048. this.size -= result ? 1 : 0;
  31049. return result;
  31050. }
  31051. module.exports = hashDelete;
  31052. /***/ }),
  31053. /***/ "../../node_modules/lodash/_hashGet.js":
  31054. /*!*********************************************!*\
  31055. !*** ../../node_modules/lodash/_hashGet.js ***!
  31056. \*********************************************/
  31057. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  31058. var nativeCreate = __webpack_require__(/*! ./_nativeCreate */ "../../node_modules/lodash/_nativeCreate.js");
  31059. /** Used to stand-in for `undefined` hash values. */
  31060. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  31061. /** Used for built-in method references. */
  31062. var objectProto = Object.prototype;
  31063. /** Used to check objects for own properties. */
  31064. var hasOwnProperty = objectProto.hasOwnProperty;
  31065. /**
  31066. * Gets the hash value for `key`.
  31067. *
  31068. * @private
  31069. * @name get
  31070. * @memberOf Hash
  31071. * @param {string} key The key of the value to get.
  31072. * @returns {*} Returns the entry value.
  31073. */
  31074. function hashGet(key) {
  31075. var data = this.__data__;
  31076. if (nativeCreate) {
  31077. var result = data[key];
  31078. return result === HASH_UNDEFINED ? undefined : result;
  31079. }
  31080. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  31081. }
  31082. module.exports = hashGet;
  31083. /***/ }),
  31084. /***/ "../../node_modules/lodash/_hashHas.js":
  31085. /*!*********************************************!*\
  31086. !*** ../../node_modules/lodash/_hashHas.js ***!
  31087. \*********************************************/
  31088. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  31089. var nativeCreate = __webpack_require__(/*! ./_nativeCreate */ "../../node_modules/lodash/_nativeCreate.js");
  31090. /** Used for built-in method references. */
  31091. var objectProto = Object.prototype;
  31092. /** Used to check objects for own properties. */
  31093. var hasOwnProperty = objectProto.hasOwnProperty;
  31094. /**
  31095. * Checks if a hash value for `key` exists.
  31096. *
  31097. * @private
  31098. * @name has
  31099. * @memberOf Hash
  31100. * @param {string} key The key of the entry to check.
  31101. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  31102. */
  31103. function hashHas(key) {
  31104. var data = this.__data__;
  31105. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  31106. }
  31107. module.exports = hashHas;
  31108. /***/ }),
  31109. /***/ "../../node_modules/lodash/_hashSet.js":
  31110. /*!*********************************************!*\
  31111. !*** ../../node_modules/lodash/_hashSet.js ***!
  31112. \*********************************************/
  31113. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  31114. var nativeCreate = __webpack_require__(/*! ./_nativeCreate */ "../../node_modules/lodash/_nativeCreate.js");
  31115. /** Used to stand-in for `undefined` hash values. */
  31116. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  31117. /**
  31118. * Sets the hash `key` to `value`.
  31119. *
  31120. * @private
  31121. * @name set
  31122. * @memberOf Hash
  31123. * @param {string} key The key of the value to set.
  31124. * @param {*} value The value to set.
  31125. * @returns {Object} Returns the hash instance.
  31126. */
  31127. function hashSet(key, value) {
  31128. var data = this.__data__;
  31129. this.size += this.has(key) ? 0 : 1;
  31130. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  31131. return this;
  31132. }
  31133. module.exports = hashSet;
  31134. /***/ }),
  31135. /***/ "../../node_modules/lodash/_isFlattenable.js":
  31136. /*!***************************************************!*\
  31137. !*** ../../node_modules/lodash/_isFlattenable.js ***!
  31138. \***************************************************/
  31139. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  31140. var Symbol = __webpack_require__(/*! ./_Symbol */ "../../node_modules/lodash/_Symbol.js"),
  31141. isArguments = __webpack_require__(/*! ./isArguments */ "../../node_modules/lodash/isArguments.js"),
  31142. isArray = __webpack_require__(/*! ./isArray */ "../../node_modules/lodash/isArray.js");
  31143. /** Built-in value references. */
  31144. var spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined;
  31145. /**
  31146. * Checks if `value` is a flattenable `arguments` object or array.
  31147. *
  31148. * @private
  31149. * @param {*} value The value to check.
  31150. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  31151. */
  31152. function isFlattenable(value) {
  31153. return isArray(value) || isArguments(value) ||
  31154. !!(spreadableSymbol && value && value[spreadableSymbol]);
  31155. }
  31156. module.exports = isFlattenable;
  31157. /***/ }),
  31158. /***/ "../../node_modules/lodash/_isIndex.js":
  31159. /*!*********************************************!*\
  31160. !*** ../../node_modules/lodash/_isIndex.js ***!
  31161. \*********************************************/
  31162. /***/ ((module) => {
  31163. /** Used as references for various `Number` constants. */
  31164. var MAX_SAFE_INTEGER = 9007199254740991;
  31165. /** Used to detect unsigned integer values. */
  31166. var reIsUint = /^(?:0|[1-9]\d*)$/;
  31167. /**
  31168. * Checks if `value` is a valid array-like index.
  31169. *
  31170. * @private
  31171. * @param {*} value The value to check.
  31172. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  31173. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  31174. */
  31175. function isIndex(value, length) {
  31176. var type = typeof value;
  31177. length = length == null ? MAX_SAFE_INTEGER : length;
  31178. return !!length &&
  31179. (type == 'number' ||
  31180. (type != 'symbol' && reIsUint.test(value))) &&
  31181. (value > -1 && value % 1 == 0 && value < length);
  31182. }
  31183. module.exports = isIndex;
  31184. /***/ }),
  31185. /***/ "../../node_modules/lodash/_isKey.js":
  31186. /*!*******************************************!*\
  31187. !*** ../../node_modules/lodash/_isKey.js ***!
  31188. \*******************************************/
  31189. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  31190. var isArray = __webpack_require__(/*! ./isArray */ "../../node_modules/lodash/isArray.js"),
  31191. isSymbol = __webpack_require__(/*! ./isSymbol */ "../../node_modules/lodash/isSymbol.js");
  31192. /** Used to match property names within property paths. */
  31193. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  31194. reIsPlainProp = /^\w*$/;
  31195. /**
  31196. * Checks if `value` is a property name and not a property path.
  31197. *
  31198. * @private
  31199. * @param {*} value The value to check.
  31200. * @param {Object} [object] The object to query keys on.
  31201. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  31202. */
  31203. function isKey(value, object) {
  31204. if (isArray(value)) {
  31205. return false;
  31206. }
  31207. var type = typeof value;
  31208. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  31209. value == null || isSymbol(value)) {
  31210. return true;
  31211. }
  31212. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  31213. (object != null && value in Object(object));
  31214. }
  31215. module.exports = isKey;
  31216. /***/ }),
  31217. /***/ "../../node_modules/lodash/_isKeyable.js":
  31218. /*!***********************************************!*\
  31219. !*** ../../node_modules/lodash/_isKeyable.js ***!
  31220. \***********************************************/
  31221. /***/ ((module) => {
  31222. /**
  31223. * Checks if `value` is suitable for use as unique object key.
  31224. *
  31225. * @private
  31226. * @param {*} value The value to check.
  31227. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  31228. */
  31229. function isKeyable(value) {
  31230. var type = typeof value;
  31231. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  31232. ? (value !== '__proto__')
  31233. : (value === null);
  31234. }
  31235. module.exports = isKeyable;
  31236. /***/ }),
  31237. /***/ "../../node_modules/lodash/_isMasked.js":
  31238. /*!**********************************************!*\
  31239. !*** ../../node_modules/lodash/_isMasked.js ***!
  31240. \**********************************************/
  31241. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  31242. var coreJsData = __webpack_require__(/*! ./_coreJsData */ "../../node_modules/lodash/_coreJsData.js");
  31243. /** Used to detect methods masquerading as native. */
  31244. var maskSrcKey = (function() {
  31245. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  31246. return uid ? ('Symbol(src)_1.' + uid) : '';
  31247. }());
  31248. /**
  31249. * Checks if `func` has its source masked.
  31250. *
  31251. * @private
  31252. * @param {Function} func The function to check.
  31253. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  31254. */
  31255. function isMasked(func) {
  31256. return !!maskSrcKey && (maskSrcKey in func);
  31257. }
  31258. module.exports = isMasked;
  31259. /***/ }),
  31260. /***/ "../../node_modules/lodash/_isPrototype.js":
  31261. /*!*************************************************!*\
  31262. !*** ../../node_modules/lodash/_isPrototype.js ***!
  31263. \*************************************************/
  31264. /***/ ((module) => {
  31265. /** Used for built-in method references. */
  31266. var objectProto = Object.prototype;
  31267. /**
  31268. * Checks if `value` is likely a prototype object.
  31269. *
  31270. * @private
  31271. * @param {*} value The value to check.
  31272. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  31273. */
  31274. function isPrototype(value) {
  31275. var Ctor = value && value.constructor,
  31276. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  31277. return value === proto;
  31278. }
  31279. module.exports = isPrototype;
  31280. /***/ }),
  31281. /***/ "../../node_modules/lodash/_isStrictComparable.js":
  31282. /*!********************************************************!*\
  31283. !*** ../../node_modules/lodash/_isStrictComparable.js ***!
  31284. \********************************************************/
  31285. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  31286. var isObject = __webpack_require__(/*! ./isObject */ "../../node_modules/lodash/isObject.js");
  31287. /**
  31288. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  31289. *
  31290. * @private
  31291. * @param {*} value The value to check.
  31292. * @returns {boolean} Returns `true` if `value` if suitable for strict
  31293. * equality comparisons, else `false`.
  31294. */
  31295. function isStrictComparable(value) {
  31296. return value === value && !isObject(value);
  31297. }
  31298. module.exports = isStrictComparable;
  31299. /***/ }),
  31300. /***/ "../../node_modules/lodash/_listCacheClear.js":
  31301. /*!****************************************************!*\
  31302. !*** ../../node_modules/lodash/_listCacheClear.js ***!
  31303. \****************************************************/
  31304. /***/ ((module) => {
  31305. /**
  31306. * Removes all key-value entries from the list cache.
  31307. *
  31308. * @private
  31309. * @name clear
  31310. * @memberOf ListCache
  31311. */
  31312. function listCacheClear() {
  31313. this.__data__ = [];
  31314. this.size = 0;
  31315. }
  31316. module.exports = listCacheClear;
  31317. /***/ }),
  31318. /***/ "../../node_modules/lodash/_listCacheDelete.js":
  31319. /*!*****************************************************!*\
  31320. !*** ../../node_modules/lodash/_listCacheDelete.js ***!
  31321. \*****************************************************/
  31322. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  31323. var assocIndexOf = __webpack_require__(/*! ./_assocIndexOf */ "../../node_modules/lodash/_assocIndexOf.js");
  31324. /** Used for built-in method references. */
  31325. var arrayProto = Array.prototype;
  31326. /** Built-in value references. */
  31327. var splice = arrayProto.splice;
  31328. /**
  31329. * Removes `key` and its value from the list cache.
  31330. *
  31331. * @private
  31332. * @name delete
  31333. * @memberOf ListCache
  31334. * @param {string} key The key of the value to remove.
  31335. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  31336. */
  31337. function listCacheDelete(key) {
  31338. var data = this.__data__,
  31339. index = assocIndexOf(data, key);
  31340. if (index < 0) {
  31341. return false;
  31342. }
  31343. var lastIndex = data.length - 1;
  31344. if (index == lastIndex) {
  31345. data.pop();
  31346. } else {
  31347. splice.call(data, index, 1);
  31348. }
  31349. --this.size;
  31350. return true;
  31351. }
  31352. module.exports = listCacheDelete;
  31353. /***/ }),
  31354. /***/ "../../node_modules/lodash/_listCacheGet.js":
  31355. /*!**************************************************!*\
  31356. !*** ../../node_modules/lodash/_listCacheGet.js ***!
  31357. \**************************************************/
  31358. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  31359. var assocIndexOf = __webpack_require__(/*! ./_assocIndexOf */ "../../node_modules/lodash/_assocIndexOf.js");
  31360. /**
  31361. * Gets the list cache value for `key`.
  31362. *
  31363. * @private
  31364. * @name get
  31365. * @memberOf ListCache
  31366. * @param {string} key The key of the value to get.
  31367. * @returns {*} Returns the entry value.
  31368. */
  31369. function listCacheGet(key) {
  31370. var data = this.__data__,
  31371. index = assocIndexOf(data, key);
  31372. return index < 0 ? undefined : data[index][1];
  31373. }
  31374. module.exports = listCacheGet;
  31375. /***/ }),
  31376. /***/ "../../node_modules/lodash/_listCacheHas.js":
  31377. /*!**************************************************!*\
  31378. !*** ../../node_modules/lodash/_listCacheHas.js ***!
  31379. \**************************************************/
  31380. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  31381. var assocIndexOf = __webpack_require__(/*! ./_assocIndexOf */ "../../node_modules/lodash/_assocIndexOf.js");
  31382. /**
  31383. * Checks if a list cache value for `key` exists.
  31384. *
  31385. * @private
  31386. * @name has
  31387. * @memberOf ListCache
  31388. * @param {string} key The key of the entry to check.
  31389. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  31390. */
  31391. function listCacheHas(key) {
  31392. return assocIndexOf(this.__data__, key) > -1;
  31393. }
  31394. module.exports = listCacheHas;
  31395. /***/ }),
  31396. /***/ "../../node_modules/lodash/_listCacheSet.js":
  31397. /*!**************************************************!*\
  31398. !*** ../../node_modules/lodash/_listCacheSet.js ***!
  31399. \**************************************************/
  31400. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  31401. var assocIndexOf = __webpack_require__(/*! ./_assocIndexOf */ "../../node_modules/lodash/_assocIndexOf.js");
  31402. /**
  31403. * Sets the list cache `key` to `value`.
  31404. *
  31405. * @private
  31406. * @name set
  31407. * @memberOf ListCache
  31408. * @param {string} key The key of the value to set.
  31409. * @param {*} value The value to set.
  31410. * @returns {Object} Returns the list cache instance.
  31411. */
  31412. function listCacheSet(key, value) {
  31413. var data = this.__data__,
  31414. index = assocIndexOf(data, key);
  31415. if (index < 0) {
  31416. ++this.size;
  31417. data.push([key, value]);
  31418. } else {
  31419. data[index][1] = value;
  31420. }
  31421. return this;
  31422. }
  31423. module.exports = listCacheSet;
  31424. /***/ }),
  31425. /***/ "../../node_modules/lodash/_mapCacheClear.js":
  31426. /*!***************************************************!*\
  31427. !*** ../../node_modules/lodash/_mapCacheClear.js ***!
  31428. \***************************************************/
  31429. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  31430. var Hash = __webpack_require__(/*! ./_Hash */ "../../node_modules/lodash/_Hash.js"),
  31431. ListCache = __webpack_require__(/*! ./_ListCache */ "../../node_modules/lodash/_ListCache.js"),
  31432. Map = __webpack_require__(/*! ./_Map */ "../../node_modules/lodash/_Map.js");
  31433. /**
  31434. * Removes all key-value entries from the map.
  31435. *
  31436. * @private
  31437. * @name clear
  31438. * @memberOf MapCache
  31439. */
  31440. function mapCacheClear() {
  31441. this.size = 0;
  31442. this.__data__ = {
  31443. 'hash': new Hash,
  31444. 'map': new (Map || ListCache),
  31445. 'string': new Hash
  31446. };
  31447. }
  31448. module.exports = mapCacheClear;
  31449. /***/ }),
  31450. /***/ "../../node_modules/lodash/_mapCacheDelete.js":
  31451. /*!****************************************************!*\
  31452. !*** ../../node_modules/lodash/_mapCacheDelete.js ***!
  31453. \****************************************************/
  31454. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  31455. var getMapData = __webpack_require__(/*! ./_getMapData */ "../../node_modules/lodash/_getMapData.js");
  31456. /**
  31457. * Removes `key` and its value from the map.
  31458. *
  31459. * @private
  31460. * @name delete
  31461. * @memberOf MapCache
  31462. * @param {string} key The key of the value to remove.
  31463. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  31464. */
  31465. function mapCacheDelete(key) {
  31466. var result = getMapData(this, key)['delete'](key);
  31467. this.size -= result ? 1 : 0;
  31468. return result;
  31469. }
  31470. module.exports = mapCacheDelete;
  31471. /***/ }),
  31472. /***/ "../../node_modules/lodash/_mapCacheGet.js":
  31473. /*!*************************************************!*\
  31474. !*** ../../node_modules/lodash/_mapCacheGet.js ***!
  31475. \*************************************************/
  31476. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  31477. var getMapData = __webpack_require__(/*! ./_getMapData */ "../../node_modules/lodash/_getMapData.js");
  31478. /**
  31479. * Gets the map value for `key`.
  31480. *
  31481. * @private
  31482. * @name get
  31483. * @memberOf MapCache
  31484. * @param {string} key The key of the value to get.
  31485. * @returns {*} Returns the entry value.
  31486. */
  31487. function mapCacheGet(key) {
  31488. return getMapData(this, key).get(key);
  31489. }
  31490. module.exports = mapCacheGet;
  31491. /***/ }),
  31492. /***/ "../../node_modules/lodash/_mapCacheHas.js":
  31493. /*!*************************************************!*\
  31494. !*** ../../node_modules/lodash/_mapCacheHas.js ***!
  31495. \*************************************************/
  31496. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  31497. var getMapData = __webpack_require__(/*! ./_getMapData */ "../../node_modules/lodash/_getMapData.js");
  31498. /**
  31499. * Checks if a map value for `key` exists.
  31500. *
  31501. * @private
  31502. * @name has
  31503. * @memberOf MapCache
  31504. * @param {string} key The key of the entry to check.
  31505. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  31506. */
  31507. function mapCacheHas(key) {
  31508. return getMapData(this, key).has(key);
  31509. }
  31510. module.exports = mapCacheHas;
  31511. /***/ }),
  31512. /***/ "../../node_modules/lodash/_mapCacheSet.js":
  31513. /*!*************************************************!*\
  31514. !*** ../../node_modules/lodash/_mapCacheSet.js ***!
  31515. \*************************************************/
  31516. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  31517. var getMapData = __webpack_require__(/*! ./_getMapData */ "../../node_modules/lodash/_getMapData.js");
  31518. /**
  31519. * Sets the map `key` to `value`.
  31520. *
  31521. * @private
  31522. * @name set
  31523. * @memberOf MapCache
  31524. * @param {string} key The key of the value to set.
  31525. * @param {*} value The value to set.
  31526. * @returns {Object} Returns the map cache instance.
  31527. */
  31528. function mapCacheSet(key, value) {
  31529. var data = getMapData(this, key),
  31530. size = data.size;
  31531. data.set(key, value);
  31532. this.size += data.size == size ? 0 : 1;
  31533. return this;
  31534. }
  31535. module.exports = mapCacheSet;
  31536. /***/ }),
  31537. /***/ "../../node_modules/lodash/_mapToArray.js":
  31538. /*!************************************************!*\
  31539. !*** ../../node_modules/lodash/_mapToArray.js ***!
  31540. \************************************************/
  31541. /***/ ((module) => {
  31542. /**
  31543. * Converts `map` to its key-value pairs.
  31544. *
  31545. * @private
  31546. * @param {Object} map The map to convert.
  31547. * @returns {Array} Returns the key-value pairs.
  31548. */
  31549. function mapToArray(map) {
  31550. var index = -1,
  31551. result = Array(map.size);
  31552. map.forEach(function(value, key) {
  31553. result[++index] = [key, value];
  31554. });
  31555. return result;
  31556. }
  31557. module.exports = mapToArray;
  31558. /***/ }),
  31559. /***/ "../../node_modules/lodash/_matchesStrictComparable.js":
  31560. /*!*************************************************************!*\
  31561. !*** ../../node_modules/lodash/_matchesStrictComparable.js ***!
  31562. \*************************************************************/
  31563. /***/ ((module) => {
  31564. /**
  31565. * A specialized version of `matchesProperty` for source values suitable
  31566. * for strict equality comparisons, i.e. `===`.
  31567. *
  31568. * @private
  31569. * @param {string} key The key of the property to get.
  31570. * @param {*} srcValue The value to match.
  31571. * @returns {Function} Returns the new spec function.
  31572. */
  31573. function matchesStrictComparable(key, srcValue) {
  31574. return function(object) {
  31575. if (object == null) {
  31576. return false;
  31577. }
  31578. return object[key] === srcValue &&
  31579. (srcValue !== undefined || (key in Object(object)));
  31580. };
  31581. }
  31582. module.exports = matchesStrictComparable;
  31583. /***/ }),
  31584. /***/ "../../node_modules/lodash/_memoizeCapped.js":
  31585. /*!***************************************************!*\
  31586. !*** ../../node_modules/lodash/_memoizeCapped.js ***!
  31587. \***************************************************/
  31588. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  31589. var memoize = __webpack_require__(/*! ./memoize */ "../../node_modules/lodash/memoize.js");
  31590. /** Used as the maximum memoize cache size. */
  31591. var MAX_MEMOIZE_SIZE = 500;
  31592. /**
  31593. * A specialized version of `_.memoize` which clears the memoized function's
  31594. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  31595. *
  31596. * @private
  31597. * @param {Function} func The function to have its output memoized.
  31598. * @returns {Function} Returns the new memoized function.
  31599. */
  31600. function memoizeCapped(func) {
  31601. var result = memoize(func, function(key) {
  31602. if (cache.size === MAX_MEMOIZE_SIZE) {
  31603. cache.clear();
  31604. }
  31605. return key;
  31606. });
  31607. var cache = result.cache;
  31608. return result;
  31609. }
  31610. module.exports = memoizeCapped;
  31611. /***/ }),
  31612. /***/ "../../node_modules/lodash/_nativeCreate.js":
  31613. /*!**************************************************!*\
  31614. !*** ../../node_modules/lodash/_nativeCreate.js ***!
  31615. \**************************************************/
  31616. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  31617. var getNative = __webpack_require__(/*! ./_getNative */ "../../node_modules/lodash/_getNative.js");
  31618. /* Built-in method references that are verified to be native. */
  31619. var nativeCreate = getNative(Object, 'create');
  31620. module.exports = nativeCreate;
  31621. /***/ }),
  31622. /***/ "../../node_modules/lodash/_nativeKeys.js":
  31623. /*!************************************************!*\
  31624. !*** ../../node_modules/lodash/_nativeKeys.js ***!
  31625. \************************************************/
  31626. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  31627. var overArg = __webpack_require__(/*! ./_overArg */ "../../node_modules/lodash/_overArg.js");
  31628. /* Built-in method references for those with the same name as other `lodash` methods. */
  31629. var nativeKeys = overArg(Object.keys, Object);
  31630. module.exports = nativeKeys;
  31631. /***/ }),
  31632. /***/ "../../node_modules/lodash/_nativeKeysIn.js":
  31633. /*!**************************************************!*\
  31634. !*** ../../node_modules/lodash/_nativeKeysIn.js ***!
  31635. \**************************************************/
  31636. /***/ ((module) => {
  31637. /**
  31638. * This function is like
  31639. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  31640. * except that it includes inherited enumerable properties.
  31641. *
  31642. * @private
  31643. * @param {Object} object The object to query.
  31644. * @returns {Array} Returns the array of property names.
  31645. */
  31646. function nativeKeysIn(object) {
  31647. var result = [];
  31648. if (object != null) {
  31649. for (var key in Object(object)) {
  31650. result.push(key);
  31651. }
  31652. }
  31653. return result;
  31654. }
  31655. module.exports = nativeKeysIn;
  31656. /***/ }),
  31657. /***/ "../../node_modules/lodash/_nodeUtil.js":
  31658. /*!**********************************************!*\
  31659. !*** ../../node_modules/lodash/_nodeUtil.js ***!
  31660. \**********************************************/
  31661. /***/ ((module, exports, __webpack_require__) => {
  31662. /* module decorator */ module = __webpack_require__.nmd(module);
  31663. var freeGlobal = __webpack_require__(/*! ./_freeGlobal */ "../../node_modules/lodash/_freeGlobal.js");
  31664. /** Detect free variable `exports`. */
  31665. var freeExports = true && exports && !exports.nodeType && exports;
  31666. /** Detect free variable `module`. */
  31667. var freeModule = freeExports && "object" == 'object' && module && !module.nodeType && module;
  31668. /** Detect the popular CommonJS extension `module.exports`. */
  31669. var moduleExports = freeModule && freeModule.exports === freeExports;
  31670. /** Detect free variable `process` from Node.js. */
  31671. var freeProcess = moduleExports && freeGlobal.process;
  31672. /** Used to access faster Node.js helpers. */
  31673. var nodeUtil = (function() {
  31674. try {
  31675. // Use `util.types` for Node.js 10+.
  31676. var types = freeModule && freeModule.require && freeModule.require('util').types;
  31677. if (types) {
  31678. return types;
  31679. }
  31680. // Legacy `process.binding('util')` for Node.js < 10.
  31681. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  31682. } catch (e) {}
  31683. }());
  31684. module.exports = nodeUtil;
  31685. /***/ }),
  31686. /***/ "../../node_modules/lodash/_objectToString.js":
  31687. /*!****************************************************!*\
  31688. !*** ../../node_modules/lodash/_objectToString.js ***!
  31689. \****************************************************/
  31690. /***/ ((module) => {
  31691. /** Used for built-in method references. */
  31692. var objectProto = Object.prototype;
  31693. /**
  31694. * Used to resolve the
  31695. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  31696. * of values.
  31697. */
  31698. var nativeObjectToString = objectProto.toString;
  31699. /**
  31700. * Converts `value` to a string using `Object.prototype.toString`.
  31701. *
  31702. * @private
  31703. * @param {*} value The value to convert.
  31704. * @returns {string} Returns the converted string.
  31705. */
  31706. function objectToString(value) {
  31707. return nativeObjectToString.call(value);
  31708. }
  31709. module.exports = objectToString;
  31710. /***/ }),
  31711. /***/ "../../node_modules/lodash/_overArg.js":
  31712. /*!*********************************************!*\
  31713. !*** ../../node_modules/lodash/_overArg.js ***!
  31714. \*********************************************/
  31715. /***/ ((module) => {
  31716. /**
  31717. * Creates a unary function that invokes `func` with its argument transformed.
  31718. *
  31719. * @private
  31720. * @param {Function} func The function to wrap.
  31721. * @param {Function} transform The argument transform.
  31722. * @returns {Function} Returns the new function.
  31723. */
  31724. function overArg(func, transform) {
  31725. return function(arg) {
  31726. return func(transform(arg));
  31727. };
  31728. }
  31729. module.exports = overArg;
  31730. /***/ }),
  31731. /***/ "../../node_modules/lodash/_root.js":
  31732. /*!******************************************!*\
  31733. !*** ../../node_modules/lodash/_root.js ***!
  31734. \******************************************/
  31735. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  31736. var freeGlobal = __webpack_require__(/*! ./_freeGlobal */ "../../node_modules/lodash/_freeGlobal.js");
  31737. /** Detect free variable `self`. */
  31738. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  31739. /** Used as a reference to the global object. */
  31740. var root = freeGlobal || freeSelf || Function('return this')();
  31741. module.exports = root;
  31742. /***/ }),
  31743. /***/ "../../node_modules/lodash/_setCacheAdd.js":
  31744. /*!*************************************************!*\
  31745. !*** ../../node_modules/lodash/_setCacheAdd.js ***!
  31746. \*************************************************/
  31747. /***/ ((module) => {
  31748. /** Used to stand-in for `undefined` hash values. */
  31749. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  31750. /**
  31751. * Adds `value` to the array cache.
  31752. *
  31753. * @private
  31754. * @name add
  31755. * @memberOf SetCache
  31756. * @alias push
  31757. * @param {*} value The value to cache.
  31758. * @returns {Object} Returns the cache instance.
  31759. */
  31760. function setCacheAdd(value) {
  31761. this.__data__.set(value, HASH_UNDEFINED);
  31762. return this;
  31763. }
  31764. module.exports = setCacheAdd;
  31765. /***/ }),
  31766. /***/ "../../node_modules/lodash/_setCacheHas.js":
  31767. /*!*************************************************!*\
  31768. !*** ../../node_modules/lodash/_setCacheHas.js ***!
  31769. \*************************************************/
  31770. /***/ ((module) => {
  31771. /**
  31772. * Checks if `value` is in the array cache.
  31773. *
  31774. * @private
  31775. * @name has
  31776. * @memberOf SetCache
  31777. * @param {*} value The value to search for.
  31778. * @returns {number} Returns `true` if `value` is found, else `false`.
  31779. */
  31780. function setCacheHas(value) {
  31781. return this.__data__.has(value);
  31782. }
  31783. module.exports = setCacheHas;
  31784. /***/ }),
  31785. /***/ "../../node_modules/lodash/_setToArray.js":
  31786. /*!************************************************!*\
  31787. !*** ../../node_modules/lodash/_setToArray.js ***!
  31788. \************************************************/
  31789. /***/ ((module) => {
  31790. /**
  31791. * Converts `set` to an array of its values.
  31792. *
  31793. * @private
  31794. * @param {Object} set The set to convert.
  31795. * @returns {Array} Returns the values.
  31796. */
  31797. function setToArray(set) {
  31798. var index = -1,
  31799. result = Array(set.size);
  31800. set.forEach(function(value) {
  31801. result[++index] = value;
  31802. });
  31803. return result;
  31804. }
  31805. module.exports = setToArray;
  31806. /***/ }),
  31807. /***/ "../../node_modules/lodash/_stackClear.js":
  31808. /*!************************************************!*\
  31809. !*** ../../node_modules/lodash/_stackClear.js ***!
  31810. \************************************************/
  31811. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  31812. var ListCache = __webpack_require__(/*! ./_ListCache */ "../../node_modules/lodash/_ListCache.js");
  31813. /**
  31814. * Removes all key-value entries from the stack.
  31815. *
  31816. * @private
  31817. * @name clear
  31818. * @memberOf Stack
  31819. */
  31820. function stackClear() {
  31821. this.__data__ = new ListCache;
  31822. this.size = 0;
  31823. }
  31824. module.exports = stackClear;
  31825. /***/ }),
  31826. /***/ "../../node_modules/lodash/_stackDelete.js":
  31827. /*!*************************************************!*\
  31828. !*** ../../node_modules/lodash/_stackDelete.js ***!
  31829. \*************************************************/
  31830. /***/ ((module) => {
  31831. /**
  31832. * Removes `key` and its value from the stack.
  31833. *
  31834. * @private
  31835. * @name delete
  31836. * @memberOf Stack
  31837. * @param {string} key The key of the value to remove.
  31838. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  31839. */
  31840. function stackDelete(key) {
  31841. var data = this.__data__,
  31842. result = data['delete'](key);
  31843. this.size = data.size;
  31844. return result;
  31845. }
  31846. module.exports = stackDelete;
  31847. /***/ }),
  31848. /***/ "../../node_modules/lodash/_stackGet.js":
  31849. /*!**********************************************!*\
  31850. !*** ../../node_modules/lodash/_stackGet.js ***!
  31851. \**********************************************/
  31852. /***/ ((module) => {
  31853. /**
  31854. * Gets the stack value for `key`.
  31855. *
  31856. * @private
  31857. * @name get
  31858. * @memberOf Stack
  31859. * @param {string} key The key of the value to get.
  31860. * @returns {*} Returns the entry value.
  31861. */
  31862. function stackGet(key) {
  31863. return this.__data__.get(key);
  31864. }
  31865. module.exports = stackGet;
  31866. /***/ }),
  31867. /***/ "../../node_modules/lodash/_stackHas.js":
  31868. /*!**********************************************!*\
  31869. !*** ../../node_modules/lodash/_stackHas.js ***!
  31870. \**********************************************/
  31871. /***/ ((module) => {
  31872. /**
  31873. * Checks if a stack value for `key` exists.
  31874. *
  31875. * @private
  31876. * @name has
  31877. * @memberOf Stack
  31878. * @param {string} key The key of the entry to check.
  31879. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  31880. */
  31881. function stackHas(key) {
  31882. return this.__data__.has(key);
  31883. }
  31884. module.exports = stackHas;
  31885. /***/ }),
  31886. /***/ "../../node_modules/lodash/_stackSet.js":
  31887. /*!**********************************************!*\
  31888. !*** ../../node_modules/lodash/_stackSet.js ***!
  31889. \**********************************************/
  31890. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  31891. var ListCache = __webpack_require__(/*! ./_ListCache */ "../../node_modules/lodash/_ListCache.js"),
  31892. Map = __webpack_require__(/*! ./_Map */ "../../node_modules/lodash/_Map.js"),
  31893. MapCache = __webpack_require__(/*! ./_MapCache */ "../../node_modules/lodash/_MapCache.js");
  31894. /** Used as the size to enable large array optimizations. */
  31895. var LARGE_ARRAY_SIZE = 200;
  31896. /**
  31897. * Sets the stack `key` to `value`.
  31898. *
  31899. * @private
  31900. * @name set
  31901. * @memberOf Stack
  31902. * @param {string} key The key of the value to set.
  31903. * @param {*} value The value to set.
  31904. * @returns {Object} Returns the stack cache instance.
  31905. */
  31906. function stackSet(key, value) {
  31907. var data = this.__data__;
  31908. if (data instanceof ListCache) {
  31909. var pairs = data.__data__;
  31910. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  31911. pairs.push([key, value]);
  31912. this.size = ++data.size;
  31913. return this;
  31914. }
  31915. data = this.__data__ = new MapCache(pairs);
  31916. }
  31917. data.set(key, value);
  31918. this.size = data.size;
  31919. return this;
  31920. }
  31921. module.exports = stackSet;
  31922. /***/ }),
  31923. /***/ "../../node_modules/lodash/_stringToPath.js":
  31924. /*!**************************************************!*\
  31925. !*** ../../node_modules/lodash/_stringToPath.js ***!
  31926. \**************************************************/
  31927. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  31928. var memoizeCapped = __webpack_require__(/*! ./_memoizeCapped */ "../../node_modules/lodash/_memoizeCapped.js");
  31929. /** Used to match property names within property paths. */
  31930. var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  31931. /** Used to match backslashes in property paths. */
  31932. var reEscapeChar = /\\(\\)?/g;
  31933. /**
  31934. * Converts `string` to a property path array.
  31935. *
  31936. * @private
  31937. * @param {string} string The string to convert.
  31938. * @returns {Array} Returns the property path array.
  31939. */
  31940. var stringToPath = memoizeCapped(function(string) {
  31941. var result = [];
  31942. if (string.charCodeAt(0) === 46 /* . */) {
  31943. result.push('');
  31944. }
  31945. string.replace(rePropName, function(match, number, quote, subString) {
  31946. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  31947. });
  31948. return result;
  31949. });
  31950. module.exports = stringToPath;
  31951. /***/ }),
  31952. /***/ "../../node_modules/lodash/_toKey.js":
  31953. /*!*******************************************!*\
  31954. !*** ../../node_modules/lodash/_toKey.js ***!
  31955. \*******************************************/
  31956. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  31957. var isSymbol = __webpack_require__(/*! ./isSymbol */ "../../node_modules/lodash/isSymbol.js");
  31958. /** Used as references for various `Number` constants. */
  31959. var INFINITY = 1 / 0;
  31960. /**
  31961. * Converts `value` to a string key if it's not a string or symbol.
  31962. *
  31963. * @private
  31964. * @param {*} value The value to inspect.
  31965. * @returns {string|symbol} Returns the key.
  31966. */
  31967. function toKey(value) {
  31968. if (typeof value == 'string' || isSymbol(value)) {
  31969. return value;
  31970. }
  31971. var result = (value + '');
  31972. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  31973. }
  31974. module.exports = toKey;
  31975. /***/ }),
  31976. /***/ "../../node_modules/lodash/_toSource.js":
  31977. /*!**********************************************!*\
  31978. !*** ../../node_modules/lodash/_toSource.js ***!
  31979. \**********************************************/
  31980. /***/ ((module) => {
  31981. /** Used for built-in method references. */
  31982. var funcProto = Function.prototype;
  31983. /** Used to resolve the decompiled source of functions. */
  31984. var funcToString = funcProto.toString;
  31985. /**
  31986. * Converts `func` to its source code.
  31987. *
  31988. * @private
  31989. * @param {Function} func The function to convert.
  31990. * @returns {string} Returns the source code.
  31991. */
  31992. function toSource(func) {
  31993. if (func != null) {
  31994. try {
  31995. return funcToString.call(func);
  31996. } catch (e) {}
  31997. try {
  31998. return (func + '');
  31999. } catch (e) {}
  32000. }
  32001. return '';
  32002. }
  32003. module.exports = toSource;
  32004. /***/ }),
  32005. /***/ "../../node_modules/lodash/eq.js":
  32006. /*!***************************************!*\
  32007. !*** ../../node_modules/lodash/eq.js ***!
  32008. \***************************************/
  32009. /***/ ((module) => {
  32010. /**
  32011. * Performs a
  32012. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  32013. * comparison between two values to determine if they are equivalent.
  32014. *
  32015. * @static
  32016. * @memberOf _
  32017. * @since 4.0.0
  32018. * @category Lang
  32019. * @param {*} value The value to compare.
  32020. * @param {*} other The other value to compare.
  32021. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  32022. * @example
  32023. *
  32024. * var object = { 'a': 1 };
  32025. * var other = { 'a': 1 };
  32026. *
  32027. * _.eq(object, object);
  32028. * // => true
  32029. *
  32030. * _.eq(object, other);
  32031. * // => false
  32032. *
  32033. * _.eq('a', 'a');
  32034. * // => true
  32035. *
  32036. * _.eq('a', Object('a'));
  32037. * // => false
  32038. *
  32039. * _.eq(NaN, NaN);
  32040. * // => true
  32041. */
  32042. function eq(value, other) {
  32043. return value === other || (value !== value && other !== other);
  32044. }
  32045. module.exports = eq;
  32046. /***/ }),
  32047. /***/ "../../node_modules/lodash/flatMap.js":
  32048. /*!********************************************!*\
  32049. !*** ../../node_modules/lodash/flatMap.js ***!
  32050. \********************************************/
  32051. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  32052. var baseFlatten = __webpack_require__(/*! ./_baseFlatten */ "../../node_modules/lodash/_baseFlatten.js"),
  32053. map = __webpack_require__(/*! ./map */ "../../node_modules/lodash/map.js");
  32054. /**
  32055. * Creates a flattened array of values by running each element in `collection`
  32056. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  32057. * with three arguments: (value, index|key, collection).
  32058. *
  32059. * @static
  32060. * @memberOf _
  32061. * @since 4.0.0
  32062. * @category Collection
  32063. * @param {Array|Object} collection The collection to iterate over.
  32064. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  32065. * @returns {Array} Returns the new flattened array.
  32066. * @example
  32067. *
  32068. * function duplicate(n) {
  32069. * return [n, n];
  32070. * }
  32071. *
  32072. * _.flatMap([1, 2], duplicate);
  32073. * // => [1, 1, 2, 2]
  32074. */
  32075. function flatMap(collection, iteratee) {
  32076. return baseFlatten(map(collection, iteratee), 1);
  32077. }
  32078. module.exports = flatMap;
  32079. /***/ }),
  32080. /***/ "../../node_modules/lodash/flatten.js":
  32081. /*!********************************************!*\
  32082. !*** ../../node_modules/lodash/flatten.js ***!
  32083. \********************************************/
  32084. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  32085. var baseFlatten = __webpack_require__(/*! ./_baseFlatten */ "../../node_modules/lodash/_baseFlatten.js");
  32086. /**
  32087. * Flattens `array` a single level deep.
  32088. *
  32089. * @static
  32090. * @memberOf _
  32091. * @since 0.1.0
  32092. * @category Array
  32093. * @param {Array} array The array to flatten.
  32094. * @returns {Array} Returns the new flattened array.
  32095. * @example
  32096. *
  32097. * _.flatten([1, [2, [3, [4]], 5]]);
  32098. * // => [1, 2, [3, [4]], 5]
  32099. */
  32100. function flatten(array) {
  32101. var length = array == null ? 0 : array.length;
  32102. return length ? baseFlatten(array, 1) : [];
  32103. }
  32104. module.exports = flatten;
  32105. /***/ }),
  32106. /***/ "../../node_modules/lodash/get.js":
  32107. /*!****************************************!*\
  32108. !*** ../../node_modules/lodash/get.js ***!
  32109. \****************************************/
  32110. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  32111. var baseGet = __webpack_require__(/*! ./_baseGet */ "../../node_modules/lodash/_baseGet.js");
  32112. /**
  32113. * Gets the value at `path` of `object`. If the resolved value is
  32114. * `undefined`, the `defaultValue` is returned in its place.
  32115. *
  32116. * @static
  32117. * @memberOf _
  32118. * @since 3.7.0
  32119. * @category Object
  32120. * @param {Object} object The object to query.
  32121. * @param {Array|string} path The path of the property to get.
  32122. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  32123. * @returns {*} Returns the resolved value.
  32124. * @example
  32125. *
  32126. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  32127. *
  32128. * _.get(object, 'a[0].b.c');
  32129. * // => 3
  32130. *
  32131. * _.get(object, ['a', '0', 'b', 'c']);
  32132. * // => 3
  32133. *
  32134. * _.get(object, 'a.b.c', 'default');
  32135. * // => 'default'
  32136. */
  32137. function get(object, path, defaultValue) {
  32138. var result = object == null ? undefined : baseGet(object, path);
  32139. return result === undefined ? defaultValue : result;
  32140. }
  32141. module.exports = get;
  32142. /***/ }),
  32143. /***/ "../../node_modules/lodash/groupBy.js":
  32144. /*!********************************************!*\
  32145. !*** ../../node_modules/lodash/groupBy.js ***!
  32146. \********************************************/
  32147. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  32148. var baseAssignValue = __webpack_require__(/*! ./_baseAssignValue */ "../../node_modules/lodash/_baseAssignValue.js"),
  32149. createAggregator = __webpack_require__(/*! ./_createAggregator */ "../../node_modules/lodash/_createAggregator.js");
  32150. /** Used for built-in method references. */
  32151. var objectProto = Object.prototype;
  32152. /** Used to check objects for own properties. */
  32153. var hasOwnProperty = objectProto.hasOwnProperty;
  32154. /**
  32155. * Creates an object composed of keys generated from the results of running
  32156. * each element of `collection` thru `iteratee`. The order of grouped values
  32157. * is determined by the order they occur in `collection`. The corresponding
  32158. * value of each key is an array of elements responsible for generating the
  32159. * key. The iteratee is invoked with one argument: (value).
  32160. *
  32161. * @static
  32162. * @memberOf _
  32163. * @since 0.1.0
  32164. * @category Collection
  32165. * @param {Array|Object} collection The collection to iterate over.
  32166. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  32167. * @returns {Object} Returns the composed aggregate object.
  32168. * @example
  32169. *
  32170. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  32171. * // => { '4': [4.2], '6': [6.1, 6.3] }
  32172. *
  32173. * // The `_.property` iteratee shorthand.
  32174. * _.groupBy(['one', 'two', 'three'], 'length');
  32175. * // => { '3': ['one', 'two'], '5': ['three'] }
  32176. */
  32177. var groupBy = createAggregator(function(result, value, key) {
  32178. if (hasOwnProperty.call(result, key)) {
  32179. result[key].push(value);
  32180. } else {
  32181. baseAssignValue(result, key, [value]);
  32182. }
  32183. });
  32184. module.exports = groupBy;
  32185. /***/ }),
  32186. /***/ "../../node_modules/lodash/hasIn.js":
  32187. /*!******************************************!*\
  32188. !*** ../../node_modules/lodash/hasIn.js ***!
  32189. \******************************************/
  32190. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  32191. var baseHasIn = __webpack_require__(/*! ./_baseHasIn */ "../../node_modules/lodash/_baseHasIn.js"),
  32192. hasPath = __webpack_require__(/*! ./_hasPath */ "../../node_modules/lodash/_hasPath.js");
  32193. /**
  32194. * Checks if `path` is a direct or inherited property of `object`.
  32195. *
  32196. * @static
  32197. * @memberOf _
  32198. * @since 4.0.0
  32199. * @category Object
  32200. * @param {Object} object The object to query.
  32201. * @param {Array|string} path The path to check.
  32202. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  32203. * @example
  32204. *
  32205. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  32206. *
  32207. * _.hasIn(object, 'a');
  32208. * // => true
  32209. *
  32210. * _.hasIn(object, 'a.b');
  32211. * // => true
  32212. *
  32213. * _.hasIn(object, ['a', 'b']);
  32214. * // => true
  32215. *
  32216. * _.hasIn(object, 'b');
  32217. * // => false
  32218. */
  32219. function hasIn(object, path) {
  32220. return object != null && hasPath(object, path, baseHasIn);
  32221. }
  32222. module.exports = hasIn;
  32223. /***/ }),
  32224. /***/ "../../node_modules/lodash/identity.js":
  32225. /*!*********************************************!*\
  32226. !*** ../../node_modules/lodash/identity.js ***!
  32227. \*********************************************/
  32228. /***/ ((module) => {
  32229. /**
  32230. * This method returns the first argument it receives.
  32231. *
  32232. * @static
  32233. * @since 0.1.0
  32234. * @memberOf _
  32235. * @category Util
  32236. * @param {*} value Any value.
  32237. * @returns {*} Returns `value`.
  32238. * @example
  32239. *
  32240. * var object = { 'a': 1 };
  32241. *
  32242. * console.log(_.identity(object) === object);
  32243. * // => true
  32244. */
  32245. function identity(value) {
  32246. return value;
  32247. }
  32248. module.exports = identity;
  32249. /***/ }),
  32250. /***/ "../../node_modules/lodash/isArguments.js":
  32251. /*!************************************************!*\
  32252. !*** ../../node_modules/lodash/isArguments.js ***!
  32253. \************************************************/
  32254. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  32255. var baseIsArguments = __webpack_require__(/*! ./_baseIsArguments */ "../../node_modules/lodash/_baseIsArguments.js"),
  32256. isObjectLike = __webpack_require__(/*! ./isObjectLike */ "../../node_modules/lodash/isObjectLike.js");
  32257. /** Used for built-in method references. */
  32258. var objectProto = Object.prototype;
  32259. /** Used to check objects for own properties. */
  32260. var hasOwnProperty = objectProto.hasOwnProperty;
  32261. /** Built-in value references. */
  32262. var propertyIsEnumerable = objectProto.propertyIsEnumerable;
  32263. /**
  32264. * Checks if `value` is likely an `arguments` object.
  32265. *
  32266. * @static
  32267. * @memberOf _
  32268. * @since 0.1.0
  32269. * @category Lang
  32270. * @param {*} value The value to check.
  32271. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  32272. * else `false`.
  32273. * @example
  32274. *
  32275. * _.isArguments(function() { return arguments; }());
  32276. * // => true
  32277. *
  32278. * _.isArguments([1, 2, 3]);
  32279. * // => false
  32280. */
  32281. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  32282. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  32283. !propertyIsEnumerable.call(value, 'callee');
  32284. };
  32285. module.exports = isArguments;
  32286. /***/ }),
  32287. /***/ "../../node_modules/lodash/isArray.js":
  32288. /*!********************************************!*\
  32289. !*** ../../node_modules/lodash/isArray.js ***!
  32290. \********************************************/
  32291. /***/ ((module) => {
  32292. /**
  32293. * Checks if `value` is classified as an `Array` object.
  32294. *
  32295. * @static
  32296. * @memberOf _
  32297. * @since 0.1.0
  32298. * @category Lang
  32299. * @param {*} value The value to check.
  32300. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  32301. * @example
  32302. *
  32303. * _.isArray([1, 2, 3]);
  32304. * // => true
  32305. *
  32306. * _.isArray(document.body.children);
  32307. * // => false
  32308. *
  32309. * _.isArray('abc');
  32310. * // => false
  32311. *
  32312. * _.isArray(_.noop);
  32313. * // => false
  32314. */
  32315. var isArray = Array.isArray;
  32316. module.exports = isArray;
  32317. /***/ }),
  32318. /***/ "../../node_modules/lodash/isArrayLike.js":
  32319. /*!************************************************!*\
  32320. !*** ../../node_modules/lodash/isArrayLike.js ***!
  32321. \************************************************/
  32322. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  32323. var isFunction = __webpack_require__(/*! ./isFunction */ "../../node_modules/lodash/isFunction.js"),
  32324. isLength = __webpack_require__(/*! ./isLength */ "../../node_modules/lodash/isLength.js");
  32325. /**
  32326. * Checks if `value` is array-like. A value is considered array-like if it's
  32327. * not a function and has a `value.length` that's an integer greater than or
  32328. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  32329. *
  32330. * @static
  32331. * @memberOf _
  32332. * @since 4.0.0
  32333. * @category Lang
  32334. * @param {*} value The value to check.
  32335. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  32336. * @example
  32337. *
  32338. * _.isArrayLike([1, 2, 3]);
  32339. * // => true
  32340. *
  32341. * _.isArrayLike(document.body.children);
  32342. * // => true
  32343. *
  32344. * _.isArrayLike('abc');
  32345. * // => true
  32346. *
  32347. * _.isArrayLike(_.noop);
  32348. * // => false
  32349. */
  32350. function isArrayLike(value) {
  32351. return value != null && isLength(value.length) && !isFunction(value);
  32352. }
  32353. module.exports = isArrayLike;
  32354. /***/ }),
  32355. /***/ "../../node_modules/lodash/isBuffer.js":
  32356. /*!*********************************************!*\
  32357. !*** ../../node_modules/lodash/isBuffer.js ***!
  32358. \*********************************************/
  32359. /***/ ((module, exports, __webpack_require__) => {
  32360. /* module decorator */ module = __webpack_require__.nmd(module);
  32361. var root = __webpack_require__(/*! ./_root */ "../../node_modules/lodash/_root.js"),
  32362. stubFalse = __webpack_require__(/*! ./stubFalse */ "../../node_modules/lodash/stubFalse.js");
  32363. /** Detect free variable `exports`. */
  32364. var freeExports = true && exports && !exports.nodeType && exports;
  32365. /** Detect free variable `module`. */
  32366. var freeModule = freeExports && "object" == 'object' && module && !module.nodeType && module;
  32367. /** Detect the popular CommonJS extension `module.exports`. */
  32368. var moduleExports = freeModule && freeModule.exports === freeExports;
  32369. /** Built-in value references. */
  32370. var Buffer = moduleExports ? root.Buffer : undefined;
  32371. /* Built-in method references for those with the same name as other `lodash` methods. */
  32372. var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
  32373. /**
  32374. * Checks if `value` is a buffer.
  32375. *
  32376. * @static
  32377. * @memberOf _
  32378. * @since 4.3.0
  32379. * @category Lang
  32380. * @param {*} value The value to check.
  32381. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  32382. * @example
  32383. *
  32384. * _.isBuffer(new Buffer(2));
  32385. * // => true
  32386. *
  32387. * _.isBuffer(new Uint8Array(2));
  32388. * // => false
  32389. */
  32390. var isBuffer = nativeIsBuffer || stubFalse;
  32391. module.exports = isBuffer;
  32392. /***/ }),
  32393. /***/ "../../node_modules/lodash/isEqual.js":
  32394. /*!********************************************!*\
  32395. !*** ../../node_modules/lodash/isEqual.js ***!
  32396. \********************************************/
  32397. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  32398. var baseIsEqual = __webpack_require__(/*! ./_baseIsEqual */ "../../node_modules/lodash/_baseIsEqual.js");
  32399. /**
  32400. * Performs a deep comparison between two values to determine if they are
  32401. * equivalent.
  32402. *
  32403. * **Note:** This method supports comparing arrays, array buffers, booleans,
  32404. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  32405. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  32406. * by their own, not inherited, enumerable properties. Functions and DOM
  32407. * nodes are compared by strict equality, i.e. `===`.
  32408. *
  32409. * @static
  32410. * @memberOf _
  32411. * @since 0.1.0
  32412. * @category Lang
  32413. * @param {*} value The value to compare.
  32414. * @param {*} other The other value to compare.
  32415. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  32416. * @example
  32417. *
  32418. * var object = { 'a': 1 };
  32419. * var other = { 'a': 1 };
  32420. *
  32421. * _.isEqual(object, other);
  32422. * // => true
  32423. *
  32424. * object === other;
  32425. * // => false
  32426. */
  32427. function isEqual(value, other) {
  32428. return baseIsEqual(value, other);
  32429. }
  32430. module.exports = isEqual;
  32431. /***/ }),
  32432. /***/ "../../node_modules/lodash/isFunction.js":
  32433. /*!***********************************************!*\
  32434. !*** ../../node_modules/lodash/isFunction.js ***!
  32435. \***********************************************/
  32436. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  32437. var baseGetTag = __webpack_require__(/*! ./_baseGetTag */ "../../node_modules/lodash/_baseGetTag.js"),
  32438. isObject = __webpack_require__(/*! ./isObject */ "../../node_modules/lodash/isObject.js");
  32439. /** `Object#toString` result references. */
  32440. var asyncTag = '[object AsyncFunction]',
  32441. funcTag = '[object Function]',
  32442. genTag = '[object GeneratorFunction]',
  32443. proxyTag = '[object Proxy]';
  32444. /**
  32445. * Checks if `value` is classified as a `Function` object.
  32446. *
  32447. * @static
  32448. * @memberOf _
  32449. * @since 0.1.0
  32450. * @category Lang
  32451. * @param {*} value The value to check.
  32452. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  32453. * @example
  32454. *
  32455. * _.isFunction(_);
  32456. * // => true
  32457. *
  32458. * _.isFunction(/abc/);
  32459. * // => false
  32460. */
  32461. function isFunction(value) {
  32462. if (!isObject(value)) {
  32463. return false;
  32464. }
  32465. // The use of `Object#toString` avoids issues with the `typeof` operator
  32466. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  32467. var tag = baseGetTag(value);
  32468. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  32469. }
  32470. module.exports = isFunction;
  32471. /***/ }),
  32472. /***/ "../../node_modules/lodash/isLength.js":
  32473. /*!*********************************************!*\
  32474. !*** ../../node_modules/lodash/isLength.js ***!
  32475. \*********************************************/
  32476. /***/ ((module) => {
  32477. /** Used as references for various `Number` constants. */
  32478. var MAX_SAFE_INTEGER = 9007199254740991;
  32479. /**
  32480. * Checks if `value` is a valid array-like length.
  32481. *
  32482. * **Note:** This method is loosely based on
  32483. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  32484. *
  32485. * @static
  32486. * @memberOf _
  32487. * @since 4.0.0
  32488. * @category Lang
  32489. * @param {*} value The value to check.
  32490. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  32491. * @example
  32492. *
  32493. * _.isLength(3);
  32494. * // => true
  32495. *
  32496. * _.isLength(Number.MIN_VALUE);
  32497. * // => false
  32498. *
  32499. * _.isLength(Infinity);
  32500. * // => false
  32501. *
  32502. * _.isLength('3');
  32503. * // => false
  32504. */
  32505. function isLength(value) {
  32506. return typeof value == 'number' &&
  32507. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  32508. }
  32509. module.exports = isLength;
  32510. /***/ }),
  32511. /***/ "../../node_modules/lodash/isObject.js":
  32512. /*!*********************************************!*\
  32513. !*** ../../node_modules/lodash/isObject.js ***!
  32514. \*********************************************/
  32515. /***/ ((module) => {
  32516. /**
  32517. * Checks if `value` is the
  32518. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  32519. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  32520. *
  32521. * @static
  32522. * @memberOf _
  32523. * @since 0.1.0
  32524. * @category Lang
  32525. * @param {*} value The value to check.
  32526. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  32527. * @example
  32528. *
  32529. * _.isObject({});
  32530. * // => true
  32531. *
  32532. * _.isObject([1, 2, 3]);
  32533. * // => true
  32534. *
  32535. * _.isObject(_.noop);
  32536. * // => true
  32537. *
  32538. * _.isObject(null);
  32539. * // => false
  32540. */
  32541. function isObject(value) {
  32542. var type = typeof value;
  32543. return value != null && (type == 'object' || type == 'function');
  32544. }
  32545. module.exports = isObject;
  32546. /***/ }),
  32547. /***/ "../../node_modules/lodash/isObjectLike.js":
  32548. /*!*************************************************!*\
  32549. !*** ../../node_modules/lodash/isObjectLike.js ***!
  32550. \*************************************************/
  32551. /***/ ((module) => {
  32552. /**
  32553. * Checks if `value` is object-like. A value is object-like if it's not `null`
  32554. * and has a `typeof` result of "object".
  32555. *
  32556. * @static
  32557. * @memberOf _
  32558. * @since 4.0.0
  32559. * @category Lang
  32560. * @param {*} value The value to check.
  32561. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  32562. * @example
  32563. *
  32564. * _.isObjectLike({});
  32565. * // => true
  32566. *
  32567. * _.isObjectLike([1, 2, 3]);
  32568. * // => true
  32569. *
  32570. * _.isObjectLike(_.noop);
  32571. * // => false
  32572. *
  32573. * _.isObjectLike(null);
  32574. * // => false
  32575. */
  32576. function isObjectLike(value) {
  32577. return value != null && typeof value == 'object';
  32578. }
  32579. module.exports = isObjectLike;
  32580. /***/ }),
  32581. /***/ "../../node_modules/lodash/isSymbol.js":
  32582. /*!*********************************************!*\
  32583. !*** ../../node_modules/lodash/isSymbol.js ***!
  32584. \*********************************************/
  32585. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  32586. var baseGetTag = __webpack_require__(/*! ./_baseGetTag */ "../../node_modules/lodash/_baseGetTag.js"),
  32587. isObjectLike = __webpack_require__(/*! ./isObjectLike */ "../../node_modules/lodash/isObjectLike.js");
  32588. /** `Object#toString` result references. */
  32589. var symbolTag = '[object Symbol]';
  32590. /**
  32591. * Checks if `value` is classified as a `Symbol` primitive or object.
  32592. *
  32593. * @static
  32594. * @memberOf _
  32595. * @since 4.0.0
  32596. * @category Lang
  32597. * @param {*} value The value to check.
  32598. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  32599. * @example
  32600. *
  32601. * _.isSymbol(Symbol.iterator);
  32602. * // => true
  32603. *
  32604. * _.isSymbol('abc');
  32605. * // => false
  32606. */
  32607. function isSymbol(value) {
  32608. return typeof value == 'symbol' ||
  32609. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  32610. }
  32611. module.exports = isSymbol;
  32612. /***/ }),
  32613. /***/ "../../node_modules/lodash/isTypedArray.js":
  32614. /*!*************************************************!*\
  32615. !*** ../../node_modules/lodash/isTypedArray.js ***!
  32616. \*************************************************/
  32617. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  32618. var baseIsTypedArray = __webpack_require__(/*! ./_baseIsTypedArray */ "../../node_modules/lodash/_baseIsTypedArray.js"),
  32619. baseUnary = __webpack_require__(/*! ./_baseUnary */ "../../node_modules/lodash/_baseUnary.js"),
  32620. nodeUtil = __webpack_require__(/*! ./_nodeUtil */ "../../node_modules/lodash/_nodeUtil.js");
  32621. /* Node.js helper references. */
  32622. var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  32623. /**
  32624. * Checks if `value` is classified as a typed array.
  32625. *
  32626. * @static
  32627. * @memberOf _
  32628. * @since 3.0.0
  32629. * @category Lang
  32630. * @param {*} value The value to check.
  32631. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  32632. * @example
  32633. *
  32634. * _.isTypedArray(new Uint8Array);
  32635. * // => true
  32636. *
  32637. * _.isTypedArray([]);
  32638. * // => false
  32639. */
  32640. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  32641. module.exports = isTypedArray;
  32642. /***/ }),
  32643. /***/ "../../node_modules/lodash/keys.js":
  32644. /*!*****************************************!*\
  32645. !*** ../../node_modules/lodash/keys.js ***!
  32646. \*****************************************/
  32647. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  32648. var arrayLikeKeys = __webpack_require__(/*! ./_arrayLikeKeys */ "../../node_modules/lodash/_arrayLikeKeys.js"),
  32649. baseKeys = __webpack_require__(/*! ./_baseKeys */ "../../node_modules/lodash/_baseKeys.js"),
  32650. isArrayLike = __webpack_require__(/*! ./isArrayLike */ "../../node_modules/lodash/isArrayLike.js");
  32651. /**
  32652. * Creates an array of the own enumerable property names of `object`.
  32653. *
  32654. * **Note:** Non-object values are coerced to objects. See the
  32655. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  32656. * for more details.
  32657. *
  32658. * @static
  32659. * @since 0.1.0
  32660. * @memberOf _
  32661. * @category Object
  32662. * @param {Object} object The object to query.
  32663. * @returns {Array} Returns the array of property names.
  32664. * @example
  32665. *
  32666. * function Foo() {
  32667. * this.a = 1;
  32668. * this.b = 2;
  32669. * }
  32670. *
  32671. * Foo.prototype.c = 3;
  32672. *
  32673. * _.keys(new Foo);
  32674. * // => ['a', 'b'] (iteration order is not guaranteed)
  32675. *
  32676. * _.keys('hi');
  32677. * // => ['0', '1']
  32678. */
  32679. function keys(object) {
  32680. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  32681. }
  32682. module.exports = keys;
  32683. /***/ }),
  32684. /***/ "../../node_modules/lodash/keysIn.js":
  32685. /*!*******************************************!*\
  32686. !*** ../../node_modules/lodash/keysIn.js ***!
  32687. \*******************************************/
  32688. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  32689. var arrayLikeKeys = __webpack_require__(/*! ./_arrayLikeKeys */ "../../node_modules/lodash/_arrayLikeKeys.js"),
  32690. baseKeysIn = __webpack_require__(/*! ./_baseKeysIn */ "../../node_modules/lodash/_baseKeysIn.js"),
  32691. isArrayLike = __webpack_require__(/*! ./isArrayLike */ "../../node_modules/lodash/isArrayLike.js");
  32692. /**
  32693. * Creates an array of the own and inherited enumerable property names of `object`.
  32694. *
  32695. * **Note:** Non-object values are coerced to objects.
  32696. *
  32697. * @static
  32698. * @memberOf _
  32699. * @since 3.0.0
  32700. * @category Object
  32701. * @param {Object} object The object to query.
  32702. * @returns {Array} Returns the array of property names.
  32703. * @example
  32704. *
  32705. * function Foo() {
  32706. * this.a = 1;
  32707. * this.b = 2;
  32708. * }
  32709. *
  32710. * Foo.prototype.c = 3;
  32711. *
  32712. * _.keysIn(new Foo);
  32713. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  32714. */
  32715. function keysIn(object) {
  32716. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  32717. }
  32718. module.exports = keysIn;
  32719. /***/ }),
  32720. /***/ "../../node_modules/lodash/lodash.js":
  32721. /*!*******************************************!*\
  32722. !*** ../../node_modules/lodash/lodash.js ***!
  32723. \*******************************************/
  32724. /***/ (function(module, exports, __webpack_require__) {
  32725. /* module decorator */ module = __webpack_require__.nmd(module);
  32726. var __WEBPACK_AMD_DEFINE_RESULT__;/**
  32727. * @license
  32728. * Lodash <https://lodash.com/>
  32729. * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
  32730. * Released under MIT license <https://lodash.com/license>
  32731. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  32732. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  32733. */
  32734. ;(function() {
  32735. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  32736. var undefined;
  32737. /** Used as the semantic version number. */
  32738. var VERSION = '4.17.21';
  32739. /** Used as the size to enable large array optimizations. */
  32740. var LARGE_ARRAY_SIZE = 200;
  32741. /** Error message constants. */
  32742. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  32743. FUNC_ERROR_TEXT = 'Expected a function',
  32744. INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`';
  32745. /** Used to stand-in for `undefined` hash values. */
  32746. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  32747. /** Used as the maximum memoize cache size. */
  32748. var MAX_MEMOIZE_SIZE = 500;
  32749. /** Used as the internal argument placeholder. */
  32750. var PLACEHOLDER = '__lodash_placeholder__';
  32751. /** Used to compose bitmasks for cloning. */
  32752. var CLONE_DEEP_FLAG = 1,
  32753. CLONE_FLAT_FLAG = 2,
  32754. CLONE_SYMBOLS_FLAG = 4;
  32755. /** Used to compose bitmasks for value comparisons. */
  32756. var COMPARE_PARTIAL_FLAG = 1,
  32757. COMPARE_UNORDERED_FLAG = 2;
  32758. /** Used to compose bitmasks for function metadata. */
  32759. var WRAP_BIND_FLAG = 1,
  32760. WRAP_BIND_KEY_FLAG = 2,
  32761. WRAP_CURRY_BOUND_FLAG = 4,
  32762. WRAP_CURRY_FLAG = 8,
  32763. WRAP_CURRY_RIGHT_FLAG = 16,
  32764. WRAP_PARTIAL_FLAG = 32,
  32765. WRAP_PARTIAL_RIGHT_FLAG = 64,
  32766. WRAP_ARY_FLAG = 128,
  32767. WRAP_REARG_FLAG = 256,
  32768. WRAP_FLIP_FLAG = 512;
  32769. /** Used as default options for `_.truncate`. */
  32770. var DEFAULT_TRUNC_LENGTH = 30,
  32771. DEFAULT_TRUNC_OMISSION = '...';
  32772. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  32773. var HOT_COUNT = 800,
  32774. HOT_SPAN = 16;
  32775. /** Used to indicate the type of lazy iteratees. */
  32776. var LAZY_FILTER_FLAG = 1,
  32777. LAZY_MAP_FLAG = 2,
  32778. LAZY_WHILE_FLAG = 3;
  32779. /** Used as references for various `Number` constants. */
  32780. var INFINITY = 1 / 0,
  32781. MAX_SAFE_INTEGER = 9007199254740991,
  32782. MAX_INTEGER = 1.7976931348623157e+308,
  32783. NAN = 0 / 0;
  32784. /** Used as references for the maximum length and index of an array. */
  32785. var MAX_ARRAY_LENGTH = 4294967295,
  32786. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  32787. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  32788. /** Used to associate wrap methods with their bit flags. */
  32789. var wrapFlags = [
  32790. ['ary', WRAP_ARY_FLAG],
  32791. ['bind', WRAP_BIND_FLAG],
  32792. ['bindKey', WRAP_BIND_KEY_FLAG],
  32793. ['curry', WRAP_CURRY_FLAG],
  32794. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  32795. ['flip', WRAP_FLIP_FLAG],
  32796. ['partial', WRAP_PARTIAL_FLAG],
  32797. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  32798. ['rearg', WRAP_REARG_FLAG]
  32799. ];
  32800. /** `Object#toString` result references. */
  32801. var argsTag = '[object Arguments]',
  32802. arrayTag = '[object Array]',
  32803. asyncTag = '[object AsyncFunction]',
  32804. boolTag = '[object Boolean]',
  32805. dateTag = '[object Date]',
  32806. domExcTag = '[object DOMException]',
  32807. errorTag = '[object Error]',
  32808. funcTag = '[object Function]',
  32809. genTag = '[object GeneratorFunction]',
  32810. mapTag = '[object Map]',
  32811. numberTag = '[object Number]',
  32812. nullTag = '[object Null]',
  32813. objectTag = '[object Object]',
  32814. promiseTag = '[object Promise]',
  32815. proxyTag = '[object Proxy]',
  32816. regexpTag = '[object RegExp]',
  32817. setTag = '[object Set]',
  32818. stringTag = '[object String]',
  32819. symbolTag = '[object Symbol]',
  32820. undefinedTag = '[object Undefined]',
  32821. weakMapTag = '[object WeakMap]',
  32822. weakSetTag = '[object WeakSet]';
  32823. var arrayBufferTag = '[object ArrayBuffer]',
  32824. dataViewTag = '[object DataView]',
  32825. float32Tag = '[object Float32Array]',
  32826. float64Tag = '[object Float64Array]',
  32827. int8Tag = '[object Int8Array]',
  32828. int16Tag = '[object Int16Array]',
  32829. int32Tag = '[object Int32Array]',
  32830. uint8Tag = '[object Uint8Array]',
  32831. uint8ClampedTag = '[object Uint8ClampedArray]',
  32832. uint16Tag = '[object Uint16Array]',
  32833. uint32Tag = '[object Uint32Array]';
  32834. /** Used to match empty string literals in compiled template source. */
  32835. var reEmptyStringLeading = /\b__p \+= '';/g,
  32836. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  32837. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  32838. /** Used to match HTML entities and HTML characters. */
  32839. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  32840. reUnescapedHtml = /[&<>"']/g,
  32841. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  32842. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  32843. /** Used to match template delimiters. */
  32844. var reEscape = /<%-([\s\S]+?)%>/g,
  32845. reEvaluate = /<%([\s\S]+?)%>/g,
  32846. reInterpolate = /<%=([\s\S]+?)%>/g;
  32847. /** Used to match property names within property paths. */
  32848. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  32849. reIsPlainProp = /^\w*$/,
  32850. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  32851. /**
  32852. * Used to match `RegExp`
  32853. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  32854. */
  32855. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  32856. reHasRegExpChar = RegExp(reRegExpChar.source);
  32857. /** Used to match leading whitespace. */
  32858. var reTrimStart = /^\s+/;
  32859. /** Used to match a single whitespace character. */
  32860. var reWhitespace = /\s/;
  32861. /** Used to match wrap detail comments. */
  32862. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  32863. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  32864. reSplitDetails = /,? & /;
  32865. /** Used to match words composed of alphanumeric characters. */
  32866. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  32867. /**
  32868. * Used to validate the `validate` option in `_.template` variable.
  32869. *
  32870. * Forbids characters which could potentially change the meaning of the function argument definition:
  32871. * - "()," (modification of function parameters)
  32872. * - "=" (default value)
  32873. * - "[]{}" (destructuring of function parameters)
  32874. * - "/" (beginning of a comment)
  32875. * - whitespace
  32876. */
  32877. var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/;
  32878. /** Used to match backslashes in property paths. */
  32879. var reEscapeChar = /\\(\\)?/g;
  32880. /**
  32881. * Used to match
  32882. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  32883. */
  32884. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  32885. /** Used to match `RegExp` flags from their coerced string values. */
  32886. var reFlags = /\w*$/;
  32887. /** Used to detect bad signed hexadecimal string values. */
  32888. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  32889. /** Used to detect binary string values. */
  32890. var reIsBinary = /^0b[01]+$/i;
  32891. /** Used to detect host constructors (Safari). */
  32892. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  32893. /** Used to detect octal string values. */
  32894. var reIsOctal = /^0o[0-7]+$/i;
  32895. /** Used to detect unsigned integer values. */
  32896. var reIsUint = /^(?:0|[1-9]\d*)$/;
  32897. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  32898. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  32899. /** Used to ensure capturing order of template delimiters. */
  32900. var reNoMatch = /($^)/;
  32901. /** Used to match unescaped characters in compiled string literals. */
  32902. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  32903. /** Used to compose unicode character classes. */
  32904. var rsAstralRange = '\\ud800-\\udfff',
  32905. rsComboMarksRange = '\\u0300-\\u036f',
  32906. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  32907. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  32908. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  32909. rsDingbatRange = '\\u2700-\\u27bf',
  32910. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  32911. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  32912. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  32913. rsPunctuationRange = '\\u2000-\\u206f',
  32914. rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000',
  32915. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  32916. rsVarRange = '\\ufe0e\\ufe0f',
  32917. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  32918. /** Used to compose unicode capture groups. */
  32919. var rsApos = "['\u2019]",
  32920. rsAstral = '[' + rsAstralRange + ']',
  32921. rsBreak = '[' + rsBreakRange + ']',
  32922. rsCombo = '[' + rsComboRange + ']',
  32923. rsDigits = '\\d+',
  32924. rsDingbat = '[' + rsDingbatRange + ']',
  32925. rsLower = '[' + rsLowerRange + ']',
  32926. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  32927. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  32928. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  32929. rsNonAstral = '[^' + rsAstralRange + ']',
  32930. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  32931. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  32932. rsUpper = '[' + rsUpperRange + ']',
  32933. rsZWJ = '\\u200d';
  32934. /** Used to compose unicode regexes. */
  32935. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  32936. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  32937. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  32938. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  32939. reOptMod = rsModifier + '?',
  32940. rsOptVar = '[' + rsVarRange + ']?',
  32941. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  32942. rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
  32943. rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
  32944. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  32945. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  32946. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  32947. /** Used to match apostrophes. */
  32948. var reApos = RegExp(rsApos, 'g');
  32949. /**
  32950. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  32951. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  32952. */
  32953. var reComboMark = RegExp(rsCombo, 'g');
  32954. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  32955. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  32956. /** Used to match complex or compound words. */
  32957. var reUnicodeWord = RegExp([
  32958. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  32959. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  32960. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  32961. rsUpper + '+' + rsOptContrUpper,
  32962. rsOrdUpper,
  32963. rsOrdLower,
  32964. rsDigits,
  32965. rsEmoji
  32966. ].join('|'), 'g');
  32967. /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
  32968. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  32969. /** Used to detect strings that need a more robust regexp to match words. */
  32970. var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
  32971. /** Used to assign default `context` object properties. */
  32972. var contextProps = [
  32973. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  32974. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  32975. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  32976. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  32977. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  32978. ];
  32979. /** Used to make template sourceURLs easier to identify. */
  32980. var templateCounter = -1;
  32981. /** Used to identify `toStringTag` values of typed arrays. */
  32982. var typedArrayTags = {};
  32983. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  32984. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  32985. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  32986. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  32987. typedArrayTags[uint32Tag] = true;
  32988. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  32989. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  32990. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  32991. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  32992. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  32993. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  32994. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  32995. typedArrayTags[weakMapTag] = false;
  32996. /** Used to identify `toStringTag` values supported by `_.clone`. */
  32997. var cloneableTags = {};
  32998. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  32999. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  33000. cloneableTags[boolTag] = cloneableTags[dateTag] =
  33001. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  33002. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  33003. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  33004. cloneableTags[numberTag] = cloneableTags[objectTag] =
  33005. cloneableTags[regexpTag] = cloneableTags[setTag] =
  33006. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  33007. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  33008. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  33009. cloneableTags[errorTag] = cloneableTags[funcTag] =
  33010. cloneableTags[weakMapTag] = false;
  33011. /** Used to map Latin Unicode letters to basic Latin letters. */
  33012. var deburredLetters = {
  33013. // Latin-1 Supplement block.
  33014. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  33015. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  33016. '\xc7': 'C', '\xe7': 'c',
  33017. '\xd0': 'D', '\xf0': 'd',
  33018. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  33019. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  33020. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  33021. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  33022. '\xd1': 'N', '\xf1': 'n',
  33023. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  33024. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  33025. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  33026. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  33027. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  33028. '\xc6': 'Ae', '\xe6': 'ae',
  33029. '\xde': 'Th', '\xfe': 'th',
  33030. '\xdf': 'ss',
  33031. // Latin Extended-A block.
  33032. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  33033. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  33034. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  33035. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  33036. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  33037. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  33038. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  33039. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  33040. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  33041. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  33042. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  33043. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  33044. '\u0134': 'J', '\u0135': 'j',
  33045. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  33046. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  33047. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  33048. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  33049. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  33050. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  33051. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  33052. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  33053. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  33054. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  33055. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  33056. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  33057. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  33058. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  33059. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  33060. '\u0174': 'W', '\u0175': 'w',
  33061. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  33062. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  33063. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  33064. '\u0132': 'IJ', '\u0133': 'ij',
  33065. '\u0152': 'Oe', '\u0153': 'oe',
  33066. '\u0149': "'n", '\u017f': 's'
  33067. };
  33068. /** Used to map characters to HTML entities. */
  33069. var htmlEscapes = {
  33070. '&': '&amp;',
  33071. '<': '&lt;',
  33072. '>': '&gt;',
  33073. '"': '&quot;',
  33074. "'": '&#39;'
  33075. };
  33076. /** Used to map HTML entities to characters. */
  33077. var htmlUnescapes = {
  33078. '&amp;': '&',
  33079. '&lt;': '<',
  33080. '&gt;': '>',
  33081. '&quot;': '"',
  33082. '&#39;': "'"
  33083. };
  33084. /** Used to escape characters for inclusion in compiled string literals. */
  33085. var stringEscapes = {
  33086. '\\': '\\',
  33087. "'": "'",
  33088. '\n': 'n',
  33089. '\r': 'r',
  33090. '\u2028': 'u2028',
  33091. '\u2029': 'u2029'
  33092. };
  33093. /** Built-in method references without a dependency on `root`. */
  33094. var freeParseFloat = parseFloat,
  33095. freeParseInt = parseInt;
  33096. /** Detect free variable `global` from Node.js. */
  33097. var freeGlobal = typeof __webpack_require__.g == 'object' && __webpack_require__.g && __webpack_require__.g.Object === Object && __webpack_require__.g;
  33098. /** Detect free variable `self`. */
  33099. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  33100. /** Used as a reference to the global object. */
  33101. var root = freeGlobal || freeSelf || Function('return this')();
  33102. /** Detect free variable `exports`. */
  33103. var freeExports = true && exports && !exports.nodeType && exports;
  33104. /** Detect free variable `module`. */
  33105. var freeModule = freeExports && "object" == 'object' && module && !module.nodeType && module;
  33106. /** Detect the popular CommonJS extension `module.exports`. */
  33107. var moduleExports = freeModule && freeModule.exports === freeExports;
  33108. /** Detect free variable `process` from Node.js. */
  33109. var freeProcess = moduleExports && freeGlobal.process;
  33110. /** Used to access faster Node.js helpers. */
  33111. var nodeUtil = (function() {
  33112. try {
  33113. // Use `util.types` for Node.js 10+.
  33114. var types = freeModule && freeModule.require && freeModule.require('util').types;
  33115. if (types) {
  33116. return types;
  33117. }
  33118. // Legacy `process.binding('util')` for Node.js < 10.
  33119. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  33120. } catch (e) {}
  33121. }());
  33122. /* Node.js helper references. */
  33123. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  33124. nodeIsDate = nodeUtil && nodeUtil.isDate,
  33125. nodeIsMap = nodeUtil && nodeUtil.isMap,
  33126. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  33127. nodeIsSet = nodeUtil && nodeUtil.isSet,
  33128. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  33129. /*--------------------------------------------------------------------------*/
  33130. /**
  33131. * A faster alternative to `Function#apply`, this function invokes `func`
  33132. * with the `this` binding of `thisArg` and the arguments of `args`.
  33133. *
  33134. * @private
  33135. * @param {Function} func The function to invoke.
  33136. * @param {*} thisArg The `this` binding of `func`.
  33137. * @param {Array} args The arguments to invoke `func` with.
  33138. * @returns {*} Returns the result of `func`.
  33139. */
  33140. function apply(func, thisArg, args) {
  33141. switch (args.length) {
  33142. case 0: return func.call(thisArg);
  33143. case 1: return func.call(thisArg, args[0]);
  33144. case 2: return func.call(thisArg, args[0], args[1]);
  33145. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  33146. }
  33147. return func.apply(thisArg, args);
  33148. }
  33149. /**
  33150. * A specialized version of `baseAggregator` for arrays.
  33151. *
  33152. * @private
  33153. * @param {Array} [array] The array to iterate over.
  33154. * @param {Function} setter The function to set `accumulator` values.
  33155. * @param {Function} iteratee The iteratee to transform keys.
  33156. * @param {Object} accumulator The initial aggregated object.
  33157. * @returns {Function} Returns `accumulator`.
  33158. */
  33159. function arrayAggregator(array, setter, iteratee, accumulator) {
  33160. var index = -1,
  33161. length = array == null ? 0 : array.length;
  33162. while (++index < length) {
  33163. var value = array[index];
  33164. setter(accumulator, value, iteratee(value), array);
  33165. }
  33166. return accumulator;
  33167. }
  33168. /**
  33169. * A specialized version of `_.forEach` for arrays without support for
  33170. * iteratee shorthands.
  33171. *
  33172. * @private
  33173. * @param {Array} [array] The array to iterate over.
  33174. * @param {Function} iteratee The function invoked per iteration.
  33175. * @returns {Array} Returns `array`.
  33176. */
  33177. function arrayEach(array, iteratee) {
  33178. var index = -1,
  33179. length = array == null ? 0 : array.length;
  33180. while (++index < length) {
  33181. if (iteratee(array[index], index, array) === false) {
  33182. break;
  33183. }
  33184. }
  33185. return array;
  33186. }
  33187. /**
  33188. * A specialized version of `_.forEachRight` for arrays without support for
  33189. * iteratee shorthands.
  33190. *
  33191. * @private
  33192. * @param {Array} [array] The array to iterate over.
  33193. * @param {Function} iteratee The function invoked per iteration.
  33194. * @returns {Array} Returns `array`.
  33195. */
  33196. function arrayEachRight(array, iteratee) {
  33197. var length = array == null ? 0 : array.length;
  33198. while (length--) {
  33199. if (iteratee(array[length], length, array) === false) {
  33200. break;
  33201. }
  33202. }
  33203. return array;
  33204. }
  33205. /**
  33206. * A specialized version of `_.every` for arrays without support for
  33207. * iteratee shorthands.
  33208. *
  33209. * @private
  33210. * @param {Array} [array] The array to iterate over.
  33211. * @param {Function} predicate The function invoked per iteration.
  33212. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  33213. * else `false`.
  33214. */
  33215. function arrayEvery(array, predicate) {
  33216. var index = -1,
  33217. length = array == null ? 0 : array.length;
  33218. while (++index < length) {
  33219. if (!predicate(array[index], index, array)) {
  33220. return false;
  33221. }
  33222. }
  33223. return true;
  33224. }
  33225. /**
  33226. * A specialized version of `_.filter` for arrays without support for
  33227. * iteratee shorthands.
  33228. *
  33229. * @private
  33230. * @param {Array} [array] The array to iterate over.
  33231. * @param {Function} predicate The function invoked per iteration.
  33232. * @returns {Array} Returns the new filtered array.
  33233. */
  33234. function arrayFilter(array, predicate) {
  33235. var index = -1,
  33236. length = array == null ? 0 : array.length,
  33237. resIndex = 0,
  33238. result = [];
  33239. while (++index < length) {
  33240. var value = array[index];
  33241. if (predicate(value, index, array)) {
  33242. result[resIndex++] = value;
  33243. }
  33244. }
  33245. return result;
  33246. }
  33247. /**
  33248. * A specialized version of `_.includes` for arrays without support for
  33249. * specifying an index to search from.
  33250. *
  33251. * @private
  33252. * @param {Array} [array] The array to inspect.
  33253. * @param {*} target The value to search for.
  33254. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  33255. */
  33256. function arrayIncludes(array, value) {
  33257. var length = array == null ? 0 : array.length;
  33258. return !!length && baseIndexOf(array, value, 0) > -1;
  33259. }
  33260. /**
  33261. * This function is like `arrayIncludes` except that it accepts a comparator.
  33262. *
  33263. * @private
  33264. * @param {Array} [array] The array to inspect.
  33265. * @param {*} target The value to search for.
  33266. * @param {Function} comparator The comparator invoked per element.
  33267. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  33268. */
  33269. function arrayIncludesWith(array, value, comparator) {
  33270. var index = -1,
  33271. length = array == null ? 0 : array.length;
  33272. while (++index < length) {
  33273. if (comparator(value, array[index])) {
  33274. return true;
  33275. }
  33276. }
  33277. return false;
  33278. }
  33279. /**
  33280. * A specialized version of `_.map` for arrays without support for iteratee
  33281. * shorthands.
  33282. *
  33283. * @private
  33284. * @param {Array} [array] The array to iterate over.
  33285. * @param {Function} iteratee The function invoked per iteration.
  33286. * @returns {Array} Returns the new mapped array.
  33287. */
  33288. function arrayMap(array, iteratee) {
  33289. var index = -1,
  33290. length = array == null ? 0 : array.length,
  33291. result = Array(length);
  33292. while (++index < length) {
  33293. result[index] = iteratee(array[index], index, array);
  33294. }
  33295. return result;
  33296. }
  33297. /**
  33298. * Appends the elements of `values` to `array`.
  33299. *
  33300. * @private
  33301. * @param {Array} array The array to modify.
  33302. * @param {Array} values The values to append.
  33303. * @returns {Array} Returns `array`.
  33304. */
  33305. function arrayPush(array, values) {
  33306. var index = -1,
  33307. length = values.length,
  33308. offset = array.length;
  33309. while (++index < length) {
  33310. array[offset + index] = values[index];
  33311. }
  33312. return array;
  33313. }
  33314. /**
  33315. * A specialized version of `_.reduce` for arrays without support for
  33316. * iteratee shorthands.
  33317. *
  33318. * @private
  33319. * @param {Array} [array] The array to iterate over.
  33320. * @param {Function} iteratee The function invoked per iteration.
  33321. * @param {*} [accumulator] The initial value.
  33322. * @param {boolean} [initAccum] Specify using the first element of `array` as
  33323. * the initial value.
  33324. * @returns {*} Returns the accumulated value.
  33325. */
  33326. function arrayReduce(array, iteratee, accumulator, initAccum) {
  33327. var index = -1,
  33328. length = array == null ? 0 : array.length;
  33329. if (initAccum && length) {
  33330. accumulator = array[++index];
  33331. }
  33332. while (++index < length) {
  33333. accumulator = iteratee(accumulator, array[index], index, array);
  33334. }
  33335. return accumulator;
  33336. }
  33337. /**
  33338. * A specialized version of `_.reduceRight` for arrays without support for
  33339. * iteratee shorthands.
  33340. *
  33341. * @private
  33342. * @param {Array} [array] The array to iterate over.
  33343. * @param {Function} iteratee The function invoked per iteration.
  33344. * @param {*} [accumulator] The initial value.
  33345. * @param {boolean} [initAccum] Specify using the last element of `array` as
  33346. * the initial value.
  33347. * @returns {*} Returns the accumulated value.
  33348. */
  33349. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  33350. var length = array == null ? 0 : array.length;
  33351. if (initAccum && length) {
  33352. accumulator = array[--length];
  33353. }
  33354. while (length--) {
  33355. accumulator = iteratee(accumulator, array[length], length, array);
  33356. }
  33357. return accumulator;
  33358. }
  33359. /**
  33360. * A specialized version of `_.some` for arrays without support for iteratee
  33361. * shorthands.
  33362. *
  33363. * @private
  33364. * @param {Array} [array] The array to iterate over.
  33365. * @param {Function} predicate The function invoked per iteration.
  33366. * @returns {boolean} Returns `true` if any element passes the predicate check,
  33367. * else `false`.
  33368. */
  33369. function arraySome(array, predicate) {
  33370. var index = -1,
  33371. length = array == null ? 0 : array.length;
  33372. while (++index < length) {
  33373. if (predicate(array[index], index, array)) {
  33374. return true;
  33375. }
  33376. }
  33377. return false;
  33378. }
  33379. /**
  33380. * Gets the size of an ASCII `string`.
  33381. *
  33382. * @private
  33383. * @param {string} string The string inspect.
  33384. * @returns {number} Returns the string size.
  33385. */
  33386. var asciiSize = baseProperty('length');
  33387. /**
  33388. * Converts an ASCII `string` to an array.
  33389. *
  33390. * @private
  33391. * @param {string} string The string to convert.
  33392. * @returns {Array} Returns the converted array.
  33393. */
  33394. function asciiToArray(string) {
  33395. return string.split('');
  33396. }
  33397. /**
  33398. * Splits an ASCII `string` into an array of its words.
  33399. *
  33400. * @private
  33401. * @param {string} The string to inspect.
  33402. * @returns {Array} Returns the words of `string`.
  33403. */
  33404. function asciiWords(string) {
  33405. return string.match(reAsciiWord) || [];
  33406. }
  33407. /**
  33408. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  33409. * without support for iteratee shorthands, which iterates over `collection`
  33410. * using `eachFunc`.
  33411. *
  33412. * @private
  33413. * @param {Array|Object} collection The collection to inspect.
  33414. * @param {Function} predicate The function invoked per iteration.
  33415. * @param {Function} eachFunc The function to iterate over `collection`.
  33416. * @returns {*} Returns the found element or its key, else `undefined`.
  33417. */
  33418. function baseFindKey(collection, predicate, eachFunc) {
  33419. var result;
  33420. eachFunc(collection, function(value, key, collection) {
  33421. if (predicate(value, key, collection)) {
  33422. result = key;
  33423. return false;
  33424. }
  33425. });
  33426. return result;
  33427. }
  33428. /**
  33429. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  33430. * support for iteratee shorthands.
  33431. *
  33432. * @private
  33433. * @param {Array} array The array to inspect.
  33434. * @param {Function} predicate The function invoked per iteration.
  33435. * @param {number} fromIndex The index to search from.
  33436. * @param {boolean} [fromRight] Specify iterating from right to left.
  33437. * @returns {number} Returns the index of the matched value, else `-1`.
  33438. */
  33439. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  33440. var length = array.length,
  33441. index = fromIndex + (fromRight ? 1 : -1);
  33442. while ((fromRight ? index-- : ++index < length)) {
  33443. if (predicate(array[index], index, array)) {
  33444. return index;
  33445. }
  33446. }
  33447. return -1;
  33448. }
  33449. /**
  33450. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  33451. *
  33452. * @private
  33453. * @param {Array} array The array to inspect.
  33454. * @param {*} value The value to search for.
  33455. * @param {number} fromIndex The index to search from.
  33456. * @returns {number} Returns the index of the matched value, else `-1`.
  33457. */
  33458. function baseIndexOf(array, value, fromIndex) {
  33459. return value === value
  33460. ? strictIndexOf(array, value, fromIndex)
  33461. : baseFindIndex(array, baseIsNaN, fromIndex);
  33462. }
  33463. /**
  33464. * This function is like `baseIndexOf` except that it accepts a comparator.
  33465. *
  33466. * @private
  33467. * @param {Array} array The array to inspect.
  33468. * @param {*} value The value to search for.
  33469. * @param {number} fromIndex The index to search from.
  33470. * @param {Function} comparator The comparator invoked per element.
  33471. * @returns {number} Returns the index of the matched value, else `-1`.
  33472. */
  33473. function baseIndexOfWith(array, value, fromIndex, comparator) {
  33474. var index = fromIndex - 1,
  33475. length = array.length;
  33476. while (++index < length) {
  33477. if (comparator(array[index], value)) {
  33478. return index;
  33479. }
  33480. }
  33481. return -1;
  33482. }
  33483. /**
  33484. * The base implementation of `_.isNaN` without support for number objects.
  33485. *
  33486. * @private
  33487. * @param {*} value The value to check.
  33488. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  33489. */
  33490. function baseIsNaN(value) {
  33491. return value !== value;
  33492. }
  33493. /**
  33494. * The base implementation of `_.mean` and `_.meanBy` without support for
  33495. * iteratee shorthands.
  33496. *
  33497. * @private
  33498. * @param {Array} array The array to iterate over.
  33499. * @param {Function} iteratee The function invoked per iteration.
  33500. * @returns {number} Returns the mean.
  33501. */
  33502. function baseMean(array, iteratee) {
  33503. var length = array == null ? 0 : array.length;
  33504. return length ? (baseSum(array, iteratee) / length) : NAN;
  33505. }
  33506. /**
  33507. * The base implementation of `_.property` without support for deep paths.
  33508. *
  33509. * @private
  33510. * @param {string} key The key of the property to get.
  33511. * @returns {Function} Returns the new accessor function.
  33512. */
  33513. function baseProperty(key) {
  33514. return function(object) {
  33515. return object == null ? undefined : object[key];
  33516. };
  33517. }
  33518. /**
  33519. * The base implementation of `_.propertyOf` without support for deep paths.
  33520. *
  33521. * @private
  33522. * @param {Object} object The object to query.
  33523. * @returns {Function} Returns the new accessor function.
  33524. */
  33525. function basePropertyOf(object) {
  33526. return function(key) {
  33527. return object == null ? undefined : object[key];
  33528. };
  33529. }
  33530. /**
  33531. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  33532. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  33533. *
  33534. * @private
  33535. * @param {Array|Object} collection The collection to iterate over.
  33536. * @param {Function} iteratee The function invoked per iteration.
  33537. * @param {*} accumulator The initial value.
  33538. * @param {boolean} initAccum Specify using the first or last element of
  33539. * `collection` as the initial value.
  33540. * @param {Function} eachFunc The function to iterate over `collection`.
  33541. * @returns {*} Returns the accumulated value.
  33542. */
  33543. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  33544. eachFunc(collection, function(value, index, collection) {
  33545. accumulator = initAccum
  33546. ? (initAccum = false, value)
  33547. : iteratee(accumulator, value, index, collection);
  33548. });
  33549. return accumulator;
  33550. }
  33551. /**
  33552. * The base implementation of `_.sortBy` which uses `comparer` to define the
  33553. * sort order of `array` and replaces criteria objects with their corresponding
  33554. * values.
  33555. *
  33556. * @private
  33557. * @param {Array} array The array to sort.
  33558. * @param {Function} comparer The function to define sort order.
  33559. * @returns {Array} Returns `array`.
  33560. */
  33561. function baseSortBy(array, comparer) {
  33562. var length = array.length;
  33563. array.sort(comparer);
  33564. while (length--) {
  33565. array[length] = array[length].value;
  33566. }
  33567. return array;
  33568. }
  33569. /**
  33570. * The base implementation of `_.sum` and `_.sumBy` without support for
  33571. * iteratee shorthands.
  33572. *
  33573. * @private
  33574. * @param {Array} array The array to iterate over.
  33575. * @param {Function} iteratee The function invoked per iteration.
  33576. * @returns {number} Returns the sum.
  33577. */
  33578. function baseSum(array, iteratee) {
  33579. var result,
  33580. index = -1,
  33581. length = array.length;
  33582. while (++index < length) {
  33583. var current = iteratee(array[index]);
  33584. if (current !== undefined) {
  33585. result = result === undefined ? current : (result + current);
  33586. }
  33587. }
  33588. return result;
  33589. }
  33590. /**
  33591. * The base implementation of `_.times` without support for iteratee shorthands
  33592. * or max array length checks.
  33593. *
  33594. * @private
  33595. * @param {number} n The number of times to invoke `iteratee`.
  33596. * @param {Function} iteratee The function invoked per iteration.
  33597. * @returns {Array} Returns the array of results.
  33598. */
  33599. function baseTimes(n, iteratee) {
  33600. var index = -1,
  33601. result = Array(n);
  33602. while (++index < n) {
  33603. result[index] = iteratee(index);
  33604. }
  33605. return result;
  33606. }
  33607. /**
  33608. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  33609. * of key-value pairs for `object` corresponding to the property names of `props`.
  33610. *
  33611. * @private
  33612. * @param {Object} object The object to query.
  33613. * @param {Array} props The property names to get values for.
  33614. * @returns {Object} Returns the key-value pairs.
  33615. */
  33616. function baseToPairs(object, props) {
  33617. return arrayMap(props, function(key) {
  33618. return [key, object[key]];
  33619. });
  33620. }
  33621. /**
  33622. * The base implementation of `_.trim`.
  33623. *
  33624. * @private
  33625. * @param {string} string The string to trim.
  33626. * @returns {string} Returns the trimmed string.
  33627. */
  33628. function baseTrim(string) {
  33629. return string
  33630. ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
  33631. : string;
  33632. }
  33633. /**
  33634. * The base implementation of `_.unary` without support for storing metadata.
  33635. *
  33636. * @private
  33637. * @param {Function} func The function to cap arguments for.
  33638. * @returns {Function} Returns the new capped function.
  33639. */
  33640. function baseUnary(func) {
  33641. return function(value) {
  33642. return func(value);
  33643. };
  33644. }
  33645. /**
  33646. * The base implementation of `_.values` and `_.valuesIn` which creates an
  33647. * array of `object` property values corresponding to the property names
  33648. * of `props`.
  33649. *
  33650. * @private
  33651. * @param {Object} object The object to query.
  33652. * @param {Array} props The property names to get values for.
  33653. * @returns {Object} Returns the array of property values.
  33654. */
  33655. function baseValues(object, props) {
  33656. return arrayMap(props, function(key) {
  33657. return object[key];
  33658. });
  33659. }
  33660. /**
  33661. * Checks if a `cache` value for `key` exists.
  33662. *
  33663. * @private
  33664. * @param {Object} cache The cache to query.
  33665. * @param {string} key The key of the entry to check.
  33666. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  33667. */
  33668. function cacheHas(cache, key) {
  33669. return cache.has(key);
  33670. }
  33671. /**
  33672. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  33673. * that is not found in the character symbols.
  33674. *
  33675. * @private
  33676. * @param {Array} strSymbols The string symbols to inspect.
  33677. * @param {Array} chrSymbols The character symbols to find.
  33678. * @returns {number} Returns the index of the first unmatched string symbol.
  33679. */
  33680. function charsStartIndex(strSymbols, chrSymbols) {
  33681. var index = -1,
  33682. length = strSymbols.length;
  33683. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  33684. return index;
  33685. }
  33686. /**
  33687. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  33688. * that is not found in the character symbols.
  33689. *
  33690. * @private
  33691. * @param {Array} strSymbols The string symbols to inspect.
  33692. * @param {Array} chrSymbols The character symbols to find.
  33693. * @returns {number} Returns the index of the last unmatched string symbol.
  33694. */
  33695. function charsEndIndex(strSymbols, chrSymbols) {
  33696. var index = strSymbols.length;
  33697. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  33698. return index;
  33699. }
  33700. /**
  33701. * Gets the number of `placeholder` occurrences in `array`.
  33702. *
  33703. * @private
  33704. * @param {Array} array The array to inspect.
  33705. * @param {*} placeholder The placeholder to search for.
  33706. * @returns {number} Returns the placeholder count.
  33707. */
  33708. function countHolders(array, placeholder) {
  33709. var length = array.length,
  33710. result = 0;
  33711. while (length--) {
  33712. if (array[length] === placeholder) {
  33713. ++result;
  33714. }
  33715. }
  33716. return result;
  33717. }
  33718. /**
  33719. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  33720. * letters to basic Latin letters.
  33721. *
  33722. * @private
  33723. * @param {string} letter The matched letter to deburr.
  33724. * @returns {string} Returns the deburred letter.
  33725. */
  33726. var deburrLetter = basePropertyOf(deburredLetters);
  33727. /**
  33728. * Used by `_.escape` to convert characters to HTML entities.
  33729. *
  33730. * @private
  33731. * @param {string} chr The matched character to escape.
  33732. * @returns {string} Returns the escaped character.
  33733. */
  33734. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  33735. /**
  33736. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  33737. *
  33738. * @private
  33739. * @param {string} chr The matched character to escape.
  33740. * @returns {string} Returns the escaped character.
  33741. */
  33742. function escapeStringChar(chr) {
  33743. return '\\' + stringEscapes[chr];
  33744. }
  33745. /**
  33746. * Gets the value at `key` of `object`.
  33747. *
  33748. * @private
  33749. * @param {Object} [object] The object to query.
  33750. * @param {string} key The key of the property to get.
  33751. * @returns {*} Returns the property value.
  33752. */
  33753. function getValue(object, key) {
  33754. return object == null ? undefined : object[key];
  33755. }
  33756. /**
  33757. * Checks if `string` contains Unicode symbols.
  33758. *
  33759. * @private
  33760. * @param {string} string The string to inspect.
  33761. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  33762. */
  33763. function hasUnicode(string) {
  33764. return reHasUnicode.test(string);
  33765. }
  33766. /**
  33767. * Checks if `string` contains a word composed of Unicode symbols.
  33768. *
  33769. * @private
  33770. * @param {string} string The string to inspect.
  33771. * @returns {boolean} Returns `true` if a word is found, else `false`.
  33772. */
  33773. function hasUnicodeWord(string) {
  33774. return reHasUnicodeWord.test(string);
  33775. }
  33776. /**
  33777. * Converts `iterator` to an array.
  33778. *
  33779. * @private
  33780. * @param {Object} iterator The iterator to convert.
  33781. * @returns {Array} Returns the converted array.
  33782. */
  33783. function iteratorToArray(iterator) {
  33784. var data,
  33785. result = [];
  33786. while (!(data = iterator.next()).done) {
  33787. result.push(data.value);
  33788. }
  33789. return result;
  33790. }
  33791. /**
  33792. * Converts `map` to its key-value pairs.
  33793. *
  33794. * @private
  33795. * @param {Object} map The map to convert.
  33796. * @returns {Array} Returns the key-value pairs.
  33797. */
  33798. function mapToArray(map) {
  33799. var index = -1,
  33800. result = Array(map.size);
  33801. map.forEach(function(value, key) {
  33802. result[++index] = [key, value];
  33803. });
  33804. return result;
  33805. }
  33806. /**
  33807. * Creates a unary function that invokes `func` with its argument transformed.
  33808. *
  33809. * @private
  33810. * @param {Function} func The function to wrap.
  33811. * @param {Function} transform The argument transform.
  33812. * @returns {Function} Returns the new function.
  33813. */
  33814. function overArg(func, transform) {
  33815. return function(arg) {
  33816. return func(transform(arg));
  33817. };
  33818. }
  33819. /**
  33820. * Replaces all `placeholder` elements in `array` with an internal placeholder
  33821. * and returns an array of their indexes.
  33822. *
  33823. * @private
  33824. * @param {Array} array The array to modify.
  33825. * @param {*} placeholder The placeholder to replace.
  33826. * @returns {Array} Returns the new array of placeholder indexes.
  33827. */
  33828. function replaceHolders(array, placeholder) {
  33829. var index = -1,
  33830. length = array.length,
  33831. resIndex = 0,
  33832. result = [];
  33833. while (++index < length) {
  33834. var value = array[index];
  33835. if (value === placeholder || value === PLACEHOLDER) {
  33836. array[index] = PLACEHOLDER;
  33837. result[resIndex++] = index;
  33838. }
  33839. }
  33840. return result;
  33841. }
  33842. /**
  33843. * Converts `set` to an array of its values.
  33844. *
  33845. * @private
  33846. * @param {Object} set The set to convert.
  33847. * @returns {Array} Returns the values.
  33848. */
  33849. function setToArray(set) {
  33850. var index = -1,
  33851. result = Array(set.size);
  33852. set.forEach(function(value) {
  33853. result[++index] = value;
  33854. });
  33855. return result;
  33856. }
  33857. /**
  33858. * Converts `set` to its value-value pairs.
  33859. *
  33860. * @private
  33861. * @param {Object} set The set to convert.
  33862. * @returns {Array} Returns the value-value pairs.
  33863. */
  33864. function setToPairs(set) {
  33865. var index = -1,
  33866. result = Array(set.size);
  33867. set.forEach(function(value) {
  33868. result[++index] = [value, value];
  33869. });
  33870. return result;
  33871. }
  33872. /**
  33873. * A specialized version of `_.indexOf` which performs strict equality
  33874. * comparisons of values, i.e. `===`.
  33875. *
  33876. * @private
  33877. * @param {Array} array The array to inspect.
  33878. * @param {*} value The value to search for.
  33879. * @param {number} fromIndex The index to search from.
  33880. * @returns {number} Returns the index of the matched value, else `-1`.
  33881. */
  33882. function strictIndexOf(array, value, fromIndex) {
  33883. var index = fromIndex - 1,
  33884. length = array.length;
  33885. while (++index < length) {
  33886. if (array[index] === value) {
  33887. return index;
  33888. }
  33889. }
  33890. return -1;
  33891. }
  33892. /**
  33893. * A specialized version of `_.lastIndexOf` which performs strict equality
  33894. * comparisons of values, i.e. `===`.
  33895. *
  33896. * @private
  33897. * @param {Array} array The array to inspect.
  33898. * @param {*} value The value to search for.
  33899. * @param {number} fromIndex The index to search from.
  33900. * @returns {number} Returns the index of the matched value, else `-1`.
  33901. */
  33902. function strictLastIndexOf(array, value, fromIndex) {
  33903. var index = fromIndex + 1;
  33904. while (index--) {
  33905. if (array[index] === value) {
  33906. return index;
  33907. }
  33908. }
  33909. return index;
  33910. }
  33911. /**
  33912. * Gets the number of symbols in `string`.
  33913. *
  33914. * @private
  33915. * @param {string} string The string to inspect.
  33916. * @returns {number} Returns the string size.
  33917. */
  33918. function stringSize(string) {
  33919. return hasUnicode(string)
  33920. ? unicodeSize(string)
  33921. : asciiSize(string);
  33922. }
  33923. /**
  33924. * Converts `string` to an array.
  33925. *
  33926. * @private
  33927. * @param {string} string The string to convert.
  33928. * @returns {Array} Returns the converted array.
  33929. */
  33930. function stringToArray(string) {
  33931. return hasUnicode(string)
  33932. ? unicodeToArray(string)
  33933. : asciiToArray(string);
  33934. }
  33935. /**
  33936. * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
  33937. * character of `string`.
  33938. *
  33939. * @private
  33940. * @param {string} string The string to inspect.
  33941. * @returns {number} Returns the index of the last non-whitespace character.
  33942. */
  33943. function trimmedEndIndex(string) {
  33944. var index = string.length;
  33945. while (index-- && reWhitespace.test(string.charAt(index))) {}
  33946. return index;
  33947. }
  33948. /**
  33949. * Used by `_.unescape` to convert HTML entities to characters.
  33950. *
  33951. * @private
  33952. * @param {string} chr The matched character to unescape.
  33953. * @returns {string} Returns the unescaped character.
  33954. */
  33955. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  33956. /**
  33957. * Gets the size of a Unicode `string`.
  33958. *
  33959. * @private
  33960. * @param {string} string The string inspect.
  33961. * @returns {number} Returns the string size.
  33962. */
  33963. function unicodeSize(string) {
  33964. var result = reUnicode.lastIndex = 0;
  33965. while (reUnicode.test(string)) {
  33966. ++result;
  33967. }
  33968. return result;
  33969. }
  33970. /**
  33971. * Converts a Unicode `string` to an array.
  33972. *
  33973. * @private
  33974. * @param {string} string The string to convert.
  33975. * @returns {Array} Returns the converted array.
  33976. */
  33977. function unicodeToArray(string) {
  33978. return string.match(reUnicode) || [];
  33979. }
  33980. /**
  33981. * Splits a Unicode `string` into an array of its words.
  33982. *
  33983. * @private
  33984. * @param {string} The string to inspect.
  33985. * @returns {Array} Returns the words of `string`.
  33986. */
  33987. function unicodeWords(string) {
  33988. return string.match(reUnicodeWord) || [];
  33989. }
  33990. /*--------------------------------------------------------------------------*/
  33991. /**
  33992. * Create a new pristine `lodash` function using the `context` object.
  33993. *
  33994. * @static
  33995. * @memberOf _
  33996. * @since 1.1.0
  33997. * @category Util
  33998. * @param {Object} [context=root] The context object.
  33999. * @returns {Function} Returns a new `lodash` function.
  34000. * @example
  34001. *
  34002. * _.mixin({ 'foo': _.constant('foo') });
  34003. *
  34004. * var lodash = _.runInContext();
  34005. * lodash.mixin({ 'bar': lodash.constant('bar') });
  34006. *
  34007. * _.isFunction(_.foo);
  34008. * // => true
  34009. * _.isFunction(_.bar);
  34010. * // => false
  34011. *
  34012. * lodash.isFunction(lodash.foo);
  34013. * // => false
  34014. * lodash.isFunction(lodash.bar);
  34015. * // => true
  34016. *
  34017. * // Create a suped-up `defer` in Node.js.
  34018. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  34019. */
  34020. var runInContext = (function runInContext(context) {
  34021. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  34022. /** Built-in constructor references. */
  34023. var Array = context.Array,
  34024. Date = context.Date,
  34025. Error = context.Error,
  34026. Function = context.Function,
  34027. Math = context.Math,
  34028. Object = context.Object,
  34029. RegExp = context.RegExp,
  34030. String = context.String,
  34031. TypeError = context.TypeError;
  34032. /** Used for built-in method references. */
  34033. var arrayProto = Array.prototype,
  34034. funcProto = Function.prototype,
  34035. objectProto = Object.prototype;
  34036. /** Used to detect overreaching core-js shims. */
  34037. var coreJsData = context['__core-js_shared__'];
  34038. /** Used to resolve the decompiled source of functions. */
  34039. var funcToString = funcProto.toString;
  34040. /** Used to check objects for own properties. */
  34041. var hasOwnProperty = objectProto.hasOwnProperty;
  34042. /** Used to generate unique IDs. */
  34043. var idCounter = 0;
  34044. /** Used to detect methods masquerading as native. */
  34045. var maskSrcKey = (function() {
  34046. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  34047. return uid ? ('Symbol(src)_1.' + uid) : '';
  34048. }());
  34049. /**
  34050. * Used to resolve the
  34051. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  34052. * of values.
  34053. */
  34054. var nativeObjectToString = objectProto.toString;
  34055. /** Used to infer the `Object` constructor. */
  34056. var objectCtorString = funcToString.call(Object);
  34057. /** Used to restore the original `_` reference in `_.noConflict`. */
  34058. var oldDash = root._;
  34059. /** Used to detect if a method is native. */
  34060. var reIsNative = RegExp('^' +
  34061. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  34062. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  34063. );
  34064. /** Built-in value references. */
  34065. var Buffer = moduleExports ? context.Buffer : undefined,
  34066. Symbol = context.Symbol,
  34067. Uint8Array = context.Uint8Array,
  34068. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  34069. getPrototype = overArg(Object.getPrototypeOf, Object),
  34070. objectCreate = Object.create,
  34071. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  34072. splice = arrayProto.splice,
  34073. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
  34074. symIterator = Symbol ? Symbol.iterator : undefined,
  34075. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  34076. var defineProperty = (function() {
  34077. try {
  34078. var func = getNative(Object, 'defineProperty');
  34079. func({}, '', {});
  34080. return func;
  34081. } catch (e) {}
  34082. }());
  34083. /** Mocked built-ins. */
  34084. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  34085. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  34086. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  34087. /* Built-in method references for those with the same name as other `lodash` methods. */
  34088. var nativeCeil = Math.ceil,
  34089. nativeFloor = Math.floor,
  34090. nativeGetSymbols = Object.getOwnPropertySymbols,
  34091. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  34092. nativeIsFinite = context.isFinite,
  34093. nativeJoin = arrayProto.join,
  34094. nativeKeys = overArg(Object.keys, Object),
  34095. nativeMax = Math.max,
  34096. nativeMin = Math.min,
  34097. nativeNow = Date.now,
  34098. nativeParseInt = context.parseInt,
  34099. nativeRandom = Math.random,
  34100. nativeReverse = arrayProto.reverse;
  34101. /* Built-in method references that are verified to be native. */
  34102. var DataView = getNative(context, 'DataView'),
  34103. Map = getNative(context, 'Map'),
  34104. Promise = getNative(context, 'Promise'),
  34105. Set = getNative(context, 'Set'),
  34106. WeakMap = getNative(context, 'WeakMap'),
  34107. nativeCreate = getNative(Object, 'create');
  34108. /** Used to store function metadata. */
  34109. var metaMap = WeakMap && new WeakMap;
  34110. /** Used to lookup unminified function names. */
  34111. var realNames = {};
  34112. /** Used to detect maps, sets, and weakmaps. */
  34113. var dataViewCtorString = toSource(DataView),
  34114. mapCtorString = toSource(Map),
  34115. promiseCtorString = toSource(Promise),
  34116. setCtorString = toSource(Set),
  34117. weakMapCtorString = toSource(WeakMap);
  34118. /** Used to convert symbols to primitives and strings. */
  34119. var symbolProto = Symbol ? Symbol.prototype : undefined,
  34120. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  34121. symbolToString = symbolProto ? symbolProto.toString : undefined;
  34122. /*------------------------------------------------------------------------*/
  34123. /**
  34124. * Creates a `lodash` object which wraps `value` to enable implicit method
  34125. * chain sequences. Methods that operate on and return arrays, collections,
  34126. * and functions can be chained together. Methods that retrieve a single value
  34127. * or may return a primitive value will automatically end the chain sequence
  34128. * and return the unwrapped value. Otherwise, the value must be unwrapped
  34129. * with `_#value`.
  34130. *
  34131. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  34132. * enabled using `_.chain`.
  34133. *
  34134. * The execution of chained methods is lazy, that is, it's deferred until
  34135. * `_#value` is implicitly or explicitly called.
  34136. *
  34137. * Lazy evaluation allows several methods to support shortcut fusion.
  34138. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  34139. * the creation of intermediate arrays and can greatly reduce the number of
  34140. * iteratee executions. Sections of a chain sequence qualify for shortcut
  34141. * fusion if the section is applied to an array and iteratees accept only
  34142. * one argument. The heuristic for whether a section qualifies for shortcut
  34143. * fusion is subject to change.
  34144. *
  34145. * Chaining is supported in custom builds as long as the `_#value` method is
  34146. * directly or indirectly included in the build.
  34147. *
  34148. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  34149. *
  34150. * The wrapper `Array` methods are:
  34151. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  34152. *
  34153. * The wrapper `String` methods are:
  34154. * `replace` and `split`
  34155. *
  34156. * The wrapper methods that support shortcut fusion are:
  34157. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  34158. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  34159. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  34160. *
  34161. * The chainable wrapper methods are:
  34162. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  34163. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  34164. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  34165. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  34166. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  34167. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  34168. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  34169. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  34170. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  34171. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  34172. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  34173. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  34174. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  34175. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  34176. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  34177. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  34178. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  34179. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  34180. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  34181. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  34182. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  34183. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  34184. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  34185. * `zipObject`, `zipObjectDeep`, and `zipWith`
  34186. *
  34187. * The wrapper methods that are **not** chainable by default are:
  34188. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  34189. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  34190. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  34191. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  34192. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  34193. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  34194. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  34195. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  34196. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  34197. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  34198. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  34199. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  34200. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  34201. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  34202. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  34203. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  34204. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  34205. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  34206. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  34207. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  34208. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  34209. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  34210. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  34211. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  34212. * `upperFirst`, `value`, and `words`
  34213. *
  34214. * @name _
  34215. * @constructor
  34216. * @category Seq
  34217. * @param {*} value The value to wrap in a `lodash` instance.
  34218. * @returns {Object} Returns the new `lodash` wrapper instance.
  34219. * @example
  34220. *
  34221. * function square(n) {
  34222. * return n * n;
  34223. * }
  34224. *
  34225. * var wrapped = _([1, 2, 3]);
  34226. *
  34227. * // Returns an unwrapped value.
  34228. * wrapped.reduce(_.add);
  34229. * // => 6
  34230. *
  34231. * // Returns a wrapped value.
  34232. * var squares = wrapped.map(square);
  34233. *
  34234. * _.isArray(squares);
  34235. * // => false
  34236. *
  34237. * _.isArray(squares.value());
  34238. * // => true
  34239. */
  34240. function lodash(value) {
  34241. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  34242. if (value instanceof LodashWrapper) {
  34243. return value;
  34244. }
  34245. if (hasOwnProperty.call(value, '__wrapped__')) {
  34246. return wrapperClone(value);
  34247. }
  34248. }
  34249. return new LodashWrapper(value);
  34250. }
  34251. /**
  34252. * The base implementation of `_.create` without support for assigning
  34253. * properties to the created object.
  34254. *
  34255. * @private
  34256. * @param {Object} proto The object to inherit from.
  34257. * @returns {Object} Returns the new object.
  34258. */
  34259. var baseCreate = (function() {
  34260. function object() {}
  34261. return function(proto) {
  34262. if (!isObject(proto)) {
  34263. return {};
  34264. }
  34265. if (objectCreate) {
  34266. return objectCreate(proto);
  34267. }
  34268. object.prototype = proto;
  34269. var result = new object;
  34270. object.prototype = undefined;
  34271. return result;
  34272. };
  34273. }());
  34274. /**
  34275. * The function whose prototype chain sequence wrappers inherit from.
  34276. *
  34277. * @private
  34278. */
  34279. function baseLodash() {
  34280. // No operation performed.
  34281. }
  34282. /**
  34283. * The base constructor for creating `lodash` wrapper objects.
  34284. *
  34285. * @private
  34286. * @param {*} value The value to wrap.
  34287. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  34288. */
  34289. function LodashWrapper(value, chainAll) {
  34290. this.__wrapped__ = value;
  34291. this.__actions__ = [];
  34292. this.__chain__ = !!chainAll;
  34293. this.__index__ = 0;
  34294. this.__values__ = undefined;
  34295. }
  34296. /**
  34297. * By default, the template delimiters used by lodash are like those in
  34298. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  34299. * following template settings to use alternative delimiters.
  34300. *
  34301. * @static
  34302. * @memberOf _
  34303. * @type {Object}
  34304. */
  34305. lodash.templateSettings = {
  34306. /**
  34307. * Used to detect `data` property values to be HTML-escaped.
  34308. *
  34309. * @memberOf _.templateSettings
  34310. * @type {RegExp}
  34311. */
  34312. 'escape': reEscape,
  34313. /**
  34314. * Used to detect code to be evaluated.
  34315. *
  34316. * @memberOf _.templateSettings
  34317. * @type {RegExp}
  34318. */
  34319. 'evaluate': reEvaluate,
  34320. /**
  34321. * Used to detect `data` property values to inject.
  34322. *
  34323. * @memberOf _.templateSettings
  34324. * @type {RegExp}
  34325. */
  34326. 'interpolate': reInterpolate,
  34327. /**
  34328. * Used to reference the data object in the template text.
  34329. *
  34330. * @memberOf _.templateSettings
  34331. * @type {string}
  34332. */
  34333. 'variable': '',
  34334. /**
  34335. * Used to import variables into the compiled template.
  34336. *
  34337. * @memberOf _.templateSettings
  34338. * @type {Object}
  34339. */
  34340. 'imports': {
  34341. /**
  34342. * A reference to the `lodash` function.
  34343. *
  34344. * @memberOf _.templateSettings.imports
  34345. * @type {Function}
  34346. */
  34347. '_': lodash
  34348. }
  34349. };
  34350. // Ensure wrappers are instances of `baseLodash`.
  34351. lodash.prototype = baseLodash.prototype;
  34352. lodash.prototype.constructor = lodash;
  34353. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  34354. LodashWrapper.prototype.constructor = LodashWrapper;
  34355. /*------------------------------------------------------------------------*/
  34356. /**
  34357. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  34358. *
  34359. * @private
  34360. * @constructor
  34361. * @param {*} value The value to wrap.
  34362. */
  34363. function LazyWrapper(value) {
  34364. this.__wrapped__ = value;
  34365. this.__actions__ = [];
  34366. this.__dir__ = 1;
  34367. this.__filtered__ = false;
  34368. this.__iteratees__ = [];
  34369. this.__takeCount__ = MAX_ARRAY_LENGTH;
  34370. this.__views__ = [];
  34371. }
  34372. /**
  34373. * Creates a clone of the lazy wrapper object.
  34374. *
  34375. * @private
  34376. * @name clone
  34377. * @memberOf LazyWrapper
  34378. * @returns {Object} Returns the cloned `LazyWrapper` object.
  34379. */
  34380. function lazyClone() {
  34381. var result = new LazyWrapper(this.__wrapped__);
  34382. result.__actions__ = copyArray(this.__actions__);
  34383. result.__dir__ = this.__dir__;
  34384. result.__filtered__ = this.__filtered__;
  34385. result.__iteratees__ = copyArray(this.__iteratees__);
  34386. result.__takeCount__ = this.__takeCount__;
  34387. result.__views__ = copyArray(this.__views__);
  34388. return result;
  34389. }
  34390. /**
  34391. * Reverses the direction of lazy iteration.
  34392. *
  34393. * @private
  34394. * @name reverse
  34395. * @memberOf LazyWrapper
  34396. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  34397. */
  34398. function lazyReverse() {
  34399. if (this.__filtered__) {
  34400. var result = new LazyWrapper(this);
  34401. result.__dir__ = -1;
  34402. result.__filtered__ = true;
  34403. } else {
  34404. result = this.clone();
  34405. result.__dir__ *= -1;
  34406. }
  34407. return result;
  34408. }
  34409. /**
  34410. * Extracts the unwrapped value from its lazy wrapper.
  34411. *
  34412. * @private
  34413. * @name value
  34414. * @memberOf LazyWrapper
  34415. * @returns {*} Returns the unwrapped value.
  34416. */
  34417. function lazyValue() {
  34418. var array = this.__wrapped__.value(),
  34419. dir = this.__dir__,
  34420. isArr = isArray(array),
  34421. isRight = dir < 0,
  34422. arrLength = isArr ? array.length : 0,
  34423. view = getView(0, arrLength, this.__views__),
  34424. start = view.start,
  34425. end = view.end,
  34426. length = end - start,
  34427. index = isRight ? end : (start - 1),
  34428. iteratees = this.__iteratees__,
  34429. iterLength = iteratees.length,
  34430. resIndex = 0,
  34431. takeCount = nativeMin(length, this.__takeCount__);
  34432. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  34433. return baseWrapperValue(array, this.__actions__);
  34434. }
  34435. var result = [];
  34436. outer:
  34437. while (length-- && resIndex < takeCount) {
  34438. index += dir;
  34439. var iterIndex = -1,
  34440. value = array[index];
  34441. while (++iterIndex < iterLength) {
  34442. var data = iteratees[iterIndex],
  34443. iteratee = data.iteratee,
  34444. type = data.type,
  34445. computed = iteratee(value);
  34446. if (type == LAZY_MAP_FLAG) {
  34447. value = computed;
  34448. } else if (!computed) {
  34449. if (type == LAZY_FILTER_FLAG) {
  34450. continue outer;
  34451. } else {
  34452. break outer;
  34453. }
  34454. }
  34455. }
  34456. result[resIndex++] = value;
  34457. }
  34458. return result;
  34459. }
  34460. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  34461. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  34462. LazyWrapper.prototype.constructor = LazyWrapper;
  34463. /*------------------------------------------------------------------------*/
  34464. /**
  34465. * Creates a hash object.
  34466. *
  34467. * @private
  34468. * @constructor
  34469. * @param {Array} [entries] The key-value pairs to cache.
  34470. */
  34471. function Hash(entries) {
  34472. var index = -1,
  34473. length = entries == null ? 0 : entries.length;
  34474. this.clear();
  34475. while (++index < length) {
  34476. var entry = entries[index];
  34477. this.set(entry[0], entry[1]);
  34478. }
  34479. }
  34480. /**
  34481. * Removes all key-value entries from the hash.
  34482. *
  34483. * @private
  34484. * @name clear
  34485. * @memberOf Hash
  34486. */
  34487. function hashClear() {
  34488. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  34489. this.size = 0;
  34490. }
  34491. /**
  34492. * Removes `key` and its value from the hash.
  34493. *
  34494. * @private
  34495. * @name delete
  34496. * @memberOf Hash
  34497. * @param {Object} hash The hash to modify.
  34498. * @param {string} key The key of the value to remove.
  34499. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  34500. */
  34501. function hashDelete(key) {
  34502. var result = this.has(key) && delete this.__data__[key];
  34503. this.size -= result ? 1 : 0;
  34504. return result;
  34505. }
  34506. /**
  34507. * Gets the hash value for `key`.
  34508. *
  34509. * @private
  34510. * @name get
  34511. * @memberOf Hash
  34512. * @param {string} key The key of the value to get.
  34513. * @returns {*} Returns the entry value.
  34514. */
  34515. function hashGet(key) {
  34516. var data = this.__data__;
  34517. if (nativeCreate) {
  34518. var result = data[key];
  34519. return result === HASH_UNDEFINED ? undefined : result;
  34520. }
  34521. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  34522. }
  34523. /**
  34524. * Checks if a hash value for `key` exists.
  34525. *
  34526. * @private
  34527. * @name has
  34528. * @memberOf Hash
  34529. * @param {string} key The key of the entry to check.
  34530. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  34531. */
  34532. function hashHas(key) {
  34533. var data = this.__data__;
  34534. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  34535. }
  34536. /**
  34537. * Sets the hash `key` to `value`.
  34538. *
  34539. * @private
  34540. * @name set
  34541. * @memberOf Hash
  34542. * @param {string} key The key of the value to set.
  34543. * @param {*} value The value to set.
  34544. * @returns {Object} Returns the hash instance.
  34545. */
  34546. function hashSet(key, value) {
  34547. var data = this.__data__;
  34548. this.size += this.has(key) ? 0 : 1;
  34549. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  34550. return this;
  34551. }
  34552. // Add methods to `Hash`.
  34553. Hash.prototype.clear = hashClear;
  34554. Hash.prototype['delete'] = hashDelete;
  34555. Hash.prototype.get = hashGet;
  34556. Hash.prototype.has = hashHas;
  34557. Hash.prototype.set = hashSet;
  34558. /*------------------------------------------------------------------------*/
  34559. /**
  34560. * Creates an list cache object.
  34561. *
  34562. * @private
  34563. * @constructor
  34564. * @param {Array} [entries] The key-value pairs to cache.
  34565. */
  34566. function ListCache(entries) {
  34567. var index = -1,
  34568. length = entries == null ? 0 : entries.length;
  34569. this.clear();
  34570. while (++index < length) {
  34571. var entry = entries[index];
  34572. this.set(entry[0], entry[1]);
  34573. }
  34574. }
  34575. /**
  34576. * Removes all key-value entries from the list cache.
  34577. *
  34578. * @private
  34579. * @name clear
  34580. * @memberOf ListCache
  34581. */
  34582. function listCacheClear() {
  34583. this.__data__ = [];
  34584. this.size = 0;
  34585. }
  34586. /**
  34587. * Removes `key` and its value from the list cache.
  34588. *
  34589. * @private
  34590. * @name delete
  34591. * @memberOf ListCache
  34592. * @param {string} key The key of the value to remove.
  34593. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  34594. */
  34595. function listCacheDelete(key) {
  34596. var data = this.__data__,
  34597. index = assocIndexOf(data, key);
  34598. if (index < 0) {
  34599. return false;
  34600. }
  34601. var lastIndex = data.length - 1;
  34602. if (index == lastIndex) {
  34603. data.pop();
  34604. } else {
  34605. splice.call(data, index, 1);
  34606. }
  34607. --this.size;
  34608. return true;
  34609. }
  34610. /**
  34611. * Gets the list cache value for `key`.
  34612. *
  34613. * @private
  34614. * @name get
  34615. * @memberOf ListCache
  34616. * @param {string} key The key of the value to get.
  34617. * @returns {*} Returns the entry value.
  34618. */
  34619. function listCacheGet(key) {
  34620. var data = this.__data__,
  34621. index = assocIndexOf(data, key);
  34622. return index < 0 ? undefined : data[index][1];
  34623. }
  34624. /**
  34625. * Checks if a list cache value for `key` exists.
  34626. *
  34627. * @private
  34628. * @name has
  34629. * @memberOf ListCache
  34630. * @param {string} key The key of the entry to check.
  34631. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  34632. */
  34633. function listCacheHas(key) {
  34634. return assocIndexOf(this.__data__, key) > -1;
  34635. }
  34636. /**
  34637. * Sets the list cache `key` to `value`.
  34638. *
  34639. * @private
  34640. * @name set
  34641. * @memberOf ListCache
  34642. * @param {string} key The key of the value to set.
  34643. * @param {*} value The value to set.
  34644. * @returns {Object} Returns the list cache instance.
  34645. */
  34646. function listCacheSet(key, value) {
  34647. var data = this.__data__,
  34648. index = assocIndexOf(data, key);
  34649. if (index < 0) {
  34650. ++this.size;
  34651. data.push([key, value]);
  34652. } else {
  34653. data[index][1] = value;
  34654. }
  34655. return this;
  34656. }
  34657. // Add methods to `ListCache`.
  34658. ListCache.prototype.clear = listCacheClear;
  34659. ListCache.prototype['delete'] = listCacheDelete;
  34660. ListCache.prototype.get = listCacheGet;
  34661. ListCache.prototype.has = listCacheHas;
  34662. ListCache.prototype.set = listCacheSet;
  34663. /*------------------------------------------------------------------------*/
  34664. /**
  34665. * Creates a map cache object to store key-value pairs.
  34666. *
  34667. * @private
  34668. * @constructor
  34669. * @param {Array} [entries] The key-value pairs to cache.
  34670. */
  34671. function MapCache(entries) {
  34672. var index = -1,
  34673. length = entries == null ? 0 : entries.length;
  34674. this.clear();
  34675. while (++index < length) {
  34676. var entry = entries[index];
  34677. this.set(entry[0], entry[1]);
  34678. }
  34679. }
  34680. /**
  34681. * Removes all key-value entries from the map.
  34682. *
  34683. * @private
  34684. * @name clear
  34685. * @memberOf MapCache
  34686. */
  34687. function mapCacheClear() {
  34688. this.size = 0;
  34689. this.__data__ = {
  34690. 'hash': new Hash,
  34691. 'map': new (Map || ListCache),
  34692. 'string': new Hash
  34693. };
  34694. }
  34695. /**
  34696. * Removes `key` and its value from the map.
  34697. *
  34698. * @private
  34699. * @name delete
  34700. * @memberOf MapCache
  34701. * @param {string} key The key of the value to remove.
  34702. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  34703. */
  34704. function mapCacheDelete(key) {
  34705. var result = getMapData(this, key)['delete'](key);
  34706. this.size -= result ? 1 : 0;
  34707. return result;
  34708. }
  34709. /**
  34710. * Gets the map value for `key`.
  34711. *
  34712. * @private
  34713. * @name get
  34714. * @memberOf MapCache
  34715. * @param {string} key The key of the value to get.
  34716. * @returns {*} Returns the entry value.
  34717. */
  34718. function mapCacheGet(key) {
  34719. return getMapData(this, key).get(key);
  34720. }
  34721. /**
  34722. * Checks if a map value for `key` exists.
  34723. *
  34724. * @private
  34725. * @name has
  34726. * @memberOf MapCache
  34727. * @param {string} key The key of the entry to check.
  34728. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  34729. */
  34730. function mapCacheHas(key) {
  34731. return getMapData(this, key).has(key);
  34732. }
  34733. /**
  34734. * Sets the map `key` to `value`.
  34735. *
  34736. * @private
  34737. * @name set
  34738. * @memberOf MapCache
  34739. * @param {string} key The key of the value to set.
  34740. * @param {*} value The value to set.
  34741. * @returns {Object} Returns the map cache instance.
  34742. */
  34743. function mapCacheSet(key, value) {
  34744. var data = getMapData(this, key),
  34745. size = data.size;
  34746. data.set(key, value);
  34747. this.size += data.size == size ? 0 : 1;
  34748. return this;
  34749. }
  34750. // Add methods to `MapCache`.
  34751. MapCache.prototype.clear = mapCacheClear;
  34752. MapCache.prototype['delete'] = mapCacheDelete;
  34753. MapCache.prototype.get = mapCacheGet;
  34754. MapCache.prototype.has = mapCacheHas;
  34755. MapCache.prototype.set = mapCacheSet;
  34756. /*------------------------------------------------------------------------*/
  34757. /**
  34758. *
  34759. * Creates an array cache object to store unique values.
  34760. *
  34761. * @private
  34762. * @constructor
  34763. * @param {Array} [values] The values to cache.
  34764. */
  34765. function SetCache(values) {
  34766. var index = -1,
  34767. length = values == null ? 0 : values.length;
  34768. this.__data__ = new MapCache;
  34769. while (++index < length) {
  34770. this.add(values[index]);
  34771. }
  34772. }
  34773. /**
  34774. * Adds `value` to the array cache.
  34775. *
  34776. * @private
  34777. * @name add
  34778. * @memberOf SetCache
  34779. * @alias push
  34780. * @param {*} value The value to cache.
  34781. * @returns {Object} Returns the cache instance.
  34782. */
  34783. function setCacheAdd(value) {
  34784. this.__data__.set(value, HASH_UNDEFINED);
  34785. return this;
  34786. }
  34787. /**
  34788. * Checks if `value` is in the array cache.
  34789. *
  34790. * @private
  34791. * @name has
  34792. * @memberOf SetCache
  34793. * @param {*} value The value to search for.
  34794. * @returns {number} Returns `true` if `value` is found, else `false`.
  34795. */
  34796. function setCacheHas(value) {
  34797. return this.__data__.has(value);
  34798. }
  34799. // Add methods to `SetCache`.
  34800. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  34801. SetCache.prototype.has = setCacheHas;
  34802. /*------------------------------------------------------------------------*/
  34803. /**
  34804. * Creates a stack cache object to store key-value pairs.
  34805. *
  34806. * @private
  34807. * @constructor
  34808. * @param {Array} [entries] The key-value pairs to cache.
  34809. */
  34810. function Stack(entries) {
  34811. var data = this.__data__ = new ListCache(entries);
  34812. this.size = data.size;
  34813. }
  34814. /**
  34815. * Removes all key-value entries from the stack.
  34816. *
  34817. * @private
  34818. * @name clear
  34819. * @memberOf Stack
  34820. */
  34821. function stackClear() {
  34822. this.__data__ = new ListCache;
  34823. this.size = 0;
  34824. }
  34825. /**
  34826. * Removes `key` and its value from the stack.
  34827. *
  34828. * @private
  34829. * @name delete
  34830. * @memberOf Stack
  34831. * @param {string} key The key of the value to remove.
  34832. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  34833. */
  34834. function stackDelete(key) {
  34835. var data = this.__data__,
  34836. result = data['delete'](key);
  34837. this.size = data.size;
  34838. return result;
  34839. }
  34840. /**
  34841. * Gets the stack value for `key`.
  34842. *
  34843. * @private
  34844. * @name get
  34845. * @memberOf Stack
  34846. * @param {string} key The key of the value to get.
  34847. * @returns {*} Returns the entry value.
  34848. */
  34849. function stackGet(key) {
  34850. return this.__data__.get(key);
  34851. }
  34852. /**
  34853. * Checks if a stack value for `key` exists.
  34854. *
  34855. * @private
  34856. * @name has
  34857. * @memberOf Stack
  34858. * @param {string} key The key of the entry to check.
  34859. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  34860. */
  34861. function stackHas(key) {
  34862. return this.__data__.has(key);
  34863. }
  34864. /**
  34865. * Sets the stack `key` to `value`.
  34866. *
  34867. * @private
  34868. * @name set
  34869. * @memberOf Stack
  34870. * @param {string} key The key of the value to set.
  34871. * @param {*} value The value to set.
  34872. * @returns {Object} Returns the stack cache instance.
  34873. */
  34874. function stackSet(key, value) {
  34875. var data = this.__data__;
  34876. if (data instanceof ListCache) {
  34877. var pairs = data.__data__;
  34878. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  34879. pairs.push([key, value]);
  34880. this.size = ++data.size;
  34881. return this;
  34882. }
  34883. data = this.__data__ = new MapCache(pairs);
  34884. }
  34885. data.set(key, value);
  34886. this.size = data.size;
  34887. return this;
  34888. }
  34889. // Add methods to `Stack`.
  34890. Stack.prototype.clear = stackClear;
  34891. Stack.prototype['delete'] = stackDelete;
  34892. Stack.prototype.get = stackGet;
  34893. Stack.prototype.has = stackHas;
  34894. Stack.prototype.set = stackSet;
  34895. /*------------------------------------------------------------------------*/
  34896. /**
  34897. * Creates an array of the enumerable property names of the array-like `value`.
  34898. *
  34899. * @private
  34900. * @param {*} value The value to query.
  34901. * @param {boolean} inherited Specify returning inherited property names.
  34902. * @returns {Array} Returns the array of property names.
  34903. */
  34904. function arrayLikeKeys(value, inherited) {
  34905. var isArr = isArray(value),
  34906. isArg = !isArr && isArguments(value),
  34907. isBuff = !isArr && !isArg && isBuffer(value),
  34908. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  34909. skipIndexes = isArr || isArg || isBuff || isType,
  34910. result = skipIndexes ? baseTimes(value.length, String) : [],
  34911. length = result.length;
  34912. for (var key in value) {
  34913. if ((inherited || hasOwnProperty.call(value, key)) &&
  34914. !(skipIndexes && (
  34915. // Safari 9 has enumerable `arguments.length` in strict mode.
  34916. key == 'length' ||
  34917. // Node.js 0.10 has enumerable non-index properties on buffers.
  34918. (isBuff && (key == 'offset' || key == 'parent')) ||
  34919. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  34920. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  34921. // Skip index properties.
  34922. isIndex(key, length)
  34923. ))) {
  34924. result.push(key);
  34925. }
  34926. }
  34927. return result;
  34928. }
  34929. /**
  34930. * A specialized version of `_.sample` for arrays.
  34931. *
  34932. * @private
  34933. * @param {Array} array The array to sample.
  34934. * @returns {*} Returns the random element.
  34935. */
  34936. function arraySample(array) {
  34937. var length = array.length;
  34938. return length ? array[baseRandom(0, length - 1)] : undefined;
  34939. }
  34940. /**
  34941. * A specialized version of `_.sampleSize` for arrays.
  34942. *
  34943. * @private
  34944. * @param {Array} array The array to sample.
  34945. * @param {number} n The number of elements to sample.
  34946. * @returns {Array} Returns the random elements.
  34947. */
  34948. function arraySampleSize(array, n) {
  34949. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  34950. }
  34951. /**
  34952. * A specialized version of `_.shuffle` for arrays.
  34953. *
  34954. * @private
  34955. * @param {Array} array The array to shuffle.
  34956. * @returns {Array} Returns the new shuffled array.
  34957. */
  34958. function arrayShuffle(array) {
  34959. return shuffleSelf(copyArray(array));
  34960. }
  34961. /**
  34962. * This function is like `assignValue` except that it doesn't assign
  34963. * `undefined` values.
  34964. *
  34965. * @private
  34966. * @param {Object} object The object to modify.
  34967. * @param {string} key The key of the property to assign.
  34968. * @param {*} value The value to assign.
  34969. */
  34970. function assignMergeValue(object, key, value) {
  34971. if ((value !== undefined && !eq(object[key], value)) ||
  34972. (value === undefined && !(key in object))) {
  34973. baseAssignValue(object, key, value);
  34974. }
  34975. }
  34976. /**
  34977. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  34978. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  34979. * for equality comparisons.
  34980. *
  34981. * @private
  34982. * @param {Object} object The object to modify.
  34983. * @param {string} key The key of the property to assign.
  34984. * @param {*} value The value to assign.
  34985. */
  34986. function assignValue(object, key, value) {
  34987. var objValue = object[key];
  34988. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  34989. (value === undefined && !(key in object))) {
  34990. baseAssignValue(object, key, value);
  34991. }
  34992. }
  34993. /**
  34994. * Gets the index at which the `key` is found in `array` of key-value pairs.
  34995. *
  34996. * @private
  34997. * @param {Array} array The array to inspect.
  34998. * @param {*} key The key to search for.
  34999. * @returns {number} Returns the index of the matched value, else `-1`.
  35000. */
  35001. function assocIndexOf(array, key) {
  35002. var length = array.length;
  35003. while (length--) {
  35004. if (eq(array[length][0], key)) {
  35005. return length;
  35006. }
  35007. }
  35008. return -1;
  35009. }
  35010. /**
  35011. * Aggregates elements of `collection` on `accumulator` with keys transformed
  35012. * by `iteratee` and values set by `setter`.
  35013. *
  35014. * @private
  35015. * @param {Array|Object} collection The collection to iterate over.
  35016. * @param {Function} setter The function to set `accumulator` values.
  35017. * @param {Function} iteratee The iteratee to transform keys.
  35018. * @param {Object} accumulator The initial aggregated object.
  35019. * @returns {Function} Returns `accumulator`.
  35020. */
  35021. function baseAggregator(collection, setter, iteratee, accumulator) {
  35022. baseEach(collection, function(value, key, collection) {
  35023. setter(accumulator, value, iteratee(value), collection);
  35024. });
  35025. return accumulator;
  35026. }
  35027. /**
  35028. * The base implementation of `_.assign` without support for multiple sources
  35029. * or `customizer` functions.
  35030. *
  35031. * @private
  35032. * @param {Object} object The destination object.
  35033. * @param {Object} source The source object.
  35034. * @returns {Object} Returns `object`.
  35035. */
  35036. function baseAssign(object, source) {
  35037. return object && copyObject(source, keys(source), object);
  35038. }
  35039. /**
  35040. * The base implementation of `_.assignIn` without support for multiple sources
  35041. * or `customizer` functions.
  35042. *
  35043. * @private
  35044. * @param {Object} object The destination object.
  35045. * @param {Object} source The source object.
  35046. * @returns {Object} Returns `object`.
  35047. */
  35048. function baseAssignIn(object, source) {
  35049. return object && copyObject(source, keysIn(source), object);
  35050. }
  35051. /**
  35052. * The base implementation of `assignValue` and `assignMergeValue` without
  35053. * value checks.
  35054. *
  35055. * @private
  35056. * @param {Object} object The object to modify.
  35057. * @param {string} key The key of the property to assign.
  35058. * @param {*} value The value to assign.
  35059. */
  35060. function baseAssignValue(object, key, value) {
  35061. if (key == '__proto__' && defineProperty) {
  35062. defineProperty(object, key, {
  35063. 'configurable': true,
  35064. 'enumerable': true,
  35065. 'value': value,
  35066. 'writable': true
  35067. });
  35068. } else {
  35069. object[key] = value;
  35070. }
  35071. }
  35072. /**
  35073. * The base implementation of `_.at` without support for individual paths.
  35074. *
  35075. * @private
  35076. * @param {Object} object The object to iterate over.
  35077. * @param {string[]} paths The property paths to pick.
  35078. * @returns {Array} Returns the picked elements.
  35079. */
  35080. function baseAt(object, paths) {
  35081. var index = -1,
  35082. length = paths.length,
  35083. result = Array(length),
  35084. skip = object == null;
  35085. while (++index < length) {
  35086. result[index] = skip ? undefined : get(object, paths[index]);
  35087. }
  35088. return result;
  35089. }
  35090. /**
  35091. * The base implementation of `_.clamp` which doesn't coerce arguments.
  35092. *
  35093. * @private
  35094. * @param {number} number The number to clamp.
  35095. * @param {number} [lower] The lower bound.
  35096. * @param {number} upper The upper bound.
  35097. * @returns {number} Returns the clamped number.
  35098. */
  35099. function baseClamp(number, lower, upper) {
  35100. if (number === number) {
  35101. if (upper !== undefined) {
  35102. number = number <= upper ? number : upper;
  35103. }
  35104. if (lower !== undefined) {
  35105. number = number >= lower ? number : lower;
  35106. }
  35107. }
  35108. return number;
  35109. }
  35110. /**
  35111. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  35112. * traversed objects.
  35113. *
  35114. * @private
  35115. * @param {*} value The value to clone.
  35116. * @param {boolean} bitmask The bitmask flags.
  35117. * 1 - Deep clone
  35118. * 2 - Flatten inherited properties
  35119. * 4 - Clone symbols
  35120. * @param {Function} [customizer] The function to customize cloning.
  35121. * @param {string} [key] The key of `value`.
  35122. * @param {Object} [object] The parent object of `value`.
  35123. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  35124. * @returns {*} Returns the cloned value.
  35125. */
  35126. function baseClone(value, bitmask, customizer, key, object, stack) {
  35127. var result,
  35128. isDeep = bitmask & CLONE_DEEP_FLAG,
  35129. isFlat = bitmask & CLONE_FLAT_FLAG,
  35130. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  35131. if (customizer) {
  35132. result = object ? customizer(value, key, object, stack) : customizer(value);
  35133. }
  35134. if (result !== undefined) {
  35135. return result;
  35136. }
  35137. if (!isObject(value)) {
  35138. return value;
  35139. }
  35140. var isArr = isArray(value);
  35141. if (isArr) {
  35142. result = initCloneArray(value);
  35143. if (!isDeep) {
  35144. return copyArray(value, result);
  35145. }
  35146. } else {
  35147. var tag = getTag(value),
  35148. isFunc = tag == funcTag || tag == genTag;
  35149. if (isBuffer(value)) {
  35150. return cloneBuffer(value, isDeep);
  35151. }
  35152. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  35153. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  35154. if (!isDeep) {
  35155. return isFlat
  35156. ? copySymbolsIn(value, baseAssignIn(result, value))
  35157. : copySymbols(value, baseAssign(result, value));
  35158. }
  35159. } else {
  35160. if (!cloneableTags[tag]) {
  35161. return object ? value : {};
  35162. }
  35163. result = initCloneByTag(value, tag, isDeep);
  35164. }
  35165. }
  35166. // Check for circular references and return its corresponding clone.
  35167. stack || (stack = new Stack);
  35168. var stacked = stack.get(value);
  35169. if (stacked) {
  35170. return stacked;
  35171. }
  35172. stack.set(value, result);
  35173. if (isSet(value)) {
  35174. value.forEach(function(subValue) {
  35175. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  35176. });
  35177. } else if (isMap(value)) {
  35178. value.forEach(function(subValue, key) {
  35179. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  35180. });
  35181. }
  35182. var keysFunc = isFull
  35183. ? (isFlat ? getAllKeysIn : getAllKeys)
  35184. : (isFlat ? keysIn : keys);
  35185. var props = isArr ? undefined : keysFunc(value);
  35186. arrayEach(props || value, function(subValue, key) {
  35187. if (props) {
  35188. key = subValue;
  35189. subValue = value[key];
  35190. }
  35191. // Recursively populate clone (susceptible to call stack limits).
  35192. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  35193. });
  35194. return result;
  35195. }
  35196. /**
  35197. * The base implementation of `_.conforms` which doesn't clone `source`.
  35198. *
  35199. * @private
  35200. * @param {Object} source The object of property predicates to conform to.
  35201. * @returns {Function} Returns the new spec function.
  35202. */
  35203. function baseConforms(source) {
  35204. var props = keys(source);
  35205. return function(object) {
  35206. return baseConformsTo(object, source, props);
  35207. };
  35208. }
  35209. /**
  35210. * The base implementation of `_.conformsTo` which accepts `props` to check.
  35211. *
  35212. * @private
  35213. * @param {Object} object The object to inspect.
  35214. * @param {Object} source The object of property predicates to conform to.
  35215. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  35216. */
  35217. function baseConformsTo(object, source, props) {
  35218. var length = props.length;
  35219. if (object == null) {
  35220. return !length;
  35221. }
  35222. object = Object(object);
  35223. while (length--) {
  35224. var key = props[length],
  35225. predicate = source[key],
  35226. value = object[key];
  35227. if ((value === undefined && !(key in object)) || !predicate(value)) {
  35228. return false;
  35229. }
  35230. }
  35231. return true;
  35232. }
  35233. /**
  35234. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  35235. * to provide to `func`.
  35236. *
  35237. * @private
  35238. * @param {Function} func The function to delay.
  35239. * @param {number} wait The number of milliseconds to delay invocation.
  35240. * @param {Array} args The arguments to provide to `func`.
  35241. * @returns {number|Object} Returns the timer id or timeout object.
  35242. */
  35243. function baseDelay(func, wait, args) {
  35244. if (typeof func != 'function') {
  35245. throw new TypeError(FUNC_ERROR_TEXT);
  35246. }
  35247. return setTimeout(function() { func.apply(undefined, args); }, wait);
  35248. }
  35249. /**
  35250. * The base implementation of methods like `_.difference` without support
  35251. * for excluding multiple arrays or iteratee shorthands.
  35252. *
  35253. * @private
  35254. * @param {Array} array The array to inspect.
  35255. * @param {Array} values The values to exclude.
  35256. * @param {Function} [iteratee] The iteratee invoked per element.
  35257. * @param {Function} [comparator] The comparator invoked per element.
  35258. * @returns {Array} Returns the new array of filtered values.
  35259. */
  35260. function baseDifference(array, values, iteratee, comparator) {
  35261. var index = -1,
  35262. includes = arrayIncludes,
  35263. isCommon = true,
  35264. length = array.length,
  35265. result = [],
  35266. valuesLength = values.length;
  35267. if (!length) {
  35268. return result;
  35269. }
  35270. if (iteratee) {
  35271. values = arrayMap(values, baseUnary(iteratee));
  35272. }
  35273. if (comparator) {
  35274. includes = arrayIncludesWith;
  35275. isCommon = false;
  35276. }
  35277. else if (values.length >= LARGE_ARRAY_SIZE) {
  35278. includes = cacheHas;
  35279. isCommon = false;
  35280. values = new SetCache(values);
  35281. }
  35282. outer:
  35283. while (++index < length) {
  35284. var value = array[index],
  35285. computed = iteratee == null ? value : iteratee(value);
  35286. value = (comparator || value !== 0) ? value : 0;
  35287. if (isCommon && computed === computed) {
  35288. var valuesIndex = valuesLength;
  35289. while (valuesIndex--) {
  35290. if (values[valuesIndex] === computed) {
  35291. continue outer;
  35292. }
  35293. }
  35294. result.push(value);
  35295. }
  35296. else if (!includes(values, computed, comparator)) {
  35297. result.push(value);
  35298. }
  35299. }
  35300. return result;
  35301. }
  35302. /**
  35303. * The base implementation of `_.forEach` without support for iteratee shorthands.
  35304. *
  35305. * @private
  35306. * @param {Array|Object} collection The collection to iterate over.
  35307. * @param {Function} iteratee The function invoked per iteration.
  35308. * @returns {Array|Object} Returns `collection`.
  35309. */
  35310. var baseEach = createBaseEach(baseForOwn);
  35311. /**
  35312. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  35313. *
  35314. * @private
  35315. * @param {Array|Object} collection The collection to iterate over.
  35316. * @param {Function} iteratee The function invoked per iteration.
  35317. * @returns {Array|Object} Returns `collection`.
  35318. */
  35319. var baseEachRight = createBaseEach(baseForOwnRight, true);
  35320. /**
  35321. * The base implementation of `_.every` without support for iteratee shorthands.
  35322. *
  35323. * @private
  35324. * @param {Array|Object} collection The collection to iterate over.
  35325. * @param {Function} predicate The function invoked per iteration.
  35326. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  35327. * else `false`
  35328. */
  35329. function baseEvery(collection, predicate) {
  35330. var result = true;
  35331. baseEach(collection, function(value, index, collection) {
  35332. result = !!predicate(value, index, collection);
  35333. return result;
  35334. });
  35335. return result;
  35336. }
  35337. /**
  35338. * The base implementation of methods like `_.max` and `_.min` which accepts a
  35339. * `comparator` to determine the extremum value.
  35340. *
  35341. * @private
  35342. * @param {Array} array The array to iterate over.
  35343. * @param {Function} iteratee The iteratee invoked per iteration.
  35344. * @param {Function} comparator The comparator used to compare values.
  35345. * @returns {*} Returns the extremum value.
  35346. */
  35347. function baseExtremum(array, iteratee, comparator) {
  35348. var index = -1,
  35349. length = array.length;
  35350. while (++index < length) {
  35351. var value = array[index],
  35352. current = iteratee(value);
  35353. if (current != null && (computed === undefined
  35354. ? (current === current && !isSymbol(current))
  35355. : comparator(current, computed)
  35356. )) {
  35357. var computed = current,
  35358. result = value;
  35359. }
  35360. }
  35361. return result;
  35362. }
  35363. /**
  35364. * The base implementation of `_.fill` without an iteratee call guard.
  35365. *
  35366. * @private
  35367. * @param {Array} array The array to fill.
  35368. * @param {*} value The value to fill `array` with.
  35369. * @param {number} [start=0] The start position.
  35370. * @param {number} [end=array.length] The end position.
  35371. * @returns {Array} Returns `array`.
  35372. */
  35373. function baseFill(array, value, start, end) {
  35374. var length = array.length;
  35375. start = toInteger(start);
  35376. if (start < 0) {
  35377. start = -start > length ? 0 : (length + start);
  35378. }
  35379. end = (end === undefined || end > length) ? length : toInteger(end);
  35380. if (end < 0) {
  35381. end += length;
  35382. }
  35383. end = start > end ? 0 : toLength(end);
  35384. while (start < end) {
  35385. array[start++] = value;
  35386. }
  35387. return array;
  35388. }
  35389. /**
  35390. * The base implementation of `_.filter` without support for iteratee shorthands.
  35391. *
  35392. * @private
  35393. * @param {Array|Object} collection The collection to iterate over.
  35394. * @param {Function} predicate The function invoked per iteration.
  35395. * @returns {Array} Returns the new filtered array.
  35396. */
  35397. function baseFilter(collection, predicate) {
  35398. var result = [];
  35399. baseEach(collection, function(value, index, collection) {
  35400. if (predicate(value, index, collection)) {
  35401. result.push(value);
  35402. }
  35403. });
  35404. return result;
  35405. }
  35406. /**
  35407. * The base implementation of `_.flatten` with support for restricting flattening.
  35408. *
  35409. * @private
  35410. * @param {Array} array The array to flatten.
  35411. * @param {number} depth The maximum recursion depth.
  35412. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  35413. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  35414. * @param {Array} [result=[]] The initial result value.
  35415. * @returns {Array} Returns the new flattened array.
  35416. */
  35417. function baseFlatten(array, depth, predicate, isStrict, result) {
  35418. var index = -1,
  35419. length = array.length;
  35420. predicate || (predicate = isFlattenable);
  35421. result || (result = []);
  35422. while (++index < length) {
  35423. var value = array[index];
  35424. if (depth > 0 && predicate(value)) {
  35425. if (depth > 1) {
  35426. // Recursively flatten arrays (susceptible to call stack limits).
  35427. baseFlatten(value, depth - 1, predicate, isStrict, result);
  35428. } else {
  35429. arrayPush(result, value);
  35430. }
  35431. } else if (!isStrict) {
  35432. result[result.length] = value;
  35433. }
  35434. }
  35435. return result;
  35436. }
  35437. /**
  35438. * The base implementation of `baseForOwn` which iterates over `object`
  35439. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  35440. * Iteratee functions may exit iteration early by explicitly returning `false`.
  35441. *
  35442. * @private
  35443. * @param {Object} object The object to iterate over.
  35444. * @param {Function} iteratee The function invoked per iteration.
  35445. * @param {Function} keysFunc The function to get the keys of `object`.
  35446. * @returns {Object} Returns `object`.
  35447. */
  35448. var baseFor = createBaseFor();
  35449. /**
  35450. * This function is like `baseFor` except that it iterates over properties
  35451. * in the opposite order.
  35452. *
  35453. * @private
  35454. * @param {Object} object The object to iterate over.
  35455. * @param {Function} iteratee The function invoked per iteration.
  35456. * @param {Function} keysFunc The function to get the keys of `object`.
  35457. * @returns {Object} Returns `object`.
  35458. */
  35459. var baseForRight = createBaseFor(true);
  35460. /**
  35461. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  35462. *
  35463. * @private
  35464. * @param {Object} object The object to iterate over.
  35465. * @param {Function} iteratee The function invoked per iteration.
  35466. * @returns {Object} Returns `object`.
  35467. */
  35468. function baseForOwn(object, iteratee) {
  35469. return object && baseFor(object, iteratee, keys);
  35470. }
  35471. /**
  35472. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  35473. *
  35474. * @private
  35475. * @param {Object} object The object to iterate over.
  35476. * @param {Function} iteratee The function invoked per iteration.
  35477. * @returns {Object} Returns `object`.
  35478. */
  35479. function baseForOwnRight(object, iteratee) {
  35480. return object && baseForRight(object, iteratee, keys);
  35481. }
  35482. /**
  35483. * The base implementation of `_.functions` which creates an array of
  35484. * `object` function property names filtered from `props`.
  35485. *
  35486. * @private
  35487. * @param {Object} object The object to inspect.
  35488. * @param {Array} props The property names to filter.
  35489. * @returns {Array} Returns the function names.
  35490. */
  35491. function baseFunctions(object, props) {
  35492. return arrayFilter(props, function(key) {
  35493. return isFunction(object[key]);
  35494. });
  35495. }
  35496. /**
  35497. * The base implementation of `_.get` without support for default values.
  35498. *
  35499. * @private
  35500. * @param {Object} object The object to query.
  35501. * @param {Array|string} path The path of the property to get.
  35502. * @returns {*} Returns the resolved value.
  35503. */
  35504. function baseGet(object, path) {
  35505. path = castPath(path, object);
  35506. var index = 0,
  35507. length = path.length;
  35508. while (object != null && index < length) {
  35509. object = object[toKey(path[index++])];
  35510. }
  35511. return (index && index == length) ? object : undefined;
  35512. }
  35513. /**
  35514. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  35515. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  35516. * symbols of `object`.
  35517. *
  35518. * @private
  35519. * @param {Object} object The object to query.
  35520. * @param {Function} keysFunc The function to get the keys of `object`.
  35521. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  35522. * @returns {Array} Returns the array of property names and symbols.
  35523. */
  35524. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  35525. var result = keysFunc(object);
  35526. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  35527. }
  35528. /**
  35529. * The base implementation of `getTag` without fallbacks for buggy environments.
  35530. *
  35531. * @private
  35532. * @param {*} value The value to query.
  35533. * @returns {string} Returns the `toStringTag`.
  35534. */
  35535. function baseGetTag(value) {
  35536. if (value == null) {
  35537. return value === undefined ? undefinedTag : nullTag;
  35538. }
  35539. return (symToStringTag && symToStringTag in Object(value))
  35540. ? getRawTag(value)
  35541. : objectToString(value);
  35542. }
  35543. /**
  35544. * The base implementation of `_.gt` which doesn't coerce arguments.
  35545. *
  35546. * @private
  35547. * @param {*} value The value to compare.
  35548. * @param {*} other The other value to compare.
  35549. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  35550. * else `false`.
  35551. */
  35552. function baseGt(value, other) {
  35553. return value > other;
  35554. }
  35555. /**
  35556. * The base implementation of `_.has` without support for deep paths.
  35557. *
  35558. * @private
  35559. * @param {Object} [object] The object to query.
  35560. * @param {Array|string} key The key to check.
  35561. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  35562. */
  35563. function baseHas(object, key) {
  35564. return object != null && hasOwnProperty.call(object, key);
  35565. }
  35566. /**
  35567. * The base implementation of `_.hasIn` without support for deep paths.
  35568. *
  35569. * @private
  35570. * @param {Object} [object] The object to query.
  35571. * @param {Array|string} key The key to check.
  35572. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  35573. */
  35574. function baseHasIn(object, key) {
  35575. return object != null && key in Object(object);
  35576. }
  35577. /**
  35578. * The base implementation of `_.inRange` which doesn't coerce arguments.
  35579. *
  35580. * @private
  35581. * @param {number} number The number to check.
  35582. * @param {number} start The start of the range.
  35583. * @param {number} end The end of the range.
  35584. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  35585. */
  35586. function baseInRange(number, start, end) {
  35587. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  35588. }
  35589. /**
  35590. * The base implementation of methods like `_.intersection`, without support
  35591. * for iteratee shorthands, that accepts an array of arrays to inspect.
  35592. *
  35593. * @private
  35594. * @param {Array} arrays The arrays to inspect.
  35595. * @param {Function} [iteratee] The iteratee invoked per element.
  35596. * @param {Function} [comparator] The comparator invoked per element.
  35597. * @returns {Array} Returns the new array of shared values.
  35598. */
  35599. function baseIntersection(arrays, iteratee, comparator) {
  35600. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  35601. length = arrays[0].length,
  35602. othLength = arrays.length,
  35603. othIndex = othLength,
  35604. caches = Array(othLength),
  35605. maxLength = Infinity,
  35606. result = [];
  35607. while (othIndex--) {
  35608. var array = arrays[othIndex];
  35609. if (othIndex && iteratee) {
  35610. array = arrayMap(array, baseUnary(iteratee));
  35611. }
  35612. maxLength = nativeMin(array.length, maxLength);
  35613. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  35614. ? new SetCache(othIndex && array)
  35615. : undefined;
  35616. }
  35617. array = arrays[0];
  35618. var index = -1,
  35619. seen = caches[0];
  35620. outer:
  35621. while (++index < length && result.length < maxLength) {
  35622. var value = array[index],
  35623. computed = iteratee ? iteratee(value) : value;
  35624. value = (comparator || value !== 0) ? value : 0;
  35625. if (!(seen
  35626. ? cacheHas(seen, computed)
  35627. : includes(result, computed, comparator)
  35628. )) {
  35629. othIndex = othLength;
  35630. while (--othIndex) {
  35631. var cache = caches[othIndex];
  35632. if (!(cache
  35633. ? cacheHas(cache, computed)
  35634. : includes(arrays[othIndex], computed, comparator))
  35635. ) {
  35636. continue outer;
  35637. }
  35638. }
  35639. if (seen) {
  35640. seen.push(computed);
  35641. }
  35642. result.push(value);
  35643. }
  35644. }
  35645. return result;
  35646. }
  35647. /**
  35648. * The base implementation of `_.invert` and `_.invertBy` which inverts
  35649. * `object` with values transformed by `iteratee` and set by `setter`.
  35650. *
  35651. * @private
  35652. * @param {Object} object The object to iterate over.
  35653. * @param {Function} setter The function to set `accumulator` values.
  35654. * @param {Function} iteratee The iteratee to transform values.
  35655. * @param {Object} accumulator The initial inverted object.
  35656. * @returns {Function} Returns `accumulator`.
  35657. */
  35658. function baseInverter(object, setter, iteratee, accumulator) {
  35659. baseForOwn(object, function(value, key, object) {
  35660. setter(accumulator, iteratee(value), key, object);
  35661. });
  35662. return accumulator;
  35663. }
  35664. /**
  35665. * The base implementation of `_.invoke` without support for individual
  35666. * method arguments.
  35667. *
  35668. * @private
  35669. * @param {Object} object The object to query.
  35670. * @param {Array|string} path The path of the method to invoke.
  35671. * @param {Array} args The arguments to invoke the method with.
  35672. * @returns {*} Returns the result of the invoked method.
  35673. */
  35674. function baseInvoke(object, path, args) {
  35675. path = castPath(path, object);
  35676. object = parent(object, path);
  35677. var func = object == null ? object : object[toKey(last(path))];
  35678. return func == null ? undefined : apply(func, object, args);
  35679. }
  35680. /**
  35681. * The base implementation of `_.isArguments`.
  35682. *
  35683. * @private
  35684. * @param {*} value The value to check.
  35685. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  35686. */
  35687. function baseIsArguments(value) {
  35688. return isObjectLike(value) && baseGetTag(value) == argsTag;
  35689. }
  35690. /**
  35691. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  35692. *
  35693. * @private
  35694. * @param {*} value The value to check.
  35695. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  35696. */
  35697. function baseIsArrayBuffer(value) {
  35698. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  35699. }
  35700. /**
  35701. * The base implementation of `_.isDate` without Node.js optimizations.
  35702. *
  35703. * @private
  35704. * @param {*} value The value to check.
  35705. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  35706. */
  35707. function baseIsDate(value) {
  35708. return isObjectLike(value) && baseGetTag(value) == dateTag;
  35709. }
  35710. /**
  35711. * The base implementation of `_.isEqual` which supports partial comparisons
  35712. * and tracks traversed objects.
  35713. *
  35714. * @private
  35715. * @param {*} value The value to compare.
  35716. * @param {*} other The other value to compare.
  35717. * @param {boolean} bitmask The bitmask flags.
  35718. * 1 - Unordered comparison
  35719. * 2 - Partial comparison
  35720. * @param {Function} [customizer] The function to customize comparisons.
  35721. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  35722. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  35723. */
  35724. function baseIsEqual(value, other, bitmask, customizer, stack) {
  35725. if (value === other) {
  35726. return true;
  35727. }
  35728. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  35729. return value !== value && other !== other;
  35730. }
  35731. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  35732. }
  35733. /**
  35734. * A specialized version of `baseIsEqual` for arrays and objects which performs
  35735. * deep comparisons and tracks traversed objects enabling objects with circular
  35736. * references to be compared.
  35737. *
  35738. * @private
  35739. * @param {Object} object The object to compare.
  35740. * @param {Object} other The other object to compare.
  35741. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  35742. * @param {Function} customizer The function to customize comparisons.
  35743. * @param {Function} equalFunc The function to determine equivalents of values.
  35744. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  35745. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  35746. */
  35747. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  35748. var objIsArr = isArray(object),
  35749. othIsArr = isArray(other),
  35750. objTag = objIsArr ? arrayTag : getTag(object),
  35751. othTag = othIsArr ? arrayTag : getTag(other);
  35752. objTag = objTag == argsTag ? objectTag : objTag;
  35753. othTag = othTag == argsTag ? objectTag : othTag;
  35754. var objIsObj = objTag == objectTag,
  35755. othIsObj = othTag == objectTag,
  35756. isSameTag = objTag == othTag;
  35757. if (isSameTag && isBuffer(object)) {
  35758. if (!isBuffer(other)) {
  35759. return false;
  35760. }
  35761. objIsArr = true;
  35762. objIsObj = false;
  35763. }
  35764. if (isSameTag && !objIsObj) {
  35765. stack || (stack = new Stack);
  35766. return (objIsArr || isTypedArray(object))
  35767. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  35768. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  35769. }
  35770. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  35771. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  35772. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  35773. if (objIsWrapped || othIsWrapped) {
  35774. var objUnwrapped = objIsWrapped ? object.value() : object,
  35775. othUnwrapped = othIsWrapped ? other.value() : other;
  35776. stack || (stack = new Stack);
  35777. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  35778. }
  35779. }
  35780. if (!isSameTag) {
  35781. return false;
  35782. }
  35783. stack || (stack = new Stack);
  35784. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  35785. }
  35786. /**
  35787. * The base implementation of `_.isMap` without Node.js optimizations.
  35788. *
  35789. * @private
  35790. * @param {*} value The value to check.
  35791. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  35792. */
  35793. function baseIsMap(value) {
  35794. return isObjectLike(value) && getTag(value) == mapTag;
  35795. }
  35796. /**
  35797. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  35798. *
  35799. * @private
  35800. * @param {Object} object The object to inspect.
  35801. * @param {Object} source The object of property values to match.
  35802. * @param {Array} matchData The property names, values, and compare flags to match.
  35803. * @param {Function} [customizer] The function to customize comparisons.
  35804. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  35805. */
  35806. function baseIsMatch(object, source, matchData, customizer) {
  35807. var index = matchData.length,
  35808. length = index,
  35809. noCustomizer = !customizer;
  35810. if (object == null) {
  35811. return !length;
  35812. }
  35813. object = Object(object);
  35814. while (index--) {
  35815. var data = matchData[index];
  35816. if ((noCustomizer && data[2])
  35817. ? data[1] !== object[data[0]]
  35818. : !(data[0] in object)
  35819. ) {
  35820. return false;
  35821. }
  35822. }
  35823. while (++index < length) {
  35824. data = matchData[index];
  35825. var key = data[0],
  35826. objValue = object[key],
  35827. srcValue = data[1];
  35828. if (noCustomizer && data[2]) {
  35829. if (objValue === undefined && !(key in object)) {
  35830. return false;
  35831. }
  35832. } else {
  35833. var stack = new Stack;
  35834. if (customizer) {
  35835. var result = customizer(objValue, srcValue, key, object, source, stack);
  35836. }
  35837. if (!(result === undefined
  35838. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  35839. : result
  35840. )) {
  35841. return false;
  35842. }
  35843. }
  35844. }
  35845. return true;
  35846. }
  35847. /**
  35848. * The base implementation of `_.isNative` without bad shim checks.
  35849. *
  35850. * @private
  35851. * @param {*} value The value to check.
  35852. * @returns {boolean} Returns `true` if `value` is a native function,
  35853. * else `false`.
  35854. */
  35855. function baseIsNative(value) {
  35856. if (!isObject(value) || isMasked(value)) {
  35857. return false;
  35858. }
  35859. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  35860. return pattern.test(toSource(value));
  35861. }
  35862. /**
  35863. * The base implementation of `_.isRegExp` without Node.js optimizations.
  35864. *
  35865. * @private
  35866. * @param {*} value The value to check.
  35867. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  35868. */
  35869. function baseIsRegExp(value) {
  35870. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  35871. }
  35872. /**
  35873. * The base implementation of `_.isSet` without Node.js optimizations.
  35874. *
  35875. * @private
  35876. * @param {*} value The value to check.
  35877. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  35878. */
  35879. function baseIsSet(value) {
  35880. return isObjectLike(value) && getTag(value) == setTag;
  35881. }
  35882. /**
  35883. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  35884. *
  35885. * @private
  35886. * @param {*} value The value to check.
  35887. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  35888. */
  35889. function baseIsTypedArray(value) {
  35890. return isObjectLike(value) &&
  35891. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  35892. }
  35893. /**
  35894. * The base implementation of `_.iteratee`.
  35895. *
  35896. * @private
  35897. * @param {*} [value=_.identity] The value to convert to an iteratee.
  35898. * @returns {Function} Returns the iteratee.
  35899. */
  35900. function baseIteratee(value) {
  35901. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  35902. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  35903. if (typeof value == 'function') {
  35904. return value;
  35905. }
  35906. if (value == null) {
  35907. return identity;
  35908. }
  35909. if (typeof value == 'object') {
  35910. return isArray(value)
  35911. ? baseMatchesProperty(value[0], value[1])
  35912. : baseMatches(value);
  35913. }
  35914. return property(value);
  35915. }
  35916. /**
  35917. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  35918. *
  35919. * @private
  35920. * @param {Object} object The object to query.
  35921. * @returns {Array} Returns the array of property names.
  35922. */
  35923. function baseKeys(object) {
  35924. if (!isPrototype(object)) {
  35925. return nativeKeys(object);
  35926. }
  35927. var result = [];
  35928. for (var key in Object(object)) {
  35929. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  35930. result.push(key);
  35931. }
  35932. }
  35933. return result;
  35934. }
  35935. /**
  35936. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  35937. *
  35938. * @private
  35939. * @param {Object} object The object to query.
  35940. * @returns {Array} Returns the array of property names.
  35941. */
  35942. function baseKeysIn(object) {
  35943. if (!isObject(object)) {
  35944. return nativeKeysIn(object);
  35945. }
  35946. var isProto = isPrototype(object),
  35947. result = [];
  35948. for (var key in object) {
  35949. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  35950. result.push(key);
  35951. }
  35952. }
  35953. return result;
  35954. }
  35955. /**
  35956. * The base implementation of `_.lt` which doesn't coerce arguments.
  35957. *
  35958. * @private
  35959. * @param {*} value The value to compare.
  35960. * @param {*} other The other value to compare.
  35961. * @returns {boolean} Returns `true` if `value` is less than `other`,
  35962. * else `false`.
  35963. */
  35964. function baseLt(value, other) {
  35965. return value < other;
  35966. }
  35967. /**
  35968. * The base implementation of `_.map` without support for iteratee shorthands.
  35969. *
  35970. * @private
  35971. * @param {Array|Object} collection The collection to iterate over.
  35972. * @param {Function} iteratee The function invoked per iteration.
  35973. * @returns {Array} Returns the new mapped array.
  35974. */
  35975. function baseMap(collection, iteratee) {
  35976. var index = -1,
  35977. result = isArrayLike(collection) ? Array(collection.length) : [];
  35978. baseEach(collection, function(value, key, collection) {
  35979. result[++index] = iteratee(value, key, collection);
  35980. });
  35981. return result;
  35982. }
  35983. /**
  35984. * The base implementation of `_.matches` which doesn't clone `source`.
  35985. *
  35986. * @private
  35987. * @param {Object} source The object of property values to match.
  35988. * @returns {Function} Returns the new spec function.
  35989. */
  35990. function baseMatches(source) {
  35991. var matchData = getMatchData(source);
  35992. if (matchData.length == 1 && matchData[0][2]) {
  35993. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  35994. }
  35995. return function(object) {
  35996. return object === source || baseIsMatch(object, source, matchData);
  35997. };
  35998. }
  35999. /**
  36000. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  36001. *
  36002. * @private
  36003. * @param {string} path The path of the property to get.
  36004. * @param {*} srcValue The value to match.
  36005. * @returns {Function} Returns the new spec function.
  36006. */
  36007. function baseMatchesProperty(path, srcValue) {
  36008. if (isKey(path) && isStrictComparable(srcValue)) {
  36009. return matchesStrictComparable(toKey(path), srcValue);
  36010. }
  36011. return function(object) {
  36012. var objValue = get(object, path);
  36013. return (objValue === undefined && objValue === srcValue)
  36014. ? hasIn(object, path)
  36015. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  36016. };
  36017. }
  36018. /**
  36019. * The base implementation of `_.merge` without support for multiple sources.
  36020. *
  36021. * @private
  36022. * @param {Object} object The destination object.
  36023. * @param {Object} source The source object.
  36024. * @param {number} srcIndex The index of `source`.
  36025. * @param {Function} [customizer] The function to customize merged values.
  36026. * @param {Object} [stack] Tracks traversed source values and their merged
  36027. * counterparts.
  36028. */
  36029. function baseMerge(object, source, srcIndex, customizer, stack) {
  36030. if (object === source) {
  36031. return;
  36032. }
  36033. baseFor(source, function(srcValue, key) {
  36034. stack || (stack = new Stack);
  36035. if (isObject(srcValue)) {
  36036. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  36037. }
  36038. else {
  36039. var newValue = customizer
  36040. ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
  36041. : undefined;
  36042. if (newValue === undefined) {
  36043. newValue = srcValue;
  36044. }
  36045. assignMergeValue(object, key, newValue);
  36046. }
  36047. }, keysIn);
  36048. }
  36049. /**
  36050. * A specialized version of `baseMerge` for arrays and objects which performs
  36051. * deep merges and tracks traversed objects enabling objects with circular
  36052. * references to be merged.
  36053. *
  36054. * @private
  36055. * @param {Object} object The destination object.
  36056. * @param {Object} source The source object.
  36057. * @param {string} key The key of the value to merge.
  36058. * @param {number} srcIndex The index of `source`.
  36059. * @param {Function} mergeFunc The function to merge values.
  36060. * @param {Function} [customizer] The function to customize assigned values.
  36061. * @param {Object} [stack] Tracks traversed source values and their merged
  36062. * counterparts.
  36063. */
  36064. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  36065. var objValue = safeGet(object, key),
  36066. srcValue = safeGet(source, key),
  36067. stacked = stack.get(srcValue);
  36068. if (stacked) {
  36069. assignMergeValue(object, key, stacked);
  36070. return;
  36071. }
  36072. var newValue = customizer
  36073. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  36074. : undefined;
  36075. var isCommon = newValue === undefined;
  36076. if (isCommon) {
  36077. var isArr = isArray(srcValue),
  36078. isBuff = !isArr && isBuffer(srcValue),
  36079. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  36080. newValue = srcValue;
  36081. if (isArr || isBuff || isTyped) {
  36082. if (isArray(objValue)) {
  36083. newValue = objValue;
  36084. }
  36085. else if (isArrayLikeObject(objValue)) {
  36086. newValue = copyArray(objValue);
  36087. }
  36088. else if (isBuff) {
  36089. isCommon = false;
  36090. newValue = cloneBuffer(srcValue, true);
  36091. }
  36092. else if (isTyped) {
  36093. isCommon = false;
  36094. newValue = cloneTypedArray(srcValue, true);
  36095. }
  36096. else {
  36097. newValue = [];
  36098. }
  36099. }
  36100. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  36101. newValue = objValue;
  36102. if (isArguments(objValue)) {
  36103. newValue = toPlainObject(objValue);
  36104. }
  36105. else if (!isObject(objValue) || isFunction(objValue)) {
  36106. newValue = initCloneObject(srcValue);
  36107. }
  36108. }
  36109. else {
  36110. isCommon = false;
  36111. }
  36112. }
  36113. if (isCommon) {
  36114. // Recursively merge objects and arrays (susceptible to call stack limits).
  36115. stack.set(srcValue, newValue);
  36116. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  36117. stack['delete'](srcValue);
  36118. }
  36119. assignMergeValue(object, key, newValue);
  36120. }
  36121. /**
  36122. * The base implementation of `_.nth` which doesn't coerce arguments.
  36123. *
  36124. * @private
  36125. * @param {Array} array The array to query.
  36126. * @param {number} n The index of the element to return.
  36127. * @returns {*} Returns the nth element of `array`.
  36128. */
  36129. function baseNth(array, n) {
  36130. var length = array.length;
  36131. if (!length) {
  36132. return;
  36133. }
  36134. n += n < 0 ? length : 0;
  36135. return isIndex(n, length) ? array[n] : undefined;
  36136. }
  36137. /**
  36138. * The base implementation of `_.orderBy` without param guards.
  36139. *
  36140. * @private
  36141. * @param {Array|Object} collection The collection to iterate over.
  36142. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  36143. * @param {string[]} orders The sort orders of `iteratees`.
  36144. * @returns {Array} Returns the new sorted array.
  36145. */
  36146. function baseOrderBy(collection, iteratees, orders) {
  36147. if (iteratees.length) {
  36148. iteratees = arrayMap(iteratees, function(iteratee) {
  36149. if (isArray(iteratee)) {
  36150. return function(value) {
  36151. return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee);
  36152. }
  36153. }
  36154. return iteratee;
  36155. });
  36156. } else {
  36157. iteratees = [identity];
  36158. }
  36159. var index = -1;
  36160. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  36161. var result = baseMap(collection, function(value, key, collection) {
  36162. var criteria = arrayMap(iteratees, function(iteratee) {
  36163. return iteratee(value);
  36164. });
  36165. return { 'criteria': criteria, 'index': ++index, 'value': value };
  36166. });
  36167. return baseSortBy(result, function(object, other) {
  36168. return compareMultiple(object, other, orders);
  36169. });
  36170. }
  36171. /**
  36172. * The base implementation of `_.pick` without support for individual
  36173. * property identifiers.
  36174. *
  36175. * @private
  36176. * @param {Object} object The source object.
  36177. * @param {string[]} paths The property paths to pick.
  36178. * @returns {Object} Returns the new object.
  36179. */
  36180. function basePick(object, paths) {
  36181. return basePickBy(object, paths, function(value, path) {
  36182. return hasIn(object, path);
  36183. });
  36184. }
  36185. /**
  36186. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  36187. *
  36188. * @private
  36189. * @param {Object} object The source object.
  36190. * @param {string[]} paths The property paths to pick.
  36191. * @param {Function} predicate The function invoked per property.
  36192. * @returns {Object} Returns the new object.
  36193. */
  36194. function basePickBy(object, paths, predicate) {
  36195. var index = -1,
  36196. length = paths.length,
  36197. result = {};
  36198. while (++index < length) {
  36199. var path = paths[index],
  36200. value = baseGet(object, path);
  36201. if (predicate(value, path)) {
  36202. baseSet(result, castPath(path, object), value);
  36203. }
  36204. }
  36205. return result;
  36206. }
  36207. /**
  36208. * A specialized version of `baseProperty` which supports deep paths.
  36209. *
  36210. * @private
  36211. * @param {Array|string} path The path of the property to get.
  36212. * @returns {Function} Returns the new accessor function.
  36213. */
  36214. function basePropertyDeep(path) {
  36215. return function(object) {
  36216. return baseGet(object, path);
  36217. };
  36218. }
  36219. /**
  36220. * The base implementation of `_.pullAllBy` without support for iteratee
  36221. * shorthands.
  36222. *
  36223. * @private
  36224. * @param {Array} array The array to modify.
  36225. * @param {Array} values The values to remove.
  36226. * @param {Function} [iteratee] The iteratee invoked per element.
  36227. * @param {Function} [comparator] The comparator invoked per element.
  36228. * @returns {Array} Returns `array`.
  36229. */
  36230. function basePullAll(array, values, iteratee, comparator) {
  36231. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  36232. index = -1,
  36233. length = values.length,
  36234. seen = array;
  36235. if (array === values) {
  36236. values = copyArray(values);
  36237. }
  36238. if (iteratee) {
  36239. seen = arrayMap(array, baseUnary(iteratee));
  36240. }
  36241. while (++index < length) {
  36242. var fromIndex = 0,
  36243. value = values[index],
  36244. computed = iteratee ? iteratee(value) : value;
  36245. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  36246. if (seen !== array) {
  36247. splice.call(seen, fromIndex, 1);
  36248. }
  36249. splice.call(array, fromIndex, 1);
  36250. }
  36251. }
  36252. return array;
  36253. }
  36254. /**
  36255. * The base implementation of `_.pullAt` without support for individual
  36256. * indexes or capturing the removed elements.
  36257. *
  36258. * @private
  36259. * @param {Array} array The array to modify.
  36260. * @param {number[]} indexes The indexes of elements to remove.
  36261. * @returns {Array} Returns `array`.
  36262. */
  36263. function basePullAt(array, indexes) {
  36264. var length = array ? indexes.length : 0,
  36265. lastIndex = length - 1;
  36266. while (length--) {
  36267. var index = indexes[length];
  36268. if (length == lastIndex || index !== previous) {
  36269. var previous = index;
  36270. if (isIndex(index)) {
  36271. splice.call(array, index, 1);
  36272. } else {
  36273. baseUnset(array, index);
  36274. }
  36275. }
  36276. }
  36277. return array;
  36278. }
  36279. /**
  36280. * The base implementation of `_.random` without support for returning
  36281. * floating-point numbers.
  36282. *
  36283. * @private
  36284. * @param {number} lower The lower bound.
  36285. * @param {number} upper The upper bound.
  36286. * @returns {number} Returns the random number.
  36287. */
  36288. function baseRandom(lower, upper) {
  36289. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  36290. }
  36291. /**
  36292. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  36293. * coerce arguments.
  36294. *
  36295. * @private
  36296. * @param {number} start The start of the range.
  36297. * @param {number} end The end of the range.
  36298. * @param {number} step The value to increment or decrement by.
  36299. * @param {boolean} [fromRight] Specify iterating from right to left.
  36300. * @returns {Array} Returns the range of numbers.
  36301. */
  36302. function baseRange(start, end, step, fromRight) {
  36303. var index = -1,
  36304. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  36305. result = Array(length);
  36306. while (length--) {
  36307. result[fromRight ? length : ++index] = start;
  36308. start += step;
  36309. }
  36310. return result;
  36311. }
  36312. /**
  36313. * The base implementation of `_.repeat` which doesn't coerce arguments.
  36314. *
  36315. * @private
  36316. * @param {string} string The string to repeat.
  36317. * @param {number} n The number of times to repeat the string.
  36318. * @returns {string} Returns the repeated string.
  36319. */
  36320. function baseRepeat(string, n) {
  36321. var result = '';
  36322. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  36323. return result;
  36324. }
  36325. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  36326. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  36327. do {
  36328. if (n % 2) {
  36329. result += string;
  36330. }
  36331. n = nativeFloor(n / 2);
  36332. if (n) {
  36333. string += string;
  36334. }
  36335. } while (n);
  36336. return result;
  36337. }
  36338. /**
  36339. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  36340. *
  36341. * @private
  36342. * @param {Function} func The function to apply a rest parameter to.
  36343. * @param {number} [start=func.length-1] The start position of the rest parameter.
  36344. * @returns {Function} Returns the new function.
  36345. */
  36346. function baseRest(func, start) {
  36347. return setToString(overRest(func, start, identity), func + '');
  36348. }
  36349. /**
  36350. * The base implementation of `_.sample`.
  36351. *
  36352. * @private
  36353. * @param {Array|Object} collection The collection to sample.
  36354. * @returns {*} Returns the random element.
  36355. */
  36356. function baseSample(collection) {
  36357. return arraySample(values(collection));
  36358. }
  36359. /**
  36360. * The base implementation of `_.sampleSize` without param guards.
  36361. *
  36362. * @private
  36363. * @param {Array|Object} collection The collection to sample.
  36364. * @param {number} n The number of elements to sample.
  36365. * @returns {Array} Returns the random elements.
  36366. */
  36367. function baseSampleSize(collection, n) {
  36368. var array = values(collection);
  36369. return shuffleSelf(array, baseClamp(n, 0, array.length));
  36370. }
  36371. /**
  36372. * The base implementation of `_.set`.
  36373. *
  36374. * @private
  36375. * @param {Object} object The object to modify.
  36376. * @param {Array|string} path The path of the property to set.
  36377. * @param {*} value The value to set.
  36378. * @param {Function} [customizer] The function to customize path creation.
  36379. * @returns {Object} Returns `object`.
  36380. */
  36381. function baseSet(object, path, value, customizer) {
  36382. if (!isObject(object)) {
  36383. return object;
  36384. }
  36385. path = castPath(path, object);
  36386. var index = -1,
  36387. length = path.length,
  36388. lastIndex = length - 1,
  36389. nested = object;
  36390. while (nested != null && ++index < length) {
  36391. var key = toKey(path[index]),
  36392. newValue = value;
  36393. if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
  36394. return object;
  36395. }
  36396. if (index != lastIndex) {
  36397. var objValue = nested[key];
  36398. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  36399. if (newValue === undefined) {
  36400. newValue = isObject(objValue)
  36401. ? objValue
  36402. : (isIndex(path[index + 1]) ? [] : {});
  36403. }
  36404. }
  36405. assignValue(nested, key, newValue);
  36406. nested = nested[key];
  36407. }
  36408. return object;
  36409. }
  36410. /**
  36411. * The base implementation of `setData` without support for hot loop shorting.
  36412. *
  36413. * @private
  36414. * @param {Function} func The function to associate metadata with.
  36415. * @param {*} data The metadata.
  36416. * @returns {Function} Returns `func`.
  36417. */
  36418. var baseSetData = !metaMap ? identity : function(func, data) {
  36419. metaMap.set(func, data);
  36420. return func;
  36421. };
  36422. /**
  36423. * The base implementation of `setToString` without support for hot loop shorting.
  36424. *
  36425. * @private
  36426. * @param {Function} func The function to modify.
  36427. * @param {Function} string The `toString` result.
  36428. * @returns {Function} Returns `func`.
  36429. */
  36430. var baseSetToString = !defineProperty ? identity : function(func, string) {
  36431. return defineProperty(func, 'toString', {
  36432. 'configurable': true,
  36433. 'enumerable': false,
  36434. 'value': constant(string),
  36435. 'writable': true
  36436. });
  36437. };
  36438. /**
  36439. * The base implementation of `_.shuffle`.
  36440. *
  36441. * @private
  36442. * @param {Array|Object} collection The collection to shuffle.
  36443. * @returns {Array} Returns the new shuffled array.
  36444. */
  36445. function baseShuffle(collection) {
  36446. return shuffleSelf(values(collection));
  36447. }
  36448. /**
  36449. * The base implementation of `_.slice` without an iteratee call guard.
  36450. *
  36451. * @private
  36452. * @param {Array} array The array to slice.
  36453. * @param {number} [start=0] The start position.
  36454. * @param {number} [end=array.length] The end position.
  36455. * @returns {Array} Returns the slice of `array`.
  36456. */
  36457. function baseSlice(array, start, end) {
  36458. var index = -1,
  36459. length = array.length;
  36460. if (start < 0) {
  36461. start = -start > length ? 0 : (length + start);
  36462. }
  36463. end = end > length ? length : end;
  36464. if (end < 0) {
  36465. end += length;
  36466. }
  36467. length = start > end ? 0 : ((end - start) >>> 0);
  36468. start >>>= 0;
  36469. var result = Array(length);
  36470. while (++index < length) {
  36471. result[index] = array[index + start];
  36472. }
  36473. return result;
  36474. }
  36475. /**
  36476. * The base implementation of `_.some` without support for iteratee shorthands.
  36477. *
  36478. * @private
  36479. * @param {Array|Object} collection The collection to iterate over.
  36480. * @param {Function} predicate The function invoked per iteration.
  36481. * @returns {boolean} Returns `true` if any element passes the predicate check,
  36482. * else `false`.
  36483. */
  36484. function baseSome(collection, predicate) {
  36485. var result;
  36486. baseEach(collection, function(value, index, collection) {
  36487. result = predicate(value, index, collection);
  36488. return !result;
  36489. });
  36490. return !!result;
  36491. }
  36492. /**
  36493. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  36494. * performs a binary search of `array` to determine the index at which `value`
  36495. * should be inserted into `array` in order to maintain its sort order.
  36496. *
  36497. * @private
  36498. * @param {Array} array The sorted array to inspect.
  36499. * @param {*} value The value to evaluate.
  36500. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  36501. * @returns {number} Returns the index at which `value` should be inserted
  36502. * into `array`.
  36503. */
  36504. function baseSortedIndex(array, value, retHighest) {
  36505. var low = 0,
  36506. high = array == null ? low : array.length;
  36507. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  36508. while (low < high) {
  36509. var mid = (low + high) >>> 1,
  36510. computed = array[mid];
  36511. if (computed !== null && !isSymbol(computed) &&
  36512. (retHighest ? (computed <= value) : (computed < value))) {
  36513. low = mid + 1;
  36514. } else {
  36515. high = mid;
  36516. }
  36517. }
  36518. return high;
  36519. }
  36520. return baseSortedIndexBy(array, value, identity, retHighest);
  36521. }
  36522. /**
  36523. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  36524. * which invokes `iteratee` for `value` and each element of `array` to compute
  36525. * their sort ranking. The iteratee is invoked with one argument; (value).
  36526. *
  36527. * @private
  36528. * @param {Array} array The sorted array to inspect.
  36529. * @param {*} value The value to evaluate.
  36530. * @param {Function} iteratee The iteratee invoked per element.
  36531. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  36532. * @returns {number} Returns the index at which `value` should be inserted
  36533. * into `array`.
  36534. */
  36535. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  36536. var low = 0,
  36537. high = array == null ? 0 : array.length;
  36538. if (high === 0) {
  36539. return 0;
  36540. }
  36541. value = iteratee(value);
  36542. var valIsNaN = value !== value,
  36543. valIsNull = value === null,
  36544. valIsSymbol = isSymbol(value),
  36545. valIsUndefined = value === undefined;
  36546. while (low < high) {
  36547. var mid = nativeFloor((low + high) / 2),
  36548. computed = iteratee(array[mid]),
  36549. othIsDefined = computed !== undefined,
  36550. othIsNull = computed === null,
  36551. othIsReflexive = computed === computed,
  36552. othIsSymbol = isSymbol(computed);
  36553. if (valIsNaN) {
  36554. var setLow = retHighest || othIsReflexive;
  36555. } else if (valIsUndefined) {
  36556. setLow = othIsReflexive && (retHighest || othIsDefined);
  36557. } else if (valIsNull) {
  36558. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  36559. } else if (valIsSymbol) {
  36560. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  36561. } else if (othIsNull || othIsSymbol) {
  36562. setLow = false;
  36563. } else {
  36564. setLow = retHighest ? (computed <= value) : (computed < value);
  36565. }
  36566. if (setLow) {
  36567. low = mid + 1;
  36568. } else {
  36569. high = mid;
  36570. }
  36571. }
  36572. return nativeMin(high, MAX_ARRAY_INDEX);
  36573. }
  36574. /**
  36575. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  36576. * support for iteratee shorthands.
  36577. *
  36578. * @private
  36579. * @param {Array} array The array to inspect.
  36580. * @param {Function} [iteratee] The iteratee invoked per element.
  36581. * @returns {Array} Returns the new duplicate free array.
  36582. */
  36583. function baseSortedUniq(array, iteratee) {
  36584. var index = -1,
  36585. length = array.length,
  36586. resIndex = 0,
  36587. result = [];
  36588. while (++index < length) {
  36589. var value = array[index],
  36590. computed = iteratee ? iteratee(value) : value;
  36591. if (!index || !eq(computed, seen)) {
  36592. var seen = computed;
  36593. result[resIndex++] = value === 0 ? 0 : value;
  36594. }
  36595. }
  36596. return result;
  36597. }
  36598. /**
  36599. * The base implementation of `_.toNumber` which doesn't ensure correct
  36600. * conversions of binary, hexadecimal, or octal string values.
  36601. *
  36602. * @private
  36603. * @param {*} value The value to process.
  36604. * @returns {number} Returns the number.
  36605. */
  36606. function baseToNumber(value) {
  36607. if (typeof value == 'number') {
  36608. return value;
  36609. }
  36610. if (isSymbol(value)) {
  36611. return NAN;
  36612. }
  36613. return +value;
  36614. }
  36615. /**
  36616. * The base implementation of `_.toString` which doesn't convert nullish
  36617. * values to empty strings.
  36618. *
  36619. * @private
  36620. * @param {*} value The value to process.
  36621. * @returns {string} Returns the string.
  36622. */
  36623. function baseToString(value) {
  36624. // Exit early for strings to avoid a performance hit in some environments.
  36625. if (typeof value == 'string') {
  36626. return value;
  36627. }
  36628. if (isArray(value)) {
  36629. // Recursively convert values (susceptible to call stack limits).
  36630. return arrayMap(value, baseToString) + '';
  36631. }
  36632. if (isSymbol(value)) {
  36633. return symbolToString ? symbolToString.call(value) : '';
  36634. }
  36635. var result = (value + '');
  36636. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  36637. }
  36638. /**
  36639. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  36640. *
  36641. * @private
  36642. * @param {Array} array The array to inspect.
  36643. * @param {Function} [iteratee] The iteratee invoked per element.
  36644. * @param {Function} [comparator] The comparator invoked per element.
  36645. * @returns {Array} Returns the new duplicate free array.
  36646. */
  36647. function baseUniq(array, iteratee, comparator) {
  36648. var index = -1,
  36649. includes = arrayIncludes,
  36650. length = array.length,
  36651. isCommon = true,
  36652. result = [],
  36653. seen = result;
  36654. if (comparator) {
  36655. isCommon = false;
  36656. includes = arrayIncludesWith;
  36657. }
  36658. else if (length >= LARGE_ARRAY_SIZE) {
  36659. var set = iteratee ? null : createSet(array);
  36660. if (set) {
  36661. return setToArray(set);
  36662. }
  36663. isCommon = false;
  36664. includes = cacheHas;
  36665. seen = new SetCache;
  36666. }
  36667. else {
  36668. seen = iteratee ? [] : result;
  36669. }
  36670. outer:
  36671. while (++index < length) {
  36672. var value = array[index],
  36673. computed = iteratee ? iteratee(value) : value;
  36674. value = (comparator || value !== 0) ? value : 0;
  36675. if (isCommon && computed === computed) {
  36676. var seenIndex = seen.length;
  36677. while (seenIndex--) {
  36678. if (seen[seenIndex] === computed) {
  36679. continue outer;
  36680. }
  36681. }
  36682. if (iteratee) {
  36683. seen.push(computed);
  36684. }
  36685. result.push(value);
  36686. }
  36687. else if (!includes(seen, computed, comparator)) {
  36688. if (seen !== result) {
  36689. seen.push(computed);
  36690. }
  36691. result.push(value);
  36692. }
  36693. }
  36694. return result;
  36695. }
  36696. /**
  36697. * The base implementation of `_.unset`.
  36698. *
  36699. * @private
  36700. * @param {Object} object The object to modify.
  36701. * @param {Array|string} path The property path to unset.
  36702. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  36703. */
  36704. function baseUnset(object, path) {
  36705. path = castPath(path, object);
  36706. object = parent(object, path);
  36707. return object == null || delete object[toKey(last(path))];
  36708. }
  36709. /**
  36710. * The base implementation of `_.update`.
  36711. *
  36712. * @private
  36713. * @param {Object} object The object to modify.
  36714. * @param {Array|string} path The path of the property to update.
  36715. * @param {Function} updater The function to produce the updated value.
  36716. * @param {Function} [customizer] The function to customize path creation.
  36717. * @returns {Object} Returns `object`.
  36718. */
  36719. function baseUpdate(object, path, updater, customizer) {
  36720. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  36721. }
  36722. /**
  36723. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  36724. * without support for iteratee shorthands.
  36725. *
  36726. * @private
  36727. * @param {Array} array The array to query.
  36728. * @param {Function} predicate The function invoked per iteration.
  36729. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  36730. * @param {boolean} [fromRight] Specify iterating from right to left.
  36731. * @returns {Array} Returns the slice of `array`.
  36732. */
  36733. function baseWhile(array, predicate, isDrop, fromRight) {
  36734. var length = array.length,
  36735. index = fromRight ? length : -1;
  36736. while ((fromRight ? index-- : ++index < length) &&
  36737. predicate(array[index], index, array)) {}
  36738. return isDrop
  36739. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  36740. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  36741. }
  36742. /**
  36743. * The base implementation of `wrapperValue` which returns the result of
  36744. * performing a sequence of actions on the unwrapped `value`, where each
  36745. * successive action is supplied the return value of the previous.
  36746. *
  36747. * @private
  36748. * @param {*} value The unwrapped value.
  36749. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  36750. * @returns {*} Returns the resolved value.
  36751. */
  36752. function baseWrapperValue(value, actions) {
  36753. var result = value;
  36754. if (result instanceof LazyWrapper) {
  36755. result = result.value();
  36756. }
  36757. return arrayReduce(actions, function(result, action) {
  36758. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  36759. }, result);
  36760. }
  36761. /**
  36762. * The base implementation of methods like `_.xor`, without support for
  36763. * iteratee shorthands, that accepts an array of arrays to inspect.
  36764. *
  36765. * @private
  36766. * @param {Array} arrays The arrays to inspect.
  36767. * @param {Function} [iteratee] The iteratee invoked per element.
  36768. * @param {Function} [comparator] The comparator invoked per element.
  36769. * @returns {Array} Returns the new array of values.
  36770. */
  36771. function baseXor(arrays, iteratee, comparator) {
  36772. var length = arrays.length;
  36773. if (length < 2) {
  36774. return length ? baseUniq(arrays[0]) : [];
  36775. }
  36776. var index = -1,
  36777. result = Array(length);
  36778. while (++index < length) {
  36779. var array = arrays[index],
  36780. othIndex = -1;
  36781. while (++othIndex < length) {
  36782. if (othIndex != index) {
  36783. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  36784. }
  36785. }
  36786. }
  36787. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  36788. }
  36789. /**
  36790. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  36791. *
  36792. * @private
  36793. * @param {Array} props The property identifiers.
  36794. * @param {Array} values The property values.
  36795. * @param {Function} assignFunc The function to assign values.
  36796. * @returns {Object} Returns the new object.
  36797. */
  36798. function baseZipObject(props, values, assignFunc) {
  36799. var index = -1,
  36800. length = props.length,
  36801. valsLength = values.length,
  36802. result = {};
  36803. while (++index < length) {
  36804. var value = index < valsLength ? values[index] : undefined;
  36805. assignFunc(result, props[index], value);
  36806. }
  36807. return result;
  36808. }
  36809. /**
  36810. * Casts `value` to an empty array if it's not an array like object.
  36811. *
  36812. * @private
  36813. * @param {*} value The value to inspect.
  36814. * @returns {Array|Object} Returns the cast array-like object.
  36815. */
  36816. function castArrayLikeObject(value) {
  36817. return isArrayLikeObject(value) ? value : [];
  36818. }
  36819. /**
  36820. * Casts `value` to `identity` if it's not a function.
  36821. *
  36822. * @private
  36823. * @param {*} value The value to inspect.
  36824. * @returns {Function} Returns cast function.
  36825. */
  36826. function castFunction(value) {
  36827. return typeof value == 'function' ? value : identity;
  36828. }
  36829. /**
  36830. * Casts `value` to a path array if it's not one.
  36831. *
  36832. * @private
  36833. * @param {*} value The value to inspect.
  36834. * @param {Object} [object] The object to query keys on.
  36835. * @returns {Array} Returns the cast property path array.
  36836. */
  36837. function castPath(value, object) {
  36838. if (isArray(value)) {
  36839. return value;
  36840. }
  36841. return isKey(value, object) ? [value] : stringToPath(toString(value));
  36842. }
  36843. /**
  36844. * A `baseRest` alias which can be replaced with `identity` by module
  36845. * replacement plugins.
  36846. *
  36847. * @private
  36848. * @type {Function}
  36849. * @param {Function} func The function to apply a rest parameter to.
  36850. * @returns {Function} Returns the new function.
  36851. */
  36852. var castRest = baseRest;
  36853. /**
  36854. * Casts `array` to a slice if it's needed.
  36855. *
  36856. * @private
  36857. * @param {Array} array The array to inspect.
  36858. * @param {number} start The start position.
  36859. * @param {number} [end=array.length] The end position.
  36860. * @returns {Array} Returns the cast slice.
  36861. */
  36862. function castSlice(array, start, end) {
  36863. var length = array.length;
  36864. end = end === undefined ? length : end;
  36865. return (!start && end >= length) ? array : baseSlice(array, start, end);
  36866. }
  36867. /**
  36868. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  36869. *
  36870. * @private
  36871. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  36872. */
  36873. var clearTimeout = ctxClearTimeout || function(id) {
  36874. return root.clearTimeout(id);
  36875. };
  36876. /**
  36877. * Creates a clone of `buffer`.
  36878. *
  36879. * @private
  36880. * @param {Buffer} buffer The buffer to clone.
  36881. * @param {boolean} [isDeep] Specify a deep clone.
  36882. * @returns {Buffer} Returns the cloned buffer.
  36883. */
  36884. function cloneBuffer(buffer, isDeep) {
  36885. if (isDeep) {
  36886. return buffer.slice();
  36887. }
  36888. var length = buffer.length,
  36889. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  36890. buffer.copy(result);
  36891. return result;
  36892. }
  36893. /**
  36894. * Creates a clone of `arrayBuffer`.
  36895. *
  36896. * @private
  36897. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  36898. * @returns {ArrayBuffer} Returns the cloned array buffer.
  36899. */
  36900. function cloneArrayBuffer(arrayBuffer) {
  36901. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  36902. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  36903. return result;
  36904. }
  36905. /**
  36906. * Creates a clone of `dataView`.
  36907. *
  36908. * @private
  36909. * @param {Object} dataView The data view to clone.
  36910. * @param {boolean} [isDeep] Specify a deep clone.
  36911. * @returns {Object} Returns the cloned data view.
  36912. */
  36913. function cloneDataView(dataView, isDeep) {
  36914. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  36915. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  36916. }
  36917. /**
  36918. * Creates a clone of `regexp`.
  36919. *
  36920. * @private
  36921. * @param {Object} regexp The regexp to clone.
  36922. * @returns {Object} Returns the cloned regexp.
  36923. */
  36924. function cloneRegExp(regexp) {
  36925. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  36926. result.lastIndex = regexp.lastIndex;
  36927. return result;
  36928. }
  36929. /**
  36930. * Creates a clone of the `symbol` object.
  36931. *
  36932. * @private
  36933. * @param {Object} symbol The symbol object to clone.
  36934. * @returns {Object} Returns the cloned symbol object.
  36935. */
  36936. function cloneSymbol(symbol) {
  36937. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  36938. }
  36939. /**
  36940. * Creates a clone of `typedArray`.
  36941. *
  36942. * @private
  36943. * @param {Object} typedArray The typed array to clone.
  36944. * @param {boolean} [isDeep] Specify a deep clone.
  36945. * @returns {Object} Returns the cloned typed array.
  36946. */
  36947. function cloneTypedArray(typedArray, isDeep) {
  36948. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  36949. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  36950. }
  36951. /**
  36952. * Compares values to sort them in ascending order.
  36953. *
  36954. * @private
  36955. * @param {*} value The value to compare.
  36956. * @param {*} other The other value to compare.
  36957. * @returns {number} Returns the sort order indicator for `value`.
  36958. */
  36959. function compareAscending(value, other) {
  36960. if (value !== other) {
  36961. var valIsDefined = value !== undefined,
  36962. valIsNull = value === null,
  36963. valIsReflexive = value === value,
  36964. valIsSymbol = isSymbol(value);
  36965. var othIsDefined = other !== undefined,
  36966. othIsNull = other === null,
  36967. othIsReflexive = other === other,
  36968. othIsSymbol = isSymbol(other);
  36969. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  36970. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  36971. (valIsNull && othIsDefined && othIsReflexive) ||
  36972. (!valIsDefined && othIsReflexive) ||
  36973. !valIsReflexive) {
  36974. return 1;
  36975. }
  36976. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  36977. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  36978. (othIsNull && valIsDefined && valIsReflexive) ||
  36979. (!othIsDefined && valIsReflexive) ||
  36980. !othIsReflexive) {
  36981. return -1;
  36982. }
  36983. }
  36984. return 0;
  36985. }
  36986. /**
  36987. * Used by `_.orderBy` to compare multiple properties of a value to another
  36988. * and stable sort them.
  36989. *
  36990. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  36991. * specify an order of "desc" for descending or "asc" for ascending sort order
  36992. * of corresponding values.
  36993. *
  36994. * @private
  36995. * @param {Object} object The object to compare.
  36996. * @param {Object} other The other object to compare.
  36997. * @param {boolean[]|string[]} orders The order to sort by for each property.
  36998. * @returns {number} Returns the sort order indicator for `object`.
  36999. */
  37000. function compareMultiple(object, other, orders) {
  37001. var index = -1,
  37002. objCriteria = object.criteria,
  37003. othCriteria = other.criteria,
  37004. length = objCriteria.length,
  37005. ordersLength = orders.length;
  37006. while (++index < length) {
  37007. var result = compareAscending(objCriteria[index], othCriteria[index]);
  37008. if (result) {
  37009. if (index >= ordersLength) {
  37010. return result;
  37011. }
  37012. var order = orders[index];
  37013. return result * (order == 'desc' ? -1 : 1);
  37014. }
  37015. }
  37016. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  37017. // that causes it, under certain circumstances, to provide the same value for
  37018. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  37019. // for more details.
  37020. //
  37021. // This also ensures a stable sort in V8 and other engines.
  37022. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  37023. return object.index - other.index;
  37024. }
  37025. /**
  37026. * Creates an array that is the composition of partially applied arguments,
  37027. * placeholders, and provided arguments into a single array of arguments.
  37028. *
  37029. * @private
  37030. * @param {Array} args The provided arguments.
  37031. * @param {Array} partials The arguments to prepend to those provided.
  37032. * @param {Array} holders The `partials` placeholder indexes.
  37033. * @params {boolean} [isCurried] Specify composing for a curried function.
  37034. * @returns {Array} Returns the new array of composed arguments.
  37035. */
  37036. function composeArgs(args, partials, holders, isCurried) {
  37037. var argsIndex = -1,
  37038. argsLength = args.length,
  37039. holdersLength = holders.length,
  37040. leftIndex = -1,
  37041. leftLength = partials.length,
  37042. rangeLength = nativeMax(argsLength - holdersLength, 0),
  37043. result = Array(leftLength + rangeLength),
  37044. isUncurried = !isCurried;
  37045. while (++leftIndex < leftLength) {
  37046. result[leftIndex] = partials[leftIndex];
  37047. }
  37048. while (++argsIndex < holdersLength) {
  37049. if (isUncurried || argsIndex < argsLength) {
  37050. result[holders[argsIndex]] = args[argsIndex];
  37051. }
  37052. }
  37053. while (rangeLength--) {
  37054. result[leftIndex++] = args[argsIndex++];
  37055. }
  37056. return result;
  37057. }
  37058. /**
  37059. * This function is like `composeArgs` except that the arguments composition
  37060. * is tailored for `_.partialRight`.
  37061. *
  37062. * @private
  37063. * @param {Array} args The provided arguments.
  37064. * @param {Array} partials The arguments to append to those provided.
  37065. * @param {Array} holders The `partials` placeholder indexes.
  37066. * @params {boolean} [isCurried] Specify composing for a curried function.
  37067. * @returns {Array} Returns the new array of composed arguments.
  37068. */
  37069. function composeArgsRight(args, partials, holders, isCurried) {
  37070. var argsIndex = -1,
  37071. argsLength = args.length,
  37072. holdersIndex = -1,
  37073. holdersLength = holders.length,
  37074. rightIndex = -1,
  37075. rightLength = partials.length,
  37076. rangeLength = nativeMax(argsLength - holdersLength, 0),
  37077. result = Array(rangeLength + rightLength),
  37078. isUncurried = !isCurried;
  37079. while (++argsIndex < rangeLength) {
  37080. result[argsIndex] = args[argsIndex];
  37081. }
  37082. var offset = argsIndex;
  37083. while (++rightIndex < rightLength) {
  37084. result[offset + rightIndex] = partials[rightIndex];
  37085. }
  37086. while (++holdersIndex < holdersLength) {
  37087. if (isUncurried || argsIndex < argsLength) {
  37088. result[offset + holders[holdersIndex]] = args[argsIndex++];
  37089. }
  37090. }
  37091. return result;
  37092. }
  37093. /**
  37094. * Copies the values of `source` to `array`.
  37095. *
  37096. * @private
  37097. * @param {Array} source The array to copy values from.
  37098. * @param {Array} [array=[]] The array to copy values to.
  37099. * @returns {Array} Returns `array`.
  37100. */
  37101. function copyArray(source, array) {
  37102. var index = -1,
  37103. length = source.length;
  37104. array || (array = Array(length));
  37105. while (++index < length) {
  37106. array[index] = source[index];
  37107. }
  37108. return array;
  37109. }
  37110. /**
  37111. * Copies properties of `source` to `object`.
  37112. *
  37113. * @private
  37114. * @param {Object} source The object to copy properties from.
  37115. * @param {Array} props The property identifiers to copy.
  37116. * @param {Object} [object={}] The object to copy properties to.
  37117. * @param {Function} [customizer] The function to customize copied values.
  37118. * @returns {Object} Returns `object`.
  37119. */
  37120. function copyObject(source, props, object, customizer) {
  37121. var isNew = !object;
  37122. object || (object = {});
  37123. var index = -1,
  37124. length = props.length;
  37125. while (++index < length) {
  37126. var key = props[index];
  37127. var newValue = customizer
  37128. ? customizer(object[key], source[key], key, object, source)
  37129. : undefined;
  37130. if (newValue === undefined) {
  37131. newValue = source[key];
  37132. }
  37133. if (isNew) {
  37134. baseAssignValue(object, key, newValue);
  37135. } else {
  37136. assignValue(object, key, newValue);
  37137. }
  37138. }
  37139. return object;
  37140. }
  37141. /**
  37142. * Copies own symbols of `source` to `object`.
  37143. *
  37144. * @private
  37145. * @param {Object} source The object to copy symbols from.
  37146. * @param {Object} [object={}] The object to copy symbols to.
  37147. * @returns {Object} Returns `object`.
  37148. */
  37149. function copySymbols(source, object) {
  37150. return copyObject(source, getSymbols(source), object);
  37151. }
  37152. /**
  37153. * Copies own and inherited symbols of `source` to `object`.
  37154. *
  37155. * @private
  37156. * @param {Object} source The object to copy symbols from.
  37157. * @param {Object} [object={}] The object to copy symbols to.
  37158. * @returns {Object} Returns `object`.
  37159. */
  37160. function copySymbolsIn(source, object) {
  37161. return copyObject(source, getSymbolsIn(source), object);
  37162. }
  37163. /**
  37164. * Creates a function like `_.groupBy`.
  37165. *
  37166. * @private
  37167. * @param {Function} setter The function to set accumulator values.
  37168. * @param {Function} [initializer] The accumulator object initializer.
  37169. * @returns {Function} Returns the new aggregator function.
  37170. */
  37171. function createAggregator(setter, initializer) {
  37172. return function(collection, iteratee) {
  37173. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  37174. accumulator = initializer ? initializer() : {};
  37175. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  37176. };
  37177. }
  37178. /**
  37179. * Creates a function like `_.assign`.
  37180. *
  37181. * @private
  37182. * @param {Function} assigner The function to assign values.
  37183. * @returns {Function} Returns the new assigner function.
  37184. */
  37185. function createAssigner(assigner) {
  37186. return baseRest(function(object, sources) {
  37187. var index = -1,
  37188. length = sources.length,
  37189. customizer = length > 1 ? sources[length - 1] : undefined,
  37190. guard = length > 2 ? sources[2] : undefined;
  37191. customizer = (assigner.length > 3 && typeof customizer == 'function')
  37192. ? (length--, customizer)
  37193. : undefined;
  37194. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  37195. customizer = length < 3 ? undefined : customizer;
  37196. length = 1;
  37197. }
  37198. object = Object(object);
  37199. while (++index < length) {
  37200. var source = sources[index];
  37201. if (source) {
  37202. assigner(object, source, index, customizer);
  37203. }
  37204. }
  37205. return object;
  37206. });
  37207. }
  37208. /**
  37209. * Creates a `baseEach` or `baseEachRight` function.
  37210. *
  37211. * @private
  37212. * @param {Function} eachFunc The function to iterate over a collection.
  37213. * @param {boolean} [fromRight] Specify iterating from right to left.
  37214. * @returns {Function} Returns the new base function.
  37215. */
  37216. function createBaseEach(eachFunc, fromRight) {
  37217. return function(collection, iteratee) {
  37218. if (collection == null) {
  37219. return collection;
  37220. }
  37221. if (!isArrayLike(collection)) {
  37222. return eachFunc(collection, iteratee);
  37223. }
  37224. var length = collection.length,
  37225. index = fromRight ? length : -1,
  37226. iterable = Object(collection);
  37227. while ((fromRight ? index-- : ++index < length)) {
  37228. if (iteratee(iterable[index], index, iterable) === false) {
  37229. break;
  37230. }
  37231. }
  37232. return collection;
  37233. };
  37234. }
  37235. /**
  37236. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  37237. *
  37238. * @private
  37239. * @param {boolean} [fromRight] Specify iterating from right to left.
  37240. * @returns {Function} Returns the new base function.
  37241. */
  37242. function createBaseFor(fromRight) {
  37243. return function(object, iteratee, keysFunc) {
  37244. var index = -1,
  37245. iterable = Object(object),
  37246. props = keysFunc(object),
  37247. length = props.length;
  37248. while (length--) {
  37249. var key = props[fromRight ? length : ++index];
  37250. if (iteratee(iterable[key], key, iterable) === false) {
  37251. break;
  37252. }
  37253. }
  37254. return object;
  37255. };
  37256. }
  37257. /**
  37258. * Creates a function that wraps `func` to invoke it with the optional `this`
  37259. * binding of `thisArg`.
  37260. *
  37261. * @private
  37262. * @param {Function} func The function to wrap.
  37263. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  37264. * @param {*} [thisArg] The `this` binding of `func`.
  37265. * @returns {Function} Returns the new wrapped function.
  37266. */
  37267. function createBind(func, bitmask, thisArg) {
  37268. var isBind = bitmask & WRAP_BIND_FLAG,
  37269. Ctor = createCtor(func);
  37270. function wrapper() {
  37271. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  37272. return fn.apply(isBind ? thisArg : this, arguments);
  37273. }
  37274. return wrapper;
  37275. }
  37276. /**
  37277. * Creates a function like `_.lowerFirst`.
  37278. *
  37279. * @private
  37280. * @param {string} methodName The name of the `String` case method to use.
  37281. * @returns {Function} Returns the new case function.
  37282. */
  37283. function createCaseFirst(methodName) {
  37284. return function(string) {
  37285. string = toString(string);
  37286. var strSymbols = hasUnicode(string)
  37287. ? stringToArray(string)
  37288. : undefined;
  37289. var chr = strSymbols
  37290. ? strSymbols[0]
  37291. : string.charAt(0);
  37292. var trailing = strSymbols
  37293. ? castSlice(strSymbols, 1).join('')
  37294. : string.slice(1);
  37295. return chr[methodName]() + trailing;
  37296. };
  37297. }
  37298. /**
  37299. * Creates a function like `_.camelCase`.
  37300. *
  37301. * @private
  37302. * @param {Function} callback The function to combine each word.
  37303. * @returns {Function} Returns the new compounder function.
  37304. */
  37305. function createCompounder(callback) {
  37306. return function(string) {
  37307. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  37308. };
  37309. }
  37310. /**
  37311. * Creates a function that produces an instance of `Ctor` regardless of
  37312. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  37313. *
  37314. * @private
  37315. * @param {Function} Ctor The constructor to wrap.
  37316. * @returns {Function} Returns the new wrapped function.
  37317. */
  37318. function createCtor(Ctor) {
  37319. return function() {
  37320. // Use a `switch` statement to work with class constructors. See
  37321. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  37322. // for more details.
  37323. var args = arguments;
  37324. switch (args.length) {
  37325. case 0: return new Ctor;
  37326. case 1: return new Ctor(args[0]);
  37327. case 2: return new Ctor(args[0], args[1]);
  37328. case 3: return new Ctor(args[0], args[1], args[2]);
  37329. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  37330. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  37331. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  37332. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  37333. }
  37334. var thisBinding = baseCreate(Ctor.prototype),
  37335. result = Ctor.apply(thisBinding, args);
  37336. // Mimic the constructor's `return` behavior.
  37337. // See https://es5.github.io/#x13.2.2 for more details.
  37338. return isObject(result) ? result : thisBinding;
  37339. };
  37340. }
  37341. /**
  37342. * Creates a function that wraps `func` to enable currying.
  37343. *
  37344. * @private
  37345. * @param {Function} func The function to wrap.
  37346. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  37347. * @param {number} arity The arity of `func`.
  37348. * @returns {Function} Returns the new wrapped function.
  37349. */
  37350. function createCurry(func, bitmask, arity) {
  37351. var Ctor = createCtor(func);
  37352. function wrapper() {
  37353. var length = arguments.length,
  37354. args = Array(length),
  37355. index = length,
  37356. placeholder = getHolder(wrapper);
  37357. while (index--) {
  37358. args[index] = arguments[index];
  37359. }
  37360. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  37361. ? []
  37362. : replaceHolders(args, placeholder);
  37363. length -= holders.length;
  37364. if (length < arity) {
  37365. return createRecurry(
  37366. func, bitmask, createHybrid, wrapper.placeholder, undefined,
  37367. args, holders, undefined, undefined, arity - length);
  37368. }
  37369. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  37370. return apply(fn, this, args);
  37371. }
  37372. return wrapper;
  37373. }
  37374. /**
  37375. * Creates a `_.find` or `_.findLast` function.
  37376. *
  37377. * @private
  37378. * @param {Function} findIndexFunc The function to find the collection index.
  37379. * @returns {Function} Returns the new find function.
  37380. */
  37381. function createFind(findIndexFunc) {
  37382. return function(collection, predicate, fromIndex) {
  37383. var iterable = Object(collection);
  37384. if (!isArrayLike(collection)) {
  37385. var iteratee = getIteratee(predicate, 3);
  37386. collection = keys(collection);
  37387. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  37388. }
  37389. var index = findIndexFunc(collection, predicate, fromIndex);
  37390. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  37391. };
  37392. }
  37393. /**
  37394. * Creates a `_.flow` or `_.flowRight` function.
  37395. *
  37396. * @private
  37397. * @param {boolean} [fromRight] Specify iterating from right to left.
  37398. * @returns {Function} Returns the new flow function.
  37399. */
  37400. function createFlow(fromRight) {
  37401. return flatRest(function(funcs) {
  37402. var length = funcs.length,
  37403. index = length,
  37404. prereq = LodashWrapper.prototype.thru;
  37405. if (fromRight) {
  37406. funcs.reverse();
  37407. }
  37408. while (index--) {
  37409. var func = funcs[index];
  37410. if (typeof func != 'function') {
  37411. throw new TypeError(FUNC_ERROR_TEXT);
  37412. }
  37413. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  37414. var wrapper = new LodashWrapper([], true);
  37415. }
  37416. }
  37417. index = wrapper ? index : length;
  37418. while (++index < length) {
  37419. func = funcs[index];
  37420. var funcName = getFuncName(func),
  37421. data = funcName == 'wrapper' ? getData(func) : undefined;
  37422. if (data && isLaziable(data[0]) &&
  37423. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  37424. !data[4].length && data[9] == 1
  37425. ) {
  37426. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  37427. } else {
  37428. wrapper = (func.length == 1 && isLaziable(func))
  37429. ? wrapper[funcName]()
  37430. : wrapper.thru(func);
  37431. }
  37432. }
  37433. return function() {
  37434. var args = arguments,
  37435. value = args[0];
  37436. if (wrapper && args.length == 1 && isArray(value)) {
  37437. return wrapper.plant(value).value();
  37438. }
  37439. var index = 0,
  37440. result = length ? funcs[index].apply(this, args) : value;
  37441. while (++index < length) {
  37442. result = funcs[index].call(this, result);
  37443. }
  37444. return result;
  37445. };
  37446. });
  37447. }
  37448. /**
  37449. * Creates a function that wraps `func` to invoke it with optional `this`
  37450. * binding of `thisArg`, partial application, and currying.
  37451. *
  37452. * @private
  37453. * @param {Function|string} func The function or method name to wrap.
  37454. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  37455. * @param {*} [thisArg] The `this` binding of `func`.
  37456. * @param {Array} [partials] The arguments to prepend to those provided to
  37457. * the new function.
  37458. * @param {Array} [holders] The `partials` placeholder indexes.
  37459. * @param {Array} [partialsRight] The arguments to append to those provided
  37460. * to the new function.
  37461. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  37462. * @param {Array} [argPos] The argument positions of the new function.
  37463. * @param {number} [ary] The arity cap of `func`.
  37464. * @param {number} [arity] The arity of `func`.
  37465. * @returns {Function} Returns the new wrapped function.
  37466. */
  37467. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  37468. var isAry = bitmask & WRAP_ARY_FLAG,
  37469. isBind = bitmask & WRAP_BIND_FLAG,
  37470. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  37471. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  37472. isFlip = bitmask & WRAP_FLIP_FLAG,
  37473. Ctor = isBindKey ? undefined : createCtor(func);
  37474. function wrapper() {
  37475. var length = arguments.length,
  37476. args = Array(length),
  37477. index = length;
  37478. while (index--) {
  37479. args[index] = arguments[index];
  37480. }
  37481. if (isCurried) {
  37482. var placeholder = getHolder(wrapper),
  37483. holdersCount = countHolders(args, placeholder);
  37484. }
  37485. if (partials) {
  37486. args = composeArgs(args, partials, holders, isCurried);
  37487. }
  37488. if (partialsRight) {
  37489. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  37490. }
  37491. length -= holdersCount;
  37492. if (isCurried && length < arity) {
  37493. var newHolders = replaceHolders(args, placeholder);
  37494. return createRecurry(
  37495. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  37496. args, newHolders, argPos, ary, arity - length
  37497. );
  37498. }
  37499. var thisBinding = isBind ? thisArg : this,
  37500. fn = isBindKey ? thisBinding[func] : func;
  37501. length = args.length;
  37502. if (argPos) {
  37503. args = reorder(args, argPos);
  37504. } else if (isFlip && length > 1) {
  37505. args.reverse();
  37506. }
  37507. if (isAry && ary < length) {
  37508. args.length = ary;
  37509. }
  37510. if (this && this !== root && this instanceof wrapper) {
  37511. fn = Ctor || createCtor(fn);
  37512. }
  37513. return fn.apply(thisBinding, args);
  37514. }
  37515. return wrapper;
  37516. }
  37517. /**
  37518. * Creates a function like `_.invertBy`.
  37519. *
  37520. * @private
  37521. * @param {Function} setter The function to set accumulator values.
  37522. * @param {Function} toIteratee The function to resolve iteratees.
  37523. * @returns {Function} Returns the new inverter function.
  37524. */
  37525. function createInverter(setter, toIteratee) {
  37526. return function(object, iteratee) {
  37527. return baseInverter(object, setter, toIteratee(iteratee), {});
  37528. };
  37529. }
  37530. /**
  37531. * Creates a function that performs a mathematical operation on two values.
  37532. *
  37533. * @private
  37534. * @param {Function} operator The function to perform the operation.
  37535. * @param {number} [defaultValue] The value used for `undefined` arguments.
  37536. * @returns {Function} Returns the new mathematical operation function.
  37537. */
  37538. function createMathOperation(operator, defaultValue) {
  37539. return function(value, other) {
  37540. var result;
  37541. if (value === undefined && other === undefined) {
  37542. return defaultValue;
  37543. }
  37544. if (value !== undefined) {
  37545. result = value;
  37546. }
  37547. if (other !== undefined) {
  37548. if (result === undefined) {
  37549. return other;
  37550. }
  37551. if (typeof value == 'string' || typeof other == 'string') {
  37552. value = baseToString(value);
  37553. other = baseToString(other);
  37554. } else {
  37555. value = baseToNumber(value);
  37556. other = baseToNumber(other);
  37557. }
  37558. result = operator(value, other);
  37559. }
  37560. return result;
  37561. };
  37562. }
  37563. /**
  37564. * Creates a function like `_.over`.
  37565. *
  37566. * @private
  37567. * @param {Function} arrayFunc The function to iterate over iteratees.
  37568. * @returns {Function} Returns the new over function.
  37569. */
  37570. function createOver(arrayFunc) {
  37571. return flatRest(function(iteratees) {
  37572. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  37573. return baseRest(function(args) {
  37574. var thisArg = this;
  37575. return arrayFunc(iteratees, function(iteratee) {
  37576. return apply(iteratee, thisArg, args);
  37577. });
  37578. });
  37579. });
  37580. }
  37581. /**
  37582. * Creates the padding for `string` based on `length`. The `chars` string
  37583. * is truncated if the number of characters exceeds `length`.
  37584. *
  37585. * @private
  37586. * @param {number} length The padding length.
  37587. * @param {string} [chars=' '] The string used as padding.
  37588. * @returns {string} Returns the padding for `string`.
  37589. */
  37590. function createPadding(length, chars) {
  37591. chars = chars === undefined ? ' ' : baseToString(chars);
  37592. var charsLength = chars.length;
  37593. if (charsLength < 2) {
  37594. return charsLength ? baseRepeat(chars, length) : chars;
  37595. }
  37596. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  37597. return hasUnicode(chars)
  37598. ? castSlice(stringToArray(result), 0, length).join('')
  37599. : result.slice(0, length);
  37600. }
  37601. /**
  37602. * Creates a function that wraps `func` to invoke it with the `this` binding
  37603. * of `thisArg` and `partials` prepended to the arguments it receives.
  37604. *
  37605. * @private
  37606. * @param {Function} func The function to wrap.
  37607. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  37608. * @param {*} thisArg The `this` binding of `func`.
  37609. * @param {Array} partials The arguments to prepend to those provided to
  37610. * the new function.
  37611. * @returns {Function} Returns the new wrapped function.
  37612. */
  37613. function createPartial(func, bitmask, thisArg, partials) {
  37614. var isBind = bitmask & WRAP_BIND_FLAG,
  37615. Ctor = createCtor(func);
  37616. function wrapper() {
  37617. var argsIndex = -1,
  37618. argsLength = arguments.length,
  37619. leftIndex = -1,
  37620. leftLength = partials.length,
  37621. args = Array(leftLength + argsLength),
  37622. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  37623. while (++leftIndex < leftLength) {
  37624. args[leftIndex] = partials[leftIndex];
  37625. }
  37626. while (argsLength--) {
  37627. args[leftIndex++] = arguments[++argsIndex];
  37628. }
  37629. return apply(fn, isBind ? thisArg : this, args);
  37630. }
  37631. return wrapper;
  37632. }
  37633. /**
  37634. * Creates a `_.range` or `_.rangeRight` function.
  37635. *
  37636. * @private
  37637. * @param {boolean} [fromRight] Specify iterating from right to left.
  37638. * @returns {Function} Returns the new range function.
  37639. */
  37640. function createRange(fromRight) {
  37641. return function(start, end, step) {
  37642. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  37643. end = step = undefined;
  37644. }
  37645. // Ensure the sign of `-0` is preserved.
  37646. start = toFinite(start);
  37647. if (end === undefined) {
  37648. end = start;
  37649. start = 0;
  37650. } else {
  37651. end = toFinite(end);
  37652. }
  37653. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  37654. return baseRange(start, end, step, fromRight);
  37655. };
  37656. }
  37657. /**
  37658. * Creates a function that performs a relational operation on two values.
  37659. *
  37660. * @private
  37661. * @param {Function} operator The function to perform the operation.
  37662. * @returns {Function} Returns the new relational operation function.
  37663. */
  37664. function createRelationalOperation(operator) {
  37665. return function(value, other) {
  37666. if (!(typeof value == 'string' && typeof other == 'string')) {
  37667. value = toNumber(value);
  37668. other = toNumber(other);
  37669. }
  37670. return operator(value, other);
  37671. };
  37672. }
  37673. /**
  37674. * Creates a function that wraps `func` to continue currying.
  37675. *
  37676. * @private
  37677. * @param {Function} func The function to wrap.
  37678. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  37679. * @param {Function} wrapFunc The function to create the `func` wrapper.
  37680. * @param {*} placeholder The placeholder value.
  37681. * @param {*} [thisArg] The `this` binding of `func`.
  37682. * @param {Array} [partials] The arguments to prepend to those provided to
  37683. * the new function.
  37684. * @param {Array} [holders] The `partials` placeholder indexes.
  37685. * @param {Array} [argPos] The argument positions of the new function.
  37686. * @param {number} [ary] The arity cap of `func`.
  37687. * @param {number} [arity] The arity of `func`.
  37688. * @returns {Function} Returns the new wrapped function.
  37689. */
  37690. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  37691. var isCurry = bitmask & WRAP_CURRY_FLAG,
  37692. newHolders = isCurry ? holders : undefined,
  37693. newHoldersRight = isCurry ? undefined : holders,
  37694. newPartials = isCurry ? partials : undefined,
  37695. newPartialsRight = isCurry ? undefined : partials;
  37696. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  37697. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  37698. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  37699. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  37700. }
  37701. var newData = [
  37702. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  37703. newHoldersRight, argPos, ary, arity
  37704. ];
  37705. var result = wrapFunc.apply(undefined, newData);
  37706. if (isLaziable(func)) {
  37707. setData(result, newData);
  37708. }
  37709. result.placeholder = placeholder;
  37710. return setWrapToString(result, func, bitmask);
  37711. }
  37712. /**
  37713. * Creates a function like `_.round`.
  37714. *
  37715. * @private
  37716. * @param {string} methodName The name of the `Math` method to use when rounding.
  37717. * @returns {Function} Returns the new round function.
  37718. */
  37719. function createRound(methodName) {
  37720. var func = Math[methodName];
  37721. return function(number, precision) {
  37722. number = toNumber(number);
  37723. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  37724. if (precision && nativeIsFinite(number)) {
  37725. // Shift with exponential notation to avoid floating-point issues.
  37726. // See [MDN](https://mdn.io/round#Examples) for more details.
  37727. var pair = (toString(number) + 'e').split('e'),
  37728. value = func(pair[0] + 'e' + (+pair[1] + precision));
  37729. pair = (toString(value) + 'e').split('e');
  37730. return +(pair[0] + 'e' + (+pair[1] - precision));
  37731. }
  37732. return func(number);
  37733. };
  37734. }
  37735. /**
  37736. * Creates a set object of `values`.
  37737. *
  37738. * @private
  37739. * @param {Array} values The values to add to the set.
  37740. * @returns {Object} Returns the new set.
  37741. */
  37742. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  37743. return new Set(values);
  37744. };
  37745. /**
  37746. * Creates a `_.toPairs` or `_.toPairsIn` function.
  37747. *
  37748. * @private
  37749. * @param {Function} keysFunc The function to get the keys of a given object.
  37750. * @returns {Function} Returns the new pairs function.
  37751. */
  37752. function createToPairs(keysFunc) {
  37753. return function(object) {
  37754. var tag = getTag(object);
  37755. if (tag == mapTag) {
  37756. return mapToArray(object);
  37757. }
  37758. if (tag == setTag) {
  37759. return setToPairs(object);
  37760. }
  37761. return baseToPairs(object, keysFunc(object));
  37762. };
  37763. }
  37764. /**
  37765. * Creates a function that either curries or invokes `func` with optional
  37766. * `this` binding and partially applied arguments.
  37767. *
  37768. * @private
  37769. * @param {Function|string} func The function or method name to wrap.
  37770. * @param {number} bitmask The bitmask flags.
  37771. * 1 - `_.bind`
  37772. * 2 - `_.bindKey`
  37773. * 4 - `_.curry` or `_.curryRight` of a bound function
  37774. * 8 - `_.curry`
  37775. * 16 - `_.curryRight`
  37776. * 32 - `_.partial`
  37777. * 64 - `_.partialRight`
  37778. * 128 - `_.rearg`
  37779. * 256 - `_.ary`
  37780. * 512 - `_.flip`
  37781. * @param {*} [thisArg] The `this` binding of `func`.
  37782. * @param {Array} [partials] The arguments to be partially applied.
  37783. * @param {Array} [holders] The `partials` placeholder indexes.
  37784. * @param {Array} [argPos] The argument positions of the new function.
  37785. * @param {number} [ary] The arity cap of `func`.
  37786. * @param {number} [arity] The arity of `func`.
  37787. * @returns {Function} Returns the new wrapped function.
  37788. */
  37789. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  37790. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  37791. if (!isBindKey && typeof func != 'function') {
  37792. throw new TypeError(FUNC_ERROR_TEXT);
  37793. }
  37794. var length = partials ? partials.length : 0;
  37795. if (!length) {
  37796. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  37797. partials = holders = undefined;
  37798. }
  37799. ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
  37800. arity = arity === undefined ? arity : toInteger(arity);
  37801. length -= holders ? holders.length : 0;
  37802. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  37803. var partialsRight = partials,
  37804. holdersRight = holders;
  37805. partials = holders = undefined;
  37806. }
  37807. var data = isBindKey ? undefined : getData(func);
  37808. var newData = [
  37809. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  37810. argPos, ary, arity
  37811. ];
  37812. if (data) {
  37813. mergeData(newData, data);
  37814. }
  37815. func = newData[0];
  37816. bitmask = newData[1];
  37817. thisArg = newData[2];
  37818. partials = newData[3];
  37819. holders = newData[4];
  37820. arity = newData[9] = newData[9] === undefined
  37821. ? (isBindKey ? 0 : func.length)
  37822. : nativeMax(newData[9] - length, 0);
  37823. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  37824. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  37825. }
  37826. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  37827. var result = createBind(func, bitmask, thisArg);
  37828. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  37829. result = createCurry(func, bitmask, arity);
  37830. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  37831. result = createPartial(func, bitmask, thisArg, partials);
  37832. } else {
  37833. result = createHybrid.apply(undefined, newData);
  37834. }
  37835. var setter = data ? baseSetData : setData;
  37836. return setWrapToString(setter(result, newData), func, bitmask);
  37837. }
  37838. /**
  37839. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  37840. * of source objects to the destination object for all destination properties
  37841. * that resolve to `undefined`.
  37842. *
  37843. * @private
  37844. * @param {*} objValue The destination value.
  37845. * @param {*} srcValue The source value.
  37846. * @param {string} key The key of the property to assign.
  37847. * @param {Object} object The parent object of `objValue`.
  37848. * @returns {*} Returns the value to assign.
  37849. */
  37850. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  37851. if (objValue === undefined ||
  37852. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  37853. return srcValue;
  37854. }
  37855. return objValue;
  37856. }
  37857. /**
  37858. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  37859. * objects into destination objects that are passed thru.
  37860. *
  37861. * @private
  37862. * @param {*} objValue The destination value.
  37863. * @param {*} srcValue The source value.
  37864. * @param {string} key The key of the property to merge.
  37865. * @param {Object} object The parent object of `objValue`.
  37866. * @param {Object} source The parent object of `srcValue`.
  37867. * @param {Object} [stack] Tracks traversed source values and their merged
  37868. * counterparts.
  37869. * @returns {*} Returns the value to assign.
  37870. */
  37871. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  37872. if (isObject(objValue) && isObject(srcValue)) {
  37873. // Recursively merge objects and arrays (susceptible to call stack limits).
  37874. stack.set(srcValue, objValue);
  37875. baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
  37876. stack['delete'](srcValue);
  37877. }
  37878. return objValue;
  37879. }
  37880. /**
  37881. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  37882. * objects.
  37883. *
  37884. * @private
  37885. * @param {*} value The value to inspect.
  37886. * @param {string} key The key of the property to inspect.
  37887. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  37888. */
  37889. function customOmitClone(value) {
  37890. return isPlainObject(value) ? undefined : value;
  37891. }
  37892. /**
  37893. * A specialized version of `baseIsEqualDeep` for arrays with support for
  37894. * partial deep comparisons.
  37895. *
  37896. * @private
  37897. * @param {Array} array The array to compare.
  37898. * @param {Array} other The other array to compare.
  37899. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  37900. * @param {Function} customizer The function to customize comparisons.
  37901. * @param {Function} equalFunc The function to determine equivalents of values.
  37902. * @param {Object} stack Tracks traversed `array` and `other` objects.
  37903. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  37904. */
  37905. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  37906. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  37907. arrLength = array.length,
  37908. othLength = other.length;
  37909. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  37910. return false;
  37911. }
  37912. // Check that cyclic values are equal.
  37913. var arrStacked = stack.get(array);
  37914. var othStacked = stack.get(other);
  37915. if (arrStacked && othStacked) {
  37916. return arrStacked == other && othStacked == array;
  37917. }
  37918. var index = -1,
  37919. result = true,
  37920. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  37921. stack.set(array, other);
  37922. stack.set(other, array);
  37923. // Ignore non-index properties.
  37924. while (++index < arrLength) {
  37925. var arrValue = array[index],
  37926. othValue = other[index];
  37927. if (customizer) {
  37928. var compared = isPartial
  37929. ? customizer(othValue, arrValue, index, other, array, stack)
  37930. : customizer(arrValue, othValue, index, array, other, stack);
  37931. }
  37932. if (compared !== undefined) {
  37933. if (compared) {
  37934. continue;
  37935. }
  37936. result = false;
  37937. break;
  37938. }
  37939. // Recursively compare arrays (susceptible to call stack limits).
  37940. if (seen) {
  37941. if (!arraySome(other, function(othValue, othIndex) {
  37942. if (!cacheHas(seen, othIndex) &&
  37943. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  37944. return seen.push(othIndex);
  37945. }
  37946. })) {
  37947. result = false;
  37948. break;
  37949. }
  37950. } else if (!(
  37951. arrValue === othValue ||
  37952. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  37953. )) {
  37954. result = false;
  37955. break;
  37956. }
  37957. }
  37958. stack['delete'](array);
  37959. stack['delete'](other);
  37960. return result;
  37961. }
  37962. /**
  37963. * A specialized version of `baseIsEqualDeep` for comparing objects of
  37964. * the same `toStringTag`.
  37965. *
  37966. * **Note:** This function only supports comparing values with tags of
  37967. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  37968. *
  37969. * @private
  37970. * @param {Object} object The object to compare.
  37971. * @param {Object} other The other object to compare.
  37972. * @param {string} tag The `toStringTag` of the objects to compare.
  37973. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  37974. * @param {Function} customizer The function to customize comparisons.
  37975. * @param {Function} equalFunc The function to determine equivalents of values.
  37976. * @param {Object} stack Tracks traversed `object` and `other` objects.
  37977. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  37978. */
  37979. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  37980. switch (tag) {
  37981. case dataViewTag:
  37982. if ((object.byteLength != other.byteLength) ||
  37983. (object.byteOffset != other.byteOffset)) {
  37984. return false;
  37985. }
  37986. object = object.buffer;
  37987. other = other.buffer;
  37988. case arrayBufferTag:
  37989. if ((object.byteLength != other.byteLength) ||
  37990. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  37991. return false;
  37992. }
  37993. return true;
  37994. case boolTag:
  37995. case dateTag:
  37996. case numberTag:
  37997. // Coerce booleans to `1` or `0` and dates to milliseconds.
  37998. // Invalid dates are coerced to `NaN`.
  37999. return eq(+object, +other);
  38000. case errorTag:
  38001. return object.name == other.name && object.message == other.message;
  38002. case regexpTag:
  38003. case stringTag:
  38004. // Coerce regexes to strings and treat strings, primitives and objects,
  38005. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  38006. // for more details.
  38007. return object == (other + '');
  38008. case mapTag:
  38009. var convert = mapToArray;
  38010. case setTag:
  38011. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  38012. convert || (convert = setToArray);
  38013. if (object.size != other.size && !isPartial) {
  38014. return false;
  38015. }
  38016. // Assume cyclic values are equal.
  38017. var stacked = stack.get(object);
  38018. if (stacked) {
  38019. return stacked == other;
  38020. }
  38021. bitmask |= COMPARE_UNORDERED_FLAG;
  38022. // Recursively compare objects (susceptible to call stack limits).
  38023. stack.set(object, other);
  38024. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  38025. stack['delete'](object);
  38026. return result;
  38027. case symbolTag:
  38028. if (symbolValueOf) {
  38029. return symbolValueOf.call(object) == symbolValueOf.call(other);
  38030. }
  38031. }
  38032. return false;
  38033. }
  38034. /**
  38035. * A specialized version of `baseIsEqualDeep` for objects with support for
  38036. * partial deep comparisons.
  38037. *
  38038. * @private
  38039. * @param {Object} object The object to compare.
  38040. * @param {Object} other The other object to compare.
  38041. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  38042. * @param {Function} customizer The function to customize comparisons.
  38043. * @param {Function} equalFunc The function to determine equivalents of values.
  38044. * @param {Object} stack Tracks traversed `object` and `other` objects.
  38045. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  38046. */
  38047. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  38048. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  38049. objProps = getAllKeys(object),
  38050. objLength = objProps.length,
  38051. othProps = getAllKeys(other),
  38052. othLength = othProps.length;
  38053. if (objLength != othLength && !isPartial) {
  38054. return false;
  38055. }
  38056. var index = objLength;
  38057. while (index--) {
  38058. var key = objProps[index];
  38059. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  38060. return false;
  38061. }
  38062. }
  38063. // Check that cyclic values are equal.
  38064. var objStacked = stack.get(object);
  38065. var othStacked = stack.get(other);
  38066. if (objStacked && othStacked) {
  38067. return objStacked == other && othStacked == object;
  38068. }
  38069. var result = true;
  38070. stack.set(object, other);
  38071. stack.set(other, object);
  38072. var skipCtor = isPartial;
  38073. while (++index < objLength) {
  38074. key = objProps[index];
  38075. var objValue = object[key],
  38076. othValue = other[key];
  38077. if (customizer) {
  38078. var compared = isPartial
  38079. ? customizer(othValue, objValue, key, other, object, stack)
  38080. : customizer(objValue, othValue, key, object, other, stack);
  38081. }
  38082. // Recursively compare objects (susceptible to call stack limits).
  38083. if (!(compared === undefined
  38084. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  38085. : compared
  38086. )) {
  38087. result = false;
  38088. break;
  38089. }
  38090. skipCtor || (skipCtor = key == 'constructor');
  38091. }
  38092. if (result && !skipCtor) {
  38093. var objCtor = object.constructor,
  38094. othCtor = other.constructor;
  38095. // Non `Object` object instances with different constructors are not equal.
  38096. if (objCtor != othCtor &&
  38097. ('constructor' in object && 'constructor' in other) &&
  38098. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  38099. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  38100. result = false;
  38101. }
  38102. }
  38103. stack['delete'](object);
  38104. stack['delete'](other);
  38105. return result;
  38106. }
  38107. /**
  38108. * A specialized version of `baseRest` which flattens the rest array.
  38109. *
  38110. * @private
  38111. * @param {Function} func The function to apply a rest parameter to.
  38112. * @returns {Function} Returns the new function.
  38113. */
  38114. function flatRest(func) {
  38115. return setToString(overRest(func, undefined, flatten), func + '');
  38116. }
  38117. /**
  38118. * Creates an array of own enumerable property names and symbols of `object`.
  38119. *
  38120. * @private
  38121. * @param {Object} object The object to query.
  38122. * @returns {Array} Returns the array of property names and symbols.
  38123. */
  38124. function getAllKeys(object) {
  38125. return baseGetAllKeys(object, keys, getSymbols);
  38126. }
  38127. /**
  38128. * Creates an array of own and inherited enumerable property names and
  38129. * symbols of `object`.
  38130. *
  38131. * @private
  38132. * @param {Object} object The object to query.
  38133. * @returns {Array} Returns the array of property names and symbols.
  38134. */
  38135. function getAllKeysIn(object) {
  38136. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  38137. }
  38138. /**
  38139. * Gets metadata for `func`.
  38140. *
  38141. * @private
  38142. * @param {Function} func The function to query.
  38143. * @returns {*} Returns the metadata for `func`.
  38144. */
  38145. var getData = !metaMap ? noop : function(func) {
  38146. return metaMap.get(func);
  38147. };
  38148. /**
  38149. * Gets the name of `func`.
  38150. *
  38151. * @private
  38152. * @param {Function} func The function to query.
  38153. * @returns {string} Returns the function name.
  38154. */
  38155. function getFuncName(func) {
  38156. var result = (func.name + ''),
  38157. array = realNames[result],
  38158. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  38159. while (length--) {
  38160. var data = array[length],
  38161. otherFunc = data.func;
  38162. if (otherFunc == null || otherFunc == func) {
  38163. return data.name;
  38164. }
  38165. }
  38166. return result;
  38167. }
  38168. /**
  38169. * Gets the argument placeholder value for `func`.
  38170. *
  38171. * @private
  38172. * @param {Function} func The function to inspect.
  38173. * @returns {*} Returns the placeholder value.
  38174. */
  38175. function getHolder(func) {
  38176. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  38177. return object.placeholder;
  38178. }
  38179. /**
  38180. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  38181. * this function returns the custom method, otherwise it returns `baseIteratee`.
  38182. * If arguments are provided, the chosen function is invoked with them and
  38183. * its result is returned.
  38184. *
  38185. * @private
  38186. * @param {*} [value] The value to convert to an iteratee.
  38187. * @param {number} [arity] The arity of the created iteratee.
  38188. * @returns {Function} Returns the chosen function or its result.
  38189. */
  38190. function getIteratee() {
  38191. var result = lodash.iteratee || iteratee;
  38192. result = result === iteratee ? baseIteratee : result;
  38193. return arguments.length ? result(arguments[0], arguments[1]) : result;
  38194. }
  38195. /**
  38196. * Gets the data for `map`.
  38197. *
  38198. * @private
  38199. * @param {Object} map The map to query.
  38200. * @param {string} key The reference key.
  38201. * @returns {*} Returns the map data.
  38202. */
  38203. function getMapData(map, key) {
  38204. var data = map.__data__;
  38205. return isKeyable(key)
  38206. ? data[typeof key == 'string' ? 'string' : 'hash']
  38207. : data.map;
  38208. }
  38209. /**
  38210. * Gets the property names, values, and compare flags of `object`.
  38211. *
  38212. * @private
  38213. * @param {Object} object The object to query.
  38214. * @returns {Array} Returns the match data of `object`.
  38215. */
  38216. function getMatchData(object) {
  38217. var result = keys(object),
  38218. length = result.length;
  38219. while (length--) {
  38220. var key = result[length],
  38221. value = object[key];
  38222. result[length] = [key, value, isStrictComparable(value)];
  38223. }
  38224. return result;
  38225. }
  38226. /**
  38227. * Gets the native function at `key` of `object`.
  38228. *
  38229. * @private
  38230. * @param {Object} object The object to query.
  38231. * @param {string} key The key of the method to get.
  38232. * @returns {*} Returns the function if it's native, else `undefined`.
  38233. */
  38234. function getNative(object, key) {
  38235. var value = getValue(object, key);
  38236. return baseIsNative(value) ? value : undefined;
  38237. }
  38238. /**
  38239. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  38240. *
  38241. * @private
  38242. * @param {*} value The value to query.
  38243. * @returns {string} Returns the raw `toStringTag`.
  38244. */
  38245. function getRawTag(value) {
  38246. var isOwn = hasOwnProperty.call(value, symToStringTag),
  38247. tag = value[symToStringTag];
  38248. try {
  38249. value[symToStringTag] = undefined;
  38250. var unmasked = true;
  38251. } catch (e) {}
  38252. var result = nativeObjectToString.call(value);
  38253. if (unmasked) {
  38254. if (isOwn) {
  38255. value[symToStringTag] = tag;
  38256. } else {
  38257. delete value[symToStringTag];
  38258. }
  38259. }
  38260. return result;
  38261. }
  38262. /**
  38263. * Creates an array of the own enumerable symbols of `object`.
  38264. *
  38265. * @private
  38266. * @param {Object} object The object to query.
  38267. * @returns {Array} Returns the array of symbols.
  38268. */
  38269. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  38270. if (object == null) {
  38271. return [];
  38272. }
  38273. object = Object(object);
  38274. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  38275. return propertyIsEnumerable.call(object, symbol);
  38276. });
  38277. };
  38278. /**
  38279. * Creates an array of the own and inherited enumerable symbols of `object`.
  38280. *
  38281. * @private
  38282. * @param {Object} object The object to query.
  38283. * @returns {Array} Returns the array of symbols.
  38284. */
  38285. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  38286. var result = [];
  38287. while (object) {
  38288. arrayPush(result, getSymbols(object));
  38289. object = getPrototype(object);
  38290. }
  38291. return result;
  38292. };
  38293. /**
  38294. * Gets the `toStringTag` of `value`.
  38295. *
  38296. * @private
  38297. * @param {*} value The value to query.
  38298. * @returns {string} Returns the `toStringTag`.
  38299. */
  38300. var getTag = baseGetTag;
  38301. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  38302. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  38303. (Map && getTag(new Map) != mapTag) ||
  38304. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  38305. (Set && getTag(new Set) != setTag) ||
  38306. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  38307. getTag = function(value) {
  38308. var result = baseGetTag(value),
  38309. Ctor = result == objectTag ? value.constructor : undefined,
  38310. ctorString = Ctor ? toSource(Ctor) : '';
  38311. if (ctorString) {
  38312. switch (ctorString) {
  38313. case dataViewCtorString: return dataViewTag;
  38314. case mapCtorString: return mapTag;
  38315. case promiseCtorString: return promiseTag;
  38316. case setCtorString: return setTag;
  38317. case weakMapCtorString: return weakMapTag;
  38318. }
  38319. }
  38320. return result;
  38321. };
  38322. }
  38323. /**
  38324. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  38325. *
  38326. * @private
  38327. * @param {number} start The start of the view.
  38328. * @param {number} end The end of the view.
  38329. * @param {Array} transforms The transformations to apply to the view.
  38330. * @returns {Object} Returns an object containing the `start` and `end`
  38331. * positions of the view.
  38332. */
  38333. function getView(start, end, transforms) {
  38334. var index = -1,
  38335. length = transforms.length;
  38336. while (++index < length) {
  38337. var data = transforms[index],
  38338. size = data.size;
  38339. switch (data.type) {
  38340. case 'drop': start += size; break;
  38341. case 'dropRight': end -= size; break;
  38342. case 'take': end = nativeMin(end, start + size); break;
  38343. case 'takeRight': start = nativeMax(start, end - size); break;
  38344. }
  38345. }
  38346. return { 'start': start, 'end': end };
  38347. }
  38348. /**
  38349. * Extracts wrapper details from the `source` body comment.
  38350. *
  38351. * @private
  38352. * @param {string} source The source to inspect.
  38353. * @returns {Array} Returns the wrapper details.
  38354. */
  38355. function getWrapDetails(source) {
  38356. var match = source.match(reWrapDetails);
  38357. return match ? match[1].split(reSplitDetails) : [];
  38358. }
  38359. /**
  38360. * Checks if `path` exists on `object`.
  38361. *
  38362. * @private
  38363. * @param {Object} object The object to query.
  38364. * @param {Array|string} path The path to check.
  38365. * @param {Function} hasFunc The function to check properties.
  38366. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  38367. */
  38368. function hasPath(object, path, hasFunc) {
  38369. path = castPath(path, object);
  38370. var index = -1,
  38371. length = path.length,
  38372. result = false;
  38373. while (++index < length) {
  38374. var key = toKey(path[index]);
  38375. if (!(result = object != null && hasFunc(object, key))) {
  38376. break;
  38377. }
  38378. object = object[key];
  38379. }
  38380. if (result || ++index != length) {
  38381. return result;
  38382. }
  38383. length = object == null ? 0 : object.length;
  38384. return !!length && isLength(length) && isIndex(key, length) &&
  38385. (isArray(object) || isArguments(object));
  38386. }
  38387. /**
  38388. * Initializes an array clone.
  38389. *
  38390. * @private
  38391. * @param {Array} array The array to clone.
  38392. * @returns {Array} Returns the initialized clone.
  38393. */
  38394. function initCloneArray(array) {
  38395. var length = array.length,
  38396. result = new array.constructor(length);
  38397. // Add properties assigned by `RegExp#exec`.
  38398. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  38399. result.index = array.index;
  38400. result.input = array.input;
  38401. }
  38402. return result;
  38403. }
  38404. /**
  38405. * Initializes an object clone.
  38406. *
  38407. * @private
  38408. * @param {Object} object The object to clone.
  38409. * @returns {Object} Returns the initialized clone.
  38410. */
  38411. function initCloneObject(object) {
  38412. return (typeof object.constructor == 'function' && !isPrototype(object))
  38413. ? baseCreate(getPrototype(object))
  38414. : {};
  38415. }
  38416. /**
  38417. * Initializes an object clone based on its `toStringTag`.
  38418. *
  38419. * **Note:** This function only supports cloning values with tags of
  38420. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  38421. *
  38422. * @private
  38423. * @param {Object} object The object to clone.
  38424. * @param {string} tag The `toStringTag` of the object to clone.
  38425. * @param {boolean} [isDeep] Specify a deep clone.
  38426. * @returns {Object} Returns the initialized clone.
  38427. */
  38428. function initCloneByTag(object, tag, isDeep) {
  38429. var Ctor = object.constructor;
  38430. switch (tag) {
  38431. case arrayBufferTag:
  38432. return cloneArrayBuffer(object);
  38433. case boolTag:
  38434. case dateTag:
  38435. return new Ctor(+object);
  38436. case dataViewTag:
  38437. return cloneDataView(object, isDeep);
  38438. case float32Tag: case float64Tag:
  38439. case int8Tag: case int16Tag: case int32Tag:
  38440. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  38441. return cloneTypedArray(object, isDeep);
  38442. case mapTag:
  38443. return new Ctor;
  38444. case numberTag:
  38445. case stringTag:
  38446. return new Ctor(object);
  38447. case regexpTag:
  38448. return cloneRegExp(object);
  38449. case setTag:
  38450. return new Ctor;
  38451. case symbolTag:
  38452. return cloneSymbol(object);
  38453. }
  38454. }
  38455. /**
  38456. * Inserts wrapper `details` in a comment at the top of the `source` body.
  38457. *
  38458. * @private
  38459. * @param {string} source The source to modify.
  38460. * @returns {Array} details The details to insert.
  38461. * @returns {string} Returns the modified source.
  38462. */
  38463. function insertWrapDetails(source, details) {
  38464. var length = details.length;
  38465. if (!length) {
  38466. return source;
  38467. }
  38468. var lastIndex = length - 1;
  38469. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  38470. details = details.join(length > 2 ? ', ' : ' ');
  38471. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  38472. }
  38473. /**
  38474. * Checks if `value` is a flattenable `arguments` object or array.
  38475. *
  38476. * @private
  38477. * @param {*} value The value to check.
  38478. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  38479. */
  38480. function isFlattenable(value) {
  38481. return isArray(value) || isArguments(value) ||
  38482. !!(spreadableSymbol && value && value[spreadableSymbol]);
  38483. }
  38484. /**
  38485. * Checks if `value` is a valid array-like index.
  38486. *
  38487. * @private
  38488. * @param {*} value The value to check.
  38489. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  38490. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  38491. */
  38492. function isIndex(value, length) {
  38493. var type = typeof value;
  38494. length = length == null ? MAX_SAFE_INTEGER : length;
  38495. return !!length &&
  38496. (type == 'number' ||
  38497. (type != 'symbol' && reIsUint.test(value))) &&
  38498. (value > -1 && value % 1 == 0 && value < length);
  38499. }
  38500. /**
  38501. * Checks if the given arguments are from an iteratee call.
  38502. *
  38503. * @private
  38504. * @param {*} value The potential iteratee value argument.
  38505. * @param {*} index The potential iteratee index or key argument.
  38506. * @param {*} object The potential iteratee object argument.
  38507. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  38508. * else `false`.
  38509. */
  38510. function isIterateeCall(value, index, object) {
  38511. if (!isObject(object)) {
  38512. return false;
  38513. }
  38514. var type = typeof index;
  38515. if (type == 'number'
  38516. ? (isArrayLike(object) && isIndex(index, object.length))
  38517. : (type == 'string' && index in object)
  38518. ) {
  38519. return eq(object[index], value);
  38520. }
  38521. return false;
  38522. }
  38523. /**
  38524. * Checks if `value` is a property name and not a property path.
  38525. *
  38526. * @private
  38527. * @param {*} value The value to check.
  38528. * @param {Object} [object] The object to query keys on.
  38529. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  38530. */
  38531. function isKey(value, object) {
  38532. if (isArray(value)) {
  38533. return false;
  38534. }
  38535. var type = typeof value;
  38536. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  38537. value == null || isSymbol(value)) {
  38538. return true;
  38539. }
  38540. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  38541. (object != null && value in Object(object));
  38542. }
  38543. /**
  38544. * Checks if `value` is suitable for use as unique object key.
  38545. *
  38546. * @private
  38547. * @param {*} value The value to check.
  38548. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  38549. */
  38550. function isKeyable(value) {
  38551. var type = typeof value;
  38552. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  38553. ? (value !== '__proto__')
  38554. : (value === null);
  38555. }
  38556. /**
  38557. * Checks if `func` has a lazy counterpart.
  38558. *
  38559. * @private
  38560. * @param {Function} func The function to check.
  38561. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  38562. * else `false`.
  38563. */
  38564. function isLaziable(func) {
  38565. var funcName = getFuncName(func),
  38566. other = lodash[funcName];
  38567. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  38568. return false;
  38569. }
  38570. if (func === other) {
  38571. return true;
  38572. }
  38573. var data = getData(other);
  38574. return !!data && func === data[0];
  38575. }
  38576. /**
  38577. * Checks if `func` has its source masked.
  38578. *
  38579. * @private
  38580. * @param {Function} func The function to check.
  38581. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  38582. */
  38583. function isMasked(func) {
  38584. return !!maskSrcKey && (maskSrcKey in func);
  38585. }
  38586. /**
  38587. * Checks if `func` is capable of being masked.
  38588. *
  38589. * @private
  38590. * @param {*} value The value to check.
  38591. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  38592. */
  38593. var isMaskable = coreJsData ? isFunction : stubFalse;
  38594. /**
  38595. * Checks if `value` is likely a prototype object.
  38596. *
  38597. * @private
  38598. * @param {*} value The value to check.
  38599. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  38600. */
  38601. function isPrototype(value) {
  38602. var Ctor = value && value.constructor,
  38603. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  38604. return value === proto;
  38605. }
  38606. /**
  38607. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  38608. *
  38609. * @private
  38610. * @param {*} value The value to check.
  38611. * @returns {boolean} Returns `true` if `value` if suitable for strict
  38612. * equality comparisons, else `false`.
  38613. */
  38614. function isStrictComparable(value) {
  38615. return value === value && !isObject(value);
  38616. }
  38617. /**
  38618. * A specialized version of `matchesProperty` for source values suitable
  38619. * for strict equality comparisons, i.e. `===`.
  38620. *
  38621. * @private
  38622. * @param {string} key The key of the property to get.
  38623. * @param {*} srcValue The value to match.
  38624. * @returns {Function} Returns the new spec function.
  38625. */
  38626. function matchesStrictComparable(key, srcValue) {
  38627. return function(object) {
  38628. if (object == null) {
  38629. return false;
  38630. }
  38631. return object[key] === srcValue &&
  38632. (srcValue !== undefined || (key in Object(object)));
  38633. };
  38634. }
  38635. /**
  38636. * A specialized version of `_.memoize` which clears the memoized function's
  38637. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  38638. *
  38639. * @private
  38640. * @param {Function} func The function to have its output memoized.
  38641. * @returns {Function} Returns the new memoized function.
  38642. */
  38643. function memoizeCapped(func) {
  38644. var result = memoize(func, function(key) {
  38645. if (cache.size === MAX_MEMOIZE_SIZE) {
  38646. cache.clear();
  38647. }
  38648. return key;
  38649. });
  38650. var cache = result.cache;
  38651. return result;
  38652. }
  38653. /**
  38654. * Merges the function metadata of `source` into `data`.
  38655. *
  38656. * Merging metadata reduces the number of wrappers used to invoke a function.
  38657. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  38658. * may be applied regardless of execution order. Methods like `_.ary` and
  38659. * `_.rearg` modify function arguments, making the order in which they are
  38660. * executed important, preventing the merging of metadata. However, we make
  38661. * an exception for a safe combined case where curried functions have `_.ary`
  38662. * and or `_.rearg` applied.
  38663. *
  38664. * @private
  38665. * @param {Array} data The destination metadata.
  38666. * @param {Array} source The source metadata.
  38667. * @returns {Array} Returns `data`.
  38668. */
  38669. function mergeData(data, source) {
  38670. var bitmask = data[1],
  38671. srcBitmask = source[1],
  38672. newBitmask = bitmask | srcBitmask,
  38673. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  38674. var isCombo =
  38675. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  38676. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  38677. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  38678. // Exit early if metadata can't be merged.
  38679. if (!(isCommon || isCombo)) {
  38680. return data;
  38681. }
  38682. // Use source `thisArg` if available.
  38683. if (srcBitmask & WRAP_BIND_FLAG) {
  38684. data[2] = source[2];
  38685. // Set when currying a bound function.
  38686. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  38687. }
  38688. // Compose partial arguments.
  38689. var value = source[3];
  38690. if (value) {
  38691. var partials = data[3];
  38692. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  38693. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  38694. }
  38695. // Compose partial right arguments.
  38696. value = source[5];
  38697. if (value) {
  38698. partials = data[5];
  38699. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  38700. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  38701. }
  38702. // Use source `argPos` if available.
  38703. value = source[7];
  38704. if (value) {
  38705. data[7] = value;
  38706. }
  38707. // Use source `ary` if it's smaller.
  38708. if (srcBitmask & WRAP_ARY_FLAG) {
  38709. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  38710. }
  38711. // Use source `arity` if one is not provided.
  38712. if (data[9] == null) {
  38713. data[9] = source[9];
  38714. }
  38715. // Use source `func` and merge bitmasks.
  38716. data[0] = source[0];
  38717. data[1] = newBitmask;
  38718. return data;
  38719. }
  38720. /**
  38721. * This function is like
  38722. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  38723. * except that it includes inherited enumerable properties.
  38724. *
  38725. * @private
  38726. * @param {Object} object The object to query.
  38727. * @returns {Array} Returns the array of property names.
  38728. */
  38729. function nativeKeysIn(object) {
  38730. var result = [];
  38731. if (object != null) {
  38732. for (var key in Object(object)) {
  38733. result.push(key);
  38734. }
  38735. }
  38736. return result;
  38737. }
  38738. /**
  38739. * Converts `value` to a string using `Object.prototype.toString`.
  38740. *
  38741. * @private
  38742. * @param {*} value The value to convert.
  38743. * @returns {string} Returns the converted string.
  38744. */
  38745. function objectToString(value) {
  38746. return nativeObjectToString.call(value);
  38747. }
  38748. /**
  38749. * A specialized version of `baseRest` which transforms the rest array.
  38750. *
  38751. * @private
  38752. * @param {Function} func The function to apply a rest parameter to.
  38753. * @param {number} [start=func.length-1] The start position of the rest parameter.
  38754. * @param {Function} transform The rest array transform.
  38755. * @returns {Function} Returns the new function.
  38756. */
  38757. function overRest(func, start, transform) {
  38758. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  38759. return function() {
  38760. var args = arguments,
  38761. index = -1,
  38762. length = nativeMax(args.length - start, 0),
  38763. array = Array(length);
  38764. while (++index < length) {
  38765. array[index] = args[start + index];
  38766. }
  38767. index = -1;
  38768. var otherArgs = Array(start + 1);
  38769. while (++index < start) {
  38770. otherArgs[index] = args[index];
  38771. }
  38772. otherArgs[start] = transform(array);
  38773. return apply(func, this, otherArgs);
  38774. };
  38775. }
  38776. /**
  38777. * Gets the parent value at `path` of `object`.
  38778. *
  38779. * @private
  38780. * @param {Object} object The object to query.
  38781. * @param {Array} path The path to get the parent value of.
  38782. * @returns {*} Returns the parent value.
  38783. */
  38784. function parent(object, path) {
  38785. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  38786. }
  38787. /**
  38788. * Reorder `array` according to the specified indexes where the element at
  38789. * the first index is assigned as the first element, the element at
  38790. * the second index is assigned as the second element, and so on.
  38791. *
  38792. * @private
  38793. * @param {Array} array The array to reorder.
  38794. * @param {Array} indexes The arranged array indexes.
  38795. * @returns {Array} Returns `array`.
  38796. */
  38797. function reorder(array, indexes) {
  38798. var arrLength = array.length,
  38799. length = nativeMin(indexes.length, arrLength),
  38800. oldArray = copyArray(array);
  38801. while (length--) {
  38802. var index = indexes[length];
  38803. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
  38804. }
  38805. return array;
  38806. }
  38807. /**
  38808. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  38809. *
  38810. * @private
  38811. * @param {Object} object The object to query.
  38812. * @param {string} key The key of the property to get.
  38813. * @returns {*} Returns the property value.
  38814. */
  38815. function safeGet(object, key) {
  38816. if (key === 'constructor' && typeof object[key] === 'function') {
  38817. return;
  38818. }
  38819. if (key == '__proto__') {
  38820. return;
  38821. }
  38822. return object[key];
  38823. }
  38824. /**
  38825. * Sets metadata for `func`.
  38826. *
  38827. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  38828. * period of time, it will trip its breaker and transition to an identity
  38829. * function to avoid garbage collection pauses in V8. See
  38830. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  38831. * for more details.
  38832. *
  38833. * @private
  38834. * @param {Function} func The function to associate metadata with.
  38835. * @param {*} data The metadata.
  38836. * @returns {Function} Returns `func`.
  38837. */
  38838. var setData = shortOut(baseSetData);
  38839. /**
  38840. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  38841. *
  38842. * @private
  38843. * @param {Function} func The function to delay.
  38844. * @param {number} wait The number of milliseconds to delay invocation.
  38845. * @returns {number|Object} Returns the timer id or timeout object.
  38846. */
  38847. var setTimeout = ctxSetTimeout || function(func, wait) {
  38848. return root.setTimeout(func, wait);
  38849. };
  38850. /**
  38851. * Sets the `toString` method of `func` to return `string`.
  38852. *
  38853. * @private
  38854. * @param {Function} func The function to modify.
  38855. * @param {Function} string The `toString` result.
  38856. * @returns {Function} Returns `func`.
  38857. */
  38858. var setToString = shortOut(baseSetToString);
  38859. /**
  38860. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  38861. * with wrapper details in a comment at the top of the source body.
  38862. *
  38863. * @private
  38864. * @param {Function} wrapper The function to modify.
  38865. * @param {Function} reference The reference function.
  38866. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  38867. * @returns {Function} Returns `wrapper`.
  38868. */
  38869. function setWrapToString(wrapper, reference, bitmask) {
  38870. var source = (reference + '');
  38871. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  38872. }
  38873. /**
  38874. * Creates a function that'll short out and invoke `identity` instead
  38875. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  38876. * milliseconds.
  38877. *
  38878. * @private
  38879. * @param {Function} func The function to restrict.
  38880. * @returns {Function} Returns the new shortable function.
  38881. */
  38882. function shortOut(func) {
  38883. var count = 0,
  38884. lastCalled = 0;
  38885. return function() {
  38886. var stamp = nativeNow(),
  38887. remaining = HOT_SPAN - (stamp - lastCalled);
  38888. lastCalled = stamp;
  38889. if (remaining > 0) {
  38890. if (++count >= HOT_COUNT) {
  38891. return arguments[0];
  38892. }
  38893. } else {
  38894. count = 0;
  38895. }
  38896. return func.apply(undefined, arguments);
  38897. };
  38898. }
  38899. /**
  38900. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  38901. *
  38902. * @private
  38903. * @param {Array} array The array to shuffle.
  38904. * @param {number} [size=array.length] The size of `array`.
  38905. * @returns {Array} Returns `array`.
  38906. */
  38907. function shuffleSelf(array, size) {
  38908. var index = -1,
  38909. length = array.length,
  38910. lastIndex = length - 1;
  38911. size = size === undefined ? length : size;
  38912. while (++index < size) {
  38913. var rand = baseRandom(index, lastIndex),
  38914. value = array[rand];
  38915. array[rand] = array[index];
  38916. array[index] = value;
  38917. }
  38918. array.length = size;
  38919. return array;
  38920. }
  38921. /**
  38922. * Converts `string` to a property path array.
  38923. *
  38924. * @private
  38925. * @param {string} string The string to convert.
  38926. * @returns {Array} Returns the property path array.
  38927. */
  38928. var stringToPath = memoizeCapped(function(string) {
  38929. var result = [];
  38930. if (string.charCodeAt(0) === 46 /* . */) {
  38931. result.push('');
  38932. }
  38933. string.replace(rePropName, function(match, number, quote, subString) {
  38934. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  38935. });
  38936. return result;
  38937. });
  38938. /**
  38939. * Converts `value` to a string key if it's not a string or symbol.
  38940. *
  38941. * @private
  38942. * @param {*} value The value to inspect.
  38943. * @returns {string|symbol} Returns the key.
  38944. */
  38945. function toKey(value) {
  38946. if (typeof value == 'string' || isSymbol(value)) {
  38947. return value;
  38948. }
  38949. var result = (value + '');
  38950. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  38951. }
  38952. /**
  38953. * Converts `func` to its source code.
  38954. *
  38955. * @private
  38956. * @param {Function} func The function to convert.
  38957. * @returns {string} Returns the source code.
  38958. */
  38959. function toSource(func) {
  38960. if (func != null) {
  38961. try {
  38962. return funcToString.call(func);
  38963. } catch (e) {}
  38964. try {
  38965. return (func + '');
  38966. } catch (e) {}
  38967. }
  38968. return '';
  38969. }
  38970. /**
  38971. * Updates wrapper `details` based on `bitmask` flags.
  38972. *
  38973. * @private
  38974. * @returns {Array} details The details to modify.
  38975. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  38976. * @returns {Array} Returns `details`.
  38977. */
  38978. function updateWrapDetails(details, bitmask) {
  38979. arrayEach(wrapFlags, function(pair) {
  38980. var value = '_.' + pair[0];
  38981. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  38982. details.push(value);
  38983. }
  38984. });
  38985. return details.sort();
  38986. }
  38987. /**
  38988. * Creates a clone of `wrapper`.
  38989. *
  38990. * @private
  38991. * @param {Object} wrapper The wrapper to clone.
  38992. * @returns {Object} Returns the cloned wrapper.
  38993. */
  38994. function wrapperClone(wrapper) {
  38995. if (wrapper instanceof LazyWrapper) {
  38996. return wrapper.clone();
  38997. }
  38998. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  38999. result.__actions__ = copyArray(wrapper.__actions__);
  39000. result.__index__ = wrapper.__index__;
  39001. result.__values__ = wrapper.__values__;
  39002. return result;
  39003. }
  39004. /*------------------------------------------------------------------------*/
  39005. /**
  39006. * Creates an array of elements split into groups the length of `size`.
  39007. * If `array` can't be split evenly, the final chunk will be the remaining
  39008. * elements.
  39009. *
  39010. * @static
  39011. * @memberOf _
  39012. * @since 3.0.0
  39013. * @category Array
  39014. * @param {Array} array The array to process.
  39015. * @param {number} [size=1] The length of each chunk
  39016. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  39017. * @returns {Array} Returns the new array of chunks.
  39018. * @example
  39019. *
  39020. * _.chunk(['a', 'b', 'c', 'd'], 2);
  39021. * // => [['a', 'b'], ['c', 'd']]
  39022. *
  39023. * _.chunk(['a', 'b', 'c', 'd'], 3);
  39024. * // => [['a', 'b', 'c'], ['d']]
  39025. */
  39026. function chunk(array, size, guard) {
  39027. if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
  39028. size = 1;
  39029. } else {
  39030. size = nativeMax(toInteger(size), 0);
  39031. }
  39032. var length = array == null ? 0 : array.length;
  39033. if (!length || size < 1) {
  39034. return [];
  39035. }
  39036. var index = 0,
  39037. resIndex = 0,
  39038. result = Array(nativeCeil(length / size));
  39039. while (index < length) {
  39040. result[resIndex++] = baseSlice(array, index, (index += size));
  39041. }
  39042. return result;
  39043. }
  39044. /**
  39045. * Creates an array with all falsey values removed. The values `false`, `null`,
  39046. * `0`, `""`, `undefined`, and `NaN` are falsey.
  39047. *
  39048. * @static
  39049. * @memberOf _
  39050. * @since 0.1.0
  39051. * @category Array
  39052. * @param {Array} array The array to compact.
  39053. * @returns {Array} Returns the new array of filtered values.
  39054. * @example
  39055. *
  39056. * _.compact([0, 1, false, 2, '', 3]);
  39057. * // => [1, 2, 3]
  39058. */
  39059. function compact(array) {
  39060. var index = -1,
  39061. length = array == null ? 0 : array.length,
  39062. resIndex = 0,
  39063. result = [];
  39064. while (++index < length) {
  39065. var value = array[index];
  39066. if (value) {
  39067. result[resIndex++] = value;
  39068. }
  39069. }
  39070. return result;
  39071. }
  39072. /**
  39073. * Creates a new array concatenating `array` with any additional arrays
  39074. * and/or values.
  39075. *
  39076. * @static
  39077. * @memberOf _
  39078. * @since 4.0.0
  39079. * @category Array
  39080. * @param {Array} array The array to concatenate.
  39081. * @param {...*} [values] The values to concatenate.
  39082. * @returns {Array} Returns the new concatenated array.
  39083. * @example
  39084. *
  39085. * var array = [1];
  39086. * var other = _.concat(array, 2, [3], [[4]]);
  39087. *
  39088. * console.log(other);
  39089. * // => [1, 2, 3, [4]]
  39090. *
  39091. * console.log(array);
  39092. * // => [1]
  39093. */
  39094. function concat() {
  39095. var length = arguments.length;
  39096. if (!length) {
  39097. return [];
  39098. }
  39099. var args = Array(length - 1),
  39100. array = arguments[0],
  39101. index = length;
  39102. while (index--) {
  39103. args[index - 1] = arguments[index];
  39104. }
  39105. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  39106. }
  39107. /**
  39108. * Creates an array of `array` values not included in the other given arrays
  39109. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  39110. * for equality comparisons. The order and references of result values are
  39111. * determined by the first array.
  39112. *
  39113. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  39114. *
  39115. * @static
  39116. * @memberOf _
  39117. * @since 0.1.0
  39118. * @category Array
  39119. * @param {Array} array The array to inspect.
  39120. * @param {...Array} [values] The values to exclude.
  39121. * @returns {Array} Returns the new array of filtered values.
  39122. * @see _.without, _.xor
  39123. * @example
  39124. *
  39125. * _.difference([2, 1], [2, 3]);
  39126. * // => [1]
  39127. */
  39128. var difference = baseRest(function(array, values) {
  39129. return isArrayLikeObject(array)
  39130. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  39131. : [];
  39132. });
  39133. /**
  39134. * This method is like `_.difference` except that it accepts `iteratee` which
  39135. * is invoked for each element of `array` and `values` to generate the criterion
  39136. * by which they're compared. The order and references of result values are
  39137. * determined by the first array. The iteratee is invoked with one argument:
  39138. * (value).
  39139. *
  39140. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  39141. *
  39142. * @static
  39143. * @memberOf _
  39144. * @since 4.0.0
  39145. * @category Array
  39146. * @param {Array} array The array to inspect.
  39147. * @param {...Array} [values] The values to exclude.
  39148. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  39149. * @returns {Array} Returns the new array of filtered values.
  39150. * @example
  39151. *
  39152. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  39153. * // => [1.2]
  39154. *
  39155. * // The `_.property` iteratee shorthand.
  39156. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  39157. * // => [{ 'x': 2 }]
  39158. */
  39159. var differenceBy = baseRest(function(array, values) {
  39160. var iteratee = last(values);
  39161. if (isArrayLikeObject(iteratee)) {
  39162. iteratee = undefined;
  39163. }
  39164. return isArrayLikeObject(array)
  39165. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  39166. : [];
  39167. });
  39168. /**
  39169. * This method is like `_.difference` except that it accepts `comparator`
  39170. * which is invoked to compare elements of `array` to `values`. The order and
  39171. * references of result values are determined by the first array. The comparator
  39172. * is invoked with two arguments: (arrVal, othVal).
  39173. *
  39174. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  39175. *
  39176. * @static
  39177. * @memberOf _
  39178. * @since 4.0.0
  39179. * @category Array
  39180. * @param {Array} array The array to inspect.
  39181. * @param {...Array} [values] The values to exclude.
  39182. * @param {Function} [comparator] The comparator invoked per element.
  39183. * @returns {Array} Returns the new array of filtered values.
  39184. * @example
  39185. *
  39186. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  39187. *
  39188. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  39189. * // => [{ 'x': 2, 'y': 1 }]
  39190. */
  39191. var differenceWith = baseRest(function(array, values) {
  39192. var comparator = last(values);
  39193. if (isArrayLikeObject(comparator)) {
  39194. comparator = undefined;
  39195. }
  39196. return isArrayLikeObject(array)
  39197. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
  39198. : [];
  39199. });
  39200. /**
  39201. * Creates a slice of `array` with `n` elements dropped from the beginning.
  39202. *
  39203. * @static
  39204. * @memberOf _
  39205. * @since 0.5.0
  39206. * @category Array
  39207. * @param {Array} array The array to query.
  39208. * @param {number} [n=1] The number of elements to drop.
  39209. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  39210. * @returns {Array} Returns the slice of `array`.
  39211. * @example
  39212. *
  39213. * _.drop([1, 2, 3]);
  39214. * // => [2, 3]
  39215. *
  39216. * _.drop([1, 2, 3], 2);
  39217. * // => [3]
  39218. *
  39219. * _.drop([1, 2, 3], 5);
  39220. * // => []
  39221. *
  39222. * _.drop([1, 2, 3], 0);
  39223. * // => [1, 2, 3]
  39224. */
  39225. function drop(array, n, guard) {
  39226. var length = array == null ? 0 : array.length;
  39227. if (!length) {
  39228. return [];
  39229. }
  39230. n = (guard || n === undefined) ? 1 : toInteger(n);
  39231. return baseSlice(array, n < 0 ? 0 : n, length);
  39232. }
  39233. /**
  39234. * Creates a slice of `array` with `n` elements dropped from the end.
  39235. *
  39236. * @static
  39237. * @memberOf _
  39238. * @since 3.0.0
  39239. * @category Array
  39240. * @param {Array} array The array to query.
  39241. * @param {number} [n=1] The number of elements to drop.
  39242. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  39243. * @returns {Array} Returns the slice of `array`.
  39244. * @example
  39245. *
  39246. * _.dropRight([1, 2, 3]);
  39247. * // => [1, 2]
  39248. *
  39249. * _.dropRight([1, 2, 3], 2);
  39250. * // => [1]
  39251. *
  39252. * _.dropRight([1, 2, 3], 5);
  39253. * // => []
  39254. *
  39255. * _.dropRight([1, 2, 3], 0);
  39256. * // => [1, 2, 3]
  39257. */
  39258. function dropRight(array, n, guard) {
  39259. var length = array == null ? 0 : array.length;
  39260. if (!length) {
  39261. return [];
  39262. }
  39263. n = (guard || n === undefined) ? 1 : toInteger(n);
  39264. n = length - n;
  39265. return baseSlice(array, 0, n < 0 ? 0 : n);
  39266. }
  39267. /**
  39268. * Creates a slice of `array` excluding elements dropped from the end.
  39269. * Elements are dropped until `predicate` returns falsey. The predicate is
  39270. * invoked with three arguments: (value, index, array).
  39271. *
  39272. * @static
  39273. * @memberOf _
  39274. * @since 3.0.0
  39275. * @category Array
  39276. * @param {Array} array The array to query.
  39277. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  39278. * @returns {Array} Returns the slice of `array`.
  39279. * @example
  39280. *
  39281. * var users = [
  39282. * { 'user': 'barney', 'active': true },
  39283. * { 'user': 'fred', 'active': false },
  39284. * { 'user': 'pebbles', 'active': false }
  39285. * ];
  39286. *
  39287. * _.dropRightWhile(users, function(o) { return !o.active; });
  39288. * // => objects for ['barney']
  39289. *
  39290. * // The `_.matches` iteratee shorthand.
  39291. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  39292. * // => objects for ['barney', 'fred']
  39293. *
  39294. * // The `_.matchesProperty` iteratee shorthand.
  39295. * _.dropRightWhile(users, ['active', false]);
  39296. * // => objects for ['barney']
  39297. *
  39298. * // The `_.property` iteratee shorthand.
  39299. * _.dropRightWhile(users, 'active');
  39300. * // => objects for ['barney', 'fred', 'pebbles']
  39301. */
  39302. function dropRightWhile(array, predicate) {
  39303. return (array && array.length)
  39304. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  39305. : [];
  39306. }
  39307. /**
  39308. * Creates a slice of `array` excluding elements dropped from the beginning.
  39309. * Elements are dropped until `predicate` returns falsey. The predicate is
  39310. * invoked with three arguments: (value, index, array).
  39311. *
  39312. * @static
  39313. * @memberOf _
  39314. * @since 3.0.0
  39315. * @category Array
  39316. * @param {Array} array The array to query.
  39317. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  39318. * @returns {Array} Returns the slice of `array`.
  39319. * @example
  39320. *
  39321. * var users = [
  39322. * { 'user': 'barney', 'active': false },
  39323. * { 'user': 'fred', 'active': false },
  39324. * { 'user': 'pebbles', 'active': true }
  39325. * ];
  39326. *
  39327. * _.dropWhile(users, function(o) { return !o.active; });
  39328. * // => objects for ['pebbles']
  39329. *
  39330. * // The `_.matches` iteratee shorthand.
  39331. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  39332. * // => objects for ['fred', 'pebbles']
  39333. *
  39334. * // The `_.matchesProperty` iteratee shorthand.
  39335. * _.dropWhile(users, ['active', false]);
  39336. * // => objects for ['pebbles']
  39337. *
  39338. * // The `_.property` iteratee shorthand.
  39339. * _.dropWhile(users, 'active');
  39340. * // => objects for ['barney', 'fred', 'pebbles']
  39341. */
  39342. function dropWhile(array, predicate) {
  39343. return (array && array.length)
  39344. ? baseWhile(array, getIteratee(predicate, 3), true)
  39345. : [];
  39346. }
  39347. /**
  39348. * Fills elements of `array` with `value` from `start` up to, but not
  39349. * including, `end`.
  39350. *
  39351. * **Note:** This method mutates `array`.
  39352. *
  39353. * @static
  39354. * @memberOf _
  39355. * @since 3.2.0
  39356. * @category Array
  39357. * @param {Array} array The array to fill.
  39358. * @param {*} value The value to fill `array` with.
  39359. * @param {number} [start=0] The start position.
  39360. * @param {number} [end=array.length] The end position.
  39361. * @returns {Array} Returns `array`.
  39362. * @example
  39363. *
  39364. * var array = [1, 2, 3];
  39365. *
  39366. * _.fill(array, 'a');
  39367. * console.log(array);
  39368. * // => ['a', 'a', 'a']
  39369. *
  39370. * _.fill(Array(3), 2);
  39371. * // => [2, 2, 2]
  39372. *
  39373. * _.fill([4, 6, 8, 10], '*', 1, 3);
  39374. * // => [4, '*', '*', 10]
  39375. */
  39376. function fill(array, value, start, end) {
  39377. var length = array == null ? 0 : array.length;
  39378. if (!length) {
  39379. return [];
  39380. }
  39381. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  39382. start = 0;
  39383. end = length;
  39384. }
  39385. return baseFill(array, value, start, end);
  39386. }
  39387. /**
  39388. * This method is like `_.find` except that it returns the index of the first
  39389. * element `predicate` returns truthy for instead of the element itself.
  39390. *
  39391. * @static
  39392. * @memberOf _
  39393. * @since 1.1.0
  39394. * @category Array
  39395. * @param {Array} array The array to inspect.
  39396. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  39397. * @param {number} [fromIndex=0] The index to search from.
  39398. * @returns {number} Returns the index of the found element, else `-1`.
  39399. * @example
  39400. *
  39401. * var users = [
  39402. * { 'user': 'barney', 'active': false },
  39403. * { 'user': 'fred', 'active': false },
  39404. * { 'user': 'pebbles', 'active': true }
  39405. * ];
  39406. *
  39407. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  39408. * // => 0
  39409. *
  39410. * // The `_.matches` iteratee shorthand.
  39411. * _.findIndex(users, { 'user': 'fred', 'active': false });
  39412. * // => 1
  39413. *
  39414. * // The `_.matchesProperty` iteratee shorthand.
  39415. * _.findIndex(users, ['active', false]);
  39416. * // => 0
  39417. *
  39418. * // The `_.property` iteratee shorthand.
  39419. * _.findIndex(users, 'active');
  39420. * // => 2
  39421. */
  39422. function findIndex(array, predicate, fromIndex) {
  39423. var length = array == null ? 0 : array.length;
  39424. if (!length) {
  39425. return -1;
  39426. }
  39427. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  39428. if (index < 0) {
  39429. index = nativeMax(length + index, 0);
  39430. }
  39431. return baseFindIndex(array, getIteratee(predicate, 3), index);
  39432. }
  39433. /**
  39434. * This method is like `_.findIndex` except that it iterates over elements
  39435. * of `collection` from right to left.
  39436. *
  39437. * @static
  39438. * @memberOf _
  39439. * @since 2.0.0
  39440. * @category Array
  39441. * @param {Array} array The array to inspect.
  39442. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  39443. * @param {number} [fromIndex=array.length-1] The index to search from.
  39444. * @returns {number} Returns the index of the found element, else `-1`.
  39445. * @example
  39446. *
  39447. * var users = [
  39448. * { 'user': 'barney', 'active': true },
  39449. * { 'user': 'fred', 'active': false },
  39450. * { 'user': 'pebbles', 'active': false }
  39451. * ];
  39452. *
  39453. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  39454. * // => 2
  39455. *
  39456. * // The `_.matches` iteratee shorthand.
  39457. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  39458. * // => 0
  39459. *
  39460. * // The `_.matchesProperty` iteratee shorthand.
  39461. * _.findLastIndex(users, ['active', false]);
  39462. * // => 2
  39463. *
  39464. * // The `_.property` iteratee shorthand.
  39465. * _.findLastIndex(users, 'active');
  39466. * // => 0
  39467. */
  39468. function findLastIndex(array, predicate, fromIndex) {
  39469. var length = array == null ? 0 : array.length;
  39470. if (!length) {
  39471. return -1;
  39472. }
  39473. var index = length - 1;
  39474. if (fromIndex !== undefined) {
  39475. index = toInteger(fromIndex);
  39476. index = fromIndex < 0
  39477. ? nativeMax(length + index, 0)
  39478. : nativeMin(index, length - 1);
  39479. }
  39480. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  39481. }
  39482. /**
  39483. * Flattens `array` a single level deep.
  39484. *
  39485. * @static
  39486. * @memberOf _
  39487. * @since 0.1.0
  39488. * @category Array
  39489. * @param {Array} array The array to flatten.
  39490. * @returns {Array} Returns the new flattened array.
  39491. * @example
  39492. *
  39493. * _.flatten([1, [2, [3, [4]], 5]]);
  39494. * // => [1, 2, [3, [4]], 5]
  39495. */
  39496. function flatten(array) {
  39497. var length = array == null ? 0 : array.length;
  39498. return length ? baseFlatten(array, 1) : [];
  39499. }
  39500. /**
  39501. * Recursively flattens `array`.
  39502. *
  39503. * @static
  39504. * @memberOf _
  39505. * @since 3.0.0
  39506. * @category Array
  39507. * @param {Array} array The array to flatten.
  39508. * @returns {Array} Returns the new flattened array.
  39509. * @example
  39510. *
  39511. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  39512. * // => [1, 2, 3, 4, 5]
  39513. */
  39514. function flattenDeep(array) {
  39515. var length = array == null ? 0 : array.length;
  39516. return length ? baseFlatten(array, INFINITY) : [];
  39517. }
  39518. /**
  39519. * Recursively flatten `array` up to `depth` times.
  39520. *
  39521. * @static
  39522. * @memberOf _
  39523. * @since 4.4.0
  39524. * @category Array
  39525. * @param {Array} array The array to flatten.
  39526. * @param {number} [depth=1] The maximum recursion depth.
  39527. * @returns {Array} Returns the new flattened array.
  39528. * @example
  39529. *
  39530. * var array = [1, [2, [3, [4]], 5]];
  39531. *
  39532. * _.flattenDepth(array, 1);
  39533. * // => [1, 2, [3, [4]], 5]
  39534. *
  39535. * _.flattenDepth(array, 2);
  39536. * // => [1, 2, 3, [4], 5]
  39537. */
  39538. function flattenDepth(array, depth) {
  39539. var length = array == null ? 0 : array.length;
  39540. if (!length) {
  39541. return [];
  39542. }
  39543. depth = depth === undefined ? 1 : toInteger(depth);
  39544. return baseFlatten(array, depth);
  39545. }
  39546. /**
  39547. * The inverse of `_.toPairs`; this method returns an object composed
  39548. * from key-value `pairs`.
  39549. *
  39550. * @static
  39551. * @memberOf _
  39552. * @since 4.0.0
  39553. * @category Array
  39554. * @param {Array} pairs The key-value pairs.
  39555. * @returns {Object} Returns the new object.
  39556. * @example
  39557. *
  39558. * _.fromPairs([['a', 1], ['b', 2]]);
  39559. * // => { 'a': 1, 'b': 2 }
  39560. */
  39561. function fromPairs(pairs) {
  39562. var index = -1,
  39563. length = pairs == null ? 0 : pairs.length,
  39564. result = {};
  39565. while (++index < length) {
  39566. var pair = pairs[index];
  39567. result[pair[0]] = pair[1];
  39568. }
  39569. return result;
  39570. }
  39571. /**
  39572. * Gets the first element of `array`.
  39573. *
  39574. * @static
  39575. * @memberOf _
  39576. * @since 0.1.0
  39577. * @alias first
  39578. * @category Array
  39579. * @param {Array} array The array to query.
  39580. * @returns {*} Returns the first element of `array`.
  39581. * @example
  39582. *
  39583. * _.head([1, 2, 3]);
  39584. * // => 1
  39585. *
  39586. * _.head([]);
  39587. * // => undefined
  39588. */
  39589. function head(array) {
  39590. return (array && array.length) ? array[0] : undefined;
  39591. }
  39592. /**
  39593. * Gets the index at which the first occurrence of `value` is found in `array`
  39594. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  39595. * for equality comparisons. If `fromIndex` is negative, it's used as the
  39596. * offset from the end of `array`.
  39597. *
  39598. * @static
  39599. * @memberOf _
  39600. * @since 0.1.0
  39601. * @category Array
  39602. * @param {Array} array The array to inspect.
  39603. * @param {*} value The value to search for.
  39604. * @param {number} [fromIndex=0] The index to search from.
  39605. * @returns {number} Returns the index of the matched value, else `-1`.
  39606. * @example
  39607. *
  39608. * _.indexOf([1, 2, 1, 2], 2);
  39609. * // => 1
  39610. *
  39611. * // Search from the `fromIndex`.
  39612. * _.indexOf([1, 2, 1, 2], 2, 2);
  39613. * // => 3
  39614. */
  39615. function indexOf(array, value, fromIndex) {
  39616. var length = array == null ? 0 : array.length;
  39617. if (!length) {
  39618. return -1;
  39619. }
  39620. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  39621. if (index < 0) {
  39622. index = nativeMax(length + index, 0);
  39623. }
  39624. return baseIndexOf(array, value, index);
  39625. }
  39626. /**
  39627. * Gets all but the last element of `array`.
  39628. *
  39629. * @static
  39630. * @memberOf _
  39631. * @since 0.1.0
  39632. * @category Array
  39633. * @param {Array} array The array to query.
  39634. * @returns {Array} Returns the slice of `array`.
  39635. * @example
  39636. *
  39637. * _.initial([1, 2, 3]);
  39638. * // => [1, 2]
  39639. */
  39640. function initial(array) {
  39641. var length = array == null ? 0 : array.length;
  39642. return length ? baseSlice(array, 0, -1) : [];
  39643. }
  39644. /**
  39645. * Creates an array of unique values that are included in all given arrays
  39646. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  39647. * for equality comparisons. The order and references of result values are
  39648. * determined by the first array.
  39649. *
  39650. * @static
  39651. * @memberOf _
  39652. * @since 0.1.0
  39653. * @category Array
  39654. * @param {...Array} [arrays] The arrays to inspect.
  39655. * @returns {Array} Returns the new array of intersecting values.
  39656. * @example
  39657. *
  39658. * _.intersection([2, 1], [2, 3]);
  39659. * // => [2]
  39660. */
  39661. var intersection = baseRest(function(arrays) {
  39662. var mapped = arrayMap(arrays, castArrayLikeObject);
  39663. return (mapped.length && mapped[0] === arrays[0])
  39664. ? baseIntersection(mapped)
  39665. : [];
  39666. });
  39667. /**
  39668. * This method is like `_.intersection` except that it accepts `iteratee`
  39669. * which is invoked for each element of each `arrays` to generate the criterion
  39670. * by which they're compared. The order and references of result values are
  39671. * determined by the first array. The iteratee is invoked with one argument:
  39672. * (value).
  39673. *
  39674. * @static
  39675. * @memberOf _
  39676. * @since 4.0.0
  39677. * @category Array
  39678. * @param {...Array} [arrays] The arrays to inspect.
  39679. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  39680. * @returns {Array} Returns the new array of intersecting values.
  39681. * @example
  39682. *
  39683. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  39684. * // => [2.1]
  39685. *
  39686. * // The `_.property` iteratee shorthand.
  39687. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  39688. * // => [{ 'x': 1 }]
  39689. */
  39690. var intersectionBy = baseRest(function(arrays) {
  39691. var iteratee = last(arrays),
  39692. mapped = arrayMap(arrays, castArrayLikeObject);
  39693. if (iteratee === last(mapped)) {
  39694. iteratee = undefined;
  39695. } else {
  39696. mapped.pop();
  39697. }
  39698. return (mapped.length && mapped[0] === arrays[0])
  39699. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  39700. : [];
  39701. });
  39702. /**
  39703. * This method is like `_.intersection` except that it accepts `comparator`
  39704. * which is invoked to compare elements of `arrays`. The order and references
  39705. * of result values are determined by the first array. The comparator is
  39706. * invoked with two arguments: (arrVal, othVal).
  39707. *
  39708. * @static
  39709. * @memberOf _
  39710. * @since 4.0.0
  39711. * @category Array
  39712. * @param {...Array} [arrays] The arrays to inspect.
  39713. * @param {Function} [comparator] The comparator invoked per element.
  39714. * @returns {Array} Returns the new array of intersecting values.
  39715. * @example
  39716. *
  39717. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  39718. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  39719. *
  39720. * _.intersectionWith(objects, others, _.isEqual);
  39721. * // => [{ 'x': 1, 'y': 2 }]
  39722. */
  39723. var intersectionWith = baseRest(function(arrays) {
  39724. var comparator = last(arrays),
  39725. mapped = arrayMap(arrays, castArrayLikeObject);
  39726. comparator = typeof comparator == 'function' ? comparator : undefined;
  39727. if (comparator) {
  39728. mapped.pop();
  39729. }
  39730. return (mapped.length && mapped[0] === arrays[0])
  39731. ? baseIntersection(mapped, undefined, comparator)
  39732. : [];
  39733. });
  39734. /**
  39735. * Converts all elements in `array` into a string separated by `separator`.
  39736. *
  39737. * @static
  39738. * @memberOf _
  39739. * @since 4.0.0
  39740. * @category Array
  39741. * @param {Array} array The array to convert.
  39742. * @param {string} [separator=','] The element separator.
  39743. * @returns {string} Returns the joined string.
  39744. * @example
  39745. *
  39746. * _.join(['a', 'b', 'c'], '~');
  39747. * // => 'a~b~c'
  39748. */
  39749. function join(array, separator) {
  39750. return array == null ? '' : nativeJoin.call(array, separator);
  39751. }
  39752. /**
  39753. * Gets the last element of `array`.
  39754. *
  39755. * @static
  39756. * @memberOf _
  39757. * @since 0.1.0
  39758. * @category Array
  39759. * @param {Array} array The array to query.
  39760. * @returns {*} Returns the last element of `array`.
  39761. * @example
  39762. *
  39763. * _.last([1, 2, 3]);
  39764. * // => 3
  39765. */
  39766. function last(array) {
  39767. var length = array == null ? 0 : array.length;
  39768. return length ? array[length - 1] : undefined;
  39769. }
  39770. /**
  39771. * This method is like `_.indexOf` except that it iterates over elements of
  39772. * `array` from right to left.
  39773. *
  39774. * @static
  39775. * @memberOf _
  39776. * @since 0.1.0
  39777. * @category Array
  39778. * @param {Array} array The array to inspect.
  39779. * @param {*} value The value to search for.
  39780. * @param {number} [fromIndex=array.length-1] The index to search from.
  39781. * @returns {number} Returns the index of the matched value, else `-1`.
  39782. * @example
  39783. *
  39784. * _.lastIndexOf([1, 2, 1, 2], 2);
  39785. * // => 3
  39786. *
  39787. * // Search from the `fromIndex`.
  39788. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  39789. * // => 1
  39790. */
  39791. function lastIndexOf(array, value, fromIndex) {
  39792. var length = array == null ? 0 : array.length;
  39793. if (!length) {
  39794. return -1;
  39795. }
  39796. var index = length;
  39797. if (fromIndex !== undefined) {
  39798. index = toInteger(fromIndex);
  39799. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  39800. }
  39801. return value === value
  39802. ? strictLastIndexOf(array, value, index)
  39803. : baseFindIndex(array, baseIsNaN, index, true);
  39804. }
  39805. /**
  39806. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  39807. * element from the end is returned.
  39808. *
  39809. * @static
  39810. * @memberOf _
  39811. * @since 4.11.0
  39812. * @category Array
  39813. * @param {Array} array The array to query.
  39814. * @param {number} [n=0] The index of the element to return.
  39815. * @returns {*} Returns the nth element of `array`.
  39816. * @example
  39817. *
  39818. * var array = ['a', 'b', 'c', 'd'];
  39819. *
  39820. * _.nth(array, 1);
  39821. * // => 'b'
  39822. *
  39823. * _.nth(array, -2);
  39824. * // => 'c';
  39825. */
  39826. function nth(array, n) {
  39827. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
  39828. }
  39829. /**
  39830. * Removes all given values from `array` using
  39831. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  39832. * for equality comparisons.
  39833. *
  39834. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  39835. * to remove elements from an array by predicate.
  39836. *
  39837. * @static
  39838. * @memberOf _
  39839. * @since 2.0.0
  39840. * @category Array
  39841. * @param {Array} array The array to modify.
  39842. * @param {...*} [values] The values to remove.
  39843. * @returns {Array} Returns `array`.
  39844. * @example
  39845. *
  39846. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  39847. *
  39848. * _.pull(array, 'a', 'c');
  39849. * console.log(array);
  39850. * // => ['b', 'b']
  39851. */
  39852. var pull = baseRest(pullAll);
  39853. /**
  39854. * This method is like `_.pull` except that it accepts an array of values to remove.
  39855. *
  39856. * **Note:** Unlike `_.difference`, this method mutates `array`.
  39857. *
  39858. * @static
  39859. * @memberOf _
  39860. * @since 4.0.0
  39861. * @category Array
  39862. * @param {Array} array The array to modify.
  39863. * @param {Array} values The values to remove.
  39864. * @returns {Array} Returns `array`.
  39865. * @example
  39866. *
  39867. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  39868. *
  39869. * _.pullAll(array, ['a', 'c']);
  39870. * console.log(array);
  39871. * // => ['b', 'b']
  39872. */
  39873. function pullAll(array, values) {
  39874. return (array && array.length && values && values.length)
  39875. ? basePullAll(array, values)
  39876. : array;
  39877. }
  39878. /**
  39879. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  39880. * invoked for each element of `array` and `values` to generate the criterion
  39881. * by which they're compared. The iteratee is invoked with one argument: (value).
  39882. *
  39883. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  39884. *
  39885. * @static
  39886. * @memberOf _
  39887. * @since 4.0.0
  39888. * @category Array
  39889. * @param {Array} array The array to modify.
  39890. * @param {Array} values The values to remove.
  39891. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  39892. * @returns {Array} Returns `array`.
  39893. * @example
  39894. *
  39895. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  39896. *
  39897. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  39898. * console.log(array);
  39899. * // => [{ 'x': 2 }]
  39900. */
  39901. function pullAllBy(array, values, iteratee) {
  39902. return (array && array.length && values && values.length)
  39903. ? basePullAll(array, values, getIteratee(iteratee, 2))
  39904. : array;
  39905. }
  39906. /**
  39907. * This method is like `_.pullAll` except that it accepts `comparator` which
  39908. * is invoked to compare elements of `array` to `values`. The comparator is
  39909. * invoked with two arguments: (arrVal, othVal).
  39910. *
  39911. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  39912. *
  39913. * @static
  39914. * @memberOf _
  39915. * @since 4.6.0
  39916. * @category Array
  39917. * @param {Array} array The array to modify.
  39918. * @param {Array} values The values to remove.
  39919. * @param {Function} [comparator] The comparator invoked per element.
  39920. * @returns {Array} Returns `array`.
  39921. * @example
  39922. *
  39923. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  39924. *
  39925. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  39926. * console.log(array);
  39927. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  39928. */
  39929. function pullAllWith(array, values, comparator) {
  39930. return (array && array.length && values && values.length)
  39931. ? basePullAll(array, values, undefined, comparator)
  39932. : array;
  39933. }
  39934. /**
  39935. * Removes elements from `array` corresponding to `indexes` and returns an
  39936. * array of removed elements.
  39937. *
  39938. * **Note:** Unlike `_.at`, this method mutates `array`.
  39939. *
  39940. * @static
  39941. * @memberOf _
  39942. * @since 3.0.0
  39943. * @category Array
  39944. * @param {Array} array The array to modify.
  39945. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  39946. * @returns {Array} Returns the new array of removed elements.
  39947. * @example
  39948. *
  39949. * var array = ['a', 'b', 'c', 'd'];
  39950. * var pulled = _.pullAt(array, [1, 3]);
  39951. *
  39952. * console.log(array);
  39953. * // => ['a', 'c']
  39954. *
  39955. * console.log(pulled);
  39956. * // => ['b', 'd']
  39957. */
  39958. var pullAt = flatRest(function(array, indexes) {
  39959. var length = array == null ? 0 : array.length,
  39960. result = baseAt(array, indexes);
  39961. basePullAt(array, arrayMap(indexes, function(index) {
  39962. return isIndex(index, length) ? +index : index;
  39963. }).sort(compareAscending));
  39964. return result;
  39965. });
  39966. /**
  39967. * Removes all elements from `array` that `predicate` returns truthy for
  39968. * and returns an array of the removed elements. The predicate is invoked
  39969. * with three arguments: (value, index, array).
  39970. *
  39971. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  39972. * to pull elements from an array by value.
  39973. *
  39974. * @static
  39975. * @memberOf _
  39976. * @since 2.0.0
  39977. * @category Array
  39978. * @param {Array} array The array to modify.
  39979. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  39980. * @returns {Array} Returns the new array of removed elements.
  39981. * @example
  39982. *
  39983. * var array = [1, 2, 3, 4];
  39984. * var evens = _.remove(array, function(n) {
  39985. * return n % 2 == 0;
  39986. * });
  39987. *
  39988. * console.log(array);
  39989. * // => [1, 3]
  39990. *
  39991. * console.log(evens);
  39992. * // => [2, 4]
  39993. */
  39994. function remove(array, predicate) {
  39995. var result = [];
  39996. if (!(array && array.length)) {
  39997. return result;
  39998. }
  39999. var index = -1,
  40000. indexes = [],
  40001. length = array.length;
  40002. predicate = getIteratee(predicate, 3);
  40003. while (++index < length) {
  40004. var value = array[index];
  40005. if (predicate(value, index, array)) {
  40006. result.push(value);
  40007. indexes.push(index);
  40008. }
  40009. }
  40010. basePullAt(array, indexes);
  40011. return result;
  40012. }
  40013. /**
  40014. * Reverses `array` so that the first element becomes the last, the second
  40015. * element becomes the second to last, and so on.
  40016. *
  40017. * **Note:** This method mutates `array` and is based on
  40018. * [`Array#reverse`](https://mdn.io/Array/reverse).
  40019. *
  40020. * @static
  40021. * @memberOf _
  40022. * @since 4.0.0
  40023. * @category Array
  40024. * @param {Array} array The array to modify.
  40025. * @returns {Array} Returns `array`.
  40026. * @example
  40027. *
  40028. * var array = [1, 2, 3];
  40029. *
  40030. * _.reverse(array);
  40031. * // => [3, 2, 1]
  40032. *
  40033. * console.log(array);
  40034. * // => [3, 2, 1]
  40035. */
  40036. function reverse(array) {
  40037. return array == null ? array : nativeReverse.call(array);
  40038. }
  40039. /**
  40040. * Creates a slice of `array` from `start` up to, but not including, `end`.
  40041. *
  40042. * **Note:** This method is used instead of
  40043. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  40044. * returned.
  40045. *
  40046. * @static
  40047. * @memberOf _
  40048. * @since 3.0.0
  40049. * @category Array
  40050. * @param {Array} array The array to slice.
  40051. * @param {number} [start=0] The start position.
  40052. * @param {number} [end=array.length] The end position.
  40053. * @returns {Array} Returns the slice of `array`.
  40054. */
  40055. function slice(array, start, end) {
  40056. var length = array == null ? 0 : array.length;
  40057. if (!length) {
  40058. return [];
  40059. }
  40060. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  40061. start = 0;
  40062. end = length;
  40063. }
  40064. else {
  40065. start = start == null ? 0 : toInteger(start);
  40066. end = end === undefined ? length : toInteger(end);
  40067. }
  40068. return baseSlice(array, start, end);
  40069. }
  40070. /**
  40071. * Uses a binary search to determine the lowest index at which `value`
  40072. * should be inserted into `array` in order to maintain its sort order.
  40073. *
  40074. * @static
  40075. * @memberOf _
  40076. * @since 0.1.0
  40077. * @category Array
  40078. * @param {Array} array The sorted array to inspect.
  40079. * @param {*} value The value to evaluate.
  40080. * @returns {number} Returns the index at which `value` should be inserted
  40081. * into `array`.
  40082. * @example
  40083. *
  40084. * _.sortedIndex([30, 50], 40);
  40085. * // => 1
  40086. */
  40087. function sortedIndex(array, value) {
  40088. return baseSortedIndex(array, value);
  40089. }
  40090. /**
  40091. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  40092. * which is invoked for `value` and each element of `array` to compute their
  40093. * sort ranking. The iteratee is invoked with one argument: (value).
  40094. *
  40095. * @static
  40096. * @memberOf _
  40097. * @since 4.0.0
  40098. * @category Array
  40099. * @param {Array} array The sorted array to inspect.
  40100. * @param {*} value The value to evaluate.
  40101. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  40102. * @returns {number} Returns the index at which `value` should be inserted
  40103. * into `array`.
  40104. * @example
  40105. *
  40106. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  40107. *
  40108. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  40109. * // => 0
  40110. *
  40111. * // The `_.property` iteratee shorthand.
  40112. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  40113. * // => 0
  40114. */
  40115. function sortedIndexBy(array, value, iteratee) {
  40116. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  40117. }
  40118. /**
  40119. * This method is like `_.indexOf` except that it performs a binary
  40120. * search on a sorted `array`.
  40121. *
  40122. * @static
  40123. * @memberOf _
  40124. * @since 4.0.0
  40125. * @category Array
  40126. * @param {Array} array The array to inspect.
  40127. * @param {*} value The value to search for.
  40128. * @returns {number} Returns the index of the matched value, else `-1`.
  40129. * @example
  40130. *
  40131. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  40132. * // => 1
  40133. */
  40134. function sortedIndexOf(array, value) {
  40135. var length = array == null ? 0 : array.length;
  40136. if (length) {
  40137. var index = baseSortedIndex(array, value);
  40138. if (index < length && eq(array[index], value)) {
  40139. return index;
  40140. }
  40141. }
  40142. return -1;
  40143. }
  40144. /**
  40145. * This method is like `_.sortedIndex` except that it returns the highest
  40146. * index at which `value` should be inserted into `array` in order to
  40147. * maintain its sort order.
  40148. *
  40149. * @static
  40150. * @memberOf _
  40151. * @since 3.0.0
  40152. * @category Array
  40153. * @param {Array} array The sorted array to inspect.
  40154. * @param {*} value The value to evaluate.
  40155. * @returns {number} Returns the index at which `value` should be inserted
  40156. * into `array`.
  40157. * @example
  40158. *
  40159. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  40160. * // => 4
  40161. */
  40162. function sortedLastIndex(array, value) {
  40163. return baseSortedIndex(array, value, true);
  40164. }
  40165. /**
  40166. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  40167. * which is invoked for `value` and each element of `array` to compute their
  40168. * sort ranking. The iteratee is invoked with one argument: (value).
  40169. *
  40170. * @static
  40171. * @memberOf _
  40172. * @since 4.0.0
  40173. * @category Array
  40174. * @param {Array} array The sorted array to inspect.
  40175. * @param {*} value The value to evaluate.
  40176. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  40177. * @returns {number} Returns the index at which `value` should be inserted
  40178. * into `array`.
  40179. * @example
  40180. *
  40181. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  40182. *
  40183. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  40184. * // => 1
  40185. *
  40186. * // The `_.property` iteratee shorthand.
  40187. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  40188. * // => 1
  40189. */
  40190. function sortedLastIndexBy(array, value, iteratee) {
  40191. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  40192. }
  40193. /**
  40194. * This method is like `_.lastIndexOf` except that it performs a binary
  40195. * search on a sorted `array`.
  40196. *
  40197. * @static
  40198. * @memberOf _
  40199. * @since 4.0.0
  40200. * @category Array
  40201. * @param {Array} array The array to inspect.
  40202. * @param {*} value The value to search for.
  40203. * @returns {number} Returns the index of the matched value, else `-1`.
  40204. * @example
  40205. *
  40206. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  40207. * // => 3
  40208. */
  40209. function sortedLastIndexOf(array, value) {
  40210. var length = array == null ? 0 : array.length;
  40211. if (length) {
  40212. var index = baseSortedIndex(array, value, true) - 1;
  40213. if (eq(array[index], value)) {
  40214. return index;
  40215. }
  40216. }
  40217. return -1;
  40218. }
  40219. /**
  40220. * This method is like `_.uniq` except that it's designed and optimized
  40221. * for sorted arrays.
  40222. *
  40223. * @static
  40224. * @memberOf _
  40225. * @since 4.0.0
  40226. * @category Array
  40227. * @param {Array} array The array to inspect.
  40228. * @returns {Array} Returns the new duplicate free array.
  40229. * @example
  40230. *
  40231. * _.sortedUniq([1, 1, 2]);
  40232. * // => [1, 2]
  40233. */
  40234. function sortedUniq(array) {
  40235. return (array && array.length)
  40236. ? baseSortedUniq(array)
  40237. : [];
  40238. }
  40239. /**
  40240. * This method is like `_.uniqBy` except that it's designed and optimized
  40241. * for sorted arrays.
  40242. *
  40243. * @static
  40244. * @memberOf _
  40245. * @since 4.0.0
  40246. * @category Array
  40247. * @param {Array} array The array to inspect.
  40248. * @param {Function} [iteratee] The iteratee invoked per element.
  40249. * @returns {Array} Returns the new duplicate free array.
  40250. * @example
  40251. *
  40252. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  40253. * // => [1.1, 2.3]
  40254. */
  40255. function sortedUniqBy(array, iteratee) {
  40256. return (array && array.length)
  40257. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  40258. : [];
  40259. }
  40260. /**
  40261. * Gets all but the first element of `array`.
  40262. *
  40263. * @static
  40264. * @memberOf _
  40265. * @since 4.0.0
  40266. * @category Array
  40267. * @param {Array} array The array to query.
  40268. * @returns {Array} Returns the slice of `array`.
  40269. * @example
  40270. *
  40271. * _.tail([1, 2, 3]);
  40272. * // => [2, 3]
  40273. */
  40274. function tail(array) {
  40275. var length = array == null ? 0 : array.length;
  40276. return length ? baseSlice(array, 1, length) : [];
  40277. }
  40278. /**
  40279. * Creates a slice of `array` with `n` elements taken from the beginning.
  40280. *
  40281. * @static
  40282. * @memberOf _
  40283. * @since 0.1.0
  40284. * @category Array
  40285. * @param {Array} array The array to query.
  40286. * @param {number} [n=1] The number of elements to take.
  40287. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  40288. * @returns {Array} Returns the slice of `array`.
  40289. * @example
  40290. *
  40291. * _.take([1, 2, 3]);
  40292. * // => [1]
  40293. *
  40294. * _.take([1, 2, 3], 2);
  40295. * // => [1, 2]
  40296. *
  40297. * _.take([1, 2, 3], 5);
  40298. * // => [1, 2, 3]
  40299. *
  40300. * _.take([1, 2, 3], 0);
  40301. * // => []
  40302. */
  40303. function take(array, n, guard) {
  40304. if (!(array && array.length)) {
  40305. return [];
  40306. }
  40307. n = (guard || n === undefined) ? 1 : toInteger(n);
  40308. return baseSlice(array, 0, n < 0 ? 0 : n);
  40309. }
  40310. /**
  40311. * Creates a slice of `array` with `n` elements taken from the end.
  40312. *
  40313. * @static
  40314. * @memberOf _
  40315. * @since 3.0.0
  40316. * @category Array
  40317. * @param {Array} array The array to query.
  40318. * @param {number} [n=1] The number of elements to take.
  40319. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  40320. * @returns {Array} Returns the slice of `array`.
  40321. * @example
  40322. *
  40323. * _.takeRight([1, 2, 3]);
  40324. * // => [3]
  40325. *
  40326. * _.takeRight([1, 2, 3], 2);
  40327. * // => [2, 3]
  40328. *
  40329. * _.takeRight([1, 2, 3], 5);
  40330. * // => [1, 2, 3]
  40331. *
  40332. * _.takeRight([1, 2, 3], 0);
  40333. * // => []
  40334. */
  40335. function takeRight(array, n, guard) {
  40336. var length = array == null ? 0 : array.length;
  40337. if (!length) {
  40338. return [];
  40339. }
  40340. n = (guard || n === undefined) ? 1 : toInteger(n);
  40341. n = length - n;
  40342. return baseSlice(array, n < 0 ? 0 : n, length);
  40343. }
  40344. /**
  40345. * Creates a slice of `array` with elements taken from the end. Elements are
  40346. * taken until `predicate` returns falsey. The predicate is invoked with
  40347. * three arguments: (value, index, array).
  40348. *
  40349. * @static
  40350. * @memberOf _
  40351. * @since 3.0.0
  40352. * @category Array
  40353. * @param {Array} array The array to query.
  40354. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  40355. * @returns {Array} Returns the slice of `array`.
  40356. * @example
  40357. *
  40358. * var users = [
  40359. * { 'user': 'barney', 'active': true },
  40360. * { 'user': 'fred', 'active': false },
  40361. * { 'user': 'pebbles', 'active': false }
  40362. * ];
  40363. *
  40364. * _.takeRightWhile(users, function(o) { return !o.active; });
  40365. * // => objects for ['fred', 'pebbles']
  40366. *
  40367. * // The `_.matches` iteratee shorthand.
  40368. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  40369. * // => objects for ['pebbles']
  40370. *
  40371. * // The `_.matchesProperty` iteratee shorthand.
  40372. * _.takeRightWhile(users, ['active', false]);
  40373. * // => objects for ['fred', 'pebbles']
  40374. *
  40375. * // The `_.property` iteratee shorthand.
  40376. * _.takeRightWhile(users, 'active');
  40377. * // => []
  40378. */
  40379. function takeRightWhile(array, predicate) {
  40380. return (array && array.length)
  40381. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  40382. : [];
  40383. }
  40384. /**
  40385. * Creates a slice of `array` with elements taken from the beginning. Elements
  40386. * are taken until `predicate` returns falsey. The predicate is invoked with
  40387. * three arguments: (value, index, array).
  40388. *
  40389. * @static
  40390. * @memberOf _
  40391. * @since 3.0.0
  40392. * @category Array
  40393. * @param {Array} array The array to query.
  40394. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  40395. * @returns {Array} Returns the slice of `array`.
  40396. * @example
  40397. *
  40398. * var users = [
  40399. * { 'user': 'barney', 'active': false },
  40400. * { 'user': 'fred', 'active': false },
  40401. * { 'user': 'pebbles', 'active': true }
  40402. * ];
  40403. *
  40404. * _.takeWhile(users, function(o) { return !o.active; });
  40405. * // => objects for ['barney', 'fred']
  40406. *
  40407. * // The `_.matches` iteratee shorthand.
  40408. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  40409. * // => objects for ['barney']
  40410. *
  40411. * // The `_.matchesProperty` iteratee shorthand.
  40412. * _.takeWhile(users, ['active', false]);
  40413. * // => objects for ['barney', 'fred']
  40414. *
  40415. * // The `_.property` iteratee shorthand.
  40416. * _.takeWhile(users, 'active');
  40417. * // => []
  40418. */
  40419. function takeWhile(array, predicate) {
  40420. return (array && array.length)
  40421. ? baseWhile(array, getIteratee(predicate, 3))
  40422. : [];
  40423. }
  40424. /**
  40425. * Creates an array of unique values, in order, from all given arrays using
  40426. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  40427. * for equality comparisons.
  40428. *
  40429. * @static
  40430. * @memberOf _
  40431. * @since 0.1.0
  40432. * @category Array
  40433. * @param {...Array} [arrays] The arrays to inspect.
  40434. * @returns {Array} Returns the new array of combined values.
  40435. * @example
  40436. *
  40437. * _.union([2], [1, 2]);
  40438. * // => [2, 1]
  40439. */
  40440. var union = baseRest(function(arrays) {
  40441. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  40442. });
  40443. /**
  40444. * This method is like `_.union` except that it accepts `iteratee` which is
  40445. * invoked for each element of each `arrays` to generate the criterion by
  40446. * which uniqueness is computed. Result values are chosen from the first
  40447. * array in which the value occurs. The iteratee is invoked with one argument:
  40448. * (value).
  40449. *
  40450. * @static
  40451. * @memberOf _
  40452. * @since 4.0.0
  40453. * @category Array
  40454. * @param {...Array} [arrays] The arrays to inspect.
  40455. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  40456. * @returns {Array} Returns the new array of combined values.
  40457. * @example
  40458. *
  40459. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  40460. * // => [2.1, 1.2]
  40461. *
  40462. * // The `_.property` iteratee shorthand.
  40463. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  40464. * // => [{ 'x': 1 }, { 'x': 2 }]
  40465. */
  40466. var unionBy = baseRest(function(arrays) {
  40467. var iteratee = last(arrays);
  40468. if (isArrayLikeObject(iteratee)) {
  40469. iteratee = undefined;
  40470. }
  40471. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  40472. });
  40473. /**
  40474. * This method is like `_.union` except that it accepts `comparator` which
  40475. * is invoked to compare elements of `arrays`. Result values are chosen from
  40476. * the first array in which the value occurs. The comparator is invoked
  40477. * with two arguments: (arrVal, othVal).
  40478. *
  40479. * @static
  40480. * @memberOf _
  40481. * @since 4.0.0
  40482. * @category Array
  40483. * @param {...Array} [arrays] The arrays to inspect.
  40484. * @param {Function} [comparator] The comparator invoked per element.
  40485. * @returns {Array} Returns the new array of combined values.
  40486. * @example
  40487. *
  40488. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  40489. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  40490. *
  40491. * _.unionWith(objects, others, _.isEqual);
  40492. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  40493. */
  40494. var unionWith = baseRest(function(arrays) {
  40495. var comparator = last(arrays);
  40496. comparator = typeof comparator == 'function' ? comparator : undefined;
  40497. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
  40498. });
  40499. /**
  40500. * Creates a duplicate-free version of an array, using
  40501. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  40502. * for equality comparisons, in which only the first occurrence of each element
  40503. * is kept. The order of result values is determined by the order they occur
  40504. * in the array.
  40505. *
  40506. * @static
  40507. * @memberOf _
  40508. * @since 0.1.0
  40509. * @category Array
  40510. * @param {Array} array The array to inspect.
  40511. * @returns {Array} Returns the new duplicate free array.
  40512. * @example
  40513. *
  40514. * _.uniq([2, 1, 2]);
  40515. * // => [2, 1]
  40516. */
  40517. function uniq(array) {
  40518. return (array && array.length) ? baseUniq(array) : [];
  40519. }
  40520. /**
  40521. * This method is like `_.uniq` except that it accepts `iteratee` which is
  40522. * invoked for each element in `array` to generate the criterion by which
  40523. * uniqueness is computed. The order of result values is determined by the
  40524. * order they occur in the array. The iteratee is invoked with one argument:
  40525. * (value).
  40526. *
  40527. * @static
  40528. * @memberOf _
  40529. * @since 4.0.0
  40530. * @category Array
  40531. * @param {Array} array The array to inspect.
  40532. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  40533. * @returns {Array} Returns the new duplicate free array.
  40534. * @example
  40535. *
  40536. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  40537. * // => [2.1, 1.2]
  40538. *
  40539. * // The `_.property` iteratee shorthand.
  40540. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  40541. * // => [{ 'x': 1 }, { 'x': 2 }]
  40542. */
  40543. function uniqBy(array, iteratee) {
  40544. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  40545. }
  40546. /**
  40547. * This method is like `_.uniq` except that it accepts `comparator` which
  40548. * is invoked to compare elements of `array`. The order of result values is
  40549. * determined by the order they occur in the array.The comparator is invoked
  40550. * with two arguments: (arrVal, othVal).
  40551. *
  40552. * @static
  40553. * @memberOf _
  40554. * @since 4.0.0
  40555. * @category Array
  40556. * @param {Array} array The array to inspect.
  40557. * @param {Function} [comparator] The comparator invoked per element.
  40558. * @returns {Array} Returns the new duplicate free array.
  40559. * @example
  40560. *
  40561. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  40562. *
  40563. * _.uniqWith(objects, _.isEqual);
  40564. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  40565. */
  40566. function uniqWith(array, comparator) {
  40567. comparator = typeof comparator == 'function' ? comparator : undefined;
  40568. return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
  40569. }
  40570. /**
  40571. * This method is like `_.zip` except that it accepts an array of grouped
  40572. * elements and creates an array regrouping the elements to their pre-zip
  40573. * configuration.
  40574. *
  40575. * @static
  40576. * @memberOf _
  40577. * @since 1.2.0
  40578. * @category Array
  40579. * @param {Array} array The array of grouped elements to process.
  40580. * @returns {Array} Returns the new array of regrouped elements.
  40581. * @example
  40582. *
  40583. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  40584. * // => [['a', 1, true], ['b', 2, false]]
  40585. *
  40586. * _.unzip(zipped);
  40587. * // => [['a', 'b'], [1, 2], [true, false]]
  40588. */
  40589. function unzip(array) {
  40590. if (!(array && array.length)) {
  40591. return [];
  40592. }
  40593. var length = 0;
  40594. array = arrayFilter(array, function(group) {
  40595. if (isArrayLikeObject(group)) {
  40596. length = nativeMax(group.length, length);
  40597. return true;
  40598. }
  40599. });
  40600. return baseTimes(length, function(index) {
  40601. return arrayMap(array, baseProperty(index));
  40602. });
  40603. }
  40604. /**
  40605. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  40606. * how regrouped values should be combined. The iteratee is invoked with the
  40607. * elements of each group: (...group).
  40608. *
  40609. * @static
  40610. * @memberOf _
  40611. * @since 3.8.0
  40612. * @category Array
  40613. * @param {Array} array The array of grouped elements to process.
  40614. * @param {Function} [iteratee=_.identity] The function to combine
  40615. * regrouped values.
  40616. * @returns {Array} Returns the new array of regrouped elements.
  40617. * @example
  40618. *
  40619. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  40620. * // => [[1, 10, 100], [2, 20, 200]]
  40621. *
  40622. * _.unzipWith(zipped, _.add);
  40623. * // => [3, 30, 300]
  40624. */
  40625. function unzipWith(array, iteratee) {
  40626. if (!(array && array.length)) {
  40627. return [];
  40628. }
  40629. var result = unzip(array);
  40630. if (iteratee == null) {
  40631. return result;
  40632. }
  40633. return arrayMap(result, function(group) {
  40634. return apply(iteratee, undefined, group);
  40635. });
  40636. }
  40637. /**
  40638. * Creates an array excluding all given values using
  40639. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  40640. * for equality comparisons.
  40641. *
  40642. * **Note:** Unlike `_.pull`, this method returns a new array.
  40643. *
  40644. * @static
  40645. * @memberOf _
  40646. * @since 0.1.0
  40647. * @category Array
  40648. * @param {Array} array The array to inspect.
  40649. * @param {...*} [values] The values to exclude.
  40650. * @returns {Array} Returns the new array of filtered values.
  40651. * @see _.difference, _.xor
  40652. * @example
  40653. *
  40654. * _.without([2, 1, 2, 3], 1, 2);
  40655. * // => [3]
  40656. */
  40657. var without = baseRest(function(array, values) {
  40658. return isArrayLikeObject(array)
  40659. ? baseDifference(array, values)
  40660. : [];
  40661. });
  40662. /**
  40663. * Creates an array of unique values that is the
  40664. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  40665. * of the given arrays. The order of result values is determined by the order
  40666. * they occur in the arrays.
  40667. *
  40668. * @static
  40669. * @memberOf _
  40670. * @since 2.4.0
  40671. * @category Array
  40672. * @param {...Array} [arrays] The arrays to inspect.
  40673. * @returns {Array} Returns the new array of filtered values.
  40674. * @see _.difference, _.without
  40675. * @example
  40676. *
  40677. * _.xor([2, 1], [2, 3]);
  40678. * // => [1, 3]
  40679. */
  40680. var xor = baseRest(function(arrays) {
  40681. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  40682. });
  40683. /**
  40684. * This method is like `_.xor` except that it accepts `iteratee` which is
  40685. * invoked for each element of each `arrays` to generate the criterion by
  40686. * which by which they're compared. The order of result values is determined
  40687. * by the order they occur in the arrays. The iteratee is invoked with one
  40688. * argument: (value).
  40689. *
  40690. * @static
  40691. * @memberOf _
  40692. * @since 4.0.0
  40693. * @category Array
  40694. * @param {...Array} [arrays] The arrays to inspect.
  40695. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  40696. * @returns {Array} Returns the new array of filtered values.
  40697. * @example
  40698. *
  40699. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  40700. * // => [1.2, 3.4]
  40701. *
  40702. * // The `_.property` iteratee shorthand.
  40703. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  40704. * // => [{ 'x': 2 }]
  40705. */
  40706. var xorBy = baseRest(function(arrays) {
  40707. var iteratee = last(arrays);
  40708. if (isArrayLikeObject(iteratee)) {
  40709. iteratee = undefined;
  40710. }
  40711. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  40712. });
  40713. /**
  40714. * This method is like `_.xor` except that it accepts `comparator` which is
  40715. * invoked to compare elements of `arrays`. The order of result values is
  40716. * determined by the order they occur in the arrays. The comparator is invoked
  40717. * with two arguments: (arrVal, othVal).
  40718. *
  40719. * @static
  40720. * @memberOf _
  40721. * @since 4.0.0
  40722. * @category Array
  40723. * @param {...Array} [arrays] The arrays to inspect.
  40724. * @param {Function} [comparator] The comparator invoked per element.
  40725. * @returns {Array} Returns the new array of filtered values.
  40726. * @example
  40727. *
  40728. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  40729. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  40730. *
  40731. * _.xorWith(objects, others, _.isEqual);
  40732. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  40733. */
  40734. var xorWith = baseRest(function(arrays) {
  40735. var comparator = last(arrays);
  40736. comparator = typeof comparator == 'function' ? comparator : undefined;
  40737. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
  40738. });
  40739. /**
  40740. * Creates an array of grouped elements, the first of which contains the
  40741. * first elements of the given arrays, the second of which contains the
  40742. * second elements of the given arrays, and so on.
  40743. *
  40744. * @static
  40745. * @memberOf _
  40746. * @since 0.1.0
  40747. * @category Array
  40748. * @param {...Array} [arrays] The arrays to process.
  40749. * @returns {Array} Returns the new array of grouped elements.
  40750. * @example
  40751. *
  40752. * _.zip(['a', 'b'], [1, 2], [true, false]);
  40753. * // => [['a', 1, true], ['b', 2, false]]
  40754. */
  40755. var zip = baseRest(unzip);
  40756. /**
  40757. * This method is like `_.fromPairs` except that it accepts two arrays,
  40758. * one of property identifiers and one of corresponding values.
  40759. *
  40760. * @static
  40761. * @memberOf _
  40762. * @since 0.4.0
  40763. * @category Array
  40764. * @param {Array} [props=[]] The property identifiers.
  40765. * @param {Array} [values=[]] The property values.
  40766. * @returns {Object} Returns the new object.
  40767. * @example
  40768. *
  40769. * _.zipObject(['a', 'b'], [1, 2]);
  40770. * // => { 'a': 1, 'b': 2 }
  40771. */
  40772. function zipObject(props, values) {
  40773. return baseZipObject(props || [], values || [], assignValue);
  40774. }
  40775. /**
  40776. * This method is like `_.zipObject` except that it supports property paths.
  40777. *
  40778. * @static
  40779. * @memberOf _
  40780. * @since 4.1.0
  40781. * @category Array
  40782. * @param {Array} [props=[]] The property identifiers.
  40783. * @param {Array} [values=[]] The property values.
  40784. * @returns {Object} Returns the new object.
  40785. * @example
  40786. *
  40787. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  40788. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  40789. */
  40790. function zipObjectDeep(props, values) {
  40791. return baseZipObject(props || [], values || [], baseSet);
  40792. }
  40793. /**
  40794. * This method is like `_.zip` except that it accepts `iteratee` to specify
  40795. * how grouped values should be combined. The iteratee is invoked with the
  40796. * elements of each group: (...group).
  40797. *
  40798. * @static
  40799. * @memberOf _
  40800. * @since 3.8.0
  40801. * @category Array
  40802. * @param {...Array} [arrays] The arrays to process.
  40803. * @param {Function} [iteratee=_.identity] The function to combine
  40804. * grouped values.
  40805. * @returns {Array} Returns the new array of grouped elements.
  40806. * @example
  40807. *
  40808. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  40809. * return a + b + c;
  40810. * });
  40811. * // => [111, 222]
  40812. */
  40813. var zipWith = baseRest(function(arrays) {
  40814. var length = arrays.length,
  40815. iteratee = length > 1 ? arrays[length - 1] : undefined;
  40816. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
  40817. return unzipWith(arrays, iteratee);
  40818. });
  40819. /*------------------------------------------------------------------------*/
  40820. /**
  40821. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  40822. * chain sequences enabled. The result of such sequences must be unwrapped
  40823. * with `_#value`.
  40824. *
  40825. * @static
  40826. * @memberOf _
  40827. * @since 1.3.0
  40828. * @category Seq
  40829. * @param {*} value The value to wrap.
  40830. * @returns {Object} Returns the new `lodash` wrapper instance.
  40831. * @example
  40832. *
  40833. * var users = [
  40834. * { 'user': 'barney', 'age': 36 },
  40835. * { 'user': 'fred', 'age': 40 },
  40836. * { 'user': 'pebbles', 'age': 1 }
  40837. * ];
  40838. *
  40839. * var youngest = _
  40840. * .chain(users)
  40841. * .sortBy('age')
  40842. * .map(function(o) {
  40843. * return o.user + ' is ' + o.age;
  40844. * })
  40845. * .head()
  40846. * .value();
  40847. * // => 'pebbles is 1'
  40848. */
  40849. function chain(value) {
  40850. var result = lodash(value);
  40851. result.__chain__ = true;
  40852. return result;
  40853. }
  40854. /**
  40855. * This method invokes `interceptor` and returns `value`. The interceptor
  40856. * is invoked with one argument; (value). The purpose of this method is to
  40857. * "tap into" a method chain sequence in order to modify intermediate results.
  40858. *
  40859. * @static
  40860. * @memberOf _
  40861. * @since 0.1.0
  40862. * @category Seq
  40863. * @param {*} value The value to provide to `interceptor`.
  40864. * @param {Function} interceptor The function to invoke.
  40865. * @returns {*} Returns `value`.
  40866. * @example
  40867. *
  40868. * _([1, 2, 3])
  40869. * .tap(function(array) {
  40870. * // Mutate input array.
  40871. * array.pop();
  40872. * })
  40873. * .reverse()
  40874. * .value();
  40875. * // => [2, 1]
  40876. */
  40877. function tap(value, interceptor) {
  40878. interceptor(value);
  40879. return value;
  40880. }
  40881. /**
  40882. * This method is like `_.tap` except that it returns the result of `interceptor`.
  40883. * The purpose of this method is to "pass thru" values replacing intermediate
  40884. * results in a method chain sequence.
  40885. *
  40886. * @static
  40887. * @memberOf _
  40888. * @since 3.0.0
  40889. * @category Seq
  40890. * @param {*} value The value to provide to `interceptor`.
  40891. * @param {Function} interceptor The function to invoke.
  40892. * @returns {*} Returns the result of `interceptor`.
  40893. * @example
  40894. *
  40895. * _(' abc ')
  40896. * .chain()
  40897. * .trim()
  40898. * .thru(function(value) {
  40899. * return [value];
  40900. * })
  40901. * .value();
  40902. * // => ['abc']
  40903. */
  40904. function thru(value, interceptor) {
  40905. return interceptor(value);
  40906. }
  40907. /**
  40908. * This method is the wrapper version of `_.at`.
  40909. *
  40910. * @name at
  40911. * @memberOf _
  40912. * @since 1.0.0
  40913. * @category Seq
  40914. * @param {...(string|string[])} [paths] The property paths to pick.
  40915. * @returns {Object} Returns the new `lodash` wrapper instance.
  40916. * @example
  40917. *
  40918. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  40919. *
  40920. * _(object).at(['a[0].b.c', 'a[1]']).value();
  40921. * // => [3, 4]
  40922. */
  40923. var wrapperAt = flatRest(function(paths) {
  40924. var length = paths.length,
  40925. start = length ? paths[0] : 0,
  40926. value = this.__wrapped__,
  40927. interceptor = function(object) { return baseAt(object, paths); };
  40928. if (length > 1 || this.__actions__.length ||
  40929. !(value instanceof LazyWrapper) || !isIndex(start)) {
  40930. return this.thru(interceptor);
  40931. }
  40932. value = value.slice(start, +start + (length ? 1 : 0));
  40933. value.__actions__.push({
  40934. 'func': thru,
  40935. 'args': [interceptor],
  40936. 'thisArg': undefined
  40937. });
  40938. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  40939. if (length && !array.length) {
  40940. array.push(undefined);
  40941. }
  40942. return array;
  40943. });
  40944. });
  40945. /**
  40946. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  40947. *
  40948. * @name chain
  40949. * @memberOf _
  40950. * @since 0.1.0
  40951. * @category Seq
  40952. * @returns {Object} Returns the new `lodash` wrapper instance.
  40953. * @example
  40954. *
  40955. * var users = [
  40956. * { 'user': 'barney', 'age': 36 },
  40957. * { 'user': 'fred', 'age': 40 }
  40958. * ];
  40959. *
  40960. * // A sequence without explicit chaining.
  40961. * _(users).head();
  40962. * // => { 'user': 'barney', 'age': 36 }
  40963. *
  40964. * // A sequence with explicit chaining.
  40965. * _(users)
  40966. * .chain()
  40967. * .head()
  40968. * .pick('user')
  40969. * .value();
  40970. * // => { 'user': 'barney' }
  40971. */
  40972. function wrapperChain() {
  40973. return chain(this);
  40974. }
  40975. /**
  40976. * Executes the chain sequence and returns the wrapped result.
  40977. *
  40978. * @name commit
  40979. * @memberOf _
  40980. * @since 3.2.0
  40981. * @category Seq
  40982. * @returns {Object} Returns the new `lodash` wrapper instance.
  40983. * @example
  40984. *
  40985. * var array = [1, 2];
  40986. * var wrapped = _(array).push(3);
  40987. *
  40988. * console.log(array);
  40989. * // => [1, 2]
  40990. *
  40991. * wrapped = wrapped.commit();
  40992. * console.log(array);
  40993. * // => [1, 2, 3]
  40994. *
  40995. * wrapped.last();
  40996. * // => 3
  40997. *
  40998. * console.log(array);
  40999. * // => [1, 2, 3]
  41000. */
  41001. function wrapperCommit() {
  41002. return new LodashWrapper(this.value(), this.__chain__);
  41003. }
  41004. /**
  41005. * Gets the next value on a wrapped object following the
  41006. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  41007. *
  41008. * @name next
  41009. * @memberOf _
  41010. * @since 4.0.0
  41011. * @category Seq
  41012. * @returns {Object} Returns the next iterator value.
  41013. * @example
  41014. *
  41015. * var wrapped = _([1, 2]);
  41016. *
  41017. * wrapped.next();
  41018. * // => { 'done': false, 'value': 1 }
  41019. *
  41020. * wrapped.next();
  41021. * // => { 'done': false, 'value': 2 }
  41022. *
  41023. * wrapped.next();
  41024. * // => { 'done': true, 'value': undefined }
  41025. */
  41026. function wrapperNext() {
  41027. if (this.__values__ === undefined) {
  41028. this.__values__ = toArray(this.value());
  41029. }
  41030. var done = this.__index__ >= this.__values__.length,
  41031. value = done ? undefined : this.__values__[this.__index__++];
  41032. return { 'done': done, 'value': value };
  41033. }
  41034. /**
  41035. * Enables the wrapper to be iterable.
  41036. *
  41037. * @name Symbol.iterator
  41038. * @memberOf _
  41039. * @since 4.0.0
  41040. * @category Seq
  41041. * @returns {Object} Returns the wrapper object.
  41042. * @example
  41043. *
  41044. * var wrapped = _([1, 2]);
  41045. *
  41046. * wrapped[Symbol.iterator]() === wrapped;
  41047. * // => true
  41048. *
  41049. * Array.from(wrapped);
  41050. * // => [1, 2]
  41051. */
  41052. function wrapperToIterator() {
  41053. return this;
  41054. }
  41055. /**
  41056. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  41057. *
  41058. * @name plant
  41059. * @memberOf _
  41060. * @since 3.2.0
  41061. * @category Seq
  41062. * @param {*} value The value to plant.
  41063. * @returns {Object} Returns the new `lodash` wrapper instance.
  41064. * @example
  41065. *
  41066. * function square(n) {
  41067. * return n * n;
  41068. * }
  41069. *
  41070. * var wrapped = _([1, 2]).map(square);
  41071. * var other = wrapped.plant([3, 4]);
  41072. *
  41073. * other.value();
  41074. * // => [9, 16]
  41075. *
  41076. * wrapped.value();
  41077. * // => [1, 4]
  41078. */
  41079. function wrapperPlant(value) {
  41080. var result,
  41081. parent = this;
  41082. while (parent instanceof baseLodash) {
  41083. var clone = wrapperClone(parent);
  41084. clone.__index__ = 0;
  41085. clone.__values__ = undefined;
  41086. if (result) {
  41087. previous.__wrapped__ = clone;
  41088. } else {
  41089. result = clone;
  41090. }
  41091. var previous = clone;
  41092. parent = parent.__wrapped__;
  41093. }
  41094. previous.__wrapped__ = value;
  41095. return result;
  41096. }
  41097. /**
  41098. * This method is the wrapper version of `_.reverse`.
  41099. *
  41100. * **Note:** This method mutates the wrapped array.
  41101. *
  41102. * @name reverse
  41103. * @memberOf _
  41104. * @since 0.1.0
  41105. * @category Seq
  41106. * @returns {Object} Returns the new `lodash` wrapper instance.
  41107. * @example
  41108. *
  41109. * var array = [1, 2, 3];
  41110. *
  41111. * _(array).reverse().value()
  41112. * // => [3, 2, 1]
  41113. *
  41114. * console.log(array);
  41115. * // => [3, 2, 1]
  41116. */
  41117. function wrapperReverse() {
  41118. var value = this.__wrapped__;
  41119. if (value instanceof LazyWrapper) {
  41120. var wrapped = value;
  41121. if (this.__actions__.length) {
  41122. wrapped = new LazyWrapper(this);
  41123. }
  41124. wrapped = wrapped.reverse();
  41125. wrapped.__actions__.push({
  41126. 'func': thru,
  41127. 'args': [reverse],
  41128. 'thisArg': undefined
  41129. });
  41130. return new LodashWrapper(wrapped, this.__chain__);
  41131. }
  41132. return this.thru(reverse);
  41133. }
  41134. /**
  41135. * Executes the chain sequence to resolve the unwrapped value.
  41136. *
  41137. * @name value
  41138. * @memberOf _
  41139. * @since 0.1.0
  41140. * @alias toJSON, valueOf
  41141. * @category Seq
  41142. * @returns {*} Returns the resolved unwrapped value.
  41143. * @example
  41144. *
  41145. * _([1, 2, 3]).value();
  41146. * // => [1, 2, 3]
  41147. */
  41148. function wrapperValue() {
  41149. return baseWrapperValue(this.__wrapped__, this.__actions__);
  41150. }
  41151. /*------------------------------------------------------------------------*/
  41152. /**
  41153. * Creates an object composed of keys generated from the results of running
  41154. * each element of `collection` thru `iteratee`. The corresponding value of
  41155. * each key is the number of times the key was returned by `iteratee`. The
  41156. * iteratee is invoked with one argument: (value).
  41157. *
  41158. * @static
  41159. * @memberOf _
  41160. * @since 0.5.0
  41161. * @category Collection
  41162. * @param {Array|Object} collection The collection to iterate over.
  41163. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  41164. * @returns {Object} Returns the composed aggregate object.
  41165. * @example
  41166. *
  41167. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  41168. * // => { '4': 1, '6': 2 }
  41169. *
  41170. * // The `_.property` iteratee shorthand.
  41171. * _.countBy(['one', 'two', 'three'], 'length');
  41172. * // => { '3': 2, '5': 1 }
  41173. */
  41174. var countBy = createAggregator(function(result, value, key) {
  41175. if (hasOwnProperty.call(result, key)) {
  41176. ++result[key];
  41177. } else {
  41178. baseAssignValue(result, key, 1);
  41179. }
  41180. });
  41181. /**
  41182. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  41183. * Iteration is stopped once `predicate` returns falsey. The predicate is
  41184. * invoked with three arguments: (value, index|key, collection).
  41185. *
  41186. * **Note:** This method returns `true` for
  41187. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  41188. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  41189. * elements of empty collections.
  41190. *
  41191. * @static
  41192. * @memberOf _
  41193. * @since 0.1.0
  41194. * @category Collection
  41195. * @param {Array|Object} collection The collection to iterate over.
  41196. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  41197. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  41198. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  41199. * else `false`.
  41200. * @example
  41201. *
  41202. * _.every([true, 1, null, 'yes'], Boolean);
  41203. * // => false
  41204. *
  41205. * var users = [
  41206. * { 'user': 'barney', 'age': 36, 'active': false },
  41207. * { 'user': 'fred', 'age': 40, 'active': false }
  41208. * ];
  41209. *
  41210. * // The `_.matches` iteratee shorthand.
  41211. * _.every(users, { 'user': 'barney', 'active': false });
  41212. * // => false
  41213. *
  41214. * // The `_.matchesProperty` iteratee shorthand.
  41215. * _.every(users, ['active', false]);
  41216. * // => true
  41217. *
  41218. * // The `_.property` iteratee shorthand.
  41219. * _.every(users, 'active');
  41220. * // => false
  41221. */
  41222. function every(collection, predicate, guard) {
  41223. var func = isArray(collection) ? arrayEvery : baseEvery;
  41224. if (guard && isIterateeCall(collection, predicate, guard)) {
  41225. predicate = undefined;
  41226. }
  41227. return func(collection, getIteratee(predicate, 3));
  41228. }
  41229. /**
  41230. * Iterates over elements of `collection`, returning an array of all elements
  41231. * `predicate` returns truthy for. The predicate is invoked with three
  41232. * arguments: (value, index|key, collection).
  41233. *
  41234. * **Note:** Unlike `_.remove`, this method returns a new array.
  41235. *
  41236. * @static
  41237. * @memberOf _
  41238. * @since 0.1.0
  41239. * @category Collection
  41240. * @param {Array|Object} collection The collection to iterate over.
  41241. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  41242. * @returns {Array} Returns the new filtered array.
  41243. * @see _.reject
  41244. * @example
  41245. *
  41246. * var users = [
  41247. * { 'user': 'barney', 'age': 36, 'active': true },
  41248. * { 'user': 'fred', 'age': 40, 'active': false }
  41249. * ];
  41250. *
  41251. * _.filter(users, function(o) { return !o.active; });
  41252. * // => objects for ['fred']
  41253. *
  41254. * // The `_.matches` iteratee shorthand.
  41255. * _.filter(users, { 'age': 36, 'active': true });
  41256. * // => objects for ['barney']
  41257. *
  41258. * // The `_.matchesProperty` iteratee shorthand.
  41259. * _.filter(users, ['active', false]);
  41260. * // => objects for ['fred']
  41261. *
  41262. * // The `_.property` iteratee shorthand.
  41263. * _.filter(users, 'active');
  41264. * // => objects for ['barney']
  41265. *
  41266. * // Combining several predicates using `_.overEvery` or `_.overSome`.
  41267. * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]]));
  41268. * // => objects for ['fred', 'barney']
  41269. */
  41270. function filter(collection, predicate) {
  41271. var func = isArray(collection) ? arrayFilter : baseFilter;
  41272. return func(collection, getIteratee(predicate, 3));
  41273. }
  41274. /**
  41275. * Iterates over elements of `collection`, returning the first element
  41276. * `predicate` returns truthy for. The predicate is invoked with three
  41277. * arguments: (value, index|key, collection).
  41278. *
  41279. * @static
  41280. * @memberOf _
  41281. * @since 0.1.0
  41282. * @category Collection
  41283. * @param {Array|Object} collection The collection to inspect.
  41284. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  41285. * @param {number} [fromIndex=0] The index to search from.
  41286. * @returns {*} Returns the matched element, else `undefined`.
  41287. * @example
  41288. *
  41289. * var users = [
  41290. * { 'user': 'barney', 'age': 36, 'active': true },
  41291. * { 'user': 'fred', 'age': 40, 'active': false },
  41292. * { 'user': 'pebbles', 'age': 1, 'active': true }
  41293. * ];
  41294. *
  41295. * _.find(users, function(o) { return o.age < 40; });
  41296. * // => object for 'barney'
  41297. *
  41298. * // The `_.matches` iteratee shorthand.
  41299. * _.find(users, { 'age': 1, 'active': true });
  41300. * // => object for 'pebbles'
  41301. *
  41302. * // The `_.matchesProperty` iteratee shorthand.
  41303. * _.find(users, ['active', false]);
  41304. * // => object for 'fred'
  41305. *
  41306. * // The `_.property` iteratee shorthand.
  41307. * _.find(users, 'active');
  41308. * // => object for 'barney'
  41309. */
  41310. var find = createFind(findIndex);
  41311. /**
  41312. * This method is like `_.find` except that it iterates over elements of
  41313. * `collection` from right to left.
  41314. *
  41315. * @static
  41316. * @memberOf _
  41317. * @since 2.0.0
  41318. * @category Collection
  41319. * @param {Array|Object} collection The collection to inspect.
  41320. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  41321. * @param {number} [fromIndex=collection.length-1] The index to search from.
  41322. * @returns {*} Returns the matched element, else `undefined`.
  41323. * @example
  41324. *
  41325. * _.findLast([1, 2, 3, 4], function(n) {
  41326. * return n % 2 == 1;
  41327. * });
  41328. * // => 3
  41329. */
  41330. var findLast = createFind(findLastIndex);
  41331. /**
  41332. * Creates a flattened array of values by running each element in `collection`
  41333. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  41334. * with three arguments: (value, index|key, collection).
  41335. *
  41336. * @static
  41337. * @memberOf _
  41338. * @since 4.0.0
  41339. * @category Collection
  41340. * @param {Array|Object} collection The collection to iterate over.
  41341. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  41342. * @returns {Array} Returns the new flattened array.
  41343. * @example
  41344. *
  41345. * function duplicate(n) {
  41346. * return [n, n];
  41347. * }
  41348. *
  41349. * _.flatMap([1, 2], duplicate);
  41350. * // => [1, 1, 2, 2]
  41351. */
  41352. function flatMap(collection, iteratee) {
  41353. return baseFlatten(map(collection, iteratee), 1);
  41354. }
  41355. /**
  41356. * This method is like `_.flatMap` except that it recursively flattens the
  41357. * mapped results.
  41358. *
  41359. * @static
  41360. * @memberOf _
  41361. * @since 4.7.0
  41362. * @category Collection
  41363. * @param {Array|Object} collection The collection to iterate over.
  41364. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  41365. * @returns {Array} Returns the new flattened array.
  41366. * @example
  41367. *
  41368. * function duplicate(n) {
  41369. * return [[[n, n]]];
  41370. * }
  41371. *
  41372. * _.flatMapDeep([1, 2], duplicate);
  41373. * // => [1, 1, 2, 2]
  41374. */
  41375. function flatMapDeep(collection, iteratee) {
  41376. return baseFlatten(map(collection, iteratee), INFINITY);
  41377. }
  41378. /**
  41379. * This method is like `_.flatMap` except that it recursively flattens the
  41380. * mapped results up to `depth` times.
  41381. *
  41382. * @static
  41383. * @memberOf _
  41384. * @since 4.7.0
  41385. * @category Collection
  41386. * @param {Array|Object} collection The collection to iterate over.
  41387. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  41388. * @param {number} [depth=1] The maximum recursion depth.
  41389. * @returns {Array} Returns the new flattened array.
  41390. * @example
  41391. *
  41392. * function duplicate(n) {
  41393. * return [[[n, n]]];
  41394. * }
  41395. *
  41396. * _.flatMapDepth([1, 2], duplicate, 2);
  41397. * // => [[1, 1], [2, 2]]
  41398. */
  41399. function flatMapDepth(collection, iteratee, depth) {
  41400. depth = depth === undefined ? 1 : toInteger(depth);
  41401. return baseFlatten(map(collection, iteratee), depth);
  41402. }
  41403. /**
  41404. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  41405. * The iteratee is invoked with three arguments: (value, index|key, collection).
  41406. * Iteratee functions may exit iteration early by explicitly returning `false`.
  41407. *
  41408. * **Note:** As with other "Collections" methods, objects with a "length"
  41409. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  41410. * or `_.forOwn` for object iteration.
  41411. *
  41412. * @static
  41413. * @memberOf _
  41414. * @since 0.1.0
  41415. * @alias each
  41416. * @category Collection
  41417. * @param {Array|Object} collection The collection to iterate over.
  41418. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  41419. * @returns {Array|Object} Returns `collection`.
  41420. * @see _.forEachRight
  41421. * @example
  41422. *
  41423. * _.forEach([1, 2], function(value) {
  41424. * console.log(value);
  41425. * });
  41426. * // => Logs `1` then `2`.
  41427. *
  41428. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  41429. * console.log(key);
  41430. * });
  41431. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  41432. */
  41433. function forEach(collection, iteratee) {
  41434. var func = isArray(collection) ? arrayEach : baseEach;
  41435. return func(collection, getIteratee(iteratee, 3));
  41436. }
  41437. /**
  41438. * This method is like `_.forEach` except that it iterates over elements of
  41439. * `collection` from right to left.
  41440. *
  41441. * @static
  41442. * @memberOf _
  41443. * @since 2.0.0
  41444. * @alias eachRight
  41445. * @category Collection
  41446. * @param {Array|Object} collection The collection to iterate over.
  41447. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  41448. * @returns {Array|Object} Returns `collection`.
  41449. * @see _.forEach
  41450. * @example
  41451. *
  41452. * _.forEachRight([1, 2], function(value) {
  41453. * console.log(value);
  41454. * });
  41455. * // => Logs `2` then `1`.
  41456. */
  41457. function forEachRight(collection, iteratee) {
  41458. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  41459. return func(collection, getIteratee(iteratee, 3));
  41460. }
  41461. /**
  41462. * Creates an object composed of keys generated from the results of running
  41463. * each element of `collection` thru `iteratee`. The order of grouped values
  41464. * is determined by the order they occur in `collection`. The corresponding
  41465. * value of each key is an array of elements responsible for generating the
  41466. * key. The iteratee is invoked with one argument: (value).
  41467. *
  41468. * @static
  41469. * @memberOf _
  41470. * @since 0.1.0
  41471. * @category Collection
  41472. * @param {Array|Object} collection The collection to iterate over.
  41473. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  41474. * @returns {Object} Returns the composed aggregate object.
  41475. * @example
  41476. *
  41477. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  41478. * // => { '4': [4.2], '6': [6.1, 6.3] }
  41479. *
  41480. * // The `_.property` iteratee shorthand.
  41481. * _.groupBy(['one', 'two', 'three'], 'length');
  41482. * // => { '3': ['one', 'two'], '5': ['three'] }
  41483. */
  41484. var groupBy = createAggregator(function(result, value, key) {
  41485. if (hasOwnProperty.call(result, key)) {
  41486. result[key].push(value);
  41487. } else {
  41488. baseAssignValue(result, key, [value]);
  41489. }
  41490. });
  41491. /**
  41492. * Checks if `value` is in `collection`. If `collection` is a string, it's
  41493. * checked for a substring of `value`, otherwise
  41494. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  41495. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  41496. * the offset from the end of `collection`.
  41497. *
  41498. * @static
  41499. * @memberOf _
  41500. * @since 0.1.0
  41501. * @category Collection
  41502. * @param {Array|Object|string} collection The collection to inspect.
  41503. * @param {*} value The value to search for.
  41504. * @param {number} [fromIndex=0] The index to search from.
  41505. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  41506. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  41507. * @example
  41508. *
  41509. * _.includes([1, 2, 3], 1);
  41510. * // => true
  41511. *
  41512. * _.includes([1, 2, 3], 1, 2);
  41513. * // => false
  41514. *
  41515. * _.includes({ 'a': 1, 'b': 2 }, 1);
  41516. * // => true
  41517. *
  41518. * _.includes('abcd', 'bc');
  41519. * // => true
  41520. */
  41521. function includes(collection, value, fromIndex, guard) {
  41522. collection = isArrayLike(collection) ? collection : values(collection);
  41523. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  41524. var length = collection.length;
  41525. if (fromIndex < 0) {
  41526. fromIndex = nativeMax(length + fromIndex, 0);
  41527. }
  41528. return isString(collection)
  41529. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  41530. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  41531. }
  41532. /**
  41533. * Invokes the method at `path` of each element in `collection`, returning
  41534. * an array of the results of each invoked method. Any additional arguments
  41535. * are provided to each invoked method. If `path` is a function, it's invoked
  41536. * for, and `this` bound to, each element in `collection`.
  41537. *
  41538. * @static
  41539. * @memberOf _
  41540. * @since 4.0.0
  41541. * @category Collection
  41542. * @param {Array|Object} collection The collection to iterate over.
  41543. * @param {Array|Function|string} path The path of the method to invoke or
  41544. * the function invoked per iteration.
  41545. * @param {...*} [args] The arguments to invoke each method with.
  41546. * @returns {Array} Returns the array of results.
  41547. * @example
  41548. *
  41549. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  41550. * // => [[1, 5, 7], [1, 2, 3]]
  41551. *
  41552. * _.invokeMap([123, 456], String.prototype.split, '');
  41553. * // => [['1', '2', '3'], ['4', '5', '6']]
  41554. */
  41555. var invokeMap = baseRest(function(collection, path, args) {
  41556. var index = -1,
  41557. isFunc = typeof path == 'function',
  41558. result = isArrayLike(collection) ? Array(collection.length) : [];
  41559. baseEach(collection, function(value) {
  41560. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  41561. });
  41562. return result;
  41563. });
  41564. /**
  41565. * Creates an object composed of keys generated from the results of running
  41566. * each element of `collection` thru `iteratee`. The corresponding value of
  41567. * each key is the last element responsible for generating the key. The
  41568. * iteratee is invoked with one argument: (value).
  41569. *
  41570. * @static
  41571. * @memberOf _
  41572. * @since 4.0.0
  41573. * @category Collection
  41574. * @param {Array|Object} collection The collection to iterate over.
  41575. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  41576. * @returns {Object} Returns the composed aggregate object.
  41577. * @example
  41578. *
  41579. * var array = [
  41580. * { 'dir': 'left', 'code': 97 },
  41581. * { 'dir': 'right', 'code': 100 }
  41582. * ];
  41583. *
  41584. * _.keyBy(array, function(o) {
  41585. * return String.fromCharCode(o.code);
  41586. * });
  41587. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  41588. *
  41589. * _.keyBy(array, 'dir');
  41590. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  41591. */
  41592. var keyBy = createAggregator(function(result, value, key) {
  41593. baseAssignValue(result, key, value);
  41594. });
  41595. /**
  41596. * Creates an array of values by running each element in `collection` thru
  41597. * `iteratee`. The iteratee is invoked with three arguments:
  41598. * (value, index|key, collection).
  41599. *
  41600. * Many lodash methods are guarded to work as iteratees for methods like
  41601. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  41602. *
  41603. * The guarded methods are:
  41604. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  41605. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  41606. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  41607. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  41608. *
  41609. * @static
  41610. * @memberOf _
  41611. * @since 0.1.0
  41612. * @category Collection
  41613. * @param {Array|Object} collection The collection to iterate over.
  41614. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  41615. * @returns {Array} Returns the new mapped array.
  41616. * @example
  41617. *
  41618. * function square(n) {
  41619. * return n * n;
  41620. * }
  41621. *
  41622. * _.map([4, 8], square);
  41623. * // => [16, 64]
  41624. *
  41625. * _.map({ 'a': 4, 'b': 8 }, square);
  41626. * // => [16, 64] (iteration order is not guaranteed)
  41627. *
  41628. * var users = [
  41629. * { 'user': 'barney' },
  41630. * { 'user': 'fred' }
  41631. * ];
  41632. *
  41633. * // The `_.property` iteratee shorthand.
  41634. * _.map(users, 'user');
  41635. * // => ['barney', 'fred']
  41636. */
  41637. function map(collection, iteratee) {
  41638. var func = isArray(collection) ? arrayMap : baseMap;
  41639. return func(collection, getIteratee(iteratee, 3));
  41640. }
  41641. /**
  41642. * This method is like `_.sortBy` except that it allows specifying the sort
  41643. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  41644. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  41645. * descending or "asc" for ascending sort order of corresponding values.
  41646. *
  41647. * @static
  41648. * @memberOf _
  41649. * @since 4.0.0
  41650. * @category Collection
  41651. * @param {Array|Object} collection The collection to iterate over.
  41652. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  41653. * The iteratees to sort by.
  41654. * @param {string[]} [orders] The sort orders of `iteratees`.
  41655. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  41656. * @returns {Array} Returns the new sorted array.
  41657. * @example
  41658. *
  41659. * var users = [
  41660. * { 'user': 'fred', 'age': 48 },
  41661. * { 'user': 'barney', 'age': 34 },
  41662. * { 'user': 'fred', 'age': 40 },
  41663. * { 'user': 'barney', 'age': 36 }
  41664. * ];
  41665. *
  41666. * // Sort by `user` in ascending order and by `age` in descending order.
  41667. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  41668. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  41669. */
  41670. function orderBy(collection, iteratees, orders, guard) {
  41671. if (collection == null) {
  41672. return [];
  41673. }
  41674. if (!isArray(iteratees)) {
  41675. iteratees = iteratees == null ? [] : [iteratees];
  41676. }
  41677. orders = guard ? undefined : orders;
  41678. if (!isArray(orders)) {
  41679. orders = orders == null ? [] : [orders];
  41680. }
  41681. return baseOrderBy(collection, iteratees, orders);
  41682. }
  41683. /**
  41684. * Creates an array of elements split into two groups, the first of which
  41685. * contains elements `predicate` returns truthy for, the second of which
  41686. * contains elements `predicate` returns falsey for. The predicate is
  41687. * invoked with one argument: (value).
  41688. *
  41689. * @static
  41690. * @memberOf _
  41691. * @since 3.0.0
  41692. * @category Collection
  41693. * @param {Array|Object} collection The collection to iterate over.
  41694. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  41695. * @returns {Array} Returns the array of grouped elements.
  41696. * @example
  41697. *
  41698. * var users = [
  41699. * { 'user': 'barney', 'age': 36, 'active': false },
  41700. * { 'user': 'fred', 'age': 40, 'active': true },
  41701. * { 'user': 'pebbles', 'age': 1, 'active': false }
  41702. * ];
  41703. *
  41704. * _.partition(users, function(o) { return o.active; });
  41705. * // => objects for [['fred'], ['barney', 'pebbles']]
  41706. *
  41707. * // The `_.matches` iteratee shorthand.
  41708. * _.partition(users, { 'age': 1, 'active': false });
  41709. * // => objects for [['pebbles'], ['barney', 'fred']]
  41710. *
  41711. * // The `_.matchesProperty` iteratee shorthand.
  41712. * _.partition(users, ['active', false]);
  41713. * // => objects for [['barney', 'pebbles'], ['fred']]
  41714. *
  41715. * // The `_.property` iteratee shorthand.
  41716. * _.partition(users, 'active');
  41717. * // => objects for [['fred'], ['barney', 'pebbles']]
  41718. */
  41719. var partition = createAggregator(function(result, value, key) {
  41720. result[key ? 0 : 1].push(value);
  41721. }, function() { return [[], []]; });
  41722. /**
  41723. * Reduces `collection` to a value which is the accumulated result of running
  41724. * each element in `collection` thru `iteratee`, where each successive
  41725. * invocation is supplied the return value of the previous. If `accumulator`
  41726. * is not given, the first element of `collection` is used as the initial
  41727. * value. The iteratee is invoked with four arguments:
  41728. * (accumulator, value, index|key, collection).
  41729. *
  41730. * Many lodash methods are guarded to work as iteratees for methods like
  41731. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  41732. *
  41733. * The guarded methods are:
  41734. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  41735. * and `sortBy`
  41736. *
  41737. * @static
  41738. * @memberOf _
  41739. * @since 0.1.0
  41740. * @category Collection
  41741. * @param {Array|Object} collection The collection to iterate over.
  41742. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  41743. * @param {*} [accumulator] The initial value.
  41744. * @returns {*} Returns the accumulated value.
  41745. * @see _.reduceRight
  41746. * @example
  41747. *
  41748. * _.reduce([1, 2], function(sum, n) {
  41749. * return sum + n;
  41750. * }, 0);
  41751. * // => 3
  41752. *
  41753. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  41754. * (result[value] || (result[value] = [])).push(key);
  41755. * return result;
  41756. * }, {});
  41757. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  41758. */
  41759. function reduce(collection, iteratee, accumulator) {
  41760. var func = isArray(collection) ? arrayReduce : baseReduce,
  41761. initAccum = arguments.length < 3;
  41762. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  41763. }
  41764. /**
  41765. * This method is like `_.reduce` except that it iterates over elements of
  41766. * `collection` from right to left.
  41767. *
  41768. * @static
  41769. * @memberOf _
  41770. * @since 0.1.0
  41771. * @category Collection
  41772. * @param {Array|Object} collection The collection to iterate over.
  41773. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  41774. * @param {*} [accumulator] The initial value.
  41775. * @returns {*} Returns the accumulated value.
  41776. * @see _.reduce
  41777. * @example
  41778. *
  41779. * var array = [[0, 1], [2, 3], [4, 5]];
  41780. *
  41781. * _.reduceRight(array, function(flattened, other) {
  41782. * return flattened.concat(other);
  41783. * }, []);
  41784. * // => [4, 5, 2, 3, 0, 1]
  41785. */
  41786. function reduceRight(collection, iteratee, accumulator) {
  41787. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  41788. initAccum = arguments.length < 3;
  41789. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  41790. }
  41791. /**
  41792. * The opposite of `_.filter`; this method returns the elements of `collection`
  41793. * that `predicate` does **not** return truthy for.
  41794. *
  41795. * @static
  41796. * @memberOf _
  41797. * @since 0.1.0
  41798. * @category Collection
  41799. * @param {Array|Object} collection The collection to iterate over.
  41800. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  41801. * @returns {Array} Returns the new filtered array.
  41802. * @see _.filter
  41803. * @example
  41804. *
  41805. * var users = [
  41806. * { 'user': 'barney', 'age': 36, 'active': false },
  41807. * { 'user': 'fred', 'age': 40, 'active': true }
  41808. * ];
  41809. *
  41810. * _.reject(users, function(o) { return !o.active; });
  41811. * // => objects for ['fred']
  41812. *
  41813. * // The `_.matches` iteratee shorthand.
  41814. * _.reject(users, { 'age': 40, 'active': true });
  41815. * // => objects for ['barney']
  41816. *
  41817. * // The `_.matchesProperty` iteratee shorthand.
  41818. * _.reject(users, ['active', false]);
  41819. * // => objects for ['fred']
  41820. *
  41821. * // The `_.property` iteratee shorthand.
  41822. * _.reject(users, 'active');
  41823. * // => objects for ['barney']
  41824. */
  41825. function reject(collection, predicate) {
  41826. var func = isArray(collection) ? arrayFilter : baseFilter;
  41827. return func(collection, negate(getIteratee(predicate, 3)));
  41828. }
  41829. /**
  41830. * Gets a random element from `collection`.
  41831. *
  41832. * @static
  41833. * @memberOf _
  41834. * @since 2.0.0
  41835. * @category Collection
  41836. * @param {Array|Object} collection The collection to sample.
  41837. * @returns {*} Returns the random element.
  41838. * @example
  41839. *
  41840. * _.sample([1, 2, 3, 4]);
  41841. * // => 2
  41842. */
  41843. function sample(collection) {
  41844. var func = isArray(collection) ? arraySample : baseSample;
  41845. return func(collection);
  41846. }
  41847. /**
  41848. * Gets `n` random elements at unique keys from `collection` up to the
  41849. * size of `collection`.
  41850. *
  41851. * @static
  41852. * @memberOf _
  41853. * @since 4.0.0
  41854. * @category Collection
  41855. * @param {Array|Object} collection The collection to sample.
  41856. * @param {number} [n=1] The number of elements to sample.
  41857. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  41858. * @returns {Array} Returns the random elements.
  41859. * @example
  41860. *
  41861. * _.sampleSize([1, 2, 3], 2);
  41862. * // => [3, 1]
  41863. *
  41864. * _.sampleSize([1, 2, 3], 4);
  41865. * // => [2, 3, 1]
  41866. */
  41867. function sampleSize(collection, n, guard) {
  41868. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
  41869. n = 1;
  41870. } else {
  41871. n = toInteger(n);
  41872. }
  41873. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  41874. return func(collection, n);
  41875. }
  41876. /**
  41877. * Creates an array of shuffled values, using a version of the
  41878. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  41879. *
  41880. * @static
  41881. * @memberOf _
  41882. * @since 0.1.0
  41883. * @category Collection
  41884. * @param {Array|Object} collection The collection to shuffle.
  41885. * @returns {Array} Returns the new shuffled array.
  41886. * @example
  41887. *
  41888. * _.shuffle([1, 2, 3, 4]);
  41889. * // => [4, 1, 3, 2]
  41890. */
  41891. function shuffle(collection) {
  41892. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  41893. return func(collection);
  41894. }
  41895. /**
  41896. * Gets the size of `collection` by returning its length for array-like
  41897. * values or the number of own enumerable string keyed properties for objects.
  41898. *
  41899. * @static
  41900. * @memberOf _
  41901. * @since 0.1.0
  41902. * @category Collection
  41903. * @param {Array|Object|string} collection The collection to inspect.
  41904. * @returns {number} Returns the collection size.
  41905. * @example
  41906. *
  41907. * _.size([1, 2, 3]);
  41908. * // => 3
  41909. *
  41910. * _.size({ 'a': 1, 'b': 2 });
  41911. * // => 2
  41912. *
  41913. * _.size('pebbles');
  41914. * // => 7
  41915. */
  41916. function size(collection) {
  41917. if (collection == null) {
  41918. return 0;
  41919. }
  41920. if (isArrayLike(collection)) {
  41921. return isString(collection) ? stringSize(collection) : collection.length;
  41922. }
  41923. var tag = getTag(collection);
  41924. if (tag == mapTag || tag == setTag) {
  41925. return collection.size;
  41926. }
  41927. return baseKeys(collection).length;
  41928. }
  41929. /**
  41930. * Checks if `predicate` returns truthy for **any** element of `collection`.
  41931. * Iteration is stopped once `predicate` returns truthy. The predicate is
  41932. * invoked with three arguments: (value, index|key, collection).
  41933. *
  41934. * @static
  41935. * @memberOf _
  41936. * @since 0.1.0
  41937. * @category Collection
  41938. * @param {Array|Object} collection The collection to iterate over.
  41939. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  41940. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  41941. * @returns {boolean} Returns `true` if any element passes the predicate check,
  41942. * else `false`.
  41943. * @example
  41944. *
  41945. * _.some([null, 0, 'yes', false], Boolean);
  41946. * // => true
  41947. *
  41948. * var users = [
  41949. * { 'user': 'barney', 'active': true },
  41950. * { 'user': 'fred', 'active': false }
  41951. * ];
  41952. *
  41953. * // The `_.matches` iteratee shorthand.
  41954. * _.some(users, { 'user': 'barney', 'active': false });
  41955. * // => false
  41956. *
  41957. * // The `_.matchesProperty` iteratee shorthand.
  41958. * _.some(users, ['active', false]);
  41959. * // => true
  41960. *
  41961. * // The `_.property` iteratee shorthand.
  41962. * _.some(users, 'active');
  41963. * // => true
  41964. */
  41965. function some(collection, predicate, guard) {
  41966. var func = isArray(collection) ? arraySome : baseSome;
  41967. if (guard && isIterateeCall(collection, predicate, guard)) {
  41968. predicate = undefined;
  41969. }
  41970. return func(collection, getIteratee(predicate, 3));
  41971. }
  41972. /**
  41973. * Creates an array of elements, sorted in ascending order by the results of
  41974. * running each element in a collection thru each iteratee. This method
  41975. * performs a stable sort, that is, it preserves the original sort order of
  41976. * equal elements. The iteratees are invoked with one argument: (value).
  41977. *
  41978. * @static
  41979. * @memberOf _
  41980. * @since 0.1.0
  41981. * @category Collection
  41982. * @param {Array|Object} collection The collection to iterate over.
  41983. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  41984. * The iteratees to sort by.
  41985. * @returns {Array} Returns the new sorted array.
  41986. * @example
  41987. *
  41988. * var users = [
  41989. * { 'user': 'fred', 'age': 48 },
  41990. * { 'user': 'barney', 'age': 36 },
  41991. * { 'user': 'fred', 'age': 30 },
  41992. * { 'user': 'barney', 'age': 34 }
  41993. * ];
  41994. *
  41995. * _.sortBy(users, [function(o) { return o.user; }]);
  41996. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]]
  41997. *
  41998. * _.sortBy(users, ['user', 'age']);
  41999. * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]]
  42000. */
  42001. var sortBy = baseRest(function(collection, iteratees) {
  42002. if (collection == null) {
  42003. return [];
  42004. }
  42005. var length = iteratees.length;
  42006. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  42007. iteratees = [];
  42008. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  42009. iteratees = [iteratees[0]];
  42010. }
  42011. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  42012. });
  42013. /*------------------------------------------------------------------------*/
  42014. /**
  42015. * Gets the timestamp of the number of milliseconds that have elapsed since
  42016. * the Unix epoch (1 January 1970 00:00:00 UTC).
  42017. *
  42018. * @static
  42019. * @memberOf _
  42020. * @since 2.4.0
  42021. * @category Date
  42022. * @returns {number} Returns the timestamp.
  42023. * @example
  42024. *
  42025. * _.defer(function(stamp) {
  42026. * console.log(_.now() - stamp);
  42027. * }, _.now());
  42028. * // => Logs the number of milliseconds it took for the deferred invocation.
  42029. */
  42030. var now = ctxNow || function() {
  42031. return root.Date.now();
  42032. };
  42033. /*------------------------------------------------------------------------*/
  42034. /**
  42035. * The opposite of `_.before`; this method creates a function that invokes
  42036. * `func` once it's called `n` or more times.
  42037. *
  42038. * @static
  42039. * @memberOf _
  42040. * @since 0.1.0
  42041. * @category Function
  42042. * @param {number} n The number of calls before `func` is invoked.
  42043. * @param {Function} func The function to restrict.
  42044. * @returns {Function} Returns the new restricted function.
  42045. * @example
  42046. *
  42047. * var saves = ['profile', 'settings'];
  42048. *
  42049. * var done = _.after(saves.length, function() {
  42050. * console.log('done saving!');
  42051. * });
  42052. *
  42053. * _.forEach(saves, function(type) {
  42054. * asyncSave({ 'type': type, 'complete': done });
  42055. * });
  42056. * // => Logs 'done saving!' after the two async saves have completed.
  42057. */
  42058. function after(n, func) {
  42059. if (typeof func != 'function') {
  42060. throw new TypeError(FUNC_ERROR_TEXT);
  42061. }
  42062. n = toInteger(n);
  42063. return function() {
  42064. if (--n < 1) {
  42065. return func.apply(this, arguments);
  42066. }
  42067. };
  42068. }
  42069. /**
  42070. * Creates a function that invokes `func`, with up to `n` arguments,
  42071. * ignoring any additional arguments.
  42072. *
  42073. * @static
  42074. * @memberOf _
  42075. * @since 3.0.0
  42076. * @category Function
  42077. * @param {Function} func The function to cap arguments for.
  42078. * @param {number} [n=func.length] The arity cap.
  42079. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  42080. * @returns {Function} Returns the new capped function.
  42081. * @example
  42082. *
  42083. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  42084. * // => [6, 8, 10]
  42085. */
  42086. function ary(func, n, guard) {
  42087. n = guard ? undefined : n;
  42088. n = (func && n == null) ? func.length : n;
  42089. return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
  42090. }
  42091. /**
  42092. * Creates a function that invokes `func`, with the `this` binding and arguments
  42093. * of the created function, while it's called less than `n` times. Subsequent
  42094. * calls to the created function return the result of the last `func` invocation.
  42095. *
  42096. * @static
  42097. * @memberOf _
  42098. * @since 3.0.0
  42099. * @category Function
  42100. * @param {number} n The number of calls at which `func` is no longer invoked.
  42101. * @param {Function} func The function to restrict.
  42102. * @returns {Function} Returns the new restricted function.
  42103. * @example
  42104. *
  42105. * jQuery(element).on('click', _.before(5, addContactToList));
  42106. * // => Allows adding up to 4 contacts to the list.
  42107. */
  42108. function before(n, func) {
  42109. var result;
  42110. if (typeof func != 'function') {
  42111. throw new TypeError(FUNC_ERROR_TEXT);
  42112. }
  42113. n = toInteger(n);
  42114. return function() {
  42115. if (--n > 0) {
  42116. result = func.apply(this, arguments);
  42117. }
  42118. if (n <= 1) {
  42119. func = undefined;
  42120. }
  42121. return result;
  42122. };
  42123. }
  42124. /**
  42125. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  42126. * and `partials` prepended to the arguments it receives.
  42127. *
  42128. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  42129. * may be used as a placeholder for partially applied arguments.
  42130. *
  42131. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  42132. * property of bound functions.
  42133. *
  42134. * @static
  42135. * @memberOf _
  42136. * @since 0.1.0
  42137. * @category Function
  42138. * @param {Function} func The function to bind.
  42139. * @param {*} thisArg The `this` binding of `func`.
  42140. * @param {...*} [partials] The arguments to be partially applied.
  42141. * @returns {Function} Returns the new bound function.
  42142. * @example
  42143. *
  42144. * function greet(greeting, punctuation) {
  42145. * return greeting + ' ' + this.user + punctuation;
  42146. * }
  42147. *
  42148. * var object = { 'user': 'fred' };
  42149. *
  42150. * var bound = _.bind(greet, object, 'hi');
  42151. * bound('!');
  42152. * // => 'hi fred!'
  42153. *
  42154. * // Bound with placeholders.
  42155. * var bound = _.bind(greet, object, _, '!');
  42156. * bound('hi');
  42157. * // => 'hi fred!'
  42158. */
  42159. var bind = baseRest(function(func, thisArg, partials) {
  42160. var bitmask = WRAP_BIND_FLAG;
  42161. if (partials.length) {
  42162. var holders = replaceHolders(partials, getHolder(bind));
  42163. bitmask |= WRAP_PARTIAL_FLAG;
  42164. }
  42165. return createWrap(func, bitmask, thisArg, partials, holders);
  42166. });
  42167. /**
  42168. * Creates a function that invokes the method at `object[key]` with `partials`
  42169. * prepended to the arguments it receives.
  42170. *
  42171. * This method differs from `_.bind` by allowing bound functions to reference
  42172. * methods that may be redefined or don't yet exist. See
  42173. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  42174. * for more details.
  42175. *
  42176. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  42177. * builds, may be used as a placeholder for partially applied arguments.
  42178. *
  42179. * @static
  42180. * @memberOf _
  42181. * @since 0.10.0
  42182. * @category Function
  42183. * @param {Object} object The object to invoke the method on.
  42184. * @param {string} key The key of the method.
  42185. * @param {...*} [partials] The arguments to be partially applied.
  42186. * @returns {Function} Returns the new bound function.
  42187. * @example
  42188. *
  42189. * var object = {
  42190. * 'user': 'fred',
  42191. * 'greet': function(greeting, punctuation) {
  42192. * return greeting + ' ' + this.user + punctuation;
  42193. * }
  42194. * };
  42195. *
  42196. * var bound = _.bindKey(object, 'greet', 'hi');
  42197. * bound('!');
  42198. * // => 'hi fred!'
  42199. *
  42200. * object.greet = function(greeting, punctuation) {
  42201. * return greeting + 'ya ' + this.user + punctuation;
  42202. * };
  42203. *
  42204. * bound('!');
  42205. * // => 'hiya fred!'
  42206. *
  42207. * // Bound with placeholders.
  42208. * var bound = _.bindKey(object, 'greet', _, '!');
  42209. * bound('hi');
  42210. * // => 'hiya fred!'
  42211. */
  42212. var bindKey = baseRest(function(object, key, partials) {
  42213. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  42214. if (partials.length) {
  42215. var holders = replaceHolders(partials, getHolder(bindKey));
  42216. bitmask |= WRAP_PARTIAL_FLAG;
  42217. }
  42218. return createWrap(key, bitmask, object, partials, holders);
  42219. });
  42220. /**
  42221. * Creates a function that accepts arguments of `func` and either invokes
  42222. * `func` returning its result, if at least `arity` number of arguments have
  42223. * been provided, or returns a function that accepts the remaining `func`
  42224. * arguments, and so on. The arity of `func` may be specified if `func.length`
  42225. * is not sufficient.
  42226. *
  42227. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  42228. * may be used as a placeholder for provided arguments.
  42229. *
  42230. * **Note:** This method doesn't set the "length" property of curried functions.
  42231. *
  42232. * @static
  42233. * @memberOf _
  42234. * @since 2.0.0
  42235. * @category Function
  42236. * @param {Function} func The function to curry.
  42237. * @param {number} [arity=func.length] The arity of `func`.
  42238. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  42239. * @returns {Function} Returns the new curried function.
  42240. * @example
  42241. *
  42242. * var abc = function(a, b, c) {
  42243. * return [a, b, c];
  42244. * };
  42245. *
  42246. * var curried = _.curry(abc);
  42247. *
  42248. * curried(1)(2)(3);
  42249. * // => [1, 2, 3]
  42250. *
  42251. * curried(1, 2)(3);
  42252. * // => [1, 2, 3]
  42253. *
  42254. * curried(1, 2, 3);
  42255. * // => [1, 2, 3]
  42256. *
  42257. * // Curried with placeholders.
  42258. * curried(1)(_, 3)(2);
  42259. * // => [1, 2, 3]
  42260. */
  42261. function curry(func, arity, guard) {
  42262. arity = guard ? undefined : arity;
  42263. var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  42264. result.placeholder = curry.placeholder;
  42265. return result;
  42266. }
  42267. /**
  42268. * This method is like `_.curry` except that arguments are applied to `func`
  42269. * in the manner of `_.partialRight` instead of `_.partial`.
  42270. *
  42271. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  42272. * builds, may be used as a placeholder for provided arguments.
  42273. *
  42274. * **Note:** This method doesn't set the "length" property of curried functions.
  42275. *
  42276. * @static
  42277. * @memberOf _
  42278. * @since 3.0.0
  42279. * @category Function
  42280. * @param {Function} func The function to curry.
  42281. * @param {number} [arity=func.length] The arity of `func`.
  42282. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  42283. * @returns {Function} Returns the new curried function.
  42284. * @example
  42285. *
  42286. * var abc = function(a, b, c) {
  42287. * return [a, b, c];
  42288. * };
  42289. *
  42290. * var curried = _.curryRight(abc);
  42291. *
  42292. * curried(3)(2)(1);
  42293. * // => [1, 2, 3]
  42294. *
  42295. * curried(2, 3)(1);
  42296. * // => [1, 2, 3]
  42297. *
  42298. * curried(1, 2, 3);
  42299. * // => [1, 2, 3]
  42300. *
  42301. * // Curried with placeholders.
  42302. * curried(3)(1, _)(2);
  42303. * // => [1, 2, 3]
  42304. */
  42305. function curryRight(func, arity, guard) {
  42306. arity = guard ? undefined : arity;
  42307. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  42308. result.placeholder = curryRight.placeholder;
  42309. return result;
  42310. }
  42311. /**
  42312. * Creates a debounced function that delays invoking `func` until after `wait`
  42313. * milliseconds have elapsed since the last time the debounced function was
  42314. * invoked. The debounced function comes with a `cancel` method to cancel
  42315. * delayed `func` invocations and a `flush` method to immediately invoke them.
  42316. * Provide `options` to indicate whether `func` should be invoked on the
  42317. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  42318. * with the last arguments provided to the debounced function. Subsequent
  42319. * calls to the debounced function return the result of the last `func`
  42320. * invocation.
  42321. *
  42322. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  42323. * invoked on the trailing edge of the timeout only if the debounced function
  42324. * is invoked more than once during the `wait` timeout.
  42325. *
  42326. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  42327. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  42328. *
  42329. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  42330. * for details over the differences between `_.debounce` and `_.throttle`.
  42331. *
  42332. * @static
  42333. * @memberOf _
  42334. * @since 0.1.0
  42335. * @category Function
  42336. * @param {Function} func The function to debounce.
  42337. * @param {number} [wait=0] The number of milliseconds to delay.
  42338. * @param {Object} [options={}] The options object.
  42339. * @param {boolean} [options.leading=false]
  42340. * Specify invoking on the leading edge of the timeout.
  42341. * @param {number} [options.maxWait]
  42342. * The maximum time `func` is allowed to be delayed before it's invoked.
  42343. * @param {boolean} [options.trailing=true]
  42344. * Specify invoking on the trailing edge of the timeout.
  42345. * @returns {Function} Returns the new debounced function.
  42346. * @example
  42347. *
  42348. * // Avoid costly calculations while the window size is in flux.
  42349. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  42350. *
  42351. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  42352. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  42353. * 'leading': true,
  42354. * 'trailing': false
  42355. * }));
  42356. *
  42357. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  42358. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  42359. * var source = new EventSource('/stream');
  42360. * jQuery(source).on('message', debounced);
  42361. *
  42362. * // Cancel the trailing debounced invocation.
  42363. * jQuery(window).on('popstate', debounced.cancel);
  42364. */
  42365. function debounce(func, wait, options) {
  42366. var lastArgs,
  42367. lastThis,
  42368. maxWait,
  42369. result,
  42370. timerId,
  42371. lastCallTime,
  42372. lastInvokeTime = 0,
  42373. leading = false,
  42374. maxing = false,
  42375. trailing = true;
  42376. if (typeof func != 'function') {
  42377. throw new TypeError(FUNC_ERROR_TEXT);
  42378. }
  42379. wait = toNumber(wait) || 0;
  42380. if (isObject(options)) {
  42381. leading = !!options.leading;
  42382. maxing = 'maxWait' in options;
  42383. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  42384. trailing = 'trailing' in options ? !!options.trailing : trailing;
  42385. }
  42386. function invokeFunc(time) {
  42387. var args = lastArgs,
  42388. thisArg = lastThis;
  42389. lastArgs = lastThis = undefined;
  42390. lastInvokeTime = time;
  42391. result = func.apply(thisArg, args);
  42392. return result;
  42393. }
  42394. function leadingEdge(time) {
  42395. // Reset any `maxWait` timer.
  42396. lastInvokeTime = time;
  42397. // Start the timer for the trailing edge.
  42398. timerId = setTimeout(timerExpired, wait);
  42399. // Invoke the leading edge.
  42400. return leading ? invokeFunc(time) : result;
  42401. }
  42402. function remainingWait(time) {
  42403. var timeSinceLastCall = time - lastCallTime,
  42404. timeSinceLastInvoke = time - lastInvokeTime,
  42405. timeWaiting = wait - timeSinceLastCall;
  42406. return maxing
  42407. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  42408. : timeWaiting;
  42409. }
  42410. function shouldInvoke(time) {
  42411. var timeSinceLastCall = time - lastCallTime,
  42412. timeSinceLastInvoke = time - lastInvokeTime;
  42413. // Either this is the first call, activity has stopped and we're at the
  42414. // trailing edge, the system time has gone backwards and we're treating
  42415. // it as the trailing edge, or we've hit the `maxWait` limit.
  42416. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  42417. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  42418. }
  42419. function timerExpired() {
  42420. var time = now();
  42421. if (shouldInvoke(time)) {
  42422. return trailingEdge(time);
  42423. }
  42424. // Restart the timer.
  42425. timerId = setTimeout(timerExpired, remainingWait(time));
  42426. }
  42427. function trailingEdge(time) {
  42428. timerId = undefined;
  42429. // Only invoke if we have `lastArgs` which means `func` has been
  42430. // debounced at least once.
  42431. if (trailing && lastArgs) {
  42432. return invokeFunc(time);
  42433. }
  42434. lastArgs = lastThis = undefined;
  42435. return result;
  42436. }
  42437. function cancel() {
  42438. if (timerId !== undefined) {
  42439. clearTimeout(timerId);
  42440. }
  42441. lastInvokeTime = 0;
  42442. lastArgs = lastCallTime = lastThis = timerId = undefined;
  42443. }
  42444. function flush() {
  42445. return timerId === undefined ? result : trailingEdge(now());
  42446. }
  42447. function debounced() {
  42448. var time = now(),
  42449. isInvoking = shouldInvoke(time);
  42450. lastArgs = arguments;
  42451. lastThis = this;
  42452. lastCallTime = time;
  42453. if (isInvoking) {
  42454. if (timerId === undefined) {
  42455. return leadingEdge(lastCallTime);
  42456. }
  42457. if (maxing) {
  42458. // Handle invocations in a tight loop.
  42459. clearTimeout(timerId);
  42460. timerId = setTimeout(timerExpired, wait);
  42461. return invokeFunc(lastCallTime);
  42462. }
  42463. }
  42464. if (timerId === undefined) {
  42465. timerId = setTimeout(timerExpired, wait);
  42466. }
  42467. return result;
  42468. }
  42469. debounced.cancel = cancel;
  42470. debounced.flush = flush;
  42471. return debounced;
  42472. }
  42473. /**
  42474. * Defers invoking the `func` until the current call stack has cleared. Any
  42475. * additional arguments are provided to `func` when it's invoked.
  42476. *
  42477. * @static
  42478. * @memberOf _
  42479. * @since 0.1.0
  42480. * @category Function
  42481. * @param {Function} func The function to defer.
  42482. * @param {...*} [args] The arguments to invoke `func` with.
  42483. * @returns {number} Returns the timer id.
  42484. * @example
  42485. *
  42486. * _.defer(function(text) {
  42487. * console.log(text);
  42488. * }, 'deferred');
  42489. * // => Logs 'deferred' after one millisecond.
  42490. */
  42491. var defer = baseRest(function(func, args) {
  42492. return baseDelay(func, 1, args);
  42493. });
  42494. /**
  42495. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  42496. * provided to `func` when it's invoked.
  42497. *
  42498. * @static
  42499. * @memberOf _
  42500. * @since 0.1.0
  42501. * @category Function
  42502. * @param {Function} func The function to delay.
  42503. * @param {number} wait The number of milliseconds to delay invocation.
  42504. * @param {...*} [args] The arguments to invoke `func` with.
  42505. * @returns {number} Returns the timer id.
  42506. * @example
  42507. *
  42508. * _.delay(function(text) {
  42509. * console.log(text);
  42510. * }, 1000, 'later');
  42511. * // => Logs 'later' after one second.
  42512. */
  42513. var delay = baseRest(function(func, wait, args) {
  42514. return baseDelay(func, toNumber(wait) || 0, args);
  42515. });
  42516. /**
  42517. * Creates a function that invokes `func` with arguments reversed.
  42518. *
  42519. * @static
  42520. * @memberOf _
  42521. * @since 4.0.0
  42522. * @category Function
  42523. * @param {Function} func The function to flip arguments for.
  42524. * @returns {Function} Returns the new flipped function.
  42525. * @example
  42526. *
  42527. * var flipped = _.flip(function() {
  42528. * return _.toArray(arguments);
  42529. * });
  42530. *
  42531. * flipped('a', 'b', 'c', 'd');
  42532. * // => ['d', 'c', 'b', 'a']
  42533. */
  42534. function flip(func) {
  42535. return createWrap(func, WRAP_FLIP_FLAG);
  42536. }
  42537. /**
  42538. * Creates a function that memoizes the result of `func`. If `resolver` is
  42539. * provided, it determines the cache key for storing the result based on the
  42540. * arguments provided to the memoized function. By default, the first argument
  42541. * provided to the memoized function is used as the map cache key. The `func`
  42542. * is invoked with the `this` binding of the memoized function.
  42543. *
  42544. * **Note:** The cache is exposed as the `cache` property on the memoized
  42545. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  42546. * constructor with one whose instances implement the
  42547. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  42548. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  42549. *
  42550. * @static
  42551. * @memberOf _
  42552. * @since 0.1.0
  42553. * @category Function
  42554. * @param {Function} func The function to have its output memoized.
  42555. * @param {Function} [resolver] The function to resolve the cache key.
  42556. * @returns {Function} Returns the new memoized function.
  42557. * @example
  42558. *
  42559. * var object = { 'a': 1, 'b': 2 };
  42560. * var other = { 'c': 3, 'd': 4 };
  42561. *
  42562. * var values = _.memoize(_.values);
  42563. * values(object);
  42564. * // => [1, 2]
  42565. *
  42566. * values(other);
  42567. * // => [3, 4]
  42568. *
  42569. * object.a = 2;
  42570. * values(object);
  42571. * // => [1, 2]
  42572. *
  42573. * // Modify the result cache.
  42574. * values.cache.set(object, ['a', 'b']);
  42575. * values(object);
  42576. * // => ['a', 'b']
  42577. *
  42578. * // Replace `_.memoize.Cache`.
  42579. * _.memoize.Cache = WeakMap;
  42580. */
  42581. function memoize(func, resolver) {
  42582. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  42583. throw new TypeError(FUNC_ERROR_TEXT);
  42584. }
  42585. var memoized = function() {
  42586. var args = arguments,
  42587. key = resolver ? resolver.apply(this, args) : args[0],
  42588. cache = memoized.cache;
  42589. if (cache.has(key)) {
  42590. return cache.get(key);
  42591. }
  42592. var result = func.apply(this, args);
  42593. memoized.cache = cache.set(key, result) || cache;
  42594. return result;
  42595. };
  42596. memoized.cache = new (memoize.Cache || MapCache);
  42597. return memoized;
  42598. }
  42599. // Expose `MapCache`.
  42600. memoize.Cache = MapCache;
  42601. /**
  42602. * Creates a function that negates the result of the predicate `func`. The
  42603. * `func` predicate is invoked with the `this` binding and arguments of the
  42604. * created function.
  42605. *
  42606. * @static
  42607. * @memberOf _
  42608. * @since 3.0.0
  42609. * @category Function
  42610. * @param {Function} predicate The predicate to negate.
  42611. * @returns {Function} Returns the new negated function.
  42612. * @example
  42613. *
  42614. * function isEven(n) {
  42615. * return n % 2 == 0;
  42616. * }
  42617. *
  42618. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  42619. * // => [1, 3, 5]
  42620. */
  42621. function negate(predicate) {
  42622. if (typeof predicate != 'function') {
  42623. throw new TypeError(FUNC_ERROR_TEXT);
  42624. }
  42625. return function() {
  42626. var args = arguments;
  42627. switch (args.length) {
  42628. case 0: return !predicate.call(this);
  42629. case 1: return !predicate.call(this, args[0]);
  42630. case 2: return !predicate.call(this, args[0], args[1]);
  42631. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  42632. }
  42633. return !predicate.apply(this, args);
  42634. };
  42635. }
  42636. /**
  42637. * Creates a function that is restricted to invoking `func` once. Repeat calls
  42638. * to the function return the value of the first invocation. The `func` is
  42639. * invoked with the `this` binding and arguments of the created function.
  42640. *
  42641. * @static
  42642. * @memberOf _
  42643. * @since 0.1.0
  42644. * @category Function
  42645. * @param {Function} func The function to restrict.
  42646. * @returns {Function} Returns the new restricted function.
  42647. * @example
  42648. *
  42649. * var initialize = _.once(createApplication);
  42650. * initialize();
  42651. * initialize();
  42652. * // => `createApplication` is invoked once
  42653. */
  42654. function once(func) {
  42655. return before(2, func);
  42656. }
  42657. /**
  42658. * Creates a function that invokes `func` with its arguments transformed.
  42659. *
  42660. * @static
  42661. * @since 4.0.0
  42662. * @memberOf _
  42663. * @category Function
  42664. * @param {Function} func The function to wrap.
  42665. * @param {...(Function|Function[])} [transforms=[_.identity]]
  42666. * The argument transforms.
  42667. * @returns {Function} Returns the new function.
  42668. * @example
  42669. *
  42670. * function doubled(n) {
  42671. * return n * 2;
  42672. * }
  42673. *
  42674. * function square(n) {
  42675. * return n * n;
  42676. * }
  42677. *
  42678. * var func = _.overArgs(function(x, y) {
  42679. * return [x, y];
  42680. * }, [square, doubled]);
  42681. *
  42682. * func(9, 3);
  42683. * // => [81, 6]
  42684. *
  42685. * func(10, 5);
  42686. * // => [100, 10]
  42687. */
  42688. var overArgs = castRest(function(func, transforms) {
  42689. transforms = (transforms.length == 1 && isArray(transforms[0]))
  42690. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  42691. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  42692. var funcsLength = transforms.length;
  42693. return baseRest(function(args) {
  42694. var index = -1,
  42695. length = nativeMin(args.length, funcsLength);
  42696. while (++index < length) {
  42697. args[index] = transforms[index].call(this, args[index]);
  42698. }
  42699. return apply(func, this, args);
  42700. });
  42701. });
  42702. /**
  42703. * Creates a function that invokes `func` with `partials` prepended to the
  42704. * arguments it receives. This method is like `_.bind` except it does **not**
  42705. * alter the `this` binding.
  42706. *
  42707. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  42708. * builds, may be used as a placeholder for partially applied arguments.
  42709. *
  42710. * **Note:** This method doesn't set the "length" property of partially
  42711. * applied functions.
  42712. *
  42713. * @static
  42714. * @memberOf _
  42715. * @since 0.2.0
  42716. * @category Function
  42717. * @param {Function} func The function to partially apply arguments to.
  42718. * @param {...*} [partials] The arguments to be partially applied.
  42719. * @returns {Function} Returns the new partially applied function.
  42720. * @example
  42721. *
  42722. * function greet(greeting, name) {
  42723. * return greeting + ' ' + name;
  42724. * }
  42725. *
  42726. * var sayHelloTo = _.partial(greet, 'hello');
  42727. * sayHelloTo('fred');
  42728. * // => 'hello fred'
  42729. *
  42730. * // Partially applied with placeholders.
  42731. * var greetFred = _.partial(greet, _, 'fred');
  42732. * greetFred('hi');
  42733. * // => 'hi fred'
  42734. */
  42735. var partial = baseRest(function(func, partials) {
  42736. var holders = replaceHolders(partials, getHolder(partial));
  42737. return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
  42738. });
  42739. /**
  42740. * This method is like `_.partial` except that partially applied arguments
  42741. * are appended to the arguments it receives.
  42742. *
  42743. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  42744. * builds, may be used as a placeholder for partially applied arguments.
  42745. *
  42746. * **Note:** This method doesn't set the "length" property of partially
  42747. * applied functions.
  42748. *
  42749. * @static
  42750. * @memberOf _
  42751. * @since 1.0.0
  42752. * @category Function
  42753. * @param {Function} func The function to partially apply arguments to.
  42754. * @param {...*} [partials] The arguments to be partially applied.
  42755. * @returns {Function} Returns the new partially applied function.
  42756. * @example
  42757. *
  42758. * function greet(greeting, name) {
  42759. * return greeting + ' ' + name;
  42760. * }
  42761. *
  42762. * var greetFred = _.partialRight(greet, 'fred');
  42763. * greetFred('hi');
  42764. * // => 'hi fred'
  42765. *
  42766. * // Partially applied with placeholders.
  42767. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  42768. * sayHelloTo('fred');
  42769. * // => 'hello fred'
  42770. */
  42771. var partialRight = baseRest(function(func, partials) {
  42772. var holders = replaceHolders(partials, getHolder(partialRight));
  42773. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
  42774. });
  42775. /**
  42776. * Creates a function that invokes `func` with arguments arranged according
  42777. * to the specified `indexes` where the argument value at the first index is
  42778. * provided as the first argument, the argument value at the second index is
  42779. * provided as the second argument, and so on.
  42780. *
  42781. * @static
  42782. * @memberOf _
  42783. * @since 3.0.0
  42784. * @category Function
  42785. * @param {Function} func The function to rearrange arguments for.
  42786. * @param {...(number|number[])} indexes The arranged argument indexes.
  42787. * @returns {Function} Returns the new function.
  42788. * @example
  42789. *
  42790. * var rearged = _.rearg(function(a, b, c) {
  42791. * return [a, b, c];
  42792. * }, [2, 0, 1]);
  42793. *
  42794. * rearged('b', 'c', 'a')
  42795. * // => ['a', 'b', 'c']
  42796. */
  42797. var rearg = flatRest(function(func, indexes) {
  42798. return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
  42799. });
  42800. /**
  42801. * Creates a function that invokes `func` with the `this` binding of the
  42802. * created function and arguments from `start` and beyond provided as
  42803. * an array.
  42804. *
  42805. * **Note:** This method is based on the
  42806. * [rest parameter](https://mdn.io/rest_parameters).
  42807. *
  42808. * @static
  42809. * @memberOf _
  42810. * @since 4.0.0
  42811. * @category Function
  42812. * @param {Function} func The function to apply a rest parameter to.
  42813. * @param {number} [start=func.length-1] The start position of the rest parameter.
  42814. * @returns {Function} Returns the new function.
  42815. * @example
  42816. *
  42817. * var say = _.rest(function(what, names) {
  42818. * return what + ' ' + _.initial(names).join(', ') +
  42819. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  42820. * });
  42821. *
  42822. * say('hello', 'fred', 'barney', 'pebbles');
  42823. * // => 'hello fred, barney, & pebbles'
  42824. */
  42825. function rest(func, start) {
  42826. if (typeof func != 'function') {
  42827. throw new TypeError(FUNC_ERROR_TEXT);
  42828. }
  42829. start = start === undefined ? start : toInteger(start);
  42830. return baseRest(func, start);
  42831. }
  42832. /**
  42833. * Creates a function that invokes `func` with the `this` binding of the
  42834. * create function and an array of arguments much like
  42835. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  42836. *
  42837. * **Note:** This method is based on the
  42838. * [spread operator](https://mdn.io/spread_operator).
  42839. *
  42840. * @static
  42841. * @memberOf _
  42842. * @since 3.2.0
  42843. * @category Function
  42844. * @param {Function} func The function to spread arguments over.
  42845. * @param {number} [start=0] The start position of the spread.
  42846. * @returns {Function} Returns the new function.
  42847. * @example
  42848. *
  42849. * var say = _.spread(function(who, what) {
  42850. * return who + ' says ' + what;
  42851. * });
  42852. *
  42853. * say(['fred', 'hello']);
  42854. * // => 'fred says hello'
  42855. *
  42856. * var numbers = Promise.all([
  42857. * Promise.resolve(40),
  42858. * Promise.resolve(36)
  42859. * ]);
  42860. *
  42861. * numbers.then(_.spread(function(x, y) {
  42862. * return x + y;
  42863. * }));
  42864. * // => a Promise of 76
  42865. */
  42866. function spread(func, start) {
  42867. if (typeof func != 'function') {
  42868. throw new TypeError(FUNC_ERROR_TEXT);
  42869. }
  42870. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  42871. return baseRest(function(args) {
  42872. var array = args[start],
  42873. otherArgs = castSlice(args, 0, start);
  42874. if (array) {
  42875. arrayPush(otherArgs, array);
  42876. }
  42877. return apply(func, this, otherArgs);
  42878. });
  42879. }
  42880. /**
  42881. * Creates a throttled function that only invokes `func` at most once per
  42882. * every `wait` milliseconds. The throttled function comes with a `cancel`
  42883. * method to cancel delayed `func` invocations and a `flush` method to
  42884. * immediately invoke them. Provide `options` to indicate whether `func`
  42885. * should be invoked on the leading and/or trailing edge of the `wait`
  42886. * timeout. The `func` is invoked with the last arguments provided to the
  42887. * throttled function. Subsequent calls to the throttled function return the
  42888. * result of the last `func` invocation.
  42889. *
  42890. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  42891. * invoked on the trailing edge of the timeout only if the throttled function
  42892. * is invoked more than once during the `wait` timeout.
  42893. *
  42894. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  42895. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  42896. *
  42897. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  42898. * for details over the differences between `_.throttle` and `_.debounce`.
  42899. *
  42900. * @static
  42901. * @memberOf _
  42902. * @since 0.1.0
  42903. * @category Function
  42904. * @param {Function} func The function to throttle.
  42905. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  42906. * @param {Object} [options={}] The options object.
  42907. * @param {boolean} [options.leading=true]
  42908. * Specify invoking on the leading edge of the timeout.
  42909. * @param {boolean} [options.trailing=true]
  42910. * Specify invoking on the trailing edge of the timeout.
  42911. * @returns {Function} Returns the new throttled function.
  42912. * @example
  42913. *
  42914. * // Avoid excessively updating the position while scrolling.
  42915. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  42916. *
  42917. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  42918. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  42919. * jQuery(element).on('click', throttled);
  42920. *
  42921. * // Cancel the trailing throttled invocation.
  42922. * jQuery(window).on('popstate', throttled.cancel);
  42923. */
  42924. function throttle(func, wait, options) {
  42925. var leading = true,
  42926. trailing = true;
  42927. if (typeof func != 'function') {
  42928. throw new TypeError(FUNC_ERROR_TEXT);
  42929. }
  42930. if (isObject(options)) {
  42931. leading = 'leading' in options ? !!options.leading : leading;
  42932. trailing = 'trailing' in options ? !!options.trailing : trailing;
  42933. }
  42934. return debounce(func, wait, {
  42935. 'leading': leading,
  42936. 'maxWait': wait,
  42937. 'trailing': trailing
  42938. });
  42939. }
  42940. /**
  42941. * Creates a function that accepts up to one argument, ignoring any
  42942. * additional arguments.
  42943. *
  42944. * @static
  42945. * @memberOf _
  42946. * @since 4.0.0
  42947. * @category Function
  42948. * @param {Function} func The function to cap arguments for.
  42949. * @returns {Function} Returns the new capped function.
  42950. * @example
  42951. *
  42952. * _.map(['6', '8', '10'], _.unary(parseInt));
  42953. * // => [6, 8, 10]
  42954. */
  42955. function unary(func) {
  42956. return ary(func, 1);
  42957. }
  42958. /**
  42959. * Creates a function that provides `value` to `wrapper` as its first
  42960. * argument. Any additional arguments provided to the function are appended
  42961. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  42962. * binding of the created function.
  42963. *
  42964. * @static
  42965. * @memberOf _
  42966. * @since 0.1.0
  42967. * @category Function
  42968. * @param {*} value The value to wrap.
  42969. * @param {Function} [wrapper=identity] The wrapper function.
  42970. * @returns {Function} Returns the new function.
  42971. * @example
  42972. *
  42973. * var p = _.wrap(_.escape, function(func, text) {
  42974. * return '<p>' + func(text) + '</p>';
  42975. * });
  42976. *
  42977. * p('fred, barney, & pebbles');
  42978. * // => '<p>fred, barney, &amp; pebbles</p>'
  42979. */
  42980. function wrap(value, wrapper) {
  42981. return partial(castFunction(wrapper), value);
  42982. }
  42983. /*------------------------------------------------------------------------*/
  42984. /**
  42985. * Casts `value` as an array if it's not one.
  42986. *
  42987. * @static
  42988. * @memberOf _
  42989. * @since 4.4.0
  42990. * @category Lang
  42991. * @param {*} value The value to inspect.
  42992. * @returns {Array} Returns the cast array.
  42993. * @example
  42994. *
  42995. * _.castArray(1);
  42996. * // => [1]
  42997. *
  42998. * _.castArray({ 'a': 1 });
  42999. * // => [{ 'a': 1 }]
  43000. *
  43001. * _.castArray('abc');
  43002. * // => ['abc']
  43003. *
  43004. * _.castArray(null);
  43005. * // => [null]
  43006. *
  43007. * _.castArray(undefined);
  43008. * // => [undefined]
  43009. *
  43010. * _.castArray();
  43011. * // => []
  43012. *
  43013. * var array = [1, 2, 3];
  43014. * console.log(_.castArray(array) === array);
  43015. * // => true
  43016. */
  43017. function castArray() {
  43018. if (!arguments.length) {
  43019. return [];
  43020. }
  43021. var value = arguments[0];
  43022. return isArray(value) ? value : [value];
  43023. }
  43024. /**
  43025. * Creates a shallow clone of `value`.
  43026. *
  43027. * **Note:** This method is loosely based on the
  43028. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  43029. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  43030. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  43031. * arrays. The own enumerable properties of `arguments` objects are cloned
  43032. * as plain objects. An empty object is returned for uncloneable values such
  43033. * as error objects, functions, DOM nodes, and WeakMaps.
  43034. *
  43035. * @static
  43036. * @memberOf _
  43037. * @since 0.1.0
  43038. * @category Lang
  43039. * @param {*} value The value to clone.
  43040. * @returns {*} Returns the cloned value.
  43041. * @see _.cloneDeep
  43042. * @example
  43043. *
  43044. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  43045. *
  43046. * var shallow = _.clone(objects);
  43047. * console.log(shallow[0] === objects[0]);
  43048. * // => true
  43049. */
  43050. function clone(value) {
  43051. return baseClone(value, CLONE_SYMBOLS_FLAG);
  43052. }
  43053. /**
  43054. * This method is like `_.clone` except that it accepts `customizer` which
  43055. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  43056. * cloning is handled by the method instead. The `customizer` is invoked with
  43057. * up to four arguments; (value [, index|key, object, stack]).
  43058. *
  43059. * @static
  43060. * @memberOf _
  43061. * @since 4.0.0
  43062. * @category Lang
  43063. * @param {*} value The value to clone.
  43064. * @param {Function} [customizer] The function to customize cloning.
  43065. * @returns {*} Returns the cloned value.
  43066. * @see _.cloneDeepWith
  43067. * @example
  43068. *
  43069. * function customizer(value) {
  43070. * if (_.isElement(value)) {
  43071. * return value.cloneNode(false);
  43072. * }
  43073. * }
  43074. *
  43075. * var el = _.cloneWith(document.body, customizer);
  43076. *
  43077. * console.log(el === document.body);
  43078. * // => false
  43079. * console.log(el.nodeName);
  43080. * // => 'BODY'
  43081. * console.log(el.childNodes.length);
  43082. * // => 0
  43083. */
  43084. function cloneWith(value, customizer) {
  43085. customizer = typeof customizer == 'function' ? customizer : undefined;
  43086. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  43087. }
  43088. /**
  43089. * This method is like `_.clone` except that it recursively clones `value`.
  43090. *
  43091. * @static
  43092. * @memberOf _
  43093. * @since 1.0.0
  43094. * @category Lang
  43095. * @param {*} value The value to recursively clone.
  43096. * @returns {*} Returns the deep cloned value.
  43097. * @see _.clone
  43098. * @example
  43099. *
  43100. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  43101. *
  43102. * var deep = _.cloneDeep(objects);
  43103. * console.log(deep[0] === objects[0]);
  43104. * // => false
  43105. */
  43106. function cloneDeep(value) {
  43107. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  43108. }
  43109. /**
  43110. * This method is like `_.cloneWith` except that it recursively clones `value`.
  43111. *
  43112. * @static
  43113. * @memberOf _
  43114. * @since 4.0.0
  43115. * @category Lang
  43116. * @param {*} value The value to recursively clone.
  43117. * @param {Function} [customizer] The function to customize cloning.
  43118. * @returns {*} Returns the deep cloned value.
  43119. * @see _.cloneWith
  43120. * @example
  43121. *
  43122. * function customizer(value) {
  43123. * if (_.isElement(value)) {
  43124. * return value.cloneNode(true);
  43125. * }
  43126. * }
  43127. *
  43128. * var el = _.cloneDeepWith(document.body, customizer);
  43129. *
  43130. * console.log(el === document.body);
  43131. * // => false
  43132. * console.log(el.nodeName);
  43133. * // => 'BODY'
  43134. * console.log(el.childNodes.length);
  43135. * // => 20
  43136. */
  43137. function cloneDeepWith(value, customizer) {
  43138. customizer = typeof customizer == 'function' ? customizer : undefined;
  43139. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  43140. }
  43141. /**
  43142. * Checks if `object` conforms to `source` by invoking the predicate
  43143. * properties of `source` with the corresponding property values of `object`.
  43144. *
  43145. * **Note:** This method is equivalent to `_.conforms` when `source` is
  43146. * partially applied.
  43147. *
  43148. * @static
  43149. * @memberOf _
  43150. * @since 4.14.0
  43151. * @category Lang
  43152. * @param {Object} object The object to inspect.
  43153. * @param {Object} source The object of property predicates to conform to.
  43154. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  43155. * @example
  43156. *
  43157. * var object = { 'a': 1, 'b': 2 };
  43158. *
  43159. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  43160. * // => true
  43161. *
  43162. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  43163. * // => false
  43164. */
  43165. function conformsTo(object, source) {
  43166. return source == null || baseConformsTo(object, source, keys(source));
  43167. }
  43168. /**
  43169. * Performs a
  43170. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  43171. * comparison between two values to determine if they are equivalent.
  43172. *
  43173. * @static
  43174. * @memberOf _
  43175. * @since 4.0.0
  43176. * @category Lang
  43177. * @param {*} value The value to compare.
  43178. * @param {*} other The other value to compare.
  43179. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  43180. * @example
  43181. *
  43182. * var object = { 'a': 1 };
  43183. * var other = { 'a': 1 };
  43184. *
  43185. * _.eq(object, object);
  43186. * // => true
  43187. *
  43188. * _.eq(object, other);
  43189. * // => false
  43190. *
  43191. * _.eq('a', 'a');
  43192. * // => true
  43193. *
  43194. * _.eq('a', Object('a'));
  43195. * // => false
  43196. *
  43197. * _.eq(NaN, NaN);
  43198. * // => true
  43199. */
  43200. function eq(value, other) {
  43201. return value === other || (value !== value && other !== other);
  43202. }
  43203. /**
  43204. * Checks if `value` is greater than `other`.
  43205. *
  43206. * @static
  43207. * @memberOf _
  43208. * @since 3.9.0
  43209. * @category Lang
  43210. * @param {*} value The value to compare.
  43211. * @param {*} other The other value to compare.
  43212. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  43213. * else `false`.
  43214. * @see _.lt
  43215. * @example
  43216. *
  43217. * _.gt(3, 1);
  43218. * // => true
  43219. *
  43220. * _.gt(3, 3);
  43221. * // => false
  43222. *
  43223. * _.gt(1, 3);
  43224. * // => false
  43225. */
  43226. var gt = createRelationalOperation(baseGt);
  43227. /**
  43228. * Checks if `value` is greater than or equal to `other`.
  43229. *
  43230. * @static
  43231. * @memberOf _
  43232. * @since 3.9.0
  43233. * @category Lang
  43234. * @param {*} value The value to compare.
  43235. * @param {*} other The other value to compare.
  43236. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  43237. * `other`, else `false`.
  43238. * @see _.lte
  43239. * @example
  43240. *
  43241. * _.gte(3, 1);
  43242. * // => true
  43243. *
  43244. * _.gte(3, 3);
  43245. * // => true
  43246. *
  43247. * _.gte(1, 3);
  43248. * // => false
  43249. */
  43250. var gte = createRelationalOperation(function(value, other) {
  43251. return value >= other;
  43252. });
  43253. /**
  43254. * Checks if `value` is likely an `arguments` object.
  43255. *
  43256. * @static
  43257. * @memberOf _
  43258. * @since 0.1.0
  43259. * @category Lang
  43260. * @param {*} value The value to check.
  43261. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  43262. * else `false`.
  43263. * @example
  43264. *
  43265. * _.isArguments(function() { return arguments; }());
  43266. * // => true
  43267. *
  43268. * _.isArguments([1, 2, 3]);
  43269. * // => false
  43270. */
  43271. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  43272. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  43273. !propertyIsEnumerable.call(value, 'callee');
  43274. };
  43275. /**
  43276. * Checks if `value` is classified as an `Array` object.
  43277. *
  43278. * @static
  43279. * @memberOf _
  43280. * @since 0.1.0
  43281. * @category Lang
  43282. * @param {*} value The value to check.
  43283. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  43284. * @example
  43285. *
  43286. * _.isArray([1, 2, 3]);
  43287. * // => true
  43288. *
  43289. * _.isArray(document.body.children);
  43290. * // => false
  43291. *
  43292. * _.isArray('abc');
  43293. * // => false
  43294. *
  43295. * _.isArray(_.noop);
  43296. * // => false
  43297. */
  43298. var isArray = Array.isArray;
  43299. /**
  43300. * Checks if `value` is classified as an `ArrayBuffer` object.
  43301. *
  43302. * @static
  43303. * @memberOf _
  43304. * @since 4.3.0
  43305. * @category Lang
  43306. * @param {*} value The value to check.
  43307. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  43308. * @example
  43309. *
  43310. * _.isArrayBuffer(new ArrayBuffer(2));
  43311. * // => true
  43312. *
  43313. * _.isArrayBuffer(new Array(2));
  43314. * // => false
  43315. */
  43316. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  43317. /**
  43318. * Checks if `value` is array-like. A value is considered array-like if it's
  43319. * not a function and has a `value.length` that's an integer greater than or
  43320. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  43321. *
  43322. * @static
  43323. * @memberOf _
  43324. * @since 4.0.0
  43325. * @category Lang
  43326. * @param {*} value The value to check.
  43327. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  43328. * @example
  43329. *
  43330. * _.isArrayLike([1, 2, 3]);
  43331. * // => true
  43332. *
  43333. * _.isArrayLike(document.body.children);
  43334. * // => true
  43335. *
  43336. * _.isArrayLike('abc');
  43337. * // => true
  43338. *
  43339. * _.isArrayLike(_.noop);
  43340. * // => false
  43341. */
  43342. function isArrayLike(value) {
  43343. return value != null && isLength(value.length) && !isFunction(value);
  43344. }
  43345. /**
  43346. * This method is like `_.isArrayLike` except that it also checks if `value`
  43347. * is an object.
  43348. *
  43349. * @static
  43350. * @memberOf _
  43351. * @since 4.0.0
  43352. * @category Lang
  43353. * @param {*} value The value to check.
  43354. * @returns {boolean} Returns `true` if `value` is an array-like object,
  43355. * else `false`.
  43356. * @example
  43357. *
  43358. * _.isArrayLikeObject([1, 2, 3]);
  43359. * // => true
  43360. *
  43361. * _.isArrayLikeObject(document.body.children);
  43362. * // => true
  43363. *
  43364. * _.isArrayLikeObject('abc');
  43365. * // => false
  43366. *
  43367. * _.isArrayLikeObject(_.noop);
  43368. * // => false
  43369. */
  43370. function isArrayLikeObject(value) {
  43371. return isObjectLike(value) && isArrayLike(value);
  43372. }
  43373. /**
  43374. * Checks if `value` is classified as a boolean primitive or object.
  43375. *
  43376. * @static
  43377. * @memberOf _
  43378. * @since 0.1.0
  43379. * @category Lang
  43380. * @param {*} value The value to check.
  43381. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  43382. * @example
  43383. *
  43384. * _.isBoolean(false);
  43385. * // => true
  43386. *
  43387. * _.isBoolean(null);
  43388. * // => false
  43389. */
  43390. function isBoolean(value) {
  43391. return value === true || value === false ||
  43392. (isObjectLike(value) && baseGetTag(value) == boolTag);
  43393. }
  43394. /**
  43395. * Checks if `value` is a buffer.
  43396. *
  43397. * @static
  43398. * @memberOf _
  43399. * @since 4.3.0
  43400. * @category Lang
  43401. * @param {*} value The value to check.
  43402. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  43403. * @example
  43404. *
  43405. * _.isBuffer(new Buffer(2));
  43406. * // => true
  43407. *
  43408. * _.isBuffer(new Uint8Array(2));
  43409. * // => false
  43410. */
  43411. var isBuffer = nativeIsBuffer || stubFalse;
  43412. /**
  43413. * Checks if `value` is classified as a `Date` object.
  43414. *
  43415. * @static
  43416. * @memberOf _
  43417. * @since 0.1.0
  43418. * @category Lang
  43419. * @param {*} value The value to check.
  43420. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  43421. * @example
  43422. *
  43423. * _.isDate(new Date);
  43424. * // => true
  43425. *
  43426. * _.isDate('Mon April 23 2012');
  43427. * // => false
  43428. */
  43429. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  43430. /**
  43431. * Checks if `value` is likely a DOM element.
  43432. *
  43433. * @static
  43434. * @memberOf _
  43435. * @since 0.1.0
  43436. * @category Lang
  43437. * @param {*} value The value to check.
  43438. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  43439. * @example
  43440. *
  43441. * _.isElement(document.body);
  43442. * // => true
  43443. *
  43444. * _.isElement('<body>');
  43445. * // => false
  43446. */
  43447. function isElement(value) {
  43448. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  43449. }
  43450. /**
  43451. * Checks if `value` is an empty object, collection, map, or set.
  43452. *
  43453. * Objects are considered empty if they have no own enumerable string keyed
  43454. * properties.
  43455. *
  43456. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  43457. * jQuery-like collections are considered empty if they have a `length` of `0`.
  43458. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  43459. *
  43460. * @static
  43461. * @memberOf _
  43462. * @since 0.1.0
  43463. * @category Lang
  43464. * @param {*} value The value to check.
  43465. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  43466. * @example
  43467. *
  43468. * _.isEmpty(null);
  43469. * // => true
  43470. *
  43471. * _.isEmpty(true);
  43472. * // => true
  43473. *
  43474. * _.isEmpty(1);
  43475. * // => true
  43476. *
  43477. * _.isEmpty([1, 2, 3]);
  43478. * // => false
  43479. *
  43480. * _.isEmpty({ 'a': 1 });
  43481. * // => false
  43482. */
  43483. function isEmpty(value) {
  43484. if (value == null) {
  43485. return true;
  43486. }
  43487. if (isArrayLike(value) &&
  43488. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  43489. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  43490. return !value.length;
  43491. }
  43492. var tag = getTag(value);
  43493. if (tag == mapTag || tag == setTag) {
  43494. return !value.size;
  43495. }
  43496. if (isPrototype(value)) {
  43497. return !baseKeys(value).length;
  43498. }
  43499. for (var key in value) {
  43500. if (hasOwnProperty.call(value, key)) {
  43501. return false;
  43502. }
  43503. }
  43504. return true;
  43505. }
  43506. /**
  43507. * Performs a deep comparison between two values to determine if they are
  43508. * equivalent.
  43509. *
  43510. * **Note:** This method supports comparing arrays, array buffers, booleans,
  43511. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  43512. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  43513. * by their own, not inherited, enumerable properties. Functions and DOM
  43514. * nodes are compared by strict equality, i.e. `===`.
  43515. *
  43516. * @static
  43517. * @memberOf _
  43518. * @since 0.1.0
  43519. * @category Lang
  43520. * @param {*} value The value to compare.
  43521. * @param {*} other The other value to compare.
  43522. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  43523. * @example
  43524. *
  43525. * var object = { 'a': 1 };
  43526. * var other = { 'a': 1 };
  43527. *
  43528. * _.isEqual(object, other);
  43529. * // => true
  43530. *
  43531. * object === other;
  43532. * // => false
  43533. */
  43534. function isEqual(value, other) {
  43535. return baseIsEqual(value, other);
  43536. }
  43537. /**
  43538. * This method is like `_.isEqual` except that it accepts `customizer` which
  43539. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  43540. * are handled by the method instead. The `customizer` is invoked with up to
  43541. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  43542. *
  43543. * @static
  43544. * @memberOf _
  43545. * @since 4.0.0
  43546. * @category Lang
  43547. * @param {*} value The value to compare.
  43548. * @param {*} other The other value to compare.
  43549. * @param {Function} [customizer] The function to customize comparisons.
  43550. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  43551. * @example
  43552. *
  43553. * function isGreeting(value) {
  43554. * return /^h(?:i|ello)$/.test(value);
  43555. * }
  43556. *
  43557. * function customizer(objValue, othValue) {
  43558. * if (isGreeting(objValue) && isGreeting(othValue)) {
  43559. * return true;
  43560. * }
  43561. * }
  43562. *
  43563. * var array = ['hello', 'goodbye'];
  43564. * var other = ['hi', 'goodbye'];
  43565. *
  43566. * _.isEqualWith(array, other, customizer);
  43567. * // => true
  43568. */
  43569. function isEqualWith(value, other, customizer) {
  43570. customizer = typeof customizer == 'function' ? customizer : undefined;
  43571. var result = customizer ? customizer(value, other) : undefined;
  43572. return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
  43573. }
  43574. /**
  43575. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  43576. * `SyntaxError`, `TypeError`, or `URIError` object.
  43577. *
  43578. * @static
  43579. * @memberOf _
  43580. * @since 3.0.0
  43581. * @category Lang
  43582. * @param {*} value The value to check.
  43583. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  43584. * @example
  43585. *
  43586. * _.isError(new Error);
  43587. * // => true
  43588. *
  43589. * _.isError(Error);
  43590. * // => false
  43591. */
  43592. function isError(value) {
  43593. if (!isObjectLike(value)) {
  43594. return false;
  43595. }
  43596. var tag = baseGetTag(value);
  43597. return tag == errorTag || tag == domExcTag ||
  43598. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  43599. }
  43600. /**
  43601. * Checks if `value` is a finite primitive number.
  43602. *
  43603. * **Note:** This method is based on
  43604. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  43605. *
  43606. * @static
  43607. * @memberOf _
  43608. * @since 0.1.0
  43609. * @category Lang
  43610. * @param {*} value The value to check.
  43611. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  43612. * @example
  43613. *
  43614. * _.isFinite(3);
  43615. * // => true
  43616. *
  43617. * _.isFinite(Number.MIN_VALUE);
  43618. * // => true
  43619. *
  43620. * _.isFinite(Infinity);
  43621. * // => false
  43622. *
  43623. * _.isFinite('3');
  43624. * // => false
  43625. */
  43626. function isFinite(value) {
  43627. return typeof value == 'number' && nativeIsFinite(value);
  43628. }
  43629. /**
  43630. * Checks if `value` is classified as a `Function` object.
  43631. *
  43632. * @static
  43633. * @memberOf _
  43634. * @since 0.1.0
  43635. * @category Lang
  43636. * @param {*} value The value to check.
  43637. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  43638. * @example
  43639. *
  43640. * _.isFunction(_);
  43641. * // => true
  43642. *
  43643. * _.isFunction(/abc/);
  43644. * // => false
  43645. */
  43646. function isFunction(value) {
  43647. if (!isObject(value)) {
  43648. return false;
  43649. }
  43650. // The use of `Object#toString` avoids issues with the `typeof` operator
  43651. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  43652. var tag = baseGetTag(value);
  43653. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  43654. }
  43655. /**
  43656. * Checks if `value` is an integer.
  43657. *
  43658. * **Note:** This method is based on
  43659. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  43660. *
  43661. * @static
  43662. * @memberOf _
  43663. * @since 4.0.0
  43664. * @category Lang
  43665. * @param {*} value The value to check.
  43666. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  43667. * @example
  43668. *
  43669. * _.isInteger(3);
  43670. * // => true
  43671. *
  43672. * _.isInteger(Number.MIN_VALUE);
  43673. * // => false
  43674. *
  43675. * _.isInteger(Infinity);
  43676. * // => false
  43677. *
  43678. * _.isInteger('3');
  43679. * // => false
  43680. */
  43681. function isInteger(value) {
  43682. return typeof value == 'number' && value == toInteger(value);
  43683. }
  43684. /**
  43685. * Checks if `value` is a valid array-like length.
  43686. *
  43687. * **Note:** This method is loosely based on
  43688. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  43689. *
  43690. * @static
  43691. * @memberOf _
  43692. * @since 4.0.0
  43693. * @category Lang
  43694. * @param {*} value The value to check.
  43695. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  43696. * @example
  43697. *
  43698. * _.isLength(3);
  43699. * // => true
  43700. *
  43701. * _.isLength(Number.MIN_VALUE);
  43702. * // => false
  43703. *
  43704. * _.isLength(Infinity);
  43705. * // => false
  43706. *
  43707. * _.isLength('3');
  43708. * // => false
  43709. */
  43710. function isLength(value) {
  43711. return typeof value == 'number' &&
  43712. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  43713. }
  43714. /**
  43715. * Checks if `value` is the
  43716. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  43717. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  43718. *
  43719. * @static
  43720. * @memberOf _
  43721. * @since 0.1.0
  43722. * @category Lang
  43723. * @param {*} value The value to check.
  43724. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  43725. * @example
  43726. *
  43727. * _.isObject({});
  43728. * // => true
  43729. *
  43730. * _.isObject([1, 2, 3]);
  43731. * // => true
  43732. *
  43733. * _.isObject(_.noop);
  43734. * // => true
  43735. *
  43736. * _.isObject(null);
  43737. * // => false
  43738. */
  43739. function isObject(value) {
  43740. var type = typeof value;
  43741. return value != null && (type == 'object' || type == 'function');
  43742. }
  43743. /**
  43744. * Checks if `value` is object-like. A value is object-like if it's not `null`
  43745. * and has a `typeof` result of "object".
  43746. *
  43747. * @static
  43748. * @memberOf _
  43749. * @since 4.0.0
  43750. * @category Lang
  43751. * @param {*} value The value to check.
  43752. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  43753. * @example
  43754. *
  43755. * _.isObjectLike({});
  43756. * // => true
  43757. *
  43758. * _.isObjectLike([1, 2, 3]);
  43759. * // => true
  43760. *
  43761. * _.isObjectLike(_.noop);
  43762. * // => false
  43763. *
  43764. * _.isObjectLike(null);
  43765. * // => false
  43766. */
  43767. function isObjectLike(value) {
  43768. return value != null && typeof value == 'object';
  43769. }
  43770. /**
  43771. * Checks if `value` is classified as a `Map` object.
  43772. *
  43773. * @static
  43774. * @memberOf _
  43775. * @since 4.3.0
  43776. * @category Lang
  43777. * @param {*} value The value to check.
  43778. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  43779. * @example
  43780. *
  43781. * _.isMap(new Map);
  43782. * // => true
  43783. *
  43784. * _.isMap(new WeakMap);
  43785. * // => false
  43786. */
  43787. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  43788. /**
  43789. * Performs a partial deep comparison between `object` and `source` to
  43790. * determine if `object` contains equivalent property values.
  43791. *
  43792. * **Note:** This method is equivalent to `_.matches` when `source` is
  43793. * partially applied.
  43794. *
  43795. * Partial comparisons will match empty array and empty object `source`
  43796. * values against any array or object value, respectively. See `_.isEqual`
  43797. * for a list of supported value comparisons.
  43798. *
  43799. * @static
  43800. * @memberOf _
  43801. * @since 3.0.0
  43802. * @category Lang
  43803. * @param {Object} object The object to inspect.
  43804. * @param {Object} source The object of property values to match.
  43805. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  43806. * @example
  43807. *
  43808. * var object = { 'a': 1, 'b': 2 };
  43809. *
  43810. * _.isMatch(object, { 'b': 2 });
  43811. * // => true
  43812. *
  43813. * _.isMatch(object, { 'b': 1 });
  43814. * // => false
  43815. */
  43816. function isMatch(object, source) {
  43817. return object === source || baseIsMatch(object, source, getMatchData(source));
  43818. }
  43819. /**
  43820. * This method is like `_.isMatch` except that it accepts `customizer` which
  43821. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  43822. * are handled by the method instead. The `customizer` is invoked with five
  43823. * arguments: (objValue, srcValue, index|key, object, source).
  43824. *
  43825. * @static
  43826. * @memberOf _
  43827. * @since 4.0.0
  43828. * @category Lang
  43829. * @param {Object} object The object to inspect.
  43830. * @param {Object} source The object of property values to match.
  43831. * @param {Function} [customizer] The function to customize comparisons.
  43832. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  43833. * @example
  43834. *
  43835. * function isGreeting(value) {
  43836. * return /^h(?:i|ello)$/.test(value);
  43837. * }
  43838. *
  43839. * function customizer(objValue, srcValue) {
  43840. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  43841. * return true;
  43842. * }
  43843. * }
  43844. *
  43845. * var object = { 'greeting': 'hello' };
  43846. * var source = { 'greeting': 'hi' };
  43847. *
  43848. * _.isMatchWith(object, source, customizer);
  43849. * // => true
  43850. */
  43851. function isMatchWith(object, source, customizer) {
  43852. customizer = typeof customizer == 'function' ? customizer : undefined;
  43853. return baseIsMatch(object, source, getMatchData(source), customizer);
  43854. }
  43855. /**
  43856. * Checks if `value` is `NaN`.
  43857. *
  43858. * **Note:** This method is based on
  43859. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  43860. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  43861. * `undefined` and other non-number values.
  43862. *
  43863. * @static
  43864. * @memberOf _
  43865. * @since 0.1.0
  43866. * @category Lang
  43867. * @param {*} value The value to check.
  43868. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  43869. * @example
  43870. *
  43871. * _.isNaN(NaN);
  43872. * // => true
  43873. *
  43874. * _.isNaN(new Number(NaN));
  43875. * // => true
  43876. *
  43877. * isNaN(undefined);
  43878. * // => true
  43879. *
  43880. * _.isNaN(undefined);
  43881. * // => false
  43882. */
  43883. function isNaN(value) {
  43884. // An `NaN` primitive is the only value that is not equal to itself.
  43885. // Perform the `toStringTag` check first to avoid errors with some
  43886. // ActiveX objects in IE.
  43887. return isNumber(value) && value != +value;
  43888. }
  43889. /**
  43890. * Checks if `value` is a pristine native function.
  43891. *
  43892. * **Note:** This method can't reliably detect native functions in the presence
  43893. * of the core-js package because core-js circumvents this kind of detection.
  43894. * Despite multiple requests, the core-js maintainer has made it clear: any
  43895. * attempt to fix the detection will be obstructed. As a result, we're left
  43896. * with little choice but to throw an error. Unfortunately, this also affects
  43897. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  43898. * which rely on core-js.
  43899. *
  43900. * @static
  43901. * @memberOf _
  43902. * @since 3.0.0
  43903. * @category Lang
  43904. * @param {*} value The value to check.
  43905. * @returns {boolean} Returns `true` if `value` is a native function,
  43906. * else `false`.
  43907. * @example
  43908. *
  43909. * _.isNative(Array.prototype.push);
  43910. * // => true
  43911. *
  43912. * _.isNative(_);
  43913. * // => false
  43914. */
  43915. function isNative(value) {
  43916. if (isMaskable(value)) {
  43917. throw new Error(CORE_ERROR_TEXT);
  43918. }
  43919. return baseIsNative(value);
  43920. }
  43921. /**
  43922. * Checks if `value` is `null`.
  43923. *
  43924. * @static
  43925. * @memberOf _
  43926. * @since 0.1.0
  43927. * @category Lang
  43928. * @param {*} value The value to check.
  43929. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  43930. * @example
  43931. *
  43932. * _.isNull(null);
  43933. * // => true
  43934. *
  43935. * _.isNull(void 0);
  43936. * // => false
  43937. */
  43938. function isNull(value) {
  43939. return value === null;
  43940. }
  43941. /**
  43942. * Checks if `value` is `null` or `undefined`.
  43943. *
  43944. * @static
  43945. * @memberOf _
  43946. * @since 4.0.0
  43947. * @category Lang
  43948. * @param {*} value The value to check.
  43949. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  43950. * @example
  43951. *
  43952. * _.isNil(null);
  43953. * // => true
  43954. *
  43955. * _.isNil(void 0);
  43956. * // => true
  43957. *
  43958. * _.isNil(NaN);
  43959. * // => false
  43960. */
  43961. function isNil(value) {
  43962. return value == null;
  43963. }
  43964. /**
  43965. * Checks if `value` is classified as a `Number` primitive or object.
  43966. *
  43967. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  43968. * classified as numbers, use the `_.isFinite` method.
  43969. *
  43970. * @static
  43971. * @memberOf _
  43972. * @since 0.1.0
  43973. * @category Lang
  43974. * @param {*} value The value to check.
  43975. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  43976. * @example
  43977. *
  43978. * _.isNumber(3);
  43979. * // => true
  43980. *
  43981. * _.isNumber(Number.MIN_VALUE);
  43982. * // => true
  43983. *
  43984. * _.isNumber(Infinity);
  43985. * // => true
  43986. *
  43987. * _.isNumber('3');
  43988. * // => false
  43989. */
  43990. function isNumber(value) {
  43991. return typeof value == 'number' ||
  43992. (isObjectLike(value) && baseGetTag(value) == numberTag);
  43993. }
  43994. /**
  43995. * Checks if `value` is a plain object, that is, an object created by the
  43996. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  43997. *
  43998. * @static
  43999. * @memberOf _
  44000. * @since 0.8.0
  44001. * @category Lang
  44002. * @param {*} value The value to check.
  44003. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  44004. * @example
  44005. *
  44006. * function Foo() {
  44007. * this.a = 1;
  44008. * }
  44009. *
  44010. * _.isPlainObject(new Foo);
  44011. * // => false
  44012. *
  44013. * _.isPlainObject([1, 2, 3]);
  44014. * // => false
  44015. *
  44016. * _.isPlainObject({ 'x': 0, 'y': 0 });
  44017. * // => true
  44018. *
  44019. * _.isPlainObject(Object.create(null));
  44020. * // => true
  44021. */
  44022. function isPlainObject(value) {
  44023. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  44024. return false;
  44025. }
  44026. var proto = getPrototype(value);
  44027. if (proto === null) {
  44028. return true;
  44029. }
  44030. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  44031. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  44032. funcToString.call(Ctor) == objectCtorString;
  44033. }
  44034. /**
  44035. * Checks if `value` is classified as a `RegExp` object.
  44036. *
  44037. * @static
  44038. * @memberOf _
  44039. * @since 0.1.0
  44040. * @category Lang
  44041. * @param {*} value The value to check.
  44042. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  44043. * @example
  44044. *
  44045. * _.isRegExp(/abc/);
  44046. * // => true
  44047. *
  44048. * _.isRegExp('/abc/');
  44049. * // => false
  44050. */
  44051. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  44052. /**
  44053. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  44054. * double precision number which isn't the result of a rounded unsafe integer.
  44055. *
  44056. * **Note:** This method is based on
  44057. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  44058. *
  44059. * @static
  44060. * @memberOf _
  44061. * @since 4.0.0
  44062. * @category Lang
  44063. * @param {*} value The value to check.
  44064. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  44065. * @example
  44066. *
  44067. * _.isSafeInteger(3);
  44068. * // => true
  44069. *
  44070. * _.isSafeInteger(Number.MIN_VALUE);
  44071. * // => false
  44072. *
  44073. * _.isSafeInteger(Infinity);
  44074. * // => false
  44075. *
  44076. * _.isSafeInteger('3');
  44077. * // => false
  44078. */
  44079. function isSafeInteger(value) {
  44080. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  44081. }
  44082. /**
  44083. * Checks if `value` is classified as a `Set` object.
  44084. *
  44085. * @static
  44086. * @memberOf _
  44087. * @since 4.3.0
  44088. * @category Lang
  44089. * @param {*} value The value to check.
  44090. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  44091. * @example
  44092. *
  44093. * _.isSet(new Set);
  44094. * // => true
  44095. *
  44096. * _.isSet(new WeakSet);
  44097. * // => false
  44098. */
  44099. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  44100. /**
  44101. * Checks if `value` is classified as a `String` primitive or object.
  44102. *
  44103. * @static
  44104. * @since 0.1.0
  44105. * @memberOf _
  44106. * @category Lang
  44107. * @param {*} value The value to check.
  44108. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  44109. * @example
  44110. *
  44111. * _.isString('abc');
  44112. * // => true
  44113. *
  44114. * _.isString(1);
  44115. * // => false
  44116. */
  44117. function isString(value) {
  44118. return typeof value == 'string' ||
  44119. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  44120. }
  44121. /**
  44122. * Checks if `value` is classified as a `Symbol` primitive or object.
  44123. *
  44124. * @static
  44125. * @memberOf _
  44126. * @since 4.0.0
  44127. * @category Lang
  44128. * @param {*} value The value to check.
  44129. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  44130. * @example
  44131. *
  44132. * _.isSymbol(Symbol.iterator);
  44133. * // => true
  44134. *
  44135. * _.isSymbol('abc');
  44136. * // => false
  44137. */
  44138. function isSymbol(value) {
  44139. return typeof value == 'symbol' ||
  44140. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  44141. }
  44142. /**
  44143. * Checks if `value` is classified as a typed array.
  44144. *
  44145. * @static
  44146. * @memberOf _
  44147. * @since 3.0.0
  44148. * @category Lang
  44149. * @param {*} value The value to check.
  44150. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  44151. * @example
  44152. *
  44153. * _.isTypedArray(new Uint8Array);
  44154. * // => true
  44155. *
  44156. * _.isTypedArray([]);
  44157. * // => false
  44158. */
  44159. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  44160. /**
  44161. * Checks if `value` is `undefined`.
  44162. *
  44163. * @static
  44164. * @since 0.1.0
  44165. * @memberOf _
  44166. * @category Lang
  44167. * @param {*} value The value to check.
  44168. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  44169. * @example
  44170. *
  44171. * _.isUndefined(void 0);
  44172. * // => true
  44173. *
  44174. * _.isUndefined(null);
  44175. * // => false
  44176. */
  44177. function isUndefined(value) {
  44178. return value === undefined;
  44179. }
  44180. /**
  44181. * Checks if `value` is classified as a `WeakMap` object.
  44182. *
  44183. * @static
  44184. * @memberOf _
  44185. * @since 4.3.0
  44186. * @category Lang
  44187. * @param {*} value The value to check.
  44188. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  44189. * @example
  44190. *
  44191. * _.isWeakMap(new WeakMap);
  44192. * // => true
  44193. *
  44194. * _.isWeakMap(new Map);
  44195. * // => false
  44196. */
  44197. function isWeakMap(value) {
  44198. return isObjectLike(value) && getTag(value) == weakMapTag;
  44199. }
  44200. /**
  44201. * Checks if `value` is classified as a `WeakSet` object.
  44202. *
  44203. * @static
  44204. * @memberOf _
  44205. * @since 4.3.0
  44206. * @category Lang
  44207. * @param {*} value The value to check.
  44208. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  44209. * @example
  44210. *
  44211. * _.isWeakSet(new WeakSet);
  44212. * // => true
  44213. *
  44214. * _.isWeakSet(new Set);
  44215. * // => false
  44216. */
  44217. function isWeakSet(value) {
  44218. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  44219. }
  44220. /**
  44221. * Checks if `value` is less than `other`.
  44222. *
  44223. * @static
  44224. * @memberOf _
  44225. * @since 3.9.0
  44226. * @category Lang
  44227. * @param {*} value The value to compare.
  44228. * @param {*} other The other value to compare.
  44229. * @returns {boolean} Returns `true` if `value` is less than `other`,
  44230. * else `false`.
  44231. * @see _.gt
  44232. * @example
  44233. *
  44234. * _.lt(1, 3);
  44235. * // => true
  44236. *
  44237. * _.lt(3, 3);
  44238. * // => false
  44239. *
  44240. * _.lt(3, 1);
  44241. * // => false
  44242. */
  44243. var lt = createRelationalOperation(baseLt);
  44244. /**
  44245. * Checks if `value` is less than or equal to `other`.
  44246. *
  44247. * @static
  44248. * @memberOf _
  44249. * @since 3.9.0
  44250. * @category Lang
  44251. * @param {*} value The value to compare.
  44252. * @param {*} other The other value to compare.
  44253. * @returns {boolean} Returns `true` if `value` is less than or equal to
  44254. * `other`, else `false`.
  44255. * @see _.gte
  44256. * @example
  44257. *
  44258. * _.lte(1, 3);
  44259. * // => true
  44260. *
  44261. * _.lte(3, 3);
  44262. * // => true
  44263. *
  44264. * _.lte(3, 1);
  44265. * // => false
  44266. */
  44267. var lte = createRelationalOperation(function(value, other) {
  44268. return value <= other;
  44269. });
  44270. /**
  44271. * Converts `value` to an array.
  44272. *
  44273. * @static
  44274. * @since 0.1.0
  44275. * @memberOf _
  44276. * @category Lang
  44277. * @param {*} value The value to convert.
  44278. * @returns {Array} Returns the converted array.
  44279. * @example
  44280. *
  44281. * _.toArray({ 'a': 1, 'b': 2 });
  44282. * // => [1, 2]
  44283. *
  44284. * _.toArray('abc');
  44285. * // => ['a', 'b', 'c']
  44286. *
  44287. * _.toArray(1);
  44288. * // => []
  44289. *
  44290. * _.toArray(null);
  44291. * // => []
  44292. */
  44293. function toArray(value) {
  44294. if (!value) {
  44295. return [];
  44296. }
  44297. if (isArrayLike(value)) {
  44298. return isString(value) ? stringToArray(value) : copyArray(value);
  44299. }
  44300. if (symIterator && value[symIterator]) {
  44301. return iteratorToArray(value[symIterator]());
  44302. }
  44303. var tag = getTag(value),
  44304. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  44305. return func(value);
  44306. }
  44307. /**
  44308. * Converts `value` to a finite number.
  44309. *
  44310. * @static
  44311. * @memberOf _
  44312. * @since 4.12.0
  44313. * @category Lang
  44314. * @param {*} value The value to convert.
  44315. * @returns {number} Returns the converted number.
  44316. * @example
  44317. *
  44318. * _.toFinite(3.2);
  44319. * // => 3.2
  44320. *
  44321. * _.toFinite(Number.MIN_VALUE);
  44322. * // => 5e-324
  44323. *
  44324. * _.toFinite(Infinity);
  44325. * // => 1.7976931348623157e+308
  44326. *
  44327. * _.toFinite('3.2');
  44328. * // => 3.2
  44329. */
  44330. function toFinite(value) {
  44331. if (!value) {
  44332. return value === 0 ? value : 0;
  44333. }
  44334. value = toNumber(value);
  44335. if (value === INFINITY || value === -INFINITY) {
  44336. var sign = (value < 0 ? -1 : 1);
  44337. return sign * MAX_INTEGER;
  44338. }
  44339. return value === value ? value : 0;
  44340. }
  44341. /**
  44342. * Converts `value` to an integer.
  44343. *
  44344. * **Note:** This method is loosely based on
  44345. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  44346. *
  44347. * @static
  44348. * @memberOf _
  44349. * @since 4.0.0
  44350. * @category Lang
  44351. * @param {*} value The value to convert.
  44352. * @returns {number} Returns the converted integer.
  44353. * @example
  44354. *
  44355. * _.toInteger(3.2);
  44356. * // => 3
  44357. *
  44358. * _.toInteger(Number.MIN_VALUE);
  44359. * // => 0
  44360. *
  44361. * _.toInteger(Infinity);
  44362. * // => 1.7976931348623157e+308
  44363. *
  44364. * _.toInteger('3.2');
  44365. * // => 3
  44366. */
  44367. function toInteger(value) {
  44368. var result = toFinite(value),
  44369. remainder = result % 1;
  44370. return result === result ? (remainder ? result - remainder : result) : 0;
  44371. }
  44372. /**
  44373. * Converts `value` to an integer suitable for use as the length of an
  44374. * array-like object.
  44375. *
  44376. * **Note:** This method is based on
  44377. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  44378. *
  44379. * @static
  44380. * @memberOf _
  44381. * @since 4.0.0
  44382. * @category Lang
  44383. * @param {*} value The value to convert.
  44384. * @returns {number} Returns the converted integer.
  44385. * @example
  44386. *
  44387. * _.toLength(3.2);
  44388. * // => 3
  44389. *
  44390. * _.toLength(Number.MIN_VALUE);
  44391. * // => 0
  44392. *
  44393. * _.toLength(Infinity);
  44394. * // => 4294967295
  44395. *
  44396. * _.toLength('3.2');
  44397. * // => 3
  44398. */
  44399. function toLength(value) {
  44400. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  44401. }
  44402. /**
  44403. * Converts `value` to a number.
  44404. *
  44405. * @static
  44406. * @memberOf _
  44407. * @since 4.0.0
  44408. * @category Lang
  44409. * @param {*} value The value to process.
  44410. * @returns {number} Returns the number.
  44411. * @example
  44412. *
  44413. * _.toNumber(3.2);
  44414. * // => 3.2
  44415. *
  44416. * _.toNumber(Number.MIN_VALUE);
  44417. * // => 5e-324
  44418. *
  44419. * _.toNumber(Infinity);
  44420. * // => Infinity
  44421. *
  44422. * _.toNumber('3.2');
  44423. * // => 3.2
  44424. */
  44425. function toNumber(value) {
  44426. if (typeof value == 'number') {
  44427. return value;
  44428. }
  44429. if (isSymbol(value)) {
  44430. return NAN;
  44431. }
  44432. if (isObject(value)) {
  44433. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  44434. value = isObject(other) ? (other + '') : other;
  44435. }
  44436. if (typeof value != 'string') {
  44437. return value === 0 ? value : +value;
  44438. }
  44439. value = baseTrim(value);
  44440. var isBinary = reIsBinary.test(value);
  44441. return (isBinary || reIsOctal.test(value))
  44442. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  44443. : (reIsBadHex.test(value) ? NAN : +value);
  44444. }
  44445. /**
  44446. * Converts `value` to a plain object flattening inherited enumerable string
  44447. * keyed properties of `value` to own properties of the plain object.
  44448. *
  44449. * @static
  44450. * @memberOf _
  44451. * @since 3.0.0
  44452. * @category Lang
  44453. * @param {*} value The value to convert.
  44454. * @returns {Object} Returns the converted plain object.
  44455. * @example
  44456. *
  44457. * function Foo() {
  44458. * this.b = 2;
  44459. * }
  44460. *
  44461. * Foo.prototype.c = 3;
  44462. *
  44463. * _.assign({ 'a': 1 }, new Foo);
  44464. * // => { 'a': 1, 'b': 2 }
  44465. *
  44466. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  44467. * // => { 'a': 1, 'b': 2, 'c': 3 }
  44468. */
  44469. function toPlainObject(value) {
  44470. return copyObject(value, keysIn(value));
  44471. }
  44472. /**
  44473. * Converts `value` to a safe integer. A safe integer can be compared and
  44474. * represented correctly.
  44475. *
  44476. * @static
  44477. * @memberOf _
  44478. * @since 4.0.0
  44479. * @category Lang
  44480. * @param {*} value The value to convert.
  44481. * @returns {number} Returns the converted integer.
  44482. * @example
  44483. *
  44484. * _.toSafeInteger(3.2);
  44485. * // => 3
  44486. *
  44487. * _.toSafeInteger(Number.MIN_VALUE);
  44488. * // => 0
  44489. *
  44490. * _.toSafeInteger(Infinity);
  44491. * // => 9007199254740991
  44492. *
  44493. * _.toSafeInteger('3.2');
  44494. * // => 3
  44495. */
  44496. function toSafeInteger(value) {
  44497. return value
  44498. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  44499. : (value === 0 ? value : 0);
  44500. }
  44501. /**
  44502. * Converts `value` to a string. An empty string is returned for `null`
  44503. * and `undefined` values. The sign of `-0` is preserved.
  44504. *
  44505. * @static
  44506. * @memberOf _
  44507. * @since 4.0.0
  44508. * @category Lang
  44509. * @param {*} value The value to convert.
  44510. * @returns {string} Returns the converted string.
  44511. * @example
  44512. *
  44513. * _.toString(null);
  44514. * // => ''
  44515. *
  44516. * _.toString(-0);
  44517. * // => '-0'
  44518. *
  44519. * _.toString([1, 2, 3]);
  44520. * // => '1,2,3'
  44521. */
  44522. function toString(value) {
  44523. return value == null ? '' : baseToString(value);
  44524. }
  44525. /*------------------------------------------------------------------------*/
  44526. /**
  44527. * Assigns own enumerable string keyed properties of source objects to the
  44528. * destination object. Source objects are applied from left to right.
  44529. * Subsequent sources overwrite property assignments of previous sources.
  44530. *
  44531. * **Note:** This method mutates `object` and is loosely based on
  44532. * [`Object.assign`](https://mdn.io/Object/assign).
  44533. *
  44534. * @static
  44535. * @memberOf _
  44536. * @since 0.10.0
  44537. * @category Object
  44538. * @param {Object} object The destination object.
  44539. * @param {...Object} [sources] The source objects.
  44540. * @returns {Object} Returns `object`.
  44541. * @see _.assignIn
  44542. * @example
  44543. *
  44544. * function Foo() {
  44545. * this.a = 1;
  44546. * }
  44547. *
  44548. * function Bar() {
  44549. * this.c = 3;
  44550. * }
  44551. *
  44552. * Foo.prototype.b = 2;
  44553. * Bar.prototype.d = 4;
  44554. *
  44555. * _.assign({ 'a': 0 }, new Foo, new Bar);
  44556. * // => { 'a': 1, 'c': 3 }
  44557. */
  44558. var assign = createAssigner(function(object, source) {
  44559. if (isPrototype(source) || isArrayLike(source)) {
  44560. copyObject(source, keys(source), object);
  44561. return;
  44562. }
  44563. for (var key in source) {
  44564. if (hasOwnProperty.call(source, key)) {
  44565. assignValue(object, key, source[key]);
  44566. }
  44567. }
  44568. });
  44569. /**
  44570. * This method is like `_.assign` except that it iterates over own and
  44571. * inherited source properties.
  44572. *
  44573. * **Note:** This method mutates `object`.
  44574. *
  44575. * @static
  44576. * @memberOf _
  44577. * @since 4.0.0
  44578. * @alias extend
  44579. * @category Object
  44580. * @param {Object} object The destination object.
  44581. * @param {...Object} [sources] The source objects.
  44582. * @returns {Object} Returns `object`.
  44583. * @see _.assign
  44584. * @example
  44585. *
  44586. * function Foo() {
  44587. * this.a = 1;
  44588. * }
  44589. *
  44590. * function Bar() {
  44591. * this.c = 3;
  44592. * }
  44593. *
  44594. * Foo.prototype.b = 2;
  44595. * Bar.prototype.d = 4;
  44596. *
  44597. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  44598. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  44599. */
  44600. var assignIn = createAssigner(function(object, source) {
  44601. copyObject(source, keysIn(source), object);
  44602. });
  44603. /**
  44604. * This method is like `_.assignIn` except that it accepts `customizer`
  44605. * which is invoked to produce the assigned values. If `customizer` returns
  44606. * `undefined`, assignment is handled by the method instead. The `customizer`
  44607. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  44608. *
  44609. * **Note:** This method mutates `object`.
  44610. *
  44611. * @static
  44612. * @memberOf _
  44613. * @since 4.0.0
  44614. * @alias extendWith
  44615. * @category Object
  44616. * @param {Object} object The destination object.
  44617. * @param {...Object} sources The source objects.
  44618. * @param {Function} [customizer] The function to customize assigned values.
  44619. * @returns {Object} Returns `object`.
  44620. * @see _.assignWith
  44621. * @example
  44622. *
  44623. * function customizer(objValue, srcValue) {
  44624. * return _.isUndefined(objValue) ? srcValue : objValue;
  44625. * }
  44626. *
  44627. * var defaults = _.partialRight(_.assignInWith, customizer);
  44628. *
  44629. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  44630. * // => { 'a': 1, 'b': 2 }
  44631. */
  44632. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  44633. copyObject(source, keysIn(source), object, customizer);
  44634. });
  44635. /**
  44636. * This method is like `_.assign` except that it accepts `customizer`
  44637. * which is invoked to produce the assigned values. If `customizer` returns
  44638. * `undefined`, assignment is handled by the method instead. The `customizer`
  44639. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  44640. *
  44641. * **Note:** This method mutates `object`.
  44642. *
  44643. * @static
  44644. * @memberOf _
  44645. * @since 4.0.0
  44646. * @category Object
  44647. * @param {Object} object The destination object.
  44648. * @param {...Object} sources The source objects.
  44649. * @param {Function} [customizer] The function to customize assigned values.
  44650. * @returns {Object} Returns `object`.
  44651. * @see _.assignInWith
  44652. * @example
  44653. *
  44654. * function customizer(objValue, srcValue) {
  44655. * return _.isUndefined(objValue) ? srcValue : objValue;
  44656. * }
  44657. *
  44658. * var defaults = _.partialRight(_.assignWith, customizer);
  44659. *
  44660. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  44661. * // => { 'a': 1, 'b': 2 }
  44662. */
  44663. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  44664. copyObject(source, keys(source), object, customizer);
  44665. });
  44666. /**
  44667. * Creates an array of values corresponding to `paths` of `object`.
  44668. *
  44669. * @static
  44670. * @memberOf _
  44671. * @since 1.0.0
  44672. * @category Object
  44673. * @param {Object} object The object to iterate over.
  44674. * @param {...(string|string[])} [paths] The property paths to pick.
  44675. * @returns {Array} Returns the picked values.
  44676. * @example
  44677. *
  44678. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  44679. *
  44680. * _.at(object, ['a[0].b.c', 'a[1]']);
  44681. * // => [3, 4]
  44682. */
  44683. var at = flatRest(baseAt);
  44684. /**
  44685. * Creates an object that inherits from the `prototype` object. If a
  44686. * `properties` object is given, its own enumerable string keyed properties
  44687. * are assigned to the created object.
  44688. *
  44689. * @static
  44690. * @memberOf _
  44691. * @since 2.3.0
  44692. * @category Object
  44693. * @param {Object} prototype The object to inherit from.
  44694. * @param {Object} [properties] The properties to assign to the object.
  44695. * @returns {Object} Returns the new object.
  44696. * @example
  44697. *
  44698. * function Shape() {
  44699. * this.x = 0;
  44700. * this.y = 0;
  44701. * }
  44702. *
  44703. * function Circle() {
  44704. * Shape.call(this);
  44705. * }
  44706. *
  44707. * Circle.prototype = _.create(Shape.prototype, {
  44708. * 'constructor': Circle
  44709. * });
  44710. *
  44711. * var circle = new Circle;
  44712. * circle instanceof Circle;
  44713. * // => true
  44714. *
  44715. * circle instanceof Shape;
  44716. * // => true
  44717. */
  44718. function create(prototype, properties) {
  44719. var result = baseCreate(prototype);
  44720. return properties == null ? result : baseAssign(result, properties);
  44721. }
  44722. /**
  44723. * Assigns own and inherited enumerable string keyed properties of source
  44724. * objects to the destination object for all destination properties that
  44725. * resolve to `undefined`. Source objects are applied from left to right.
  44726. * Once a property is set, additional values of the same property are ignored.
  44727. *
  44728. * **Note:** This method mutates `object`.
  44729. *
  44730. * @static
  44731. * @since 0.1.0
  44732. * @memberOf _
  44733. * @category Object
  44734. * @param {Object} object The destination object.
  44735. * @param {...Object} [sources] The source objects.
  44736. * @returns {Object} Returns `object`.
  44737. * @see _.defaultsDeep
  44738. * @example
  44739. *
  44740. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  44741. * // => { 'a': 1, 'b': 2 }
  44742. */
  44743. var defaults = baseRest(function(object, sources) {
  44744. object = Object(object);
  44745. var index = -1;
  44746. var length = sources.length;
  44747. var guard = length > 2 ? sources[2] : undefined;
  44748. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  44749. length = 1;
  44750. }
  44751. while (++index < length) {
  44752. var source = sources[index];
  44753. var props = keysIn(source);
  44754. var propsIndex = -1;
  44755. var propsLength = props.length;
  44756. while (++propsIndex < propsLength) {
  44757. var key = props[propsIndex];
  44758. var value = object[key];
  44759. if (value === undefined ||
  44760. (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  44761. object[key] = source[key];
  44762. }
  44763. }
  44764. }
  44765. return object;
  44766. });
  44767. /**
  44768. * This method is like `_.defaults` except that it recursively assigns
  44769. * default properties.
  44770. *
  44771. * **Note:** This method mutates `object`.
  44772. *
  44773. * @static
  44774. * @memberOf _
  44775. * @since 3.10.0
  44776. * @category Object
  44777. * @param {Object} object The destination object.
  44778. * @param {...Object} [sources] The source objects.
  44779. * @returns {Object} Returns `object`.
  44780. * @see _.defaults
  44781. * @example
  44782. *
  44783. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  44784. * // => { 'a': { 'b': 2, 'c': 3 } }
  44785. */
  44786. var defaultsDeep = baseRest(function(args) {
  44787. args.push(undefined, customDefaultsMerge);
  44788. return apply(mergeWith, undefined, args);
  44789. });
  44790. /**
  44791. * This method is like `_.find` except that it returns the key of the first
  44792. * element `predicate` returns truthy for instead of the element itself.
  44793. *
  44794. * @static
  44795. * @memberOf _
  44796. * @since 1.1.0
  44797. * @category Object
  44798. * @param {Object} object The object to inspect.
  44799. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  44800. * @returns {string|undefined} Returns the key of the matched element,
  44801. * else `undefined`.
  44802. * @example
  44803. *
  44804. * var users = {
  44805. * 'barney': { 'age': 36, 'active': true },
  44806. * 'fred': { 'age': 40, 'active': false },
  44807. * 'pebbles': { 'age': 1, 'active': true }
  44808. * };
  44809. *
  44810. * _.findKey(users, function(o) { return o.age < 40; });
  44811. * // => 'barney' (iteration order is not guaranteed)
  44812. *
  44813. * // The `_.matches` iteratee shorthand.
  44814. * _.findKey(users, { 'age': 1, 'active': true });
  44815. * // => 'pebbles'
  44816. *
  44817. * // The `_.matchesProperty` iteratee shorthand.
  44818. * _.findKey(users, ['active', false]);
  44819. * // => 'fred'
  44820. *
  44821. * // The `_.property` iteratee shorthand.
  44822. * _.findKey(users, 'active');
  44823. * // => 'barney'
  44824. */
  44825. function findKey(object, predicate) {
  44826. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  44827. }
  44828. /**
  44829. * This method is like `_.findKey` except that it iterates over elements of
  44830. * a collection in the opposite order.
  44831. *
  44832. * @static
  44833. * @memberOf _
  44834. * @since 2.0.0
  44835. * @category Object
  44836. * @param {Object} object The object to inspect.
  44837. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  44838. * @returns {string|undefined} Returns the key of the matched element,
  44839. * else `undefined`.
  44840. * @example
  44841. *
  44842. * var users = {
  44843. * 'barney': { 'age': 36, 'active': true },
  44844. * 'fred': { 'age': 40, 'active': false },
  44845. * 'pebbles': { 'age': 1, 'active': true }
  44846. * };
  44847. *
  44848. * _.findLastKey(users, function(o) { return o.age < 40; });
  44849. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  44850. *
  44851. * // The `_.matches` iteratee shorthand.
  44852. * _.findLastKey(users, { 'age': 36, 'active': true });
  44853. * // => 'barney'
  44854. *
  44855. * // The `_.matchesProperty` iteratee shorthand.
  44856. * _.findLastKey(users, ['active', false]);
  44857. * // => 'fred'
  44858. *
  44859. * // The `_.property` iteratee shorthand.
  44860. * _.findLastKey(users, 'active');
  44861. * // => 'pebbles'
  44862. */
  44863. function findLastKey(object, predicate) {
  44864. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  44865. }
  44866. /**
  44867. * Iterates over own and inherited enumerable string keyed properties of an
  44868. * object and invokes `iteratee` for each property. The iteratee is invoked
  44869. * with three arguments: (value, key, object). Iteratee functions may exit
  44870. * iteration early by explicitly returning `false`.
  44871. *
  44872. * @static
  44873. * @memberOf _
  44874. * @since 0.3.0
  44875. * @category Object
  44876. * @param {Object} object The object to iterate over.
  44877. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  44878. * @returns {Object} Returns `object`.
  44879. * @see _.forInRight
  44880. * @example
  44881. *
  44882. * function Foo() {
  44883. * this.a = 1;
  44884. * this.b = 2;
  44885. * }
  44886. *
  44887. * Foo.prototype.c = 3;
  44888. *
  44889. * _.forIn(new Foo, function(value, key) {
  44890. * console.log(key);
  44891. * });
  44892. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  44893. */
  44894. function forIn(object, iteratee) {
  44895. return object == null
  44896. ? object
  44897. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  44898. }
  44899. /**
  44900. * This method is like `_.forIn` except that it iterates over properties of
  44901. * `object` in the opposite order.
  44902. *
  44903. * @static
  44904. * @memberOf _
  44905. * @since 2.0.0
  44906. * @category Object
  44907. * @param {Object} object The object to iterate over.
  44908. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  44909. * @returns {Object} Returns `object`.
  44910. * @see _.forIn
  44911. * @example
  44912. *
  44913. * function Foo() {
  44914. * this.a = 1;
  44915. * this.b = 2;
  44916. * }
  44917. *
  44918. * Foo.prototype.c = 3;
  44919. *
  44920. * _.forInRight(new Foo, function(value, key) {
  44921. * console.log(key);
  44922. * });
  44923. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  44924. */
  44925. function forInRight(object, iteratee) {
  44926. return object == null
  44927. ? object
  44928. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  44929. }
  44930. /**
  44931. * Iterates over own enumerable string keyed properties of an object and
  44932. * invokes `iteratee` for each property. The iteratee is invoked with three
  44933. * arguments: (value, key, object). Iteratee functions may exit iteration
  44934. * early by explicitly returning `false`.
  44935. *
  44936. * @static
  44937. * @memberOf _
  44938. * @since 0.3.0
  44939. * @category Object
  44940. * @param {Object} object The object to iterate over.
  44941. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  44942. * @returns {Object} Returns `object`.
  44943. * @see _.forOwnRight
  44944. * @example
  44945. *
  44946. * function Foo() {
  44947. * this.a = 1;
  44948. * this.b = 2;
  44949. * }
  44950. *
  44951. * Foo.prototype.c = 3;
  44952. *
  44953. * _.forOwn(new Foo, function(value, key) {
  44954. * console.log(key);
  44955. * });
  44956. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  44957. */
  44958. function forOwn(object, iteratee) {
  44959. return object && baseForOwn(object, getIteratee(iteratee, 3));
  44960. }
  44961. /**
  44962. * This method is like `_.forOwn` except that it iterates over properties of
  44963. * `object` in the opposite order.
  44964. *
  44965. * @static
  44966. * @memberOf _
  44967. * @since 2.0.0
  44968. * @category Object
  44969. * @param {Object} object The object to iterate over.
  44970. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  44971. * @returns {Object} Returns `object`.
  44972. * @see _.forOwn
  44973. * @example
  44974. *
  44975. * function Foo() {
  44976. * this.a = 1;
  44977. * this.b = 2;
  44978. * }
  44979. *
  44980. * Foo.prototype.c = 3;
  44981. *
  44982. * _.forOwnRight(new Foo, function(value, key) {
  44983. * console.log(key);
  44984. * });
  44985. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  44986. */
  44987. function forOwnRight(object, iteratee) {
  44988. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  44989. }
  44990. /**
  44991. * Creates an array of function property names from own enumerable properties
  44992. * of `object`.
  44993. *
  44994. * @static
  44995. * @since 0.1.0
  44996. * @memberOf _
  44997. * @category Object
  44998. * @param {Object} object The object to inspect.
  44999. * @returns {Array} Returns the function names.
  45000. * @see _.functionsIn
  45001. * @example
  45002. *
  45003. * function Foo() {
  45004. * this.a = _.constant('a');
  45005. * this.b = _.constant('b');
  45006. * }
  45007. *
  45008. * Foo.prototype.c = _.constant('c');
  45009. *
  45010. * _.functions(new Foo);
  45011. * // => ['a', 'b']
  45012. */
  45013. function functions(object) {
  45014. return object == null ? [] : baseFunctions(object, keys(object));
  45015. }
  45016. /**
  45017. * Creates an array of function property names from own and inherited
  45018. * enumerable properties of `object`.
  45019. *
  45020. * @static
  45021. * @memberOf _
  45022. * @since 4.0.0
  45023. * @category Object
  45024. * @param {Object} object The object to inspect.
  45025. * @returns {Array} Returns the function names.
  45026. * @see _.functions
  45027. * @example
  45028. *
  45029. * function Foo() {
  45030. * this.a = _.constant('a');
  45031. * this.b = _.constant('b');
  45032. * }
  45033. *
  45034. * Foo.prototype.c = _.constant('c');
  45035. *
  45036. * _.functionsIn(new Foo);
  45037. * // => ['a', 'b', 'c']
  45038. */
  45039. function functionsIn(object) {
  45040. return object == null ? [] : baseFunctions(object, keysIn(object));
  45041. }
  45042. /**
  45043. * Gets the value at `path` of `object`. If the resolved value is
  45044. * `undefined`, the `defaultValue` is returned in its place.
  45045. *
  45046. * @static
  45047. * @memberOf _
  45048. * @since 3.7.0
  45049. * @category Object
  45050. * @param {Object} object The object to query.
  45051. * @param {Array|string} path The path of the property to get.
  45052. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  45053. * @returns {*} Returns the resolved value.
  45054. * @example
  45055. *
  45056. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  45057. *
  45058. * _.get(object, 'a[0].b.c');
  45059. * // => 3
  45060. *
  45061. * _.get(object, ['a', '0', 'b', 'c']);
  45062. * // => 3
  45063. *
  45064. * _.get(object, 'a.b.c', 'default');
  45065. * // => 'default'
  45066. */
  45067. function get(object, path, defaultValue) {
  45068. var result = object == null ? undefined : baseGet(object, path);
  45069. return result === undefined ? defaultValue : result;
  45070. }
  45071. /**
  45072. * Checks if `path` is a direct property of `object`.
  45073. *
  45074. * @static
  45075. * @since 0.1.0
  45076. * @memberOf _
  45077. * @category Object
  45078. * @param {Object} object The object to query.
  45079. * @param {Array|string} path The path to check.
  45080. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  45081. * @example
  45082. *
  45083. * var object = { 'a': { 'b': 2 } };
  45084. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  45085. *
  45086. * _.has(object, 'a');
  45087. * // => true
  45088. *
  45089. * _.has(object, 'a.b');
  45090. * // => true
  45091. *
  45092. * _.has(object, ['a', 'b']);
  45093. * // => true
  45094. *
  45095. * _.has(other, 'a');
  45096. * // => false
  45097. */
  45098. function has(object, path) {
  45099. return object != null && hasPath(object, path, baseHas);
  45100. }
  45101. /**
  45102. * Checks if `path` is a direct or inherited property of `object`.
  45103. *
  45104. * @static
  45105. * @memberOf _
  45106. * @since 4.0.0
  45107. * @category Object
  45108. * @param {Object} object The object to query.
  45109. * @param {Array|string} path The path to check.
  45110. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  45111. * @example
  45112. *
  45113. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  45114. *
  45115. * _.hasIn(object, 'a');
  45116. * // => true
  45117. *
  45118. * _.hasIn(object, 'a.b');
  45119. * // => true
  45120. *
  45121. * _.hasIn(object, ['a', 'b']);
  45122. * // => true
  45123. *
  45124. * _.hasIn(object, 'b');
  45125. * // => false
  45126. */
  45127. function hasIn(object, path) {
  45128. return object != null && hasPath(object, path, baseHasIn);
  45129. }
  45130. /**
  45131. * Creates an object composed of the inverted keys and values of `object`.
  45132. * If `object` contains duplicate values, subsequent values overwrite
  45133. * property assignments of previous values.
  45134. *
  45135. * @static
  45136. * @memberOf _
  45137. * @since 0.7.0
  45138. * @category Object
  45139. * @param {Object} object The object to invert.
  45140. * @returns {Object} Returns the new inverted object.
  45141. * @example
  45142. *
  45143. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  45144. *
  45145. * _.invert(object);
  45146. * // => { '1': 'c', '2': 'b' }
  45147. */
  45148. var invert = createInverter(function(result, value, key) {
  45149. if (value != null &&
  45150. typeof value.toString != 'function') {
  45151. value = nativeObjectToString.call(value);
  45152. }
  45153. result[value] = key;
  45154. }, constant(identity));
  45155. /**
  45156. * This method is like `_.invert` except that the inverted object is generated
  45157. * from the results of running each element of `object` thru `iteratee`. The
  45158. * corresponding inverted value of each inverted key is an array of keys
  45159. * responsible for generating the inverted value. The iteratee is invoked
  45160. * with one argument: (value).
  45161. *
  45162. * @static
  45163. * @memberOf _
  45164. * @since 4.1.0
  45165. * @category Object
  45166. * @param {Object} object The object to invert.
  45167. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  45168. * @returns {Object} Returns the new inverted object.
  45169. * @example
  45170. *
  45171. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  45172. *
  45173. * _.invertBy(object);
  45174. * // => { '1': ['a', 'c'], '2': ['b'] }
  45175. *
  45176. * _.invertBy(object, function(value) {
  45177. * return 'group' + value;
  45178. * });
  45179. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  45180. */
  45181. var invertBy = createInverter(function(result, value, key) {
  45182. if (value != null &&
  45183. typeof value.toString != 'function') {
  45184. value = nativeObjectToString.call(value);
  45185. }
  45186. if (hasOwnProperty.call(result, value)) {
  45187. result[value].push(key);
  45188. } else {
  45189. result[value] = [key];
  45190. }
  45191. }, getIteratee);
  45192. /**
  45193. * Invokes the method at `path` of `object`.
  45194. *
  45195. * @static
  45196. * @memberOf _
  45197. * @since 4.0.0
  45198. * @category Object
  45199. * @param {Object} object The object to query.
  45200. * @param {Array|string} path The path of the method to invoke.
  45201. * @param {...*} [args] The arguments to invoke the method with.
  45202. * @returns {*} Returns the result of the invoked method.
  45203. * @example
  45204. *
  45205. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  45206. *
  45207. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  45208. * // => [2, 3]
  45209. */
  45210. var invoke = baseRest(baseInvoke);
  45211. /**
  45212. * Creates an array of the own enumerable property names of `object`.
  45213. *
  45214. * **Note:** Non-object values are coerced to objects. See the
  45215. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  45216. * for more details.
  45217. *
  45218. * @static
  45219. * @since 0.1.0
  45220. * @memberOf _
  45221. * @category Object
  45222. * @param {Object} object The object to query.
  45223. * @returns {Array} Returns the array of property names.
  45224. * @example
  45225. *
  45226. * function Foo() {
  45227. * this.a = 1;
  45228. * this.b = 2;
  45229. * }
  45230. *
  45231. * Foo.prototype.c = 3;
  45232. *
  45233. * _.keys(new Foo);
  45234. * // => ['a', 'b'] (iteration order is not guaranteed)
  45235. *
  45236. * _.keys('hi');
  45237. * // => ['0', '1']
  45238. */
  45239. function keys(object) {
  45240. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  45241. }
  45242. /**
  45243. * Creates an array of the own and inherited enumerable property names of `object`.
  45244. *
  45245. * **Note:** Non-object values are coerced to objects.
  45246. *
  45247. * @static
  45248. * @memberOf _
  45249. * @since 3.0.0
  45250. * @category Object
  45251. * @param {Object} object The object to query.
  45252. * @returns {Array} Returns the array of property names.
  45253. * @example
  45254. *
  45255. * function Foo() {
  45256. * this.a = 1;
  45257. * this.b = 2;
  45258. * }
  45259. *
  45260. * Foo.prototype.c = 3;
  45261. *
  45262. * _.keysIn(new Foo);
  45263. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  45264. */
  45265. function keysIn(object) {
  45266. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  45267. }
  45268. /**
  45269. * The opposite of `_.mapValues`; this method creates an object with the
  45270. * same values as `object` and keys generated by running each own enumerable
  45271. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  45272. * with three arguments: (value, key, object).
  45273. *
  45274. * @static
  45275. * @memberOf _
  45276. * @since 3.8.0
  45277. * @category Object
  45278. * @param {Object} object The object to iterate over.
  45279. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  45280. * @returns {Object} Returns the new mapped object.
  45281. * @see _.mapValues
  45282. * @example
  45283. *
  45284. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  45285. * return key + value;
  45286. * });
  45287. * // => { 'a1': 1, 'b2': 2 }
  45288. */
  45289. function mapKeys(object, iteratee) {
  45290. var result = {};
  45291. iteratee = getIteratee(iteratee, 3);
  45292. baseForOwn(object, function(value, key, object) {
  45293. baseAssignValue(result, iteratee(value, key, object), value);
  45294. });
  45295. return result;
  45296. }
  45297. /**
  45298. * Creates an object with the same keys as `object` and values generated
  45299. * by running each own enumerable string keyed property of `object` thru
  45300. * `iteratee`. The iteratee is invoked with three arguments:
  45301. * (value, key, object).
  45302. *
  45303. * @static
  45304. * @memberOf _
  45305. * @since 2.4.0
  45306. * @category Object
  45307. * @param {Object} object The object to iterate over.
  45308. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  45309. * @returns {Object} Returns the new mapped object.
  45310. * @see _.mapKeys
  45311. * @example
  45312. *
  45313. * var users = {
  45314. * 'fred': { 'user': 'fred', 'age': 40 },
  45315. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  45316. * };
  45317. *
  45318. * _.mapValues(users, function(o) { return o.age; });
  45319. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  45320. *
  45321. * // The `_.property` iteratee shorthand.
  45322. * _.mapValues(users, 'age');
  45323. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  45324. */
  45325. function mapValues(object, iteratee) {
  45326. var result = {};
  45327. iteratee = getIteratee(iteratee, 3);
  45328. baseForOwn(object, function(value, key, object) {
  45329. baseAssignValue(result, key, iteratee(value, key, object));
  45330. });
  45331. return result;
  45332. }
  45333. /**
  45334. * This method is like `_.assign` except that it recursively merges own and
  45335. * inherited enumerable string keyed properties of source objects into the
  45336. * destination object. Source properties that resolve to `undefined` are
  45337. * skipped if a destination value exists. Array and plain object properties
  45338. * are merged recursively. Other objects and value types are overridden by
  45339. * assignment. Source objects are applied from left to right. Subsequent
  45340. * sources overwrite property assignments of previous sources.
  45341. *
  45342. * **Note:** This method mutates `object`.
  45343. *
  45344. * @static
  45345. * @memberOf _
  45346. * @since 0.5.0
  45347. * @category Object
  45348. * @param {Object} object The destination object.
  45349. * @param {...Object} [sources] The source objects.
  45350. * @returns {Object} Returns `object`.
  45351. * @example
  45352. *
  45353. * var object = {
  45354. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  45355. * };
  45356. *
  45357. * var other = {
  45358. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  45359. * };
  45360. *
  45361. * _.merge(object, other);
  45362. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  45363. */
  45364. var merge = createAssigner(function(object, source, srcIndex) {
  45365. baseMerge(object, source, srcIndex);
  45366. });
  45367. /**
  45368. * This method is like `_.merge` except that it accepts `customizer` which
  45369. * is invoked to produce the merged values of the destination and source
  45370. * properties. If `customizer` returns `undefined`, merging is handled by the
  45371. * method instead. The `customizer` is invoked with six arguments:
  45372. * (objValue, srcValue, key, object, source, stack).
  45373. *
  45374. * **Note:** This method mutates `object`.
  45375. *
  45376. * @static
  45377. * @memberOf _
  45378. * @since 4.0.0
  45379. * @category Object
  45380. * @param {Object} object The destination object.
  45381. * @param {...Object} sources The source objects.
  45382. * @param {Function} customizer The function to customize assigned values.
  45383. * @returns {Object} Returns `object`.
  45384. * @example
  45385. *
  45386. * function customizer(objValue, srcValue) {
  45387. * if (_.isArray(objValue)) {
  45388. * return objValue.concat(srcValue);
  45389. * }
  45390. * }
  45391. *
  45392. * var object = { 'a': [1], 'b': [2] };
  45393. * var other = { 'a': [3], 'b': [4] };
  45394. *
  45395. * _.mergeWith(object, other, customizer);
  45396. * // => { 'a': [1, 3], 'b': [2, 4] }
  45397. */
  45398. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  45399. baseMerge(object, source, srcIndex, customizer);
  45400. });
  45401. /**
  45402. * The opposite of `_.pick`; this method creates an object composed of the
  45403. * own and inherited enumerable property paths of `object` that are not omitted.
  45404. *
  45405. * **Note:** This method is considerably slower than `_.pick`.
  45406. *
  45407. * @static
  45408. * @since 0.1.0
  45409. * @memberOf _
  45410. * @category Object
  45411. * @param {Object} object The source object.
  45412. * @param {...(string|string[])} [paths] The property paths to omit.
  45413. * @returns {Object} Returns the new object.
  45414. * @example
  45415. *
  45416. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  45417. *
  45418. * _.omit(object, ['a', 'c']);
  45419. * // => { 'b': '2' }
  45420. */
  45421. var omit = flatRest(function(object, paths) {
  45422. var result = {};
  45423. if (object == null) {
  45424. return result;
  45425. }
  45426. var isDeep = false;
  45427. paths = arrayMap(paths, function(path) {
  45428. path = castPath(path, object);
  45429. isDeep || (isDeep = path.length > 1);
  45430. return path;
  45431. });
  45432. copyObject(object, getAllKeysIn(object), result);
  45433. if (isDeep) {
  45434. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  45435. }
  45436. var length = paths.length;
  45437. while (length--) {
  45438. baseUnset(result, paths[length]);
  45439. }
  45440. return result;
  45441. });
  45442. /**
  45443. * The opposite of `_.pickBy`; this method creates an object composed of
  45444. * the own and inherited enumerable string keyed properties of `object` that
  45445. * `predicate` doesn't return truthy for. The predicate is invoked with two
  45446. * arguments: (value, key).
  45447. *
  45448. * @static
  45449. * @memberOf _
  45450. * @since 4.0.0
  45451. * @category Object
  45452. * @param {Object} object The source object.
  45453. * @param {Function} [predicate=_.identity] The function invoked per property.
  45454. * @returns {Object} Returns the new object.
  45455. * @example
  45456. *
  45457. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  45458. *
  45459. * _.omitBy(object, _.isNumber);
  45460. * // => { 'b': '2' }
  45461. */
  45462. function omitBy(object, predicate) {
  45463. return pickBy(object, negate(getIteratee(predicate)));
  45464. }
  45465. /**
  45466. * Creates an object composed of the picked `object` properties.
  45467. *
  45468. * @static
  45469. * @since 0.1.0
  45470. * @memberOf _
  45471. * @category Object
  45472. * @param {Object} object The source object.
  45473. * @param {...(string|string[])} [paths] The property paths to pick.
  45474. * @returns {Object} Returns the new object.
  45475. * @example
  45476. *
  45477. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  45478. *
  45479. * _.pick(object, ['a', 'c']);
  45480. * // => { 'a': 1, 'c': 3 }
  45481. */
  45482. var pick = flatRest(function(object, paths) {
  45483. return object == null ? {} : basePick(object, paths);
  45484. });
  45485. /**
  45486. * Creates an object composed of the `object` properties `predicate` returns
  45487. * truthy for. The predicate is invoked with two arguments: (value, key).
  45488. *
  45489. * @static
  45490. * @memberOf _
  45491. * @since 4.0.0
  45492. * @category Object
  45493. * @param {Object} object The source object.
  45494. * @param {Function} [predicate=_.identity] The function invoked per property.
  45495. * @returns {Object} Returns the new object.
  45496. * @example
  45497. *
  45498. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  45499. *
  45500. * _.pickBy(object, _.isNumber);
  45501. * // => { 'a': 1, 'c': 3 }
  45502. */
  45503. function pickBy(object, predicate) {
  45504. if (object == null) {
  45505. return {};
  45506. }
  45507. var props = arrayMap(getAllKeysIn(object), function(prop) {
  45508. return [prop];
  45509. });
  45510. predicate = getIteratee(predicate);
  45511. return basePickBy(object, props, function(value, path) {
  45512. return predicate(value, path[0]);
  45513. });
  45514. }
  45515. /**
  45516. * This method is like `_.get` except that if the resolved value is a
  45517. * function it's invoked with the `this` binding of its parent object and
  45518. * its result is returned.
  45519. *
  45520. * @static
  45521. * @since 0.1.0
  45522. * @memberOf _
  45523. * @category Object
  45524. * @param {Object} object The object to query.
  45525. * @param {Array|string} path The path of the property to resolve.
  45526. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  45527. * @returns {*} Returns the resolved value.
  45528. * @example
  45529. *
  45530. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  45531. *
  45532. * _.result(object, 'a[0].b.c1');
  45533. * // => 3
  45534. *
  45535. * _.result(object, 'a[0].b.c2');
  45536. * // => 4
  45537. *
  45538. * _.result(object, 'a[0].b.c3', 'default');
  45539. * // => 'default'
  45540. *
  45541. * _.result(object, 'a[0].b.c3', _.constant('default'));
  45542. * // => 'default'
  45543. */
  45544. function result(object, path, defaultValue) {
  45545. path = castPath(path, object);
  45546. var index = -1,
  45547. length = path.length;
  45548. // Ensure the loop is entered when path is empty.
  45549. if (!length) {
  45550. length = 1;
  45551. object = undefined;
  45552. }
  45553. while (++index < length) {
  45554. var value = object == null ? undefined : object[toKey(path[index])];
  45555. if (value === undefined) {
  45556. index = length;
  45557. value = defaultValue;
  45558. }
  45559. object = isFunction(value) ? value.call(object) : value;
  45560. }
  45561. return object;
  45562. }
  45563. /**
  45564. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  45565. * it's created. Arrays are created for missing index properties while objects
  45566. * are created for all other missing properties. Use `_.setWith` to customize
  45567. * `path` creation.
  45568. *
  45569. * **Note:** This method mutates `object`.
  45570. *
  45571. * @static
  45572. * @memberOf _
  45573. * @since 3.7.0
  45574. * @category Object
  45575. * @param {Object} object The object to modify.
  45576. * @param {Array|string} path The path of the property to set.
  45577. * @param {*} value The value to set.
  45578. * @returns {Object} Returns `object`.
  45579. * @example
  45580. *
  45581. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  45582. *
  45583. * _.set(object, 'a[0].b.c', 4);
  45584. * console.log(object.a[0].b.c);
  45585. * // => 4
  45586. *
  45587. * _.set(object, ['x', '0', 'y', 'z'], 5);
  45588. * console.log(object.x[0].y.z);
  45589. * // => 5
  45590. */
  45591. function set(object, path, value) {
  45592. return object == null ? object : baseSet(object, path, value);
  45593. }
  45594. /**
  45595. * This method is like `_.set` except that it accepts `customizer` which is
  45596. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  45597. * path creation is handled by the method instead. The `customizer` is invoked
  45598. * with three arguments: (nsValue, key, nsObject).
  45599. *
  45600. * **Note:** This method mutates `object`.
  45601. *
  45602. * @static
  45603. * @memberOf _
  45604. * @since 4.0.0
  45605. * @category Object
  45606. * @param {Object} object The object to modify.
  45607. * @param {Array|string} path The path of the property to set.
  45608. * @param {*} value The value to set.
  45609. * @param {Function} [customizer] The function to customize assigned values.
  45610. * @returns {Object} Returns `object`.
  45611. * @example
  45612. *
  45613. * var object = {};
  45614. *
  45615. * _.setWith(object, '[0][1]', 'a', Object);
  45616. * // => { '0': { '1': 'a' } }
  45617. */
  45618. function setWith(object, path, value, customizer) {
  45619. customizer = typeof customizer == 'function' ? customizer : undefined;
  45620. return object == null ? object : baseSet(object, path, value, customizer);
  45621. }
  45622. /**
  45623. * Creates an array of own enumerable string keyed-value pairs for `object`
  45624. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  45625. * entries are returned.
  45626. *
  45627. * @static
  45628. * @memberOf _
  45629. * @since 4.0.0
  45630. * @alias entries
  45631. * @category Object
  45632. * @param {Object} object The object to query.
  45633. * @returns {Array} Returns the key-value pairs.
  45634. * @example
  45635. *
  45636. * function Foo() {
  45637. * this.a = 1;
  45638. * this.b = 2;
  45639. * }
  45640. *
  45641. * Foo.prototype.c = 3;
  45642. *
  45643. * _.toPairs(new Foo);
  45644. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  45645. */
  45646. var toPairs = createToPairs(keys);
  45647. /**
  45648. * Creates an array of own and inherited enumerable string keyed-value pairs
  45649. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  45650. * or set, its entries are returned.
  45651. *
  45652. * @static
  45653. * @memberOf _
  45654. * @since 4.0.0
  45655. * @alias entriesIn
  45656. * @category Object
  45657. * @param {Object} object The object to query.
  45658. * @returns {Array} Returns the key-value pairs.
  45659. * @example
  45660. *
  45661. * function Foo() {
  45662. * this.a = 1;
  45663. * this.b = 2;
  45664. * }
  45665. *
  45666. * Foo.prototype.c = 3;
  45667. *
  45668. * _.toPairsIn(new Foo);
  45669. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  45670. */
  45671. var toPairsIn = createToPairs(keysIn);
  45672. /**
  45673. * An alternative to `_.reduce`; this method transforms `object` to a new
  45674. * `accumulator` object which is the result of running each of its own
  45675. * enumerable string keyed properties thru `iteratee`, with each invocation
  45676. * potentially mutating the `accumulator` object. If `accumulator` is not
  45677. * provided, a new object with the same `[[Prototype]]` will be used. The
  45678. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  45679. * Iteratee functions may exit iteration early by explicitly returning `false`.
  45680. *
  45681. * @static
  45682. * @memberOf _
  45683. * @since 1.3.0
  45684. * @category Object
  45685. * @param {Object} object The object to iterate over.
  45686. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  45687. * @param {*} [accumulator] The custom accumulator value.
  45688. * @returns {*} Returns the accumulated value.
  45689. * @example
  45690. *
  45691. * _.transform([2, 3, 4], function(result, n) {
  45692. * result.push(n *= n);
  45693. * return n % 2 == 0;
  45694. * }, []);
  45695. * // => [4, 9]
  45696. *
  45697. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  45698. * (result[value] || (result[value] = [])).push(key);
  45699. * }, {});
  45700. * // => { '1': ['a', 'c'], '2': ['b'] }
  45701. */
  45702. function transform(object, iteratee, accumulator) {
  45703. var isArr = isArray(object),
  45704. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  45705. iteratee = getIteratee(iteratee, 4);
  45706. if (accumulator == null) {
  45707. var Ctor = object && object.constructor;
  45708. if (isArrLike) {
  45709. accumulator = isArr ? new Ctor : [];
  45710. }
  45711. else if (isObject(object)) {
  45712. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  45713. }
  45714. else {
  45715. accumulator = {};
  45716. }
  45717. }
  45718. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  45719. return iteratee(accumulator, value, index, object);
  45720. });
  45721. return accumulator;
  45722. }
  45723. /**
  45724. * Removes the property at `path` of `object`.
  45725. *
  45726. * **Note:** This method mutates `object`.
  45727. *
  45728. * @static
  45729. * @memberOf _
  45730. * @since 4.0.0
  45731. * @category Object
  45732. * @param {Object} object The object to modify.
  45733. * @param {Array|string} path The path of the property to unset.
  45734. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  45735. * @example
  45736. *
  45737. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  45738. * _.unset(object, 'a[0].b.c');
  45739. * // => true
  45740. *
  45741. * console.log(object);
  45742. * // => { 'a': [{ 'b': {} }] };
  45743. *
  45744. * _.unset(object, ['a', '0', 'b', 'c']);
  45745. * // => true
  45746. *
  45747. * console.log(object);
  45748. * // => { 'a': [{ 'b': {} }] };
  45749. */
  45750. function unset(object, path) {
  45751. return object == null ? true : baseUnset(object, path);
  45752. }
  45753. /**
  45754. * This method is like `_.set` except that accepts `updater` to produce the
  45755. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  45756. * is invoked with one argument: (value).
  45757. *
  45758. * **Note:** This method mutates `object`.
  45759. *
  45760. * @static
  45761. * @memberOf _
  45762. * @since 4.6.0
  45763. * @category Object
  45764. * @param {Object} object The object to modify.
  45765. * @param {Array|string} path The path of the property to set.
  45766. * @param {Function} updater The function to produce the updated value.
  45767. * @returns {Object} Returns `object`.
  45768. * @example
  45769. *
  45770. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  45771. *
  45772. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  45773. * console.log(object.a[0].b.c);
  45774. * // => 9
  45775. *
  45776. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  45777. * console.log(object.x[0].y.z);
  45778. * // => 0
  45779. */
  45780. function update(object, path, updater) {
  45781. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  45782. }
  45783. /**
  45784. * This method is like `_.update` except that it accepts `customizer` which is
  45785. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  45786. * path creation is handled by the method instead. The `customizer` is invoked
  45787. * with three arguments: (nsValue, key, nsObject).
  45788. *
  45789. * **Note:** This method mutates `object`.
  45790. *
  45791. * @static
  45792. * @memberOf _
  45793. * @since 4.6.0
  45794. * @category Object
  45795. * @param {Object} object The object to modify.
  45796. * @param {Array|string} path The path of the property to set.
  45797. * @param {Function} updater The function to produce the updated value.
  45798. * @param {Function} [customizer] The function to customize assigned values.
  45799. * @returns {Object} Returns `object`.
  45800. * @example
  45801. *
  45802. * var object = {};
  45803. *
  45804. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  45805. * // => { '0': { '1': 'a' } }
  45806. */
  45807. function updateWith(object, path, updater, customizer) {
  45808. customizer = typeof customizer == 'function' ? customizer : undefined;
  45809. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  45810. }
  45811. /**
  45812. * Creates an array of the own enumerable string keyed property values of `object`.
  45813. *
  45814. * **Note:** Non-object values are coerced to objects.
  45815. *
  45816. * @static
  45817. * @since 0.1.0
  45818. * @memberOf _
  45819. * @category Object
  45820. * @param {Object} object The object to query.
  45821. * @returns {Array} Returns the array of property values.
  45822. * @example
  45823. *
  45824. * function Foo() {
  45825. * this.a = 1;
  45826. * this.b = 2;
  45827. * }
  45828. *
  45829. * Foo.prototype.c = 3;
  45830. *
  45831. * _.values(new Foo);
  45832. * // => [1, 2] (iteration order is not guaranteed)
  45833. *
  45834. * _.values('hi');
  45835. * // => ['h', 'i']
  45836. */
  45837. function values(object) {
  45838. return object == null ? [] : baseValues(object, keys(object));
  45839. }
  45840. /**
  45841. * Creates an array of the own and inherited enumerable string keyed property
  45842. * values of `object`.
  45843. *
  45844. * **Note:** Non-object values are coerced to objects.
  45845. *
  45846. * @static
  45847. * @memberOf _
  45848. * @since 3.0.0
  45849. * @category Object
  45850. * @param {Object} object The object to query.
  45851. * @returns {Array} Returns the array of property values.
  45852. * @example
  45853. *
  45854. * function Foo() {
  45855. * this.a = 1;
  45856. * this.b = 2;
  45857. * }
  45858. *
  45859. * Foo.prototype.c = 3;
  45860. *
  45861. * _.valuesIn(new Foo);
  45862. * // => [1, 2, 3] (iteration order is not guaranteed)
  45863. */
  45864. function valuesIn(object) {
  45865. return object == null ? [] : baseValues(object, keysIn(object));
  45866. }
  45867. /*------------------------------------------------------------------------*/
  45868. /**
  45869. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  45870. *
  45871. * @static
  45872. * @memberOf _
  45873. * @since 4.0.0
  45874. * @category Number
  45875. * @param {number} number The number to clamp.
  45876. * @param {number} [lower] The lower bound.
  45877. * @param {number} upper The upper bound.
  45878. * @returns {number} Returns the clamped number.
  45879. * @example
  45880. *
  45881. * _.clamp(-10, -5, 5);
  45882. * // => -5
  45883. *
  45884. * _.clamp(10, -5, 5);
  45885. * // => 5
  45886. */
  45887. function clamp(number, lower, upper) {
  45888. if (upper === undefined) {
  45889. upper = lower;
  45890. lower = undefined;
  45891. }
  45892. if (upper !== undefined) {
  45893. upper = toNumber(upper);
  45894. upper = upper === upper ? upper : 0;
  45895. }
  45896. if (lower !== undefined) {
  45897. lower = toNumber(lower);
  45898. lower = lower === lower ? lower : 0;
  45899. }
  45900. return baseClamp(toNumber(number), lower, upper);
  45901. }
  45902. /**
  45903. * Checks if `n` is between `start` and up to, but not including, `end`. If
  45904. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  45905. * If `start` is greater than `end` the params are swapped to support
  45906. * negative ranges.
  45907. *
  45908. * @static
  45909. * @memberOf _
  45910. * @since 3.3.0
  45911. * @category Number
  45912. * @param {number} number The number to check.
  45913. * @param {number} [start=0] The start of the range.
  45914. * @param {number} end The end of the range.
  45915. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  45916. * @see _.range, _.rangeRight
  45917. * @example
  45918. *
  45919. * _.inRange(3, 2, 4);
  45920. * // => true
  45921. *
  45922. * _.inRange(4, 8);
  45923. * // => true
  45924. *
  45925. * _.inRange(4, 2);
  45926. * // => false
  45927. *
  45928. * _.inRange(2, 2);
  45929. * // => false
  45930. *
  45931. * _.inRange(1.2, 2);
  45932. * // => true
  45933. *
  45934. * _.inRange(5.2, 4);
  45935. * // => false
  45936. *
  45937. * _.inRange(-3, -2, -6);
  45938. * // => true
  45939. */
  45940. function inRange(number, start, end) {
  45941. start = toFinite(start);
  45942. if (end === undefined) {
  45943. end = start;
  45944. start = 0;
  45945. } else {
  45946. end = toFinite(end);
  45947. }
  45948. number = toNumber(number);
  45949. return baseInRange(number, start, end);
  45950. }
  45951. /**
  45952. * Produces a random number between the inclusive `lower` and `upper` bounds.
  45953. * If only one argument is provided a number between `0` and the given number
  45954. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  45955. * floats, a floating-point number is returned instead of an integer.
  45956. *
  45957. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  45958. * floating-point values which can produce unexpected results.
  45959. *
  45960. * @static
  45961. * @memberOf _
  45962. * @since 0.7.0
  45963. * @category Number
  45964. * @param {number} [lower=0] The lower bound.
  45965. * @param {number} [upper=1] The upper bound.
  45966. * @param {boolean} [floating] Specify returning a floating-point number.
  45967. * @returns {number} Returns the random number.
  45968. * @example
  45969. *
  45970. * _.random(0, 5);
  45971. * // => an integer between 0 and 5
  45972. *
  45973. * _.random(5);
  45974. * // => also an integer between 0 and 5
  45975. *
  45976. * _.random(5, true);
  45977. * // => a floating-point number between 0 and 5
  45978. *
  45979. * _.random(1.2, 5.2);
  45980. * // => a floating-point number between 1.2 and 5.2
  45981. */
  45982. function random(lower, upper, floating) {
  45983. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  45984. upper = floating = undefined;
  45985. }
  45986. if (floating === undefined) {
  45987. if (typeof upper == 'boolean') {
  45988. floating = upper;
  45989. upper = undefined;
  45990. }
  45991. else if (typeof lower == 'boolean') {
  45992. floating = lower;
  45993. lower = undefined;
  45994. }
  45995. }
  45996. if (lower === undefined && upper === undefined) {
  45997. lower = 0;
  45998. upper = 1;
  45999. }
  46000. else {
  46001. lower = toFinite(lower);
  46002. if (upper === undefined) {
  46003. upper = lower;
  46004. lower = 0;
  46005. } else {
  46006. upper = toFinite(upper);
  46007. }
  46008. }
  46009. if (lower > upper) {
  46010. var temp = lower;
  46011. lower = upper;
  46012. upper = temp;
  46013. }
  46014. if (floating || lower % 1 || upper % 1) {
  46015. var rand = nativeRandom();
  46016. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  46017. }
  46018. return baseRandom(lower, upper);
  46019. }
  46020. /*------------------------------------------------------------------------*/
  46021. /**
  46022. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  46023. *
  46024. * @static
  46025. * @memberOf _
  46026. * @since 3.0.0
  46027. * @category String
  46028. * @param {string} [string=''] The string to convert.
  46029. * @returns {string} Returns the camel cased string.
  46030. * @example
  46031. *
  46032. * _.camelCase('Foo Bar');
  46033. * // => 'fooBar'
  46034. *
  46035. * _.camelCase('--foo-bar--');
  46036. * // => 'fooBar'
  46037. *
  46038. * _.camelCase('__FOO_BAR__');
  46039. * // => 'fooBar'
  46040. */
  46041. var camelCase = createCompounder(function(result, word, index) {
  46042. word = word.toLowerCase();
  46043. return result + (index ? capitalize(word) : word);
  46044. });
  46045. /**
  46046. * Converts the first character of `string` to upper case and the remaining
  46047. * to lower case.
  46048. *
  46049. * @static
  46050. * @memberOf _
  46051. * @since 3.0.0
  46052. * @category String
  46053. * @param {string} [string=''] The string to capitalize.
  46054. * @returns {string} Returns the capitalized string.
  46055. * @example
  46056. *
  46057. * _.capitalize('FRED');
  46058. * // => 'Fred'
  46059. */
  46060. function capitalize(string) {
  46061. return upperFirst(toString(string).toLowerCase());
  46062. }
  46063. /**
  46064. * Deburrs `string` by converting
  46065. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  46066. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  46067. * letters to basic Latin letters and removing
  46068. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  46069. *
  46070. * @static
  46071. * @memberOf _
  46072. * @since 3.0.0
  46073. * @category String
  46074. * @param {string} [string=''] The string to deburr.
  46075. * @returns {string} Returns the deburred string.
  46076. * @example
  46077. *
  46078. * _.deburr('déjà vu');
  46079. * // => 'deja vu'
  46080. */
  46081. function deburr(string) {
  46082. string = toString(string);
  46083. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  46084. }
  46085. /**
  46086. * Checks if `string` ends with the given target string.
  46087. *
  46088. * @static
  46089. * @memberOf _
  46090. * @since 3.0.0
  46091. * @category String
  46092. * @param {string} [string=''] The string to inspect.
  46093. * @param {string} [target] The string to search for.
  46094. * @param {number} [position=string.length] The position to search up to.
  46095. * @returns {boolean} Returns `true` if `string` ends with `target`,
  46096. * else `false`.
  46097. * @example
  46098. *
  46099. * _.endsWith('abc', 'c');
  46100. * // => true
  46101. *
  46102. * _.endsWith('abc', 'b');
  46103. * // => false
  46104. *
  46105. * _.endsWith('abc', 'b', 2);
  46106. * // => true
  46107. */
  46108. function endsWith(string, target, position) {
  46109. string = toString(string);
  46110. target = baseToString(target);
  46111. var length = string.length;
  46112. position = position === undefined
  46113. ? length
  46114. : baseClamp(toInteger(position), 0, length);
  46115. var end = position;
  46116. position -= target.length;
  46117. return position >= 0 && string.slice(position, end) == target;
  46118. }
  46119. /**
  46120. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  46121. * corresponding HTML entities.
  46122. *
  46123. * **Note:** No other characters are escaped. To escape additional
  46124. * characters use a third-party library like [_he_](https://mths.be/he).
  46125. *
  46126. * Though the ">" character is escaped for symmetry, characters like
  46127. * ">" and "/" don't need escaping in HTML and have no special meaning
  46128. * unless they're part of a tag or unquoted attribute value. See
  46129. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  46130. * (under "semi-related fun fact") for more details.
  46131. *
  46132. * When working with HTML you should always
  46133. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  46134. * XSS vectors.
  46135. *
  46136. * @static
  46137. * @since 0.1.0
  46138. * @memberOf _
  46139. * @category String
  46140. * @param {string} [string=''] The string to escape.
  46141. * @returns {string} Returns the escaped string.
  46142. * @example
  46143. *
  46144. * _.escape('fred, barney, & pebbles');
  46145. * // => 'fred, barney, &amp; pebbles'
  46146. */
  46147. function escape(string) {
  46148. string = toString(string);
  46149. return (string && reHasUnescapedHtml.test(string))
  46150. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  46151. : string;
  46152. }
  46153. /**
  46154. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  46155. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  46156. *
  46157. * @static
  46158. * @memberOf _
  46159. * @since 3.0.0
  46160. * @category String
  46161. * @param {string} [string=''] The string to escape.
  46162. * @returns {string} Returns the escaped string.
  46163. * @example
  46164. *
  46165. * _.escapeRegExp('[lodash](https://lodash.com/)');
  46166. * // => '\[lodash\]\(https://lodash\.com/\)'
  46167. */
  46168. function escapeRegExp(string) {
  46169. string = toString(string);
  46170. return (string && reHasRegExpChar.test(string))
  46171. ? string.replace(reRegExpChar, '\\$&')
  46172. : string;
  46173. }
  46174. /**
  46175. * Converts `string` to
  46176. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  46177. *
  46178. * @static
  46179. * @memberOf _
  46180. * @since 3.0.0
  46181. * @category String
  46182. * @param {string} [string=''] The string to convert.
  46183. * @returns {string} Returns the kebab cased string.
  46184. * @example
  46185. *
  46186. * _.kebabCase('Foo Bar');
  46187. * // => 'foo-bar'
  46188. *
  46189. * _.kebabCase('fooBar');
  46190. * // => 'foo-bar'
  46191. *
  46192. * _.kebabCase('__FOO_BAR__');
  46193. * // => 'foo-bar'
  46194. */
  46195. var kebabCase = createCompounder(function(result, word, index) {
  46196. return result + (index ? '-' : '') + word.toLowerCase();
  46197. });
  46198. /**
  46199. * Converts `string`, as space separated words, to lower case.
  46200. *
  46201. * @static
  46202. * @memberOf _
  46203. * @since 4.0.0
  46204. * @category String
  46205. * @param {string} [string=''] The string to convert.
  46206. * @returns {string} Returns the lower cased string.
  46207. * @example
  46208. *
  46209. * _.lowerCase('--Foo-Bar--');
  46210. * // => 'foo bar'
  46211. *
  46212. * _.lowerCase('fooBar');
  46213. * // => 'foo bar'
  46214. *
  46215. * _.lowerCase('__FOO_BAR__');
  46216. * // => 'foo bar'
  46217. */
  46218. var lowerCase = createCompounder(function(result, word, index) {
  46219. return result + (index ? ' ' : '') + word.toLowerCase();
  46220. });
  46221. /**
  46222. * Converts the first character of `string` to lower case.
  46223. *
  46224. * @static
  46225. * @memberOf _
  46226. * @since 4.0.0
  46227. * @category String
  46228. * @param {string} [string=''] The string to convert.
  46229. * @returns {string} Returns the converted string.
  46230. * @example
  46231. *
  46232. * _.lowerFirst('Fred');
  46233. * // => 'fred'
  46234. *
  46235. * _.lowerFirst('FRED');
  46236. * // => 'fRED'
  46237. */
  46238. var lowerFirst = createCaseFirst('toLowerCase');
  46239. /**
  46240. * Pads `string` on the left and right sides if it's shorter than `length`.
  46241. * Padding characters are truncated if they can't be evenly divided by `length`.
  46242. *
  46243. * @static
  46244. * @memberOf _
  46245. * @since 3.0.0
  46246. * @category String
  46247. * @param {string} [string=''] The string to pad.
  46248. * @param {number} [length=0] The padding length.
  46249. * @param {string} [chars=' '] The string used as padding.
  46250. * @returns {string} Returns the padded string.
  46251. * @example
  46252. *
  46253. * _.pad('abc', 8);
  46254. * // => ' abc '
  46255. *
  46256. * _.pad('abc', 8, '_-');
  46257. * // => '_-abc_-_'
  46258. *
  46259. * _.pad('abc', 3);
  46260. * // => 'abc'
  46261. */
  46262. function pad(string, length, chars) {
  46263. string = toString(string);
  46264. length = toInteger(length);
  46265. var strLength = length ? stringSize(string) : 0;
  46266. if (!length || strLength >= length) {
  46267. return string;
  46268. }
  46269. var mid = (length - strLength) / 2;
  46270. return (
  46271. createPadding(nativeFloor(mid), chars) +
  46272. string +
  46273. createPadding(nativeCeil(mid), chars)
  46274. );
  46275. }
  46276. /**
  46277. * Pads `string` on the right side if it's shorter than `length`. Padding
  46278. * characters are truncated if they exceed `length`.
  46279. *
  46280. * @static
  46281. * @memberOf _
  46282. * @since 4.0.0
  46283. * @category String
  46284. * @param {string} [string=''] The string to pad.
  46285. * @param {number} [length=0] The padding length.
  46286. * @param {string} [chars=' '] The string used as padding.
  46287. * @returns {string} Returns the padded string.
  46288. * @example
  46289. *
  46290. * _.padEnd('abc', 6);
  46291. * // => 'abc '
  46292. *
  46293. * _.padEnd('abc', 6, '_-');
  46294. * // => 'abc_-_'
  46295. *
  46296. * _.padEnd('abc', 3);
  46297. * // => 'abc'
  46298. */
  46299. function padEnd(string, length, chars) {
  46300. string = toString(string);
  46301. length = toInteger(length);
  46302. var strLength = length ? stringSize(string) : 0;
  46303. return (length && strLength < length)
  46304. ? (string + createPadding(length - strLength, chars))
  46305. : string;
  46306. }
  46307. /**
  46308. * Pads `string` on the left side if it's shorter than `length`. Padding
  46309. * characters are truncated if they exceed `length`.
  46310. *
  46311. * @static
  46312. * @memberOf _
  46313. * @since 4.0.0
  46314. * @category String
  46315. * @param {string} [string=''] The string to pad.
  46316. * @param {number} [length=0] The padding length.
  46317. * @param {string} [chars=' '] The string used as padding.
  46318. * @returns {string} Returns the padded string.
  46319. * @example
  46320. *
  46321. * _.padStart('abc', 6);
  46322. * // => ' abc'
  46323. *
  46324. * _.padStart('abc', 6, '_-');
  46325. * // => '_-_abc'
  46326. *
  46327. * _.padStart('abc', 3);
  46328. * // => 'abc'
  46329. */
  46330. function padStart(string, length, chars) {
  46331. string = toString(string);
  46332. length = toInteger(length);
  46333. var strLength = length ? stringSize(string) : 0;
  46334. return (length && strLength < length)
  46335. ? (createPadding(length - strLength, chars) + string)
  46336. : string;
  46337. }
  46338. /**
  46339. * Converts `string` to an integer of the specified radix. If `radix` is
  46340. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  46341. * hexadecimal, in which case a `radix` of `16` is used.
  46342. *
  46343. * **Note:** This method aligns with the
  46344. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  46345. *
  46346. * @static
  46347. * @memberOf _
  46348. * @since 1.1.0
  46349. * @category String
  46350. * @param {string} string The string to convert.
  46351. * @param {number} [radix=10] The radix to interpret `value` by.
  46352. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  46353. * @returns {number} Returns the converted integer.
  46354. * @example
  46355. *
  46356. * _.parseInt('08');
  46357. * // => 8
  46358. *
  46359. * _.map(['6', '08', '10'], _.parseInt);
  46360. * // => [6, 8, 10]
  46361. */
  46362. function parseInt(string, radix, guard) {
  46363. if (guard || radix == null) {
  46364. radix = 0;
  46365. } else if (radix) {
  46366. radix = +radix;
  46367. }
  46368. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  46369. }
  46370. /**
  46371. * Repeats the given string `n` times.
  46372. *
  46373. * @static
  46374. * @memberOf _
  46375. * @since 3.0.0
  46376. * @category String
  46377. * @param {string} [string=''] The string to repeat.
  46378. * @param {number} [n=1] The number of times to repeat the string.
  46379. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  46380. * @returns {string} Returns the repeated string.
  46381. * @example
  46382. *
  46383. * _.repeat('*', 3);
  46384. * // => '***'
  46385. *
  46386. * _.repeat('abc', 2);
  46387. * // => 'abcabc'
  46388. *
  46389. * _.repeat('abc', 0);
  46390. * // => ''
  46391. */
  46392. function repeat(string, n, guard) {
  46393. if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
  46394. n = 1;
  46395. } else {
  46396. n = toInteger(n);
  46397. }
  46398. return baseRepeat(toString(string), n);
  46399. }
  46400. /**
  46401. * Replaces matches for `pattern` in `string` with `replacement`.
  46402. *
  46403. * **Note:** This method is based on
  46404. * [`String#replace`](https://mdn.io/String/replace).
  46405. *
  46406. * @static
  46407. * @memberOf _
  46408. * @since 4.0.0
  46409. * @category String
  46410. * @param {string} [string=''] The string to modify.
  46411. * @param {RegExp|string} pattern The pattern to replace.
  46412. * @param {Function|string} replacement The match replacement.
  46413. * @returns {string} Returns the modified string.
  46414. * @example
  46415. *
  46416. * _.replace('Hi Fred', 'Fred', 'Barney');
  46417. * // => 'Hi Barney'
  46418. */
  46419. function replace() {
  46420. var args = arguments,
  46421. string = toString(args[0]);
  46422. return args.length < 3 ? string : string.replace(args[1], args[2]);
  46423. }
  46424. /**
  46425. * Converts `string` to
  46426. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  46427. *
  46428. * @static
  46429. * @memberOf _
  46430. * @since 3.0.0
  46431. * @category String
  46432. * @param {string} [string=''] The string to convert.
  46433. * @returns {string} Returns the snake cased string.
  46434. * @example
  46435. *
  46436. * _.snakeCase('Foo Bar');
  46437. * // => 'foo_bar'
  46438. *
  46439. * _.snakeCase('fooBar');
  46440. * // => 'foo_bar'
  46441. *
  46442. * _.snakeCase('--FOO-BAR--');
  46443. * // => 'foo_bar'
  46444. */
  46445. var snakeCase = createCompounder(function(result, word, index) {
  46446. return result + (index ? '_' : '') + word.toLowerCase();
  46447. });
  46448. /**
  46449. * Splits `string` by `separator`.
  46450. *
  46451. * **Note:** This method is based on
  46452. * [`String#split`](https://mdn.io/String/split).
  46453. *
  46454. * @static
  46455. * @memberOf _
  46456. * @since 4.0.0
  46457. * @category String
  46458. * @param {string} [string=''] The string to split.
  46459. * @param {RegExp|string} separator The separator pattern to split by.
  46460. * @param {number} [limit] The length to truncate results to.
  46461. * @returns {Array} Returns the string segments.
  46462. * @example
  46463. *
  46464. * _.split('a-b-c', '-', 2);
  46465. * // => ['a', 'b']
  46466. */
  46467. function split(string, separator, limit) {
  46468. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  46469. separator = limit = undefined;
  46470. }
  46471. limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
  46472. if (!limit) {
  46473. return [];
  46474. }
  46475. string = toString(string);
  46476. if (string && (
  46477. typeof separator == 'string' ||
  46478. (separator != null && !isRegExp(separator))
  46479. )) {
  46480. separator = baseToString(separator);
  46481. if (!separator && hasUnicode(string)) {
  46482. return castSlice(stringToArray(string), 0, limit);
  46483. }
  46484. }
  46485. return string.split(separator, limit);
  46486. }
  46487. /**
  46488. * Converts `string` to
  46489. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  46490. *
  46491. * @static
  46492. * @memberOf _
  46493. * @since 3.1.0
  46494. * @category String
  46495. * @param {string} [string=''] The string to convert.
  46496. * @returns {string} Returns the start cased string.
  46497. * @example
  46498. *
  46499. * _.startCase('--foo-bar--');
  46500. * // => 'Foo Bar'
  46501. *
  46502. * _.startCase('fooBar');
  46503. * // => 'Foo Bar'
  46504. *
  46505. * _.startCase('__FOO_BAR__');
  46506. * // => 'FOO BAR'
  46507. */
  46508. var startCase = createCompounder(function(result, word, index) {
  46509. return result + (index ? ' ' : '') + upperFirst(word);
  46510. });
  46511. /**
  46512. * Checks if `string` starts with the given target string.
  46513. *
  46514. * @static
  46515. * @memberOf _
  46516. * @since 3.0.0
  46517. * @category String
  46518. * @param {string} [string=''] The string to inspect.
  46519. * @param {string} [target] The string to search for.
  46520. * @param {number} [position=0] The position to search from.
  46521. * @returns {boolean} Returns `true` if `string` starts with `target`,
  46522. * else `false`.
  46523. * @example
  46524. *
  46525. * _.startsWith('abc', 'a');
  46526. * // => true
  46527. *
  46528. * _.startsWith('abc', 'b');
  46529. * // => false
  46530. *
  46531. * _.startsWith('abc', 'b', 1);
  46532. * // => true
  46533. */
  46534. function startsWith(string, target, position) {
  46535. string = toString(string);
  46536. position = position == null
  46537. ? 0
  46538. : baseClamp(toInteger(position), 0, string.length);
  46539. target = baseToString(target);
  46540. return string.slice(position, position + target.length) == target;
  46541. }
  46542. /**
  46543. * Creates a compiled template function that can interpolate data properties
  46544. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  46545. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  46546. * properties may be accessed as free variables in the template. If a setting
  46547. * object is given, it takes precedence over `_.templateSettings` values.
  46548. *
  46549. * **Note:** In the development build `_.template` utilizes
  46550. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  46551. * for easier debugging.
  46552. *
  46553. * For more information on precompiling templates see
  46554. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  46555. *
  46556. * For more information on Chrome extension sandboxes see
  46557. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  46558. *
  46559. * @static
  46560. * @since 0.1.0
  46561. * @memberOf _
  46562. * @category String
  46563. * @param {string} [string=''] The template string.
  46564. * @param {Object} [options={}] The options object.
  46565. * @param {RegExp} [options.escape=_.templateSettings.escape]
  46566. * The HTML "escape" delimiter.
  46567. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  46568. * The "evaluate" delimiter.
  46569. * @param {Object} [options.imports=_.templateSettings.imports]
  46570. * An object to import into the template as free variables.
  46571. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  46572. * The "interpolate" delimiter.
  46573. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  46574. * The sourceURL of the compiled template.
  46575. * @param {string} [options.variable='obj']
  46576. * The data object variable name.
  46577. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  46578. * @returns {Function} Returns the compiled template function.
  46579. * @example
  46580. *
  46581. * // Use the "interpolate" delimiter to create a compiled template.
  46582. * var compiled = _.template('hello <%= user %>!');
  46583. * compiled({ 'user': 'fred' });
  46584. * // => 'hello fred!'
  46585. *
  46586. * // Use the HTML "escape" delimiter to escape data property values.
  46587. * var compiled = _.template('<b><%- value %></b>');
  46588. * compiled({ 'value': '<script>' });
  46589. * // => '<b>&lt;script&gt;</b>'
  46590. *
  46591. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  46592. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  46593. * compiled({ 'users': ['fred', 'barney'] });
  46594. * // => '<li>fred</li><li>barney</li>'
  46595. *
  46596. * // Use the internal `print` function in "evaluate" delimiters.
  46597. * var compiled = _.template('<% print("hello " + user); %>!');
  46598. * compiled({ 'user': 'barney' });
  46599. * // => 'hello barney!'
  46600. *
  46601. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  46602. * // Disable support by replacing the "interpolate" delimiter.
  46603. * var compiled = _.template('hello ${ user }!');
  46604. * compiled({ 'user': 'pebbles' });
  46605. * // => 'hello pebbles!'
  46606. *
  46607. * // Use backslashes to treat delimiters as plain text.
  46608. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  46609. * compiled({ 'value': 'ignored' });
  46610. * // => '<%- value %>'
  46611. *
  46612. * // Use the `imports` option to import `jQuery` as `jq`.
  46613. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  46614. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  46615. * compiled({ 'users': ['fred', 'barney'] });
  46616. * // => '<li>fred</li><li>barney</li>'
  46617. *
  46618. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  46619. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  46620. * compiled(data);
  46621. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  46622. *
  46623. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  46624. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  46625. * compiled.source;
  46626. * // => function(data) {
  46627. * // var __t, __p = '';
  46628. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  46629. * // return __p;
  46630. * // }
  46631. *
  46632. * // Use custom template delimiters.
  46633. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  46634. * var compiled = _.template('hello {{ user }}!');
  46635. * compiled({ 'user': 'mustache' });
  46636. * // => 'hello mustache!'
  46637. *
  46638. * // Use the `source` property to inline compiled templates for meaningful
  46639. * // line numbers in error messages and stack traces.
  46640. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  46641. * var JST = {\
  46642. * "main": ' + _.template(mainText).source + '\
  46643. * };\
  46644. * ');
  46645. */
  46646. function template(string, options, guard) {
  46647. // Based on John Resig's `tmpl` implementation
  46648. // (http://ejohn.org/blog/javascript-micro-templating/)
  46649. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  46650. var settings = lodash.templateSettings;
  46651. if (guard && isIterateeCall(string, options, guard)) {
  46652. options = undefined;
  46653. }
  46654. string = toString(string);
  46655. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  46656. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  46657. importsKeys = keys(imports),
  46658. importsValues = baseValues(imports, importsKeys);
  46659. var isEscaping,
  46660. isEvaluating,
  46661. index = 0,
  46662. interpolate = options.interpolate || reNoMatch,
  46663. source = "__p += '";
  46664. // Compile the regexp to match each delimiter.
  46665. var reDelimiters = RegExp(
  46666. (options.escape || reNoMatch).source + '|' +
  46667. interpolate.source + '|' +
  46668. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  46669. (options.evaluate || reNoMatch).source + '|$'
  46670. , 'g');
  46671. // Use a sourceURL for easier debugging.
  46672. // The sourceURL gets injected into the source that's eval-ed, so be careful
  46673. // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in
  46674. // and escape the comment, thus injecting code that gets evaled.
  46675. var sourceURL = '//# sourceURL=' +
  46676. (hasOwnProperty.call(options, 'sourceURL')
  46677. ? (options.sourceURL + '').replace(/\s/g, ' ')
  46678. : ('lodash.templateSources[' + (++templateCounter) + ']')
  46679. ) + '\n';
  46680. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  46681. interpolateValue || (interpolateValue = esTemplateValue);
  46682. // Escape characters that can't be included in string literals.
  46683. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  46684. // Replace delimiters with snippets.
  46685. if (escapeValue) {
  46686. isEscaping = true;
  46687. source += "' +\n__e(" + escapeValue + ") +\n'";
  46688. }
  46689. if (evaluateValue) {
  46690. isEvaluating = true;
  46691. source += "';\n" + evaluateValue + ";\n__p += '";
  46692. }
  46693. if (interpolateValue) {
  46694. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  46695. }
  46696. index = offset + match.length;
  46697. // The JS engine embedded in Adobe products needs `match` returned in
  46698. // order to produce the correct `offset` value.
  46699. return match;
  46700. });
  46701. source += "';\n";
  46702. // If `variable` is not specified wrap a with-statement around the generated
  46703. // code to add the data object to the top of the scope chain.
  46704. var variable = hasOwnProperty.call(options, 'variable') && options.variable;
  46705. if (!variable) {
  46706. source = 'with (obj) {\n' + source + '\n}\n';
  46707. }
  46708. // Throw an error if a forbidden character was found in `variable`, to prevent
  46709. // potential command injection attacks.
  46710. else if (reForbiddenIdentifierChars.test(variable)) {
  46711. throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT);
  46712. }
  46713. // Cleanup code by stripping empty strings.
  46714. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  46715. .replace(reEmptyStringMiddle, '$1')
  46716. .replace(reEmptyStringTrailing, '$1;');
  46717. // Frame code as the function body.
  46718. source = 'function(' + (variable || 'obj') + ') {\n' +
  46719. (variable
  46720. ? ''
  46721. : 'obj || (obj = {});\n'
  46722. ) +
  46723. "var __t, __p = ''" +
  46724. (isEscaping
  46725. ? ', __e = _.escape'
  46726. : ''
  46727. ) +
  46728. (isEvaluating
  46729. ? ', __j = Array.prototype.join;\n' +
  46730. "function print() { __p += __j.call(arguments, '') }\n"
  46731. : ';\n'
  46732. ) +
  46733. source +
  46734. 'return __p\n}';
  46735. var result = attempt(function() {
  46736. return Function(importsKeys, sourceURL + 'return ' + source)
  46737. .apply(undefined, importsValues);
  46738. });
  46739. // Provide the compiled function's source by its `toString` method or
  46740. // the `source` property as a convenience for inlining compiled templates.
  46741. result.source = source;
  46742. if (isError(result)) {
  46743. throw result;
  46744. }
  46745. return result;
  46746. }
  46747. /**
  46748. * Converts `string`, as a whole, to lower case just like
  46749. * [String#toLowerCase](https://mdn.io/toLowerCase).
  46750. *
  46751. * @static
  46752. * @memberOf _
  46753. * @since 4.0.0
  46754. * @category String
  46755. * @param {string} [string=''] The string to convert.
  46756. * @returns {string} Returns the lower cased string.
  46757. * @example
  46758. *
  46759. * _.toLower('--Foo-Bar--');
  46760. * // => '--foo-bar--'
  46761. *
  46762. * _.toLower('fooBar');
  46763. * // => 'foobar'
  46764. *
  46765. * _.toLower('__FOO_BAR__');
  46766. * // => '__foo_bar__'
  46767. */
  46768. function toLower(value) {
  46769. return toString(value).toLowerCase();
  46770. }
  46771. /**
  46772. * Converts `string`, as a whole, to upper case just like
  46773. * [String#toUpperCase](https://mdn.io/toUpperCase).
  46774. *
  46775. * @static
  46776. * @memberOf _
  46777. * @since 4.0.0
  46778. * @category String
  46779. * @param {string} [string=''] The string to convert.
  46780. * @returns {string} Returns the upper cased string.
  46781. * @example
  46782. *
  46783. * _.toUpper('--foo-bar--');
  46784. * // => '--FOO-BAR--'
  46785. *
  46786. * _.toUpper('fooBar');
  46787. * // => 'FOOBAR'
  46788. *
  46789. * _.toUpper('__foo_bar__');
  46790. * // => '__FOO_BAR__'
  46791. */
  46792. function toUpper(value) {
  46793. return toString(value).toUpperCase();
  46794. }
  46795. /**
  46796. * Removes leading and trailing whitespace or specified characters from `string`.
  46797. *
  46798. * @static
  46799. * @memberOf _
  46800. * @since 3.0.0
  46801. * @category String
  46802. * @param {string} [string=''] The string to trim.
  46803. * @param {string} [chars=whitespace] The characters to trim.
  46804. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  46805. * @returns {string} Returns the trimmed string.
  46806. * @example
  46807. *
  46808. * _.trim(' abc ');
  46809. * // => 'abc'
  46810. *
  46811. * _.trim('-_-abc-_-', '_-');
  46812. * // => 'abc'
  46813. *
  46814. * _.map([' foo ', ' bar '], _.trim);
  46815. * // => ['foo', 'bar']
  46816. */
  46817. function trim(string, chars, guard) {
  46818. string = toString(string);
  46819. if (string && (guard || chars === undefined)) {
  46820. return baseTrim(string);
  46821. }
  46822. if (!string || !(chars = baseToString(chars))) {
  46823. return string;
  46824. }
  46825. var strSymbols = stringToArray(string),
  46826. chrSymbols = stringToArray(chars),
  46827. start = charsStartIndex(strSymbols, chrSymbols),
  46828. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  46829. return castSlice(strSymbols, start, end).join('');
  46830. }
  46831. /**
  46832. * Removes trailing whitespace or specified characters from `string`.
  46833. *
  46834. * @static
  46835. * @memberOf _
  46836. * @since 4.0.0
  46837. * @category String
  46838. * @param {string} [string=''] The string to trim.
  46839. * @param {string} [chars=whitespace] The characters to trim.
  46840. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  46841. * @returns {string} Returns the trimmed string.
  46842. * @example
  46843. *
  46844. * _.trimEnd(' abc ');
  46845. * // => ' abc'
  46846. *
  46847. * _.trimEnd('-_-abc-_-', '_-');
  46848. * // => '-_-abc'
  46849. */
  46850. function trimEnd(string, chars, guard) {
  46851. string = toString(string);
  46852. if (string && (guard || chars === undefined)) {
  46853. return string.slice(0, trimmedEndIndex(string) + 1);
  46854. }
  46855. if (!string || !(chars = baseToString(chars))) {
  46856. return string;
  46857. }
  46858. var strSymbols = stringToArray(string),
  46859. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  46860. return castSlice(strSymbols, 0, end).join('');
  46861. }
  46862. /**
  46863. * Removes leading whitespace or specified characters from `string`.
  46864. *
  46865. * @static
  46866. * @memberOf _
  46867. * @since 4.0.0
  46868. * @category String
  46869. * @param {string} [string=''] The string to trim.
  46870. * @param {string} [chars=whitespace] The characters to trim.
  46871. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  46872. * @returns {string} Returns the trimmed string.
  46873. * @example
  46874. *
  46875. * _.trimStart(' abc ');
  46876. * // => 'abc '
  46877. *
  46878. * _.trimStart('-_-abc-_-', '_-');
  46879. * // => 'abc-_-'
  46880. */
  46881. function trimStart(string, chars, guard) {
  46882. string = toString(string);
  46883. if (string && (guard || chars === undefined)) {
  46884. return string.replace(reTrimStart, '');
  46885. }
  46886. if (!string || !(chars = baseToString(chars))) {
  46887. return string;
  46888. }
  46889. var strSymbols = stringToArray(string),
  46890. start = charsStartIndex(strSymbols, stringToArray(chars));
  46891. return castSlice(strSymbols, start).join('');
  46892. }
  46893. /**
  46894. * Truncates `string` if it's longer than the given maximum string length.
  46895. * The last characters of the truncated string are replaced with the omission
  46896. * string which defaults to "...".
  46897. *
  46898. * @static
  46899. * @memberOf _
  46900. * @since 4.0.0
  46901. * @category String
  46902. * @param {string} [string=''] The string to truncate.
  46903. * @param {Object} [options={}] The options object.
  46904. * @param {number} [options.length=30] The maximum string length.
  46905. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  46906. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  46907. * @returns {string} Returns the truncated string.
  46908. * @example
  46909. *
  46910. * _.truncate('hi-diddly-ho there, neighborino');
  46911. * // => 'hi-diddly-ho there, neighbo...'
  46912. *
  46913. * _.truncate('hi-diddly-ho there, neighborino', {
  46914. * 'length': 24,
  46915. * 'separator': ' '
  46916. * });
  46917. * // => 'hi-diddly-ho there,...'
  46918. *
  46919. * _.truncate('hi-diddly-ho there, neighborino', {
  46920. * 'length': 24,
  46921. * 'separator': /,? +/
  46922. * });
  46923. * // => 'hi-diddly-ho there...'
  46924. *
  46925. * _.truncate('hi-diddly-ho there, neighborino', {
  46926. * 'omission': ' [...]'
  46927. * });
  46928. * // => 'hi-diddly-ho there, neig [...]'
  46929. */
  46930. function truncate(string, options) {
  46931. var length = DEFAULT_TRUNC_LENGTH,
  46932. omission = DEFAULT_TRUNC_OMISSION;
  46933. if (isObject(options)) {
  46934. var separator = 'separator' in options ? options.separator : separator;
  46935. length = 'length' in options ? toInteger(options.length) : length;
  46936. omission = 'omission' in options ? baseToString(options.omission) : omission;
  46937. }
  46938. string = toString(string);
  46939. var strLength = string.length;
  46940. if (hasUnicode(string)) {
  46941. var strSymbols = stringToArray(string);
  46942. strLength = strSymbols.length;
  46943. }
  46944. if (length >= strLength) {
  46945. return string;
  46946. }
  46947. var end = length - stringSize(omission);
  46948. if (end < 1) {
  46949. return omission;
  46950. }
  46951. var result = strSymbols
  46952. ? castSlice(strSymbols, 0, end).join('')
  46953. : string.slice(0, end);
  46954. if (separator === undefined) {
  46955. return result + omission;
  46956. }
  46957. if (strSymbols) {
  46958. end += (result.length - end);
  46959. }
  46960. if (isRegExp(separator)) {
  46961. if (string.slice(end).search(separator)) {
  46962. var match,
  46963. substring = result;
  46964. if (!separator.global) {
  46965. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  46966. }
  46967. separator.lastIndex = 0;
  46968. while ((match = separator.exec(substring))) {
  46969. var newEnd = match.index;
  46970. }
  46971. result = result.slice(0, newEnd === undefined ? end : newEnd);
  46972. }
  46973. } else if (string.indexOf(baseToString(separator), end) != end) {
  46974. var index = result.lastIndexOf(separator);
  46975. if (index > -1) {
  46976. result = result.slice(0, index);
  46977. }
  46978. }
  46979. return result + omission;
  46980. }
  46981. /**
  46982. * The inverse of `_.escape`; this method converts the HTML entities
  46983. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  46984. * their corresponding characters.
  46985. *
  46986. * **Note:** No other HTML entities are unescaped. To unescape additional
  46987. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  46988. *
  46989. * @static
  46990. * @memberOf _
  46991. * @since 0.6.0
  46992. * @category String
  46993. * @param {string} [string=''] The string to unescape.
  46994. * @returns {string} Returns the unescaped string.
  46995. * @example
  46996. *
  46997. * _.unescape('fred, barney, &amp; pebbles');
  46998. * // => 'fred, barney, & pebbles'
  46999. */
  47000. function unescape(string) {
  47001. string = toString(string);
  47002. return (string && reHasEscapedHtml.test(string))
  47003. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  47004. : string;
  47005. }
  47006. /**
  47007. * Converts `string`, as space separated words, to upper case.
  47008. *
  47009. * @static
  47010. * @memberOf _
  47011. * @since 4.0.0
  47012. * @category String
  47013. * @param {string} [string=''] The string to convert.
  47014. * @returns {string} Returns the upper cased string.
  47015. * @example
  47016. *
  47017. * _.upperCase('--foo-bar');
  47018. * // => 'FOO BAR'
  47019. *
  47020. * _.upperCase('fooBar');
  47021. * // => 'FOO BAR'
  47022. *
  47023. * _.upperCase('__foo_bar__');
  47024. * // => 'FOO BAR'
  47025. */
  47026. var upperCase = createCompounder(function(result, word, index) {
  47027. return result + (index ? ' ' : '') + word.toUpperCase();
  47028. });
  47029. /**
  47030. * Converts the first character of `string` to upper case.
  47031. *
  47032. * @static
  47033. * @memberOf _
  47034. * @since 4.0.0
  47035. * @category String
  47036. * @param {string} [string=''] The string to convert.
  47037. * @returns {string} Returns the converted string.
  47038. * @example
  47039. *
  47040. * _.upperFirst('fred');
  47041. * // => 'Fred'
  47042. *
  47043. * _.upperFirst('FRED');
  47044. * // => 'FRED'
  47045. */
  47046. var upperFirst = createCaseFirst('toUpperCase');
  47047. /**
  47048. * Splits `string` into an array of its words.
  47049. *
  47050. * @static
  47051. * @memberOf _
  47052. * @since 3.0.0
  47053. * @category String
  47054. * @param {string} [string=''] The string to inspect.
  47055. * @param {RegExp|string} [pattern] The pattern to match words.
  47056. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  47057. * @returns {Array} Returns the words of `string`.
  47058. * @example
  47059. *
  47060. * _.words('fred, barney, & pebbles');
  47061. * // => ['fred', 'barney', 'pebbles']
  47062. *
  47063. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  47064. * // => ['fred', 'barney', '&', 'pebbles']
  47065. */
  47066. function words(string, pattern, guard) {
  47067. string = toString(string);
  47068. pattern = guard ? undefined : pattern;
  47069. if (pattern === undefined) {
  47070. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  47071. }
  47072. return string.match(pattern) || [];
  47073. }
  47074. /*------------------------------------------------------------------------*/
  47075. /**
  47076. * Attempts to invoke `func`, returning either the result or the caught error
  47077. * object. Any additional arguments are provided to `func` when it's invoked.
  47078. *
  47079. * @static
  47080. * @memberOf _
  47081. * @since 3.0.0
  47082. * @category Util
  47083. * @param {Function} func The function to attempt.
  47084. * @param {...*} [args] The arguments to invoke `func` with.
  47085. * @returns {*} Returns the `func` result or error object.
  47086. * @example
  47087. *
  47088. * // Avoid throwing errors for invalid selectors.
  47089. * var elements = _.attempt(function(selector) {
  47090. * return document.querySelectorAll(selector);
  47091. * }, '>_>');
  47092. *
  47093. * if (_.isError(elements)) {
  47094. * elements = [];
  47095. * }
  47096. */
  47097. var attempt = baseRest(function(func, args) {
  47098. try {
  47099. return apply(func, undefined, args);
  47100. } catch (e) {
  47101. return isError(e) ? e : new Error(e);
  47102. }
  47103. });
  47104. /**
  47105. * Binds methods of an object to the object itself, overwriting the existing
  47106. * method.
  47107. *
  47108. * **Note:** This method doesn't set the "length" property of bound functions.
  47109. *
  47110. * @static
  47111. * @since 0.1.0
  47112. * @memberOf _
  47113. * @category Util
  47114. * @param {Object} object The object to bind and assign the bound methods to.
  47115. * @param {...(string|string[])} methodNames The object method names to bind.
  47116. * @returns {Object} Returns `object`.
  47117. * @example
  47118. *
  47119. * var view = {
  47120. * 'label': 'docs',
  47121. * 'click': function() {
  47122. * console.log('clicked ' + this.label);
  47123. * }
  47124. * };
  47125. *
  47126. * _.bindAll(view, ['click']);
  47127. * jQuery(element).on('click', view.click);
  47128. * // => Logs 'clicked docs' when clicked.
  47129. */
  47130. var bindAll = flatRest(function(object, methodNames) {
  47131. arrayEach(methodNames, function(key) {
  47132. key = toKey(key);
  47133. baseAssignValue(object, key, bind(object[key], object));
  47134. });
  47135. return object;
  47136. });
  47137. /**
  47138. * Creates a function that iterates over `pairs` and invokes the corresponding
  47139. * function of the first predicate to return truthy. The predicate-function
  47140. * pairs are invoked with the `this` binding and arguments of the created
  47141. * function.
  47142. *
  47143. * @static
  47144. * @memberOf _
  47145. * @since 4.0.0
  47146. * @category Util
  47147. * @param {Array} pairs The predicate-function pairs.
  47148. * @returns {Function} Returns the new composite function.
  47149. * @example
  47150. *
  47151. * var func = _.cond([
  47152. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  47153. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  47154. * [_.stubTrue, _.constant('no match')]
  47155. * ]);
  47156. *
  47157. * func({ 'a': 1, 'b': 2 });
  47158. * // => 'matches A'
  47159. *
  47160. * func({ 'a': 0, 'b': 1 });
  47161. * // => 'matches B'
  47162. *
  47163. * func({ 'a': '1', 'b': '2' });
  47164. * // => 'no match'
  47165. */
  47166. function cond(pairs) {
  47167. var length = pairs == null ? 0 : pairs.length,
  47168. toIteratee = getIteratee();
  47169. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  47170. if (typeof pair[1] != 'function') {
  47171. throw new TypeError(FUNC_ERROR_TEXT);
  47172. }
  47173. return [toIteratee(pair[0]), pair[1]];
  47174. });
  47175. return baseRest(function(args) {
  47176. var index = -1;
  47177. while (++index < length) {
  47178. var pair = pairs[index];
  47179. if (apply(pair[0], this, args)) {
  47180. return apply(pair[1], this, args);
  47181. }
  47182. }
  47183. });
  47184. }
  47185. /**
  47186. * Creates a function that invokes the predicate properties of `source` with
  47187. * the corresponding property values of a given object, returning `true` if
  47188. * all predicates return truthy, else `false`.
  47189. *
  47190. * **Note:** The created function is equivalent to `_.conformsTo` with
  47191. * `source` partially applied.
  47192. *
  47193. * @static
  47194. * @memberOf _
  47195. * @since 4.0.0
  47196. * @category Util
  47197. * @param {Object} source The object of property predicates to conform to.
  47198. * @returns {Function} Returns the new spec function.
  47199. * @example
  47200. *
  47201. * var objects = [
  47202. * { 'a': 2, 'b': 1 },
  47203. * { 'a': 1, 'b': 2 }
  47204. * ];
  47205. *
  47206. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  47207. * // => [{ 'a': 1, 'b': 2 }]
  47208. */
  47209. function conforms(source) {
  47210. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  47211. }
  47212. /**
  47213. * Creates a function that returns `value`.
  47214. *
  47215. * @static
  47216. * @memberOf _
  47217. * @since 2.4.0
  47218. * @category Util
  47219. * @param {*} value The value to return from the new function.
  47220. * @returns {Function} Returns the new constant function.
  47221. * @example
  47222. *
  47223. * var objects = _.times(2, _.constant({ 'a': 1 }));
  47224. *
  47225. * console.log(objects);
  47226. * // => [{ 'a': 1 }, { 'a': 1 }]
  47227. *
  47228. * console.log(objects[0] === objects[1]);
  47229. * // => true
  47230. */
  47231. function constant(value) {
  47232. return function() {
  47233. return value;
  47234. };
  47235. }
  47236. /**
  47237. * Checks `value` to determine whether a default value should be returned in
  47238. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  47239. * or `undefined`.
  47240. *
  47241. * @static
  47242. * @memberOf _
  47243. * @since 4.14.0
  47244. * @category Util
  47245. * @param {*} value The value to check.
  47246. * @param {*} defaultValue The default value.
  47247. * @returns {*} Returns the resolved value.
  47248. * @example
  47249. *
  47250. * _.defaultTo(1, 10);
  47251. * // => 1
  47252. *
  47253. * _.defaultTo(undefined, 10);
  47254. * // => 10
  47255. */
  47256. function defaultTo(value, defaultValue) {
  47257. return (value == null || value !== value) ? defaultValue : value;
  47258. }
  47259. /**
  47260. * Creates a function that returns the result of invoking the given functions
  47261. * with the `this` binding of the created function, where each successive
  47262. * invocation is supplied the return value of the previous.
  47263. *
  47264. * @static
  47265. * @memberOf _
  47266. * @since 3.0.0
  47267. * @category Util
  47268. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  47269. * @returns {Function} Returns the new composite function.
  47270. * @see _.flowRight
  47271. * @example
  47272. *
  47273. * function square(n) {
  47274. * return n * n;
  47275. * }
  47276. *
  47277. * var addSquare = _.flow([_.add, square]);
  47278. * addSquare(1, 2);
  47279. * // => 9
  47280. */
  47281. var flow = createFlow();
  47282. /**
  47283. * This method is like `_.flow` except that it creates a function that
  47284. * invokes the given functions from right to left.
  47285. *
  47286. * @static
  47287. * @since 3.0.0
  47288. * @memberOf _
  47289. * @category Util
  47290. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  47291. * @returns {Function} Returns the new composite function.
  47292. * @see _.flow
  47293. * @example
  47294. *
  47295. * function square(n) {
  47296. * return n * n;
  47297. * }
  47298. *
  47299. * var addSquare = _.flowRight([square, _.add]);
  47300. * addSquare(1, 2);
  47301. * // => 9
  47302. */
  47303. var flowRight = createFlow(true);
  47304. /**
  47305. * This method returns the first argument it receives.
  47306. *
  47307. * @static
  47308. * @since 0.1.0
  47309. * @memberOf _
  47310. * @category Util
  47311. * @param {*} value Any value.
  47312. * @returns {*} Returns `value`.
  47313. * @example
  47314. *
  47315. * var object = { 'a': 1 };
  47316. *
  47317. * console.log(_.identity(object) === object);
  47318. * // => true
  47319. */
  47320. function identity(value) {
  47321. return value;
  47322. }
  47323. /**
  47324. * Creates a function that invokes `func` with the arguments of the created
  47325. * function. If `func` is a property name, the created function returns the
  47326. * property value for a given element. If `func` is an array or object, the
  47327. * created function returns `true` for elements that contain the equivalent
  47328. * source properties, otherwise it returns `false`.
  47329. *
  47330. * @static
  47331. * @since 4.0.0
  47332. * @memberOf _
  47333. * @category Util
  47334. * @param {*} [func=_.identity] The value to convert to a callback.
  47335. * @returns {Function} Returns the callback.
  47336. * @example
  47337. *
  47338. * var users = [
  47339. * { 'user': 'barney', 'age': 36, 'active': true },
  47340. * { 'user': 'fred', 'age': 40, 'active': false }
  47341. * ];
  47342. *
  47343. * // The `_.matches` iteratee shorthand.
  47344. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  47345. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  47346. *
  47347. * // The `_.matchesProperty` iteratee shorthand.
  47348. * _.filter(users, _.iteratee(['user', 'fred']));
  47349. * // => [{ 'user': 'fred', 'age': 40 }]
  47350. *
  47351. * // The `_.property` iteratee shorthand.
  47352. * _.map(users, _.iteratee('user'));
  47353. * // => ['barney', 'fred']
  47354. *
  47355. * // Create custom iteratee shorthands.
  47356. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  47357. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  47358. * return func.test(string);
  47359. * };
  47360. * });
  47361. *
  47362. * _.filter(['abc', 'def'], /ef/);
  47363. * // => ['def']
  47364. */
  47365. function iteratee(func) {
  47366. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  47367. }
  47368. /**
  47369. * Creates a function that performs a partial deep comparison between a given
  47370. * object and `source`, returning `true` if the given object has equivalent
  47371. * property values, else `false`.
  47372. *
  47373. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  47374. * partially applied.
  47375. *
  47376. * Partial comparisons will match empty array and empty object `source`
  47377. * values against any array or object value, respectively. See `_.isEqual`
  47378. * for a list of supported value comparisons.
  47379. *
  47380. * **Note:** Multiple values can be checked by combining several matchers
  47381. * using `_.overSome`
  47382. *
  47383. * @static
  47384. * @memberOf _
  47385. * @since 3.0.0
  47386. * @category Util
  47387. * @param {Object} source The object of property values to match.
  47388. * @returns {Function} Returns the new spec function.
  47389. * @example
  47390. *
  47391. * var objects = [
  47392. * { 'a': 1, 'b': 2, 'c': 3 },
  47393. * { 'a': 4, 'b': 5, 'c': 6 }
  47394. * ];
  47395. *
  47396. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  47397. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  47398. *
  47399. * // Checking for several possible values
  47400. * _.filter(objects, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })]));
  47401. * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
  47402. */
  47403. function matches(source) {
  47404. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  47405. }
  47406. /**
  47407. * Creates a function that performs a partial deep comparison between the
  47408. * value at `path` of a given object to `srcValue`, returning `true` if the
  47409. * object value is equivalent, else `false`.
  47410. *
  47411. * **Note:** Partial comparisons will match empty array and empty object
  47412. * `srcValue` values against any array or object value, respectively. See
  47413. * `_.isEqual` for a list of supported value comparisons.
  47414. *
  47415. * **Note:** Multiple values can be checked by combining several matchers
  47416. * using `_.overSome`
  47417. *
  47418. * @static
  47419. * @memberOf _
  47420. * @since 3.2.0
  47421. * @category Util
  47422. * @param {Array|string} path The path of the property to get.
  47423. * @param {*} srcValue The value to match.
  47424. * @returns {Function} Returns the new spec function.
  47425. * @example
  47426. *
  47427. * var objects = [
  47428. * { 'a': 1, 'b': 2, 'c': 3 },
  47429. * { 'a': 4, 'b': 5, 'c': 6 }
  47430. * ];
  47431. *
  47432. * _.find(objects, _.matchesProperty('a', 4));
  47433. * // => { 'a': 4, 'b': 5, 'c': 6 }
  47434. *
  47435. * // Checking for several possible values
  47436. * _.filter(objects, _.overSome([_.matchesProperty('a', 1), _.matchesProperty('a', 4)]));
  47437. * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
  47438. */
  47439. function matchesProperty(path, srcValue) {
  47440. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  47441. }
  47442. /**
  47443. * Creates a function that invokes the method at `path` of a given object.
  47444. * Any additional arguments are provided to the invoked method.
  47445. *
  47446. * @static
  47447. * @memberOf _
  47448. * @since 3.7.0
  47449. * @category Util
  47450. * @param {Array|string} path The path of the method to invoke.
  47451. * @param {...*} [args] The arguments to invoke the method with.
  47452. * @returns {Function} Returns the new invoker function.
  47453. * @example
  47454. *
  47455. * var objects = [
  47456. * { 'a': { 'b': _.constant(2) } },
  47457. * { 'a': { 'b': _.constant(1) } }
  47458. * ];
  47459. *
  47460. * _.map(objects, _.method('a.b'));
  47461. * // => [2, 1]
  47462. *
  47463. * _.map(objects, _.method(['a', 'b']));
  47464. * // => [2, 1]
  47465. */
  47466. var method = baseRest(function(path, args) {
  47467. return function(object) {
  47468. return baseInvoke(object, path, args);
  47469. };
  47470. });
  47471. /**
  47472. * The opposite of `_.method`; this method creates a function that invokes
  47473. * the method at a given path of `object`. Any additional arguments are
  47474. * provided to the invoked method.
  47475. *
  47476. * @static
  47477. * @memberOf _
  47478. * @since 3.7.0
  47479. * @category Util
  47480. * @param {Object} object The object to query.
  47481. * @param {...*} [args] The arguments to invoke the method with.
  47482. * @returns {Function} Returns the new invoker function.
  47483. * @example
  47484. *
  47485. * var array = _.times(3, _.constant),
  47486. * object = { 'a': array, 'b': array, 'c': array };
  47487. *
  47488. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  47489. * // => [2, 0]
  47490. *
  47491. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  47492. * // => [2, 0]
  47493. */
  47494. var methodOf = baseRest(function(object, args) {
  47495. return function(path) {
  47496. return baseInvoke(object, path, args);
  47497. };
  47498. });
  47499. /**
  47500. * Adds all own enumerable string keyed function properties of a source
  47501. * object to the destination object. If `object` is a function, then methods
  47502. * are added to its prototype as well.
  47503. *
  47504. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  47505. * avoid conflicts caused by modifying the original.
  47506. *
  47507. * @static
  47508. * @since 0.1.0
  47509. * @memberOf _
  47510. * @category Util
  47511. * @param {Function|Object} [object=lodash] The destination object.
  47512. * @param {Object} source The object of functions to add.
  47513. * @param {Object} [options={}] The options object.
  47514. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  47515. * @returns {Function|Object} Returns `object`.
  47516. * @example
  47517. *
  47518. * function vowels(string) {
  47519. * return _.filter(string, function(v) {
  47520. * return /[aeiou]/i.test(v);
  47521. * });
  47522. * }
  47523. *
  47524. * _.mixin({ 'vowels': vowels });
  47525. * _.vowels('fred');
  47526. * // => ['e']
  47527. *
  47528. * _('fred').vowels().value();
  47529. * // => ['e']
  47530. *
  47531. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  47532. * _('fred').vowels();
  47533. * // => ['e']
  47534. */
  47535. function mixin(object, source, options) {
  47536. var props = keys(source),
  47537. methodNames = baseFunctions(source, props);
  47538. if (options == null &&
  47539. !(isObject(source) && (methodNames.length || !props.length))) {
  47540. options = source;
  47541. source = object;
  47542. object = this;
  47543. methodNames = baseFunctions(source, keys(source));
  47544. }
  47545. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  47546. isFunc = isFunction(object);
  47547. arrayEach(methodNames, function(methodName) {
  47548. var func = source[methodName];
  47549. object[methodName] = func;
  47550. if (isFunc) {
  47551. object.prototype[methodName] = function() {
  47552. var chainAll = this.__chain__;
  47553. if (chain || chainAll) {
  47554. var result = object(this.__wrapped__),
  47555. actions = result.__actions__ = copyArray(this.__actions__);
  47556. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  47557. result.__chain__ = chainAll;
  47558. return result;
  47559. }
  47560. return func.apply(object, arrayPush([this.value()], arguments));
  47561. };
  47562. }
  47563. });
  47564. return object;
  47565. }
  47566. /**
  47567. * Reverts the `_` variable to its previous value and returns a reference to
  47568. * the `lodash` function.
  47569. *
  47570. * @static
  47571. * @since 0.1.0
  47572. * @memberOf _
  47573. * @category Util
  47574. * @returns {Function} Returns the `lodash` function.
  47575. * @example
  47576. *
  47577. * var lodash = _.noConflict();
  47578. */
  47579. function noConflict() {
  47580. if (root._ === this) {
  47581. root._ = oldDash;
  47582. }
  47583. return this;
  47584. }
  47585. /**
  47586. * This method returns `undefined`.
  47587. *
  47588. * @static
  47589. * @memberOf _
  47590. * @since 2.3.0
  47591. * @category Util
  47592. * @example
  47593. *
  47594. * _.times(2, _.noop);
  47595. * // => [undefined, undefined]
  47596. */
  47597. function noop() {
  47598. // No operation performed.
  47599. }
  47600. /**
  47601. * Creates a function that gets the argument at index `n`. If `n` is negative,
  47602. * the nth argument from the end is returned.
  47603. *
  47604. * @static
  47605. * @memberOf _
  47606. * @since 4.0.0
  47607. * @category Util
  47608. * @param {number} [n=0] The index of the argument to return.
  47609. * @returns {Function} Returns the new pass-thru function.
  47610. * @example
  47611. *
  47612. * var func = _.nthArg(1);
  47613. * func('a', 'b', 'c', 'd');
  47614. * // => 'b'
  47615. *
  47616. * var func = _.nthArg(-2);
  47617. * func('a', 'b', 'c', 'd');
  47618. * // => 'c'
  47619. */
  47620. function nthArg(n) {
  47621. n = toInteger(n);
  47622. return baseRest(function(args) {
  47623. return baseNth(args, n);
  47624. });
  47625. }
  47626. /**
  47627. * Creates a function that invokes `iteratees` with the arguments it receives
  47628. * and returns their results.
  47629. *
  47630. * @static
  47631. * @memberOf _
  47632. * @since 4.0.0
  47633. * @category Util
  47634. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  47635. * The iteratees to invoke.
  47636. * @returns {Function} Returns the new function.
  47637. * @example
  47638. *
  47639. * var func = _.over([Math.max, Math.min]);
  47640. *
  47641. * func(1, 2, 3, 4);
  47642. * // => [4, 1]
  47643. */
  47644. var over = createOver(arrayMap);
  47645. /**
  47646. * Creates a function that checks if **all** of the `predicates` return
  47647. * truthy when invoked with the arguments it receives.
  47648. *
  47649. * Following shorthands are possible for providing predicates.
  47650. * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.
  47651. * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.
  47652. *
  47653. * @static
  47654. * @memberOf _
  47655. * @since 4.0.0
  47656. * @category Util
  47657. * @param {...(Function|Function[])} [predicates=[_.identity]]
  47658. * The predicates to check.
  47659. * @returns {Function} Returns the new function.
  47660. * @example
  47661. *
  47662. * var func = _.overEvery([Boolean, isFinite]);
  47663. *
  47664. * func('1');
  47665. * // => true
  47666. *
  47667. * func(null);
  47668. * // => false
  47669. *
  47670. * func(NaN);
  47671. * // => false
  47672. */
  47673. var overEvery = createOver(arrayEvery);
  47674. /**
  47675. * Creates a function that checks if **any** of the `predicates` return
  47676. * truthy when invoked with the arguments it receives.
  47677. *
  47678. * Following shorthands are possible for providing predicates.
  47679. * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.
  47680. * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.
  47681. *
  47682. * @static
  47683. * @memberOf _
  47684. * @since 4.0.0
  47685. * @category Util
  47686. * @param {...(Function|Function[])} [predicates=[_.identity]]
  47687. * The predicates to check.
  47688. * @returns {Function} Returns the new function.
  47689. * @example
  47690. *
  47691. * var func = _.overSome([Boolean, isFinite]);
  47692. *
  47693. * func('1');
  47694. * // => true
  47695. *
  47696. * func(null);
  47697. * // => true
  47698. *
  47699. * func(NaN);
  47700. * // => false
  47701. *
  47702. * var matchesFunc = _.overSome([{ 'a': 1 }, { 'a': 2 }])
  47703. * var matchesPropertyFunc = _.overSome([['a', 1], ['a', 2]])
  47704. */
  47705. var overSome = createOver(arraySome);
  47706. /**
  47707. * Creates a function that returns the value at `path` of a given object.
  47708. *
  47709. * @static
  47710. * @memberOf _
  47711. * @since 2.4.0
  47712. * @category Util
  47713. * @param {Array|string} path The path of the property to get.
  47714. * @returns {Function} Returns the new accessor function.
  47715. * @example
  47716. *
  47717. * var objects = [
  47718. * { 'a': { 'b': 2 } },
  47719. * { 'a': { 'b': 1 } }
  47720. * ];
  47721. *
  47722. * _.map(objects, _.property('a.b'));
  47723. * // => [2, 1]
  47724. *
  47725. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  47726. * // => [1, 2]
  47727. */
  47728. function property(path) {
  47729. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  47730. }
  47731. /**
  47732. * The opposite of `_.property`; this method creates a function that returns
  47733. * the value at a given path of `object`.
  47734. *
  47735. * @static
  47736. * @memberOf _
  47737. * @since 3.0.0
  47738. * @category Util
  47739. * @param {Object} object The object to query.
  47740. * @returns {Function} Returns the new accessor function.
  47741. * @example
  47742. *
  47743. * var array = [0, 1, 2],
  47744. * object = { 'a': array, 'b': array, 'c': array };
  47745. *
  47746. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  47747. * // => [2, 0]
  47748. *
  47749. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  47750. * // => [2, 0]
  47751. */
  47752. function propertyOf(object) {
  47753. return function(path) {
  47754. return object == null ? undefined : baseGet(object, path);
  47755. };
  47756. }
  47757. /**
  47758. * Creates an array of numbers (positive and/or negative) progressing from
  47759. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  47760. * `start` is specified without an `end` or `step`. If `end` is not specified,
  47761. * it's set to `start` with `start` then set to `0`.
  47762. *
  47763. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  47764. * floating-point values which can produce unexpected results.
  47765. *
  47766. * @static
  47767. * @since 0.1.0
  47768. * @memberOf _
  47769. * @category Util
  47770. * @param {number} [start=0] The start of the range.
  47771. * @param {number} end The end of the range.
  47772. * @param {number} [step=1] The value to increment or decrement by.
  47773. * @returns {Array} Returns the range of numbers.
  47774. * @see _.inRange, _.rangeRight
  47775. * @example
  47776. *
  47777. * _.range(4);
  47778. * // => [0, 1, 2, 3]
  47779. *
  47780. * _.range(-4);
  47781. * // => [0, -1, -2, -3]
  47782. *
  47783. * _.range(1, 5);
  47784. * // => [1, 2, 3, 4]
  47785. *
  47786. * _.range(0, 20, 5);
  47787. * // => [0, 5, 10, 15]
  47788. *
  47789. * _.range(0, -4, -1);
  47790. * // => [0, -1, -2, -3]
  47791. *
  47792. * _.range(1, 4, 0);
  47793. * // => [1, 1, 1]
  47794. *
  47795. * _.range(0);
  47796. * // => []
  47797. */
  47798. var range = createRange();
  47799. /**
  47800. * This method is like `_.range` except that it populates values in
  47801. * descending order.
  47802. *
  47803. * @static
  47804. * @memberOf _
  47805. * @since 4.0.0
  47806. * @category Util
  47807. * @param {number} [start=0] The start of the range.
  47808. * @param {number} end The end of the range.
  47809. * @param {number} [step=1] The value to increment or decrement by.
  47810. * @returns {Array} Returns the range of numbers.
  47811. * @see _.inRange, _.range
  47812. * @example
  47813. *
  47814. * _.rangeRight(4);
  47815. * // => [3, 2, 1, 0]
  47816. *
  47817. * _.rangeRight(-4);
  47818. * // => [-3, -2, -1, 0]
  47819. *
  47820. * _.rangeRight(1, 5);
  47821. * // => [4, 3, 2, 1]
  47822. *
  47823. * _.rangeRight(0, 20, 5);
  47824. * // => [15, 10, 5, 0]
  47825. *
  47826. * _.rangeRight(0, -4, -1);
  47827. * // => [-3, -2, -1, 0]
  47828. *
  47829. * _.rangeRight(1, 4, 0);
  47830. * // => [1, 1, 1]
  47831. *
  47832. * _.rangeRight(0);
  47833. * // => []
  47834. */
  47835. var rangeRight = createRange(true);
  47836. /**
  47837. * This method returns a new empty array.
  47838. *
  47839. * @static
  47840. * @memberOf _
  47841. * @since 4.13.0
  47842. * @category Util
  47843. * @returns {Array} Returns the new empty array.
  47844. * @example
  47845. *
  47846. * var arrays = _.times(2, _.stubArray);
  47847. *
  47848. * console.log(arrays);
  47849. * // => [[], []]
  47850. *
  47851. * console.log(arrays[0] === arrays[1]);
  47852. * // => false
  47853. */
  47854. function stubArray() {
  47855. return [];
  47856. }
  47857. /**
  47858. * This method returns `false`.
  47859. *
  47860. * @static
  47861. * @memberOf _
  47862. * @since 4.13.0
  47863. * @category Util
  47864. * @returns {boolean} Returns `false`.
  47865. * @example
  47866. *
  47867. * _.times(2, _.stubFalse);
  47868. * // => [false, false]
  47869. */
  47870. function stubFalse() {
  47871. return false;
  47872. }
  47873. /**
  47874. * This method returns a new empty object.
  47875. *
  47876. * @static
  47877. * @memberOf _
  47878. * @since 4.13.0
  47879. * @category Util
  47880. * @returns {Object} Returns the new empty object.
  47881. * @example
  47882. *
  47883. * var objects = _.times(2, _.stubObject);
  47884. *
  47885. * console.log(objects);
  47886. * // => [{}, {}]
  47887. *
  47888. * console.log(objects[0] === objects[1]);
  47889. * // => false
  47890. */
  47891. function stubObject() {
  47892. return {};
  47893. }
  47894. /**
  47895. * This method returns an empty string.
  47896. *
  47897. * @static
  47898. * @memberOf _
  47899. * @since 4.13.0
  47900. * @category Util
  47901. * @returns {string} Returns the empty string.
  47902. * @example
  47903. *
  47904. * _.times(2, _.stubString);
  47905. * // => ['', '']
  47906. */
  47907. function stubString() {
  47908. return '';
  47909. }
  47910. /**
  47911. * This method returns `true`.
  47912. *
  47913. * @static
  47914. * @memberOf _
  47915. * @since 4.13.0
  47916. * @category Util
  47917. * @returns {boolean} Returns `true`.
  47918. * @example
  47919. *
  47920. * _.times(2, _.stubTrue);
  47921. * // => [true, true]
  47922. */
  47923. function stubTrue() {
  47924. return true;
  47925. }
  47926. /**
  47927. * Invokes the iteratee `n` times, returning an array of the results of
  47928. * each invocation. The iteratee is invoked with one argument; (index).
  47929. *
  47930. * @static
  47931. * @since 0.1.0
  47932. * @memberOf _
  47933. * @category Util
  47934. * @param {number} n The number of times to invoke `iteratee`.
  47935. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  47936. * @returns {Array} Returns the array of results.
  47937. * @example
  47938. *
  47939. * _.times(3, String);
  47940. * // => ['0', '1', '2']
  47941. *
  47942. * _.times(4, _.constant(0));
  47943. * // => [0, 0, 0, 0]
  47944. */
  47945. function times(n, iteratee) {
  47946. n = toInteger(n);
  47947. if (n < 1 || n > MAX_SAFE_INTEGER) {
  47948. return [];
  47949. }
  47950. var index = MAX_ARRAY_LENGTH,
  47951. length = nativeMin(n, MAX_ARRAY_LENGTH);
  47952. iteratee = getIteratee(iteratee);
  47953. n -= MAX_ARRAY_LENGTH;
  47954. var result = baseTimes(length, iteratee);
  47955. while (++index < n) {
  47956. iteratee(index);
  47957. }
  47958. return result;
  47959. }
  47960. /**
  47961. * Converts `value` to a property path array.
  47962. *
  47963. * @static
  47964. * @memberOf _
  47965. * @since 4.0.0
  47966. * @category Util
  47967. * @param {*} value The value to convert.
  47968. * @returns {Array} Returns the new property path array.
  47969. * @example
  47970. *
  47971. * _.toPath('a.b.c');
  47972. * // => ['a', 'b', 'c']
  47973. *
  47974. * _.toPath('a[0].b.c');
  47975. * // => ['a', '0', 'b', 'c']
  47976. */
  47977. function toPath(value) {
  47978. if (isArray(value)) {
  47979. return arrayMap(value, toKey);
  47980. }
  47981. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  47982. }
  47983. /**
  47984. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  47985. *
  47986. * @static
  47987. * @since 0.1.0
  47988. * @memberOf _
  47989. * @category Util
  47990. * @param {string} [prefix=''] The value to prefix the ID with.
  47991. * @returns {string} Returns the unique ID.
  47992. * @example
  47993. *
  47994. * _.uniqueId('contact_');
  47995. * // => 'contact_104'
  47996. *
  47997. * _.uniqueId();
  47998. * // => '105'
  47999. */
  48000. function uniqueId(prefix) {
  48001. var id = ++idCounter;
  48002. return toString(prefix) + id;
  48003. }
  48004. /*------------------------------------------------------------------------*/
  48005. /**
  48006. * Adds two numbers.
  48007. *
  48008. * @static
  48009. * @memberOf _
  48010. * @since 3.4.0
  48011. * @category Math
  48012. * @param {number} augend The first number in an addition.
  48013. * @param {number} addend The second number in an addition.
  48014. * @returns {number} Returns the total.
  48015. * @example
  48016. *
  48017. * _.add(6, 4);
  48018. * // => 10
  48019. */
  48020. var add = createMathOperation(function(augend, addend) {
  48021. return augend + addend;
  48022. }, 0);
  48023. /**
  48024. * Computes `number` rounded up to `precision`.
  48025. *
  48026. * @static
  48027. * @memberOf _
  48028. * @since 3.10.0
  48029. * @category Math
  48030. * @param {number} number The number to round up.
  48031. * @param {number} [precision=0] The precision to round up to.
  48032. * @returns {number} Returns the rounded up number.
  48033. * @example
  48034. *
  48035. * _.ceil(4.006);
  48036. * // => 5
  48037. *
  48038. * _.ceil(6.004, 2);
  48039. * // => 6.01
  48040. *
  48041. * _.ceil(6040, -2);
  48042. * // => 6100
  48043. */
  48044. var ceil = createRound('ceil');
  48045. /**
  48046. * Divide two numbers.
  48047. *
  48048. * @static
  48049. * @memberOf _
  48050. * @since 4.7.0
  48051. * @category Math
  48052. * @param {number} dividend The first number in a division.
  48053. * @param {number} divisor The second number in a division.
  48054. * @returns {number} Returns the quotient.
  48055. * @example
  48056. *
  48057. * _.divide(6, 4);
  48058. * // => 1.5
  48059. */
  48060. var divide = createMathOperation(function(dividend, divisor) {
  48061. return dividend / divisor;
  48062. }, 1);
  48063. /**
  48064. * Computes `number` rounded down to `precision`.
  48065. *
  48066. * @static
  48067. * @memberOf _
  48068. * @since 3.10.0
  48069. * @category Math
  48070. * @param {number} number The number to round down.
  48071. * @param {number} [precision=0] The precision to round down to.
  48072. * @returns {number} Returns the rounded down number.
  48073. * @example
  48074. *
  48075. * _.floor(4.006);
  48076. * // => 4
  48077. *
  48078. * _.floor(0.046, 2);
  48079. * // => 0.04
  48080. *
  48081. * _.floor(4060, -2);
  48082. * // => 4000
  48083. */
  48084. var floor = createRound('floor');
  48085. /**
  48086. * Computes the maximum value of `array`. If `array` is empty or falsey,
  48087. * `undefined` is returned.
  48088. *
  48089. * @static
  48090. * @since 0.1.0
  48091. * @memberOf _
  48092. * @category Math
  48093. * @param {Array} array The array to iterate over.
  48094. * @returns {*} Returns the maximum value.
  48095. * @example
  48096. *
  48097. * _.max([4, 2, 8, 6]);
  48098. * // => 8
  48099. *
  48100. * _.max([]);
  48101. * // => undefined
  48102. */
  48103. function max(array) {
  48104. return (array && array.length)
  48105. ? baseExtremum(array, identity, baseGt)
  48106. : undefined;
  48107. }
  48108. /**
  48109. * This method is like `_.max` except that it accepts `iteratee` which is
  48110. * invoked for each element in `array` to generate the criterion by which
  48111. * the value is ranked. The iteratee is invoked with one argument: (value).
  48112. *
  48113. * @static
  48114. * @memberOf _
  48115. * @since 4.0.0
  48116. * @category Math
  48117. * @param {Array} array The array to iterate over.
  48118. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  48119. * @returns {*} Returns the maximum value.
  48120. * @example
  48121. *
  48122. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  48123. *
  48124. * _.maxBy(objects, function(o) { return o.n; });
  48125. * // => { 'n': 2 }
  48126. *
  48127. * // The `_.property` iteratee shorthand.
  48128. * _.maxBy(objects, 'n');
  48129. * // => { 'n': 2 }
  48130. */
  48131. function maxBy(array, iteratee) {
  48132. return (array && array.length)
  48133. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  48134. : undefined;
  48135. }
  48136. /**
  48137. * Computes the mean of the values in `array`.
  48138. *
  48139. * @static
  48140. * @memberOf _
  48141. * @since 4.0.0
  48142. * @category Math
  48143. * @param {Array} array The array to iterate over.
  48144. * @returns {number} Returns the mean.
  48145. * @example
  48146. *
  48147. * _.mean([4, 2, 8, 6]);
  48148. * // => 5
  48149. */
  48150. function mean(array) {
  48151. return baseMean(array, identity);
  48152. }
  48153. /**
  48154. * This method is like `_.mean` except that it accepts `iteratee` which is
  48155. * invoked for each element in `array` to generate the value to be averaged.
  48156. * The iteratee is invoked with one argument: (value).
  48157. *
  48158. * @static
  48159. * @memberOf _
  48160. * @since 4.7.0
  48161. * @category Math
  48162. * @param {Array} array The array to iterate over.
  48163. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  48164. * @returns {number} Returns the mean.
  48165. * @example
  48166. *
  48167. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  48168. *
  48169. * _.meanBy(objects, function(o) { return o.n; });
  48170. * // => 5
  48171. *
  48172. * // The `_.property` iteratee shorthand.
  48173. * _.meanBy(objects, 'n');
  48174. * // => 5
  48175. */
  48176. function meanBy(array, iteratee) {
  48177. return baseMean(array, getIteratee(iteratee, 2));
  48178. }
  48179. /**
  48180. * Computes the minimum value of `array`. If `array` is empty or falsey,
  48181. * `undefined` is returned.
  48182. *
  48183. * @static
  48184. * @since 0.1.0
  48185. * @memberOf _
  48186. * @category Math
  48187. * @param {Array} array The array to iterate over.
  48188. * @returns {*} Returns the minimum value.
  48189. * @example
  48190. *
  48191. * _.min([4, 2, 8, 6]);
  48192. * // => 2
  48193. *
  48194. * _.min([]);
  48195. * // => undefined
  48196. */
  48197. function min(array) {
  48198. return (array && array.length)
  48199. ? baseExtremum(array, identity, baseLt)
  48200. : undefined;
  48201. }
  48202. /**
  48203. * This method is like `_.min` except that it accepts `iteratee` which is
  48204. * invoked for each element in `array` to generate the criterion by which
  48205. * the value is ranked. The iteratee is invoked with one argument: (value).
  48206. *
  48207. * @static
  48208. * @memberOf _
  48209. * @since 4.0.0
  48210. * @category Math
  48211. * @param {Array} array The array to iterate over.
  48212. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  48213. * @returns {*} Returns the minimum value.
  48214. * @example
  48215. *
  48216. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  48217. *
  48218. * _.minBy(objects, function(o) { return o.n; });
  48219. * // => { 'n': 1 }
  48220. *
  48221. * // The `_.property` iteratee shorthand.
  48222. * _.minBy(objects, 'n');
  48223. * // => { 'n': 1 }
  48224. */
  48225. function minBy(array, iteratee) {
  48226. return (array && array.length)
  48227. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  48228. : undefined;
  48229. }
  48230. /**
  48231. * Multiply two numbers.
  48232. *
  48233. * @static
  48234. * @memberOf _
  48235. * @since 4.7.0
  48236. * @category Math
  48237. * @param {number} multiplier The first number in a multiplication.
  48238. * @param {number} multiplicand The second number in a multiplication.
  48239. * @returns {number} Returns the product.
  48240. * @example
  48241. *
  48242. * _.multiply(6, 4);
  48243. * // => 24
  48244. */
  48245. var multiply = createMathOperation(function(multiplier, multiplicand) {
  48246. return multiplier * multiplicand;
  48247. }, 1);
  48248. /**
  48249. * Computes `number` rounded to `precision`.
  48250. *
  48251. * @static
  48252. * @memberOf _
  48253. * @since 3.10.0
  48254. * @category Math
  48255. * @param {number} number The number to round.
  48256. * @param {number} [precision=0] The precision to round to.
  48257. * @returns {number} Returns the rounded number.
  48258. * @example
  48259. *
  48260. * _.round(4.006);
  48261. * // => 4
  48262. *
  48263. * _.round(4.006, 2);
  48264. * // => 4.01
  48265. *
  48266. * _.round(4060, -2);
  48267. * // => 4100
  48268. */
  48269. var round = createRound('round');
  48270. /**
  48271. * Subtract two numbers.
  48272. *
  48273. * @static
  48274. * @memberOf _
  48275. * @since 4.0.0
  48276. * @category Math
  48277. * @param {number} minuend The first number in a subtraction.
  48278. * @param {number} subtrahend The second number in a subtraction.
  48279. * @returns {number} Returns the difference.
  48280. * @example
  48281. *
  48282. * _.subtract(6, 4);
  48283. * // => 2
  48284. */
  48285. var subtract = createMathOperation(function(minuend, subtrahend) {
  48286. return minuend - subtrahend;
  48287. }, 0);
  48288. /**
  48289. * Computes the sum of the values in `array`.
  48290. *
  48291. * @static
  48292. * @memberOf _
  48293. * @since 3.4.0
  48294. * @category Math
  48295. * @param {Array} array The array to iterate over.
  48296. * @returns {number} Returns the sum.
  48297. * @example
  48298. *
  48299. * _.sum([4, 2, 8, 6]);
  48300. * // => 20
  48301. */
  48302. function sum(array) {
  48303. return (array && array.length)
  48304. ? baseSum(array, identity)
  48305. : 0;
  48306. }
  48307. /**
  48308. * This method is like `_.sum` except that it accepts `iteratee` which is
  48309. * invoked for each element in `array` to generate the value to be summed.
  48310. * The iteratee is invoked with one argument: (value).
  48311. *
  48312. * @static
  48313. * @memberOf _
  48314. * @since 4.0.0
  48315. * @category Math
  48316. * @param {Array} array The array to iterate over.
  48317. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  48318. * @returns {number} Returns the sum.
  48319. * @example
  48320. *
  48321. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  48322. *
  48323. * _.sumBy(objects, function(o) { return o.n; });
  48324. * // => 20
  48325. *
  48326. * // The `_.property` iteratee shorthand.
  48327. * _.sumBy(objects, 'n');
  48328. * // => 20
  48329. */
  48330. function sumBy(array, iteratee) {
  48331. return (array && array.length)
  48332. ? baseSum(array, getIteratee(iteratee, 2))
  48333. : 0;
  48334. }
  48335. /*------------------------------------------------------------------------*/
  48336. // Add methods that return wrapped values in chain sequences.
  48337. lodash.after = after;
  48338. lodash.ary = ary;
  48339. lodash.assign = assign;
  48340. lodash.assignIn = assignIn;
  48341. lodash.assignInWith = assignInWith;
  48342. lodash.assignWith = assignWith;
  48343. lodash.at = at;
  48344. lodash.before = before;
  48345. lodash.bind = bind;
  48346. lodash.bindAll = bindAll;
  48347. lodash.bindKey = bindKey;
  48348. lodash.castArray = castArray;
  48349. lodash.chain = chain;
  48350. lodash.chunk = chunk;
  48351. lodash.compact = compact;
  48352. lodash.concat = concat;
  48353. lodash.cond = cond;
  48354. lodash.conforms = conforms;
  48355. lodash.constant = constant;
  48356. lodash.countBy = countBy;
  48357. lodash.create = create;
  48358. lodash.curry = curry;
  48359. lodash.curryRight = curryRight;
  48360. lodash.debounce = debounce;
  48361. lodash.defaults = defaults;
  48362. lodash.defaultsDeep = defaultsDeep;
  48363. lodash.defer = defer;
  48364. lodash.delay = delay;
  48365. lodash.difference = difference;
  48366. lodash.differenceBy = differenceBy;
  48367. lodash.differenceWith = differenceWith;
  48368. lodash.drop = drop;
  48369. lodash.dropRight = dropRight;
  48370. lodash.dropRightWhile = dropRightWhile;
  48371. lodash.dropWhile = dropWhile;
  48372. lodash.fill = fill;
  48373. lodash.filter = filter;
  48374. lodash.flatMap = flatMap;
  48375. lodash.flatMapDeep = flatMapDeep;
  48376. lodash.flatMapDepth = flatMapDepth;
  48377. lodash.flatten = flatten;
  48378. lodash.flattenDeep = flattenDeep;
  48379. lodash.flattenDepth = flattenDepth;
  48380. lodash.flip = flip;
  48381. lodash.flow = flow;
  48382. lodash.flowRight = flowRight;
  48383. lodash.fromPairs = fromPairs;
  48384. lodash.functions = functions;
  48385. lodash.functionsIn = functionsIn;
  48386. lodash.groupBy = groupBy;
  48387. lodash.initial = initial;
  48388. lodash.intersection = intersection;
  48389. lodash.intersectionBy = intersectionBy;
  48390. lodash.intersectionWith = intersectionWith;
  48391. lodash.invert = invert;
  48392. lodash.invertBy = invertBy;
  48393. lodash.invokeMap = invokeMap;
  48394. lodash.iteratee = iteratee;
  48395. lodash.keyBy = keyBy;
  48396. lodash.keys = keys;
  48397. lodash.keysIn = keysIn;
  48398. lodash.map = map;
  48399. lodash.mapKeys = mapKeys;
  48400. lodash.mapValues = mapValues;
  48401. lodash.matches = matches;
  48402. lodash.matchesProperty = matchesProperty;
  48403. lodash.memoize = memoize;
  48404. lodash.merge = merge;
  48405. lodash.mergeWith = mergeWith;
  48406. lodash.method = method;
  48407. lodash.methodOf = methodOf;
  48408. lodash.mixin = mixin;
  48409. lodash.negate = negate;
  48410. lodash.nthArg = nthArg;
  48411. lodash.omit = omit;
  48412. lodash.omitBy = omitBy;
  48413. lodash.once = once;
  48414. lodash.orderBy = orderBy;
  48415. lodash.over = over;
  48416. lodash.overArgs = overArgs;
  48417. lodash.overEvery = overEvery;
  48418. lodash.overSome = overSome;
  48419. lodash.partial = partial;
  48420. lodash.partialRight = partialRight;
  48421. lodash.partition = partition;
  48422. lodash.pick = pick;
  48423. lodash.pickBy = pickBy;
  48424. lodash.property = property;
  48425. lodash.propertyOf = propertyOf;
  48426. lodash.pull = pull;
  48427. lodash.pullAll = pullAll;
  48428. lodash.pullAllBy = pullAllBy;
  48429. lodash.pullAllWith = pullAllWith;
  48430. lodash.pullAt = pullAt;
  48431. lodash.range = range;
  48432. lodash.rangeRight = rangeRight;
  48433. lodash.rearg = rearg;
  48434. lodash.reject = reject;
  48435. lodash.remove = remove;
  48436. lodash.rest = rest;
  48437. lodash.reverse = reverse;
  48438. lodash.sampleSize = sampleSize;
  48439. lodash.set = set;
  48440. lodash.setWith = setWith;
  48441. lodash.shuffle = shuffle;
  48442. lodash.slice = slice;
  48443. lodash.sortBy = sortBy;
  48444. lodash.sortedUniq = sortedUniq;
  48445. lodash.sortedUniqBy = sortedUniqBy;
  48446. lodash.split = split;
  48447. lodash.spread = spread;
  48448. lodash.tail = tail;
  48449. lodash.take = take;
  48450. lodash.takeRight = takeRight;
  48451. lodash.takeRightWhile = takeRightWhile;
  48452. lodash.takeWhile = takeWhile;
  48453. lodash.tap = tap;
  48454. lodash.throttle = throttle;
  48455. lodash.thru = thru;
  48456. lodash.toArray = toArray;
  48457. lodash.toPairs = toPairs;
  48458. lodash.toPairsIn = toPairsIn;
  48459. lodash.toPath = toPath;
  48460. lodash.toPlainObject = toPlainObject;
  48461. lodash.transform = transform;
  48462. lodash.unary = unary;
  48463. lodash.union = union;
  48464. lodash.unionBy = unionBy;
  48465. lodash.unionWith = unionWith;
  48466. lodash.uniq = uniq;
  48467. lodash.uniqBy = uniqBy;
  48468. lodash.uniqWith = uniqWith;
  48469. lodash.unset = unset;
  48470. lodash.unzip = unzip;
  48471. lodash.unzipWith = unzipWith;
  48472. lodash.update = update;
  48473. lodash.updateWith = updateWith;
  48474. lodash.values = values;
  48475. lodash.valuesIn = valuesIn;
  48476. lodash.without = without;
  48477. lodash.words = words;
  48478. lodash.wrap = wrap;
  48479. lodash.xor = xor;
  48480. lodash.xorBy = xorBy;
  48481. lodash.xorWith = xorWith;
  48482. lodash.zip = zip;
  48483. lodash.zipObject = zipObject;
  48484. lodash.zipObjectDeep = zipObjectDeep;
  48485. lodash.zipWith = zipWith;
  48486. // Add aliases.
  48487. lodash.entries = toPairs;
  48488. lodash.entriesIn = toPairsIn;
  48489. lodash.extend = assignIn;
  48490. lodash.extendWith = assignInWith;
  48491. // Add methods to `lodash.prototype`.
  48492. mixin(lodash, lodash);
  48493. /*------------------------------------------------------------------------*/
  48494. // Add methods that return unwrapped values in chain sequences.
  48495. lodash.add = add;
  48496. lodash.attempt = attempt;
  48497. lodash.camelCase = camelCase;
  48498. lodash.capitalize = capitalize;
  48499. lodash.ceil = ceil;
  48500. lodash.clamp = clamp;
  48501. lodash.clone = clone;
  48502. lodash.cloneDeep = cloneDeep;
  48503. lodash.cloneDeepWith = cloneDeepWith;
  48504. lodash.cloneWith = cloneWith;
  48505. lodash.conformsTo = conformsTo;
  48506. lodash.deburr = deburr;
  48507. lodash.defaultTo = defaultTo;
  48508. lodash.divide = divide;
  48509. lodash.endsWith = endsWith;
  48510. lodash.eq = eq;
  48511. lodash.escape = escape;
  48512. lodash.escapeRegExp = escapeRegExp;
  48513. lodash.every = every;
  48514. lodash.find = find;
  48515. lodash.findIndex = findIndex;
  48516. lodash.findKey = findKey;
  48517. lodash.findLast = findLast;
  48518. lodash.findLastIndex = findLastIndex;
  48519. lodash.findLastKey = findLastKey;
  48520. lodash.floor = floor;
  48521. lodash.forEach = forEach;
  48522. lodash.forEachRight = forEachRight;
  48523. lodash.forIn = forIn;
  48524. lodash.forInRight = forInRight;
  48525. lodash.forOwn = forOwn;
  48526. lodash.forOwnRight = forOwnRight;
  48527. lodash.get = get;
  48528. lodash.gt = gt;
  48529. lodash.gte = gte;
  48530. lodash.has = has;
  48531. lodash.hasIn = hasIn;
  48532. lodash.head = head;
  48533. lodash.identity = identity;
  48534. lodash.includes = includes;
  48535. lodash.indexOf = indexOf;
  48536. lodash.inRange = inRange;
  48537. lodash.invoke = invoke;
  48538. lodash.isArguments = isArguments;
  48539. lodash.isArray = isArray;
  48540. lodash.isArrayBuffer = isArrayBuffer;
  48541. lodash.isArrayLike = isArrayLike;
  48542. lodash.isArrayLikeObject = isArrayLikeObject;
  48543. lodash.isBoolean = isBoolean;
  48544. lodash.isBuffer = isBuffer;
  48545. lodash.isDate = isDate;
  48546. lodash.isElement = isElement;
  48547. lodash.isEmpty = isEmpty;
  48548. lodash.isEqual = isEqual;
  48549. lodash.isEqualWith = isEqualWith;
  48550. lodash.isError = isError;
  48551. lodash.isFinite = isFinite;
  48552. lodash.isFunction = isFunction;
  48553. lodash.isInteger = isInteger;
  48554. lodash.isLength = isLength;
  48555. lodash.isMap = isMap;
  48556. lodash.isMatch = isMatch;
  48557. lodash.isMatchWith = isMatchWith;
  48558. lodash.isNaN = isNaN;
  48559. lodash.isNative = isNative;
  48560. lodash.isNil = isNil;
  48561. lodash.isNull = isNull;
  48562. lodash.isNumber = isNumber;
  48563. lodash.isObject = isObject;
  48564. lodash.isObjectLike = isObjectLike;
  48565. lodash.isPlainObject = isPlainObject;
  48566. lodash.isRegExp = isRegExp;
  48567. lodash.isSafeInteger = isSafeInteger;
  48568. lodash.isSet = isSet;
  48569. lodash.isString = isString;
  48570. lodash.isSymbol = isSymbol;
  48571. lodash.isTypedArray = isTypedArray;
  48572. lodash.isUndefined = isUndefined;
  48573. lodash.isWeakMap = isWeakMap;
  48574. lodash.isWeakSet = isWeakSet;
  48575. lodash.join = join;
  48576. lodash.kebabCase = kebabCase;
  48577. lodash.last = last;
  48578. lodash.lastIndexOf = lastIndexOf;
  48579. lodash.lowerCase = lowerCase;
  48580. lodash.lowerFirst = lowerFirst;
  48581. lodash.lt = lt;
  48582. lodash.lte = lte;
  48583. lodash.max = max;
  48584. lodash.maxBy = maxBy;
  48585. lodash.mean = mean;
  48586. lodash.meanBy = meanBy;
  48587. lodash.min = min;
  48588. lodash.minBy = minBy;
  48589. lodash.stubArray = stubArray;
  48590. lodash.stubFalse = stubFalse;
  48591. lodash.stubObject = stubObject;
  48592. lodash.stubString = stubString;
  48593. lodash.stubTrue = stubTrue;
  48594. lodash.multiply = multiply;
  48595. lodash.nth = nth;
  48596. lodash.noConflict = noConflict;
  48597. lodash.noop = noop;
  48598. lodash.now = now;
  48599. lodash.pad = pad;
  48600. lodash.padEnd = padEnd;
  48601. lodash.padStart = padStart;
  48602. lodash.parseInt = parseInt;
  48603. lodash.random = random;
  48604. lodash.reduce = reduce;
  48605. lodash.reduceRight = reduceRight;
  48606. lodash.repeat = repeat;
  48607. lodash.replace = replace;
  48608. lodash.result = result;
  48609. lodash.round = round;
  48610. lodash.runInContext = runInContext;
  48611. lodash.sample = sample;
  48612. lodash.size = size;
  48613. lodash.snakeCase = snakeCase;
  48614. lodash.some = some;
  48615. lodash.sortedIndex = sortedIndex;
  48616. lodash.sortedIndexBy = sortedIndexBy;
  48617. lodash.sortedIndexOf = sortedIndexOf;
  48618. lodash.sortedLastIndex = sortedLastIndex;
  48619. lodash.sortedLastIndexBy = sortedLastIndexBy;
  48620. lodash.sortedLastIndexOf = sortedLastIndexOf;
  48621. lodash.startCase = startCase;
  48622. lodash.startsWith = startsWith;
  48623. lodash.subtract = subtract;
  48624. lodash.sum = sum;
  48625. lodash.sumBy = sumBy;
  48626. lodash.template = template;
  48627. lodash.times = times;
  48628. lodash.toFinite = toFinite;
  48629. lodash.toInteger = toInteger;
  48630. lodash.toLength = toLength;
  48631. lodash.toLower = toLower;
  48632. lodash.toNumber = toNumber;
  48633. lodash.toSafeInteger = toSafeInteger;
  48634. lodash.toString = toString;
  48635. lodash.toUpper = toUpper;
  48636. lodash.trim = trim;
  48637. lodash.trimEnd = trimEnd;
  48638. lodash.trimStart = trimStart;
  48639. lodash.truncate = truncate;
  48640. lodash.unescape = unescape;
  48641. lodash.uniqueId = uniqueId;
  48642. lodash.upperCase = upperCase;
  48643. lodash.upperFirst = upperFirst;
  48644. // Add aliases.
  48645. lodash.each = forEach;
  48646. lodash.eachRight = forEachRight;
  48647. lodash.first = head;
  48648. mixin(lodash, (function() {
  48649. var source = {};
  48650. baseForOwn(lodash, function(func, methodName) {
  48651. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  48652. source[methodName] = func;
  48653. }
  48654. });
  48655. return source;
  48656. }()), { 'chain': false });
  48657. /*------------------------------------------------------------------------*/
  48658. /**
  48659. * The semantic version number.
  48660. *
  48661. * @static
  48662. * @memberOf _
  48663. * @type {string}
  48664. */
  48665. lodash.VERSION = VERSION;
  48666. // Assign default placeholders.
  48667. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  48668. lodash[methodName].placeholder = lodash;
  48669. });
  48670. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  48671. arrayEach(['drop', 'take'], function(methodName, index) {
  48672. LazyWrapper.prototype[methodName] = function(n) {
  48673. n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
  48674. var result = (this.__filtered__ && !index)
  48675. ? new LazyWrapper(this)
  48676. : this.clone();
  48677. if (result.__filtered__) {
  48678. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  48679. } else {
  48680. result.__views__.push({
  48681. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  48682. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  48683. });
  48684. }
  48685. return result;
  48686. };
  48687. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  48688. return this.reverse()[methodName](n).reverse();
  48689. };
  48690. });
  48691. // Add `LazyWrapper` methods that accept an `iteratee` value.
  48692. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  48693. var type = index + 1,
  48694. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  48695. LazyWrapper.prototype[methodName] = function(iteratee) {
  48696. var result = this.clone();
  48697. result.__iteratees__.push({
  48698. 'iteratee': getIteratee(iteratee, 3),
  48699. 'type': type
  48700. });
  48701. result.__filtered__ = result.__filtered__ || isFilter;
  48702. return result;
  48703. };
  48704. });
  48705. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  48706. arrayEach(['head', 'last'], function(methodName, index) {
  48707. var takeName = 'take' + (index ? 'Right' : '');
  48708. LazyWrapper.prototype[methodName] = function() {
  48709. return this[takeName](1).value()[0];
  48710. };
  48711. });
  48712. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  48713. arrayEach(['initial', 'tail'], function(methodName, index) {
  48714. var dropName = 'drop' + (index ? '' : 'Right');
  48715. LazyWrapper.prototype[methodName] = function() {
  48716. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  48717. };
  48718. });
  48719. LazyWrapper.prototype.compact = function() {
  48720. return this.filter(identity);
  48721. };
  48722. LazyWrapper.prototype.find = function(predicate) {
  48723. return this.filter(predicate).head();
  48724. };
  48725. LazyWrapper.prototype.findLast = function(predicate) {
  48726. return this.reverse().find(predicate);
  48727. };
  48728. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  48729. if (typeof path == 'function') {
  48730. return new LazyWrapper(this);
  48731. }
  48732. return this.map(function(value) {
  48733. return baseInvoke(value, path, args);
  48734. });
  48735. });
  48736. LazyWrapper.prototype.reject = function(predicate) {
  48737. return this.filter(negate(getIteratee(predicate)));
  48738. };
  48739. LazyWrapper.prototype.slice = function(start, end) {
  48740. start = toInteger(start);
  48741. var result = this;
  48742. if (result.__filtered__ && (start > 0 || end < 0)) {
  48743. return new LazyWrapper(result);
  48744. }
  48745. if (start < 0) {
  48746. result = result.takeRight(-start);
  48747. } else if (start) {
  48748. result = result.drop(start);
  48749. }
  48750. if (end !== undefined) {
  48751. end = toInteger(end);
  48752. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  48753. }
  48754. return result;
  48755. };
  48756. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  48757. return this.reverse().takeWhile(predicate).reverse();
  48758. };
  48759. LazyWrapper.prototype.toArray = function() {
  48760. return this.take(MAX_ARRAY_LENGTH);
  48761. };
  48762. // Add `LazyWrapper` methods to `lodash.prototype`.
  48763. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  48764. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  48765. isTaker = /^(?:head|last)$/.test(methodName),
  48766. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  48767. retUnwrapped = isTaker || /^find/.test(methodName);
  48768. if (!lodashFunc) {
  48769. return;
  48770. }
  48771. lodash.prototype[methodName] = function() {
  48772. var value = this.__wrapped__,
  48773. args = isTaker ? [1] : arguments,
  48774. isLazy = value instanceof LazyWrapper,
  48775. iteratee = args[0],
  48776. useLazy = isLazy || isArray(value);
  48777. var interceptor = function(value) {
  48778. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  48779. return (isTaker && chainAll) ? result[0] : result;
  48780. };
  48781. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  48782. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  48783. isLazy = useLazy = false;
  48784. }
  48785. var chainAll = this.__chain__,
  48786. isHybrid = !!this.__actions__.length,
  48787. isUnwrapped = retUnwrapped && !chainAll,
  48788. onlyLazy = isLazy && !isHybrid;
  48789. if (!retUnwrapped && useLazy) {
  48790. value = onlyLazy ? value : new LazyWrapper(this);
  48791. var result = func.apply(value, args);
  48792. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
  48793. return new LodashWrapper(result, chainAll);
  48794. }
  48795. if (isUnwrapped && onlyLazy) {
  48796. return func.apply(this, args);
  48797. }
  48798. result = this.thru(interceptor);
  48799. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  48800. };
  48801. });
  48802. // Add `Array` methods to `lodash.prototype`.
  48803. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  48804. var func = arrayProto[methodName],
  48805. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  48806. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  48807. lodash.prototype[methodName] = function() {
  48808. var args = arguments;
  48809. if (retUnwrapped && !this.__chain__) {
  48810. var value = this.value();
  48811. return func.apply(isArray(value) ? value : [], args);
  48812. }
  48813. return this[chainName](function(value) {
  48814. return func.apply(isArray(value) ? value : [], args);
  48815. });
  48816. };
  48817. });
  48818. // Map minified method names to their real names.
  48819. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  48820. var lodashFunc = lodash[methodName];
  48821. if (lodashFunc) {
  48822. var key = lodashFunc.name + '';
  48823. if (!hasOwnProperty.call(realNames, key)) {
  48824. realNames[key] = [];
  48825. }
  48826. realNames[key].push({ 'name': methodName, 'func': lodashFunc });
  48827. }
  48828. });
  48829. realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
  48830. 'name': 'wrapper',
  48831. 'func': undefined
  48832. }];
  48833. // Add methods to `LazyWrapper`.
  48834. LazyWrapper.prototype.clone = lazyClone;
  48835. LazyWrapper.prototype.reverse = lazyReverse;
  48836. LazyWrapper.prototype.value = lazyValue;
  48837. // Add chain sequence methods to the `lodash` wrapper.
  48838. lodash.prototype.at = wrapperAt;
  48839. lodash.prototype.chain = wrapperChain;
  48840. lodash.prototype.commit = wrapperCommit;
  48841. lodash.prototype.next = wrapperNext;
  48842. lodash.prototype.plant = wrapperPlant;
  48843. lodash.prototype.reverse = wrapperReverse;
  48844. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  48845. // Add lazy aliases.
  48846. lodash.prototype.first = lodash.prototype.head;
  48847. if (symIterator) {
  48848. lodash.prototype[symIterator] = wrapperToIterator;
  48849. }
  48850. return lodash;
  48851. });
  48852. /*--------------------------------------------------------------------------*/
  48853. // Export lodash.
  48854. var _ = runInContext();
  48855. // Some AMD build optimizers, like r.js, check for condition patterns like:
  48856. if (true) {
  48857. // Expose Lodash on the global object to prevent errors when Lodash is
  48858. // loaded by a script tag in the presence of an AMD loader.
  48859. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  48860. // Use `_.noConflict` to remove Lodash from the global object.
  48861. root._ = _;
  48862. // Define as an anonymous module so, through path mapping, it can be
  48863. // referenced as the "underscore" module.
  48864. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  48865. return _;
  48866. }).call(exports, __webpack_require__, exports, module),
  48867. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  48868. }
  48869. // Check for `exports` after `define` in case a build optimizer adds it.
  48870. else {}
  48871. }.call(this));
  48872. /***/ }),
  48873. /***/ "../../node_modules/lodash/map.js":
  48874. /*!****************************************!*\
  48875. !*** ../../node_modules/lodash/map.js ***!
  48876. \****************************************/
  48877. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  48878. var arrayMap = __webpack_require__(/*! ./_arrayMap */ "../../node_modules/lodash/_arrayMap.js"),
  48879. baseIteratee = __webpack_require__(/*! ./_baseIteratee */ "../../node_modules/lodash/_baseIteratee.js"),
  48880. baseMap = __webpack_require__(/*! ./_baseMap */ "../../node_modules/lodash/_baseMap.js"),
  48881. isArray = __webpack_require__(/*! ./isArray */ "../../node_modules/lodash/isArray.js");
  48882. /**
  48883. * Creates an array of values by running each element in `collection` thru
  48884. * `iteratee`. The iteratee is invoked with three arguments:
  48885. * (value, index|key, collection).
  48886. *
  48887. * Many lodash methods are guarded to work as iteratees for methods like
  48888. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  48889. *
  48890. * The guarded methods are:
  48891. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  48892. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  48893. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  48894. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  48895. *
  48896. * @static
  48897. * @memberOf _
  48898. * @since 0.1.0
  48899. * @category Collection
  48900. * @param {Array|Object} collection The collection to iterate over.
  48901. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  48902. * @returns {Array} Returns the new mapped array.
  48903. * @example
  48904. *
  48905. * function square(n) {
  48906. * return n * n;
  48907. * }
  48908. *
  48909. * _.map([4, 8], square);
  48910. * // => [16, 64]
  48911. *
  48912. * _.map({ 'a': 4, 'b': 8 }, square);
  48913. * // => [16, 64] (iteration order is not guaranteed)
  48914. *
  48915. * var users = [
  48916. * { 'user': 'barney' },
  48917. * { 'user': 'fred' }
  48918. * ];
  48919. *
  48920. * // The `_.property` iteratee shorthand.
  48921. * _.map(users, 'user');
  48922. * // => ['barney', 'fred']
  48923. */
  48924. function map(collection, iteratee) {
  48925. var func = isArray(collection) ? arrayMap : baseMap;
  48926. return func(collection, baseIteratee(iteratee, 3));
  48927. }
  48928. module.exports = map;
  48929. /***/ }),
  48930. /***/ "../../node_modules/lodash/memoize.js":
  48931. /*!********************************************!*\
  48932. !*** ../../node_modules/lodash/memoize.js ***!
  48933. \********************************************/
  48934. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  48935. var MapCache = __webpack_require__(/*! ./_MapCache */ "../../node_modules/lodash/_MapCache.js");
  48936. /** Error message constants. */
  48937. var FUNC_ERROR_TEXT = 'Expected a function';
  48938. /**
  48939. * Creates a function that memoizes the result of `func`. If `resolver` is
  48940. * provided, it determines the cache key for storing the result based on the
  48941. * arguments provided to the memoized function. By default, the first argument
  48942. * provided to the memoized function is used as the map cache key. The `func`
  48943. * is invoked with the `this` binding of the memoized function.
  48944. *
  48945. * **Note:** The cache is exposed as the `cache` property on the memoized
  48946. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  48947. * constructor with one whose instances implement the
  48948. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  48949. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  48950. *
  48951. * @static
  48952. * @memberOf _
  48953. * @since 0.1.0
  48954. * @category Function
  48955. * @param {Function} func The function to have its output memoized.
  48956. * @param {Function} [resolver] The function to resolve the cache key.
  48957. * @returns {Function} Returns the new memoized function.
  48958. * @example
  48959. *
  48960. * var object = { 'a': 1, 'b': 2 };
  48961. * var other = { 'c': 3, 'd': 4 };
  48962. *
  48963. * var values = _.memoize(_.values);
  48964. * values(object);
  48965. * // => [1, 2]
  48966. *
  48967. * values(other);
  48968. * // => [3, 4]
  48969. *
  48970. * object.a = 2;
  48971. * values(object);
  48972. * // => [1, 2]
  48973. *
  48974. * // Modify the result cache.
  48975. * values.cache.set(object, ['a', 'b']);
  48976. * values(object);
  48977. * // => ['a', 'b']
  48978. *
  48979. * // Replace `_.memoize.Cache`.
  48980. * _.memoize.Cache = WeakMap;
  48981. */
  48982. function memoize(func, resolver) {
  48983. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  48984. throw new TypeError(FUNC_ERROR_TEXT);
  48985. }
  48986. var memoized = function() {
  48987. var args = arguments,
  48988. key = resolver ? resolver.apply(this, args) : args[0],
  48989. cache = memoized.cache;
  48990. if (cache.has(key)) {
  48991. return cache.get(key);
  48992. }
  48993. var result = func.apply(this, args);
  48994. memoized.cache = cache.set(key, result) || cache;
  48995. return result;
  48996. };
  48997. memoized.cache = new (memoize.Cache || MapCache);
  48998. return memoized;
  48999. }
  49000. // Expose `MapCache`.
  49001. memoize.Cache = MapCache;
  49002. module.exports = memoize;
  49003. /***/ }),
  49004. /***/ "../../node_modules/lodash/negate.js":
  49005. /*!*******************************************!*\
  49006. !*** ../../node_modules/lodash/negate.js ***!
  49007. \*******************************************/
  49008. /***/ ((module) => {
  49009. /** Error message constants. */
  49010. var FUNC_ERROR_TEXT = 'Expected a function';
  49011. /**
  49012. * Creates a function that negates the result of the predicate `func`. The
  49013. * `func` predicate is invoked with the `this` binding and arguments of the
  49014. * created function.
  49015. *
  49016. * @static
  49017. * @memberOf _
  49018. * @since 3.0.0
  49019. * @category Function
  49020. * @param {Function} predicate The predicate to negate.
  49021. * @returns {Function} Returns the new negated function.
  49022. * @example
  49023. *
  49024. * function isEven(n) {
  49025. * return n % 2 == 0;
  49026. * }
  49027. *
  49028. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  49029. * // => [1, 3, 5]
  49030. */
  49031. function negate(predicate) {
  49032. if (typeof predicate != 'function') {
  49033. throw new TypeError(FUNC_ERROR_TEXT);
  49034. }
  49035. return function() {
  49036. var args = arguments;
  49037. switch (args.length) {
  49038. case 0: return !predicate.call(this);
  49039. case 1: return !predicate.call(this, args[0]);
  49040. case 2: return !predicate.call(this, args[0], args[1]);
  49041. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  49042. }
  49043. return !predicate.apply(this, args);
  49044. };
  49045. }
  49046. module.exports = negate;
  49047. /***/ }),
  49048. /***/ "../../node_modules/lodash/omitBy.js":
  49049. /*!*******************************************!*\
  49050. !*** ../../node_modules/lodash/omitBy.js ***!
  49051. \*******************************************/
  49052. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  49053. var baseIteratee = __webpack_require__(/*! ./_baseIteratee */ "../../node_modules/lodash/_baseIteratee.js"),
  49054. negate = __webpack_require__(/*! ./negate */ "../../node_modules/lodash/negate.js"),
  49055. pickBy = __webpack_require__(/*! ./pickBy */ "../../node_modules/lodash/pickBy.js");
  49056. /**
  49057. * The opposite of `_.pickBy`; this method creates an object composed of
  49058. * the own and inherited enumerable string keyed properties of `object` that
  49059. * `predicate` doesn't return truthy for. The predicate is invoked with two
  49060. * arguments: (value, key).
  49061. *
  49062. * @static
  49063. * @memberOf _
  49064. * @since 4.0.0
  49065. * @category Object
  49066. * @param {Object} object The source object.
  49067. * @param {Function} [predicate=_.identity] The function invoked per property.
  49068. * @returns {Object} Returns the new object.
  49069. * @example
  49070. *
  49071. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  49072. *
  49073. * _.omitBy(object, _.isNumber);
  49074. * // => { 'b': '2' }
  49075. */
  49076. function omitBy(object, predicate) {
  49077. return pickBy(object, negate(baseIteratee(predicate)));
  49078. }
  49079. module.exports = omitBy;
  49080. /***/ }),
  49081. /***/ "../../node_modules/lodash/pickBy.js":
  49082. /*!*******************************************!*\
  49083. !*** ../../node_modules/lodash/pickBy.js ***!
  49084. \*******************************************/
  49085. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  49086. var arrayMap = __webpack_require__(/*! ./_arrayMap */ "../../node_modules/lodash/_arrayMap.js"),
  49087. baseIteratee = __webpack_require__(/*! ./_baseIteratee */ "../../node_modules/lodash/_baseIteratee.js"),
  49088. basePickBy = __webpack_require__(/*! ./_basePickBy */ "../../node_modules/lodash/_basePickBy.js"),
  49089. getAllKeysIn = __webpack_require__(/*! ./_getAllKeysIn */ "../../node_modules/lodash/_getAllKeysIn.js");
  49090. /**
  49091. * Creates an object composed of the `object` properties `predicate` returns
  49092. * truthy for. The predicate is invoked with two arguments: (value, key).
  49093. *
  49094. * @static
  49095. * @memberOf _
  49096. * @since 4.0.0
  49097. * @category Object
  49098. * @param {Object} object The source object.
  49099. * @param {Function} [predicate=_.identity] The function invoked per property.
  49100. * @returns {Object} Returns the new object.
  49101. * @example
  49102. *
  49103. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  49104. *
  49105. * _.pickBy(object, _.isNumber);
  49106. * // => { 'a': 1, 'c': 3 }
  49107. */
  49108. function pickBy(object, predicate) {
  49109. if (object == null) {
  49110. return {};
  49111. }
  49112. var props = arrayMap(getAllKeysIn(object), function(prop) {
  49113. return [prop];
  49114. });
  49115. predicate = baseIteratee(predicate);
  49116. return basePickBy(object, props, function(value, path) {
  49117. return predicate(value, path[0]);
  49118. });
  49119. }
  49120. module.exports = pickBy;
  49121. /***/ }),
  49122. /***/ "../../node_modules/lodash/property.js":
  49123. /*!*********************************************!*\
  49124. !*** ../../node_modules/lodash/property.js ***!
  49125. \*********************************************/
  49126. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  49127. var baseProperty = __webpack_require__(/*! ./_baseProperty */ "../../node_modules/lodash/_baseProperty.js"),
  49128. basePropertyDeep = __webpack_require__(/*! ./_basePropertyDeep */ "../../node_modules/lodash/_basePropertyDeep.js"),
  49129. isKey = __webpack_require__(/*! ./_isKey */ "../../node_modules/lodash/_isKey.js"),
  49130. toKey = __webpack_require__(/*! ./_toKey */ "../../node_modules/lodash/_toKey.js");
  49131. /**
  49132. * Creates a function that returns the value at `path` of a given object.
  49133. *
  49134. * @static
  49135. * @memberOf _
  49136. * @since 2.4.0
  49137. * @category Util
  49138. * @param {Array|string} path The path of the property to get.
  49139. * @returns {Function} Returns the new accessor function.
  49140. * @example
  49141. *
  49142. * var objects = [
  49143. * { 'a': { 'b': 2 } },
  49144. * { 'a': { 'b': 1 } }
  49145. * ];
  49146. *
  49147. * _.map(objects, _.property('a.b'));
  49148. * // => [2, 1]
  49149. *
  49150. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  49151. * // => [1, 2]
  49152. */
  49153. function property(path) {
  49154. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  49155. }
  49156. module.exports = property;
  49157. /***/ }),
  49158. /***/ "../../node_modules/lodash/stubArray.js":
  49159. /*!**********************************************!*\
  49160. !*** ../../node_modules/lodash/stubArray.js ***!
  49161. \**********************************************/
  49162. /***/ ((module) => {
  49163. /**
  49164. * This method returns a new empty array.
  49165. *
  49166. * @static
  49167. * @memberOf _
  49168. * @since 4.13.0
  49169. * @category Util
  49170. * @returns {Array} Returns the new empty array.
  49171. * @example
  49172. *
  49173. * var arrays = _.times(2, _.stubArray);
  49174. *
  49175. * console.log(arrays);
  49176. * // => [[], []]
  49177. *
  49178. * console.log(arrays[0] === arrays[1]);
  49179. * // => false
  49180. */
  49181. function stubArray() {
  49182. return [];
  49183. }
  49184. module.exports = stubArray;
  49185. /***/ }),
  49186. /***/ "../../node_modules/lodash/stubFalse.js":
  49187. /*!**********************************************!*\
  49188. !*** ../../node_modules/lodash/stubFalse.js ***!
  49189. \**********************************************/
  49190. /***/ ((module) => {
  49191. /**
  49192. * This method returns `false`.
  49193. *
  49194. * @static
  49195. * @memberOf _
  49196. * @since 4.13.0
  49197. * @category Util
  49198. * @returns {boolean} Returns `false`.
  49199. * @example
  49200. *
  49201. * _.times(2, _.stubFalse);
  49202. * // => [false, false]
  49203. */
  49204. function stubFalse() {
  49205. return false;
  49206. }
  49207. module.exports = stubFalse;
  49208. /***/ }),
  49209. /***/ "../../node_modules/lodash/toString.js":
  49210. /*!*********************************************!*\
  49211. !*** ../../node_modules/lodash/toString.js ***!
  49212. \*********************************************/
  49213. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  49214. var baseToString = __webpack_require__(/*! ./_baseToString */ "../../node_modules/lodash/_baseToString.js");
  49215. /**
  49216. * Converts `value` to a string. An empty string is returned for `null`
  49217. * and `undefined` values. The sign of `-0` is preserved.
  49218. *
  49219. * @static
  49220. * @memberOf _
  49221. * @since 4.0.0
  49222. * @category Lang
  49223. * @param {*} value The value to convert.
  49224. * @returns {string} Returns the converted string.
  49225. * @example
  49226. *
  49227. * _.toString(null);
  49228. * // => ''
  49229. *
  49230. * _.toString(-0);
  49231. * // => '-0'
  49232. *
  49233. * _.toString([1, 2, 3]);
  49234. * // => '1,2,3'
  49235. */
  49236. function toString(value) {
  49237. return value == null ? '' : baseToString(value);
  49238. }
  49239. module.exports = toString;
  49240. /***/ }),
  49241. /***/ "../../node_modules/md5.js/index.js":
  49242. /*!******************************************!*\
  49243. !*** ../../node_modules/md5.js/index.js ***!
  49244. \******************************************/
  49245. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  49246. "use strict";
  49247. var inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js")
  49248. var HashBase = __webpack_require__(/*! hash-base */ "../../node_modules/hash-base/index.js")
  49249. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  49250. var ARRAY16 = new Array(16)
  49251. function MD5 () {
  49252. HashBase.call(this, 64)
  49253. // state
  49254. this._a = 0x67452301
  49255. this._b = 0xefcdab89
  49256. this._c = 0x98badcfe
  49257. this._d = 0x10325476
  49258. }
  49259. inherits(MD5, HashBase)
  49260. MD5.prototype._update = function () {
  49261. var M = ARRAY16
  49262. for (var i = 0; i < 16; ++i) M[i] = this._block.readInt32LE(i * 4)
  49263. var a = this._a
  49264. var b = this._b
  49265. var c = this._c
  49266. var d = this._d
  49267. a = fnF(a, b, c, d, M[0], 0xd76aa478, 7)
  49268. d = fnF(d, a, b, c, M[1], 0xe8c7b756, 12)
  49269. c = fnF(c, d, a, b, M[2], 0x242070db, 17)
  49270. b = fnF(b, c, d, a, M[3], 0xc1bdceee, 22)
  49271. a = fnF(a, b, c, d, M[4], 0xf57c0faf, 7)
  49272. d = fnF(d, a, b, c, M[5], 0x4787c62a, 12)
  49273. c = fnF(c, d, a, b, M[6], 0xa8304613, 17)
  49274. b = fnF(b, c, d, a, M[7], 0xfd469501, 22)
  49275. a = fnF(a, b, c, d, M[8], 0x698098d8, 7)
  49276. d = fnF(d, a, b, c, M[9], 0x8b44f7af, 12)
  49277. c = fnF(c, d, a, b, M[10], 0xffff5bb1, 17)
  49278. b = fnF(b, c, d, a, M[11], 0x895cd7be, 22)
  49279. a = fnF(a, b, c, d, M[12], 0x6b901122, 7)
  49280. d = fnF(d, a, b, c, M[13], 0xfd987193, 12)
  49281. c = fnF(c, d, a, b, M[14], 0xa679438e, 17)
  49282. b = fnF(b, c, d, a, M[15], 0x49b40821, 22)
  49283. a = fnG(a, b, c, d, M[1], 0xf61e2562, 5)
  49284. d = fnG(d, a, b, c, M[6], 0xc040b340, 9)
  49285. c = fnG(c, d, a, b, M[11], 0x265e5a51, 14)
  49286. b = fnG(b, c, d, a, M[0], 0xe9b6c7aa, 20)
  49287. a = fnG(a, b, c, d, M[5], 0xd62f105d, 5)
  49288. d = fnG(d, a, b, c, M[10], 0x02441453, 9)
  49289. c = fnG(c, d, a, b, M[15], 0xd8a1e681, 14)
  49290. b = fnG(b, c, d, a, M[4], 0xe7d3fbc8, 20)
  49291. a = fnG(a, b, c, d, M[9], 0x21e1cde6, 5)
  49292. d = fnG(d, a, b, c, M[14], 0xc33707d6, 9)
  49293. c = fnG(c, d, a, b, M[3], 0xf4d50d87, 14)
  49294. b = fnG(b, c, d, a, M[8], 0x455a14ed, 20)
  49295. a = fnG(a, b, c, d, M[13], 0xa9e3e905, 5)
  49296. d = fnG(d, a, b, c, M[2], 0xfcefa3f8, 9)
  49297. c = fnG(c, d, a, b, M[7], 0x676f02d9, 14)
  49298. b = fnG(b, c, d, a, M[12], 0x8d2a4c8a, 20)
  49299. a = fnH(a, b, c, d, M[5], 0xfffa3942, 4)
  49300. d = fnH(d, a, b, c, M[8], 0x8771f681, 11)
  49301. c = fnH(c, d, a, b, M[11], 0x6d9d6122, 16)
  49302. b = fnH(b, c, d, a, M[14], 0xfde5380c, 23)
  49303. a = fnH(a, b, c, d, M[1], 0xa4beea44, 4)
  49304. d = fnH(d, a, b, c, M[4], 0x4bdecfa9, 11)
  49305. c = fnH(c, d, a, b, M[7], 0xf6bb4b60, 16)
  49306. b = fnH(b, c, d, a, M[10], 0xbebfbc70, 23)
  49307. a = fnH(a, b, c, d, M[13], 0x289b7ec6, 4)
  49308. d = fnH(d, a, b, c, M[0], 0xeaa127fa, 11)
  49309. c = fnH(c, d, a, b, M[3], 0xd4ef3085, 16)
  49310. b = fnH(b, c, d, a, M[6], 0x04881d05, 23)
  49311. a = fnH(a, b, c, d, M[9], 0xd9d4d039, 4)
  49312. d = fnH(d, a, b, c, M[12], 0xe6db99e5, 11)
  49313. c = fnH(c, d, a, b, M[15], 0x1fa27cf8, 16)
  49314. b = fnH(b, c, d, a, M[2], 0xc4ac5665, 23)
  49315. a = fnI(a, b, c, d, M[0], 0xf4292244, 6)
  49316. d = fnI(d, a, b, c, M[7], 0x432aff97, 10)
  49317. c = fnI(c, d, a, b, M[14], 0xab9423a7, 15)
  49318. b = fnI(b, c, d, a, M[5], 0xfc93a039, 21)
  49319. a = fnI(a, b, c, d, M[12], 0x655b59c3, 6)
  49320. d = fnI(d, a, b, c, M[3], 0x8f0ccc92, 10)
  49321. c = fnI(c, d, a, b, M[10], 0xffeff47d, 15)
  49322. b = fnI(b, c, d, a, M[1], 0x85845dd1, 21)
  49323. a = fnI(a, b, c, d, M[8], 0x6fa87e4f, 6)
  49324. d = fnI(d, a, b, c, M[15], 0xfe2ce6e0, 10)
  49325. c = fnI(c, d, a, b, M[6], 0xa3014314, 15)
  49326. b = fnI(b, c, d, a, M[13], 0x4e0811a1, 21)
  49327. a = fnI(a, b, c, d, M[4], 0xf7537e82, 6)
  49328. d = fnI(d, a, b, c, M[11], 0xbd3af235, 10)
  49329. c = fnI(c, d, a, b, M[2], 0x2ad7d2bb, 15)
  49330. b = fnI(b, c, d, a, M[9], 0xeb86d391, 21)
  49331. this._a = (this._a + a) | 0
  49332. this._b = (this._b + b) | 0
  49333. this._c = (this._c + c) | 0
  49334. this._d = (this._d + d) | 0
  49335. }
  49336. MD5.prototype._digest = function () {
  49337. // create padding and handle blocks
  49338. this._block[this._blockOffset++] = 0x80
  49339. if (this._blockOffset > 56) {
  49340. this._block.fill(0, this._blockOffset, 64)
  49341. this._update()
  49342. this._blockOffset = 0
  49343. }
  49344. this._block.fill(0, this._blockOffset, 56)
  49345. this._block.writeUInt32LE(this._length[0], 56)
  49346. this._block.writeUInt32LE(this._length[1], 60)
  49347. this._update()
  49348. // produce result
  49349. var buffer = Buffer.allocUnsafe(16)
  49350. buffer.writeInt32LE(this._a, 0)
  49351. buffer.writeInt32LE(this._b, 4)
  49352. buffer.writeInt32LE(this._c, 8)
  49353. buffer.writeInt32LE(this._d, 12)
  49354. return buffer
  49355. }
  49356. function rotl (x, n) {
  49357. return (x << n) | (x >>> (32 - n))
  49358. }
  49359. function fnF (a, b, c, d, m, k, s) {
  49360. return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + b) | 0
  49361. }
  49362. function fnG (a, b, c, d, m, k, s) {
  49363. return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + b) | 0
  49364. }
  49365. function fnH (a, b, c, d, m, k, s) {
  49366. return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + b) | 0
  49367. }
  49368. function fnI (a, b, c, d, m, k, s) {
  49369. return (rotl((a + ((c ^ (b | (~d)))) + m + k) | 0, s) + b) | 0
  49370. }
  49371. module.exports = MD5
  49372. /***/ }),
  49373. /***/ "../../node_modules/miller-rabin/lib/mr.js":
  49374. /*!*************************************************!*\
  49375. !*** ../../node_modules/miller-rabin/lib/mr.js ***!
  49376. \*************************************************/
  49377. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  49378. var bn = __webpack_require__(/*! bn.js */ "../../node_modules/diffie-hellman/node_modules/bn.js/lib/bn.js");
  49379. var brorand = __webpack_require__(/*! brorand */ "../../node_modules/brorand/index.js");
  49380. function MillerRabin(rand) {
  49381. this.rand = rand || new brorand.Rand();
  49382. }
  49383. module.exports = MillerRabin;
  49384. MillerRabin.create = function create(rand) {
  49385. return new MillerRabin(rand);
  49386. };
  49387. MillerRabin.prototype._randbelow = function _randbelow(n) {
  49388. var len = n.bitLength();
  49389. var min_bytes = Math.ceil(len / 8);
  49390. // Generage random bytes until a number less than n is found.
  49391. // This ensures that 0..n-1 have an equal probability of being selected.
  49392. do
  49393. var a = new bn(this.rand.generate(min_bytes));
  49394. while (a.cmp(n) >= 0);
  49395. return a;
  49396. };
  49397. MillerRabin.prototype._randrange = function _randrange(start, stop) {
  49398. // Generate a random number greater than or equal to start and less than stop.
  49399. var size = stop.sub(start);
  49400. return start.add(this._randbelow(size));
  49401. };
  49402. MillerRabin.prototype.test = function test(n, k, cb) {
  49403. var len = n.bitLength();
  49404. var red = bn.mont(n);
  49405. var rone = new bn(1).toRed(red);
  49406. if (!k)
  49407. k = Math.max(1, (len / 48) | 0);
  49408. // Find d and s, (n - 1) = (2 ^ s) * d;
  49409. var n1 = n.subn(1);
  49410. for (var s = 0; !n1.testn(s); s++) {}
  49411. var d = n.shrn(s);
  49412. var rn1 = n1.toRed(red);
  49413. var prime = true;
  49414. for (; k > 0; k--) {
  49415. var a = this._randrange(new bn(2), n1);
  49416. if (cb)
  49417. cb(a);
  49418. var x = a.toRed(red).redPow(d);
  49419. if (x.cmp(rone) === 0 || x.cmp(rn1) === 0)
  49420. continue;
  49421. for (var i = 1; i < s; i++) {
  49422. x = x.redSqr();
  49423. if (x.cmp(rone) === 0)
  49424. return false;
  49425. if (x.cmp(rn1) === 0)
  49426. break;
  49427. }
  49428. if (i === s)
  49429. return false;
  49430. }
  49431. return prime;
  49432. };
  49433. MillerRabin.prototype.getDivisor = function getDivisor(n, k) {
  49434. var len = n.bitLength();
  49435. var red = bn.mont(n);
  49436. var rone = new bn(1).toRed(red);
  49437. if (!k)
  49438. k = Math.max(1, (len / 48) | 0);
  49439. // Find d and s, (n - 1) = (2 ^ s) * d;
  49440. var n1 = n.subn(1);
  49441. for (var s = 0; !n1.testn(s); s++) {}
  49442. var d = n.shrn(s);
  49443. var rn1 = n1.toRed(red);
  49444. for (; k > 0; k--) {
  49445. var a = this._randrange(new bn(2), n1);
  49446. var g = n.gcd(a);
  49447. if (g.cmpn(1) !== 0)
  49448. return g;
  49449. var x = a.toRed(red).redPow(d);
  49450. if (x.cmp(rone) === 0 || x.cmp(rn1) === 0)
  49451. continue;
  49452. for (var i = 1; i < s; i++) {
  49453. x = x.redSqr();
  49454. if (x.cmp(rone) === 0)
  49455. return x.fromRed().subn(1).gcd(n);
  49456. if (x.cmp(rn1) === 0)
  49457. break;
  49458. }
  49459. if (i === s) {
  49460. x = x.redSqr();
  49461. return x.fromRed().subn(1).gcd(n);
  49462. }
  49463. }
  49464. return false;
  49465. };
  49466. /***/ }),
  49467. /***/ "../../node_modules/minimalistic-assert/index.js":
  49468. /*!*******************************************************!*\
  49469. !*** ../../node_modules/minimalistic-assert/index.js ***!
  49470. \*******************************************************/
  49471. /***/ ((module) => {
  49472. module.exports = assert;
  49473. function assert(val, msg) {
  49474. if (!val)
  49475. throw new Error(msg || 'Assertion failed');
  49476. }
  49477. assert.equal = function assertEqual(l, r, msg) {
  49478. if (l != r)
  49479. throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
  49480. };
  49481. /***/ }),
  49482. /***/ "../../node_modules/minimalistic-crypto-utils/lib/utils.js":
  49483. /*!*****************************************************************!*\
  49484. !*** ../../node_modules/minimalistic-crypto-utils/lib/utils.js ***!
  49485. \*****************************************************************/
  49486. /***/ ((__unused_webpack_module, exports) => {
  49487. "use strict";
  49488. var utils = exports;
  49489. function toArray(msg, enc) {
  49490. if (Array.isArray(msg))
  49491. return msg.slice();
  49492. if (!msg)
  49493. return [];
  49494. var res = [];
  49495. if (typeof msg !== 'string') {
  49496. for (var i = 0; i < msg.length; i++)
  49497. res[i] = msg[i] | 0;
  49498. return res;
  49499. }
  49500. if (enc === 'hex') {
  49501. msg = msg.replace(/[^a-z0-9]+/ig, '');
  49502. if (msg.length % 2 !== 0)
  49503. msg = '0' + msg;
  49504. for (var i = 0; i < msg.length; i += 2)
  49505. res.push(parseInt(msg[i] + msg[i + 1], 16));
  49506. } else {
  49507. for (var i = 0; i < msg.length; i++) {
  49508. var c = msg.charCodeAt(i);
  49509. var hi = c >> 8;
  49510. var lo = c & 0xff;
  49511. if (hi)
  49512. res.push(hi, lo);
  49513. else
  49514. res.push(lo);
  49515. }
  49516. }
  49517. return res;
  49518. }
  49519. utils.toArray = toArray;
  49520. function zero2(word) {
  49521. if (word.length === 1)
  49522. return '0' + word;
  49523. else
  49524. return word;
  49525. }
  49526. utils.zero2 = zero2;
  49527. function toHex(msg) {
  49528. var res = '';
  49529. for (var i = 0; i < msg.length; i++)
  49530. res += zero2(msg[i].toString(16));
  49531. return res;
  49532. }
  49533. utils.toHex = toHex;
  49534. utils.encode = function encode(arr, enc) {
  49535. if (enc === 'hex')
  49536. return toHex(arr);
  49537. else
  49538. return arr;
  49539. };
  49540. /***/ }),
  49541. /***/ "../../node_modules/object-is/implementation.js":
  49542. /*!******************************************************!*\
  49543. !*** ../../node_modules/object-is/implementation.js ***!
  49544. \******************************************************/
  49545. /***/ ((module) => {
  49546. "use strict";
  49547. var numberIsNaN = function (value) {
  49548. return value !== value;
  49549. };
  49550. module.exports = function is(a, b) {
  49551. if (a === 0 && b === 0) {
  49552. return 1 / a === 1 / b;
  49553. }
  49554. if (a === b) {
  49555. return true;
  49556. }
  49557. if (numberIsNaN(a) && numberIsNaN(b)) {
  49558. return true;
  49559. }
  49560. return false;
  49561. };
  49562. /***/ }),
  49563. /***/ "../../node_modules/object-is/index.js":
  49564. /*!*********************************************!*\
  49565. !*** ../../node_modules/object-is/index.js ***!
  49566. \*********************************************/
  49567. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  49568. "use strict";
  49569. var define = __webpack_require__(/*! define-properties */ "../../node_modules/define-properties/index.js");
  49570. var callBind = __webpack_require__(/*! call-bind */ "../../node_modules/call-bind/index.js");
  49571. var implementation = __webpack_require__(/*! ./implementation */ "../../node_modules/object-is/implementation.js");
  49572. var getPolyfill = __webpack_require__(/*! ./polyfill */ "../../node_modules/object-is/polyfill.js");
  49573. var shim = __webpack_require__(/*! ./shim */ "../../node_modules/object-is/shim.js");
  49574. var polyfill = callBind(getPolyfill(), Object);
  49575. define(polyfill, {
  49576. getPolyfill: getPolyfill,
  49577. implementation: implementation,
  49578. shim: shim
  49579. });
  49580. module.exports = polyfill;
  49581. /***/ }),
  49582. /***/ "../../node_modules/object-is/polyfill.js":
  49583. /*!************************************************!*\
  49584. !*** ../../node_modules/object-is/polyfill.js ***!
  49585. \************************************************/
  49586. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  49587. "use strict";
  49588. var implementation = __webpack_require__(/*! ./implementation */ "../../node_modules/object-is/implementation.js");
  49589. module.exports = function getPolyfill() {
  49590. return typeof Object.is === 'function' ? Object.is : implementation;
  49591. };
  49592. /***/ }),
  49593. /***/ "../../node_modules/object-is/shim.js":
  49594. /*!********************************************!*\
  49595. !*** ../../node_modules/object-is/shim.js ***!
  49596. \********************************************/
  49597. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  49598. "use strict";
  49599. var getPolyfill = __webpack_require__(/*! ./polyfill */ "../../node_modules/object-is/polyfill.js");
  49600. var define = __webpack_require__(/*! define-properties */ "../../node_modules/define-properties/index.js");
  49601. module.exports = function shimObjectIs() {
  49602. var polyfill = getPolyfill();
  49603. define(Object, { is: polyfill }, {
  49604. is: function testObjectIs() {
  49605. return Object.is !== polyfill;
  49606. }
  49607. });
  49608. return polyfill;
  49609. };
  49610. /***/ }),
  49611. /***/ "../../node_modules/object-keys/implementation.js":
  49612. /*!********************************************************!*\
  49613. !*** ../../node_modules/object-keys/implementation.js ***!
  49614. \********************************************************/
  49615. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  49616. "use strict";
  49617. var keysShim;
  49618. if (!Object.keys) {
  49619. // modified from https://github.com/es-shims/es5-shim
  49620. var has = Object.prototype.hasOwnProperty;
  49621. var toStr = Object.prototype.toString;
  49622. var isArgs = __webpack_require__(/*! ./isArguments */ "../../node_modules/object-keys/isArguments.js"); // eslint-disable-line global-require
  49623. var isEnumerable = Object.prototype.propertyIsEnumerable;
  49624. var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
  49625. var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
  49626. var dontEnums = [
  49627. 'toString',
  49628. 'toLocaleString',
  49629. 'valueOf',
  49630. 'hasOwnProperty',
  49631. 'isPrototypeOf',
  49632. 'propertyIsEnumerable',
  49633. 'constructor'
  49634. ];
  49635. var equalsConstructorPrototype = function (o) {
  49636. var ctor = o.constructor;
  49637. return ctor && ctor.prototype === o;
  49638. };
  49639. var excludedKeys = {
  49640. $applicationCache: true,
  49641. $console: true,
  49642. $external: true,
  49643. $frame: true,
  49644. $frameElement: true,
  49645. $frames: true,
  49646. $innerHeight: true,
  49647. $innerWidth: true,
  49648. $onmozfullscreenchange: true,
  49649. $onmozfullscreenerror: true,
  49650. $outerHeight: true,
  49651. $outerWidth: true,
  49652. $pageXOffset: true,
  49653. $pageYOffset: true,
  49654. $parent: true,
  49655. $scrollLeft: true,
  49656. $scrollTop: true,
  49657. $scrollX: true,
  49658. $scrollY: true,
  49659. $self: true,
  49660. $webkitIndexedDB: true,
  49661. $webkitStorageInfo: true,
  49662. $window: true
  49663. };
  49664. var hasAutomationEqualityBug = (function () {
  49665. /* global window */
  49666. if (typeof window === 'undefined') { return false; }
  49667. for (var k in window) {
  49668. try {
  49669. if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
  49670. try {
  49671. equalsConstructorPrototype(window[k]);
  49672. } catch (e) {
  49673. return true;
  49674. }
  49675. }
  49676. } catch (e) {
  49677. return true;
  49678. }
  49679. }
  49680. return false;
  49681. }());
  49682. var equalsConstructorPrototypeIfNotBuggy = function (o) {
  49683. /* global window */
  49684. if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
  49685. return equalsConstructorPrototype(o);
  49686. }
  49687. try {
  49688. return equalsConstructorPrototype(o);
  49689. } catch (e) {
  49690. return false;
  49691. }
  49692. };
  49693. keysShim = function keys(object) {
  49694. var isObject = object !== null && typeof object === 'object';
  49695. var isFunction = toStr.call(object) === '[object Function]';
  49696. var isArguments = isArgs(object);
  49697. var isString = isObject && toStr.call(object) === '[object String]';
  49698. var theKeys = [];
  49699. if (!isObject && !isFunction && !isArguments) {
  49700. throw new TypeError('Object.keys called on a non-object');
  49701. }
  49702. var skipProto = hasProtoEnumBug && isFunction;
  49703. if (isString && object.length > 0 && !has.call(object, 0)) {
  49704. for (var i = 0; i < object.length; ++i) {
  49705. theKeys.push(String(i));
  49706. }
  49707. }
  49708. if (isArguments && object.length > 0) {
  49709. for (var j = 0; j < object.length; ++j) {
  49710. theKeys.push(String(j));
  49711. }
  49712. } else {
  49713. for (var name in object) {
  49714. if (!(skipProto && name === 'prototype') && has.call(object, name)) {
  49715. theKeys.push(String(name));
  49716. }
  49717. }
  49718. }
  49719. if (hasDontEnumBug) {
  49720. var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
  49721. for (var k = 0; k < dontEnums.length; ++k) {
  49722. if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
  49723. theKeys.push(dontEnums[k]);
  49724. }
  49725. }
  49726. }
  49727. return theKeys;
  49728. };
  49729. }
  49730. module.exports = keysShim;
  49731. /***/ }),
  49732. /***/ "../../node_modules/object-keys/index.js":
  49733. /*!***********************************************!*\
  49734. !*** ../../node_modules/object-keys/index.js ***!
  49735. \***********************************************/
  49736. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  49737. "use strict";
  49738. var slice = Array.prototype.slice;
  49739. var isArgs = __webpack_require__(/*! ./isArguments */ "../../node_modules/object-keys/isArguments.js");
  49740. var origKeys = Object.keys;
  49741. var keysShim = origKeys ? function keys(o) { return origKeys(o); } : __webpack_require__(/*! ./implementation */ "../../node_modules/object-keys/implementation.js");
  49742. var originalKeys = Object.keys;
  49743. keysShim.shim = function shimObjectKeys() {
  49744. if (Object.keys) {
  49745. var keysWorksWithArguments = (function () {
  49746. // Safari 5.0 bug
  49747. var args = Object.keys(arguments);
  49748. return args && args.length === arguments.length;
  49749. }(1, 2));
  49750. if (!keysWorksWithArguments) {
  49751. Object.keys = function keys(object) { // eslint-disable-line func-name-matching
  49752. if (isArgs(object)) {
  49753. return originalKeys(slice.call(object));
  49754. }
  49755. return originalKeys(object);
  49756. };
  49757. }
  49758. } else {
  49759. Object.keys = keysShim;
  49760. }
  49761. return Object.keys || keysShim;
  49762. };
  49763. module.exports = keysShim;
  49764. /***/ }),
  49765. /***/ "../../node_modules/object-keys/isArguments.js":
  49766. /*!*****************************************************!*\
  49767. !*** ../../node_modules/object-keys/isArguments.js ***!
  49768. \*****************************************************/
  49769. /***/ ((module) => {
  49770. "use strict";
  49771. var toStr = Object.prototype.toString;
  49772. module.exports = function isArguments(value) {
  49773. var str = toStr.call(value);
  49774. var isArgs = str === '[object Arguments]';
  49775. if (!isArgs) {
  49776. isArgs = str !== '[object Array]' &&
  49777. value !== null &&
  49778. typeof value === 'object' &&
  49779. typeof value.length === 'number' &&
  49780. value.length >= 0 &&
  49781. toStr.call(value.callee) === '[object Function]';
  49782. }
  49783. return isArgs;
  49784. };
  49785. /***/ }),
  49786. /***/ "../../node_modules/parse-asn1/asn1.js":
  49787. /*!*********************************************!*\
  49788. !*** ../../node_modules/parse-asn1/asn1.js ***!
  49789. \*********************************************/
  49790. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  49791. "use strict";
  49792. // from https://github.com/indutny/self-signed/blob/gh-pages/lib/asn1.js
  49793. // Fedor, you are amazing.
  49794. var asn1 = __webpack_require__(/*! asn1.js */ "../../node_modules/asn1.js/lib/asn1.js")
  49795. exports.certificate = __webpack_require__(/*! ./certificate */ "../../node_modules/parse-asn1/certificate.js")
  49796. var RSAPrivateKey = asn1.define('RSAPrivateKey', function () {
  49797. this.seq().obj(
  49798. this.key('version').int(),
  49799. this.key('modulus').int(),
  49800. this.key('publicExponent').int(),
  49801. this.key('privateExponent').int(),
  49802. this.key('prime1').int(),
  49803. this.key('prime2').int(),
  49804. this.key('exponent1').int(),
  49805. this.key('exponent2').int(),
  49806. this.key('coefficient').int()
  49807. )
  49808. })
  49809. exports.RSAPrivateKey = RSAPrivateKey
  49810. var RSAPublicKey = asn1.define('RSAPublicKey', function () {
  49811. this.seq().obj(
  49812. this.key('modulus').int(),
  49813. this.key('publicExponent').int()
  49814. )
  49815. })
  49816. exports.RSAPublicKey = RSAPublicKey
  49817. var PublicKey = asn1.define('SubjectPublicKeyInfo', function () {
  49818. this.seq().obj(
  49819. this.key('algorithm').use(AlgorithmIdentifier),
  49820. this.key('subjectPublicKey').bitstr()
  49821. )
  49822. })
  49823. exports.PublicKey = PublicKey
  49824. var AlgorithmIdentifier = asn1.define('AlgorithmIdentifier', function () {
  49825. this.seq().obj(
  49826. this.key('algorithm').objid(),
  49827. this.key('none').null_().optional(),
  49828. this.key('curve').objid().optional(),
  49829. this.key('params').seq().obj(
  49830. this.key('p').int(),
  49831. this.key('q').int(),
  49832. this.key('g').int()
  49833. ).optional()
  49834. )
  49835. })
  49836. var PrivateKeyInfo = asn1.define('PrivateKeyInfo', function () {
  49837. this.seq().obj(
  49838. this.key('version').int(),
  49839. this.key('algorithm').use(AlgorithmIdentifier),
  49840. this.key('subjectPrivateKey').octstr()
  49841. )
  49842. })
  49843. exports.PrivateKey = PrivateKeyInfo
  49844. var EncryptedPrivateKeyInfo = asn1.define('EncryptedPrivateKeyInfo', function () {
  49845. this.seq().obj(
  49846. this.key('algorithm').seq().obj(
  49847. this.key('id').objid(),
  49848. this.key('decrypt').seq().obj(
  49849. this.key('kde').seq().obj(
  49850. this.key('id').objid(),
  49851. this.key('kdeparams').seq().obj(
  49852. this.key('salt').octstr(),
  49853. this.key('iters').int()
  49854. )
  49855. ),
  49856. this.key('cipher').seq().obj(
  49857. this.key('algo').objid(),
  49858. this.key('iv').octstr()
  49859. )
  49860. )
  49861. ),
  49862. this.key('subjectPrivateKey').octstr()
  49863. )
  49864. })
  49865. exports.EncryptedPrivateKey = EncryptedPrivateKeyInfo
  49866. var DSAPrivateKey = asn1.define('DSAPrivateKey', function () {
  49867. this.seq().obj(
  49868. this.key('version').int(),
  49869. this.key('p').int(),
  49870. this.key('q').int(),
  49871. this.key('g').int(),
  49872. this.key('pub_key').int(),
  49873. this.key('priv_key').int()
  49874. )
  49875. })
  49876. exports.DSAPrivateKey = DSAPrivateKey
  49877. exports.DSAparam = asn1.define('DSAparam', function () {
  49878. this.int()
  49879. })
  49880. var ECPrivateKey = asn1.define('ECPrivateKey', function () {
  49881. this.seq().obj(
  49882. this.key('version').int(),
  49883. this.key('privateKey').octstr(),
  49884. this.key('parameters').optional().explicit(0).use(ECParameters),
  49885. this.key('publicKey').optional().explicit(1).bitstr()
  49886. )
  49887. })
  49888. exports.ECPrivateKey = ECPrivateKey
  49889. var ECParameters = asn1.define('ECParameters', function () {
  49890. this.choice({
  49891. namedCurve: this.objid()
  49892. })
  49893. })
  49894. exports.signature = asn1.define('signature', function () {
  49895. this.seq().obj(
  49896. this.key('r').int(),
  49897. this.key('s').int()
  49898. )
  49899. })
  49900. /***/ }),
  49901. /***/ "../../node_modules/parse-asn1/certificate.js":
  49902. /*!****************************************************!*\
  49903. !*** ../../node_modules/parse-asn1/certificate.js ***!
  49904. \****************************************************/
  49905. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  49906. "use strict";
  49907. // from https://github.com/Rantanen/node-dtls/blob/25a7dc861bda38cfeac93a723500eea4f0ac2e86/Certificate.js
  49908. // thanks to @Rantanen
  49909. var asn = __webpack_require__(/*! asn1.js */ "../../node_modules/asn1.js/lib/asn1.js")
  49910. var Time = asn.define('Time', function () {
  49911. this.choice({
  49912. utcTime: this.utctime(),
  49913. generalTime: this.gentime()
  49914. })
  49915. })
  49916. var AttributeTypeValue = asn.define('AttributeTypeValue', function () {
  49917. this.seq().obj(
  49918. this.key('type').objid(),
  49919. this.key('value').any()
  49920. )
  49921. })
  49922. var AlgorithmIdentifier = asn.define('AlgorithmIdentifier', function () {
  49923. this.seq().obj(
  49924. this.key('algorithm').objid(),
  49925. this.key('parameters').optional(),
  49926. this.key('curve').objid().optional()
  49927. )
  49928. })
  49929. var SubjectPublicKeyInfo = asn.define('SubjectPublicKeyInfo', function () {
  49930. this.seq().obj(
  49931. this.key('algorithm').use(AlgorithmIdentifier),
  49932. this.key('subjectPublicKey').bitstr()
  49933. )
  49934. })
  49935. var RelativeDistinguishedName = asn.define('RelativeDistinguishedName', function () {
  49936. this.setof(AttributeTypeValue)
  49937. })
  49938. var RDNSequence = asn.define('RDNSequence', function () {
  49939. this.seqof(RelativeDistinguishedName)
  49940. })
  49941. var Name = asn.define('Name', function () {
  49942. this.choice({
  49943. rdnSequence: this.use(RDNSequence)
  49944. })
  49945. })
  49946. var Validity = asn.define('Validity', function () {
  49947. this.seq().obj(
  49948. this.key('notBefore').use(Time),
  49949. this.key('notAfter').use(Time)
  49950. )
  49951. })
  49952. var Extension = asn.define('Extension', function () {
  49953. this.seq().obj(
  49954. this.key('extnID').objid(),
  49955. this.key('critical').bool().def(false),
  49956. this.key('extnValue').octstr()
  49957. )
  49958. })
  49959. var TBSCertificate = asn.define('TBSCertificate', function () {
  49960. this.seq().obj(
  49961. this.key('version').explicit(0).int().optional(),
  49962. this.key('serialNumber').int(),
  49963. this.key('signature').use(AlgorithmIdentifier),
  49964. this.key('issuer').use(Name),
  49965. this.key('validity').use(Validity),
  49966. this.key('subject').use(Name),
  49967. this.key('subjectPublicKeyInfo').use(SubjectPublicKeyInfo),
  49968. this.key('issuerUniqueID').implicit(1).bitstr().optional(),
  49969. this.key('subjectUniqueID').implicit(2).bitstr().optional(),
  49970. this.key('extensions').explicit(3).seqof(Extension).optional()
  49971. )
  49972. })
  49973. var X509Certificate = asn.define('X509Certificate', function () {
  49974. this.seq().obj(
  49975. this.key('tbsCertificate').use(TBSCertificate),
  49976. this.key('signatureAlgorithm').use(AlgorithmIdentifier),
  49977. this.key('signatureValue').bitstr()
  49978. )
  49979. })
  49980. module.exports = X509Certificate
  49981. /***/ }),
  49982. /***/ "../../node_modules/parse-asn1/fixProc.js":
  49983. /*!************************************************!*\
  49984. !*** ../../node_modules/parse-asn1/fixProc.js ***!
  49985. \************************************************/
  49986. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  49987. // adapted from https://github.com/apatil/pemstrip
  49988. var findProc = /Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m
  49989. var startRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m
  49990. var fullRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m
  49991. var evp = __webpack_require__(/*! evp_bytestokey */ "../../node_modules/evp_bytestokey/index.js")
  49992. var ciphers = __webpack_require__(/*! browserify-aes */ "../../node_modules/browserify-aes/browser.js")
  49993. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  49994. module.exports = function (okey, password) {
  49995. var key = okey.toString()
  49996. var match = key.match(findProc)
  49997. var decrypted
  49998. if (!match) {
  49999. var match2 = key.match(fullRegex)
  50000. decrypted = Buffer.from(match2[2].replace(/[\r\n]/g, ''), 'base64')
  50001. } else {
  50002. var suite = 'aes' + match[1]
  50003. var iv = Buffer.from(match[2], 'hex')
  50004. var cipherText = Buffer.from(match[3].replace(/[\r\n]/g, ''), 'base64')
  50005. var cipherKey = evp(password, iv.slice(0, 8), parseInt(match[1], 10)).key
  50006. var out = []
  50007. var cipher = ciphers.createDecipheriv(suite, cipherKey, iv)
  50008. out.push(cipher.update(cipherText))
  50009. out.push(cipher.final())
  50010. decrypted = Buffer.concat(out)
  50011. }
  50012. var tag = key.match(startRegex)[1]
  50013. return {
  50014. tag: tag,
  50015. data: decrypted
  50016. }
  50017. }
  50018. /***/ }),
  50019. /***/ "../../node_modules/parse-asn1/index.js":
  50020. /*!**********************************************!*\
  50021. !*** ../../node_modules/parse-asn1/index.js ***!
  50022. \**********************************************/
  50023. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  50024. var asn1 = __webpack_require__(/*! ./asn1 */ "../../node_modules/parse-asn1/asn1.js")
  50025. var aesid = __webpack_require__(/*! ./aesid.json */ "../../node_modules/parse-asn1/aesid.json")
  50026. var fixProc = __webpack_require__(/*! ./fixProc */ "../../node_modules/parse-asn1/fixProc.js")
  50027. var ciphers = __webpack_require__(/*! browserify-aes */ "../../node_modules/browserify-aes/browser.js")
  50028. var compat = __webpack_require__(/*! pbkdf2 */ "../../node_modules/pbkdf2/browser.js")
  50029. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  50030. module.exports = parseKeys
  50031. function parseKeys (buffer) {
  50032. var password
  50033. if (typeof buffer === 'object' && !Buffer.isBuffer(buffer)) {
  50034. password = buffer.passphrase
  50035. buffer = buffer.key
  50036. }
  50037. if (typeof buffer === 'string') {
  50038. buffer = Buffer.from(buffer)
  50039. }
  50040. var stripped = fixProc(buffer, password)
  50041. var type = stripped.tag
  50042. var data = stripped.data
  50043. var subtype, ndata
  50044. switch (type) {
  50045. case 'CERTIFICATE':
  50046. ndata = asn1.certificate.decode(data, 'der').tbsCertificate.subjectPublicKeyInfo
  50047. // falls through
  50048. case 'PUBLIC KEY':
  50049. if (!ndata) {
  50050. ndata = asn1.PublicKey.decode(data, 'der')
  50051. }
  50052. subtype = ndata.algorithm.algorithm.join('.')
  50053. switch (subtype) {
  50054. case '1.2.840.113549.1.1.1':
  50055. return asn1.RSAPublicKey.decode(ndata.subjectPublicKey.data, 'der')
  50056. case '1.2.840.10045.2.1':
  50057. ndata.subjectPrivateKey = ndata.subjectPublicKey
  50058. return {
  50059. type: 'ec',
  50060. data: ndata
  50061. }
  50062. case '1.2.840.10040.4.1':
  50063. ndata.algorithm.params.pub_key = asn1.DSAparam.decode(ndata.subjectPublicKey.data, 'der')
  50064. return {
  50065. type: 'dsa',
  50066. data: ndata.algorithm.params
  50067. }
  50068. default: throw new Error('unknown key id ' + subtype)
  50069. }
  50070. // throw new Error('unknown key type ' + type)
  50071. case 'ENCRYPTED PRIVATE KEY':
  50072. data = asn1.EncryptedPrivateKey.decode(data, 'der')
  50073. data = decrypt(data, password)
  50074. // falls through
  50075. case 'PRIVATE KEY':
  50076. ndata = asn1.PrivateKey.decode(data, 'der')
  50077. subtype = ndata.algorithm.algorithm.join('.')
  50078. switch (subtype) {
  50079. case '1.2.840.113549.1.1.1':
  50080. return asn1.RSAPrivateKey.decode(ndata.subjectPrivateKey, 'der')
  50081. case '1.2.840.10045.2.1':
  50082. return {
  50083. curve: ndata.algorithm.curve,
  50084. privateKey: asn1.ECPrivateKey.decode(ndata.subjectPrivateKey, 'der').privateKey
  50085. }
  50086. case '1.2.840.10040.4.1':
  50087. ndata.algorithm.params.priv_key = asn1.DSAparam.decode(ndata.subjectPrivateKey, 'der')
  50088. return {
  50089. type: 'dsa',
  50090. params: ndata.algorithm.params
  50091. }
  50092. default: throw new Error('unknown key id ' + subtype)
  50093. }
  50094. // throw new Error('unknown key type ' + type)
  50095. case 'RSA PUBLIC KEY':
  50096. return asn1.RSAPublicKey.decode(data, 'der')
  50097. case 'RSA PRIVATE KEY':
  50098. return asn1.RSAPrivateKey.decode(data, 'der')
  50099. case 'DSA PRIVATE KEY':
  50100. return {
  50101. type: 'dsa',
  50102. params: asn1.DSAPrivateKey.decode(data, 'der')
  50103. }
  50104. case 'EC PRIVATE KEY':
  50105. data = asn1.ECPrivateKey.decode(data, 'der')
  50106. return {
  50107. curve: data.parameters.value,
  50108. privateKey: data.privateKey
  50109. }
  50110. default: throw new Error('unknown key type ' + type)
  50111. }
  50112. }
  50113. parseKeys.signature = asn1.signature
  50114. function decrypt (data, password) {
  50115. var salt = data.algorithm.decrypt.kde.kdeparams.salt
  50116. var iters = parseInt(data.algorithm.decrypt.kde.kdeparams.iters.toString(), 10)
  50117. var algo = aesid[data.algorithm.decrypt.cipher.algo.join('.')]
  50118. var iv = data.algorithm.decrypt.cipher.iv
  50119. var cipherText = data.subjectPrivateKey
  50120. var keylen = parseInt(algo.split('-')[1], 10) / 8
  50121. var key = compat.pbkdf2Sync(password, salt, iters, keylen, 'sha1')
  50122. var cipher = ciphers.createDecipheriv(algo, key, iv)
  50123. var out = []
  50124. out.push(cipher.update(cipherText))
  50125. out.push(cipher.final())
  50126. return Buffer.concat(out)
  50127. }
  50128. /***/ }),
  50129. /***/ "../../node_modules/pbkdf2/browser.js":
  50130. /*!********************************************!*\
  50131. !*** ../../node_modules/pbkdf2/browser.js ***!
  50132. \********************************************/
  50133. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  50134. exports.pbkdf2 = __webpack_require__(/*! ./lib/async */ "../../node_modules/pbkdf2/lib/async.js")
  50135. exports.pbkdf2Sync = __webpack_require__(/*! ./lib/sync */ "../../node_modules/pbkdf2/lib/sync-browser.js")
  50136. /***/ }),
  50137. /***/ "../../node_modules/pbkdf2/lib/async.js":
  50138. /*!**********************************************!*\
  50139. !*** ../../node_modules/pbkdf2/lib/async.js ***!
  50140. \**********************************************/
  50141. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  50142. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  50143. var checkParameters = __webpack_require__(/*! ./precondition */ "../../node_modules/pbkdf2/lib/precondition.js")
  50144. var defaultEncoding = __webpack_require__(/*! ./default-encoding */ "../../node_modules/pbkdf2/lib/default-encoding.js")
  50145. var sync = __webpack_require__(/*! ./sync */ "../../node_modules/pbkdf2/lib/sync-browser.js")
  50146. var toBuffer = __webpack_require__(/*! ./to-buffer */ "../../node_modules/pbkdf2/lib/to-buffer.js")
  50147. var ZERO_BUF
  50148. var subtle = __webpack_require__.g.crypto && __webpack_require__.g.crypto.subtle
  50149. var toBrowser = {
  50150. sha: 'SHA-1',
  50151. 'sha-1': 'SHA-1',
  50152. sha1: 'SHA-1',
  50153. sha256: 'SHA-256',
  50154. 'sha-256': 'SHA-256',
  50155. sha384: 'SHA-384',
  50156. 'sha-384': 'SHA-384',
  50157. 'sha-512': 'SHA-512',
  50158. sha512: 'SHA-512'
  50159. }
  50160. var checks = []
  50161. function checkNative (algo) {
  50162. if (__webpack_require__.g.process && !__webpack_require__.g.process.browser) {
  50163. return Promise.resolve(false)
  50164. }
  50165. if (!subtle || !subtle.importKey || !subtle.deriveBits) {
  50166. return Promise.resolve(false)
  50167. }
  50168. if (checks[algo] !== undefined) {
  50169. return checks[algo]
  50170. }
  50171. ZERO_BUF = ZERO_BUF || Buffer.alloc(8)
  50172. var prom = browserPbkdf2(ZERO_BUF, ZERO_BUF, 10, 128, algo)
  50173. .then(function () {
  50174. return true
  50175. }).catch(function () {
  50176. return false
  50177. })
  50178. checks[algo] = prom
  50179. return prom
  50180. }
  50181. var nextTick
  50182. function getNextTick () {
  50183. if (nextTick) {
  50184. return nextTick
  50185. }
  50186. if (__webpack_require__.g.process && __webpack_require__.g.process.nextTick) {
  50187. nextTick = __webpack_require__.g.process.nextTick
  50188. } else if (__webpack_require__.g.queueMicrotask) {
  50189. nextTick = __webpack_require__.g.queueMicrotask
  50190. } else if (__webpack_require__.g.setImmediate) {
  50191. nextTick = __webpack_require__.g.setImmediate
  50192. } else {
  50193. nextTick = __webpack_require__.g.setTimeout
  50194. }
  50195. return nextTick
  50196. }
  50197. function browserPbkdf2 (password, salt, iterations, length, algo) {
  50198. return subtle.importKey(
  50199. 'raw', password, { name: 'PBKDF2' }, false, ['deriveBits']
  50200. ).then(function (key) {
  50201. return subtle.deriveBits({
  50202. name: 'PBKDF2',
  50203. salt: salt,
  50204. iterations: iterations,
  50205. hash: {
  50206. name: algo
  50207. }
  50208. }, key, length << 3)
  50209. }).then(function (res) {
  50210. return Buffer.from(res)
  50211. })
  50212. }
  50213. function resolvePromise (promise, callback) {
  50214. promise.then(function (out) {
  50215. getNextTick()(function () {
  50216. callback(null, out)
  50217. })
  50218. }, function (e) {
  50219. getNextTick()(function () {
  50220. callback(e)
  50221. })
  50222. })
  50223. }
  50224. module.exports = function (password, salt, iterations, keylen, digest, callback) {
  50225. if (typeof digest === 'function') {
  50226. callback = digest
  50227. digest = undefined
  50228. }
  50229. digest = digest || 'sha1'
  50230. var algo = toBrowser[digest.toLowerCase()]
  50231. if (!algo || typeof __webpack_require__.g.Promise !== 'function') {
  50232. getNextTick()(function () {
  50233. var out
  50234. try {
  50235. out = sync(password, salt, iterations, keylen, digest)
  50236. } catch (e) {
  50237. return callback(e)
  50238. }
  50239. callback(null, out)
  50240. })
  50241. return
  50242. }
  50243. checkParameters(iterations, keylen)
  50244. password = toBuffer(password, defaultEncoding, 'Password')
  50245. salt = toBuffer(salt, defaultEncoding, 'Salt')
  50246. if (typeof callback !== 'function') throw new Error('No callback provided to pbkdf2')
  50247. resolvePromise(checkNative(algo).then(function (resp) {
  50248. if (resp) return browserPbkdf2(password, salt, iterations, keylen, algo)
  50249. return sync(password, salt, iterations, keylen, digest)
  50250. }), callback)
  50251. }
  50252. /***/ }),
  50253. /***/ "../../node_modules/pbkdf2/lib/default-encoding.js":
  50254. /*!*********************************************************!*\
  50255. !*** ../../node_modules/pbkdf2/lib/default-encoding.js ***!
  50256. \*********************************************************/
  50257. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  50258. /* provided dependency */ var process = __webpack_require__(/*! process/browser */ "../../node_modules/process/browser.js");
  50259. var defaultEncoding
  50260. /* istanbul ignore next */
  50261. if (__webpack_require__.g.process && __webpack_require__.g.process.browser) {
  50262. defaultEncoding = 'utf-8'
  50263. } else if (__webpack_require__.g.process && __webpack_require__.g.process.version) {
  50264. var pVersionMajor = parseInt(process.version.split('.')[0].slice(1), 10)
  50265. defaultEncoding = pVersionMajor >= 6 ? 'utf-8' : 'binary'
  50266. } else {
  50267. defaultEncoding = 'utf-8'
  50268. }
  50269. module.exports = defaultEncoding
  50270. /***/ }),
  50271. /***/ "../../node_modules/pbkdf2/lib/precondition.js":
  50272. /*!*****************************************************!*\
  50273. !*** ../../node_modules/pbkdf2/lib/precondition.js ***!
  50274. \*****************************************************/
  50275. /***/ ((module) => {
  50276. var MAX_ALLOC = Math.pow(2, 30) - 1 // default in iojs
  50277. module.exports = function (iterations, keylen) {
  50278. if (typeof iterations !== 'number') {
  50279. throw new TypeError('Iterations not a number')
  50280. }
  50281. if (iterations < 0) {
  50282. throw new TypeError('Bad iterations')
  50283. }
  50284. if (typeof keylen !== 'number') {
  50285. throw new TypeError('Key length not a number')
  50286. }
  50287. if (keylen < 0 || keylen > MAX_ALLOC || keylen !== keylen) { /* eslint no-self-compare: 0 */
  50288. throw new TypeError('Bad key length')
  50289. }
  50290. }
  50291. /***/ }),
  50292. /***/ "../../node_modules/pbkdf2/lib/sync-browser.js":
  50293. /*!*****************************************************!*\
  50294. !*** ../../node_modules/pbkdf2/lib/sync-browser.js ***!
  50295. \*****************************************************/
  50296. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  50297. var md5 = __webpack_require__(/*! create-hash/md5 */ "../../node_modules/create-hash/md5.js")
  50298. var RIPEMD160 = __webpack_require__(/*! ripemd160 */ "../../node_modules/ripemd160/index.js")
  50299. var sha = __webpack_require__(/*! sha.js */ "../../node_modules/sha.js/index.js")
  50300. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  50301. var checkParameters = __webpack_require__(/*! ./precondition */ "../../node_modules/pbkdf2/lib/precondition.js")
  50302. var defaultEncoding = __webpack_require__(/*! ./default-encoding */ "../../node_modules/pbkdf2/lib/default-encoding.js")
  50303. var toBuffer = __webpack_require__(/*! ./to-buffer */ "../../node_modules/pbkdf2/lib/to-buffer.js")
  50304. var ZEROS = Buffer.alloc(128)
  50305. var sizes = {
  50306. md5: 16,
  50307. sha1: 20,
  50308. sha224: 28,
  50309. sha256: 32,
  50310. sha384: 48,
  50311. sha512: 64,
  50312. rmd160: 20,
  50313. ripemd160: 20
  50314. }
  50315. function Hmac (alg, key, saltLen) {
  50316. var hash = getDigest(alg)
  50317. var blocksize = (alg === 'sha512' || alg === 'sha384') ? 128 : 64
  50318. if (key.length > blocksize) {
  50319. key = hash(key)
  50320. } else if (key.length < blocksize) {
  50321. key = Buffer.concat([key, ZEROS], blocksize)
  50322. }
  50323. var ipad = Buffer.allocUnsafe(blocksize + sizes[alg])
  50324. var opad = Buffer.allocUnsafe(blocksize + sizes[alg])
  50325. for (var i = 0; i < blocksize; i++) {
  50326. ipad[i] = key[i] ^ 0x36
  50327. opad[i] = key[i] ^ 0x5C
  50328. }
  50329. var ipad1 = Buffer.allocUnsafe(blocksize + saltLen + 4)
  50330. ipad.copy(ipad1, 0, 0, blocksize)
  50331. this.ipad1 = ipad1
  50332. this.ipad2 = ipad
  50333. this.opad = opad
  50334. this.alg = alg
  50335. this.blocksize = blocksize
  50336. this.hash = hash
  50337. this.size = sizes[alg]
  50338. }
  50339. Hmac.prototype.run = function (data, ipad) {
  50340. data.copy(ipad, this.blocksize)
  50341. var h = this.hash(ipad)
  50342. h.copy(this.opad, this.blocksize)
  50343. return this.hash(this.opad)
  50344. }
  50345. function getDigest (alg) {
  50346. function shaFunc (data) {
  50347. return sha(alg).update(data).digest()
  50348. }
  50349. function rmd160Func (data) {
  50350. return new RIPEMD160().update(data).digest()
  50351. }
  50352. if (alg === 'rmd160' || alg === 'ripemd160') return rmd160Func
  50353. if (alg === 'md5') return md5
  50354. return shaFunc
  50355. }
  50356. function pbkdf2 (password, salt, iterations, keylen, digest) {
  50357. checkParameters(iterations, keylen)
  50358. password = toBuffer(password, defaultEncoding, 'Password')
  50359. salt = toBuffer(salt, defaultEncoding, 'Salt')
  50360. digest = digest || 'sha1'
  50361. var hmac = new Hmac(digest, password, salt.length)
  50362. var DK = Buffer.allocUnsafe(keylen)
  50363. var block1 = Buffer.allocUnsafe(salt.length + 4)
  50364. salt.copy(block1, 0, 0, salt.length)
  50365. var destPos = 0
  50366. var hLen = sizes[digest]
  50367. var l = Math.ceil(keylen / hLen)
  50368. for (var i = 1; i <= l; i++) {
  50369. block1.writeUInt32BE(i, salt.length)
  50370. var T = hmac.run(block1, hmac.ipad1)
  50371. var U = T
  50372. for (var j = 1; j < iterations; j++) {
  50373. U = hmac.run(U, hmac.ipad2)
  50374. for (var k = 0; k < hLen; k++) T[k] ^= U[k]
  50375. }
  50376. T.copy(DK, destPos)
  50377. destPos += hLen
  50378. }
  50379. return DK
  50380. }
  50381. module.exports = pbkdf2
  50382. /***/ }),
  50383. /***/ "../../node_modules/pbkdf2/lib/to-buffer.js":
  50384. /*!**************************************************!*\
  50385. !*** ../../node_modules/pbkdf2/lib/to-buffer.js ***!
  50386. \**************************************************/
  50387. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  50388. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  50389. module.exports = function (thing, encoding, name) {
  50390. if (Buffer.isBuffer(thing)) {
  50391. return thing
  50392. } else if (typeof thing === 'string') {
  50393. return Buffer.from(thing, encoding)
  50394. } else if (ArrayBuffer.isView(thing)) {
  50395. return Buffer.from(thing.buffer)
  50396. } else {
  50397. throw new TypeError(name + ' must be a string, a Buffer, a typed array or a DataView')
  50398. }
  50399. }
  50400. /***/ }),
  50401. /***/ "../../node_modules/process/browser.js":
  50402. /*!*********************************************!*\
  50403. !*** ../../node_modules/process/browser.js ***!
  50404. \*********************************************/
  50405. /***/ ((module) => {
  50406. // shim for using process in browser
  50407. var process = module.exports = {};
  50408. // cached from whatever global is present so that test runners that stub it
  50409. // don't break things. But we need to wrap it in a try catch in case it is
  50410. // wrapped in strict mode code which doesn't define any globals. It's inside a
  50411. // function because try/catches deoptimize in certain engines.
  50412. var cachedSetTimeout;
  50413. var cachedClearTimeout;
  50414. function defaultSetTimout() {
  50415. throw new Error('setTimeout has not been defined');
  50416. }
  50417. function defaultClearTimeout () {
  50418. throw new Error('clearTimeout has not been defined');
  50419. }
  50420. (function () {
  50421. try {
  50422. if (typeof setTimeout === 'function') {
  50423. cachedSetTimeout = setTimeout;
  50424. } else {
  50425. cachedSetTimeout = defaultSetTimout;
  50426. }
  50427. } catch (e) {
  50428. cachedSetTimeout = defaultSetTimout;
  50429. }
  50430. try {
  50431. if (typeof clearTimeout === 'function') {
  50432. cachedClearTimeout = clearTimeout;
  50433. } else {
  50434. cachedClearTimeout = defaultClearTimeout;
  50435. }
  50436. } catch (e) {
  50437. cachedClearTimeout = defaultClearTimeout;
  50438. }
  50439. } ())
  50440. function runTimeout(fun) {
  50441. if (cachedSetTimeout === setTimeout) {
  50442. //normal enviroments in sane situations
  50443. return setTimeout(fun, 0);
  50444. }
  50445. // if setTimeout wasn't available but was latter defined
  50446. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  50447. cachedSetTimeout = setTimeout;
  50448. return setTimeout(fun, 0);
  50449. }
  50450. try {
  50451. // when when somebody has screwed with setTimeout but no I.E. maddness
  50452. return cachedSetTimeout(fun, 0);
  50453. } catch(e){
  50454. try {
  50455. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  50456. return cachedSetTimeout.call(null, fun, 0);
  50457. } catch(e){
  50458. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  50459. return cachedSetTimeout.call(this, fun, 0);
  50460. }
  50461. }
  50462. }
  50463. function runClearTimeout(marker) {
  50464. if (cachedClearTimeout === clearTimeout) {
  50465. //normal enviroments in sane situations
  50466. return clearTimeout(marker);
  50467. }
  50468. // if clearTimeout wasn't available but was latter defined
  50469. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  50470. cachedClearTimeout = clearTimeout;
  50471. return clearTimeout(marker);
  50472. }
  50473. try {
  50474. // when when somebody has screwed with setTimeout but no I.E. maddness
  50475. return cachedClearTimeout(marker);
  50476. } catch (e){
  50477. try {
  50478. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  50479. return cachedClearTimeout.call(null, marker);
  50480. } catch (e){
  50481. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  50482. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  50483. return cachedClearTimeout.call(this, marker);
  50484. }
  50485. }
  50486. }
  50487. var queue = [];
  50488. var draining = false;
  50489. var currentQueue;
  50490. var queueIndex = -1;
  50491. function cleanUpNextTick() {
  50492. if (!draining || !currentQueue) {
  50493. return;
  50494. }
  50495. draining = false;
  50496. if (currentQueue.length) {
  50497. queue = currentQueue.concat(queue);
  50498. } else {
  50499. queueIndex = -1;
  50500. }
  50501. if (queue.length) {
  50502. drainQueue();
  50503. }
  50504. }
  50505. function drainQueue() {
  50506. if (draining) {
  50507. return;
  50508. }
  50509. var timeout = runTimeout(cleanUpNextTick);
  50510. draining = true;
  50511. var len = queue.length;
  50512. while(len) {
  50513. currentQueue = queue;
  50514. queue = [];
  50515. while (++queueIndex < len) {
  50516. if (currentQueue) {
  50517. currentQueue[queueIndex].run();
  50518. }
  50519. }
  50520. queueIndex = -1;
  50521. len = queue.length;
  50522. }
  50523. currentQueue = null;
  50524. draining = false;
  50525. runClearTimeout(timeout);
  50526. }
  50527. process.nextTick = function (fun) {
  50528. var args = new Array(arguments.length - 1);
  50529. if (arguments.length > 1) {
  50530. for (var i = 1; i < arguments.length; i++) {
  50531. args[i - 1] = arguments[i];
  50532. }
  50533. }
  50534. queue.push(new Item(fun, args));
  50535. if (queue.length === 1 && !draining) {
  50536. runTimeout(drainQueue);
  50537. }
  50538. };
  50539. // v8 likes predictible objects
  50540. function Item(fun, array) {
  50541. this.fun = fun;
  50542. this.array = array;
  50543. }
  50544. Item.prototype.run = function () {
  50545. this.fun.apply(null, this.array);
  50546. };
  50547. process.title = 'browser';
  50548. process.browser = true;
  50549. process.env = {};
  50550. process.argv = [];
  50551. process.version = ''; // empty string to avoid regexp issues
  50552. process.versions = {};
  50553. function noop() {}
  50554. process.on = noop;
  50555. process.addListener = noop;
  50556. process.once = noop;
  50557. process.off = noop;
  50558. process.removeListener = noop;
  50559. process.removeAllListeners = noop;
  50560. process.emit = noop;
  50561. process.prependListener = noop;
  50562. process.prependOnceListener = noop;
  50563. process.listeners = function (name) { return [] }
  50564. process.binding = function (name) {
  50565. throw new Error('process.binding is not supported');
  50566. };
  50567. process.cwd = function () { return '/' };
  50568. process.chdir = function (dir) {
  50569. throw new Error('process.chdir is not supported');
  50570. };
  50571. process.umask = function() { return 0; };
  50572. /***/ }),
  50573. /***/ "../../node_modules/public-encrypt/browser.js":
  50574. /*!****************************************************!*\
  50575. !*** ../../node_modules/public-encrypt/browser.js ***!
  50576. \****************************************************/
  50577. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  50578. exports.publicEncrypt = __webpack_require__(/*! ./publicEncrypt */ "../../node_modules/public-encrypt/publicEncrypt.js")
  50579. exports.privateDecrypt = __webpack_require__(/*! ./privateDecrypt */ "../../node_modules/public-encrypt/privateDecrypt.js")
  50580. exports.privateEncrypt = function privateEncrypt (key, buf) {
  50581. return exports.publicEncrypt(key, buf, true)
  50582. }
  50583. exports.publicDecrypt = function publicDecrypt (key, buf) {
  50584. return exports.privateDecrypt(key, buf, true)
  50585. }
  50586. /***/ }),
  50587. /***/ "../../node_modules/public-encrypt/mgf.js":
  50588. /*!************************************************!*\
  50589. !*** ../../node_modules/public-encrypt/mgf.js ***!
  50590. \************************************************/
  50591. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  50592. var createHash = __webpack_require__(/*! create-hash */ "../../node_modules/create-hash/browser.js")
  50593. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  50594. module.exports = function (seed, len) {
  50595. var t = Buffer.alloc(0)
  50596. var i = 0
  50597. var c
  50598. while (t.length < len) {
  50599. c = i2ops(i++)
  50600. t = Buffer.concat([t, createHash('sha1').update(seed).update(c).digest()])
  50601. }
  50602. return t.slice(0, len)
  50603. }
  50604. function i2ops (c) {
  50605. var out = Buffer.allocUnsafe(4)
  50606. out.writeUInt32BE(c, 0)
  50607. return out
  50608. }
  50609. /***/ }),
  50610. /***/ "../../node_modules/public-encrypt/privateDecrypt.js":
  50611. /*!***********************************************************!*\
  50612. !*** ../../node_modules/public-encrypt/privateDecrypt.js ***!
  50613. \***********************************************************/
  50614. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  50615. var parseKeys = __webpack_require__(/*! parse-asn1 */ "../../node_modules/parse-asn1/index.js")
  50616. var mgf = __webpack_require__(/*! ./mgf */ "../../node_modules/public-encrypt/mgf.js")
  50617. var xor = __webpack_require__(/*! ./xor */ "../../node_modules/public-encrypt/xor.js")
  50618. var BN = __webpack_require__(/*! bn.js */ "../../node_modules/diffie-hellman/node_modules/bn.js/lib/bn.js")
  50619. var crt = __webpack_require__(/*! browserify-rsa */ "../../node_modules/browserify-rsa/index.js")
  50620. var createHash = __webpack_require__(/*! create-hash */ "../../node_modules/create-hash/browser.js")
  50621. var withPublic = __webpack_require__(/*! ./withPublic */ "../../node_modules/public-encrypt/withPublic.js")
  50622. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  50623. module.exports = function privateDecrypt (privateKey, enc, reverse) {
  50624. var padding
  50625. if (privateKey.padding) {
  50626. padding = privateKey.padding
  50627. } else if (reverse) {
  50628. padding = 1
  50629. } else {
  50630. padding = 4
  50631. }
  50632. var key = parseKeys(privateKey)
  50633. var k = key.modulus.byteLength()
  50634. if (enc.length > k || new BN(enc).cmp(key.modulus) >= 0) {
  50635. throw new Error('decryption error')
  50636. }
  50637. var msg
  50638. if (reverse) {
  50639. msg = withPublic(new BN(enc), key)
  50640. } else {
  50641. msg = crt(enc, key)
  50642. }
  50643. var zBuffer = Buffer.alloc(k - msg.length)
  50644. msg = Buffer.concat([zBuffer, msg], k)
  50645. if (padding === 4) {
  50646. return oaep(key, msg)
  50647. } else if (padding === 1) {
  50648. return pkcs1(key, msg, reverse)
  50649. } else if (padding === 3) {
  50650. return msg
  50651. } else {
  50652. throw new Error('unknown padding')
  50653. }
  50654. }
  50655. function oaep (key, msg) {
  50656. var k = key.modulus.byteLength()
  50657. var iHash = createHash('sha1').update(Buffer.alloc(0)).digest()
  50658. var hLen = iHash.length
  50659. if (msg[0] !== 0) {
  50660. throw new Error('decryption error')
  50661. }
  50662. var maskedSeed = msg.slice(1, hLen + 1)
  50663. var maskedDb = msg.slice(hLen + 1)
  50664. var seed = xor(maskedSeed, mgf(maskedDb, hLen))
  50665. var db = xor(maskedDb, mgf(seed, k - hLen - 1))
  50666. if (compare(iHash, db.slice(0, hLen))) {
  50667. throw new Error('decryption error')
  50668. }
  50669. var i = hLen
  50670. while (db[i] === 0) {
  50671. i++
  50672. }
  50673. if (db[i++] !== 1) {
  50674. throw new Error('decryption error')
  50675. }
  50676. return db.slice(i)
  50677. }
  50678. function pkcs1 (key, msg, reverse) {
  50679. var p1 = msg.slice(0, 2)
  50680. var i = 2
  50681. var status = 0
  50682. while (msg[i++] !== 0) {
  50683. if (i >= msg.length) {
  50684. status++
  50685. break
  50686. }
  50687. }
  50688. var ps = msg.slice(2, i - 1)
  50689. if ((p1.toString('hex') !== '0002' && !reverse) || (p1.toString('hex') !== '0001' && reverse)) {
  50690. status++
  50691. }
  50692. if (ps.length < 8) {
  50693. status++
  50694. }
  50695. if (status) {
  50696. throw new Error('decryption error')
  50697. }
  50698. return msg.slice(i)
  50699. }
  50700. function compare (a, b) {
  50701. a = Buffer.from(a)
  50702. b = Buffer.from(b)
  50703. var dif = 0
  50704. var len = a.length
  50705. if (a.length !== b.length) {
  50706. dif++
  50707. len = Math.min(a.length, b.length)
  50708. }
  50709. var i = -1
  50710. while (++i < len) {
  50711. dif += (a[i] ^ b[i])
  50712. }
  50713. return dif
  50714. }
  50715. /***/ }),
  50716. /***/ "../../node_modules/public-encrypt/publicEncrypt.js":
  50717. /*!**********************************************************!*\
  50718. !*** ../../node_modules/public-encrypt/publicEncrypt.js ***!
  50719. \**********************************************************/
  50720. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  50721. var parseKeys = __webpack_require__(/*! parse-asn1 */ "../../node_modules/parse-asn1/index.js")
  50722. var randomBytes = __webpack_require__(/*! randombytes */ "../../node_modules/randombytes/browser.js")
  50723. var createHash = __webpack_require__(/*! create-hash */ "../../node_modules/create-hash/browser.js")
  50724. var mgf = __webpack_require__(/*! ./mgf */ "../../node_modules/public-encrypt/mgf.js")
  50725. var xor = __webpack_require__(/*! ./xor */ "../../node_modules/public-encrypt/xor.js")
  50726. var BN = __webpack_require__(/*! bn.js */ "../../node_modules/diffie-hellman/node_modules/bn.js/lib/bn.js")
  50727. var withPublic = __webpack_require__(/*! ./withPublic */ "../../node_modules/public-encrypt/withPublic.js")
  50728. var crt = __webpack_require__(/*! browserify-rsa */ "../../node_modules/browserify-rsa/index.js")
  50729. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  50730. module.exports = function publicEncrypt (publicKey, msg, reverse) {
  50731. var padding
  50732. if (publicKey.padding) {
  50733. padding = publicKey.padding
  50734. } else if (reverse) {
  50735. padding = 1
  50736. } else {
  50737. padding = 4
  50738. }
  50739. var key = parseKeys(publicKey)
  50740. var paddedMsg
  50741. if (padding === 4) {
  50742. paddedMsg = oaep(key, msg)
  50743. } else if (padding === 1) {
  50744. paddedMsg = pkcs1(key, msg, reverse)
  50745. } else if (padding === 3) {
  50746. paddedMsg = new BN(msg)
  50747. if (paddedMsg.cmp(key.modulus) >= 0) {
  50748. throw new Error('data too long for modulus')
  50749. }
  50750. } else {
  50751. throw new Error('unknown padding')
  50752. }
  50753. if (reverse) {
  50754. return crt(paddedMsg, key)
  50755. } else {
  50756. return withPublic(paddedMsg, key)
  50757. }
  50758. }
  50759. function oaep (key, msg) {
  50760. var k = key.modulus.byteLength()
  50761. var mLen = msg.length
  50762. var iHash = createHash('sha1').update(Buffer.alloc(0)).digest()
  50763. var hLen = iHash.length
  50764. var hLen2 = 2 * hLen
  50765. if (mLen > k - hLen2 - 2) {
  50766. throw new Error('message too long')
  50767. }
  50768. var ps = Buffer.alloc(k - mLen - hLen2 - 2)
  50769. var dblen = k - hLen - 1
  50770. var seed = randomBytes(hLen)
  50771. var maskedDb = xor(Buffer.concat([iHash, ps, Buffer.alloc(1, 1), msg], dblen), mgf(seed, dblen))
  50772. var maskedSeed = xor(seed, mgf(maskedDb, hLen))
  50773. return new BN(Buffer.concat([Buffer.alloc(1), maskedSeed, maskedDb], k))
  50774. }
  50775. function pkcs1 (key, msg, reverse) {
  50776. var mLen = msg.length
  50777. var k = key.modulus.byteLength()
  50778. if (mLen > k - 11) {
  50779. throw new Error('message too long')
  50780. }
  50781. var ps
  50782. if (reverse) {
  50783. ps = Buffer.alloc(k - mLen - 3, 0xff)
  50784. } else {
  50785. ps = nonZero(k - mLen - 3)
  50786. }
  50787. return new BN(Buffer.concat([Buffer.from([0, reverse ? 1 : 2]), ps, Buffer.alloc(1), msg], k))
  50788. }
  50789. function nonZero (len) {
  50790. var out = Buffer.allocUnsafe(len)
  50791. var i = 0
  50792. var cache = randomBytes(len * 2)
  50793. var cur = 0
  50794. var num
  50795. while (i < len) {
  50796. if (cur === cache.length) {
  50797. cache = randomBytes(len * 2)
  50798. cur = 0
  50799. }
  50800. num = cache[cur++]
  50801. if (num) {
  50802. out[i++] = num
  50803. }
  50804. }
  50805. return out
  50806. }
  50807. /***/ }),
  50808. /***/ "../../node_modules/public-encrypt/withPublic.js":
  50809. /*!*******************************************************!*\
  50810. !*** ../../node_modules/public-encrypt/withPublic.js ***!
  50811. \*******************************************************/
  50812. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  50813. var BN = __webpack_require__(/*! bn.js */ "../../node_modules/diffie-hellman/node_modules/bn.js/lib/bn.js")
  50814. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  50815. function withPublic (paddedMsg, key) {
  50816. return Buffer.from(paddedMsg
  50817. .toRed(BN.mont(key.modulus))
  50818. .redPow(new BN(key.publicExponent))
  50819. .fromRed()
  50820. .toArray())
  50821. }
  50822. module.exports = withPublic
  50823. /***/ }),
  50824. /***/ "../../node_modules/public-encrypt/xor.js":
  50825. /*!************************************************!*\
  50826. !*** ../../node_modules/public-encrypt/xor.js ***!
  50827. \************************************************/
  50828. /***/ ((module) => {
  50829. module.exports = function xor (a, b) {
  50830. var len = a.length
  50831. var i = -1
  50832. while (++i < len) {
  50833. a[i] ^= b[i]
  50834. }
  50835. return a
  50836. }
  50837. /***/ }),
  50838. /***/ "../../node_modules/querystring/decode.js":
  50839. /*!************************************************!*\
  50840. !*** ../../node_modules/querystring/decode.js ***!
  50841. \************************************************/
  50842. /***/ ((module) => {
  50843. "use strict";
  50844. // Copyright Joyent, Inc. and other Node contributors.
  50845. //
  50846. // Permission is hereby granted, free of charge, to any person obtaining a
  50847. // copy of this software and associated documentation files (the
  50848. // "Software"), to deal in the Software without restriction, including
  50849. // without limitation the rights to use, copy, modify, merge, publish,
  50850. // distribute, sublicense, and/or sell copies of the Software, and to permit
  50851. // persons to whom the Software is furnished to do so, subject to the
  50852. // following conditions:
  50853. //
  50854. // The above copyright notice and this permission notice shall be included
  50855. // in all copies or substantial portions of the Software.
  50856. //
  50857. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  50858. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  50859. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  50860. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  50861. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  50862. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  50863. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  50864. // If obj.hasOwnProperty has been overridden, then calling
  50865. // obj.hasOwnProperty(prop) will break.
  50866. // See: https://github.com/joyent/node/issues/1707
  50867. function hasOwnProperty(obj, prop) {
  50868. return Object.prototype.hasOwnProperty.call(obj, prop);
  50869. }
  50870. module.exports = function(qs, sep, eq, options) {
  50871. sep = sep || '&';
  50872. eq = eq || '=';
  50873. var obj = {};
  50874. if (typeof qs !== 'string' || qs.length === 0) {
  50875. return obj;
  50876. }
  50877. var regexp = /\+/g;
  50878. qs = qs.split(sep);
  50879. var maxKeys = 1000;
  50880. if (options && typeof options.maxKeys === 'number') {
  50881. maxKeys = options.maxKeys;
  50882. }
  50883. var len = qs.length;
  50884. // maxKeys <= 0 means that we should not limit keys count
  50885. if (maxKeys > 0 && len > maxKeys) {
  50886. len = maxKeys;
  50887. }
  50888. for (var i = 0; i < len; ++i) {
  50889. var x = qs[i].replace(regexp, '%20'),
  50890. idx = x.indexOf(eq),
  50891. kstr, vstr, k, v;
  50892. if (idx >= 0) {
  50893. kstr = x.substr(0, idx);
  50894. vstr = x.substr(idx + 1);
  50895. } else {
  50896. kstr = x;
  50897. vstr = '';
  50898. }
  50899. k = decodeURIComponent(kstr);
  50900. v = decodeURIComponent(vstr);
  50901. if (!hasOwnProperty(obj, k)) {
  50902. obj[k] = v;
  50903. } else if (Array.isArray(obj[k])) {
  50904. obj[k].push(v);
  50905. } else {
  50906. obj[k] = [obj[k], v];
  50907. }
  50908. }
  50909. return obj;
  50910. };
  50911. /***/ }),
  50912. /***/ "../../node_modules/querystring/encode.js":
  50913. /*!************************************************!*\
  50914. !*** ../../node_modules/querystring/encode.js ***!
  50915. \************************************************/
  50916. /***/ ((module) => {
  50917. "use strict";
  50918. // Copyright Joyent, Inc. and other Node contributors.
  50919. //
  50920. // Permission is hereby granted, free of charge, to any person obtaining a
  50921. // copy of this software and associated documentation files (the
  50922. // "Software"), to deal in the Software without restriction, including
  50923. // without limitation the rights to use, copy, modify, merge, publish,
  50924. // distribute, sublicense, and/or sell copies of the Software, and to permit
  50925. // persons to whom the Software is furnished to do so, subject to the
  50926. // following conditions:
  50927. //
  50928. // The above copyright notice and this permission notice shall be included
  50929. // in all copies or substantial portions of the Software.
  50930. //
  50931. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  50932. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  50933. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  50934. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  50935. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  50936. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  50937. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  50938. var stringifyPrimitive = function(v) {
  50939. switch (typeof v) {
  50940. case 'string':
  50941. return v;
  50942. case 'boolean':
  50943. return v ? 'true' : 'false';
  50944. case 'number':
  50945. return isFinite(v) ? v : '';
  50946. default:
  50947. return '';
  50948. }
  50949. };
  50950. module.exports = function(obj, sep, eq, name) {
  50951. sep = sep || '&';
  50952. eq = eq || '=';
  50953. if (obj === null) {
  50954. obj = undefined;
  50955. }
  50956. if (typeof obj === 'object') {
  50957. return Object.keys(obj).map(function(k) {
  50958. var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
  50959. if (Array.isArray(obj[k])) {
  50960. return obj[k].map(function(v) {
  50961. return ks + encodeURIComponent(stringifyPrimitive(v));
  50962. }).join(sep);
  50963. } else {
  50964. return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
  50965. }
  50966. }).join(sep);
  50967. }
  50968. if (!name) return '';
  50969. return encodeURIComponent(stringifyPrimitive(name)) + eq +
  50970. encodeURIComponent(stringifyPrimitive(obj));
  50971. };
  50972. /***/ }),
  50973. /***/ "../../node_modules/querystring/index.js":
  50974. /*!***********************************************!*\
  50975. !*** ../../node_modules/querystring/index.js ***!
  50976. \***********************************************/
  50977. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  50978. "use strict";
  50979. exports.decode = exports.parse = __webpack_require__(/*! ./decode */ "../../node_modules/querystring/decode.js");
  50980. exports.encode = exports.stringify = __webpack_require__(/*! ./encode */ "../../node_modules/querystring/encode.js");
  50981. /***/ }),
  50982. /***/ "../../node_modules/randombytes/browser.js":
  50983. /*!*************************************************!*\
  50984. !*** ../../node_modules/randombytes/browser.js ***!
  50985. \*************************************************/
  50986. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  50987. "use strict";
  50988. /* provided dependency */ var process = __webpack_require__(/*! process/browser */ "../../node_modules/process/browser.js");
  50989. // limit of Crypto.getRandomValues()
  50990. // https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues
  50991. var MAX_BYTES = 65536
  50992. // Node supports requesting up to this number of bytes
  50993. // https://github.com/nodejs/node/blob/master/lib/internal/crypto/random.js#L48
  50994. var MAX_UINT32 = 4294967295
  50995. function oldBrowser () {
  50996. throw new Error('Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11')
  50997. }
  50998. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  50999. var crypto = __webpack_require__.g.crypto || __webpack_require__.g.msCrypto
  51000. if (crypto && crypto.getRandomValues) {
  51001. module.exports = randomBytes
  51002. } else {
  51003. module.exports = oldBrowser
  51004. }
  51005. function randomBytes (size, cb) {
  51006. // phantomjs needs to throw
  51007. if (size > MAX_UINT32) throw new RangeError('requested too many random bytes')
  51008. var bytes = Buffer.allocUnsafe(size)
  51009. if (size > 0) { // getRandomValues fails on IE if size == 0
  51010. if (size > MAX_BYTES) { // this is the max bytes crypto.getRandomValues
  51011. // can do at once see https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues
  51012. for (var generated = 0; generated < size; generated += MAX_BYTES) {
  51013. // buffer.slice automatically checks if the end is past the end of
  51014. // the buffer so we don't have to here
  51015. crypto.getRandomValues(bytes.slice(generated, generated + MAX_BYTES))
  51016. }
  51017. } else {
  51018. crypto.getRandomValues(bytes)
  51019. }
  51020. }
  51021. if (typeof cb === 'function') {
  51022. return process.nextTick(function () {
  51023. cb(null, bytes)
  51024. })
  51025. }
  51026. return bytes
  51027. }
  51028. /***/ }),
  51029. /***/ "../../node_modules/randomfill/browser.js":
  51030. /*!************************************************!*\
  51031. !*** ../../node_modules/randomfill/browser.js ***!
  51032. \************************************************/
  51033. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  51034. "use strict";
  51035. /* provided dependency */ var process = __webpack_require__(/*! process/browser */ "../../node_modules/process/browser.js");
  51036. function oldBrowser () {
  51037. throw new Error('secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11')
  51038. }
  51039. var safeBuffer = __webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js")
  51040. var randombytes = __webpack_require__(/*! randombytes */ "../../node_modules/randombytes/browser.js")
  51041. var Buffer = safeBuffer.Buffer
  51042. var kBufferMaxLength = safeBuffer.kMaxLength
  51043. var crypto = __webpack_require__.g.crypto || __webpack_require__.g.msCrypto
  51044. var kMaxUint32 = Math.pow(2, 32) - 1
  51045. function assertOffset (offset, length) {
  51046. if (typeof offset !== 'number' || offset !== offset) { // eslint-disable-line no-self-compare
  51047. throw new TypeError('offset must be a number')
  51048. }
  51049. if (offset > kMaxUint32 || offset < 0) {
  51050. throw new TypeError('offset must be a uint32')
  51051. }
  51052. if (offset > kBufferMaxLength || offset > length) {
  51053. throw new RangeError('offset out of range')
  51054. }
  51055. }
  51056. function assertSize (size, offset, length) {
  51057. if (typeof size !== 'number' || size !== size) { // eslint-disable-line no-self-compare
  51058. throw new TypeError('size must be a number')
  51059. }
  51060. if (size > kMaxUint32 || size < 0) {
  51061. throw new TypeError('size must be a uint32')
  51062. }
  51063. if (size + offset > length || size > kBufferMaxLength) {
  51064. throw new RangeError('buffer too small')
  51065. }
  51066. }
  51067. if ((crypto && crypto.getRandomValues) || !process.browser) {
  51068. exports.randomFill = randomFill
  51069. exports.randomFillSync = randomFillSync
  51070. } else {
  51071. exports.randomFill = oldBrowser
  51072. exports.randomFillSync = oldBrowser
  51073. }
  51074. function randomFill (buf, offset, size, cb) {
  51075. if (!Buffer.isBuffer(buf) && !(buf instanceof __webpack_require__.g.Uint8Array)) {
  51076. throw new TypeError('"buf" argument must be a Buffer or Uint8Array')
  51077. }
  51078. if (typeof offset === 'function') {
  51079. cb = offset
  51080. offset = 0
  51081. size = buf.length
  51082. } else if (typeof size === 'function') {
  51083. cb = size
  51084. size = buf.length - offset
  51085. } else if (typeof cb !== 'function') {
  51086. throw new TypeError('"cb" argument must be a function')
  51087. }
  51088. assertOffset(offset, buf.length)
  51089. assertSize(size, offset, buf.length)
  51090. return actualFill(buf, offset, size, cb)
  51091. }
  51092. function actualFill (buf, offset, size, cb) {
  51093. if (process.browser) {
  51094. var ourBuf = buf.buffer
  51095. var uint = new Uint8Array(ourBuf, offset, size)
  51096. crypto.getRandomValues(uint)
  51097. if (cb) {
  51098. process.nextTick(function () {
  51099. cb(null, buf)
  51100. })
  51101. return
  51102. }
  51103. return buf
  51104. }
  51105. if (cb) {
  51106. randombytes(size, function (err, bytes) {
  51107. if (err) {
  51108. return cb(err)
  51109. }
  51110. bytes.copy(buf, offset)
  51111. cb(null, buf)
  51112. })
  51113. return
  51114. }
  51115. var bytes = randombytes(size)
  51116. bytes.copy(buf, offset)
  51117. return buf
  51118. }
  51119. function randomFillSync (buf, offset, size) {
  51120. if (typeof offset === 'undefined') {
  51121. offset = 0
  51122. }
  51123. if (!Buffer.isBuffer(buf) && !(buf instanceof __webpack_require__.g.Uint8Array)) {
  51124. throw new TypeError('"buf" argument must be a Buffer or Uint8Array')
  51125. }
  51126. assertOffset(offset, buf.length)
  51127. if (size === undefined) size = buf.length - offset
  51128. assertSize(size, offset, buf.length)
  51129. return actualFill(buf, offset, size)
  51130. }
  51131. /***/ }),
  51132. /***/ "../../node_modules/readable-stream/errors-browser.js":
  51133. /*!************************************************************!*\
  51134. !*** ../../node_modules/readable-stream/errors-browser.js ***!
  51135. \************************************************************/
  51136. /***/ ((module) => {
  51137. "use strict";
  51138. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  51139. var codes = {};
  51140. function createErrorType(code, message, Base) {
  51141. if (!Base) {
  51142. Base = Error;
  51143. }
  51144. function getMessage(arg1, arg2, arg3) {
  51145. if (typeof message === 'string') {
  51146. return message;
  51147. } else {
  51148. return message(arg1, arg2, arg3);
  51149. }
  51150. }
  51151. var NodeError =
  51152. /*#__PURE__*/
  51153. function (_Base) {
  51154. _inheritsLoose(NodeError, _Base);
  51155. function NodeError(arg1, arg2, arg3) {
  51156. return _Base.call(this, getMessage(arg1, arg2, arg3)) || this;
  51157. }
  51158. return NodeError;
  51159. }(Base);
  51160. NodeError.prototype.name = Base.name;
  51161. NodeError.prototype.code = code;
  51162. codes[code] = NodeError;
  51163. } // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js
  51164. function oneOf(expected, thing) {
  51165. if (Array.isArray(expected)) {
  51166. var len = expected.length;
  51167. expected = expected.map(function (i) {
  51168. return String(i);
  51169. });
  51170. if (len > 2) {
  51171. return "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(', '), ", or ") + expected[len - 1];
  51172. } else if (len === 2) {
  51173. return "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1]);
  51174. } else {
  51175. return "of ".concat(thing, " ").concat(expected[0]);
  51176. }
  51177. } else {
  51178. return "of ".concat(thing, " ").concat(String(expected));
  51179. }
  51180. } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
  51181. function startsWith(str, search, pos) {
  51182. return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
  51183. } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
  51184. function endsWith(str, search, this_len) {
  51185. if (this_len === undefined || this_len > str.length) {
  51186. this_len = str.length;
  51187. }
  51188. return str.substring(this_len - search.length, this_len) === search;
  51189. } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
  51190. function includes(str, search, start) {
  51191. if (typeof start !== 'number') {
  51192. start = 0;
  51193. }
  51194. if (start + search.length > str.length) {
  51195. return false;
  51196. } else {
  51197. return str.indexOf(search, start) !== -1;
  51198. }
  51199. }
  51200. createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) {
  51201. return 'The value "' + value + '" is invalid for option "' + name + '"';
  51202. }, TypeError);
  51203. createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) {
  51204. // determiner: 'must be' or 'must not be'
  51205. var determiner;
  51206. if (typeof expected === 'string' && startsWith(expected, 'not ')) {
  51207. determiner = 'must not be';
  51208. expected = expected.replace(/^not /, '');
  51209. } else {
  51210. determiner = 'must be';
  51211. }
  51212. var msg;
  51213. if (endsWith(name, ' argument')) {
  51214. // For cases like 'first argument'
  51215. msg = "The ".concat(name, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));
  51216. } else {
  51217. var type = includes(name, '.') ? 'property' : 'argument';
  51218. msg = "The \"".concat(name, "\" ").concat(type, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));
  51219. }
  51220. msg += ". Received type ".concat(typeof actual);
  51221. return msg;
  51222. }, TypeError);
  51223. createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF');
  51224. createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) {
  51225. return 'The ' + name + ' method is not implemented';
  51226. });
  51227. createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close');
  51228. createErrorType('ERR_STREAM_DESTROYED', function (name) {
  51229. return 'Cannot call ' + name + ' after a stream was destroyed';
  51230. });
  51231. createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times');
  51232. createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable');
  51233. createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end');
  51234. createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError);
  51235. createErrorType('ERR_UNKNOWN_ENCODING', function (arg) {
  51236. return 'Unknown encoding: ' + arg;
  51237. }, TypeError);
  51238. createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');
  51239. module.exports.codes = codes;
  51240. /***/ }),
  51241. /***/ "../../node_modules/readable-stream/lib/_stream_duplex.js":
  51242. /*!****************************************************************!*\
  51243. !*** ../../node_modules/readable-stream/lib/_stream_duplex.js ***!
  51244. \****************************************************************/
  51245. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  51246. "use strict";
  51247. /* provided dependency */ var process = __webpack_require__(/*! process/browser */ "../../node_modules/process/browser.js");
  51248. // Copyright Joyent, Inc. and other Node contributors.
  51249. //
  51250. // Permission is hereby granted, free of charge, to any person obtaining a
  51251. // copy of this software and associated documentation files (the
  51252. // "Software"), to deal in the Software without restriction, including
  51253. // without limitation the rights to use, copy, modify, merge, publish,
  51254. // distribute, sublicense, and/or sell copies of the Software, and to permit
  51255. // persons to whom the Software is furnished to do so, subject to the
  51256. // following conditions:
  51257. //
  51258. // The above copyright notice and this permission notice shall be included
  51259. // in all copies or substantial portions of the Software.
  51260. //
  51261. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  51262. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  51263. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  51264. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  51265. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  51266. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  51267. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  51268. // a duplex stream is just a stream that is both readable and writable.
  51269. // Since JS doesn't have multiple prototypal inheritance, this class
  51270. // prototypally inherits from Readable, and then parasitically from
  51271. // Writable.
  51272. /*<replacement>*/
  51273. var objectKeys = Object.keys || function (obj) {
  51274. var keys = [];
  51275. for (var key in obj) {
  51276. keys.push(key);
  51277. }
  51278. return keys;
  51279. };
  51280. /*</replacement>*/
  51281. module.exports = Duplex;
  51282. var Readable = __webpack_require__(/*! ./_stream_readable */ "../../node_modules/readable-stream/lib/_stream_readable.js");
  51283. var Writable = __webpack_require__(/*! ./_stream_writable */ "../../node_modules/readable-stream/lib/_stream_writable.js");
  51284. __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js")(Duplex, Readable);
  51285. {
  51286. // Allow the keys array to be GC'ed.
  51287. var keys = objectKeys(Writable.prototype);
  51288. for (var v = 0; v < keys.length; v++) {
  51289. var method = keys[v];
  51290. if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
  51291. }
  51292. }
  51293. function Duplex(options) {
  51294. if (!(this instanceof Duplex)) return new Duplex(options);
  51295. Readable.call(this, options);
  51296. Writable.call(this, options);
  51297. this.allowHalfOpen = true;
  51298. if (options) {
  51299. if (options.readable === false) this.readable = false;
  51300. if (options.writable === false) this.writable = false;
  51301. if (options.allowHalfOpen === false) {
  51302. this.allowHalfOpen = false;
  51303. this.once('end', onend);
  51304. }
  51305. }
  51306. }
  51307. Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
  51308. // making it explicit this property is not enumerable
  51309. // because otherwise some prototype manipulation in
  51310. // userland will fail
  51311. enumerable: false,
  51312. get: function get() {
  51313. return this._writableState.highWaterMark;
  51314. }
  51315. });
  51316. Object.defineProperty(Duplex.prototype, 'writableBuffer', {
  51317. // making it explicit this property is not enumerable
  51318. // because otherwise some prototype manipulation in
  51319. // userland will fail
  51320. enumerable: false,
  51321. get: function get() {
  51322. return this._writableState && this._writableState.getBuffer();
  51323. }
  51324. });
  51325. Object.defineProperty(Duplex.prototype, 'writableLength', {
  51326. // making it explicit this property is not enumerable
  51327. // because otherwise some prototype manipulation in
  51328. // userland will fail
  51329. enumerable: false,
  51330. get: function get() {
  51331. return this._writableState.length;
  51332. }
  51333. }); // the no-half-open enforcer
  51334. function onend() {
  51335. // If the writable side ended, then we're ok.
  51336. if (this._writableState.ended) return; // no more data can be written.
  51337. // But allow more writes to happen in this tick.
  51338. process.nextTick(onEndNT, this);
  51339. }
  51340. function onEndNT(self) {
  51341. self.end();
  51342. }
  51343. Object.defineProperty(Duplex.prototype, 'destroyed', {
  51344. // making it explicit this property is not enumerable
  51345. // because otherwise some prototype manipulation in
  51346. // userland will fail
  51347. enumerable: false,
  51348. get: function get() {
  51349. if (this._readableState === undefined || this._writableState === undefined) {
  51350. return false;
  51351. }
  51352. return this._readableState.destroyed && this._writableState.destroyed;
  51353. },
  51354. set: function set(value) {
  51355. // we ignore the value if the stream
  51356. // has not been initialized yet
  51357. if (this._readableState === undefined || this._writableState === undefined) {
  51358. return;
  51359. } // backward compatibility, the user is explicitly
  51360. // managing destroyed
  51361. this._readableState.destroyed = value;
  51362. this._writableState.destroyed = value;
  51363. }
  51364. });
  51365. /***/ }),
  51366. /***/ "../../node_modules/readable-stream/lib/_stream_passthrough.js":
  51367. /*!*********************************************************************!*\
  51368. !*** ../../node_modules/readable-stream/lib/_stream_passthrough.js ***!
  51369. \*********************************************************************/
  51370. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  51371. "use strict";
  51372. // Copyright Joyent, Inc. and other Node contributors.
  51373. //
  51374. // Permission is hereby granted, free of charge, to any person obtaining a
  51375. // copy of this software and associated documentation files (the
  51376. // "Software"), to deal in the Software without restriction, including
  51377. // without limitation the rights to use, copy, modify, merge, publish,
  51378. // distribute, sublicense, and/or sell copies of the Software, and to permit
  51379. // persons to whom the Software is furnished to do so, subject to the
  51380. // following conditions:
  51381. //
  51382. // The above copyright notice and this permission notice shall be included
  51383. // in all copies or substantial portions of the Software.
  51384. //
  51385. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  51386. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  51387. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  51388. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  51389. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  51390. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  51391. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  51392. // a passthrough stream.
  51393. // basically just the most minimal sort of Transform stream.
  51394. // Every written chunk gets output as-is.
  51395. module.exports = PassThrough;
  51396. var Transform = __webpack_require__(/*! ./_stream_transform */ "../../node_modules/readable-stream/lib/_stream_transform.js");
  51397. __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js")(PassThrough, Transform);
  51398. function PassThrough(options) {
  51399. if (!(this instanceof PassThrough)) return new PassThrough(options);
  51400. Transform.call(this, options);
  51401. }
  51402. PassThrough.prototype._transform = function (chunk, encoding, cb) {
  51403. cb(null, chunk);
  51404. };
  51405. /***/ }),
  51406. /***/ "../../node_modules/readable-stream/lib/_stream_readable.js":
  51407. /*!******************************************************************!*\
  51408. !*** ../../node_modules/readable-stream/lib/_stream_readable.js ***!
  51409. \******************************************************************/
  51410. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  51411. "use strict";
  51412. /* provided dependency */ var process = __webpack_require__(/*! process/browser */ "../../node_modules/process/browser.js");
  51413. // Copyright Joyent, Inc. and other Node contributors.
  51414. //
  51415. // Permission is hereby granted, free of charge, to any person obtaining a
  51416. // copy of this software and associated documentation files (the
  51417. // "Software"), to deal in the Software without restriction, including
  51418. // without limitation the rights to use, copy, modify, merge, publish,
  51419. // distribute, sublicense, and/or sell copies of the Software, and to permit
  51420. // persons to whom the Software is furnished to do so, subject to the
  51421. // following conditions:
  51422. //
  51423. // The above copyright notice and this permission notice shall be included
  51424. // in all copies or substantial portions of the Software.
  51425. //
  51426. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  51427. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  51428. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  51429. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  51430. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  51431. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  51432. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  51433. module.exports = Readable;
  51434. /*<replacement>*/
  51435. var Duplex;
  51436. /*</replacement>*/
  51437. Readable.ReadableState = ReadableState;
  51438. /*<replacement>*/
  51439. var EE = (__webpack_require__(/*! events */ "../../node_modules/events/events.js").EventEmitter);
  51440. var EElistenerCount = function EElistenerCount(emitter, type) {
  51441. return emitter.listeners(type).length;
  51442. };
  51443. /*</replacement>*/
  51444. /*<replacement>*/
  51445. var Stream = __webpack_require__(/*! ./internal/streams/stream */ "../../node_modules/readable-stream/lib/internal/streams/stream-browser.js");
  51446. /*</replacement>*/
  51447. var Buffer = (__webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js").Buffer);
  51448. var OurUint8Array = __webpack_require__.g.Uint8Array || function () {};
  51449. function _uint8ArrayToBuffer(chunk) {
  51450. return Buffer.from(chunk);
  51451. }
  51452. function _isUint8Array(obj) {
  51453. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  51454. }
  51455. /*<replacement>*/
  51456. var debugUtil = __webpack_require__(/*! util */ "?983a");
  51457. var debug;
  51458. if (debugUtil && debugUtil.debuglog) {
  51459. debug = debugUtil.debuglog('stream');
  51460. } else {
  51461. debug = function debug() {};
  51462. }
  51463. /*</replacement>*/
  51464. var BufferList = __webpack_require__(/*! ./internal/streams/buffer_list */ "../../node_modules/readable-stream/lib/internal/streams/buffer_list.js");
  51465. var destroyImpl = __webpack_require__(/*! ./internal/streams/destroy */ "../../node_modules/readable-stream/lib/internal/streams/destroy.js");
  51466. var _require = __webpack_require__(/*! ./internal/streams/state */ "../../node_modules/readable-stream/lib/internal/streams/state.js"),
  51467. getHighWaterMark = _require.getHighWaterMark;
  51468. var _require$codes = (__webpack_require__(/*! ../errors */ "../../node_modules/readable-stream/errors-browser.js").codes),
  51469. ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
  51470. ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF,
  51471. ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
  51472. ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT; // Lazy loaded to improve the startup performance.
  51473. var StringDecoder;
  51474. var createReadableStreamAsyncIterator;
  51475. var from;
  51476. __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js")(Readable, Stream);
  51477. var errorOrDestroy = destroyImpl.errorOrDestroy;
  51478. var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
  51479. function prependListener(emitter, event, fn) {
  51480. // Sadly this is not cacheable as some libraries bundle their own
  51481. // event emitter implementation with them.
  51482. if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); // This is a hack to make sure that our error handler is attached before any
  51483. // userland ones. NEVER DO THIS. This is here only because this code needs
  51484. // to continue to work with older versions of Node.js that do not include
  51485. // the prependListener() method. The goal is to eventually remove this hack.
  51486. if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
  51487. }
  51488. function ReadableState(options, stream, isDuplex) {
  51489. Duplex = Duplex || __webpack_require__(/*! ./_stream_duplex */ "../../node_modules/readable-stream/lib/_stream_duplex.js");
  51490. options = options || {}; // Duplex streams are both readable and writable, but share
  51491. // the same options object.
  51492. // However, some cases require setting options to different
  51493. // values for the readable and the writable sides of the duplex stream.
  51494. // These options can be provided separately as readableXXX and writableXXX.
  51495. if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag. Used to make read(n) ignore n and to
  51496. // make all the buffer merging and length checks go away
  51497. this.objectMode = !!options.objectMode;
  51498. if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; // the point at which it stops calling _read() to fill the buffer
  51499. // Note: 0 is a valid value, means "don't call _read preemptively ever"
  51500. this.highWaterMark = getHighWaterMark(this, options, 'readableHighWaterMark', isDuplex); // A linked list is used to store data chunks instead of an array because the
  51501. // linked list can remove elements from the beginning faster than
  51502. // array.shift()
  51503. this.buffer = new BufferList();
  51504. this.length = 0;
  51505. this.pipes = null;
  51506. this.pipesCount = 0;
  51507. this.flowing = null;
  51508. this.ended = false;
  51509. this.endEmitted = false;
  51510. this.reading = false; // a flag to be able to tell if the event 'readable'/'data' is emitted
  51511. // immediately, or on a later tick. We set this to true at first, because
  51512. // any actions that shouldn't happen until "later" should generally also
  51513. // not happen before the first read call.
  51514. this.sync = true; // whenever we return null, then we set a flag to say
  51515. // that we're awaiting a 'readable' event emission.
  51516. this.needReadable = false;
  51517. this.emittedReadable = false;
  51518. this.readableListening = false;
  51519. this.resumeScheduled = false;
  51520. this.paused = true; // Should close be emitted on destroy. Defaults to true.
  51521. this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'end' (and potentially 'finish')
  51522. this.autoDestroy = !!options.autoDestroy; // has it been destroyed
  51523. this.destroyed = false; // Crypto is kind of old and crusty. Historically, its default string
  51524. // encoding is 'binary' so we have to make this configurable.
  51525. // Everything else in the universe uses 'utf8', though.
  51526. this.defaultEncoding = options.defaultEncoding || 'utf8'; // the number of writers that are awaiting a drain event in .pipe()s
  51527. this.awaitDrain = 0; // if true, a maybeReadMore has been scheduled
  51528. this.readingMore = false;
  51529. this.decoder = null;
  51530. this.encoding = null;
  51531. if (options.encoding) {
  51532. if (!StringDecoder) StringDecoder = (__webpack_require__(/*! string_decoder/ */ "../../node_modules/string_decoder/lib/string_decoder.js").StringDecoder);
  51533. this.decoder = new StringDecoder(options.encoding);
  51534. this.encoding = options.encoding;
  51535. }
  51536. }
  51537. function Readable(options) {
  51538. Duplex = Duplex || __webpack_require__(/*! ./_stream_duplex */ "../../node_modules/readable-stream/lib/_stream_duplex.js");
  51539. if (!(this instanceof Readable)) return new Readable(options); // Checking for a Stream.Duplex instance is faster here instead of inside
  51540. // the ReadableState constructor, at least with V8 6.5
  51541. var isDuplex = this instanceof Duplex;
  51542. this._readableState = new ReadableState(options, this, isDuplex); // legacy
  51543. this.readable = true;
  51544. if (options) {
  51545. if (typeof options.read === 'function') this._read = options.read;
  51546. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  51547. }
  51548. Stream.call(this);
  51549. }
  51550. Object.defineProperty(Readable.prototype, 'destroyed', {
  51551. // making it explicit this property is not enumerable
  51552. // because otherwise some prototype manipulation in
  51553. // userland will fail
  51554. enumerable: false,
  51555. get: function get() {
  51556. if (this._readableState === undefined) {
  51557. return false;
  51558. }
  51559. return this._readableState.destroyed;
  51560. },
  51561. set: function set(value) {
  51562. // we ignore the value if the stream
  51563. // has not been initialized yet
  51564. if (!this._readableState) {
  51565. return;
  51566. } // backward compatibility, the user is explicitly
  51567. // managing destroyed
  51568. this._readableState.destroyed = value;
  51569. }
  51570. });
  51571. Readable.prototype.destroy = destroyImpl.destroy;
  51572. Readable.prototype._undestroy = destroyImpl.undestroy;
  51573. Readable.prototype._destroy = function (err, cb) {
  51574. cb(err);
  51575. }; // Manually shove something into the read() buffer.
  51576. // This returns true if the highWaterMark has not been hit yet,
  51577. // similar to how Writable.write() returns true if you should
  51578. // write() some more.
  51579. Readable.prototype.push = function (chunk, encoding) {
  51580. var state = this._readableState;
  51581. var skipChunkCheck;
  51582. if (!state.objectMode) {
  51583. if (typeof chunk === 'string') {
  51584. encoding = encoding || state.defaultEncoding;
  51585. if (encoding !== state.encoding) {
  51586. chunk = Buffer.from(chunk, encoding);
  51587. encoding = '';
  51588. }
  51589. skipChunkCheck = true;
  51590. }
  51591. } else {
  51592. skipChunkCheck = true;
  51593. }
  51594. return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
  51595. }; // Unshift should *always* be something directly out of read()
  51596. Readable.prototype.unshift = function (chunk) {
  51597. return readableAddChunk(this, chunk, null, true, false);
  51598. };
  51599. function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
  51600. debug('readableAddChunk', chunk);
  51601. var state = stream._readableState;
  51602. if (chunk === null) {
  51603. state.reading = false;
  51604. onEofChunk(stream, state);
  51605. } else {
  51606. var er;
  51607. if (!skipChunkCheck) er = chunkInvalid(state, chunk);
  51608. if (er) {
  51609. errorOrDestroy(stream, er);
  51610. } else if (state.objectMode || chunk && chunk.length > 0) {
  51611. if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
  51612. chunk = _uint8ArrayToBuffer(chunk);
  51613. }
  51614. if (addToFront) {
  51615. if (state.endEmitted) errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());else addChunk(stream, state, chunk, true);
  51616. } else if (state.ended) {
  51617. errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF());
  51618. } else if (state.destroyed) {
  51619. return false;
  51620. } else {
  51621. state.reading = false;
  51622. if (state.decoder && !encoding) {
  51623. chunk = state.decoder.write(chunk);
  51624. if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
  51625. } else {
  51626. addChunk(stream, state, chunk, false);
  51627. }
  51628. }
  51629. } else if (!addToFront) {
  51630. state.reading = false;
  51631. maybeReadMore(stream, state);
  51632. }
  51633. } // We can push more data if we are below the highWaterMark.
  51634. // Also, if we have no data yet, we can stand some more bytes.
  51635. // This is to work around cases where hwm=0, such as the repl.
  51636. return !state.ended && (state.length < state.highWaterMark || state.length === 0);
  51637. }
  51638. function addChunk(stream, state, chunk, addToFront) {
  51639. if (state.flowing && state.length === 0 && !state.sync) {
  51640. state.awaitDrain = 0;
  51641. stream.emit('data', chunk);
  51642. } else {
  51643. // update the buffer info.
  51644. state.length += state.objectMode ? 1 : chunk.length;
  51645. if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
  51646. if (state.needReadable) emitReadable(stream);
  51647. }
  51648. maybeReadMore(stream, state);
  51649. }
  51650. function chunkInvalid(state, chunk) {
  51651. var er;
  51652. if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
  51653. er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer', 'Uint8Array'], chunk);
  51654. }
  51655. return er;
  51656. }
  51657. Readable.prototype.isPaused = function () {
  51658. return this._readableState.flowing === false;
  51659. }; // backwards compatibility.
  51660. Readable.prototype.setEncoding = function (enc) {
  51661. if (!StringDecoder) StringDecoder = (__webpack_require__(/*! string_decoder/ */ "../../node_modules/string_decoder/lib/string_decoder.js").StringDecoder);
  51662. var decoder = new StringDecoder(enc);
  51663. this._readableState.decoder = decoder; // If setEncoding(null), decoder.encoding equals utf8
  51664. this._readableState.encoding = this._readableState.decoder.encoding; // Iterate over current buffer to convert already stored Buffers:
  51665. var p = this._readableState.buffer.head;
  51666. var content = '';
  51667. while (p !== null) {
  51668. content += decoder.write(p.data);
  51669. p = p.next;
  51670. }
  51671. this._readableState.buffer.clear();
  51672. if (content !== '') this._readableState.buffer.push(content);
  51673. this._readableState.length = content.length;
  51674. return this;
  51675. }; // Don't raise the hwm > 1GB
  51676. var MAX_HWM = 0x40000000;
  51677. function computeNewHighWaterMark(n) {
  51678. if (n >= MAX_HWM) {
  51679. // TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE.
  51680. n = MAX_HWM;
  51681. } else {
  51682. // Get the next highest power of 2 to prevent increasing hwm excessively in
  51683. // tiny amounts
  51684. n--;
  51685. n |= n >>> 1;
  51686. n |= n >>> 2;
  51687. n |= n >>> 4;
  51688. n |= n >>> 8;
  51689. n |= n >>> 16;
  51690. n++;
  51691. }
  51692. return n;
  51693. } // This function is designed to be inlinable, so please take care when making
  51694. // changes to the function body.
  51695. function howMuchToRead(n, state) {
  51696. if (n <= 0 || state.length === 0 && state.ended) return 0;
  51697. if (state.objectMode) return 1;
  51698. if (n !== n) {
  51699. // Only flow one buffer at a time
  51700. if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
  51701. } // If we're asking for more than the current hwm, then raise the hwm.
  51702. if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
  51703. if (n <= state.length) return n; // Don't have enough
  51704. if (!state.ended) {
  51705. state.needReadable = true;
  51706. return 0;
  51707. }
  51708. return state.length;
  51709. } // you can override either this method, or the async _read(n) below.
  51710. Readable.prototype.read = function (n) {
  51711. debug('read', n);
  51712. n = parseInt(n, 10);
  51713. var state = this._readableState;
  51714. var nOrig = n;
  51715. if (n !== 0) state.emittedReadable = false; // if we're doing read(0) to trigger a readable event, but we
  51716. // already have a bunch of data in the buffer, then just trigger
  51717. // the 'readable' event and move on.
  51718. if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) {
  51719. debug('read: emitReadable', state.length, state.ended);
  51720. if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
  51721. return null;
  51722. }
  51723. n = howMuchToRead(n, state); // if we've ended, and we're now clear, then finish it up.
  51724. if (n === 0 && state.ended) {
  51725. if (state.length === 0) endReadable(this);
  51726. return null;
  51727. } // All the actual chunk generation logic needs to be
  51728. // *below* the call to _read. The reason is that in certain
  51729. // synthetic stream cases, such as passthrough streams, _read
  51730. // may be a completely synchronous operation which may change
  51731. // the state of the read buffer, providing enough data when
  51732. // before there was *not* enough.
  51733. //
  51734. // So, the steps are:
  51735. // 1. Figure out what the state of things will be after we do
  51736. // a read from the buffer.
  51737. //
  51738. // 2. If that resulting state will trigger a _read, then call _read.
  51739. // Note that this may be asynchronous, or synchronous. Yes, it is
  51740. // deeply ugly to write APIs this way, but that still doesn't mean
  51741. // that the Readable class should behave improperly, as streams are
  51742. // designed to be sync/async agnostic.
  51743. // Take note if the _read call is sync or async (ie, if the read call
  51744. // has returned yet), so that we know whether or not it's safe to emit
  51745. // 'readable' etc.
  51746. //
  51747. // 3. Actually pull the requested chunks out of the buffer and return.
  51748. // if we need a readable event, then we need to do some reading.
  51749. var doRead = state.needReadable;
  51750. debug('need readable', doRead); // if we currently have less than the highWaterMark, then also read some
  51751. if (state.length === 0 || state.length - n < state.highWaterMark) {
  51752. doRead = true;
  51753. debug('length less than watermark', doRead);
  51754. } // however, if we've ended, then there's no point, and if we're already
  51755. // reading, then it's unnecessary.
  51756. if (state.ended || state.reading) {
  51757. doRead = false;
  51758. debug('reading or ended', doRead);
  51759. } else if (doRead) {
  51760. debug('do read');
  51761. state.reading = true;
  51762. state.sync = true; // if the length is currently zero, then we *need* a readable event.
  51763. if (state.length === 0) state.needReadable = true; // call internal read method
  51764. this._read(state.highWaterMark);
  51765. state.sync = false; // If _read pushed data synchronously, then `reading` will be false,
  51766. // and we need to re-evaluate how much data we can return to the user.
  51767. if (!state.reading) n = howMuchToRead(nOrig, state);
  51768. }
  51769. var ret;
  51770. if (n > 0) ret = fromList(n, state);else ret = null;
  51771. if (ret === null) {
  51772. state.needReadable = state.length <= state.highWaterMark;
  51773. n = 0;
  51774. } else {
  51775. state.length -= n;
  51776. state.awaitDrain = 0;
  51777. }
  51778. if (state.length === 0) {
  51779. // If we have nothing in the buffer, then we want to know
  51780. // as soon as we *do* get something into the buffer.
  51781. if (!state.ended) state.needReadable = true; // If we tried to read() past the EOF, then emit end on the next tick.
  51782. if (nOrig !== n && state.ended) endReadable(this);
  51783. }
  51784. if (ret !== null) this.emit('data', ret);
  51785. return ret;
  51786. };
  51787. function onEofChunk(stream, state) {
  51788. debug('onEofChunk');
  51789. if (state.ended) return;
  51790. if (state.decoder) {
  51791. var chunk = state.decoder.end();
  51792. if (chunk && chunk.length) {
  51793. state.buffer.push(chunk);
  51794. state.length += state.objectMode ? 1 : chunk.length;
  51795. }
  51796. }
  51797. state.ended = true;
  51798. if (state.sync) {
  51799. // if we are sync, wait until next tick to emit the data.
  51800. // Otherwise we risk emitting data in the flow()
  51801. // the readable code triggers during a read() call
  51802. emitReadable(stream);
  51803. } else {
  51804. // emit 'readable' now to make sure it gets picked up.
  51805. state.needReadable = false;
  51806. if (!state.emittedReadable) {
  51807. state.emittedReadable = true;
  51808. emitReadable_(stream);
  51809. }
  51810. }
  51811. } // Don't emit readable right away in sync mode, because this can trigger
  51812. // another read() call => stack overflow. This way, it might trigger
  51813. // a nextTick recursion warning, but that's not so bad.
  51814. function emitReadable(stream) {
  51815. var state = stream._readableState;
  51816. debug('emitReadable', state.needReadable, state.emittedReadable);
  51817. state.needReadable = false;
  51818. if (!state.emittedReadable) {
  51819. debug('emitReadable', state.flowing);
  51820. state.emittedReadable = true;
  51821. process.nextTick(emitReadable_, stream);
  51822. }
  51823. }
  51824. function emitReadable_(stream) {
  51825. var state = stream._readableState;
  51826. debug('emitReadable_', state.destroyed, state.length, state.ended);
  51827. if (!state.destroyed && (state.length || state.ended)) {
  51828. stream.emit('readable');
  51829. state.emittedReadable = false;
  51830. } // The stream needs another readable event if
  51831. // 1. It is not flowing, as the flow mechanism will take
  51832. // care of it.
  51833. // 2. It is not ended.
  51834. // 3. It is below the highWaterMark, so we can schedule
  51835. // another readable later.
  51836. state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark;
  51837. flow(stream);
  51838. } // at this point, the user has presumably seen the 'readable' event,
  51839. // and called read() to consume some data. that may have triggered
  51840. // in turn another _read(n) call, in which case reading = true if
  51841. // it's in progress.
  51842. // However, if we're not ended, or reading, and the length < hwm,
  51843. // then go ahead and try to read some more preemptively.
  51844. function maybeReadMore(stream, state) {
  51845. if (!state.readingMore) {
  51846. state.readingMore = true;
  51847. process.nextTick(maybeReadMore_, stream, state);
  51848. }
  51849. }
  51850. function maybeReadMore_(stream, state) {
  51851. // Attempt to read more data if we should.
  51852. //
  51853. // The conditions for reading more data are (one of):
  51854. // - Not enough data buffered (state.length < state.highWaterMark). The loop
  51855. // is responsible for filling the buffer with enough data if such data
  51856. // is available. If highWaterMark is 0 and we are not in the flowing mode
  51857. // we should _not_ attempt to buffer any extra data. We'll get more data
  51858. // when the stream consumer calls read() instead.
  51859. // - No data in the buffer, and the stream is in flowing mode. In this mode
  51860. // the loop below is responsible for ensuring read() is called. Failing to
  51861. // call read here would abort the flow and there's no other mechanism for
  51862. // continuing the flow if the stream consumer has just subscribed to the
  51863. // 'data' event.
  51864. //
  51865. // In addition to the above conditions to keep reading data, the following
  51866. // conditions prevent the data from being read:
  51867. // - The stream has ended (state.ended).
  51868. // - There is already a pending 'read' operation (state.reading). This is a
  51869. // case where the the stream has called the implementation defined _read()
  51870. // method, but they are processing the call asynchronously and have _not_
  51871. // called push() with new data. In this case we skip performing more
  51872. // read()s. The execution ends in this method again after the _read() ends
  51873. // up calling push() with more data.
  51874. while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) {
  51875. var len = state.length;
  51876. debug('maybeReadMore read 0');
  51877. stream.read(0);
  51878. if (len === state.length) // didn't get any data, stop spinning.
  51879. break;
  51880. }
  51881. state.readingMore = false;
  51882. } // abstract method. to be overridden in specific implementation classes.
  51883. // call cb(er, data) where data is <= n in length.
  51884. // for virtual (non-string, non-buffer) streams, "length" is somewhat
  51885. // arbitrary, and perhaps not very meaningful.
  51886. Readable.prototype._read = function (n) {
  51887. errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED('_read()'));
  51888. };
  51889. Readable.prototype.pipe = function (dest, pipeOpts) {
  51890. var src = this;
  51891. var state = this._readableState;
  51892. switch (state.pipesCount) {
  51893. case 0:
  51894. state.pipes = dest;
  51895. break;
  51896. case 1:
  51897. state.pipes = [state.pipes, dest];
  51898. break;
  51899. default:
  51900. state.pipes.push(dest);
  51901. break;
  51902. }
  51903. state.pipesCount += 1;
  51904. debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
  51905. var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
  51906. var endFn = doEnd ? onend : unpipe;
  51907. if (state.endEmitted) process.nextTick(endFn);else src.once('end', endFn);
  51908. dest.on('unpipe', onunpipe);
  51909. function onunpipe(readable, unpipeInfo) {
  51910. debug('onunpipe');
  51911. if (readable === src) {
  51912. if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
  51913. unpipeInfo.hasUnpiped = true;
  51914. cleanup();
  51915. }
  51916. }
  51917. }
  51918. function onend() {
  51919. debug('onend');
  51920. dest.end();
  51921. } // when the dest drains, it reduces the awaitDrain counter
  51922. // on the source. This would be more elegant with a .once()
  51923. // handler in flow(), but adding and removing repeatedly is
  51924. // too slow.
  51925. var ondrain = pipeOnDrain(src);
  51926. dest.on('drain', ondrain);
  51927. var cleanedUp = false;
  51928. function cleanup() {
  51929. debug('cleanup'); // cleanup event handlers once the pipe is broken
  51930. dest.removeListener('close', onclose);
  51931. dest.removeListener('finish', onfinish);
  51932. dest.removeListener('drain', ondrain);
  51933. dest.removeListener('error', onerror);
  51934. dest.removeListener('unpipe', onunpipe);
  51935. src.removeListener('end', onend);
  51936. src.removeListener('end', unpipe);
  51937. src.removeListener('data', ondata);
  51938. cleanedUp = true; // if the reader is waiting for a drain event from this
  51939. // specific writer, then it would cause it to never start
  51940. // flowing again.
  51941. // So, if this is awaiting a drain, then we just call it now.
  51942. // If we don't know, then assume that we are waiting for one.
  51943. if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
  51944. }
  51945. src.on('data', ondata);
  51946. function ondata(chunk) {
  51947. debug('ondata');
  51948. var ret = dest.write(chunk);
  51949. debug('dest.write', ret);
  51950. if (ret === false) {
  51951. // If the user unpiped during `dest.write()`, it is possible
  51952. // to get stuck in a permanently paused state if that write
  51953. // also returned false.
  51954. // => Check whether `dest` is still a piping destination.
  51955. if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
  51956. debug('false write response, pause', state.awaitDrain);
  51957. state.awaitDrain++;
  51958. }
  51959. src.pause();
  51960. }
  51961. } // if the dest has an error, then stop piping into it.
  51962. // however, don't suppress the throwing behavior for this.
  51963. function onerror(er) {
  51964. debug('onerror', er);
  51965. unpipe();
  51966. dest.removeListener('error', onerror);
  51967. if (EElistenerCount(dest, 'error') === 0) errorOrDestroy(dest, er);
  51968. } // Make sure our error handler is attached before userland ones.
  51969. prependListener(dest, 'error', onerror); // Both close and finish should trigger unpipe, but only once.
  51970. function onclose() {
  51971. dest.removeListener('finish', onfinish);
  51972. unpipe();
  51973. }
  51974. dest.once('close', onclose);
  51975. function onfinish() {
  51976. debug('onfinish');
  51977. dest.removeListener('close', onclose);
  51978. unpipe();
  51979. }
  51980. dest.once('finish', onfinish);
  51981. function unpipe() {
  51982. debug('unpipe');
  51983. src.unpipe(dest);
  51984. } // tell the dest that it's being piped to
  51985. dest.emit('pipe', src); // start the flow if it hasn't been started already.
  51986. if (!state.flowing) {
  51987. debug('pipe resume');
  51988. src.resume();
  51989. }
  51990. return dest;
  51991. };
  51992. function pipeOnDrain(src) {
  51993. return function pipeOnDrainFunctionResult() {
  51994. var state = src._readableState;
  51995. debug('pipeOnDrain', state.awaitDrain);
  51996. if (state.awaitDrain) state.awaitDrain--;
  51997. if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
  51998. state.flowing = true;
  51999. flow(src);
  52000. }
  52001. };
  52002. }
  52003. Readable.prototype.unpipe = function (dest) {
  52004. var state = this._readableState;
  52005. var unpipeInfo = {
  52006. hasUnpiped: false
  52007. }; // if we're not piping anywhere, then do nothing.
  52008. if (state.pipesCount === 0) return this; // just one destination. most common case.
  52009. if (state.pipesCount === 1) {
  52010. // passed in one, but it's not the right one.
  52011. if (dest && dest !== state.pipes) return this;
  52012. if (!dest) dest = state.pipes; // got a match.
  52013. state.pipes = null;
  52014. state.pipesCount = 0;
  52015. state.flowing = false;
  52016. if (dest) dest.emit('unpipe', this, unpipeInfo);
  52017. return this;
  52018. } // slow case. multiple pipe destinations.
  52019. if (!dest) {
  52020. // remove all.
  52021. var dests = state.pipes;
  52022. var len = state.pipesCount;
  52023. state.pipes = null;
  52024. state.pipesCount = 0;
  52025. state.flowing = false;
  52026. for (var i = 0; i < len; i++) {
  52027. dests[i].emit('unpipe', this, {
  52028. hasUnpiped: false
  52029. });
  52030. }
  52031. return this;
  52032. } // try to find the right one.
  52033. var index = indexOf(state.pipes, dest);
  52034. if (index === -1) return this;
  52035. state.pipes.splice(index, 1);
  52036. state.pipesCount -= 1;
  52037. if (state.pipesCount === 1) state.pipes = state.pipes[0];
  52038. dest.emit('unpipe', this, unpipeInfo);
  52039. return this;
  52040. }; // set up data events if they are asked for
  52041. // Ensure readable listeners eventually get something
  52042. Readable.prototype.on = function (ev, fn) {
  52043. var res = Stream.prototype.on.call(this, ev, fn);
  52044. var state = this._readableState;
  52045. if (ev === 'data') {
  52046. // update readableListening so that resume() may be a no-op
  52047. // a few lines down. This is needed to support once('readable').
  52048. state.readableListening = this.listenerCount('readable') > 0; // Try start flowing on next tick if stream isn't explicitly paused
  52049. if (state.flowing !== false) this.resume();
  52050. } else if (ev === 'readable') {
  52051. if (!state.endEmitted && !state.readableListening) {
  52052. state.readableListening = state.needReadable = true;
  52053. state.flowing = false;
  52054. state.emittedReadable = false;
  52055. debug('on readable', state.length, state.reading);
  52056. if (state.length) {
  52057. emitReadable(this);
  52058. } else if (!state.reading) {
  52059. process.nextTick(nReadingNextTick, this);
  52060. }
  52061. }
  52062. }
  52063. return res;
  52064. };
  52065. Readable.prototype.addListener = Readable.prototype.on;
  52066. Readable.prototype.removeListener = function (ev, fn) {
  52067. var res = Stream.prototype.removeListener.call(this, ev, fn);
  52068. if (ev === 'readable') {
  52069. // We need to check if there is someone still listening to
  52070. // readable and reset the state. However this needs to happen
  52071. // after readable has been emitted but before I/O (nextTick) to
  52072. // support once('readable', fn) cycles. This means that calling
  52073. // resume within the same tick will have no
  52074. // effect.
  52075. process.nextTick(updateReadableListening, this);
  52076. }
  52077. return res;
  52078. };
  52079. Readable.prototype.removeAllListeners = function (ev) {
  52080. var res = Stream.prototype.removeAllListeners.apply(this, arguments);
  52081. if (ev === 'readable' || ev === undefined) {
  52082. // We need to check if there is someone still listening to
  52083. // readable and reset the state. However this needs to happen
  52084. // after readable has been emitted but before I/O (nextTick) to
  52085. // support once('readable', fn) cycles. This means that calling
  52086. // resume within the same tick will have no
  52087. // effect.
  52088. process.nextTick(updateReadableListening, this);
  52089. }
  52090. return res;
  52091. };
  52092. function updateReadableListening(self) {
  52093. var state = self._readableState;
  52094. state.readableListening = self.listenerCount('readable') > 0;
  52095. if (state.resumeScheduled && !state.paused) {
  52096. // flowing needs to be set to true now, otherwise
  52097. // the upcoming resume will not flow.
  52098. state.flowing = true; // crude way to check if we should resume
  52099. } else if (self.listenerCount('data') > 0) {
  52100. self.resume();
  52101. }
  52102. }
  52103. function nReadingNextTick(self) {
  52104. debug('readable nexttick read 0');
  52105. self.read(0);
  52106. } // pause() and resume() are remnants of the legacy readable stream API
  52107. // If the user uses them, then switch into old mode.
  52108. Readable.prototype.resume = function () {
  52109. var state = this._readableState;
  52110. if (!state.flowing) {
  52111. debug('resume'); // we flow only if there is no one listening
  52112. // for readable, but we still have to call
  52113. // resume()
  52114. state.flowing = !state.readableListening;
  52115. resume(this, state);
  52116. }
  52117. state.paused = false;
  52118. return this;
  52119. };
  52120. function resume(stream, state) {
  52121. if (!state.resumeScheduled) {
  52122. state.resumeScheduled = true;
  52123. process.nextTick(resume_, stream, state);
  52124. }
  52125. }
  52126. function resume_(stream, state) {
  52127. debug('resume', state.reading);
  52128. if (!state.reading) {
  52129. stream.read(0);
  52130. }
  52131. state.resumeScheduled = false;
  52132. stream.emit('resume');
  52133. flow(stream);
  52134. if (state.flowing && !state.reading) stream.read(0);
  52135. }
  52136. Readable.prototype.pause = function () {
  52137. debug('call pause flowing=%j', this._readableState.flowing);
  52138. if (this._readableState.flowing !== false) {
  52139. debug('pause');
  52140. this._readableState.flowing = false;
  52141. this.emit('pause');
  52142. }
  52143. this._readableState.paused = true;
  52144. return this;
  52145. };
  52146. function flow(stream) {
  52147. var state = stream._readableState;
  52148. debug('flow', state.flowing);
  52149. while (state.flowing && stream.read() !== null) {
  52150. ;
  52151. }
  52152. } // wrap an old-style stream as the async data source.
  52153. // This is *not* part of the readable stream interface.
  52154. // It is an ugly unfortunate mess of history.
  52155. Readable.prototype.wrap = function (stream) {
  52156. var _this = this;
  52157. var state = this._readableState;
  52158. var paused = false;
  52159. stream.on('end', function () {
  52160. debug('wrapped end');
  52161. if (state.decoder && !state.ended) {
  52162. var chunk = state.decoder.end();
  52163. if (chunk && chunk.length) _this.push(chunk);
  52164. }
  52165. _this.push(null);
  52166. });
  52167. stream.on('data', function (chunk) {
  52168. debug('wrapped data');
  52169. if (state.decoder) chunk = state.decoder.write(chunk); // don't skip over falsy values in objectMode
  52170. if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
  52171. var ret = _this.push(chunk);
  52172. if (!ret) {
  52173. paused = true;
  52174. stream.pause();
  52175. }
  52176. }); // proxy all the other methods.
  52177. // important when wrapping filters and duplexes.
  52178. for (var i in stream) {
  52179. if (this[i] === undefined && typeof stream[i] === 'function') {
  52180. this[i] = function methodWrap(method) {
  52181. return function methodWrapReturnFunction() {
  52182. return stream[method].apply(stream, arguments);
  52183. };
  52184. }(i);
  52185. }
  52186. } // proxy certain important events.
  52187. for (var n = 0; n < kProxyEvents.length; n++) {
  52188. stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
  52189. } // when we try to consume some more bytes, simply unpause the
  52190. // underlying stream.
  52191. this._read = function (n) {
  52192. debug('wrapped _read', n);
  52193. if (paused) {
  52194. paused = false;
  52195. stream.resume();
  52196. }
  52197. };
  52198. return this;
  52199. };
  52200. if (typeof Symbol === 'function') {
  52201. Readable.prototype[Symbol.asyncIterator] = function () {
  52202. if (createReadableStreamAsyncIterator === undefined) {
  52203. createReadableStreamAsyncIterator = __webpack_require__(/*! ./internal/streams/async_iterator */ "../../node_modules/readable-stream/lib/internal/streams/async_iterator.js");
  52204. }
  52205. return createReadableStreamAsyncIterator(this);
  52206. };
  52207. }
  52208. Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
  52209. // making it explicit this property is not enumerable
  52210. // because otherwise some prototype manipulation in
  52211. // userland will fail
  52212. enumerable: false,
  52213. get: function get() {
  52214. return this._readableState.highWaterMark;
  52215. }
  52216. });
  52217. Object.defineProperty(Readable.prototype, 'readableBuffer', {
  52218. // making it explicit this property is not enumerable
  52219. // because otherwise some prototype manipulation in
  52220. // userland will fail
  52221. enumerable: false,
  52222. get: function get() {
  52223. return this._readableState && this._readableState.buffer;
  52224. }
  52225. });
  52226. Object.defineProperty(Readable.prototype, 'readableFlowing', {
  52227. // making it explicit this property is not enumerable
  52228. // because otherwise some prototype manipulation in
  52229. // userland will fail
  52230. enumerable: false,
  52231. get: function get() {
  52232. return this._readableState.flowing;
  52233. },
  52234. set: function set(state) {
  52235. if (this._readableState) {
  52236. this._readableState.flowing = state;
  52237. }
  52238. }
  52239. }); // exposed for testing purposes only.
  52240. Readable._fromList = fromList;
  52241. Object.defineProperty(Readable.prototype, 'readableLength', {
  52242. // making it explicit this property is not enumerable
  52243. // because otherwise some prototype manipulation in
  52244. // userland will fail
  52245. enumerable: false,
  52246. get: function get() {
  52247. return this._readableState.length;
  52248. }
  52249. }); // Pluck off n bytes from an array of buffers.
  52250. // Length is the combined lengths of all the buffers in the list.
  52251. // This function is designed to be inlinable, so please take care when making
  52252. // changes to the function body.
  52253. function fromList(n, state) {
  52254. // nothing buffered
  52255. if (state.length === 0) return null;
  52256. var ret;
  52257. if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
  52258. // read it all, truncate the list
  52259. if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.first();else ret = state.buffer.concat(state.length);
  52260. state.buffer.clear();
  52261. } else {
  52262. // read part of list
  52263. ret = state.buffer.consume(n, state.decoder);
  52264. }
  52265. return ret;
  52266. }
  52267. function endReadable(stream) {
  52268. var state = stream._readableState;
  52269. debug('endReadable', state.endEmitted);
  52270. if (!state.endEmitted) {
  52271. state.ended = true;
  52272. process.nextTick(endReadableNT, state, stream);
  52273. }
  52274. }
  52275. function endReadableNT(state, stream) {
  52276. debug('endReadableNT', state.endEmitted, state.length); // Check that we didn't get one last unshift.
  52277. if (!state.endEmitted && state.length === 0) {
  52278. state.endEmitted = true;
  52279. stream.readable = false;
  52280. stream.emit('end');
  52281. if (state.autoDestroy) {
  52282. // In case of duplex streams we need a way to detect
  52283. // if the writable side is ready for autoDestroy as well
  52284. var wState = stream._writableState;
  52285. if (!wState || wState.autoDestroy && wState.finished) {
  52286. stream.destroy();
  52287. }
  52288. }
  52289. }
  52290. }
  52291. if (typeof Symbol === 'function') {
  52292. Readable.from = function (iterable, opts) {
  52293. if (from === undefined) {
  52294. from = __webpack_require__(/*! ./internal/streams/from */ "../../node_modules/readable-stream/lib/internal/streams/from-browser.js");
  52295. }
  52296. return from(Readable, iterable, opts);
  52297. };
  52298. }
  52299. function indexOf(xs, x) {
  52300. for (var i = 0, l = xs.length; i < l; i++) {
  52301. if (xs[i] === x) return i;
  52302. }
  52303. return -1;
  52304. }
  52305. /***/ }),
  52306. /***/ "../../node_modules/readable-stream/lib/_stream_transform.js":
  52307. /*!*******************************************************************!*\
  52308. !*** ../../node_modules/readable-stream/lib/_stream_transform.js ***!
  52309. \*******************************************************************/
  52310. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  52311. "use strict";
  52312. // Copyright Joyent, Inc. and other Node contributors.
  52313. //
  52314. // Permission is hereby granted, free of charge, to any person obtaining a
  52315. // copy of this software and associated documentation files (the
  52316. // "Software"), to deal in the Software without restriction, including
  52317. // without limitation the rights to use, copy, modify, merge, publish,
  52318. // distribute, sublicense, and/or sell copies of the Software, and to permit
  52319. // persons to whom the Software is furnished to do so, subject to the
  52320. // following conditions:
  52321. //
  52322. // The above copyright notice and this permission notice shall be included
  52323. // in all copies or substantial portions of the Software.
  52324. //
  52325. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  52326. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  52327. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  52328. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  52329. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  52330. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  52331. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  52332. // a transform stream is a readable/writable stream where you do
  52333. // something with the data. Sometimes it's called a "filter",
  52334. // but that's not a great name for it, since that implies a thing where
  52335. // some bits pass through, and others are simply ignored. (That would
  52336. // be a valid example of a transform, of course.)
  52337. //
  52338. // While the output is causally related to the input, it's not a
  52339. // necessarily symmetric or synchronous transformation. For example,
  52340. // a zlib stream might take multiple plain-text writes(), and then
  52341. // emit a single compressed chunk some time in the future.
  52342. //
  52343. // Here's how this works:
  52344. //
  52345. // The Transform stream has all the aspects of the readable and writable
  52346. // stream classes. When you write(chunk), that calls _write(chunk,cb)
  52347. // internally, and returns false if there's a lot of pending writes
  52348. // buffered up. When you call read(), that calls _read(n) until
  52349. // there's enough pending readable data buffered up.
  52350. //
  52351. // In a transform stream, the written data is placed in a buffer. When
  52352. // _read(n) is called, it transforms the queued up data, calling the
  52353. // buffered _write cb's as it consumes chunks. If consuming a single
  52354. // written chunk would result in multiple output chunks, then the first
  52355. // outputted bit calls the readcb, and subsequent chunks just go into
  52356. // the read buffer, and will cause it to emit 'readable' if necessary.
  52357. //
  52358. // This way, back-pressure is actually determined by the reading side,
  52359. // since _read has to be called to start processing a new chunk. However,
  52360. // a pathological inflate type of transform can cause excessive buffering
  52361. // here. For example, imagine a stream where every byte of input is
  52362. // interpreted as an integer from 0-255, and then results in that many
  52363. // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
  52364. // 1kb of data being output. In this case, you could write a very small
  52365. // amount of input, and end up with a very large amount of output. In
  52366. // such a pathological inflating mechanism, there'd be no way to tell
  52367. // the system to stop doing the transform. A single 4MB write could
  52368. // cause the system to run out of memory.
  52369. //
  52370. // However, even in such a pathological case, only a single written chunk
  52371. // would be consumed, and then the rest would wait (un-transformed) until
  52372. // the results of the previous transformed chunk were consumed.
  52373. module.exports = Transform;
  52374. var _require$codes = (__webpack_require__(/*! ../errors */ "../../node_modules/readable-stream/errors-browser.js").codes),
  52375. ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
  52376. ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
  52377. ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING,
  52378. ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0;
  52379. var Duplex = __webpack_require__(/*! ./_stream_duplex */ "../../node_modules/readable-stream/lib/_stream_duplex.js");
  52380. __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js")(Transform, Duplex);
  52381. function afterTransform(er, data) {
  52382. var ts = this._transformState;
  52383. ts.transforming = false;
  52384. var cb = ts.writecb;
  52385. if (cb === null) {
  52386. return this.emit('error', new ERR_MULTIPLE_CALLBACK());
  52387. }
  52388. ts.writechunk = null;
  52389. ts.writecb = null;
  52390. if (data != null) // single equals check for both `null` and `undefined`
  52391. this.push(data);
  52392. cb(er);
  52393. var rs = this._readableState;
  52394. rs.reading = false;
  52395. if (rs.needReadable || rs.length < rs.highWaterMark) {
  52396. this._read(rs.highWaterMark);
  52397. }
  52398. }
  52399. function Transform(options) {
  52400. if (!(this instanceof Transform)) return new Transform(options);
  52401. Duplex.call(this, options);
  52402. this._transformState = {
  52403. afterTransform: afterTransform.bind(this),
  52404. needTransform: false,
  52405. transforming: false,
  52406. writecb: null,
  52407. writechunk: null,
  52408. writeencoding: null
  52409. }; // start out asking for a readable event once data is transformed.
  52410. this._readableState.needReadable = true; // we have implemented the _read method, and done the other things
  52411. // that Readable wants before the first _read call, so unset the
  52412. // sync guard flag.
  52413. this._readableState.sync = false;
  52414. if (options) {
  52415. if (typeof options.transform === 'function') this._transform = options.transform;
  52416. if (typeof options.flush === 'function') this._flush = options.flush;
  52417. } // When the writable side finishes, then flush out anything remaining.
  52418. this.on('prefinish', prefinish);
  52419. }
  52420. function prefinish() {
  52421. var _this = this;
  52422. if (typeof this._flush === 'function' && !this._readableState.destroyed) {
  52423. this._flush(function (er, data) {
  52424. done(_this, er, data);
  52425. });
  52426. } else {
  52427. done(this, null, null);
  52428. }
  52429. }
  52430. Transform.prototype.push = function (chunk, encoding) {
  52431. this._transformState.needTransform = false;
  52432. return Duplex.prototype.push.call(this, chunk, encoding);
  52433. }; // This is the part where you do stuff!
  52434. // override this function in implementation classes.
  52435. // 'chunk' is an input chunk.
  52436. //
  52437. // Call `push(newChunk)` to pass along transformed output
  52438. // to the readable side. You may call 'push' zero or more times.
  52439. //
  52440. // Call `cb(err)` when you are done with this chunk. If you pass
  52441. // an error, then that'll put the hurt on the whole operation. If you
  52442. // never call cb(), then you'll never get another chunk.
  52443. Transform.prototype._transform = function (chunk, encoding, cb) {
  52444. cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()'));
  52445. };
  52446. Transform.prototype._write = function (chunk, encoding, cb) {
  52447. var ts = this._transformState;
  52448. ts.writecb = cb;
  52449. ts.writechunk = chunk;
  52450. ts.writeencoding = encoding;
  52451. if (!ts.transforming) {
  52452. var rs = this._readableState;
  52453. if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
  52454. }
  52455. }; // Doesn't matter what the args are here.
  52456. // _transform does all the work.
  52457. // That we got here means that the readable side wants more data.
  52458. Transform.prototype._read = function (n) {
  52459. var ts = this._transformState;
  52460. if (ts.writechunk !== null && !ts.transforming) {
  52461. ts.transforming = true;
  52462. this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
  52463. } else {
  52464. // mark that we need a transform, so that any data that comes in
  52465. // will get processed, now that we've asked for it.
  52466. ts.needTransform = true;
  52467. }
  52468. };
  52469. Transform.prototype._destroy = function (err, cb) {
  52470. Duplex.prototype._destroy.call(this, err, function (err2) {
  52471. cb(err2);
  52472. });
  52473. };
  52474. function done(stream, er, data) {
  52475. if (er) return stream.emit('error', er);
  52476. if (data != null) // single equals check for both `null` and `undefined`
  52477. stream.push(data); // TODO(BridgeAR): Write a test for these two error cases
  52478. // if there's nothing in the write buffer, then that means
  52479. // that nothing more will ever be provided
  52480. if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0();
  52481. if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING();
  52482. return stream.push(null);
  52483. }
  52484. /***/ }),
  52485. /***/ "../../node_modules/readable-stream/lib/_stream_writable.js":
  52486. /*!******************************************************************!*\
  52487. !*** ../../node_modules/readable-stream/lib/_stream_writable.js ***!
  52488. \******************************************************************/
  52489. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  52490. "use strict";
  52491. /* provided dependency */ var process = __webpack_require__(/*! process/browser */ "../../node_modules/process/browser.js");
  52492. // Copyright Joyent, Inc. and other Node contributors.
  52493. //
  52494. // Permission is hereby granted, free of charge, to any person obtaining a
  52495. // copy of this software and associated documentation files (the
  52496. // "Software"), to deal in the Software without restriction, including
  52497. // without limitation the rights to use, copy, modify, merge, publish,
  52498. // distribute, sublicense, and/or sell copies of the Software, and to permit
  52499. // persons to whom the Software is furnished to do so, subject to the
  52500. // following conditions:
  52501. //
  52502. // The above copyright notice and this permission notice shall be included
  52503. // in all copies or substantial portions of the Software.
  52504. //
  52505. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  52506. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  52507. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  52508. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  52509. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  52510. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  52511. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  52512. // A bit simpler than readable streams.
  52513. // Implement an async ._write(chunk, encoding, cb), and it'll handle all
  52514. // the drain event emission and buffering.
  52515. module.exports = Writable;
  52516. /* <replacement> */
  52517. function WriteReq(chunk, encoding, cb) {
  52518. this.chunk = chunk;
  52519. this.encoding = encoding;
  52520. this.callback = cb;
  52521. this.next = null;
  52522. } // It seems a linked list but it is not
  52523. // there will be only 2 of these for each stream
  52524. function CorkedRequest(state) {
  52525. var _this = this;
  52526. this.next = null;
  52527. this.entry = null;
  52528. this.finish = function () {
  52529. onCorkedFinish(_this, state);
  52530. };
  52531. }
  52532. /* </replacement> */
  52533. /*<replacement>*/
  52534. var Duplex;
  52535. /*</replacement>*/
  52536. Writable.WritableState = WritableState;
  52537. /*<replacement>*/
  52538. var internalUtil = {
  52539. deprecate: __webpack_require__(/*! util-deprecate */ "../../node_modules/util-deprecate/browser.js")
  52540. };
  52541. /*</replacement>*/
  52542. /*<replacement>*/
  52543. var Stream = __webpack_require__(/*! ./internal/streams/stream */ "../../node_modules/readable-stream/lib/internal/streams/stream-browser.js");
  52544. /*</replacement>*/
  52545. var Buffer = (__webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js").Buffer);
  52546. var OurUint8Array = __webpack_require__.g.Uint8Array || function () {};
  52547. function _uint8ArrayToBuffer(chunk) {
  52548. return Buffer.from(chunk);
  52549. }
  52550. function _isUint8Array(obj) {
  52551. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  52552. }
  52553. var destroyImpl = __webpack_require__(/*! ./internal/streams/destroy */ "../../node_modules/readable-stream/lib/internal/streams/destroy.js");
  52554. var _require = __webpack_require__(/*! ./internal/streams/state */ "../../node_modules/readable-stream/lib/internal/streams/state.js"),
  52555. getHighWaterMark = _require.getHighWaterMark;
  52556. var _require$codes = (__webpack_require__(/*! ../errors */ "../../node_modules/readable-stream/errors-browser.js").codes),
  52557. ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
  52558. ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
  52559. ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
  52560. ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE,
  52561. ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED,
  52562. ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES,
  52563. ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END,
  52564. ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING;
  52565. var errorOrDestroy = destroyImpl.errorOrDestroy;
  52566. __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js")(Writable, Stream);
  52567. function nop() {}
  52568. function WritableState(options, stream, isDuplex) {
  52569. Duplex = Duplex || __webpack_require__(/*! ./_stream_duplex */ "../../node_modules/readable-stream/lib/_stream_duplex.js");
  52570. options = options || {}; // Duplex streams are both readable and writable, but share
  52571. // the same options object.
  52572. // However, some cases require setting options to different
  52573. // values for the readable and the writable sides of the duplex stream,
  52574. // e.g. options.readableObjectMode vs. options.writableObjectMode, etc.
  52575. if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag to indicate whether or not this stream
  52576. // contains buffers or objects.
  52577. this.objectMode = !!options.objectMode;
  52578. if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; // the point at which write() starts returning false
  52579. // Note: 0 is a valid value, means that we always return false if
  52580. // the entire buffer is not flushed immediately on write()
  52581. this.highWaterMark = getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex); // if _final has been called
  52582. this.finalCalled = false; // drain event flag.
  52583. this.needDrain = false; // at the start of calling end()
  52584. this.ending = false; // when end() has been called, and returned
  52585. this.ended = false; // when 'finish' is emitted
  52586. this.finished = false; // has it been destroyed
  52587. this.destroyed = false; // should we decode strings into buffers before passing to _write?
  52588. // this is here so that some node-core streams can optimize string
  52589. // handling at a lower level.
  52590. var noDecode = options.decodeStrings === false;
  52591. this.decodeStrings = !noDecode; // Crypto is kind of old and crusty. Historically, its default string
  52592. // encoding is 'binary' so we have to make this configurable.
  52593. // Everything else in the universe uses 'utf8', though.
  52594. this.defaultEncoding = options.defaultEncoding || 'utf8'; // not an actual buffer we keep track of, but a measurement
  52595. // of how much we're waiting to get pushed to some underlying
  52596. // socket or file.
  52597. this.length = 0; // a flag to see when we're in the middle of a write.
  52598. this.writing = false; // when true all writes will be buffered until .uncork() call
  52599. this.corked = 0; // a flag to be able to tell if the onwrite cb is called immediately,
  52600. // or on a later tick. We set this to true at first, because any
  52601. // actions that shouldn't happen until "later" should generally also
  52602. // not happen before the first write call.
  52603. this.sync = true; // a flag to know if we're processing previously buffered items, which
  52604. // may call the _write() callback in the same tick, so that we don't
  52605. // end up in an overlapped onwrite situation.
  52606. this.bufferProcessing = false; // the callback that's passed to _write(chunk,cb)
  52607. this.onwrite = function (er) {
  52608. onwrite(stream, er);
  52609. }; // the callback that the user supplies to write(chunk,encoding,cb)
  52610. this.writecb = null; // the amount that is being written when _write is called.
  52611. this.writelen = 0;
  52612. this.bufferedRequest = null;
  52613. this.lastBufferedRequest = null; // number of pending user-supplied write callbacks
  52614. // this must be 0 before 'finish' can be emitted
  52615. this.pendingcb = 0; // emit prefinish if the only thing we're waiting for is _write cbs
  52616. // This is relevant for synchronous Transform streams
  52617. this.prefinished = false; // True if the error was already emitted and should not be thrown again
  52618. this.errorEmitted = false; // Should close be emitted on destroy. Defaults to true.
  52619. this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'finish' (and potentially 'end')
  52620. this.autoDestroy = !!options.autoDestroy; // count buffered requests
  52621. this.bufferedRequestCount = 0; // allocate the first CorkedRequest, there is always
  52622. // one allocated and free to use, and we maintain at most two
  52623. this.corkedRequestsFree = new CorkedRequest(this);
  52624. }
  52625. WritableState.prototype.getBuffer = function getBuffer() {
  52626. var current = this.bufferedRequest;
  52627. var out = [];
  52628. while (current) {
  52629. out.push(current);
  52630. current = current.next;
  52631. }
  52632. return out;
  52633. };
  52634. (function () {
  52635. try {
  52636. Object.defineProperty(WritableState.prototype, 'buffer', {
  52637. get: internalUtil.deprecate(function writableStateBufferGetter() {
  52638. return this.getBuffer();
  52639. }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
  52640. });
  52641. } catch (_) {}
  52642. })(); // Test _writableState for inheritance to account for Duplex streams,
  52643. // whose prototype chain only points to Readable.
  52644. var realHasInstance;
  52645. if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
  52646. realHasInstance = Function.prototype[Symbol.hasInstance];
  52647. Object.defineProperty(Writable, Symbol.hasInstance, {
  52648. value: function value(object) {
  52649. if (realHasInstance.call(this, object)) return true;
  52650. if (this !== Writable) return false;
  52651. return object && object._writableState instanceof WritableState;
  52652. }
  52653. });
  52654. } else {
  52655. realHasInstance = function realHasInstance(object) {
  52656. return object instanceof this;
  52657. };
  52658. }
  52659. function Writable(options) {
  52660. Duplex = Duplex || __webpack_require__(/*! ./_stream_duplex */ "../../node_modules/readable-stream/lib/_stream_duplex.js"); // Writable ctor is applied to Duplexes, too.
  52661. // `realHasInstance` is necessary because using plain `instanceof`
  52662. // would return false, as no `_writableState` property is attached.
  52663. // Trying to use the custom `instanceof` for Writable here will also break the
  52664. // Node.js LazyTransform implementation, which has a non-trivial getter for
  52665. // `_writableState` that would lead to infinite recursion.
  52666. // Checking for a Stream.Duplex instance is faster here instead of inside
  52667. // the WritableState constructor, at least with V8 6.5
  52668. var isDuplex = this instanceof Duplex;
  52669. if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options);
  52670. this._writableState = new WritableState(options, this, isDuplex); // legacy.
  52671. this.writable = true;
  52672. if (options) {
  52673. if (typeof options.write === 'function') this._write = options.write;
  52674. if (typeof options.writev === 'function') this._writev = options.writev;
  52675. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  52676. if (typeof options.final === 'function') this._final = options.final;
  52677. }
  52678. Stream.call(this);
  52679. } // Otherwise people can pipe Writable streams, which is just wrong.
  52680. Writable.prototype.pipe = function () {
  52681. errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE());
  52682. };
  52683. function writeAfterEnd(stream, cb) {
  52684. var er = new ERR_STREAM_WRITE_AFTER_END(); // TODO: defer error events consistently everywhere, not just the cb
  52685. errorOrDestroy(stream, er);
  52686. process.nextTick(cb, er);
  52687. } // Checks that a user-supplied chunk is valid, especially for the particular
  52688. // mode the stream is in. Currently this means that `null` is never accepted
  52689. // and undefined/non-string values are only allowed in object mode.
  52690. function validChunk(stream, state, chunk, cb) {
  52691. var er;
  52692. if (chunk === null) {
  52693. er = new ERR_STREAM_NULL_VALUES();
  52694. } else if (typeof chunk !== 'string' && !state.objectMode) {
  52695. er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk);
  52696. }
  52697. if (er) {
  52698. errorOrDestroy(stream, er);
  52699. process.nextTick(cb, er);
  52700. return false;
  52701. }
  52702. return true;
  52703. }
  52704. Writable.prototype.write = function (chunk, encoding, cb) {
  52705. var state = this._writableState;
  52706. var ret = false;
  52707. var isBuf = !state.objectMode && _isUint8Array(chunk);
  52708. if (isBuf && !Buffer.isBuffer(chunk)) {
  52709. chunk = _uint8ArrayToBuffer(chunk);
  52710. }
  52711. if (typeof encoding === 'function') {
  52712. cb = encoding;
  52713. encoding = null;
  52714. }
  52715. if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
  52716. if (typeof cb !== 'function') cb = nop;
  52717. if (state.ending) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
  52718. state.pendingcb++;
  52719. ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
  52720. }
  52721. return ret;
  52722. };
  52723. Writable.prototype.cork = function () {
  52724. this._writableState.corked++;
  52725. };
  52726. Writable.prototype.uncork = function () {
  52727. var state = this._writableState;
  52728. if (state.corked) {
  52729. state.corked--;
  52730. if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
  52731. }
  52732. };
  52733. Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
  52734. // node::ParseEncoding() requires lower case.
  52735. if (typeof encoding === 'string') encoding = encoding.toLowerCase();
  52736. if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new ERR_UNKNOWN_ENCODING(encoding);
  52737. this._writableState.defaultEncoding = encoding;
  52738. return this;
  52739. };
  52740. Object.defineProperty(Writable.prototype, 'writableBuffer', {
  52741. // making it explicit this property is not enumerable
  52742. // because otherwise some prototype manipulation in
  52743. // userland will fail
  52744. enumerable: false,
  52745. get: function get() {
  52746. return this._writableState && this._writableState.getBuffer();
  52747. }
  52748. });
  52749. function decodeChunk(state, chunk, encoding) {
  52750. if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
  52751. chunk = Buffer.from(chunk, encoding);
  52752. }
  52753. return chunk;
  52754. }
  52755. Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
  52756. // making it explicit this property is not enumerable
  52757. // because otherwise some prototype manipulation in
  52758. // userland will fail
  52759. enumerable: false,
  52760. get: function get() {
  52761. return this._writableState.highWaterMark;
  52762. }
  52763. }); // if we're already writing something, then just put this
  52764. // in the queue, and wait our turn. Otherwise, call _write
  52765. // If we return false, then we need a drain event, so set that flag.
  52766. function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
  52767. if (!isBuf) {
  52768. var newChunk = decodeChunk(state, chunk, encoding);
  52769. if (chunk !== newChunk) {
  52770. isBuf = true;
  52771. encoding = 'buffer';
  52772. chunk = newChunk;
  52773. }
  52774. }
  52775. var len = state.objectMode ? 1 : chunk.length;
  52776. state.length += len;
  52777. var ret = state.length < state.highWaterMark; // we must ensure that previous needDrain will not be reset to false.
  52778. if (!ret) state.needDrain = true;
  52779. if (state.writing || state.corked) {
  52780. var last = state.lastBufferedRequest;
  52781. state.lastBufferedRequest = {
  52782. chunk: chunk,
  52783. encoding: encoding,
  52784. isBuf: isBuf,
  52785. callback: cb,
  52786. next: null
  52787. };
  52788. if (last) {
  52789. last.next = state.lastBufferedRequest;
  52790. } else {
  52791. state.bufferedRequest = state.lastBufferedRequest;
  52792. }
  52793. state.bufferedRequestCount += 1;
  52794. } else {
  52795. doWrite(stream, state, false, len, chunk, encoding, cb);
  52796. }
  52797. return ret;
  52798. }
  52799. function doWrite(stream, state, writev, len, chunk, encoding, cb) {
  52800. state.writelen = len;
  52801. state.writecb = cb;
  52802. state.writing = true;
  52803. state.sync = true;
  52804. if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED('write'));else if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
  52805. state.sync = false;
  52806. }
  52807. function onwriteError(stream, state, sync, er, cb) {
  52808. --state.pendingcb;
  52809. if (sync) {
  52810. // defer the callback if we are being called synchronously
  52811. // to avoid piling up things on the stack
  52812. process.nextTick(cb, er); // this can emit finish, and it will always happen
  52813. // after error
  52814. process.nextTick(finishMaybe, stream, state);
  52815. stream._writableState.errorEmitted = true;
  52816. errorOrDestroy(stream, er);
  52817. } else {
  52818. // the caller expect this to happen before if
  52819. // it is async
  52820. cb(er);
  52821. stream._writableState.errorEmitted = true;
  52822. errorOrDestroy(stream, er); // this can emit finish, but finish must
  52823. // always follow error
  52824. finishMaybe(stream, state);
  52825. }
  52826. }
  52827. function onwriteStateUpdate(state) {
  52828. state.writing = false;
  52829. state.writecb = null;
  52830. state.length -= state.writelen;
  52831. state.writelen = 0;
  52832. }
  52833. function onwrite(stream, er) {
  52834. var state = stream._writableState;
  52835. var sync = state.sync;
  52836. var cb = state.writecb;
  52837. if (typeof cb !== 'function') throw new ERR_MULTIPLE_CALLBACK();
  52838. onwriteStateUpdate(state);
  52839. if (er) onwriteError(stream, state, sync, er, cb);else {
  52840. // Check if we're actually ready to finish, but don't emit yet
  52841. var finished = needFinish(state) || stream.destroyed;
  52842. if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
  52843. clearBuffer(stream, state);
  52844. }
  52845. if (sync) {
  52846. process.nextTick(afterWrite, stream, state, finished, cb);
  52847. } else {
  52848. afterWrite(stream, state, finished, cb);
  52849. }
  52850. }
  52851. }
  52852. function afterWrite(stream, state, finished, cb) {
  52853. if (!finished) onwriteDrain(stream, state);
  52854. state.pendingcb--;
  52855. cb();
  52856. finishMaybe(stream, state);
  52857. } // Must force callback to be called on nextTick, so that we don't
  52858. // emit 'drain' before the write() consumer gets the 'false' return
  52859. // value, and has a chance to attach a 'drain' listener.
  52860. function onwriteDrain(stream, state) {
  52861. if (state.length === 0 && state.needDrain) {
  52862. state.needDrain = false;
  52863. stream.emit('drain');
  52864. }
  52865. } // if there's something in the buffer waiting, then process it
  52866. function clearBuffer(stream, state) {
  52867. state.bufferProcessing = true;
  52868. var entry = state.bufferedRequest;
  52869. if (stream._writev && entry && entry.next) {
  52870. // Fast case, write everything using _writev()
  52871. var l = state.bufferedRequestCount;
  52872. var buffer = new Array(l);
  52873. var holder = state.corkedRequestsFree;
  52874. holder.entry = entry;
  52875. var count = 0;
  52876. var allBuffers = true;
  52877. while (entry) {
  52878. buffer[count] = entry;
  52879. if (!entry.isBuf) allBuffers = false;
  52880. entry = entry.next;
  52881. count += 1;
  52882. }
  52883. buffer.allBuffers = allBuffers;
  52884. doWrite(stream, state, true, state.length, buffer, '', holder.finish); // doWrite is almost always async, defer these to save a bit of time
  52885. // as the hot path ends with doWrite
  52886. state.pendingcb++;
  52887. state.lastBufferedRequest = null;
  52888. if (holder.next) {
  52889. state.corkedRequestsFree = holder.next;
  52890. holder.next = null;
  52891. } else {
  52892. state.corkedRequestsFree = new CorkedRequest(state);
  52893. }
  52894. state.bufferedRequestCount = 0;
  52895. } else {
  52896. // Slow case, write chunks one-by-one
  52897. while (entry) {
  52898. var chunk = entry.chunk;
  52899. var encoding = entry.encoding;
  52900. var cb = entry.callback;
  52901. var len = state.objectMode ? 1 : chunk.length;
  52902. doWrite(stream, state, false, len, chunk, encoding, cb);
  52903. entry = entry.next;
  52904. state.bufferedRequestCount--; // if we didn't call the onwrite immediately, then
  52905. // it means that we need to wait until it does.
  52906. // also, that means that the chunk and cb are currently
  52907. // being processed, so move the buffer counter past them.
  52908. if (state.writing) {
  52909. break;
  52910. }
  52911. }
  52912. if (entry === null) state.lastBufferedRequest = null;
  52913. }
  52914. state.bufferedRequest = entry;
  52915. state.bufferProcessing = false;
  52916. }
  52917. Writable.prototype._write = function (chunk, encoding, cb) {
  52918. cb(new ERR_METHOD_NOT_IMPLEMENTED('_write()'));
  52919. };
  52920. Writable.prototype._writev = null;
  52921. Writable.prototype.end = function (chunk, encoding, cb) {
  52922. var state = this._writableState;
  52923. if (typeof chunk === 'function') {
  52924. cb = chunk;
  52925. chunk = null;
  52926. encoding = null;
  52927. } else if (typeof encoding === 'function') {
  52928. cb = encoding;
  52929. encoding = null;
  52930. }
  52931. if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); // .end() fully uncorks
  52932. if (state.corked) {
  52933. state.corked = 1;
  52934. this.uncork();
  52935. } // ignore unnecessary end() calls.
  52936. if (!state.ending) endWritable(this, state, cb);
  52937. return this;
  52938. };
  52939. Object.defineProperty(Writable.prototype, 'writableLength', {
  52940. // making it explicit this property is not enumerable
  52941. // because otherwise some prototype manipulation in
  52942. // userland will fail
  52943. enumerable: false,
  52944. get: function get() {
  52945. return this._writableState.length;
  52946. }
  52947. });
  52948. function needFinish(state) {
  52949. return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
  52950. }
  52951. function callFinal(stream, state) {
  52952. stream._final(function (err) {
  52953. state.pendingcb--;
  52954. if (err) {
  52955. errorOrDestroy(stream, err);
  52956. }
  52957. state.prefinished = true;
  52958. stream.emit('prefinish');
  52959. finishMaybe(stream, state);
  52960. });
  52961. }
  52962. function prefinish(stream, state) {
  52963. if (!state.prefinished && !state.finalCalled) {
  52964. if (typeof stream._final === 'function' && !state.destroyed) {
  52965. state.pendingcb++;
  52966. state.finalCalled = true;
  52967. process.nextTick(callFinal, stream, state);
  52968. } else {
  52969. state.prefinished = true;
  52970. stream.emit('prefinish');
  52971. }
  52972. }
  52973. }
  52974. function finishMaybe(stream, state) {
  52975. var need = needFinish(state);
  52976. if (need) {
  52977. prefinish(stream, state);
  52978. if (state.pendingcb === 0) {
  52979. state.finished = true;
  52980. stream.emit('finish');
  52981. if (state.autoDestroy) {
  52982. // In case of duplex streams we need a way to detect
  52983. // if the readable side is ready for autoDestroy as well
  52984. var rState = stream._readableState;
  52985. if (!rState || rState.autoDestroy && rState.endEmitted) {
  52986. stream.destroy();
  52987. }
  52988. }
  52989. }
  52990. }
  52991. return need;
  52992. }
  52993. function endWritable(stream, state, cb) {
  52994. state.ending = true;
  52995. finishMaybe(stream, state);
  52996. if (cb) {
  52997. if (state.finished) process.nextTick(cb);else stream.once('finish', cb);
  52998. }
  52999. state.ended = true;
  53000. stream.writable = false;
  53001. }
  53002. function onCorkedFinish(corkReq, state, err) {
  53003. var entry = corkReq.entry;
  53004. corkReq.entry = null;
  53005. while (entry) {
  53006. var cb = entry.callback;
  53007. state.pendingcb--;
  53008. cb(err);
  53009. entry = entry.next;
  53010. } // reuse the free corkReq.
  53011. state.corkedRequestsFree.next = corkReq;
  53012. }
  53013. Object.defineProperty(Writable.prototype, 'destroyed', {
  53014. // making it explicit this property is not enumerable
  53015. // because otherwise some prototype manipulation in
  53016. // userland will fail
  53017. enumerable: false,
  53018. get: function get() {
  53019. if (this._writableState === undefined) {
  53020. return false;
  53021. }
  53022. return this._writableState.destroyed;
  53023. },
  53024. set: function set(value) {
  53025. // we ignore the value if the stream
  53026. // has not been initialized yet
  53027. if (!this._writableState) {
  53028. return;
  53029. } // backward compatibility, the user is explicitly
  53030. // managing destroyed
  53031. this._writableState.destroyed = value;
  53032. }
  53033. });
  53034. Writable.prototype.destroy = destroyImpl.destroy;
  53035. Writable.prototype._undestroy = destroyImpl.undestroy;
  53036. Writable.prototype._destroy = function (err, cb) {
  53037. cb(err);
  53038. };
  53039. /***/ }),
  53040. /***/ "../../node_modules/readable-stream/lib/internal/streams/async_iterator.js":
  53041. /*!*********************************************************************************!*\
  53042. !*** ../../node_modules/readable-stream/lib/internal/streams/async_iterator.js ***!
  53043. \*********************************************************************************/
  53044. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  53045. "use strict";
  53046. /* provided dependency */ var process = __webpack_require__(/*! process/browser */ "../../node_modules/process/browser.js");
  53047. var _Object$setPrototypeO;
  53048. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  53049. var finished = __webpack_require__(/*! ./end-of-stream */ "../../node_modules/readable-stream/lib/internal/streams/end-of-stream.js");
  53050. var kLastResolve = Symbol('lastResolve');
  53051. var kLastReject = Symbol('lastReject');
  53052. var kError = Symbol('error');
  53053. var kEnded = Symbol('ended');
  53054. var kLastPromise = Symbol('lastPromise');
  53055. var kHandlePromise = Symbol('handlePromise');
  53056. var kStream = Symbol('stream');
  53057. function createIterResult(value, done) {
  53058. return {
  53059. value: value,
  53060. done: done
  53061. };
  53062. }
  53063. function readAndResolve(iter) {
  53064. var resolve = iter[kLastResolve];
  53065. if (resolve !== null) {
  53066. var data = iter[kStream].read(); // we defer if data is null
  53067. // we can be expecting either 'end' or
  53068. // 'error'
  53069. if (data !== null) {
  53070. iter[kLastPromise] = null;
  53071. iter[kLastResolve] = null;
  53072. iter[kLastReject] = null;
  53073. resolve(createIterResult(data, false));
  53074. }
  53075. }
  53076. }
  53077. function onReadable(iter) {
  53078. // we wait for the next tick, because it might
  53079. // emit an error with process.nextTick
  53080. process.nextTick(readAndResolve, iter);
  53081. }
  53082. function wrapForNext(lastPromise, iter) {
  53083. return function (resolve, reject) {
  53084. lastPromise.then(function () {
  53085. if (iter[kEnded]) {
  53086. resolve(createIterResult(undefined, true));
  53087. return;
  53088. }
  53089. iter[kHandlePromise](resolve, reject);
  53090. }, reject);
  53091. };
  53092. }
  53093. var AsyncIteratorPrototype = Object.getPrototypeOf(function () {});
  53094. var ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = {
  53095. get stream() {
  53096. return this[kStream];
  53097. },
  53098. next: function next() {
  53099. var _this = this;
  53100. // if we have detected an error in the meanwhile
  53101. // reject straight away
  53102. var error = this[kError];
  53103. if (error !== null) {
  53104. return Promise.reject(error);
  53105. }
  53106. if (this[kEnded]) {
  53107. return Promise.resolve(createIterResult(undefined, true));
  53108. }
  53109. if (this[kStream].destroyed) {
  53110. // We need to defer via nextTick because if .destroy(err) is
  53111. // called, the error will be emitted via nextTick, and
  53112. // we cannot guarantee that there is no error lingering around
  53113. // waiting to be emitted.
  53114. return new Promise(function (resolve, reject) {
  53115. process.nextTick(function () {
  53116. if (_this[kError]) {
  53117. reject(_this[kError]);
  53118. } else {
  53119. resolve(createIterResult(undefined, true));
  53120. }
  53121. });
  53122. });
  53123. } // if we have multiple next() calls
  53124. // we will wait for the previous Promise to finish
  53125. // this logic is optimized to support for await loops,
  53126. // where next() is only called once at a time
  53127. var lastPromise = this[kLastPromise];
  53128. var promise;
  53129. if (lastPromise) {
  53130. promise = new Promise(wrapForNext(lastPromise, this));
  53131. } else {
  53132. // fast path needed to support multiple this.push()
  53133. // without triggering the next() queue
  53134. var data = this[kStream].read();
  53135. if (data !== null) {
  53136. return Promise.resolve(createIterResult(data, false));
  53137. }
  53138. promise = new Promise(this[kHandlePromise]);
  53139. }
  53140. this[kLastPromise] = promise;
  53141. return promise;
  53142. }
  53143. }, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function () {
  53144. return this;
  53145. }), _defineProperty(_Object$setPrototypeO, "return", function _return() {
  53146. var _this2 = this;
  53147. // destroy(err, cb) is a private API
  53148. // we can guarantee we have that here, because we control the
  53149. // Readable class this is attached to
  53150. return new Promise(function (resolve, reject) {
  53151. _this2[kStream].destroy(null, function (err) {
  53152. if (err) {
  53153. reject(err);
  53154. return;
  53155. }
  53156. resolve(createIterResult(undefined, true));
  53157. });
  53158. });
  53159. }), _Object$setPrototypeO), AsyncIteratorPrototype);
  53160. var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator(stream) {
  53161. var _Object$create;
  53162. var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, {
  53163. value: stream,
  53164. writable: true
  53165. }), _defineProperty(_Object$create, kLastResolve, {
  53166. value: null,
  53167. writable: true
  53168. }), _defineProperty(_Object$create, kLastReject, {
  53169. value: null,
  53170. writable: true
  53171. }), _defineProperty(_Object$create, kError, {
  53172. value: null,
  53173. writable: true
  53174. }), _defineProperty(_Object$create, kEnded, {
  53175. value: stream._readableState.endEmitted,
  53176. writable: true
  53177. }), _defineProperty(_Object$create, kHandlePromise, {
  53178. value: function value(resolve, reject) {
  53179. var data = iterator[kStream].read();
  53180. if (data) {
  53181. iterator[kLastPromise] = null;
  53182. iterator[kLastResolve] = null;
  53183. iterator[kLastReject] = null;
  53184. resolve(createIterResult(data, false));
  53185. } else {
  53186. iterator[kLastResolve] = resolve;
  53187. iterator[kLastReject] = reject;
  53188. }
  53189. },
  53190. writable: true
  53191. }), _Object$create));
  53192. iterator[kLastPromise] = null;
  53193. finished(stream, function (err) {
  53194. if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {
  53195. var reject = iterator[kLastReject]; // reject if we are waiting for data in the Promise
  53196. // returned by next() and store the error
  53197. if (reject !== null) {
  53198. iterator[kLastPromise] = null;
  53199. iterator[kLastResolve] = null;
  53200. iterator[kLastReject] = null;
  53201. reject(err);
  53202. }
  53203. iterator[kError] = err;
  53204. return;
  53205. }
  53206. var resolve = iterator[kLastResolve];
  53207. if (resolve !== null) {
  53208. iterator[kLastPromise] = null;
  53209. iterator[kLastResolve] = null;
  53210. iterator[kLastReject] = null;
  53211. resolve(createIterResult(undefined, true));
  53212. }
  53213. iterator[kEnded] = true;
  53214. });
  53215. stream.on('readable', onReadable.bind(null, iterator));
  53216. return iterator;
  53217. };
  53218. module.exports = createReadableStreamAsyncIterator;
  53219. /***/ }),
  53220. /***/ "../../node_modules/readable-stream/lib/internal/streams/buffer_list.js":
  53221. /*!******************************************************************************!*\
  53222. !*** ../../node_modules/readable-stream/lib/internal/streams/buffer_list.js ***!
  53223. \******************************************************************************/
  53224. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  53225. "use strict";
  53226. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
  53227. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
  53228. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  53229. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  53230. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  53231. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  53232. var _require = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js"),
  53233. Buffer = _require.Buffer;
  53234. var _require2 = __webpack_require__(/*! util */ "?1dff"),
  53235. inspect = _require2.inspect;
  53236. var custom = inspect && inspect.custom || 'inspect';
  53237. function copyBuffer(src, target, offset) {
  53238. Buffer.prototype.copy.call(src, target, offset);
  53239. }
  53240. module.exports =
  53241. /*#__PURE__*/
  53242. function () {
  53243. function BufferList() {
  53244. _classCallCheck(this, BufferList);
  53245. this.head = null;
  53246. this.tail = null;
  53247. this.length = 0;
  53248. }
  53249. _createClass(BufferList, [{
  53250. key: "push",
  53251. value: function push(v) {
  53252. var entry = {
  53253. data: v,
  53254. next: null
  53255. };
  53256. if (this.length > 0) this.tail.next = entry;else this.head = entry;
  53257. this.tail = entry;
  53258. ++this.length;
  53259. }
  53260. }, {
  53261. key: "unshift",
  53262. value: function unshift(v) {
  53263. var entry = {
  53264. data: v,
  53265. next: this.head
  53266. };
  53267. if (this.length === 0) this.tail = entry;
  53268. this.head = entry;
  53269. ++this.length;
  53270. }
  53271. }, {
  53272. key: "shift",
  53273. value: function shift() {
  53274. if (this.length === 0) return;
  53275. var ret = this.head.data;
  53276. if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
  53277. --this.length;
  53278. return ret;
  53279. }
  53280. }, {
  53281. key: "clear",
  53282. value: function clear() {
  53283. this.head = this.tail = null;
  53284. this.length = 0;
  53285. }
  53286. }, {
  53287. key: "join",
  53288. value: function join(s) {
  53289. if (this.length === 0) return '';
  53290. var p = this.head;
  53291. var ret = '' + p.data;
  53292. while (p = p.next) {
  53293. ret += s + p.data;
  53294. }
  53295. return ret;
  53296. }
  53297. }, {
  53298. key: "concat",
  53299. value: function concat(n) {
  53300. if (this.length === 0) return Buffer.alloc(0);
  53301. var ret = Buffer.allocUnsafe(n >>> 0);
  53302. var p = this.head;
  53303. var i = 0;
  53304. while (p) {
  53305. copyBuffer(p.data, ret, i);
  53306. i += p.data.length;
  53307. p = p.next;
  53308. }
  53309. return ret;
  53310. } // Consumes a specified amount of bytes or characters from the buffered data.
  53311. }, {
  53312. key: "consume",
  53313. value: function consume(n, hasStrings) {
  53314. var ret;
  53315. if (n < this.head.data.length) {
  53316. // `slice` is the same for buffers and strings.
  53317. ret = this.head.data.slice(0, n);
  53318. this.head.data = this.head.data.slice(n);
  53319. } else if (n === this.head.data.length) {
  53320. // First chunk is a perfect match.
  53321. ret = this.shift();
  53322. } else {
  53323. // Result spans more than one buffer.
  53324. ret = hasStrings ? this._getString(n) : this._getBuffer(n);
  53325. }
  53326. return ret;
  53327. }
  53328. }, {
  53329. key: "first",
  53330. value: function first() {
  53331. return this.head.data;
  53332. } // Consumes a specified amount of characters from the buffered data.
  53333. }, {
  53334. key: "_getString",
  53335. value: function _getString(n) {
  53336. var p = this.head;
  53337. var c = 1;
  53338. var ret = p.data;
  53339. n -= ret.length;
  53340. while (p = p.next) {
  53341. var str = p.data;
  53342. var nb = n > str.length ? str.length : n;
  53343. if (nb === str.length) ret += str;else ret += str.slice(0, n);
  53344. n -= nb;
  53345. if (n === 0) {
  53346. if (nb === str.length) {
  53347. ++c;
  53348. if (p.next) this.head = p.next;else this.head = this.tail = null;
  53349. } else {
  53350. this.head = p;
  53351. p.data = str.slice(nb);
  53352. }
  53353. break;
  53354. }
  53355. ++c;
  53356. }
  53357. this.length -= c;
  53358. return ret;
  53359. } // Consumes a specified amount of bytes from the buffered data.
  53360. }, {
  53361. key: "_getBuffer",
  53362. value: function _getBuffer(n) {
  53363. var ret = Buffer.allocUnsafe(n);
  53364. var p = this.head;
  53365. var c = 1;
  53366. p.data.copy(ret);
  53367. n -= p.data.length;
  53368. while (p = p.next) {
  53369. var buf = p.data;
  53370. var nb = n > buf.length ? buf.length : n;
  53371. buf.copy(ret, ret.length - n, 0, nb);
  53372. n -= nb;
  53373. if (n === 0) {
  53374. if (nb === buf.length) {
  53375. ++c;
  53376. if (p.next) this.head = p.next;else this.head = this.tail = null;
  53377. } else {
  53378. this.head = p;
  53379. p.data = buf.slice(nb);
  53380. }
  53381. break;
  53382. }
  53383. ++c;
  53384. }
  53385. this.length -= c;
  53386. return ret;
  53387. } // Make sure the linked list only shows the minimal necessary information.
  53388. }, {
  53389. key: custom,
  53390. value: function value(_, options) {
  53391. return inspect(this, _objectSpread({}, options, {
  53392. // Only inspect one level.
  53393. depth: 0,
  53394. // It should not recurse.
  53395. customInspect: false
  53396. }));
  53397. }
  53398. }]);
  53399. return BufferList;
  53400. }();
  53401. /***/ }),
  53402. /***/ "../../node_modules/readable-stream/lib/internal/streams/destroy.js":
  53403. /*!**************************************************************************!*\
  53404. !*** ../../node_modules/readable-stream/lib/internal/streams/destroy.js ***!
  53405. \**************************************************************************/
  53406. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  53407. "use strict";
  53408. /* provided dependency */ var process = __webpack_require__(/*! process/browser */ "../../node_modules/process/browser.js");
  53409. // undocumented cb() API, needed for core, not for public API
  53410. function destroy(err, cb) {
  53411. var _this = this;
  53412. var readableDestroyed = this._readableState && this._readableState.destroyed;
  53413. var writableDestroyed = this._writableState && this._writableState.destroyed;
  53414. if (readableDestroyed || writableDestroyed) {
  53415. if (cb) {
  53416. cb(err);
  53417. } else if (err) {
  53418. if (!this._writableState) {
  53419. process.nextTick(emitErrorNT, this, err);
  53420. } else if (!this._writableState.errorEmitted) {
  53421. this._writableState.errorEmitted = true;
  53422. process.nextTick(emitErrorNT, this, err);
  53423. }
  53424. }
  53425. return this;
  53426. } // we set destroyed to true before firing error callbacks in order
  53427. // to make it re-entrance safe in case destroy() is called within callbacks
  53428. if (this._readableState) {
  53429. this._readableState.destroyed = true;
  53430. } // if this is a duplex stream mark the writable part as destroyed as well
  53431. if (this._writableState) {
  53432. this._writableState.destroyed = true;
  53433. }
  53434. this._destroy(err || null, function (err) {
  53435. if (!cb && err) {
  53436. if (!_this._writableState) {
  53437. process.nextTick(emitErrorAndCloseNT, _this, err);
  53438. } else if (!_this._writableState.errorEmitted) {
  53439. _this._writableState.errorEmitted = true;
  53440. process.nextTick(emitErrorAndCloseNT, _this, err);
  53441. } else {
  53442. process.nextTick(emitCloseNT, _this);
  53443. }
  53444. } else if (cb) {
  53445. process.nextTick(emitCloseNT, _this);
  53446. cb(err);
  53447. } else {
  53448. process.nextTick(emitCloseNT, _this);
  53449. }
  53450. });
  53451. return this;
  53452. }
  53453. function emitErrorAndCloseNT(self, err) {
  53454. emitErrorNT(self, err);
  53455. emitCloseNT(self);
  53456. }
  53457. function emitCloseNT(self) {
  53458. if (self._writableState && !self._writableState.emitClose) return;
  53459. if (self._readableState && !self._readableState.emitClose) return;
  53460. self.emit('close');
  53461. }
  53462. function undestroy() {
  53463. if (this._readableState) {
  53464. this._readableState.destroyed = false;
  53465. this._readableState.reading = false;
  53466. this._readableState.ended = false;
  53467. this._readableState.endEmitted = false;
  53468. }
  53469. if (this._writableState) {
  53470. this._writableState.destroyed = false;
  53471. this._writableState.ended = false;
  53472. this._writableState.ending = false;
  53473. this._writableState.finalCalled = false;
  53474. this._writableState.prefinished = false;
  53475. this._writableState.finished = false;
  53476. this._writableState.errorEmitted = false;
  53477. }
  53478. }
  53479. function emitErrorNT(self, err) {
  53480. self.emit('error', err);
  53481. }
  53482. function errorOrDestroy(stream, err) {
  53483. // We have tests that rely on errors being emitted
  53484. // in the same tick, so changing this is semver major.
  53485. // For now when you opt-in to autoDestroy we allow
  53486. // the error to be emitted nextTick. In a future
  53487. // semver major update we should change the default to this.
  53488. var rState = stream._readableState;
  53489. var wState = stream._writableState;
  53490. if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);
  53491. }
  53492. module.exports = {
  53493. destroy: destroy,
  53494. undestroy: undestroy,
  53495. errorOrDestroy: errorOrDestroy
  53496. };
  53497. /***/ }),
  53498. /***/ "../../node_modules/readable-stream/lib/internal/streams/end-of-stream.js":
  53499. /*!********************************************************************************!*\
  53500. !*** ../../node_modules/readable-stream/lib/internal/streams/end-of-stream.js ***!
  53501. \********************************************************************************/
  53502. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  53503. "use strict";
  53504. // Ported from https://github.com/mafintosh/end-of-stream with
  53505. // permission from the author, Mathias Buus (@mafintosh).
  53506. var ERR_STREAM_PREMATURE_CLOSE = (__webpack_require__(/*! ../../../errors */ "../../node_modules/readable-stream/errors-browser.js").codes.ERR_STREAM_PREMATURE_CLOSE);
  53507. function once(callback) {
  53508. var called = false;
  53509. return function () {
  53510. if (called) return;
  53511. called = true;
  53512. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  53513. args[_key] = arguments[_key];
  53514. }
  53515. callback.apply(this, args);
  53516. };
  53517. }
  53518. function noop() {}
  53519. function isRequest(stream) {
  53520. return stream.setHeader && typeof stream.abort === 'function';
  53521. }
  53522. function eos(stream, opts, callback) {
  53523. if (typeof opts === 'function') return eos(stream, null, opts);
  53524. if (!opts) opts = {};
  53525. callback = once(callback || noop);
  53526. var readable = opts.readable || opts.readable !== false && stream.readable;
  53527. var writable = opts.writable || opts.writable !== false && stream.writable;
  53528. var onlegacyfinish = function onlegacyfinish() {
  53529. if (!stream.writable) onfinish();
  53530. };
  53531. var writableEnded = stream._writableState && stream._writableState.finished;
  53532. var onfinish = function onfinish() {
  53533. writable = false;
  53534. writableEnded = true;
  53535. if (!readable) callback.call(stream);
  53536. };
  53537. var readableEnded = stream._readableState && stream._readableState.endEmitted;
  53538. var onend = function onend() {
  53539. readable = false;
  53540. readableEnded = true;
  53541. if (!writable) callback.call(stream);
  53542. };
  53543. var onerror = function onerror(err) {
  53544. callback.call(stream, err);
  53545. };
  53546. var onclose = function onclose() {
  53547. var err;
  53548. if (readable && !readableEnded) {
  53549. if (!stream._readableState || !stream._readableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();
  53550. return callback.call(stream, err);
  53551. }
  53552. if (writable && !writableEnded) {
  53553. if (!stream._writableState || !stream._writableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();
  53554. return callback.call(stream, err);
  53555. }
  53556. };
  53557. var onrequest = function onrequest() {
  53558. stream.req.on('finish', onfinish);
  53559. };
  53560. if (isRequest(stream)) {
  53561. stream.on('complete', onfinish);
  53562. stream.on('abort', onclose);
  53563. if (stream.req) onrequest();else stream.on('request', onrequest);
  53564. } else if (writable && !stream._writableState) {
  53565. // legacy streams
  53566. stream.on('end', onlegacyfinish);
  53567. stream.on('close', onlegacyfinish);
  53568. }
  53569. stream.on('end', onend);
  53570. stream.on('finish', onfinish);
  53571. if (opts.error !== false) stream.on('error', onerror);
  53572. stream.on('close', onclose);
  53573. return function () {
  53574. stream.removeListener('complete', onfinish);
  53575. stream.removeListener('abort', onclose);
  53576. stream.removeListener('request', onrequest);
  53577. if (stream.req) stream.req.removeListener('finish', onfinish);
  53578. stream.removeListener('end', onlegacyfinish);
  53579. stream.removeListener('close', onlegacyfinish);
  53580. stream.removeListener('finish', onfinish);
  53581. stream.removeListener('end', onend);
  53582. stream.removeListener('error', onerror);
  53583. stream.removeListener('close', onclose);
  53584. };
  53585. }
  53586. module.exports = eos;
  53587. /***/ }),
  53588. /***/ "../../node_modules/readable-stream/lib/internal/streams/from-browser.js":
  53589. /*!*******************************************************************************!*\
  53590. !*** ../../node_modules/readable-stream/lib/internal/streams/from-browser.js ***!
  53591. \*******************************************************************************/
  53592. /***/ ((module) => {
  53593. module.exports = function () {
  53594. throw new Error('Readable.from is not available in the browser')
  53595. };
  53596. /***/ }),
  53597. /***/ "../../node_modules/readable-stream/lib/internal/streams/pipeline.js":
  53598. /*!***************************************************************************!*\
  53599. !*** ../../node_modules/readable-stream/lib/internal/streams/pipeline.js ***!
  53600. \***************************************************************************/
  53601. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  53602. "use strict";
  53603. // Ported from https://github.com/mafintosh/pump with
  53604. // permission from the author, Mathias Buus (@mafintosh).
  53605. var eos;
  53606. function once(callback) {
  53607. var called = false;
  53608. return function () {
  53609. if (called) return;
  53610. called = true;
  53611. callback.apply(void 0, arguments);
  53612. };
  53613. }
  53614. var _require$codes = (__webpack_require__(/*! ../../../errors */ "../../node_modules/readable-stream/errors-browser.js").codes),
  53615. ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS,
  53616. ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED;
  53617. function noop(err) {
  53618. // Rethrow the error if it exists to avoid swallowing it
  53619. if (err) throw err;
  53620. }
  53621. function isRequest(stream) {
  53622. return stream.setHeader && typeof stream.abort === 'function';
  53623. }
  53624. function destroyer(stream, reading, writing, callback) {
  53625. callback = once(callback);
  53626. var closed = false;
  53627. stream.on('close', function () {
  53628. closed = true;
  53629. });
  53630. if (eos === undefined) eos = __webpack_require__(/*! ./end-of-stream */ "../../node_modules/readable-stream/lib/internal/streams/end-of-stream.js");
  53631. eos(stream, {
  53632. readable: reading,
  53633. writable: writing
  53634. }, function (err) {
  53635. if (err) return callback(err);
  53636. closed = true;
  53637. callback();
  53638. });
  53639. var destroyed = false;
  53640. return function (err) {
  53641. if (closed) return;
  53642. if (destroyed) return;
  53643. destroyed = true; // request.destroy just do .end - .abort is what we want
  53644. if (isRequest(stream)) return stream.abort();
  53645. if (typeof stream.destroy === 'function') return stream.destroy();
  53646. callback(err || new ERR_STREAM_DESTROYED('pipe'));
  53647. };
  53648. }
  53649. function call(fn) {
  53650. fn();
  53651. }
  53652. function pipe(from, to) {
  53653. return from.pipe(to);
  53654. }
  53655. function popCallback(streams) {
  53656. if (!streams.length) return noop;
  53657. if (typeof streams[streams.length - 1] !== 'function') return noop;
  53658. return streams.pop();
  53659. }
  53660. function pipeline() {
  53661. for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) {
  53662. streams[_key] = arguments[_key];
  53663. }
  53664. var callback = popCallback(streams);
  53665. if (Array.isArray(streams[0])) streams = streams[0];
  53666. if (streams.length < 2) {
  53667. throw new ERR_MISSING_ARGS('streams');
  53668. }
  53669. var error;
  53670. var destroys = streams.map(function (stream, i) {
  53671. var reading = i < streams.length - 1;
  53672. var writing = i > 0;
  53673. return destroyer(stream, reading, writing, function (err) {
  53674. if (!error) error = err;
  53675. if (err) destroys.forEach(call);
  53676. if (reading) return;
  53677. destroys.forEach(call);
  53678. callback(error);
  53679. });
  53680. });
  53681. return streams.reduce(pipe);
  53682. }
  53683. module.exports = pipeline;
  53684. /***/ }),
  53685. /***/ "../../node_modules/readable-stream/lib/internal/streams/state.js":
  53686. /*!************************************************************************!*\
  53687. !*** ../../node_modules/readable-stream/lib/internal/streams/state.js ***!
  53688. \************************************************************************/
  53689. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  53690. "use strict";
  53691. var ERR_INVALID_OPT_VALUE = (__webpack_require__(/*! ../../../errors */ "../../node_modules/readable-stream/errors-browser.js").codes.ERR_INVALID_OPT_VALUE);
  53692. function highWaterMarkFrom(options, isDuplex, duplexKey) {
  53693. return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
  53694. }
  53695. function getHighWaterMark(state, options, duplexKey, isDuplex) {
  53696. var hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
  53697. if (hwm != null) {
  53698. if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
  53699. var name = isDuplex ? duplexKey : 'highWaterMark';
  53700. throw new ERR_INVALID_OPT_VALUE(name, hwm);
  53701. }
  53702. return Math.floor(hwm);
  53703. } // Default value
  53704. return state.objectMode ? 16 : 16 * 1024;
  53705. }
  53706. module.exports = {
  53707. getHighWaterMark: getHighWaterMark
  53708. };
  53709. /***/ }),
  53710. /***/ "../../node_modules/readable-stream/lib/internal/streams/stream-browser.js":
  53711. /*!*********************************************************************************!*\
  53712. !*** ../../node_modules/readable-stream/lib/internal/streams/stream-browser.js ***!
  53713. \*********************************************************************************/
  53714. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  53715. module.exports = __webpack_require__(/*! events */ "../../node_modules/events/events.js").EventEmitter;
  53716. /***/ }),
  53717. /***/ "../../node_modules/readable-stream/readable-browser.js":
  53718. /*!**************************************************************!*\
  53719. !*** ../../node_modules/readable-stream/readable-browser.js ***!
  53720. \**************************************************************/
  53721. /***/ ((module, exports, __webpack_require__) => {
  53722. exports = module.exports = __webpack_require__(/*! ./lib/_stream_readable.js */ "../../node_modules/readable-stream/lib/_stream_readable.js");
  53723. exports.Stream = exports;
  53724. exports.Readable = exports;
  53725. exports.Writable = __webpack_require__(/*! ./lib/_stream_writable.js */ "../../node_modules/readable-stream/lib/_stream_writable.js");
  53726. exports.Duplex = __webpack_require__(/*! ./lib/_stream_duplex.js */ "../../node_modules/readable-stream/lib/_stream_duplex.js");
  53727. exports.Transform = __webpack_require__(/*! ./lib/_stream_transform.js */ "../../node_modules/readable-stream/lib/_stream_transform.js");
  53728. exports.PassThrough = __webpack_require__(/*! ./lib/_stream_passthrough.js */ "../../node_modules/readable-stream/lib/_stream_passthrough.js");
  53729. exports.finished = __webpack_require__(/*! ./lib/internal/streams/end-of-stream.js */ "../../node_modules/readable-stream/lib/internal/streams/end-of-stream.js");
  53730. exports.pipeline = __webpack_require__(/*! ./lib/internal/streams/pipeline.js */ "../../node_modules/readable-stream/lib/internal/streams/pipeline.js");
  53731. /***/ }),
  53732. /***/ "../../node_modules/ripemd160/index.js":
  53733. /*!*********************************************!*\
  53734. !*** ../../node_modules/ripemd160/index.js ***!
  53735. \*********************************************/
  53736. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  53737. "use strict";
  53738. var Buffer = (__webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js").Buffer)
  53739. var inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js")
  53740. var HashBase = __webpack_require__(/*! hash-base */ "../../node_modules/hash-base/index.js")
  53741. var ARRAY16 = new Array(16)
  53742. var zl = [
  53743. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
  53744. 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
  53745. 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
  53746. 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
  53747. 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
  53748. ]
  53749. var zr = [
  53750. 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
  53751. 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
  53752. 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
  53753. 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
  53754. 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
  53755. ]
  53756. var sl = [
  53757. 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
  53758. 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
  53759. 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
  53760. 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
  53761. 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
  53762. ]
  53763. var sr = [
  53764. 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
  53765. 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
  53766. 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
  53767. 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
  53768. 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
  53769. ]
  53770. var hl = [0x00000000, 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xa953fd4e]
  53771. var hr = [0x50a28be6, 0x5c4dd124, 0x6d703ef3, 0x7a6d76e9, 0x00000000]
  53772. function RIPEMD160 () {
  53773. HashBase.call(this, 64)
  53774. // state
  53775. this._a = 0x67452301
  53776. this._b = 0xefcdab89
  53777. this._c = 0x98badcfe
  53778. this._d = 0x10325476
  53779. this._e = 0xc3d2e1f0
  53780. }
  53781. inherits(RIPEMD160, HashBase)
  53782. RIPEMD160.prototype._update = function () {
  53783. var words = ARRAY16
  53784. for (var j = 0; j < 16; ++j) words[j] = this._block.readInt32LE(j * 4)
  53785. var al = this._a | 0
  53786. var bl = this._b | 0
  53787. var cl = this._c | 0
  53788. var dl = this._d | 0
  53789. var el = this._e | 0
  53790. var ar = this._a | 0
  53791. var br = this._b | 0
  53792. var cr = this._c | 0
  53793. var dr = this._d | 0
  53794. var er = this._e | 0
  53795. // computation
  53796. for (var i = 0; i < 80; i += 1) {
  53797. var tl
  53798. var tr
  53799. if (i < 16) {
  53800. tl = fn1(al, bl, cl, dl, el, words[zl[i]], hl[0], sl[i])
  53801. tr = fn5(ar, br, cr, dr, er, words[zr[i]], hr[0], sr[i])
  53802. } else if (i < 32) {
  53803. tl = fn2(al, bl, cl, dl, el, words[zl[i]], hl[1], sl[i])
  53804. tr = fn4(ar, br, cr, dr, er, words[zr[i]], hr[1], sr[i])
  53805. } else if (i < 48) {
  53806. tl = fn3(al, bl, cl, dl, el, words[zl[i]], hl[2], sl[i])
  53807. tr = fn3(ar, br, cr, dr, er, words[zr[i]], hr[2], sr[i])
  53808. } else if (i < 64) {
  53809. tl = fn4(al, bl, cl, dl, el, words[zl[i]], hl[3], sl[i])
  53810. tr = fn2(ar, br, cr, dr, er, words[zr[i]], hr[3], sr[i])
  53811. } else { // if (i<80) {
  53812. tl = fn5(al, bl, cl, dl, el, words[zl[i]], hl[4], sl[i])
  53813. tr = fn1(ar, br, cr, dr, er, words[zr[i]], hr[4], sr[i])
  53814. }
  53815. al = el
  53816. el = dl
  53817. dl = rotl(cl, 10)
  53818. cl = bl
  53819. bl = tl
  53820. ar = er
  53821. er = dr
  53822. dr = rotl(cr, 10)
  53823. cr = br
  53824. br = tr
  53825. }
  53826. // update state
  53827. var t = (this._b + cl + dr) | 0
  53828. this._b = (this._c + dl + er) | 0
  53829. this._c = (this._d + el + ar) | 0
  53830. this._d = (this._e + al + br) | 0
  53831. this._e = (this._a + bl + cr) | 0
  53832. this._a = t
  53833. }
  53834. RIPEMD160.prototype._digest = function () {
  53835. // create padding and handle blocks
  53836. this._block[this._blockOffset++] = 0x80
  53837. if (this._blockOffset > 56) {
  53838. this._block.fill(0, this._blockOffset, 64)
  53839. this._update()
  53840. this._blockOffset = 0
  53841. }
  53842. this._block.fill(0, this._blockOffset, 56)
  53843. this._block.writeUInt32LE(this._length[0], 56)
  53844. this._block.writeUInt32LE(this._length[1], 60)
  53845. this._update()
  53846. // produce result
  53847. var buffer = Buffer.alloc ? Buffer.alloc(20) : new Buffer(20)
  53848. buffer.writeInt32LE(this._a, 0)
  53849. buffer.writeInt32LE(this._b, 4)
  53850. buffer.writeInt32LE(this._c, 8)
  53851. buffer.writeInt32LE(this._d, 12)
  53852. buffer.writeInt32LE(this._e, 16)
  53853. return buffer
  53854. }
  53855. function rotl (x, n) {
  53856. return (x << n) | (x >>> (32 - n))
  53857. }
  53858. function fn1 (a, b, c, d, e, m, k, s) {
  53859. return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + e) | 0
  53860. }
  53861. function fn2 (a, b, c, d, e, m, k, s) {
  53862. return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + e) | 0
  53863. }
  53864. function fn3 (a, b, c, d, e, m, k, s) {
  53865. return (rotl((a + ((b | (~c)) ^ d) + m + k) | 0, s) + e) | 0
  53866. }
  53867. function fn4 (a, b, c, d, e, m, k, s) {
  53868. return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + e) | 0
  53869. }
  53870. function fn5 (a, b, c, d, e, m, k, s) {
  53871. return (rotl((a + (b ^ (c | (~d))) + m + k) | 0, s) + e) | 0
  53872. }
  53873. module.exports = RIPEMD160
  53874. /***/ }),
  53875. /***/ "../../node_modules/ripple-address-codec/dist/index.js":
  53876. /*!*************************************************************!*\
  53877. !*** ../../node_modules/ripple-address-codec/dist/index.js ***!
  53878. \*************************************************************/
  53879. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  53880. "use strict";
  53881. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js")["Buffer"];
  53882. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  53883. if (k2 === undefined) k2 = k;
  53884. var desc = Object.getOwnPropertyDescriptor(m, k);
  53885. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  53886. desc = { enumerable: true, get: function() { return m[k]; } };
  53887. }
  53888. Object.defineProperty(o, k2, desc);
  53889. }) : (function(o, m, k, k2) {
  53890. if (k2 === undefined) k2 = k;
  53891. o[k2] = m[k];
  53892. }));
  53893. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  53894. Object.defineProperty(o, "default", { enumerable: true, value: v });
  53895. }) : function(o, v) {
  53896. o["default"] = v;
  53897. });
  53898. var __importStar = (this && this.__importStar) || function (mod) {
  53899. if (mod && mod.__esModule) return mod;
  53900. var result = {};
  53901. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  53902. __setModuleDefault(result, mod);
  53903. return result;
  53904. };
  53905. Object.defineProperty(exports, "__esModule", ({ value: true }));
  53906. exports.isValidXAddress = exports.decodeXAddress = exports.xAddressToClassicAddress = exports.encodeXAddress = exports.classicAddressToXAddress = exports.isValidClassicAddress = exports.decodeAccountPublic = exports.encodeAccountPublic = exports.decodeNodePublic = exports.encodeNodePublic = exports.decodeAccountID = exports.encodeAccountID = exports.decodeSeed = exports.encodeSeed = exports.codec = void 0;
  53907. const assert = __importStar(__webpack_require__(/*! assert */ "../../node_modules/assert/build/assert.js"));
  53908. const xrp_codec_1 = __webpack_require__(/*! ./xrp-codec */ "../../node_modules/ripple-address-codec/dist/xrp-codec.js");
  53909. Object.defineProperty(exports, "codec", ({ enumerable: true, get: function () { return xrp_codec_1.codec; } }));
  53910. Object.defineProperty(exports, "encodeSeed", ({ enumerable: true, get: function () { return xrp_codec_1.encodeSeed; } }));
  53911. Object.defineProperty(exports, "decodeSeed", ({ enumerable: true, get: function () { return xrp_codec_1.decodeSeed; } }));
  53912. Object.defineProperty(exports, "encodeAccountID", ({ enumerable: true, get: function () { return xrp_codec_1.encodeAccountID; } }));
  53913. Object.defineProperty(exports, "decodeAccountID", ({ enumerable: true, get: function () { return xrp_codec_1.decodeAccountID; } }));
  53914. Object.defineProperty(exports, "encodeNodePublic", ({ enumerable: true, get: function () { return xrp_codec_1.encodeNodePublic; } }));
  53915. Object.defineProperty(exports, "decodeNodePublic", ({ enumerable: true, get: function () { return xrp_codec_1.decodeNodePublic; } }));
  53916. Object.defineProperty(exports, "encodeAccountPublic", ({ enumerable: true, get: function () { return xrp_codec_1.encodeAccountPublic; } }));
  53917. Object.defineProperty(exports, "decodeAccountPublic", ({ enumerable: true, get: function () { return xrp_codec_1.decodeAccountPublic; } }));
  53918. Object.defineProperty(exports, "isValidClassicAddress", ({ enumerable: true, get: function () { return xrp_codec_1.isValidClassicAddress; } }));
  53919. const PREFIX_BYTES = {
  53920. // 5, 68
  53921. main: Buffer.from([0x05, 0x44]),
  53922. // 4, 147
  53923. test: Buffer.from([0x04, 0x93]),
  53924. };
  53925. const MAX_32_BIT_UNSIGNED_INT = 4294967295;
  53926. function classicAddressToXAddress(classicAddress, tag, test) {
  53927. const accountId = (0, xrp_codec_1.decodeAccountID)(classicAddress);
  53928. return encodeXAddress(accountId, tag, test);
  53929. }
  53930. exports.classicAddressToXAddress = classicAddressToXAddress;
  53931. function encodeXAddress(accountId, tag, test) {
  53932. if (accountId.length !== 20) {
  53933. // RIPEMD160 is 160 bits = 20 bytes
  53934. throw new Error('Account ID must be 20 bytes');
  53935. }
  53936. if (tag > MAX_32_BIT_UNSIGNED_INT) {
  53937. throw new Error('Invalid tag');
  53938. }
  53939. const theTag = tag || 0;
  53940. // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Passing null is a common js mistake
  53941. const flag = tag === false || tag == null ? 0 : 1;
  53942. /* eslint-disable no-bitwise ---
  53943. * need to use bitwise operations here */
  53944. const bytes = Buffer.concat([
  53945. test ? PREFIX_BYTES.test : PREFIX_BYTES.main,
  53946. accountId,
  53947. Buffer.from([
  53948. // 0x00 if no tag, 0x01 if 32-bit tag
  53949. flag,
  53950. // first byte
  53951. theTag & 0xff,
  53952. // second byte
  53953. (theTag >> 8) & 0xff,
  53954. // third byte
  53955. (theTag >> 16) & 0xff,
  53956. // fourth byte
  53957. (theTag >> 24) & 0xff,
  53958. 0,
  53959. 0,
  53960. 0,
  53961. // four zero bytes (reserved for 64-bit tags)
  53962. 0,
  53963. ]),
  53964. ]);
  53965. /* eslint-enable no-bitwise */
  53966. return xrp_codec_1.codec.encodeChecked(bytes);
  53967. }
  53968. exports.encodeXAddress = encodeXAddress;
  53969. function xAddressToClassicAddress(xAddress) {
  53970. /* eslint-disable @typescript-eslint/naming-convention --
  53971. * TODO 'test' should be something like 'isTest', do this later
  53972. */
  53973. const { accountId, tag, test } = decodeXAddress(xAddress);
  53974. /* eslint-enable @typescript-eslint/naming-convention */
  53975. const classicAddress = (0, xrp_codec_1.encodeAccountID)(accountId);
  53976. return {
  53977. classicAddress,
  53978. tag,
  53979. test,
  53980. };
  53981. }
  53982. exports.xAddressToClassicAddress = xAddressToClassicAddress;
  53983. function decodeXAddress(xAddress) {
  53984. const decoded = xrp_codec_1.codec.decodeChecked(xAddress);
  53985. /* eslint-disable @typescript-eslint/naming-convention --
  53986. * TODO 'test' should be something like 'isTest', do this later
  53987. */
  53988. const test = isBufferForTestAddress(decoded);
  53989. /* eslint-enable @typescript-eslint/naming-convention */
  53990. const accountId = decoded.slice(2, 22);
  53991. const tag = tagFromBuffer(decoded);
  53992. return {
  53993. accountId,
  53994. tag,
  53995. test,
  53996. };
  53997. }
  53998. exports.decodeXAddress = decodeXAddress;
  53999. function isBufferForTestAddress(buf) {
  54000. const decodedPrefix = buf.slice(0, 2);
  54001. if (PREFIX_BYTES.main.equals(decodedPrefix)) {
  54002. return false;
  54003. }
  54004. if (PREFIX_BYTES.test.equals(decodedPrefix)) {
  54005. return true;
  54006. }
  54007. throw new Error('Invalid X-address: bad prefix');
  54008. }
  54009. function tagFromBuffer(buf) {
  54010. const flag = buf[22];
  54011. if (flag >= 2) {
  54012. // No support for 64-bit tags at this time
  54013. throw new Error('Unsupported X-address');
  54014. }
  54015. if (flag === 1) {
  54016. // Little-endian to big-endian
  54017. return buf[23] + buf[24] * 0x100 + buf[25] * 0x10000 + buf[26] * 0x1000000;
  54018. }
  54019. assert.strictEqual(flag, 0, 'flag must be zero to indicate no tag');
  54020. assert.ok(Buffer.from('0000000000000000', 'hex').equals(buf.slice(23, 23 + 8)), 'remaining bytes must be zero');
  54021. return false;
  54022. }
  54023. function isValidXAddress(xAddress) {
  54024. try {
  54025. decodeXAddress(xAddress);
  54026. }
  54027. catch (_error) {
  54028. return false;
  54029. }
  54030. return true;
  54031. }
  54032. exports.isValidXAddress = isValidXAddress;
  54033. /***/ }),
  54034. /***/ "../../node_modules/ripple-address-codec/dist/utils.js":
  54035. /*!*************************************************************!*\
  54036. !*** ../../node_modules/ripple-address-codec/dist/utils.js ***!
  54037. \*************************************************************/
  54038. /***/ ((__unused_webpack_module, exports) => {
  54039. "use strict";
  54040. Object.defineProperty(exports, "__esModule", ({ value: true }));
  54041. exports.concatArgs = exports.seqEqual = void 0;
  54042. /**
  54043. * Check whether two sequences (e.g. Arrays of numbers) are equal.
  54044. *
  54045. * @param arr1 - One of the arrays to compare.
  54046. * @param arr2 - The other array to compare.
  54047. */
  54048. function seqEqual(arr1, arr2) {
  54049. if (arr1.length !== arr2.length) {
  54050. return false;
  54051. }
  54052. for (let i = 0; i < arr1.length; i++) {
  54053. if (arr1[i] !== arr2[i]) {
  54054. return false;
  54055. }
  54056. }
  54057. return true;
  54058. }
  54059. exports.seqEqual = seqEqual;
  54060. /**
  54061. * Check whether a value is a sequence (e.g. Array of numbers).
  54062. *
  54063. * @param val - The value to check.
  54064. */
  54065. function isSequence(val) {
  54066. return typeof val !== 'number';
  54067. }
  54068. /**
  54069. * Concatenate all `arguments` into a single array. Each argument can be either
  54070. * a single element or a sequence, which has a `length` property and supports
  54071. * element retrieval via sequence[ix].
  54072. *
  54073. * > concatArgs(1, [2, 3], Buffer.from([4,5]), new Uint8Array([6, 7]));
  54074. * [1,2,3,4,5,6,7]
  54075. *
  54076. * @param args - Concatenate of these args into a single array.
  54077. * @returns Array of concatenated arguments
  54078. */
  54079. function concatArgs(...args) {
  54080. const ret = [];
  54081. args.forEach((arg) => {
  54082. if (isSequence(arg)) {
  54083. for (const j of arg) {
  54084. ret.push(j);
  54085. }
  54086. }
  54087. else {
  54088. ret.push(arg);
  54089. }
  54090. });
  54091. return ret;
  54092. }
  54093. exports.concatArgs = concatArgs;
  54094. /***/ }),
  54095. /***/ "../../node_modules/ripple-address-codec/dist/xrp-codec.js":
  54096. /*!*****************************************************************!*\
  54097. !*** ../../node_modules/ripple-address-codec/dist/xrp-codec.js ***!
  54098. \*****************************************************************/
  54099. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  54100. "use strict";
  54101. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js")["Buffer"];
  54102. /**
  54103. * Codec class
  54104. */
  54105. Object.defineProperty(exports, "__esModule", ({ value: true }));
  54106. exports.isValidClassicAddress = exports.decodeAccountPublic = exports.encodeAccountPublic = exports.encodeNodePublic = exports.decodeNodePublic = exports.decodeAddress = exports.decodeAccountID = exports.encodeAddress = exports.encodeAccountID = exports.decodeSeed = exports.encodeSeed = exports.codec = void 0;
  54107. const baseCodec = __webpack_require__(/*! base-x */ "../../node_modules/base-x/src/index.js");
  54108. const createHash = __webpack_require__(/*! create-hash */ "../../node_modules/create-hash/browser.js");
  54109. const utils_1 = __webpack_require__(/*! ./utils */ "../../node_modules/ripple-address-codec/dist/utils.js");
  54110. class Codec {
  54111. constructor(options) {
  54112. this._sha256 = options.sha256;
  54113. this._alphabet = options.alphabet;
  54114. this._codec = baseCodec(this._alphabet);
  54115. }
  54116. /**
  54117. * Encoder.
  54118. *
  54119. * @param bytes - Buffer of data to encode.
  54120. * @param opts - Options object including the version bytes and the expected length of the data to encode.
  54121. */
  54122. encode(bytes, opts) {
  54123. const versions = opts.versions;
  54124. return this._encodeVersioned(bytes, versions, opts.expectedLength);
  54125. }
  54126. /**
  54127. * Decoder.
  54128. *
  54129. * @param base58string - Base58Check-encoded string to decode.
  54130. * @param opts - Options object including the version byte(s) and the expected length of the data after decoding.
  54131. */
  54132. /* eslint-disable max-lines-per-function --
  54133. * TODO refactor */
  54134. decode(base58string, opts) {
  54135. var _a;
  54136. const versions = opts.versions;
  54137. const types = opts.versionTypes;
  54138. const withoutSum = this.decodeChecked(base58string);
  54139. if (versions.length > 1 && !opts.expectedLength) {
  54140. throw new Error('expectedLength is required because there are >= 2 possible versions');
  54141. }
  54142. const versionLengthGuess = typeof versions[0] === 'number' ? 1 : versions[0].length;
  54143. const payloadLength = (_a = opts.expectedLength) !== null && _a !== void 0 ? _a : withoutSum.length - versionLengthGuess;
  54144. const versionBytes = withoutSum.slice(0, -payloadLength);
  54145. const payload = withoutSum.slice(-payloadLength);
  54146. for (let i = 0; i < versions.length; i++) {
  54147. /* eslint-disable @typescript-eslint/consistent-type-assertions --
  54148. * TODO refactor */
  54149. const version = Array.isArray(versions[i])
  54150. ? versions[i]
  54151. : [versions[i]];
  54152. if ((0, utils_1.seqEqual)(versionBytes, version)) {
  54153. return {
  54154. version,
  54155. bytes: payload,
  54156. type: types ? types[i] : null,
  54157. };
  54158. }
  54159. /* eslint-enable @typescript-eslint/consistent-type-assertions */
  54160. }
  54161. throw new Error('version_invalid: version bytes do not match any of the provided version(s)');
  54162. }
  54163. encodeChecked(buffer) {
  54164. const check = this._sha256(this._sha256(buffer)).slice(0, 4);
  54165. return this._encodeRaw(Buffer.from((0, utils_1.concatArgs)(buffer, check)));
  54166. }
  54167. decodeChecked(base58string) {
  54168. const buffer = this._decodeRaw(base58string);
  54169. if (buffer.length < 5) {
  54170. throw new Error('invalid_input_size: decoded data must have length >= 5');
  54171. }
  54172. if (!this._verifyCheckSum(buffer)) {
  54173. throw new Error('checksum_invalid');
  54174. }
  54175. return buffer.slice(0, -4);
  54176. }
  54177. _encodeVersioned(bytes, versions, expectedLength) {
  54178. if (expectedLength && bytes.length !== expectedLength) {
  54179. throw new Error('unexpected_payload_length: bytes.length does not match expectedLength.' +
  54180. ' Ensure that the bytes are a Buffer.');
  54181. }
  54182. return this.encodeChecked(Buffer.from((0, utils_1.concatArgs)(versions, bytes)));
  54183. }
  54184. _encodeRaw(bytes) {
  54185. return this._codec.encode(bytes);
  54186. }
  54187. /* eslint-enable max-lines-per-function */
  54188. _decodeRaw(base58string) {
  54189. return this._codec.decode(base58string);
  54190. }
  54191. _verifyCheckSum(bytes) {
  54192. const computed = this._sha256(this._sha256(bytes.slice(0, -4))).slice(0, 4);
  54193. const checksum = bytes.slice(-4);
  54194. return (0, utils_1.seqEqual)(computed, checksum);
  54195. }
  54196. }
  54197. /**
  54198. * XRP codec
  54199. */
  54200. // base58 encodings: https://xrpl.org/base58-encodings.html
  54201. // Account address (20 bytes)
  54202. const ACCOUNT_ID = 0;
  54203. // Account public key (33 bytes)
  54204. const ACCOUNT_PUBLIC_KEY = 0x23;
  54205. // 33; Seed value (for secret keys) (16 bytes)
  54206. const FAMILY_SEED = 0x21;
  54207. // 28; Validation public key (33 bytes)
  54208. const NODE_PUBLIC = 0x1c;
  54209. // [1, 225, 75]
  54210. const ED25519_SEED = [0x01, 0xe1, 0x4b];
  54211. const codecOptions = {
  54212. sha256(bytes) {
  54213. return createHash('sha256').update(Buffer.from(bytes)).digest();
  54214. },
  54215. alphabet: 'rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz',
  54216. };
  54217. const codecWithXrpAlphabet = new Codec(codecOptions);
  54218. exports.codec = codecWithXrpAlphabet;
  54219. // entropy is a Buffer of size 16
  54220. // type is 'ed25519' or 'secp256k1'
  54221. function encodeSeed(entropy, type) {
  54222. if (entropy.length !== 16) {
  54223. throw new Error('entropy must have length 16');
  54224. }
  54225. const opts = {
  54226. expectedLength: 16,
  54227. // for secp256k1, use `FAMILY_SEED`
  54228. versions: type === 'ed25519' ? ED25519_SEED : [FAMILY_SEED],
  54229. };
  54230. // prefixes entropy with version bytes
  54231. return codecWithXrpAlphabet.encode(entropy, opts);
  54232. }
  54233. exports.encodeSeed = encodeSeed;
  54234. function decodeSeed(seed, opts = {
  54235. versionTypes: ['ed25519', 'secp256k1'],
  54236. versions: [ED25519_SEED, FAMILY_SEED],
  54237. expectedLength: 16,
  54238. }) {
  54239. return codecWithXrpAlphabet.decode(seed, opts);
  54240. }
  54241. exports.decodeSeed = decodeSeed;
  54242. function encodeAccountID(bytes) {
  54243. const opts = { versions: [ACCOUNT_ID], expectedLength: 20 };
  54244. return codecWithXrpAlphabet.encode(bytes, opts);
  54245. }
  54246. exports.encodeAccountID = encodeAccountID;
  54247. /* eslint-disable import/no-unused-modules ---
  54248. * unclear why this is aliased but we should keep it in case someone else is
  54249. * importing it with the aliased name */
  54250. exports.encodeAddress = encodeAccountID;
  54251. /* eslint-enable import/no-unused-modules */
  54252. function decodeAccountID(accountId) {
  54253. const opts = { versions: [ACCOUNT_ID], expectedLength: 20 };
  54254. return codecWithXrpAlphabet.decode(accountId, opts).bytes;
  54255. }
  54256. exports.decodeAccountID = decodeAccountID;
  54257. /* eslint-disable import/no-unused-modules ---
  54258. * unclear why this is aliased but we should keep it in case someone else is
  54259. * importing it with the aliased name */
  54260. exports.decodeAddress = decodeAccountID;
  54261. /* eslint-enable import/no-unused-modules */
  54262. function decodeNodePublic(base58string) {
  54263. const opts = { versions: [NODE_PUBLIC], expectedLength: 33 };
  54264. return codecWithXrpAlphabet.decode(base58string, opts).bytes;
  54265. }
  54266. exports.decodeNodePublic = decodeNodePublic;
  54267. function encodeNodePublic(bytes) {
  54268. const opts = { versions: [NODE_PUBLIC], expectedLength: 33 };
  54269. return codecWithXrpAlphabet.encode(bytes, opts);
  54270. }
  54271. exports.encodeNodePublic = encodeNodePublic;
  54272. function encodeAccountPublic(bytes) {
  54273. const opts = { versions: [ACCOUNT_PUBLIC_KEY], expectedLength: 33 };
  54274. return codecWithXrpAlphabet.encode(bytes, opts);
  54275. }
  54276. exports.encodeAccountPublic = encodeAccountPublic;
  54277. function decodeAccountPublic(base58string) {
  54278. const opts = { versions: [ACCOUNT_PUBLIC_KEY], expectedLength: 33 };
  54279. return codecWithXrpAlphabet.decode(base58string, opts).bytes;
  54280. }
  54281. exports.decodeAccountPublic = decodeAccountPublic;
  54282. function isValidClassicAddress(address) {
  54283. try {
  54284. decodeAccountID(address);
  54285. }
  54286. catch (_error) {
  54287. return false;
  54288. }
  54289. return true;
  54290. }
  54291. exports.isValidClassicAddress = isValidClassicAddress;
  54292. /***/ }),
  54293. /***/ "../../node_modules/ripple-binary-codec/dist/binary.js":
  54294. /*!*************************************************************!*\
  54295. !*** ../../node_modules/ripple-binary-codec/dist/binary.js ***!
  54296. \*************************************************************/
  54297. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  54298. "use strict";
  54299. /* eslint-disable func-style */
  54300. Object.defineProperty(exports, "__esModule", ({ value: true }));
  54301. exports.transactionID = exports.sha512Half = exports.binaryToJSON = exports.signingClaimData = exports.signingData = exports.multiSigningData = exports.readJSON = exports.serializeObject = exports.makeParser = exports.BytesList = exports.BinarySerializer = exports.BinaryParser = void 0;
  54302. const types_1 = __webpack_require__(/*! ./types */ "../../node_modules/ripple-binary-codec/dist/types/index.js");
  54303. const binary_parser_1 = __webpack_require__(/*! ./serdes/binary-parser */ "../../node_modules/ripple-binary-codec/dist/serdes/binary-parser.js");
  54304. Object.defineProperty(exports, "BinaryParser", ({ enumerable: true, get: function () { return binary_parser_1.BinaryParser; } }));
  54305. const hash_prefixes_1 = __webpack_require__(/*! ./hash-prefixes */ "../../node_modules/ripple-binary-codec/dist/hash-prefixes.js");
  54306. const binary_serializer_1 = __webpack_require__(/*! ./serdes/binary-serializer */ "../../node_modules/ripple-binary-codec/dist/serdes/binary-serializer.js");
  54307. Object.defineProperty(exports, "BinarySerializer", ({ enumerable: true, get: function () { return binary_serializer_1.BinarySerializer; } }));
  54308. Object.defineProperty(exports, "BytesList", ({ enumerable: true, get: function () { return binary_serializer_1.BytesList; } }));
  54309. const hashes_1 = __webpack_require__(/*! ./hashes */ "../../node_modules/ripple-binary-codec/dist/hashes.js");
  54310. Object.defineProperty(exports, "sha512Half", ({ enumerable: true, get: function () { return hashes_1.sha512Half; } }));
  54311. Object.defineProperty(exports, "transactionID", ({ enumerable: true, get: function () { return hashes_1.transactionID; } }));
  54312. const bigInt = __webpack_require__(/*! big-integer */ "../../node_modules/big-integer/BigInteger.js");
  54313. /**
  54314. * Construct a BinaryParser
  54315. *
  54316. * @param bytes hex-string to construct BinaryParser from
  54317. * @returns A BinaryParser
  54318. */
  54319. const makeParser = (bytes) => new binary_parser_1.BinaryParser(bytes);
  54320. exports.makeParser = makeParser;
  54321. /**
  54322. * Parse BinaryParser into JSON
  54323. *
  54324. * @param parser BinaryParser object
  54325. * @returns JSON for the bytes in the BinaryParser
  54326. */
  54327. const readJSON = (parser) => parser.readType(types_1.coreTypes.STObject).toJSON();
  54328. exports.readJSON = readJSON;
  54329. /**
  54330. * Parse a hex-string into its JSON interpretation
  54331. *
  54332. * @param bytes hex-string to parse into JSON
  54333. * @returns JSON
  54334. */
  54335. const binaryToJSON = (bytes) => readJSON(makeParser(bytes));
  54336. exports.binaryToJSON = binaryToJSON;
  54337. /**
  54338. * Function to serialize JSON object representing a transaction
  54339. *
  54340. * @param object JSON object to serialize
  54341. * @param opts options for serializing, including optional prefix, suffix, and signingFieldOnly
  54342. * @returns A Buffer containing the serialized object
  54343. */
  54344. function serializeObject(object, opts = {}) {
  54345. const { prefix, suffix, signingFieldsOnly = false } = opts;
  54346. const bytesList = new binary_serializer_1.BytesList();
  54347. if (prefix) {
  54348. bytesList.put(prefix);
  54349. }
  54350. const filter = signingFieldsOnly
  54351. ? (f) => f.isSigningField
  54352. : undefined;
  54353. types_1.coreTypes.STObject.from(object, filter).toBytesSink(bytesList);
  54354. if (suffix) {
  54355. bytesList.put(suffix);
  54356. }
  54357. return bytesList.toBytes();
  54358. }
  54359. exports.serializeObject = serializeObject;
  54360. /**
  54361. * Serialize an object for signing
  54362. *
  54363. * @param transaction Transaction to serialize
  54364. * @param prefix Prefix bytes to put before the serialized object
  54365. * @returns A Buffer with the serialized object
  54366. */
  54367. function signingData(transaction, prefix = hash_prefixes_1.HashPrefix.transactionSig) {
  54368. return serializeObject(transaction, { prefix, signingFieldsOnly: true });
  54369. }
  54370. exports.signingData = signingData;
  54371. /**
  54372. * Serialize a signingClaim
  54373. *
  54374. * @param claim A claim object to serialize
  54375. * @returns the serialized object with appropriate prefix
  54376. */
  54377. function signingClaimData(claim) {
  54378. const num = bigInt(String(claim.amount));
  54379. const prefix = hash_prefixes_1.HashPrefix.paymentChannelClaim;
  54380. const channel = types_1.coreTypes.Hash256.from(claim.channel).toBytes();
  54381. const amount = types_1.coreTypes.UInt64.from(num).toBytes();
  54382. const bytesList = new binary_serializer_1.BytesList();
  54383. bytesList.put(prefix);
  54384. bytesList.put(channel);
  54385. bytesList.put(amount);
  54386. return bytesList.toBytes();
  54387. }
  54388. exports.signingClaimData = signingClaimData;
  54389. /**
  54390. * Serialize a transaction object for multiSigning
  54391. *
  54392. * @param transaction transaction to serialize
  54393. * @param signingAccount Account to sign the transaction with
  54394. * @returns serialized transaction with appropriate prefix and suffix
  54395. */
  54396. function multiSigningData(transaction, signingAccount) {
  54397. const prefix = hash_prefixes_1.HashPrefix.transactionMultiSig;
  54398. const suffix = types_1.coreTypes.AccountID.from(signingAccount).toBytes();
  54399. return serializeObject(transaction, {
  54400. prefix,
  54401. suffix,
  54402. signingFieldsOnly: true,
  54403. });
  54404. }
  54405. exports.multiSigningData = multiSigningData;
  54406. /***/ }),
  54407. /***/ "../../node_modules/ripple-binary-codec/dist/coretypes.js":
  54408. /*!****************************************************************!*\
  54409. !*** ../../node_modules/ripple-binary-codec/dist/coretypes.js ***!
  54410. \****************************************************************/
  54411. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  54412. "use strict";
  54413. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  54414. if (k2 === undefined) k2 = k;
  54415. var desc = Object.getOwnPropertyDescriptor(m, k);
  54416. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  54417. desc = { enumerable: true, get: function() { return m[k]; } };
  54418. }
  54419. Object.defineProperty(o, k2, desc);
  54420. }) : (function(o, m, k, k2) {
  54421. if (k2 === undefined) k2 = k;
  54422. o[k2] = m[k];
  54423. }));
  54424. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  54425. Object.defineProperty(o, "default", { enumerable: true, value: v });
  54426. }) : function(o, v) {
  54427. o["default"] = v;
  54428. });
  54429. var __importStar = (this && this.__importStar) || function (mod) {
  54430. if (mod && mod.__esModule) return mod;
  54431. var result = {};
  54432. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  54433. __setModuleDefault(result, mod);
  54434. return result;
  54435. };
  54436. Object.defineProperty(exports, "__esModule", ({ value: true }));
  54437. exports.types = exports.ShaMap = exports.HashPrefix = exports.quality = exports.TransactionResult = exports.Type = exports.LedgerEntryType = exports.TransactionType = exports.Field = exports.ledgerHashes = exports.binary = exports.hashes = void 0;
  54438. const enums_1 = __webpack_require__(/*! ./enums */ "../../node_modules/ripple-binary-codec/dist/enums/index.js");
  54439. Object.defineProperty(exports, "Field", ({ enumerable: true, get: function () { return enums_1.Field; } }));
  54440. Object.defineProperty(exports, "TransactionType", ({ enumerable: true, get: function () { return enums_1.TransactionType; } }));
  54441. Object.defineProperty(exports, "LedgerEntryType", ({ enumerable: true, get: function () { return enums_1.LedgerEntryType; } }));
  54442. Object.defineProperty(exports, "Type", ({ enumerable: true, get: function () { return enums_1.Type; } }));
  54443. Object.defineProperty(exports, "TransactionResult", ({ enumerable: true, get: function () { return enums_1.TransactionResult; } }));
  54444. const types = __importStar(__webpack_require__(/*! ./types */ "../../node_modules/ripple-binary-codec/dist/types/index.js"));
  54445. exports.types = types;
  54446. const binary = __importStar(__webpack_require__(/*! ./binary */ "../../node_modules/ripple-binary-codec/dist/binary.js"));
  54447. exports.binary = binary;
  54448. const shamap_1 = __webpack_require__(/*! ./shamap */ "../../node_modules/ripple-binary-codec/dist/shamap.js");
  54449. Object.defineProperty(exports, "ShaMap", ({ enumerable: true, get: function () { return shamap_1.ShaMap; } }));
  54450. const ledgerHashes = __importStar(__webpack_require__(/*! ./ledger-hashes */ "../../node_modules/ripple-binary-codec/dist/ledger-hashes.js"));
  54451. exports.ledgerHashes = ledgerHashes;
  54452. const hashes = __importStar(__webpack_require__(/*! ./hashes */ "../../node_modules/ripple-binary-codec/dist/hashes.js"));
  54453. exports.hashes = hashes;
  54454. const quality_1 = __webpack_require__(/*! ./quality */ "../../node_modules/ripple-binary-codec/dist/quality.js");
  54455. Object.defineProperty(exports, "quality", ({ enumerable: true, get: function () { return quality_1.quality; } }));
  54456. const hash_prefixes_1 = __webpack_require__(/*! ./hash-prefixes */ "../../node_modules/ripple-binary-codec/dist/hash-prefixes.js");
  54457. Object.defineProperty(exports, "HashPrefix", ({ enumerable: true, get: function () { return hash_prefixes_1.HashPrefix; } }));
  54458. /***/ }),
  54459. /***/ "../../node_modules/ripple-binary-codec/dist/enums/index.js":
  54460. /*!******************************************************************!*\
  54461. !*** ../../node_modules/ripple-binary-codec/dist/enums/index.js ***!
  54462. \******************************************************************/
  54463. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  54464. "use strict";
  54465. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  54466. if (k2 === undefined) k2 = k;
  54467. var desc = Object.getOwnPropertyDescriptor(m, k);
  54468. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  54469. desc = { enumerable: true, get: function() { return m[k]; } };
  54470. }
  54471. Object.defineProperty(o, k2, desc);
  54472. }) : (function(o, m, k, k2) {
  54473. if (k2 === undefined) k2 = k;
  54474. o[k2] = m[k];
  54475. }));
  54476. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  54477. Object.defineProperty(o, "default", { enumerable: true, value: v });
  54478. }) : function(o, v) {
  54479. o["default"] = v;
  54480. });
  54481. var __importStar = (this && this.__importStar) || function (mod) {
  54482. if (mod && mod.__esModule) return mod;
  54483. var result = {};
  54484. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  54485. __setModuleDefault(result, mod);
  54486. return result;
  54487. };
  54488. Object.defineProperty(exports, "__esModule", ({ value: true }));
  54489. exports.TransactionType = exports.TransactionResult = exports.LedgerEntryType = exports.Type = exports.Field = exports.Bytes = exports.TRANSACTION_TYPES = void 0;
  54490. const enums = __importStar(__webpack_require__(/*! ./definitions.json */ "../../node_modules/ripple-binary-codec/dist/enums/definitions.json"));
  54491. const serialized_type_1 = __webpack_require__(/*! ../types/serialized-type */ "../../node_modules/ripple-binary-codec/dist/types/serialized-type.js");
  54492. const buffer_1 = __webpack_require__(/*! buffer/ */ "../../node_modules/ripple-binary-codec/node_modules/buffer/index.js");
  54493. /*
  54494. * @brief: All valid transaction types
  54495. */
  54496. exports.TRANSACTION_TYPES = Object.entries(enums.TRANSACTION_TYPES)
  54497. .filter(([_key, value]) => value >= 0)
  54498. .map(([key, _value]) => key);
  54499. const TYPE_WIDTH = 2;
  54500. const LEDGER_ENTRY_WIDTH = 2;
  54501. const TRANSACTION_TYPE_WIDTH = 2;
  54502. const TRANSACTION_RESULT_WIDTH = 1;
  54503. /*
  54504. * @brief: Serialize a field based on type_code and Field.nth
  54505. */
  54506. function fieldHeader(type, nth) {
  54507. const header = [];
  54508. if (type < 16) {
  54509. if (nth < 16) {
  54510. header.push((type << 4) | nth);
  54511. }
  54512. else {
  54513. header.push(type << 4, nth);
  54514. }
  54515. }
  54516. else if (nth < 16) {
  54517. header.push(nth, type);
  54518. }
  54519. else {
  54520. header.push(0, type, nth);
  54521. }
  54522. return buffer_1.Buffer.from(header);
  54523. }
  54524. /*
  54525. * @brief: Bytes, name, and ordinal representing one type, ledger_type, transaction type, or result
  54526. */
  54527. class Bytes {
  54528. constructor(name, ordinal, ordinalWidth) {
  54529. this.name = name;
  54530. this.ordinal = ordinal;
  54531. this.ordinalWidth = ordinalWidth;
  54532. this.bytes = buffer_1.Buffer.alloc(ordinalWidth);
  54533. for (let i = 0; i < ordinalWidth; i++) {
  54534. this.bytes[ordinalWidth - i - 1] = (ordinal >>> (i * 8)) & 0xff;
  54535. }
  54536. }
  54537. toJSON() {
  54538. return this.name;
  54539. }
  54540. toBytesSink(sink) {
  54541. sink.put(this.bytes);
  54542. }
  54543. toBytes() {
  54544. return this.bytes;
  54545. }
  54546. }
  54547. exports.Bytes = Bytes;
  54548. /*
  54549. * @brief: Collection of Bytes objects, mapping bidirectionally
  54550. */
  54551. class BytesLookup {
  54552. constructor(types, ordinalWidth) {
  54553. this.ordinalWidth = ordinalWidth;
  54554. Object.entries(types).forEach(([k, v]) => {
  54555. this[k] = new Bytes(k, v, ordinalWidth);
  54556. this[v.toString()] = this[k];
  54557. });
  54558. }
  54559. from(value) {
  54560. return value instanceof Bytes ? value : this[value];
  54561. }
  54562. fromParser(parser) {
  54563. return this.from(parser.readUIntN(this.ordinalWidth).toString());
  54564. }
  54565. }
  54566. function buildField([name, info]) {
  54567. const typeOrdinal = enums.TYPES[info.type];
  54568. const field = fieldHeader(typeOrdinal, info.nth);
  54569. return {
  54570. name: name,
  54571. nth: info.nth,
  54572. isVariableLengthEncoded: info.isVLEncoded,
  54573. isSerialized: info.isSerialized,
  54574. isSigningField: info.isSigningField,
  54575. ordinal: (typeOrdinal << 16) | info.nth,
  54576. type: new Bytes(info.type, typeOrdinal, TYPE_WIDTH),
  54577. header: field,
  54578. associatedType: serialized_type_1.SerializedType, // For later assignment in ./types/index.js
  54579. };
  54580. }
  54581. /*
  54582. * @brief: The collection of all fields as defined in definitions.json
  54583. */
  54584. class FieldLookup {
  54585. constructor(fields) {
  54586. fields.forEach(([k, v]) => {
  54587. this[k] = buildField([k, v]);
  54588. this[this[k].ordinal.toString()] = this[k];
  54589. });
  54590. }
  54591. fromString(value) {
  54592. return this[value];
  54593. }
  54594. }
  54595. const Type = new BytesLookup(enums.TYPES, TYPE_WIDTH);
  54596. exports.Type = Type;
  54597. const LedgerEntryType = new BytesLookup(enums.LEDGER_ENTRY_TYPES, LEDGER_ENTRY_WIDTH);
  54598. exports.LedgerEntryType = LedgerEntryType;
  54599. const TransactionType = new BytesLookup(enums.TRANSACTION_TYPES, TRANSACTION_TYPE_WIDTH);
  54600. exports.TransactionType = TransactionType;
  54601. const TransactionResult = new BytesLookup(enums.TRANSACTION_RESULTS, TRANSACTION_RESULT_WIDTH);
  54602. exports.TransactionResult = TransactionResult;
  54603. const Field = new FieldLookup(enums.FIELDS);
  54604. exports.Field = Field;
  54605. /***/ }),
  54606. /***/ "../../node_modules/ripple-binary-codec/dist/hash-prefixes.js":
  54607. /*!********************************************************************!*\
  54608. !*** ../../node_modules/ripple-binary-codec/dist/hash-prefixes.js ***!
  54609. \********************************************************************/
  54610. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  54611. "use strict";
  54612. Object.defineProperty(exports, "__esModule", ({ value: true }));
  54613. exports.HashPrefix = void 0;
  54614. const buffer_1 = __webpack_require__(/*! buffer/ */ "../../node_modules/ripple-binary-codec/node_modules/buffer/index.js");
  54615. /**
  54616. * Write a 32 bit integer to a Buffer
  54617. *
  54618. * @param uint32 32 bit integer to write to buffer
  54619. * @returns a buffer with the bytes representation of uint32
  54620. */
  54621. function bytes(uint32) {
  54622. const result = buffer_1.Buffer.alloc(4);
  54623. result.writeUInt32BE(uint32, 0);
  54624. return result;
  54625. }
  54626. /**
  54627. * Maps HashPrefix names to their byte representation
  54628. */
  54629. const HashPrefix = {
  54630. transactionID: bytes(0x54584e00),
  54631. // transaction plus metadata
  54632. transaction: bytes(0x534e4400),
  54633. // account state
  54634. accountStateEntry: bytes(0x4d4c4e00),
  54635. // inner node in tree
  54636. innerNode: bytes(0x4d494e00),
  54637. // ledger master data for signing
  54638. ledgerHeader: bytes(0x4c575200),
  54639. // inner transaction to sign
  54640. transactionSig: bytes(0x53545800),
  54641. // inner transaction to sign
  54642. transactionMultiSig: bytes(0x534d5400),
  54643. // validation for signing
  54644. validation: bytes(0x56414c00),
  54645. // proposal for signing
  54646. proposal: bytes(0x50525000),
  54647. // payment channel claim
  54648. paymentChannelClaim: bytes(0x434c4d00),
  54649. };
  54650. exports.HashPrefix = HashPrefix;
  54651. /***/ }),
  54652. /***/ "../../node_modules/ripple-binary-codec/dist/hashes.js":
  54653. /*!*************************************************************!*\
  54654. !*** ../../node_modules/ripple-binary-codec/dist/hashes.js ***!
  54655. \*************************************************************/
  54656. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  54657. "use strict";
  54658. Object.defineProperty(exports, "__esModule", ({ value: true }));
  54659. exports.transactionID = exports.sha512Half = exports.Sha512Half = void 0;
  54660. const hash_prefixes_1 = __webpack_require__(/*! ./hash-prefixes */ "../../node_modules/ripple-binary-codec/dist/hash-prefixes.js");
  54661. const createHash = __webpack_require__(/*! create-hash */ "../../node_modules/create-hash/browser.js");
  54662. const hash_256_1 = __webpack_require__(/*! ./types/hash-256 */ "../../node_modules/ripple-binary-codec/dist/types/hash-256.js");
  54663. const binary_serializer_1 = __webpack_require__(/*! ./serdes/binary-serializer */ "../../node_modules/ripple-binary-codec/dist/serdes/binary-serializer.js");
  54664. const buffer_1 = __webpack_require__(/*! buffer/ */ "../../node_modules/ripple-binary-codec/node_modules/buffer/index.js");
  54665. /**
  54666. * Class for hashing with SHA512
  54667. * @extends BytesList So SerializedTypes can write bytes to a Sha512Half
  54668. */
  54669. class Sha512Half extends binary_serializer_1.BytesList {
  54670. constructor() {
  54671. super(...arguments);
  54672. this.hash = createHash('sha512');
  54673. }
  54674. /**
  54675. * Construct a new Sha512Hash and write bytes this.hash
  54676. *
  54677. * @param bytes bytes to write to this.hash
  54678. * @returns the new Sha512Hash object
  54679. */
  54680. static put(bytes) {
  54681. return new Sha512Half().put(bytes);
  54682. }
  54683. /**
  54684. * Write bytes to an existing Sha512Hash
  54685. *
  54686. * @param bytes bytes to write to object
  54687. * @returns the Sha512 object
  54688. */
  54689. put(bytes) {
  54690. this.hash.update(bytes);
  54691. return this;
  54692. }
  54693. /**
  54694. * Compute SHA512 hash and slice in half
  54695. *
  54696. * @returns half of a SHA512 hash
  54697. */
  54698. finish256() {
  54699. return buffer_1.Buffer.from(this.hash.digest().slice(0, 32));
  54700. }
  54701. /**
  54702. * Constructs a Hash256 from the Sha512Half object
  54703. *
  54704. * @returns a Hash256 object
  54705. */
  54706. finish() {
  54707. return new hash_256_1.Hash256(this.finish256());
  54708. }
  54709. }
  54710. exports.Sha512Half = Sha512Half;
  54711. /**
  54712. * compute SHA512 hash of a list of bytes
  54713. *
  54714. * @param args zero or more arguments to hash
  54715. * @returns the sha512half hash of the arguments.
  54716. */
  54717. function sha512Half(...args) {
  54718. const hash = new Sha512Half();
  54719. args.forEach((a) => hash.put(a));
  54720. return hash.finish256();
  54721. }
  54722. exports.sha512Half = sha512Half;
  54723. /**
  54724. * Construct a transactionID from a Serialized Transaction
  54725. *
  54726. * @param serialized bytes to hash
  54727. * @returns a Hash256 object
  54728. */
  54729. function transactionID(serialized) {
  54730. return new hash_256_1.Hash256(sha512Half(hash_prefixes_1.HashPrefix.transactionID, serialized));
  54731. }
  54732. exports.transactionID = transactionID;
  54733. /***/ }),
  54734. /***/ "../../node_modules/ripple-binary-codec/dist/index.js":
  54735. /*!************************************************************!*\
  54736. !*** ../../node_modules/ripple-binary-codec/dist/index.js ***!
  54737. \************************************************************/
  54738. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  54739. "use strict";
  54740. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  54741. if (k2 === undefined) k2 = k;
  54742. var desc = Object.getOwnPropertyDescriptor(m, k);
  54743. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  54744. desc = { enumerable: true, get: function() { return m[k]; } };
  54745. }
  54746. Object.defineProperty(o, k2, desc);
  54747. }) : (function(o, m, k, k2) {
  54748. if (k2 === undefined) k2 = k;
  54749. o[k2] = m[k];
  54750. }));
  54751. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  54752. Object.defineProperty(o, "default", { enumerable: true, value: v });
  54753. }) : function(o, v) {
  54754. o["default"] = v;
  54755. });
  54756. var __importStar = (this && this.__importStar) || function (mod) {
  54757. if (mod && mod.__esModule) return mod;
  54758. var result = {};
  54759. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  54760. __setModuleDefault(result, mod);
  54761. return result;
  54762. };
  54763. Object.defineProperty(exports, "__esModule", ({ value: true }));
  54764. exports.TRANSACTION_TYPES = exports.decodeLedgerData = exports.decodeQuality = exports.encodeQuality = exports.encodeForMultisigning = exports.encodeForSigningClaim = exports.encodeForSigning = exports.encode = exports.decode = void 0;
  54765. const assert = __importStar(__webpack_require__(/*! assert */ "../../node_modules/assert/build/assert.js"));
  54766. const coretypes_1 = __webpack_require__(/*! ./coretypes */ "../../node_modules/ripple-binary-codec/dist/coretypes.js");
  54767. const ledger_hashes_1 = __webpack_require__(/*! ./ledger-hashes */ "../../node_modules/ripple-binary-codec/dist/ledger-hashes.js");
  54768. Object.defineProperty(exports, "decodeLedgerData", ({ enumerable: true, get: function () { return ledger_hashes_1.decodeLedgerData; } }));
  54769. const enums_1 = __webpack_require__(/*! ./enums */ "../../node_modules/ripple-binary-codec/dist/enums/index.js");
  54770. Object.defineProperty(exports, "TRANSACTION_TYPES", ({ enumerable: true, get: function () { return enums_1.TRANSACTION_TYPES; } }));
  54771. const { signingData, signingClaimData, multiSigningData, binaryToJSON, serializeObject, } = coretypes_1.binary;
  54772. /**
  54773. * Decode a transaction
  54774. *
  54775. * @param binary hex-string of the encoded transaction
  54776. * @returns the JSON representation of the transaction
  54777. */
  54778. function decode(binary) {
  54779. assert.ok(typeof binary === 'string', 'binary must be a hex string');
  54780. return binaryToJSON(binary);
  54781. }
  54782. exports.decode = decode;
  54783. /**
  54784. * Encode a transaction
  54785. *
  54786. * @param json The JSON representation of a transaction
  54787. * @returns A hex-string of the encoded transaction
  54788. */
  54789. function encode(json) {
  54790. assert.ok(typeof json === 'object');
  54791. return serializeObject(json)
  54792. .toString('hex')
  54793. .toUpperCase();
  54794. }
  54795. exports.encode = encode;
  54796. /**
  54797. * Encode a transaction and prepare for signing
  54798. *
  54799. * @param json JSON object representing the transaction
  54800. * @param signer string representing the account to sign the transaction with
  54801. * @returns a hex string of the encoded transaction
  54802. */
  54803. function encodeForSigning(json) {
  54804. assert.ok(typeof json === 'object');
  54805. return signingData(json)
  54806. .toString('hex')
  54807. .toUpperCase();
  54808. }
  54809. exports.encodeForSigning = encodeForSigning;
  54810. /**
  54811. * Encode a transaction and prepare for signing with a claim
  54812. *
  54813. * @param json JSON object representing the transaction
  54814. * @param signer string representing the account to sign the transaction with
  54815. * @returns a hex string of the encoded transaction
  54816. */
  54817. function encodeForSigningClaim(json) {
  54818. assert.ok(typeof json === 'object');
  54819. return signingClaimData(json)
  54820. .toString('hex')
  54821. .toUpperCase();
  54822. }
  54823. exports.encodeForSigningClaim = encodeForSigningClaim;
  54824. /**
  54825. * Encode a transaction and prepare for multi-signing
  54826. *
  54827. * @param json JSON object representing the transaction
  54828. * @param signer string representing the account to sign the transaction with
  54829. * @returns a hex string of the encoded transaction
  54830. */
  54831. function encodeForMultisigning(json, signer) {
  54832. assert.ok(typeof json === 'object');
  54833. assert.equal(json['SigningPubKey'], '');
  54834. return multiSigningData(json, signer)
  54835. .toString('hex')
  54836. .toUpperCase();
  54837. }
  54838. exports.encodeForMultisigning = encodeForMultisigning;
  54839. /**
  54840. * Encode a quality value
  54841. *
  54842. * @param value string representation of a number
  54843. * @returns a hex-string representing the quality
  54844. */
  54845. function encodeQuality(value) {
  54846. assert.ok(typeof value === 'string');
  54847. return coretypes_1.quality.encode(value).toString('hex').toUpperCase();
  54848. }
  54849. exports.encodeQuality = encodeQuality;
  54850. /**
  54851. * Decode a quality value
  54852. *
  54853. * @param value hex-string of a quality
  54854. * @returns a string representing the quality
  54855. */
  54856. function decodeQuality(value) {
  54857. assert.ok(typeof value === 'string');
  54858. return coretypes_1.quality.decode(value).toString();
  54859. }
  54860. exports.decodeQuality = decodeQuality;
  54861. /***/ }),
  54862. /***/ "../../node_modules/ripple-binary-codec/dist/ledger-hashes.js":
  54863. /*!********************************************************************!*\
  54864. !*** ../../node_modules/ripple-binary-codec/dist/ledger-hashes.js ***!
  54865. \********************************************************************/
  54866. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  54867. "use strict";
  54868. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  54869. if (k2 === undefined) k2 = k;
  54870. var desc = Object.getOwnPropertyDescriptor(m, k);
  54871. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  54872. desc = { enumerable: true, get: function() { return m[k]; } };
  54873. }
  54874. Object.defineProperty(o, k2, desc);
  54875. }) : (function(o, m, k, k2) {
  54876. if (k2 === undefined) k2 = k;
  54877. o[k2] = m[k];
  54878. }));
  54879. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  54880. Object.defineProperty(o, "default", { enumerable: true, value: v });
  54881. }) : function(o, v) {
  54882. o["default"] = v;
  54883. });
  54884. var __importStar = (this && this.__importStar) || function (mod) {
  54885. if (mod && mod.__esModule) return mod;
  54886. var result = {};
  54887. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  54888. __setModuleDefault(result, mod);
  54889. return result;
  54890. };
  54891. Object.defineProperty(exports, "__esModule", ({ value: true }));
  54892. exports.decodeLedgerData = exports.ledgerHash = exports.transactionTreeHash = exports.accountStateHash = void 0;
  54893. const assert = __importStar(__webpack_require__(/*! assert */ "../../node_modules/assert/build/assert.js"));
  54894. const shamap_1 = __webpack_require__(/*! ./shamap */ "../../node_modules/ripple-binary-codec/dist/shamap.js");
  54895. const hash_prefixes_1 = __webpack_require__(/*! ./hash-prefixes */ "../../node_modules/ripple-binary-codec/dist/hash-prefixes.js");
  54896. const hashes_1 = __webpack_require__(/*! ./hashes */ "../../node_modules/ripple-binary-codec/dist/hashes.js");
  54897. const binary_1 = __webpack_require__(/*! ./binary */ "../../node_modules/ripple-binary-codec/dist/binary.js");
  54898. const hash_256_1 = __webpack_require__(/*! ./types/hash-256 */ "../../node_modules/ripple-binary-codec/dist/types/hash-256.js");
  54899. const st_object_1 = __webpack_require__(/*! ./types/st-object */ "../../node_modules/ripple-binary-codec/dist/types/st-object.js");
  54900. const uint_64_1 = __webpack_require__(/*! ./types/uint-64 */ "../../node_modules/ripple-binary-codec/dist/types/uint-64.js");
  54901. const uint_32_1 = __webpack_require__(/*! ./types/uint-32 */ "../../node_modules/ripple-binary-codec/dist/types/uint-32.js");
  54902. const uint_8_1 = __webpack_require__(/*! ./types/uint-8 */ "../../node_modules/ripple-binary-codec/dist/types/uint-8.js");
  54903. const binary_parser_1 = __webpack_require__(/*! ./serdes/binary-parser */ "../../node_modules/ripple-binary-codec/dist/serdes/binary-parser.js");
  54904. const bigInt = __webpack_require__(/*! big-integer */ "../../node_modules/big-integer/BigInteger.js");
  54905. /**
  54906. * Computes the hash of a list of objects
  54907. *
  54908. * @param itemizer Converts an item into a format that can be added to SHAMap
  54909. * @param itemsJson Array of items to add to a SHAMap
  54910. * @returns the hash of the SHAMap
  54911. */
  54912. function computeHash(itemizer, itemsJson) {
  54913. const map = new shamap_1.ShaMap();
  54914. itemsJson.forEach((item) => map.addItem(...itemizer(item)));
  54915. return map.hash();
  54916. }
  54917. /**
  54918. * Convert a transaction into an index and an item
  54919. *
  54920. * @param json transaction with metadata
  54921. * @returns a tuple of index and item to be added to SHAMap
  54922. */
  54923. function transactionItemizer(json) {
  54924. assert.ok(json.hash);
  54925. const index = hash_256_1.Hash256.from(json.hash);
  54926. const item = {
  54927. hashPrefix() {
  54928. return hash_prefixes_1.HashPrefix.transaction;
  54929. },
  54930. toBytesSink(sink) {
  54931. const serializer = new binary_1.BinarySerializer(sink);
  54932. serializer.writeLengthEncoded(st_object_1.STObject.from(json));
  54933. serializer.writeLengthEncoded(st_object_1.STObject.from(json.metaData));
  54934. },
  54935. };
  54936. return [index, item, undefined];
  54937. }
  54938. /**
  54939. * Convert an entry to a pair Hash256 and ShaMapNode
  54940. *
  54941. * @param json JSON describing a ledger entry item
  54942. * @returns a tuple of index and item to be added to SHAMap
  54943. */
  54944. function entryItemizer(json) {
  54945. const index = hash_256_1.Hash256.from(json.index);
  54946. const bytes = (0, binary_1.serializeObject)(json);
  54947. const item = {
  54948. hashPrefix() {
  54949. return hash_prefixes_1.HashPrefix.accountStateEntry;
  54950. },
  54951. toBytesSink(sink) {
  54952. sink.put(bytes);
  54953. },
  54954. };
  54955. return [index, item, undefined];
  54956. }
  54957. /**
  54958. * Function computing the hash of a transaction tree
  54959. *
  54960. * @param param An array of transaction objects to hash
  54961. * @returns A Hash256 object
  54962. */
  54963. function transactionTreeHash(param) {
  54964. const itemizer = transactionItemizer;
  54965. return computeHash(itemizer, param);
  54966. }
  54967. exports.transactionTreeHash = transactionTreeHash;
  54968. /**
  54969. * Function computing the hash of accountState
  54970. *
  54971. * @param param A list of accountStates hash
  54972. * @returns A Hash256 object
  54973. */
  54974. function accountStateHash(param) {
  54975. const itemizer = entryItemizer;
  54976. return computeHash(itemizer, param);
  54977. }
  54978. exports.accountStateHash = accountStateHash;
  54979. /**
  54980. * Serialize and hash a ledger header
  54981. *
  54982. * @param header a ledger header
  54983. * @returns the hash of header
  54984. */
  54985. function ledgerHash(header) {
  54986. const hash = new hashes_1.Sha512Half();
  54987. hash.put(hash_prefixes_1.HashPrefix.ledgerHeader);
  54988. assert.ok(header.parent_close_time !== undefined);
  54989. assert.ok(header.close_flags !== undefined);
  54990. uint_32_1.UInt32.from(header.ledger_index).toBytesSink(hash);
  54991. uint_64_1.UInt64.from(bigInt(String(header.total_coins))).toBytesSink(hash);
  54992. hash_256_1.Hash256.from(header.parent_hash).toBytesSink(hash);
  54993. hash_256_1.Hash256.from(header.transaction_hash).toBytesSink(hash);
  54994. hash_256_1.Hash256.from(header.account_hash).toBytesSink(hash);
  54995. uint_32_1.UInt32.from(header.parent_close_time).toBytesSink(hash);
  54996. uint_32_1.UInt32.from(header.close_time).toBytesSink(hash);
  54997. uint_8_1.UInt8.from(header.close_time_resolution).toBytesSink(hash);
  54998. uint_8_1.UInt8.from(header.close_flags).toBytesSink(hash);
  54999. return hash.finish();
  55000. }
  55001. exports.ledgerHash = ledgerHash;
  55002. /**
  55003. * Decodes a serialized ledger header
  55004. *
  55005. * @param binary A serialized ledger header
  55006. * @returns A JSON object describing a ledger header
  55007. */
  55008. function decodeLedgerData(binary) {
  55009. assert.ok(typeof binary === 'string', 'binary must be a hex string');
  55010. const parser = new binary_parser_1.BinaryParser(binary);
  55011. return {
  55012. ledger_index: parser.readUInt32(),
  55013. total_coins: parser.readType(uint_64_1.UInt64).valueOf().toString(),
  55014. parent_hash: parser.readType(hash_256_1.Hash256).toHex(),
  55015. transaction_hash: parser.readType(hash_256_1.Hash256).toHex(),
  55016. account_hash: parser.readType(hash_256_1.Hash256).toHex(),
  55017. parent_close_time: parser.readUInt32(),
  55018. close_time: parser.readUInt32(),
  55019. close_time_resolution: parser.readUInt8(),
  55020. close_flags: parser.readUInt8(),
  55021. };
  55022. }
  55023. exports.decodeLedgerData = decodeLedgerData;
  55024. /***/ }),
  55025. /***/ "../../node_modules/ripple-binary-codec/dist/quality.js":
  55026. /*!**************************************************************!*\
  55027. !*** ../../node_modules/ripple-binary-codec/dist/quality.js ***!
  55028. \**************************************************************/
  55029. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  55030. "use strict";
  55031. Object.defineProperty(exports, "__esModule", ({ value: true }));
  55032. exports.quality = void 0;
  55033. const types_1 = __webpack_require__(/*! ./types */ "../../node_modules/ripple-binary-codec/dist/types/index.js");
  55034. const decimal_js_1 = __webpack_require__(/*! decimal.js */ "../../node_modules/decimal.js/decimal.js");
  55035. const bigInt = __webpack_require__(/*! big-integer */ "../../node_modules/big-integer/BigInteger.js");
  55036. const buffer_1 = __webpack_require__(/*! buffer/ */ "../../node_modules/ripple-binary-codec/node_modules/buffer/index.js");
  55037. /**
  55038. * class for encoding and decoding quality
  55039. */
  55040. class quality {
  55041. /**
  55042. * Encode quality amount
  55043. *
  55044. * @param arg string representation of an amount
  55045. * @returns Serialized quality
  55046. */
  55047. static encode(quality) {
  55048. const decimal = new decimal_js_1.Decimal(quality);
  55049. const exponent = decimal.e - 15;
  55050. const qualityString = decimal.times(`1e${-exponent}`).abs().toString();
  55051. const bytes = types_1.coreTypes.UInt64.from(bigInt(qualityString)).toBytes();
  55052. bytes[0] = exponent + 100;
  55053. return bytes;
  55054. }
  55055. /**
  55056. * Decode quality amount
  55057. *
  55058. * @param arg hex-string denoting serialized quality
  55059. * @returns deserialized quality
  55060. */
  55061. static decode(quality) {
  55062. const bytes = buffer_1.Buffer.from(quality, 'hex').slice(-8);
  55063. const exponent = bytes[0] - 100;
  55064. const mantissa = new decimal_js_1.Decimal(`0x${bytes.slice(1).toString('hex')}`);
  55065. return mantissa.times(`1e${exponent}`);
  55066. }
  55067. }
  55068. exports.quality = quality;
  55069. /***/ }),
  55070. /***/ "../../node_modules/ripple-binary-codec/dist/serdes/binary-parser.js":
  55071. /*!***************************************************************************!*\
  55072. !*** ../../node_modules/ripple-binary-codec/dist/serdes/binary-parser.js ***!
  55073. \***************************************************************************/
  55074. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  55075. "use strict";
  55076. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  55077. if (k2 === undefined) k2 = k;
  55078. var desc = Object.getOwnPropertyDescriptor(m, k);
  55079. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  55080. desc = { enumerable: true, get: function() { return m[k]; } };
  55081. }
  55082. Object.defineProperty(o, k2, desc);
  55083. }) : (function(o, m, k, k2) {
  55084. if (k2 === undefined) k2 = k;
  55085. o[k2] = m[k];
  55086. }));
  55087. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  55088. Object.defineProperty(o, "default", { enumerable: true, value: v });
  55089. }) : function(o, v) {
  55090. o["default"] = v;
  55091. });
  55092. var __importStar = (this && this.__importStar) || function (mod) {
  55093. if (mod && mod.__esModule) return mod;
  55094. var result = {};
  55095. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  55096. __setModuleDefault(result, mod);
  55097. return result;
  55098. };
  55099. Object.defineProperty(exports, "__esModule", ({ value: true }));
  55100. exports.BinaryParser = void 0;
  55101. const assert = __importStar(__webpack_require__(/*! assert */ "../../node_modules/assert/build/assert.js"));
  55102. const enums_1 = __webpack_require__(/*! ../enums */ "../../node_modules/ripple-binary-codec/dist/enums/index.js");
  55103. const buffer_1 = __webpack_require__(/*! buffer/ */ "../../node_modules/ripple-binary-codec/node_modules/buffer/index.js");
  55104. /**
  55105. * BinaryParser is used to compute fields and values from a HexString
  55106. */
  55107. class BinaryParser {
  55108. /**
  55109. * Initialize bytes to a hex string
  55110. *
  55111. * @param hexBytes a hex string
  55112. */
  55113. constructor(hexBytes) {
  55114. this.bytes = buffer_1.Buffer.from(hexBytes, 'hex');
  55115. }
  55116. /**
  55117. * Peek the first byte of the BinaryParser
  55118. *
  55119. * @returns The first byte of the BinaryParser
  55120. */
  55121. peek() {
  55122. assert.ok(this.bytes.byteLength !== 0);
  55123. return this.bytes[0];
  55124. }
  55125. /**
  55126. * Consume the first n bytes of the BinaryParser
  55127. *
  55128. * @param n the number of bytes to skip
  55129. */
  55130. skip(n) {
  55131. assert.ok(n <= this.bytes.byteLength);
  55132. this.bytes = this.bytes.slice(n);
  55133. }
  55134. /**
  55135. * read the first n bytes from the BinaryParser
  55136. *
  55137. * @param n The number of bytes to read
  55138. * @return The bytes
  55139. */
  55140. read(n) {
  55141. assert.ok(n <= this.bytes.byteLength);
  55142. const slice = this.bytes.slice(0, n);
  55143. this.skip(n);
  55144. return slice;
  55145. }
  55146. /**
  55147. * Read an integer of given size
  55148. *
  55149. * @param n The number of bytes to read
  55150. * @return The number represented by those bytes
  55151. */
  55152. readUIntN(n) {
  55153. assert.ok(0 < n && n <= 4, 'invalid n');
  55154. return this.read(n).reduce((a, b) => (a << 8) | b) >>> 0;
  55155. }
  55156. readUInt8() {
  55157. return this.readUIntN(1);
  55158. }
  55159. readUInt16() {
  55160. return this.readUIntN(2);
  55161. }
  55162. readUInt32() {
  55163. return this.readUIntN(4);
  55164. }
  55165. size() {
  55166. return this.bytes.byteLength;
  55167. }
  55168. end(customEnd) {
  55169. const length = this.bytes.byteLength;
  55170. return length === 0 || (customEnd !== undefined && length <= customEnd);
  55171. }
  55172. /**
  55173. * Reads variable length encoded bytes
  55174. *
  55175. * @return The variable length bytes
  55176. */
  55177. readVariableLength() {
  55178. return this.read(this.readVariableLengthLength());
  55179. }
  55180. /**
  55181. * Reads the length of the variable length encoded bytes
  55182. *
  55183. * @return The length of the variable length encoded bytes
  55184. */
  55185. readVariableLengthLength() {
  55186. const b1 = this.readUInt8();
  55187. if (b1 <= 192) {
  55188. return b1;
  55189. }
  55190. else if (b1 <= 240) {
  55191. const b2 = this.readUInt8();
  55192. return 193 + (b1 - 193) * 256 + b2;
  55193. }
  55194. else if (b1 <= 254) {
  55195. const b2 = this.readUInt8();
  55196. const b3 = this.readUInt8();
  55197. return 12481 + (b1 - 241) * 65536 + b2 * 256 + b3;
  55198. }
  55199. throw new Error('Invalid variable length indicator');
  55200. }
  55201. /**
  55202. * Reads the field ordinal from the BinaryParser
  55203. *
  55204. * @return Field ordinal
  55205. */
  55206. readFieldOrdinal() {
  55207. let type = this.readUInt8();
  55208. let nth = type & 15;
  55209. type >>= 4;
  55210. if (type === 0) {
  55211. type = this.readUInt8();
  55212. if (type === 0 || type < 16) {
  55213. throw new Error('Cannot read FieldOrdinal, type_code out of range');
  55214. }
  55215. }
  55216. if (nth === 0) {
  55217. nth = this.readUInt8();
  55218. if (nth === 0 || nth < 16) {
  55219. throw new Error('Cannot read FieldOrdinal, field_code out of range');
  55220. }
  55221. }
  55222. return (type << 16) | nth;
  55223. }
  55224. /**
  55225. * Read the field from the BinaryParser
  55226. *
  55227. * @return The field represented by the bytes at the head of the BinaryParser
  55228. */
  55229. readField() {
  55230. return enums_1.Field.fromString(this.readFieldOrdinal().toString());
  55231. }
  55232. /**
  55233. * Read a given type from the BinaryParser
  55234. *
  55235. * @param type The type that you want to read from the BinaryParser
  55236. * @return The instance of that type read from the BinaryParser
  55237. */
  55238. readType(type) {
  55239. return type.fromParser(this);
  55240. }
  55241. /**
  55242. * Get the type associated with a given field
  55243. *
  55244. * @param field The field that you wan to get the type of
  55245. * @return The type associated with the given field
  55246. */
  55247. typeForField(field) {
  55248. return field.associatedType;
  55249. }
  55250. /**
  55251. * Read value of the type specified by field from the BinaryParser
  55252. *
  55253. * @param field The field that you want to get the associated value for
  55254. * @return The value associated with the given field
  55255. */
  55256. readFieldValue(field) {
  55257. const type = this.typeForField(field);
  55258. if (!type) {
  55259. throw new Error(`unsupported: (${field.name}, ${field.type.name})`);
  55260. }
  55261. const sizeHint = field.isVariableLengthEncoded
  55262. ? this.readVariableLengthLength()
  55263. : undefined;
  55264. const value = type.fromParser(this, sizeHint);
  55265. if (value === undefined) {
  55266. throw new Error(`fromParser for (${field.name}, ${field.type.name}) -> undefined `);
  55267. }
  55268. return value;
  55269. }
  55270. /**
  55271. * Get the next field and value from the BinaryParser
  55272. *
  55273. * @return The field and value
  55274. */
  55275. readFieldAndValue() {
  55276. const field = this.readField();
  55277. return [field, this.readFieldValue(field)];
  55278. }
  55279. }
  55280. exports.BinaryParser = BinaryParser;
  55281. /***/ }),
  55282. /***/ "../../node_modules/ripple-binary-codec/dist/serdes/binary-serializer.js":
  55283. /*!*******************************************************************************!*\
  55284. !*** ../../node_modules/ripple-binary-codec/dist/serdes/binary-serializer.js ***!
  55285. \*******************************************************************************/
  55286. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  55287. "use strict";
  55288. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  55289. if (k2 === undefined) k2 = k;
  55290. var desc = Object.getOwnPropertyDescriptor(m, k);
  55291. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  55292. desc = { enumerable: true, get: function() { return m[k]; } };
  55293. }
  55294. Object.defineProperty(o, k2, desc);
  55295. }) : (function(o, m, k, k2) {
  55296. if (k2 === undefined) k2 = k;
  55297. o[k2] = m[k];
  55298. }));
  55299. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  55300. Object.defineProperty(o, "default", { enumerable: true, value: v });
  55301. }) : function(o, v) {
  55302. o["default"] = v;
  55303. });
  55304. var __importStar = (this && this.__importStar) || function (mod) {
  55305. if (mod && mod.__esModule) return mod;
  55306. var result = {};
  55307. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  55308. __setModuleDefault(result, mod);
  55309. return result;
  55310. };
  55311. Object.defineProperty(exports, "__esModule", ({ value: true }));
  55312. exports.BinarySerializer = exports.BytesList = void 0;
  55313. const assert = __importStar(__webpack_require__(/*! assert */ "../../node_modules/assert/build/assert.js"));
  55314. const buffer_1 = __webpack_require__(/*! buffer/ */ "../../node_modules/ripple-binary-codec/node_modules/buffer/index.js");
  55315. /**
  55316. * Bytes list is a collection of buffer objects
  55317. */
  55318. class BytesList {
  55319. constructor() {
  55320. this.bytesArray = [];
  55321. }
  55322. /**
  55323. * Get the total number of bytes in the BytesList
  55324. *
  55325. * @return the number of bytes
  55326. */
  55327. getLength() {
  55328. return buffer_1.Buffer.concat(this.bytesArray).byteLength;
  55329. }
  55330. /**
  55331. * Put bytes in the BytesList
  55332. *
  55333. * @param bytesArg A Buffer
  55334. * @return this BytesList
  55335. */
  55336. put(bytesArg) {
  55337. const bytes = buffer_1.Buffer.from(bytesArg); // Temporary, to catch instances of Uint8Array being passed in
  55338. this.bytesArray.push(bytes);
  55339. return this;
  55340. }
  55341. /**
  55342. * Write this BytesList to the back of another bytes list
  55343. *
  55344. * @param list The BytesList to write to
  55345. */
  55346. toBytesSink(list) {
  55347. list.put(this.toBytes());
  55348. }
  55349. toBytes() {
  55350. return buffer_1.Buffer.concat(this.bytesArray);
  55351. }
  55352. toHex() {
  55353. return this.toBytes().toString('hex').toUpperCase();
  55354. }
  55355. }
  55356. exports.BytesList = BytesList;
  55357. /**
  55358. * BinarySerializer is used to write fields and values to buffers
  55359. */
  55360. class BinarySerializer {
  55361. constructor(sink) {
  55362. this.sink = new BytesList();
  55363. this.sink = sink;
  55364. }
  55365. /**
  55366. * Write a value to this BinarySerializer
  55367. *
  55368. * @param value a SerializedType value
  55369. */
  55370. write(value) {
  55371. value.toBytesSink(this.sink);
  55372. }
  55373. /**
  55374. * Write bytes to this BinarySerializer
  55375. *
  55376. * @param bytes the bytes to write
  55377. */
  55378. put(bytes) {
  55379. this.sink.put(bytes);
  55380. }
  55381. /**
  55382. * Write a value of a given type to this BinarySerializer
  55383. *
  55384. * @param type the type to write
  55385. * @param value a value of that type
  55386. */
  55387. writeType(type, value) {
  55388. this.write(type.from(value));
  55389. }
  55390. /**
  55391. * Write BytesList to this BinarySerializer
  55392. *
  55393. * @param bl BytesList to write to BinarySerializer
  55394. */
  55395. writeBytesList(bl) {
  55396. bl.toBytesSink(this.sink);
  55397. }
  55398. /**
  55399. * Calculate the header of Variable Length encoded bytes
  55400. *
  55401. * @param length the length of the bytes
  55402. */
  55403. encodeVariableLength(length) {
  55404. const lenBytes = buffer_1.Buffer.alloc(3);
  55405. if (length <= 192) {
  55406. lenBytes[0] = length;
  55407. return lenBytes.slice(0, 1);
  55408. }
  55409. else if (length <= 12480) {
  55410. length -= 193;
  55411. lenBytes[0] = 193 + (length >>> 8);
  55412. lenBytes[1] = length & 0xff;
  55413. return lenBytes.slice(0, 2);
  55414. }
  55415. else if (length <= 918744) {
  55416. length -= 12481;
  55417. lenBytes[0] = 241 + (length >>> 16);
  55418. lenBytes[1] = (length >> 8) & 0xff;
  55419. lenBytes[2] = length & 0xff;
  55420. return lenBytes.slice(0, 3);
  55421. }
  55422. throw new Error('Overflow error');
  55423. }
  55424. /**
  55425. * Write field and value to BinarySerializer
  55426. *
  55427. * @param field field to write to BinarySerializer
  55428. * @param value value to write to BinarySerializer
  55429. */
  55430. writeFieldAndValue(field, value, isUnlModifyWorkaround = false) {
  55431. const associatedValue = field.associatedType.from(value);
  55432. assert.ok(associatedValue.toBytesSink !== undefined);
  55433. assert.ok(field.name !== undefined);
  55434. this.sink.put(field.header);
  55435. if (field.isVariableLengthEncoded) {
  55436. this.writeLengthEncoded(associatedValue, isUnlModifyWorkaround);
  55437. }
  55438. else {
  55439. associatedValue.toBytesSink(this.sink);
  55440. }
  55441. }
  55442. /**
  55443. * Write a variable length encoded value to the BinarySerializer
  55444. *
  55445. * @param value length encoded value to write to BytesList
  55446. */
  55447. writeLengthEncoded(value, isUnlModifyWorkaround = false) {
  55448. const bytes = new BytesList();
  55449. if (!isUnlModifyWorkaround) {
  55450. // this part doesn't happen for the Account field in a UNLModify transaction
  55451. value.toBytesSink(bytes);
  55452. }
  55453. this.put(this.encodeVariableLength(bytes.getLength()));
  55454. this.writeBytesList(bytes);
  55455. }
  55456. }
  55457. exports.BinarySerializer = BinarySerializer;
  55458. /***/ }),
  55459. /***/ "../../node_modules/ripple-binary-codec/dist/shamap.js":
  55460. /*!*************************************************************!*\
  55461. !*** ../../node_modules/ripple-binary-codec/dist/shamap.js ***!
  55462. \*************************************************************/
  55463. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  55464. "use strict";
  55465. Object.defineProperty(exports, "__esModule", ({ value: true }));
  55466. exports.ShaMapLeaf = exports.ShaMapNode = exports.ShaMap = void 0;
  55467. const assert_1 = __webpack_require__(/*! assert */ "../../node_modules/assert/build/assert.js");
  55468. const types_1 = __webpack_require__(/*! ./types */ "../../node_modules/ripple-binary-codec/dist/types/index.js");
  55469. const hash_prefixes_1 = __webpack_require__(/*! ./hash-prefixes */ "../../node_modules/ripple-binary-codec/dist/hash-prefixes.js");
  55470. const hashes_1 = __webpack_require__(/*! ./hashes */ "../../node_modules/ripple-binary-codec/dist/hashes.js");
  55471. const buffer_1 = __webpack_require__(/*! buffer/ */ "../../node_modules/ripple-binary-codec/node_modules/buffer/index.js");
  55472. /**
  55473. * Abstract class describing a SHAMapNode
  55474. */
  55475. class ShaMapNode {
  55476. }
  55477. exports.ShaMapNode = ShaMapNode;
  55478. /**
  55479. * Class describing a Leaf of SHAMap
  55480. */
  55481. class ShaMapLeaf extends ShaMapNode {
  55482. constructor(index, item) {
  55483. super();
  55484. this.index = index;
  55485. this.item = item;
  55486. }
  55487. /**
  55488. * @returns true as ShaMapLeaf is a leaf node
  55489. */
  55490. isLeaf() {
  55491. return true;
  55492. }
  55493. /**
  55494. * @returns false as ShaMapLeaf is not an inner node
  55495. */
  55496. isInner() {
  55497. return false;
  55498. }
  55499. /**
  55500. * Get the prefix of the this.item
  55501. *
  55502. * @returns The hash prefix, unless this.item is undefined, then it returns an empty Buffer
  55503. */
  55504. hashPrefix() {
  55505. return this.item === undefined ? buffer_1.Buffer.alloc(0) : this.item.hashPrefix();
  55506. }
  55507. /**
  55508. * Hash the bytes representation of this
  55509. *
  55510. * @returns hash of this.item concatenated with this.index
  55511. */
  55512. hash() {
  55513. const hash = hashes_1.Sha512Half.put(this.hashPrefix());
  55514. this.toBytesSink(hash);
  55515. return hash.finish();
  55516. }
  55517. /**
  55518. * Write the bytes representation of this to a BytesList
  55519. * @param list BytesList to write bytes to
  55520. */
  55521. toBytesSink(list) {
  55522. if (this.item !== undefined) {
  55523. this.item.toBytesSink(list);
  55524. }
  55525. this.index.toBytesSink(list);
  55526. }
  55527. }
  55528. exports.ShaMapLeaf = ShaMapLeaf;
  55529. /**
  55530. * Class defining an Inner Node of a SHAMap
  55531. */
  55532. class ShaMapInner extends ShaMapNode {
  55533. constructor(depth = 0) {
  55534. super();
  55535. this.depth = depth;
  55536. this.slotBits = 0;
  55537. this.branches = Array(16);
  55538. }
  55539. /**
  55540. * @returns true as ShaMapInner is an inner node
  55541. */
  55542. isInner() {
  55543. return true;
  55544. }
  55545. /**
  55546. * @returns false as ShaMapInner is not a leaf node
  55547. */
  55548. isLeaf() {
  55549. return false;
  55550. }
  55551. /**
  55552. * Get the hash prefix for this node
  55553. *
  55554. * @returns hash prefix describing an inner node
  55555. */
  55556. hashPrefix() {
  55557. return hash_prefixes_1.HashPrefix.innerNode;
  55558. }
  55559. /**
  55560. * Set a branch of this node to be another node
  55561. *
  55562. * @param slot Slot to add branch to this.branches
  55563. * @param branch Branch to add
  55564. */
  55565. setBranch(slot, branch) {
  55566. this.slotBits = this.slotBits | (1 << slot);
  55567. this.branches[slot] = branch;
  55568. }
  55569. /**
  55570. * @returns true if node is empty
  55571. */
  55572. empty() {
  55573. return this.slotBits === 0;
  55574. }
  55575. /**
  55576. * Compute the hash of this node
  55577. *
  55578. * @returns The hash of this node
  55579. */
  55580. hash() {
  55581. if (this.empty()) {
  55582. return types_1.coreTypes.Hash256.ZERO_256;
  55583. }
  55584. const hash = hashes_1.Sha512Half.put(this.hashPrefix());
  55585. this.toBytesSink(hash);
  55586. return hash.finish();
  55587. }
  55588. /**
  55589. * Writes the bytes representation of this node to a BytesList
  55590. *
  55591. * @param list BytesList to write bytes to
  55592. */
  55593. toBytesSink(list) {
  55594. for (let i = 0; i < this.branches.length; i++) {
  55595. const branch = this.branches[i];
  55596. const hash = branch ? branch.hash() : types_1.coreTypes.Hash256.ZERO_256;
  55597. hash.toBytesSink(list);
  55598. }
  55599. }
  55600. /**
  55601. * Add item to the SHAMap
  55602. *
  55603. * @param index Hash of the index of the item being inserted
  55604. * @param item Item to insert in the map
  55605. * @param leaf Leaf node to insert when branch doesn't exist
  55606. */
  55607. addItem(index, item, leaf) {
  55608. assert_1.strict.ok(index !== undefined);
  55609. if (index !== undefined) {
  55610. const nibble = index.nibblet(this.depth);
  55611. const existing = this.branches[nibble];
  55612. if (existing === undefined) {
  55613. this.setBranch(nibble, leaf || new ShaMapLeaf(index, item));
  55614. }
  55615. else if (existing instanceof ShaMapLeaf) {
  55616. const newInner = new ShaMapInner(this.depth + 1);
  55617. newInner.addItem(existing.index, undefined, existing);
  55618. newInner.addItem(index, item, leaf);
  55619. this.setBranch(nibble, newInner);
  55620. }
  55621. else if (existing instanceof ShaMapInner) {
  55622. existing.addItem(index, item, leaf);
  55623. }
  55624. else {
  55625. throw new Error('invalid ShaMap.addItem call');
  55626. }
  55627. }
  55628. }
  55629. }
  55630. class ShaMap extends ShaMapInner {
  55631. }
  55632. exports.ShaMap = ShaMap;
  55633. /***/ }),
  55634. /***/ "../../node_modules/ripple-binary-codec/dist/types/account-id.js":
  55635. /*!***********************************************************************!*\
  55636. !*** ../../node_modules/ripple-binary-codec/dist/types/account-id.js ***!
  55637. \***********************************************************************/
  55638. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  55639. "use strict";
  55640. Object.defineProperty(exports, "__esModule", ({ value: true }));
  55641. exports.AccountID = void 0;
  55642. const ripple_address_codec_1 = __webpack_require__(/*! ripple-address-codec */ "../../node_modules/ripple-address-codec/dist/index.js");
  55643. const hash_160_1 = __webpack_require__(/*! ./hash-160 */ "../../node_modules/ripple-binary-codec/dist/types/hash-160.js");
  55644. const buffer_1 = __webpack_require__(/*! buffer/ */ "../../node_modules/ripple-binary-codec/node_modules/buffer/index.js");
  55645. const HEX_REGEX = /^[A-F0-9]{40}$/;
  55646. /**
  55647. * Class defining how to encode and decode an AccountID
  55648. */
  55649. class AccountID extends hash_160_1.Hash160 {
  55650. constructor(bytes) {
  55651. super(bytes !== null && bytes !== void 0 ? bytes : AccountID.defaultAccountID.bytes);
  55652. }
  55653. /**
  55654. * Defines how to construct an AccountID
  55655. *
  55656. * @param value either an existing AccountID, a hex-string, or a base58 r-Address
  55657. * @returns an AccountID object
  55658. */
  55659. static from(value) {
  55660. if (value instanceof AccountID) {
  55661. return value;
  55662. }
  55663. if (typeof value === 'string') {
  55664. if (value === '') {
  55665. return new AccountID();
  55666. }
  55667. return HEX_REGEX.test(value)
  55668. ? new AccountID(buffer_1.Buffer.from(value, 'hex'))
  55669. : this.fromBase58(value);
  55670. }
  55671. throw new Error('Cannot construct AccountID from value given');
  55672. }
  55673. /**
  55674. * Defines how to build an AccountID from a base58 r-Address
  55675. *
  55676. * @param value a base58 r-Address
  55677. * @returns an AccountID object
  55678. */
  55679. static fromBase58(value) {
  55680. if ((0, ripple_address_codec_1.isValidXAddress)(value)) {
  55681. const classic = (0, ripple_address_codec_1.xAddressToClassicAddress)(value);
  55682. if (classic.tag !== false)
  55683. throw new Error('Only allowed to have tag on Account or Destination');
  55684. value = classic.classicAddress;
  55685. }
  55686. return new AccountID(buffer_1.Buffer.from((0, ripple_address_codec_1.decodeAccountID)(value)));
  55687. }
  55688. /**
  55689. * Overload of toJSON
  55690. *
  55691. * @returns the base58 string for this AccountID
  55692. */
  55693. toJSON() {
  55694. return this.toBase58();
  55695. }
  55696. /**
  55697. * Defines how to encode AccountID into a base58 address
  55698. *
  55699. * @returns the base58 string defined by this.bytes
  55700. */
  55701. toBase58() {
  55702. /* eslint-disable @typescript-eslint/no-explicit-any */
  55703. return (0, ripple_address_codec_1.encodeAccountID)(this.bytes);
  55704. /* eslint-enable @typescript-eslint/no-explicit-any */
  55705. }
  55706. }
  55707. exports.AccountID = AccountID;
  55708. AccountID.defaultAccountID = new AccountID(buffer_1.Buffer.alloc(20));
  55709. /***/ }),
  55710. /***/ "../../node_modules/ripple-binary-codec/dist/types/amount.js":
  55711. /*!*******************************************************************!*\
  55712. !*** ../../node_modules/ripple-binary-codec/dist/types/amount.js ***!
  55713. \*******************************************************************/
  55714. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  55715. "use strict";
  55716. Object.defineProperty(exports, "__esModule", ({ value: true }));
  55717. exports.Amount = void 0;
  55718. const decimal_js_1 = __webpack_require__(/*! decimal.js */ "../../node_modules/decimal.js/decimal.js");
  55719. const binary_parser_1 = __webpack_require__(/*! ../serdes/binary-parser */ "../../node_modules/ripple-binary-codec/dist/serdes/binary-parser.js");
  55720. const account_id_1 = __webpack_require__(/*! ./account-id */ "../../node_modules/ripple-binary-codec/dist/types/account-id.js");
  55721. const currency_1 = __webpack_require__(/*! ./currency */ "../../node_modules/ripple-binary-codec/dist/types/currency.js");
  55722. const serialized_type_1 = __webpack_require__(/*! ./serialized-type */ "../../node_modules/ripple-binary-codec/dist/types/serialized-type.js");
  55723. const bigInt = __webpack_require__(/*! big-integer */ "../../node_modules/big-integer/BigInteger.js");
  55724. const buffer_1 = __webpack_require__(/*! buffer/ */ "../../node_modules/ripple-binary-codec/node_modules/buffer/index.js");
  55725. /**
  55726. * Constants for validating amounts
  55727. */
  55728. const MIN_IOU_EXPONENT = -96;
  55729. const MAX_IOU_EXPONENT = 80;
  55730. const MAX_IOU_PRECISION = 16;
  55731. const MAX_DROPS = new decimal_js_1.Decimal('1e17');
  55732. const MIN_XRP = new decimal_js_1.Decimal('1e-6');
  55733. const mask = bigInt(0x00000000ffffffff);
  55734. /**
  55735. * decimal.js configuration for Amount IOUs
  55736. */
  55737. decimal_js_1.Decimal.config({
  55738. toExpPos: MAX_IOU_EXPONENT + MAX_IOU_PRECISION,
  55739. toExpNeg: MIN_IOU_EXPONENT - MAX_IOU_PRECISION,
  55740. });
  55741. /**
  55742. * Type guard for AmountObject
  55743. */
  55744. function isAmountObject(arg) {
  55745. const keys = Object.keys(arg).sort();
  55746. return (keys.length === 3 &&
  55747. keys[0] === 'currency' &&
  55748. keys[1] === 'issuer' &&
  55749. keys[2] === 'value');
  55750. }
  55751. /**
  55752. * Class for serializing/Deserializing Amounts
  55753. */
  55754. class Amount extends serialized_type_1.SerializedType {
  55755. constructor(bytes) {
  55756. super(bytes !== null && bytes !== void 0 ? bytes : Amount.defaultAmount.bytes);
  55757. }
  55758. /**
  55759. * Construct an amount from an IOU or string amount
  55760. *
  55761. * @param value An Amount, object representing an IOU, or a string
  55762. * representing an integer amount
  55763. * @returns An Amount object
  55764. */
  55765. static from(value) {
  55766. if (value instanceof Amount) {
  55767. return value;
  55768. }
  55769. let amount = buffer_1.Buffer.alloc(8);
  55770. if (typeof value === 'string') {
  55771. Amount.assertXrpIsValid(value);
  55772. const number = bigInt(value);
  55773. const intBuf = [buffer_1.Buffer.alloc(4), buffer_1.Buffer.alloc(4)];
  55774. intBuf[0].writeUInt32BE(Number(number.shiftRight(32)), 0);
  55775. intBuf[1].writeUInt32BE(Number(number.and(mask)), 0);
  55776. amount = buffer_1.Buffer.concat(intBuf);
  55777. amount[0] |= 0x40;
  55778. return new Amount(amount);
  55779. }
  55780. if (isAmountObject(value)) {
  55781. const number = new decimal_js_1.Decimal(value.value);
  55782. Amount.assertIouIsValid(number);
  55783. if (number.isZero()) {
  55784. amount[0] |= 0x80;
  55785. }
  55786. else {
  55787. const integerNumberString = number
  55788. .times(`1e${-(number.e - 15)}`)
  55789. .abs()
  55790. .toString();
  55791. const num = bigInt(integerNumberString);
  55792. const intBuf = [buffer_1.Buffer.alloc(4), buffer_1.Buffer.alloc(4)];
  55793. intBuf[0].writeUInt32BE(Number(num.shiftRight(32)), 0);
  55794. intBuf[1].writeUInt32BE(Number(num.and(mask)), 0);
  55795. amount = buffer_1.Buffer.concat(intBuf);
  55796. amount[0] |= 0x80;
  55797. if (number.gt(new decimal_js_1.Decimal(0))) {
  55798. amount[0] |= 0x40;
  55799. }
  55800. const exponent = number.e - 15;
  55801. const exponentByte = 97 + exponent;
  55802. amount[0] |= exponentByte >>> 2;
  55803. amount[1] |= (exponentByte & 0x03) << 6;
  55804. }
  55805. const currency = currency_1.Currency.from(value.currency).toBytes();
  55806. const issuer = account_id_1.AccountID.from(value.issuer).toBytes();
  55807. return new Amount(buffer_1.Buffer.concat([amount, currency, issuer]));
  55808. }
  55809. throw new Error('Invalid type to construct an Amount');
  55810. }
  55811. /**
  55812. * Read an amount from a BinaryParser
  55813. *
  55814. * @param parser BinaryParser to read the Amount from
  55815. * @returns An Amount object
  55816. */
  55817. static fromParser(parser) {
  55818. const isXRP = parser.peek() & 0x80;
  55819. const numBytes = isXRP ? 48 : 8;
  55820. return new Amount(parser.read(numBytes));
  55821. }
  55822. /**
  55823. * Get the JSON representation of this Amount
  55824. *
  55825. * @returns the JSON interpretation of this.bytes
  55826. */
  55827. toJSON() {
  55828. if (this.isNative()) {
  55829. const bytes = this.bytes;
  55830. const isPositive = bytes[0] & 0x40;
  55831. const sign = isPositive ? '' : '-';
  55832. bytes[0] &= 0x3f;
  55833. const msb = bigInt(bytes.slice(0, 4).readUInt32BE(0));
  55834. const lsb = bigInt(bytes.slice(4).readUInt32BE(0));
  55835. const num = msb.shiftLeft(32).or(lsb);
  55836. return `${sign}${num.toString()}`;
  55837. }
  55838. else {
  55839. const parser = new binary_parser_1.BinaryParser(this.toString());
  55840. const mantissa = parser.read(8);
  55841. const currency = currency_1.Currency.fromParser(parser);
  55842. const issuer = account_id_1.AccountID.fromParser(parser);
  55843. const b1 = mantissa[0];
  55844. const b2 = mantissa[1];
  55845. const isPositive = b1 & 0x40;
  55846. const sign = isPositive ? '' : '-';
  55847. const exponent = ((b1 & 0x3f) << 2) + ((b2 & 0xff) >> 6) - 97;
  55848. mantissa[0] = 0;
  55849. mantissa[1] &= 0x3f;
  55850. const value = new decimal_js_1.Decimal(`${sign}0x${mantissa.toString('hex')}`).times(`1e${exponent}`);
  55851. Amount.assertIouIsValid(value);
  55852. return {
  55853. value: value.toString(),
  55854. currency: currency.toJSON(),
  55855. issuer: issuer.toJSON(),
  55856. };
  55857. }
  55858. }
  55859. /**
  55860. * Validate XRP amount
  55861. *
  55862. * @param amount String representing XRP amount
  55863. * @returns void, but will throw if invalid amount
  55864. */
  55865. static assertXrpIsValid(amount) {
  55866. if (amount.indexOf('.') !== -1) {
  55867. throw new Error(`${amount.toString()} is an illegal amount`);
  55868. }
  55869. const decimal = new decimal_js_1.Decimal(amount);
  55870. if (!decimal.isZero()) {
  55871. if (decimal.lt(MIN_XRP) || decimal.gt(MAX_DROPS)) {
  55872. throw new Error(`${amount.toString()} is an illegal amount`);
  55873. }
  55874. }
  55875. }
  55876. /**
  55877. * Validate IOU.value amount
  55878. *
  55879. * @param decimal Decimal.js object representing IOU.value
  55880. * @returns void, but will throw if invalid amount
  55881. */
  55882. static assertIouIsValid(decimal) {
  55883. if (!decimal.isZero()) {
  55884. const p = decimal.precision();
  55885. const e = decimal.e - 15;
  55886. if (p > MAX_IOU_PRECISION ||
  55887. e > MAX_IOU_EXPONENT ||
  55888. e < MIN_IOU_EXPONENT) {
  55889. throw new Error('Decimal precision out of range');
  55890. }
  55891. this.verifyNoDecimal(decimal);
  55892. }
  55893. }
  55894. /**
  55895. * Ensure that the value after being multiplied by the exponent does not
  55896. * contain a decimal.
  55897. *
  55898. * @param decimal a Decimal object
  55899. * @returns a string of the object without a decimal
  55900. */
  55901. static verifyNoDecimal(decimal) {
  55902. const integerNumberString = decimal
  55903. .times(`1e${-(decimal.e - 15)}`)
  55904. .abs()
  55905. .toString();
  55906. if (integerNumberString.indexOf('.') !== -1) {
  55907. throw new Error('Decimal place found in integerNumberString');
  55908. }
  55909. }
  55910. /**
  55911. * Test if this amount is in units of Native Currency(XRP)
  55912. *
  55913. * @returns true if Native (XRP)
  55914. */
  55915. isNative() {
  55916. return (this.bytes[0] & 0x80) === 0;
  55917. }
  55918. }
  55919. exports.Amount = Amount;
  55920. Amount.defaultAmount = new Amount(buffer_1.Buffer.from('4000000000000000', 'hex'));
  55921. /***/ }),
  55922. /***/ "../../node_modules/ripple-binary-codec/dist/types/blob.js":
  55923. /*!*****************************************************************!*\
  55924. !*** ../../node_modules/ripple-binary-codec/dist/types/blob.js ***!
  55925. \*****************************************************************/
  55926. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  55927. "use strict";
  55928. Object.defineProperty(exports, "__esModule", ({ value: true }));
  55929. exports.Blob = void 0;
  55930. const serialized_type_1 = __webpack_require__(/*! ./serialized-type */ "../../node_modules/ripple-binary-codec/dist/types/serialized-type.js");
  55931. const buffer_1 = __webpack_require__(/*! buffer/ */ "../../node_modules/ripple-binary-codec/node_modules/buffer/index.js");
  55932. /**
  55933. * Variable length encoded type
  55934. */
  55935. class Blob extends serialized_type_1.SerializedType {
  55936. constructor(bytes) {
  55937. super(bytes);
  55938. }
  55939. /**
  55940. * Defines how to read a Blob from a BinaryParser
  55941. *
  55942. * @param parser The binary parser to read the Blob from
  55943. * @param hint The length of the blob, computed by readVariableLengthLength() and passed in
  55944. * @returns A Blob object
  55945. */
  55946. static fromParser(parser, hint) {
  55947. return new Blob(parser.read(hint));
  55948. }
  55949. /**
  55950. * Create a Blob object from a hex-string
  55951. *
  55952. * @param value existing Blob object or a hex-string
  55953. * @returns A Blob object
  55954. */
  55955. static from(value) {
  55956. if (value instanceof Blob) {
  55957. return value;
  55958. }
  55959. if (typeof value === 'string') {
  55960. return new Blob(buffer_1.Buffer.from(value, 'hex'));
  55961. }
  55962. throw new Error('Cannot construct Blob from value given');
  55963. }
  55964. }
  55965. exports.Blob = Blob;
  55966. /***/ }),
  55967. /***/ "../../node_modules/ripple-binary-codec/dist/types/currency.js":
  55968. /*!*********************************************************************!*\
  55969. !*** ../../node_modules/ripple-binary-codec/dist/types/currency.js ***!
  55970. \*********************************************************************/
  55971. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  55972. "use strict";
  55973. Object.defineProperty(exports, "__esModule", ({ value: true }));
  55974. exports.Currency = void 0;
  55975. const hash_160_1 = __webpack_require__(/*! ./hash-160 */ "../../node_modules/ripple-binary-codec/dist/types/hash-160.js");
  55976. const buffer_1 = __webpack_require__(/*! buffer/ */ "../../node_modules/ripple-binary-codec/node_modules/buffer/index.js");
  55977. const XRP_HEX_REGEX = /^0{40}$/;
  55978. const ISO_REGEX = /^[A-Z0-9a-z?!@#$%^&*(){}[\]|]{3}$/;
  55979. const HEX_REGEX = /^[A-F0-9]{40}$/;
  55980. // eslint-disable-next-line no-control-regex
  55981. const STANDARD_FORMAT_HEX_REGEX = /^0{24}[\x00-\x7F]{6}0{10}$/;
  55982. /**
  55983. * Convert an ISO code to a currency bytes representation
  55984. */
  55985. function isoToBytes(iso) {
  55986. const bytes = buffer_1.Buffer.alloc(20);
  55987. if (iso !== 'XRP') {
  55988. const isoBytes = iso.split('').map((c) => c.charCodeAt(0));
  55989. bytes.set(isoBytes, 12);
  55990. }
  55991. return bytes;
  55992. }
  55993. /**
  55994. * Tests if ISO is a valid iso code
  55995. */
  55996. function isIsoCode(iso) {
  55997. return ISO_REGEX.test(iso);
  55998. }
  55999. function isoCodeFromHex(code) {
  56000. const iso = code.toString();
  56001. if (iso === 'XRP') {
  56002. return null;
  56003. }
  56004. if (isIsoCode(iso)) {
  56005. return iso;
  56006. }
  56007. return null;
  56008. }
  56009. /**
  56010. * Tests if hex is a valid hex-string
  56011. */
  56012. function isHex(hex) {
  56013. return HEX_REGEX.test(hex);
  56014. }
  56015. /**
  56016. * Tests if a string is a valid representation of a currency
  56017. */
  56018. function isStringRepresentation(input) {
  56019. return input.length === 3 || isHex(input);
  56020. }
  56021. /**
  56022. * Tests if a Buffer is a valid representation of a currency
  56023. */
  56024. function isBytesArray(bytes) {
  56025. return bytes.byteLength === 20;
  56026. }
  56027. /**
  56028. * Ensures that a value is a valid representation of a currency
  56029. */
  56030. function isValidRepresentation(input) {
  56031. return input instanceof buffer_1.Buffer
  56032. ? isBytesArray(input)
  56033. : isStringRepresentation(input);
  56034. }
  56035. /**
  56036. * Generate bytes from a string or buffer representation of a currency
  56037. */
  56038. function bytesFromRepresentation(input) {
  56039. if (!isValidRepresentation(input)) {
  56040. throw new Error(`Unsupported Currency representation: ${input}`);
  56041. }
  56042. return input.length === 3 ? isoToBytes(input) : buffer_1.Buffer.from(input, 'hex');
  56043. }
  56044. /**
  56045. * Class defining how to encode and decode Currencies
  56046. */
  56047. class Currency extends hash_160_1.Hash160 {
  56048. constructor(byteBuf) {
  56049. super(byteBuf !== null && byteBuf !== void 0 ? byteBuf : Currency.XRP.bytes);
  56050. const hex = this.bytes.toString('hex');
  56051. if (XRP_HEX_REGEX.test(hex)) {
  56052. this._iso = 'XRP';
  56053. }
  56054. else if (STANDARD_FORMAT_HEX_REGEX.test(hex)) {
  56055. this._iso = isoCodeFromHex(this.bytes.slice(12, 15));
  56056. }
  56057. else {
  56058. this._iso = null;
  56059. }
  56060. }
  56061. /**
  56062. * Return the ISO code of this currency
  56063. *
  56064. * @returns ISO code if it exists, else null
  56065. */
  56066. iso() {
  56067. return this._iso;
  56068. }
  56069. /**
  56070. * Constructs a Currency object
  56071. *
  56072. * @param val Currency object or a string representation of a currency
  56073. */
  56074. static from(value) {
  56075. if (value instanceof Currency) {
  56076. return value;
  56077. }
  56078. if (typeof value === 'string') {
  56079. return new Currency(bytesFromRepresentation(value));
  56080. }
  56081. throw new Error('Cannot construct Currency from value given');
  56082. }
  56083. /**
  56084. * Gets the JSON representation of a currency
  56085. *
  56086. * @returns JSON representation
  56087. */
  56088. toJSON() {
  56089. const iso = this.iso();
  56090. if (iso !== null) {
  56091. return iso;
  56092. }
  56093. return this.bytes.toString('hex').toUpperCase();
  56094. }
  56095. }
  56096. exports.Currency = Currency;
  56097. Currency.XRP = new Currency(buffer_1.Buffer.alloc(20));
  56098. /***/ }),
  56099. /***/ "../../node_modules/ripple-binary-codec/dist/types/hash-128.js":
  56100. /*!*********************************************************************!*\
  56101. !*** ../../node_modules/ripple-binary-codec/dist/types/hash-128.js ***!
  56102. \*********************************************************************/
  56103. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  56104. "use strict";
  56105. Object.defineProperty(exports, "__esModule", ({ value: true }));
  56106. exports.Hash128 = void 0;
  56107. const hash_1 = __webpack_require__(/*! ./hash */ "../../node_modules/ripple-binary-codec/dist/types/hash.js");
  56108. const buffer_1 = __webpack_require__(/*! buffer/ */ "../../node_modules/ripple-binary-codec/node_modules/buffer/index.js");
  56109. /**
  56110. * Hash with a width of 128 bits
  56111. */
  56112. class Hash128 extends hash_1.Hash {
  56113. constructor(bytes) {
  56114. if (bytes && bytes.byteLength === 0) {
  56115. bytes = Hash128.ZERO_128.bytes;
  56116. }
  56117. super(bytes !== null && bytes !== void 0 ? bytes : Hash128.ZERO_128.bytes);
  56118. }
  56119. /**
  56120. * Get the hex representation of a hash-128 bytes, allowing unset
  56121. *
  56122. * @returns hex String of this.bytes
  56123. */
  56124. toHex() {
  56125. const hex = this.toBytes().toString('hex').toUpperCase();
  56126. if (/^0+$/.exec(hex)) {
  56127. return '';
  56128. }
  56129. return hex;
  56130. }
  56131. }
  56132. exports.Hash128 = Hash128;
  56133. Hash128.width = 16;
  56134. Hash128.ZERO_128 = new Hash128(buffer_1.Buffer.alloc(Hash128.width));
  56135. /***/ }),
  56136. /***/ "../../node_modules/ripple-binary-codec/dist/types/hash-160.js":
  56137. /*!*********************************************************************!*\
  56138. !*** ../../node_modules/ripple-binary-codec/dist/types/hash-160.js ***!
  56139. \*********************************************************************/
  56140. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  56141. "use strict";
  56142. Object.defineProperty(exports, "__esModule", ({ value: true }));
  56143. exports.Hash160 = void 0;
  56144. const hash_1 = __webpack_require__(/*! ./hash */ "../../node_modules/ripple-binary-codec/dist/types/hash.js");
  56145. const buffer_1 = __webpack_require__(/*! buffer/ */ "../../node_modules/ripple-binary-codec/node_modules/buffer/index.js");
  56146. /**
  56147. * Hash with a width of 160 bits
  56148. */
  56149. class Hash160 extends hash_1.Hash {
  56150. constructor(bytes) {
  56151. if (bytes && bytes.byteLength === 0) {
  56152. bytes = Hash160.ZERO_160.bytes;
  56153. }
  56154. super(bytes !== null && bytes !== void 0 ? bytes : Hash160.ZERO_160.bytes);
  56155. }
  56156. }
  56157. exports.Hash160 = Hash160;
  56158. Hash160.width = 20;
  56159. Hash160.ZERO_160 = new Hash160(buffer_1.Buffer.alloc(Hash160.width));
  56160. /***/ }),
  56161. /***/ "../../node_modules/ripple-binary-codec/dist/types/hash-256.js":
  56162. /*!*********************************************************************!*\
  56163. !*** ../../node_modules/ripple-binary-codec/dist/types/hash-256.js ***!
  56164. \*********************************************************************/
  56165. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  56166. "use strict";
  56167. Object.defineProperty(exports, "__esModule", ({ value: true }));
  56168. exports.Hash256 = void 0;
  56169. const hash_1 = __webpack_require__(/*! ./hash */ "../../node_modules/ripple-binary-codec/dist/types/hash.js");
  56170. const buffer_1 = __webpack_require__(/*! buffer/ */ "../../node_modules/ripple-binary-codec/node_modules/buffer/index.js");
  56171. /**
  56172. * Hash with a width of 256 bits
  56173. */
  56174. class Hash256 extends hash_1.Hash {
  56175. constructor(bytes) {
  56176. super(bytes !== null && bytes !== void 0 ? bytes : Hash256.ZERO_256.bytes);
  56177. }
  56178. }
  56179. exports.Hash256 = Hash256;
  56180. Hash256.width = 32;
  56181. Hash256.ZERO_256 = new Hash256(buffer_1.Buffer.alloc(Hash256.width));
  56182. /***/ }),
  56183. /***/ "../../node_modules/ripple-binary-codec/dist/types/hash.js":
  56184. /*!*****************************************************************!*\
  56185. !*** ../../node_modules/ripple-binary-codec/dist/types/hash.js ***!
  56186. \*****************************************************************/
  56187. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  56188. "use strict";
  56189. Object.defineProperty(exports, "__esModule", ({ value: true }));
  56190. exports.Hash = void 0;
  56191. const serialized_type_1 = __webpack_require__(/*! ./serialized-type */ "../../node_modules/ripple-binary-codec/dist/types/serialized-type.js");
  56192. const buffer_1 = __webpack_require__(/*! buffer/ */ "../../node_modules/ripple-binary-codec/node_modules/buffer/index.js");
  56193. /**
  56194. * Base class defining how to encode and decode hashes
  56195. */
  56196. class Hash extends serialized_type_1.Comparable {
  56197. constructor(bytes) {
  56198. super(bytes);
  56199. if (this.bytes.byteLength !== this.constructor.width) {
  56200. throw new Error(`Invalid Hash length ${this.bytes.byteLength}`);
  56201. }
  56202. }
  56203. /**
  56204. * Construct a Hash object from an existing Hash object or a hex-string
  56205. *
  56206. * @param value A hash object or hex-string of a hash
  56207. */
  56208. static from(value) {
  56209. if (value instanceof this) {
  56210. return value;
  56211. }
  56212. if (typeof value === 'string') {
  56213. return new this(buffer_1.Buffer.from(value, 'hex'));
  56214. }
  56215. throw new Error('Cannot construct Hash from given value');
  56216. }
  56217. /**
  56218. * Read a Hash object from a BinaryParser
  56219. *
  56220. * @param parser BinaryParser to read the hash from
  56221. * @param hint length of the bytes to read, optional
  56222. */
  56223. static fromParser(parser, hint) {
  56224. return new this(parser.read(hint !== null && hint !== void 0 ? hint : this.width));
  56225. }
  56226. /**
  56227. * Overloaded operator for comparing two hash objects
  56228. *
  56229. * @param other The Hash to compare this to
  56230. */
  56231. compareTo(other) {
  56232. return this.bytes.compare(this.constructor.from(other).bytes);
  56233. }
  56234. /**
  56235. * @returns the hex-string representation of this Hash
  56236. */
  56237. toString() {
  56238. return this.toHex();
  56239. }
  56240. /**
  56241. * Returns four bits at the specified depth within a hash
  56242. *
  56243. * @param depth The depth of the four bits
  56244. * @returns The number represented by the four bits
  56245. */
  56246. nibblet(depth) {
  56247. const byteIx = depth > 0 ? (depth / 2) | 0 : 0;
  56248. let b = this.bytes[byteIx];
  56249. if (depth % 2 === 0) {
  56250. b = (b & 0xf0) >>> 4;
  56251. }
  56252. else {
  56253. b = b & 0x0f;
  56254. }
  56255. return b;
  56256. }
  56257. }
  56258. exports.Hash = Hash;
  56259. /***/ }),
  56260. /***/ "../../node_modules/ripple-binary-codec/dist/types/index.js":
  56261. /*!******************************************************************!*\
  56262. !*** ../../node_modules/ripple-binary-codec/dist/types/index.js ***!
  56263. \******************************************************************/
  56264. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  56265. "use strict";
  56266. Object.defineProperty(exports, "__esModule", ({ value: true }));
  56267. exports.coreTypes = void 0;
  56268. const enums_1 = __webpack_require__(/*! ../enums */ "../../node_modules/ripple-binary-codec/dist/enums/index.js");
  56269. const account_id_1 = __webpack_require__(/*! ./account-id */ "../../node_modules/ripple-binary-codec/dist/types/account-id.js");
  56270. const amount_1 = __webpack_require__(/*! ./amount */ "../../node_modules/ripple-binary-codec/dist/types/amount.js");
  56271. const blob_1 = __webpack_require__(/*! ./blob */ "../../node_modules/ripple-binary-codec/dist/types/blob.js");
  56272. const currency_1 = __webpack_require__(/*! ./currency */ "../../node_modules/ripple-binary-codec/dist/types/currency.js");
  56273. const hash_128_1 = __webpack_require__(/*! ./hash-128 */ "../../node_modules/ripple-binary-codec/dist/types/hash-128.js");
  56274. const hash_160_1 = __webpack_require__(/*! ./hash-160 */ "../../node_modules/ripple-binary-codec/dist/types/hash-160.js");
  56275. const hash_256_1 = __webpack_require__(/*! ./hash-256 */ "../../node_modules/ripple-binary-codec/dist/types/hash-256.js");
  56276. const path_set_1 = __webpack_require__(/*! ./path-set */ "../../node_modules/ripple-binary-codec/dist/types/path-set.js");
  56277. const st_array_1 = __webpack_require__(/*! ./st-array */ "../../node_modules/ripple-binary-codec/dist/types/st-array.js");
  56278. const st_object_1 = __webpack_require__(/*! ./st-object */ "../../node_modules/ripple-binary-codec/dist/types/st-object.js");
  56279. const uint_16_1 = __webpack_require__(/*! ./uint-16 */ "../../node_modules/ripple-binary-codec/dist/types/uint-16.js");
  56280. const uint_32_1 = __webpack_require__(/*! ./uint-32 */ "../../node_modules/ripple-binary-codec/dist/types/uint-32.js");
  56281. const uint_64_1 = __webpack_require__(/*! ./uint-64 */ "../../node_modules/ripple-binary-codec/dist/types/uint-64.js");
  56282. const uint_8_1 = __webpack_require__(/*! ./uint-8 */ "../../node_modules/ripple-binary-codec/dist/types/uint-8.js");
  56283. const vector_256_1 = __webpack_require__(/*! ./vector-256 */ "../../node_modules/ripple-binary-codec/dist/types/vector-256.js");
  56284. const coreTypes = {
  56285. AccountID: account_id_1.AccountID,
  56286. Amount: amount_1.Amount,
  56287. Blob: blob_1.Blob,
  56288. Currency: currency_1.Currency,
  56289. Hash128: hash_128_1.Hash128,
  56290. Hash160: hash_160_1.Hash160,
  56291. Hash256: hash_256_1.Hash256,
  56292. PathSet: path_set_1.PathSet,
  56293. STArray: st_array_1.STArray,
  56294. STObject: st_object_1.STObject,
  56295. UInt8: uint_8_1.UInt8,
  56296. UInt16: uint_16_1.UInt16,
  56297. UInt32: uint_32_1.UInt32,
  56298. UInt64: uint_64_1.UInt64,
  56299. Vector256: vector_256_1.Vector256,
  56300. };
  56301. exports.coreTypes = coreTypes;
  56302. Object.values(enums_1.Field).forEach((field) => {
  56303. field.associatedType = coreTypes[field.type.name];
  56304. });
  56305. enums_1.Field['TransactionType'].associatedType = enums_1.TransactionType;
  56306. enums_1.Field['TransactionResult'].associatedType = enums_1.TransactionResult;
  56307. enums_1.Field['LedgerEntryType'].associatedType = enums_1.LedgerEntryType;
  56308. /***/ }),
  56309. /***/ "../../node_modules/ripple-binary-codec/dist/types/path-set.js":
  56310. /*!*********************************************************************!*\
  56311. !*** ../../node_modules/ripple-binary-codec/dist/types/path-set.js ***!
  56312. \*********************************************************************/
  56313. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  56314. "use strict";
  56315. Object.defineProperty(exports, "__esModule", ({ value: true }));
  56316. exports.PathSet = void 0;
  56317. const account_id_1 = __webpack_require__(/*! ./account-id */ "../../node_modules/ripple-binary-codec/dist/types/account-id.js");
  56318. const currency_1 = __webpack_require__(/*! ./currency */ "../../node_modules/ripple-binary-codec/dist/types/currency.js");
  56319. const binary_parser_1 = __webpack_require__(/*! ../serdes/binary-parser */ "../../node_modules/ripple-binary-codec/dist/serdes/binary-parser.js");
  56320. const serialized_type_1 = __webpack_require__(/*! ./serialized-type */ "../../node_modules/ripple-binary-codec/dist/types/serialized-type.js");
  56321. const buffer_1 = __webpack_require__(/*! buffer/ */ "../../node_modules/ripple-binary-codec/node_modules/buffer/index.js");
  56322. /**
  56323. * Constants for separating Paths in a PathSet
  56324. */
  56325. const PATHSET_END_BYTE = 0x00;
  56326. const PATH_SEPARATOR_BYTE = 0xff;
  56327. /**
  56328. * Constant for masking types of a Hop
  56329. */
  56330. const TYPE_ACCOUNT = 0x01;
  56331. const TYPE_CURRENCY = 0x10;
  56332. const TYPE_ISSUER = 0x20;
  56333. /**
  56334. * TypeGuard for HopObject
  56335. */
  56336. function isHopObject(arg) {
  56337. return (arg.issuer !== undefined ||
  56338. arg.account !== undefined ||
  56339. arg.currency !== undefined);
  56340. }
  56341. /**
  56342. * TypeGuard for PathSet
  56343. */
  56344. function isPathSet(arg) {
  56345. return ((Array.isArray(arg) && arg.length === 0) ||
  56346. (Array.isArray(arg) && Array.isArray(arg[0]) && arg[0].length === 0) ||
  56347. (Array.isArray(arg) && Array.isArray(arg[0]) && isHopObject(arg[0][0])));
  56348. }
  56349. /**
  56350. * Serialize and Deserialize a Hop
  56351. */
  56352. class Hop extends serialized_type_1.SerializedType {
  56353. /**
  56354. * Create a Hop from a HopObject
  56355. *
  56356. * @param value Either a hop or HopObject to create a hop with
  56357. * @returns a Hop
  56358. */
  56359. static from(value) {
  56360. if (value instanceof Hop) {
  56361. return value;
  56362. }
  56363. const bytes = [buffer_1.Buffer.from([0])];
  56364. if (value.account) {
  56365. bytes.push(account_id_1.AccountID.from(value.account).toBytes());
  56366. bytes[0][0] |= TYPE_ACCOUNT;
  56367. }
  56368. if (value.currency) {
  56369. bytes.push(currency_1.Currency.from(value.currency).toBytes());
  56370. bytes[0][0] |= TYPE_CURRENCY;
  56371. }
  56372. if (value.issuer) {
  56373. bytes.push(account_id_1.AccountID.from(value.issuer).toBytes());
  56374. bytes[0][0] |= TYPE_ISSUER;
  56375. }
  56376. return new Hop(buffer_1.Buffer.concat(bytes));
  56377. }
  56378. /**
  56379. * Construct a Hop from a BinaryParser
  56380. *
  56381. * @param parser BinaryParser to read the Hop from
  56382. * @returns a Hop
  56383. */
  56384. static fromParser(parser) {
  56385. const type = parser.readUInt8();
  56386. const bytes = [buffer_1.Buffer.from([type])];
  56387. if (type & TYPE_ACCOUNT) {
  56388. bytes.push(parser.read(account_id_1.AccountID.width));
  56389. }
  56390. if (type & TYPE_CURRENCY) {
  56391. bytes.push(parser.read(currency_1.Currency.width));
  56392. }
  56393. if (type & TYPE_ISSUER) {
  56394. bytes.push(parser.read(account_id_1.AccountID.width));
  56395. }
  56396. return new Hop(buffer_1.Buffer.concat(bytes));
  56397. }
  56398. /**
  56399. * Get the JSON interpretation of this hop
  56400. *
  56401. * @returns a HopObject, an JS object with optional account, issuer, and currency
  56402. */
  56403. toJSON() {
  56404. const hopParser = new binary_parser_1.BinaryParser(this.bytes.toString('hex'));
  56405. const type = hopParser.readUInt8();
  56406. let account, currency, issuer;
  56407. if (type & TYPE_ACCOUNT) {
  56408. account = account_id_1.AccountID.fromParser(hopParser).toJSON();
  56409. }
  56410. if (type & TYPE_CURRENCY) {
  56411. currency = currency_1.Currency.fromParser(hopParser).toJSON();
  56412. }
  56413. if (type & TYPE_ISSUER) {
  56414. issuer = account_id_1.AccountID.fromParser(hopParser).toJSON();
  56415. }
  56416. const result = {};
  56417. if (account) {
  56418. result.account = account;
  56419. }
  56420. if (issuer) {
  56421. result.issuer = issuer;
  56422. }
  56423. if (currency) {
  56424. result.currency = currency;
  56425. }
  56426. return result;
  56427. }
  56428. /**
  56429. * get a number representing the type of this hop
  56430. *
  56431. * @returns a number to be bitwise and-ed with TYPE_ constants to describe the types in the hop
  56432. */
  56433. type() {
  56434. return this.bytes[0];
  56435. }
  56436. }
  56437. /**
  56438. * Class for serializing/deserializing Paths
  56439. */
  56440. class Path extends serialized_type_1.SerializedType {
  56441. /**
  56442. * construct a Path from an array of Hops
  56443. *
  56444. * @param value Path or array of HopObjects to construct a Path
  56445. * @returns the Path
  56446. */
  56447. static from(value) {
  56448. if (value instanceof Path) {
  56449. return value;
  56450. }
  56451. const bytes = [];
  56452. value.forEach((hop) => {
  56453. bytes.push(Hop.from(hop).toBytes());
  56454. });
  56455. return new Path(buffer_1.Buffer.concat(bytes));
  56456. }
  56457. /**
  56458. * Read a Path from a BinaryParser
  56459. *
  56460. * @param parser BinaryParser to read Path from
  56461. * @returns the Path represented by the bytes read from the BinaryParser
  56462. */
  56463. static fromParser(parser) {
  56464. const bytes = [];
  56465. while (!parser.end()) {
  56466. bytes.push(Hop.fromParser(parser).toBytes());
  56467. if (parser.peek() === PATHSET_END_BYTE ||
  56468. parser.peek() === PATH_SEPARATOR_BYTE) {
  56469. break;
  56470. }
  56471. }
  56472. return new Path(buffer_1.Buffer.concat(bytes));
  56473. }
  56474. /**
  56475. * Get the JSON representation of this Path
  56476. *
  56477. * @returns an Array of HopObject constructed from this.bytes
  56478. */
  56479. toJSON() {
  56480. const json = [];
  56481. const pathParser = new binary_parser_1.BinaryParser(this.toString());
  56482. while (!pathParser.end()) {
  56483. json.push(Hop.fromParser(pathParser).toJSON());
  56484. }
  56485. return json;
  56486. }
  56487. }
  56488. /**
  56489. * Deserialize and Serialize the PathSet type
  56490. */
  56491. class PathSet extends serialized_type_1.SerializedType {
  56492. /**
  56493. * Construct a PathSet from an Array of Arrays representing paths
  56494. *
  56495. * @param value A PathSet or Array of Array of HopObjects
  56496. * @returns the PathSet constructed from value
  56497. */
  56498. static from(value) {
  56499. if (value instanceof PathSet) {
  56500. return value;
  56501. }
  56502. if (isPathSet(value)) {
  56503. const bytes = [];
  56504. value.forEach((path) => {
  56505. bytes.push(Path.from(path).toBytes());
  56506. bytes.push(buffer_1.Buffer.from([PATH_SEPARATOR_BYTE]));
  56507. });
  56508. bytes[bytes.length - 1] = buffer_1.Buffer.from([PATHSET_END_BYTE]);
  56509. return new PathSet(buffer_1.Buffer.concat(bytes));
  56510. }
  56511. throw new Error('Cannot construct PathSet from given value');
  56512. }
  56513. /**
  56514. * Construct a PathSet from a BinaryParser
  56515. *
  56516. * @param parser A BinaryParser to read PathSet from
  56517. * @returns the PathSet read from parser
  56518. */
  56519. static fromParser(parser) {
  56520. const bytes = [];
  56521. while (!parser.end()) {
  56522. bytes.push(Path.fromParser(parser).toBytes());
  56523. bytes.push(parser.read(1));
  56524. if (bytes[bytes.length - 1][0] == PATHSET_END_BYTE) {
  56525. break;
  56526. }
  56527. }
  56528. return new PathSet(buffer_1.Buffer.concat(bytes));
  56529. }
  56530. /**
  56531. * Get the JSON representation of this PathSet
  56532. *
  56533. * @returns an Array of Array of HopObjects, representing this PathSet
  56534. */
  56535. toJSON() {
  56536. const json = [];
  56537. const pathParser = new binary_parser_1.BinaryParser(this.toString());
  56538. while (!pathParser.end()) {
  56539. json.push(Path.fromParser(pathParser).toJSON());
  56540. pathParser.skip(1);
  56541. }
  56542. return json;
  56543. }
  56544. }
  56545. exports.PathSet = PathSet;
  56546. /***/ }),
  56547. /***/ "../../node_modules/ripple-binary-codec/dist/types/serialized-type.js":
  56548. /*!****************************************************************************!*\
  56549. !*** ../../node_modules/ripple-binary-codec/dist/types/serialized-type.js ***!
  56550. \****************************************************************************/
  56551. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  56552. "use strict";
  56553. Object.defineProperty(exports, "__esModule", ({ value: true }));
  56554. exports.Comparable = exports.SerializedType = void 0;
  56555. const binary_serializer_1 = __webpack_require__(/*! ../serdes/binary-serializer */ "../../node_modules/ripple-binary-codec/dist/serdes/binary-serializer.js");
  56556. const buffer_1 = __webpack_require__(/*! buffer/ */ "../../node_modules/ripple-binary-codec/node_modules/buffer/index.js");
  56557. /**
  56558. * The base class for all binary-codec types
  56559. */
  56560. class SerializedType {
  56561. constructor(bytes) {
  56562. this.bytes = buffer_1.Buffer.alloc(0);
  56563. this.bytes = bytes !== null && bytes !== void 0 ? bytes : buffer_1.Buffer.alloc(0);
  56564. }
  56565. static fromParser(parser, hint) {
  56566. throw new Error('fromParser not implemented');
  56567. return this.fromParser(parser, hint);
  56568. }
  56569. static from(value) {
  56570. throw new Error('from not implemented');
  56571. return this.from(value);
  56572. }
  56573. /**
  56574. * Write the bytes representation of a SerializedType to a BytesList
  56575. *
  56576. * @param list The BytesList to write SerializedType bytes to
  56577. */
  56578. toBytesSink(list) {
  56579. list.put(this.bytes);
  56580. }
  56581. /**
  56582. * Get the hex representation of a SerializedType's bytes
  56583. *
  56584. * @returns hex String of this.bytes
  56585. */
  56586. toHex() {
  56587. return this.toBytes().toString('hex').toUpperCase();
  56588. }
  56589. /**
  56590. * Get the bytes representation of a SerializedType
  56591. *
  56592. * @returns A buffer of the bytes
  56593. */
  56594. toBytes() {
  56595. if (this.bytes) {
  56596. return this.bytes;
  56597. }
  56598. const bytes = new binary_serializer_1.BytesList();
  56599. this.toBytesSink(bytes);
  56600. return bytes.toBytes();
  56601. }
  56602. /**
  56603. * Return the JSON representation of a SerializedType
  56604. *
  56605. * @returns any type, if not overloaded returns hexString representation of bytes
  56606. */
  56607. toJSON() {
  56608. return this.toHex();
  56609. }
  56610. /**
  56611. * @returns hexString representation of this.bytes
  56612. */
  56613. toString() {
  56614. return this.toHex();
  56615. }
  56616. }
  56617. exports.SerializedType = SerializedType;
  56618. /**
  56619. * Base class for SerializedTypes that are comparable
  56620. */
  56621. class Comparable extends SerializedType {
  56622. lt(other) {
  56623. return this.compareTo(other) < 0;
  56624. }
  56625. eq(other) {
  56626. return this.compareTo(other) === 0;
  56627. }
  56628. gt(other) {
  56629. return this.compareTo(other) > 0;
  56630. }
  56631. gte(other) {
  56632. return this.compareTo(other) > -1;
  56633. }
  56634. lte(other) {
  56635. return this.compareTo(other) < 1;
  56636. }
  56637. /**
  56638. * Overload this method to define how two Comparable SerializedTypes are compared
  56639. *
  56640. * @param other The comparable object to compare this to
  56641. * @returns A number denoting the relationship of this and other
  56642. */
  56643. compareTo(other) {
  56644. throw new Error(`cannot compare ${this.toString()} and ${other.toString()}`);
  56645. }
  56646. }
  56647. exports.Comparable = Comparable;
  56648. /***/ }),
  56649. /***/ "../../node_modules/ripple-binary-codec/dist/types/st-array.js":
  56650. /*!*********************************************************************!*\
  56651. !*** ../../node_modules/ripple-binary-codec/dist/types/st-array.js ***!
  56652. \*********************************************************************/
  56653. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  56654. "use strict";
  56655. Object.defineProperty(exports, "__esModule", ({ value: true }));
  56656. exports.STArray = void 0;
  56657. const serialized_type_1 = __webpack_require__(/*! ./serialized-type */ "../../node_modules/ripple-binary-codec/dist/types/serialized-type.js");
  56658. const st_object_1 = __webpack_require__(/*! ./st-object */ "../../node_modules/ripple-binary-codec/dist/types/st-object.js");
  56659. const binary_parser_1 = __webpack_require__(/*! ../serdes/binary-parser */ "../../node_modules/ripple-binary-codec/dist/serdes/binary-parser.js");
  56660. const buffer_1 = __webpack_require__(/*! buffer/ */ "../../node_modules/ripple-binary-codec/node_modules/buffer/index.js");
  56661. const ARRAY_END_MARKER = buffer_1.Buffer.from([0xf1]);
  56662. const ARRAY_END_MARKER_NAME = 'ArrayEndMarker';
  56663. const OBJECT_END_MARKER = buffer_1.Buffer.from([0xe1]);
  56664. /**
  56665. * TypeGuard for Array<JsonObject>
  56666. */
  56667. function isObjects(args) {
  56668. return (Array.isArray(args) && (args.length === 0 || typeof args[0] === 'object'));
  56669. }
  56670. /**
  56671. * Class for serializing and deserializing Arrays of Objects
  56672. */
  56673. class STArray extends serialized_type_1.SerializedType {
  56674. /**
  56675. * Construct an STArray from a BinaryParser
  56676. *
  56677. * @param parser BinaryParser to parse an STArray from
  56678. * @returns An STArray Object
  56679. */
  56680. static fromParser(parser) {
  56681. const bytes = [];
  56682. while (!parser.end()) {
  56683. const field = parser.readField();
  56684. if (field.name === ARRAY_END_MARKER_NAME) {
  56685. break;
  56686. }
  56687. bytes.push(field.header, parser.readFieldValue(field).toBytes(), OBJECT_END_MARKER);
  56688. }
  56689. bytes.push(ARRAY_END_MARKER);
  56690. return new STArray(buffer_1.Buffer.concat(bytes));
  56691. }
  56692. /**
  56693. * Construct an STArray from an Array of JSON Objects
  56694. *
  56695. * @param value STArray or Array of Objects to parse into an STArray
  56696. * @returns An STArray object
  56697. */
  56698. static from(value) {
  56699. if (value instanceof STArray) {
  56700. return value;
  56701. }
  56702. if (isObjects(value)) {
  56703. const bytes = [];
  56704. value.forEach((obj) => {
  56705. bytes.push(st_object_1.STObject.from(obj).toBytes());
  56706. });
  56707. bytes.push(ARRAY_END_MARKER);
  56708. return new STArray(buffer_1.Buffer.concat(bytes));
  56709. }
  56710. throw new Error('Cannot construct STArray from value given');
  56711. }
  56712. /**
  56713. * Return the JSON representation of this.bytes
  56714. *
  56715. * @returns An Array of JSON objects
  56716. */
  56717. toJSON() {
  56718. const result = [];
  56719. const arrayParser = new binary_parser_1.BinaryParser(this.toString());
  56720. while (!arrayParser.end()) {
  56721. const field = arrayParser.readField();
  56722. if (field.name === ARRAY_END_MARKER_NAME) {
  56723. break;
  56724. }
  56725. const outer = {};
  56726. outer[field.name] = st_object_1.STObject.fromParser(arrayParser).toJSON();
  56727. result.push(outer);
  56728. }
  56729. return result;
  56730. }
  56731. }
  56732. exports.STArray = STArray;
  56733. /***/ }),
  56734. /***/ "../../node_modules/ripple-binary-codec/dist/types/st-object.js":
  56735. /*!**********************************************************************!*\
  56736. !*** ../../node_modules/ripple-binary-codec/dist/types/st-object.js ***!
  56737. \**********************************************************************/
  56738. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  56739. "use strict";
  56740. Object.defineProperty(exports, "__esModule", ({ value: true }));
  56741. exports.STObject = void 0;
  56742. const enums_1 = __webpack_require__(/*! ../enums */ "../../node_modules/ripple-binary-codec/dist/enums/index.js");
  56743. const serialized_type_1 = __webpack_require__(/*! ./serialized-type */ "../../node_modules/ripple-binary-codec/dist/types/serialized-type.js");
  56744. const ripple_address_codec_1 = __webpack_require__(/*! ripple-address-codec */ "../../node_modules/ripple-address-codec/dist/index.js");
  56745. const binary_parser_1 = __webpack_require__(/*! ../serdes/binary-parser */ "../../node_modules/ripple-binary-codec/dist/serdes/binary-parser.js");
  56746. const binary_serializer_1 = __webpack_require__(/*! ../serdes/binary-serializer */ "../../node_modules/ripple-binary-codec/dist/serdes/binary-serializer.js");
  56747. const buffer_1 = __webpack_require__(/*! buffer/ */ "../../node_modules/ripple-binary-codec/node_modules/buffer/index.js");
  56748. const OBJECT_END_MARKER_BYTE = buffer_1.Buffer.from([0xe1]);
  56749. const OBJECT_END_MARKER = 'ObjectEndMarker';
  56750. const ST_OBJECT = 'STObject';
  56751. const DESTINATION = 'Destination';
  56752. const ACCOUNT = 'Account';
  56753. const SOURCE_TAG = 'SourceTag';
  56754. const DEST_TAG = 'DestinationTag';
  56755. /**
  56756. * Break down an X-Address into an account and a tag
  56757. *
  56758. * @param field Name of field
  56759. * @param xAddress X-Address corresponding to the field
  56760. */
  56761. function handleXAddress(field, xAddress) {
  56762. const decoded = (0, ripple_address_codec_1.xAddressToClassicAddress)(xAddress);
  56763. let tagName;
  56764. if (field === DESTINATION)
  56765. tagName = DEST_TAG;
  56766. else if (field === ACCOUNT)
  56767. tagName = SOURCE_TAG;
  56768. else if (decoded.tag !== false)
  56769. throw new Error(`${field} cannot have an associated tag`);
  56770. return decoded.tag !== false
  56771. ? { [field]: decoded.classicAddress, [tagName]: decoded.tag }
  56772. : { [field]: decoded.classicAddress };
  56773. }
  56774. /**
  56775. * Validate that two objects don't both have the same tag fields
  56776. *
  56777. * @param obj1 First object to check for tags
  56778. * @param obj2 Second object to check for tags
  56779. * @throws When both objects have SourceTag or DestinationTag
  56780. */
  56781. function checkForDuplicateTags(obj1, obj2) {
  56782. if (!(obj1[SOURCE_TAG] === undefined || obj2[SOURCE_TAG] === undefined))
  56783. throw new Error('Cannot have Account X-Address and SourceTag');
  56784. if (!(obj1[DEST_TAG] === undefined || obj2[DEST_TAG] === undefined))
  56785. throw new Error('Cannot have Destination X-Address and DestinationTag');
  56786. }
  56787. /**
  56788. * Class for Serializing/Deserializing objects
  56789. */
  56790. class STObject extends serialized_type_1.SerializedType {
  56791. /**
  56792. * Construct a STObject from a BinaryParser
  56793. *
  56794. * @param parser BinaryParser to read STObject from
  56795. * @returns A STObject object
  56796. */
  56797. static fromParser(parser) {
  56798. const list = new binary_serializer_1.BytesList();
  56799. const bytes = new binary_serializer_1.BinarySerializer(list);
  56800. while (!parser.end()) {
  56801. const field = parser.readField();
  56802. if (field.name === OBJECT_END_MARKER) {
  56803. break;
  56804. }
  56805. const associatedValue = parser.readFieldValue(field);
  56806. bytes.writeFieldAndValue(field, associatedValue);
  56807. if (field.type.name === ST_OBJECT) {
  56808. bytes.put(OBJECT_END_MARKER_BYTE);
  56809. }
  56810. }
  56811. return new STObject(list.toBytes());
  56812. }
  56813. /**
  56814. * Construct a STObject from a JSON object
  56815. *
  56816. * @param value An object to include
  56817. * @param filter optional, denote which field to include in serialized object
  56818. * @returns a STObject object
  56819. */
  56820. static from(value, filter) {
  56821. if (value instanceof STObject) {
  56822. return value;
  56823. }
  56824. const list = new binary_serializer_1.BytesList();
  56825. const bytes = new binary_serializer_1.BinarySerializer(list);
  56826. let isUnlModify = false;
  56827. const xAddressDecoded = Object.entries(value).reduce((acc, [key, val]) => {
  56828. let handled = undefined;
  56829. if (val && (0, ripple_address_codec_1.isValidXAddress)(val.toString())) {
  56830. handled = handleXAddress(key, val.toString());
  56831. checkForDuplicateTags(handled, value);
  56832. }
  56833. return Object.assign(acc, handled !== null && handled !== void 0 ? handled : { [key]: val });
  56834. }, {});
  56835. let sorted = Object.keys(xAddressDecoded)
  56836. .map((f) => enums_1.Field[f])
  56837. .filter((f) => f !== undefined &&
  56838. xAddressDecoded[f.name] !== undefined &&
  56839. f.isSerialized)
  56840. .sort((a, b) => {
  56841. return a.ordinal - b.ordinal;
  56842. });
  56843. if (filter !== undefined) {
  56844. sorted = sorted.filter(filter);
  56845. }
  56846. sorted.forEach((field) => {
  56847. const associatedValue = field.associatedType.from(xAddressDecoded[field.name]);
  56848. if (associatedValue == undefined) {
  56849. throw new TypeError(`Unable to interpret "${field.name}: ${xAddressDecoded[field.name]}".`);
  56850. }
  56851. if (associatedValue.name === 'UNLModify') {
  56852. // triggered when the TransactionType field has a value of 'UNLModify'
  56853. isUnlModify = true;
  56854. }
  56855. // true when in the UNLModify pseudotransaction (after the transaction type has been processed) and working with the
  56856. // Account field
  56857. // The Account field must not be a part of the UNLModify pseudotransaction encoding, due to a bug in rippled
  56858. const isUnlModifyWorkaround = field.name == 'Account' && isUnlModify;
  56859. bytes.writeFieldAndValue(field, associatedValue, isUnlModifyWorkaround);
  56860. if (field.type.name === ST_OBJECT) {
  56861. bytes.put(OBJECT_END_MARKER_BYTE);
  56862. }
  56863. });
  56864. return new STObject(list.toBytes());
  56865. }
  56866. /**
  56867. * Get the JSON interpretation of this.bytes
  56868. *
  56869. * @returns a JSON object
  56870. */
  56871. toJSON() {
  56872. const objectParser = new binary_parser_1.BinaryParser(this.toString());
  56873. const accumulator = {};
  56874. while (!objectParser.end()) {
  56875. const field = objectParser.readField();
  56876. if (field.name === OBJECT_END_MARKER) {
  56877. break;
  56878. }
  56879. accumulator[field.name] = objectParser.readFieldValue(field).toJSON();
  56880. }
  56881. return accumulator;
  56882. }
  56883. }
  56884. exports.STObject = STObject;
  56885. /***/ }),
  56886. /***/ "../../node_modules/ripple-binary-codec/dist/types/uint-16.js":
  56887. /*!********************************************************************!*\
  56888. !*** ../../node_modules/ripple-binary-codec/dist/types/uint-16.js ***!
  56889. \********************************************************************/
  56890. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  56891. "use strict";
  56892. Object.defineProperty(exports, "__esModule", ({ value: true }));
  56893. exports.UInt16 = void 0;
  56894. const uint_1 = __webpack_require__(/*! ./uint */ "../../node_modules/ripple-binary-codec/dist/types/uint.js");
  56895. const buffer_1 = __webpack_require__(/*! buffer/ */ "../../node_modules/ripple-binary-codec/node_modules/buffer/index.js");
  56896. /**
  56897. * Derived UInt class for serializing/deserializing 16 bit UInt
  56898. */
  56899. class UInt16 extends uint_1.UInt {
  56900. constructor(bytes) {
  56901. super(bytes !== null && bytes !== void 0 ? bytes : UInt16.defaultUInt16.bytes);
  56902. }
  56903. static fromParser(parser) {
  56904. return new UInt16(parser.read(UInt16.width));
  56905. }
  56906. /**
  56907. * Construct a UInt16 object from a number
  56908. *
  56909. * @param val UInt16 object or number
  56910. */
  56911. static from(val) {
  56912. if (val instanceof UInt16) {
  56913. return val;
  56914. }
  56915. if (typeof val === 'number') {
  56916. const buf = buffer_1.Buffer.alloc(UInt16.width);
  56917. buf.writeUInt16BE(val, 0);
  56918. return new UInt16(buf);
  56919. }
  56920. throw new Error('Can not construct UInt16 with given value');
  56921. }
  56922. /**
  56923. * get the value of a UInt16 object
  56924. *
  56925. * @returns the number represented by this.bytes
  56926. */
  56927. valueOf() {
  56928. return this.bytes.readUInt16BE(0);
  56929. }
  56930. }
  56931. exports.UInt16 = UInt16;
  56932. UInt16.width = 16 / 8; // 2
  56933. UInt16.defaultUInt16 = new UInt16(buffer_1.Buffer.alloc(UInt16.width));
  56934. /***/ }),
  56935. /***/ "../../node_modules/ripple-binary-codec/dist/types/uint-32.js":
  56936. /*!********************************************************************!*\
  56937. !*** ../../node_modules/ripple-binary-codec/dist/types/uint-32.js ***!
  56938. \********************************************************************/
  56939. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  56940. "use strict";
  56941. Object.defineProperty(exports, "__esModule", ({ value: true }));
  56942. exports.UInt32 = void 0;
  56943. const uint_1 = __webpack_require__(/*! ./uint */ "../../node_modules/ripple-binary-codec/dist/types/uint.js");
  56944. const buffer_1 = __webpack_require__(/*! buffer/ */ "../../node_modules/ripple-binary-codec/node_modules/buffer/index.js");
  56945. /**
  56946. * Derived UInt class for serializing/deserializing 32 bit UInt
  56947. */
  56948. class UInt32 extends uint_1.UInt {
  56949. constructor(bytes) {
  56950. super(bytes !== null && bytes !== void 0 ? bytes : UInt32.defaultUInt32.bytes);
  56951. }
  56952. static fromParser(parser) {
  56953. return new UInt32(parser.read(UInt32.width));
  56954. }
  56955. /**
  56956. * Construct a UInt32 object from a number
  56957. *
  56958. * @param val UInt32 object or number
  56959. */
  56960. static from(val) {
  56961. if (val instanceof UInt32) {
  56962. return val;
  56963. }
  56964. const buf = buffer_1.Buffer.alloc(UInt32.width);
  56965. if (typeof val === 'string') {
  56966. const num = Number.parseInt(val);
  56967. buf.writeUInt32BE(num, 0);
  56968. return new UInt32(buf);
  56969. }
  56970. if (typeof val === 'number') {
  56971. buf.writeUInt32BE(val, 0);
  56972. return new UInt32(buf);
  56973. }
  56974. throw new Error('Cannot construct UInt32 from given value');
  56975. }
  56976. /**
  56977. * get the value of a UInt32 object
  56978. *
  56979. * @returns the number represented by this.bytes
  56980. */
  56981. valueOf() {
  56982. return this.bytes.readUInt32BE(0);
  56983. }
  56984. }
  56985. exports.UInt32 = UInt32;
  56986. UInt32.width = 32 / 8; // 4
  56987. UInt32.defaultUInt32 = new UInt32(buffer_1.Buffer.alloc(UInt32.width));
  56988. /***/ }),
  56989. /***/ "../../node_modules/ripple-binary-codec/dist/types/uint-64.js":
  56990. /*!********************************************************************!*\
  56991. !*** ../../node_modules/ripple-binary-codec/dist/types/uint-64.js ***!
  56992. \********************************************************************/
  56993. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  56994. "use strict";
  56995. Object.defineProperty(exports, "__esModule", ({ value: true }));
  56996. exports.UInt64 = void 0;
  56997. const uint_1 = __webpack_require__(/*! ./uint */ "../../node_modules/ripple-binary-codec/dist/types/uint.js");
  56998. const bigInt = __webpack_require__(/*! big-integer */ "../../node_modules/big-integer/BigInteger.js");
  56999. const big_integer_1 = __webpack_require__(/*! big-integer */ "../../node_modules/big-integer/BigInteger.js");
  57000. const buffer_1 = __webpack_require__(/*! buffer/ */ "../../node_modules/ripple-binary-codec/node_modules/buffer/index.js");
  57001. const HEX_REGEX = /^[a-fA-F0-9]{1,16}$/;
  57002. const mask = bigInt(0x00000000ffffffff);
  57003. /**
  57004. * Derived UInt class for serializing/deserializing 64 bit UInt
  57005. */
  57006. class UInt64 extends uint_1.UInt {
  57007. constructor(bytes) {
  57008. super(bytes !== null && bytes !== void 0 ? bytes : UInt64.defaultUInt64.bytes);
  57009. }
  57010. static fromParser(parser) {
  57011. return new UInt64(parser.read(UInt64.width));
  57012. }
  57013. /**
  57014. * Construct a UInt64 object
  57015. *
  57016. * @param val A UInt64, hex-string, bigInt, or number
  57017. * @returns A UInt64 object
  57018. */
  57019. static from(val) {
  57020. if (val instanceof UInt64) {
  57021. return val;
  57022. }
  57023. let buf = buffer_1.Buffer.alloc(UInt64.width);
  57024. if (typeof val === 'number') {
  57025. if (val < 0) {
  57026. throw new Error('value must be an unsigned integer');
  57027. }
  57028. const number = bigInt(val);
  57029. const intBuf = [buffer_1.Buffer.alloc(4), buffer_1.Buffer.alloc(4)];
  57030. intBuf[0].writeUInt32BE(Number(number.shiftRight(32)), 0);
  57031. intBuf[1].writeUInt32BE(Number(number.and(mask)), 0);
  57032. return new UInt64(buffer_1.Buffer.concat(intBuf));
  57033. }
  57034. if (typeof val === 'string') {
  57035. if (!HEX_REGEX.test(val)) {
  57036. throw new Error(`${val} is not a valid hex-string`);
  57037. }
  57038. const strBuf = val.padStart(16, '0');
  57039. buf = buffer_1.Buffer.from(strBuf, 'hex');
  57040. return new UInt64(buf);
  57041. }
  57042. if ((0, big_integer_1.isInstance)(val)) {
  57043. const intBuf = [buffer_1.Buffer.alloc(4), buffer_1.Buffer.alloc(4)];
  57044. intBuf[0].writeUInt32BE(Number(val.shiftRight(bigInt(32))), 0);
  57045. intBuf[1].writeUInt32BE(Number(val.and(mask)), 0);
  57046. return new UInt64(buffer_1.Buffer.concat(intBuf));
  57047. }
  57048. throw new Error('Cannot construct UInt64 from given value');
  57049. }
  57050. /**
  57051. * The JSON representation of a UInt64 object
  57052. *
  57053. * @returns a hex-string
  57054. */
  57055. toJSON() {
  57056. return this.bytes.toString('hex').toUpperCase();
  57057. }
  57058. /**
  57059. * Get the value of the UInt64
  57060. *
  57061. * @returns the number represented buy this.bytes
  57062. */
  57063. valueOf() {
  57064. const msb = bigInt(this.bytes.slice(0, 4).readUInt32BE(0));
  57065. const lsb = bigInt(this.bytes.slice(4).readUInt32BE(0));
  57066. return msb.shiftLeft(bigInt(32)).or(lsb);
  57067. }
  57068. /**
  57069. * Get the bytes representation of the UInt64 object
  57070. *
  57071. * @returns 8 bytes representing the UInt64
  57072. */
  57073. toBytes() {
  57074. return this.bytes;
  57075. }
  57076. }
  57077. exports.UInt64 = UInt64;
  57078. UInt64.width = 64 / 8; // 8
  57079. UInt64.defaultUInt64 = new UInt64(buffer_1.Buffer.alloc(UInt64.width));
  57080. /***/ }),
  57081. /***/ "../../node_modules/ripple-binary-codec/dist/types/uint-8.js":
  57082. /*!*******************************************************************!*\
  57083. !*** ../../node_modules/ripple-binary-codec/dist/types/uint-8.js ***!
  57084. \*******************************************************************/
  57085. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  57086. "use strict";
  57087. Object.defineProperty(exports, "__esModule", ({ value: true }));
  57088. exports.UInt8 = void 0;
  57089. const uint_1 = __webpack_require__(/*! ./uint */ "../../node_modules/ripple-binary-codec/dist/types/uint.js");
  57090. const buffer_1 = __webpack_require__(/*! buffer/ */ "../../node_modules/ripple-binary-codec/node_modules/buffer/index.js");
  57091. /**
  57092. * Derived UInt class for serializing/deserializing 8 bit UInt
  57093. */
  57094. class UInt8 extends uint_1.UInt {
  57095. constructor(bytes) {
  57096. super(bytes !== null && bytes !== void 0 ? bytes : UInt8.defaultUInt8.bytes);
  57097. }
  57098. static fromParser(parser) {
  57099. return new UInt8(parser.read(UInt8.width));
  57100. }
  57101. /**
  57102. * Construct a UInt8 object from a number
  57103. *
  57104. * @param val UInt8 object or number
  57105. */
  57106. static from(val) {
  57107. if (val instanceof UInt8) {
  57108. return val;
  57109. }
  57110. if (typeof val === 'number') {
  57111. const buf = buffer_1.Buffer.alloc(UInt8.width);
  57112. buf.writeUInt8(val, 0);
  57113. return new UInt8(buf);
  57114. }
  57115. throw new Error('Cannot construct UInt8 from given value');
  57116. }
  57117. /**
  57118. * get the value of a UInt8 object
  57119. *
  57120. * @returns the number represented by this.bytes
  57121. */
  57122. valueOf() {
  57123. return this.bytes.readUInt8(0);
  57124. }
  57125. }
  57126. exports.UInt8 = UInt8;
  57127. UInt8.width = 8 / 8; // 1
  57128. UInt8.defaultUInt8 = new UInt8(buffer_1.Buffer.alloc(UInt8.width));
  57129. /***/ }),
  57130. /***/ "../../node_modules/ripple-binary-codec/dist/types/uint.js":
  57131. /*!*****************************************************************!*\
  57132. !*** ../../node_modules/ripple-binary-codec/dist/types/uint.js ***!
  57133. \*****************************************************************/
  57134. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  57135. "use strict";
  57136. Object.defineProperty(exports, "__esModule", ({ value: true }));
  57137. exports.UInt = void 0;
  57138. const serialized_type_1 = __webpack_require__(/*! ./serialized-type */ "../../node_modules/ripple-binary-codec/dist/types/serialized-type.js");
  57139. /**
  57140. * Compare numbers and bigInts n1 and n2
  57141. *
  57142. * @param n1 First object to compare
  57143. * @param n2 Second object to compare
  57144. * @returns -1, 0, or 1, depending on how the two objects compare
  57145. */
  57146. function compare(n1, n2) {
  57147. return n1 < n2 ? -1 : n1 == n2 ? 0 : 1;
  57148. }
  57149. /**
  57150. * Base class for serializing and deserializing unsigned integers.
  57151. */
  57152. class UInt extends serialized_type_1.Comparable {
  57153. constructor(bytes) {
  57154. super(bytes);
  57155. }
  57156. /**
  57157. * Overload of compareTo for Comparable
  57158. *
  57159. * @param other other UInt to compare this to
  57160. * @returns -1, 0, or 1 depending on how the objects relate to each other
  57161. */
  57162. compareTo(other) {
  57163. return compare(this.valueOf(), other.valueOf());
  57164. }
  57165. /**
  57166. * Convert a UInt object to JSON
  57167. *
  57168. * @returns number or string represented by this.bytes
  57169. */
  57170. toJSON() {
  57171. const val = this.valueOf();
  57172. return typeof val === 'number' ? val : val.toString();
  57173. }
  57174. }
  57175. exports.UInt = UInt;
  57176. /***/ }),
  57177. /***/ "../../node_modules/ripple-binary-codec/dist/types/vector-256.js":
  57178. /*!***********************************************************************!*\
  57179. !*** ../../node_modules/ripple-binary-codec/dist/types/vector-256.js ***!
  57180. \***********************************************************************/
  57181. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  57182. "use strict";
  57183. Object.defineProperty(exports, "__esModule", ({ value: true }));
  57184. exports.Vector256 = void 0;
  57185. const serialized_type_1 = __webpack_require__(/*! ./serialized-type */ "../../node_modules/ripple-binary-codec/dist/types/serialized-type.js");
  57186. const hash_256_1 = __webpack_require__(/*! ./hash-256 */ "../../node_modules/ripple-binary-codec/dist/types/hash-256.js");
  57187. const binary_serializer_1 = __webpack_require__(/*! ../serdes/binary-serializer */ "../../node_modules/ripple-binary-codec/dist/serdes/binary-serializer.js");
  57188. /**
  57189. * TypeGuard for Array<string>
  57190. */
  57191. function isStrings(arg) {
  57192. return Array.isArray(arg) && (arg.length === 0 || typeof arg[0] === 'string');
  57193. }
  57194. /**
  57195. * Class for serializing and deserializing vectors of Hash256
  57196. */
  57197. class Vector256 extends serialized_type_1.SerializedType {
  57198. constructor(bytes) {
  57199. super(bytes);
  57200. }
  57201. /**
  57202. * Construct a Vector256 from a BinaryParser
  57203. *
  57204. * @param parser BinaryParser to
  57205. * @param hint length of the vector, in bytes, optional
  57206. * @returns a Vector256 object
  57207. */
  57208. static fromParser(parser, hint) {
  57209. const bytesList = new binary_serializer_1.BytesList();
  57210. const bytes = hint !== null && hint !== void 0 ? hint : parser.size();
  57211. const hashes = bytes / 32;
  57212. for (let i = 0; i < hashes; i++) {
  57213. hash_256_1.Hash256.fromParser(parser).toBytesSink(bytesList);
  57214. }
  57215. return new Vector256(bytesList.toBytes());
  57216. }
  57217. /**
  57218. * Construct a Vector256 object from an array of hashes
  57219. *
  57220. * @param value A Vector256 object or array of hex-strings representing Hash256's
  57221. * @returns a Vector256 object
  57222. */
  57223. static from(value) {
  57224. if (value instanceof Vector256) {
  57225. return value;
  57226. }
  57227. if (isStrings(value)) {
  57228. const bytesList = new binary_serializer_1.BytesList();
  57229. value.forEach((hash) => {
  57230. hash_256_1.Hash256.from(hash).toBytesSink(bytesList);
  57231. });
  57232. return new Vector256(bytesList.toBytes());
  57233. }
  57234. throw new Error('Cannot construct Vector256 from given value');
  57235. }
  57236. /**
  57237. * Return an Array of hex-strings represented by this.bytes
  57238. *
  57239. * @returns An Array of strings representing the Hash256 objects
  57240. */
  57241. toJSON() {
  57242. if (this.bytes.byteLength % 32 !== 0) {
  57243. throw new Error('Invalid bytes for Vector256');
  57244. }
  57245. const result = [];
  57246. for (let i = 0; i < this.bytes.byteLength; i += 32) {
  57247. result.push(this.bytes
  57248. .slice(i, i + 32)
  57249. .toString('hex')
  57250. .toUpperCase());
  57251. }
  57252. return result;
  57253. }
  57254. }
  57255. exports.Vector256 = Vector256;
  57256. /***/ }),
  57257. /***/ "../../node_modules/ripple-binary-codec/node_modules/buffer/index.js":
  57258. /*!***************************************************************************!*\
  57259. !*** ../../node_modules/ripple-binary-codec/node_modules/buffer/index.js ***!
  57260. \***************************************************************************/
  57261. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  57262. "use strict";
  57263. /*!
  57264. * The buffer module from node.js, for the browser.
  57265. *
  57266. * @author Feross Aboukhadijeh <https://feross.org>
  57267. * @license MIT
  57268. */
  57269. /* eslint-disable no-proto */
  57270. var base64 = __webpack_require__(/*! base64-js */ "../../node_modules/base64-js/index.js")
  57271. var ieee754 = __webpack_require__(/*! ieee754 */ "../../node_modules/ieee754/index.js")
  57272. var customInspectSymbol =
  57273. (typeof Symbol === 'function' && typeof Symbol.for === 'function')
  57274. ? Symbol.for('nodejs.util.inspect.custom')
  57275. : null
  57276. exports.Buffer = Buffer
  57277. exports.SlowBuffer = SlowBuffer
  57278. exports.INSPECT_MAX_BYTES = 50
  57279. var K_MAX_LENGTH = 0x7fffffff
  57280. exports.kMaxLength = K_MAX_LENGTH
  57281. /**
  57282. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  57283. * === true Use Uint8Array implementation (fastest)
  57284. * === false Print warning and recommend using `buffer` v4.x which has an Object
  57285. * implementation (most compatible, even IE6)
  57286. *
  57287. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  57288. * Opera 11.6+, iOS 4.2+.
  57289. *
  57290. * We report that the browser does not support typed arrays if the are not subclassable
  57291. * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
  57292. * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
  57293. * for __proto__ and has a buggy typed array implementation.
  57294. */
  57295. Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
  57296. if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
  57297. typeof console.error === 'function') {
  57298. console.error(
  57299. 'This browser lacks typed array (Uint8Array) support which is required by ' +
  57300. '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
  57301. )
  57302. }
  57303. function typedArraySupport () {
  57304. // Can typed array instances can be augmented?
  57305. try {
  57306. var arr = new Uint8Array(1)
  57307. var proto = { foo: function () { return 42 } }
  57308. Object.setPrototypeOf(proto, Uint8Array.prototype)
  57309. Object.setPrototypeOf(arr, proto)
  57310. return arr.foo() === 42
  57311. } catch (e) {
  57312. return false
  57313. }
  57314. }
  57315. Object.defineProperty(Buffer.prototype, 'parent', {
  57316. enumerable: true,
  57317. get: function () {
  57318. if (!Buffer.isBuffer(this)) return undefined
  57319. return this.buffer
  57320. }
  57321. })
  57322. Object.defineProperty(Buffer.prototype, 'offset', {
  57323. enumerable: true,
  57324. get: function () {
  57325. if (!Buffer.isBuffer(this)) return undefined
  57326. return this.byteOffset
  57327. }
  57328. })
  57329. function createBuffer (length) {
  57330. if (length > K_MAX_LENGTH) {
  57331. throw new RangeError('The value "' + length + '" is invalid for option "size"')
  57332. }
  57333. // Return an augmented `Uint8Array` instance
  57334. var buf = new Uint8Array(length)
  57335. Object.setPrototypeOf(buf, Buffer.prototype)
  57336. return buf
  57337. }
  57338. /**
  57339. * The Buffer constructor returns instances of `Uint8Array` that have their
  57340. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  57341. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  57342. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  57343. * returns a single octet.
  57344. *
  57345. * The `Uint8Array` prototype remains unmodified.
  57346. */
  57347. function Buffer (arg, encodingOrOffset, length) {
  57348. // Common case.
  57349. if (typeof arg === 'number') {
  57350. if (typeof encodingOrOffset === 'string') {
  57351. throw new TypeError(
  57352. 'The "string" argument must be of type string. Received type number'
  57353. )
  57354. }
  57355. return allocUnsafe(arg)
  57356. }
  57357. return from(arg, encodingOrOffset, length)
  57358. }
  57359. Buffer.poolSize = 8192 // not used by this implementation
  57360. function from (value, encodingOrOffset, length) {
  57361. if (typeof value === 'string') {
  57362. return fromString(value, encodingOrOffset)
  57363. }
  57364. if (ArrayBuffer.isView(value)) {
  57365. return fromArrayLike(value)
  57366. }
  57367. if (value == null) {
  57368. throw new TypeError(
  57369. 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
  57370. 'or Array-like Object. Received type ' + (typeof value)
  57371. )
  57372. }
  57373. if (isInstance(value, ArrayBuffer) ||
  57374. (value && isInstance(value.buffer, ArrayBuffer))) {
  57375. return fromArrayBuffer(value, encodingOrOffset, length)
  57376. }
  57377. if (typeof SharedArrayBuffer !== 'undefined' &&
  57378. (isInstance(value, SharedArrayBuffer) ||
  57379. (value && isInstance(value.buffer, SharedArrayBuffer)))) {
  57380. return fromArrayBuffer(value, encodingOrOffset, length)
  57381. }
  57382. if (typeof value === 'number') {
  57383. throw new TypeError(
  57384. 'The "value" argument must not be of type number. Received type number'
  57385. )
  57386. }
  57387. var valueOf = value.valueOf && value.valueOf()
  57388. if (valueOf != null && valueOf !== value) {
  57389. return Buffer.from(valueOf, encodingOrOffset, length)
  57390. }
  57391. var b = fromObject(value)
  57392. if (b) return b
  57393. if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
  57394. typeof value[Symbol.toPrimitive] === 'function') {
  57395. return Buffer.from(
  57396. value[Symbol.toPrimitive]('string'), encodingOrOffset, length
  57397. )
  57398. }
  57399. throw new TypeError(
  57400. 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
  57401. 'or Array-like Object. Received type ' + (typeof value)
  57402. )
  57403. }
  57404. /**
  57405. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  57406. * if value is a number.
  57407. * Buffer.from(str[, encoding])
  57408. * Buffer.from(array)
  57409. * Buffer.from(buffer)
  57410. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  57411. **/
  57412. Buffer.from = function (value, encodingOrOffset, length) {
  57413. return from(value, encodingOrOffset, length)
  57414. }
  57415. // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
  57416. // https://github.com/feross/buffer/pull/148
  57417. Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype)
  57418. Object.setPrototypeOf(Buffer, Uint8Array)
  57419. function assertSize (size) {
  57420. if (typeof size !== 'number') {
  57421. throw new TypeError('"size" argument must be of type number')
  57422. } else if (size < 0) {
  57423. throw new RangeError('The value "' + size + '" is invalid for option "size"')
  57424. }
  57425. }
  57426. function alloc (size, fill, encoding) {
  57427. assertSize(size)
  57428. if (size <= 0) {
  57429. return createBuffer(size)
  57430. }
  57431. if (fill !== undefined) {
  57432. // Only pay attention to encoding if it's a string. This
  57433. // prevents accidentally sending in a number that would
  57434. // be interpretted as a start offset.
  57435. return typeof encoding === 'string'
  57436. ? createBuffer(size).fill(fill, encoding)
  57437. : createBuffer(size).fill(fill)
  57438. }
  57439. return createBuffer(size)
  57440. }
  57441. /**
  57442. * Creates a new filled Buffer instance.
  57443. * alloc(size[, fill[, encoding]])
  57444. **/
  57445. Buffer.alloc = function (size, fill, encoding) {
  57446. return alloc(size, fill, encoding)
  57447. }
  57448. function allocUnsafe (size) {
  57449. assertSize(size)
  57450. return createBuffer(size < 0 ? 0 : checked(size) | 0)
  57451. }
  57452. /**
  57453. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  57454. * */
  57455. Buffer.allocUnsafe = function (size) {
  57456. return allocUnsafe(size)
  57457. }
  57458. /**
  57459. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  57460. */
  57461. Buffer.allocUnsafeSlow = function (size) {
  57462. return allocUnsafe(size)
  57463. }
  57464. function fromString (string, encoding) {
  57465. if (typeof encoding !== 'string' || encoding === '') {
  57466. encoding = 'utf8'
  57467. }
  57468. if (!Buffer.isEncoding(encoding)) {
  57469. throw new TypeError('Unknown encoding: ' + encoding)
  57470. }
  57471. var length = byteLength(string, encoding) | 0
  57472. var buf = createBuffer(length)
  57473. var actual = buf.write(string, encoding)
  57474. if (actual !== length) {
  57475. // Writing a hex string, for example, that contains invalid characters will
  57476. // cause everything after the first invalid character to be ignored. (e.g.
  57477. // 'abxxcd' will be treated as 'ab')
  57478. buf = buf.slice(0, actual)
  57479. }
  57480. return buf
  57481. }
  57482. function fromArrayLike (array) {
  57483. var length = array.length < 0 ? 0 : checked(array.length) | 0
  57484. var buf = createBuffer(length)
  57485. for (var i = 0; i < length; i += 1) {
  57486. buf[i] = array[i] & 255
  57487. }
  57488. return buf
  57489. }
  57490. function fromArrayBuffer (array, byteOffset, length) {
  57491. if (byteOffset < 0 || array.byteLength < byteOffset) {
  57492. throw new RangeError('"offset" is outside of buffer bounds')
  57493. }
  57494. if (array.byteLength < byteOffset + (length || 0)) {
  57495. throw new RangeError('"length" is outside of buffer bounds')
  57496. }
  57497. var buf
  57498. if (byteOffset === undefined && length === undefined) {
  57499. buf = new Uint8Array(array)
  57500. } else if (length === undefined) {
  57501. buf = new Uint8Array(array, byteOffset)
  57502. } else {
  57503. buf = new Uint8Array(array, byteOffset, length)
  57504. }
  57505. // Return an augmented `Uint8Array` instance
  57506. Object.setPrototypeOf(buf, Buffer.prototype)
  57507. return buf
  57508. }
  57509. function fromObject (obj) {
  57510. if (Buffer.isBuffer(obj)) {
  57511. var len = checked(obj.length) | 0
  57512. var buf = createBuffer(len)
  57513. if (buf.length === 0) {
  57514. return buf
  57515. }
  57516. obj.copy(buf, 0, 0, len)
  57517. return buf
  57518. }
  57519. if (obj.length !== undefined) {
  57520. if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
  57521. return createBuffer(0)
  57522. }
  57523. return fromArrayLike(obj)
  57524. }
  57525. if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
  57526. return fromArrayLike(obj.data)
  57527. }
  57528. }
  57529. function checked (length) {
  57530. // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
  57531. // length is NaN (which is otherwise coerced to zero.)
  57532. if (length >= K_MAX_LENGTH) {
  57533. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  57534. 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
  57535. }
  57536. return length | 0
  57537. }
  57538. function SlowBuffer (length) {
  57539. if (+length != length) { // eslint-disable-line eqeqeq
  57540. length = 0
  57541. }
  57542. return Buffer.alloc(+length)
  57543. }
  57544. Buffer.isBuffer = function isBuffer (b) {
  57545. return b != null && b._isBuffer === true &&
  57546. b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
  57547. }
  57548. Buffer.compare = function compare (a, b) {
  57549. if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)
  57550. if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)
  57551. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  57552. throw new TypeError(
  57553. 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
  57554. )
  57555. }
  57556. if (a === b) return 0
  57557. var x = a.length
  57558. var y = b.length
  57559. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  57560. if (a[i] !== b[i]) {
  57561. x = a[i]
  57562. y = b[i]
  57563. break
  57564. }
  57565. }
  57566. if (x < y) return -1
  57567. if (y < x) return 1
  57568. return 0
  57569. }
  57570. Buffer.isEncoding = function isEncoding (encoding) {
  57571. switch (String(encoding).toLowerCase()) {
  57572. case 'hex':
  57573. case 'utf8':
  57574. case 'utf-8':
  57575. case 'ascii':
  57576. case 'latin1':
  57577. case 'binary':
  57578. case 'base64':
  57579. case 'ucs2':
  57580. case 'ucs-2':
  57581. case 'utf16le':
  57582. case 'utf-16le':
  57583. return true
  57584. default:
  57585. return false
  57586. }
  57587. }
  57588. Buffer.concat = function concat (list, length) {
  57589. if (!Array.isArray(list)) {
  57590. throw new TypeError('"list" argument must be an Array of Buffers')
  57591. }
  57592. if (list.length === 0) {
  57593. return Buffer.alloc(0)
  57594. }
  57595. var i
  57596. if (length === undefined) {
  57597. length = 0
  57598. for (i = 0; i < list.length; ++i) {
  57599. length += list[i].length
  57600. }
  57601. }
  57602. var buffer = Buffer.allocUnsafe(length)
  57603. var pos = 0
  57604. for (i = 0; i < list.length; ++i) {
  57605. var buf = list[i]
  57606. if (isInstance(buf, Uint8Array)) {
  57607. buf = Buffer.from(buf)
  57608. }
  57609. if (!Buffer.isBuffer(buf)) {
  57610. throw new TypeError('"list" argument must be an Array of Buffers')
  57611. }
  57612. buf.copy(buffer, pos)
  57613. pos += buf.length
  57614. }
  57615. return buffer
  57616. }
  57617. function byteLength (string, encoding) {
  57618. if (Buffer.isBuffer(string)) {
  57619. return string.length
  57620. }
  57621. if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
  57622. return string.byteLength
  57623. }
  57624. if (typeof string !== 'string') {
  57625. throw new TypeError(
  57626. 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
  57627. 'Received type ' + typeof string
  57628. )
  57629. }
  57630. var len = string.length
  57631. var mustMatch = (arguments.length > 2 && arguments[2] === true)
  57632. if (!mustMatch && len === 0) return 0
  57633. // Use a for loop to avoid recursion
  57634. var loweredCase = false
  57635. for (;;) {
  57636. switch (encoding) {
  57637. case 'ascii':
  57638. case 'latin1':
  57639. case 'binary':
  57640. return len
  57641. case 'utf8':
  57642. case 'utf-8':
  57643. return utf8ToBytes(string).length
  57644. case 'ucs2':
  57645. case 'ucs-2':
  57646. case 'utf16le':
  57647. case 'utf-16le':
  57648. return len * 2
  57649. case 'hex':
  57650. return len >>> 1
  57651. case 'base64':
  57652. return base64ToBytes(string).length
  57653. default:
  57654. if (loweredCase) {
  57655. return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
  57656. }
  57657. encoding = ('' + encoding).toLowerCase()
  57658. loweredCase = true
  57659. }
  57660. }
  57661. }
  57662. Buffer.byteLength = byteLength
  57663. function slowToString (encoding, start, end) {
  57664. var loweredCase = false
  57665. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  57666. // property of a typed array.
  57667. // This behaves neither like String nor Uint8Array in that we set start/end
  57668. // to their upper/lower bounds if the value passed is out of range.
  57669. // undefined is handled specially as per ECMA-262 6th Edition,
  57670. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  57671. if (start === undefined || start < 0) {
  57672. start = 0
  57673. }
  57674. // Return early if start > this.length. Done here to prevent potential uint32
  57675. // coercion fail below.
  57676. if (start > this.length) {
  57677. return ''
  57678. }
  57679. if (end === undefined || end > this.length) {
  57680. end = this.length
  57681. }
  57682. if (end <= 0) {
  57683. return ''
  57684. }
  57685. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  57686. end >>>= 0
  57687. start >>>= 0
  57688. if (end <= start) {
  57689. return ''
  57690. }
  57691. if (!encoding) encoding = 'utf8'
  57692. while (true) {
  57693. switch (encoding) {
  57694. case 'hex':
  57695. return hexSlice(this, start, end)
  57696. case 'utf8':
  57697. case 'utf-8':
  57698. return utf8Slice(this, start, end)
  57699. case 'ascii':
  57700. return asciiSlice(this, start, end)
  57701. case 'latin1':
  57702. case 'binary':
  57703. return latin1Slice(this, start, end)
  57704. case 'base64':
  57705. return base64Slice(this, start, end)
  57706. case 'ucs2':
  57707. case 'ucs-2':
  57708. case 'utf16le':
  57709. case 'utf-16le':
  57710. return utf16leSlice(this, start, end)
  57711. default:
  57712. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  57713. encoding = (encoding + '').toLowerCase()
  57714. loweredCase = true
  57715. }
  57716. }
  57717. }
  57718. // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
  57719. // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
  57720. // reliably in a browserify context because there could be multiple different
  57721. // copies of the 'buffer' package in use. This method works even for Buffer
  57722. // instances that were created from another copy of the `buffer` package.
  57723. // See: https://github.com/feross/buffer/issues/154
  57724. Buffer.prototype._isBuffer = true
  57725. function swap (b, n, m) {
  57726. var i = b[n]
  57727. b[n] = b[m]
  57728. b[m] = i
  57729. }
  57730. Buffer.prototype.swap16 = function swap16 () {
  57731. var len = this.length
  57732. if (len % 2 !== 0) {
  57733. throw new RangeError('Buffer size must be a multiple of 16-bits')
  57734. }
  57735. for (var i = 0; i < len; i += 2) {
  57736. swap(this, i, i + 1)
  57737. }
  57738. return this
  57739. }
  57740. Buffer.prototype.swap32 = function swap32 () {
  57741. var len = this.length
  57742. if (len % 4 !== 0) {
  57743. throw new RangeError('Buffer size must be a multiple of 32-bits')
  57744. }
  57745. for (var i = 0; i < len; i += 4) {
  57746. swap(this, i, i + 3)
  57747. swap(this, i + 1, i + 2)
  57748. }
  57749. return this
  57750. }
  57751. Buffer.prototype.swap64 = function swap64 () {
  57752. var len = this.length
  57753. if (len % 8 !== 0) {
  57754. throw new RangeError('Buffer size must be a multiple of 64-bits')
  57755. }
  57756. for (var i = 0; i < len; i += 8) {
  57757. swap(this, i, i + 7)
  57758. swap(this, i + 1, i + 6)
  57759. swap(this, i + 2, i + 5)
  57760. swap(this, i + 3, i + 4)
  57761. }
  57762. return this
  57763. }
  57764. Buffer.prototype.toString = function toString () {
  57765. var length = this.length
  57766. if (length === 0) return ''
  57767. if (arguments.length === 0) return utf8Slice(this, 0, length)
  57768. return slowToString.apply(this, arguments)
  57769. }
  57770. Buffer.prototype.toLocaleString = Buffer.prototype.toString
  57771. Buffer.prototype.equals = function equals (b) {
  57772. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  57773. if (this === b) return true
  57774. return Buffer.compare(this, b) === 0
  57775. }
  57776. Buffer.prototype.inspect = function inspect () {
  57777. var str = ''
  57778. var max = exports.INSPECT_MAX_BYTES
  57779. str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()
  57780. if (this.length > max) str += ' ... '
  57781. return '<Buffer ' + str + '>'
  57782. }
  57783. if (customInspectSymbol) {
  57784. Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect
  57785. }
  57786. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  57787. if (isInstance(target, Uint8Array)) {
  57788. target = Buffer.from(target, target.offset, target.byteLength)
  57789. }
  57790. if (!Buffer.isBuffer(target)) {
  57791. throw new TypeError(
  57792. 'The "target" argument must be one of type Buffer or Uint8Array. ' +
  57793. 'Received type ' + (typeof target)
  57794. )
  57795. }
  57796. if (start === undefined) {
  57797. start = 0
  57798. }
  57799. if (end === undefined) {
  57800. end = target ? target.length : 0
  57801. }
  57802. if (thisStart === undefined) {
  57803. thisStart = 0
  57804. }
  57805. if (thisEnd === undefined) {
  57806. thisEnd = this.length
  57807. }
  57808. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  57809. throw new RangeError('out of range index')
  57810. }
  57811. if (thisStart >= thisEnd && start >= end) {
  57812. return 0
  57813. }
  57814. if (thisStart >= thisEnd) {
  57815. return -1
  57816. }
  57817. if (start >= end) {
  57818. return 1
  57819. }
  57820. start >>>= 0
  57821. end >>>= 0
  57822. thisStart >>>= 0
  57823. thisEnd >>>= 0
  57824. if (this === target) return 0
  57825. var x = thisEnd - thisStart
  57826. var y = end - start
  57827. var len = Math.min(x, y)
  57828. var thisCopy = this.slice(thisStart, thisEnd)
  57829. var targetCopy = target.slice(start, end)
  57830. for (var i = 0; i < len; ++i) {
  57831. if (thisCopy[i] !== targetCopy[i]) {
  57832. x = thisCopy[i]
  57833. y = targetCopy[i]
  57834. break
  57835. }
  57836. }
  57837. if (x < y) return -1
  57838. if (y < x) return 1
  57839. return 0
  57840. }
  57841. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  57842. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  57843. //
  57844. // Arguments:
  57845. // - buffer - a Buffer to search
  57846. // - val - a string, Buffer, or number
  57847. // - byteOffset - an index into `buffer`; will be clamped to an int32
  57848. // - encoding - an optional encoding, relevant is val is a string
  57849. // - dir - true for indexOf, false for lastIndexOf
  57850. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  57851. // Empty buffer means no match
  57852. if (buffer.length === 0) return -1
  57853. // Normalize byteOffset
  57854. if (typeof byteOffset === 'string') {
  57855. encoding = byteOffset
  57856. byteOffset = 0
  57857. } else if (byteOffset > 0x7fffffff) {
  57858. byteOffset = 0x7fffffff
  57859. } else if (byteOffset < -0x80000000) {
  57860. byteOffset = -0x80000000
  57861. }
  57862. byteOffset = +byteOffset // Coerce to Number.
  57863. if (numberIsNaN(byteOffset)) {
  57864. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  57865. byteOffset = dir ? 0 : (buffer.length - 1)
  57866. }
  57867. // Normalize byteOffset: negative offsets start from the end of the buffer
  57868. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  57869. if (byteOffset >= buffer.length) {
  57870. if (dir) return -1
  57871. else byteOffset = buffer.length - 1
  57872. } else if (byteOffset < 0) {
  57873. if (dir) byteOffset = 0
  57874. else return -1
  57875. }
  57876. // Normalize val
  57877. if (typeof val === 'string') {
  57878. val = Buffer.from(val, encoding)
  57879. }
  57880. // Finally, search either indexOf (if dir is true) or lastIndexOf
  57881. if (Buffer.isBuffer(val)) {
  57882. // Special case: looking for empty string/buffer always fails
  57883. if (val.length === 0) {
  57884. return -1
  57885. }
  57886. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  57887. } else if (typeof val === 'number') {
  57888. val = val & 0xFF // Search for a byte value [0-255]
  57889. if (typeof Uint8Array.prototype.indexOf === 'function') {
  57890. if (dir) {
  57891. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  57892. } else {
  57893. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  57894. }
  57895. }
  57896. return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)
  57897. }
  57898. throw new TypeError('val must be string, number or Buffer')
  57899. }
  57900. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  57901. var indexSize = 1
  57902. var arrLength = arr.length
  57903. var valLength = val.length
  57904. if (encoding !== undefined) {
  57905. encoding = String(encoding).toLowerCase()
  57906. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  57907. encoding === 'utf16le' || encoding === 'utf-16le') {
  57908. if (arr.length < 2 || val.length < 2) {
  57909. return -1
  57910. }
  57911. indexSize = 2
  57912. arrLength /= 2
  57913. valLength /= 2
  57914. byteOffset /= 2
  57915. }
  57916. }
  57917. function read (buf, i) {
  57918. if (indexSize === 1) {
  57919. return buf[i]
  57920. } else {
  57921. return buf.readUInt16BE(i * indexSize)
  57922. }
  57923. }
  57924. var i
  57925. if (dir) {
  57926. var foundIndex = -1
  57927. for (i = byteOffset; i < arrLength; i++) {
  57928. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  57929. if (foundIndex === -1) foundIndex = i
  57930. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  57931. } else {
  57932. if (foundIndex !== -1) i -= i - foundIndex
  57933. foundIndex = -1
  57934. }
  57935. }
  57936. } else {
  57937. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  57938. for (i = byteOffset; i >= 0; i--) {
  57939. var found = true
  57940. for (var j = 0; j < valLength; j++) {
  57941. if (read(arr, i + j) !== read(val, j)) {
  57942. found = false
  57943. break
  57944. }
  57945. }
  57946. if (found) return i
  57947. }
  57948. }
  57949. return -1
  57950. }
  57951. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  57952. return this.indexOf(val, byteOffset, encoding) !== -1
  57953. }
  57954. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  57955. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  57956. }
  57957. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  57958. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  57959. }
  57960. function hexWrite (buf, string, offset, length) {
  57961. offset = Number(offset) || 0
  57962. var remaining = buf.length - offset
  57963. if (!length) {
  57964. length = remaining
  57965. } else {
  57966. length = Number(length)
  57967. if (length > remaining) {
  57968. length = remaining
  57969. }
  57970. }
  57971. var strLen = string.length
  57972. if (length > strLen / 2) {
  57973. length = strLen / 2
  57974. }
  57975. for (var i = 0; i < length; ++i) {
  57976. var parsed = parseInt(string.substr(i * 2, 2), 16)
  57977. if (numberIsNaN(parsed)) return i
  57978. buf[offset + i] = parsed
  57979. }
  57980. return i
  57981. }
  57982. function utf8Write (buf, string, offset, length) {
  57983. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  57984. }
  57985. function asciiWrite (buf, string, offset, length) {
  57986. return blitBuffer(asciiToBytes(string), buf, offset, length)
  57987. }
  57988. function latin1Write (buf, string, offset, length) {
  57989. return asciiWrite(buf, string, offset, length)
  57990. }
  57991. function base64Write (buf, string, offset, length) {
  57992. return blitBuffer(base64ToBytes(string), buf, offset, length)
  57993. }
  57994. function ucs2Write (buf, string, offset, length) {
  57995. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  57996. }
  57997. Buffer.prototype.write = function write (string, offset, length, encoding) {
  57998. // Buffer#write(string)
  57999. if (offset === undefined) {
  58000. encoding = 'utf8'
  58001. length = this.length
  58002. offset = 0
  58003. // Buffer#write(string, encoding)
  58004. } else if (length === undefined && typeof offset === 'string') {
  58005. encoding = offset
  58006. length = this.length
  58007. offset = 0
  58008. // Buffer#write(string, offset[, length][, encoding])
  58009. } else if (isFinite(offset)) {
  58010. offset = offset >>> 0
  58011. if (isFinite(length)) {
  58012. length = length >>> 0
  58013. if (encoding === undefined) encoding = 'utf8'
  58014. } else {
  58015. encoding = length
  58016. length = undefined
  58017. }
  58018. } else {
  58019. throw new Error(
  58020. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  58021. )
  58022. }
  58023. var remaining = this.length - offset
  58024. if (length === undefined || length > remaining) length = remaining
  58025. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  58026. throw new RangeError('Attempt to write outside buffer bounds')
  58027. }
  58028. if (!encoding) encoding = 'utf8'
  58029. var loweredCase = false
  58030. for (;;) {
  58031. switch (encoding) {
  58032. case 'hex':
  58033. return hexWrite(this, string, offset, length)
  58034. case 'utf8':
  58035. case 'utf-8':
  58036. return utf8Write(this, string, offset, length)
  58037. case 'ascii':
  58038. return asciiWrite(this, string, offset, length)
  58039. case 'latin1':
  58040. case 'binary':
  58041. return latin1Write(this, string, offset, length)
  58042. case 'base64':
  58043. // Warning: maxLength not taken into account in base64Write
  58044. return base64Write(this, string, offset, length)
  58045. case 'ucs2':
  58046. case 'ucs-2':
  58047. case 'utf16le':
  58048. case 'utf-16le':
  58049. return ucs2Write(this, string, offset, length)
  58050. default:
  58051. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  58052. encoding = ('' + encoding).toLowerCase()
  58053. loweredCase = true
  58054. }
  58055. }
  58056. }
  58057. Buffer.prototype.toJSON = function toJSON () {
  58058. return {
  58059. type: 'Buffer',
  58060. data: Array.prototype.slice.call(this._arr || this, 0)
  58061. }
  58062. }
  58063. function base64Slice (buf, start, end) {
  58064. if (start === 0 && end === buf.length) {
  58065. return base64.fromByteArray(buf)
  58066. } else {
  58067. return base64.fromByteArray(buf.slice(start, end))
  58068. }
  58069. }
  58070. function utf8Slice (buf, start, end) {
  58071. end = Math.min(buf.length, end)
  58072. var res = []
  58073. var i = start
  58074. while (i < end) {
  58075. var firstByte = buf[i]
  58076. var codePoint = null
  58077. var bytesPerSequence = (firstByte > 0xEF) ? 4
  58078. : (firstByte > 0xDF) ? 3
  58079. : (firstByte > 0xBF) ? 2
  58080. : 1
  58081. if (i + bytesPerSequence <= end) {
  58082. var secondByte, thirdByte, fourthByte, tempCodePoint
  58083. switch (bytesPerSequence) {
  58084. case 1:
  58085. if (firstByte < 0x80) {
  58086. codePoint = firstByte
  58087. }
  58088. break
  58089. case 2:
  58090. secondByte = buf[i + 1]
  58091. if ((secondByte & 0xC0) === 0x80) {
  58092. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  58093. if (tempCodePoint > 0x7F) {
  58094. codePoint = tempCodePoint
  58095. }
  58096. }
  58097. break
  58098. case 3:
  58099. secondByte = buf[i + 1]
  58100. thirdByte = buf[i + 2]
  58101. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  58102. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  58103. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  58104. codePoint = tempCodePoint
  58105. }
  58106. }
  58107. break
  58108. case 4:
  58109. secondByte = buf[i + 1]
  58110. thirdByte = buf[i + 2]
  58111. fourthByte = buf[i + 3]
  58112. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  58113. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  58114. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  58115. codePoint = tempCodePoint
  58116. }
  58117. }
  58118. }
  58119. }
  58120. if (codePoint === null) {
  58121. // we did not generate a valid codePoint so insert a
  58122. // replacement char (U+FFFD) and advance only 1 byte
  58123. codePoint = 0xFFFD
  58124. bytesPerSequence = 1
  58125. } else if (codePoint > 0xFFFF) {
  58126. // encode to utf16 (surrogate pair dance)
  58127. codePoint -= 0x10000
  58128. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  58129. codePoint = 0xDC00 | codePoint & 0x3FF
  58130. }
  58131. res.push(codePoint)
  58132. i += bytesPerSequence
  58133. }
  58134. return decodeCodePointsArray(res)
  58135. }
  58136. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  58137. // the lowest limit is Chrome, with 0x10000 args.
  58138. // We go 1 magnitude less, for safety
  58139. var MAX_ARGUMENTS_LENGTH = 0x1000
  58140. function decodeCodePointsArray (codePoints) {
  58141. var len = codePoints.length
  58142. if (len <= MAX_ARGUMENTS_LENGTH) {
  58143. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  58144. }
  58145. // Decode in chunks to avoid "call stack size exceeded".
  58146. var res = ''
  58147. var i = 0
  58148. while (i < len) {
  58149. res += String.fromCharCode.apply(
  58150. String,
  58151. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  58152. )
  58153. }
  58154. return res
  58155. }
  58156. function asciiSlice (buf, start, end) {
  58157. var ret = ''
  58158. end = Math.min(buf.length, end)
  58159. for (var i = start; i < end; ++i) {
  58160. ret += String.fromCharCode(buf[i] & 0x7F)
  58161. }
  58162. return ret
  58163. }
  58164. function latin1Slice (buf, start, end) {
  58165. var ret = ''
  58166. end = Math.min(buf.length, end)
  58167. for (var i = start; i < end; ++i) {
  58168. ret += String.fromCharCode(buf[i])
  58169. }
  58170. return ret
  58171. }
  58172. function hexSlice (buf, start, end) {
  58173. var len = buf.length
  58174. if (!start || start < 0) start = 0
  58175. if (!end || end < 0 || end > len) end = len
  58176. var out = ''
  58177. for (var i = start; i < end; ++i) {
  58178. out += hexSliceLookupTable[buf[i]]
  58179. }
  58180. return out
  58181. }
  58182. function utf16leSlice (buf, start, end) {
  58183. var bytes = buf.slice(start, end)
  58184. var res = ''
  58185. for (var i = 0; i < bytes.length; i += 2) {
  58186. res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
  58187. }
  58188. return res
  58189. }
  58190. Buffer.prototype.slice = function slice (start, end) {
  58191. var len = this.length
  58192. start = ~~start
  58193. end = end === undefined ? len : ~~end
  58194. if (start < 0) {
  58195. start += len
  58196. if (start < 0) start = 0
  58197. } else if (start > len) {
  58198. start = len
  58199. }
  58200. if (end < 0) {
  58201. end += len
  58202. if (end < 0) end = 0
  58203. } else if (end > len) {
  58204. end = len
  58205. }
  58206. if (end < start) end = start
  58207. var newBuf = this.subarray(start, end)
  58208. // Return an augmented `Uint8Array` instance
  58209. Object.setPrototypeOf(newBuf, Buffer.prototype)
  58210. return newBuf
  58211. }
  58212. /*
  58213. * Need to make sure that buffer isn't trying to write out of bounds.
  58214. */
  58215. function checkOffset (offset, ext, length) {
  58216. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  58217. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  58218. }
  58219. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  58220. offset = offset >>> 0
  58221. byteLength = byteLength >>> 0
  58222. if (!noAssert) checkOffset(offset, byteLength, this.length)
  58223. var val = this[offset]
  58224. var mul = 1
  58225. var i = 0
  58226. while (++i < byteLength && (mul *= 0x100)) {
  58227. val += this[offset + i] * mul
  58228. }
  58229. return val
  58230. }
  58231. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  58232. offset = offset >>> 0
  58233. byteLength = byteLength >>> 0
  58234. if (!noAssert) {
  58235. checkOffset(offset, byteLength, this.length)
  58236. }
  58237. var val = this[offset + --byteLength]
  58238. var mul = 1
  58239. while (byteLength > 0 && (mul *= 0x100)) {
  58240. val += this[offset + --byteLength] * mul
  58241. }
  58242. return val
  58243. }
  58244. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  58245. offset = offset >>> 0
  58246. if (!noAssert) checkOffset(offset, 1, this.length)
  58247. return this[offset]
  58248. }
  58249. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  58250. offset = offset >>> 0
  58251. if (!noAssert) checkOffset(offset, 2, this.length)
  58252. return this[offset] | (this[offset + 1] << 8)
  58253. }
  58254. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  58255. offset = offset >>> 0
  58256. if (!noAssert) checkOffset(offset, 2, this.length)
  58257. return (this[offset] << 8) | this[offset + 1]
  58258. }
  58259. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  58260. offset = offset >>> 0
  58261. if (!noAssert) checkOffset(offset, 4, this.length)
  58262. return ((this[offset]) |
  58263. (this[offset + 1] << 8) |
  58264. (this[offset + 2] << 16)) +
  58265. (this[offset + 3] * 0x1000000)
  58266. }
  58267. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  58268. offset = offset >>> 0
  58269. if (!noAssert) checkOffset(offset, 4, this.length)
  58270. return (this[offset] * 0x1000000) +
  58271. ((this[offset + 1] << 16) |
  58272. (this[offset + 2] << 8) |
  58273. this[offset + 3])
  58274. }
  58275. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  58276. offset = offset >>> 0
  58277. byteLength = byteLength >>> 0
  58278. if (!noAssert) checkOffset(offset, byteLength, this.length)
  58279. var val = this[offset]
  58280. var mul = 1
  58281. var i = 0
  58282. while (++i < byteLength && (mul *= 0x100)) {
  58283. val += this[offset + i] * mul
  58284. }
  58285. mul *= 0x80
  58286. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  58287. return val
  58288. }
  58289. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  58290. offset = offset >>> 0
  58291. byteLength = byteLength >>> 0
  58292. if (!noAssert) checkOffset(offset, byteLength, this.length)
  58293. var i = byteLength
  58294. var mul = 1
  58295. var val = this[offset + --i]
  58296. while (i > 0 && (mul *= 0x100)) {
  58297. val += this[offset + --i] * mul
  58298. }
  58299. mul *= 0x80
  58300. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  58301. return val
  58302. }
  58303. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  58304. offset = offset >>> 0
  58305. if (!noAssert) checkOffset(offset, 1, this.length)
  58306. if (!(this[offset] & 0x80)) return (this[offset])
  58307. return ((0xff - this[offset] + 1) * -1)
  58308. }
  58309. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  58310. offset = offset >>> 0
  58311. if (!noAssert) checkOffset(offset, 2, this.length)
  58312. var val = this[offset] | (this[offset + 1] << 8)
  58313. return (val & 0x8000) ? val | 0xFFFF0000 : val
  58314. }
  58315. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  58316. offset = offset >>> 0
  58317. if (!noAssert) checkOffset(offset, 2, this.length)
  58318. var val = this[offset + 1] | (this[offset] << 8)
  58319. return (val & 0x8000) ? val | 0xFFFF0000 : val
  58320. }
  58321. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  58322. offset = offset >>> 0
  58323. if (!noAssert) checkOffset(offset, 4, this.length)
  58324. return (this[offset]) |
  58325. (this[offset + 1] << 8) |
  58326. (this[offset + 2] << 16) |
  58327. (this[offset + 3] << 24)
  58328. }
  58329. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  58330. offset = offset >>> 0
  58331. if (!noAssert) checkOffset(offset, 4, this.length)
  58332. return (this[offset] << 24) |
  58333. (this[offset + 1] << 16) |
  58334. (this[offset + 2] << 8) |
  58335. (this[offset + 3])
  58336. }
  58337. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  58338. offset = offset >>> 0
  58339. if (!noAssert) checkOffset(offset, 4, this.length)
  58340. return ieee754.read(this, offset, true, 23, 4)
  58341. }
  58342. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  58343. offset = offset >>> 0
  58344. if (!noAssert) checkOffset(offset, 4, this.length)
  58345. return ieee754.read(this, offset, false, 23, 4)
  58346. }
  58347. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  58348. offset = offset >>> 0
  58349. if (!noAssert) checkOffset(offset, 8, this.length)
  58350. return ieee754.read(this, offset, true, 52, 8)
  58351. }
  58352. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  58353. offset = offset >>> 0
  58354. if (!noAssert) checkOffset(offset, 8, this.length)
  58355. return ieee754.read(this, offset, false, 52, 8)
  58356. }
  58357. function checkInt (buf, value, offset, ext, max, min) {
  58358. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  58359. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  58360. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  58361. }
  58362. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  58363. value = +value
  58364. offset = offset >>> 0
  58365. byteLength = byteLength >>> 0
  58366. if (!noAssert) {
  58367. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  58368. checkInt(this, value, offset, byteLength, maxBytes, 0)
  58369. }
  58370. var mul = 1
  58371. var i = 0
  58372. this[offset] = value & 0xFF
  58373. while (++i < byteLength && (mul *= 0x100)) {
  58374. this[offset + i] = (value / mul) & 0xFF
  58375. }
  58376. return offset + byteLength
  58377. }
  58378. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  58379. value = +value
  58380. offset = offset >>> 0
  58381. byteLength = byteLength >>> 0
  58382. if (!noAssert) {
  58383. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  58384. checkInt(this, value, offset, byteLength, maxBytes, 0)
  58385. }
  58386. var i = byteLength - 1
  58387. var mul = 1
  58388. this[offset + i] = value & 0xFF
  58389. while (--i >= 0 && (mul *= 0x100)) {
  58390. this[offset + i] = (value / mul) & 0xFF
  58391. }
  58392. return offset + byteLength
  58393. }
  58394. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  58395. value = +value
  58396. offset = offset >>> 0
  58397. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  58398. this[offset] = (value & 0xff)
  58399. return offset + 1
  58400. }
  58401. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  58402. value = +value
  58403. offset = offset >>> 0
  58404. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  58405. this[offset] = (value & 0xff)
  58406. this[offset + 1] = (value >>> 8)
  58407. return offset + 2
  58408. }
  58409. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  58410. value = +value
  58411. offset = offset >>> 0
  58412. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  58413. this[offset] = (value >>> 8)
  58414. this[offset + 1] = (value & 0xff)
  58415. return offset + 2
  58416. }
  58417. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  58418. value = +value
  58419. offset = offset >>> 0
  58420. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  58421. this[offset + 3] = (value >>> 24)
  58422. this[offset + 2] = (value >>> 16)
  58423. this[offset + 1] = (value >>> 8)
  58424. this[offset] = (value & 0xff)
  58425. return offset + 4
  58426. }
  58427. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  58428. value = +value
  58429. offset = offset >>> 0
  58430. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  58431. this[offset] = (value >>> 24)
  58432. this[offset + 1] = (value >>> 16)
  58433. this[offset + 2] = (value >>> 8)
  58434. this[offset + 3] = (value & 0xff)
  58435. return offset + 4
  58436. }
  58437. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  58438. value = +value
  58439. offset = offset >>> 0
  58440. if (!noAssert) {
  58441. var limit = Math.pow(2, (8 * byteLength) - 1)
  58442. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  58443. }
  58444. var i = 0
  58445. var mul = 1
  58446. var sub = 0
  58447. this[offset] = value & 0xFF
  58448. while (++i < byteLength && (mul *= 0x100)) {
  58449. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  58450. sub = 1
  58451. }
  58452. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  58453. }
  58454. return offset + byteLength
  58455. }
  58456. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  58457. value = +value
  58458. offset = offset >>> 0
  58459. if (!noAssert) {
  58460. var limit = Math.pow(2, (8 * byteLength) - 1)
  58461. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  58462. }
  58463. var i = byteLength - 1
  58464. var mul = 1
  58465. var sub = 0
  58466. this[offset + i] = value & 0xFF
  58467. while (--i >= 0 && (mul *= 0x100)) {
  58468. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  58469. sub = 1
  58470. }
  58471. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  58472. }
  58473. return offset + byteLength
  58474. }
  58475. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  58476. value = +value
  58477. offset = offset >>> 0
  58478. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  58479. if (value < 0) value = 0xff + value + 1
  58480. this[offset] = (value & 0xff)
  58481. return offset + 1
  58482. }
  58483. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  58484. value = +value
  58485. offset = offset >>> 0
  58486. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  58487. this[offset] = (value & 0xff)
  58488. this[offset + 1] = (value >>> 8)
  58489. return offset + 2
  58490. }
  58491. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  58492. value = +value
  58493. offset = offset >>> 0
  58494. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  58495. this[offset] = (value >>> 8)
  58496. this[offset + 1] = (value & 0xff)
  58497. return offset + 2
  58498. }
  58499. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  58500. value = +value
  58501. offset = offset >>> 0
  58502. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  58503. this[offset] = (value & 0xff)
  58504. this[offset + 1] = (value >>> 8)
  58505. this[offset + 2] = (value >>> 16)
  58506. this[offset + 3] = (value >>> 24)
  58507. return offset + 4
  58508. }
  58509. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  58510. value = +value
  58511. offset = offset >>> 0
  58512. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  58513. if (value < 0) value = 0xffffffff + value + 1
  58514. this[offset] = (value >>> 24)
  58515. this[offset + 1] = (value >>> 16)
  58516. this[offset + 2] = (value >>> 8)
  58517. this[offset + 3] = (value & 0xff)
  58518. return offset + 4
  58519. }
  58520. function checkIEEE754 (buf, value, offset, ext, max, min) {
  58521. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  58522. if (offset < 0) throw new RangeError('Index out of range')
  58523. }
  58524. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  58525. value = +value
  58526. offset = offset >>> 0
  58527. if (!noAssert) {
  58528. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  58529. }
  58530. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  58531. return offset + 4
  58532. }
  58533. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  58534. return writeFloat(this, value, offset, true, noAssert)
  58535. }
  58536. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  58537. return writeFloat(this, value, offset, false, noAssert)
  58538. }
  58539. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  58540. value = +value
  58541. offset = offset >>> 0
  58542. if (!noAssert) {
  58543. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  58544. }
  58545. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  58546. return offset + 8
  58547. }
  58548. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  58549. return writeDouble(this, value, offset, true, noAssert)
  58550. }
  58551. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  58552. return writeDouble(this, value, offset, false, noAssert)
  58553. }
  58554. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  58555. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  58556. if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
  58557. if (!start) start = 0
  58558. if (!end && end !== 0) end = this.length
  58559. if (targetStart >= target.length) targetStart = target.length
  58560. if (!targetStart) targetStart = 0
  58561. if (end > 0 && end < start) end = start
  58562. // Copy 0 bytes; we're done
  58563. if (end === start) return 0
  58564. if (target.length === 0 || this.length === 0) return 0
  58565. // Fatal error conditions
  58566. if (targetStart < 0) {
  58567. throw new RangeError('targetStart out of bounds')
  58568. }
  58569. if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
  58570. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  58571. // Are we oob?
  58572. if (end > this.length) end = this.length
  58573. if (target.length - targetStart < end - start) {
  58574. end = target.length - targetStart + start
  58575. }
  58576. var len = end - start
  58577. if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
  58578. // Use built-in when available, missing from IE11
  58579. this.copyWithin(targetStart, start, end)
  58580. } else if (this === target && start < targetStart && targetStart < end) {
  58581. // descending copy from end
  58582. for (var i = len - 1; i >= 0; --i) {
  58583. target[i + targetStart] = this[i + start]
  58584. }
  58585. } else {
  58586. Uint8Array.prototype.set.call(
  58587. target,
  58588. this.subarray(start, end),
  58589. targetStart
  58590. )
  58591. }
  58592. return len
  58593. }
  58594. // Usage:
  58595. // buffer.fill(number[, offset[, end]])
  58596. // buffer.fill(buffer[, offset[, end]])
  58597. // buffer.fill(string[, offset[, end]][, encoding])
  58598. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  58599. // Handle string cases:
  58600. if (typeof val === 'string') {
  58601. if (typeof start === 'string') {
  58602. encoding = start
  58603. start = 0
  58604. end = this.length
  58605. } else if (typeof end === 'string') {
  58606. encoding = end
  58607. end = this.length
  58608. }
  58609. if (encoding !== undefined && typeof encoding !== 'string') {
  58610. throw new TypeError('encoding must be a string')
  58611. }
  58612. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  58613. throw new TypeError('Unknown encoding: ' + encoding)
  58614. }
  58615. if (val.length === 1) {
  58616. var code = val.charCodeAt(0)
  58617. if ((encoding === 'utf8' && code < 128) ||
  58618. encoding === 'latin1') {
  58619. // Fast path: If `val` fits into a single byte, use that numeric value.
  58620. val = code
  58621. }
  58622. }
  58623. } else if (typeof val === 'number') {
  58624. val = val & 255
  58625. } else if (typeof val === 'boolean') {
  58626. val = Number(val)
  58627. }
  58628. // Invalid ranges are not set to a default, so can range check early.
  58629. if (start < 0 || this.length < start || this.length < end) {
  58630. throw new RangeError('Out of range index')
  58631. }
  58632. if (end <= start) {
  58633. return this
  58634. }
  58635. start = start >>> 0
  58636. end = end === undefined ? this.length : end >>> 0
  58637. if (!val) val = 0
  58638. var i
  58639. if (typeof val === 'number') {
  58640. for (i = start; i < end; ++i) {
  58641. this[i] = val
  58642. }
  58643. } else {
  58644. var bytes = Buffer.isBuffer(val)
  58645. ? val
  58646. : Buffer.from(val, encoding)
  58647. var len = bytes.length
  58648. if (len === 0) {
  58649. throw new TypeError('The value "' + val +
  58650. '" is invalid for argument "value"')
  58651. }
  58652. for (i = 0; i < end - start; ++i) {
  58653. this[i + start] = bytes[i % len]
  58654. }
  58655. }
  58656. return this
  58657. }
  58658. // HELPER FUNCTIONS
  58659. // ================
  58660. var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
  58661. function base64clean (str) {
  58662. // Node takes equal signs as end of the Base64 encoding
  58663. str = str.split('=')[0]
  58664. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  58665. str = str.trim().replace(INVALID_BASE64_RE, '')
  58666. // Node converts strings with length < 2 to ''
  58667. if (str.length < 2) return ''
  58668. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  58669. while (str.length % 4 !== 0) {
  58670. str = str + '='
  58671. }
  58672. return str
  58673. }
  58674. function utf8ToBytes (string, units) {
  58675. units = units || Infinity
  58676. var codePoint
  58677. var length = string.length
  58678. var leadSurrogate = null
  58679. var bytes = []
  58680. for (var i = 0; i < length; ++i) {
  58681. codePoint = string.charCodeAt(i)
  58682. // is surrogate component
  58683. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  58684. // last char was a lead
  58685. if (!leadSurrogate) {
  58686. // no lead yet
  58687. if (codePoint > 0xDBFF) {
  58688. // unexpected trail
  58689. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  58690. continue
  58691. } else if (i + 1 === length) {
  58692. // unpaired lead
  58693. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  58694. continue
  58695. }
  58696. // valid lead
  58697. leadSurrogate = codePoint
  58698. continue
  58699. }
  58700. // 2 leads in a row
  58701. if (codePoint < 0xDC00) {
  58702. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  58703. leadSurrogate = codePoint
  58704. continue
  58705. }
  58706. // valid surrogate pair
  58707. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  58708. } else if (leadSurrogate) {
  58709. // valid bmp char, but last char was a lead
  58710. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  58711. }
  58712. leadSurrogate = null
  58713. // encode utf8
  58714. if (codePoint < 0x80) {
  58715. if ((units -= 1) < 0) break
  58716. bytes.push(codePoint)
  58717. } else if (codePoint < 0x800) {
  58718. if ((units -= 2) < 0) break
  58719. bytes.push(
  58720. codePoint >> 0x6 | 0xC0,
  58721. codePoint & 0x3F | 0x80
  58722. )
  58723. } else if (codePoint < 0x10000) {
  58724. if ((units -= 3) < 0) break
  58725. bytes.push(
  58726. codePoint >> 0xC | 0xE0,
  58727. codePoint >> 0x6 & 0x3F | 0x80,
  58728. codePoint & 0x3F | 0x80
  58729. )
  58730. } else if (codePoint < 0x110000) {
  58731. if ((units -= 4) < 0) break
  58732. bytes.push(
  58733. codePoint >> 0x12 | 0xF0,
  58734. codePoint >> 0xC & 0x3F | 0x80,
  58735. codePoint >> 0x6 & 0x3F | 0x80,
  58736. codePoint & 0x3F | 0x80
  58737. )
  58738. } else {
  58739. throw new Error('Invalid code point')
  58740. }
  58741. }
  58742. return bytes
  58743. }
  58744. function asciiToBytes (str) {
  58745. var byteArray = []
  58746. for (var i = 0; i < str.length; ++i) {
  58747. // Node's code seems to be doing this and not & 0x7F..
  58748. byteArray.push(str.charCodeAt(i) & 0xFF)
  58749. }
  58750. return byteArray
  58751. }
  58752. function utf16leToBytes (str, units) {
  58753. var c, hi, lo
  58754. var byteArray = []
  58755. for (var i = 0; i < str.length; ++i) {
  58756. if ((units -= 2) < 0) break
  58757. c = str.charCodeAt(i)
  58758. hi = c >> 8
  58759. lo = c % 256
  58760. byteArray.push(lo)
  58761. byteArray.push(hi)
  58762. }
  58763. return byteArray
  58764. }
  58765. function base64ToBytes (str) {
  58766. return base64.toByteArray(base64clean(str))
  58767. }
  58768. function blitBuffer (src, dst, offset, length) {
  58769. for (var i = 0; i < length; ++i) {
  58770. if ((i + offset >= dst.length) || (i >= src.length)) break
  58771. dst[i + offset] = src[i]
  58772. }
  58773. return i
  58774. }
  58775. // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
  58776. // the `instanceof` check but they should be treated as of that type.
  58777. // See: https://github.com/feross/buffer/issues/166
  58778. function isInstance (obj, type) {
  58779. return obj instanceof type ||
  58780. (obj != null && obj.constructor != null && obj.constructor.name != null &&
  58781. obj.constructor.name === type.name)
  58782. }
  58783. function numberIsNaN (obj) {
  58784. // For IE11 support
  58785. return obj !== obj // eslint-disable-line no-self-compare
  58786. }
  58787. // Create lookup table for `toString('hex')`
  58788. // See: https://github.com/feross/buffer/issues/219
  58789. var hexSliceLookupTable = (function () {
  58790. var alphabet = '0123456789abcdef'
  58791. var table = new Array(256)
  58792. for (var i = 0; i < 16; ++i) {
  58793. var i16 = i * 16
  58794. for (var j = 0; j < 16; ++j) {
  58795. table[i16 + j] = alphabet[i] + alphabet[j]
  58796. }
  58797. }
  58798. return table
  58799. })()
  58800. /***/ }),
  58801. /***/ "../../node_modules/ripple-keypairs/dist/Sha512.js":
  58802. /*!*********************************************************!*\
  58803. !*** ../../node_modules/ripple-keypairs/dist/Sha512.js ***!
  58804. \*********************************************************/
  58805. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  58806. "use strict";
  58807. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  58808. if (k2 === undefined) k2 = k;
  58809. var desc = Object.getOwnPropertyDescriptor(m, k);
  58810. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  58811. desc = { enumerable: true, get: function() { return m[k]; } };
  58812. }
  58813. Object.defineProperty(o, k2, desc);
  58814. }) : (function(o, m, k, k2) {
  58815. if (k2 === undefined) k2 = k;
  58816. o[k2] = m[k];
  58817. }));
  58818. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  58819. Object.defineProperty(o, "default", { enumerable: true, value: v });
  58820. }) : function(o, v) {
  58821. o["default"] = v;
  58822. });
  58823. var __importStar = (this && this.__importStar) || function (mod) {
  58824. if (mod && mod.__esModule) return mod;
  58825. var result = {};
  58826. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  58827. __setModuleDefault(result, mod);
  58828. return result;
  58829. };
  58830. Object.defineProperty(exports, "__esModule", ({ value: true }));
  58831. /* eslint-disable no-bitwise --
  58832. * lots of bitwise operators necessary for this */
  58833. const hashjs = __importStar(__webpack_require__(/*! hash.js */ "../../node_modules/hash.js/lib/hash.js"));
  58834. const BigNum = __webpack_require__(/*! bn.js */ "../../node_modules/bn.js/lib/bn.js");
  58835. class Sha512 {
  58836. constructor() {
  58837. this.hash = hashjs.sha512();
  58838. }
  58839. add(bytes) {
  58840. this.hash.update(bytes);
  58841. return this;
  58842. }
  58843. addU32(i) {
  58844. return this.add([
  58845. (i >>> 24) & 0xff,
  58846. (i >>> 16) & 0xff,
  58847. (i >>> 8) & 0xff,
  58848. i & 0xff,
  58849. ]);
  58850. }
  58851. finish() {
  58852. return this.hash.digest();
  58853. }
  58854. first256() {
  58855. return this.finish().slice(0, 32);
  58856. }
  58857. first256BN() {
  58858. return new BigNum(this.first256());
  58859. }
  58860. }
  58861. exports["default"] = Sha512;
  58862. /***/ }),
  58863. /***/ "../../node_modules/ripple-keypairs/dist/index.js":
  58864. /*!********************************************************!*\
  58865. !*** ../../node_modules/ripple-keypairs/dist/index.js ***!
  58866. \********************************************************/
  58867. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  58868. "use strict";
  58869. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js")["Buffer"];
  58870. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  58871. if (k2 === undefined) k2 = k;
  58872. var desc = Object.getOwnPropertyDescriptor(m, k);
  58873. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  58874. desc = { enumerable: true, get: function() { return m[k]; } };
  58875. }
  58876. Object.defineProperty(o, k2, desc);
  58877. }) : (function(o, m, k, k2) {
  58878. if (k2 === undefined) k2 = k;
  58879. o[k2] = m[k];
  58880. }));
  58881. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  58882. Object.defineProperty(o, "default", { enumerable: true, value: v });
  58883. }) : function(o, v) {
  58884. o["default"] = v;
  58885. });
  58886. var __importStar = (this && this.__importStar) || function (mod) {
  58887. if (mod && mod.__esModule) return mod;
  58888. var result = {};
  58889. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  58890. __setModuleDefault(result, mod);
  58891. return result;
  58892. };
  58893. Object.defineProperty(exports, "__esModule", ({ value: true }));
  58894. exports.decodeSeed = exports.deriveNodeAddress = exports.deriveAddress = exports.verify = exports.sign = exports.deriveKeypair = exports.generateSeed = void 0;
  58895. const assert = __importStar(__webpack_require__(/*! assert */ "../../node_modules/assert/build/assert.js"));
  58896. const brorand = __webpack_require__(/*! brorand */ "../../node_modules/brorand/index.js");
  58897. const hashjs = __importStar(__webpack_require__(/*! hash.js */ "../../node_modules/hash.js/lib/hash.js"));
  58898. const elliptic = __importStar(__webpack_require__(/*! elliptic */ "../../node_modules/elliptic/lib/elliptic.js"));
  58899. const addressCodec = __importStar(__webpack_require__(/*! ripple-address-codec */ "../../node_modules/ripple-address-codec/dist/index.js"));
  58900. const secp256k1_1 = __webpack_require__(/*! ./secp256k1 */ "../../node_modules/ripple-keypairs/dist/secp256k1.js");
  58901. const utils = __importStar(__webpack_require__(/*! ./utils */ "../../node_modules/ripple-keypairs/dist/utils.js"));
  58902. const Ed25519 = elliptic.eddsa('ed25519');
  58903. const Secp256k1 = elliptic.ec('secp256k1');
  58904. const { hexToBytes } = utils;
  58905. const { bytesToHex } = utils;
  58906. function generateSeed(options = {}) {
  58907. assert.ok(!options.entropy || options.entropy.length >= 16, 'entropy too short');
  58908. const entropy = options.entropy ? options.entropy.slice(0, 16) : brorand(16);
  58909. const type = options.algorithm === 'ed25519' ? 'ed25519' : 'secp256k1';
  58910. return addressCodec.encodeSeed(Buffer.from(entropy), type);
  58911. }
  58912. exports.generateSeed = generateSeed;
  58913. function hash(message) {
  58914. return hashjs.sha512().update(message).digest().slice(0, 32);
  58915. }
  58916. const secp256k1 = {
  58917. deriveKeypair(entropy, options) {
  58918. const prefix = '00';
  58919. const privateKey = prefix + (0, secp256k1_1.derivePrivateKey)(entropy, options).toString(16, 64).toUpperCase();
  58920. const publicKey = bytesToHex(Secp256k1.keyFromPrivate(privateKey.slice(2))
  58921. .getPublic()
  58922. .encodeCompressed());
  58923. return { privateKey, publicKey };
  58924. },
  58925. sign(message, privateKey) {
  58926. return bytesToHex(Secp256k1.sign(hash(message), hexToBytes(privateKey), {
  58927. canonical: true,
  58928. }).toDER());
  58929. },
  58930. verify(message, signature, publicKey) {
  58931. return Secp256k1.verify(hash(message), signature, hexToBytes(publicKey));
  58932. },
  58933. };
  58934. const ed25519 = {
  58935. deriveKeypair(entropy) {
  58936. const prefix = 'ED';
  58937. const rawPrivateKey = hash(entropy);
  58938. const privateKey = prefix + bytesToHex(rawPrivateKey);
  58939. const publicKey = prefix + bytesToHex(Ed25519.keyFromSecret(rawPrivateKey).pubBytes());
  58940. return { privateKey, publicKey };
  58941. },
  58942. sign(message, privateKey) {
  58943. // caution: Ed25519.sign interprets all strings as hex, stripping
  58944. // any non-hex characters without warning
  58945. assert.ok(Array.isArray(message), 'message must be array of octets');
  58946. return bytesToHex(Ed25519.sign(message, hexToBytes(privateKey).slice(1)).toBytes());
  58947. },
  58948. verify(message, signature, publicKey) {
  58949. return Ed25519.verify(message, hexToBytes(signature), hexToBytes(publicKey).slice(1));
  58950. },
  58951. };
  58952. function select(algorithm) {
  58953. const methods = { 'ecdsa-secp256k1': secp256k1, ed25519 };
  58954. return methods[algorithm];
  58955. }
  58956. function deriveKeypair(seed, options) {
  58957. const decoded = addressCodec.decodeSeed(seed);
  58958. const algorithm = decoded.type === 'ed25519' ? 'ed25519' : 'ecdsa-secp256k1';
  58959. const method = select(algorithm);
  58960. const keypair = method.deriveKeypair(decoded.bytes, options);
  58961. const messageToVerify = hash('This test message should verify.');
  58962. const signature = method.sign(messageToVerify, keypair.privateKey);
  58963. /* istanbul ignore if */
  58964. if (method.verify(messageToVerify, signature, keypair.publicKey) !== true) {
  58965. throw new Error('derived keypair did not generate verifiable signature');
  58966. }
  58967. return keypair;
  58968. }
  58969. exports.deriveKeypair = deriveKeypair;
  58970. function getAlgorithmFromKey(key) {
  58971. const bytes = hexToBytes(key);
  58972. return bytes.length === 33 && bytes[0] === 0xed
  58973. ? 'ed25519'
  58974. : 'ecdsa-secp256k1';
  58975. }
  58976. function sign(messageHex, privateKey) {
  58977. const algorithm = getAlgorithmFromKey(privateKey);
  58978. return select(algorithm).sign(hexToBytes(messageHex), privateKey);
  58979. }
  58980. exports.sign = sign;
  58981. function verify(messageHex, signature, publicKey) {
  58982. const algorithm = getAlgorithmFromKey(publicKey);
  58983. return select(algorithm).verify(hexToBytes(messageHex), signature, publicKey);
  58984. }
  58985. exports.verify = verify;
  58986. function deriveAddressFromBytes(publicKeyBytes) {
  58987. return addressCodec.encodeAccountID(utils.computePublicKeyHash(publicKeyBytes));
  58988. }
  58989. function deriveAddress(publicKey) {
  58990. return deriveAddressFromBytes(Buffer.from(hexToBytes(publicKey)));
  58991. }
  58992. exports.deriveAddress = deriveAddress;
  58993. function deriveNodeAddress(publicKey) {
  58994. const generatorBytes = addressCodec.decodeNodePublic(publicKey);
  58995. const accountPublicBytes = (0, secp256k1_1.accountPublicFromPublicGenerator)(generatorBytes);
  58996. return deriveAddressFromBytes(accountPublicBytes);
  58997. }
  58998. exports.deriveNodeAddress = deriveNodeAddress;
  58999. const { decodeSeed } = addressCodec;
  59000. exports.decodeSeed = decodeSeed;
  59001. /***/ }),
  59002. /***/ "../../node_modules/ripple-keypairs/dist/secp256k1.js":
  59003. /*!************************************************************!*\
  59004. !*** ../../node_modules/ripple-keypairs/dist/secp256k1.js ***!
  59005. \************************************************************/
  59006. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  59007. "use strict";
  59008. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  59009. if (k2 === undefined) k2 = k;
  59010. var desc = Object.getOwnPropertyDescriptor(m, k);
  59011. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  59012. desc = { enumerable: true, get: function() { return m[k]; } };
  59013. }
  59014. Object.defineProperty(o, k2, desc);
  59015. }) : (function(o, m, k, k2) {
  59016. if (k2 === undefined) k2 = k;
  59017. o[k2] = m[k];
  59018. }));
  59019. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  59020. Object.defineProperty(o, "default", { enumerable: true, value: v });
  59021. }) : function(o, v) {
  59022. o["default"] = v;
  59023. });
  59024. var __importStar = (this && this.__importStar) || function (mod) {
  59025. if (mod && mod.__esModule) return mod;
  59026. var result = {};
  59027. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  59028. __setModuleDefault(result, mod);
  59029. return result;
  59030. };
  59031. var __importDefault = (this && this.__importDefault) || function (mod) {
  59032. return (mod && mod.__esModule) ? mod : { "default": mod };
  59033. };
  59034. Object.defineProperty(exports, "__esModule", ({ value: true }));
  59035. exports.accountPublicFromPublicGenerator = exports.derivePrivateKey = void 0;
  59036. const elliptic = __importStar(__webpack_require__(/*! elliptic */ "../../node_modules/elliptic/lib/elliptic.js"));
  59037. const Sha512_1 = __importDefault(__webpack_require__(/*! ./Sha512 */ "../../node_modules/ripple-keypairs/dist/Sha512.js"));
  59038. const secp256k1 = elliptic.ec('secp256k1');
  59039. function deriveScalar(bytes, discrim) {
  59040. const order = secp256k1.curve.n;
  59041. for (let i = 0; i <= 0xffffffff; i++) {
  59042. // We hash the bytes to find a 256 bit number, looping until we are sure it
  59043. // is less than the order of the curve.
  59044. const hasher = new Sha512_1.default().add(bytes);
  59045. // If the optional discriminator index was passed in, update the hash.
  59046. if (discrim !== undefined) {
  59047. hasher.addU32(discrim);
  59048. }
  59049. hasher.addU32(i);
  59050. const key = hasher.first256BN();
  59051. /* istanbul ignore else */
  59052. if (key.cmpn(0) > 0 && key.cmp(order) < 0) {
  59053. return key;
  59054. }
  59055. }
  59056. // This error is practically impossible to reach.
  59057. // The order of the curve describes the (finite) amount of points on the curve
  59058. // https://github.com/indutny/elliptic/blob/master/lib/elliptic/curves.js#L182
  59059. // How often will an (essentially) random number generated by Sha512 be larger than that?
  59060. // There's 2^32 chances (the for loop) to get a number smaller than the order,
  59061. // and it's rare that you'll even get past the first loop iteration.
  59062. // Note that in TypeScript we actually need the throw, otherwise the function signature would be BN | undefined
  59063. //
  59064. /* istanbul ignore next */
  59065. throw new Error('impossible unicorn ;)');
  59066. }
  59067. /**
  59068. * @param seed - Bytes.
  59069. * @param [opts] - Object.
  59070. * @param [opts.accountIndex=0] - The account number to generate.
  59071. * @param [opts.validator=false] - Generate root key-pair,
  59072. * as used by validators.
  59073. * @returns {bn.js} 256 bit scalar value.
  59074. *
  59075. */
  59076. function derivePrivateKey(seed, opts = {}) {
  59077. const root = opts.validator;
  59078. const order = secp256k1.curve.n;
  59079. // This private generator represents the `root` private key, and is what's
  59080. // used by validators for signing when a keypair is generated from a seed.
  59081. const privateGen = deriveScalar(seed);
  59082. if (root) {
  59083. // As returned by validation_create for a given seed
  59084. return privateGen;
  59085. }
  59086. const publicGen = secp256k1.g.mul(privateGen);
  59087. // A seed can generate many keypairs as a function of the seed and a uint32.
  59088. // Almost everyone just uses the first account, `0`.
  59089. const accountIndex = opts.accountIndex || 0;
  59090. return deriveScalar(publicGen.encodeCompressed(), accountIndex)
  59091. .add(privateGen)
  59092. .mod(order);
  59093. }
  59094. exports.derivePrivateKey = derivePrivateKey;
  59095. function accountPublicFromPublicGenerator(publicGenBytes) {
  59096. const rootPubPoint = secp256k1.curve.decodePoint(publicGenBytes);
  59097. const scalar = deriveScalar(publicGenBytes, 0);
  59098. const point = secp256k1.g.mul(scalar);
  59099. const offset = rootPubPoint.add(point);
  59100. return offset.encodeCompressed();
  59101. }
  59102. exports.accountPublicFromPublicGenerator = accountPublicFromPublicGenerator;
  59103. /***/ }),
  59104. /***/ "../../node_modules/ripple-keypairs/dist/utils.js":
  59105. /*!********************************************************!*\
  59106. !*** ../../node_modules/ripple-keypairs/dist/utils.js ***!
  59107. \********************************************************/
  59108. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  59109. "use strict";
  59110. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js")["Buffer"];
  59111. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  59112. if (k2 === undefined) k2 = k;
  59113. var desc = Object.getOwnPropertyDescriptor(m, k);
  59114. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  59115. desc = { enumerable: true, get: function() { return m[k]; } };
  59116. }
  59117. Object.defineProperty(o, k2, desc);
  59118. }) : (function(o, m, k, k2) {
  59119. if (k2 === undefined) k2 = k;
  59120. o[k2] = m[k];
  59121. }));
  59122. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  59123. Object.defineProperty(o, "default", { enumerable: true, value: v });
  59124. }) : function(o, v) {
  59125. o["default"] = v;
  59126. });
  59127. var __importStar = (this && this.__importStar) || function (mod) {
  59128. if (mod && mod.__esModule) return mod;
  59129. var result = {};
  59130. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  59131. __setModuleDefault(result, mod);
  59132. return result;
  59133. };
  59134. Object.defineProperty(exports, "__esModule", ({ value: true }));
  59135. exports.computePublicKeyHash = exports.hexToBytes = exports.bytesToHex = void 0;
  59136. const assert = __importStar(__webpack_require__(/*! assert */ "../../node_modules/assert/build/assert.js"));
  59137. const hashjs = __importStar(__webpack_require__(/*! hash.js */ "../../node_modules/hash.js/lib/hash.js"));
  59138. const BN = __webpack_require__(/*! bn.js */ "../../node_modules/bn.js/lib/bn.js");
  59139. function bytesToHex(a) {
  59140. return Array.from(a, (byteValue) => {
  59141. const hex = byteValue.toString(16).toUpperCase();
  59142. return hex.length > 1 ? hex : `0${hex}`;
  59143. }).join('');
  59144. }
  59145. exports.bytesToHex = bytesToHex;
  59146. function hexToBytes(a) {
  59147. assert.ok(a.length % 2 === 0);
  59148. // Special-case length zero to return [].
  59149. // BN.toArray intentionally returns [0] rather than [] for length zero,
  59150. // which may make sense for BigNum data, but not for byte strings.
  59151. return a.length === 0 ? [] : new BN(a, 16).toArray(null, a.length / 2);
  59152. }
  59153. exports.hexToBytes = hexToBytes;
  59154. function computePublicKeyHash(publicKeyBytes) {
  59155. const hash256 = hashjs.sha256().update(publicKeyBytes).digest();
  59156. const hash160 = hashjs.ripemd160().update(hash256).digest();
  59157. return Buffer.from(hash160);
  59158. }
  59159. exports.computePublicKeyHash = computePublicKeyHash;
  59160. /***/ }),
  59161. /***/ "../../node_modules/safe-buffer/index.js":
  59162. /*!***********************************************!*\
  59163. !*** ../../node_modules/safe-buffer/index.js ***!
  59164. \***********************************************/
  59165. /***/ ((module, exports, __webpack_require__) => {
  59166. /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
  59167. /* eslint-disable node/no-deprecated-api */
  59168. var buffer = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js")
  59169. var Buffer = buffer.Buffer
  59170. // alternative to using Object.keys for old browsers
  59171. function copyProps (src, dst) {
  59172. for (var key in src) {
  59173. dst[key] = src[key]
  59174. }
  59175. }
  59176. if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
  59177. module.exports = buffer
  59178. } else {
  59179. // Copy properties from require('buffer')
  59180. copyProps(buffer, exports)
  59181. exports.Buffer = SafeBuffer
  59182. }
  59183. function SafeBuffer (arg, encodingOrOffset, length) {
  59184. return Buffer(arg, encodingOrOffset, length)
  59185. }
  59186. SafeBuffer.prototype = Object.create(Buffer.prototype)
  59187. // Copy static methods from Buffer
  59188. copyProps(Buffer, SafeBuffer)
  59189. SafeBuffer.from = function (arg, encodingOrOffset, length) {
  59190. if (typeof arg === 'number') {
  59191. throw new TypeError('Argument must not be a number')
  59192. }
  59193. return Buffer(arg, encodingOrOffset, length)
  59194. }
  59195. SafeBuffer.alloc = function (size, fill, encoding) {
  59196. if (typeof size !== 'number') {
  59197. throw new TypeError('Argument must be a number')
  59198. }
  59199. var buf = Buffer(size)
  59200. if (fill !== undefined) {
  59201. if (typeof encoding === 'string') {
  59202. buf.fill(fill, encoding)
  59203. } else {
  59204. buf.fill(fill)
  59205. }
  59206. } else {
  59207. buf.fill(0)
  59208. }
  59209. return buf
  59210. }
  59211. SafeBuffer.allocUnsafe = function (size) {
  59212. if (typeof size !== 'number') {
  59213. throw new TypeError('Argument must be a number')
  59214. }
  59215. return Buffer(size)
  59216. }
  59217. SafeBuffer.allocUnsafeSlow = function (size) {
  59218. if (typeof size !== 'number') {
  59219. throw new TypeError('Argument must be a number')
  59220. }
  59221. return buffer.SlowBuffer(size)
  59222. }
  59223. /***/ }),
  59224. /***/ "../../node_modules/safer-buffer/safer.js":
  59225. /*!************************************************!*\
  59226. !*** ../../node_modules/safer-buffer/safer.js ***!
  59227. \************************************************/
  59228. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  59229. "use strict";
  59230. /* provided dependency */ var process = __webpack_require__(/*! process/browser */ "../../node_modules/process/browser.js");
  59231. /* eslint-disable node/no-deprecated-api */
  59232. var buffer = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js")
  59233. var Buffer = buffer.Buffer
  59234. var safer = {}
  59235. var key
  59236. for (key in buffer) {
  59237. if (!buffer.hasOwnProperty(key)) continue
  59238. if (key === 'SlowBuffer' || key === 'Buffer') continue
  59239. safer[key] = buffer[key]
  59240. }
  59241. var Safer = safer.Buffer = {}
  59242. for (key in Buffer) {
  59243. if (!Buffer.hasOwnProperty(key)) continue
  59244. if (key === 'allocUnsafe' || key === 'allocUnsafeSlow') continue
  59245. Safer[key] = Buffer[key]
  59246. }
  59247. safer.Buffer.prototype = Buffer.prototype
  59248. if (!Safer.from || Safer.from === Uint8Array.from) {
  59249. Safer.from = function (value, encodingOrOffset, length) {
  59250. if (typeof value === 'number') {
  59251. throw new TypeError('The "value" argument must not be of type number. Received type ' + typeof value)
  59252. }
  59253. if (value && typeof value.length === 'undefined') {
  59254. throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type ' + typeof value)
  59255. }
  59256. return Buffer(value, encodingOrOffset, length)
  59257. }
  59258. }
  59259. if (!Safer.alloc) {
  59260. Safer.alloc = function (size, fill, encoding) {
  59261. if (typeof size !== 'number') {
  59262. throw new TypeError('The "size" argument must be of type number. Received type ' + typeof size)
  59263. }
  59264. if (size < 0 || size >= 2 * (1 << 30)) {
  59265. throw new RangeError('The value "' + size + '" is invalid for option "size"')
  59266. }
  59267. var buf = Buffer(size)
  59268. if (!fill || fill.length === 0) {
  59269. buf.fill(0)
  59270. } else if (typeof encoding === 'string') {
  59271. buf.fill(fill, encoding)
  59272. } else {
  59273. buf.fill(fill)
  59274. }
  59275. return buf
  59276. }
  59277. }
  59278. if (!safer.kStringMaxLength) {
  59279. try {
  59280. safer.kStringMaxLength = process.binding('buffer').kStringMaxLength
  59281. } catch (e) {
  59282. // we can't determine kStringMaxLength in environments where process.binding
  59283. // is unsupported, so let's not set it
  59284. }
  59285. }
  59286. if (!safer.constants) {
  59287. safer.constants = {
  59288. MAX_LENGTH: safer.kMaxLength
  59289. }
  59290. if (safer.kStringMaxLength) {
  59291. safer.constants.MAX_STRING_LENGTH = safer.kStringMaxLength
  59292. }
  59293. }
  59294. module.exports = safer
  59295. /***/ }),
  59296. /***/ "../../node_modules/sha.js/hash.js":
  59297. /*!*****************************************!*\
  59298. !*** ../../node_modules/sha.js/hash.js ***!
  59299. \*****************************************/
  59300. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  59301. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  59302. // prototype class for hash functions
  59303. function Hash (blockSize, finalSize) {
  59304. this._block = Buffer.alloc(blockSize)
  59305. this._finalSize = finalSize
  59306. this._blockSize = blockSize
  59307. this._len = 0
  59308. }
  59309. Hash.prototype.update = function (data, enc) {
  59310. if (typeof data === 'string') {
  59311. enc = enc || 'utf8'
  59312. data = Buffer.from(data, enc)
  59313. }
  59314. var block = this._block
  59315. var blockSize = this._blockSize
  59316. var length = data.length
  59317. var accum = this._len
  59318. for (var offset = 0; offset < length;) {
  59319. var assigned = accum % blockSize
  59320. var remainder = Math.min(length - offset, blockSize - assigned)
  59321. for (var i = 0; i < remainder; i++) {
  59322. block[assigned + i] = data[offset + i]
  59323. }
  59324. accum += remainder
  59325. offset += remainder
  59326. if ((accum % blockSize) === 0) {
  59327. this._update(block)
  59328. }
  59329. }
  59330. this._len += length
  59331. return this
  59332. }
  59333. Hash.prototype.digest = function (enc) {
  59334. var rem = this._len % this._blockSize
  59335. this._block[rem] = 0x80
  59336. // zero (rem + 1) trailing bits, where (rem + 1) is the smallest
  59337. // non-negative solution to the equation (length + 1 + (rem + 1)) === finalSize mod blockSize
  59338. this._block.fill(0, rem + 1)
  59339. if (rem >= this._finalSize) {
  59340. this._update(this._block)
  59341. this._block.fill(0)
  59342. }
  59343. var bits = this._len * 8
  59344. // uint32
  59345. if (bits <= 0xffffffff) {
  59346. this._block.writeUInt32BE(bits, this._blockSize - 4)
  59347. // uint64
  59348. } else {
  59349. var lowBits = (bits & 0xffffffff) >>> 0
  59350. var highBits = (bits - lowBits) / 0x100000000
  59351. this._block.writeUInt32BE(highBits, this._blockSize - 8)
  59352. this._block.writeUInt32BE(lowBits, this._blockSize - 4)
  59353. }
  59354. this._update(this._block)
  59355. var hash = this._hash()
  59356. return enc ? hash.toString(enc) : hash
  59357. }
  59358. Hash.prototype._update = function () {
  59359. throw new Error('_update must be implemented by subclass')
  59360. }
  59361. module.exports = Hash
  59362. /***/ }),
  59363. /***/ "../../node_modules/sha.js/index.js":
  59364. /*!******************************************!*\
  59365. !*** ../../node_modules/sha.js/index.js ***!
  59366. \******************************************/
  59367. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  59368. var exports = module.exports = function SHA (algorithm) {
  59369. algorithm = algorithm.toLowerCase()
  59370. var Algorithm = exports[algorithm]
  59371. if (!Algorithm) throw new Error(algorithm + ' is not supported (we accept pull requests)')
  59372. return new Algorithm()
  59373. }
  59374. exports.sha = __webpack_require__(/*! ./sha */ "../../node_modules/sha.js/sha.js")
  59375. exports.sha1 = __webpack_require__(/*! ./sha1 */ "../../node_modules/sha.js/sha1.js")
  59376. exports.sha224 = __webpack_require__(/*! ./sha224 */ "../../node_modules/sha.js/sha224.js")
  59377. exports.sha256 = __webpack_require__(/*! ./sha256 */ "../../node_modules/sha.js/sha256.js")
  59378. exports.sha384 = __webpack_require__(/*! ./sha384 */ "../../node_modules/sha.js/sha384.js")
  59379. exports.sha512 = __webpack_require__(/*! ./sha512 */ "../../node_modules/sha.js/sha512.js")
  59380. /***/ }),
  59381. /***/ "../../node_modules/sha.js/sha.js":
  59382. /*!****************************************!*\
  59383. !*** ../../node_modules/sha.js/sha.js ***!
  59384. \****************************************/
  59385. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  59386. /*
  59387. * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined
  59388. * in FIPS PUB 180-1
  59389. * This source code is derived from sha1.js of the same repository.
  59390. * The difference between SHA-0 and SHA-1 is just a bitwise rotate left
  59391. * operation was added.
  59392. */
  59393. var inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js")
  59394. var Hash = __webpack_require__(/*! ./hash */ "../../node_modules/sha.js/hash.js")
  59395. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  59396. var K = [
  59397. 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
  59398. ]
  59399. var W = new Array(80)
  59400. function Sha () {
  59401. this.init()
  59402. this._w = W
  59403. Hash.call(this, 64, 56)
  59404. }
  59405. inherits(Sha, Hash)
  59406. Sha.prototype.init = function () {
  59407. this._a = 0x67452301
  59408. this._b = 0xefcdab89
  59409. this._c = 0x98badcfe
  59410. this._d = 0x10325476
  59411. this._e = 0xc3d2e1f0
  59412. return this
  59413. }
  59414. function rotl5 (num) {
  59415. return (num << 5) | (num >>> 27)
  59416. }
  59417. function rotl30 (num) {
  59418. return (num << 30) | (num >>> 2)
  59419. }
  59420. function ft (s, b, c, d) {
  59421. if (s === 0) return (b & c) | ((~b) & d)
  59422. if (s === 2) return (b & c) | (b & d) | (c & d)
  59423. return b ^ c ^ d
  59424. }
  59425. Sha.prototype._update = function (M) {
  59426. var W = this._w
  59427. var a = this._a | 0
  59428. var b = this._b | 0
  59429. var c = this._c | 0
  59430. var d = this._d | 0
  59431. var e = this._e | 0
  59432. for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
  59433. for (; i < 80; ++i) W[i] = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]
  59434. for (var j = 0; j < 80; ++j) {
  59435. var s = ~~(j / 20)
  59436. var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0
  59437. e = d
  59438. d = c
  59439. c = rotl30(b)
  59440. b = a
  59441. a = t
  59442. }
  59443. this._a = (a + this._a) | 0
  59444. this._b = (b + this._b) | 0
  59445. this._c = (c + this._c) | 0
  59446. this._d = (d + this._d) | 0
  59447. this._e = (e + this._e) | 0
  59448. }
  59449. Sha.prototype._hash = function () {
  59450. var H = Buffer.allocUnsafe(20)
  59451. H.writeInt32BE(this._a | 0, 0)
  59452. H.writeInt32BE(this._b | 0, 4)
  59453. H.writeInt32BE(this._c | 0, 8)
  59454. H.writeInt32BE(this._d | 0, 12)
  59455. H.writeInt32BE(this._e | 0, 16)
  59456. return H
  59457. }
  59458. module.exports = Sha
  59459. /***/ }),
  59460. /***/ "../../node_modules/sha.js/sha1.js":
  59461. /*!*****************************************!*\
  59462. !*** ../../node_modules/sha.js/sha1.js ***!
  59463. \*****************************************/
  59464. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  59465. /*
  59466. * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
  59467. * in FIPS PUB 180-1
  59468. * Version 2.1a Copyright Paul Johnston 2000 - 2002.
  59469. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  59470. * Distributed under the BSD License
  59471. * See http://pajhome.org.uk/crypt/md5 for details.
  59472. */
  59473. var inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js")
  59474. var Hash = __webpack_require__(/*! ./hash */ "../../node_modules/sha.js/hash.js")
  59475. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  59476. var K = [
  59477. 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
  59478. ]
  59479. var W = new Array(80)
  59480. function Sha1 () {
  59481. this.init()
  59482. this._w = W
  59483. Hash.call(this, 64, 56)
  59484. }
  59485. inherits(Sha1, Hash)
  59486. Sha1.prototype.init = function () {
  59487. this._a = 0x67452301
  59488. this._b = 0xefcdab89
  59489. this._c = 0x98badcfe
  59490. this._d = 0x10325476
  59491. this._e = 0xc3d2e1f0
  59492. return this
  59493. }
  59494. function rotl1 (num) {
  59495. return (num << 1) | (num >>> 31)
  59496. }
  59497. function rotl5 (num) {
  59498. return (num << 5) | (num >>> 27)
  59499. }
  59500. function rotl30 (num) {
  59501. return (num << 30) | (num >>> 2)
  59502. }
  59503. function ft (s, b, c, d) {
  59504. if (s === 0) return (b & c) | ((~b) & d)
  59505. if (s === 2) return (b & c) | (b & d) | (c & d)
  59506. return b ^ c ^ d
  59507. }
  59508. Sha1.prototype._update = function (M) {
  59509. var W = this._w
  59510. var a = this._a | 0
  59511. var b = this._b | 0
  59512. var c = this._c | 0
  59513. var d = this._d | 0
  59514. var e = this._e | 0
  59515. for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
  59516. for (; i < 80; ++i) W[i] = rotl1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16])
  59517. for (var j = 0; j < 80; ++j) {
  59518. var s = ~~(j / 20)
  59519. var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0
  59520. e = d
  59521. d = c
  59522. c = rotl30(b)
  59523. b = a
  59524. a = t
  59525. }
  59526. this._a = (a + this._a) | 0
  59527. this._b = (b + this._b) | 0
  59528. this._c = (c + this._c) | 0
  59529. this._d = (d + this._d) | 0
  59530. this._e = (e + this._e) | 0
  59531. }
  59532. Sha1.prototype._hash = function () {
  59533. var H = Buffer.allocUnsafe(20)
  59534. H.writeInt32BE(this._a | 0, 0)
  59535. H.writeInt32BE(this._b | 0, 4)
  59536. H.writeInt32BE(this._c | 0, 8)
  59537. H.writeInt32BE(this._d | 0, 12)
  59538. H.writeInt32BE(this._e | 0, 16)
  59539. return H
  59540. }
  59541. module.exports = Sha1
  59542. /***/ }),
  59543. /***/ "../../node_modules/sha.js/sha224.js":
  59544. /*!*******************************************!*\
  59545. !*** ../../node_modules/sha.js/sha224.js ***!
  59546. \*******************************************/
  59547. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  59548. /**
  59549. * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
  59550. * in FIPS 180-2
  59551. * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
  59552. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  59553. *
  59554. */
  59555. var inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js")
  59556. var Sha256 = __webpack_require__(/*! ./sha256 */ "../../node_modules/sha.js/sha256.js")
  59557. var Hash = __webpack_require__(/*! ./hash */ "../../node_modules/sha.js/hash.js")
  59558. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  59559. var W = new Array(64)
  59560. function Sha224 () {
  59561. this.init()
  59562. this._w = W // new Array(64)
  59563. Hash.call(this, 64, 56)
  59564. }
  59565. inherits(Sha224, Sha256)
  59566. Sha224.prototype.init = function () {
  59567. this._a = 0xc1059ed8
  59568. this._b = 0x367cd507
  59569. this._c = 0x3070dd17
  59570. this._d = 0xf70e5939
  59571. this._e = 0xffc00b31
  59572. this._f = 0x68581511
  59573. this._g = 0x64f98fa7
  59574. this._h = 0xbefa4fa4
  59575. return this
  59576. }
  59577. Sha224.prototype._hash = function () {
  59578. var H = Buffer.allocUnsafe(28)
  59579. H.writeInt32BE(this._a, 0)
  59580. H.writeInt32BE(this._b, 4)
  59581. H.writeInt32BE(this._c, 8)
  59582. H.writeInt32BE(this._d, 12)
  59583. H.writeInt32BE(this._e, 16)
  59584. H.writeInt32BE(this._f, 20)
  59585. H.writeInt32BE(this._g, 24)
  59586. return H
  59587. }
  59588. module.exports = Sha224
  59589. /***/ }),
  59590. /***/ "../../node_modules/sha.js/sha256.js":
  59591. /*!*******************************************!*\
  59592. !*** ../../node_modules/sha.js/sha256.js ***!
  59593. \*******************************************/
  59594. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  59595. /**
  59596. * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
  59597. * in FIPS 180-2
  59598. * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
  59599. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  59600. *
  59601. */
  59602. var inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js")
  59603. var Hash = __webpack_require__(/*! ./hash */ "../../node_modules/sha.js/hash.js")
  59604. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  59605. var K = [
  59606. 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
  59607. 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
  59608. 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
  59609. 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
  59610. 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
  59611. 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
  59612. 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
  59613. 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
  59614. 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
  59615. 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
  59616. 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
  59617. 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
  59618. 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
  59619. 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
  59620. 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
  59621. 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2
  59622. ]
  59623. var W = new Array(64)
  59624. function Sha256 () {
  59625. this.init()
  59626. this._w = W // new Array(64)
  59627. Hash.call(this, 64, 56)
  59628. }
  59629. inherits(Sha256, Hash)
  59630. Sha256.prototype.init = function () {
  59631. this._a = 0x6a09e667
  59632. this._b = 0xbb67ae85
  59633. this._c = 0x3c6ef372
  59634. this._d = 0xa54ff53a
  59635. this._e = 0x510e527f
  59636. this._f = 0x9b05688c
  59637. this._g = 0x1f83d9ab
  59638. this._h = 0x5be0cd19
  59639. return this
  59640. }
  59641. function ch (x, y, z) {
  59642. return z ^ (x & (y ^ z))
  59643. }
  59644. function maj (x, y, z) {
  59645. return (x & y) | (z & (x | y))
  59646. }
  59647. function sigma0 (x) {
  59648. return (x >>> 2 | x << 30) ^ (x >>> 13 | x << 19) ^ (x >>> 22 | x << 10)
  59649. }
  59650. function sigma1 (x) {
  59651. return (x >>> 6 | x << 26) ^ (x >>> 11 | x << 21) ^ (x >>> 25 | x << 7)
  59652. }
  59653. function gamma0 (x) {
  59654. return (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ (x >>> 3)
  59655. }
  59656. function gamma1 (x) {
  59657. return (x >>> 17 | x << 15) ^ (x >>> 19 | x << 13) ^ (x >>> 10)
  59658. }
  59659. Sha256.prototype._update = function (M) {
  59660. var W = this._w
  59661. var a = this._a | 0
  59662. var b = this._b | 0
  59663. var c = this._c | 0
  59664. var d = this._d | 0
  59665. var e = this._e | 0
  59666. var f = this._f | 0
  59667. var g = this._g | 0
  59668. var h = this._h | 0
  59669. for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
  59670. for (; i < 64; ++i) W[i] = (gamma1(W[i - 2]) + W[i - 7] + gamma0(W[i - 15]) + W[i - 16]) | 0
  59671. for (var j = 0; j < 64; ++j) {
  59672. var T1 = (h + sigma1(e) + ch(e, f, g) + K[j] + W[j]) | 0
  59673. var T2 = (sigma0(a) + maj(a, b, c)) | 0
  59674. h = g
  59675. g = f
  59676. f = e
  59677. e = (d + T1) | 0
  59678. d = c
  59679. c = b
  59680. b = a
  59681. a = (T1 + T2) | 0
  59682. }
  59683. this._a = (a + this._a) | 0
  59684. this._b = (b + this._b) | 0
  59685. this._c = (c + this._c) | 0
  59686. this._d = (d + this._d) | 0
  59687. this._e = (e + this._e) | 0
  59688. this._f = (f + this._f) | 0
  59689. this._g = (g + this._g) | 0
  59690. this._h = (h + this._h) | 0
  59691. }
  59692. Sha256.prototype._hash = function () {
  59693. var H = Buffer.allocUnsafe(32)
  59694. H.writeInt32BE(this._a, 0)
  59695. H.writeInt32BE(this._b, 4)
  59696. H.writeInt32BE(this._c, 8)
  59697. H.writeInt32BE(this._d, 12)
  59698. H.writeInt32BE(this._e, 16)
  59699. H.writeInt32BE(this._f, 20)
  59700. H.writeInt32BE(this._g, 24)
  59701. H.writeInt32BE(this._h, 28)
  59702. return H
  59703. }
  59704. module.exports = Sha256
  59705. /***/ }),
  59706. /***/ "../../node_modules/sha.js/sha384.js":
  59707. /*!*******************************************!*\
  59708. !*** ../../node_modules/sha.js/sha384.js ***!
  59709. \*******************************************/
  59710. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  59711. var inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js")
  59712. var SHA512 = __webpack_require__(/*! ./sha512 */ "../../node_modules/sha.js/sha512.js")
  59713. var Hash = __webpack_require__(/*! ./hash */ "../../node_modules/sha.js/hash.js")
  59714. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  59715. var W = new Array(160)
  59716. function Sha384 () {
  59717. this.init()
  59718. this._w = W
  59719. Hash.call(this, 128, 112)
  59720. }
  59721. inherits(Sha384, SHA512)
  59722. Sha384.prototype.init = function () {
  59723. this._ah = 0xcbbb9d5d
  59724. this._bh = 0x629a292a
  59725. this._ch = 0x9159015a
  59726. this._dh = 0x152fecd8
  59727. this._eh = 0x67332667
  59728. this._fh = 0x8eb44a87
  59729. this._gh = 0xdb0c2e0d
  59730. this._hh = 0x47b5481d
  59731. this._al = 0xc1059ed8
  59732. this._bl = 0x367cd507
  59733. this._cl = 0x3070dd17
  59734. this._dl = 0xf70e5939
  59735. this._el = 0xffc00b31
  59736. this._fl = 0x68581511
  59737. this._gl = 0x64f98fa7
  59738. this._hl = 0xbefa4fa4
  59739. return this
  59740. }
  59741. Sha384.prototype._hash = function () {
  59742. var H = Buffer.allocUnsafe(48)
  59743. function writeInt64BE (h, l, offset) {
  59744. H.writeInt32BE(h, offset)
  59745. H.writeInt32BE(l, offset + 4)
  59746. }
  59747. writeInt64BE(this._ah, this._al, 0)
  59748. writeInt64BE(this._bh, this._bl, 8)
  59749. writeInt64BE(this._ch, this._cl, 16)
  59750. writeInt64BE(this._dh, this._dl, 24)
  59751. writeInt64BE(this._eh, this._el, 32)
  59752. writeInt64BE(this._fh, this._fl, 40)
  59753. return H
  59754. }
  59755. module.exports = Sha384
  59756. /***/ }),
  59757. /***/ "../../node_modules/sha.js/sha512.js":
  59758. /*!*******************************************!*\
  59759. !*** ../../node_modules/sha.js/sha512.js ***!
  59760. \*******************************************/
  59761. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  59762. var inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js")
  59763. var Hash = __webpack_require__(/*! ./hash */ "../../node_modules/sha.js/hash.js")
  59764. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer)
  59765. var K = [
  59766. 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
  59767. 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
  59768. 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
  59769. 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
  59770. 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
  59771. 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
  59772. 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
  59773. 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
  59774. 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
  59775. 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
  59776. 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
  59777. 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
  59778. 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
  59779. 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
  59780. 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
  59781. 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
  59782. 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
  59783. 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
  59784. 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
  59785. 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
  59786. 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
  59787. 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
  59788. 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
  59789. 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
  59790. 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
  59791. 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
  59792. 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
  59793. 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
  59794. 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
  59795. 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
  59796. 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
  59797. 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
  59798. 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
  59799. 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
  59800. 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
  59801. 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
  59802. 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
  59803. 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
  59804. 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
  59805. 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
  59806. ]
  59807. var W = new Array(160)
  59808. function Sha512 () {
  59809. this.init()
  59810. this._w = W
  59811. Hash.call(this, 128, 112)
  59812. }
  59813. inherits(Sha512, Hash)
  59814. Sha512.prototype.init = function () {
  59815. this._ah = 0x6a09e667
  59816. this._bh = 0xbb67ae85
  59817. this._ch = 0x3c6ef372
  59818. this._dh = 0xa54ff53a
  59819. this._eh = 0x510e527f
  59820. this._fh = 0x9b05688c
  59821. this._gh = 0x1f83d9ab
  59822. this._hh = 0x5be0cd19
  59823. this._al = 0xf3bcc908
  59824. this._bl = 0x84caa73b
  59825. this._cl = 0xfe94f82b
  59826. this._dl = 0x5f1d36f1
  59827. this._el = 0xade682d1
  59828. this._fl = 0x2b3e6c1f
  59829. this._gl = 0xfb41bd6b
  59830. this._hl = 0x137e2179
  59831. return this
  59832. }
  59833. function Ch (x, y, z) {
  59834. return z ^ (x & (y ^ z))
  59835. }
  59836. function maj (x, y, z) {
  59837. return (x & y) | (z & (x | y))
  59838. }
  59839. function sigma0 (x, xl) {
  59840. return (x >>> 28 | xl << 4) ^ (xl >>> 2 | x << 30) ^ (xl >>> 7 | x << 25)
  59841. }
  59842. function sigma1 (x, xl) {
  59843. return (x >>> 14 | xl << 18) ^ (x >>> 18 | xl << 14) ^ (xl >>> 9 | x << 23)
  59844. }
  59845. function Gamma0 (x, xl) {
  59846. return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7)
  59847. }
  59848. function Gamma0l (x, xl) {
  59849. return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7 | xl << 25)
  59850. }
  59851. function Gamma1 (x, xl) {
  59852. return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6)
  59853. }
  59854. function Gamma1l (x, xl) {
  59855. return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6 | xl << 26)
  59856. }
  59857. function getCarry (a, b) {
  59858. return (a >>> 0) < (b >>> 0) ? 1 : 0
  59859. }
  59860. Sha512.prototype._update = function (M) {
  59861. var W = this._w
  59862. var ah = this._ah | 0
  59863. var bh = this._bh | 0
  59864. var ch = this._ch | 0
  59865. var dh = this._dh | 0
  59866. var eh = this._eh | 0
  59867. var fh = this._fh | 0
  59868. var gh = this._gh | 0
  59869. var hh = this._hh | 0
  59870. var al = this._al | 0
  59871. var bl = this._bl | 0
  59872. var cl = this._cl | 0
  59873. var dl = this._dl | 0
  59874. var el = this._el | 0
  59875. var fl = this._fl | 0
  59876. var gl = this._gl | 0
  59877. var hl = this._hl | 0
  59878. for (var i = 0; i < 32; i += 2) {
  59879. W[i] = M.readInt32BE(i * 4)
  59880. W[i + 1] = M.readInt32BE(i * 4 + 4)
  59881. }
  59882. for (; i < 160; i += 2) {
  59883. var xh = W[i - 15 * 2]
  59884. var xl = W[i - 15 * 2 + 1]
  59885. var gamma0 = Gamma0(xh, xl)
  59886. var gamma0l = Gamma0l(xl, xh)
  59887. xh = W[i - 2 * 2]
  59888. xl = W[i - 2 * 2 + 1]
  59889. var gamma1 = Gamma1(xh, xl)
  59890. var gamma1l = Gamma1l(xl, xh)
  59891. // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
  59892. var Wi7h = W[i - 7 * 2]
  59893. var Wi7l = W[i - 7 * 2 + 1]
  59894. var Wi16h = W[i - 16 * 2]
  59895. var Wi16l = W[i - 16 * 2 + 1]
  59896. var Wil = (gamma0l + Wi7l) | 0
  59897. var Wih = (gamma0 + Wi7h + getCarry(Wil, gamma0l)) | 0
  59898. Wil = (Wil + gamma1l) | 0
  59899. Wih = (Wih + gamma1 + getCarry(Wil, gamma1l)) | 0
  59900. Wil = (Wil + Wi16l) | 0
  59901. Wih = (Wih + Wi16h + getCarry(Wil, Wi16l)) | 0
  59902. W[i] = Wih
  59903. W[i + 1] = Wil
  59904. }
  59905. for (var j = 0; j < 160; j += 2) {
  59906. Wih = W[j]
  59907. Wil = W[j + 1]
  59908. var majh = maj(ah, bh, ch)
  59909. var majl = maj(al, bl, cl)
  59910. var sigma0h = sigma0(ah, al)
  59911. var sigma0l = sigma0(al, ah)
  59912. var sigma1h = sigma1(eh, el)
  59913. var sigma1l = sigma1(el, eh)
  59914. // t1 = h + sigma1 + ch + K[j] + W[j]
  59915. var Kih = K[j]
  59916. var Kil = K[j + 1]
  59917. var chh = Ch(eh, fh, gh)
  59918. var chl = Ch(el, fl, gl)
  59919. var t1l = (hl + sigma1l) | 0
  59920. var t1h = (hh + sigma1h + getCarry(t1l, hl)) | 0
  59921. t1l = (t1l + chl) | 0
  59922. t1h = (t1h + chh + getCarry(t1l, chl)) | 0
  59923. t1l = (t1l + Kil) | 0
  59924. t1h = (t1h + Kih + getCarry(t1l, Kil)) | 0
  59925. t1l = (t1l + Wil) | 0
  59926. t1h = (t1h + Wih + getCarry(t1l, Wil)) | 0
  59927. // t2 = sigma0 + maj
  59928. var t2l = (sigma0l + majl) | 0
  59929. var t2h = (sigma0h + majh + getCarry(t2l, sigma0l)) | 0
  59930. hh = gh
  59931. hl = gl
  59932. gh = fh
  59933. gl = fl
  59934. fh = eh
  59935. fl = el
  59936. el = (dl + t1l) | 0
  59937. eh = (dh + t1h + getCarry(el, dl)) | 0
  59938. dh = ch
  59939. dl = cl
  59940. ch = bh
  59941. cl = bl
  59942. bh = ah
  59943. bl = al
  59944. al = (t1l + t2l) | 0
  59945. ah = (t1h + t2h + getCarry(al, t1l)) | 0
  59946. }
  59947. this._al = (this._al + al) | 0
  59948. this._bl = (this._bl + bl) | 0
  59949. this._cl = (this._cl + cl) | 0
  59950. this._dl = (this._dl + dl) | 0
  59951. this._el = (this._el + el) | 0
  59952. this._fl = (this._fl + fl) | 0
  59953. this._gl = (this._gl + gl) | 0
  59954. this._hl = (this._hl + hl) | 0
  59955. this._ah = (this._ah + ah + getCarry(this._al, al)) | 0
  59956. this._bh = (this._bh + bh + getCarry(this._bl, bl)) | 0
  59957. this._ch = (this._ch + ch + getCarry(this._cl, cl)) | 0
  59958. this._dh = (this._dh + dh + getCarry(this._dl, dl)) | 0
  59959. this._eh = (this._eh + eh + getCarry(this._el, el)) | 0
  59960. this._fh = (this._fh + fh + getCarry(this._fl, fl)) | 0
  59961. this._gh = (this._gh + gh + getCarry(this._gl, gl)) | 0
  59962. this._hh = (this._hh + hh + getCarry(this._hl, hl)) | 0
  59963. }
  59964. Sha512.prototype._hash = function () {
  59965. var H = Buffer.allocUnsafe(64)
  59966. function writeInt64BE (h, l, offset) {
  59967. H.writeInt32BE(h, offset)
  59968. H.writeInt32BE(l, offset + 4)
  59969. }
  59970. writeInt64BE(this._ah, this._al, 0)
  59971. writeInt64BE(this._bh, this._bl, 8)
  59972. writeInt64BE(this._ch, this._cl, 16)
  59973. writeInt64BE(this._dh, this._dl, 24)
  59974. writeInt64BE(this._eh, this._el, 32)
  59975. writeInt64BE(this._fh, this._fl, 40)
  59976. writeInt64BE(this._gh, this._gl, 48)
  59977. writeInt64BE(this._hh, this._hl, 56)
  59978. return H
  59979. }
  59980. module.exports = Sha512
  59981. /***/ }),
  59982. /***/ "../../node_modules/stream-browserify/index.js":
  59983. /*!*****************************************************!*\
  59984. !*** ../../node_modules/stream-browserify/index.js ***!
  59985. \*****************************************************/
  59986. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  59987. // Copyright Joyent, Inc. and other Node contributors.
  59988. //
  59989. // Permission is hereby granted, free of charge, to any person obtaining a
  59990. // copy of this software and associated documentation files (the
  59991. // "Software"), to deal in the Software without restriction, including
  59992. // without limitation the rights to use, copy, modify, merge, publish,
  59993. // distribute, sublicense, and/or sell copies of the Software, and to permit
  59994. // persons to whom the Software is furnished to do so, subject to the
  59995. // following conditions:
  59996. //
  59997. // The above copyright notice and this permission notice shall be included
  59998. // in all copies or substantial portions of the Software.
  59999. //
  60000. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  60001. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  60002. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  60003. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  60004. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  60005. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  60006. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  60007. module.exports = Stream;
  60008. var EE = (__webpack_require__(/*! events */ "../../node_modules/events/events.js").EventEmitter);
  60009. var inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js");
  60010. inherits(Stream, EE);
  60011. Stream.Readable = __webpack_require__(/*! readable-stream/lib/_stream_readable.js */ "../../node_modules/readable-stream/lib/_stream_readable.js");
  60012. Stream.Writable = __webpack_require__(/*! readable-stream/lib/_stream_writable.js */ "../../node_modules/readable-stream/lib/_stream_writable.js");
  60013. Stream.Duplex = __webpack_require__(/*! readable-stream/lib/_stream_duplex.js */ "../../node_modules/readable-stream/lib/_stream_duplex.js");
  60014. Stream.Transform = __webpack_require__(/*! readable-stream/lib/_stream_transform.js */ "../../node_modules/readable-stream/lib/_stream_transform.js");
  60015. Stream.PassThrough = __webpack_require__(/*! readable-stream/lib/_stream_passthrough.js */ "../../node_modules/readable-stream/lib/_stream_passthrough.js");
  60016. Stream.finished = __webpack_require__(/*! readable-stream/lib/internal/streams/end-of-stream.js */ "../../node_modules/readable-stream/lib/internal/streams/end-of-stream.js")
  60017. Stream.pipeline = __webpack_require__(/*! readable-stream/lib/internal/streams/pipeline.js */ "../../node_modules/readable-stream/lib/internal/streams/pipeline.js")
  60018. // Backwards-compat with node 0.4.x
  60019. Stream.Stream = Stream;
  60020. // old-style streams. Note that the pipe method (the only relevant
  60021. // part of this class) is overridden in the Readable class.
  60022. function Stream() {
  60023. EE.call(this);
  60024. }
  60025. Stream.prototype.pipe = function(dest, options) {
  60026. var source = this;
  60027. function ondata(chunk) {
  60028. if (dest.writable) {
  60029. if (false === dest.write(chunk) && source.pause) {
  60030. source.pause();
  60031. }
  60032. }
  60033. }
  60034. source.on('data', ondata);
  60035. function ondrain() {
  60036. if (source.readable && source.resume) {
  60037. source.resume();
  60038. }
  60039. }
  60040. dest.on('drain', ondrain);
  60041. // If the 'end' option is not supplied, dest.end() will be called when
  60042. // source gets the 'end' or 'close' events. Only dest.end() once.
  60043. if (!dest._isStdio && (!options || options.end !== false)) {
  60044. source.on('end', onend);
  60045. source.on('close', onclose);
  60046. }
  60047. var didOnEnd = false;
  60048. function onend() {
  60049. if (didOnEnd) return;
  60050. didOnEnd = true;
  60051. dest.end();
  60052. }
  60053. function onclose() {
  60054. if (didOnEnd) return;
  60055. didOnEnd = true;
  60056. if (typeof dest.destroy === 'function') dest.destroy();
  60057. }
  60058. // don't leave dangling pipes when there are errors.
  60059. function onerror(er) {
  60060. cleanup();
  60061. if (EE.listenerCount(this, 'error') === 0) {
  60062. throw er; // Unhandled stream error in pipe.
  60063. }
  60064. }
  60065. source.on('error', onerror);
  60066. dest.on('error', onerror);
  60067. // remove all the event listeners that were added.
  60068. function cleanup() {
  60069. source.removeListener('data', ondata);
  60070. dest.removeListener('drain', ondrain);
  60071. source.removeListener('end', onend);
  60072. source.removeListener('close', onclose);
  60073. source.removeListener('error', onerror);
  60074. dest.removeListener('error', onerror);
  60075. source.removeListener('end', cleanup);
  60076. source.removeListener('close', cleanup);
  60077. dest.removeListener('close', cleanup);
  60078. }
  60079. source.on('end', cleanup);
  60080. source.on('close', cleanup);
  60081. dest.on('close', cleanup);
  60082. dest.emit('pipe', source);
  60083. // Allow for unix-like usage: A.pipe(B).pipe(C)
  60084. return dest;
  60085. };
  60086. /***/ }),
  60087. /***/ "../../node_modules/stream-http/index.js":
  60088. /*!***********************************************!*\
  60089. !*** ../../node_modules/stream-http/index.js ***!
  60090. \***********************************************/
  60091. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  60092. var ClientRequest = __webpack_require__(/*! ./lib/request */ "../../node_modules/stream-http/lib/request.js")
  60093. var response = __webpack_require__(/*! ./lib/response */ "../../node_modules/stream-http/lib/response.js")
  60094. var extend = __webpack_require__(/*! xtend */ "../../node_modules/xtend/immutable.js")
  60095. var statusCodes = __webpack_require__(/*! builtin-status-codes */ "../../node_modules/builtin-status-codes/browser.js")
  60096. var url = __webpack_require__(/*! url */ "../../node_modules/url/url.js")
  60097. var http = exports
  60098. http.request = function (opts, cb) {
  60099. if (typeof opts === 'string')
  60100. opts = url.parse(opts)
  60101. else
  60102. opts = extend(opts)
  60103. // Normally, the page is loaded from http or https, so not specifying a protocol
  60104. // will result in a (valid) protocol-relative url. However, this won't work if
  60105. // the protocol is something else, like 'file:'
  60106. var defaultProtocol = __webpack_require__.g.location.protocol.search(/^https?:$/) === -1 ? 'http:' : ''
  60107. var protocol = opts.protocol || defaultProtocol
  60108. var host = opts.hostname || opts.host
  60109. var port = opts.port
  60110. var path = opts.path || '/'
  60111. // Necessary for IPv6 addresses
  60112. if (host && host.indexOf(':') !== -1)
  60113. host = '[' + host + ']'
  60114. // This may be a relative url. The browser should always be able to interpret it correctly.
  60115. opts.url = (host ? (protocol + '//' + host) : '') + (port ? ':' + port : '') + path
  60116. opts.method = (opts.method || 'GET').toUpperCase()
  60117. opts.headers = opts.headers || {}
  60118. // Also valid opts.auth, opts.mode
  60119. var req = new ClientRequest(opts)
  60120. if (cb)
  60121. req.on('response', cb)
  60122. return req
  60123. }
  60124. http.get = function get (opts, cb) {
  60125. var req = http.request(opts, cb)
  60126. req.end()
  60127. return req
  60128. }
  60129. http.ClientRequest = ClientRequest
  60130. http.IncomingMessage = response.IncomingMessage
  60131. http.Agent = function () {}
  60132. http.Agent.defaultMaxSockets = 4
  60133. http.globalAgent = new http.Agent()
  60134. http.STATUS_CODES = statusCodes
  60135. http.METHODS = [
  60136. 'CHECKOUT',
  60137. 'CONNECT',
  60138. 'COPY',
  60139. 'DELETE',
  60140. 'GET',
  60141. 'HEAD',
  60142. 'LOCK',
  60143. 'M-SEARCH',
  60144. 'MERGE',
  60145. 'MKACTIVITY',
  60146. 'MKCOL',
  60147. 'MOVE',
  60148. 'NOTIFY',
  60149. 'OPTIONS',
  60150. 'PATCH',
  60151. 'POST',
  60152. 'PROPFIND',
  60153. 'PROPPATCH',
  60154. 'PURGE',
  60155. 'PUT',
  60156. 'REPORT',
  60157. 'SEARCH',
  60158. 'SUBSCRIBE',
  60159. 'TRACE',
  60160. 'UNLOCK',
  60161. 'UNSUBSCRIBE'
  60162. ]
  60163. /***/ }),
  60164. /***/ "../../node_modules/stream-http/lib/capability.js":
  60165. /*!********************************************************!*\
  60166. !*** ../../node_modules/stream-http/lib/capability.js ***!
  60167. \********************************************************/
  60168. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  60169. exports.fetch = isFunction(__webpack_require__.g.fetch) && isFunction(__webpack_require__.g.ReadableStream)
  60170. exports.writableStream = isFunction(__webpack_require__.g.WritableStream)
  60171. exports.abortController = isFunction(__webpack_require__.g.AbortController)
  60172. // The xhr request to example.com may violate some restrictive CSP configurations,
  60173. // so if we're running in a browser that supports `fetch`, avoid calling getXHR()
  60174. // and assume support for certain features below.
  60175. var xhr
  60176. function getXHR () {
  60177. // Cache the xhr value
  60178. if (xhr !== undefined) return xhr
  60179. if (__webpack_require__.g.XMLHttpRequest) {
  60180. xhr = new __webpack_require__.g.XMLHttpRequest()
  60181. // If XDomainRequest is available (ie only, where xhr might not work
  60182. // cross domain), use the page location. Otherwise use example.com
  60183. // Note: this doesn't actually make an http request.
  60184. try {
  60185. xhr.open('GET', __webpack_require__.g.XDomainRequest ? '/' : 'https://example.com')
  60186. } catch(e) {
  60187. xhr = null
  60188. }
  60189. } else {
  60190. // Service workers don't have XHR
  60191. xhr = null
  60192. }
  60193. return xhr
  60194. }
  60195. function checkTypeSupport (type) {
  60196. var xhr = getXHR()
  60197. if (!xhr) return false
  60198. try {
  60199. xhr.responseType = type
  60200. return xhr.responseType === type
  60201. } catch (e) {}
  60202. return false
  60203. }
  60204. // If fetch is supported, then arraybuffer will be supported too. Skip calling
  60205. // checkTypeSupport(), since that calls getXHR().
  60206. exports.arraybuffer = exports.fetch || checkTypeSupport('arraybuffer')
  60207. // These next two tests unavoidably show warnings in Chrome. Since fetch will always
  60208. // be used if it's available, just return false for these to avoid the warnings.
  60209. exports.msstream = !exports.fetch && checkTypeSupport('ms-stream')
  60210. exports.mozchunkedarraybuffer = !exports.fetch && checkTypeSupport('moz-chunked-arraybuffer')
  60211. // If fetch is supported, then overrideMimeType will be supported too. Skip calling
  60212. // getXHR().
  60213. exports.overrideMimeType = exports.fetch || (getXHR() ? isFunction(getXHR().overrideMimeType) : false)
  60214. function isFunction (value) {
  60215. return typeof value === 'function'
  60216. }
  60217. xhr = null // Help gc
  60218. /***/ }),
  60219. /***/ "../../node_modules/stream-http/lib/request.js":
  60220. /*!*****************************************************!*\
  60221. !*** ../../node_modules/stream-http/lib/request.js ***!
  60222. \*****************************************************/
  60223. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  60224. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js")["Buffer"];
  60225. /* provided dependency */ var process = __webpack_require__(/*! process/browser */ "../../node_modules/process/browser.js");
  60226. var capability = __webpack_require__(/*! ./capability */ "../../node_modules/stream-http/lib/capability.js")
  60227. var inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js")
  60228. var response = __webpack_require__(/*! ./response */ "../../node_modules/stream-http/lib/response.js")
  60229. var stream = __webpack_require__(/*! readable-stream */ "../../node_modules/readable-stream/readable-browser.js")
  60230. var IncomingMessage = response.IncomingMessage
  60231. var rStates = response.readyStates
  60232. function decideMode (preferBinary, useFetch) {
  60233. if (capability.fetch && useFetch) {
  60234. return 'fetch'
  60235. } else if (capability.mozchunkedarraybuffer) {
  60236. return 'moz-chunked-arraybuffer'
  60237. } else if (capability.msstream) {
  60238. return 'ms-stream'
  60239. } else if (capability.arraybuffer && preferBinary) {
  60240. return 'arraybuffer'
  60241. } else {
  60242. return 'text'
  60243. }
  60244. }
  60245. var ClientRequest = module.exports = function (opts) {
  60246. var self = this
  60247. stream.Writable.call(self)
  60248. self._opts = opts
  60249. self._body = []
  60250. self._headers = {}
  60251. if (opts.auth)
  60252. self.setHeader('Authorization', 'Basic ' + Buffer.from(opts.auth).toString('base64'))
  60253. Object.keys(opts.headers).forEach(function (name) {
  60254. self.setHeader(name, opts.headers[name])
  60255. })
  60256. var preferBinary
  60257. var useFetch = true
  60258. if (opts.mode === 'disable-fetch' || ('requestTimeout' in opts && !capability.abortController)) {
  60259. // If the use of XHR should be preferred. Not typically needed.
  60260. useFetch = false
  60261. preferBinary = true
  60262. } else if (opts.mode === 'prefer-streaming') {
  60263. // If streaming is a high priority but binary compatibility and
  60264. // the accuracy of the 'content-type' header aren't
  60265. preferBinary = false
  60266. } else if (opts.mode === 'allow-wrong-content-type') {
  60267. // If streaming is more important than preserving the 'content-type' header
  60268. preferBinary = !capability.overrideMimeType
  60269. } else if (!opts.mode || opts.mode === 'default' || opts.mode === 'prefer-fast') {
  60270. // Use binary if text streaming may corrupt data or the content-type header, or for speed
  60271. preferBinary = true
  60272. } else {
  60273. throw new Error('Invalid value for opts.mode')
  60274. }
  60275. self._mode = decideMode(preferBinary, useFetch)
  60276. self._fetchTimer = null
  60277. self._socketTimeout = null
  60278. self._socketTimer = null
  60279. self.on('finish', function () {
  60280. self._onFinish()
  60281. })
  60282. }
  60283. inherits(ClientRequest, stream.Writable)
  60284. ClientRequest.prototype.setHeader = function (name, value) {
  60285. var self = this
  60286. var lowerName = name.toLowerCase()
  60287. // This check is not necessary, but it prevents warnings from browsers about setting unsafe
  60288. // headers. To be honest I'm not entirely sure hiding these warnings is a good thing, but
  60289. // http-browserify did it, so I will too.
  60290. if (unsafeHeaders.indexOf(lowerName) !== -1)
  60291. return
  60292. self._headers[lowerName] = {
  60293. name: name,
  60294. value: value
  60295. }
  60296. }
  60297. ClientRequest.prototype.getHeader = function (name) {
  60298. var header = this._headers[name.toLowerCase()]
  60299. if (header)
  60300. return header.value
  60301. return null
  60302. }
  60303. ClientRequest.prototype.removeHeader = function (name) {
  60304. var self = this
  60305. delete self._headers[name.toLowerCase()]
  60306. }
  60307. ClientRequest.prototype._onFinish = function () {
  60308. var self = this
  60309. if (self._destroyed)
  60310. return
  60311. var opts = self._opts
  60312. if ('timeout' in opts && opts.timeout !== 0) {
  60313. self.setTimeout(opts.timeout)
  60314. }
  60315. var headersObj = self._headers
  60316. var body = null
  60317. if (opts.method !== 'GET' && opts.method !== 'HEAD') {
  60318. body = new Blob(self._body, {
  60319. type: (headersObj['content-type'] || {}).value || ''
  60320. });
  60321. }
  60322. // create flattened list of headers
  60323. var headersList = []
  60324. Object.keys(headersObj).forEach(function (keyName) {
  60325. var name = headersObj[keyName].name
  60326. var value = headersObj[keyName].value
  60327. if (Array.isArray(value)) {
  60328. value.forEach(function (v) {
  60329. headersList.push([name, v])
  60330. })
  60331. } else {
  60332. headersList.push([name, value])
  60333. }
  60334. })
  60335. if (self._mode === 'fetch') {
  60336. var signal = null
  60337. if (capability.abortController) {
  60338. var controller = new AbortController()
  60339. signal = controller.signal
  60340. self._fetchAbortController = controller
  60341. if ('requestTimeout' in opts && opts.requestTimeout !== 0) {
  60342. self._fetchTimer = __webpack_require__.g.setTimeout(function () {
  60343. self.emit('requestTimeout')
  60344. if (self._fetchAbortController)
  60345. self._fetchAbortController.abort()
  60346. }, opts.requestTimeout)
  60347. }
  60348. }
  60349. __webpack_require__.g.fetch(self._opts.url, {
  60350. method: self._opts.method,
  60351. headers: headersList,
  60352. body: body || undefined,
  60353. mode: 'cors',
  60354. credentials: opts.withCredentials ? 'include' : 'same-origin',
  60355. signal: signal
  60356. }).then(function (response) {
  60357. self._fetchResponse = response
  60358. self._resetTimers(false)
  60359. self._connect()
  60360. }, function (reason) {
  60361. self._resetTimers(true)
  60362. if (!self._destroyed)
  60363. self.emit('error', reason)
  60364. })
  60365. } else {
  60366. var xhr = self._xhr = new __webpack_require__.g.XMLHttpRequest()
  60367. try {
  60368. xhr.open(self._opts.method, self._opts.url, true)
  60369. } catch (err) {
  60370. process.nextTick(function () {
  60371. self.emit('error', err)
  60372. })
  60373. return
  60374. }
  60375. // Can't set responseType on really old browsers
  60376. if ('responseType' in xhr)
  60377. xhr.responseType = self._mode
  60378. if ('withCredentials' in xhr)
  60379. xhr.withCredentials = !!opts.withCredentials
  60380. if (self._mode === 'text' && 'overrideMimeType' in xhr)
  60381. xhr.overrideMimeType('text/plain; charset=x-user-defined')
  60382. if ('requestTimeout' in opts) {
  60383. xhr.timeout = opts.requestTimeout
  60384. xhr.ontimeout = function () {
  60385. self.emit('requestTimeout')
  60386. }
  60387. }
  60388. headersList.forEach(function (header) {
  60389. xhr.setRequestHeader(header[0], header[1])
  60390. })
  60391. self._response = null
  60392. xhr.onreadystatechange = function () {
  60393. switch (xhr.readyState) {
  60394. case rStates.LOADING:
  60395. case rStates.DONE:
  60396. self._onXHRProgress()
  60397. break
  60398. }
  60399. }
  60400. // Necessary for streaming in Firefox, since xhr.response is ONLY defined
  60401. // in onprogress, not in onreadystatechange with xhr.readyState = 3
  60402. if (self._mode === 'moz-chunked-arraybuffer') {
  60403. xhr.onprogress = function () {
  60404. self._onXHRProgress()
  60405. }
  60406. }
  60407. xhr.onerror = function () {
  60408. if (self._destroyed)
  60409. return
  60410. self._resetTimers(true)
  60411. self.emit('error', new Error('XHR error'))
  60412. }
  60413. try {
  60414. xhr.send(body)
  60415. } catch (err) {
  60416. process.nextTick(function () {
  60417. self.emit('error', err)
  60418. })
  60419. return
  60420. }
  60421. }
  60422. }
  60423. /**
  60424. * Checks if xhr.status is readable and non-zero, indicating no error.
  60425. * Even though the spec says it should be available in readyState 3,
  60426. * accessing it throws an exception in IE8
  60427. */
  60428. function statusValid (xhr) {
  60429. try {
  60430. var status = xhr.status
  60431. return (status !== null && status !== 0)
  60432. } catch (e) {
  60433. return false
  60434. }
  60435. }
  60436. ClientRequest.prototype._onXHRProgress = function () {
  60437. var self = this
  60438. self._resetTimers(false)
  60439. if (!statusValid(self._xhr) || self._destroyed)
  60440. return
  60441. if (!self._response)
  60442. self._connect()
  60443. self._response._onXHRProgress(self._resetTimers.bind(self))
  60444. }
  60445. ClientRequest.prototype._connect = function () {
  60446. var self = this
  60447. if (self._destroyed)
  60448. return
  60449. self._response = new IncomingMessage(self._xhr, self._fetchResponse, self._mode, self._resetTimers.bind(self))
  60450. self._response.on('error', function(err) {
  60451. self.emit('error', err)
  60452. })
  60453. self.emit('response', self._response)
  60454. }
  60455. ClientRequest.prototype._write = function (chunk, encoding, cb) {
  60456. var self = this
  60457. self._body.push(chunk)
  60458. cb()
  60459. }
  60460. ClientRequest.prototype._resetTimers = function (done) {
  60461. var self = this
  60462. __webpack_require__.g.clearTimeout(self._socketTimer)
  60463. self._socketTimer = null
  60464. if (done) {
  60465. __webpack_require__.g.clearTimeout(self._fetchTimer)
  60466. self._fetchTimer = null
  60467. } else if (self._socketTimeout) {
  60468. self._socketTimer = __webpack_require__.g.setTimeout(function () {
  60469. self.emit('timeout')
  60470. }, self._socketTimeout)
  60471. }
  60472. }
  60473. ClientRequest.prototype.abort = ClientRequest.prototype.destroy = function (err) {
  60474. var self = this
  60475. self._destroyed = true
  60476. self._resetTimers(true)
  60477. if (self._response)
  60478. self._response._destroyed = true
  60479. if (self._xhr)
  60480. self._xhr.abort()
  60481. else if (self._fetchAbortController)
  60482. self._fetchAbortController.abort()
  60483. if (err)
  60484. self.emit('error', err)
  60485. }
  60486. ClientRequest.prototype.end = function (data, encoding, cb) {
  60487. var self = this
  60488. if (typeof data === 'function') {
  60489. cb = data
  60490. data = undefined
  60491. }
  60492. stream.Writable.prototype.end.call(self, data, encoding, cb)
  60493. }
  60494. ClientRequest.prototype.setTimeout = function (timeout, cb) {
  60495. var self = this
  60496. if (cb)
  60497. self.once('timeout', cb)
  60498. self._socketTimeout = timeout
  60499. self._resetTimers(false)
  60500. }
  60501. ClientRequest.prototype.flushHeaders = function () {}
  60502. ClientRequest.prototype.setNoDelay = function () {}
  60503. ClientRequest.prototype.setSocketKeepAlive = function () {}
  60504. // Taken from http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader%28%29-method
  60505. var unsafeHeaders = [
  60506. 'accept-charset',
  60507. 'accept-encoding',
  60508. 'access-control-request-headers',
  60509. 'access-control-request-method',
  60510. 'connection',
  60511. 'content-length',
  60512. 'cookie',
  60513. 'cookie2',
  60514. 'date',
  60515. 'dnt',
  60516. 'expect',
  60517. 'host',
  60518. 'keep-alive',
  60519. 'origin',
  60520. 'referer',
  60521. 'te',
  60522. 'trailer',
  60523. 'transfer-encoding',
  60524. 'upgrade',
  60525. 'via'
  60526. ]
  60527. /***/ }),
  60528. /***/ "../../node_modules/stream-http/lib/response.js":
  60529. /*!******************************************************!*\
  60530. !*** ../../node_modules/stream-http/lib/response.js ***!
  60531. \******************************************************/
  60532. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  60533. /* provided dependency */ var process = __webpack_require__(/*! process/browser */ "../../node_modules/process/browser.js");
  60534. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js")["Buffer"];
  60535. var capability = __webpack_require__(/*! ./capability */ "../../node_modules/stream-http/lib/capability.js")
  60536. var inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js")
  60537. var stream = __webpack_require__(/*! readable-stream */ "../../node_modules/readable-stream/readable-browser.js")
  60538. var rStates = exports.readyStates = {
  60539. UNSENT: 0,
  60540. OPENED: 1,
  60541. HEADERS_RECEIVED: 2,
  60542. LOADING: 3,
  60543. DONE: 4
  60544. }
  60545. var IncomingMessage = exports.IncomingMessage = function (xhr, response, mode, resetTimers) {
  60546. var self = this
  60547. stream.Readable.call(self)
  60548. self._mode = mode
  60549. self.headers = {}
  60550. self.rawHeaders = []
  60551. self.trailers = {}
  60552. self.rawTrailers = []
  60553. // Fake the 'close' event, but only once 'end' fires
  60554. self.on('end', function () {
  60555. // The nextTick is necessary to prevent the 'request' module from causing an infinite loop
  60556. process.nextTick(function () {
  60557. self.emit('close')
  60558. })
  60559. })
  60560. if (mode === 'fetch') {
  60561. self._fetchResponse = response
  60562. self.url = response.url
  60563. self.statusCode = response.status
  60564. self.statusMessage = response.statusText
  60565. response.headers.forEach(function (header, key){
  60566. self.headers[key.toLowerCase()] = header
  60567. self.rawHeaders.push(key, header)
  60568. })
  60569. if (capability.writableStream) {
  60570. var writable = new WritableStream({
  60571. write: function (chunk) {
  60572. resetTimers(false)
  60573. return new Promise(function (resolve, reject) {
  60574. if (self._destroyed) {
  60575. reject()
  60576. } else if(self.push(Buffer.from(chunk))) {
  60577. resolve()
  60578. } else {
  60579. self._resumeFetch = resolve
  60580. }
  60581. })
  60582. },
  60583. close: function () {
  60584. resetTimers(true)
  60585. if (!self._destroyed)
  60586. self.push(null)
  60587. },
  60588. abort: function (err) {
  60589. resetTimers(true)
  60590. if (!self._destroyed)
  60591. self.emit('error', err)
  60592. }
  60593. })
  60594. try {
  60595. response.body.pipeTo(writable).catch(function (err) {
  60596. resetTimers(true)
  60597. if (!self._destroyed)
  60598. self.emit('error', err)
  60599. })
  60600. return
  60601. } catch (e) {} // pipeTo method isn't defined. Can't find a better way to feature test this
  60602. }
  60603. // fallback for when writableStream or pipeTo aren't available
  60604. var reader = response.body.getReader()
  60605. function read () {
  60606. reader.read().then(function (result) {
  60607. if (self._destroyed)
  60608. return
  60609. resetTimers(result.done)
  60610. if (result.done) {
  60611. self.push(null)
  60612. return
  60613. }
  60614. self.push(Buffer.from(result.value))
  60615. read()
  60616. }).catch(function (err) {
  60617. resetTimers(true)
  60618. if (!self._destroyed)
  60619. self.emit('error', err)
  60620. })
  60621. }
  60622. read()
  60623. } else {
  60624. self._xhr = xhr
  60625. self._pos = 0
  60626. self.url = xhr.responseURL
  60627. self.statusCode = xhr.status
  60628. self.statusMessage = xhr.statusText
  60629. var headers = xhr.getAllResponseHeaders().split(/\r?\n/)
  60630. headers.forEach(function (header) {
  60631. var matches = header.match(/^([^:]+):\s*(.*)/)
  60632. if (matches) {
  60633. var key = matches[1].toLowerCase()
  60634. if (key === 'set-cookie') {
  60635. if (self.headers[key] === undefined) {
  60636. self.headers[key] = []
  60637. }
  60638. self.headers[key].push(matches[2])
  60639. } else if (self.headers[key] !== undefined) {
  60640. self.headers[key] += ', ' + matches[2]
  60641. } else {
  60642. self.headers[key] = matches[2]
  60643. }
  60644. self.rawHeaders.push(matches[1], matches[2])
  60645. }
  60646. })
  60647. self._charset = 'x-user-defined'
  60648. if (!capability.overrideMimeType) {
  60649. var mimeType = self.rawHeaders['mime-type']
  60650. if (mimeType) {
  60651. var charsetMatch = mimeType.match(/;\s*charset=([^;])(;|$)/)
  60652. if (charsetMatch) {
  60653. self._charset = charsetMatch[1].toLowerCase()
  60654. }
  60655. }
  60656. if (!self._charset)
  60657. self._charset = 'utf-8' // best guess
  60658. }
  60659. }
  60660. }
  60661. inherits(IncomingMessage, stream.Readable)
  60662. IncomingMessage.prototype._read = function () {
  60663. var self = this
  60664. var resolve = self._resumeFetch
  60665. if (resolve) {
  60666. self._resumeFetch = null
  60667. resolve()
  60668. }
  60669. }
  60670. IncomingMessage.prototype._onXHRProgress = function (resetTimers) {
  60671. var self = this
  60672. var xhr = self._xhr
  60673. var response = null
  60674. switch (self._mode) {
  60675. case 'text':
  60676. response = xhr.responseText
  60677. if (response.length > self._pos) {
  60678. var newData = response.substr(self._pos)
  60679. if (self._charset === 'x-user-defined') {
  60680. var buffer = Buffer.alloc(newData.length)
  60681. for (var i = 0; i < newData.length; i++)
  60682. buffer[i] = newData.charCodeAt(i) & 0xff
  60683. self.push(buffer)
  60684. } else {
  60685. self.push(newData, self._charset)
  60686. }
  60687. self._pos = response.length
  60688. }
  60689. break
  60690. case 'arraybuffer':
  60691. if (xhr.readyState !== rStates.DONE || !xhr.response)
  60692. break
  60693. response = xhr.response
  60694. self.push(Buffer.from(new Uint8Array(response)))
  60695. break
  60696. case 'moz-chunked-arraybuffer': // take whole
  60697. response = xhr.response
  60698. if (xhr.readyState !== rStates.LOADING || !response)
  60699. break
  60700. self.push(Buffer.from(new Uint8Array(response)))
  60701. break
  60702. case 'ms-stream':
  60703. response = xhr.response
  60704. if (xhr.readyState !== rStates.LOADING)
  60705. break
  60706. var reader = new __webpack_require__.g.MSStreamReader()
  60707. reader.onprogress = function () {
  60708. if (reader.result.byteLength > self._pos) {
  60709. self.push(Buffer.from(new Uint8Array(reader.result.slice(self._pos))))
  60710. self._pos = reader.result.byteLength
  60711. }
  60712. }
  60713. reader.onload = function () {
  60714. resetTimers(true)
  60715. self.push(null)
  60716. }
  60717. // reader.onerror = ??? // TODO: this
  60718. reader.readAsArrayBuffer(response)
  60719. break
  60720. }
  60721. // The ms-stream case handles end separately in reader.onload()
  60722. if (self._xhr.readyState === rStates.DONE && self._mode !== 'ms-stream') {
  60723. resetTimers(true)
  60724. self.push(null)
  60725. }
  60726. }
  60727. /***/ }),
  60728. /***/ "../../node_modules/string_decoder/lib/string_decoder.js":
  60729. /*!***************************************************************!*\
  60730. !*** ../../node_modules/string_decoder/lib/string_decoder.js ***!
  60731. \***************************************************************/
  60732. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  60733. "use strict";
  60734. // Copyright Joyent, Inc. and other Node contributors.
  60735. //
  60736. // Permission is hereby granted, free of charge, to any person obtaining a
  60737. // copy of this software and associated documentation files (the
  60738. // "Software"), to deal in the Software without restriction, including
  60739. // without limitation the rights to use, copy, modify, merge, publish,
  60740. // distribute, sublicense, and/or sell copies of the Software, and to permit
  60741. // persons to whom the Software is furnished to do so, subject to the
  60742. // following conditions:
  60743. //
  60744. // The above copyright notice and this permission notice shall be included
  60745. // in all copies or substantial portions of the Software.
  60746. //
  60747. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  60748. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  60749. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  60750. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  60751. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  60752. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  60753. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  60754. /*<replacement>*/
  60755. var Buffer = (__webpack_require__(/*! safe-buffer */ "../../node_modules/safe-buffer/index.js").Buffer);
  60756. /*</replacement>*/
  60757. var isEncoding = Buffer.isEncoding || function (encoding) {
  60758. encoding = '' + encoding;
  60759. switch (encoding && encoding.toLowerCase()) {
  60760. case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
  60761. return true;
  60762. default:
  60763. return false;
  60764. }
  60765. };
  60766. function _normalizeEncoding(enc) {
  60767. if (!enc) return 'utf8';
  60768. var retried;
  60769. while (true) {
  60770. switch (enc) {
  60771. case 'utf8':
  60772. case 'utf-8':
  60773. return 'utf8';
  60774. case 'ucs2':
  60775. case 'ucs-2':
  60776. case 'utf16le':
  60777. case 'utf-16le':
  60778. return 'utf16le';
  60779. case 'latin1':
  60780. case 'binary':
  60781. return 'latin1';
  60782. case 'base64':
  60783. case 'ascii':
  60784. case 'hex':
  60785. return enc;
  60786. default:
  60787. if (retried) return; // undefined
  60788. enc = ('' + enc).toLowerCase();
  60789. retried = true;
  60790. }
  60791. }
  60792. };
  60793. // Do not cache `Buffer.isEncoding` when checking encoding names as some
  60794. // modules monkey-patch it to support additional encodings
  60795. function normalizeEncoding(enc) {
  60796. var nenc = _normalizeEncoding(enc);
  60797. if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
  60798. return nenc || enc;
  60799. }
  60800. // StringDecoder provides an interface for efficiently splitting a series of
  60801. // buffers into a series of JS strings without breaking apart multi-byte
  60802. // characters.
  60803. exports.StringDecoder = StringDecoder;
  60804. function StringDecoder(encoding) {
  60805. this.encoding = normalizeEncoding(encoding);
  60806. var nb;
  60807. switch (this.encoding) {
  60808. case 'utf16le':
  60809. this.text = utf16Text;
  60810. this.end = utf16End;
  60811. nb = 4;
  60812. break;
  60813. case 'utf8':
  60814. this.fillLast = utf8FillLast;
  60815. nb = 4;
  60816. break;
  60817. case 'base64':
  60818. this.text = base64Text;
  60819. this.end = base64End;
  60820. nb = 3;
  60821. break;
  60822. default:
  60823. this.write = simpleWrite;
  60824. this.end = simpleEnd;
  60825. return;
  60826. }
  60827. this.lastNeed = 0;
  60828. this.lastTotal = 0;
  60829. this.lastChar = Buffer.allocUnsafe(nb);
  60830. }
  60831. StringDecoder.prototype.write = function (buf) {
  60832. if (buf.length === 0) return '';
  60833. var r;
  60834. var i;
  60835. if (this.lastNeed) {
  60836. r = this.fillLast(buf);
  60837. if (r === undefined) return '';
  60838. i = this.lastNeed;
  60839. this.lastNeed = 0;
  60840. } else {
  60841. i = 0;
  60842. }
  60843. if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
  60844. return r || '';
  60845. };
  60846. StringDecoder.prototype.end = utf8End;
  60847. // Returns only complete characters in a Buffer
  60848. StringDecoder.prototype.text = utf8Text;
  60849. // Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
  60850. StringDecoder.prototype.fillLast = function (buf) {
  60851. if (this.lastNeed <= buf.length) {
  60852. buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
  60853. return this.lastChar.toString(this.encoding, 0, this.lastTotal);
  60854. }
  60855. buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
  60856. this.lastNeed -= buf.length;
  60857. };
  60858. // Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
  60859. // continuation byte. If an invalid byte is detected, -2 is returned.
  60860. function utf8CheckByte(byte) {
  60861. if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
  60862. return byte >> 6 === 0x02 ? -1 : -2;
  60863. }
  60864. // Checks at most 3 bytes at the end of a Buffer in order to detect an
  60865. // incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
  60866. // needed to complete the UTF-8 character (if applicable) are returned.
  60867. function utf8CheckIncomplete(self, buf, i) {
  60868. var j = buf.length - 1;
  60869. if (j < i) return 0;
  60870. var nb = utf8CheckByte(buf[j]);
  60871. if (nb >= 0) {
  60872. if (nb > 0) self.lastNeed = nb - 1;
  60873. return nb;
  60874. }
  60875. if (--j < i || nb === -2) return 0;
  60876. nb = utf8CheckByte(buf[j]);
  60877. if (nb >= 0) {
  60878. if (nb > 0) self.lastNeed = nb - 2;
  60879. return nb;
  60880. }
  60881. if (--j < i || nb === -2) return 0;
  60882. nb = utf8CheckByte(buf[j]);
  60883. if (nb >= 0) {
  60884. if (nb > 0) {
  60885. if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
  60886. }
  60887. return nb;
  60888. }
  60889. return 0;
  60890. }
  60891. // Validates as many continuation bytes for a multi-byte UTF-8 character as
  60892. // needed or are available. If we see a non-continuation byte where we expect
  60893. // one, we "replace" the validated continuation bytes we've seen so far with
  60894. // a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
  60895. // behavior. The continuation byte check is included three times in the case
  60896. // where all of the continuation bytes for a character exist in the same buffer.
  60897. // It is also done this way as a slight performance increase instead of using a
  60898. // loop.
  60899. function utf8CheckExtraBytes(self, buf, p) {
  60900. if ((buf[0] & 0xC0) !== 0x80) {
  60901. self.lastNeed = 0;
  60902. return '\ufffd';
  60903. }
  60904. if (self.lastNeed > 1 && buf.length > 1) {
  60905. if ((buf[1] & 0xC0) !== 0x80) {
  60906. self.lastNeed = 1;
  60907. return '\ufffd';
  60908. }
  60909. if (self.lastNeed > 2 && buf.length > 2) {
  60910. if ((buf[2] & 0xC0) !== 0x80) {
  60911. self.lastNeed = 2;
  60912. return '\ufffd';
  60913. }
  60914. }
  60915. }
  60916. }
  60917. // Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
  60918. function utf8FillLast(buf) {
  60919. var p = this.lastTotal - this.lastNeed;
  60920. var r = utf8CheckExtraBytes(this, buf, p);
  60921. if (r !== undefined) return r;
  60922. if (this.lastNeed <= buf.length) {
  60923. buf.copy(this.lastChar, p, 0, this.lastNeed);
  60924. return this.lastChar.toString(this.encoding, 0, this.lastTotal);
  60925. }
  60926. buf.copy(this.lastChar, p, 0, buf.length);
  60927. this.lastNeed -= buf.length;
  60928. }
  60929. // Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
  60930. // partial character, the character's bytes are buffered until the required
  60931. // number of bytes are available.
  60932. function utf8Text(buf, i) {
  60933. var total = utf8CheckIncomplete(this, buf, i);
  60934. if (!this.lastNeed) return buf.toString('utf8', i);
  60935. this.lastTotal = total;
  60936. var end = buf.length - (total - this.lastNeed);
  60937. buf.copy(this.lastChar, 0, end);
  60938. return buf.toString('utf8', i, end);
  60939. }
  60940. // For UTF-8, a replacement character is added when ending on a partial
  60941. // character.
  60942. function utf8End(buf) {
  60943. var r = buf && buf.length ? this.write(buf) : '';
  60944. if (this.lastNeed) return r + '\ufffd';
  60945. return r;
  60946. }
  60947. // UTF-16LE typically needs two bytes per character, but even if we have an even
  60948. // number of bytes available, we need to check if we end on a leading/high
  60949. // surrogate. In that case, we need to wait for the next two bytes in order to
  60950. // decode the last character properly.
  60951. function utf16Text(buf, i) {
  60952. if ((buf.length - i) % 2 === 0) {
  60953. var r = buf.toString('utf16le', i);
  60954. if (r) {
  60955. var c = r.charCodeAt(r.length - 1);
  60956. if (c >= 0xD800 && c <= 0xDBFF) {
  60957. this.lastNeed = 2;
  60958. this.lastTotal = 4;
  60959. this.lastChar[0] = buf[buf.length - 2];
  60960. this.lastChar[1] = buf[buf.length - 1];
  60961. return r.slice(0, -1);
  60962. }
  60963. }
  60964. return r;
  60965. }
  60966. this.lastNeed = 1;
  60967. this.lastTotal = 2;
  60968. this.lastChar[0] = buf[buf.length - 1];
  60969. return buf.toString('utf16le', i, buf.length - 1);
  60970. }
  60971. // For UTF-16LE we do not explicitly append special replacement characters if we
  60972. // end on a partial character, we simply let v8 handle that.
  60973. function utf16End(buf) {
  60974. var r = buf && buf.length ? this.write(buf) : '';
  60975. if (this.lastNeed) {
  60976. var end = this.lastTotal - this.lastNeed;
  60977. return r + this.lastChar.toString('utf16le', 0, end);
  60978. }
  60979. return r;
  60980. }
  60981. function base64Text(buf, i) {
  60982. var n = (buf.length - i) % 3;
  60983. if (n === 0) return buf.toString('base64', i);
  60984. this.lastNeed = 3 - n;
  60985. this.lastTotal = 3;
  60986. if (n === 1) {
  60987. this.lastChar[0] = buf[buf.length - 1];
  60988. } else {
  60989. this.lastChar[0] = buf[buf.length - 2];
  60990. this.lastChar[1] = buf[buf.length - 1];
  60991. }
  60992. return buf.toString('base64', i, buf.length - n);
  60993. }
  60994. function base64End(buf) {
  60995. var r = buf && buf.length ? this.write(buf) : '';
  60996. if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
  60997. return r;
  60998. }
  60999. // Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
  61000. function simpleWrite(buf) {
  61001. return buf.toString(this.encoding);
  61002. }
  61003. function simpleEnd(buf) {
  61004. return buf && buf.length ? this.write(buf) : '';
  61005. }
  61006. /***/ }),
  61007. /***/ "../../node_modules/tiny-secp256k1/js.js":
  61008. /*!***********************************************!*\
  61009. !*** ../../node_modules/tiny-secp256k1/js.js ***!
  61010. \***********************************************/
  61011. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  61012. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js")["Buffer"];
  61013. const BN = __webpack_require__(/*! bn.js */ "../../node_modules/diffie-hellman/node_modules/bn.js/lib/bn.js")
  61014. const EC = (__webpack_require__(/*! elliptic */ "../../node_modules/elliptic/lib/elliptic.js").ec)
  61015. const secp256k1 = new EC('secp256k1')
  61016. const deterministicGenerateK = __webpack_require__(/*! ./rfc6979 */ "../../node_modules/tiny-secp256k1/rfc6979.js")
  61017. const ZERO32 = Buffer.alloc(32, 0)
  61018. const EC_GROUP_ORDER = Buffer.from('fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141', 'hex')
  61019. const EC_P = Buffer.from('fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f', 'hex')
  61020. const n = secp256k1.curve.n
  61021. const nDiv2 = n.shrn(1)
  61022. const G = secp256k1.curve.g
  61023. const THROW_BAD_PRIVATE = 'Expected Private'
  61024. const THROW_BAD_POINT = 'Expected Point'
  61025. const THROW_BAD_TWEAK = 'Expected Tweak'
  61026. const THROW_BAD_HASH = 'Expected Hash'
  61027. const THROW_BAD_SIGNATURE = 'Expected Signature'
  61028. const THROW_BAD_EXTRA_DATA = 'Expected Extra Data (32 bytes)'
  61029. function isScalar (x) {
  61030. return Buffer.isBuffer(x) && x.length === 32
  61031. }
  61032. function isOrderScalar (x) {
  61033. if (!isScalar(x)) return false
  61034. return x.compare(EC_GROUP_ORDER) < 0 // < G
  61035. }
  61036. function isPoint (p) {
  61037. if (!Buffer.isBuffer(p)) return false
  61038. if (p.length < 33) return false
  61039. const t = p[0]
  61040. const x = p.slice(1, 33)
  61041. if (x.compare(ZERO32) === 0) return false
  61042. if (x.compare(EC_P) >= 0) return false
  61043. if ((t === 0x02 || t === 0x03) && p.length === 33) {
  61044. try { decodeFrom(p) } catch (e) { return false } // TODO: temporary
  61045. return true
  61046. }
  61047. const y = p.slice(33)
  61048. if (y.compare(ZERO32) === 0) return false
  61049. if (y.compare(EC_P) >= 0) return false
  61050. if (t === 0x04 && p.length === 65) return true
  61051. return false
  61052. }
  61053. function __isPointCompressed (p) {
  61054. return p[0] !== 0x04
  61055. }
  61056. function isPointCompressed (p) {
  61057. if (!isPoint(p)) return false
  61058. return __isPointCompressed(p)
  61059. }
  61060. function isPrivate (x) {
  61061. if (!isScalar(x)) return false
  61062. return x.compare(ZERO32) > 0 && // > 0
  61063. x.compare(EC_GROUP_ORDER) < 0 // < G
  61064. }
  61065. function isSignature (value) {
  61066. const r = value.slice(0, 32)
  61067. const s = value.slice(32, 64)
  61068. return Buffer.isBuffer(value) && value.length === 64 &&
  61069. r.compare(EC_GROUP_ORDER) < 0 &&
  61070. s.compare(EC_GROUP_ORDER) < 0
  61071. }
  61072. function assumeCompression (value, pubkey) {
  61073. if (value === undefined && pubkey !== undefined) return __isPointCompressed(pubkey)
  61074. if (value === undefined) return true
  61075. return value
  61076. }
  61077. function fromBuffer (d) { return new BN(d) }
  61078. function toBuffer (d) { return d.toArrayLike(Buffer, 'be', 32) }
  61079. function decodeFrom (P) { return secp256k1.curve.decodePoint(P) }
  61080. function getEncoded (P, compressed) { return Buffer.from(P._encode(compressed)) }
  61081. function pointAdd (pA, pB, __compressed) {
  61082. if (!isPoint(pA)) throw new TypeError(THROW_BAD_POINT)
  61083. if (!isPoint(pB)) throw new TypeError(THROW_BAD_POINT)
  61084. const a = decodeFrom(pA)
  61085. const b = decodeFrom(pB)
  61086. const pp = a.add(b)
  61087. if (pp.isInfinity()) return null
  61088. const compressed = assumeCompression(__compressed, pA)
  61089. return getEncoded(pp, compressed)
  61090. }
  61091. function pointAddScalar (p, tweak, __compressed) {
  61092. if (!isPoint(p)) throw new TypeError(THROW_BAD_POINT)
  61093. if (!isOrderScalar(tweak)) throw new TypeError(THROW_BAD_TWEAK)
  61094. const compressed = assumeCompression(__compressed, p)
  61095. const pp = decodeFrom(p)
  61096. if (tweak.compare(ZERO32) === 0) return getEncoded(pp, compressed)
  61097. const tt = fromBuffer(tweak)
  61098. const qq = G.mul(tt)
  61099. const uu = pp.add(qq)
  61100. if (uu.isInfinity()) return null
  61101. return getEncoded(uu, compressed)
  61102. }
  61103. function pointCompress (p, __compressed) {
  61104. if (!isPoint(p)) throw new TypeError(THROW_BAD_POINT)
  61105. const pp = decodeFrom(p)
  61106. if (pp.isInfinity()) throw new TypeError(THROW_BAD_POINT)
  61107. const compressed = assumeCompression(__compressed, p)
  61108. return getEncoded(pp, compressed)
  61109. }
  61110. function pointFromScalar (d, __compressed) {
  61111. if (!isPrivate(d)) throw new TypeError(THROW_BAD_PRIVATE)
  61112. const dd = fromBuffer(d)
  61113. const pp = G.mul(dd)
  61114. if (pp.isInfinity()) return null
  61115. const compressed = assumeCompression(__compressed)
  61116. return getEncoded(pp, compressed)
  61117. }
  61118. function pointMultiply (p, tweak, __compressed) {
  61119. if (!isPoint(p)) throw new TypeError(THROW_BAD_POINT)
  61120. if (!isOrderScalar(tweak)) throw new TypeError(THROW_BAD_TWEAK)
  61121. const compressed = assumeCompression(__compressed, p)
  61122. const pp = decodeFrom(p)
  61123. const tt = fromBuffer(tweak)
  61124. const qq = pp.mul(tt)
  61125. if (qq.isInfinity()) return null
  61126. return getEncoded(qq, compressed)
  61127. }
  61128. function privateAdd (d, tweak) {
  61129. if (!isPrivate(d)) throw new TypeError(THROW_BAD_PRIVATE)
  61130. if (!isOrderScalar(tweak)) throw new TypeError(THROW_BAD_TWEAK)
  61131. const dd = fromBuffer(d)
  61132. const tt = fromBuffer(tweak)
  61133. const dt = toBuffer(dd.add(tt).umod(n))
  61134. if (!isPrivate(dt)) return null
  61135. return dt
  61136. }
  61137. function privateSub (d, tweak) {
  61138. if (!isPrivate(d)) throw new TypeError(THROW_BAD_PRIVATE)
  61139. if (!isOrderScalar(tweak)) throw new TypeError(THROW_BAD_TWEAK)
  61140. const dd = fromBuffer(d)
  61141. const tt = fromBuffer(tweak)
  61142. const dt = toBuffer(dd.sub(tt).umod(n))
  61143. if (!isPrivate(dt)) return null
  61144. return dt
  61145. }
  61146. function sign (hash, x) {
  61147. return __sign(hash, x)
  61148. }
  61149. function signWithEntropy (hash, x, addData) {
  61150. return __sign(hash, x, addData)
  61151. }
  61152. function __sign (hash, x, addData) {
  61153. if (!isScalar(hash)) throw new TypeError(THROW_BAD_HASH)
  61154. if (!isPrivate(x)) throw new TypeError(THROW_BAD_PRIVATE)
  61155. if (addData !== undefined && !isScalar(addData)) throw new TypeError(THROW_BAD_EXTRA_DATA)
  61156. const d = fromBuffer(x)
  61157. const e = fromBuffer(hash)
  61158. let r, s
  61159. const checkSig = function (k) {
  61160. const kI = fromBuffer(k)
  61161. const Q = G.mul(kI)
  61162. if (Q.isInfinity()) return false
  61163. r = Q.x.umod(n)
  61164. if (r.isZero() === 0) return false
  61165. s = kI
  61166. .invm(n)
  61167. .mul(e.add(d.mul(r)))
  61168. .umod(n)
  61169. if (s.isZero() === 0) return false
  61170. return true
  61171. }
  61172. deterministicGenerateK(hash, x, checkSig, isPrivate, addData)
  61173. // enforce low S values, see bip62: 'low s values in signatures'
  61174. if (s.cmp(nDiv2) > 0) {
  61175. s = n.sub(s)
  61176. }
  61177. const buffer = Buffer.allocUnsafe(64)
  61178. toBuffer(r).copy(buffer, 0)
  61179. toBuffer(s).copy(buffer, 32)
  61180. return buffer
  61181. }
  61182. function verify (hash, q, signature, strict) {
  61183. if (!isScalar(hash)) throw new TypeError(THROW_BAD_HASH)
  61184. if (!isPoint(q)) throw new TypeError(THROW_BAD_POINT)
  61185. // 1.4.1 Enforce r and s are both integers in the interval [1, n − 1] (1, isSignature enforces '< n - 1')
  61186. if (!isSignature(signature)) throw new TypeError(THROW_BAD_SIGNATURE)
  61187. const Q = decodeFrom(q)
  61188. const r = fromBuffer(signature.slice(0, 32))
  61189. const s = fromBuffer(signature.slice(32, 64))
  61190. if (strict && s.cmp(nDiv2) > 0) {
  61191. return false
  61192. }
  61193. // 1.4.1 Enforce r and s are both integers in the interval [1, n − 1] (2, enforces '> 0')
  61194. if (r.gtn(0) <= 0 /* || r.compareTo(n) >= 0 */) return false
  61195. if (s.gtn(0) <= 0 /* || s.compareTo(n) >= 0 */) return false
  61196. // 1.4.2 H = Hash(M), already done by the user
  61197. // 1.4.3 e = H
  61198. const e = fromBuffer(hash)
  61199. // Compute s^-1
  61200. const sInv = s.invm(n)
  61201. // 1.4.4 Compute u1 = es^−1 mod n
  61202. // u2 = rs^−1 mod n
  61203. const u1 = e.mul(sInv).umod(n)
  61204. const u2 = r.mul(sInv).umod(n)
  61205. // 1.4.5 Compute R = (xR, yR)
  61206. // R = u1G + u2Q
  61207. const R = G.mulAdd(u1, Q, u2)
  61208. // 1.4.5 (cont.) Enforce R is not at infinity
  61209. if (R.isInfinity()) return false
  61210. // 1.4.6 Convert the field element R.x to an integer
  61211. const xR = R.x
  61212. // 1.4.7 Set v = xR mod n
  61213. const v = xR.umod(n)
  61214. // 1.4.8 If v = r, output "valid", and if v != r, output "invalid"
  61215. return v.eq(r)
  61216. }
  61217. module.exports = {
  61218. isPoint,
  61219. isPointCompressed,
  61220. isPrivate,
  61221. pointAdd,
  61222. pointAddScalar,
  61223. pointCompress,
  61224. pointFromScalar,
  61225. pointMultiply,
  61226. privateAdd,
  61227. privateSub,
  61228. sign,
  61229. signWithEntropy,
  61230. verify
  61231. }
  61232. /***/ }),
  61233. /***/ "../../node_modules/tiny-secp256k1/rfc6979.js":
  61234. /*!****************************************************!*\
  61235. !*** ../../node_modules/tiny-secp256k1/rfc6979.js ***!
  61236. \****************************************************/
  61237. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  61238. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js")["Buffer"];
  61239. const createHmac = __webpack_require__(/*! create-hmac */ "../../node_modules/create-hmac/browser.js")
  61240. const ONE1 = Buffer.alloc(1, 1)
  61241. const ZERO1 = Buffer.alloc(1, 0)
  61242. // https://tools.ietf.org/html/rfc6979#section-3.2
  61243. function deterministicGenerateK (hash, x, checkSig, isPrivate, extraEntropy) {
  61244. // Step A, ignored as hash already provided
  61245. // Step B
  61246. // Step C
  61247. let k = Buffer.alloc(32, 0)
  61248. let v = Buffer.alloc(32, 1)
  61249. // Step D
  61250. k = createHmac('sha256', k)
  61251. .update(v)
  61252. .update(ZERO1)
  61253. .update(x)
  61254. .update(hash)
  61255. .update(extraEntropy || '')
  61256. .digest()
  61257. // Step E
  61258. v = createHmac('sha256', k).update(v).digest()
  61259. // Step F
  61260. k = createHmac('sha256', k)
  61261. .update(v)
  61262. .update(ONE1)
  61263. .update(x)
  61264. .update(hash)
  61265. .update(extraEntropy || '')
  61266. .digest()
  61267. // Step G
  61268. v = createHmac('sha256', k).update(v).digest()
  61269. // Step H1/H2a, ignored as tlen === qlen (256 bit)
  61270. // Step H2b
  61271. v = createHmac('sha256', k).update(v).digest()
  61272. let T = v
  61273. // Step H3, repeat until T is within the interval [1, n - 1] and is suitable for ECDSA
  61274. while (!isPrivate(T) || !checkSig(T)) {
  61275. k = createHmac('sha256', k)
  61276. .update(v)
  61277. .update(ZERO1)
  61278. .digest()
  61279. v = createHmac('sha256', k).update(v).digest()
  61280. // Step H1/H2a, again, ignored as tlen === qlen (256 bit)
  61281. // Step H2b again
  61282. v = createHmac('sha256', k).update(v).digest()
  61283. T = v
  61284. }
  61285. return T
  61286. }
  61287. module.exports = deterministicGenerateK
  61288. /***/ }),
  61289. /***/ "../../node_modules/typeforce/errors.js":
  61290. /*!**********************************************!*\
  61291. !*** ../../node_modules/typeforce/errors.js ***!
  61292. \**********************************************/
  61293. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  61294. var native = __webpack_require__(/*! ./native */ "../../node_modules/typeforce/native.js")
  61295. function getTypeName (fn) {
  61296. return fn.name || fn.toString().match(/function (.*?)\s*\(/)[1]
  61297. }
  61298. function getValueTypeName (value) {
  61299. return native.Nil(value) ? '' : getTypeName(value.constructor)
  61300. }
  61301. function getValue (value) {
  61302. if (native.Function(value)) return ''
  61303. if (native.String(value)) return JSON.stringify(value)
  61304. if (value && native.Object(value)) return ''
  61305. return value
  61306. }
  61307. function captureStackTrace (e, t) {
  61308. if (Error.captureStackTrace) {
  61309. Error.captureStackTrace(e, t)
  61310. }
  61311. }
  61312. function tfJSON (type) {
  61313. if (native.Function(type)) return type.toJSON ? type.toJSON() : getTypeName(type)
  61314. if (native.Array(type)) return 'Array'
  61315. if (type && native.Object(type)) return 'Object'
  61316. return type !== undefined ? type : ''
  61317. }
  61318. function tfErrorString (type, value, valueTypeName) {
  61319. var valueJson = getValue(value)
  61320. return 'Expected ' + tfJSON(type) + ', got' +
  61321. (valueTypeName !== '' ? ' ' + valueTypeName : '') +
  61322. (valueJson !== '' ? ' ' + valueJson : '')
  61323. }
  61324. function TfTypeError (type, value, valueTypeName) {
  61325. valueTypeName = valueTypeName || getValueTypeName(value)
  61326. this.message = tfErrorString(type, value, valueTypeName)
  61327. captureStackTrace(this, TfTypeError)
  61328. this.__type = type
  61329. this.__value = value
  61330. this.__valueTypeName = valueTypeName
  61331. }
  61332. TfTypeError.prototype = Object.create(Error.prototype)
  61333. TfTypeError.prototype.constructor = TfTypeError
  61334. function tfPropertyErrorString (type, label, name, value, valueTypeName) {
  61335. var description = '" of type '
  61336. if (label === 'key') description = '" with key type '
  61337. return tfErrorString('property "' + tfJSON(name) + description + tfJSON(type), value, valueTypeName)
  61338. }
  61339. function TfPropertyTypeError (type, property, label, value, valueTypeName) {
  61340. if (type) {
  61341. valueTypeName = valueTypeName || getValueTypeName(value)
  61342. this.message = tfPropertyErrorString(type, label, property, value, valueTypeName)
  61343. } else {
  61344. this.message = 'Unexpected property "' + property + '"'
  61345. }
  61346. captureStackTrace(this, TfTypeError)
  61347. this.__label = label
  61348. this.__property = property
  61349. this.__type = type
  61350. this.__value = value
  61351. this.__valueTypeName = valueTypeName
  61352. }
  61353. TfPropertyTypeError.prototype = Object.create(Error.prototype)
  61354. TfPropertyTypeError.prototype.constructor = TfTypeError
  61355. function tfCustomError (expected, actual) {
  61356. return new TfTypeError(expected, {}, actual)
  61357. }
  61358. function tfSubError (e, property, label) {
  61359. // sub child?
  61360. if (e instanceof TfPropertyTypeError) {
  61361. property = property + '.' + e.__property
  61362. e = new TfPropertyTypeError(
  61363. e.__type, property, e.__label, e.__value, e.__valueTypeName
  61364. )
  61365. // child?
  61366. } else if (e instanceof TfTypeError) {
  61367. e = new TfPropertyTypeError(
  61368. e.__type, property, label, e.__value, e.__valueTypeName
  61369. )
  61370. }
  61371. captureStackTrace(e)
  61372. return e
  61373. }
  61374. module.exports = {
  61375. TfTypeError: TfTypeError,
  61376. TfPropertyTypeError: TfPropertyTypeError,
  61377. tfCustomError: tfCustomError,
  61378. tfSubError: tfSubError,
  61379. tfJSON: tfJSON,
  61380. getValueTypeName: getValueTypeName
  61381. }
  61382. /***/ }),
  61383. /***/ "../../node_modules/typeforce/extra.js":
  61384. /*!*********************************************!*\
  61385. !*** ../../node_modules/typeforce/extra.js ***!
  61386. \*********************************************/
  61387. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  61388. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js")["Buffer"];
  61389. var NATIVE = __webpack_require__(/*! ./native */ "../../node_modules/typeforce/native.js")
  61390. var ERRORS = __webpack_require__(/*! ./errors */ "../../node_modules/typeforce/errors.js")
  61391. function _Buffer (value) {
  61392. return Buffer.isBuffer(value)
  61393. }
  61394. function Hex (value) {
  61395. return typeof value === 'string' && /^([0-9a-f]{2})+$/i.test(value)
  61396. }
  61397. function _LengthN (type, length) {
  61398. var name = type.toJSON()
  61399. function Length (value) {
  61400. if (!type(value)) return false
  61401. if (value.length === length) return true
  61402. throw ERRORS.tfCustomError(name + '(Length: ' + length + ')', name + '(Length: ' + value.length + ')')
  61403. }
  61404. Length.toJSON = function () { return name }
  61405. return Length
  61406. }
  61407. var _ArrayN = _LengthN.bind(null, NATIVE.Array)
  61408. var _BufferN = _LengthN.bind(null, _Buffer)
  61409. var _HexN = _LengthN.bind(null, Hex)
  61410. var _StringN = _LengthN.bind(null, NATIVE.String)
  61411. function Range (a, b, f) {
  61412. f = f || NATIVE.Number
  61413. function _range (value, strict) {
  61414. return f(value, strict) && (value > a) && (value < b)
  61415. }
  61416. _range.toJSON = function () {
  61417. return `${f.toJSON()} between [${a}, ${b}]`
  61418. }
  61419. return _range
  61420. }
  61421. var INT53_MAX = Math.pow(2, 53) - 1
  61422. function Finite (value) {
  61423. return typeof value === 'number' && isFinite(value)
  61424. }
  61425. function Int8 (value) { return ((value << 24) >> 24) === value }
  61426. function Int16 (value) { return ((value << 16) >> 16) === value }
  61427. function Int32 (value) { return (value | 0) === value }
  61428. function Int53 (value) {
  61429. return typeof value === 'number' &&
  61430. value >= -INT53_MAX &&
  61431. value <= INT53_MAX &&
  61432. Math.floor(value) === value
  61433. }
  61434. function UInt8 (value) { return (value & 0xff) === value }
  61435. function UInt16 (value) { return (value & 0xffff) === value }
  61436. function UInt32 (value) { return (value >>> 0) === value }
  61437. function UInt53 (value) {
  61438. return typeof value === 'number' &&
  61439. value >= 0 &&
  61440. value <= INT53_MAX &&
  61441. Math.floor(value) === value
  61442. }
  61443. var types = {
  61444. ArrayN: _ArrayN,
  61445. Buffer: _Buffer,
  61446. BufferN: _BufferN,
  61447. Finite: Finite,
  61448. Hex: Hex,
  61449. HexN: _HexN,
  61450. Int8: Int8,
  61451. Int16: Int16,
  61452. Int32: Int32,
  61453. Int53: Int53,
  61454. Range: Range,
  61455. StringN: _StringN,
  61456. UInt8: UInt8,
  61457. UInt16: UInt16,
  61458. UInt32: UInt32,
  61459. UInt53: UInt53
  61460. }
  61461. for (var typeName in types) {
  61462. types[typeName].toJSON = function (t) {
  61463. return t
  61464. }.bind(null, typeName)
  61465. }
  61466. module.exports = types
  61467. /***/ }),
  61468. /***/ "../../node_modules/typeforce/index.js":
  61469. /*!*********************************************!*\
  61470. !*** ../../node_modules/typeforce/index.js ***!
  61471. \*********************************************/
  61472. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  61473. var ERRORS = __webpack_require__(/*! ./errors */ "../../node_modules/typeforce/errors.js")
  61474. var NATIVE = __webpack_require__(/*! ./native */ "../../node_modules/typeforce/native.js")
  61475. // short-hand
  61476. var tfJSON = ERRORS.tfJSON
  61477. var TfTypeError = ERRORS.TfTypeError
  61478. var TfPropertyTypeError = ERRORS.TfPropertyTypeError
  61479. var tfSubError = ERRORS.tfSubError
  61480. var getValueTypeName = ERRORS.getValueTypeName
  61481. var TYPES = {
  61482. arrayOf: function arrayOf (type, options) {
  61483. type = compile(type)
  61484. options = options || {}
  61485. function _arrayOf (array, strict) {
  61486. if (!NATIVE.Array(array)) return false
  61487. if (NATIVE.Nil(array)) return false
  61488. if (options.minLength !== undefined && array.length < options.minLength) return false
  61489. if (options.maxLength !== undefined && array.length > options.maxLength) return false
  61490. if (options.length !== undefined && array.length !== options.length) return false
  61491. return array.every(function (value, i) {
  61492. try {
  61493. return typeforce(type, value, strict)
  61494. } catch (e) {
  61495. throw tfSubError(e, i)
  61496. }
  61497. })
  61498. }
  61499. _arrayOf.toJSON = function () {
  61500. var str = '[' + tfJSON(type) + ']'
  61501. if (options.length !== undefined) {
  61502. str += '{' + options.length + '}'
  61503. } else if (options.minLength !== undefined || options.maxLength !== undefined) {
  61504. str += '{' +
  61505. (options.minLength === undefined ? 0 : options.minLength) + ',' +
  61506. (options.maxLength === undefined ? Infinity : options.maxLength) + '}'
  61507. }
  61508. return str
  61509. }
  61510. return _arrayOf
  61511. },
  61512. maybe: function maybe (type) {
  61513. type = compile(type)
  61514. function _maybe (value, strict) {
  61515. return NATIVE.Nil(value) || type(value, strict, maybe)
  61516. }
  61517. _maybe.toJSON = function () { return '?' + tfJSON(type) }
  61518. return _maybe
  61519. },
  61520. map: function map (propertyType, propertyKeyType) {
  61521. propertyType = compile(propertyType)
  61522. if (propertyKeyType) propertyKeyType = compile(propertyKeyType)
  61523. function _map (value, strict) {
  61524. if (!NATIVE.Object(value)) return false
  61525. if (NATIVE.Nil(value)) return false
  61526. for (var propertyName in value) {
  61527. try {
  61528. if (propertyKeyType) {
  61529. typeforce(propertyKeyType, propertyName, strict)
  61530. }
  61531. } catch (e) {
  61532. throw tfSubError(e, propertyName, 'key')
  61533. }
  61534. try {
  61535. var propertyValue = value[propertyName]
  61536. typeforce(propertyType, propertyValue, strict)
  61537. } catch (e) {
  61538. throw tfSubError(e, propertyName)
  61539. }
  61540. }
  61541. return true
  61542. }
  61543. if (propertyKeyType) {
  61544. _map.toJSON = function () {
  61545. return '{' + tfJSON(propertyKeyType) + ': ' + tfJSON(propertyType) + '}'
  61546. }
  61547. } else {
  61548. _map.toJSON = function () { return '{' + tfJSON(propertyType) + '}' }
  61549. }
  61550. return _map
  61551. },
  61552. object: function object (uncompiled) {
  61553. var type = {}
  61554. for (var typePropertyName in uncompiled) {
  61555. type[typePropertyName] = compile(uncompiled[typePropertyName])
  61556. }
  61557. function _object (value, strict) {
  61558. if (!NATIVE.Object(value)) return false
  61559. if (NATIVE.Nil(value)) return false
  61560. var propertyName
  61561. try {
  61562. for (propertyName in type) {
  61563. var propertyType = type[propertyName]
  61564. var propertyValue = value[propertyName]
  61565. typeforce(propertyType, propertyValue, strict)
  61566. }
  61567. } catch (e) {
  61568. throw tfSubError(e, propertyName)
  61569. }
  61570. if (strict) {
  61571. for (propertyName in value) {
  61572. if (type[propertyName]) continue
  61573. throw new TfPropertyTypeError(undefined, propertyName)
  61574. }
  61575. }
  61576. return true
  61577. }
  61578. _object.toJSON = function () { return tfJSON(type) }
  61579. return _object
  61580. },
  61581. anyOf: function anyOf () {
  61582. var types = [].slice.call(arguments).map(compile)
  61583. function _anyOf (value, strict) {
  61584. return types.some(function (type) {
  61585. try {
  61586. return typeforce(type, value, strict)
  61587. } catch (e) {
  61588. return false
  61589. }
  61590. })
  61591. }
  61592. _anyOf.toJSON = function () { return types.map(tfJSON).join('|') }
  61593. return _anyOf
  61594. },
  61595. allOf: function allOf () {
  61596. var types = [].slice.call(arguments).map(compile)
  61597. function _allOf (value, strict) {
  61598. return types.every(function (type) {
  61599. try {
  61600. return typeforce(type, value, strict)
  61601. } catch (e) {
  61602. return false
  61603. }
  61604. })
  61605. }
  61606. _allOf.toJSON = function () { return types.map(tfJSON).join(' & ') }
  61607. return _allOf
  61608. },
  61609. quacksLike: function quacksLike (type) {
  61610. function _quacksLike (value) {
  61611. return type === getValueTypeName(value)
  61612. }
  61613. _quacksLike.toJSON = function () { return type }
  61614. return _quacksLike
  61615. },
  61616. tuple: function tuple () {
  61617. var types = [].slice.call(arguments).map(compile)
  61618. function _tuple (values, strict) {
  61619. if (NATIVE.Nil(values)) return false
  61620. if (NATIVE.Nil(values.length)) return false
  61621. if (strict && (values.length !== types.length)) return false
  61622. return types.every(function (type, i) {
  61623. try {
  61624. return typeforce(type, values[i], strict)
  61625. } catch (e) {
  61626. throw tfSubError(e, i)
  61627. }
  61628. })
  61629. }
  61630. _tuple.toJSON = function () { return '(' + types.map(tfJSON).join(', ') + ')' }
  61631. return _tuple
  61632. },
  61633. value: function value (expected) {
  61634. function _value (actual) {
  61635. return actual === expected
  61636. }
  61637. _value.toJSON = function () { return expected }
  61638. return _value
  61639. }
  61640. }
  61641. // TODO: deprecate
  61642. TYPES.oneOf = TYPES.anyOf
  61643. function compile (type) {
  61644. if (NATIVE.String(type)) {
  61645. if (type[0] === '?') return TYPES.maybe(type.slice(1))
  61646. return NATIVE[type] || TYPES.quacksLike(type)
  61647. } else if (type && NATIVE.Object(type)) {
  61648. if (NATIVE.Array(type)) {
  61649. if (type.length !== 1) throw new TypeError('Expected compile() parameter of type Array of length 1')
  61650. return TYPES.arrayOf(type[0])
  61651. }
  61652. return TYPES.object(type)
  61653. } else if (NATIVE.Function(type)) {
  61654. return type
  61655. }
  61656. return TYPES.value(type)
  61657. }
  61658. function typeforce (type, value, strict, surrogate) {
  61659. if (NATIVE.Function(type)) {
  61660. if (type(value, strict)) return true
  61661. throw new TfTypeError(surrogate || type, value)
  61662. }
  61663. // JIT
  61664. return typeforce(compile(type), value, strict)
  61665. }
  61666. // assign types to typeforce function
  61667. for (var typeName in NATIVE) {
  61668. typeforce[typeName] = NATIVE[typeName]
  61669. }
  61670. for (typeName in TYPES) {
  61671. typeforce[typeName] = TYPES[typeName]
  61672. }
  61673. var EXTRA = __webpack_require__(/*! ./extra */ "../../node_modules/typeforce/extra.js")
  61674. for (typeName in EXTRA) {
  61675. typeforce[typeName] = EXTRA[typeName]
  61676. }
  61677. typeforce.compile = compile
  61678. typeforce.TfTypeError = TfTypeError
  61679. typeforce.TfPropertyTypeError = TfPropertyTypeError
  61680. module.exports = typeforce
  61681. /***/ }),
  61682. /***/ "../../node_modules/typeforce/native.js":
  61683. /*!**********************************************!*\
  61684. !*** ../../node_modules/typeforce/native.js ***!
  61685. \**********************************************/
  61686. /***/ ((module) => {
  61687. var types = {
  61688. Array: function (value) { return value !== null && value !== undefined && value.constructor === Array },
  61689. Boolean: function (value) { return typeof value === 'boolean' },
  61690. Function: function (value) { return typeof value === 'function' },
  61691. Nil: function (value) { return value === undefined || value === null },
  61692. Number: function (value) { return typeof value === 'number' },
  61693. Object: function (value) { return typeof value === 'object' },
  61694. String: function (value) { return typeof value === 'string' },
  61695. '': function () { return true }
  61696. }
  61697. // TODO: deprecate
  61698. types.Null = types.Nil
  61699. for (var typeName in types) {
  61700. types[typeName].toJSON = function (t) {
  61701. return t
  61702. }.bind(null, typeName)
  61703. }
  61704. module.exports = types
  61705. /***/ }),
  61706. /***/ "../../node_modules/url/node_modules/punycode/punycode.js":
  61707. /*!****************************************************************!*\
  61708. !*** ../../node_modules/url/node_modules/punycode/punycode.js ***!
  61709. \****************************************************************/
  61710. /***/ (function(module, exports, __webpack_require__) {
  61711. /* module decorator */ module = __webpack_require__.nmd(module);
  61712. var __WEBPACK_AMD_DEFINE_RESULT__;/*! https://mths.be/punycode v1.3.2 by @mathias */
  61713. ;(function(root) {
  61714. /** Detect free variables */
  61715. var freeExports = true && exports &&
  61716. !exports.nodeType && exports;
  61717. var freeModule = true && module &&
  61718. !module.nodeType && module;
  61719. var freeGlobal = typeof __webpack_require__.g == 'object' && __webpack_require__.g;
  61720. if (
  61721. freeGlobal.global === freeGlobal ||
  61722. freeGlobal.window === freeGlobal ||
  61723. freeGlobal.self === freeGlobal
  61724. ) {
  61725. root = freeGlobal;
  61726. }
  61727. /**
  61728. * The `punycode` object.
  61729. * @name punycode
  61730. * @type Object
  61731. */
  61732. var punycode,
  61733. /** Highest positive signed 32-bit float value */
  61734. maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1
  61735. /** Bootstring parameters */
  61736. base = 36,
  61737. tMin = 1,
  61738. tMax = 26,
  61739. skew = 38,
  61740. damp = 700,
  61741. initialBias = 72,
  61742. initialN = 128, // 0x80
  61743. delimiter = '-', // '\x2D'
  61744. /** Regular expressions */
  61745. regexPunycode = /^xn--/,
  61746. regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars
  61747. regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators
  61748. /** Error messages */
  61749. errors = {
  61750. 'overflow': 'Overflow: input needs wider integers to process',
  61751. 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
  61752. 'invalid-input': 'Invalid input'
  61753. },
  61754. /** Convenience shortcuts */
  61755. baseMinusTMin = base - tMin,
  61756. floor = Math.floor,
  61757. stringFromCharCode = String.fromCharCode,
  61758. /** Temporary variable */
  61759. key;
  61760. /*--------------------------------------------------------------------------*/
  61761. /**
  61762. * A generic error utility function.
  61763. * @private
  61764. * @param {String} type The error type.
  61765. * @returns {Error} Throws a `RangeError` with the applicable error message.
  61766. */
  61767. function error(type) {
  61768. throw RangeError(errors[type]);
  61769. }
  61770. /**
  61771. * A generic `Array#map` utility function.
  61772. * @private
  61773. * @param {Array} array The array to iterate over.
  61774. * @param {Function} callback The function that gets called for every array
  61775. * item.
  61776. * @returns {Array} A new array of values returned by the callback function.
  61777. */
  61778. function map(array, fn) {
  61779. var length = array.length;
  61780. var result = [];
  61781. while (length--) {
  61782. result[length] = fn(array[length]);
  61783. }
  61784. return result;
  61785. }
  61786. /**
  61787. * A simple `Array#map`-like wrapper to work with domain name strings or email
  61788. * addresses.
  61789. * @private
  61790. * @param {String} domain The domain name or email address.
  61791. * @param {Function} callback The function that gets called for every
  61792. * character.
  61793. * @returns {Array} A new string of characters returned by the callback
  61794. * function.
  61795. */
  61796. function mapDomain(string, fn) {
  61797. var parts = string.split('@');
  61798. var result = '';
  61799. if (parts.length > 1) {
  61800. // In email addresses, only the domain name should be punycoded. Leave
  61801. // the local part (i.e. everything up to `@`) intact.
  61802. result = parts[0] + '@';
  61803. string = parts[1];
  61804. }
  61805. // Avoid `split(regex)` for IE8 compatibility. See #17.
  61806. string = string.replace(regexSeparators, '\x2E');
  61807. var labels = string.split('.');
  61808. var encoded = map(labels, fn).join('.');
  61809. return result + encoded;
  61810. }
  61811. /**
  61812. * Creates an array containing the numeric code points of each Unicode
  61813. * character in the string. While JavaScript uses UCS-2 internally,
  61814. * this function will convert a pair of surrogate halves (each of which
  61815. * UCS-2 exposes as separate characters) into a single code point,
  61816. * matching UTF-16.
  61817. * @see `punycode.ucs2.encode`
  61818. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  61819. * @memberOf punycode.ucs2
  61820. * @name decode
  61821. * @param {String} string The Unicode input string (UCS-2).
  61822. * @returns {Array} The new array of code points.
  61823. */
  61824. function ucs2decode(string) {
  61825. var output = [],
  61826. counter = 0,
  61827. length = string.length,
  61828. value,
  61829. extra;
  61830. while (counter < length) {
  61831. value = string.charCodeAt(counter++);
  61832. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  61833. // high surrogate, and there is a next character
  61834. extra = string.charCodeAt(counter++);
  61835. if ((extra & 0xFC00) == 0xDC00) { // low surrogate
  61836. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  61837. } else {
  61838. // unmatched surrogate; only append this code unit, in case the next
  61839. // code unit is the high surrogate of a surrogate pair
  61840. output.push(value);
  61841. counter--;
  61842. }
  61843. } else {
  61844. output.push(value);
  61845. }
  61846. }
  61847. return output;
  61848. }
  61849. /**
  61850. * Creates a string based on an array of numeric code points.
  61851. * @see `punycode.ucs2.decode`
  61852. * @memberOf punycode.ucs2
  61853. * @name encode
  61854. * @param {Array} codePoints The array of numeric code points.
  61855. * @returns {String} The new Unicode string (UCS-2).
  61856. */
  61857. function ucs2encode(array) {
  61858. return map(array, function(value) {
  61859. var output = '';
  61860. if (value > 0xFFFF) {
  61861. value -= 0x10000;
  61862. output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
  61863. value = 0xDC00 | value & 0x3FF;
  61864. }
  61865. output += stringFromCharCode(value);
  61866. return output;
  61867. }).join('');
  61868. }
  61869. /**
  61870. * Converts a basic code point into a digit/integer.
  61871. * @see `digitToBasic()`
  61872. * @private
  61873. * @param {Number} codePoint The basic numeric code point value.
  61874. * @returns {Number} The numeric value of a basic code point (for use in
  61875. * representing integers) in the range `0` to `base - 1`, or `base` if
  61876. * the code point does not represent a value.
  61877. */
  61878. function basicToDigit(codePoint) {
  61879. if (codePoint - 48 < 10) {
  61880. return codePoint - 22;
  61881. }
  61882. if (codePoint - 65 < 26) {
  61883. return codePoint - 65;
  61884. }
  61885. if (codePoint - 97 < 26) {
  61886. return codePoint - 97;
  61887. }
  61888. return base;
  61889. }
  61890. /**
  61891. * Converts a digit/integer into a basic code point.
  61892. * @see `basicToDigit()`
  61893. * @private
  61894. * @param {Number} digit The numeric value of a basic code point.
  61895. * @returns {Number} The basic code point whose value (when used for
  61896. * representing integers) is `digit`, which needs to be in the range
  61897. * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
  61898. * used; else, the lowercase form is used. The behavior is undefined
  61899. * if `flag` is non-zero and `digit` has no uppercase form.
  61900. */
  61901. function digitToBasic(digit, flag) {
  61902. // 0..25 map to ASCII a..z or A..Z
  61903. // 26..35 map to ASCII 0..9
  61904. return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
  61905. }
  61906. /**
  61907. * Bias adaptation function as per section 3.4 of RFC 3492.
  61908. * http://tools.ietf.org/html/rfc3492#section-3.4
  61909. * @private
  61910. */
  61911. function adapt(delta, numPoints, firstTime) {
  61912. var k = 0;
  61913. delta = firstTime ? floor(delta / damp) : delta >> 1;
  61914. delta += floor(delta / numPoints);
  61915. for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
  61916. delta = floor(delta / baseMinusTMin);
  61917. }
  61918. return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
  61919. }
  61920. /**
  61921. * Converts a Punycode string of ASCII-only symbols to a string of Unicode
  61922. * symbols.
  61923. * @memberOf punycode
  61924. * @param {String} input The Punycode string of ASCII-only symbols.
  61925. * @returns {String} The resulting string of Unicode symbols.
  61926. */
  61927. function decode(input) {
  61928. // Don't use UCS-2
  61929. var output = [],
  61930. inputLength = input.length,
  61931. out,
  61932. i = 0,
  61933. n = initialN,
  61934. bias = initialBias,
  61935. basic,
  61936. j,
  61937. index,
  61938. oldi,
  61939. w,
  61940. k,
  61941. digit,
  61942. t,
  61943. /** Cached calculation results */
  61944. baseMinusT;
  61945. // Handle the basic code points: let `basic` be the number of input code
  61946. // points before the last delimiter, or `0` if there is none, then copy
  61947. // the first basic code points to the output.
  61948. basic = input.lastIndexOf(delimiter);
  61949. if (basic < 0) {
  61950. basic = 0;
  61951. }
  61952. for (j = 0; j < basic; ++j) {
  61953. // if it's not a basic code point
  61954. if (input.charCodeAt(j) >= 0x80) {
  61955. error('not-basic');
  61956. }
  61957. output.push(input.charCodeAt(j));
  61958. }
  61959. // Main decoding loop: start just after the last delimiter if any basic code
  61960. // points were copied; start at the beginning otherwise.
  61961. for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
  61962. // `index` is the index of the next character to be consumed.
  61963. // Decode a generalized variable-length integer into `delta`,
  61964. // which gets added to `i`. The overflow checking is easier
  61965. // if we increase `i` as we go, then subtract off its starting
  61966. // value at the end to obtain `delta`.
  61967. for (oldi = i, w = 1, k = base; /* no condition */; k += base) {
  61968. if (index >= inputLength) {
  61969. error('invalid-input');
  61970. }
  61971. digit = basicToDigit(input.charCodeAt(index++));
  61972. if (digit >= base || digit > floor((maxInt - i) / w)) {
  61973. error('overflow');
  61974. }
  61975. i += digit * w;
  61976. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  61977. if (digit < t) {
  61978. break;
  61979. }
  61980. baseMinusT = base - t;
  61981. if (w > floor(maxInt / baseMinusT)) {
  61982. error('overflow');
  61983. }
  61984. w *= baseMinusT;
  61985. }
  61986. out = output.length + 1;
  61987. bias = adapt(i - oldi, out, oldi == 0);
  61988. // `i` was supposed to wrap around from `out` to `0`,
  61989. // incrementing `n` each time, so we'll fix that now:
  61990. if (floor(i / out) > maxInt - n) {
  61991. error('overflow');
  61992. }
  61993. n += floor(i / out);
  61994. i %= out;
  61995. // Insert `n` at position `i` of the output
  61996. output.splice(i++, 0, n);
  61997. }
  61998. return ucs2encode(output);
  61999. }
  62000. /**
  62001. * Converts a string of Unicode symbols (e.g. a domain name label) to a
  62002. * Punycode string of ASCII-only symbols.
  62003. * @memberOf punycode
  62004. * @param {String} input The string of Unicode symbols.
  62005. * @returns {String} The resulting Punycode string of ASCII-only symbols.
  62006. */
  62007. function encode(input) {
  62008. var n,
  62009. delta,
  62010. handledCPCount,
  62011. basicLength,
  62012. bias,
  62013. j,
  62014. m,
  62015. q,
  62016. k,
  62017. t,
  62018. currentValue,
  62019. output = [],
  62020. /** `inputLength` will hold the number of code points in `input`. */
  62021. inputLength,
  62022. /** Cached calculation results */
  62023. handledCPCountPlusOne,
  62024. baseMinusT,
  62025. qMinusT;
  62026. // Convert the input in UCS-2 to Unicode
  62027. input = ucs2decode(input);
  62028. // Cache the length
  62029. inputLength = input.length;
  62030. // Initialize the state
  62031. n = initialN;
  62032. delta = 0;
  62033. bias = initialBias;
  62034. // Handle the basic code points
  62035. for (j = 0; j < inputLength; ++j) {
  62036. currentValue = input[j];
  62037. if (currentValue < 0x80) {
  62038. output.push(stringFromCharCode(currentValue));
  62039. }
  62040. }
  62041. handledCPCount = basicLength = output.length;
  62042. // `handledCPCount` is the number of code points that have been handled;
  62043. // `basicLength` is the number of basic code points.
  62044. // Finish the basic string - if it is not empty - with a delimiter
  62045. if (basicLength) {
  62046. output.push(delimiter);
  62047. }
  62048. // Main encoding loop:
  62049. while (handledCPCount < inputLength) {
  62050. // All non-basic code points < n have been handled already. Find the next
  62051. // larger one:
  62052. for (m = maxInt, j = 0; j < inputLength; ++j) {
  62053. currentValue = input[j];
  62054. if (currentValue >= n && currentValue < m) {
  62055. m = currentValue;
  62056. }
  62057. }
  62058. // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
  62059. // but guard against overflow
  62060. handledCPCountPlusOne = handledCPCount + 1;
  62061. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  62062. error('overflow');
  62063. }
  62064. delta += (m - n) * handledCPCountPlusOne;
  62065. n = m;
  62066. for (j = 0; j < inputLength; ++j) {
  62067. currentValue = input[j];
  62068. if (currentValue < n && ++delta > maxInt) {
  62069. error('overflow');
  62070. }
  62071. if (currentValue == n) {
  62072. // Represent delta as a generalized variable-length integer
  62073. for (q = delta, k = base; /* no condition */; k += base) {
  62074. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  62075. if (q < t) {
  62076. break;
  62077. }
  62078. qMinusT = q - t;
  62079. baseMinusT = base - t;
  62080. output.push(
  62081. stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
  62082. );
  62083. q = floor(qMinusT / baseMinusT);
  62084. }
  62085. output.push(stringFromCharCode(digitToBasic(q, 0)));
  62086. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  62087. delta = 0;
  62088. ++handledCPCount;
  62089. }
  62090. }
  62091. ++delta;
  62092. ++n;
  62093. }
  62094. return output.join('');
  62095. }
  62096. /**
  62097. * Converts a Punycode string representing a domain name or an email address
  62098. * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
  62099. * it doesn't matter if you call it on a string that has already been
  62100. * converted to Unicode.
  62101. * @memberOf punycode
  62102. * @param {String} input The Punycoded domain name or email address to
  62103. * convert to Unicode.
  62104. * @returns {String} The Unicode representation of the given Punycode
  62105. * string.
  62106. */
  62107. function toUnicode(input) {
  62108. return mapDomain(input, function(string) {
  62109. return regexPunycode.test(string)
  62110. ? decode(string.slice(4).toLowerCase())
  62111. : string;
  62112. });
  62113. }
  62114. /**
  62115. * Converts a Unicode string representing a domain name or an email address to
  62116. * Punycode. Only the non-ASCII parts of the domain name will be converted,
  62117. * i.e. it doesn't matter if you call it with a domain that's already in
  62118. * ASCII.
  62119. * @memberOf punycode
  62120. * @param {String} input The domain name or email address to convert, as a
  62121. * Unicode string.
  62122. * @returns {String} The Punycode representation of the given domain name or
  62123. * email address.
  62124. */
  62125. function toASCII(input) {
  62126. return mapDomain(input, function(string) {
  62127. return regexNonASCII.test(string)
  62128. ? 'xn--' + encode(string)
  62129. : string;
  62130. });
  62131. }
  62132. /*--------------------------------------------------------------------------*/
  62133. /** Define the public API */
  62134. punycode = {
  62135. /**
  62136. * A string representing the current Punycode.js version number.
  62137. * @memberOf punycode
  62138. * @type String
  62139. */
  62140. 'version': '1.3.2',
  62141. /**
  62142. * An object of methods to convert from JavaScript's internal character
  62143. * representation (UCS-2) to Unicode code points, and back.
  62144. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  62145. * @memberOf punycode
  62146. * @type Object
  62147. */
  62148. 'ucs2': {
  62149. 'decode': ucs2decode,
  62150. 'encode': ucs2encode
  62151. },
  62152. 'decode': decode,
  62153. 'encode': encode,
  62154. 'toASCII': toASCII,
  62155. 'toUnicode': toUnicode
  62156. };
  62157. /** Expose `punycode` */
  62158. // Some AMD build optimizers, like r.js, check for specific condition patterns
  62159. // like the following:
  62160. if (
  62161. true
  62162. ) {
  62163. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  62164. return punycode;
  62165. }).call(exports, __webpack_require__, exports, module),
  62166. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  62167. } else {}
  62168. }(this));
  62169. /***/ }),
  62170. /***/ "../../node_modules/url/url.js":
  62171. /*!*************************************!*\
  62172. !*** ../../node_modules/url/url.js ***!
  62173. \*************************************/
  62174. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  62175. "use strict";
  62176. // Copyright Joyent, Inc. and other Node contributors.
  62177. //
  62178. // Permission is hereby granted, free of charge, to any person obtaining a
  62179. // copy of this software and associated documentation files (the
  62180. // "Software"), to deal in the Software without restriction, including
  62181. // without limitation the rights to use, copy, modify, merge, publish,
  62182. // distribute, sublicense, and/or sell copies of the Software, and to permit
  62183. // persons to whom the Software is furnished to do so, subject to the
  62184. // following conditions:
  62185. //
  62186. // The above copyright notice and this permission notice shall be included
  62187. // in all copies or substantial portions of the Software.
  62188. //
  62189. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  62190. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  62191. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  62192. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  62193. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  62194. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  62195. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  62196. var punycode = __webpack_require__(/*! punycode */ "../../node_modules/url/node_modules/punycode/punycode.js");
  62197. var util = __webpack_require__(/*! ./util */ "../../node_modules/url/util.js");
  62198. exports.parse = urlParse;
  62199. exports.resolve = urlResolve;
  62200. exports.resolveObject = urlResolveObject;
  62201. exports.format = urlFormat;
  62202. exports.Url = Url;
  62203. function Url() {
  62204. this.protocol = null;
  62205. this.slashes = null;
  62206. this.auth = null;
  62207. this.host = null;
  62208. this.port = null;
  62209. this.hostname = null;
  62210. this.hash = null;
  62211. this.search = null;
  62212. this.query = null;
  62213. this.pathname = null;
  62214. this.path = null;
  62215. this.href = null;
  62216. }
  62217. // Reference: RFC 3986, RFC 1808, RFC 2396
  62218. // define these here so at least they only have to be
  62219. // compiled once on the first module load.
  62220. var protocolPattern = /^([a-z0-9.+-]+:)/i,
  62221. portPattern = /:[0-9]*$/,
  62222. // Special case for a simple path URL
  62223. simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
  62224. // RFC 2396: characters reserved for delimiting URLs.
  62225. // We actually just auto-escape these.
  62226. delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
  62227. // RFC 2396: characters not allowed for various reasons.
  62228. unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
  62229. // Allowed by RFCs, but cause of XSS attacks. Always escape these.
  62230. autoEscape = ['\''].concat(unwise),
  62231. // Characters that are never ever allowed in a hostname.
  62232. // Note that any invalid chars are also handled, but these
  62233. // are the ones that are *expected* to be seen, so we fast-path
  62234. // them.
  62235. nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
  62236. hostEndingChars = ['/', '?', '#'],
  62237. hostnameMaxLen = 255,
  62238. hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
  62239. hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
  62240. // protocols that can allow "unsafe" and "unwise" chars.
  62241. unsafeProtocol = {
  62242. 'javascript': true,
  62243. 'javascript:': true
  62244. },
  62245. // protocols that never have a hostname.
  62246. hostlessProtocol = {
  62247. 'javascript': true,
  62248. 'javascript:': true
  62249. },
  62250. // protocols that always contain a // bit.
  62251. slashedProtocol = {
  62252. 'http': true,
  62253. 'https': true,
  62254. 'ftp': true,
  62255. 'gopher': true,
  62256. 'file': true,
  62257. 'http:': true,
  62258. 'https:': true,
  62259. 'ftp:': true,
  62260. 'gopher:': true,
  62261. 'file:': true
  62262. },
  62263. querystring = __webpack_require__(/*! querystring */ "../../node_modules/querystring/index.js");
  62264. function urlParse(url, parseQueryString, slashesDenoteHost) {
  62265. if (url && util.isObject(url) && url instanceof Url) return url;
  62266. var u = new Url;
  62267. u.parse(url, parseQueryString, slashesDenoteHost);
  62268. return u;
  62269. }
  62270. Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
  62271. if (!util.isString(url)) {
  62272. throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
  62273. }
  62274. // Copy chrome, IE, opera backslash-handling behavior.
  62275. // Back slashes before the query string get converted to forward slashes
  62276. // See: https://code.google.com/p/chromium/issues/detail?id=25916
  62277. var queryIndex = url.indexOf('?'),
  62278. splitter =
  62279. (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#',
  62280. uSplit = url.split(splitter),
  62281. slashRegex = /\\/g;
  62282. uSplit[0] = uSplit[0].replace(slashRegex, '/');
  62283. url = uSplit.join(splitter);
  62284. var rest = url;
  62285. // trim before proceeding.
  62286. // This is to support parse stuff like " http://foo.com \n"
  62287. rest = rest.trim();
  62288. if (!slashesDenoteHost && url.split('#').length === 1) {
  62289. // Try fast path regexp
  62290. var simplePath = simplePathPattern.exec(rest);
  62291. if (simplePath) {
  62292. this.path = rest;
  62293. this.href = rest;
  62294. this.pathname = simplePath[1];
  62295. if (simplePath[2]) {
  62296. this.search = simplePath[2];
  62297. if (parseQueryString) {
  62298. this.query = querystring.parse(this.search.substr(1));
  62299. } else {
  62300. this.query = this.search.substr(1);
  62301. }
  62302. } else if (parseQueryString) {
  62303. this.search = '';
  62304. this.query = {};
  62305. }
  62306. return this;
  62307. }
  62308. }
  62309. var proto = protocolPattern.exec(rest);
  62310. if (proto) {
  62311. proto = proto[0];
  62312. var lowerProto = proto.toLowerCase();
  62313. this.protocol = lowerProto;
  62314. rest = rest.substr(proto.length);
  62315. }
  62316. // figure out if it's got a host
  62317. // user@server is *always* interpreted as a hostname, and url
  62318. // resolution will treat //foo/bar as host=foo,path=bar because that's
  62319. // how the browser resolves relative URLs.
  62320. if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
  62321. var slashes = rest.substr(0, 2) === '//';
  62322. if (slashes && !(proto && hostlessProtocol[proto])) {
  62323. rest = rest.substr(2);
  62324. this.slashes = true;
  62325. }
  62326. }
  62327. if (!hostlessProtocol[proto] &&
  62328. (slashes || (proto && !slashedProtocol[proto]))) {
  62329. // there's a hostname.
  62330. // the first instance of /, ?, ;, or # ends the host.
  62331. //
  62332. // If there is an @ in the hostname, then non-host chars *are* allowed
  62333. // to the left of the last @ sign, unless some host-ending character
  62334. // comes *before* the @-sign.
  62335. // URLs are obnoxious.
  62336. //
  62337. // ex:
  62338. // http://a@b@c/ => user:a@b host:c
  62339. // http://a@b?@c => user:a host:c path:/?@c
  62340. // v0.12 TODO(isaacs): This is not quite how Chrome does things.
  62341. // Review our test case against browsers more comprehensively.
  62342. // find the first instance of any hostEndingChars
  62343. var hostEnd = -1;
  62344. for (var i = 0; i < hostEndingChars.length; i++) {
  62345. var hec = rest.indexOf(hostEndingChars[i]);
  62346. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  62347. hostEnd = hec;
  62348. }
  62349. // at this point, either we have an explicit point where the
  62350. // auth portion cannot go past, or the last @ char is the decider.
  62351. var auth, atSign;
  62352. if (hostEnd === -1) {
  62353. // atSign can be anywhere.
  62354. atSign = rest.lastIndexOf('@');
  62355. } else {
  62356. // atSign must be in auth portion.
  62357. // http://a@b/c@d => host:b auth:a path:/c@d
  62358. atSign = rest.lastIndexOf('@', hostEnd);
  62359. }
  62360. // Now we have a portion which is definitely the auth.
  62361. // Pull that off.
  62362. if (atSign !== -1) {
  62363. auth = rest.slice(0, atSign);
  62364. rest = rest.slice(atSign + 1);
  62365. this.auth = decodeURIComponent(auth);
  62366. }
  62367. // the host is the remaining to the left of the first non-host char
  62368. hostEnd = -1;
  62369. for (var i = 0; i < nonHostChars.length; i++) {
  62370. var hec = rest.indexOf(nonHostChars[i]);
  62371. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  62372. hostEnd = hec;
  62373. }
  62374. // if we still have not hit it, then the entire thing is a host.
  62375. if (hostEnd === -1)
  62376. hostEnd = rest.length;
  62377. this.host = rest.slice(0, hostEnd);
  62378. rest = rest.slice(hostEnd);
  62379. // pull out port.
  62380. this.parseHost();
  62381. // we've indicated that there is a hostname,
  62382. // so even if it's empty, it has to be present.
  62383. this.hostname = this.hostname || '';
  62384. // if hostname begins with [ and ends with ]
  62385. // assume that it's an IPv6 address.
  62386. var ipv6Hostname = this.hostname[0] === '[' &&
  62387. this.hostname[this.hostname.length - 1] === ']';
  62388. // validate a little.
  62389. if (!ipv6Hostname) {
  62390. var hostparts = this.hostname.split(/\./);
  62391. for (var i = 0, l = hostparts.length; i < l; i++) {
  62392. var part = hostparts[i];
  62393. if (!part) continue;
  62394. if (!part.match(hostnamePartPattern)) {
  62395. var newpart = '';
  62396. for (var j = 0, k = part.length; j < k; j++) {
  62397. if (part.charCodeAt(j) > 127) {
  62398. // we replace non-ASCII char with a temporary placeholder
  62399. // we need this to make sure size of hostname is not
  62400. // broken by replacing non-ASCII by nothing
  62401. newpart += 'x';
  62402. } else {
  62403. newpart += part[j];
  62404. }
  62405. }
  62406. // we test again with ASCII char only
  62407. if (!newpart.match(hostnamePartPattern)) {
  62408. var validParts = hostparts.slice(0, i);
  62409. var notHost = hostparts.slice(i + 1);
  62410. var bit = part.match(hostnamePartStart);
  62411. if (bit) {
  62412. validParts.push(bit[1]);
  62413. notHost.unshift(bit[2]);
  62414. }
  62415. if (notHost.length) {
  62416. rest = '/' + notHost.join('.') + rest;
  62417. }
  62418. this.hostname = validParts.join('.');
  62419. break;
  62420. }
  62421. }
  62422. }
  62423. }
  62424. if (this.hostname.length > hostnameMaxLen) {
  62425. this.hostname = '';
  62426. } else {
  62427. // hostnames are always lower case.
  62428. this.hostname = this.hostname.toLowerCase();
  62429. }
  62430. if (!ipv6Hostname) {
  62431. // IDNA Support: Returns a punycoded representation of "domain".
  62432. // It only converts parts of the domain name that
  62433. // have non-ASCII characters, i.e. it doesn't matter if
  62434. // you call it with a domain that already is ASCII-only.
  62435. this.hostname = punycode.toASCII(this.hostname);
  62436. }
  62437. var p = this.port ? ':' + this.port : '';
  62438. var h = this.hostname || '';
  62439. this.host = h + p;
  62440. this.href += this.host;
  62441. // strip [ and ] from the hostname
  62442. // the host field still retains them, though
  62443. if (ipv6Hostname) {
  62444. this.hostname = this.hostname.substr(1, this.hostname.length - 2);
  62445. if (rest[0] !== '/') {
  62446. rest = '/' + rest;
  62447. }
  62448. }
  62449. }
  62450. // now rest is set to the post-host stuff.
  62451. // chop off any delim chars.
  62452. if (!unsafeProtocol[lowerProto]) {
  62453. // First, make 100% sure that any "autoEscape" chars get
  62454. // escaped, even if encodeURIComponent doesn't think they
  62455. // need to be.
  62456. for (var i = 0, l = autoEscape.length; i < l; i++) {
  62457. var ae = autoEscape[i];
  62458. if (rest.indexOf(ae) === -1)
  62459. continue;
  62460. var esc = encodeURIComponent(ae);
  62461. if (esc === ae) {
  62462. esc = escape(ae);
  62463. }
  62464. rest = rest.split(ae).join(esc);
  62465. }
  62466. }
  62467. // chop off from the tail first.
  62468. var hash = rest.indexOf('#');
  62469. if (hash !== -1) {
  62470. // got a fragment string.
  62471. this.hash = rest.substr(hash);
  62472. rest = rest.slice(0, hash);
  62473. }
  62474. var qm = rest.indexOf('?');
  62475. if (qm !== -1) {
  62476. this.search = rest.substr(qm);
  62477. this.query = rest.substr(qm + 1);
  62478. if (parseQueryString) {
  62479. this.query = querystring.parse(this.query);
  62480. }
  62481. rest = rest.slice(0, qm);
  62482. } else if (parseQueryString) {
  62483. // no query string, but parseQueryString still requested
  62484. this.search = '';
  62485. this.query = {};
  62486. }
  62487. if (rest) this.pathname = rest;
  62488. if (slashedProtocol[lowerProto] &&
  62489. this.hostname && !this.pathname) {
  62490. this.pathname = '/';
  62491. }
  62492. //to support http.request
  62493. if (this.pathname || this.search) {
  62494. var p = this.pathname || '';
  62495. var s = this.search || '';
  62496. this.path = p + s;
  62497. }
  62498. // finally, reconstruct the href based on what has been validated.
  62499. this.href = this.format();
  62500. return this;
  62501. };
  62502. // format a parsed object into a url string
  62503. function urlFormat(obj) {
  62504. // ensure it's an object, and not a string url.
  62505. // If it's an obj, this is a no-op.
  62506. // this way, you can call url_format() on strings
  62507. // to clean up potentially wonky urls.
  62508. if (util.isString(obj)) obj = urlParse(obj);
  62509. if (!(obj instanceof Url)) return Url.prototype.format.call(obj);
  62510. return obj.format();
  62511. }
  62512. Url.prototype.format = function() {
  62513. var auth = this.auth || '';
  62514. if (auth) {
  62515. auth = encodeURIComponent(auth);
  62516. auth = auth.replace(/%3A/i, ':');
  62517. auth += '@';
  62518. }
  62519. var protocol = this.protocol || '',
  62520. pathname = this.pathname || '',
  62521. hash = this.hash || '',
  62522. host = false,
  62523. query = '';
  62524. if (this.host) {
  62525. host = auth + this.host;
  62526. } else if (this.hostname) {
  62527. host = auth + (this.hostname.indexOf(':') === -1 ?
  62528. this.hostname :
  62529. '[' + this.hostname + ']');
  62530. if (this.port) {
  62531. host += ':' + this.port;
  62532. }
  62533. }
  62534. if (this.query &&
  62535. util.isObject(this.query) &&
  62536. Object.keys(this.query).length) {
  62537. query = querystring.stringify(this.query);
  62538. }
  62539. var search = this.search || (query && ('?' + query)) || '';
  62540. if (protocol && protocol.substr(-1) !== ':') protocol += ':';
  62541. // only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
  62542. // unless they had them to begin with.
  62543. if (this.slashes ||
  62544. (!protocol || slashedProtocol[protocol]) && host !== false) {
  62545. host = '//' + (host || '');
  62546. if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
  62547. } else if (!host) {
  62548. host = '';
  62549. }
  62550. if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
  62551. if (search && search.charAt(0) !== '?') search = '?' + search;
  62552. pathname = pathname.replace(/[?#]/g, function(match) {
  62553. return encodeURIComponent(match);
  62554. });
  62555. search = search.replace('#', '%23');
  62556. return protocol + host + pathname + search + hash;
  62557. };
  62558. function urlResolve(source, relative) {
  62559. return urlParse(source, false, true).resolve(relative);
  62560. }
  62561. Url.prototype.resolve = function(relative) {
  62562. return this.resolveObject(urlParse(relative, false, true)).format();
  62563. };
  62564. function urlResolveObject(source, relative) {
  62565. if (!source) return relative;
  62566. return urlParse(source, false, true).resolveObject(relative);
  62567. }
  62568. Url.prototype.resolveObject = function(relative) {
  62569. if (util.isString(relative)) {
  62570. var rel = new Url();
  62571. rel.parse(relative, false, true);
  62572. relative = rel;
  62573. }
  62574. var result = new Url();
  62575. var tkeys = Object.keys(this);
  62576. for (var tk = 0; tk < tkeys.length; tk++) {
  62577. var tkey = tkeys[tk];
  62578. result[tkey] = this[tkey];
  62579. }
  62580. // hash is always overridden, no matter what.
  62581. // even href="" will remove it.
  62582. result.hash = relative.hash;
  62583. // if the relative url is empty, then there's nothing left to do here.
  62584. if (relative.href === '') {
  62585. result.href = result.format();
  62586. return result;
  62587. }
  62588. // hrefs like //foo/bar always cut to the protocol.
  62589. if (relative.slashes && !relative.protocol) {
  62590. // take everything except the protocol from relative
  62591. var rkeys = Object.keys(relative);
  62592. for (var rk = 0; rk < rkeys.length; rk++) {
  62593. var rkey = rkeys[rk];
  62594. if (rkey !== 'protocol')
  62595. result[rkey] = relative[rkey];
  62596. }
  62597. //urlParse appends trailing / to urls like http://www.example.com
  62598. if (slashedProtocol[result.protocol] &&
  62599. result.hostname && !result.pathname) {
  62600. result.path = result.pathname = '/';
  62601. }
  62602. result.href = result.format();
  62603. return result;
  62604. }
  62605. if (relative.protocol && relative.protocol !== result.protocol) {
  62606. // if it's a known url protocol, then changing
  62607. // the protocol does weird things
  62608. // first, if it's not file:, then we MUST have a host,
  62609. // and if there was a path
  62610. // to begin with, then we MUST have a path.
  62611. // if it is file:, then the host is dropped,
  62612. // because that's known to be hostless.
  62613. // anything else is assumed to be absolute.
  62614. if (!slashedProtocol[relative.protocol]) {
  62615. var keys = Object.keys(relative);
  62616. for (var v = 0; v < keys.length; v++) {
  62617. var k = keys[v];
  62618. result[k] = relative[k];
  62619. }
  62620. result.href = result.format();
  62621. return result;
  62622. }
  62623. result.protocol = relative.protocol;
  62624. if (!relative.host && !hostlessProtocol[relative.protocol]) {
  62625. var relPath = (relative.pathname || '').split('/');
  62626. while (relPath.length && !(relative.host = relPath.shift()));
  62627. if (!relative.host) relative.host = '';
  62628. if (!relative.hostname) relative.hostname = '';
  62629. if (relPath[0] !== '') relPath.unshift('');
  62630. if (relPath.length < 2) relPath.unshift('');
  62631. result.pathname = relPath.join('/');
  62632. } else {
  62633. result.pathname = relative.pathname;
  62634. }
  62635. result.search = relative.search;
  62636. result.query = relative.query;
  62637. result.host = relative.host || '';
  62638. result.auth = relative.auth;
  62639. result.hostname = relative.hostname || relative.host;
  62640. result.port = relative.port;
  62641. // to support http.request
  62642. if (result.pathname || result.search) {
  62643. var p = result.pathname || '';
  62644. var s = result.search || '';
  62645. result.path = p + s;
  62646. }
  62647. result.slashes = result.slashes || relative.slashes;
  62648. result.href = result.format();
  62649. return result;
  62650. }
  62651. var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
  62652. isRelAbs = (
  62653. relative.host ||
  62654. relative.pathname && relative.pathname.charAt(0) === '/'
  62655. ),
  62656. mustEndAbs = (isRelAbs || isSourceAbs ||
  62657. (result.host && relative.pathname)),
  62658. removeAllDots = mustEndAbs,
  62659. srcPath = result.pathname && result.pathname.split('/') || [],
  62660. relPath = relative.pathname && relative.pathname.split('/') || [],
  62661. psychotic = result.protocol && !slashedProtocol[result.protocol];
  62662. // if the url is a non-slashed url, then relative
  62663. // links like ../.. should be able
  62664. // to crawl up to the hostname, as well. This is strange.
  62665. // result.protocol has already been set by now.
  62666. // Later on, put the first path part into the host field.
  62667. if (psychotic) {
  62668. result.hostname = '';
  62669. result.port = null;
  62670. if (result.host) {
  62671. if (srcPath[0] === '') srcPath[0] = result.host;
  62672. else srcPath.unshift(result.host);
  62673. }
  62674. result.host = '';
  62675. if (relative.protocol) {
  62676. relative.hostname = null;
  62677. relative.port = null;
  62678. if (relative.host) {
  62679. if (relPath[0] === '') relPath[0] = relative.host;
  62680. else relPath.unshift(relative.host);
  62681. }
  62682. relative.host = null;
  62683. }
  62684. mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
  62685. }
  62686. if (isRelAbs) {
  62687. // it's absolute.
  62688. result.host = (relative.host || relative.host === '') ?
  62689. relative.host : result.host;
  62690. result.hostname = (relative.hostname || relative.hostname === '') ?
  62691. relative.hostname : result.hostname;
  62692. result.search = relative.search;
  62693. result.query = relative.query;
  62694. srcPath = relPath;
  62695. // fall through to the dot-handling below.
  62696. } else if (relPath.length) {
  62697. // it's relative
  62698. // throw away the existing file, and take the new path instead.
  62699. if (!srcPath) srcPath = [];
  62700. srcPath.pop();
  62701. srcPath = srcPath.concat(relPath);
  62702. result.search = relative.search;
  62703. result.query = relative.query;
  62704. } else if (!util.isNullOrUndefined(relative.search)) {
  62705. // just pull out the search.
  62706. // like href='?foo'.
  62707. // Put this after the other two cases because it simplifies the booleans
  62708. if (psychotic) {
  62709. result.hostname = result.host = srcPath.shift();
  62710. //occationaly the auth can get stuck only in host
  62711. //this especially happens in cases like
  62712. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  62713. var authInHost = result.host && result.host.indexOf('@') > 0 ?
  62714. result.host.split('@') : false;
  62715. if (authInHost) {
  62716. result.auth = authInHost.shift();
  62717. result.host = result.hostname = authInHost.shift();
  62718. }
  62719. }
  62720. result.search = relative.search;
  62721. result.query = relative.query;
  62722. //to support http.request
  62723. if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
  62724. result.path = (result.pathname ? result.pathname : '') +
  62725. (result.search ? result.search : '');
  62726. }
  62727. result.href = result.format();
  62728. return result;
  62729. }
  62730. if (!srcPath.length) {
  62731. // no path at all. easy.
  62732. // we've already handled the other stuff above.
  62733. result.pathname = null;
  62734. //to support http.request
  62735. if (result.search) {
  62736. result.path = '/' + result.search;
  62737. } else {
  62738. result.path = null;
  62739. }
  62740. result.href = result.format();
  62741. return result;
  62742. }
  62743. // if a url ENDs in . or .., then it must get a trailing slash.
  62744. // however, if it ends in anything else non-slashy,
  62745. // then it must NOT get a trailing slash.
  62746. var last = srcPath.slice(-1)[0];
  62747. var hasTrailingSlash = (
  62748. (result.host || relative.host || srcPath.length > 1) &&
  62749. (last === '.' || last === '..') || last === '');
  62750. // strip single dots, resolve double dots to parent dir
  62751. // if the path tries to go above the root, `up` ends up > 0
  62752. var up = 0;
  62753. for (var i = srcPath.length; i >= 0; i--) {
  62754. last = srcPath[i];
  62755. if (last === '.') {
  62756. srcPath.splice(i, 1);
  62757. } else if (last === '..') {
  62758. srcPath.splice(i, 1);
  62759. up++;
  62760. } else if (up) {
  62761. srcPath.splice(i, 1);
  62762. up--;
  62763. }
  62764. }
  62765. // if the path is allowed to go above the root, restore leading ..s
  62766. if (!mustEndAbs && !removeAllDots) {
  62767. for (; up--; up) {
  62768. srcPath.unshift('..');
  62769. }
  62770. }
  62771. if (mustEndAbs && srcPath[0] !== '' &&
  62772. (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
  62773. srcPath.unshift('');
  62774. }
  62775. if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
  62776. srcPath.push('');
  62777. }
  62778. var isAbsolute = srcPath[0] === '' ||
  62779. (srcPath[0] && srcPath[0].charAt(0) === '/');
  62780. // put the host back
  62781. if (psychotic) {
  62782. result.hostname = result.host = isAbsolute ? '' :
  62783. srcPath.length ? srcPath.shift() : '';
  62784. //occationaly the auth can get stuck only in host
  62785. //this especially happens in cases like
  62786. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  62787. var authInHost = result.host && result.host.indexOf('@') > 0 ?
  62788. result.host.split('@') : false;
  62789. if (authInHost) {
  62790. result.auth = authInHost.shift();
  62791. result.host = result.hostname = authInHost.shift();
  62792. }
  62793. }
  62794. mustEndAbs = mustEndAbs || (result.host && srcPath.length);
  62795. if (mustEndAbs && !isAbsolute) {
  62796. srcPath.unshift('');
  62797. }
  62798. if (!srcPath.length) {
  62799. result.pathname = null;
  62800. result.path = null;
  62801. } else {
  62802. result.pathname = srcPath.join('/');
  62803. }
  62804. //to support request.http
  62805. if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
  62806. result.path = (result.pathname ? result.pathname : '') +
  62807. (result.search ? result.search : '');
  62808. }
  62809. result.auth = relative.auth || result.auth;
  62810. result.slashes = result.slashes || relative.slashes;
  62811. result.href = result.format();
  62812. return result;
  62813. };
  62814. Url.prototype.parseHost = function() {
  62815. var host = this.host;
  62816. var port = portPattern.exec(host);
  62817. if (port) {
  62818. port = port[0];
  62819. if (port !== ':') {
  62820. this.port = port.substr(1);
  62821. }
  62822. host = host.substr(0, host.length - port.length);
  62823. }
  62824. if (host) this.hostname = host;
  62825. };
  62826. /***/ }),
  62827. /***/ "../../node_modules/url/util.js":
  62828. /*!**************************************!*\
  62829. !*** ../../node_modules/url/util.js ***!
  62830. \**************************************/
  62831. /***/ ((module) => {
  62832. "use strict";
  62833. module.exports = {
  62834. isString: function(arg) {
  62835. return typeof(arg) === 'string';
  62836. },
  62837. isObject: function(arg) {
  62838. return typeof(arg) === 'object' && arg !== null;
  62839. },
  62840. isNull: function(arg) {
  62841. return arg === null;
  62842. },
  62843. isNullOrUndefined: function(arg) {
  62844. return arg == null;
  62845. }
  62846. };
  62847. /***/ }),
  62848. /***/ "../../node_modules/util-deprecate/browser.js":
  62849. /*!****************************************************!*\
  62850. !*** ../../node_modules/util-deprecate/browser.js ***!
  62851. \****************************************************/
  62852. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  62853. /**
  62854. * Module exports.
  62855. */
  62856. module.exports = deprecate;
  62857. /**
  62858. * Mark that a method should not be used.
  62859. * Returns a modified function which warns once by default.
  62860. *
  62861. * If `localStorage.noDeprecation = true` is set, then it is a no-op.
  62862. *
  62863. * If `localStorage.throwDeprecation = true` is set, then deprecated functions
  62864. * will throw an Error when invoked.
  62865. *
  62866. * If `localStorage.traceDeprecation = true` is set, then deprecated functions
  62867. * will invoke `console.trace()` instead of `console.error()`.
  62868. *
  62869. * @param {Function} fn - the function to deprecate
  62870. * @param {String} msg - the string to print to the console when `fn` is invoked
  62871. * @returns {Function} a new "deprecated" version of `fn`
  62872. * @api public
  62873. */
  62874. function deprecate (fn, msg) {
  62875. if (config('noDeprecation')) {
  62876. return fn;
  62877. }
  62878. var warned = false;
  62879. function deprecated() {
  62880. if (!warned) {
  62881. if (config('throwDeprecation')) {
  62882. throw new Error(msg);
  62883. } else if (config('traceDeprecation')) {
  62884. console.trace(msg);
  62885. } else {
  62886. console.warn(msg);
  62887. }
  62888. warned = true;
  62889. }
  62890. return fn.apply(this, arguments);
  62891. }
  62892. return deprecated;
  62893. }
  62894. /**
  62895. * Checks `localStorage` for boolean values for the given `name`.
  62896. *
  62897. * @param {String} name
  62898. * @returns {Boolean}
  62899. * @api private
  62900. */
  62901. function config (name) {
  62902. // accessing global.localStorage can trigger a DOMException in sandboxed iframes
  62903. try {
  62904. if (!__webpack_require__.g.localStorage) return false;
  62905. } catch (_) {
  62906. return false;
  62907. }
  62908. var val = __webpack_require__.g.localStorage[name];
  62909. if (null == val) return false;
  62910. return String(val).toLowerCase() === 'true';
  62911. }
  62912. /***/ }),
  62913. /***/ "../../node_modules/util/support/isBufferBrowser.js":
  62914. /*!**********************************************************!*\
  62915. !*** ../../node_modules/util/support/isBufferBrowser.js ***!
  62916. \**********************************************************/
  62917. /***/ ((module) => {
  62918. module.exports = function isBuffer(arg) {
  62919. return arg && typeof arg === 'object'
  62920. && typeof arg.copy === 'function'
  62921. && typeof arg.fill === 'function'
  62922. && typeof arg.readUInt8 === 'function';
  62923. }
  62924. /***/ }),
  62925. /***/ "../../node_modules/util/support/types.js":
  62926. /*!************************************************!*\
  62927. !*** ../../node_modules/util/support/types.js ***!
  62928. \************************************************/
  62929. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  62930. "use strict";
  62931. // Currently in sync with Node.js lib/internal/util/types.js
  62932. // https://github.com/nodejs/node/commit/112cc7c27551254aa2b17098fb774867f05ed0d9
  62933. var isArgumentsObject = __webpack_require__(/*! is-arguments */ "../../node_modules/is-arguments/index.js");
  62934. var isGeneratorFunction = __webpack_require__(/*! is-generator-function */ "../../node_modules/is-generator-function/index.js");
  62935. var whichTypedArray = __webpack_require__(/*! which-typed-array */ "../../node_modules/which-typed-array/index.js");
  62936. var isTypedArray = __webpack_require__(/*! is-typed-array */ "../../node_modules/is-typed-array/index.js");
  62937. function uncurryThis(f) {
  62938. return f.call.bind(f);
  62939. }
  62940. var BigIntSupported = typeof BigInt !== 'undefined';
  62941. var SymbolSupported = typeof Symbol !== 'undefined';
  62942. var ObjectToString = uncurryThis(Object.prototype.toString);
  62943. var numberValue = uncurryThis(Number.prototype.valueOf);
  62944. var stringValue = uncurryThis(String.prototype.valueOf);
  62945. var booleanValue = uncurryThis(Boolean.prototype.valueOf);
  62946. if (BigIntSupported) {
  62947. var bigIntValue = uncurryThis(BigInt.prototype.valueOf);
  62948. }
  62949. if (SymbolSupported) {
  62950. var symbolValue = uncurryThis(Symbol.prototype.valueOf);
  62951. }
  62952. function checkBoxedPrimitive(value, prototypeValueOf) {
  62953. if (typeof value !== 'object') {
  62954. return false;
  62955. }
  62956. try {
  62957. prototypeValueOf(value);
  62958. return true;
  62959. } catch(e) {
  62960. return false;
  62961. }
  62962. }
  62963. exports.isArgumentsObject = isArgumentsObject;
  62964. exports.isGeneratorFunction = isGeneratorFunction;
  62965. exports.isTypedArray = isTypedArray;
  62966. // Taken from here and modified for better browser support
  62967. // https://github.com/sindresorhus/p-is-promise/blob/cda35a513bda03f977ad5cde3a079d237e82d7ef/index.js
  62968. function isPromise(input) {
  62969. return (
  62970. (
  62971. typeof Promise !== 'undefined' &&
  62972. input instanceof Promise
  62973. ) ||
  62974. (
  62975. input !== null &&
  62976. typeof input === 'object' &&
  62977. typeof input.then === 'function' &&
  62978. typeof input.catch === 'function'
  62979. )
  62980. );
  62981. }
  62982. exports.isPromise = isPromise;
  62983. function isArrayBufferView(value) {
  62984. if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) {
  62985. return ArrayBuffer.isView(value);
  62986. }
  62987. return (
  62988. isTypedArray(value) ||
  62989. isDataView(value)
  62990. );
  62991. }
  62992. exports.isArrayBufferView = isArrayBufferView;
  62993. function isUint8Array(value) {
  62994. return whichTypedArray(value) === 'Uint8Array';
  62995. }
  62996. exports.isUint8Array = isUint8Array;
  62997. function isUint8ClampedArray(value) {
  62998. return whichTypedArray(value) === 'Uint8ClampedArray';
  62999. }
  63000. exports.isUint8ClampedArray = isUint8ClampedArray;
  63001. function isUint16Array(value) {
  63002. return whichTypedArray(value) === 'Uint16Array';
  63003. }
  63004. exports.isUint16Array = isUint16Array;
  63005. function isUint32Array(value) {
  63006. return whichTypedArray(value) === 'Uint32Array';
  63007. }
  63008. exports.isUint32Array = isUint32Array;
  63009. function isInt8Array(value) {
  63010. return whichTypedArray(value) === 'Int8Array';
  63011. }
  63012. exports.isInt8Array = isInt8Array;
  63013. function isInt16Array(value) {
  63014. return whichTypedArray(value) === 'Int16Array';
  63015. }
  63016. exports.isInt16Array = isInt16Array;
  63017. function isInt32Array(value) {
  63018. return whichTypedArray(value) === 'Int32Array';
  63019. }
  63020. exports.isInt32Array = isInt32Array;
  63021. function isFloat32Array(value) {
  63022. return whichTypedArray(value) === 'Float32Array';
  63023. }
  63024. exports.isFloat32Array = isFloat32Array;
  63025. function isFloat64Array(value) {
  63026. return whichTypedArray(value) === 'Float64Array';
  63027. }
  63028. exports.isFloat64Array = isFloat64Array;
  63029. function isBigInt64Array(value) {
  63030. return whichTypedArray(value) === 'BigInt64Array';
  63031. }
  63032. exports.isBigInt64Array = isBigInt64Array;
  63033. function isBigUint64Array(value) {
  63034. return whichTypedArray(value) === 'BigUint64Array';
  63035. }
  63036. exports.isBigUint64Array = isBigUint64Array;
  63037. function isMapToString(value) {
  63038. return ObjectToString(value) === '[object Map]';
  63039. }
  63040. isMapToString.working = (
  63041. typeof Map !== 'undefined' &&
  63042. isMapToString(new Map())
  63043. );
  63044. function isMap(value) {
  63045. if (typeof Map === 'undefined') {
  63046. return false;
  63047. }
  63048. return isMapToString.working
  63049. ? isMapToString(value)
  63050. : value instanceof Map;
  63051. }
  63052. exports.isMap = isMap;
  63053. function isSetToString(value) {
  63054. return ObjectToString(value) === '[object Set]';
  63055. }
  63056. isSetToString.working = (
  63057. typeof Set !== 'undefined' &&
  63058. isSetToString(new Set())
  63059. );
  63060. function isSet(value) {
  63061. if (typeof Set === 'undefined') {
  63062. return false;
  63063. }
  63064. return isSetToString.working
  63065. ? isSetToString(value)
  63066. : value instanceof Set;
  63067. }
  63068. exports.isSet = isSet;
  63069. function isWeakMapToString(value) {
  63070. return ObjectToString(value) === '[object WeakMap]';
  63071. }
  63072. isWeakMapToString.working = (
  63073. typeof WeakMap !== 'undefined' &&
  63074. isWeakMapToString(new WeakMap())
  63075. );
  63076. function isWeakMap(value) {
  63077. if (typeof WeakMap === 'undefined') {
  63078. return false;
  63079. }
  63080. return isWeakMapToString.working
  63081. ? isWeakMapToString(value)
  63082. : value instanceof WeakMap;
  63083. }
  63084. exports.isWeakMap = isWeakMap;
  63085. function isWeakSetToString(value) {
  63086. return ObjectToString(value) === '[object WeakSet]';
  63087. }
  63088. isWeakSetToString.working = (
  63089. typeof WeakSet !== 'undefined' &&
  63090. isWeakSetToString(new WeakSet())
  63091. );
  63092. function isWeakSet(value) {
  63093. return isWeakSetToString(value);
  63094. }
  63095. exports.isWeakSet = isWeakSet;
  63096. function isArrayBufferToString(value) {
  63097. return ObjectToString(value) === '[object ArrayBuffer]';
  63098. }
  63099. isArrayBufferToString.working = (
  63100. typeof ArrayBuffer !== 'undefined' &&
  63101. isArrayBufferToString(new ArrayBuffer())
  63102. );
  63103. function isArrayBuffer(value) {
  63104. if (typeof ArrayBuffer === 'undefined') {
  63105. return false;
  63106. }
  63107. return isArrayBufferToString.working
  63108. ? isArrayBufferToString(value)
  63109. : value instanceof ArrayBuffer;
  63110. }
  63111. exports.isArrayBuffer = isArrayBuffer;
  63112. function isDataViewToString(value) {
  63113. return ObjectToString(value) === '[object DataView]';
  63114. }
  63115. isDataViewToString.working = (
  63116. typeof ArrayBuffer !== 'undefined' &&
  63117. typeof DataView !== 'undefined' &&
  63118. isDataViewToString(new DataView(new ArrayBuffer(1), 0, 1))
  63119. );
  63120. function isDataView(value) {
  63121. if (typeof DataView === 'undefined') {
  63122. return false;
  63123. }
  63124. return isDataViewToString.working
  63125. ? isDataViewToString(value)
  63126. : value instanceof DataView;
  63127. }
  63128. exports.isDataView = isDataView;
  63129. // Store a copy of SharedArrayBuffer in case it's deleted elsewhere
  63130. var SharedArrayBufferCopy = typeof SharedArrayBuffer !== 'undefined' ? SharedArrayBuffer : undefined;
  63131. function isSharedArrayBufferToString(value) {
  63132. return ObjectToString(value) === '[object SharedArrayBuffer]';
  63133. }
  63134. function isSharedArrayBuffer(value) {
  63135. if (typeof SharedArrayBufferCopy === 'undefined') {
  63136. return false;
  63137. }
  63138. if (typeof isSharedArrayBufferToString.working === 'undefined') {
  63139. isSharedArrayBufferToString.working = isSharedArrayBufferToString(new SharedArrayBufferCopy());
  63140. }
  63141. return isSharedArrayBufferToString.working
  63142. ? isSharedArrayBufferToString(value)
  63143. : value instanceof SharedArrayBufferCopy;
  63144. }
  63145. exports.isSharedArrayBuffer = isSharedArrayBuffer;
  63146. function isAsyncFunction(value) {
  63147. return ObjectToString(value) === '[object AsyncFunction]';
  63148. }
  63149. exports.isAsyncFunction = isAsyncFunction;
  63150. function isMapIterator(value) {
  63151. return ObjectToString(value) === '[object Map Iterator]';
  63152. }
  63153. exports.isMapIterator = isMapIterator;
  63154. function isSetIterator(value) {
  63155. return ObjectToString(value) === '[object Set Iterator]';
  63156. }
  63157. exports.isSetIterator = isSetIterator;
  63158. function isGeneratorObject(value) {
  63159. return ObjectToString(value) === '[object Generator]';
  63160. }
  63161. exports.isGeneratorObject = isGeneratorObject;
  63162. function isWebAssemblyCompiledModule(value) {
  63163. return ObjectToString(value) === '[object WebAssembly.Module]';
  63164. }
  63165. exports.isWebAssemblyCompiledModule = isWebAssemblyCompiledModule;
  63166. function isNumberObject(value) {
  63167. return checkBoxedPrimitive(value, numberValue);
  63168. }
  63169. exports.isNumberObject = isNumberObject;
  63170. function isStringObject(value) {
  63171. return checkBoxedPrimitive(value, stringValue);
  63172. }
  63173. exports.isStringObject = isStringObject;
  63174. function isBooleanObject(value) {
  63175. return checkBoxedPrimitive(value, booleanValue);
  63176. }
  63177. exports.isBooleanObject = isBooleanObject;
  63178. function isBigIntObject(value) {
  63179. return BigIntSupported && checkBoxedPrimitive(value, bigIntValue);
  63180. }
  63181. exports.isBigIntObject = isBigIntObject;
  63182. function isSymbolObject(value) {
  63183. return SymbolSupported && checkBoxedPrimitive(value, symbolValue);
  63184. }
  63185. exports.isSymbolObject = isSymbolObject;
  63186. function isBoxedPrimitive(value) {
  63187. return (
  63188. isNumberObject(value) ||
  63189. isStringObject(value) ||
  63190. isBooleanObject(value) ||
  63191. isBigIntObject(value) ||
  63192. isSymbolObject(value)
  63193. );
  63194. }
  63195. exports.isBoxedPrimitive = isBoxedPrimitive;
  63196. function isAnyArrayBuffer(value) {
  63197. return typeof Uint8Array !== 'undefined' && (
  63198. isArrayBuffer(value) ||
  63199. isSharedArrayBuffer(value)
  63200. );
  63201. }
  63202. exports.isAnyArrayBuffer = isAnyArrayBuffer;
  63203. ['isProxy', 'isExternal', 'isModuleNamespaceObject'].forEach(function(method) {
  63204. Object.defineProperty(exports, method, {
  63205. enumerable: false,
  63206. value: function() {
  63207. throw new Error(method + ' is not supported in userland');
  63208. }
  63209. });
  63210. });
  63211. /***/ }),
  63212. /***/ "../../node_modules/util/util.js":
  63213. /*!***************************************!*\
  63214. !*** ../../node_modules/util/util.js ***!
  63215. \***************************************/
  63216. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  63217. /* provided dependency */ var process = __webpack_require__(/*! process/browser */ "../../node_modules/process/browser.js");
  63218. // Copyright Joyent, Inc. and other Node contributors.
  63219. //
  63220. // Permission is hereby granted, free of charge, to any person obtaining a
  63221. // copy of this software and associated documentation files (the
  63222. // "Software"), to deal in the Software without restriction, including
  63223. // without limitation the rights to use, copy, modify, merge, publish,
  63224. // distribute, sublicense, and/or sell copies of the Software, and to permit
  63225. // persons to whom the Software is furnished to do so, subject to the
  63226. // following conditions:
  63227. //
  63228. // The above copyright notice and this permission notice shall be included
  63229. // in all copies or substantial portions of the Software.
  63230. //
  63231. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  63232. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  63233. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  63234. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  63235. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  63236. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  63237. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  63238. var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors ||
  63239. function getOwnPropertyDescriptors(obj) {
  63240. var keys = Object.keys(obj);
  63241. var descriptors = {};
  63242. for (var i = 0; i < keys.length; i++) {
  63243. descriptors[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]);
  63244. }
  63245. return descriptors;
  63246. };
  63247. var formatRegExp = /%[sdj%]/g;
  63248. exports.format = function(f) {
  63249. if (!isString(f)) {
  63250. var objects = [];
  63251. for (var i = 0; i < arguments.length; i++) {
  63252. objects.push(inspect(arguments[i]));
  63253. }
  63254. return objects.join(' ');
  63255. }
  63256. var i = 1;
  63257. var args = arguments;
  63258. var len = args.length;
  63259. var str = String(f).replace(formatRegExp, function(x) {
  63260. if (x === '%%') return '%';
  63261. if (i >= len) return x;
  63262. switch (x) {
  63263. case '%s': return String(args[i++]);
  63264. case '%d': return Number(args[i++]);
  63265. case '%j':
  63266. try {
  63267. return JSON.stringify(args[i++]);
  63268. } catch (_) {
  63269. return '[Circular]';
  63270. }
  63271. default:
  63272. return x;
  63273. }
  63274. });
  63275. for (var x = args[i]; i < len; x = args[++i]) {
  63276. if (isNull(x) || !isObject(x)) {
  63277. str += ' ' + x;
  63278. } else {
  63279. str += ' ' + inspect(x);
  63280. }
  63281. }
  63282. return str;
  63283. };
  63284. // Mark that a method should not be used.
  63285. // Returns a modified function which warns once by default.
  63286. // If --no-deprecation is set, then it is a no-op.
  63287. exports.deprecate = function(fn, msg) {
  63288. if (typeof process !== 'undefined' && process.noDeprecation === true) {
  63289. return fn;
  63290. }
  63291. // Allow for deprecating things in the process of starting up.
  63292. if (typeof process === 'undefined') {
  63293. return function() {
  63294. return exports.deprecate(fn, msg).apply(this, arguments);
  63295. };
  63296. }
  63297. var warned = false;
  63298. function deprecated() {
  63299. if (!warned) {
  63300. if (process.throwDeprecation) {
  63301. throw new Error(msg);
  63302. } else if (process.traceDeprecation) {
  63303. console.trace(msg);
  63304. } else {
  63305. console.error(msg);
  63306. }
  63307. warned = true;
  63308. }
  63309. return fn.apply(this, arguments);
  63310. }
  63311. return deprecated;
  63312. };
  63313. var debugs = {};
  63314. var debugEnvRegex = /^$/;
  63315. if (process.env.NODE_DEBUG) {
  63316. var debugEnv = process.env.NODE_DEBUG;
  63317. debugEnv = debugEnv.replace(/[|\\{}()[\]^$+?.]/g, '\\$&')
  63318. .replace(/\*/g, '.*')
  63319. .replace(/,/g, '$|^')
  63320. .toUpperCase();
  63321. debugEnvRegex = new RegExp('^' + debugEnv + '$', 'i');
  63322. }
  63323. exports.debuglog = function(set) {
  63324. set = set.toUpperCase();
  63325. if (!debugs[set]) {
  63326. if (debugEnvRegex.test(set)) {
  63327. var pid = process.pid;
  63328. debugs[set] = function() {
  63329. var msg = exports.format.apply(exports, arguments);
  63330. console.error('%s %d: %s', set, pid, msg);
  63331. };
  63332. } else {
  63333. debugs[set] = function() {};
  63334. }
  63335. }
  63336. return debugs[set];
  63337. };
  63338. /**
  63339. * Echos the value of a value. Trys to print the value out
  63340. * in the best way possible given the different types.
  63341. *
  63342. * @param {Object} obj The object to print out.
  63343. * @param {Object} opts Optional options object that alters the output.
  63344. */
  63345. /* legacy: obj, showHidden, depth, colors*/
  63346. function inspect(obj, opts) {
  63347. // default options
  63348. var ctx = {
  63349. seen: [],
  63350. stylize: stylizeNoColor
  63351. };
  63352. // legacy...
  63353. if (arguments.length >= 3) ctx.depth = arguments[2];
  63354. if (arguments.length >= 4) ctx.colors = arguments[3];
  63355. if (isBoolean(opts)) {
  63356. // legacy...
  63357. ctx.showHidden = opts;
  63358. } else if (opts) {
  63359. // got an "options" object
  63360. exports._extend(ctx, opts);
  63361. }
  63362. // set default options
  63363. if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
  63364. if (isUndefined(ctx.depth)) ctx.depth = 2;
  63365. if (isUndefined(ctx.colors)) ctx.colors = false;
  63366. if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
  63367. if (ctx.colors) ctx.stylize = stylizeWithColor;
  63368. return formatValue(ctx, obj, ctx.depth);
  63369. }
  63370. exports.inspect = inspect;
  63371. // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  63372. inspect.colors = {
  63373. 'bold' : [1, 22],
  63374. 'italic' : [3, 23],
  63375. 'underline' : [4, 24],
  63376. 'inverse' : [7, 27],
  63377. 'white' : [37, 39],
  63378. 'grey' : [90, 39],
  63379. 'black' : [30, 39],
  63380. 'blue' : [34, 39],
  63381. 'cyan' : [36, 39],
  63382. 'green' : [32, 39],
  63383. 'magenta' : [35, 39],
  63384. 'red' : [31, 39],
  63385. 'yellow' : [33, 39]
  63386. };
  63387. // Don't use 'blue' not visible on cmd.exe
  63388. inspect.styles = {
  63389. 'special': 'cyan',
  63390. 'number': 'yellow',
  63391. 'boolean': 'yellow',
  63392. 'undefined': 'grey',
  63393. 'null': 'bold',
  63394. 'string': 'green',
  63395. 'date': 'magenta',
  63396. // "name": intentionally not styling
  63397. 'regexp': 'red'
  63398. };
  63399. function stylizeWithColor(str, styleType) {
  63400. var style = inspect.styles[styleType];
  63401. if (style) {
  63402. return '\u001b[' + inspect.colors[style][0] + 'm' + str +
  63403. '\u001b[' + inspect.colors[style][1] + 'm';
  63404. } else {
  63405. return str;
  63406. }
  63407. }
  63408. function stylizeNoColor(str, styleType) {
  63409. return str;
  63410. }
  63411. function arrayToHash(array) {
  63412. var hash = {};
  63413. array.forEach(function(val, idx) {
  63414. hash[val] = true;
  63415. });
  63416. return hash;
  63417. }
  63418. function formatValue(ctx, value, recurseTimes) {
  63419. // Provide a hook for user-specified inspect functions.
  63420. // Check that value is an object with an inspect function on it
  63421. if (ctx.customInspect &&
  63422. value &&
  63423. isFunction(value.inspect) &&
  63424. // Filter out the util module, it's inspect function is special
  63425. value.inspect !== exports.inspect &&
  63426. // Also filter out any prototype objects using the circular check.
  63427. !(value.constructor && value.constructor.prototype === value)) {
  63428. var ret = value.inspect(recurseTimes, ctx);
  63429. if (!isString(ret)) {
  63430. ret = formatValue(ctx, ret, recurseTimes);
  63431. }
  63432. return ret;
  63433. }
  63434. // Primitive types cannot have properties
  63435. var primitive = formatPrimitive(ctx, value);
  63436. if (primitive) {
  63437. return primitive;
  63438. }
  63439. // Look up the keys of the object.
  63440. var keys = Object.keys(value);
  63441. var visibleKeys = arrayToHash(keys);
  63442. if (ctx.showHidden) {
  63443. keys = Object.getOwnPropertyNames(value);
  63444. }
  63445. // IE doesn't make error fields non-enumerable
  63446. // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
  63447. if (isError(value)
  63448. && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
  63449. return formatError(value);
  63450. }
  63451. // Some type of object without properties can be shortcutted.
  63452. if (keys.length === 0) {
  63453. if (isFunction(value)) {
  63454. var name = value.name ? ': ' + value.name : '';
  63455. return ctx.stylize('[Function' + name + ']', 'special');
  63456. }
  63457. if (isRegExp(value)) {
  63458. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  63459. }
  63460. if (isDate(value)) {
  63461. return ctx.stylize(Date.prototype.toString.call(value), 'date');
  63462. }
  63463. if (isError(value)) {
  63464. return formatError(value);
  63465. }
  63466. }
  63467. var base = '', array = false, braces = ['{', '}'];
  63468. // Make Array say that they are Array
  63469. if (isArray(value)) {
  63470. array = true;
  63471. braces = ['[', ']'];
  63472. }
  63473. // Make functions say that they are functions
  63474. if (isFunction(value)) {
  63475. var n = value.name ? ': ' + value.name : '';
  63476. base = ' [Function' + n + ']';
  63477. }
  63478. // Make RegExps say that they are RegExps
  63479. if (isRegExp(value)) {
  63480. base = ' ' + RegExp.prototype.toString.call(value);
  63481. }
  63482. // Make dates with properties first say the date
  63483. if (isDate(value)) {
  63484. base = ' ' + Date.prototype.toUTCString.call(value);
  63485. }
  63486. // Make error with message first say the error
  63487. if (isError(value)) {
  63488. base = ' ' + formatError(value);
  63489. }
  63490. if (keys.length === 0 && (!array || value.length == 0)) {
  63491. return braces[0] + base + braces[1];
  63492. }
  63493. if (recurseTimes < 0) {
  63494. if (isRegExp(value)) {
  63495. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  63496. } else {
  63497. return ctx.stylize('[Object]', 'special');
  63498. }
  63499. }
  63500. ctx.seen.push(value);
  63501. var output;
  63502. if (array) {
  63503. output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
  63504. } else {
  63505. output = keys.map(function(key) {
  63506. return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
  63507. });
  63508. }
  63509. ctx.seen.pop();
  63510. return reduceToSingleString(output, base, braces);
  63511. }
  63512. function formatPrimitive(ctx, value) {
  63513. if (isUndefined(value))
  63514. return ctx.stylize('undefined', 'undefined');
  63515. if (isString(value)) {
  63516. var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
  63517. .replace(/'/g, "\\'")
  63518. .replace(/\\"/g, '"') + '\'';
  63519. return ctx.stylize(simple, 'string');
  63520. }
  63521. if (isNumber(value))
  63522. return ctx.stylize('' + value, 'number');
  63523. if (isBoolean(value))
  63524. return ctx.stylize('' + value, 'boolean');
  63525. // For some reason typeof null is "object", so special case here.
  63526. if (isNull(value))
  63527. return ctx.stylize('null', 'null');
  63528. }
  63529. function formatError(value) {
  63530. return '[' + Error.prototype.toString.call(value) + ']';
  63531. }
  63532. function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
  63533. var output = [];
  63534. for (var i = 0, l = value.length; i < l; ++i) {
  63535. if (hasOwnProperty(value, String(i))) {
  63536. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  63537. String(i), true));
  63538. } else {
  63539. output.push('');
  63540. }
  63541. }
  63542. keys.forEach(function(key) {
  63543. if (!key.match(/^\d+$/)) {
  63544. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  63545. key, true));
  63546. }
  63547. });
  63548. return output;
  63549. }
  63550. function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
  63551. var name, str, desc;
  63552. desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
  63553. if (desc.get) {
  63554. if (desc.set) {
  63555. str = ctx.stylize('[Getter/Setter]', 'special');
  63556. } else {
  63557. str = ctx.stylize('[Getter]', 'special');
  63558. }
  63559. } else {
  63560. if (desc.set) {
  63561. str = ctx.stylize('[Setter]', 'special');
  63562. }
  63563. }
  63564. if (!hasOwnProperty(visibleKeys, key)) {
  63565. name = '[' + key + ']';
  63566. }
  63567. if (!str) {
  63568. if (ctx.seen.indexOf(desc.value) < 0) {
  63569. if (isNull(recurseTimes)) {
  63570. str = formatValue(ctx, desc.value, null);
  63571. } else {
  63572. str = formatValue(ctx, desc.value, recurseTimes - 1);
  63573. }
  63574. if (str.indexOf('\n') > -1) {
  63575. if (array) {
  63576. str = str.split('\n').map(function(line) {
  63577. return ' ' + line;
  63578. }).join('\n').slice(2);
  63579. } else {
  63580. str = '\n' + str.split('\n').map(function(line) {
  63581. return ' ' + line;
  63582. }).join('\n');
  63583. }
  63584. }
  63585. } else {
  63586. str = ctx.stylize('[Circular]', 'special');
  63587. }
  63588. }
  63589. if (isUndefined(name)) {
  63590. if (array && key.match(/^\d+$/)) {
  63591. return str;
  63592. }
  63593. name = JSON.stringify('' + key);
  63594. if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
  63595. name = name.slice(1, -1);
  63596. name = ctx.stylize(name, 'name');
  63597. } else {
  63598. name = name.replace(/'/g, "\\'")
  63599. .replace(/\\"/g, '"')
  63600. .replace(/(^"|"$)/g, "'");
  63601. name = ctx.stylize(name, 'string');
  63602. }
  63603. }
  63604. return name + ': ' + str;
  63605. }
  63606. function reduceToSingleString(output, base, braces) {
  63607. var numLinesEst = 0;
  63608. var length = output.reduce(function(prev, cur) {
  63609. numLinesEst++;
  63610. if (cur.indexOf('\n') >= 0) numLinesEst++;
  63611. return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
  63612. }, 0);
  63613. if (length > 60) {
  63614. return braces[0] +
  63615. (base === '' ? '' : base + '\n ') +
  63616. ' ' +
  63617. output.join(',\n ') +
  63618. ' ' +
  63619. braces[1];
  63620. }
  63621. return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  63622. }
  63623. // NOTE: These type checking functions intentionally don't use `instanceof`
  63624. // because it is fragile and can be easily faked with `Object.create()`.
  63625. exports.types = __webpack_require__(/*! ./support/types */ "../../node_modules/util/support/types.js");
  63626. function isArray(ar) {
  63627. return Array.isArray(ar);
  63628. }
  63629. exports.isArray = isArray;
  63630. function isBoolean(arg) {
  63631. return typeof arg === 'boolean';
  63632. }
  63633. exports.isBoolean = isBoolean;
  63634. function isNull(arg) {
  63635. return arg === null;
  63636. }
  63637. exports.isNull = isNull;
  63638. function isNullOrUndefined(arg) {
  63639. return arg == null;
  63640. }
  63641. exports.isNullOrUndefined = isNullOrUndefined;
  63642. function isNumber(arg) {
  63643. return typeof arg === 'number';
  63644. }
  63645. exports.isNumber = isNumber;
  63646. function isString(arg) {
  63647. return typeof arg === 'string';
  63648. }
  63649. exports.isString = isString;
  63650. function isSymbol(arg) {
  63651. return typeof arg === 'symbol';
  63652. }
  63653. exports.isSymbol = isSymbol;
  63654. function isUndefined(arg) {
  63655. return arg === void 0;
  63656. }
  63657. exports.isUndefined = isUndefined;
  63658. function isRegExp(re) {
  63659. return isObject(re) && objectToString(re) === '[object RegExp]';
  63660. }
  63661. exports.isRegExp = isRegExp;
  63662. exports.types.isRegExp = isRegExp;
  63663. function isObject(arg) {
  63664. return typeof arg === 'object' && arg !== null;
  63665. }
  63666. exports.isObject = isObject;
  63667. function isDate(d) {
  63668. return isObject(d) && objectToString(d) === '[object Date]';
  63669. }
  63670. exports.isDate = isDate;
  63671. exports.types.isDate = isDate;
  63672. function isError(e) {
  63673. return isObject(e) &&
  63674. (objectToString(e) === '[object Error]' || e instanceof Error);
  63675. }
  63676. exports.isError = isError;
  63677. exports.types.isNativeError = isError;
  63678. function isFunction(arg) {
  63679. return typeof arg === 'function';
  63680. }
  63681. exports.isFunction = isFunction;
  63682. function isPrimitive(arg) {
  63683. return arg === null ||
  63684. typeof arg === 'boolean' ||
  63685. typeof arg === 'number' ||
  63686. typeof arg === 'string' ||
  63687. typeof arg === 'symbol' || // ES6 symbol
  63688. typeof arg === 'undefined';
  63689. }
  63690. exports.isPrimitive = isPrimitive;
  63691. exports.isBuffer = __webpack_require__(/*! ./support/isBuffer */ "../../node_modules/util/support/isBufferBrowser.js");
  63692. function objectToString(o) {
  63693. return Object.prototype.toString.call(o);
  63694. }
  63695. function pad(n) {
  63696. return n < 10 ? '0' + n.toString(10) : n.toString(10);
  63697. }
  63698. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
  63699. 'Oct', 'Nov', 'Dec'];
  63700. // 26 Feb 16:19:34
  63701. function timestamp() {
  63702. var d = new Date();
  63703. var time = [pad(d.getHours()),
  63704. pad(d.getMinutes()),
  63705. pad(d.getSeconds())].join(':');
  63706. return [d.getDate(), months[d.getMonth()], time].join(' ');
  63707. }
  63708. // log is just a thin wrapper to console.log that prepends a timestamp
  63709. exports.log = function() {
  63710. console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
  63711. };
  63712. /**
  63713. * Inherit the prototype methods from one constructor into another.
  63714. *
  63715. * The Function.prototype.inherits from lang.js rewritten as a standalone
  63716. * function (not on Function.prototype). NOTE: If this file is to be loaded
  63717. * during bootstrapping this function needs to be rewritten using some native
  63718. * functions as prototype setup using normal JavaScript does not work as
  63719. * expected during bootstrapping (see mirror.js in r114903).
  63720. *
  63721. * @param {function} ctor Constructor function which needs to inherit the
  63722. * prototype.
  63723. * @param {function} superCtor Constructor function to inherit prototype from.
  63724. */
  63725. exports.inherits = __webpack_require__(/*! inherits */ "../../node_modules/inherits/inherits_browser.js");
  63726. exports._extend = function(origin, add) {
  63727. // Don't do anything if add isn't an object
  63728. if (!add || !isObject(add)) return origin;
  63729. var keys = Object.keys(add);
  63730. var i = keys.length;
  63731. while (i--) {
  63732. origin[keys[i]] = add[keys[i]];
  63733. }
  63734. return origin;
  63735. };
  63736. function hasOwnProperty(obj, prop) {
  63737. return Object.prototype.hasOwnProperty.call(obj, prop);
  63738. }
  63739. var kCustomPromisifiedSymbol = typeof Symbol !== 'undefined' ? Symbol('util.promisify.custom') : undefined;
  63740. exports.promisify = function promisify(original) {
  63741. if (typeof original !== 'function')
  63742. throw new TypeError('The "original" argument must be of type Function');
  63743. if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) {
  63744. var fn = original[kCustomPromisifiedSymbol];
  63745. if (typeof fn !== 'function') {
  63746. throw new TypeError('The "util.promisify.custom" argument must be of type Function');
  63747. }
  63748. Object.defineProperty(fn, kCustomPromisifiedSymbol, {
  63749. value: fn, enumerable: false, writable: false, configurable: true
  63750. });
  63751. return fn;
  63752. }
  63753. function fn() {
  63754. var promiseResolve, promiseReject;
  63755. var promise = new Promise(function (resolve, reject) {
  63756. promiseResolve = resolve;
  63757. promiseReject = reject;
  63758. });
  63759. var args = [];
  63760. for (var i = 0; i < arguments.length; i++) {
  63761. args.push(arguments[i]);
  63762. }
  63763. args.push(function (err, value) {
  63764. if (err) {
  63765. promiseReject(err);
  63766. } else {
  63767. promiseResolve(value);
  63768. }
  63769. });
  63770. try {
  63771. original.apply(this, args);
  63772. } catch (err) {
  63773. promiseReject(err);
  63774. }
  63775. return promise;
  63776. }
  63777. Object.setPrototypeOf(fn, Object.getPrototypeOf(original));
  63778. if (kCustomPromisifiedSymbol) Object.defineProperty(fn, kCustomPromisifiedSymbol, {
  63779. value: fn, enumerable: false, writable: false, configurable: true
  63780. });
  63781. return Object.defineProperties(
  63782. fn,
  63783. getOwnPropertyDescriptors(original)
  63784. );
  63785. }
  63786. exports.promisify.custom = kCustomPromisifiedSymbol
  63787. function callbackifyOnRejected(reason, cb) {
  63788. // `!reason` guard inspired by bluebird (Ref: https://goo.gl/t5IS6M).
  63789. // Because `null` is a special error value in callbacks which means "no error
  63790. // occurred", we error-wrap so the callback consumer can distinguish between
  63791. // "the promise rejected with null" or "the promise fulfilled with undefined".
  63792. if (!reason) {
  63793. var newReason = new Error('Promise was rejected with a falsy value');
  63794. newReason.reason = reason;
  63795. reason = newReason;
  63796. }
  63797. return cb(reason);
  63798. }
  63799. function callbackify(original) {
  63800. if (typeof original !== 'function') {
  63801. throw new TypeError('The "original" argument must be of type Function');
  63802. }
  63803. // We DO NOT return the promise as it gives the user a false sense that
  63804. // the promise is actually somehow related to the callback's execution
  63805. // and that the callback throwing will reject the promise.
  63806. function callbackified() {
  63807. var args = [];
  63808. for (var i = 0; i < arguments.length; i++) {
  63809. args.push(arguments[i]);
  63810. }
  63811. var maybeCb = args.pop();
  63812. if (typeof maybeCb !== 'function') {
  63813. throw new TypeError('The last argument must be of type Function');
  63814. }
  63815. var self = this;
  63816. var cb = function() {
  63817. return maybeCb.apply(self, arguments);
  63818. };
  63819. // In true node style we process the callback on `nextTick` with all the
  63820. // implications (stack, `uncaughtException`, `async_hooks`)
  63821. original.apply(this, args)
  63822. .then(function(ret) { process.nextTick(cb.bind(null, null, ret)) },
  63823. function(rej) { process.nextTick(callbackifyOnRejected.bind(null, rej, cb)) });
  63824. }
  63825. Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original));
  63826. Object.defineProperties(callbackified,
  63827. getOwnPropertyDescriptors(original));
  63828. return callbackified;
  63829. }
  63830. exports.callbackify = callbackify;
  63831. /***/ }),
  63832. /***/ "../../node_modules/which-typed-array/index.js":
  63833. /*!*****************************************************!*\
  63834. !*** ../../node_modules/which-typed-array/index.js ***!
  63835. \*****************************************************/
  63836. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  63837. "use strict";
  63838. var forEach = __webpack_require__(/*! for-each */ "../../node_modules/for-each/index.js");
  63839. var availableTypedArrays = __webpack_require__(/*! available-typed-arrays */ "../../node_modules/available-typed-arrays/index.js");
  63840. var callBound = __webpack_require__(/*! call-bind/callBound */ "../../node_modules/call-bind/callBound.js");
  63841. var gOPD = __webpack_require__(/*! gopd */ "../../node_modules/gopd/index.js");
  63842. var $toString = callBound('Object.prototype.toString');
  63843. var hasToStringTag = __webpack_require__(/*! has-tostringtag/shams */ "../../node_modules/has-tostringtag/shams.js")();
  63844. var g = typeof globalThis === 'undefined' ? __webpack_require__.g : globalThis;
  63845. var typedArrays = availableTypedArrays();
  63846. var $slice = callBound('String.prototype.slice');
  63847. var toStrTags = {};
  63848. var getPrototypeOf = Object.getPrototypeOf; // require('getprototypeof');
  63849. if (hasToStringTag && gOPD && getPrototypeOf) {
  63850. forEach(typedArrays, function (typedArray) {
  63851. if (typeof g[typedArray] === 'function') {
  63852. var arr = new g[typedArray]();
  63853. if (Symbol.toStringTag in arr) {
  63854. var proto = getPrototypeOf(arr);
  63855. var descriptor = gOPD(proto, Symbol.toStringTag);
  63856. if (!descriptor) {
  63857. var superProto = getPrototypeOf(proto);
  63858. descriptor = gOPD(superProto, Symbol.toStringTag);
  63859. }
  63860. toStrTags[typedArray] = descriptor.get;
  63861. }
  63862. }
  63863. });
  63864. }
  63865. var tryTypedArrays = function tryAllTypedArrays(value) {
  63866. var foundName = false;
  63867. forEach(toStrTags, function (getter, typedArray) {
  63868. if (!foundName) {
  63869. try {
  63870. var name = getter.call(value);
  63871. if (name === typedArray) {
  63872. foundName = name;
  63873. }
  63874. } catch (e) {}
  63875. }
  63876. });
  63877. return foundName;
  63878. };
  63879. var isTypedArray = __webpack_require__(/*! is-typed-array */ "../../node_modules/is-typed-array/index.js");
  63880. module.exports = function whichTypedArray(value) {
  63881. if (!isTypedArray(value)) { return false; }
  63882. if (!hasToStringTag || !(Symbol.toStringTag in value)) { return $slice($toString(value), 8, -1); }
  63883. return tryTypedArrays(value);
  63884. };
  63885. /***/ }),
  63886. /***/ "../../node_modules/wif/index.js":
  63887. /*!***************************************!*\
  63888. !*** ../../node_modules/wif/index.js ***!
  63889. \***************************************/
  63890. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  63891. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js")["Buffer"];
  63892. var bs58check = __webpack_require__(/*! bs58check */ "../../node_modules/bs58check/index.js")
  63893. function decodeRaw (buffer, version) {
  63894. // check version only if defined
  63895. if (version !== undefined && buffer[0] !== version) throw new Error('Invalid network version')
  63896. // uncompressed
  63897. if (buffer.length === 33) {
  63898. return {
  63899. version: buffer[0],
  63900. privateKey: buffer.slice(1, 33),
  63901. compressed: false
  63902. }
  63903. }
  63904. // invalid length
  63905. if (buffer.length !== 34) throw new Error('Invalid WIF length')
  63906. // invalid compression flag
  63907. if (buffer[33] !== 0x01) throw new Error('Invalid compression flag')
  63908. return {
  63909. version: buffer[0],
  63910. privateKey: buffer.slice(1, 33),
  63911. compressed: true
  63912. }
  63913. }
  63914. function encodeRaw (version, privateKey, compressed) {
  63915. var result = new Buffer(compressed ? 34 : 33)
  63916. result.writeUInt8(version, 0)
  63917. privateKey.copy(result, 1)
  63918. if (compressed) {
  63919. result[33] = 0x01
  63920. }
  63921. return result
  63922. }
  63923. function decode (string, version) {
  63924. return decodeRaw(bs58check.decode(string), version)
  63925. }
  63926. function encode (version, privateKey, compressed) {
  63927. if (typeof version === 'number') return bs58check.encode(encodeRaw(version, privateKey, compressed))
  63928. return bs58check.encode(
  63929. encodeRaw(
  63930. version.version,
  63931. version.privateKey,
  63932. version.compressed
  63933. )
  63934. )
  63935. }
  63936. module.exports = {
  63937. decode: decode,
  63938. decodeRaw: decodeRaw,
  63939. encode: encode,
  63940. encodeRaw: encodeRaw
  63941. }
  63942. /***/ }),
  63943. /***/ "../../node_modules/xtend/immutable.js":
  63944. /*!*********************************************!*\
  63945. !*** ../../node_modules/xtend/immutable.js ***!
  63946. \*********************************************/
  63947. /***/ ((module) => {
  63948. module.exports = extend
  63949. var hasOwnProperty = Object.prototype.hasOwnProperty;
  63950. function extend() {
  63951. var target = {}
  63952. for (var i = 0; i < arguments.length; i++) {
  63953. var source = arguments[i]
  63954. for (var key in source) {
  63955. if (hasOwnProperty.call(source, key)) {
  63956. target[key] = source[key]
  63957. }
  63958. }
  63959. }
  63960. return target
  63961. }
  63962. /***/ }),
  63963. /***/ "./dist/npm/ECDSA.js":
  63964. /*!***************************!*\
  63965. !*** ./dist/npm/ECDSA.js ***!
  63966. \***************************/
  63967. /***/ ((__unused_webpack_module, exports) => {
  63968. "use strict";
  63969. Object.defineProperty(exports, "__esModule", ({ value: true }));
  63970. var ECDSA;
  63971. (function (ECDSA) {
  63972. ECDSA["ed25519"] = "ed25519";
  63973. ECDSA["secp256k1"] = "ecdsa-secp256k1";
  63974. })(ECDSA || (ECDSA = {}));
  63975. exports["default"] = ECDSA;
  63976. /***/ }),
  63977. /***/ "./dist/npm/Wallet/defaultFaucets.js":
  63978. /*!*******************************************!*\
  63979. !*** ./dist/npm/Wallet/defaultFaucets.js ***!
  63980. \*******************************************/
  63981. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  63982. "use strict";
  63983. Object.defineProperty(exports, "__esModule", ({ value: true }));
  63984. exports.getDefaultFaucetPath = exports.getFaucetHost = exports.FaucetNetworkPaths = exports.FaucetNetwork = void 0;
  63985. const errors_1 = __webpack_require__(/*! ../errors */ "./dist/npm/errors.js");
  63986. var FaucetNetwork;
  63987. (function (FaucetNetwork) {
  63988. FaucetNetwork["Testnet"] = "faucet.altnet.rippletest.net";
  63989. FaucetNetwork["Devnet"] = "faucet.devnet.rippletest.net";
  63990. FaucetNetwork["AMMDevnet"] = "ammfaucet.devnet.rippletest.net";
  63991. FaucetNetwork["HooksV2Testnet"] = "hooks-testnet-v2.xrpl-labs.com";
  63992. })(FaucetNetwork = exports.FaucetNetwork || (exports.FaucetNetwork = {}));
  63993. exports.FaucetNetworkPaths = {
  63994. [FaucetNetwork.Testnet]: '/accounts',
  63995. [FaucetNetwork.Devnet]: '/accounts',
  63996. [FaucetNetwork.AMMDevnet]: '/accounts',
  63997. [FaucetNetwork.HooksV2Testnet]: '/accounts',
  63998. };
  63999. function getFaucetHost(client) {
  64000. const connectionUrl = client.url;
  64001. if (connectionUrl.includes('hooks-testnet-v2')) {
  64002. return FaucetNetwork.HooksV2Testnet;
  64003. }
  64004. if (connectionUrl.includes('altnet') || connectionUrl.includes('testnet')) {
  64005. return FaucetNetwork.Testnet;
  64006. }
  64007. if (connectionUrl.includes('amm')) {
  64008. return FaucetNetwork.AMMDevnet;
  64009. }
  64010. if (connectionUrl.includes('devnet')) {
  64011. return FaucetNetwork.Devnet;
  64012. }
  64013. throw new errors_1.XRPLFaucetError('Faucet URL is not defined or inferrable.');
  64014. }
  64015. exports.getFaucetHost = getFaucetHost;
  64016. function getDefaultFaucetPath(hostname) {
  64017. if (hostname === undefined) {
  64018. return '/accounts';
  64019. }
  64020. return exports.FaucetNetworkPaths[hostname] || '/accounts';
  64021. }
  64022. exports.getDefaultFaucetPath = getDefaultFaucetPath;
  64023. /***/ }),
  64024. /***/ "./dist/npm/Wallet/fundWallet.js":
  64025. /*!***************************************!*\
  64026. !*** ./dist/npm/Wallet/fundWallet.js ***!
  64027. \***************************************/
  64028. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  64029. "use strict";
  64030. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js")["Buffer"];
  64031. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  64032. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  64033. return new (P || (P = Promise))(function (resolve, reject) {
  64034. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  64035. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  64036. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  64037. step((generator = generator.apply(thisArg, _arguments || [])).next());
  64038. });
  64039. };
  64040. var __importDefault = (this && this.__importDefault) || function (mod) {
  64041. return (mod && mod.__esModule) ? mod : { "default": mod };
  64042. };
  64043. Object.defineProperty(exports, "__esModule", ({ value: true }));
  64044. const https_1 = __webpack_require__(/*! https */ "../../node_modules/https-browserify/index.js");
  64045. const ripple_address_codec_1 = __webpack_require__(/*! ripple-address-codec */ "../../node_modules/ripple-address-codec/dist/index.js");
  64046. const errors_1 = __webpack_require__(/*! ../errors */ "./dist/npm/errors.js");
  64047. const defaultFaucets_1 = __webpack_require__(/*! ./defaultFaucets */ "./dist/npm/Wallet/defaultFaucets.js");
  64048. const _1 = __importDefault(__webpack_require__(/*! . */ "./dist/npm/Wallet/index.js"));
  64049. const INTERVAL_SECONDS = 1;
  64050. const MAX_ATTEMPTS = 20;
  64051. function fundWallet(wallet, options) {
  64052. return __awaiter(this, void 0, void 0, function* () {
  64053. if (!this.isConnected()) {
  64054. throw new errors_1.RippledError('Client not connected, cannot call faucet');
  64055. }
  64056. const walletToFund = wallet && (0, ripple_address_codec_1.isValidClassicAddress)(wallet.classicAddress)
  64057. ? wallet
  64058. : _1.default.generate();
  64059. const postBody = Buffer.from(new TextEncoder().encode(JSON.stringify({
  64060. destination: walletToFund.classicAddress,
  64061. xrpAmount: options === null || options === void 0 ? void 0 : options.amount,
  64062. })));
  64063. let startingBalance = 0;
  64064. try {
  64065. startingBalance = Number(yield this.getXrpBalance(walletToFund.classicAddress));
  64066. }
  64067. catch (_a) {
  64068. }
  64069. const httpOptions = getHTTPOptions(this, postBody, {
  64070. hostname: options === null || options === void 0 ? void 0 : options.faucetHost,
  64071. pathname: options === null || options === void 0 ? void 0 : options.faucetPath,
  64072. });
  64073. return returnPromise(httpOptions, this, startingBalance, walletToFund, postBody);
  64074. });
  64075. }
  64076. function returnPromise(options, client, startingBalance, walletToFund, postBody) {
  64077. return __awaiter(this, void 0, void 0, function* () {
  64078. return new Promise((resolve, reject) => {
  64079. const request = (0, https_1.request)(options, (response) => {
  64080. const chunks = [];
  64081. response.on('data', (data) => chunks.push(data));
  64082. response.on('end', () => __awaiter(this, void 0, void 0, function* () {
  64083. return onEnd(response, chunks, client, startingBalance, walletToFund, resolve, reject);
  64084. }));
  64085. });
  64086. request.write(postBody);
  64087. request.on('error', (error) => {
  64088. reject(error);
  64089. });
  64090. request.end();
  64091. });
  64092. });
  64093. }
  64094. function getHTTPOptions(client, postBody, options) {
  64095. var _a, _b;
  64096. const finalHostname = (_a = options === null || options === void 0 ? void 0 : options.hostname) !== null && _a !== void 0 ? _a : (0, defaultFaucets_1.getFaucetHost)(client);
  64097. const finalPathname = (_b = options === null || options === void 0 ? void 0 : options.pathname) !== null && _b !== void 0 ? _b : (0, defaultFaucets_1.getDefaultFaucetPath)(finalHostname);
  64098. return {
  64099. hostname: finalHostname,
  64100. port: 443,
  64101. path: finalPathname,
  64102. method: 'POST',
  64103. headers: {
  64104. 'Content-Type': 'application/json',
  64105. 'Content-Length': postBody.length,
  64106. },
  64107. };
  64108. }
  64109. function onEnd(response, chunks, client, startingBalance, walletToFund, resolve, reject) {
  64110. var _a;
  64111. return __awaiter(this, void 0, void 0, function* () {
  64112. const body = Buffer.concat(chunks).toString();
  64113. if ((_a = response.headers['content-type']) === null || _a === void 0 ? void 0 : _a.startsWith('application/json')) {
  64114. const faucetWallet = JSON.parse(body);
  64115. const classicAddress = faucetWallet.account.classicAddress;
  64116. yield processSuccessfulResponse(client, classicAddress, walletToFund, startingBalance, resolve, reject);
  64117. }
  64118. else {
  64119. reject(new errors_1.XRPLFaucetError(`Content type is not \`application/json\`: ${JSON.stringify({
  64120. statusCode: response.statusCode,
  64121. contentType: response.headers['content-type'],
  64122. body,
  64123. })}`));
  64124. }
  64125. });
  64126. }
  64127. function processSuccessfulResponse(client, classicAddress, walletToFund, startingBalance, resolve, reject) {
  64128. return __awaiter(this, void 0, void 0, function* () {
  64129. if (!classicAddress) {
  64130. reject(new errors_1.XRPLFaucetError(`The faucet account is undefined`));
  64131. return;
  64132. }
  64133. try {
  64134. const updatedBalance = yield getUpdatedBalance(client, classicAddress, startingBalance);
  64135. if (updatedBalance > startingBalance) {
  64136. resolve({
  64137. wallet: walletToFund,
  64138. balance: yield getUpdatedBalance(client, walletToFund.classicAddress, startingBalance),
  64139. });
  64140. }
  64141. else {
  64142. reject(new errors_1.XRPLFaucetError(`Unable to fund address with faucet after waiting ${INTERVAL_SECONDS * MAX_ATTEMPTS} seconds`));
  64143. }
  64144. }
  64145. catch (err) {
  64146. if (err instanceof Error) {
  64147. reject(new errors_1.XRPLFaucetError(err.message));
  64148. }
  64149. reject(err);
  64150. }
  64151. });
  64152. }
  64153. function getUpdatedBalance(client, address, originalBalance) {
  64154. return __awaiter(this, void 0, void 0, function* () {
  64155. return new Promise((resolve, reject) => {
  64156. let attempts = MAX_ATTEMPTS;
  64157. const interval = setInterval(() => __awaiter(this, void 0, void 0, function* () {
  64158. if (attempts < 0) {
  64159. clearInterval(interval);
  64160. resolve(originalBalance);
  64161. }
  64162. else {
  64163. attempts -= 1;
  64164. }
  64165. try {
  64166. let newBalance;
  64167. try {
  64168. newBalance = Number(yield client.getXrpBalance(address));
  64169. }
  64170. catch (_a) {
  64171. }
  64172. if (newBalance > originalBalance) {
  64173. clearInterval(interval);
  64174. resolve(newBalance);
  64175. }
  64176. }
  64177. catch (err) {
  64178. clearInterval(interval);
  64179. if (err instanceof Error) {
  64180. reject(new errors_1.XRPLFaucetError(`Unable to check if the address ${address} balance has increased. Error: ${err.message}`));
  64181. }
  64182. reject(err);
  64183. }
  64184. }), INTERVAL_SECONDS * 1000);
  64185. });
  64186. });
  64187. }
  64188. exports["default"] = fundWallet;
  64189. /***/ }),
  64190. /***/ "./dist/npm/Wallet/index.js":
  64191. /*!**********************************!*\
  64192. !*** ./dist/npm/Wallet/index.js ***!
  64193. \**********************************/
  64194. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  64195. "use strict";
  64196. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js")["Buffer"];
  64197. var __importDefault = (this && this.__importDefault) || function (mod) {
  64198. return (mod && mod.__esModule) ? mod : { "default": mod };
  64199. };
  64200. Object.defineProperty(exports, "__esModule", ({ value: true }));
  64201. const bignumber_js_1 = __importDefault(__webpack_require__(/*! bignumber.js */ "../../node_modules/bignumber.js/bignumber.js"));
  64202. const bip32_1 = __webpack_require__(/*! bip32 */ "../../node_modules/bip32/src/index.js");
  64203. const bip39_1 = __webpack_require__(/*! bip39 */ "../../node_modules/bip39/src/index.js");
  64204. const isEqual_1 = __importDefault(__webpack_require__(/*! lodash/isEqual */ "../../node_modules/lodash/isEqual.js"));
  64205. const ripple_address_codec_1 = __webpack_require__(/*! ripple-address-codec */ "../../node_modules/ripple-address-codec/dist/index.js");
  64206. const ripple_binary_codec_1 = __webpack_require__(/*! ripple-binary-codec */ "../../node_modules/ripple-binary-codec/dist/index.js");
  64207. const ripple_keypairs_1 = __webpack_require__(/*! ripple-keypairs */ "../../node_modules/ripple-keypairs/dist/index.js");
  64208. const ECDSA_1 = __importDefault(__webpack_require__(/*! ../ECDSA */ "./dist/npm/ECDSA.js"));
  64209. const errors_1 = __webpack_require__(/*! ../errors */ "./dist/npm/errors.js");
  64210. const common_1 = __webpack_require__(/*! ../models/transactions/common */ "./dist/npm/models/transactions/common.js");
  64211. const utils_1 = __webpack_require__(/*! ../models/utils */ "./dist/npm/models/utils/index.js");
  64212. const utils_2 = __webpack_require__(/*! ../sugar/utils */ "./dist/npm/sugar/utils.js");
  64213. const hashLedger_1 = __webpack_require__(/*! ../utils/hashes/hashLedger */ "./dist/npm/utils/hashes/hashLedger.js");
  64214. const rfc1751_1 = __webpack_require__(/*! ./rfc1751 */ "./dist/npm/Wallet/rfc1751.js");
  64215. const DEFAULT_ALGORITHM = ECDSA_1.default.ed25519;
  64216. const DEFAULT_DERIVATION_PATH = "m/44'/144'/0'/0/0";
  64217. function hexFromBuffer(buffer) {
  64218. return buffer.toString('hex').toUpperCase();
  64219. }
  64220. class Wallet {
  64221. constructor(publicKey, privateKey, opts = {}) {
  64222. this.publicKey = publicKey;
  64223. this.privateKey = privateKey;
  64224. this.classicAddress = opts.masterAddress
  64225. ? (0, utils_2.ensureClassicAddress)(opts.masterAddress)
  64226. : (0, ripple_keypairs_1.deriveAddress)(publicKey);
  64227. this.seed = opts.seed;
  64228. }
  64229. get address() {
  64230. return this.classicAddress;
  64231. }
  64232. static generate(algorithm = DEFAULT_ALGORITHM) {
  64233. const seed = (0, ripple_keypairs_1.generateSeed)({ algorithm });
  64234. return Wallet.fromSeed(seed);
  64235. }
  64236. static fromSeed(seed, opts = {}) {
  64237. return Wallet.deriveWallet(seed, {
  64238. algorithm: opts.algorithm,
  64239. masterAddress: opts.masterAddress,
  64240. });
  64241. }
  64242. static fromEntropy(entropy, opts = {}) {
  64243. var _a;
  64244. const algorithm = (_a = opts.algorithm) !== null && _a !== void 0 ? _a : DEFAULT_ALGORITHM;
  64245. const options = {
  64246. entropy: Uint8Array.from(entropy),
  64247. algorithm,
  64248. };
  64249. const seed = (0, ripple_keypairs_1.generateSeed)(options);
  64250. return Wallet.deriveWallet(seed, {
  64251. algorithm,
  64252. masterAddress: opts.masterAddress,
  64253. });
  64254. }
  64255. static fromMnemonic(mnemonic, opts = {}) {
  64256. var _a;
  64257. if (opts.mnemonicEncoding === 'rfc1751') {
  64258. return Wallet.fromRFC1751Mnemonic(mnemonic, {
  64259. masterAddress: opts.masterAddress,
  64260. algorithm: opts.algorithm,
  64261. });
  64262. }
  64263. if (!(0, bip39_1.validateMnemonic)(mnemonic)) {
  64264. throw new errors_1.ValidationError('Unable to parse the given mnemonic using bip39 encoding');
  64265. }
  64266. const seed = (0, bip39_1.mnemonicToSeedSync)(mnemonic);
  64267. const masterNode = (0, bip32_1.fromSeed)(seed);
  64268. const node = masterNode.derivePath((_a = opts.derivationPath) !== null && _a !== void 0 ? _a : DEFAULT_DERIVATION_PATH);
  64269. if (node.privateKey === undefined) {
  64270. throw new errors_1.ValidationError('Unable to derive privateKey from mnemonic input');
  64271. }
  64272. const publicKey = hexFromBuffer(node.publicKey);
  64273. const privateKey = hexFromBuffer(node.privateKey);
  64274. return new Wallet(publicKey, `00${privateKey}`, {
  64275. masterAddress: opts.masterAddress,
  64276. });
  64277. }
  64278. static fromRFC1751Mnemonic(mnemonic, opts) {
  64279. const seed = (0, rfc1751_1.rfc1751MnemonicToKey)(mnemonic);
  64280. let encodeAlgorithm;
  64281. if (opts.algorithm === ECDSA_1.default.ed25519) {
  64282. encodeAlgorithm = 'ed25519';
  64283. }
  64284. else {
  64285. encodeAlgorithm = 'secp256k1';
  64286. }
  64287. const encodedSeed = (0, ripple_address_codec_1.encodeSeed)(seed, encodeAlgorithm);
  64288. return Wallet.fromSeed(encodedSeed, {
  64289. masterAddress: opts.masterAddress,
  64290. algorithm: opts.algorithm,
  64291. });
  64292. }
  64293. static deriveWallet(seed, opts = {}) {
  64294. var _a;
  64295. const { publicKey, privateKey } = (0, ripple_keypairs_1.deriveKeypair)(seed, {
  64296. algorithm: (_a = opts.algorithm) !== null && _a !== void 0 ? _a : DEFAULT_ALGORITHM,
  64297. });
  64298. return new Wallet(publicKey, privateKey, {
  64299. seed,
  64300. masterAddress: opts.masterAddress,
  64301. });
  64302. }
  64303. sign(transaction, multisign) {
  64304. let multisignAddress = false;
  64305. if (typeof multisign === 'string' && multisign.startsWith('X')) {
  64306. multisignAddress = multisign;
  64307. }
  64308. else if (multisign) {
  64309. multisignAddress = this.classicAddress;
  64310. }
  64311. const tx = Object.assign({}, transaction);
  64312. if (tx.TxnSignature || tx.Signers) {
  64313. throw new errors_1.ValidationError('txJSON must not contain "TxnSignature" or "Signers" properties');
  64314. }
  64315. removeTrailingZeros(tx);
  64316. const txToSignAndEncode = Object.assign({}, tx);
  64317. txToSignAndEncode.SigningPubKey = multisignAddress ? '' : this.publicKey;
  64318. if (multisignAddress) {
  64319. const signer = {
  64320. Account: multisignAddress,
  64321. SigningPubKey: this.publicKey,
  64322. TxnSignature: computeSignature(txToSignAndEncode, this.privateKey, multisignAddress),
  64323. };
  64324. txToSignAndEncode.Signers = [{ Signer: signer }];
  64325. }
  64326. else {
  64327. txToSignAndEncode.TxnSignature = computeSignature(txToSignAndEncode, this.privateKey);
  64328. }
  64329. const serialized = (0, ripple_binary_codec_1.encode)(txToSignAndEncode);
  64330. this.checkTxSerialization(serialized, tx);
  64331. return {
  64332. tx_blob: serialized,
  64333. hash: (0, hashLedger_1.hashSignedTx)(serialized),
  64334. };
  64335. }
  64336. verifyTransaction(signedTransaction) {
  64337. const tx = typeof signedTransaction === 'string'
  64338. ? (0, ripple_binary_codec_1.decode)(signedTransaction)
  64339. : signedTransaction;
  64340. const messageHex = (0, ripple_binary_codec_1.encodeForSigning)(tx);
  64341. const signature = tx.TxnSignature;
  64342. return (0, ripple_keypairs_1.verify)(messageHex, signature, this.publicKey);
  64343. }
  64344. getXAddress(tag = false, isTestnet = false) {
  64345. return (0, ripple_address_codec_1.classicAddressToXAddress)(this.classicAddress, tag, isTestnet);
  64346. }
  64347. checkTxSerialization(serialized, tx) {
  64348. var _a;
  64349. const decoded = (0, ripple_binary_codec_1.decode)(serialized);
  64350. const txCopy = Object.assign({}, tx);
  64351. if (!decoded.TxnSignature && !decoded.Signers) {
  64352. throw new errors_1.ValidationError('Serialized transaction must have a TxnSignature or Signers property');
  64353. }
  64354. delete decoded.TxnSignature;
  64355. delete decoded.Signers;
  64356. if (!tx.SigningPubKey) {
  64357. delete decoded.SigningPubKey;
  64358. }
  64359. (_a = txCopy.Memos) === null || _a === void 0 ? void 0 : _a.map((memo) => {
  64360. const memoCopy = Object.assign({}, memo);
  64361. if (memo.Memo.MemoData) {
  64362. if (!(0, utils_1.isHex)(memo.Memo.MemoData)) {
  64363. throw new errors_1.ValidationError('MemoData field must be a hex value');
  64364. }
  64365. memoCopy.Memo.MemoData = memo.Memo.MemoData.toUpperCase();
  64366. }
  64367. if (memo.Memo.MemoType) {
  64368. if (!(0, utils_1.isHex)(memo.Memo.MemoType)) {
  64369. throw new errors_1.ValidationError('MemoType field must be a hex value');
  64370. }
  64371. memoCopy.Memo.MemoType = memo.Memo.MemoType.toUpperCase();
  64372. }
  64373. if (memo.Memo.MemoFormat) {
  64374. if (!(0, utils_1.isHex)(memo.Memo.MemoFormat)) {
  64375. throw new errors_1.ValidationError('MemoFormat field must be a hex value');
  64376. }
  64377. memoCopy.Memo.MemoFormat = memo.Memo.MemoFormat.toUpperCase();
  64378. }
  64379. return memo;
  64380. });
  64381. if (txCopy.TransactionType === 'NFTokenMint' && txCopy.URI) {
  64382. if (!(0, utils_1.isHex)(txCopy.URI)) {
  64383. throw new errors_1.ValidationError('URI must be a hex value');
  64384. }
  64385. txCopy.URI = txCopy.URI.toUpperCase();
  64386. }
  64387. Object.keys(txCopy).forEach((key) => {
  64388. const standard_currency_code_len = 3;
  64389. if (txCopy[key] && (0, common_1.isIssuedCurrency)(txCopy[key])) {
  64390. const decodedAmount = decoded[key];
  64391. const decodedCurrency = decodedAmount.currency;
  64392. const txCurrency = txCopy[key].currency;
  64393. if (txCurrency.length === standard_currency_code_len &&
  64394. txCurrency.toUpperCase() === 'XRP') {
  64395. throw new errors_1.XrplError(`Trying to sign an issued currency with a similar standard code to XRP (received '${txCurrency}'). XRP is not an issued currency.`);
  64396. }
  64397. const amount = txCopy[key];
  64398. if (amount.currency.length !== decodedCurrency.length) {
  64399. if (decodedCurrency.length === standard_currency_code_len) {
  64400. decodedAmount.currency = isoToHex(decodedCurrency);
  64401. }
  64402. else {
  64403. txCopy[key].currency = isoToHex(txCopy[key].currency);
  64404. }
  64405. }
  64406. }
  64407. });
  64408. if (!(0, isEqual_1.default)(decoded, txCopy)) {
  64409. const data = {
  64410. decoded,
  64411. tx,
  64412. };
  64413. const error = new errors_1.ValidationError('Serialized transaction does not match original txJSON. See error.data', data);
  64414. throw error;
  64415. }
  64416. }
  64417. }
  64418. Wallet.fromSecret = Wallet.fromSeed;
  64419. function computeSignature(tx, privateKey, signAs) {
  64420. if (signAs) {
  64421. const classicAddress = (0, ripple_address_codec_1.isValidXAddress)(signAs)
  64422. ? (0, ripple_address_codec_1.xAddressToClassicAddress)(signAs).classicAddress
  64423. : signAs;
  64424. return (0, ripple_keypairs_1.sign)((0, ripple_binary_codec_1.encodeForMultisigning)(tx, classicAddress), privateKey);
  64425. }
  64426. return (0, ripple_keypairs_1.sign)((0, ripple_binary_codec_1.encodeForSigning)(tx), privateKey);
  64427. }
  64428. function removeTrailingZeros(tx) {
  64429. if (tx.TransactionType === 'Payment' &&
  64430. typeof tx.Amount !== 'string' &&
  64431. tx.Amount.value.includes('.') &&
  64432. tx.Amount.value.endsWith('0')) {
  64433. tx.Amount = Object.assign({}, tx.Amount);
  64434. tx.Amount.value = new bignumber_js_1.default(tx.Amount.value).toString();
  64435. }
  64436. }
  64437. function isoToHex(iso) {
  64438. const bytes = Buffer.alloc(20);
  64439. if (iso !== 'XRP') {
  64440. const isoBytes = iso.split('').map((chr) => chr.charCodeAt(0));
  64441. bytes.set(isoBytes, 12);
  64442. }
  64443. return bytes.toString('hex').toUpperCase();
  64444. }
  64445. exports["default"] = Wallet;
  64446. /***/ }),
  64447. /***/ "./dist/npm/Wallet/rfc1751.js":
  64448. /*!************************************!*\
  64449. !*** ./dist/npm/Wallet/rfc1751.js ***!
  64450. \************************************/
  64451. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  64452. "use strict";
  64453. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js")["Buffer"];
  64454. var __importDefault = (this && this.__importDefault) || function (mod) {
  64455. return (mod && mod.__esModule) ? mod : { "default": mod };
  64456. };
  64457. Object.defineProperty(exports, "__esModule", ({ value: true }));
  64458. exports.keyToRFC1751Mnemonic = exports.rfc1751MnemonicToKey = void 0;
  64459. const rfc1751Words_json_1 = __importDefault(__webpack_require__(/*! ./rfc1751Words.json */ "./dist/npm/Wallet/rfc1751Words.json"));
  64460. const rfc1751WordList = rfc1751Words_json_1.default;
  64461. const BINARY = ['0000', '0001', '0010', '0011', '0100', '0101', '0110', '0111',
  64462. '1000', '1001', '1010', '1011', '1100', '1101', '1110', '1111'];
  64463. function keyToBinary(key) {
  64464. let res = '';
  64465. for (const num of key) {
  64466. res += BINARY[num >> 4] + BINARY[num & 0x0f];
  64467. }
  64468. return res;
  64469. }
  64470. function extract(key, start, length) {
  64471. const subKey = key.substring(start, start + length);
  64472. let acc = 0;
  64473. for (let index = 0; index < subKey.length; index++) {
  64474. acc = acc * 2 + subKey.charCodeAt(index) - 48;
  64475. }
  64476. return acc;
  64477. }
  64478. function keyToRFC1751Mnemonic(hex_key) {
  64479. const buf = Buffer.from(hex_key.replace(/\s+/gu, ''), 'hex');
  64480. let key = bufferToArray(swap128(buf));
  64481. const padding = [];
  64482. for (let index = 0; index < (8 - (key.length % 8)) % 8; index++) {
  64483. padding.push(0);
  64484. }
  64485. key = padding.concat(key);
  64486. const english = [];
  64487. for (let index = 0; index < key.length; index += 8) {
  64488. const subKey = key.slice(index, index + 8);
  64489. let skbin = keyToBinary(subKey);
  64490. let parity = 0;
  64491. for (let j = 0; j < 64; j += 2) {
  64492. parity += extract(skbin, j, 2);
  64493. }
  64494. subKey.push((parity << 6) & 0xff);
  64495. skbin = keyToBinary(subKey);
  64496. for (let j = 0; j < 64; j += 11) {
  64497. english.push(rfc1751WordList[extract(skbin, j, 11)]);
  64498. }
  64499. }
  64500. return english.join(' ');
  64501. }
  64502. exports.keyToRFC1751Mnemonic = keyToRFC1751Mnemonic;
  64503. function rfc1751MnemonicToKey(english) {
  64504. const words = english.split(' ');
  64505. let key = [];
  64506. for (let index = 0; index < words.length; index += 6) {
  64507. const { subKey, word } = getSubKey(words, index);
  64508. const skbin = keyToBinary(subKey);
  64509. let parity = 0;
  64510. for (let j = 0; j < 64; j += 2) {
  64511. parity += extract(skbin, j, 2);
  64512. }
  64513. const cs0 = extract(skbin, 64, 2);
  64514. const cs1 = parity & 3;
  64515. if (cs0 !== cs1) {
  64516. throw new Error(`Parity error at ${word}`);
  64517. }
  64518. key = key.concat(subKey.slice(0, 8));
  64519. }
  64520. const bufferKey = swap128(Buffer.from(key));
  64521. return bufferKey;
  64522. }
  64523. exports.rfc1751MnemonicToKey = rfc1751MnemonicToKey;
  64524. function getSubKey(words, index) {
  64525. const sublist = words.slice(index, index + 6);
  64526. let bits = 0;
  64527. const ch = [0, 0, 0, 0, 0, 0, 0, 0, 0];
  64528. let word = '';
  64529. for (word of sublist) {
  64530. const idx = rfc1751WordList.indexOf(word.toUpperCase());
  64531. if (idx === -1) {
  64532. throw new TypeError(`Expected an RFC1751 word, but received '${word}'. ` +
  64533. `For the full list of words in the RFC1751 encoding see https://datatracker.ietf.org/doc/html/rfc1751`);
  64534. }
  64535. const shift = (8 - ((bits + 11) % 8)) % 8;
  64536. const y = idx << shift;
  64537. const cl = y >> 16;
  64538. const cc = (y >> 8) & 0xff;
  64539. const cr = y & 0xff;
  64540. const t = Math.floor(bits / 8);
  64541. if (shift > 5) {
  64542. ch[t] |= cl;
  64543. ch[t + 1] |= cc;
  64544. ch[t + 2] |= cr;
  64545. }
  64546. else if (shift > -3) {
  64547. ch[t] |= cc;
  64548. ch[t + 1] |= cr;
  64549. }
  64550. else {
  64551. ch[t] |= cr;
  64552. }
  64553. bits += 11;
  64554. }
  64555. const subKey = ch.slice();
  64556. return { subKey, word };
  64557. }
  64558. function bufferToArray(buf) {
  64559. return Array.prototype.slice.call(buf);
  64560. }
  64561. function swap128(buf) {
  64562. const reversedBytes = buf.swap64();
  64563. return Buffer.concat([reversedBytes.slice(8, 16), reversedBytes.slice(0, 8)], 16);
  64564. }
  64565. /***/ }),
  64566. /***/ "./dist/npm/Wallet/signer.js":
  64567. /*!***********************************!*\
  64568. !*** ./dist/npm/Wallet/signer.js ***!
  64569. \***********************************/
  64570. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  64571. "use strict";
  64572. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js")["Buffer"];
  64573. Object.defineProperty(exports, "__esModule", ({ value: true }));
  64574. exports.multisign = exports.verifySignature = exports.authorizeChannel = void 0;
  64575. const bignumber_js_1 = __webpack_require__(/*! bignumber.js */ "../../node_modules/bignumber.js/bignumber.js");
  64576. const lodash_1 = __webpack_require__(/*! lodash */ "../../node_modules/lodash/lodash.js");
  64577. const ripple_address_codec_1 = __webpack_require__(/*! ripple-address-codec */ "../../node_modules/ripple-address-codec/dist/index.js");
  64578. const ripple_binary_codec_1 = __webpack_require__(/*! ripple-binary-codec */ "../../node_modules/ripple-binary-codec/dist/index.js");
  64579. const ripple_keypairs_1 = __webpack_require__(/*! ripple-keypairs */ "../../node_modules/ripple-keypairs/dist/index.js");
  64580. const errors_1 = __webpack_require__(/*! ../errors */ "./dist/npm/errors.js");
  64581. const transactions_1 = __webpack_require__(/*! ../models/transactions */ "./dist/npm/models/transactions/index.js");
  64582. function multisign(transactions) {
  64583. if (transactions.length === 0) {
  64584. throw new errors_1.ValidationError('There were 0 transactions to multisign');
  64585. }
  64586. transactions.forEach((txOrBlob) => {
  64587. const tx = getDecodedTransaction(txOrBlob);
  64588. (0, transactions_1.validate)(tx);
  64589. if (tx.Signers == null || tx.Signers.length === 0) {
  64590. throw new errors_1.ValidationError("For multisigning all transactions must include a Signers field containing an array of signatures. You may have forgotten to pass the 'forMultisign' parameter when signing.");
  64591. }
  64592. if (tx.SigningPubKey !== '') {
  64593. throw new errors_1.ValidationError('SigningPubKey must be an empty string for all transactions when multisigning.');
  64594. }
  64595. });
  64596. const decodedTransactions = transactions.map((txOrBlob) => {
  64597. return getDecodedTransaction(txOrBlob);
  64598. });
  64599. validateTransactionEquivalence(decodedTransactions);
  64600. return (0, ripple_binary_codec_1.encode)(getTransactionWithAllSigners(decodedTransactions));
  64601. }
  64602. exports.multisign = multisign;
  64603. function authorizeChannel(wallet, channelId, amount) {
  64604. const signingData = (0, ripple_binary_codec_1.encodeForSigningClaim)({
  64605. channel: channelId,
  64606. amount,
  64607. });
  64608. return (0, ripple_keypairs_1.sign)(signingData, wallet.privateKey);
  64609. }
  64610. exports.authorizeChannel = authorizeChannel;
  64611. function verifySignature(tx) {
  64612. const decodedTx = getDecodedTransaction(tx);
  64613. return (0, ripple_keypairs_1.verify)((0, ripple_binary_codec_1.encodeForSigning)(decodedTx), decodedTx.TxnSignature, decodedTx.SigningPubKey);
  64614. }
  64615. exports.verifySignature = verifySignature;
  64616. function validateTransactionEquivalence(transactions) {
  64617. const exampleTransaction = JSON.stringify(Object.assign(Object.assign({}, transactions[0]), { Signers: null }));
  64618. if (transactions
  64619. .slice(1)
  64620. .some((tx) => JSON.stringify(Object.assign(Object.assign({}, tx), { Signers: null })) !== exampleTransaction)) {
  64621. throw new errors_1.ValidationError('txJSON is not the same for all signedTransactions');
  64622. }
  64623. }
  64624. function getTransactionWithAllSigners(transactions) {
  64625. const sortedSigners = (0, lodash_1.flatMap)(transactions, (tx) => { var _a; return (_a = tx.Signers) !== null && _a !== void 0 ? _a : []; }).sort(compareSigners);
  64626. return Object.assign(Object.assign({}, transactions[0]), { Signers: sortedSigners });
  64627. }
  64628. function compareSigners(left, right) {
  64629. return addressToBigNumber(left.Signer.Account).comparedTo(addressToBigNumber(right.Signer.Account));
  64630. }
  64631. function addressToBigNumber(address) {
  64632. const hex = Buffer.from((0, ripple_address_codec_1.decodeAccountID)(address)).toString('hex');
  64633. const numberOfBitsInHex = 16;
  64634. return new bignumber_js_1.BigNumber(hex, numberOfBitsInHex);
  64635. }
  64636. function getDecodedTransaction(txOrBlob) {
  64637. if (typeof txOrBlob === 'object') {
  64638. return (0, ripple_binary_codec_1.decode)((0, ripple_binary_codec_1.encode)(txOrBlob));
  64639. }
  64640. return (0, ripple_binary_codec_1.decode)(txOrBlob);
  64641. }
  64642. /***/ }),
  64643. /***/ "./dist/npm/client/BroadcastClient.js":
  64644. /*!********************************************!*\
  64645. !*** ./dist/npm/client/BroadcastClient.js ***!
  64646. \********************************************/
  64647. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  64648. "use strict";
  64649. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  64650. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  64651. return new (P || (P = Promise))(function (resolve, reject) {
  64652. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  64653. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  64654. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  64655. step((generator = generator.apply(thisArg, _arguments || [])).next());
  64656. });
  64657. };
  64658. Object.defineProperty(exports, "__esModule", ({ value: true }));
  64659. const _1 = __webpack_require__(/*! . */ "./dist/npm/client/index.js");
  64660. class BroadcastClient extends _1.Client {
  64661. constructor(servers, options = {}) {
  64662. super(servers[0], options);
  64663. const clients = servers.map((server) => new _1.Client(server, options));
  64664. this.clients = clients;
  64665. this.getMethodNames().forEach((name) => {
  64666. this[name] = (...args) => __awaiter(this, void 0, void 0, function* () { return Promise.race(clients.map((client) => __awaiter(this, void 0, void 0, function* () { return client[name](...args); }))); });
  64667. });
  64668. this.connect = () => __awaiter(this, void 0, void 0, function* () {
  64669. yield Promise.all(clients.map((client) => __awaiter(this, void 0, void 0, function* () { return client.connect(); })));
  64670. });
  64671. this.disconnect = () => __awaiter(this, void 0, void 0, function* () {
  64672. yield Promise.all(clients.map((client) => __awaiter(this, void 0, void 0, function* () { return client.disconnect(); })));
  64673. });
  64674. this.isConnected = () => clients.map((client) => client.isConnected()).every(Boolean);
  64675. clients.forEach((client) => {
  64676. client.on('error', (errorCode, errorMessage, data) => this.emit('error', errorCode, errorMessage, data));
  64677. });
  64678. }
  64679. getMethodNames() {
  64680. const methodNames = [];
  64681. const firstClient = this.clients[0];
  64682. const methods = Object.getOwnPropertyNames(firstClient);
  64683. methods.push(...Object.getOwnPropertyNames(Object.getPrototypeOf(firstClient)));
  64684. for (const name of methods) {
  64685. if (typeof firstClient[name] === 'function' &&
  64686. name !== 'constructor' &&
  64687. name !== 'on') {
  64688. methodNames.push(name);
  64689. }
  64690. }
  64691. return methodNames;
  64692. }
  64693. }
  64694. exports["default"] = BroadcastClient;
  64695. /***/ }),
  64696. /***/ "./dist/npm/client/ConnectionManager.js":
  64697. /*!**********************************************!*\
  64698. !*** ./dist/npm/client/ConnectionManager.js ***!
  64699. \**********************************************/
  64700. /***/ (function(__unused_webpack_module, exports) {
  64701. "use strict";
  64702. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  64703. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  64704. return new (P || (P = Promise))(function (resolve, reject) {
  64705. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  64706. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  64707. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  64708. step((generator = generator.apply(thisArg, _arguments || [])).next());
  64709. });
  64710. };
  64711. Object.defineProperty(exports, "__esModule", ({ value: true }));
  64712. class ConnectionManager {
  64713. constructor() {
  64714. this.promisesAwaitingConnection = [];
  64715. }
  64716. resolveAllAwaiting() {
  64717. this.promisesAwaitingConnection.map(({ resolve }) => resolve());
  64718. this.promisesAwaitingConnection = [];
  64719. }
  64720. rejectAllAwaiting(error) {
  64721. this.promisesAwaitingConnection.map(({ reject }) => reject(error));
  64722. this.promisesAwaitingConnection = [];
  64723. }
  64724. awaitConnection() {
  64725. return __awaiter(this, void 0, void 0, function* () {
  64726. return new Promise((resolve, reject) => {
  64727. this.promisesAwaitingConnection.push({ resolve, reject });
  64728. });
  64729. });
  64730. }
  64731. }
  64732. exports["default"] = ConnectionManager;
  64733. /***/ }),
  64734. /***/ "./dist/npm/client/ExponentialBackoff.js":
  64735. /*!***********************************************!*\
  64736. !*** ./dist/npm/client/ExponentialBackoff.js ***!
  64737. \***********************************************/
  64738. /***/ ((__unused_webpack_module, exports) => {
  64739. "use strict";
  64740. Object.defineProperty(exports, "__esModule", ({ value: true }));
  64741. const DEFAULT_MIN = 100;
  64742. const DEFAULT_MAX = 1000;
  64743. class ExponentialBackoff {
  64744. constructor(opts = {}) {
  64745. var _a, _b;
  64746. this.factor = 2;
  64747. this.numAttempts = 0;
  64748. this.ms = (_a = opts.min) !== null && _a !== void 0 ? _a : DEFAULT_MIN;
  64749. this.max = (_b = opts.max) !== null && _b !== void 0 ? _b : DEFAULT_MAX;
  64750. }
  64751. get attempts() {
  64752. return this.numAttempts;
  64753. }
  64754. duration() {
  64755. const ms = this.ms * Math.pow(this.factor, this.numAttempts);
  64756. this.numAttempts += 1;
  64757. return Math.floor(Math.min(ms, this.max));
  64758. }
  64759. reset() {
  64760. this.numAttempts = 0;
  64761. }
  64762. }
  64763. exports["default"] = ExponentialBackoff;
  64764. /***/ }),
  64765. /***/ "./dist/npm/client/RequestManager.js":
  64766. /*!*******************************************!*\
  64767. !*** ./dist/npm/client/RequestManager.js ***!
  64768. \*******************************************/
  64769. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  64770. "use strict";
  64771. Object.defineProperty(exports, "__esModule", ({ value: true }));
  64772. const errors_1 = __webpack_require__(/*! ../errors */ "./dist/npm/errors.js");
  64773. class RequestManager {
  64774. constructor() {
  64775. this.nextId = 0;
  64776. this.promisesAwaitingResponse = new Map();
  64777. }
  64778. resolve(id, response) {
  64779. const promise = this.promisesAwaitingResponse.get(id);
  64780. if (promise == null) {
  64781. throw new errors_1.XrplError(`No existing promise with id ${id}`, {
  64782. type: 'resolve',
  64783. response,
  64784. });
  64785. }
  64786. clearTimeout(promise.timer);
  64787. promise.resolve(response);
  64788. this.deletePromise(id);
  64789. }
  64790. reject(id, error) {
  64791. const promise = this.promisesAwaitingResponse.get(id);
  64792. if (promise == null) {
  64793. throw new errors_1.XrplError(`No existing promise with id ${id}`, {
  64794. type: 'reject',
  64795. error,
  64796. });
  64797. }
  64798. clearTimeout(promise.timer);
  64799. promise.reject(error);
  64800. this.deletePromise(id);
  64801. }
  64802. rejectAll(error) {
  64803. this.promisesAwaitingResponse.forEach((_promise, id, _map) => {
  64804. this.reject(id, error);
  64805. this.deletePromise(id);
  64806. });
  64807. }
  64808. createRequest(request, timeout) {
  64809. let newId;
  64810. if (request.id == null) {
  64811. newId = this.nextId;
  64812. this.nextId += 1;
  64813. }
  64814. else {
  64815. newId = request.id;
  64816. }
  64817. const newRequest = JSON.stringify(Object.assign(Object.assign({}, request), { id: newId }));
  64818. const timer = setTimeout(() => {
  64819. this.reject(newId, new errors_1.TimeoutError(`Timeout for request: ${JSON.stringify(request)} with id ${newId}`, request));
  64820. }, timeout);
  64821. if (timer.unref) {
  64822. ;
  64823. timer.unref();
  64824. }
  64825. if (this.promisesAwaitingResponse.has(newId)) {
  64826. clearTimeout(timer);
  64827. throw new errors_1.XrplError(`Response with id '${newId}' is already pending`, request);
  64828. }
  64829. const newPromise = new Promise((resolve, reject) => {
  64830. this.promisesAwaitingResponse.set(newId, { resolve, reject, timer });
  64831. });
  64832. return [newId, newRequest, newPromise];
  64833. }
  64834. handleResponse(response) {
  64835. var _a, _b;
  64836. if (response.id == null ||
  64837. !(typeof response.id === 'string' || typeof response.id === 'number')) {
  64838. throw new errors_1.ResponseFormatError('valid id not found in response', response);
  64839. }
  64840. if (!this.promisesAwaitingResponse.has(response.id)) {
  64841. return;
  64842. }
  64843. if (response.status == null) {
  64844. const error = new errors_1.ResponseFormatError('Response has no status');
  64845. this.reject(response.id, error);
  64846. }
  64847. if (response.status === 'error') {
  64848. const errorResponse = response;
  64849. const error = new errors_1.RippledError((_a = errorResponse.error_message) !== null && _a !== void 0 ? _a : errorResponse.error, errorResponse);
  64850. this.reject(response.id, error);
  64851. return;
  64852. }
  64853. if (response.status !== 'success') {
  64854. const error = new errors_1.ResponseFormatError(`unrecognized response.status: ${(_b = response.status) !== null && _b !== void 0 ? _b : ''}`, response);
  64855. this.reject(response.id, error);
  64856. return;
  64857. }
  64858. delete response.status;
  64859. this.resolve(response.id, response);
  64860. }
  64861. deletePromise(id) {
  64862. this.promisesAwaitingResponse.delete(id);
  64863. }
  64864. }
  64865. exports["default"] = RequestManager;
  64866. /***/ }),
  64867. /***/ "./dist/npm/client/WSWrapper.js":
  64868. /*!**************************************!*\
  64869. !*** ./dist/npm/client/WSWrapper.js ***!
  64870. \**************************************/
  64871. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  64872. "use strict";
  64873. Object.defineProperty(exports, "__esModule", ({ value: true }));
  64874. const events_1 = __webpack_require__(/*! events */ "../../node_modules/events/events.js");
  64875. class WSWrapper extends events_1.EventEmitter {
  64876. constructor(url, _protocols, _websocketOptions) {
  64877. super();
  64878. this.setMaxListeners(Infinity);
  64879. this.ws = new WebSocket(url);
  64880. this.ws.onclose = (closeEvent) => {
  64881. let reason;
  64882. if (closeEvent.reason) {
  64883. const enc = new TextEncoder();
  64884. reason = enc.encode(closeEvent.reason);
  64885. }
  64886. this.emit('close', closeEvent.code, reason);
  64887. };
  64888. this.ws.onopen = () => {
  64889. this.emit('open');
  64890. };
  64891. this.ws.onerror = (error) => {
  64892. this.emit('error', error);
  64893. };
  64894. this.ws.onmessage = (message) => {
  64895. this.emit('message', message.data);
  64896. };
  64897. }
  64898. get readyState() {
  64899. return this.ws.readyState;
  64900. }
  64901. close(code, reason) {
  64902. if (this.readyState === 1) {
  64903. this.ws.close(code, reason);
  64904. }
  64905. }
  64906. send(message) {
  64907. this.ws.send(message);
  64908. }
  64909. }
  64910. exports["default"] = WSWrapper;
  64911. WSWrapper.CONNECTING = 0;
  64912. WSWrapper.OPEN = 1;
  64913. WSWrapper.CLOSING = 2;
  64914. WSWrapper.CLOSED = 3;
  64915. /***/ }),
  64916. /***/ "./dist/npm/client/connection.js":
  64917. /*!***************************************!*\
  64918. !*** ./dist/npm/client/connection.js ***!
  64919. \***************************************/
  64920. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  64921. "use strict";
  64922. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js")["Buffer"];
  64923. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  64924. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  64925. return new (P || (P = Promise))(function (resolve, reject) {
  64926. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  64927. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  64928. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  64929. step((generator = generator.apply(thisArg, _arguments || [])).next());
  64930. });
  64931. };
  64932. var __importDefault = (this && this.__importDefault) || function (mod) {
  64933. return (mod && mod.__esModule) ? mod : { "default": mod };
  64934. };
  64935. Object.defineProperty(exports, "__esModule", ({ value: true }));
  64936. exports.Connection = exports.INTENTIONAL_DISCONNECT_CODE = void 0;
  64937. const events_1 = __webpack_require__(/*! events */ "../../node_modules/events/events.js");
  64938. const omitBy_1 = __importDefault(__webpack_require__(/*! lodash/omitBy */ "../../node_modules/lodash/omitBy.js"));
  64939. const ws_1 = __importDefault(__webpack_require__(/*! ws */ "./dist/npm/client/WSWrapper.js"));
  64940. const errors_1 = __webpack_require__(/*! ../errors */ "./dist/npm/errors.js");
  64941. const ConnectionManager_1 = __importDefault(__webpack_require__(/*! ./ConnectionManager */ "./dist/npm/client/ConnectionManager.js"));
  64942. const ExponentialBackoff_1 = __importDefault(__webpack_require__(/*! ./ExponentialBackoff */ "./dist/npm/client/ExponentialBackoff.js"));
  64943. const RequestManager_1 = __importDefault(__webpack_require__(/*! ./RequestManager */ "./dist/npm/client/RequestManager.js"));
  64944. const SECONDS_PER_MINUTE = 60;
  64945. const TIMEOUT = 20;
  64946. const CONNECTION_TIMEOUT = 5;
  64947. exports.INTENTIONAL_DISCONNECT_CODE = 4000;
  64948. function getAgent(url, config) {
  64949. if (config.proxy == null) {
  64950. return undefined;
  64951. }
  64952. const parsedURL = new URL(url);
  64953. const parsedProxyURL = new URL(config.proxy);
  64954. const proxyOptions = (0, omitBy_1.default)({
  64955. secureEndpoint: parsedURL.protocol === 'wss:',
  64956. secureProxy: parsedProxyURL.protocol === 'https:',
  64957. auth: config.proxyAuthorization,
  64958. ca: config.trustedCertificates,
  64959. key: config.key,
  64960. passphrase: config.passphrase,
  64961. cert: config.certificate,
  64962. href: parsedProxyURL.href,
  64963. origin: parsedProxyURL.origin,
  64964. protocol: parsedProxyURL.protocol,
  64965. username: parsedProxyURL.username,
  64966. password: parsedProxyURL.password,
  64967. host: parsedProxyURL.host,
  64968. hostname: parsedProxyURL.hostname,
  64969. port: parsedProxyURL.port,
  64970. pathname: parsedProxyURL.pathname,
  64971. search: parsedProxyURL.search,
  64972. hash: parsedProxyURL.hash,
  64973. }, (value) => value == null);
  64974. let HttpsProxyAgent;
  64975. try {
  64976. HttpsProxyAgent = __webpack_require__(/*! https-proxy-agent */ "?fbd7");
  64977. }
  64978. catch (_error) {
  64979. throw new Error('"proxy" option is not supported in the browser');
  64980. }
  64981. return new HttpsProxyAgent(proxyOptions);
  64982. }
  64983. function createWebSocket(url, config) {
  64984. const options = {};
  64985. options.agent = getAgent(url, config);
  64986. if (config.headers) {
  64987. options.headers = config.headers;
  64988. }
  64989. if (config.authorization != null) {
  64990. const base64 = Buffer.from(config.authorization).toString('base64');
  64991. options.headers = Object.assign(Object.assign({}, options.headers), { Authorization: `Basic ${base64}` });
  64992. }
  64993. const optionsOverrides = (0, omitBy_1.default)({
  64994. ca: config.trustedCertificates,
  64995. key: config.key,
  64996. passphrase: config.passphrase,
  64997. cert: config.certificate,
  64998. }, (value) => value == null);
  64999. const websocketOptions = Object.assign(Object.assign({}, options), optionsOverrides);
  65000. const websocket = new ws_1.default(url, websocketOptions);
  65001. if (typeof websocket.setMaxListeners === 'function') {
  65002. websocket.setMaxListeners(Infinity);
  65003. }
  65004. return websocket;
  65005. }
  65006. function websocketSendAsync(ws, message) {
  65007. return __awaiter(this, void 0, void 0, function* () {
  65008. return new Promise((resolve, reject) => {
  65009. ws.send(message, (error) => {
  65010. if (error) {
  65011. reject(new errors_1.DisconnectedError(error.message, error));
  65012. }
  65013. else {
  65014. resolve();
  65015. }
  65016. });
  65017. });
  65018. });
  65019. }
  65020. class Connection extends events_1.EventEmitter {
  65021. constructor(url, options = {}) {
  65022. super();
  65023. this.ws = null;
  65024. this.reconnectTimeoutID = null;
  65025. this.heartbeatIntervalID = null;
  65026. this.retryConnectionBackoff = new ExponentialBackoff_1.default({
  65027. min: 100,
  65028. max: SECONDS_PER_MINUTE * 1000,
  65029. });
  65030. this.requestManager = new RequestManager_1.default();
  65031. this.connectionManager = new ConnectionManager_1.default();
  65032. this.trace = () => { };
  65033. this.setMaxListeners(Infinity);
  65034. this.url = url;
  65035. this.config = Object.assign({ timeout: TIMEOUT * 1000, connectionTimeout: CONNECTION_TIMEOUT * 1000 }, options);
  65036. if (typeof options.trace === 'function') {
  65037. this.trace = options.trace;
  65038. }
  65039. else if (options.trace) {
  65040. this.trace = console.log;
  65041. }
  65042. }
  65043. get state() {
  65044. return this.ws ? this.ws.readyState : ws_1.default.CLOSED;
  65045. }
  65046. get shouldBeConnected() {
  65047. return this.ws !== null;
  65048. }
  65049. isConnected() {
  65050. return this.state === ws_1.default.OPEN;
  65051. }
  65052. connect() {
  65053. return __awaiter(this, void 0, void 0, function* () {
  65054. if (this.isConnected()) {
  65055. return Promise.resolve();
  65056. }
  65057. if (this.state === ws_1.default.CONNECTING) {
  65058. return this.connectionManager.awaitConnection();
  65059. }
  65060. if (!this.url) {
  65061. return Promise.reject(new errors_1.ConnectionError('Cannot connect because no server was specified'));
  65062. }
  65063. if (this.ws != null) {
  65064. return Promise.reject(new errors_1.XrplError('Websocket connection never cleaned up.', {
  65065. state: this.state,
  65066. }));
  65067. }
  65068. const connectionTimeoutID = setTimeout(() => {
  65069. this.onConnectionFailed(new errors_1.ConnectionError(`Error: connect() timed out after ${this.config.connectionTimeout} ms. If your internet connection is working, the ` +
  65070. `rippled server may be blocked or inaccessible. You can also try setting the 'connectionTimeout' option in the Client constructor.`));
  65071. }, this.config.connectionTimeout);
  65072. this.ws = createWebSocket(this.url, this.config);
  65073. if (this.ws == null) {
  65074. throw new errors_1.XrplError('Connect: created null websocket');
  65075. }
  65076. this.ws.on('error', (error) => this.onConnectionFailed(error));
  65077. this.ws.on('error', () => clearTimeout(connectionTimeoutID));
  65078. this.ws.on('close', (reason) => this.onConnectionFailed(reason));
  65079. this.ws.on('close', () => clearTimeout(connectionTimeoutID));
  65080. this.ws.once('open', () => {
  65081. void this.onceOpen(connectionTimeoutID);
  65082. });
  65083. return this.connectionManager.awaitConnection();
  65084. });
  65085. }
  65086. disconnect() {
  65087. return __awaiter(this, void 0, void 0, function* () {
  65088. this.clearHeartbeatInterval();
  65089. if (this.reconnectTimeoutID !== null) {
  65090. clearTimeout(this.reconnectTimeoutID);
  65091. this.reconnectTimeoutID = null;
  65092. }
  65093. if (this.state === ws_1.default.CLOSED) {
  65094. return Promise.resolve(undefined);
  65095. }
  65096. if (this.ws == null) {
  65097. return Promise.resolve(undefined);
  65098. }
  65099. return new Promise((resolve) => {
  65100. if (this.ws == null) {
  65101. resolve(undefined);
  65102. }
  65103. if (this.ws != null) {
  65104. this.ws.once('close', (code) => resolve(code));
  65105. }
  65106. if (this.ws != null && this.state !== ws_1.default.CLOSING) {
  65107. this.ws.close(exports.INTENTIONAL_DISCONNECT_CODE);
  65108. }
  65109. });
  65110. });
  65111. }
  65112. reconnect() {
  65113. return __awaiter(this, void 0, void 0, function* () {
  65114. this.emit('reconnect');
  65115. yield this.disconnect();
  65116. yield this.connect();
  65117. });
  65118. }
  65119. request(request, timeout) {
  65120. return __awaiter(this, void 0, void 0, function* () {
  65121. if (!this.shouldBeConnected || this.ws == null) {
  65122. throw new errors_1.NotConnectedError(JSON.stringify(request), request);
  65123. }
  65124. const [id, message, responsePromise] = this.requestManager.createRequest(request, timeout !== null && timeout !== void 0 ? timeout : this.config.timeout);
  65125. this.trace('send', message);
  65126. websocketSendAsync(this.ws, message).catch((error) => {
  65127. this.requestManager.reject(id, error);
  65128. });
  65129. return responsePromise;
  65130. });
  65131. }
  65132. getUrl() {
  65133. var _a;
  65134. return (_a = this.url) !== null && _a !== void 0 ? _a : '';
  65135. }
  65136. onMessage(message) {
  65137. this.trace('receive', message);
  65138. let data;
  65139. try {
  65140. data = JSON.parse(message);
  65141. }
  65142. catch (error) {
  65143. if (error instanceof Error) {
  65144. this.emit('error', 'badMessage', error.message, message);
  65145. }
  65146. return;
  65147. }
  65148. if (data.type == null && data.error) {
  65149. this.emit('error', data.error, data.error_message, data);
  65150. return;
  65151. }
  65152. if (data.type) {
  65153. this.emit(data.type, data);
  65154. }
  65155. if (data.type === 'response') {
  65156. try {
  65157. this.requestManager.handleResponse(data);
  65158. }
  65159. catch (error) {
  65160. if (error instanceof Error) {
  65161. this.emit('error', 'badMessage', error.message, message);
  65162. }
  65163. else {
  65164. this.emit('error', 'badMessage', error, error);
  65165. }
  65166. }
  65167. }
  65168. }
  65169. onceOpen(connectionTimeoutID) {
  65170. return __awaiter(this, void 0, void 0, function* () {
  65171. if (this.ws == null) {
  65172. throw new errors_1.XrplError('onceOpen: ws is null');
  65173. }
  65174. this.ws.removeAllListeners();
  65175. clearTimeout(connectionTimeoutID);
  65176. this.ws.on('message', (message) => this.onMessage(message));
  65177. this.ws.on('error', (error) => this.emit('error', 'websocket', error.message, error));
  65178. this.ws.once('close', (code, reason) => {
  65179. if (this.ws == null) {
  65180. throw new errors_1.XrplError('onceClose: ws is null');
  65181. }
  65182. this.clearHeartbeatInterval();
  65183. this.requestManager.rejectAll(new errors_1.DisconnectedError(`websocket was closed, ${new TextDecoder('utf-8').decode(reason)}`));
  65184. this.ws.removeAllListeners();
  65185. this.ws = null;
  65186. if (code === undefined) {
  65187. const internalErrorCode = 1011;
  65188. this.emit('disconnected', internalErrorCode);
  65189. }
  65190. else {
  65191. this.emit('disconnected', code);
  65192. }
  65193. if (code !== exports.INTENTIONAL_DISCONNECT_CODE && code !== undefined) {
  65194. this.intentionalDisconnect();
  65195. }
  65196. });
  65197. try {
  65198. this.retryConnectionBackoff.reset();
  65199. this.startHeartbeatInterval();
  65200. this.connectionManager.resolveAllAwaiting();
  65201. this.emit('connected');
  65202. }
  65203. catch (error) {
  65204. if (error instanceof Error) {
  65205. this.connectionManager.rejectAllAwaiting(error);
  65206. yield this.disconnect().catch(() => { });
  65207. }
  65208. }
  65209. });
  65210. }
  65211. intentionalDisconnect() {
  65212. const retryTimeout = this.retryConnectionBackoff.duration();
  65213. this.trace('reconnect', `Retrying connection in ${retryTimeout}ms.`);
  65214. this.emit('reconnecting', this.retryConnectionBackoff.attempts);
  65215. this.reconnectTimeoutID = setTimeout(() => {
  65216. this.reconnect().catch((error) => {
  65217. this.emit('error', 'reconnect', error.message, error);
  65218. });
  65219. }, retryTimeout);
  65220. }
  65221. clearHeartbeatInterval() {
  65222. if (this.heartbeatIntervalID) {
  65223. clearInterval(this.heartbeatIntervalID);
  65224. }
  65225. }
  65226. startHeartbeatInterval() {
  65227. this.clearHeartbeatInterval();
  65228. this.heartbeatIntervalID = setInterval(() => {
  65229. void this.heartbeat();
  65230. }, this.config.timeout);
  65231. }
  65232. heartbeat() {
  65233. return __awaiter(this, void 0, void 0, function* () {
  65234. this.request({ command: 'ping' }).catch(() => __awaiter(this, void 0, void 0, function* () {
  65235. return this.reconnect().catch((error) => {
  65236. this.emit('error', 'reconnect', error.message, error);
  65237. });
  65238. }));
  65239. });
  65240. }
  65241. onConnectionFailed(errorOrCode) {
  65242. if (this.ws) {
  65243. this.ws.removeAllListeners();
  65244. this.ws.on('error', () => {
  65245. });
  65246. this.ws.close();
  65247. this.ws = null;
  65248. }
  65249. if (typeof errorOrCode === 'number') {
  65250. this.connectionManager.rejectAllAwaiting(new errors_1.NotConnectedError(`Connection failed with code ${errorOrCode}.`, {
  65251. code: errorOrCode,
  65252. }));
  65253. }
  65254. else if (errorOrCode === null || errorOrCode === void 0 ? void 0 : errorOrCode.message) {
  65255. this.connectionManager.rejectAllAwaiting(new errors_1.NotConnectedError(errorOrCode.message, errorOrCode));
  65256. }
  65257. else {
  65258. this.connectionManager.rejectAllAwaiting(new errors_1.NotConnectedError('Connection failed.'));
  65259. }
  65260. }
  65261. }
  65262. exports.Connection = Connection;
  65263. /***/ }),
  65264. /***/ "./dist/npm/client/index.js":
  65265. /*!**********************************!*\
  65266. !*** ./dist/npm/client/index.js ***!
  65267. \**********************************/
  65268. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  65269. "use strict";
  65270. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  65271. if (k2 === undefined) k2 = k;
  65272. var desc = Object.getOwnPropertyDescriptor(m, k);
  65273. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  65274. desc = { enumerable: true, get: function() { return m[k]; } };
  65275. }
  65276. Object.defineProperty(o, k2, desc);
  65277. }) : (function(o, m, k, k2) {
  65278. if (k2 === undefined) k2 = k;
  65279. o[k2] = m[k];
  65280. }));
  65281. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  65282. Object.defineProperty(o, "default", { enumerable: true, value: v });
  65283. }) : function(o, v) {
  65284. o["default"] = v;
  65285. });
  65286. var __importStar = (this && this.__importStar) || function (mod) {
  65287. if (mod && mod.__esModule) return mod;
  65288. var result = {};
  65289. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  65290. __setModuleDefault(result, mod);
  65291. return result;
  65292. };
  65293. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  65294. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  65295. return new (P || (P = Promise))(function (resolve, reject) {
  65296. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  65297. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  65298. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  65299. step((generator = generator.apply(thisArg, _arguments || [])).next());
  65300. });
  65301. };
  65302. var __importDefault = (this && this.__importDefault) || function (mod) {
  65303. return (mod && mod.__esModule) ? mod : { "default": mod };
  65304. };
  65305. Object.defineProperty(exports, "__esModule", ({ value: true }));
  65306. exports.Client = void 0;
  65307. const assert = __importStar(__webpack_require__(/*! assert */ "../../node_modules/assert/build/assert.js"));
  65308. const events_1 = __webpack_require__(/*! events */ "../../node_modules/events/events.js");
  65309. const errors_1 = __webpack_require__(/*! ../errors */ "./dist/npm/errors.js");
  65310. const sugar_1 = __webpack_require__(/*! ../sugar */ "./dist/npm/sugar/index.js");
  65311. const fundWallet_1 = __importDefault(__webpack_require__(/*! ../Wallet/fundWallet */ "./dist/npm/Wallet/fundWallet.js"));
  65312. const connection_1 = __webpack_require__(/*! ./connection */ "./dist/npm/client/connection.js");
  65313. const partialPayment_1 = __webpack_require__(/*! ./partialPayment */ "./dist/npm/client/partialPayment.js");
  65314. function getCollectKeyFromCommand(command) {
  65315. switch (command) {
  65316. case 'account_channels':
  65317. return 'channels';
  65318. case 'account_lines':
  65319. return 'lines';
  65320. case 'account_objects':
  65321. return 'account_objects';
  65322. case 'account_tx':
  65323. return 'transactions';
  65324. case 'account_offers':
  65325. case 'book_offers':
  65326. return 'offers';
  65327. case 'ledger_data':
  65328. return 'state';
  65329. default:
  65330. return null;
  65331. }
  65332. }
  65333. function clamp(value, min, max) {
  65334. assert.ok(min <= max, 'Illegal clamp bounds');
  65335. return Math.min(Math.max(value, min), max);
  65336. }
  65337. const DEFAULT_FEE_CUSHION = 1.2;
  65338. const DEFAULT_MAX_FEE_XRP = '2';
  65339. const MIN_LIMIT = 10;
  65340. const MAX_LIMIT = 400;
  65341. const NORMAL_DISCONNECT_CODE = 1000;
  65342. class Client extends events_1.EventEmitter {
  65343. constructor(server, options = {}) {
  65344. var _a, _b;
  65345. super();
  65346. this.autofill = sugar_1.autofill;
  65347. this.submit = sugar_1.submit;
  65348. this.submitAndWait = sugar_1.submitAndWait;
  65349. this.prepareTransaction = sugar_1.autofill;
  65350. this.getXrpBalance = sugar_1.getXrpBalance;
  65351. this.getBalances = sugar_1.getBalances;
  65352. this.getOrderbook = sugar_1.getOrderbook;
  65353. this.getLedgerIndex = sugar_1.getLedgerIndex;
  65354. this.fundWallet = fundWallet_1.default;
  65355. if (typeof server !== 'string' || !/wss?(?:\+unix)?:\/\//u.exec(server)) {
  65356. throw new errors_1.ValidationError('server URI must start with `wss://`, `ws://`, `wss+unix://`, or `ws+unix://`.');
  65357. }
  65358. this.feeCushion = (_a = options.feeCushion) !== null && _a !== void 0 ? _a : DEFAULT_FEE_CUSHION;
  65359. this.maxFeeXRP = (_b = options.maxFeeXRP) !== null && _b !== void 0 ? _b : DEFAULT_MAX_FEE_XRP;
  65360. this.connection = new connection_1.Connection(server, options);
  65361. this.connection.on('error', (errorCode, errorMessage, data) => {
  65362. this.emit('error', errorCode, errorMessage, data);
  65363. });
  65364. this.connection.on('connected', () => {
  65365. this.emit('connected');
  65366. });
  65367. this.connection.on('disconnected', (code) => {
  65368. let finalCode = code;
  65369. if (finalCode === connection_1.INTENTIONAL_DISCONNECT_CODE) {
  65370. finalCode = NORMAL_DISCONNECT_CODE;
  65371. }
  65372. this.emit('disconnected', finalCode);
  65373. });
  65374. this.connection.on('ledgerClosed', (ledger) => {
  65375. this.emit('ledgerClosed', ledger);
  65376. });
  65377. this.connection.on('transaction', (tx) => {
  65378. (0, partialPayment_1.handleStreamPartialPayment)(tx, this.connection.trace);
  65379. this.emit('transaction', tx);
  65380. });
  65381. this.connection.on('validationReceived', (validation) => {
  65382. this.emit('validationReceived', validation);
  65383. });
  65384. this.connection.on('manifestReceived', (manifest) => {
  65385. this.emit('manifestReceived', manifest);
  65386. });
  65387. this.connection.on('peerStatusChange', (status) => {
  65388. this.emit('peerStatusChange', status);
  65389. });
  65390. this.connection.on('consensusPhase', (consensus) => {
  65391. this.emit('consensusPhase', consensus);
  65392. });
  65393. this.connection.on('path_find', (path) => {
  65394. this.emit('path_find', path);
  65395. });
  65396. }
  65397. get url() {
  65398. return this.connection.getUrl();
  65399. }
  65400. request(req) {
  65401. return __awaiter(this, void 0, void 0, function* () {
  65402. const response = (yield this.connection.request(Object.assign(Object.assign({}, req), { account: req.account
  65403. ?
  65404. (0, sugar_1.ensureClassicAddress)(req.account)
  65405. : undefined })));
  65406. (0, partialPayment_1.handlePartialPayment)(req.command, response);
  65407. return response;
  65408. });
  65409. }
  65410. requestNextPage(req, resp) {
  65411. return __awaiter(this, void 0, void 0, function* () {
  65412. if (!resp.result.marker) {
  65413. return Promise.reject(new errors_1.NotFoundError('response does not have a next page'));
  65414. }
  65415. const nextPageRequest = Object.assign(Object.assign({}, req), { marker: resp.result.marker });
  65416. return this.request(nextPageRequest);
  65417. });
  65418. }
  65419. on(eventName, listener) {
  65420. return super.on(eventName, listener);
  65421. }
  65422. requestAll(request, collect) {
  65423. return __awaiter(this, void 0, void 0, function* () {
  65424. const collectKey = collect !== null && collect !== void 0 ? collect : getCollectKeyFromCommand(request.command);
  65425. if (!collectKey) {
  65426. throw new errors_1.ValidationError(`no collect key for command ${request.command}`);
  65427. }
  65428. const countTo = request.limit == null ? Infinity : request.limit;
  65429. let count = 0;
  65430. let marker = request.marker;
  65431. let lastBatchLength;
  65432. const results = [];
  65433. do {
  65434. const countRemaining = clamp(countTo - count, MIN_LIMIT, MAX_LIMIT);
  65435. const repeatProps = Object.assign(Object.assign({}, request), { limit: countRemaining, marker });
  65436. const singleResponse = yield this.connection.request(repeatProps);
  65437. const singleResult = singleResponse.result;
  65438. if (!(collectKey in singleResult)) {
  65439. throw new errors_1.XrplError(`${collectKey} not in result`);
  65440. }
  65441. const collectedData = singleResult[collectKey];
  65442. marker = singleResult.marker;
  65443. results.push(singleResponse);
  65444. if (Array.isArray(collectedData)) {
  65445. count += collectedData.length;
  65446. lastBatchLength = collectedData.length;
  65447. }
  65448. else {
  65449. lastBatchLength = 0;
  65450. }
  65451. } while (Boolean(marker) && count < countTo && lastBatchLength !== 0);
  65452. return results;
  65453. });
  65454. }
  65455. connect() {
  65456. return __awaiter(this, void 0, void 0, function* () {
  65457. return this.connection.connect();
  65458. });
  65459. }
  65460. disconnect() {
  65461. return __awaiter(this, void 0, void 0, function* () {
  65462. yield this.connection.disconnect();
  65463. });
  65464. }
  65465. isConnected() {
  65466. return this.connection.isConnected();
  65467. }
  65468. }
  65469. exports.Client = Client;
  65470. /***/ }),
  65471. /***/ "./dist/npm/client/partialPayment.js":
  65472. /*!*******************************************!*\
  65473. !*** ./dist/npm/client/partialPayment.js ***!
  65474. \*******************************************/
  65475. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  65476. "use strict";
  65477. var __importDefault = (this && this.__importDefault) || function (mod) {
  65478. return (mod && mod.__esModule) ? mod : { "default": mod };
  65479. };
  65480. Object.defineProperty(exports, "__esModule", ({ value: true }));
  65481. exports.handleStreamPartialPayment = exports.handlePartialPayment = void 0;
  65482. const bignumber_js_1 = __importDefault(__webpack_require__(/*! bignumber.js */ "../../node_modules/bignumber.js/bignumber.js"));
  65483. const ripple_binary_codec_1 = __webpack_require__(/*! ripple-binary-codec */ "../../node_modules/ripple-binary-codec/dist/index.js");
  65484. const transactions_1 = __webpack_require__(/*! ../models/transactions */ "./dist/npm/models/transactions/index.js");
  65485. const utils_1 = __webpack_require__(/*! ../models/utils */ "./dist/npm/models/utils/index.js");
  65486. const WARN_PARTIAL_PAYMENT_CODE = 2001;
  65487. function amountsEqual(amt1, amt2) {
  65488. if (typeof amt1 === 'string' && typeof amt2 === 'string') {
  65489. return amt1 === amt2;
  65490. }
  65491. if (typeof amt1 === 'string' || typeof amt2 === 'string') {
  65492. return false;
  65493. }
  65494. const aValue = new bignumber_js_1.default(amt1.value);
  65495. const bValue = new bignumber_js_1.default(amt2.value);
  65496. return (amt1.currency === amt2.currency &&
  65497. amt1.issuer === amt2.issuer &&
  65498. aValue.isEqualTo(bValue));
  65499. }
  65500. function isPartialPayment(tx, metadata) {
  65501. var _a;
  65502. if (tx == null || metadata == null || tx.TransactionType !== 'Payment') {
  65503. return false;
  65504. }
  65505. let meta = metadata;
  65506. if (typeof meta === 'string') {
  65507. if (meta === 'unavailable') {
  65508. return false;
  65509. }
  65510. meta = (0, ripple_binary_codec_1.decode)(meta);
  65511. }
  65512. const tfPartial = typeof tx.Flags === 'number'
  65513. ? (0, utils_1.isFlagEnabled)(tx.Flags, transactions_1.PaymentFlags.tfPartialPayment)
  65514. : (_a = tx.Flags) === null || _a === void 0 ? void 0 : _a.tfPartialPayment;
  65515. if (!tfPartial) {
  65516. return false;
  65517. }
  65518. const delivered = meta.delivered_amount;
  65519. const amount = tx.Amount;
  65520. if (delivered === undefined) {
  65521. return false;
  65522. }
  65523. return !amountsEqual(delivered, amount);
  65524. }
  65525. function txHasPartialPayment(response) {
  65526. return isPartialPayment(response.result, response.result.meta);
  65527. }
  65528. function txEntryHasPartialPayment(response) {
  65529. return isPartialPayment(response.result.tx_json, response.result.metadata);
  65530. }
  65531. function accountTxHasPartialPayment(response) {
  65532. const { transactions } = response.result;
  65533. const foo = transactions.some((tx) => isPartialPayment(tx.tx, tx.meta));
  65534. return foo;
  65535. }
  65536. function hasPartialPayment(command, response) {
  65537. switch (command) {
  65538. case 'tx':
  65539. return txHasPartialPayment(response);
  65540. case 'transaction_entry':
  65541. return txEntryHasPartialPayment(response);
  65542. case 'account_tx':
  65543. return accountTxHasPartialPayment(response);
  65544. default:
  65545. return false;
  65546. }
  65547. }
  65548. function handlePartialPayment(command, response) {
  65549. var _a;
  65550. if (hasPartialPayment(command, response)) {
  65551. const warnings = (_a = response.warnings) !== null && _a !== void 0 ? _a : [];
  65552. const warning = {
  65553. id: WARN_PARTIAL_PAYMENT_CODE,
  65554. message: 'This response contains a Partial Payment',
  65555. };
  65556. warnings.push(warning);
  65557. response.warnings = warnings;
  65558. }
  65559. }
  65560. exports.handlePartialPayment = handlePartialPayment;
  65561. function handleStreamPartialPayment(stream, log) {
  65562. var _a;
  65563. if (isPartialPayment(stream.transaction, stream.meta)) {
  65564. const warnings = (_a = stream.warnings) !== null && _a !== void 0 ? _a : [];
  65565. const warning = {
  65566. id: WARN_PARTIAL_PAYMENT_CODE,
  65567. message: 'This response contains a Partial Payment',
  65568. };
  65569. warnings.push(warning);
  65570. stream.warnings = warnings;
  65571. log('Partial payment received', JSON.stringify(stream));
  65572. }
  65573. }
  65574. exports.handleStreamPartialPayment = handleStreamPartialPayment;
  65575. /***/ }),
  65576. /***/ "./dist/npm/errors.js":
  65577. /*!****************************!*\
  65578. !*** ./dist/npm/errors.js ***!
  65579. \****************************/
  65580. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  65581. "use strict";
  65582. Object.defineProperty(exports, "__esModule", ({ value: true }));
  65583. exports.XRPLFaucetError = exports.NotFoundError = exports.ValidationError = exports.ResponseFormatError = exports.TimeoutError = exports.RippledNotInitializedError = exports.DisconnectedError = exports.NotConnectedError = exports.RippledError = exports.ConnectionError = exports.UnexpectedError = exports.XrplError = void 0;
  65584. const util_1 = __webpack_require__(/*! util */ "../../node_modules/util/util.js");
  65585. class XrplError extends Error {
  65586. constructor(message = '', data) {
  65587. super(message);
  65588. this.name = this.constructor.name;
  65589. this.message = message;
  65590. this.data = data;
  65591. if (Error.captureStackTrace != null) {
  65592. Error.captureStackTrace(this, this.constructor);
  65593. }
  65594. }
  65595. toString() {
  65596. let result = `[${this.name}(${this.message}`;
  65597. if (this.data) {
  65598. result += `, ${(0, util_1.inspect)(this.data)}`;
  65599. }
  65600. result += ')]';
  65601. return result;
  65602. }
  65603. inspect() {
  65604. return this.toString();
  65605. }
  65606. }
  65607. exports.XrplError = XrplError;
  65608. class RippledError extends XrplError {
  65609. }
  65610. exports.RippledError = RippledError;
  65611. class UnexpectedError extends XrplError {
  65612. }
  65613. exports.UnexpectedError = UnexpectedError;
  65614. class ConnectionError extends XrplError {
  65615. }
  65616. exports.ConnectionError = ConnectionError;
  65617. class NotConnectedError extends ConnectionError {
  65618. }
  65619. exports.NotConnectedError = NotConnectedError;
  65620. class DisconnectedError extends ConnectionError {
  65621. }
  65622. exports.DisconnectedError = DisconnectedError;
  65623. class RippledNotInitializedError extends ConnectionError {
  65624. }
  65625. exports.RippledNotInitializedError = RippledNotInitializedError;
  65626. class TimeoutError extends ConnectionError {
  65627. }
  65628. exports.TimeoutError = TimeoutError;
  65629. class ResponseFormatError extends ConnectionError {
  65630. }
  65631. exports.ResponseFormatError = ResponseFormatError;
  65632. class ValidationError extends XrplError {
  65633. }
  65634. exports.ValidationError = ValidationError;
  65635. class XRPLFaucetError extends XrplError {
  65636. }
  65637. exports.XRPLFaucetError = XRPLFaucetError;
  65638. class NotFoundError extends XrplError {
  65639. constructor(message = 'Not found') {
  65640. super(message);
  65641. }
  65642. }
  65643. exports.NotFoundError = NotFoundError;
  65644. /***/ }),
  65645. /***/ "./dist/npm/index.js":
  65646. /*!***************************!*\
  65647. !*** ./dist/npm/index.js ***!
  65648. \***************************/
  65649. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  65650. "use strict";
  65651. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  65652. if (k2 === undefined) k2 = k;
  65653. var desc = Object.getOwnPropertyDescriptor(m, k);
  65654. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  65655. desc = { enumerable: true, get: function() { return m[k]; } };
  65656. }
  65657. Object.defineProperty(o, k2, desc);
  65658. }) : (function(o, m, k, k2) {
  65659. if (k2 === undefined) k2 = k;
  65660. o[k2] = m[k];
  65661. }));
  65662. var __exportStar = (this && this.__exportStar) || function(m, exports) {
  65663. for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
  65664. };
  65665. var __importDefault = (this && this.__importDefault) || function (mod) {
  65666. return (mod && mod.__esModule) ? mod : { "default": mod };
  65667. };
  65668. Object.defineProperty(exports, "__esModule", ({ value: true }));
  65669. exports.rfc1751MnemonicToKey = exports.keyToRFC1751Mnemonic = exports.Wallet = exports.Client = exports.BroadcastClient = void 0;
  65670. var BroadcastClient_1 = __webpack_require__(/*! ./client/BroadcastClient */ "./dist/npm/client/BroadcastClient.js");
  65671. Object.defineProperty(exports, "BroadcastClient", ({ enumerable: true, get: function () { return __importDefault(BroadcastClient_1).default; } }));
  65672. var client_1 = __webpack_require__(/*! ./client */ "./dist/npm/client/index.js");
  65673. Object.defineProperty(exports, "Client", ({ enumerable: true, get: function () { return client_1.Client; } }));
  65674. __exportStar(__webpack_require__(/*! ./models */ "./dist/npm/models/index.js"), exports);
  65675. __exportStar(__webpack_require__(/*! ./utils */ "./dist/npm/utils/index.js"), exports);
  65676. __exportStar(__webpack_require__(/*! ./errors */ "./dist/npm/errors.js"), exports);
  65677. var Wallet_1 = __webpack_require__(/*! ./Wallet */ "./dist/npm/Wallet/index.js");
  65678. Object.defineProperty(exports, "Wallet", ({ enumerable: true, get: function () { return __importDefault(Wallet_1).default; } }));
  65679. var rfc1751_1 = __webpack_require__(/*! ./Wallet/rfc1751 */ "./dist/npm/Wallet/rfc1751.js");
  65680. Object.defineProperty(exports, "keyToRFC1751Mnemonic", ({ enumerable: true, get: function () { return rfc1751_1.keyToRFC1751Mnemonic; } }));
  65681. Object.defineProperty(exports, "rfc1751MnemonicToKey", ({ enumerable: true, get: function () { return rfc1751_1.rfc1751MnemonicToKey; } }));
  65682. __exportStar(__webpack_require__(/*! ./Wallet/signer */ "./dist/npm/Wallet/signer.js"), exports);
  65683. /***/ }),
  65684. /***/ "./dist/npm/models/index.js":
  65685. /*!**********************************!*\
  65686. !*** ./dist/npm/models/index.js ***!
  65687. \**********************************/
  65688. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  65689. "use strict";
  65690. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  65691. if (k2 === undefined) k2 = k;
  65692. var desc = Object.getOwnPropertyDescriptor(m, k);
  65693. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  65694. desc = { enumerable: true, get: function() { return m[k]; } };
  65695. }
  65696. Object.defineProperty(o, k2, desc);
  65697. }) : (function(o, m, k, k2) {
  65698. if (k2 === undefined) k2 = k;
  65699. o[k2] = m[k];
  65700. }));
  65701. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  65702. Object.defineProperty(o, "default", { enumerable: true, value: v });
  65703. }) : function(o, v) {
  65704. o["default"] = v;
  65705. });
  65706. var __importStar = (this && this.__importStar) || function (mod) {
  65707. if (mod && mod.__esModule) return mod;
  65708. var result = {};
  65709. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  65710. __setModuleDefault(result, mod);
  65711. return result;
  65712. };
  65713. var __exportStar = (this && this.__exportStar) || function(m, exports) {
  65714. for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
  65715. };
  65716. Object.defineProperty(exports, "__esModule", ({ value: true }));
  65717. exports.parseAccountRootFlags = exports.setTransactionFlagsToNumber = exports.LedgerEntry = void 0;
  65718. exports.LedgerEntry = __importStar(__webpack_require__(/*! ./ledger */ "./dist/npm/models/ledger/index.js"));
  65719. var flags_1 = __webpack_require__(/*! ./utils/flags */ "./dist/npm/models/utils/flags.js");
  65720. Object.defineProperty(exports, "setTransactionFlagsToNumber", ({ enumerable: true, get: function () { return flags_1.setTransactionFlagsToNumber; } }));
  65721. Object.defineProperty(exports, "parseAccountRootFlags", ({ enumerable: true, get: function () { return flags_1.parseAccountRootFlags; } }));
  65722. __exportStar(__webpack_require__(/*! ./methods */ "./dist/npm/models/methods/index.js"), exports);
  65723. __exportStar(__webpack_require__(/*! ./transactions */ "./dist/npm/models/transactions/index.js"), exports);
  65724. /***/ }),
  65725. /***/ "./dist/npm/models/ledger/AccountRoot.js":
  65726. /*!***********************************************!*\
  65727. !*** ./dist/npm/models/ledger/AccountRoot.js ***!
  65728. \***********************************************/
  65729. /***/ ((__unused_webpack_module, exports) => {
  65730. "use strict";
  65731. Object.defineProperty(exports, "__esModule", ({ value: true }));
  65732. exports.AccountRootFlags = void 0;
  65733. var AccountRootFlags;
  65734. (function (AccountRootFlags) {
  65735. AccountRootFlags[AccountRootFlags["lsfPasswordSpent"] = 65536] = "lsfPasswordSpent";
  65736. AccountRootFlags[AccountRootFlags["lsfRequireDestTag"] = 131072] = "lsfRequireDestTag";
  65737. AccountRootFlags[AccountRootFlags["lsfRequireAuth"] = 262144] = "lsfRequireAuth";
  65738. AccountRootFlags[AccountRootFlags["lsfDisallowXRP"] = 524288] = "lsfDisallowXRP";
  65739. AccountRootFlags[AccountRootFlags["lsfDisableMaster"] = 1048576] = "lsfDisableMaster";
  65740. AccountRootFlags[AccountRootFlags["lsfNoFreeze"] = 2097152] = "lsfNoFreeze";
  65741. AccountRootFlags[AccountRootFlags["lsfGlobalFreeze"] = 4194304] = "lsfGlobalFreeze";
  65742. AccountRootFlags[AccountRootFlags["lsfDefaultRipple"] = 8388608] = "lsfDefaultRipple";
  65743. AccountRootFlags[AccountRootFlags["lsfDepositAuth"] = 16777216] = "lsfDepositAuth";
  65744. AccountRootFlags[AccountRootFlags["lsfDisallowIncomingNFTokenOffer"] = 67108864] = "lsfDisallowIncomingNFTokenOffer";
  65745. AccountRootFlags[AccountRootFlags["lsfDisallowIncomingCheck"] = 134217728] = "lsfDisallowIncomingCheck";
  65746. AccountRootFlags[AccountRootFlags["lsfDisallowIncomingPayChan"] = 268435456] = "lsfDisallowIncomingPayChan";
  65747. AccountRootFlags[AccountRootFlags["lsfDisallowIncomingTrustline"] = 536870912] = "lsfDisallowIncomingTrustline";
  65748. })(AccountRootFlags = exports.AccountRootFlags || (exports.AccountRootFlags = {}));
  65749. /***/ }),
  65750. /***/ "./dist/npm/models/ledger/Offer.js":
  65751. /*!*****************************************!*\
  65752. !*** ./dist/npm/models/ledger/Offer.js ***!
  65753. \*****************************************/
  65754. /***/ ((__unused_webpack_module, exports) => {
  65755. "use strict";
  65756. Object.defineProperty(exports, "__esModule", ({ value: true }));
  65757. exports.OfferFlags = void 0;
  65758. var OfferFlags;
  65759. (function (OfferFlags) {
  65760. OfferFlags[OfferFlags["lsfPassive"] = 65536] = "lsfPassive";
  65761. OfferFlags[OfferFlags["lsfSell"] = 131072] = "lsfSell";
  65762. })(OfferFlags = exports.OfferFlags || (exports.OfferFlags = {}));
  65763. /***/ }),
  65764. /***/ "./dist/npm/models/ledger/RippleState.js":
  65765. /*!***********************************************!*\
  65766. !*** ./dist/npm/models/ledger/RippleState.js ***!
  65767. \***********************************************/
  65768. /***/ ((__unused_webpack_module, exports) => {
  65769. "use strict";
  65770. Object.defineProperty(exports, "__esModule", ({ value: true }));
  65771. exports.RippleStateFlags = void 0;
  65772. var RippleStateFlags;
  65773. (function (RippleStateFlags) {
  65774. RippleStateFlags[RippleStateFlags["lsfLowReserve"] = 65536] = "lsfLowReserve";
  65775. RippleStateFlags[RippleStateFlags["lsfHighReserve"] = 131072] = "lsfHighReserve";
  65776. RippleStateFlags[RippleStateFlags["lsfLowAuth"] = 262144] = "lsfLowAuth";
  65777. RippleStateFlags[RippleStateFlags["lsfHighAuth"] = 524288] = "lsfHighAuth";
  65778. RippleStateFlags[RippleStateFlags["lsfLowNoRipple"] = 1048576] = "lsfLowNoRipple";
  65779. RippleStateFlags[RippleStateFlags["lsfHighNoRipple"] = 2097152] = "lsfHighNoRipple";
  65780. RippleStateFlags[RippleStateFlags["lsfLowFreeze"] = 4194304] = "lsfLowFreeze";
  65781. RippleStateFlags[RippleStateFlags["lsfHighFreeze"] = 8388608] = "lsfHighFreeze";
  65782. })(RippleStateFlags = exports.RippleStateFlags || (exports.RippleStateFlags = {}));
  65783. /***/ }),
  65784. /***/ "./dist/npm/models/ledger/SignerList.js":
  65785. /*!**********************************************!*\
  65786. !*** ./dist/npm/models/ledger/SignerList.js ***!
  65787. \**********************************************/
  65788. /***/ ((__unused_webpack_module, exports) => {
  65789. "use strict";
  65790. Object.defineProperty(exports, "__esModule", ({ value: true }));
  65791. exports.SignerListFlags = void 0;
  65792. var SignerListFlags;
  65793. (function (SignerListFlags) {
  65794. SignerListFlags[SignerListFlags["lsfOneOwnerCount"] = 65536] = "lsfOneOwnerCount";
  65795. })(SignerListFlags = exports.SignerListFlags || (exports.SignerListFlags = {}));
  65796. /***/ }),
  65797. /***/ "./dist/npm/models/ledger/index.js":
  65798. /*!*****************************************!*\
  65799. !*** ./dist/npm/models/ledger/index.js ***!
  65800. \*****************************************/
  65801. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  65802. "use strict";
  65803. Object.defineProperty(exports, "__esModule", ({ value: true }));
  65804. exports.SignerListFlags = exports.RippleStateFlags = exports.OfferFlags = exports.AccountRootFlags = void 0;
  65805. const AccountRoot_1 = __webpack_require__(/*! ./AccountRoot */ "./dist/npm/models/ledger/AccountRoot.js");
  65806. Object.defineProperty(exports, "AccountRootFlags", ({ enumerable: true, get: function () { return AccountRoot_1.AccountRootFlags; } }));
  65807. const Offer_1 = __webpack_require__(/*! ./Offer */ "./dist/npm/models/ledger/Offer.js");
  65808. Object.defineProperty(exports, "OfferFlags", ({ enumerable: true, get: function () { return Offer_1.OfferFlags; } }));
  65809. const RippleState_1 = __webpack_require__(/*! ./RippleState */ "./dist/npm/models/ledger/RippleState.js");
  65810. Object.defineProperty(exports, "RippleStateFlags", ({ enumerable: true, get: function () { return RippleState_1.RippleStateFlags; } }));
  65811. const SignerList_1 = __webpack_require__(/*! ./SignerList */ "./dist/npm/models/ledger/SignerList.js");
  65812. Object.defineProperty(exports, "SignerListFlags", ({ enumerable: true, get: function () { return SignerList_1.SignerListFlags; } }));
  65813. /***/ }),
  65814. /***/ "./dist/npm/models/methods/index.js":
  65815. /*!******************************************!*\
  65816. !*** ./dist/npm/models/methods/index.js ***!
  65817. \******************************************/
  65818. /***/ ((__unused_webpack_module, exports) => {
  65819. "use strict";
  65820. Object.defineProperty(exports, "__esModule", ({ value: true }));
  65821. /***/ }),
  65822. /***/ "./dist/npm/models/transactions/NFTokenAcceptOffer.js":
  65823. /*!************************************************************!*\
  65824. !*** ./dist/npm/models/transactions/NFTokenAcceptOffer.js ***!
  65825. \************************************************************/
  65826. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  65827. "use strict";
  65828. Object.defineProperty(exports, "__esModule", ({ value: true }));
  65829. exports.validateNFTokenAcceptOffer = void 0;
  65830. const errors_1 = __webpack_require__(/*! ../../errors */ "./dist/npm/errors.js");
  65831. const common_1 = __webpack_require__(/*! ./common */ "./dist/npm/models/transactions/common.js");
  65832. function validateNFTokenBrokerFee(tx) {
  65833. const value = (0, common_1.parseAmountValue)(tx.NFTokenBrokerFee);
  65834. if (Number.isNaN(value)) {
  65835. throw new errors_1.ValidationError('NFTokenAcceptOffer: invalid NFTokenBrokerFee');
  65836. }
  65837. if (value <= 0) {
  65838. throw new errors_1.ValidationError('NFTokenAcceptOffer: NFTokenBrokerFee must be greater than 0; omit if there is no fee');
  65839. }
  65840. if (tx.NFTokenSellOffer == null || tx.NFTokenBuyOffer == null) {
  65841. throw new errors_1.ValidationError('NFTokenAcceptOffer: both NFTokenSellOffer and NFTokenBuyOffer must be set if using brokered mode');
  65842. }
  65843. }
  65844. function validateNFTokenAcceptOffer(tx) {
  65845. (0, common_1.validateBaseTransaction)(tx);
  65846. if (tx.NFTokenBrokerFee != null) {
  65847. validateNFTokenBrokerFee(tx);
  65848. }
  65849. if (tx.NFTokenSellOffer == null && tx.NFTokenBuyOffer == null) {
  65850. throw new errors_1.ValidationError('NFTokenAcceptOffer: must set either NFTokenSellOffer or NFTokenBuyOffer');
  65851. }
  65852. }
  65853. exports.validateNFTokenAcceptOffer = validateNFTokenAcceptOffer;
  65854. /***/ }),
  65855. /***/ "./dist/npm/models/transactions/NFTokenBurn.js":
  65856. /*!*****************************************************!*\
  65857. !*** ./dist/npm/models/transactions/NFTokenBurn.js ***!
  65858. \*****************************************************/
  65859. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  65860. "use strict";
  65861. Object.defineProperty(exports, "__esModule", ({ value: true }));
  65862. exports.validateNFTokenBurn = void 0;
  65863. const errors_1 = __webpack_require__(/*! ../../errors */ "./dist/npm/errors.js");
  65864. const common_1 = __webpack_require__(/*! ./common */ "./dist/npm/models/transactions/common.js");
  65865. function validateNFTokenBurn(tx) {
  65866. (0, common_1.validateBaseTransaction)(tx);
  65867. if (tx.NFTokenID == null) {
  65868. throw new errors_1.ValidationError('NFTokenBurn: missing field NFTokenID');
  65869. }
  65870. }
  65871. exports.validateNFTokenBurn = validateNFTokenBurn;
  65872. /***/ }),
  65873. /***/ "./dist/npm/models/transactions/NFTokenCancelOffer.js":
  65874. /*!************************************************************!*\
  65875. !*** ./dist/npm/models/transactions/NFTokenCancelOffer.js ***!
  65876. \************************************************************/
  65877. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  65878. "use strict";
  65879. Object.defineProperty(exports, "__esModule", ({ value: true }));
  65880. exports.validateNFTokenCancelOffer = void 0;
  65881. const errors_1 = __webpack_require__(/*! ../../errors */ "./dist/npm/errors.js");
  65882. const common_1 = __webpack_require__(/*! ./common */ "./dist/npm/models/transactions/common.js");
  65883. function validateNFTokenCancelOffer(tx) {
  65884. (0, common_1.validateBaseTransaction)(tx);
  65885. if (!Array.isArray(tx.NFTokenOffers)) {
  65886. throw new errors_1.ValidationError('NFTokenCancelOffer: missing field NFTokenOffers');
  65887. }
  65888. if (tx.NFTokenOffers.length < 1) {
  65889. throw new errors_1.ValidationError('NFTokenCancelOffer: empty field NFTokenOffers');
  65890. }
  65891. }
  65892. exports.validateNFTokenCancelOffer = validateNFTokenCancelOffer;
  65893. /***/ }),
  65894. /***/ "./dist/npm/models/transactions/NFTokenCreateOffer.js":
  65895. /*!************************************************************!*\
  65896. !*** ./dist/npm/models/transactions/NFTokenCreateOffer.js ***!
  65897. \************************************************************/
  65898. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  65899. "use strict";
  65900. Object.defineProperty(exports, "__esModule", ({ value: true }));
  65901. exports.validateNFTokenCreateOffer = exports.NFTokenCreateOfferFlags = void 0;
  65902. const errors_1 = __webpack_require__(/*! ../../errors */ "./dist/npm/errors.js");
  65903. const utils_1 = __webpack_require__(/*! ../utils */ "./dist/npm/models/utils/index.js");
  65904. const common_1 = __webpack_require__(/*! ./common */ "./dist/npm/models/transactions/common.js");
  65905. var NFTokenCreateOfferFlags;
  65906. (function (NFTokenCreateOfferFlags) {
  65907. NFTokenCreateOfferFlags[NFTokenCreateOfferFlags["tfSellNFToken"] = 1] = "tfSellNFToken";
  65908. })(NFTokenCreateOfferFlags = exports.NFTokenCreateOfferFlags || (exports.NFTokenCreateOfferFlags = {}));
  65909. function validateNFTokenSellOfferCases(tx) {
  65910. if (tx.Owner != null) {
  65911. throw new errors_1.ValidationError('NFTokenCreateOffer: Owner must not be present for sell offers');
  65912. }
  65913. }
  65914. function validateNFTokenBuyOfferCases(tx) {
  65915. if (tx.Owner == null) {
  65916. throw new errors_1.ValidationError('NFTokenCreateOffer: Owner must be present for buy offers');
  65917. }
  65918. if ((0, common_1.parseAmountValue)(tx.Amount) <= 0) {
  65919. throw new errors_1.ValidationError('NFTokenCreateOffer: Amount must be greater than 0 for buy offers');
  65920. }
  65921. }
  65922. function validateNFTokenCreateOffer(tx) {
  65923. (0, common_1.validateBaseTransaction)(tx);
  65924. if (tx.Account === tx.Owner) {
  65925. throw new errors_1.ValidationError('NFTokenCreateOffer: Owner and Account must not be equal');
  65926. }
  65927. if (tx.Account === tx.Destination) {
  65928. throw new errors_1.ValidationError('NFTokenCreateOffer: Destination and Account must not be equal');
  65929. }
  65930. if (tx.NFTokenID == null) {
  65931. throw new errors_1.ValidationError('NFTokenCreateOffer: missing field NFTokenID');
  65932. }
  65933. if (!(0, common_1.isAmount)(tx.Amount)) {
  65934. throw new errors_1.ValidationError('NFTokenCreateOffer: invalid Amount');
  65935. }
  65936. if (typeof tx.Flags === 'number' &&
  65937. (0, utils_1.isFlagEnabled)(tx.Flags, NFTokenCreateOfferFlags.tfSellNFToken)) {
  65938. validateNFTokenSellOfferCases(tx);
  65939. }
  65940. else {
  65941. validateNFTokenBuyOfferCases(tx);
  65942. }
  65943. }
  65944. exports.validateNFTokenCreateOffer = validateNFTokenCreateOffer;
  65945. /***/ }),
  65946. /***/ "./dist/npm/models/transactions/NFTokenMint.js":
  65947. /*!*****************************************************!*\
  65948. !*** ./dist/npm/models/transactions/NFTokenMint.js ***!
  65949. \*****************************************************/
  65950. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  65951. "use strict";
  65952. Object.defineProperty(exports, "__esModule", ({ value: true }));
  65953. exports.validateNFTokenMint = exports.NFTokenMintFlags = void 0;
  65954. const errors_1 = __webpack_require__(/*! ../../errors */ "./dist/npm/errors.js");
  65955. const utils_1 = __webpack_require__(/*! ../utils */ "./dist/npm/models/utils/index.js");
  65956. const common_1 = __webpack_require__(/*! ./common */ "./dist/npm/models/transactions/common.js");
  65957. var NFTokenMintFlags;
  65958. (function (NFTokenMintFlags) {
  65959. NFTokenMintFlags[NFTokenMintFlags["tfBurnable"] = 1] = "tfBurnable";
  65960. NFTokenMintFlags[NFTokenMintFlags["tfOnlyXRP"] = 2] = "tfOnlyXRP";
  65961. NFTokenMintFlags[NFTokenMintFlags["tfTrustLine"] = 4] = "tfTrustLine";
  65962. NFTokenMintFlags[NFTokenMintFlags["tfTransferable"] = 8] = "tfTransferable";
  65963. })(NFTokenMintFlags = exports.NFTokenMintFlags || (exports.NFTokenMintFlags = {}));
  65964. function validateNFTokenMint(tx) {
  65965. (0, common_1.validateBaseTransaction)(tx);
  65966. if (tx.Account === tx.Issuer) {
  65967. throw new errors_1.ValidationError('NFTokenMint: Issuer must not be equal to Account');
  65968. }
  65969. if (typeof tx.URI === 'string' && !(0, utils_1.isHex)(tx.URI)) {
  65970. throw new errors_1.ValidationError('NFTokenMint: URI must be in hex format');
  65971. }
  65972. if (tx.NFTokenTaxon == null) {
  65973. throw new errors_1.ValidationError('NFTokenMint: missing field NFTokenTaxon');
  65974. }
  65975. }
  65976. exports.validateNFTokenMint = validateNFTokenMint;
  65977. /***/ }),
  65978. /***/ "./dist/npm/models/transactions/accountDelete.js":
  65979. /*!*******************************************************!*\
  65980. !*** ./dist/npm/models/transactions/accountDelete.js ***!
  65981. \*******************************************************/
  65982. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  65983. "use strict";
  65984. Object.defineProperty(exports, "__esModule", ({ value: true }));
  65985. exports.validateAccountDelete = void 0;
  65986. const errors_1 = __webpack_require__(/*! ../../errors */ "./dist/npm/errors.js");
  65987. const common_1 = __webpack_require__(/*! ./common */ "./dist/npm/models/transactions/common.js");
  65988. function validateAccountDelete(tx) {
  65989. (0, common_1.validateBaseTransaction)(tx);
  65990. if (tx.Destination === undefined) {
  65991. throw new errors_1.ValidationError('AccountDelete: missing field Destination');
  65992. }
  65993. if (typeof tx.Destination !== 'string') {
  65994. throw new errors_1.ValidationError('AccountDelete: invalid Destination');
  65995. }
  65996. if (tx.DestinationTag !== undefined &&
  65997. typeof tx.DestinationTag !== 'number') {
  65998. throw new errors_1.ValidationError('AccountDelete: invalid DestinationTag');
  65999. }
  66000. }
  66001. exports.validateAccountDelete = validateAccountDelete;
  66002. /***/ }),
  66003. /***/ "./dist/npm/models/transactions/accountSet.js":
  66004. /*!****************************************************!*\
  66005. !*** ./dist/npm/models/transactions/accountSet.js ***!
  66006. \****************************************************/
  66007. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  66008. "use strict";
  66009. Object.defineProperty(exports, "__esModule", ({ value: true }));
  66010. exports.validateAccountSet = exports.AccountSetTfFlags = exports.AccountSetAsfFlags = void 0;
  66011. const ripple_address_codec_1 = __webpack_require__(/*! ripple-address-codec */ "../../node_modules/ripple-address-codec/dist/index.js");
  66012. const errors_1 = __webpack_require__(/*! ../../errors */ "./dist/npm/errors.js");
  66013. const common_1 = __webpack_require__(/*! ./common */ "./dist/npm/models/transactions/common.js");
  66014. var AccountSetAsfFlags;
  66015. (function (AccountSetAsfFlags) {
  66016. AccountSetAsfFlags[AccountSetAsfFlags["asfRequireDest"] = 1] = "asfRequireDest";
  66017. AccountSetAsfFlags[AccountSetAsfFlags["asfRequireAuth"] = 2] = "asfRequireAuth";
  66018. AccountSetAsfFlags[AccountSetAsfFlags["asfDisallowXRP"] = 3] = "asfDisallowXRP";
  66019. AccountSetAsfFlags[AccountSetAsfFlags["asfDisableMaster"] = 4] = "asfDisableMaster";
  66020. AccountSetAsfFlags[AccountSetAsfFlags["asfAccountTxnID"] = 5] = "asfAccountTxnID";
  66021. AccountSetAsfFlags[AccountSetAsfFlags["asfNoFreeze"] = 6] = "asfNoFreeze";
  66022. AccountSetAsfFlags[AccountSetAsfFlags["asfGlobalFreeze"] = 7] = "asfGlobalFreeze";
  66023. AccountSetAsfFlags[AccountSetAsfFlags["asfDefaultRipple"] = 8] = "asfDefaultRipple";
  66024. AccountSetAsfFlags[AccountSetAsfFlags["asfDepositAuth"] = 9] = "asfDepositAuth";
  66025. AccountSetAsfFlags[AccountSetAsfFlags["asfAuthorizedNFTokenMinter"] = 10] = "asfAuthorizedNFTokenMinter";
  66026. AccountSetAsfFlags[AccountSetAsfFlags["asfDisallowIncomingNFTokenOffer"] = 12] = "asfDisallowIncomingNFTokenOffer";
  66027. AccountSetAsfFlags[AccountSetAsfFlags["asfDisallowIncomingCheck"] = 13] = "asfDisallowIncomingCheck";
  66028. AccountSetAsfFlags[AccountSetAsfFlags["asfDisallowIncomingPayChan"] = 14] = "asfDisallowIncomingPayChan";
  66029. AccountSetAsfFlags[AccountSetAsfFlags["asfDisallowIncomingTrustline"] = 15] = "asfDisallowIncomingTrustline";
  66030. })(AccountSetAsfFlags = exports.AccountSetAsfFlags || (exports.AccountSetAsfFlags = {}));
  66031. var AccountSetTfFlags;
  66032. (function (AccountSetTfFlags) {
  66033. AccountSetTfFlags[AccountSetTfFlags["tfRequireDestTag"] = 65536] = "tfRequireDestTag";
  66034. AccountSetTfFlags[AccountSetTfFlags["tfOptionalDestTag"] = 131072] = "tfOptionalDestTag";
  66035. AccountSetTfFlags[AccountSetTfFlags["tfRequireAuth"] = 262144] = "tfRequireAuth";
  66036. AccountSetTfFlags[AccountSetTfFlags["tfOptionalAuth"] = 524288] = "tfOptionalAuth";
  66037. AccountSetTfFlags[AccountSetTfFlags["tfDisallowXRP"] = 1048576] = "tfDisallowXRP";
  66038. AccountSetTfFlags[AccountSetTfFlags["tfAllowXRP"] = 2097152] = "tfAllowXRP";
  66039. })(AccountSetTfFlags = exports.AccountSetTfFlags || (exports.AccountSetTfFlags = {}));
  66040. const MIN_TICK_SIZE = 3;
  66041. const MAX_TICK_SIZE = 15;
  66042. function validateAccountSet(tx) {
  66043. (0, common_1.validateBaseTransaction)(tx);
  66044. if (tx.NFTokenMinter !== undefined &&
  66045. !(0, ripple_address_codec_1.isValidClassicAddress)(String(tx.NFTokenMinter))) {
  66046. throw new errors_1.ValidationError('AccountSet: invalid NFTokenMinter');
  66047. }
  66048. if (tx.ClearFlag !== undefined) {
  66049. if (typeof tx.ClearFlag !== 'number') {
  66050. throw new errors_1.ValidationError('AccountSet: invalid ClearFlag');
  66051. }
  66052. if (!Object.values(AccountSetAsfFlags).includes(tx.ClearFlag)) {
  66053. throw new errors_1.ValidationError('AccountSet: invalid ClearFlag');
  66054. }
  66055. }
  66056. if (tx.Domain !== undefined && typeof tx.Domain !== 'string') {
  66057. throw new errors_1.ValidationError('AccountSet: invalid Domain');
  66058. }
  66059. if (tx.EmailHash !== undefined && typeof tx.EmailHash !== 'string') {
  66060. throw new errors_1.ValidationError('AccountSet: invalid EmailHash');
  66061. }
  66062. if (tx.MessageKey !== undefined && typeof tx.MessageKey !== 'string') {
  66063. throw new errors_1.ValidationError('AccountSet: invalid MessageKey');
  66064. }
  66065. if (tx.SetFlag !== undefined) {
  66066. if (typeof tx.SetFlag !== 'number') {
  66067. throw new errors_1.ValidationError('AccountSet: invalid SetFlag');
  66068. }
  66069. if (!Object.values(AccountSetAsfFlags).includes(tx.SetFlag)) {
  66070. throw new errors_1.ValidationError('AccountSet: invalid SetFlag');
  66071. }
  66072. }
  66073. if (tx.TransferRate !== undefined && typeof tx.TransferRate !== 'number') {
  66074. throw new errors_1.ValidationError('AccountSet: invalid TransferRate');
  66075. }
  66076. if (tx.TickSize !== undefined) {
  66077. if (typeof tx.TickSize !== 'number') {
  66078. throw new errors_1.ValidationError('AccountSet: invalid TickSize');
  66079. }
  66080. if (tx.TickSize !== 0 &&
  66081. (tx.TickSize < MIN_TICK_SIZE || tx.TickSize > MAX_TICK_SIZE)) {
  66082. throw new errors_1.ValidationError('AccountSet: invalid TickSize');
  66083. }
  66084. }
  66085. }
  66086. exports.validateAccountSet = validateAccountSet;
  66087. /***/ }),
  66088. /***/ "./dist/npm/models/transactions/checkCancel.js":
  66089. /*!*****************************************************!*\
  66090. !*** ./dist/npm/models/transactions/checkCancel.js ***!
  66091. \*****************************************************/
  66092. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  66093. "use strict";
  66094. Object.defineProperty(exports, "__esModule", ({ value: true }));
  66095. exports.validateCheckCancel = void 0;
  66096. const errors_1 = __webpack_require__(/*! ../../errors */ "./dist/npm/errors.js");
  66097. const common_1 = __webpack_require__(/*! ./common */ "./dist/npm/models/transactions/common.js");
  66098. function validateCheckCancel(tx) {
  66099. (0, common_1.validateBaseTransaction)(tx);
  66100. if (tx.CheckID !== undefined && typeof tx.CheckID !== 'string') {
  66101. throw new errors_1.ValidationError('CheckCancel: invalid CheckID');
  66102. }
  66103. }
  66104. exports.validateCheckCancel = validateCheckCancel;
  66105. /***/ }),
  66106. /***/ "./dist/npm/models/transactions/checkCash.js":
  66107. /*!***************************************************!*\
  66108. !*** ./dist/npm/models/transactions/checkCash.js ***!
  66109. \***************************************************/
  66110. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  66111. "use strict";
  66112. Object.defineProperty(exports, "__esModule", ({ value: true }));
  66113. exports.validateCheckCash = void 0;
  66114. const errors_1 = __webpack_require__(/*! ../../errors */ "./dist/npm/errors.js");
  66115. const common_1 = __webpack_require__(/*! ./common */ "./dist/npm/models/transactions/common.js");
  66116. function validateCheckCash(tx) {
  66117. (0, common_1.validateBaseTransaction)(tx);
  66118. if (tx.Amount == null && tx.DeliverMin == null) {
  66119. throw new errors_1.ValidationError('CheckCash: must have either Amount or DeliverMin');
  66120. }
  66121. if (tx.Amount != null && tx.DeliverMin != null) {
  66122. throw new errors_1.ValidationError('CheckCash: cannot have both Amount and DeliverMin');
  66123. }
  66124. if (tx.Amount != null && tx.Amount !== undefined && !(0, common_1.isAmount)(tx.Amount)) {
  66125. throw new errors_1.ValidationError('CheckCash: invalid Amount');
  66126. }
  66127. if (tx.DeliverMin != null &&
  66128. tx.DeliverMin !== undefined &&
  66129. !(0, common_1.isAmount)(tx.DeliverMin)) {
  66130. throw new errors_1.ValidationError('CheckCash: invalid DeliverMin');
  66131. }
  66132. if (tx.CheckID !== undefined && typeof tx.CheckID !== 'string') {
  66133. throw new errors_1.ValidationError('CheckCash: invalid CheckID');
  66134. }
  66135. }
  66136. exports.validateCheckCash = validateCheckCash;
  66137. /***/ }),
  66138. /***/ "./dist/npm/models/transactions/checkCreate.js":
  66139. /*!*****************************************************!*\
  66140. !*** ./dist/npm/models/transactions/checkCreate.js ***!
  66141. \*****************************************************/
  66142. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  66143. "use strict";
  66144. Object.defineProperty(exports, "__esModule", ({ value: true }));
  66145. exports.validateCheckCreate = void 0;
  66146. const errors_1 = __webpack_require__(/*! ../../errors */ "./dist/npm/errors.js");
  66147. const common_1 = __webpack_require__(/*! ./common */ "./dist/npm/models/transactions/common.js");
  66148. function validateCheckCreate(tx) {
  66149. (0, common_1.validateBaseTransaction)(tx);
  66150. if (tx.SendMax === undefined) {
  66151. throw new errors_1.ValidationError('CheckCreate: missing field SendMax');
  66152. }
  66153. if (tx.Destination === undefined) {
  66154. throw new errors_1.ValidationError('CheckCreate: missing field Destination');
  66155. }
  66156. if (typeof tx.SendMax !== 'string' &&
  66157. !(0, common_1.isIssuedCurrency)(tx.SendMax)) {
  66158. throw new errors_1.ValidationError('CheckCreate: invalid SendMax');
  66159. }
  66160. if (typeof tx.Destination !== 'string') {
  66161. throw new errors_1.ValidationError('CheckCreate: invalid Destination');
  66162. }
  66163. if (tx.DestinationTag !== undefined &&
  66164. typeof tx.DestinationTag !== 'number') {
  66165. throw new errors_1.ValidationError('CheckCreate: invalid DestinationTag');
  66166. }
  66167. if (tx.Expiration !== undefined && typeof tx.Expiration !== 'number') {
  66168. throw new errors_1.ValidationError('CheckCreate: invalid Expiration');
  66169. }
  66170. if (tx.InvoiceID !== undefined && typeof tx.InvoiceID !== 'string') {
  66171. throw new errors_1.ValidationError('CheckCreate: invalid InvoiceID');
  66172. }
  66173. }
  66174. exports.validateCheckCreate = validateCheckCreate;
  66175. /***/ }),
  66176. /***/ "./dist/npm/models/transactions/common.js":
  66177. /*!************************************************!*\
  66178. !*** ./dist/npm/models/transactions/common.js ***!
  66179. \************************************************/
  66180. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  66181. "use strict";
  66182. Object.defineProperty(exports, "__esModule", ({ value: true }));
  66183. exports.parseAmountValue = exports.validateBaseTransaction = exports.isAmount = exports.isIssuedCurrency = void 0;
  66184. const ripple_binary_codec_1 = __webpack_require__(/*! ripple-binary-codec */ "../../node_modules/ripple-binary-codec/dist/index.js");
  66185. const errors_1 = __webpack_require__(/*! ../../errors */ "./dist/npm/errors.js");
  66186. const utils_1 = __webpack_require__(/*! ../utils */ "./dist/npm/models/utils/index.js");
  66187. const MEMO_SIZE = 3;
  66188. function isMemo(obj) {
  66189. if (obj.Memo == null) {
  66190. return false;
  66191. }
  66192. const memo = obj.Memo;
  66193. const size = Object.keys(memo).length;
  66194. const validData = memo.MemoData == null || typeof memo.MemoData === 'string';
  66195. const validFormat = memo.MemoFormat == null || typeof memo.MemoFormat === 'string';
  66196. const validType = memo.MemoType == null || typeof memo.MemoType === 'string';
  66197. return (size >= 1 &&
  66198. size <= MEMO_SIZE &&
  66199. validData &&
  66200. validFormat &&
  66201. validType &&
  66202. (0, utils_1.onlyHasFields)(memo, ['MemoFormat', 'MemoData', 'MemoType']));
  66203. }
  66204. const SIGNER_SIZE = 3;
  66205. function isSigner(obj) {
  66206. const signerWrapper = obj;
  66207. if (signerWrapper.Signer == null) {
  66208. return false;
  66209. }
  66210. const signer = signerWrapper.Signer;
  66211. return (Object.keys(signer).length === SIGNER_SIZE &&
  66212. typeof signer.Account === 'string' &&
  66213. typeof signer.TxnSignature === 'string' &&
  66214. typeof signer.SigningPubKey === 'string');
  66215. }
  66216. const ISSUED_CURRENCY_SIZE = 3;
  66217. function isRecord(value) {
  66218. return value !== null && typeof value === 'object';
  66219. }
  66220. function isIssuedCurrency(input) {
  66221. return (isRecord(input) &&
  66222. Object.keys(input).length === ISSUED_CURRENCY_SIZE &&
  66223. typeof input.value === 'string' &&
  66224. typeof input.issuer === 'string' &&
  66225. typeof input.currency === 'string');
  66226. }
  66227. exports.isIssuedCurrency = isIssuedCurrency;
  66228. function isAmount(amount) {
  66229. return typeof amount === 'string' || isIssuedCurrency(amount);
  66230. }
  66231. exports.isAmount = isAmount;
  66232. function validateBaseTransaction(common) {
  66233. if (common.Account === undefined) {
  66234. throw new errors_1.ValidationError('BaseTransaction: missing field Account');
  66235. }
  66236. if (typeof common.Account !== 'string') {
  66237. throw new errors_1.ValidationError('BaseTransaction: Account not string');
  66238. }
  66239. if (common.TransactionType === undefined) {
  66240. throw new errors_1.ValidationError('BaseTransaction: missing field TransactionType');
  66241. }
  66242. if (typeof common.TransactionType !== 'string') {
  66243. throw new errors_1.ValidationError('BaseTransaction: TransactionType not string');
  66244. }
  66245. if (!ripple_binary_codec_1.TRANSACTION_TYPES.includes(common.TransactionType)) {
  66246. throw new errors_1.ValidationError('BaseTransaction: Unknown TransactionType');
  66247. }
  66248. if (common.Fee !== undefined && typeof common.Fee !== 'string') {
  66249. throw new errors_1.ValidationError('BaseTransaction: invalid Fee');
  66250. }
  66251. if (common.Sequence !== undefined && typeof common.Sequence !== 'number') {
  66252. throw new errors_1.ValidationError('BaseTransaction: invalid Sequence');
  66253. }
  66254. if (common.AccountTxnID !== undefined &&
  66255. typeof common.AccountTxnID !== 'string') {
  66256. throw new errors_1.ValidationError('BaseTransaction: invalid AccountTxnID');
  66257. }
  66258. if (common.LastLedgerSequence !== undefined &&
  66259. typeof common.LastLedgerSequence !== 'number') {
  66260. throw new errors_1.ValidationError('BaseTransaction: invalid LastLedgerSequence');
  66261. }
  66262. const memos = common.Memos;
  66263. if (memos !== undefined && !memos.every(isMemo)) {
  66264. throw new errors_1.ValidationError('BaseTransaction: invalid Memos');
  66265. }
  66266. const signers = common.Signers;
  66267. if (signers !== undefined &&
  66268. (signers.length === 0 || !signers.every(isSigner))) {
  66269. throw new errors_1.ValidationError('BaseTransaction: invalid Signers');
  66270. }
  66271. if (common.SourceTag !== undefined && typeof common.SourceTag !== 'number') {
  66272. throw new errors_1.ValidationError('BaseTransaction: invalid SourceTag');
  66273. }
  66274. if (common.SigningPubKey !== undefined &&
  66275. typeof common.SigningPubKey !== 'string') {
  66276. throw new errors_1.ValidationError('BaseTransaction: invalid SigningPubKey');
  66277. }
  66278. if (common.TicketSequence !== undefined &&
  66279. typeof common.TicketSequence !== 'number') {
  66280. throw new errors_1.ValidationError('BaseTransaction: invalid TicketSequence');
  66281. }
  66282. if (common.TxnSignature !== undefined &&
  66283. typeof common.TxnSignature !== 'string') {
  66284. throw new errors_1.ValidationError('BaseTransaction: invalid TxnSignature');
  66285. }
  66286. }
  66287. exports.validateBaseTransaction = validateBaseTransaction;
  66288. function parseAmountValue(amount) {
  66289. if (!isAmount(amount)) {
  66290. return NaN;
  66291. }
  66292. if (typeof amount === 'string') {
  66293. return parseFloat(amount);
  66294. }
  66295. return parseFloat(amount.value);
  66296. }
  66297. exports.parseAmountValue = parseAmountValue;
  66298. /***/ }),
  66299. /***/ "./dist/npm/models/transactions/depositPreauth.js":
  66300. /*!********************************************************!*\
  66301. !*** ./dist/npm/models/transactions/depositPreauth.js ***!
  66302. \********************************************************/
  66303. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  66304. "use strict";
  66305. Object.defineProperty(exports, "__esModule", ({ value: true }));
  66306. exports.validateDepositPreauth = void 0;
  66307. const errors_1 = __webpack_require__(/*! ../../errors */ "./dist/npm/errors.js");
  66308. const common_1 = __webpack_require__(/*! ./common */ "./dist/npm/models/transactions/common.js");
  66309. function validateDepositPreauth(tx) {
  66310. (0, common_1.validateBaseTransaction)(tx);
  66311. if (tx.Authorize !== undefined && tx.Unauthorize !== undefined) {
  66312. throw new errors_1.ValidationError("DepositPreauth: can't provide both Authorize and Unauthorize fields");
  66313. }
  66314. if (tx.Authorize === undefined && tx.Unauthorize === undefined) {
  66315. throw new errors_1.ValidationError('DepositPreauth: must provide either Authorize or Unauthorize field');
  66316. }
  66317. if (tx.Authorize !== undefined) {
  66318. if (typeof tx.Authorize !== 'string') {
  66319. throw new errors_1.ValidationError('DepositPreauth: Authorize must be a string');
  66320. }
  66321. if (tx.Account === tx.Authorize) {
  66322. throw new errors_1.ValidationError("DepositPreauth: Account can't preauthorize its own address");
  66323. }
  66324. }
  66325. if (tx.Unauthorize !== undefined) {
  66326. if (typeof tx.Unauthorize !== 'string') {
  66327. throw new errors_1.ValidationError('DepositPreauth: Unauthorize must be a string');
  66328. }
  66329. if (tx.Account === tx.Unauthorize) {
  66330. throw new errors_1.ValidationError("DepositPreauth: Account can't unauthorize its own address");
  66331. }
  66332. }
  66333. }
  66334. exports.validateDepositPreauth = validateDepositPreauth;
  66335. /***/ }),
  66336. /***/ "./dist/npm/models/transactions/escrowCancel.js":
  66337. /*!******************************************************!*\
  66338. !*** ./dist/npm/models/transactions/escrowCancel.js ***!
  66339. \******************************************************/
  66340. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  66341. "use strict";
  66342. Object.defineProperty(exports, "__esModule", ({ value: true }));
  66343. exports.validateEscrowCancel = void 0;
  66344. const errors_1 = __webpack_require__(/*! ../../errors */ "./dist/npm/errors.js");
  66345. const common_1 = __webpack_require__(/*! ./common */ "./dist/npm/models/transactions/common.js");
  66346. function validateEscrowCancel(tx) {
  66347. (0, common_1.validateBaseTransaction)(tx);
  66348. if (tx.Owner === undefined) {
  66349. throw new errors_1.ValidationError('EscrowCancel: missing Owner');
  66350. }
  66351. if (typeof tx.Owner !== 'string') {
  66352. throw new errors_1.ValidationError('EscrowCancel: Owner must be a string');
  66353. }
  66354. if (tx.OfferSequence === undefined) {
  66355. throw new errors_1.ValidationError('EscrowCancel: missing OfferSequence');
  66356. }
  66357. if (typeof tx.OfferSequence !== 'number') {
  66358. throw new errors_1.ValidationError('EscrowCancel: OfferSequence must be a number');
  66359. }
  66360. }
  66361. exports.validateEscrowCancel = validateEscrowCancel;
  66362. /***/ }),
  66363. /***/ "./dist/npm/models/transactions/escrowCreate.js":
  66364. /*!******************************************************!*\
  66365. !*** ./dist/npm/models/transactions/escrowCreate.js ***!
  66366. \******************************************************/
  66367. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  66368. "use strict";
  66369. Object.defineProperty(exports, "__esModule", ({ value: true }));
  66370. exports.validateEscrowCreate = void 0;
  66371. const errors_1 = __webpack_require__(/*! ../../errors */ "./dist/npm/errors.js");
  66372. const common_1 = __webpack_require__(/*! ./common */ "./dist/npm/models/transactions/common.js");
  66373. function validateEscrowCreate(tx) {
  66374. (0, common_1.validateBaseTransaction)(tx);
  66375. if (tx.Amount === undefined) {
  66376. throw new errors_1.ValidationError('EscrowCreate: missing field Amount');
  66377. }
  66378. if (typeof tx.Amount !== 'string') {
  66379. throw new errors_1.ValidationError('EscrowCreate: Amount must be a string');
  66380. }
  66381. if (tx.Destination === undefined) {
  66382. throw new errors_1.ValidationError('EscrowCreate: missing field Destination');
  66383. }
  66384. if (typeof tx.Destination !== 'string') {
  66385. throw new errors_1.ValidationError('EscrowCreate: Destination must be a string');
  66386. }
  66387. if (tx.CancelAfter === undefined && tx.FinishAfter === undefined) {
  66388. throw new errors_1.ValidationError('EscrowCreate: Either CancelAfter or FinishAfter must be specified');
  66389. }
  66390. if (tx.FinishAfter === undefined && tx.Condition === undefined) {
  66391. throw new errors_1.ValidationError('EscrowCreate: Either Condition or FinishAfter must be specified');
  66392. }
  66393. if (tx.CancelAfter !== undefined && typeof tx.CancelAfter !== 'number') {
  66394. throw new errors_1.ValidationError('EscrowCreate: CancelAfter must be a number');
  66395. }
  66396. if (tx.FinishAfter !== undefined && typeof tx.FinishAfter !== 'number') {
  66397. throw new errors_1.ValidationError('EscrowCreate: FinishAfter must be a number');
  66398. }
  66399. if (tx.Condition !== undefined && typeof tx.Condition !== 'string') {
  66400. throw new errors_1.ValidationError('EscrowCreate: Condition must be a string');
  66401. }
  66402. if (tx.DestinationTag !== undefined &&
  66403. typeof tx.DestinationTag !== 'number') {
  66404. throw new errors_1.ValidationError('EscrowCreate: DestinationTag must be a number');
  66405. }
  66406. }
  66407. exports.validateEscrowCreate = validateEscrowCreate;
  66408. /***/ }),
  66409. /***/ "./dist/npm/models/transactions/escrowFinish.js":
  66410. /*!******************************************************!*\
  66411. !*** ./dist/npm/models/transactions/escrowFinish.js ***!
  66412. \******************************************************/
  66413. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  66414. "use strict";
  66415. Object.defineProperty(exports, "__esModule", ({ value: true }));
  66416. exports.validateEscrowFinish = void 0;
  66417. const errors_1 = __webpack_require__(/*! ../../errors */ "./dist/npm/errors.js");
  66418. const common_1 = __webpack_require__(/*! ./common */ "./dist/npm/models/transactions/common.js");
  66419. function validateEscrowFinish(tx) {
  66420. (0, common_1.validateBaseTransaction)(tx);
  66421. if (tx.Owner === undefined) {
  66422. throw new errors_1.ValidationError('EscrowFinish: missing field Owner');
  66423. }
  66424. if (typeof tx.Owner !== 'string') {
  66425. throw new errors_1.ValidationError('EscrowFinish: Owner must be a string');
  66426. }
  66427. if (tx.OfferSequence === undefined) {
  66428. throw new errors_1.ValidationError('EscrowFinish: missing field OfferSequence');
  66429. }
  66430. if (typeof tx.OfferSequence !== 'number') {
  66431. throw new errors_1.ValidationError('EscrowFinish: OfferSequence must be a number');
  66432. }
  66433. if (tx.Condition !== undefined && typeof tx.Condition !== 'string') {
  66434. throw new errors_1.ValidationError('EscrowFinish: Condition must be a string');
  66435. }
  66436. if (tx.Fulfillment !== undefined && typeof tx.Fulfillment !== 'string') {
  66437. throw new errors_1.ValidationError('EscrowFinish: Fulfillment must be a string');
  66438. }
  66439. }
  66440. exports.validateEscrowFinish = validateEscrowFinish;
  66441. /***/ }),
  66442. /***/ "./dist/npm/models/transactions/index.js":
  66443. /*!***********************************************!*\
  66444. !*** ./dist/npm/models/transactions/index.js ***!
  66445. \***********************************************/
  66446. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  66447. "use strict";
  66448. Object.defineProperty(exports, "__esModule", ({ value: true }));
  66449. exports.TrustSetFlags = exports.PaymentChannelClaimFlags = exports.PaymentFlags = exports.OfferCreateFlags = exports.NFTokenMintFlags = exports.NFTokenCreateOfferFlags = exports.AccountSetTfFlags = exports.AccountSetAsfFlags = exports.validate = void 0;
  66450. var transaction_1 = __webpack_require__(/*! ./transaction */ "./dist/npm/models/transactions/transaction.js");
  66451. Object.defineProperty(exports, "validate", ({ enumerable: true, get: function () { return transaction_1.validate; } }));
  66452. var accountSet_1 = __webpack_require__(/*! ./accountSet */ "./dist/npm/models/transactions/accountSet.js");
  66453. Object.defineProperty(exports, "AccountSetAsfFlags", ({ enumerable: true, get: function () { return accountSet_1.AccountSetAsfFlags; } }));
  66454. Object.defineProperty(exports, "AccountSetTfFlags", ({ enumerable: true, get: function () { return accountSet_1.AccountSetTfFlags; } }));
  66455. var NFTokenCreateOffer_1 = __webpack_require__(/*! ./NFTokenCreateOffer */ "./dist/npm/models/transactions/NFTokenCreateOffer.js");
  66456. Object.defineProperty(exports, "NFTokenCreateOfferFlags", ({ enumerable: true, get: function () { return NFTokenCreateOffer_1.NFTokenCreateOfferFlags; } }));
  66457. var NFTokenMint_1 = __webpack_require__(/*! ./NFTokenMint */ "./dist/npm/models/transactions/NFTokenMint.js");
  66458. Object.defineProperty(exports, "NFTokenMintFlags", ({ enumerable: true, get: function () { return NFTokenMint_1.NFTokenMintFlags; } }));
  66459. var offerCreate_1 = __webpack_require__(/*! ./offerCreate */ "./dist/npm/models/transactions/offerCreate.js");
  66460. Object.defineProperty(exports, "OfferCreateFlags", ({ enumerable: true, get: function () { return offerCreate_1.OfferCreateFlags; } }));
  66461. var payment_1 = __webpack_require__(/*! ./payment */ "./dist/npm/models/transactions/payment.js");
  66462. Object.defineProperty(exports, "PaymentFlags", ({ enumerable: true, get: function () { return payment_1.PaymentFlags; } }));
  66463. var paymentChannelClaim_1 = __webpack_require__(/*! ./paymentChannelClaim */ "./dist/npm/models/transactions/paymentChannelClaim.js");
  66464. Object.defineProperty(exports, "PaymentChannelClaimFlags", ({ enumerable: true, get: function () { return paymentChannelClaim_1.PaymentChannelClaimFlags; } }));
  66465. var trustSet_1 = __webpack_require__(/*! ./trustSet */ "./dist/npm/models/transactions/trustSet.js");
  66466. Object.defineProperty(exports, "TrustSetFlags", ({ enumerable: true, get: function () { return trustSet_1.TrustSetFlags; } }));
  66467. /***/ }),
  66468. /***/ "./dist/npm/models/transactions/metadata.js":
  66469. /*!**************************************************!*\
  66470. !*** ./dist/npm/models/transactions/metadata.js ***!
  66471. \**************************************************/
  66472. /***/ ((__unused_webpack_module, exports) => {
  66473. "use strict";
  66474. Object.defineProperty(exports, "__esModule", ({ value: true }));
  66475. exports.isDeletedNode = exports.isModifiedNode = exports.isCreatedNode = void 0;
  66476. function isCreatedNode(node) {
  66477. return Object.prototype.hasOwnProperty.call(node, `CreatedNode`);
  66478. }
  66479. exports.isCreatedNode = isCreatedNode;
  66480. function isModifiedNode(node) {
  66481. return Object.prototype.hasOwnProperty.call(node, `ModifiedNode`);
  66482. }
  66483. exports.isModifiedNode = isModifiedNode;
  66484. function isDeletedNode(node) {
  66485. return Object.prototype.hasOwnProperty.call(node, `DeletedNode`);
  66486. }
  66487. exports.isDeletedNode = isDeletedNode;
  66488. /***/ }),
  66489. /***/ "./dist/npm/models/transactions/offerCancel.js":
  66490. /*!*****************************************************!*\
  66491. !*** ./dist/npm/models/transactions/offerCancel.js ***!
  66492. \*****************************************************/
  66493. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  66494. "use strict";
  66495. Object.defineProperty(exports, "__esModule", ({ value: true }));
  66496. exports.validateOfferCancel = void 0;
  66497. const errors_1 = __webpack_require__(/*! ../../errors */ "./dist/npm/errors.js");
  66498. const common_1 = __webpack_require__(/*! ./common */ "./dist/npm/models/transactions/common.js");
  66499. function validateOfferCancel(tx) {
  66500. (0, common_1.validateBaseTransaction)(tx);
  66501. if (tx.OfferSequence === undefined) {
  66502. throw new errors_1.ValidationError('OfferCancel: missing field OfferSequence');
  66503. }
  66504. if (typeof tx.OfferSequence !== 'number') {
  66505. throw new errors_1.ValidationError('OfferCancel: OfferSequence must be a number');
  66506. }
  66507. }
  66508. exports.validateOfferCancel = validateOfferCancel;
  66509. /***/ }),
  66510. /***/ "./dist/npm/models/transactions/offerCreate.js":
  66511. /*!*****************************************************!*\
  66512. !*** ./dist/npm/models/transactions/offerCreate.js ***!
  66513. \*****************************************************/
  66514. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  66515. "use strict";
  66516. Object.defineProperty(exports, "__esModule", ({ value: true }));
  66517. exports.validateOfferCreate = exports.OfferCreateFlags = void 0;
  66518. const errors_1 = __webpack_require__(/*! ../../errors */ "./dist/npm/errors.js");
  66519. const common_1 = __webpack_require__(/*! ./common */ "./dist/npm/models/transactions/common.js");
  66520. var OfferCreateFlags;
  66521. (function (OfferCreateFlags) {
  66522. OfferCreateFlags[OfferCreateFlags["tfPassive"] = 65536] = "tfPassive";
  66523. OfferCreateFlags[OfferCreateFlags["tfImmediateOrCancel"] = 131072] = "tfImmediateOrCancel";
  66524. OfferCreateFlags[OfferCreateFlags["tfFillOrKill"] = 262144] = "tfFillOrKill";
  66525. OfferCreateFlags[OfferCreateFlags["tfSell"] = 524288] = "tfSell";
  66526. })(OfferCreateFlags = exports.OfferCreateFlags || (exports.OfferCreateFlags = {}));
  66527. function validateOfferCreate(tx) {
  66528. (0, common_1.validateBaseTransaction)(tx);
  66529. if (tx.TakerGets === undefined) {
  66530. throw new errors_1.ValidationError('OfferCreate: missing field TakerGets');
  66531. }
  66532. if (tx.TakerPays === undefined) {
  66533. throw new errors_1.ValidationError('OfferCreate: missing field TakerPays');
  66534. }
  66535. if (typeof tx.TakerGets !== 'string' && !(0, common_1.isAmount)(tx.TakerGets)) {
  66536. throw new errors_1.ValidationError('OfferCreate: invalid TakerGets');
  66537. }
  66538. if (typeof tx.TakerPays !== 'string' && !(0, common_1.isAmount)(tx.TakerPays)) {
  66539. throw new errors_1.ValidationError('OfferCreate: invalid TakerPays');
  66540. }
  66541. if (tx.Expiration !== undefined && typeof tx.Expiration !== 'number') {
  66542. throw new errors_1.ValidationError('OfferCreate: invalid Expiration');
  66543. }
  66544. if (tx.OfferSequence !== undefined && typeof tx.OfferSequence !== 'number') {
  66545. throw new errors_1.ValidationError('OfferCreate: invalid OfferSequence');
  66546. }
  66547. }
  66548. exports.validateOfferCreate = validateOfferCreate;
  66549. /***/ }),
  66550. /***/ "./dist/npm/models/transactions/payment.js":
  66551. /*!*************************************************!*\
  66552. !*** ./dist/npm/models/transactions/payment.js ***!
  66553. \*************************************************/
  66554. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  66555. "use strict";
  66556. Object.defineProperty(exports, "__esModule", ({ value: true }));
  66557. exports.validatePayment = exports.PaymentFlags = void 0;
  66558. const errors_1 = __webpack_require__(/*! ../../errors */ "./dist/npm/errors.js");
  66559. const utils_1 = __webpack_require__(/*! ../utils */ "./dist/npm/models/utils/index.js");
  66560. const common_1 = __webpack_require__(/*! ./common */ "./dist/npm/models/transactions/common.js");
  66561. var PaymentFlags;
  66562. (function (PaymentFlags) {
  66563. PaymentFlags[PaymentFlags["tfNoDirectRipple"] = 65536] = "tfNoDirectRipple";
  66564. PaymentFlags[PaymentFlags["tfPartialPayment"] = 131072] = "tfPartialPayment";
  66565. PaymentFlags[PaymentFlags["tfLimitQuality"] = 262144] = "tfLimitQuality";
  66566. })(PaymentFlags = exports.PaymentFlags || (exports.PaymentFlags = {}));
  66567. function validatePayment(tx) {
  66568. (0, common_1.validateBaseTransaction)(tx);
  66569. if (tx.Amount === undefined) {
  66570. throw new errors_1.ValidationError('PaymentTransaction: missing field Amount');
  66571. }
  66572. if (!(0, common_1.isAmount)(tx.Amount)) {
  66573. throw new errors_1.ValidationError('PaymentTransaction: invalid Amount');
  66574. }
  66575. if (tx.Destination === undefined) {
  66576. throw new errors_1.ValidationError('PaymentTransaction: missing field Destination');
  66577. }
  66578. if (!(0, common_1.isAmount)(tx.Destination)) {
  66579. throw new errors_1.ValidationError('PaymentTransaction: invalid Destination');
  66580. }
  66581. if (tx.DestinationTag != null && typeof tx.DestinationTag !== 'number') {
  66582. throw new errors_1.ValidationError('PaymentTransaction: DestinationTag must be a number');
  66583. }
  66584. if (tx.InvoiceID !== undefined && typeof tx.InvoiceID !== 'string') {
  66585. throw new errors_1.ValidationError('PaymentTransaction: InvoiceID must be a string');
  66586. }
  66587. if (tx.Paths !== undefined &&
  66588. !isPaths(tx.Paths)) {
  66589. throw new errors_1.ValidationError('PaymentTransaction: invalid Paths');
  66590. }
  66591. if (tx.SendMax !== undefined && !(0, common_1.isAmount)(tx.SendMax)) {
  66592. throw new errors_1.ValidationError('PaymentTransaction: invalid SendMax');
  66593. }
  66594. checkPartialPayment(tx);
  66595. }
  66596. exports.validatePayment = validatePayment;
  66597. function checkPartialPayment(tx) {
  66598. var _a;
  66599. if (tx.DeliverMin != null) {
  66600. if (tx.Flags == null) {
  66601. throw new errors_1.ValidationError('PaymentTransaction: tfPartialPayment flag required with DeliverMin');
  66602. }
  66603. const flags = tx.Flags;
  66604. const isTfPartialPayment = typeof flags === 'number'
  66605. ? (0, utils_1.isFlagEnabled)(flags, PaymentFlags.tfPartialPayment)
  66606. : (_a = flags.tfPartialPayment) !== null && _a !== void 0 ? _a : false;
  66607. if (!isTfPartialPayment) {
  66608. throw new errors_1.ValidationError('PaymentTransaction: tfPartialPayment flag required with DeliverMin');
  66609. }
  66610. if (!(0, common_1.isAmount)(tx.DeliverMin)) {
  66611. throw new errors_1.ValidationError('PaymentTransaction: invalid DeliverMin');
  66612. }
  66613. }
  66614. }
  66615. function isPathStep(pathStep) {
  66616. if (pathStep.account !== undefined && typeof pathStep.account !== 'string') {
  66617. return false;
  66618. }
  66619. if (pathStep.currency !== undefined &&
  66620. typeof pathStep.currency !== 'string') {
  66621. return false;
  66622. }
  66623. if (pathStep.issuer !== undefined && typeof pathStep.issuer !== 'string') {
  66624. return false;
  66625. }
  66626. if (pathStep.account !== undefined &&
  66627. pathStep.currency === undefined &&
  66628. pathStep.issuer === undefined) {
  66629. return true;
  66630. }
  66631. if (pathStep.currency !== undefined || pathStep.issuer !== undefined) {
  66632. return true;
  66633. }
  66634. return false;
  66635. }
  66636. function isPath(path) {
  66637. for (const pathStep of path) {
  66638. if (!isPathStep(pathStep)) {
  66639. return false;
  66640. }
  66641. }
  66642. return true;
  66643. }
  66644. function isPaths(paths) {
  66645. if (!Array.isArray(paths) || paths.length === 0) {
  66646. return false;
  66647. }
  66648. for (const path of paths) {
  66649. if (!Array.isArray(path) || path.length === 0) {
  66650. return false;
  66651. }
  66652. if (!isPath(path)) {
  66653. return false;
  66654. }
  66655. }
  66656. return true;
  66657. }
  66658. /***/ }),
  66659. /***/ "./dist/npm/models/transactions/paymentChannelClaim.js":
  66660. /*!*************************************************************!*\
  66661. !*** ./dist/npm/models/transactions/paymentChannelClaim.js ***!
  66662. \*************************************************************/
  66663. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  66664. "use strict";
  66665. Object.defineProperty(exports, "__esModule", ({ value: true }));
  66666. exports.validatePaymentChannelClaim = exports.PaymentChannelClaimFlags = void 0;
  66667. const errors_1 = __webpack_require__(/*! ../../errors */ "./dist/npm/errors.js");
  66668. const common_1 = __webpack_require__(/*! ./common */ "./dist/npm/models/transactions/common.js");
  66669. var PaymentChannelClaimFlags;
  66670. (function (PaymentChannelClaimFlags) {
  66671. PaymentChannelClaimFlags[PaymentChannelClaimFlags["tfRenew"] = 65536] = "tfRenew";
  66672. PaymentChannelClaimFlags[PaymentChannelClaimFlags["tfClose"] = 131072] = "tfClose";
  66673. })(PaymentChannelClaimFlags = exports.PaymentChannelClaimFlags || (exports.PaymentChannelClaimFlags = {}));
  66674. function validatePaymentChannelClaim(tx) {
  66675. (0, common_1.validateBaseTransaction)(tx);
  66676. if (tx.Channel === undefined) {
  66677. throw new errors_1.ValidationError('PaymentChannelClaim: missing Channel');
  66678. }
  66679. if (typeof tx.Channel !== 'string') {
  66680. throw new errors_1.ValidationError('PaymentChannelClaim: Channel must be a string');
  66681. }
  66682. if (tx.Balance !== undefined && typeof tx.Balance !== 'string') {
  66683. throw new errors_1.ValidationError('PaymentChannelClaim: Balance must be a string');
  66684. }
  66685. if (tx.Amount !== undefined && typeof tx.Amount !== 'string') {
  66686. throw new errors_1.ValidationError('PaymentChannelClaim: Amount must be a string');
  66687. }
  66688. if (tx.Signature !== undefined && typeof tx.Signature !== 'string') {
  66689. throw new errors_1.ValidationError('PaymentChannelClaim: Signature must be a string');
  66690. }
  66691. if (tx.PublicKey !== undefined && typeof tx.PublicKey !== 'string') {
  66692. throw new errors_1.ValidationError('PaymentChannelClaim: PublicKey must be a string');
  66693. }
  66694. }
  66695. exports.validatePaymentChannelClaim = validatePaymentChannelClaim;
  66696. /***/ }),
  66697. /***/ "./dist/npm/models/transactions/paymentChannelCreate.js":
  66698. /*!**************************************************************!*\
  66699. !*** ./dist/npm/models/transactions/paymentChannelCreate.js ***!
  66700. \**************************************************************/
  66701. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  66702. "use strict";
  66703. Object.defineProperty(exports, "__esModule", ({ value: true }));
  66704. exports.validatePaymentChannelCreate = void 0;
  66705. const errors_1 = __webpack_require__(/*! ../../errors */ "./dist/npm/errors.js");
  66706. const common_1 = __webpack_require__(/*! ./common */ "./dist/npm/models/transactions/common.js");
  66707. function validatePaymentChannelCreate(tx) {
  66708. (0, common_1.validateBaseTransaction)(tx);
  66709. if (tx.Amount === undefined) {
  66710. throw new errors_1.ValidationError('PaymentChannelCreate: missing Amount');
  66711. }
  66712. if (typeof tx.Amount !== 'string') {
  66713. throw new errors_1.ValidationError('PaymentChannelCreate: Amount must be a string');
  66714. }
  66715. if (tx.Destination === undefined) {
  66716. throw new errors_1.ValidationError('PaymentChannelCreate: missing Destination');
  66717. }
  66718. if (typeof tx.Destination !== 'string') {
  66719. throw new errors_1.ValidationError('PaymentChannelCreate: Destination must be a string');
  66720. }
  66721. if (tx.SettleDelay === undefined) {
  66722. throw new errors_1.ValidationError('PaymentChannelCreate: missing SettleDelay');
  66723. }
  66724. if (typeof tx.SettleDelay !== 'number') {
  66725. throw new errors_1.ValidationError('PaymentChannelCreate: SettleDelay must be a number');
  66726. }
  66727. if (tx.PublicKey === undefined) {
  66728. throw new errors_1.ValidationError('PaymentChannelCreate: missing PublicKey');
  66729. }
  66730. if (typeof tx.PublicKey !== 'string') {
  66731. throw new errors_1.ValidationError('PaymentChannelCreate: PublicKey must be a string');
  66732. }
  66733. if (tx.CancelAfter !== undefined && typeof tx.CancelAfter !== 'number') {
  66734. throw new errors_1.ValidationError('PaymentChannelCreate: CancelAfter must be a number');
  66735. }
  66736. if (tx.DestinationTag !== undefined &&
  66737. typeof tx.DestinationTag !== 'number') {
  66738. throw new errors_1.ValidationError('PaymentChannelCreate: DestinationTag must be a number');
  66739. }
  66740. }
  66741. exports.validatePaymentChannelCreate = validatePaymentChannelCreate;
  66742. /***/ }),
  66743. /***/ "./dist/npm/models/transactions/paymentChannelFund.js":
  66744. /*!************************************************************!*\
  66745. !*** ./dist/npm/models/transactions/paymentChannelFund.js ***!
  66746. \************************************************************/
  66747. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  66748. "use strict";
  66749. Object.defineProperty(exports, "__esModule", ({ value: true }));
  66750. exports.validatePaymentChannelFund = void 0;
  66751. const errors_1 = __webpack_require__(/*! ../../errors */ "./dist/npm/errors.js");
  66752. const common_1 = __webpack_require__(/*! ./common */ "./dist/npm/models/transactions/common.js");
  66753. function validatePaymentChannelFund(tx) {
  66754. (0, common_1.validateBaseTransaction)(tx);
  66755. if (tx.Channel === undefined) {
  66756. throw new errors_1.ValidationError('PaymentChannelFund: missing Channel');
  66757. }
  66758. if (typeof tx.Channel !== 'string') {
  66759. throw new errors_1.ValidationError('PaymentChannelFund: Channel must be a string');
  66760. }
  66761. if (tx.Amount === undefined) {
  66762. throw new errors_1.ValidationError('PaymentChannelFund: missing Amount');
  66763. }
  66764. if (typeof tx.Amount !== 'string') {
  66765. throw new errors_1.ValidationError('PaymentChannelFund: Amount must be a string');
  66766. }
  66767. if (tx.Expiration !== undefined && typeof tx.Expiration !== 'number') {
  66768. throw new errors_1.ValidationError('PaymentChannelFund: Expiration must be a number');
  66769. }
  66770. }
  66771. exports.validatePaymentChannelFund = validatePaymentChannelFund;
  66772. /***/ }),
  66773. /***/ "./dist/npm/models/transactions/setRegularKey.js":
  66774. /*!*******************************************************!*\
  66775. !*** ./dist/npm/models/transactions/setRegularKey.js ***!
  66776. \*******************************************************/
  66777. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  66778. "use strict";
  66779. Object.defineProperty(exports, "__esModule", ({ value: true }));
  66780. exports.validateSetRegularKey = void 0;
  66781. const errors_1 = __webpack_require__(/*! ../../errors */ "./dist/npm/errors.js");
  66782. const common_1 = __webpack_require__(/*! ./common */ "./dist/npm/models/transactions/common.js");
  66783. function validateSetRegularKey(tx) {
  66784. (0, common_1.validateBaseTransaction)(tx);
  66785. if (tx.RegularKey !== undefined && typeof tx.RegularKey !== 'string') {
  66786. throw new errors_1.ValidationError('SetRegularKey: RegularKey must be a string');
  66787. }
  66788. }
  66789. exports.validateSetRegularKey = validateSetRegularKey;
  66790. /***/ }),
  66791. /***/ "./dist/npm/models/transactions/signerListSet.js":
  66792. /*!*******************************************************!*\
  66793. !*** ./dist/npm/models/transactions/signerListSet.js ***!
  66794. \*******************************************************/
  66795. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  66796. "use strict";
  66797. Object.defineProperty(exports, "__esModule", ({ value: true }));
  66798. exports.validateSignerListSet = void 0;
  66799. const errors_1 = __webpack_require__(/*! ../../errors */ "./dist/npm/errors.js");
  66800. const common_1 = __webpack_require__(/*! ./common */ "./dist/npm/models/transactions/common.js");
  66801. const MAX_SIGNERS = 32;
  66802. const HEX_WALLET_LOCATOR_REGEX = /^[0-9A-Fa-f]{64}$/u;
  66803. function validateSignerListSet(tx) {
  66804. (0, common_1.validateBaseTransaction)(tx);
  66805. if (tx.SignerQuorum === undefined) {
  66806. throw new errors_1.ValidationError('SignerListSet: missing field SignerQuorum');
  66807. }
  66808. if (typeof tx.SignerQuorum !== 'number') {
  66809. throw new errors_1.ValidationError('SignerListSet: invalid SignerQuorum');
  66810. }
  66811. if (tx.SignerEntries === undefined) {
  66812. throw new errors_1.ValidationError('SignerListSet: missing field SignerEntries');
  66813. }
  66814. if (!Array.isArray(tx.SignerEntries)) {
  66815. throw new errors_1.ValidationError('SignerListSet: invalid SignerEntries');
  66816. }
  66817. if (tx.SignerEntries.length === 0) {
  66818. throw new errors_1.ValidationError('SignerListSet: need at least 1 member in SignerEntries');
  66819. }
  66820. if (tx.SignerEntries.length > MAX_SIGNERS) {
  66821. throw new errors_1.ValidationError(`SignerListSet: maximum of ${MAX_SIGNERS} members allowed in SignerEntries`);
  66822. }
  66823. for (const entry of tx.SignerEntries) {
  66824. const signerEntry = entry;
  66825. const { WalletLocator } = signerEntry.SignerEntry;
  66826. if (WalletLocator !== undefined &&
  66827. !HEX_WALLET_LOCATOR_REGEX.test(WalletLocator)) {
  66828. throw new errors_1.ValidationError(`SignerListSet: WalletLocator in SignerEntry must be a 256-bit (32-byte) hexadecimal value`);
  66829. }
  66830. }
  66831. }
  66832. exports.validateSignerListSet = validateSignerListSet;
  66833. /***/ }),
  66834. /***/ "./dist/npm/models/transactions/ticketCreate.js":
  66835. /*!******************************************************!*\
  66836. !*** ./dist/npm/models/transactions/ticketCreate.js ***!
  66837. \******************************************************/
  66838. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  66839. "use strict";
  66840. Object.defineProperty(exports, "__esModule", ({ value: true }));
  66841. exports.validateTicketCreate = void 0;
  66842. const errors_1 = __webpack_require__(/*! ../../errors */ "./dist/npm/errors.js");
  66843. const common_1 = __webpack_require__(/*! ./common */ "./dist/npm/models/transactions/common.js");
  66844. const MAX_TICKETS = 250;
  66845. function validateTicketCreate(tx) {
  66846. (0, common_1.validateBaseTransaction)(tx);
  66847. const { TicketCount } = tx;
  66848. if (TicketCount === undefined) {
  66849. throw new errors_1.ValidationError('TicketCreate: missing field TicketCount');
  66850. }
  66851. if (typeof TicketCount !== 'number') {
  66852. throw new errors_1.ValidationError('TicketCreate: TicketCount must be a number');
  66853. }
  66854. if (!Number.isInteger(TicketCount) ||
  66855. TicketCount < 1 ||
  66856. TicketCount > MAX_TICKETS) {
  66857. throw new errors_1.ValidationError('TicketCreate: TicketCount must be an integer from 1 to 250');
  66858. }
  66859. }
  66860. exports.validateTicketCreate = validateTicketCreate;
  66861. /***/ }),
  66862. /***/ "./dist/npm/models/transactions/transaction.js":
  66863. /*!*****************************************************!*\
  66864. !*** ./dist/npm/models/transactions/transaction.js ***!
  66865. \*****************************************************/
  66866. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  66867. "use strict";
  66868. var __importDefault = (this && this.__importDefault) || function (mod) {
  66869. return (mod && mod.__esModule) ? mod : { "default": mod };
  66870. };
  66871. Object.defineProperty(exports, "__esModule", ({ value: true }));
  66872. exports.validate = void 0;
  66873. const isEqual_1 = __importDefault(__webpack_require__(/*! lodash/isEqual */ "../../node_modules/lodash/isEqual.js"));
  66874. const omitBy_1 = __importDefault(__webpack_require__(/*! lodash/omitBy */ "../../node_modules/lodash/omitBy.js"));
  66875. const ripple_binary_codec_1 = __webpack_require__(/*! ripple-binary-codec */ "../../node_modules/ripple-binary-codec/dist/index.js");
  66876. const errors_1 = __webpack_require__(/*! ../../errors */ "./dist/npm/errors.js");
  66877. const flags_1 = __webpack_require__(/*! ../utils/flags */ "./dist/npm/models/utils/flags.js");
  66878. const accountDelete_1 = __webpack_require__(/*! ./accountDelete */ "./dist/npm/models/transactions/accountDelete.js");
  66879. const accountSet_1 = __webpack_require__(/*! ./accountSet */ "./dist/npm/models/transactions/accountSet.js");
  66880. const checkCancel_1 = __webpack_require__(/*! ./checkCancel */ "./dist/npm/models/transactions/checkCancel.js");
  66881. const checkCash_1 = __webpack_require__(/*! ./checkCash */ "./dist/npm/models/transactions/checkCash.js");
  66882. const checkCreate_1 = __webpack_require__(/*! ./checkCreate */ "./dist/npm/models/transactions/checkCreate.js");
  66883. const depositPreauth_1 = __webpack_require__(/*! ./depositPreauth */ "./dist/npm/models/transactions/depositPreauth.js");
  66884. const escrowCancel_1 = __webpack_require__(/*! ./escrowCancel */ "./dist/npm/models/transactions/escrowCancel.js");
  66885. const escrowCreate_1 = __webpack_require__(/*! ./escrowCreate */ "./dist/npm/models/transactions/escrowCreate.js");
  66886. const escrowFinish_1 = __webpack_require__(/*! ./escrowFinish */ "./dist/npm/models/transactions/escrowFinish.js");
  66887. const NFTokenAcceptOffer_1 = __webpack_require__(/*! ./NFTokenAcceptOffer */ "./dist/npm/models/transactions/NFTokenAcceptOffer.js");
  66888. const NFTokenBurn_1 = __webpack_require__(/*! ./NFTokenBurn */ "./dist/npm/models/transactions/NFTokenBurn.js");
  66889. const NFTokenCancelOffer_1 = __webpack_require__(/*! ./NFTokenCancelOffer */ "./dist/npm/models/transactions/NFTokenCancelOffer.js");
  66890. const NFTokenCreateOffer_1 = __webpack_require__(/*! ./NFTokenCreateOffer */ "./dist/npm/models/transactions/NFTokenCreateOffer.js");
  66891. const NFTokenMint_1 = __webpack_require__(/*! ./NFTokenMint */ "./dist/npm/models/transactions/NFTokenMint.js");
  66892. const offerCancel_1 = __webpack_require__(/*! ./offerCancel */ "./dist/npm/models/transactions/offerCancel.js");
  66893. const offerCreate_1 = __webpack_require__(/*! ./offerCreate */ "./dist/npm/models/transactions/offerCreate.js");
  66894. const payment_1 = __webpack_require__(/*! ./payment */ "./dist/npm/models/transactions/payment.js");
  66895. const paymentChannelClaim_1 = __webpack_require__(/*! ./paymentChannelClaim */ "./dist/npm/models/transactions/paymentChannelClaim.js");
  66896. const paymentChannelCreate_1 = __webpack_require__(/*! ./paymentChannelCreate */ "./dist/npm/models/transactions/paymentChannelCreate.js");
  66897. const paymentChannelFund_1 = __webpack_require__(/*! ./paymentChannelFund */ "./dist/npm/models/transactions/paymentChannelFund.js");
  66898. const setRegularKey_1 = __webpack_require__(/*! ./setRegularKey */ "./dist/npm/models/transactions/setRegularKey.js");
  66899. const signerListSet_1 = __webpack_require__(/*! ./signerListSet */ "./dist/npm/models/transactions/signerListSet.js");
  66900. const ticketCreate_1 = __webpack_require__(/*! ./ticketCreate */ "./dist/npm/models/transactions/ticketCreate.js");
  66901. const trustSet_1 = __webpack_require__(/*! ./trustSet */ "./dist/npm/models/transactions/trustSet.js");
  66902. function validate(transaction) {
  66903. const tx = Object.assign({}, transaction);
  66904. if (tx.TransactionType == null) {
  66905. throw new errors_1.ValidationError('Object does not have a `TransactionType`');
  66906. }
  66907. if (typeof tx.TransactionType !== 'string') {
  66908. throw new errors_1.ValidationError("Object's `TransactionType` is not a string");
  66909. }
  66910. (0, flags_1.setTransactionFlagsToNumber)(tx);
  66911. switch (tx.TransactionType) {
  66912. case 'AccountDelete':
  66913. (0, accountDelete_1.validateAccountDelete)(tx);
  66914. break;
  66915. case 'AccountSet':
  66916. (0, accountSet_1.validateAccountSet)(tx);
  66917. break;
  66918. case 'CheckCancel':
  66919. (0, checkCancel_1.validateCheckCancel)(tx);
  66920. break;
  66921. case 'CheckCash':
  66922. (0, checkCash_1.validateCheckCash)(tx);
  66923. break;
  66924. case 'CheckCreate':
  66925. (0, checkCreate_1.validateCheckCreate)(tx);
  66926. break;
  66927. case 'DepositPreauth':
  66928. (0, depositPreauth_1.validateDepositPreauth)(tx);
  66929. break;
  66930. case 'EscrowCancel':
  66931. (0, escrowCancel_1.validateEscrowCancel)(tx);
  66932. break;
  66933. case 'EscrowCreate':
  66934. (0, escrowCreate_1.validateEscrowCreate)(tx);
  66935. break;
  66936. case 'EscrowFinish':
  66937. (0, escrowFinish_1.validateEscrowFinish)(tx);
  66938. break;
  66939. case 'NFTokenAcceptOffer':
  66940. (0, NFTokenAcceptOffer_1.validateNFTokenAcceptOffer)(tx);
  66941. break;
  66942. case 'NFTokenBurn':
  66943. (0, NFTokenBurn_1.validateNFTokenBurn)(tx);
  66944. break;
  66945. case 'NFTokenCancelOffer':
  66946. (0, NFTokenCancelOffer_1.validateNFTokenCancelOffer)(tx);
  66947. break;
  66948. case 'NFTokenCreateOffer':
  66949. (0, NFTokenCreateOffer_1.validateNFTokenCreateOffer)(tx);
  66950. break;
  66951. case 'NFTokenMint':
  66952. (0, NFTokenMint_1.validateNFTokenMint)(tx);
  66953. break;
  66954. case 'OfferCancel':
  66955. (0, offerCancel_1.validateOfferCancel)(tx);
  66956. break;
  66957. case 'OfferCreate':
  66958. (0, offerCreate_1.validateOfferCreate)(tx);
  66959. break;
  66960. case 'Payment':
  66961. (0, payment_1.validatePayment)(tx);
  66962. break;
  66963. case 'PaymentChannelClaim':
  66964. (0, paymentChannelClaim_1.validatePaymentChannelClaim)(tx);
  66965. break;
  66966. case 'PaymentChannelCreate':
  66967. (0, paymentChannelCreate_1.validatePaymentChannelCreate)(tx);
  66968. break;
  66969. case 'PaymentChannelFund':
  66970. (0, paymentChannelFund_1.validatePaymentChannelFund)(tx);
  66971. break;
  66972. case 'SetRegularKey':
  66973. (0, setRegularKey_1.validateSetRegularKey)(tx);
  66974. break;
  66975. case 'SignerListSet':
  66976. (0, signerListSet_1.validateSignerListSet)(tx);
  66977. break;
  66978. case 'TicketCreate':
  66979. (0, ticketCreate_1.validateTicketCreate)(tx);
  66980. break;
  66981. case 'TrustSet':
  66982. (0, trustSet_1.validateTrustSet)(tx);
  66983. break;
  66984. default:
  66985. throw new errors_1.ValidationError(`Invalid field TransactionType: ${tx.TransactionType}`);
  66986. }
  66987. if (!(0, isEqual_1.default)((0, ripple_binary_codec_1.decode)((0, ripple_binary_codec_1.encode)(tx)), (0, omitBy_1.default)(tx, (value) => value == null))) {
  66988. throw new errors_1.ValidationError(`Invalid Transaction: ${tx.TransactionType}`);
  66989. }
  66990. }
  66991. exports.validate = validate;
  66992. /***/ }),
  66993. /***/ "./dist/npm/models/transactions/trustSet.js":
  66994. /*!**************************************************!*\
  66995. !*** ./dist/npm/models/transactions/trustSet.js ***!
  66996. \**************************************************/
  66997. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  66998. "use strict";
  66999. Object.defineProperty(exports, "__esModule", ({ value: true }));
  67000. exports.validateTrustSet = exports.TrustSetFlags = void 0;
  67001. const errors_1 = __webpack_require__(/*! ../../errors */ "./dist/npm/errors.js");
  67002. const common_1 = __webpack_require__(/*! ./common */ "./dist/npm/models/transactions/common.js");
  67003. var TrustSetFlags;
  67004. (function (TrustSetFlags) {
  67005. TrustSetFlags[TrustSetFlags["tfSetfAuth"] = 65536] = "tfSetfAuth";
  67006. TrustSetFlags[TrustSetFlags["tfSetNoRipple"] = 131072] = "tfSetNoRipple";
  67007. TrustSetFlags[TrustSetFlags["tfClearNoRipple"] = 262144] = "tfClearNoRipple";
  67008. TrustSetFlags[TrustSetFlags["tfSetFreeze"] = 1048576] = "tfSetFreeze";
  67009. TrustSetFlags[TrustSetFlags["tfClearFreeze"] = 2097152] = "tfClearFreeze";
  67010. })(TrustSetFlags = exports.TrustSetFlags || (exports.TrustSetFlags = {}));
  67011. function validateTrustSet(tx) {
  67012. (0, common_1.validateBaseTransaction)(tx);
  67013. const { LimitAmount, QualityIn, QualityOut } = tx;
  67014. if (LimitAmount === undefined) {
  67015. throw new errors_1.ValidationError('TrustSet: missing field LimitAmount');
  67016. }
  67017. if (!(0, common_1.isAmount)(LimitAmount)) {
  67018. throw new errors_1.ValidationError('TrustSet: invalid LimitAmount');
  67019. }
  67020. if (QualityIn !== undefined && typeof QualityIn !== 'number') {
  67021. throw new errors_1.ValidationError('TrustSet: QualityIn must be a number');
  67022. }
  67023. if (QualityOut !== undefined && typeof QualityOut !== 'number') {
  67024. throw new errors_1.ValidationError('TrustSet: QualityOut must be a number');
  67025. }
  67026. }
  67027. exports.validateTrustSet = validateTrustSet;
  67028. /***/ }),
  67029. /***/ "./dist/npm/models/utils/flags.js":
  67030. /*!****************************************!*\
  67031. !*** ./dist/npm/models/utils/flags.js ***!
  67032. \****************************************/
  67033. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  67034. "use strict";
  67035. Object.defineProperty(exports, "__esModule", ({ value: true }));
  67036. exports.setTransactionFlagsToNumber = exports.parseAccountRootFlags = void 0;
  67037. const errors_1 = __webpack_require__(/*! ../../errors */ "./dist/npm/errors.js");
  67038. const AccountRoot_1 = __webpack_require__(/*! ../ledger/AccountRoot */ "./dist/npm/models/ledger/AccountRoot.js");
  67039. const accountSet_1 = __webpack_require__(/*! ../transactions/accountSet */ "./dist/npm/models/transactions/accountSet.js");
  67040. const offerCreate_1 = __webpack_require__(/*! ../transactions/offerCreate */ "./dist/npm/models/transactions/offerCreate.js");
  67041. const payment_1 = __webpack_require__(/*! ../transactions/payment */ "./dist/npm/models/transactions/payment.js");
  67042. const paymentChannelClaim_1 = __webpack_require__(/*! ../transactions/paymentChannelClaim */ "./dist/npm/models/transactions/paymentChannelClaim.js");
  67043. const trustSet_1 = __webpack_require__(/*! ../transactions/trustSet */ "./dist/npm/models/transactions/trustSet.js");
  67044. const _1 = __webpack_require__(/*! . */ "./dist/npm/models/utils/index.js");
  67045. function parseAccountRootFlags(flags) {
  67046. const flagsInterface = {};
  67047. Object.keys(AccountRoot_1.AccountRootFlags).forEach((flag) => {
  67048. if ((0, _1.isFlagEnabled)(flags, AccountRoot_1.AccountRootFlags[flag])) {
  67049. flagsInterface[flag] = true;
  67050. }
  67051. });
  67052. return flagsInterface;
  67053. }
  67054. exports.parseAccountRootFlags = parseAccountRootFlags;
  67055. function setTransactionFlagsToNumber(tx) {
  67056. if (tx.Flags == null) {
  67057. tx.Flags = 0;
  67058. return;
  67059. }
  67060. if (typeof tx.Flags === 'number') {
  67061. return;
  67062. }
  67063. switch (tx.TransactionType) {
  67064. case 'AccountSet':
  67065. tx.Flags = convertAccountSetFlagsToNumber(tx.Flags);
  67066. return;
  67067. case 'OfferCreate':
  67068. tx.Flags = convertOfferCreateFlagsToNumber(tx.Flags);
  67069. return;
  67070. case 'PaymentChannelClaim':
  67071. tx.Flags = convertPaymentChannelClaimFlagsToNumber(tx.Flags);
  67072. return;
  67073. case 'Payment':
  67074. tx.Flags = convertPaymentTransactionFlagsToNumber(tx.Flags);
  67075. return;
  67076. case 'TrustSet':
  67077. tx.Flags = convertTrustSetFlagsToNumber(tx.Flags);
  67078. return;
  67079. default:
  67080. tx.Flags = 0;
  67081. }
  67082. }
  67083. exports.setTransactionFlagsToNumber = setTransactionFlagsToNumber;
  67084. function convertAccountSetFlagsToNumber(flags) {
  67085. return reduceFlags(flags, accountSet_1.AccountSetTfFlags);
  67086. }
  67087. function convertOfferCreateFlagsToNumber(flags) {
  67088. return reduceFlags(flags, offerCreate_1.OfferCreateFlags);
  67089. }
  67090. function convertPaymentChannelClaimFlagsToNumber(flags) {
  67091. return reduceFlags(flags, paymentChannelClaim_1.PaymentChannelClaimFlags);
  67092. }
  67093. function convertPaymentTransactionFlagsToNumber(flags) {
  67094. return reduceFlags(flags, payment_1.PaymentFlags);
  67095. }
  67096. function convertTrustSetFlagsToNumber(flags) {
  67097. return reduceFlags(flags, trustSet_1.TrustSetFlags);
  67098. }
  67099. function reduceFlags(flags, flagEnum) {
  67100. return Object.keys(flags).reduce((resultFlags, flag) => {
  67101. if (flagEnum[flag] == null) {
  67102. throw new errors_1.ValidationError(`flag ${flag} doesn't exist in flagEnum: ${JSON.stringify(flagEnum)}`);
  67103. }
  67104. return flags[flag] ? resultFlags | flagEnum[flag] : resultFlags;
  67105. }, 0);
  67106. }
  67107. /***/ }),
  67108. /***/ "./dist/npm/models/utils/index.js":
  67109. /*!****************************************!*\
  67110. !*** ./dist/npm/models/utils/index.js ***!
  67111. \****************************************/
  67112. /***/ ((__unused_webpack_module, exports) => {
  67113. "use strict";
  67114. Object.defineProperty(exports, "__esModule", ({ value: true }));
  67115. exports.isHex = exports.isFlagEnabled = exports.onlyHasFields = void 0;
  67116. const HEX_REGEX = /^[0-9A-Fa-f]+$/u;
  67117. function onlyHasFields(obj, fields) {
  67118. return Object.keys(obj).every((key) => fields.includes(key));
  67119. }
  67120. exports.onlyHasFields = onlyHasFields;
  67121. function isFlagEnabled(Flags, checkFlag) {
  67122. return (checkFlag & Flags) === checkFlag;
  67123. }
  67124. exports.isFlagEnabled = isFlagEnabled;
  67125. function isHex(str) {
  67126. return HEX_REGEX.test(str);
  67127. }
  67128. exports.isHex = isHex;
  67129. /***/ }),
  67130. /***/ "./dist/npm/sugar/autofill.js":
  67131. /*!************************************!*\
  67132. !*** ./dist/npm/sugar/autofill.js ***!
  67133. \************************************/
  67134. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  67135. "use strict";
  67136. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  67137. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  67138. return new (P || (P = Promise))(function (resolve, reject) {
  67139. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  67140. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  67141. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  67142. step((generator = generator.apply(thisArg, _arguments || [])).next());
  67143. });
  67144. };
  67145. var __importDefault = (this && this.__importDefault) || function (mod) {
  67146. return (mod && mod.__esModule) ? mod : { "default": mod };
  67147. };
  67148. Object.defineProperty(exports, "__esModule", ({ value: true }));
  67149. const bignumber_js_1 = __importDefault(__webpack_require__(/*! bignumber.js */ "../../node_modules/bignumber.js/bignumber.js"));
  67150. const ripple_address_codec_1 = __webpack_require__(/*! ripple-address-codec */ "../../node_modules/ripple-address-codec/dist/index.js");
  67151. const errors_1 = __webpack_require__(/*! ../errors */ "./dist/npm/errors.js");
  67152. const flags_1 = __webpack_require__(/*! ../models/utils/flags */ "./dist/npm/models/utils/flags.js");
  67153. const utils_1 = __webpack_require__(/*! ../utils */ "./dist/npm/utils/index.js");
  67154. const getFeeXrp_1 = __importDefault(__webpack_require__(/*! ./getFeeXrp */ "./dist/npm/sugar/getFeeXrp.js"));
  67155. const LEDGER_OFFSET = 20;
  67156. function autofill(transaction, signersCount) {
  67157. return __awaiter(this, void 0, void 0, function* () {
  67158. const tx = Object.assign({}, transaction);
  67159. setValidAddresses(tx);
  67160. (0, flags_1.setTransactionFlagsToNumber)(tx);
  67161. const promises = [];
  67162. if (tx.Sequence == null) {
  67163. promises.push(setNextValidSequenceNumber(this, tx));
  67164. }
  67165. if (tx.Fee == null) {
  67166. promises.push(calculateFeePerTransactionType(this, tx, signersCount));
  67167. }
  67168. if (tx.LastLedgerSequence == null) {
  67169. promises.push(setLatestValidatedLedgerSequence(this, tx));
  67170. }
  67171. if (tx.TransactionType === 'AccountDelete') {
  67172. promises.push(checkAccountDeleteBlockers(this, tx));
  67173. }
  67174. return Promise.all(promises).then(() => tx);
  67175. });
  67176. }
  67177. function setValidAddresses(tx) {
  67178. validateAccountAddress(tx, 'Account', 'SourceTag');
  67179. if (tx['Destination'] != null) {
  67180. validateAccountAddress(tx, 'Destination', 'DestinationTag');
  67181. }
  67182. convertToClassicAddress(tx, 'Authorize');
  67183. convertToClassicAddress(tx, 'Unauthorize');
  67184. convertToClassicAddress(tx, 'Owner');
  67185. convertToClassicAddress(tx, 'RegularKey');
  67186. }
  67187. function validateAccountAddress(tx, accountField, tagField) {
  67188. const { classicAccount, tag } = getClassicAccountAndTag(tx[accountField]);
  67189. tx[accountField] = classicAccount;
  67190. if (tag != null && tag !== false) {
  67191. if (tx[tagField] && tx[tagField] !== tag) {
  67192. throw new errors_1.ValidationError(`The ${tagField}, if present, must match the tag of the ${accountField} X-address`);
  67193. }
  67194. tx[tagField] = tag;
  67195. }
  67196. }
  67197. function getClassicAccountAndTag(Account, expectedTag) {
  67198. if ((0, ripple_address_codec_1.isValidXAddress)(Account)) {
  67199. const classic = (0, ripple_address_codec_1.xAddressToClassicAddress)(Account);
  67200. if (expectedTag != null && classic.tag !== expectedTag) {
  67201. throw new errors_1.ValidationError('address includes a tag that does not match the tag specified in the transaction');
  67202. }
  67203. return {
  67204. classicAccount: classic.classicAddress,
  67205. tag: classic.tag,
  67206. };
  67207. }
  67208. return {
  67209. classicAccount: Account,
  67210. tag: expectedTag,
  67211. };
  67212. }
  67213. function convertToClassicAddress(tx, fieldName) {
  67214. const account = tx[fieldName];
  67215. if (typeof account === 'string') {
  67216. const { classicAccount } = getClassicAccountAndTag(account);
  67217. tx[fieldName] = classicAccount;
  67218. }
  67219. }
  67220. function setNextValidSequenceNumber(client, tx) {
  67221. return __awaiter(this, void 0, void 0, function* () {
  67222. const request = {
  67223. command: 'account_info',
  67224. account: tx.Account,
  67225. ledger_index: 'current',
  67226. };
  67227. const data = yield client.request(request);
  67228. tx.Sequence = data.result.account_data.Sequence;
  67229. });
  67230. }
  67231. function fetchAccountDeleteFee(client) {
  67232. var _a;
  67233. return __awaiter(this, void 0, void 0, function* () {
  67234. const response = yield client.request({ command: 'server_state' });
  67235. const fee = (_a = response.result.state.validated_ledger) === null || _a === void 0 ? void 0 : _a.reserve_inc;
  67236. if (fee == null) {
  67237. return Promise.reject(new Error('Could not fetch Owner Reserve.'));
  67238. }
  67239. return new bignumber_js_1.default(fee);
  67240. });
  67241. }
  67242. function calculateFeePerTransactionType(client, tx, signersCount = 0) {
  67243. return __awaiter(this, void 0, void 0, function* () {
  67244. const netFeeXRP = yield (0, getFeeXrp_1.default)(client);
  67245. const netFeeDrops = (0, utils_1.xrpToDrops)(netFeeXRP);
  67246. let baseFee = new bignumber_js_1.default(netFeeDrops);
  67247. if (tx.TransactionType === 'EscrowFinish' && tx.Fulfillment != null) {
  67248. const fulfillmentBytesSize = Math.ceil(tx.Fulfillment.length / 2);
  67249. const product = new bignumber_js_1.default(scaleValue(netFeeDrops, 33 + fulfillmentBytesSize / 16));
  67250. baseFee = product.dp(0, bignumber_js_1.default.ROUND_CEIL);
  67251. }
  67252. if (tx.TransactionType === 'AccountDelete') {
  67253. baseFee = yield fetchAccountDeleteFee(client);
  67254. }
  67255. if (signersCount > 0) {
  67256. baseFee = bignumber_js_1.default.sum(baseFee, scaleValue(netFeeDrops, 1 + signersCount));
  67257. }
  67258. const maxFeeDrops = (0, utils_1.xrpToDrops)(client.maxFeeXRP);
  67259. const totalFee = tx.TransactionType === 'AccountDelete'
  67260. ? baseFee
  67261. : bignumber_js_1.default.min(baseFee, maxFeeDrops);
  67262. tx.Fee = totalFee.dp(0, bignumber_js_1.default.ROUND_CEIL).toString(10);
  67263. });
  67264. }
  67265. function scaleValue(value, multiplier) {
  67266. return new bignumber_js_1.default(value).times(multiplier).toString();
  67267. }
  67268. function setLatestValidatedLedgerSequence(client, tx) {
  67269. return __awaiter(this, void 0, void 0, function* () {
  67270. const ledgerSequence = yield client.getLedgerIndex();
  67271. tx.LastLedgerSequence = ledgerSequence + LEDGER_OFFSET;
  67272. });
  67273. }
  67274. function checkAccountDeleteBlockers(client, tx) {
  67275. return __awaiter(this, void 0, void 0, function* () {
  67276. const request = {
  67277. command: 'account_objects',
  67278. account: tx.Account,
  67279. ledger_index: 'validated',
  67280. deletion_blockers_only: true,
  67281. };
  67282. const response = yield client.request(request);
  67283. return new Promise((resolve, reject) => {
  67284. if (response.result.account_objects.length > 0) {
  67285. reject(new errors_1.XrplError(`Account ${tx.Account} cannot be deleted; there are Escrows, PayChannels, RippleStates, or Checks associated with the account.`, response.result.account_objects));
  67286. }
  67287. resolve();
  67288. });
  67289. });
  67290. }
  67291. exports["default"] = autofill;
  67292. /***/ }),
  67293. /***/ "./dist/npm/sugar/balances.js":
  67294. /*!************************************!*\
  67295. !*** ./dist/npm/sugar/balances.js ***!
  67296. \************************************/
  67297. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  67298. "use strict";
  67299. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  67300. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  67301. return new (P || (P = Promise))(function (resolve, reject) {
  67302. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  67303. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  67304. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  67305. step((generator = generator.apply(thisArg, _arguments || [])).next());
  67306. });
  67307. };
  67308. var __importDefault = (this && this.__importDefault) || function (mod) {
  67309. return (mod && mod.__esModule) ? mod : { "default": mod };
  67310. };
  67311. Object.defineProperty(exports, "__esModule", ({ value: true }));
  67312. exports.getBalances = exports.getXrpBalance = void 0;
  67313. const flatMap_1 = __importDefault(__webpack_require__(/*! lodash/flatMap */ "../../node_modules/lodash/flatMap.js"));
  67314. const utils_1 = __webpack_require__(/*! ../utils */ "./dist/npm/utils/index.js");
  67315. function formatBalances(trustlines) {
  67316. return trustlines.map((trustline) => ({
  67317. value: trustline.balance,
  67318. currency: trustline.currency,
  67319. issuer: trustline.account,
  67320. }));
  67321. }
  67322. function getXrpBalance(address, options = {}) {
  67323. var _a;
  67324. return __awaiter(this, void 0, void 0, function* () {
  67325. const xrpRequest = {
  67326. command: 'account_info',
  67327. account: address,
  67328. ledger_index: (_a = options.ledger_index) !== null && _a !== void 0 ? _a : 'validated',
  67329. ledger_hash: options.ledger_hash,
  67330. };
  67331. const response = yield this.request(xrpRequest);
  67332. return (0, utils_1.dropsToXrp)(response.result.account_data.Balance);
  67333. });
  67334. }
  67335. exports.getXrpBalance = getXrpBalance;
  67336. function getBalances(address, options = {}) {
  67337. var _a;
  67338. return __awaiter(this, void 0, void 0, function* () {
  67339. const balances = [];
  67340. let xrpPromise = Promise.resolve('');
  67341. if (!options.peer) {
  67342. xrpPromise = this.getXrpBalance(address, {
  67343. ledger_hash: options.ledger_hash,
  67344. ledger_index: options.ledger_index,
  67345. });
  67346. }
  67347. const linesRequest = {
  67348. command: 'account_lines',
  67349. account: address,
  67350. ledger_index: (_a = options.ledger_index) !== null && _a !== void 0 ? _a : 'validated',
  67351. ledger_hash: options.ledger_hash,
  67352. peer: options.peer,
  67353. limit: options.limit,
  67354. };
  67355. const linesPromise = this.requestAll(linesRequest);
  67356. yield Promise.all([xrpPromise, linesPromise]).then(([xrpBalance, linesResponses]) => {
  67357. const accountLinesBalance = (0, flatMap_1.default)(linesResponses, (response) => formatBalances(response.result.lines));
  67358. if (xrpBalance !== '') {
  67359. balances.push({ currency: 'XRP', value: xrpBalance });
  67360. }
  67361. balances.push(...accountLinesBalance);
  67362. });
  67363. return balances.slice(0, options.limit);
  67364. });
  67365. }
  67366. exports.getBalances = getBalances;
  67367. /***/ }),
  67368. /***/ "./dist/npm/sugar/getFeeXrp.js":
  67369. /*!*************************************!*\
  67370. !*** ./dist/npm/sugar/getFeeXrp.js ***!
  67371. \*************************************/
  67372. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  67373. "use strict";
  67374. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  67375. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  67376. return new (P || (P = Promise))(function (resolve, reject) {
  67377. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  67378. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  67379. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  67380. step((generator = generator.apply(thisArg, _arguments || [])).next());
  67381. });
  67382. };
  67383. var __importDefault = (this && this.__importDefault) || function (mod) {
  67384. return (mod && mod.__esModule) ? mod : { "default": mod };
  67385. };
  67386. Object.defineProperty(exports, "__esModule", ({ value: true }));
  67387. const bignumber_js_1 = __importDefault(__webpack_require__(/*! bignumber.js */ "../../node_modules/bignumber.js/bignumber.js"));
  67388. const errors_1 = __webpack_require__(/*! ../errors */ "./dist/npm/errors.js");
  67389. const NUM_DECIMAL_PLACES = 6;
  67390. const BASE_10 = 10;
  67391. function getFeeXrp(client, cushion) {
  67392. var _a;
  67393. return __awaiter(this, void 0, void 0, function* () {
  67394. const feeCushion = cushion !== null && cushion !== void 0 ? cushion : client.feeCushion;
  67395. const serverInfo = (yield client.request({ command: 'server_info' })).result
  67396. .info;
  67397. const baseFee = (_a = serverInfo.validated_ledger) === null || _a === void 0 ? void 0 : _a.base_fee_xrp;
  67398. if (baseFee == null) {
  67399. throw new errors_1.XrplError('getFeeXrp: Could not get base_fee_xrp from server_info');
  67400. }
  67401. const baseFeeXrp = new bignumber_js_1.default(baseFee);
  67402. if (serverInfo.load_factor == null) {
  67403. serverInfo.load_factor = 1;
  67404. }
  67405. let fee = baseFeeXrp.times(serverInfo.load_factor).times(feeCushion);
  67406. fee = bignumber_js_1.default.min(fee, client.maxFeeXRP);
  67407. return new bignumber_js_1.default(fee.toFixed(NUM_DECIMAL_PLACES)).toString(BASE_10);
  67408. });
  67409. }
  67410. exports["default"] = getFeeXrp;
  67411. /***/ }),
  67412. /***/ "./dist/npm/sugar/getLedgerIndex.js":
  67413. /*!******************************************!*\
  67414. !*** ./dist/npm/sugar/getLedgerIndex.js ***!
  67415. \******************************************/
  67416. /***/ (function(__unused_webpack_module, exports) {
  67417. "use strict";
  67418. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  67419. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  67420. return new (P || (P = Promise))(function (resolve, reject) {
  67421. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  67422. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  67423. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  67424. step((generator = generator.apply(thisArg, _arguments || [])).next());
  67425. });
  67426. };
  67427. Object.defineProperty(exports, "__esModule", ({ value: true }));
  67428. function getLedgerIndex() {
  67429. return __awaiter(this, void 0, void 0, function* () {
  67430. const ledgerResponse = yield this.request({
  67431. command: 'ledger',
  67432. ledger_index: 'validated',
  67433. });
  67434. return ledgerResponse.result.ledger_index;
  67435. });
  67436. }
  67437. exports["default"] = getLedgerIndex;
  67438. /***/ }),
  67439. /***/ "./dist/npm/sugar/getOrderbook.js":
  67440. /*!****************************************!*\
  67441. !*** ./dist/npm/sugar/getOrderbook.js ***!
  67442. \****************************************/
  67443. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  67444. "use strict";
  67445. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  67446. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  67447. return new (P || (P = Promise))(function (resolve, reject) {
  67448. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  67449. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  67450. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  67451. step((generator = generator.apply(thisArg, _arguments || [])).next());
  67452. });
  67453. };
  67454. var __importDefault = (this && this.__importDefault) || function (mod) {
  67455. return (mod && mod.__esModule) ? mod : { "default": mod };
  67456. };
  67457. Object.defineProperty(exports, "__esModule", ({ value: true }));
  67458. const bignumber_js_1 = __importDefault(__webpack_require__(/*! bignumber.js */ "../../node_modules/bignumber.js/bignumber.js"));
  67459. const flatMap_1 = __importDefault(__webpack_require__(/*! lodash/flatMap */ "../../node_modules/lodash/flatMap.js"));
  67460. const errors_1 = __webpack_require__(/*! ../errors */ "./dist/npm/errors.js");
  67461. const Offer_1 = __webpack_require__(/*! ../models/ledger/Offer */ "./dist/npm/models/ledger/Offer.js");
  67462. const DEFAULT_LIMIT = 20;
  67463. function sortOffers(offers) {
  67464. return offers.sort((offerA, offerB) => {
  67465. var _a, _b;
  67466. const qualityA = (_a = offerA.quality) !== null && _a !== void 0 ? _a : 0;
  67467. const qualityB = (_b = offerB.quality) !== null && _b !== void 0 ? _b : 0;
  67468. return new bignumber_js_1.default(qualityA).comparedTo(qualityB);
  67469. });
  67470. }
  67471. const getOrderbookOptionsSet = new Set([
  67472. 'limit',
  67473. 'ledger_index',
  67474. 'ledger_hash',
  67475. 'taker',
  67476. ]);
  67477. function getOrderbook(takerPays, takerGets, options = {}) {
  67478. var _a, _b;
  67479. return __awaiter(this, void 0, void 0, function* () {
  67480. Object.keys(options).forEach((key) => {
  67481. if (!getOrderbookOptionsSet.has(key)) {
  67482. throw new errors_1.ValidationError(`Unexpected option: ${key}`, options);
  67483. }
  67484. });
  67485. if (options.limit && typeof options.limit !== 'number') {
  67486. throw new errors_1.ValidationError('limit must be a number', options.limit);
  67487. }
  67488. if (options.ledger_index &&
  67489. !(typeof options.ledger_index === 'number' ||
  67490. (typeof options.ledger_index === 'string' &&
  67491. ['validated', 'closed', 'current'].includes(options.ledger_index)))) {
  67492. throw new errors_1.ValidationError('ledger_index must be a number or a string of "validated", "closed", or "current"', options.ledger_index);
  67493. }
  67494. if (options.ledger_hash !== undefined &&
  67495. options.ledger_hash !== null &&
  67496. typeof options.ledger_hash !== 'string') {
  67497. throw new errors_1.ValidationError('ledger_hash must be a string', options.ledger_hash);
  67498. }
  67499. if (options.taker !== undefined && typeof options.taker !== 'string') {
  67500. throw new errors_1.ValidationError('taker must be a string', options.taker);
  67501. }
  67502. const request = {
  67503. command: 'book_offers',
  67504. taker_pays: takerPays,
  67505. taker_gets: takerGets,
  67506. ledger_index: (_a = options.ledger_index) !== null && _a !== void 0 ? _a : 'validated',
  67507. ledger_hash: options.ledger_hash === null ? undefined : options.ledger_hash,
  67508. limit: (_b = options.limit) !== null && _b !== void 0 ? _b : DEFAULT_LIMIT,
  67509. taker: options.taker ? options.taker : undefined,
  67510. };
  67511. const directOfferResults = yield this.requestAll(request);
  67512. request.taker_gets = takerPays;
  67513. request.taker_pays = takerGets;
  67514. const reverseOfferResults = yield this.requestAll(request);
  67515. const directOffers = (0, flatMap_1.default)(directOfferResults, (directOfferResult) => directOfferResult.result.offers);
  67516. const reverseOffers = (0, flatMap_1.default)(reverseOfferResults, (reverseOfferResult) => reverseOfferResult.result.offers);
  67517. const orders = [...directOffers, ...reverseOffers];
  67518. const buy = [];
  67519. const sell = [];
  67520. orders.forEach((order) => {
  67521. if ((order.Flags & Offer_1.OfferFlags.lsfSell) === 0) {
  67522. buy.push(order);
  67523. }
  67524. else {
  67525. sell.push(order);
  67526. }
  67527. });
  67528. return {
  67529. buy: sortOffers(buy).slice(0, options.limit),
  67530. sell: sortOffers(sell).slice(0, options.limit),
  67531. };
  67532. });
  67533. }
  67534. exports["default"] = getOrderbook;
  67535. /***/ }),
  67536. /***/ "./dist/npm/sugar/index.js":
  67537. /*!*********************************!*\
  67538. !*** ./dist/npm/sugar/index.js ***!
  67539. \*********************************/
  67540. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  67541. "use strict";
  67542. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  67543. if (k2 === undefined) k2 = k;
  67544. var desc = Object.getOwnPropertyDescriptor(m, k);
  67545. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  67546. desc = { enumerable: true, get: function() { return m[k]; } };
  67547. }
  67548. Object.defineProperty(o, k2, desc);
  67549. }) : (function(o, m, k, k2) {
  67550. if (k2 === undefined) k2 = k;
  67551. o[k2] = m[k];
  67552. }));
  67553. var __exportStar = (this && this.__exportStar) || function(m, exports) {
  67554. for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
  67555. };
  67556. var __importDefault = (this && this.__importDefault) || function (mod) {
  67557. return (mod && mod.__esModule) ? mod : { "default": mod };
  67558. };
  67559. Object.defineProperty(exports, "__esModule", ({ value: true }));
  67560. exports.getOrderbook = exports.getLedgerIndex = exports.getXrpBalance = exports.getBalances = exports.autofill = void 0;
  67561. var autofill_1 = __webpack_require__(/*! ./autofill */ "./dist/npm/sugar/autofill.js");
  67562. Object.defineProperty(exports, "autofill", ({ enumerable: true, get: function () { return __importDefault(autofill_1).default; } }));
  67563. var balances_1 = __webpack_require__(/*! ./balances */ "./dist/npm/sugar/balances.js");
  67564. Object.defineProperty(exports, "getBalances", ({ enumerable: true, get: function () { return balances_1.getBalances; } }));
  67565. Object.defineProperty(exports, "getXrpBalance", ({ enumerable: true, get: function () { return balances_1.getXrpBalance; } }));
  67566. var getLedgerIndex_1 = __webpack_require__(/*! ./getLedgerIndex */ "./dist/npm/sugar/getLedgerIndex.js");
  67567. Object.defineProperty(exports, "getLedgerIndex", ({ enumerable: true, get: function () { return __importDefault(getLedgerIndex_1).default; } }));
  67568. var getOrderbook_1 = __webpack_require__(/*! ./getOrderbook */ "./dist/npm/sugar/getOrderbook.js");
  67569. Object.defineProperty(exports, "getOrderbook", ({ enumerable: true, get: function () { return __importDefault(getOrderbook_1).default; } }));
  67570. __exportStar(__webpack_require__(/*! ./submit */ "./dist/npm/sugar/submit.js"), exports);
  67571. __exportStar(__webpack_require__(/*! ./utils */ "./dist/npm/sugar/utils.js"), exports);
  67572. /***/ }),
  67573. /***/ "./dist/npm/sugar/submit.js":
  67574. /*!**********************************!*\
  67575. !*** ./dist/npm/sugar/submit.js ***!
  67576. \**********************************/
  67577. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  67578. "use strict";
  67579. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  67580. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  67581. return new (P || (P = Promise))(function (resolve, reject) {
  67582. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  67583. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  67584. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  67585. step((generator = generator.apply(thisArg, _arguments || [])).next());
  67586. });
  67587. };
  67588. Object.defineProperty(exports, "__esModule", ({ value: true }));
  67589. exports.submitAndWait = exports.submit = void 0;
  67590. const ripple_binary_codec_1 = __webpack_require__(/*! ripple-binary-codec */ "../../node_modules/ripple-binary-codec/dist/index.js");
  67591. const errors_1 = __webpack_require__(/*! ../errors */ "./dist/npm/errors.js");
  67592. const utils_1 = __webpack_require__(/*! ../utils */ "./dist/npm/utils/index.js");
  67593. const LEDGER_CLOSE_TIME = 1000;
  67594. function sleep(ms) {
  67595. return __awaiter(this, void 0, void 0, function* () {
  67596. return new Promise((resolve) => {
  67597. setTimeout(resolve, ms);
  67598. });
  67599. });
  67600. }
  67601. function submit(transaction, opts) {
  67602. return __awaiter(this, void 0, void 0, function* () {
  67603. const signedTx = yield getSignedTx(this, transaction, opts);
  67604. return submitRequest(this, signedTx, opts === null || opts === void 0 ? void 0 : opts.failHard);
  67605. });
  67606. }
  67607. exports.submit = submit;
  67608. function submitAndWait(transaction, opts) {
  67609. return __awaiter(this, void 0, void 0, function* () {
  67610. const signedTx = yield getSignedTx(this, transaction, opts);
  67611. const lastLedger = getLastLedgerSequence(signedTx);
  67612. if (lastLedger == null) {
  67613. throw new errors_1.ValidationError('Transaction must contain a LastLedgerSequence value for reliable submission.');
  67614. }
  67615. const response = yield submitRequest(this, signedTx, opts === null || opts === void 0 ? void 0 : opts.failHard);
  67616. const txHash = utils_1.hashes.hashSignedTx(signedTx);
  67617. return waitForFinalTransactionOutcome(this, txHash, lastLedger, response.result.engine_result);
  67618. });
  67619. }
  67620. exports.submitAndWait = submitAndWait;
  67621. function submitRequest(client, signedTransaction, failHard = false) {
  67622. return __awaiter(this, void 0, void 0, function* () {
  67623. if (!isSigned(signedTransaction)) {
  67624. throw new errors_1.ValidationError('Transaction must be signed');
  67625. }
  67626. const signedTxEncoded = typeof signedTransaction === 'string'
  67627. ? signedTransaction
  67628. : (0, ripple_binary_codec_1.encode)(signedTransaction);
  67629. const request = {
  67630. command: 'submit',
  67631. tx_blob: signedTxEncoded,
  67632. fail_hard: isAccountDelete(signedTransaction) || failHard,
  67633. };
  67634. return client.request(request);
  67635. });
  67636. }
  67637. function waitForFinalTransactionOutcome(client, txHash, lastLedger, submissionResult) {
  67638. return __awaiter(this, void 0, void 0, function* () {
  67639. yield sleep(LEDGER_CLOSE_TIME);
  67640. const latestLedger = yield client.getLedgerIndex();
  67641. if (lastLedger < latestLedger) {
  67642. throw new errors_1.XrplError(`The latest ledger sequence ${latestLedger} is greater than the transaction's LastLedgerSequence (${lastLedger}).\n` +
  67643. `Preliminary result: ${submissionResult}`);
  67644. }
  67645. const txResponse = yield client
  67646. .request({
  67647. command: 'tx',
  67648. transaction: txHash,
  67649. })
  67650. .catch((error) => __awaiter(this, void 0, void 0, function* () {
  67651. var _a;
  67652. const message = (_a = error === null || error === void 0 ? void 0 : error.data) === null || _a === void 0 ? void 0 : _a.error;
  67653. if (message === 'txnNotFound') {
  67654. return waitForFinalTransactionOutcome(client, txHash, lastLedger, submissionResult);
  67655. }
  67656. throw new Error(`${message} \n Preliminary result: ${submissionResult}.\nFull error details: ${String(error)}`);
  67657. }));
  67658. if (txResponse.result.validated) {
  67659. return txResponse;
  67660. }
  67661. return waitForFinalTransactionOutcome(client, txHash, lastLedger, submissionResult);
  67662. });
  67663. }
  67664. function isSigned(transaction) {
  67665. const tx = typeof transaction === 'string' ? (0, ripple_binary_codec_1.decode)(transaction) : transaction;
  67666. return (typeof tx !== 'string' &&
  67667. (tx.SigningPubKey != null || tx.TxnSignature != null));
  67668. }
  67669. function getSignedTx(client, transaction, { autofill = true, wallet, } = {}) {
  67670. return __awaiter(this, void 0, void 0, function* () {
  67671. if (isSigned(transaction)) {
  67672. return transaction;
  67673. }
  67674. if (!wallet) {
  67675. throw new errors_1.ValidationError('Wallet must be provided when submitting an unsigned transaction');
  67676. }
  67677. let tx = typeof transaction === 'string'
  67678. ?
  67679. (0, ripple_binary_codec_1.decode)(transaction)
  67680. : transaction;
  67681. if (autofill) {
  67682. tx = yield client.autofill(tx);
  67683. }
  67684. return wallet.sign(tx).tx_blob;
  67685. });
  67686. }
  67687. function getLastLedgerSequence(transaction) {
  67688. const tx = typeof transaction === 'string' ? (0, ripple_binary_codec_1.decode)(transaction) : transaction;
  67689. return tx.LastLedgerSequence;
  67690. }
  67691. function isAccountDelete(transaction) {
  67692. const tx = typeof transaction === 'string' ? (0, ripple_binary_codec_1.decode)(transaction) : transaction;
  67693. return tx.TransactionType === 'AccountDelete';
  67694. }
  67695. /***/ }),
  67696. /***/ "./dist/npm/sugar/utils.js":
  67697. /*!*********************************!*\
  67698. !*** ./dist/npm/sugar/utils.js ***!
  67699. \*********************************/
  67700. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  67701. "use strict";
  67702. Object.defineProperty(exports, "__esModule", ({ value: true }));
  67703. exports.ensureClassicAddress = void 0;
  67704. const ripple_address_codec_1 = __webpack_require__(/*! ripple-address-codec */ "../../node_modules/ripple-address-codec/dist/index.js");
  67705. function ensureClassicAddress(account) {
  67706. if ((0, ripple_address_codec_1.isValidXAddress)(account)) {
  67707. const { classicAddress, tag } = (0, ripple_address_codec_1.xAddressToClassicAddress)(account);
  67708. if (tag !== false) {
  67709. throw new Error('This command does not support the use of a tag. Use an address without a tag.');
  67710. }
  67711. return classicAddress;
  67712. }
  67713. return account;
  67714. }
  67715. exports.ensureClassicAddress = ensureClassicAddress;
  67716. /***/ }),
  67717. /***/ "./dist/npm/utils/createCrossChainPayment.js":
  67718. /*!***************************************************!*\
  67719. !*** ./dist/npm/utils/createCrossChainPayment.js ***!
  67720. \***************************************************/
  67721. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  67722. "use strict";
  67723. Object.defineProperty(exports, "__esModule", ({ value: true }));
  67724. const errors_1 = __webpack_require__(/*! ../errors */ "./dist/npm/errors.js");
  67725. const stringConversion_1 = __webpack_require__(/*! ./stringConversion */ "./dist/npm/utils/stringConversion.js");
  67726. function createCrossChainPayment(payment, destAccount) {
  67727. var _a;
  67728. const destAccountHex = (0, stringConversion_1.convertStringToHex)(destAccount);
  67729. const destAccountMemo = { Memo: { MemoData: destAccountHex } };
  67730. const memos = (_a = payment.Memos) !== null && _a !== void 0 ? _a : [];
  67731. if (memos.length > 2) {
  67732. throw new errors_1.XrplError('Cannot have more than 2 memos in a cross-chain transaction.');
  67733. }
  67734. const newMemos = [destAccountMemo, ...memos];
  67735. const newPayment = Object.assign(Object.assign({}, payment), { Memos: newMemos });
  67736. delete newPayment.TxnSignature;
  67737. return newPayment;
  67738. }
  67739. exports["default"] = createCrossChainPayment;
  67740. /***/ }),
  67741. /***/ "./dist/npm/utils/derive.js":
  67742. /*!**********************************!*\
  67743. !*** ./dist/npm/utils/derive.js ***!
  67744. \**********************************/
  67745. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  67746. "use strict";
  67747. Object.defineProperty(exports, "__esModule", ({ value: true }));
  67748. exports.deriveXAddress = exports.deriveAddress = exports.deriveKeypair = void 0;
  67749. const ripple_address_codec_1 = __webpack_require__(/*! ripple-address-codec */ "../../node_modules/ripple-address-codec/dist/index.js");
  67750. const ripple_keypairs_1 = __webpack_require__(/*! ripple-keypairs */ "../../node_modules/ripple-keypairs/dist/index.js");
  67751. Object.defineProperty(exports, "deriveKeypair", ({ enumerable: true, get: function () { return ripple_keypairs_1.deriveKeypair; } }));
  67752. Object.defineProperty(exports, "deriveAddress", ({ enumerable: true, get: function () { return ripple_keypairs_1.deriveAddress; } }));
  67753. function deriveXAddress(options) {
  67754. const classicAddress = (0, ripple_keypairs_1.deriveAddress)(options.publicKey);
  67755. return (0, ripple_address_codec_1.classicAddressToXAddress)(classicAddress, options.tag, options.test);
  67756. }
  67757. exports.deriveXAddress = deriveXAddress;
  67758. /***/ }),
  67759. /***/ "./dist/npm/utils/getBalanceChanges.js":
  67760. /*!*********************************************!*\
  67761. !*** ./dist/npm/utils/getBalanceChanges.js ***!
  67762. \*********************************************/
  67763. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  67764. "use strict";
  67765. var __importDefault = (this && this.__importDefault) || function (mod) {
  67766. return (mod && mod.__esModule) ? mod : { "default": mod };
  67767. };
  67768. Object.defineProperty(exports, "__esModule", ({ value: true }));
  67769. const bignumber_js_1 = __importDefault(__webpack_require__(/*! bignumber.js */ "../../node_modules/bignumber.js/bignumber.js"));
  67770. const flatten_1 = __importDefault(__webpack_require__(/*! lodash/flatten */ "../../node_modules/lodash/flatten.js"));
  67771. const groupBy_1 = __importDefault(__webpack_require__(/*! lodash/groupBy */ "../../node_modules/lodash/groupBy.js"));
  67772. const xrpConversion_1 = __webpack_require__(/*! ./xrpConversion */ "./dist/npm/utils/xrpConversion.js");
  67773. function normalizeNode(affectedNode) {
  67774. const diffType = Object.keys(affectedNode)[0];
  67775. const node = affectedNode[diffType];
  67776. return Object.assign(Object.assign({}, node), { NodeType: diffType, LedgerEntryType: node.LedgerEntryType, LedgerIndex: node.LedgerIndex, NewFields: node.NewFields, FinalFields: node.FinalFields, PreviousFields: node.PreviousFields });
  67777. }
  67778. function normalizeNodes(metadata) {
  67779. if (metadata.AffectedNodes.length === 0) {
  67780. return [];
  67781. }
  67782. return metadata.AffectedNodes.map(normalizeNode);
  67783. }
  67784. function groupByAccount(balanceChanges) {
  67785. const grouped = (0, groupBy_1.default)(balanceChanges, (node) => node.account);
  67786. return Object.entries(grouped).map(([account, items]) => {
  67787. return { account, balances: items.map((item) => item.balance) };
  67788. });
  67789. }
  67790. function getValue(balance) {
  67791. if (typeof balance === 'string') {
  67792. return new bignumber_js_1.default(balance);
  67793. }
  67794. return new bignumber_js_1.default(balance.value);
  67795. }
  67796. function computeBalanceChange(node) {
  67797. var _a, _b, _c;
  67798. let value = null;
  67799. if ((_a = node.NewFields) === null || _a === void 0 ? void 0 : _a.Balance) {
  67800. value = getValue(node.NewFields.Balance);
  67801. }
  67802. else if (((_b = node.PreviousFields) === null || _b === void 0 ? void 0 : _b.Balance) && ((_c = node.FinalFields) === null || _c === void 0 ? void 0 : _c.Balance)) {
  67803. value = getValue(node.FinalFields.Balance).minus(getValue(node.PreviousFields.Balance));
  67804. }
  67805. if (value === null || value.isZero()) {
  67806. return null;
  67807. }
  67808. return value;
  67809. }
  67810. function getXRPQuantity(node) {
  67811. var _a, _b, _c;
  67812. const value = computeBalanceChange(node);
  67813. if (value === null) {
  67814. return null;
  67815. }
  67816. return {
  67817. account: ((_b = (_a = node.FinalFields) === null || _a === void 0 ? void 0 : _a.Account) !== null && _b !== void 0 ? _b : (_c = node.NewFields) === null || _c === void 0 ? void 0 : _c.Account),
  67818. balance: {
  67819. currency: 'XRP',
  67820. value: (0, xrpConversion_1.dropsToXrp)(value).toString(),
  67821. },
  67822. };
  67823. }
  67824. function flipTrustlinePerspective(balanceChange) {
  67825. const negatedBalance = new bignumber_js_1.default(balanceChange.balance.value).negated();
  67826. return {
  67827. account: balanceChange.balance.issuer,
  67828. balance: {
  67829. issuer: balanceChange.account,
  67830. currency: balanceChange.balance.currency,
  67831. value: negatedBalance.toString(),
  67832. },
  67833. };
  67834. }
  67835. function getTrustlineQuantity(node) {
  67836. var _a, _b;
  67837. const value = computeBalanceChange(node);
  67838. if (value === null) {
  67839. return null;
  67840. }
  67841. const fields = node.NewFields == null ? node.FinalFields : node.NewFields;
  67842. const result = {
  67843. account: (_a = fields === null || fields === void 0 ? void 0 : fields.LowLimit) === null || _a === void 0 ? void 0 : _a.issuer,
  67844. balance: {
  67845. issuer: (_b = fields === null || fields === void 0 ? void 0 : fields.HighLimit) === null || _b === void 0 ? void 0 : _b.issuer,
  67846. currency: (fields === null || fields === void 0 ? void 0 : fields.Balance).currency,
  67847. value: value.toString(),
  67848. },
  67849. };
  67850. return [result, flipTrustlinePerspective(result)];
  67851. }
  67852. function getBalanceChanges(metadata) {
  67853. const quantities = normalizeNodes(metadata).map((node) => {
  67854. if (node.LedgerEntryType === 'AccountRoot') {
  67855. const xrpQuantity = getXRPQuantity(node);
  67856. if (xrpQuantity == null) {
  67857. return [];
  67858. }
  67859. return [xrpQuantity];
  67860. }
  67861. if (node.LedgerEntryType === 'RippleState') {
  67862. const trustlineQuantity = getTrustlineQuantity(node);
  67863. if (trustlineQuantity == null) {
  67864. return [];
  67865. }
  67866. return trustlineQuantity;
  67867. }
  67868. return [];
  67869. });
  67870. return groupByAccount((0, flatten_1.default)(quantities));
  67871. }
  67872. exports["default"] = getBalanceChanges;
  67873. /***/ }),
  67874. /***/ "./dist/npm/utils/getNFTokenID.js":
  67875. /*!****************************************!*\
  67876. !*** ./dist/npm/utils/getNFTokenID.js ***!
  67877. \****************************************/
  67878. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  67879. "use strict";
  67880. var __importDefault = (this && this.__importDefault) || function (mod) {
  67881. return (mod && mod.__esModule) ? mod : { "default": mod };
  67882. };
  67883. Object.defineProperty(exports, "__esModule", ({ value: true }));
  67884. const flatMap_1 = __importDefault(__webpack_require__(/*! lodash/flatMap */ "../../node_modules/lodash/flatMap.js"));
  67885. const metadata_1 = __webpack_require__(/*! ../models/transactions/metadata */ "./dist/npm/models/transactions/metadata.js");
  67886. function getNFTokenID(meta) {
  67887. if (meta.AffectedNodes === undefined) {
  67888. throw new TypeError(`Unable to parse the parameter given to getNFTokenID.
  67889. 'meta' must be the metadata from an NFTokenMint transaction. Received ${JSON.stringify(meta)} instead.`);
  67890. }
  67891. const affectedNodes = meta.AffectedNodes.filter((node) => {
  67892. var _a;
  67893. if ((0, metadata_1.isCreatedNode)(node)) {
  67894. return node.CreatedNode.LedgerEntryType === 'NFTokenPage';
  67895. }
  67896. if ((0, metadata_1.isModifiedNode)(node)) {
  67897. return (node.ModifiedNode.LedgerEntryType === 'NFTokenPage' &&
  67898. Boolean((_a = node.ModifiedNode.PreviousFields) === null || _a === void 0 ? void 0 : _a.NFTokens));
  67899. }
  67900. return false;
  67901. });
  67902. const previousTokenIDSet = new Set((0, flatMap_1.default)(affectedNodes, (node) => {
  67903. var _a;
  67904. const nftokens = (0, metadata_1.isModifiedNode)(node)
  67905. ? (_a = node.ModifiedNode.PreviousFields) === null || _a === void 0 ? void 0 : _a.NFTokens
  67906. : [];
  67907. return nftokens.map((token) => token.NFToken.NFTokenID);
  67908. }).filter((id) => Boolean(id)));
  67909. const finalTokenIDs = (0, flatMap_1.default)(affectedNodes, (node) => {
  67910. var _a, _b, _c, _d, _e, _f;
  67911. return ((_f = ((_c = (_b = (_a = node.ModifiedNode) === null || _a === void 0 ? void 0 : _a.FinalFields) === null || _b === void 0 ? void 0 : _b.NFTokens) !== null && _c !== void 0 ? _c : (_e = (_d = node.CreatedNode) === null || _d === void 0 ? void 0 : _d.NewFields) === null || _e === void 0 ? void 0 : _e.NFTokens)) !== null && _f !== void 0 ? _f : []).map((token) => token.NFToken.NFTokenID);
  67912. }).filter((nftokenID) => Boolean(nftokenID));
  67913. const nftokenID = finalTokenIDs.find((id) => !previousTokenIDSet.has(id));
  67914. return nftokenID;
  67915. }
  67916. exports["default"] = getNFTokenID;
  67917. /***/ }),
  67918. /***/ "./dist/npm/utils/hashes/HashPrefix.js":
  67919. /*!*********************************************!*\
  67920. !*** ./dist/npm/utils/hashes/HashPrefix.js ***!
  67921. \*********************************************/
  67922. /***/ ((__unused_webpack_module, exports) => {
  67923. "use strict";
  67924. Object.defineProperty(exports, "__esModule", ({ value: true }));
  67925. var HashPrefix;
  67926. (function (HashPrefix) {
  67927. HashPrefix[HashPrefix["TRANSACTION_ID"] = 1415073280] = "TRANSACTION_ID";
  67928. HashPrefix[HashPrefix["TRANSACTION_NODE"] = 1397638144] = "TRANSACTION_NODE";
  67929. HashPrefix[HashPrefix["INNER_NODE"] = 1296649728] = "INNER_NODE";
  67930. HashPrefix[HashPrefix["LEAF_NODE"] = 1296846336] = "LEAF_NODE";
  67931. HashPrefix[HashPrefix["TRANSACTION_SIGN"] = 1398036480] = "TRANSACTION_SIGN";
  67932. HashPrefix[HashPrefix["TRANSACTION_SIGN_TESTNET"] = 1937012736] = "TRANSACTION_SIGN_TESTNET";
  67933. HashPrefix[HashPrefix["TRANSACTION_MULTISIGN"] = 1397576704] = "TRANSACTION_MULTISIGN";
  67934. HashPrefix[HashPrefix["LEDGER"] = 1280791040] = "LEDGER";
  67935. })(HashPrefix || (HashPrefix = {}));
  67936. exports["default"] = HashPrefix;
  67937. /***/ }),
  67938. /***/ "./dist/npm/utils/hashes/SHAMap/InnerNode.js":
  67939. /*!***************************************************!*\
  67940. !*** ./dist/npm/utils/hashes/SHAMap/InnerNode.js ***!
  67941. \***************************************************/
  67942. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  67943. "use strict";
  67944. var __importDefault = (this && this.__importDefault) || function (mod) {
  67945. return (mod && mod.__esModule) ? mod : { "default": mod };
  67946. };
  67947. Object.defineProperty(exports, "__esModule", ({ value: true }));
  67948. const errors_1 = __webpack_require__(/*! ../../../errors */ "./dist/npm/errors.js");
  67949. const HashPrefix_1 = __importDefault(__webpack_require__(/*! ../HashPrefix */ "./dist/npm/utils/hashes/HashPrefix.js"));
  67950. const sha512Half_1 = __importDefault(__webpack_require__(/*! ../sha512Half */ "./dist/npm/utils/hashes/sha512Half.js"));
  67951. const LeafNode_1 = __importDefault(__webpack_require__(/*! ./LeafNode */ "./dist/npm/utils/hashes/SHAMap/LeafNode.js"));
  67952. const node_1 = __webpack_require__(/*! ./node */ "./dist/npm/utils/hashes/SHAMap/node.js");
  67953. const HEX_ZERO = '0000000000000000000000000000000000000000000000000000000000000000';
  67954. const SLOT_MAX = 15;
  67955. const HEX = 16;
  67956. class InnerNode extends node_1.Node {
  67957. constructor(depth = 0) {
  67958. super();
  67959. this.leaves = {};
  67960. this.type = node_1.NodeType.INNER;
  67961. this.depth = depth;
  67962. this.empty = true;
  67963. }
  67964. get hash() {
  67965. if (this.empty) {
  67966. return HEX_ZERO;
  67967. }
  67968. let hex = '';
  67969. for (let iter = 0; iter <= SLOT_MAX; iter++) {
  67970. const child = this.leaves[iter];
  67971. const hash = child == null ? HEX_ZERO : child.hash;
  67972. hex += hash;
  67973. }
  67974. const prefix = HashPrefix_1.default.INNER_NODE.toString(HEX);
  67975. return (0, sha512Half_1.default)(prefix + hex);
  67976. }
  67977. addItem(tag, node) {
  67978. const existingNode = this.getNode(parseInt(tag[this.depth], HEX));
  67979. if (existingNode === undefined) {
  67980. this.setNode(parseInt(tag[this.depth], HEX), node);
  67981. return;
  67982. }
  67983. if (existingNode instanceof InnerNode) {
  67984. existingNode.addItem(tag, node);
  67985. }
  67986. else if (existingNode instanceof LeafNode_1.default) {
  67987. if (existingNode.tag === tag) {
  67988. throw new errors_1.XrplError('Tried to add a node to a SHAMap that was already in there.');
  67989. }
  67990. else {
  67991. const newInnerNode = new InnerNode(this.depth + 1);
  67992. newInnerNode.addItem(existingNode.tag, existingNode);
  67993. newInnerNode.addItem(tag, node);
  67994. this.setNode(parseInt(tag[this.depth], HEX), newInnerNode);
  67995. }
  67996. }
  67997. }
  67998. setNode(slot, node) {
  67999. if (slot < 0 || slot > SLOT_MAX) {
  68000. throw new errors_1.XrplError('Invalid slot: slot must be between 0-15.');
  68001. }
  68002. this.leaves[slot] = node;
  68003. this.empty = false;
  68004. }
  68005. getNode(slot) {
  68006. if (slot < 0 || slot > SLOT_MAX) {
  68007. throw new errors_1.XrplError('Invalid slot: slot must be between 0-15.');
  68008. }
  68009. return this.leaves[slot];
  68010. }
  68011. }
  68012. exports["default"] = InnerNode;
  68013. /***/ }),
  68014. /***/ "./dist/npm/utils/hashes/SHAMap/LeafNode.js":
  68015. /*!**************************************************!*\
  68016. !*** ./dist/npm/utils/hashes/SHAMap/LeafNode.js ***!
  68017. \**************************************************/
  68018. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  68019. "use strict";
  68020. var __importDefault = (this && this.__importDefault) || function (mod) {
  68021. return (mod && mod.__esModule) ? mod : { "default": mod };
  68022. };
  68023. Object.defineProperty(exports, "__esModule", ({ value: true }));
  68024. const errors_1 = __webpack_require__(/*! ../../../errors */ "./dist/npm/errors.js");
  68025. const HashPrefix_1 = __importDefault(__webpack_require__(/*! ../HashPrefix */ "./dist/npm/utils/hashes/HashPrefix.js"));
  68026. const sha512Half_1 = __importDefault(__webpack_require__(/*! ../sha512Half */ "./dist/npm/utils/hashes/sha512Half.js"));
  68027. const node_1 = __webpack_require__(/*! ./node */ "./dist/npm/utils/hashes/SHAMap/node.js");
  68028. const HEX = 16;
  68029. class LeafNode extends node_1.Node {
  68030. constructor(tag, data, type) {
  68031. super();
  68032. this.tag = tag;
  68033. this.type = type;
  68034. this.data = data;
  68035. }
  68036. get hash() {
  68037. switch (this.type) {
  68038. case node_1.NodeType.ACCOUNT_STATE: {
  68039. const leafPrefix = HashPrefix_1.default.LEAF_NODE.toString(HEX);
  68040. return (0, sha512Half_1.default)(leafPrefix + this.data + this.tag);
  68041. }
  68042. case node_1.NodeType.TRANSACTION_NO_METADATA: {
  68043. const txIDPrefix = HashPrefix_1.default.TRANSACTION_ID.toString(HEX);
  68044. return (0, sha512Half_1.default)(txIDPrefix + this.data);
  68045. }
  68046. case node_1.NodeType.TRANSACTION_METADATA: {
  68047. const txNodePrefix = HashPrefix_1.default.TRANSACTION_NODE.toString(HEX);
  68048. return (0, sha512Half_1.default)(txNodePrefix + this.data + this.tag);
  68049. }
  68050. default:
  68051. throw new errors_1.XrplError('Tried to hash a SHAMap node of unknown type.');
  68052. }
  68053. }
  68054. addItem(tag, node) {
  68055. throw new errors_1.XrplError('Cannot call addItem on a LeafNode');
  68056. this.addItem(tag, node);
  68057. }
  68058. }
  68059. exports["default"] = LeafNode;
  68060. /***/ }),
  68061. /***/ "./dist/npm/utils/hashes/SHAMap/index.js":
  68062. /*!***********************************************!*\
  68063. !*** ./dist/npm/utils/hashes/SHAMap/index.js ***!
  68064. \***********************************************/
  68065. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  68066. "use strict";
  68067. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  68068. if (k2 === undefined) k2 = k;
  68069. var desc = Object.getOwnPropertyDescriptor(m, k);
  68070. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  68071. desc = { enumerable: true, get: function() { return m[k]; } };
  68072. }
  68073. Object.defineProperty(o, k2, desc);
  68074. }) : (function(o, m, k, k2) {
  68075. if (k2 === undefined) k2 = k;
  68076. o[k2] = m[k];
  68077. }));
  68078. var __exportStar = (this && this.__exportStar) || function(m, exports) {
  68079. for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
  68080. };
  68081. var __importDefault = (this && this.__importDefault) || function (mod) {
  68082. return (mod && mod.__esModule) ? mod : { "default": mod };
  68083. };
  68084. Object.defineProperty(exports, "__esModule", ({ value: true }));
  68085. const InnerNode_1 = __importDefault(__webpack_require__(/*! ./InnerNode */ "./dist/npm/utils/hashes/SHAMap/InnerNode.js"));
  68086. const LeafNode_1 = __importDefault(__webpack_require__(/*! ./LeafNode */ "./dist/npm/utils/hashes/SHAMap/LeafNode.js"));
  68087. class SHAMap {
  68088. constructor() {
  68089. this.root = new InnerNode_1.default(0);
  68090. }
  68091. get hash() {
  68092. return this.root.hash;
  68093. }
  68094. addItem(tag, data, type) {
  68095. this.root.addItem(tag, new LeafNode_1.default(tag, data, type));
  68096. }
  68097. }
  68098. __exportStar(__webpack_require__(/*! ./node */ "./dist/npm/utils/hashes/SHAMap/node.js"), exports);
  68099. exports["default"] = SHAMap;
  68100. /***/ }),
  68101. /***/ "./dist/npm/utils/hashes/SHAMap/node.js":
  68102. /*!**********************************************!*\
  68103. !*** ./dist/npm/utils/hashes/SHAMap/node.js ***!
  68104. \**********************************************/
  68105. /***/ ((__unused_webpack_module, exports) => {
  68106. "use strict";
  68107. Object.defineProperty(exports, "__esModule", ({ value: true }));
  68108. exports.Node = exports.NodeType = void 0;
  68109. var NodeType;
  68110. (function (NodeType) {
  68111. NodeType[NodeType["INNER"] = 1] = "INNER";
  68112. NodeType[NodeType["TRANSACTION_NO_METADATA"] = 2] = "TRANSACTION_NO_METADATA";
  68113. NodeType[NodeType["TRANSACTION_METADATA"] = 3] = "TRANSACTION_METADATA";
  68114. NodeType[NodeType["ACCOUNT_STATE"] = 4] = "ACCOUNT_STATE";
  68115. })(NodeType = exports.NodeType || (exports.NodeType = {}));
  68116. class Node {
  68117. }
  68118. exports.Node = Node;
  68119. /***/ }),
  68120. /***/ "./dist/npm/utils/hashes/hashLedger.js":
  68121. /*!*********************************************!*\
  68122. !*** ./dist/npm/utils/hashes/hashLedger.js ***!
  68123. \*********************************************/
  68124. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  68125. "use strict";
  68126. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js")["Buffer"];
  68127. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  68128. if (k2 === undefined) k2 = k;
  68129. var desc = Object.getOwnPropertyDescriptor(m, k);
  68130. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  68131. desc = { enumerable: true, get: function() { return m[k]; } };
  68132. }
  68133. Object.defineProperty(o, k2, desc);
  68134. }) : (function(o, m, k, k2) {
  68135. if (k2 === undefined) k2 = k;
  68136. o[k2] = m[k];
  68137. }));
  68138. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  68139. Object.defineProperty(o, "default", { enumerable: true, value: v });
  68140. }) : function(o, v) {
  68141. o["default"] = v;
  68142. });
  68143. var __importStar = (this && this.__importStar) || function (mod) {
  68144. if (mod && mod.__esModule) return mod;
  68145. var result = {};
  68146. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  68147. __setModuleDefault(result, mod);
  68148. return result;
  68149. };
  68150. var __importDefault = (this && this.__importDefault) || function (mod) {
  68151. return (mod && mod.__esModule) ? mod : { "default": mod };
  68152. };
  68153. Object.defineProperty(exports, "__esModule", ({ value: true }));
  68154. exports.hashStateTree = exports.hashTxTree = exports.hashLedgerHeader = exports.hashSignedTx = void 0;
  68155. const bignumber_js_1 = __importDefault(__webpack_require__(/*! bignumber.js */ "../../node_modules/bignumber.js/bignumber.js"));
  68156. const ripple_binary_codec_1 = __webpack_require__(/*! ripple-binary-codec */ "../../node_modules/ripple-binary-codec/dist/index.js");
  68157. const errors_1 = __webpack_require__(/*! ../../errors */ "./dist/npm/errors.js");
  68158. const HashPrefix_1 = __importDefault(__webpack_require__(/*! ./HashPrefix */ "./dist/npm/utils/hashes/HashPrefix.js"));
  68159. const sha512Half_1 = __importDefault(__webpack_require__(/*! ./sha512Half */ "./dist/npm/utils/hashes/sha512Half.js"));
  68160. const SHAMap_1 = __importStar(__webpack_require__(/*! ./SHAMap */ "./dist/npm/utils/hashes/SHAMap/index.js"));
  68161. const HEX = 16;
  68162. function intToHex(integer, byteLength) {
  68163. const foo = Number(integer)
  68164. .toString(HEX)
  68165. .padStart(byteLength * 2, '0');
  68166. return foo;
  68167. }
  68168. function bytesToHex(bytes) {
  68169. return Buffer.from(bytes).toString('hex');
  68170. }
  68171. function bigintToHex(integerString, byteLength) {
  68172. const hex = new bignumber_js_1.default(integerString).toString(HEX);
  68173. return hex.padStart(byteLength * 2, '0');
  68174. }
  68175. function addLengthPrefix(hex) {
  68176. const length = hex.length / 2;
  68177. if (length <= 192) {
  68178. return bytesToHex([length]) + hex;
  68179. }
  68180. if (length <= 12480) {
  68181. const prefix = length - 193;
  68182. return bytesToHex([193 + (prefix >>> 8), prefix & 0xff]) + hex;
  68183. }
  68184. if (length <= 918744) {
  68185. const prefix = length - 12481;
  68186. return (bytesToHex([
  68187. 241 + (prefix >>> 16),
  68188. (prefix >>> 8) & 0xff,
  68189. prefix & 0xff,
  68190. ]) + hex);
  68191. }
  68192. throw new errors_1.XrplError('Variable integer overflow.');
  68193. }
  68194. function hashSignedTx(tx) {
  68195. let txBlob;
  68196. let txObject;
  68197. if (typeof tx === 'string') {
  68198. txBlob = tx;
  68199. txObject = (0, ripple_binary_codec_1.decode)(tx);
  68200. }
  68201. else {
  68202. txBlob = (0, ripple_binary_codec_1.encode)(tx);
  68203. txObject = tx;
  68204. }
  68205. if (txObject.TxnSignature === undefined && txObject.Signers === undefined) {
  68206. throw new errors_1.ValidationError('The transaction must be signed to hash it.');
  68207. }
  68208. const prefix = HashPrefix_1.default.TRANSACTION_ID.toString(16).toUpperCase();
  68209. return (0, sha512Half_1.default)(prefix.concat(txBlob));
  68210. }
  68211. exports.hashSignedTx = hashSignedTx;
  68212. function hashLedgerHeader(ledgerHeader) {
  68213. const prefix = HashPrefix_1.default.LEDGER.toString(HEX).toUpperCase();
  68214. const ledger = prefix +
  68215. intToHex(Number(ledgerHeader.ledger_index), 4) +
  68216. bigintToHex(ledgerHeader.total_coins, 8) +
  68217. ledgerHeader.parent_hash +
  68218. ledgerHeader.transaction_hash +
  68219. ledgerHeader.account_hash +
  68220. intToHex(ledgerHeader.parent_close_time, 4) +
  68221. intToHex(ledgerHeader.close_time, 4) +
  68222. intToHex(ledgerHeader.close_time_resolution, 1) +
  68223. intToHex(ledgerHeader.close_flags, 1);
  68224. return (0, sha512Half_1.default)(ledger);
  68225. }
  68226. exports.hashLedgerHeader = hashLedgerHeader;
  68227. function hashTxTree(transactions) {
  68228. var _a;
  68229. const shamap = new SHAMap_1.default();
  68230. for (const txJSON of transactions) {
  68231. const txBlobHex = (0, ripple_binary_codec_1.encode)(txJSON);
  68232. const metaHex = (0, ripple_binary_codec_1.encode)((_a = txJSON.metaData) !== null && _a !== void 0 ? _a : {});
  68233. const txHash = hashSignedTx(txBlobHex);
  68234. const data = addLengthPrefix(txBlobHex) + addLengthPrefix(metaHex);
  68235. shamap.addItem(txHash, data, SHAMap_1.NodeType.TRANSACTION_METADATA);
  68236. }
  68237. return shamap.hash;
  68238. }
  68239. exports.hashTxTree = hashTxTree;
  68240. function hashStateTree(entries) {
  68241. const shamap = new SHAMap_1.default();
  68242. entries.forEach((ledgerEntry) => {
  68243. const data = (0, ripple_binary_codec_1.encode)(ledgerEntry);
  68244. shamap.addItem(ledgerEntry.index, data, SHAMap_1.NodeType.ACCOUNT_STATE);
  68245. });
  68246. return shamap.hash;
  68247. }
  68248. exports.hashStateTree = hashStateTree;
  68249. function computeTransactionHash(ledger, options) {
  68250. const { transaction_hash } = ledger;
  68251. if (!options.computeTreeHashes) {
  68252. return transaction_hash;
  68253. }
  68254. if (ledger.transactions == null) {
  68255. throw new errors_1.ValidationError('transactions is missing from the ledger');
  68256. }
  68257. const transactionHash = hashTxTree(ledger.transactions);
  68258. if (transaction_hash !== transactionHash) {
  68259. throw new errors_1.ValidationError('transactionHash in header' +
  68260. ' does not match computed hash of transactions', {
  68261. transactionHashInHeader: transaction_hash,
  68262. computedHashOfTransactions: transactionHash,
  68263. });
  68264. }
  68265. return transactionHash;
  68266. }
  68267. function computeStateHash(ledger, options) {
  68268. const { account_hash } = ledger;
  68269. if (!options.computeTreeHashes) {
  68270. return account_hash;
  68271. }
  68272. if (ledger.accountState == null) {
  68273. throw new errors_1.ValidationError('accountState is missing from the ledger');
  68274. }
  68275. const stateHash = hashStateTree(ledger.accountState);
  68276. if (account_hash !== stateHash) {
  68277. throw new errors_1.ValidationError('stateHash in header does not match computed hash of state');
  68278. }
  68279. return stateHash;
  68280. }
  68281. function hashLedger(ledger, options = {}) {
  68282. const subhashes = {
  68283. transaction_hash: computeTransactionHash(ledger, options),
  68284. account_hash: computeStateHash(ledger, options),
  68285. };
  68286. return hashLedgerHeader(Object.assign(Object.assign({}, ledger), subhashes));
  68287. }
  68288. exports["default"] = hashLedger;
  68289. /***/ }),
  68290. /***/ "./dist/npm/utils/hashes/index.js":
  68291. /*!****************************************!*\
  68292. !*** ./dist/npm/utils/hashes/index.js ***!
  68293. \****************************************/
  68294. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  68295. "use strict";
  68296. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js")["Buffer"];
  68297. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  68298. if (k2 === undefined) k2 = k;
  68299. var desc = Object.getOwnPropertyDescriptor(m, k);
  68300. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  68301. desc = { enumerable: true, get: function() { return m[k]; } };
  68302. }
  68303. Object.defineProperty(o, k2, desc);
  68304. }) : (function(o, m, k, k2) {
  68305. if (k2 === undefined) k2 = k;
  68306. o[k2] = m[k];
  68307. }));
  68308. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  68309. Object.defineProperty(o, "default", { enumerable: true, value: v });
  68310. }) : function(o, v) {
  68311. o["default"] = v;
  68312. });
  68313. var __importStar = (this && this.__importStar) || function (mod) {
  68314. if (mod && mod.__esModule) return mod;
  68315. var result = {};
  68316. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  68317. __setModuleDefault(result, mod);
  68318. return result;
  68319. };
  68320. var __importDefault = (this && this.__importDefault) || function (mod) {
  68321. return (mod && mod.__esModule) ? mod : { "default": mod };
  68322. };
  68323. Object.defineProperty(exports, "__esModule", ({ value: true }));
  68324. exports.hashTxTree = exports.hashStateTree = exports.hashLedger = exports.hashSignedTx = exports.hashLedgerHeader = exports.hashPaymentChannel = exports.hashEscrow = exports.hashTrustline = exports.hashOfferId = exports.hashSignerListId = exports.hashAccountRoot = exports.hashTx = void 0;
  68325. const bignumber_js_1 = __importDefault(__webpack_require__(/*! bignumber.js */ "../../node_modules/bignumber.js/bignumber.js"));
  68326. const ripple_address_codec_1 = __webpack_require__(/*! ripple-address-codec */ "../../node_modules/ripple-address-codec/dist/index.js");
  68327. const hashLedger_1 = __importStar(__webpack_require__(/*! ./hashLedger */ "./dist/npm/utils/hashes/hashLedger.js"));
  68328. exports.hashLedger = hashLedger_1.default;
  68329. Object.defineProperty(exports, "hashLedgerHeader", ({ enumerable: true, get: function () { return hashLedger_1.hashLedgerHeader; } }));
  68330. Object.defineProperty(exports, "hashSignedTx", ({ enumerable: true, get: function () { return hashLedger_1.hashSignedTx; } }));
  68331. Object.defineProperty(exports, "hashTxTree", ({ enumerable: true, get: function () { return hashLedger_1.hashTxTree; } }));
  68332. Object.defineProperty(exports, "hashStateTree", ({ enumerable: true, get: function () { return hashLedger_1.hashStateTree; } }));
  68333. const HashPrefix_1 = __importDefault(__webpack_require__(/*! ./HashPrefix */ "./dist/npm/utils/hashes/HashPrefix.js"));
  68334. const ledgerSpaces_1 = __importDefault(__webpack_require__(/*! ./ledgerSpaces */ "./dist/npm/utils/hashes/ledgerSpaces.js"));
  68335. const sha512Half_1 = __importDefault(__webpack_require__(/*! ./sha512Half */ "./dist/npm/utils/hashes/sha512Half.js"));
  68336. const HEX = 16;
  68337. const BYTE_LENGTH = 4;
  68338. function addressToHex(address) {
  68339. return Buffer.from((0, ripple_address_codec_1.decodeAccountID)(address)).toString('hex');
  68340. }
  68341. function ledgerSpaceHex(name) {
  68342. return ledgerSpaces_1.default[name].charCodeAt(0).toString(HEX).padStart(4, '0');
  68343. }
  68344. const MASK = 0xff;
  68345. function currencyToHex(currency) {
  68346. if (currency.length !== 3) {
  68347. return currency;
  68348. }
  68349. const bytes = Array(20).fill(0);
  68350. bytes[12] = currency.charCodeAt(0) & MASK;
  68351. bytes[13] = currency.charCodeAt(1) & MASK;
  68352. bytes[14] = currency.charCodeAt(2) & MASK;
  68353. return Buffer.from(bytes).toString('hex');
  68354. }
  68355. function hashTx(txBlobHex) {
  68356. const prefix = HashPrefix_1.default.TRANSACTION_SIGN.toString(HEX).toUpperCase();
  68357. return (0, sha512Half_1.default)(prefix + txBlobHex);
  68358. }
  68359. exports.hashTx = hashTx;
  68360. function hashAccountRoot(address) {
  68361. return (0, sha512Half_1.default)(ledgerSpaceHex('account') + addressToHex(address));
  68362. }
  68363. exports.hashAccountRoot = hashAccountRoot;
  68364. function hashSignerListId(address) {
  68365. return (0, sha512Half_1.default)(`${ledgerSpaceHex('signerList') + addressToHex(address)}00000000`);
  68366. }
  68367. exports.hashSignerListId = hashSignerListId;
  68368. function hashOfferId(address, sequence) {
  68369. const hexPrefix = ledgerSpaces_1.default.offer
  68370. .charCodeAt(0)
  68371. .toString(HEX)
  68372. .padStart(2, '0');
  68373. const hexSequence = sequence.toString(HEX).padStart(8, '0');
  68374. const prefix = `00${hexPrefix}`;
  68375. return (0, sha512Half_1.default)(prefix + addressToHex(address) + hexSequence);
  68376. }
  68377. exports.hashOfferId = hashOfferId;
  68378. function hashTrustline(address1, address2, currency) {
  68379. const address1Hex = addressToHex(address1);
  68380. const address2Hex = addressToHex(address2);
  68381. const swap = new bignumber_js_1.default(address1Hex, 16).isGreaterThan(new bignumber_js_1.default(address2Hex, 16));
  68382. const lowAddressHex = swap ? address2Hex : address1Hex;
  68383. const highAddressHex = swap ? address1Hex : address2Hex;
  68384. const prefix = ledgerSpaceHex('rippleState');
  68385. return (0, sha512Half_1.default)(prefix + lowAddressHex + highAddressHex + currencyToHex(currency));
  68386. }
  68387. exports.hashTrustline = hashTrustline;
  68388. function hashEscrow(address, sequence) {
  68389. return (0, sha512Half_1.default)(ledgerSpaceHex('escrow') +
  68390. addressToHex(address) +
  68391. sequence.toString(HEX).padStart(BYTE_LENGTH * 2, '0'));
  68392. }
  68393. exports.hashEscrow = hashEscrow;
  68394. function hashPaymentChannel(address, dstAddress, sequence) {
  68395. return (0, sha512Half_1.default)(ledgerSpaceHex('paychan') +
  68396. addressToHex(address) +
  68397. addressToHex(dstAddress) +
  68398. sequence.toString(HEX).padStart(BYTE_LENGTH * 2, '0'));
  68399. }
  68400. exports.hashPaymentChannel = hashPaymentChannel;
  68401. /***/ }),
  68402. /***/ "./dist/npm/utils/hashes/ledgerSpaces.js":
  68403. /*!***********************************************!*\
  68404. !*** ./dist/npm/utils/hashes/ledgerSpaces.js ***!
  68405. \***********************************************/
  68406. /***/ ((__unused_webpack_module, exports) => {
  68407. "use strict";
  68408. Object.defineProperty(exports, "__esModule", ({ value: true }));
  68409. const ledgerSpaces = {
  68410. account: 'a',
  68411. dirNode: 'd',
  68412. generatorMap: 'g',
  68413. rippleState: 'r',
  68414. offer: 'o',
  68415. ownerDir: 'O',
  68416. bookDir: 'B',
  68417. contract: 'c',
  68418. skipList: 's',
  68419. escrow: 'u',
  68420. amendment: 'f',
  68421. feeSettings: 'e',
  68422. ticket: 'T',
  68423. signerList: 'S',
  68424. paychan: 'x',
  68425. check: 'C',
  68426. depositPreauth: 'p',
  68427. };
  68428. exports["default"] = ledgerSpaces;
  68429. /***/ }),
  68430. /***/ "./dist/npm/utils/hashes/sha512Half.js":
  68431. /*!*********************************************!*\
  68432. !*** ./dist/npm/utils/hashes/sha512Half.js ***!
  68433. \*********************************************/
  68434. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  68435. "use strict";
  68436. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js")["Buffer"];
  68437. Object.defineProperty(exports, "__esModule", ({ value: true }));
  68438. const crypto_1 = __webpack_require__(/*! crypto */ "../../node_modules/crypto-browserify/index.js");
  68439. const HASH_SIZE = 64;
  68440. function sha512Half(hex) {
  68441. return (0, crypto_1.createHash)('sha512')
  68442. .update(Buffer.from(hex, 'hex'))
  68443. .digest('hex')
  68444. .toUpperCase()
  68445. .slice(0, HASH_SIZE);
  68446. }
  68447. exports["default"] = sha512Half;
  68448. /***/ }),
  68449. /***/ "./dist/npm/utils/index.js":
  68450. /*!*********************************!*\
  68451. !*** ./dist/npm/utils/index.js ***!
  68452. \*********************************/
  68453. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  68454. "use strict";
  68455. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  68456. if (k2 === undefined) k2 = k;
  68457. var desc = Object.getOwnPropertyDescriptor(m, k);
  68458. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  68459. desc = { enumerable: true, get: function() { return m[k]; } };
  68460. }
  68461. Object.defineProperty(o, k2, desc);
  68462. }) : (function(o, m, k, k2) {
  68463. if (k2 === undefined) k2 = k;
  68464. o[k2] = m[k];
  68465. }));
  68466. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  68467. Object.defineProperty(o, "default", { enumerable: true, value: v });
  68468. }) : function(o, v) {
  68469. o["default"] = v;
  68470. });
  68471. var __importStar = (this && this.__importStar) || function (mod) {
  68472. if (mod && mod.__esModule) return mod;
  68473. var result = {};
  68474. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  68475. __setModuleDefault(result, mod);
  68476. return result;
  68477. };
  68478. var __importDefault = (this && this.__importDefault) || function (mod) {
  68479. return (mod && mod.__esModule) ? mod : { "default": mod };
  68480. };
  68481. Object.defineProperty(exports, "__esModule", ({ value: true }));
  68482. exports.parseNFTokenID = exports.createCrossChainPayment = exports.getNFTokenID = exports.encodeForSigningClaim = exports.encodeForSigning = exports.encodeForMultiSigning = exports.decode = exports.encode = exports.decodeXAddress = exports.encodeXAddress = exports.decodeAccountPublic = exports.encodeAccountPublic = exports.decodeNodePublic = exports.encodeNodePublic = exports.decodeAccountID = exports.encodeAccountID = exports.decodeSeed = exports.encodeSeed = exports.isValidClassicAddress = exports.isValidXAddress = exports.xAddressToClassicAddress = exports.classicAddressToXAddress = exports.convertHexToString = exports.convertStringToHex = exports.verifyPaymentChannelClaim = exports.verifyKeypairSignature = exports.signPaymentChannelClaim = exports.deriveXAddress = exports.deriveAddress = exports.deriveKeypair = exports.hashes = exports.isValidAddress = exports.isValidSecret = exports.qualityToDecimal = exports.transferRateToDecimal = exports.decimalToTransferRate = exports.percentToTransferRate = exports.decimalToQuality = exports.percentToQuality = exports.unixTimeToRippleTime = exports.rippleTimeToUnixTime = exports.isoTimeToRippleTime = exports.rippleTimeToISOTime = exports.hasNextPage = exports.xrpToDrops = exports.dropsToXrp = exports.getBalanceChanges = void 0;
  68483. const ripple_address_codec_1 = __webpack_require__(/*! ripple-address-codec */ "../../node_modules/ripple-address-codec/dist/index.js");
  68484. Object.defineProperty(exports, "classicAddressToXAddress", ({ enumerable: true, get: function () { return ripple_address_codec_1.classicAddressToXAddress; } }));
  68485. Object.defineProperty(exports, "decodeAccountID", ({ enumerable: true, get: function () { return ripple_address_codec_1.decodeAccountID; } }));
  68486. Object.defineProperty(exports, "decodeAccountPublic", ({ enumerable: true, get: function () { return ripple_address_codec_1.decodeAccountPublic; } }));
  68487. Object.defineProperty(exports, "decodeNodePublic", ({ enumerable: true, get: function () { return ripple_address_codec_1.decodeNodePublic; } }));
  68488. Object.defineProperty(exports, "decodeSeed", ({ enumerable: true, get: function () { return ripple_address_codec_1.decodeSeed; } }));
  68489. Object.defineProperty(exports, "decodeXAddress", ({ enumerable: true, get: function () { return ripple_address_codec_1.decodeXAddress; } }));
  68490. Object.defineProperty(exports, "encodeAccountID", ({ enumerable: true, get: function () { return ripple_address_codec_1.encodeAccountID; } }));
  68491. Object.defineProperty(exports, "encodeAccountPublic", ({ enumerable: true, get: function () { return ripple_address_codec_1.encodeAccountPublic; } }));
  68492. Object.defineProperty(exports, "encodeNodePublic", ({ enumerable: true, get: function () { return ripple_address_codec_1.encodeNodePublic; } }));
  68493. Object.defineProperty(exports, "encodeSeed", ({ enumerable: true, get: function () { return ripple_address_codec_1.encodeSeed; } }));
  68494. Object.defineProperty(exports, "encodeXAddress", ({ enumerable: true, get: function () { return ripple_address_codec_1.encodeXAddress; } }));
  68495. Object.defineProperty(exports, "isValidClassicAddress", ({ enumerable: true, get: function () { return ripple_address_codec_1.isValidClassicAddress; } }));
  68496. Object.defineProperty(exports, "isValidXAddress", ({ enumerable: true, get: function () { return ripple_address_codec_1.isValidXAddress; } }));
  68497. Object.defineProperty(exports, "xAddressToClassicAddress", ({ enumerable: true, get: function () { return ripple_address_codec_1.xAddressToClassicAddress; } }));
  68498. const rbc = __importStar(__webpack_require__(/*! ripple-binary-codec */ "../../node_modules/ripple-binary-codec/dist/index.js"));
  68499. const ripple_keypairs_1 = __webpack_require__(/*! ripple-keypairs */ "../../node_modules/ripple-keypairs/dist/index.js");
  68500. Object.defineProperty(exports, "verifyKeypairSignature", ({ enumerable: true, get: function () { return ripple_keypairs_1.verify; } }));
  68501. const createCrossChainPayment_1 = __importDefault(__webpack_require__(/*! ./createCrossChainPayment */ "./dist/npm/utils/createCrossChainPayment.js"));
  68502. exports.createCrossChainPayment = createCrossChainPayment_1.default;
  68503. const derive_1 = __webpack_require__(/*! ./derive */ "./dist/npm/utils/derive.js");
  68504. Object.defineProperty(exports, "deriveKeypair", ({ enumerable: true, get: function () { return derive_1.deriveKeypair; } }));
  68505. Object.defineProperty(exports, "deriveAddress", ({ enumerable: true, get: function () { return derive_1.deriveAddress; } }));
  68506. Object.defineProperty(exports, "deriveXAddress", ({ enumerable: true, get: function () { return derive_1.deriveXAddress; } }));
  68507. const getBalanceChanges_1 = __importDefault(__webpack_require__(/*! ./getBalanceChanges */ "./dist/npm/utils/getBalanceChanges.js"));
  68508. exports.getBalanceChanges = getBalanceChanges_1.default;
  68509. const getNFTokenID_1 = __importDefault(__webpack_require__(/*! ./getNFTokenID */ "./dist/npm/utils/getNFTokenID.js"));
  68510. exports.getNFTokenID = getNFTokenID_1.default;
  68511. const hashes_1 = __webpack_require__(/*! ./hashes */ "./dist/npm/utils/hashes/index.js");
  68512. const parseNFTokenID_1 = __importDefault(__webpack_require__(/*! ./parseNFTokenID */ "./dist/npm/utils/parseNFTokenID.js"));
  68513. exports.parseNFTokenID = parseNFTokenID_1.default;
  68514. const quality_1 = __webpack_require__(/*! ./quality */ "./dist/npm/utils/quality.js");
  68515. Object.defineProperty(exports, "percentToTransferRate", ({ enumerable: true, get: function () { return quality_1.percentToTransferRate; } }));
  68516. Object.defineProperty(exports, "decimalToTransferRate", ({ enumerable: true, get: function () { return quality_1.decimalToTransferRate; } }));
  68517. Object.defineProperty(exports, "transferRateToDecimal", ({ enumerable: true, get: function () { return quality_1.transferRateToDecimal; } }));
  68518. Object.defineProperty(exports, "percentToQuality", ({ enumerable: true, get: function () { return quality_1.percentToQuality; } }));
  68519. Object.defineProperty(exports, "decimalToQuality", ({ enumerable: true, get: function () { return quality_1.decimalToQuality; } }));
  68520. Object.defineProperty(exports, "qualityToDecimal", ({ enumerable: true, get: function () { return quality_1.qualityToDecimal; } }));
  68521. const signPaymentChannelClaim_1 = __importDefault(__webpack_require__(/*! ./signPaymentChannelClaim */ "./dist/npm/utils/signPaymentChannelClaim.js"));
  68522. exports.signPaymentChannelClaim = signPaymentChannelClaim_1.default;
  68523. const stringConversion_1 = __webpack_require__(/*! ./stringConversion */ "./dist/npm/utils/stringConversion.js");
  68524. Object.defineProperty(exports, "convertHexToString", ({ enumerable: true, get: function () { return stringConversion_1.convertHexToString; } }));
  68525. Object.defineProperty(exports, "convertStringToHex", ({ enumerable: true, get: function () { return stringConversion_1.convertStringToHex; } }));
  68526. const timeConversion_1 = __webpack_require__(/*! ./timeConversion */ "./dist/npm/utils/timeConversion.js");
  68527. Object.defineProperty(exports, "rippleTimeToISOTime", ({ enumerable: true, get: function () { return timeConversion_1.rippleTimeToISOTime; } }));
  68528. Object.defineProperty(exports, "isoTimeToRippleTime", ({ enumerable: true, get: function () { return timeConversion_1.isoTimeToRippleTime; } }));
  68529. Object.defineProperty(exports, "rippleTimeToUnixTime", ({ enumerable: true, get: function () { return timeConversion_1.rippleTimeToUnixTime; } }));
  68530. Object.defineProperty(exports, "unixTimeToRippleTime", ({ enumerable: true, get: function () { return timeConversion_1.unixTimeToRippleTime; } }));
  68531. const verifyPaymentChannelClaim_1 = __importDefault(__webpack_require__(/*! ./verifyPaymentChannelClaim */ "./dist/npm/utils/verifyPaymentChannelClaim.js"));
  68532. exports.verifyPaymentChannelClaim = verifyPaymentChannelClaim_1.default;
  68533. const xrpConversion_1 = __webpack_require__(/*! ./xrpConversion */ "./dist/npm/utils/xrpConversion.js");
  68534. Object.defineProperty(exports, "xrpToDrops", ({ enumerable: true, get: function () { return xrpConversion_1.xrpToDrops; } }));
  68535. Object.defineProperty(exports, "dropsToXrp", ({ enumerable: true, get: function () { return xrpConversion_1.dropsToXrp; } }));
  68536. function isValidSecret(secret) {
  68537. try {
  68538. (0, derive_1.deriveKeypair)(secret);
  68539. return true;
  68540. }
  68541. catch (_err) {
  68542. return false;
  68543. }
  68544. }
  68545. exports.isValidSecret = isValidSecret;
  68546. function encode(object) {
  68547. return rbc.encode(object);
  68548. }
  68549. exports.encode = encode;
  68550. function encodeForSigning(object) {
  68551. return rbc.encodeForSigning(object);
  68552. }
  68553. exports.encodeForSigning = encodeForSigning;
  68554. function encodeForSigningClaim(object) {
  68555. return rbc.encodeForSigningClaim(object);
  68556. }
  68557. exports.encodeForSigningClaim = encodeForSigningClaim;
  68558. function encodeForMultiSigning(object, signer) {
  68559. return rbc.encodeForMultisigning(object, signer);
  68560. }
  68561. exports.encodeForMultiSigning = encodeForMultiSigning;
  68562. function decode(hex) {
  68563. return rbc.decode(hex);
  68564. }
  68565. exports.decode = decode;
  68566. function isValidAddress(address) {
  68567. return (0, ripple_address_codec_1.isValidXAddress)(address) || (0, ripple_address_codec_1.isValidClassicAddress)(address);
  68568. }
  68569. exports.isValidAddress = isValidAddress;
  68570. function hasNextPage(response) {
  68571. return Boolean(response.result['marker']);
  68572. }
  68573. exports.hasNextPage = hasNextPage;
  68574. const hashes = {
  68575. hashSignedTx: hashes_1.hashSignedTx,
  68576. hashTx: hashes_1.hashTx,
  68577. hashAccountRoot: hashes_1.hashAccountRoot,
  68578. hashSignerListId: hashes_1.hashSignerListId,
  68579. hashOfferId: hashes_1.hashOfferId,
  68580. hashTrustline: hashes_1.hashTrustline,
  68581. hashTxTree: hashes_1.hashTxTree,
  68582. hashStateTree: hashes_1.hashStateTree,
  68583. hashLedger: hashes_1.hashLedger,
  68584. hashLedgerHeader: hashes_1.hashLedgerHeader,
  68585. hashEscrow: hashes_1.hashEscrow,
  68586. hashPaymentChannel: hashes_1.hashPaymentChannel,
  68587. };
  68588. exports.hashes = hashes;
  68589. /***/ }),
  68590. /***/ "./dist/npm/utils/parseNFTokenID.js":
  68591. /*!******************************************!*\
  68592. !*** ./dist/npm/utils/parseNFTokenID.js ***!
  68593. \******************************************/
  68594. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  68595. "use strict";
  68596. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js")["Buffer"];
  68597. var __importDefault = (this && this.__importDefault) || function (mod) {
  68598. return (mod && mod.__esModule) ? mod : { "default": mod };
  68599. };
  68600. Object.defineProperty(exports, "__esModule", ({ value: true }));
  68601. const bignumber_js_1 = __importDefault(__webpack_require__(/*! bignumber.js */ "../../node_modules/bignumber.js/bignumber.js"));
  68602. const ripple_address_codec_1 = __webpack_require__(/*! ripple-address-codec */ "../../node_modules/ripple-address-codec/dist/index.js");
  68603. const errors_1 = __webpack_require__(/*! ../errors */ "./dist/npm/errors.js");
  68604. function unscrambleTaxon(taxon, tokenSeq) {
  68605. return (taxon ^ (384160001 * tokenSeq + 2459)) % 4294967296;
  68606. }
  68607. function parseNFTokenID(nftokenID) {
  68608. const expectedLength = 64;
  68609. if (nftokenID.length !== expectedLength) {
  68610. throw new errors_1.XrplError(`Attempting to parse a nftokenID with length ${nftokenID.length}
  68611. , but expected a token with length ${expectedLength}`);
  68612. }
  68613. const scrambledTaxon = new bignumber_js_1.default(nftokenID.substring(48, 56), 16).toNumber();
  68614. const sequence = new bignumber_js_1.default(nftokenID.substring(56, 64), 16).toNumber();
  68615. const NFTokenIDData = {
  68616. NFTokenID: nftokenID,
  68617. Flags: new bignumber_js_1.default(nftokenID.substring(0, 4), 16).toNumber(),
  68618. TransferFee: new bignumber_js_1.default(nftokenID.substring(4, 8), 16).toNumber(),
  68619. Issuer: (0, ripple_address_codec_1.encodeAccountID)(Buffer.from(nftokenID.substring(8, 48), 'hex')),
  68620. Taxon: unscrambleTaxon(scrambledTaxon, sequence),
  68621. Sequence: sequence,
  68622. };
  68623. return NFTokenIDData;
  68624. }
  68625. exports["default"] = parseNFTokenID;
  68626. /***/ }),
  68627. /***/ "./dist/npm/utils/quality.js":
  68628. /*!***********************************!*\
  68629. !*** ./dist/npm/utils/quality.js ***!
  68630. \***********************************/
  68631. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  68632. "use strict";
  68633. var __importDefault = (this && this.__importDefault) || function (mod) {
  68634. return (mod && mod.__esModule) ? mod : { "default": mod };
  68635. };
  68636. Object.defineProperty(exports, "__esModule", ({ value: true }));
  68637. exports.percentToQuality = exports.transferRateToDecimal = exports.qualityToDecimal = exports.decimalToQuality = exports.percentToTransferRate = exports.decimalToTransferRate = void 0;
  68638. const bignumber_js_1 = __importDefault(__webpack_require__(/*! bignumber.js */ "../../node_modules/bignumber.js/bignumber.js"));
  68639. const errors_1 = __webpack_require__(/*! ../errors */ "./dist/npm/errors.js");
  68640. const BASE_TEN = 10;
  68641. const ONE_BILLION = '1000000000';
  68642. const TWO_BILLION = '2000000000';
  68643. function percentToDecimal(percent) {
  68644. if (!percent.endsWith('%')) {
  68645. throw new errors_1.ValidationError(`Value ${percent} must end with %`);
  68646. }
  68647. const split = percent.split('%').filter((str) => str !== '');
  68648. if (split.length !== 1) {
  68649. throw new errors_1.ValidationError(`Value ${percent} contains too many % signs`);
  68650. }
  68651. return new bignumber_js_1.default(split[0]).dividedBy('100').toString(BASE_TEN);
  68652. }
  68653. function decimalToTransferRate(decimal) {
  68654. const rate = new bignumber_js_1.default(decimal).times(ONE_BILLION).plus(ONE_BILLION);
  68655. if (rate.isLessThan(ONE_BILLION) || rate.isGreaterThan(TWO_BILLION)) {
  68656. throw new errors_1.ValidationError(`Decimal value must be between 0 and 1.00.`);
  68657. }
  68658. const billionths = rate.toString(BASE_TEN);
  68659. if (billionths === ONE_BILLION) {
  68660. return 0;
  68661. }
  68662. if (billionths === 'NaN') {
  68663. throw new errors_1.ValidationError(`Value is not a number`);
  68664. }
  68665. if (billionths.includes('.')) {
  68666. throw new errors_1.ValidationError(`Decimal exceeds maximum precision.`);
  68667. }
  68668. return Number(billionths);
  68669. }
  68670. exports.decimalToTransferRate = decimalToTransferRate;
  68671. function percentToTransferRate(percent) {
  68672. return decimalToTransferRate(percentToDecimal(percent));
  68673. }
  68674. exports.percentToTransferRate = percentToTransferRate;
  68675. function decimalToQuality(decimal) {
  68676. const rate = new bignumber_js_1.default(decimal).times(ONE_BILLION);
  68677. const billionths = rate.toString(BASE_TEN);
  68678. if (billionths === 'NaN') {
  68679. throw new errors_1.ValidationError(`Value is not a number`);
  68680. }
  68681. if (billionths.includes('-')) {
  68682. throw new errors_1.ValidationError('Cannot have negative Quality');
  68683. }
  68684. if (billionths === ONE_BILLION) {
  68685. return 0;
  68686. }
  68687. if (billionths.includes('.')) {
  68688. throw new errors_1.ValidationError(`Decimal exceeds maximum precision.`);
  68689. }
  68690. return Number(billionths);
  68691. }
  68692. exports.decimalToQuality = decimalToQuality;
  68693. function qualityToDecimal(quality) {
  68694. if (!Number.isInteger(quality)) {
  68695. throw new errors_1.ValidationError('Quality must be an integer');
  68696. }
  68697. if (quality < 0) {
  68698. throw new errors_1.ValidationError('Negative quality not allowed');
  68699. }
  68700. if (quality === 0) {
  68701. return '1';
  68702. }
  68703. const decimal = new bignumber_js_1.default(quality).dividedBy(ONE_BILLION);
  68704. return decimal.toString(BASE_TEN);
  68705. }
  68706. exports.qualityToDecimal = qualityToDecimal;
  68707. function transferRateToDecimal(rate) {
  68708. if (!Number.isInteger(rate)) {
  68709. throw new errors_1.ValidationError('Error decoding, transfer Rate must be an integer');
  68710. }
  68711. if (rate === 0) {
  68712. return '0';
  68713. }
  68714. const decimal = new bignumber_js_1.default(rate).minus(ONE_BILLION).dividedBy(ONE_BILLION);
  68715. if (decimal.isLessThan(0)) {
  68716. throw new errors_1.ValidationError('Error decoding, negative transfer rate');
  68717. }
  68718. return decimal.toString(BASE_TEN);
  68719. }
  68720. exports.transferRateToDecimal = transferRateToDecimal;
  68721. function percentToQuality(percent) {
  68722. return decimalToQuality(percentToDecimal(percent));
  68723. }
  68724. exports.percentToQuality = percentToQuality;
  68725. /***/ }),
  68726. /***/ "./dist/npm/utils/signPaymentChannelClaim.js":
  68727. /*!***************************************************!*\
  68728. !*** ./dist/npm/utils/signPaymentChannelClaim.js ***!
  68729. \***************************************************/
  68730. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  68731. "use strict";
  68732. Object.defineProperty(exports, "__esModule", ({ value: true }));
  68733. const ripple_binary_codec_1 = __webpack_require__(/*! ripple-binary-codec */ "../../node_modules/ripple-binary-codec/dist/index.js");
  68734. const ripple_keypairs_1 = __webpack_require__(/*! ripple-keypairs */ "../../node_modules/ripple-keypairs/dist/index.js");
  68735. const xrpConversion_1 = __webpack_require__(/*! ./xrpConversion */ "./dist/npm/utils/xrpConversion.js");
  68736. function signPaymentChannelClaim(channel, amount, privateKey) {
  68737. const signingData = (0, ripple_binary_codec_1.encodeForSigningClaim)({
  68738. channel,
  68739. amount: (0, xrpConversion_1.xrpToDrops)(amount),
  68740. });
  68741. return (0, ripple_keypairs_1.sign)(signingData, privateKey);
  68742. }
  68743. exports["default"] = signPaymentChannelClaim;
  68744. /***/ }),
  68745. /***/ "./dist/npm/utils/stringConversion.js":
  68746. /*!********************************************!*\
  68747. !*** ./dist/npm/utils/stringConversion.js ***!
  68748. \********************************************/
  68749. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  68750. "use strict";
  68751. /* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js")["Buffer"];
  68752. Object.defineProperty(exports, "__esModule", ({ value: true }));
  68753. exports.convertStringToHex = exports.convertHexToString = void 0;
  68754. function convertStringToHex(string) {
  68755. return Buffer.from(string, 'utf8').toString('hex').toUpperCase();
  68756. }
  68757. exports.convertStringToHex = convertStringToHex;
  68758. function convertHexToString(hex, encoding = 'utf8') {
  68759. return Buffer.from(hex, 'hex').toString(encoding);
  68760. }
  68761. exports.convertHexToString = convertHexToString;
  68762. /***/ }),
  68763. /***/ "./dist/npm/utils/timeConversion.js":
  68764. /*!******************************************!*\
  68765. !*** ./dist/npm/utils/timeConversion.js ***!
  68766. \******************************************/
  68767. /***/ ((__unused_webpack_module, exports) => {
  68768. "use strict";
  68769. Object.defineProperty(exports, "__esModule", ({ value: true }));
  68770. exports.isoTimeToRippleTime = exports.rippleTimeToISOTime = exports.unixTimeToRippleTime = exports.rippleTimeToUnixTime = void 0;
  68771. const RIPPLE_EPOCH_DIFF = 0x386d4380;
  68772. function rippleTimeToUnixTime(rpepoch) {
  68773. return (rpepoch + RIPPLE_EPOCH_DIFF) * 1000;
  68774. }
  68775. exports.rippleTimeToUnixTime = rippleTimeToUnixTime;
  68776. function unixTimeToRippleTime(timestamp) {
  68777. return Math.round(timestamp / 1000) - RIPPLE_EPOCH_DIFF;
  68778. }
  68779. exports.unixTimeToRippleTime = unixTimeToRippleTime;
  68780. function rippleTimeToISOTime(rippleTime) {
  68781. return new Date(rippleTimeToUnixTime(rippleTime)).toISOString();
  68782. }
  68783. exports.rippleTimeToISOTime = rippleTimeToISOTime;
  68784. function isoTimeToRippleTime(iso8601) {
  68785. const isoDate = typeof iso8601 === 'string' ? new Date(iso8601) : iso8601;
  68786. return unixTimeToRippleTime(isoDate.getTime());
  68787. }
  68788. exports.isoTimeToRippleTime = isoTimeToRippleTime;
  68789. /***/ }),
  68790. /***/ "./dist/npm/utils/verifyPaymentChannelClaim.js":
  68791. /*!*****************************************************!*\
  68792. !*** ./dist/npm/utils/verifyPaymentChannelClaim.js ***!
  68793. \*****************************************************/
  68794. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  68795. "use strict";
  68796. Object.defineProperty(exports, "__esModule", ({ value: true }));
  68797. const ripple_binary_codec_1 = __webpack_require__(/*! ripple-binary-codec */ "../../node_modules/ripple-binary-codec/dist/index.js");
  68798. const ripple_keypairs_1 = __webpack_require__(/*! ripple-keypairs */ "../../node_modules/ripple-keypairs/dist/index.js");
  68799. const xrpConversion_1 = __webpack_require__(/*! ./xrpConversion */ "./dist/npm/utils/xrpConversion.js");
  68800. function verifyPaymentChannelClaim(channel, amount, signature, publicKey) {
  68801. const signingData = (0, ripple_binary_codec_1.encodeForSigningClaim)({
  68802. channel,
  68803. amount: (0, xrpConversion_1.xrpToDrops)(amount),
  68804. });
  68805. return (0, ripple_keypairs_1.verify)(signingData, signature, publicKey);
  68806. }
  68807. exports["default"] = verifyPaymentChannelClaim;
  68808. /***/ }),
  68809. /***/ "./dist/npm/utils/xrpConversion.js":
  68810. /*!*****************************************!*\
  68811. !*** ./dist/npm/utils/xrpConversion.js ***!
  68812. \*****************************************/
  68813. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  68814. "use strict";
  68815. var __importDefault = (this && this.__importDefault) || function (mod) {
  68816. return (mod && mod.__esModule) ? mod : { "default": mod };
  68817. };
  68818. Object.defineProperty(exports, "__esModule", ({ value: true }));
  68819. exports.xrpToDrops = exports.dropsToXrp = void 0;
  68820. const bignumber_js_1 = __importDefault(__webpack_require__(/*! bignumber.js */ "../../node_modules/bignumber.js/bignumber.js"));
  68821. const errors_1 = __webpack_require__(/*! ../errors */ "./dist/npm/errors.js");
  68822. const DROPS_PER_XRP = 1000000.0;
  68823. const MAX_FRACTION_LENGTH = 6;
  68824. const BASE_TEN = 10;
  68825. const SANITY_CHECK = /^-?[0-9.]+$/u;
  68826. function dropsToXrp(dropsToConvert) {
  68827. const drops = new bignumber_js_1.default(dropsToConvert).toString(BASE_TEN);
  68828. if (typeof dropsToConvert === 'string' && drops === 'NaN') {
  68829. throw new errors_1.ValidationError(`dropsToXrp: invalid value '${dropsToConvert}', should be a BigNumber or string-encoded number.`);
  68830. }
  68831. if (drops.includes('.')) {
  68832. throw new errors_1.ValidationError(`dropsToXrp: value '${drops}' has too many decimal places.`);
  68833. }
  68834. if (!SANITY_CHECK.exec(drops)) {
  68835. throw new errors_1.ValidationError(`dropsToXrp: failed sanity check -` +
  68836. ` value '${drops}',` +
  68837. ` does not match (^-?[0-9]+$).`);
  68838. }
  68839. return new bignumber_js_1.default(drops).dividedBy(DROPS_PER_XRP).toString(BASE_TEN);
  68840. }
  68841. exports.dropsToXrp = dropsToXrp;
  68842. function xrpToDrops(xrpToConvert) {
  68843. const xrp = new bignumber_js_1.default(xrpToConvert).toString(BASE_TEN);
  68844. if (typeof xrpToConvert === 'string' && xrp === 'NaN') {
  68845. throw new errors_1.ValidationError(`xrpToDrops: invalid value '${xrpToConvert}', should be a BigNumber or string-encoded number.`);
  68846. }
  68847. if (!SANITY_CHECK.exec(xrp)) {
  68848. throw new errors_1.ValidationError(`xrpToDrops: failed sanity check - value '${xrp}', does not match (^-?[0-9.]+$).`);
  68849. }
  68850. const components = xrp.split('.');
  68851. if (components.length > 2) {
  68852. throw new errors_1.ValidationError(`xrpToDrops: failed sanity check - value '${xrp}' has too many decimal points.`);
  68853. }
  68854. const fraction = components[1] || '0';
  68855. if (fraction.length > MAX_FRACTION_LENGTH) {
  68856. throw new errors_1.ValidationError(`xrpToDrops: value '${xrp}' has too many decimal places.`);
  68857. }
  68858. return new bignumber_js_1.default(xrp)
  68859. .times(DROPS_PER_XRP)
  68860. .integerValue(bignumber_js_1.default.ROUND_FLOOR)
  68861. .toString(BASE_TEN);
  68862. }
  68863. exports.xrpToDrops = xrpToDrops;
  68864. /***/ }),
  68865. /***/ "?2e65":
  68866. /*!************************!*\
  68867. !*** buffer (ignored) ***!
  68868. \************************/
  68869. /***/ (() => {
  68870. /* (ignored) */
  68871. /***/ }),
  68872. /***/ "?0749":
  68873. /*!************************!*\
  68874. !*** crypto (ignored) ***!
  68875. \************************/
  68876. /***/ (() => {
  68877. /* (ignored) */
  68878. /***/ }),
  68879. /***/ "?7dc1":
  68880. /*!************************!*\
  68881. !*** buffer (ignored) ***!
  68882. \************************/
  68883. /***/ (() => {
  68884. /* (ignored) */
  68885. /***/ }),
  68886. /***/ "?1dff":
  68887. /*!**********************!*\
  68888. !*** util (ignored) ***!
  68889. \**********************/
  68890. /***/ (() => {
  68891. /* (ignored) */
  68892. /***/ }),
  68893. /***/ "?983a":
  68894. /*!**********************!*\
  68895. !*** util (ignored) ***!
  68896. \**********************/
  68897. /***/ (() => {
  68898. /* (ignored) */
  68899. /***/ }),
  68900. /***/ "?fbd7":
  68901. /*!***********************************!*\
  68902. !*** https-proxy-agent (ignored) ***!
  68903. \***********************************/
  68904. /***/ (() => {
  68905. /* (ignored) */
  68906. /***/ }),
  68907. /***/ "../../node_modules/available-typed-arrays/index.js":
  68908. /*!**********************************************************!*\
  68909. !*** ../../node_modules/available-typed-arrays/index.js ***!
  68910. \**********************************************************/
  68911. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  68912. "use strict";
  68913. var possibleNames = [
  68914. 'BigInt64Array',
  68915. 'BigUint64Array',
  68916. 'Float32Array',
  68917. 'Float64Array',
  68918. 'Int16Array',
  68919. 'Int32Array',
  68920. 'Int8Array',
  68921. 'Uint16Array',
  68922. 'Uint32Array',
  68923. 'Uint8Array',
  68924. 'Uint8ClampedArray'
  68925. ];
  68926. var g = typeof globalThis === 'undefined' ? __webpack_require__.g : globalThis;
  68927. module.exports = function availableTypedArrays() {
  68928. var out = [];
  68929. for (var i = 0; i < possibleNames.length; i++) {
  68930. if (typeof g[possibleNames[i]] === 'function') {
  68931. out[out.length] = possibleNames[i];
  68932. }
  68933. }
  68934. return out;
  68935. };
  68936. /***/ }),
  68937. /***/ "../../node_modules/bip39/src/wordlists/english.json":
  68938. /*!***********************************************************!*\
  68939. !*** ../../node_modules/bip39/src/wordlists/english.json ***!
  68940. \***********************************************************/
  68941. /***/ ((module) => {
  68942. "use strict";
  68943. module.exports = JSON.parse('["abandon","ability","able","about","above","absent","absorb","abstract","absurd","abuse","access","accident","account","accuse","achieve","acid","acoustic","acquire","across","act","action","actor","actress","actual","adapt","add","addict","address","adjust","admit","adult","advance","advice","aerobic","affair","afford","afraid","again","age","agent","agree","ahead","aim","air","airport","aisle","alarm","album","alcohol","alert","alien","all","alley","allow","almost","alone","alpha","already","also","alter","always","amateur","amazing","among","amount","amused","analyst","anchor","ancient","anger","angle","angry","animal","ankle","announce","annual","another","answer","antenna","antique","anxiety","any","apart","apology","appear","apple","approve","april","arch","arctic","area","arena","argue","arm","armed","armor","army","around","arrange","arrest","arrive","arrow","art","artefact","artist","artwork","ask","aspect","assault","asset","assist","assume","asthma","athlete","atom","attack","attend","attitude","attract","auction","audit","august","aunt","author","auto","autumn","average","avocado","avoid","awake","aware","away","awesome","awful","awkward","axis","baby","bachelor","bacon","badge","bag","balance","balcony","ball","bamboo","banana","banner","bar","barely","bargain","barrel","base","basic","basket","battle","beach","bean","beauty","because","become","beef","before","begin","behave","behind","believe","below","belt","bench","benefit","best","betray","better","between","beyond","bicycle","bid","bike","bind","biology","bird","birth","bitter","black","blade","blame","blanket","blast","bleak","bless","blind","blood","blossom","blouse","blue","blur","blush","board","boat","body","boil","bomb","bone","bonus","book","boost","border","boring","borrow","boss","bottom","bounce","box","boy","bracket","brain","brand","brass","brave","bread","breeze","brick","bridge","brief","bright","bring","brisk","broccoli","broken","bronze","broom","brother","brown","brush","bubble","buddy","budget","buffalo","build","bulb","bulk","bullet","bundle","bunker","burden","burger","burst","bus","business","busy","butter","buyer","buzz","cabbage","cabin","cable","cactus","cage","cake","call","calm","camera","camp","can","canal","cancel","candy","cannon","canoe","canvas","canyon","capable","capital","captain","car","carbon","card","cargo","carpet","carry","cart","case","cash","casino","castle","casual","cat","catalog","catch","category","cattle","caught","cause","caution","cave","ceiling","celery","cement","census","century","cereal","certain","chair","chalk","champion","change","chaos","chapter","charge","chase","chat","cheap","check","cheese","chef","cherry","chest","chicken","chief","child","chimney","choice","choose","chronic","chuckle","chunk","churn","cigar","cinnamon","circle","citizen","city","civil","claim","clap","clarify","claw","clay","clean","clerk","clever","click","client","cliff","climb","clinic","clip","clock","clog","close","cloth","cloud","clown","club","clump","cluster","clutch","coach","coast","coconut","code","coffee","coil","coin","collect","color","column","combine","come","comfort","comic","common","company","concert","conduct","confirm","congress","connect","consider","control","convince","cook","cool","copper","copy","coral","core","corn","correct","cost","cotton","couch","country","couple","course","cousin","cover","coyote","crack","cradle","craft","cram","crane","crash","crater","crawl","crazy","cream","credit","creek","crew","cricket","crime","crisp","critic","crop","cross","crouch","crowd","crucial","cruel","cruise","crumble","crunch","crush","cry","crystal","cube","culture","cup","cupboard","curious","current","curtain","curve","cushion","custom","cute","cycle","dad","damage","damp","dance","danger","daring","dash","daughter","dawn","day","deal","debate","debris","decade","december","decide","decline","decorate","decrease","deer","defense","define","defy","degree","delay","deliver","demand","demise","denial","dentist","deny","depart","depend","deposit","depth","deputy","derive","describe","desert","design","desk","despair","destroy","detail","detect","develop","device","devote","diagram","dial","diamond","diary","dice","diesel","diet","differ","digital","dignity","dilemma","dinner","dinosaur","direct","dirt","disagree","discover","disease","dish","dismiss","disorder","display","distance","divert","divide","divorce","dizzy","doctor","document","dog","doll","dolphin","domain","donate","donkey","donor","door","dose","double","dove","draft","dragon","drama","drastic","draw","dream","dress","drift","drill","drink","drip","drive","drop","drum","dry","duck","dumb","dune","during","dust","dutch","duty","dwarf","dynamic","eager","eagle","early","earn","earth","easily","east","easy","echo","ecology","economy","edge","edit","educate","effort","egg","eight","either","elbow","elder","electric","elegant","element","elephant","elevator","elite","else","embark","embody","embrace","emerge","emotion","employ","empower","empty","enable","enact","end","endless","endorse","enemy","energy","enforce","engage","engine","enhance","enjoy","enlist","enough","enrich","enroll","ensure","enter","entire","entry","envelope","episode","equal","equip","era","erase","erode","erosion","error","erupt","escape","essay","essence","estate","eternal","ethics","evidence","evil","evoke","evolve","exact","example","excess","exchange","excite","exclude","excuse","execute","exercise","exhaust","exhibit","exile","exist","exit","exotic","expand","expect","expire","explain","expose","express","extend","extra","eye","eyebrow","fabric","face","faculty","fade","faint","faith","fall","false","fame","family","famous","fan","fancy","fantasy","farm","fashion","fat","fatal","father","fatigue","fault","favorite","feature","february","federal","fee","feed","feel","female","fence","festival","fetch","fever","few","fiber","fiction","field","figure","file","film","filter","final","find","fine","finger","finish","fire","firm","first","fiscal","fish","fit","fitness","fix","flag","flame","flash","flat","flavor","flee","flight","flip","float","flock","floor","flower","fluid","flush","fly","foam","focus","fog","foil","fold","follow","food","foot","force","forest","forget","fork","fortune","forum","forward","fossil","foster","found","fox","fragile","frame","frequent","fresh","friend","fringe","frog","front","frost","frown","frozen","fruit","fuel","fun","funny","furnace","fury","future","gadget","gain","galaxy","gallery","game","gap","garage","garbage","garden","garlic","garment","gas","gasp","gate","gather","gauge","gaze","general","genius","genre","gentle","genuine","gesture","ghost","giant","gift","giggle","ginger","giraffe","girl","give","glad","glance","glare","glass","glide","glimpse","globe","gloom","glory","glove","glow","glue","goat","goddess","gold","good","goose","gorilla","gospel","gossip","govern","gown","grab","grace","grain","grant","grape","grass","gravity","great","green","grid","grief","grit","grocery","group","grow","grunt","guard","guess","guide","guilt","guitar","gun","gym","habit","hair","half","hammer","hamster","hand","happy","harbor","hard","harsh","harvest","hat","have","hawk","hazard","head","health","heart","heavy","hedgehog","height","hello","helmet","help","hen","hero","hidden","high","hill","hint","hip","hire","history","hobby","hockey","hold","hole","holiday","hollow","home","honey","hood","hope","horn","horror","horse","hospital","host","hotel","hour","hover","hub","huge","human","humble","humor","hundred","hungry","hunt","hurdle","hurry","hurt","husband","hybrid","ice","icon","idea","identify","idle","ignore","ill","illegal","illness","image","imitate","immense","immune","impact","impose","improve","impulse","inch","include","income","increase","index","indicate","indoor","industry","infant","inflict","inform","inhale","inherit","initial","inject","injury","inmate","inner","innocent","input","inquiry","insane","insect","inside","inspire","install","intact","interest","into","invest","invite","involve","iron","island","isolate","issue","item","ivory","jacket","jaguar","jar","jazz","jealous","jeans","jelly","jewel","job","join","joke","journey","joy","judge","juice","jump","jungle","junior","junk","just","kangaroo","keen","keep","ketchup","key","kick","kid","kidney","kind","kingdom","kiss","kit","kitchen","kite","kitten","kiwi","knee","knife","knock","know","lab","label","labor","ladder","lady","lake","lamp","language","laptop","large","later","latin","laugh","laundry","lava","law","lawn","lawsuit","layer","lazy","leader","leaf","learn","leave","lecture","left","leg","legal","legend","leisure","lemon","lend","length","lens","leopard","lesson","letter","level","liar","liberty","library","license","life","lift","light","like","limb","limit","link","lion","liquid","list","little","live","lizard","load","loan","lobster","local","lock","logic","lonely","long","loop","lottery","loud","lounge","love","loyal","lucky","luggage","lumber","lunar","lunch","luxury","lyrics","machine","mad","magic","magnet","maid","mail","main","major","make","mammal","man","manage","mandate","mango","mansion","manual","maple","marble","march","margin","marine","market","marriage","mask","mass","master","match","material","math","matrix","matter","maximum","maze","meadow","mean","measure","meat","mechanic","medal","media","melody","melt","member","memory","mention","menu","mercy","merge","merit","merry","mesh","message","metal","method","middle","midnight","milk","million","mimic","mind","minimum","minor","minute","miracle","mirror","misery","miss","mistake","mix","mixed","mixture","mobile","model","modify","mom","moment","monitor","monkey","monster","month","moon","moral","more","morning","mosquito","mother","motion","motor","mountain","mouse","move","movie","much","muffin","mule","multiply","muscle","museum","mushroom","music","must","mutual","myself","mystery","myth","naive","name","napkin","narrow","nasty","nation","nature","near","neck","need","negative","neglect","neither","nephew","nerve","nest","net","network","neutral","never","news","next","nice","night","noble","noise","nominee","noodle","normal","north","nose","notable","note","nothing","notice","novel","now","nuclear","number","nurse","nut","oak","obey","object","oblige","obscure","observe","obtain","obvious","occur","ocean","october","odor","off","offer","office","often","oil","okay","old","olive","olympic","omit","once","one","onion","online","only","open","opera","opinion","oppose","option","orange","orbit","orchard","order","ordinary","organ","orient","original","orphan","ostrich","other","outdoor","outer","output","outside","oval","oven","over","own","owner","oxygen","oyster","ozone","pact","paddle","page","pair","palace","palm","panda","panel","panic","panther","paper","parade","parent","park","parrot","party","pass","patch","path","patient","patrol","pattern","pause","pave","payment","peace","peanut","pear","peasant","pelican","pen","penalty","pencil","people","pepper","perfect","permit","person","pet","phone","photo","phrase","physical","piano","picnic","picture","piece","pig","pigeon","pill","pilot","pink","pioneer","pipe","pistol","pitch","pizza","place","planet","plastic","plate","play","please","pledge","pluck","plug","plunge","poem","poet","point","polar","pole","police","pond","pony","pool","popular","portion","position","possible","post","potato","pottery","poverty","powder","power","practice","praise","predict","prefer","prepare","present","pretty","prevent","price","pride","primary","print","priority","prison","private","prize","problem","process","produce","profit","program","project","promote","proof","property","prosper","protect","proud","provide","public","pudding","pull","pulp","pulse","pumpkin","punch","pupil","puppy","purchase","purity","purpose","purse","push","put","puzzle","pyramid","quality","quantum","quarter","question","quick","quit","quiz","quote","rabbit","raccoon","race","rack","radar","radio","rail","rain","raise","rally","ramp","ranch","random","range","rapid","rare","rate","rather","raven","raw","razor","ready","real","reason","rebel","rebuild","recall","receive","recipe","record","recycle","reduce","reflect","reform","refuse","region","regret","regular","reject","relax","release","relief","rely","remain","remember","remind","remove","render","renew","rent","reopen","repair","repeat","replace","report","require","rescue","resemble","resist","resource","response","result","retire","retreat","return","reunion","reveal","review","reward","rhythm","rib","ribbon","rice","rich","ride","ridge","rifle","right","rigid","ring","riot","ripple","risk","ritual","rival","river","road","roast","robot","robust","rocket","romance","roof","rookie","room","rose","rotate","rough","round","route","royal","rubber","rude","rug","rule","run","runway","rural","sad","saddle","sadness","safe","sail","salad","salmon","salon","salt","salute","same","sample","sand","satisfy","satoshi","sauce","sausage","save","say","scale","scan","scare","scatter","scene","scheme","school","science","scissors","scorpion","scout","scrap","screen","script","scrub","sea","search","season","seat","second","secret","section","security","seed","seek","segment","select","sell","seminar","senior","sense","sentence","series","service","session","settle","setup","seven","shadow","shaft","shallow","share","shed","shell","sheriff","shield","shift","shine","ship","shiver","shock","shoe","shoot","shop","short","shoulder","shove","shrimp","shrug","shuffle","shy","sibling","sick","side","siege","sight","sign","silent","silk","silly","silver","similar","simple","since","sing","siren","sister","situate","six","size","skate","sketch","ski","skill","skin","skirt","skull","slab","slam","sleep","slender","slice","slide","slight","slim","slogan","slot","slow","slush","small","smart","smile","smoke","smooth","snack","snake","snap","sniff","snow","soap","soccer","social","sock","soda","soft","solar","soldier","solid","solution","solve","someone","song","soon","sorry","sort","soul","sound","soup","source","south","space","spare","spatial","spawn","speak","special","speed","spell","spend","sphere","spice","spider","spike","spin","spirit","split","spoil","sponsor","spoon","sport","spot","spray","spread","spring","spy","square","squeeze","squirrel","stable","stadium","staff","stage","stairs","stamp","stand","start","state","stay","steak","steel","stem","step","stereo","stick","still","sting","stock","stomach","stone","stool","story","stove","strategy","street","strike","strong","struggle","student","stuff","stumble","style","subject","submit","subway","success","such","sudden","suffer","sugar","suggest","suit","summer","sun","sunny","sunset","super","supply","supreme","sure","surface","surge","surprise","surround","survey","suspect","sustain","swallow","swamp","swap","swarm","swear","sweet","swift","swim","swing","switch","sword","symbol","symptom","syrup","system","table","tackle","tag","tail","talent","talk","tank","tape","target","task","taste","tattoo","taxi","teach","team","tell","ten","tenant","tennis","tent","term","test","text","thank","that","theme","then","theory","there","they","thing","this","thought","three","thrive","throw","thumb","thunder","ticket","tide","tiger","tilt","timber","time","tiny","tip","tired","tissue","title","toast","tobacco","today","toddler","toe","together","toilet","token","tomato","tomorrow","tone","tongue","tonight","tool","tooth","top","topic","topple","torch","tornado","tortoise","toss","total","tourist","toward","tower","town","toy","track","trade","traffic","tragic","train","transfer","trap","trash","travel","tray","treat","tree","trend","trial","tribe","trick","trigger","trim","trip","trophy","trouble","truck","true","truly","trumpet","trust","truth","try","tube","tuition","tumble","tuna","tunnel","turkey","turn","turtle","twelve","twenty","twice","twin","twist","two","type","typical","ugly","umbrella","unable","unaware","uncle","uncover","under","undo","unfair","unfold","unhappy","uniform","unique","unit","universe","unknown","unlock","until","unusual","unveil","update","upgrade","uphold","upon","upper","upset","urban","urge","usage","use","used","useful","useless","usual","utility","vacant","vacuum","vague","valid","valley","valve","van","vanish","vapor","various","vast","vault","vehicle","velvet","vendor","venture","venue","verb","verify","version","very","vessel","veteran","viable","vibrant","vicious","victory","video","view","village","vintage","violin","virtual","virus","visa","visit","visual","vital","vivid","vocal","voice","void","volcano","volume","vote","voyage","wage","wagon","wait","walk","wall","walnut","want","warfare","warm","warrior","wash","wasp","waste","water","wave","way","wealth","weapon","wear","weasel","weather","web","wedding","weekend","weird","welcome","west","wet","whale","what","wheat","wheel","when","where","whip","whisper","wide","width","wife","wild","will","win","window","wine","wing","wink","winner","winter","wire","wisdom","wise","wish","witness","wolf","woman","wonder","wood","wool","word","work","world","worry","worth","wrap","wreck","wrestle","wrist","write","wrong","yard","year","yellow","you","young","youth","zebra","zero","zone","zoo"]');
  68944. /***/ }),
  68945. /***/ "../../node_modules/browserify-aes/modes/list.json":
  68946. /*!*********************************************************!*\
  68947. !*** ../../node_modules/browserify-aes/modes/list.json ***!
  68948. \*********************************************************/
  68949. /***/ ((module) => {
  68950. "use strict";
  68951. module.exports = JSON.parse('{"aes-128-ecb":{"cipher":"AES","key":128,"iv":0,"mode":"ECB","type":"block"},"aes-192-ecb":{"cipher":"AES","key":192,"iv":0,"mode":"ECB","type":"block"},"aes-256-ecb":{"cipher":"AES","key":256,"iv":0,"mode":"ECB","type":"block"},"aes-128-cbc":{"cipher":"AES","key":128,"iv":16,"mode":"CBC","type":"block"},"aes-192-cbc":{"cipher":"AES","key":192,"iv":16,"mode":"CBC","type":"block"},"aes-256-cbc":{"cipher":"AES","key":256,"iv":16,"mode":"CBC","type":"block"},"aes128":{"cipher":"AES","key":128,"iv":16,"mode":"CBC","type":"block"},"aes192":{"cipher":"AES","key":192,"iv":16,"mode":"CBC","type":"block"},"aes256":{"cipher":"AES","key":256,"iv":16,"mode":"CBC","type":"block"},"aes-128-cfb":{"cipher":"AES","key":128,"iv":16,"mode":"CFB","type":"stream"},"aes-192-cfb":{"cipher":"AES","key":192,"iv":16,"mode":"CFB","type":"stream"},"aes-256-cfb":{"cipher":"AES","key":256,"iv":16,"mode":"CFB","type":"stream"},"aes-128-cfb8":{"cipher":"AES","key":128,"iv":16,"mode":"CFB8","type":"stream"},"aes-192-cfb8":{"cipher":"AES","key":192,"iv":16,"mode":"CFB8","type":"stream"},"aes-256-cfb8":{"cipher":"AES","key":256,"iv":16,"mode":"CFB8","type":"stream"},"aes-128-cfb1":{"cipher":"AES","key":128,"iv":16,"mode":"CFB1","type":"stream"},"aes-192-cfb1":{"cipher":"AES","key":192,"iv":16,"mode":"CFB1","type":"stream"},"aes-256-cfb1":{"cipher":"AES","key":256,"iv":16,"mode":"CFB1","type":"stream"},"aes-128-ofb":{"cipher":"AES","key":128,"iv":16,"mode":"OFB","type":"stream"},"aes-192-ofb":{"cipher":"AES","key":192,"iv":16,"mode":"OFB","type":"stream"},"aes-256-ofb":{"cipher":"AES","key":256,"iv":16,"mode":"OFB","type":"stream"},"aes-128-ctr":{"cipher":"AES","key":128,"iv":16,"mode":"CTR","type":"stream"},"aes-192-ctr":{"cipher":"AES","key":192,"iv":16,"mode":"CTR","type":"stream"},"aes-256-ctr":{"cipher":"AES","key":256,"iv":16,"mode":"CTR","type":"stream"},"aes-128-gcm":{"cipher":"AES","key":128,"iv":12,"mode":"GCM","type":"auth"},"aes-192-gcm":{"cipher":"AES","key":192,"iv":12,"mode":"GCM","type":"auth"},"aes-256-gcm":{"cipher":"AES","key":256,"iv":12,"mode":"GCM","type":"auth"}}');
  68952. /***/ }),
  68953. /***/ "../../node_modules/browserify-sign/browser/algorithms.json":
  68954. /*!******************************************************************!*\
  68955. !*** ../../node_modules/browserify-sign/browser/algorithms.json ***!
  68956. \******************************************************************/
  68957. /***/ ((module) => {
  68958. "use strict";
  68959. module.exports = JSON.parse('{"sha224WithRSAEncryption":{"sign":"rsa","hash":"sha224","id":"302d300d06096086480165030402040500041c"},"RSA-SHA224":{"sign":"ecdsa/rsa","hash":"sha224","id":"302d300d06096086480165030402040500041c"},"sha256WithRSAEncryption":{"sign":"rsa","hash":"sha256","id":"3031300d060960864801650304020105000420"},"RSA-SHA256":{"sign":"ecdsa/rsa","hash":"sha256","id":"3031300d060960864801650304020105000420"},"sha384WithRSAEncryption":{"sign":"rsa","hash":"sha384","id":"3041300d060960864801650304020205000430"},"RSA-SHA384":{"sign":"ecdsa/rsa","hash":"sha384","id":"3041300d060960864801650304020205000430"},"sha512WithRSAEncryption":{"sign":"rsa","hash":"sha512","id":"3051300d060960864801650304020305000440"},"RSA-SHA512":{"sign":"ecdsa/rsa","hash":"sha512","id":"3051300d060960864801650304020305000440"},"RSA-SHA1":{"sign":"rsa","hash":"sha1","id":"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{"sign":"ecdsa","hash":"sha1","id":""},"sha256":{"sign":"ecdsa","hash":"sha256","id":""},"sha224":{"sign":"ecdsa","hash":"sha224","id":""},"sha384":{"sign":"ecdsa","hash":"sha384","id":""},"sha512":{"sign":"ecdsa","hash":"sha512","id":""},"DSA-SHA":{"sign":"dsa","hash":"sha1","id":""},"DSA-SHA1":{"sign":"dsa","hash":"sha1","id":""},"DSA":{"sign":"dsa","hash":"sha1","id":""},"DSA-WITH-SHA224":{"sign":"dsa","hash":"sha224","id":""},"DSA-SHA224":{"sign":"dsa","hash":"sha224","id":""},"DSA-WITH-SHA256":{"sign":"dsa","hash":"sha256","id":""},"DSA-SHA256":{"sign":"dsa","hash":"sha256","id":""},"DSA-WITH-SHA384":{"sign":"dsa","hash":"sha384","id":""},"DSA-SHA384":{"sign":"dsa","hash":"sha384","id":""},"DSA-WITH-SHA512":{"sign":"dsa","hash":"sha512","id":""},"DSA-SHA512":{"sign":"dsa","hash":"sha512","id":""},"DSA-RIPEMD160":{"sign":"dsa","hash":"rmd160","id":""},"ripemd160WithRSA":{"sign":"rsa","hash":"rmd160","id":"3021300906052b2403020105000414"},"RSA-RIPEMD160":{"sign":"rsa","hash":"rmd160","id":"3021300906052b2403020105000414"},"md5WithRSAEncryption":{"sign":"rsa","hash":"md5","id":"3020300c06082a864886f70d020505000410"},"RSA-MD5":{"sign":"rsa","hash":"md5","id":"3020300c06082a864886f70d020505000410"}}');
  68960. /***/ }),
  68961. /***/ "../../node_modules/browserify-sign/browser/curves.json":
  68962. /*!**************************************************************!*\
  68963. !*** ../../node_modules/browserify-sign/browser/curves.json ***!
  68964. \**************************************************************/
  68965. /***/ ((module) => {
  68966. "use strict";
  68967. module.exports = JSON.parse('{"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}');
  68968. /***/ }),
  68969. /***/ "../../node_modules/diffie-hellman/lib/primes.json":
  68970. /*!*********************************************************!*\
  68971. !*** ../../node_modules/diffie-hellman/lib/primes.json ***!
  68972. \*********************************************************/
  68973. /***/ ((module) => {
  68974. "use strict";
  68975. module.exports = JSON.parse('{"modp1":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},"modp2":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},"modp5":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},"modp14":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},"modp15":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},"modp16":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},"modp17":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},"modp18":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}');
  68976. /***/ }),
  68977. /***/ "../../node_modules/elliptic/package.json":
  68978. /*!************************************************!*\
  68979. !*** ../../node_modules/elliptic/package.json ***!
  68980. \************************************************/
  68981. /***/ ((module) => {
  68982. "use strict";
  68983. module.exports = JSON.parse('{"name":"elliptic","version":"6.5.4","description":"EC cryptography","main":"lib/elliptic.js","files":["lib"],"scripts":{"lint":"eslint lib test","lint:fix":"npm run lint -- --fix","unit":"istanbul test _mocha --reporter=spec test/index.js","test":"npm run lint && npm run unit","version":"grunt dist && git add dist/"},"repository":{"type":"git","url":"git@github.com:indutny/elliptic"},"keywords":["EC","Elliptic","curve","Cryptography"],"author":"Fedor Indutny <fedor@indutny.com>","license":"MIT","bugs":{"url":"https://github.com/indutny/elliptic/issues"},"homepage":"https://github.com/indutny/elliptic","devDependencies":{"brfs":"^2.0.2","coveralls":"^3.1.0","eslint":"^7.6.0","grunt":"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1","istanbul":"^0.4.5","mocha":"^8.0.1"},"dependencies":{"bn.js":"^4.11.9","brorand":"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1","inherits":"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"}}');
  68984. /***/ }),
  68985. /***/ "../../node_modules/parse-asn1/aesid.json":
  68986. /*!************************************************!*\
  68987. !*** ../../node_modules/parse-asn1/aesid.json ***!
  68988. \************************************************/
  68989. /***/ ((module) => {
  68990. "use strict";
  68991. module.exports = JSON.parse('{"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}');
  68992. /***/ }),
  68993. /***/ "../../node_modules/ripple-binary-codec/dist/enums/definitions.json":
  68994. /*!**************************************************************************!*\
  68995. !*** ../../node_modules/ripple-binary-codec/dist/enums/definitions.json ***!
  68996. \**************************************************************************/
  68997. /***/ ((module) => {
  68998. "use strict";
  68999. module.exports = JSON.parse('{"TYPES":{"Done":-1,"Unknown":-2,"NotPresent":0,"UInt16":1,"UInt32":2,"UInt64":3,"Hash128":4,"Hash256":5,"Amount":6,"Blob":7,"AccountID":8,"STObject":14,"STArray":15,"UInt8":16,"Hash160":17,"PathSet":18,"Vector256":19,"UInt96":20,"UInt192":21,"UInt384":22,"UInt512":23,"Transaction":10001,"LedgerEntry":10002,"Validation":10003,"Metadata":10004},"LEDGER_ENTRY_TYPES":{"Invalid":-1,"AccountRoot":97,"DirectoryNode":100,"RippleState":114,"Ticket":84,"SignerList":83,"Offer":111,"LedgerHashes":104,"Amendments":102,"FeeSettings":115,"Escrow":117,"PayChannel":120,"Check":67,"DepositPreauth":112,"NegativeUNL":78,"NFTokenPage":80,"NFTokenOffer":55,"Any":-3,"Child":-2,"Nickname":110,"Contract":99,"GeneratorMap":103},"FIELDS":[["Generic",{"nth":0,"isVLEncoded":false,"isSerialized":false,"isSigningField":false,"type":"Unknown"}],["Invalid",{"nth":-1,"isVLEncoded":false,"isSerialized":false,"isSigningField":false,"type":"Unknown"}],["ObjectEndMarker",{"nth":1,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STObject"}],["ArrayEndMarker",{"nth":1,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STArray"}],["hash",{"nth":257,"isVLEncoded":false,"isSerialized":false,"isSigningField":false,"type":"Hash256"}],["index",{"nth":258,"isVLEncoded":false,"isSerialized":false,"isSigningField":false,"type":"Hash256"}],["taker_gets_funded",{"nth":258,"isVLEncoded":false,"isSerialized":false,"isSigningField":false,"type":"Amount"}],["taker_pays_funded",{"nth":259,"isVLEncoded":false,"isSerialized":false,"isSigningField":false,"type":"Amount"}],["LedgerEntry",{"nth":1,"isVLEncoded":false,"isSerialized":false,"isSigningField":true,"type":"LedgerEntry"}],["Transaction",{"nth":1,"isVLEncoded":false,"isSerialized":false,"isSigningField":true,"type":"Transaction"}],["Validation",{"nth":1,"isVLEncoded":false,"isSerialized":false,"isSigningField":true,"type":"Validation"}],["Metadata",{"nth":1,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Metadata"}],["CloseResolution",{"nth":1,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt8"}],["Method",{"nth":2,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt8"}],["TransactionResult",{"nth":3,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt8"}],["TickSize",{"nth":16,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt8"}],["UNLModifyDisabling",{"nth":17,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt8"}],["HookResult",{"nth":18,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt8"}],["LedgerEntryType",{"nth":1,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt16"}],["TransactionType",{"nth":2,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt16"}],["SignerWeight",{"nth":3,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt16"}],["TransferFee",{"nth":4,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt16"}],["Version",{"nth":16,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt16"}],["HookStateChangeCount",{"nth":17,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt16"}],["HookEmitCount",{"nth":18,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt16"}],["HookExecutionIndex",{"nth":19,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt16"}],["HookApiVersion",{"nth":20,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt16"}],["Flags",{"nth":2,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["SourceTag",{"nth":3,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["Sequence",{"nth":4,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["PreviousTxnLgrSeq",{"nth":5,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["LedgerSequence",{"nth":6,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["CloseTime",{"nth":7,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["ParentCloseTime",{"nth":8,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["SigningTime",{"nth":9,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["Expiration",{"nth":10,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["TransferRate",{"nth":11,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["WalletSize",{"nth":12,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["OwnerCount",{"nth":13,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["DestinationTag",{"nth":14,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["HighQualityIn",{"nth":16,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["HighQualityOut",{"nth":17,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["LowQualityIn",{"nth":18,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["LowQualityOut",{"nth":19,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["QualityIn",{"nth":20,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["QualityOut",{"nth":21,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["StampEscrow",{"nth":22,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["BondAmount",{"nth":23,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["LoadFee",{"nth":24,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["OfferSequence",{"nth":25,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["FirstLedgerSequence",{"nth":26,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["LastLedgerSequence",{"nth":27,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["TransactionIndex",{"nth":28,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["OperationLimit",{"nth":29,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["ReferenceFeeUnits",{"nth":30,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["ReserveBase",{"nth":31,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["ReserveIncrement",{"nth":32,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["SetFlag",{"nth":33,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["ClearFlag",{"nth":34,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["SignerQuorum",{"nth":35,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["CancelAfter",{"nth":36,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["FinishAfter",{"nth":37,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["SignerListID",{"nth":38,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["SettleDelay",{"nth":39,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["TicketCount",{"nth":40,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["TicketSequence",{"nth":41,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["NFTokenTaxon",{"nth":42,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["MintedNFTokens",{"nth":43,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["BurnedNFTokens",{"nth":44,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["HookStateCount",{"nth":45,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["EmitGeneration",{"nth":46,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt32"}],["IndexNext",{"nth":1,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt64"}],["IndexPrevious",{"nth":2,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt64"}],["BookNode",{"nth":3,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt64"}],["OwnerNode",{"nth":4,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt64"}],["BaseFee",{"nth":5,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt64"}],["ExchangeRate",{"nth":6,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt64"}],["LowNode",{"nth":7,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt64"}],["HighNode",{"nth":8,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt64"}],["DestinationNode",{"nth":9,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt64"}],["Cookie",{"nth":10,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt64"}],["ServerVersion",{"nth":11,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt64"}],["NFTokenOfferNode",{"nth":12,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt64"}],["EmitBurden",{"nth":13,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt64"}],["HookOn",{"nth":16,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt64"}],["HookInstructionCount",{"nth":17,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt64"}],["HookReturnCode",{"nth":18,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt64"}],["ReferenceCount",{"nth":19,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"UInt64"}],["EmailHash",{"nth":1,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash128"}],["TakerPaysCurrency",{"nth":1,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash160"}],["TakerPaysIssuer",{"nth":2,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash160"}],["TakerGetsCurrency",{"nth":3,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash160"}],["TakerGetsIssuer",{"nth":4,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash160"}],["LedgerHash",{"nth":1,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash256"}],["ParentHash",{"nth":2,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash256"}],["TransactionHash",{"nth":3,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash256"}],["AccountHash",{"nth":4,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash256"}],["PreviousTxnID",{"nth":5,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash256"}],["LedgerIndex",{"nth":6,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash256"}],["WalletLocator",{"nth":7,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash256"}],["RootIndex",{"nth":8,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash256"}],["AccountTxnID",{"nth":9,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash256"}],["NFTokenID",{"nth":10,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash256"}],["EmitParentTxnID",{"nth":11,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash256"}],["EmitNonce",{"nth":12,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash256"}],["EmitHookHash",{"nth":13,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash256"}],["BookDirectory",{"nth":16,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash256"}],["InvoiceID",{"nth":17,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash256"}],["Nickname",{"nth":18,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash256"}],["Amendment",{"nth":19,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash256"}],["Digest",{"nth":21,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash256"}],["Channel",{"nth":22,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash256"}],["ConsensusHash",{"nth":23,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash256"}],["CheckID",{"nth":24,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash256"}],["ValidatedHash",{"nth":25,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash256"}],["PreviousPageMin",{"nth":26,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash256"}],["NextPageMin",{"nth":27,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash256"}],["NFTokenBuyOffer",{"nth":28,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash256"}],["NFTokenSellOffer",{"nth":29,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash256"}],["HookStateKey",{"nth":30,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash256"}],["HookHash",{"nth":31,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash256"}],["HookNamespace",{"nth":32,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash256"}],["HookSetTxnID",{"nth":33,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Hash256"}],["Amount",{"nth":1,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Amount"}],["Balance",{"nth":2,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Amount"}],["LimitAmount",{"nth":3,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Amount"}],["TakerPays",{"nth":4,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Amount"}],["TakerGets",{"nth":5,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Amount"}],["LowLimit",{"nth":6,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Amount"}],["HighLimit",{"nth":7,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Amount"}],["Fee",{"nth":8,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Amount"}],["SendMax",{"nth":9,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Amount"}],["DeliverMin",{"nth":10,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Amount"}],["MinimumOffer",{"nth":16,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Amount"}],["RippleEscrow",{"nth":17,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Amount"}],["DeliveredAmount",{"nth":18,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Amount"}],["NFTokenBrokerFee",{"nth":19,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"Amount"}],["PublicKey",{"nth":1,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"Blob"}],["MessageKey",{"nth":2,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"Blob"}],["SigningPubKey",{"nth":3,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"Blob"}],["TxnSignature",{"nth":4,"isVLEncoded":true,"isSerialized":true,"isSigningField":false,"type":"Blob"}],["URI",{"nth":5,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"Blob"}],["Signature",{"nth":6,"isVLEncoded":true,"isSerialized":true,"isSigningField":false,"type":"Blob"}],["Domain",{"nth":7,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"Blob"}],["FundCode",{"nth":8,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"Blob"}],["RemoveCode",{"nth":9,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"Blob"}],["ExpireCode",{"nth":10,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"Blob"}],["CreateCode",{"nth":11,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"Blob"}],["MemoType",{"nth":12,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"Blob"}],["MemoData",{"nth":13,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"Blob"}],["MemoFormat",{"nth":14,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"Blob"}],["Fulfillment",{"nth":16,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"Blob"}],["Condition",{"nth":17,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"Blob"}],["MasterSignature",{"nth":18,"isVLEncoded":true,"isSerialized":true,"isSigningField":false,"type":"Blob"}],["UNLModifyValidator",{"nth":19,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"Blob"}],["ValidatorToDisable",{"nth":20,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"Blob"}],["ValidatorToReEnable",{"nth":21,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"Blob"}],["HookStateData",{"nth":22,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"Blob"}],["HookReturnString",{"nth":23,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"Blob"}],["HookParameterName",{"nth":24,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"Blob"}],["HookParameterValue",{"nth":25,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"Blob"}],["Account",{"nth":1,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"AccountID"}],["Owner",{"nth":2,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"AccountID"}],["Destination",{"nth":3,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"AccountID"}],["Issuer",{"nth":4,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"AccountID"}],["Authorize",{"nth":5,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"AccountID"}],["Unauthorize",{"nth":6,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"AccountID"}],["RegularKey",{"nth":8,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"AccountID"}],["NFTokenMinter",{"nth":9,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"AccountID"}],["EmitCallback",{"nth":10,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"AccountID"}],["HookAccount",{"nth":16,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"AccountID"}],["Indexes",{"nth":1,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"Vector256"}],["Hashes",{"nth":2,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"Vector256"}],["Amendments",{"nth":3,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"Vector256"}],["NFTokenOffers",{"nth":4,"isVLEncoded":true,"isSerialized":true,"isSigningField":true,"type":"Vector256"}],["Paths",{"nth":1,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"PathSet"}],["TransactionMetaData",{"nth":2,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STObject"}],["CreatedNode",{"nth":3,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STObject"}],["DeletedNode",{"nth":4,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STObject"}],["ModifiedNode",{"nth":5,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STObject"}],["PreviousFields",{"nth":6,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STObject"}],["FinalFields",{"nth":7,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STObject"}],["NewFields",{"nth":8,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STObject"}],["TemplateEntry",{"nth":9,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STObject"}],["Memo",{"nth":10,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STObject"}],["SignerEntry",{"nth":11,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STObject"}],["NFToken",{"nth":12,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STObject"}],["EmitDetails",{"nth":13,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STObject"}],["Hook",{"nth":14,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STObject"}],["Signer",{"nth":16,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STObject"}],["Majority",{"nth":18,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STObject"}],["DisabledValidator",{"nth":19,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STObject"}],["EmittedTxn",{"nth":20,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STObject"}],["HookExecution",{"nth":21,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STObject"}],["HookDefinition",{"nth":22,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STObject"}],["HookParameter",{"nth":23,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STObject"}],["HookGrant",{"nth":24,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STObject"}],["Signers",{"nth":3,"isVLEncoded":false,"isSerialized":true,"isSigningField":false,"type":"STArray"}],["SignerEntries",{"nth":4,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STArray"}],["Template",{"nth":5,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STArray"}],["Necessary",{"nth":6,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STArray"}],["Sufficient",{"nth":7,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STArray"}],["AffectedNodes",{"nth":8,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STArray"}],["Memos",{"nth":9,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STArray"}],["NFTokens",{"nth":10,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STArray"}],["Hooks",{"nth":11,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STArray"}],["Majorities",{"nth":16,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STArray"}],["DisabledValidators",{"nth":17,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STArray"}],["HookExecutions",{"nth":18,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STArray"}],["HookParameters",{"nth":19,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STArray"}],["HookGrants",{"nth":20,"isVLEncoded":false,"isSerialized":true,"isSigningField":true,"type":"STArray"}]],"TRANSACTION_RESULTS":{"telLOCAL_ERROR":-399,"telBAD_DOMAIN":-398,"telBAD_PATH_COUNT":-397,"telBAD_PUBLIC_KEY":-396,"telFAILED_PROCESSING":-395,"telINSUF_FEE_P":-394,"telNO_DST_PARTIAL":-393,"telCAN_NOT_QUEUE":-392,"telCAN_NOT_QUEUE_BALANCE":-391,"telCAN_NOT_QUEUE_BLOCKS":-390,"telCAN_NOT_QUEUE_BLOCKED":-389,"telCAN_NOT_QUEUE_FEE":-388,"telCAN_NOT_QUEUE_FULL":-387,"temMALFORMED":-299,"temBAD_AMOUNT":-298,"temBAD_CURRENCY":-297,"temBAD_EXPIRATION":-296,"temBAD_FEE":-295,"temBAD_ISSUER":-294,"temBAD_LIMIT":-293,"temBAD_OFFER":-292,"temBAD_PATH":-291,"temBAD_PATH_LOOP":-290,"temBAD_REGKEY":-289,"temBAD_SEND_XRP_LIMIT":-288,"temBAD_SEND_XRP_MAX":-287,"temBAD_SEND_XRP_NO_DIRECT":-286,"temBAD_SEND_XRP_PARTIAL":-285,"temBAD_SEND_XRP_PATHS":-284,"temBAD_SEQUENCE":-283,"temBAD_SIGNATURE":-282,"temBAD_SRC_ACCOUNT":-281,"temBAD_TRANSFER_RATE":-280,"temDST_IS_SRC":-279,"temDST_NEEDED":-278,"temINVALID":-277,"temINVALID_FLAG":-276,"temREDUNDANT":-275,"temRIPPLE_EMPTY":-274,"temDISABLED":-273,"temBAD_SIGNER":-272,"temBAD_QUORUM":-271,"temBAD_WEIGHT":-270,"temBAD_TICK_SIZE":-269,"temINVALID_ACCOUNT_ID":-268,"temCANNOT_PREAUTH_SELF":-267,"temINVALID_COUNT":-266,"temUNCERTAIN":-265,"temUNKNOWN":-264,"temSEQ_AND_TICKET":-263,"temBAD_NFTOKEN_TRANSFER_FEE":-262,"tefFAILURE":-199,"tefALREADY":-198,"tefBAD_ADD_AUTH":-197,"tefBAD_AUTH":-196,"tefBAD_LEDGER":-195,"tefCREATED":-194,"tefEXCEPTION":-193,"tefINTERNAL":-192,"tefNO_AUTH_REQUIRED":-191,"tefPAST_SEQ":-190,"tefWRONG_PRIOR":-189,"tefMASTER_DISABLED":-188,"tefMAX_LEDGER":-187,"tefBAD_SIGNATURE":-186,"tefBAD_QUORUM":-185,"tefNOT_MULTI_SIGNING":-184,"tefBAD_AUTH_MASTER":-183,"tefINVARIANT_FAILED":-182,"tefTOO_BIG":-181,"tefNO_TICKET":-180,"tefNFTOKEN_IS_NOT_TRANSFERABLE":-179,"terRETRY":-99,"terFUNDS_SPENT":-98,"terINSUF_FEE_B":-97,"terNO_ACCOUNT":-96,"terNO_AUTH":-95,"terNO_LINE":-94,"terOWNERS":-93,"terPRE_SEQ":-92,"terLAST":-91,"terNO_RIPPLE":-90,"terQUEUED":-89,"terPRE_TICKET":-88,"tesSUCCESS":0,"tecCLAIM":100,"tecPATH_PARTIAL":101,"tecUNFUNDED_ADD":102,"tecUNFUNDED_OFFER":103,"tecUNFUNDED_PAYMENT":104,"tecFAILED_PROCESSING":105,"tecDIR_FULL":121,"tecINSUF_RESERVE_LINE":122,"tecINSUF_RESERVE_OFFER":123,"tecNO_DST":124,"tecNO_DST_INSUF_XRP":125,"tecNO_LINE_INSUF_RESERVE":126,"tecNO_LINE_REDUNDANT":127,"tecPATH_DRY":128,"tecUNFUNDED":129,"tecNO_ALTERNATIVE_KEY":130,"tecNO_REGULAR_KEY":131,"tecOWNERS":132,"tecNO_ISSUER":133,"tecNO_AUTH":134,"tecNO_LINE":135,"tecINSUFF_FEE":136,"tecFROZEN":137,"tecNO_TARGET":138,"tecNO_PERMISSION":139,"tecNO_ENTRY":140,"tecINSUFFICIENT_RESERVE":141,"tecNEED_MASTER_KEY":142,"tecDST_TAG_NEEDED":143,"tecINTERNAL":144,"tecOVERSIZE":145,"tecCRYPTOCONDITION_ERROR":146,"tecINVARIANT_FAILED":147,"tecEXPIRED":148,"tecDUPLICATE":149,"tecKILLED":150,"tecHAS_OBLIGATIONS":151,"tecTOO_SOON":152,"tecMAX_SEQUENCE_REACHED":154,"tecNO_SUITABLE_NFTOKEN_PAGE":155,"tecNFTOKEN_BUY_SELL_MISMATCH":156,"tecNFTOKEN_OFFER_TYPE_MISMATCH":157,"tecCANT_ACCEPT_OWN_NFTOKEN_OFFER":158,"tecINSUFFICIENT_FUNDS":159,"tecOBJECT_NOT_FOUND":160,"tecINSUFFICIENT_PAYMENT":161},"TRANSACTION_TYPES":{"Invalid":-1,"Payment":0,"EscrowCreate":1,"EscrowFinish":2,"AccountSet":3,"EscrowCancel":4,"SetRegularKey":5,"NickNameSet":6,"OfferCreate":7,"OfferCancel":8,"Contract":9,"TicketCreate":10,"TicketCancel":11,"SignerListSet":12,"PaymentChannelCreate":13,"PaymentChannelFund":14,"PaymentChannelClaim":15,"CheckCreate":16,"CheckCash":17,"CheckCancel":18,"DepositPreauth":19,"TrustSet":20,"AccountDelete":21,"SetHook":22,"NFTokenMint":25,"NFTokenBurn":26,"NFTokenCreateOffer":27,"NFTokenCancelOffer":28,"NFTokenAcceptOffer":29,"EnableAmendment":100,"SetFee":101,"UNLModify":102}}');
  69000. /***/ }),
  69001. /***/ "./dist/npm/Wallet/rfc1751Words.json":
  69002. /*!*******************************************!*\
  69003. !*** ./dist/npm/Wallet/rfc1751Words.json ***!
  69004. \*******************************************/
  69005. /***/ ((module) => {
  69006. "use strict";
  69007. module.exports = JSON.parse('["A","ABE","ACE","ACT","AD","ADA","ADD","AGO","AID","AIM","AIR","ALL","ALP","AM","AMY","AN","ANA","AND","ANN","ANT","ANY","APE","APS","APT","ARC","ARE","ARK","ARM","ART","AS","ASH","ASK","AT","ATE","AUG","AUK","AVE","AWE","AWK","AWL","AWN","AX","AYE","BAD","BAG","BAH","BAM","BAN","BAR","BAT","BAY","BE","BED","BEE","BEG","BEN","BET","BEY","BIB","BID","BIG","BIN","BIT","BOB","BOG","BON","BOO","BOP","BOW","BOY","BUB","BUD","BUG","BUM","BUN","BUS","BUT","BUY","BY","BYE","CAB","CAL","CAM","CAN","CAP","CAR","CAT","CAW","COD","COG","COL","CON","COO","COP","COT","COW","COY","CRY","CUB","CUE","CUP","CUR","CUT","DAB","DAD","DAM","DAN","DAR","DAY","DEE","DEL","DEN","DES","DEW","DID","DIE","DIG","DIN","DIP","DO","DOE","DOG","DON","DOT","DOW","DRY","DUB","DUD","DUE","DUG","DUN","EAR","EAT","ED","EEL","EGG","EGO","ELI","ELK","ELM","ELY","EM","END","EST","ETC","EVA","EVE","EWE","EYE","FAD","FAN","FAR","FAT","FAY","FED","FEE","FEW","FIB","FIG","FIN","FIR","FIT","FLO","FLY","FOE","FOG","FOR","FRY","FUM","FUN","FUR","GAB","GAD","GAG","GAL","GAM","GAP","GAS","GAY","GEE","GEL","GEM","GET","GIG","GIL","GIN","GO","GOT","GUM","GUN","GUS","GUT","GUY","GYM","GYP","HA","HAD","HAL","HAM","HAN","HAP","HAS","HAT","HAW","HAY","HE","HEM","HEN","HER","HEW","HEY","HI","HID","HIM","HIP","HIS","HIT","HO","HOB","HOC","HOE","HOG","HOP","HOT","HOW","HUB","HUE","HUG","HUH","HUM","HUT","I","ICY","IDA","IF","IKE","ILL","INK","INN","IO","ION","IQ","IRA","IRE","IRK","IS","IT","ITS","IVY","JAB","JAG","JAM","JAN","JAR","JAW","JAY","JET","JIG","JIM","JO","JOB","JOE","JOG","JOT","JOY","JUG","JUT","KAY","KEG","KEN","KEY","KID","KIM","KIN","KIT","LA","LAB","LAC","LAD","LAG","LAM","LAP","LAW","LAY","LEA","LED","LEE","LEG","LEN","LEO","LET","LEW","LID","LIE","LIN","LIP","LIT","LO","LOB","LOG","LOP","LOS","LOT","LOU","LOW","LOY","LUG","LYE","MA","MAC","MAD","MAE","MAN","MAO","MAP","MAT","MAW","MAY","ME","MEG","MEL","MEN","MET","MEW","MID","MIN","MIT","MOB","MOD","MOE","MOO","MOP","MOS","MOT","MOW","MUD","MUG","MUM","MY","NAB","NAG","NAN","NAP","NAT","NAY","NE","NED","NEE","NET","NEW","NIB","NIL","NIP","NIT","NO","NOB","NOD","NON","NOR","NOT","NOV","NOW","NU","NUN","NUT","O","OAF","OAK","OAR","OAT","ODD","ODE","OF","OFF","OFT","OH","OIL","OK","OLD","ON","ONE","OR","ORB","ORE","ORR","OS","OTT","OUR","OUT","OVA","OW","OWE","OWL","OWN","OX","PA","PAD","PAL","PAM","PAN","PAP","PAR","PAT","PAW","PAY","PEA","PEG","PEN","PEP","PER","PET","PEW","PHI","PI","PIE","PIN","PIT","PLY","PO","POD","POE","POP","POT","POW","PRO","PRY","PUB","PUG","PUN","PUP","PUT","QUO","RAG","RAM","RAN","RAP","RAT","RAW","RAY","REB","RED","REP","RET","RIB","RID","RIG","RIM","RIO","RIP","ROB","ROD","ROE","RON","ROT","ROW","ROY","RUB","RUE","RUG","RUM","RUN","RYE","SAC","SAD","SAG","SAL","SAM","SAN","SAP","SAT","SAW","SAY","SEA","SEC","SEE","SEN","SET","SEW","SHE","SHY","SIN","SIP","SIR","SIS","SIT","SKI","SKY","SLY","SO","SOB","SOD","SON","SOP","SOW","SOY","SPA","SPY","SUB","SUD","SUE","SUM","SUN","SUP","TAB","TAD","TAG","TAN","TAP","TAR","TEA","TED","TEE","TEN","THE","THY","TIC","TIE","TIM","TIN","TIP","TO","TOE","TOG","TOM","TON","TOO","TOP","TOW","TOY","TRY","TUB","TUG","TUM","TUN","TWO","UN","UP","US","USE","VAN","VAT","VET","VIE","WAD","WAG","WAR","WAS","WAY","WE","WEB","WED","WEE","WET","WHO","WHY","WIN","WIT","WOK","WON","WOO","WOW","WRY","WU","YAM","YAP","YAW","YE","YEA","YES","YET","YOU","ABED","ABEL","ABET","ABLE","ABUT","ACHE","ACID","ACME","ACRE","ACTA","ACTS","ADAM","ADDS","ADEN","AFAR","AFRO","AGEE","AHEM","AHOY","AIDA","AIDE","AIDS","AIRY","AJAR","AKIN","ALAN","ALEC","ALGA","ALIA","ALLY","ALMA","ALOE","ALSO","ALTO","ALUM","ALVA","AMEN","AMES","AMID","AMMO","AMOK","AMOS","AMRA","ANDY","ANEW","ANNA","ANNE","ANTE","ANTI","AQUA","ARAB","ARCH","AREA","ARGO","ARID","ARMY","ARTS","ARTY","ASIA","ASKS","ATOM","AUNT","AURA","AUTO","AVER","AVID","AVIS","AVON","AVOW","AWAY","AWRY","BABE","BABY","BACH","BACK","BADE","BAIL","BAIT","BAKE","BALD","BALE","BALI","BALK","BALL","BALM","BAND","BANE","BANG","BANK","BARB","BARD","BARE","BARK","BARN","BARR","BASE","BASH","BASK","BASS","BATE","BATH","BAWD","BAWL","BEAD","BEAK","BEAM","BEAN","BEAR","BEAT","BEAU","BECK","BEEF","BEEN","BEER","BEET","BELA","BELL","BELT","BEND","BENT","BERG","BERN","BERT","BESS","BEST","BETA","BETH","BHOY","BIAS","BIDE","BIEN","BILE","BILK","BILL","BIND","BING","BIRD","BITE","BITS","BLAB","BLAT","BLED","BLEW","BLOB","BLOC","BLOT","BLOW","BLUE","BLUM","BLUR","BOAR","BOAT","BOCA","BOCK","BODE","BODY","BOGY","BOHR","BOIL","BOLD","BOLO","BOLT","BOMB","BONA","BOND","BONE","BONG","BONN","BONY","BOOK","BOOM","BOON","BOOT","BORE","BORG","BORN","BOSE","BOSS","BOTH","BOUT","BOWL","BOYD","BRAD","BRAE","BRAG","BRAN","BRAY","BRED","BREW","BRIG","BRIM","BROW","BUCK","BUDD","BUFF","BULB","BULK","BULL","BUNK","BUNT","BUOY","BURG","BURL","BURN","BURR","BURT","BURY","BUSH","BUSS","BUST","BUSY","BYTE","CADY","CAFE","CAGE","CAIN","CAKE","CALF","CALL","CALM","CAME","CANE","CANT","CARD","CARE","CARL","CARR","CART","CASE","CASH","CASK","CAST","CAVE","CEIL","CELL","CENT","CERN","CHAD","CHAR","CHAT","CHAW","CHEF","CHEN","CHEW","CHIC","CHIN","CHOU","CHOW","CHUB","CHUG","CHUM","CITE","CITY","CLAD","CLAM","CLAN","CLAW","CLAY","CLOD","CLOG","CLOT","CLUB","CLUE","COAL","COAT","COCA","COCK","COCO","CODA","CODE","CODY","COED","COIL","COIN","COKE","COLA","COLD","COLT","COMA","COMB","COME","COOK","COOL","COON","COOT","CORD","CORE","CORK","CORN","COST","COVE","COWL","CRAB","CRAG","CRAM","CRAY","CREW","CRIB","CROW","CRUD","CUBA","CUBE","CUFF","CULL","CULT","CUNY","CURB","CURD","CURE","CURL","CURT","CUTS","DADE","DALE","DAME","DANA","DANE","DANG","DANK","DARE","DARK","DARN","DART","DASH","DATA","DATE","DAVE","DAVY","DAWN","DAYS","DEAD","DEAF","DEAL","DEAN","DEAR","DEBT","DECK","DEED","DEEM","DEER","DEFT","DEFY","DELL","DENT","DENY","DESK","DIAL","DICE","DIED","DIET","DIME","DINE","DING","DINT","DIRE","DIRT","DISC","DISH","DISK","DIVE","DOCK","DOES","DOLE","DOLL","DOLT","DOME","DONE","DOOM","DOOR","DORA","DOSE","DOTE","DOUG","DOUR","DOVE","DOWN","DRAB","DRAG","DRAM","DRAW","DREW","DRUB","DRUG","DRUM","DUAL","DUCK","DUCT","DUEL","DUET","DUKE","DULL","DUMB","DUNE","DUNK","DUSK","DUST","DUTY","EACH","EARL","EARN","EASE","EAST","EASY","EBEN","ECHO","EDDY","EDEN","EDGE","EDGY","EDIT","EDNA","EGAN","ELAN","ELBA","ELLA","ELSE","EMIL","EMIT","EMMA","ENDS","ERIC","EROS","EVEN","EVER","EVIL","EYED","FACE","FACT","FADE","FAIL","FAIN","FAIR","FAKE","FALL","FAME","FANG","FARM","FAST","FATE","FAWN","FEAR","FEAT","FEED","FEEL","FEET","FELL","FELT","FEND","FERN","FEST","FEUD","FIEF","FIGS","FILE","FILL","FILM","FIND","FINE","FINK","FIRE","FIRM","FISH","FISK","FIST","FITS","FIVE","FLAG","FLAK","FLAM","FLAT","FLAW","FLEA","FLED","FLEW","FLIT","FLOC","FLOG","FLOW","FLUB","FLUE","FOAL","FOAM","FOGY","FOIL","FOLD","FOLK","FOND","FONT","FOOD","FOOL","FOOT","FORD","FORE","FORK","FORM","FORT","FOSS","FOUL","FOUR","FOWL","FRAU","FRAY","FRED","FREE","FRET","FREY","FROG","FROM","FUEL","FULL","FUME","FUND","FUNK","FURY","FUSE","FUSS","GAFF","GAGE","GAIL","GAIN","GAIT","GALA","GALE","GALL","GALT","GAME","GANG","GARB","GARY","GASH","GATE","GAUL","GAUR","GAVE","GAWK","GEAR","GELD","GENE","GENT","GERM","GETS","GIBE","GIFT","GILD","GILL","GILT","GINA","GIRD","GIRL","GIST","GIVE","GLAD","GLEE","GLEN","GLIB","GLOB","GLOM","GLOW","GLUE","GLUM","GLUT","GOAD","GOAL","GOAT","GOER","GOES","GOLD","GOLF","GONE","GONG","GOOD","GOOF","GORE","GORY","GOSH","GOUT","GOWN","GRAB","GRAD","GRAY","GREG","GREW","GREY","GRID","GRIM","GRIN","GRIT","GROW","GRUB","GULF","GULL","GUNK","GURU","GUSH","GUST","GWEN","GWYN","HAAG","HAAS","HACK","HAIL","HAIR","HALE","HALF","HALL","HALO","HALT","HAND","HANG","HANK","HANS","HARD","HARK","HARM","HART","HASH","HAST","HATE","HATH","HAUL","HAVE","HAWK","HAYS","HEAD","HEAL","HEAR","HEAT","HEBE","HECK","HEED","HEEL","HEFT","HELD","HELL","HELM","HERB","HERD","HERE","HERO","HERS","HESS","HEWN","HICK","HIDE","HIGH","HIKE","HILL","HILT","HIND","HINT","HIRE","HISS","HIVE","HOBO","HOCK","HOFF","HOLD","HOLE","HOLM","HOLT","HOME","HONE","HONK","HOOD","HOOF","HOOK","HOOT","HORN","HOSE","HOST","HOUR","HOVE","HOWE","HOWL","HOYT","HUCK","HUED","HUFF","HUGE","HUGH","HUGO","HULK","HULL","HUNK","HUNT","HURD","HURL","HURT","HUSH","HYDE","HYMN","IBIS","ICON","IDEA","IDLE","IFFY","INCA","INCH","INTO","IONS","IOTA","IOWA","IRIS","IRMA","IRON","ISLE","ITCH","ITEM","IVAN","JACK","JADE","JAIL","JAKE","JANE","JAVA","JEAN","JEFF","JERK","JESS","JEST","JIBE","JILL","JILT","JIVE","JOAN","JOBS","JOCK","JOEL","JOEY","JOHN","JOIN","JOKE","JOLT","JOVE","JUDD","JUDE","JUDO","JUDY","JUJU","JUKE","JULY","JUNE","JUNK","JUNO","JURY","JUST","JUTE","KAHN","KALE","KANE","KANT","KARL","KATE","KEEL","KEEN","KENO","KENT","KERN","KERR","KEYS","KICK","KILL","KIND","KING","KIRK","KISS","KITE","KLAN","KNEE","KNEW","KNIT","KNOB","KNOT","KNOW","KOCH","KONG","KUDO","KURD","KURT","KYLE","LACE","LACK","LACY","LADY","LAID","LAIN","LAIR","LAKE","LAMB","LAME","LAND","LANE","LANG","LARD","LARK","LASS","LAST","LATE","LAUD","LAVA","LAWN","LAWS","LAYS","LEAD","LEAF","LEAK","LEAN","LEAR","LEEK","LEER","LEFT","LEND","LENS","LENT","LEON","LESK","LESS","LEST","LETS","LIAR","LICE","LICK","LIED","LIEN","LIES","LIEU","LIFE","LIFT","LIKE","LILA","LILT","LILY","LIMA","LIMB","LIME","LIND","LINE","LINK","LINT","LION","LISA","LIST","LIVE","LOAD","LOAF","LOAM","LOAN","LOCK","LOFT","LOGE","LOIS","LOLA","LONE","LONG","LOOK","LOON","LOOT","LORD","LORE","LOSE","LOSS","LOST","LOUD","LOVE","LOWE","LUCK","LUCY","LUGE","LUKE","LULU","LUND","LUNG","LURA","LURE","LURK","LUSH","LUST","LYLE","LYNN","LYON","LYRA","MACE","MADE","MAGI","MAID","MAIL","MAIN","MAKE","MALE","MALI","MALL","MALT","MANA","MANN","MANY","MARC","MARE","MARK","MARS","MART","MARY","MASH","MASK","MASS","MAST","MATE","MATH","MAUL","MAYO","MEAD","MEAL","MEAN","MEAT","MEEK","MEET","MELD","MELT","MEMO","MEND","MENU","MERT","MESH","MESS","MICE","MIKE","MILD","MILE","MILK","MILL","MILT","MIMI","MIND","MINE","MINI","MINK","MINT","MIRE","MISS","MIST","MITE","MITT","MOAN","MOAT","MOCK","MODE","MOLD","MOLE","MOLL","MOLT","MONA","MONK","MONT","MOOD","MOON","MOOR","MOOT","MORE","MORN","MORT","MOSS","MOST","MOTH","MOVE","MUCH","MUCK","MUDD","MUFF","MULE","MULL","MURK","MUSH","MUST","MUTE","MUTT","MYRA","MYTH","NAGY","NAIL","NAIR","NAME","NARY","NASH","NAVE","NAVY","NEAL","NEAR","NEAT","NECK","NEED","NEIL","NELL","NEON","NERO","NESS","NEST","NEWS","NEWT","NIBS","NICE","NICK","NILE","NINA","NINE","NOAH","NODE","NOEL","NOLL","NONE","NOOK","NOON","NORM","NOSE","NOTE","NOUN","NOVA","NUDE","NULL","NUMB","OATH","OBEY","OBOE","ODIN","OHIO","OILY","OINT","OKAY","OLAF","OLDY","OLGA","OLIN","OMAN","OMEN","OMIT","ONCE","ONES","ONLY","ONTO","ONUS","ORAL","ORGY","OSLO","OTIS","OTTO","OUCH","OUST","OUTS","OVAL","OVEN","OVER","OWLY","OWNS","QUAD","QUIT","QUOD","RACE","RACK","RACY","RAFT","RAGE","RAID","RAIL","RAIN","RAKE","RANK","RANT","RARE","RASH","RATE","RAVE","RAYS","READ","REAL","REAM","REAR","RECK","REED","REEF","REEK","REEL","REID","REIN","RENA","REND","RENT","REST","RICE","RICH","RICK","RIDE","RIFT","RILL","RIME","RING","RINK","RISE","RISK","RITE","ROAD","ROAM","ROAR","ROBE","ROCK","RODE","ROIL","ROLL","ROME","ROOD","ROOF","ROOK","ROOM","ROOT","ROSA","ROSE","ROSS","ROSY","ROTH","ROUT","ROVE","ROWE","ROWS","RUBE","RUBY","RUDE","RUDY","RUIN","RULE","RUNG","RUNS","RUNT","RUSE","RUSH","RUSK","RUSS","RUST","RUTH","SACK","SAFE","SAGE","SAID","SAIL","SALE","SALK","SALT","SAME","SAND","SANE","SANG","SANK","SARA","SAUL","SAVE","SAYS","SCAN","SCAR","SCAT","SCOT","SEAL","SEAM","SEAR","SEAT","SEED","SEEK","SEEM","SEEN","SEES","SELF","SELL","SEND","SENT","SETS","SEWN","SHAG","SHAM","SHAW","SHAY","SHED","SHIM","SHIN","SHOD","SHOE","SHOT","SHOW","SHUN","SHUT","SICK","SIDE","SIFT","SIGH","SIGN","SILK","SILL","SILO","SILT","SINE","SING","SINK","SIRE","SITE","SITS","SITU","SKAT","SKEW","SKID","SKIM","SKIN","SKIT","SLAB","SLAM","SLAT","SLAY","SLED","SLEW","SLID","SLIM","SLIT","SLOB","SLOG","SLOT","SLOW","SLUG","SLUM","SLUR","SMOG","SMUG","SNAG","SNOB","SNOW","SNUB","SNUG","SOAK","SOAR","SOCK","SODA","SOFA","SOFT","SOIL","SOLD","SOME","SONG","SOON","SOOT","SORE","SORT","SOUL","SOUR","SOWN","STAB","STAG","STAN","STAR","STAY","STEM","STEW","STIR","STOW","STUB","STUN","SUCH","SUDS","SUIT","SULK","SUMS","SUNG","SUNK","SURE","SURF","SWAB","SWAG","SWAM","SWAN","SWAT","SWAY","SWIM","SWUM","TACK","TACT","TAIL","TAKE","TALE","TALK","TALL","TANK","TASK","TATE","TAUT","TEAL","TEAM","TEAR","TECH","TEEM","TEEN","TEET","TELL","TEND","TENT","TERM","TERN","TESS","TEST","THAN","THAT","THEE","THEM","THEN","THEY","THIN","THIS","THUD","THUG","TICK","TIDE","TIDY","TIED","TIER","TILE","TILL","TILT","TIME","TINA","TINE","TINT","TINY","TIRE","TOAD","TOGO","TOIL","TOLD","TOLL","TONE","TONG","TONY","TOOK","TOOL","TOOT","TORE","TORN","TOTE","TOUR","TOUT","TOWN","TRAG","TRAM","TRAY","TREE","TREK","TRIG","TRIM","TRIO","TROD","TROT","TROY","TRUE","TUBA","TUBE","TUCK","TUFT","TUNA","TUNE","TUNG","TURF","TURN","TUSK","TWIG","TWIN","TWIT","ULAN","UNIT","URGE","USED","USER","USES","UTAH","VAIL","VAIN","VALE","VARY","VASE","VAST","VEAL","VEDA","VEIL","VEIN","VEND","VENT","VERB","VERY","VETO","VICE","VIEW","VINE","VISE","VOID","VOLT","VOTE","WACK","WADE","WAGE","WAIL","WAIT","WAKE","WALE","WALK","WALL","WALT","WAND","WANE","WANG","WANT","WARD","WARM","WARN","WART","WASH","WAST","WATS","WATT","WAVE","WAVY","WAYS","WEAK","WEAL","WEAN","WEAR","WEED","WEEK","WEIR","WELD","WELL","WELT","WENT","WERE","WERT","WEST","WHAM","WHAT","WHEE","WHEN","WHET","WHOA","WHOM","WICK","WIFE","WILD","WILL","WIND","WINE","WING","WINK","WINO","WIRE","WISE","WISH","WITH","WOLF","WONT","WOOD","WOOL","WORD","WORE","WORK","WORM","WORN","WOVE","WRIT","WYNN","YALE","YANG","YANK","YARD","YARN","YAWL","YAWN","YEAH","YEAR","YELL","YOGA","YOKE"]');
  69008. /***/ })
  69009. /******/ });
  69010. /************************************************************************/
  69011. /******/ // The module cache
  69012. /******/ var __webpack_module_cache__ = {};
  69013. /******/
  69014. /******/ // The require function
  69015. /******/ function __webpack_require__(moduleId) {
  69016. /******/ // Check if module is in cache
  69017. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  69018. /******/ if (cachedModule !== undefined) {
  69019. /******/ return cachedModule.exports;
  69020. /******/ }
  69021. /******/ // Create a new module (and put it into the cache)
  69022. /******/ var module = __webpack_module_cache__[moduleId] = {
  69023. /******/ id: moduleId,
  69024. /******/ loaded: false,
  69025. /******/ exports: {}
  69026. /******/ };
  69027. /******/
  69028. /******/ // Execute the module function
  69029. /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  69030. /******/
  69031. /******/ // Flag the module as loaded
  69032. /******/ module.loaded = true;
  69033. /******/
  69034. /******/ // Return the exports of the module
  69035. /******/ return module.exports;
  69036. /******/ }
  69037. /******/
  69038. /************************************************************************/
  69039. /******/ /* webpack/runtime/global */
  69040. /******/ (() => {
  69041. /******/ __webpack_require__.g = (function() {
  69042. /******/ if (typeof globalThis === 'object') return globalThis;
  69043. /******/ try {
  69044. /******/ return this || new Function('return this')();
  69045. /******/ } catch (e) {
  69046. /******/ if (typeof window === 'object') return window;
  69047. /******/ }
  69048. /******/ })();
  69049. /******/ })();
  69050. /******/
  69051. /******/ /* webpack/runtime/node module decorator */
  69052. /******/ (() => {
  69053. /******/ __webpack_require__.nmd = (module) => {
  69054. /******/ module.paths = [];
  69055. /******/ if (!module.children) module.children = [];
  69056. /******/ return module;
  69057. /******/ };
  69058. /******/ })();
  69059. /******/
  69060. /************************************************************************/
  69061. /******/
  69062. /******/ // startup
  69063. /******/ // Load entry module and return exports
  69064. /******/ // This entry module is referenced by other modules so it can't be inlined
  69065. /******/ var __webpack_exports__ = __webpack_require__("./dist/npm/index.js");
  69066. /******/ xrpl = __webpack_exports__;
  69067. /******/
  69068. /******/ })()
  69069. ;
  69070. //# sourceMappingURL=xrpl-latest.js.map