app.js 2.8 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076840778407884079840808408184082840838408484085840868408784088840898409084091840928409384094840958409684097840988409984100841018410284103841048410584106841078410884109841108411184112841138411484115841168411784118841198412084121841228412384124841258412684127841288412984130841318413284133841348413584136841378413884139841408414184142841438414484145841468414784148841498415084151841528415384154841558415684157841588415984160841618416284163841648416584166841678416884169841708417184172841738417484175841768417784178841798418084181841828418384184841858418684187841888418984190841918419284193841948419584196841978419884199842008420184202842038420484205842068420784208842098421084211842128421384214842158421684217842188421984220842218422284223842248422584226842278422884229842308423184232842338423484235842368423784238842398424084241842428424384244842458424684247842488424984250842518425284253842548425584256842578425884259842608426184262842638426484265842668426784268842698427084271842728427384274842758427684277842788427984280842818428284283842848428584286842878428884289842908429184292842938429484295842968429784298842998430084301843028430384304843058430684307843088430984310843118431284313843148431584316843178431884319843208432184322843238432484325843268432784328843298433084331843328433384334843358433684337843388433984340843418434284343843448434584346843478434884349843508435184352843538435484355843568435784358843598436084361843628436384364843658436684367843688436984370843718437284373843748437584376843778437884379843808438184382843838438484385843868438784388843898439084391843928439384394843958439684397843988439984400844018440284403844048440584406844078440884409844108441184412844138441484415844168441784418844198442084421844228442384424844258442684427844288442984430844318443284433844348443584436844378443884439844408444184442844438444484445844468444784448844498445084451844528445384454844558445684457844588445984460844618446284463844648446584466844678446884469844708447184472844738447484475844768447784478844798448084481844828448384484844858448684487844888448984490844918449284493844948449584496844978449884499845008450184502845038450484505845068450784508845098451084511845128451384514845158451684517845188451984520845218452284523845248452584526845278452884529845308453184532845338453484535845368453784538845398454084541845428454384544845458454684547845488454984550845518455284553845548455584556845578455884559845608456184562845638456484565845668456784568845698457084571845728457384574845758457684577845788457984580845818458284583845848458584586845878458884589845908459184592845938459484595845968459784598845998460084601846028460384604846058460684607846088460984610846118461284613846148461584616846178461884619846208462184622846238462484625846268462784628846298463084631846328463384634846358463684637846388463984640846418464284643846448464584646846478464884649846508465184652846538465484655846568465784658846598466084661846628466384664846658466684667846688466984670846718467284673846748467584676846778467884679846808468184682846838468484685846868468784688846898469084691846928469384694846958469684697846988469984700847018470284703847048470584706847078470884709847108471184712847138471484715847168471784718847198472084721847228472384724847258472684727847288472984730847318473284733847348473584736847378473884739847408474184742847438474484745847468474784748847498475084751847528475384754847558475684757847588475984760847618476284763847648476584766847678476884769847708477184772847738477484775847768477784778847798478084781847828478384784847858478684787847888478984790847918479284793847948479584796847978479884799848008480184802848038480484805848068480784808848098481084811848128481384814848158481684817848188481984820848218482284823848248482584826848278482884829848308483184832848338483484835848368483784838848398484084841848428484384844848458484684847848488484984850848518485284853848548485584856848578485884859848608486184862848638486484865848668486784868848698487084871848728487384874848758487684877848788487984880848818488284883848848488584886848878488884889848908489184892848938489484895848968489784898848998490084901849028490384904849058490684907849088490984910849118491284913849148491584916849178491884919849208492184922849238492484925849268492784928849298493084931849328493384934849358493684937849388493984940849418494284943849448494584946849478494884949849508495184952849538495484955849568495784958849598496084961849628496384964849658496684967849688496984970849718497284973849748497584976849778497884979849808498184982849838498484985849868498784988849898499084991849928499384994849958499684997849988499985000850018500285003850048500585006850078500885009850108501185012850138501485015850168501785018850198502085021850228502385024850258502685027850288502985030850318503285033850348503585036850378503885039850408504185042850438504485045850468504785048850498505085051850528505385054850558505685057850588505985060850618506285063850648506585066850678506885069850708507185072850738507485075850768507785078850798508085081850828508385084850858508685087850888508985090850918509285093850948509585096850978509885099851008510185102851038510485105851068510785108851098511085111851128511385114851158511685117851188511985120851218512285123851248512585126851278512885129851308513185132851338513485135851368513785138851398514085141851428514385144851458514685147851488514985150851518515285153851548515585156851578515885159851608516185162851638516485165851668516785168851698517085171851728517385174851758517685177851788517985180851818518285183851848518585186851878518885189851908519185192851938519485195851968519785198851998520085201852028520385204852058520685207852088520985210852118521285213852148521585216852178521885219852208522185222852238522485225852268522785228852298523085231852328523385234852358523685237852388523985240852418524285243852448524585246852478524885249852508525185252852538525485255852568525785258852598526085261852628526385264852658526685267852688526985270852718527285273852748527585276852778527885279852808528185282852838528485285852868528785288852898529085291852928529385294852958529685297852988529985300853018530285303853048530585306853078530885309853108531185312853138531485315853168531785318853198532085321853228532385324853258532685327853288532985330853318533285333853348533585336853378533885339853408534185342853438534485345853468534785348853498535085351853528535385354853558535685357853588535985360853618536285363853648536585366853678536885369853708537185372853738537485375853768537785378853798538085381853828538385384853858538685387853888538985390853918539285393853948539585396853978539885399854008540185402854038540485405854068540785408854098541085411854128541385414854158541685417854188541985420854218542285423854248542585426854278542885429854308543185432854338543485435854368543785438854398544085441854428544385444854458544685447854488544985450854518545285453854548545585456854578545885459854608546185462854638546485465854668546785468854698547085471854728547385474854758547685477854788547985480854818548285483854848548585486854878548885489854908549185492854938549485495854968549785498854998550085501855028550385504855058550685507855088550985510855118551285513855148551585516855178551885519855208552185522855238552485525855268552785528855298553085531855328553385534855358553685537855388553985540855418554285543855448554585546855478554885549855508555185552855538555485555855568555785558855598556085561855628556385564855658556685567855688556985570855718557285573855748557585576855778557885579855808558185582855838558485585855868558785588855898559085591855928559385594855958559685597855988559985600856018560285603856048560585606856078560885609856108561185612856138561485615856168561785618856198562085621856228562385624856258562685627856288562985630856318563285633856348563585636856378563885639856408564185642856438564485645856468564785648856498565085651856528565385654856558565685657856588565985660856618566285663856648566585666856678566885669856708567185672856738567485675856768567785678856798568085681856828568385684856858568685687856888568985690856918569285693856948569585696856978569885699857008570185702857038570485705857068570785708857098571085711857128571385714857158571685717857188571985720857218572285723857248572585726857278572885729857308573185732857338573485735857368573785738857398574085741857428574385744857458574685747857488574985750857518575285753857548575585756857578575885759857608576185762857638576485765857668576785768857698577085771857728577385774857758577685777857788577985780857818578285783857848578585786857878578885789857908579185792857938579485795857968579785798857998580085801858028580385804858058580685807858088580985810858118581285813858148581585816858178581885819858208582185822858238582485825858268582785828858298583085831858328583385834858358583685837858388583985840858418584285843858448584585846858478584885849858508585185852858538585485855858568585785858858598586085861858628586385864858658586685867858688586985870858718587285873858748587585876858778587885879858808588185882858838588485885858868588785888858898589085891858928589385894858958589685897858988589985900859018590285903859048590585906859078590885909859108591185912859138591485915859168591785918859198592085921859228592385924859258592685927859288592985930859318593285933859348593585936859378593885939859408594185942859438594485945859468594785948859498595085951859528595385954859558595685957859588595985960859618596285963859648596585966859678596885969859708597185972859738597485975859768597785978859798598085981859828598385984859858598685987859888598985990859918599285993859948599585996859978599885999860008600186002860038600486005860068600786008860098601086011860128601386014860158601686017860188601986020860218602286023860248602586026860278602886029860308603186032860338603486035860368603786038860398604086041860428604386044860458604686047860488604986050860518605286053860548605586056860578605886059860608606186062860638606486065860668606786068860698607086071860728607386074860758607686077860788607986080860818608286083860848608586086860878608886089860908609186092860938609486095860968609786098860998610086101861028610386104861058610686107861088610986110861118611286113861148611586116861178611886119861208612186122861238612486125861268612786128861298613086131861328613386134861358613686137861388613986140861418614286143861448614586146861478614886149861508615186152861538615486155861568615786158861598616086161861628616386164861658616686167861688616986170861718617286173861748617586176861778617886179861808618186182861838618486185861868618786188861898619086191861928619386194861958619686197861988619986200862018620286203862048620586206862078620886209862108621186212862138621486215862168621786218862198622086221862228622386224862258622686227862288622986230862318623286233862348623586236862378623886239862408624186242862438624486245862468624786248862498625086251862528625386254862558625686257862588625986260862618626286263862648626586266862678626886269862708627186272862738627486275862768627786278862798628086281862828628386284862858628686287862888628986290862918629286293862948629586296862978629886299863008630186302863038630486305863068630786308863098631086311863128631386314863158631686317863188631986320863218632286323863248632586326863278632886329863308633186332863338633486335863368633786338863398634086341863428634386344863458634686347863488634986350863518635286353863548635586356863578635886359863608636186362863638636486365863668636786368863698637086371863728637386374863758637686377863788637986380863818638286383863848638586386863878638886389863908639186392863938639486395863968639786398863998640086401864028640386404864058640686407864088640986410864118641286413864148641586416864178641886419864208642186422864238642486425864268642786428864298643086431864328643386434864358643686437864388643986440864418644286443864448644586446864478644886449864508645186452864538645486455864568645786458864598646086461864628646386464864658646686467864688646986470864718647286473864748647586476864778647886479864808648186482864838648486485864868648786488864898649086491864928649386494864958649686497864988649986500865018650286503865048650586506865078650886509865108651186512865138651486515865168651786518865198652086521865228652386524865258652686527865288652986530865318653286533865348653586536865378653886539865408654186542865438654486545865468654786548865498655086551865528655386554865558655686557865588655986560865618656286563865648656586566865678656886569865708657186572865738657486575865768657786578865798658086581865828658386584865858658686587865888658986590865918659286593865948659586596865978659886599866008660186602866038660486605866068660786608866098661086611866128661386614866158661686617866188661986620866218662286623866248662586626866278662886629866308663186632866338663486635866368663786638866398664086641866428664386644866458664686647866488664986650866518665286653866548665586656866578665886659866608666186662866638666486665866668666786668866698667086671866728667386674866758667686677866788667986680866818668286683866848668586686866878668886689866908669186692866938669486695866968669786698866998670086701867028670386704867058670686707867088670986710867118671286713867148671586716867178671886719867208672186722867238672486725867268672786728867298673086731867328673386734867358673686737867388673986740867418674286743867448674586746867478674886749867508675186752867538675486755867568675786758867598676086761867628676386764867658676686767867688676986770867718677286773867748677586776867778677886779867808678186782867838678486785867868678786788867898679086791867928679386794867958679686797867988679986800868018680286803868048680586806868078680886809868108681186812868138681486815868168681786818868198682086821868228682386824868258682686827868288682986830868318683286833868348683586836868378683886839868408684186842868438684486845868468684786848868498685086851868528685386854868558685686857868588685986860868618686286863868648686586866868678686886869868708687186872868738687486875868768687786878868798688086881868828688386884868858688686887868888688986890868918689286893868948689586896868978689886899869008690186902869038690486905869068690786908869098691086911869128691386914869158691686917869188691986920869218692286923869248692586926869278692886929869308693186932869338693486935869368693786938869398694086941869428694386944869458694686947869488694986950869518695286953869548695586956869578695886959869608696186962869638696486965869668696786968869698697086971869728697386974869758697686977869788697986980869818698286983869848698586986869878698886989869908699186992869938699486995869968699786998869998700087001870028700387004870058700687007870088700987010870118701287013870148701587016870178701887019870208702187022870238702487025870268702787028870298703087031870328703387034870358703687037870388703987040870418704287043870448704587046870478704887049870508705187052870538705487055870568705787058870598706087061870628706387064870658706687067870688706987070870718707287073870748707587076870778707887079870808708187082870838708487085870868708787088870898709087091870928709387094870958709687097870988709987100871018710287103871048710587106871078710887109871108711187112871138711487115871168711787118871198712087121871228712387124871258712687127871288712987130871318713287133871348713587136871378713887139871408714187142871438714487145871468714787148871498715087151871528715387154871558715687157871588715987160871618716287163871648716587166871678716887169871708717187172871738717487175871768717787178871798718087181871828718387184871858718687187871888718987190871918719287193871948719587196871978719887199872008720187202872038720487205872068720787208872098721087211872128721387214872158721687217872188721987220872218722287223872248722587226872278722887229872308723187232872338723487235872368723787238872398724087241872428724387244872458724687247872488724987250872518725287253872548725587256872578725887259872608726187262872638726487265872668726787268872698727087271872728727387274872758727687277872788727987280872818728287283872848728587286872878728887289872908729187292872938729487295872968729787298872998730087301873028730387304873058730687307873088730987310873118731287313873148731587316873178731887319873208732187322873238732487325873268732787328873298733087331873328733387334873358733687337873388733987340873418734287343873448734587346873478734887349873508735187352873538735487355873568735787358873598736087361873628736387364873658736687367873688736987370873718737287373873748737587376873778737887379873808738187382873838738487385873868738787388873898739087391873928739387394873958739687397873988739987400874018740287403874048740587406874078740887409874108741187412874138741487415874168741787418874198742087421874228742387424874258742687427874288742987430874318743287433874348743587436874378743887439874408744187442874438744487445874468744787448874498745087451874528745387454874558745687457874588745987460874618746287463874648746587466874678746887469874708747187472874738747487475874768747787478874798748087481874828748387484874858748687487874888748987490874918749287493874948749587496874978749887499875008750187502875038750487505875068750787508875098751087511875128751387514875158751687517875188751987520875218752287523875248752587526875278752887529875308753187532875338753487535875368753787538875398754087541875428754387544875458754687547875488754987550875518755287553875548755587556875578755887559875608756187562875638756487565875668756787568875698757087571875728757387574875758757687577875788757987580875818758287583875848758587586875878758887589875908759187592875938759487595875968759787598875998760087601876028760387604876058760687607876088760987610876118761287613876148761587616876178761887619876208762187622876238762487625876268762787628876298763087631876328763387634876358763687637876388763987640876418764287643876448764587646876478764887649876508765187652876538765487655876568765787658876598766087661876628766387664876658766687667876688766987670876718767287673876748767587676876778767887679876808768187682876838768487685876868768787688876898769087691876928769387694876958769687697876988769987700877018770287703877048770587706877078770887709877108771187712877138771487715877168771787718877198772087721877228772387724877258772687727877288772987730877318773287733877348773587736877378773887739877408774187742877438774487745877468774787748877498775087751877528775387754877558775687757877588775987760877618776287763877648776587766877678776887769877708777187772877738777487775877768777787778877798778087781877828778387784877858778687787877888778987790877918779287793877948779587796877978779887799878008780187802878038780487805878068780787808878098781087811878128781387814878158781687817878188781987820878218782287823878248782587826878278782887829878308783187832878338783487835878368783787838878398784087841878428784387844878458784687847878488784987850878518785287853878548785587856878578785887859878608786187862878638786487865878668786787868878698787087871878728787387874878758787687877878788787987880878818788287883878848788587886878878788887889878908789187892878938789487895878968789787898878998790087901879028790387904879058790687907879088790987910879118791287913879148791587916879178791887919879208792187922879238792487925879268792787928879298793087931879328793387934879358793687937879388793987940879418794287943879448794587946879478794887949879508795187952879538795487955879568795787958879598796087961879628796387964879658796687967879688796987970879718797287973879748797587976879778797887979879808798187982879838798487985879868798787988879898799087991879928799387994879958799687997879988799988000880018800288003880048800588006880078800888009880108801188012880138801488015880168801788018880198802088021880228802388024880258802688027880288802988030880318803288033880348803588036880378803888039880408804188042880438804488045880468804788048880498805088051880528805388054880558805688057880588805988060880618806288063880648806588066880678806888069880708807188072880738807488075880768807788078880798808088081880828808388084880858808688087880888808988090880918809288093880948809588096880978809888099881008810188102881038810488105881068810788108881098811088111881128811388114881158811688117881188811988120881218812288123881248812588126881278812888129881308813188132881338813488135881368813788138881398814088141881428814388144881458814688147881488814988150881518815288153881548815588156881578815888159881608816188162881638816488165881668816788168881698817088171881728817388174881758817688177881788817988180881818818288183881848818588186881878818888189881908819188192881938819488195881968819788198881998820088201882028820388204882058820688207882088820988210882118821288213882148821588216882178821888219882208822188222882238822488225882268822788228882298823088231882328823388234882358823688237882388823988240882418824288243882448824588246882478824888249882508825188252882538825488255882568825788258882598826088261882628826388264882658826688267882688826988270882718827288273882748827588276882778827888279882808828188282882838828488285882868828788288882898829088291882928829388294882958829688297882988829988300883018830288303883048830588306883078830888309883108831188312883138831488315883168831788318883198832088321883228832388324883258832688327883288832988330883318833288333883348833588336883378833888339883408834188342883438834488345883468834788348883498835088351883528835388354883558835688357883588835988360883618836288363883648836588366883678836888369883708837188372883738837488375883768837788378883798838088381883828838388384883858838688387883888838988390883918839288393883948839588396883978839888399884008840188402884038840488405884068840788408884098841088411884128841388414884158841688417884188841988420884218842288423884248842588426884278842888429884308843188432884338843488435884368843788438884398844088441884428844388444884458844688447884488844988450884518845288453884548845588456884578845888459884608846188462884638846488465884668846788468884698847088471884728847388474884758847688477884788847988480884818848288483884848848588486884878848888489884908849188492884938849488495884968849788498884998850088501885028850388504885058850688507885088850988510885118851288513885148851588516885178851888519885208852188522885238852488525885268852788528885298853088531885328853388534885358853688537885388853988540885418854288543885448854588546885478854888549885508855188552885538855488555885568855788558885598856088561885628856388564885658856688567885688856988570885718857288573885748857588576885778857888579885808858188582885838858488585885868858788588885898859088591885928859388594885958859688597885988859988600886018860288603886048860588606886078860888609886108861188612886138861488615886168861788618886198862088621886228862388624886258862688627886288862988630886318863288633886348863588636886378863888639886408864188642886438864488645886468864788648886498865088651886528865388654886558865688657886588865988660886618866288663886648866588666886678866888669886708867188672886738867488675886768867788678886798868088681886828868388684886858868688687886888868988690886918869288693886948869588696886978869888699887008870188702887038870488705887068870788708887098871088711887128871388714887158871688717887188871988720887218872288723887248872588726887278872888729887308873188732887338873488735887368873788738887398874088741887428874388744887458874688747887488874988750887518875288753887548875588756887578875888759887608876188762887638876488765887668876788768887698877088771887728877388774887758877688777887788877988780887818878288783887848878588786887878878888789887908879188792887938879488795887968879788798887998880088801888028880388804888058880688807888088880988810888118881288813888148881588816888178881888819888208882188822888238882488825888268882788828888298883088831888328883388834888358883688837888388883988840888418884288843888448884588846888478884888849888508885188852888538885488855888568885788858888598886088861888628886388864888658886688867888688886988870888718887288873888748887588876888778887888879888808888188882888838888488885888868888788888888898889088891888928889388894888958889688897888988889988900889018890288903889048890588906889078890888909889108891188912889138891488915889168891788918889198892088921889228892388924889258892688927889288892988930889318893288933889348893588936889378893888939889408894188942889438894488945889468894788948889498895088951889528895388954889558895688957889588895988960889618896288963889648896588966889678896888969889708897188972889738897488975889768897788978889798898088981889828898388984889858898688987889888898988990889918899288993889948899588996889978899888999890008900189002890038900489005890068900789008890098901089011890128901389014890158901689017890188901989020890218902289023890248902589026890278902889029890308903189032890338903489035890368903789038890398904089041890428904389044890458904689047890488904989050890518905289053890548905589056890578905889059890608906189062890638906489065890668906789068890698907089071890728907389074890758907689077890788907989080890818908289083890848908589086890878908889089890908909189092890938909489095890968909789098890998910089101891028910389104891058910689107891088910989110891118911289113891148911589116891178911889119891208912189122891238912489125891268912789128891298913089131891328913389134891358913689137891388913989140891418914289143891448914589146891478914889149891508915189152891538915489155891568915789158891598916089161891628916389164891658916689167891688916989170891718917289173891748917589176891778917889179891808918189182891838918489185891868918789188891898919089191891928919389194891958919689197891988919989200892018920289203892048920589206892078920889209892108921189212892138921489215892168921789218892198922089221892228922389224892258922689227892288922989230892318923289233892348923589236892378923889239892408924189242892438924489245892468924789248892498925089251892528925389254892558925689257892588925989260892618926289263892648926589266892678926889269892708927189272892738927489275892768927789278892798928089281892828928389284892858928689287892888928989290892918929289293892948929589296892978929889299893008930189302893038930489305893068930789308893098931089311893128931389314893158931689317893188931989320893218932289323893248932589326893278932889329893308933189332893338933489335893368933789338893398934089341893428934389344893458934689347893488934989350893518935289353893548935589356893578935889359893608936189362893638936489365893668936789368893698937089371893728937389374893758937689377893788937989380893818938289383893848938589386893878938889389893908939189392893938939489395893968939789398893998940089401894028940389404894058940689407894088940989410894118941289413894148941589416894178941889419894208942189422894238942489425894268942789428894298943089431894328943389434894358943689437894388943989440894418944289443894448944589446894478944889449894508945189452894538945489455894568945789458894598946089461894628946389464894658946689467894688946989470894718947289473894748947589476894778947889479894808948189482894838948489485894868948789488894898949089491894928949389494894958949689497894988949989500895018950289503895048950589506895078950889509895108951189512895138951489515895168951789518895198952089521895228952389524895258952689527895288952989530895318953289533895348953589536895378953889539895408954189542895438954489545895468954789548895498955089551895528955389554895558955689557895588955989560895618956289563895648956589566895678956889569895708957189572895738957489575895768957789578895798958089581895828958389584895858958689587895888958989590895918959289593895948959589596895978959889599896008960189602896038960489605896068960789608896098961089611896128961389614896158961689617896188961989620896218962289623896248962589626896278962889629896308963189632896338963489635896368963789638896398964089641896428964389644896458964689647896488964989650896518965289653896548965589656896578965889659896608966189662896638966489665896668966789668896698967089671896728967389674896758967689677896788967989680896818968289683896848968589686896878968889689896908969189692896938969489695896968969789698896998970089701897028970389704897058970689707897088970989710897118971289713897148971589716897178971889719897208972189722897238972489725897268972789728897298973089731897328973389734897358973689737897388973989740897418974289743897448974589746897478974889749897508975189752897538975489755897568975789758897598976089761897628976389764897658976689767897688976989770897718977289773897748977589776897778977889779897808978189782897838978489785897868978789788897898979089791897928979389794897958979689797897988979989800898018980289803898048980589806898078980889809898108981189812898138981489815898168981789818898198982089821898228982389824898258982689827898288982989830898318983289833898348983589836898378983889839898408984189842898438984489845898468984789848898498985089851898528985389854898558985689857898588985989860898618986289863898648986589866898678986889869898708987189872898738987489875898768987789878898798988089881898828988389884898858988689887898888988989890898918989289893898948989589896898978989889899899008990189902899038990489905899068990789908899098991089911899128991389914899158991689917899188991989920899218992289923899248992589926899278992889929899308993189932899338993489935899368993789938899398994089941899428994389944899458994689947899488994989950899518995289953899548995589956899578995889959899608996189962899638996489965899668996789968899698997089971899728997389974899758997689977899788997989980899818998289983899848998589986899878998889989899908999189992899938999489995899968999789998899999000090001900029000390004900059000690007900089000990010900119001290013900149001590016900179001890019900209002190022900239002490025900269002790028900299003090031900329003390034900359003690037900389003990040900419004290043900449004590046900479004890049900509005190052900539005490055900569005790058900599006090061900629006390064900659006690067900689006990070900719007290073900749007590076900779007890079900809008190082900839008490085900869008790088900899009090091900929009390094900959009690097900989009990100901019010290103901049010590106901079010890109901109011190112901139011490115901169011790118901199012090121901229012390124901259012690127901289012990130901319013290133901349013590136901379013890139901409014190142901439014490145901469014790148901499015090151901529015390154901559015690157901589015990160901619016290163901649016590166901679016890169901709017190172901739017490175901769017790178901799018090181901829018390184901859018690187901889018990190901919019290193901949019590196901979019890199902009020190202902039020490205902069020790208902099021090211902129021390214902159021690217902189021990220902219022290223902249022590226902279022890229902309023190232902339023490235902369023790238902399024090241902429024390244902459024690247902489024990250902519025290253902549025590256902579025890259902609026190262902639026490265902669026790268902699027090271902729027390274902759027690277902789027990280902819028290283902849028590286902879028890289902909029190292902939029490295902969029790298902999030090301903029030390304903059030690307903089030990310903119031290313903149031590316903179031890319903209032190322903239032490325903269032790328903299033090331903329033390334903359033690337903389033990340903419034290343903449034590346903479034890349903509035190352903539035490355903569035790358903599036090361903629036390364903659036690367903689036990370903719037290373903749037590376903779037890379903809038190382903839038490385903869038790388903899039090391903929039390394903959039690397903989039990400904019040290403904049040590406904079040890409904109041190412904139041490415904169041790418904199042090421904229042390424904259042690427904289042990430904319043290433904349043590436904379043890439904409044190442904439044490445904469044790448904499045090451904529045390454904559045690457904589045990460904619046290463904649046590466904679046890469904709047190472904739047490475904769047790478904799048090481904829048390484904859048690487904889048990490904919049290493904949049590496904979049890499905009050190502905039050490505905069050790508905099051090511905129051390514905159051690517905189051990520905219052290523905249052590526905279052890529905309053190532905339053490535905369053790538905399054090541905429054390544905459054690547905489054990550905519055290553905549055590556905579055890559905609056190562905639056490565905669056790568905699057090571905729057390574905759057690577905789057990580905819058290583905849058590586905879058890589905909059190592905939059490595905969059790598905999060090601906029060390604906059060690607906089060990610906119061290613906149061590616906179061890619906209062190622906239062490625906269062790628906299063090631906329063390634906359063690637906389063990640906419064290643906449064590646906479064890649906509065190652906539065490655906569065790658906599066090661906629066390664906659066690667906689066990670906719067290673906749067590676906779067890679906809068190682906839068490685906869068790688906899069090691906929069390694906959069690697906989069990700907019070290703907049070590706907079070890709907109071190712907139071490715907169071790718907199072090721907229072390724907259072690727907289072990730907319073290733907349073590736907379073890739907409074190742907439074490745907469074790748907499075090751907529075390754907559075690757907589075990760907619076290763907649076590766907679076890769907709077190772907739077490775907769077790778907799078090781907829078390784907859078690787907889078990790907919079290793907949079590796907979079890799908009080190802908039080490805908069080790808908099081090811908129081390814908159081690817908189081990820908219082290823908249082590826908279082890829908309083190832908339083490835908369083790838908399084090841908429084390844908459084690847908489084990850908519085290853908549085590856908579085890859908609086190862908639086490865908669086790868908699087090871908729087390874908759087690877908789087990880908819088290883908849088590886908879088890889908909089190892908939089490895908969089790898908999090090901909029090390904909059090690907909089090990910909119091290913909149091590916909179091890919909209092190922909239092490925909269092790928909299093090931909329093390934909359093690937909389093990940909419094290943909449094590946909479094890949909509095190952909539095490955909569095790958909599096090961909629096390964909659096690967909689096990970909719097290973909749097590976909779097890979909809098190982909839098490985909869098790988909899099090991909929099390994909959099690997909989099991000910019100291003910049100591006910079100891009910109101191012910139101491015910169101791018910199102091021910229102391024910259102691027910289102991030910319103291033910349103591036910379103891039910409104191042910439104491045910469104791048910499105091051910529105391054910559105691057910589105991060910619106291063910649106591066910679106891069910709107191072910739107491075910769107791078910799108091081910829108391084910859108691087910889108991090910919109291093910949109591096910979109891099911009110191102911039110491105911069110791108911099111091111911129111391114911159111691117911189111991120911219112291123911249112591126911279112891129911309113191132911339113491135911369113791138911399114091141911429114391144911459114691147911489114991150911519115291153911549115591156911579115891159911609116191162911639116491165911669116791168911699117091171911729117391174911759117691177911789117991180911819118291183911849118591186911879118891189911909119191192911939119491195911969119791198911999120091201912029120391204912059120691207912089120991210912119121291213912149121591216912179121891219912209122191222912239122491225912269122791228912299123091231912329123391234912359123691237912389123991240912419124291243912449124591246912479124891249912509125191252912539125491255912569125791258912599126091261912629126391264912659126691267912689126991270912719127291273912749127591276912779127891279912809128191282912839128491285912869128791288912899129091291912929129391294912959129691297912989129991300913019130291303913049130591306913079130891309913109131191312913139131491315913169131791318913199132091321913229132391324913259132691327913289132991330913319133291333913349133591336913379133891339913409134191342913439134491345913469134791348913499135091351913529135391354913559135691357913589135991360913619136291363913649136591366913679136891369913709137191372913739137491375913769137791378913799138091381913829138391384913859138691387913889138991390913919139291393913949139591396913979139891399914009140191402914039140491405914069140791408914099141091411914129141391414914159141691417914189141991420914219142291423914249142591426914279142891429914309143191432914339143491435914369143791438914399144091441914429144391444914459144691447914489144991450914519145291453914549145591456914579145891459914609146191462914639146491465914669146791468914699147091471914729147391474914759147691477914789147991480914819148291483914849148591486914879148891489914909149191492914939149491495914969149791498914999150091501915029150391504915059150691507915089150991510915119151291513915149151591516915179151891519915209152191522915239152491525915269152791528915299153091531915329153391534915359153691537915389153991540915419154291543915449154591546915479154891549915509155191552915539155491555915569155791558915599156091561915629156391564915659156691567915689156991570915719157291573915749157591576915779157891579915809158191582915839158491585915869158791588915899159091591915929159391594915959159691597915989159991600916019160291603916049160591606916079160891609916109161191612916139161491615916169161791618916199162091621916229162391624916259162691627916289162991630916319163291633916349163591636916379163891639916409164191642916439164491645916469164791648916499165091651916529165391654916559165691657916589165991660916619166291663916649166591666916679166891669916709167191672916739167491675916769167791678916799168091681916829168391684916859168691687916889168991690916919169291693916949169591696916979169891699917009170191702917039170491705917069170791708917099171091711917129171391714917159171691717917189171991720917219172291723917249172591726917279172891729917309173191732917339173491735917369173791738917399174091741917429174391744917459174691747917489174991750917519175291753917549175591756917579175891759917609176191762917639176491765917669176791768917699177091771917729177391774917759177691777917789177991780917819178291783917849178591786917879178891789917909179191792917939179491795917969179791798917999180091801918029180391804918059180691807918089180991810918119181291813918149181591816918179181891819918209182191822918239182491825918269182791828918299183091831918329183391834918359183691837918389183991840918419184291843918449184591846918479184891849918509185191852918539185491855918569185791858918599186091861918629186391864918659186691867918689186991870918719187291873918749187591876918779187891879918809188191882918839188491885918869188791888918899189091891918929189391894918959189691897918989189991900919019190291903919049190591906919079190891909919109191191912919139191491915919169191791918919199192091921919229192391924919259192691927919289192991930919319193291933919349193591936919379193891939919409194191942919439194491945919469194791948919499195091951919529195391954919559195691957919589195991960919619196291963919649196591966919679196891969919709197191972919739197491975919769197791978919799198091981919829198391984919859198691987919889198991990919919199291993919949199591996919979199891999920009200192002920039200492005920069200792008920099201092011920129201392014920159201692017920189201992020920219202292023920249202592026920279202892029920309203192032920339203492035920369203792038920399204092041920429204392044920459204692047920489204992050920519205292053920549205592056920579205892059920609206192062920639206492065920669206792068920699207092071920729207392074920759207692077920789207992080920819208292083920849208592086920879208892089920909209192092920939209492095920969209792098920999210092101921029210392104921059210692107921089210992110921119211292113921149211592116921179211892119921209212192122921239212492125921269212792128921299213092131921329213392134921359213692137921389213992140921419214292143921449214592146921479214892149921509215192152921539215492155921569215792158921599216092161921629216392164921659216692167921689216992170921719217292173921749217592176921779217892179921809218192182921839218492185921869218792188921899219092191921929219392194921959219692197921989219992200922019220292203922049220592206922079220892209922109221192212922139221492215922169221792218922199222092221922229222392224922259222692227922289222992230922319223292233922349223592236922379223892239922409224192242922439224492245922469224792248922499225092251922529225392254922559225692257922589225992260922619226292263922649226592266922679226892269922709227192272922739227492275922769227792278922799228092281922829228392284922859228692287922889228992290922919229292293922949229592296922979229892299923009230192302923039230492305923069230792308923099231092311923129231392314923159231692317923189231992320923219232292323923249232592326923279232892329923309233192332923339233492335923369233792338923399234092341923429234392344923459234692347923489234992350923519235292353923549235592356923579235892359923609236192362923639236492365923669236792368923699237092371923729237392374923759237692377923789237992380923819238292383923849238592386923879238892389923909239192392923939239492395923969239792398923999240092401924029240392404924059240692407924089240992410924119241292413924149241592416924179241892419924209242192422924239242492425924269242792428924299243092431924329243392434924359243692437924389243992440924419244292443924449244592446924479244892449924509245192452924539245492455924569245792458924599246092461924629246392464924659246692467924689246992470924719247292473924749247592476924779247892479924809248192482924839248492485924869248792488924899249092491924929249392494924959249692497924989249992500925019250292503925049250592506925079250892509925109251192512925139251492515925169251792518925199252092521925229252392524925259252692527925289252992530925319253292533925349253592536925379253892539925409254192542925439254492545925469254792548925499255092551925529255392554925559255692557925589255992560925619256292563925649256592566925679256892569925709257192572925739257492575925769257792578925799258092581925829258392584925859258692587925889258992590925919259292593925949259592596925979259892599926009260192602926039260492605926069260792608926099261092611926129261392614926159261692617926189261992620926219262292623926249262592626926279262892629926309263192632926339263492635926369263792638926399264092641926429264392644926459264692647926489264992650926519265292653926549265592656926579265892659926609266192662926639266492665926669266792668926699267092671926729267392674926759267692677926789267992680926819268292683926849268592686926879268892689926909269192692926939269492695926969269792698926999270092701927029270392704927059270692707927089270992710927119271292713927149271592716927179271892719927209272192722927239272492725927269272792728927299273092731927329273392734927359273692737927389273992740927419274292743927449274592746927479274892749927509275192752927539275492755927569275792758927599276092761927629276392764927659276692767927689276992770927719277292773927749277592776927779277892779927809278192782927839278492785927869278792788927899279092791927929279392794927959279692797927989279992800928019280292803928049280592806928079280892809928109281192812928139281492815928169281792818928199282092821928229282392824928259282692827928289282992830928319283292833928349283592836928379283892839928409284192842928439284492845928469284792848928499285092851928529285392854928559285692857928589285992860928619286292863928649286592866928679286892869928709287192872928739287492875928769287792878928799288092881928829288392884928859288692887928889288992890928919289292893928949289592896928979289892899929009290192902929039290492905929069290792908929099291092911929129291392914929159291692917929189291992920929219292292923929249292592926929279292892929929309293192932929339293492935929369293792938929399294092941929429294392944929459294692947929489294992950929519295292953929549295592956929579295892959929609296192962929639296492965929669296792968929699297092971929729297392974929759297692977929789297992980929819298292983929849298592986929879298892989929909299192992929939299492995929969299792998929999300093001930029300393004930059300693007930089300993010930119301293013930149301593016930179301893019930209302193022930239302493025930269302793028930299303093031930329303393034930359303693037930389303993040930419304293043930449304593046930479304893049930509305193052930539305493055930569305793058930599306093061930629306393064930659306693067930689306993070930719307293073930749307593076930779307893079930809308193082930839308493085930869308793088930899309093091930929309393094930959309693097930989309993100931019310293103931049310593106931079310893109931109311193112931139311493115931169311793118931199312093121931229312393124931259312693127931289312993130931319313293133931349313593136931379313893139931409314193142931439314493145931469314793148931499315093151931529315393154931559315693157931589315993160931619316293163931649316593166931679316893169931709317193172931739317493175931769317793178931799318093181931829318393184931859318693187931889318993190931919319293193931949319593196931979319893199932009320193202932039320493205932069320793208932099321093211932129321393214932159321693217932189321993220932219322293223932249322593226932279322893229932309323193232932339323493235932369323793238932399324093241932429324393244932459324693247932489324993250932519325293253932549325593256932579325893259932609326193262932639326493265932669326793268932699327093271932729327393274932759327693277932789327993280932819328293283932849328593286932879328893289932909329193292932939329493295932969329793298932999330093301933029330393304933059330693307933089330993310933119331293313933149331593316933179331893319933209332193322933239332493325933269332793328933299333093331933329333393334933359333693337933389333993340933419334293343933449334593346933479334893349933509335193352933539335493355933569335793358933599336093361933629336393364933659336693367933689336993370933719337293373933749337593376933779337893379933809338193382933839338493385933869338793388933899339093391933929339393394933959339693397933989339993400934019340293403934049340593406934079340893409934109341193412934139341493415934169341793418934199342093421934229342393424934259342693427934289342993430934319343293433934349343593436934379343893439934409344193442934439344493445934469344793448934499345093451934529345393454934559345693457934589345993460934619346293463934649346593466934679346893469934709347193472934739347493475934769347793478934799348093481934829348393484934859348693487934889348993490934919349293493934949349593496934979349893499935009350193502935039350493505935069350793508935099351093511935129351393514935159351693517935189351993520935219352293523935249352593526935279352893529935309353193532935339353493535935369353793538935399354093541935429354393544935459354693547935489354993550935519355293553935549355593556935579355893559935609356193562935639356493565935669356793568935699357093571935729357393574935759357693577935789357993580935819358293583935849358593586935879358893589935909359193592935939359493595935969359793598935999360093601936029360393604936059360693607936089360993610936119361293613936149361593616936179361893619936209362193622936239362493625936269362793628936299363093631936329363393634936359363693637936389363993640936419364293643936449364593646936479364893649936509365193652936539365493655936569365793658936599366093661936629366393664936659366693667936689366993670936719367293673936749367593676936779367893679936809368193682936839368493685936869368793688936899369093691936929369393694936959369693697936989369993700937019370293703937049370593706937079370893709937109371193712937139371493715937169371793718937199372093721937229372393724937259372693727937289372993730937319373293733937349373593736937379373893739937409374193742937439374493745937469374793748937499375093751937529375393754937559375693757937589375993760937619376293763937649376593766937679376893769937709377193772937739377493775937769377793778937799378093781937829378393784937859378693787937889378993790937919379293793937949379593796937979379893799938009380193802938039380493805938069380793808938099381093811938129381393814938159381693817938189381993820938219382293823938249382593826938279382893829938309383193832938339383493835938369383793838938399384093841938429384393844938459384693847938489384993850938519385293853938549385593856938579385893859938609386193862938639386493865938669386793868938699387093871938729387393874938759387693877938789387993880938819388293883938849388593886938879388893889938909389193892938939389493895938969389793898938999390093901939029390393904939059390693907939089390993910939119391293913939149391593916939179391893919939209392193922939239392493925939269392793928939299393093931939329393393934939359393693937939389393993940939419394293943939449394593946939479394893949939509395193952939539395493955939569395793958939599396093961939629396393964939659396693967939689396993970939719397293973939749397593976939779397893979939809398193982939839398493985939869398793988939899399093991939929399393994939959399693997939989399994000940019400294003940049400594006940079400894009940109401194012940139401494015940169401794018940199402094021940229402394024940259402694027940289402994030940319403294033940349403594036940379403894039940409404194042940439404494045940469404794048940499405094051940529405394054940559405694057940589405994060940619406294063940649406594066940679406894069940709407194072940739407494075940769407794078940799408094081940829408394084940859408694087940889408994090940919409294093940949409594096940979409894099941009410194102941039410494105941069410794108941099411094111941129411394114941159411694117941189411994120941219412294123941249412594126941279412894129941309413194132941339413494135941369413794138941399414094141941429414394144941459414694147941489414994150941519415294153941549415594156941579415894159941609416194162941639416494165941669416794168941699417094171941729417394174941759417694177941789417994180941819418294183941849418594186941879418894189941909419194192941939419494195941969419794198941999420094201942029420394204942059420694207942089420994210942119421294213942149421594216942179421894219942209422194222942239422494225942269422794228942299423094231942329423394234942359423694237942389423994240942419424294243942449424594246942479424894249942509425194252942539425494255942569425794258942599426094261942629426394264942659426694267942689426994270942719427294273942749427594276942779427894279942809428194282942839428494285942869428794288942899429094291942929429394294942959429694297942989429994300943019430294303943049430594306943079430894309943109431194312943139431494315943169431794318943199432094321943229432394324943259432694327943289432994330943319433294333943349433594336943379433894339943409434194342943439434494345943469434794348943499435094351943529435394354943559435694357943589435994360943619436294363943649436594366943679436894369943709437194372943739437494375943769437794378943799438094381943829438394384943859438694387943889438994390943919439294393943949439594396943979439894399944009440194402944039440494405944069440794408944099441094411944129441394414944159441694417944189441994420944219442294423944249442594426944279442894429944309443194432944339443494435944369443794438944399444094441944429444394444944459444694447944489444994450944519445294453944549445594456944579445894459944609446194462944639446494465944669446794468944699447094471944729447394474944759447694477944789447994480944819448294483944849448594486944879448894489944909449194492944939449494495944969449794498944999450094501945029450394504945059450694507945089450994510945119451294513945149451594516945179451894519945209452194522945239452494525945269452794528945299453094531945329453394534945359453694537945389453994540945419454294543945449454594546945479454894549945509455194552945539455494555945569455794558945599456094561945629456394564945659456694567945689456994570945719457294573945749457594576945779457894579945809458194582945839458494585945869458794588945899459094591945929459394594945959459694597945989459994600946019460294603946049460594606946079460894609946109461194612946139461494615946169461794618946199462094621946229462394624946259462694627946289462994630946319463294633946349463594636946379463894639946409464194642946439464494645946469464794648946499465094651946529465394654946559465694657946589465994660946619466294663946649466594666946679466894669946709467194672946739467494675946769467794678946799468094681946829468394684946859468694687946889468994690946919469294693946949469594696946979469894699947009470194702947039470494705947069470794708947099471094711947129471394714947159471694717947189471994720947219472294723947249472594726947279472894729947309473194732947339473494735947369473794738947399474094741947429474394744947459474694747947489474994750947519475294753947549475594756947579475894759947609476194762947639476494765947669476794768947699477094771947729477394774947759477694777947789477994780947819478294783947849478594786947879478894789947909479194792947939479494795947969479794798947999480094801948029480394804948059480694807948089480994810948119481294813948149481594816948179481894819948209482194822948239482494825948269482794828948299483094831948329483394834948359483694837948389483994840948419484294843948449484594846948479484894849948509485194852948539485494855948569485794858948599486094861948629486394864948659486694867948689486994870948719487294873948749487594876948779487894879948809488194882948839488494885948869488794888948899489094891948929489394894948959489694897948989489994900949019490294903949049490594906949079490894909949109491194912949139491494915949169491794918949199492094921949229492394924949259492694927949289492994930949319493294933949349493594936949379493894939949409494194942949439494494945949469494794948949499495094951949529495394954949559495694957949589495994960949619496294963949649496594966949679496894969949709497194972949739497494975949769497794978949799498094981949829498394984949859498694987949889498994990949919499294993949949499594996949979499894999950009500195002950039500495005950069500795008950099501095011950129501395014950159501695017950189501995020950219502295023950249502595026950279502895029950309503195032950339503495035950369503795038950399504095041950429504395044950459504695047950489504995050950519505295053950549505595056950579505895059950609506195062950639506495065950669506795068950699507095071950729507395074950759507695077950789507995080950819508295083950849508595086950879508895089950909509195092950939509495095950969509795098950999510095101951029510395104951059510695107951089510995110951119511295113951149511595116951179511895119951209512195122951239512495125951269512795128951299513095131951329513395134951359513695137951389513995140951419514295143951449514595146951479514895149951509515195152951539515495155951569515795158951599516095161951629516395164951659516695167951689516995170951719517295173951749517595176951779517895179951809518195182951839518495185951869518795188951899519095191951929519395194951959519695197951989519995200952019520295203952049520595206952079520895209952109521195212952139521495215952169521795218952199522095221952229522395224952259522695227952289522995230952319523295233952349523595236952379523895239952409524195242952439524495245952469524795248952499525095251952529525395254952559525695257952589525995260952619526295263952649526595266952679526895269952709527195272952739527495275952769527795278952799528095281952829528395284952859528695287952889528995290952919529295293952949529595296952979529895299953009530195302953039530495305953069530795308953099531095311953129531395314953159531695317953189531995320953219532295323953249532595326953279532895329953309533195332953339533495335953369533795338953399534095341953429534395344953459534695347953489534995350953519535295353953549535595356953579535895359953609536195362953639536495365953669536795368953699537095371953729537395374953759537695377953789537995380953819538295383953849538595386953879538895389953909539195392953939539495395953969539795398953999540095401954029540395404954059540695407954089540995410954119541295413954149541595416954179541895419954209542195422954239542495425954269542795428954299543095431954329543395434954359543695437954389543995440954419544295443954449544595446954479544895449954509545195452954539545495455954569545795458954599546095461954629546395464954659546695467954689546995470954719547295473954749547595476954779547895479954809548195482954839548495485954869548795488954899549095491954929549395494954959549695497954989549995500955019550295503955049550595506955079550895509955109551195512955139551495515955169551795518955199552095521955229552395524955259552695527955289552995530955319553295533955349553595536955379553895539955409554195542955439554495545955469554795548955499555095551955529555395554955559555695557955589555995560955619556295563955649556595566955679556895569955709557195572955739557495575955769557795578955799558095581955829558395584955859558695587955889558995590955919559295593955949559595596955979559895599956009560195602956039560495605956069560795608956099561095611956129561395614956159561695617956189561995620956219562295623956249562595626956279562895629956309563195632956339563495635956369563795638956399564095641956429564395644956459564695647956489564995650956519565295653956549565595656956579565895659956609566195662956639566495665956669566795668956699567095671956729567395674956759567695677956789567995680956819568295683956849568595686956879568895689956909569195692956939569495695956969569795698956999570095701957029570395704957059570695707957089570995710957119571295713957149571595716957179571895719957209572195722957239572495725957269572795728957299573095731957329573395734957359573695737957389573995740957419574295743957449574595746957479574895749957509575195752957539575495755957569575795758957599576095761957629576395764957659576695767957689576995770957719577295773957749577595776957779577895779957809578195782957839578495785957869578795788957899579095791957929579395794957959579695797957989579995800958019580295803958049580595806958079580895809958109581195812958139581495815958169581795818958199582095821958229582395824958259582695827958289582995830958319583295833958349583595836958379583895839958409584195842958439584495845958469584795848958499585095851958529585395854958559585695857958589585995860958619586295863958649586595866958679586895869958709587195872958739587495875958769587795878958799588095881958829588395884958859588695887958889588995890958919589295893958949589595896958979589895899959009590195902959039590495905959069590795908959099591095911959129591395914959159591695917959189591995920959219592295923959249592595926959279592895929959309593195932959339593495935959369593795938959399594095941959429594395944959459594695947959489594995950959519595295953959549595595956959579595895959959609596195962959639596495965959669596795968959699597095971959729597395974959759597695977959789597995980959819598295983959849598595986959879598895989959909599195992959939599495995959969599795998959999600096001960029600396004960059600696007960089600996010960119601296013960149601596016960179601896019960209602196022960239602496025960269602796028960299603096031960329603396034960359603696037960389603996040960419604296043960449604596046960479604896049960509605196052960539605496055960569605796058960599606096061960629606396064960659606696067960689606996070960719607296073960749607596076960779607896079960809608196082960839608496085960869608796088960899609096091960929609396094960959609696097960989609996100961019610296103961049610596106961079610896109961109611196112961139611496115961169611796118961199612096121961229612396124961259612696127961289612996130961319613296133961349613596136961379613896139961409614196142961439614496145961469614796148961499615096151961529615396154961559615696157961589615996160961619616296163961649616596166961679616896169961709617196172961739617496175961769617796178961799618096181961829618396184961859618696187961889618996190961919619296193961949619596196961979619896199962009620196202962039620496205962069620796208962099621096211962129621396214962159621696217962189621996220962219622296223962249622596226962279622896229962309623196232962339623496235962369623796238962399624096241962429624396244962459624696247962489624996250962519625296253962549625596256962579625896259962609626196262962639626496265962669626796268962699627096271962729627396274962759627696277962789627996280962819628296283962849628596286962879628896289962909629196292962939629496295962969629796298962999630096301963029630396304963059630696307963089630996310963119631296313963149631596316963179631896319963209632196322963239632496325963269632796328963299633096331963329633396334963359633696337963389633996340963419634296343963449634596346963479634896349963509635196352963539635496355963569635796358963599636096361963629636396364963659636696367963689636996370963719637296373963749637596376963779637896379963809638196382963839638496385963869638796388963899639096391963929639396394963959639696397963989639996400964019640296403964049640596406964079640896409964109641196412964139641496415964169641796418964199642096421964229642396424964259642696427964289642996430964319643296433964349643596436964379643896439964409644196442964439644496445964469644796448964499645096451964529645396454964559645696457964589645996460964619646296463964649646596466964679646896469964709647196472964739647496475964769647796478964799648096481964829648396484964859648696487964889648996490964919649296493964949649596496964979649896499965009650196502965039650496505965069650796508965099651096511965129651396514965159651696517965189651996520965219652296523965249652596526965279652896529965309653196532965339653496535965369653796538965399654096541965429654396544965459654696547965489654996550965519655296553965549655596556965579655896559965609656196562965639656496565965669656796568965699657096571965729657396574965759657696577965789657996580965819658296583965849658596586965879658896589965909659196592965939659496595965969659796598965999660096601966029660396604966059660696607966089660996610966119661296613966149661596616966179661896619966209662196622966239662496625966269662796628966299663096631966329663396634966359663696637966389663996640966419664296643966449664596646966479664896649966509665196652966539665496655966569665796658966599666096661966629666396664966659666696667966689666996670966719667296673966749667596676966779667896679966809668196682966839668496685966869668796688966899669096691966929669396694966959669696697966989669996700967019670296703967049670596706967079670896709967109671196712967139671496715967169671796718967199672096721967229672396724967259672696727967289672996730967319673296733967349673596736967379673896739967409674196742967439674496745967469674796748967499675096751967529675396754967559675696757967589675996760967619676296763967649676596766967679676896769967709677196772967739677496775967769677796778967799678096781967829678396784967859678696787967889678996790967919679296793967949679596796967979679896799968009680196802968039680496805968069680796808968099681096811968129681396814968159681696817968189681996820968219682296823968249682596826968279682896829968309683196832968339683496835968369683796838968399684096841968429684396844968459684696847968489684996850968519685296853968549685596856968579685896859968609686196862968639686496865968669686796868968699687096871968729687396874968759687696877968789687996880968819688296883968849688596886968879688896889968909689196892968939689496895968969689796898968999690096901969029690396904969059690696907969089690996910969119691296913969149691596916969179691896919969209692196922969239692496925969269692796928969299693096931969329693396934969359693696937969389693996940969419694296943969449694596946969479694896949969509695196952969539695496955969569695796958969599696096961969629696396964969659696696967969689696996970969719697296973969749697596976969779697896979969809698196982969839698496985969869698796988969899699096991969929699396994969959699696997969989699997000970019700297003970049700597006970079700897009970109701197012970139701497015970169701797018970199702097021970229702397024970259702697027970289702997030970319703297033970349703597036970379703897039970409704197042970439704497045970469704797048970499705097051970529705397054970559705697057970589705997060970619706297063970649706597066970679706897069970709707197072970739707497075970769707797078970799708097081970829708397084970859708697087970889708997090970919709297093970949709597096970979709897099971009710197102971039710497105971069710797108971099711097111971129711397114971159711697117971189711997120971219712297123971249712597126971279712897129971309713197132971339713497135971369713797138971399714097141971429714397144971459714697147971489714997150971519715297153971549715597156971579715897159971609716197162971639716497165971669716797168971699717097171971729717397174971759717697177971789717997180971819718297183971849718597186971879718897189971909719197192971939719497195971969719797198971999720097201972029720397204972059720697207972089720997210972119721297213972149721597216972179721897219972209722197222972239722497225972269722797228972299723097231972329723397234972359723697237972389723997240972419724297243972449724597246972479724897249972509725197252972539725497255972569725797258972599726097261972629726397264972659726697267972689726997270972719727297273972749727597276972779727897279972809728197282972839728497285972869728797288972899729097291972929729397294972959729697297972989729997300973019730297303973049730597306973079730897309973109731197312973139731497315973169731797318973199732097321973229732397324973259732697327973289732997330973319733297333973349733597336973379733897339973409734197342973439734497345973469734797348973499735097351973529735397354973559735697357973589735997360973619736297363973649736597366973679736897369973709737197372973739737497375973769737797378973799738097381973829738397384973859738697387973889738997390973919739297393973949739597396973979739897399974009740197402974039740497405974069740797408974099741097411974129741397414974159741697417974189741997420974219742297423974249742597426974279742897429974309743197432974339743497435974369743797438974399744097441974429744397444974459744697447974489744997450974519745297453974549745597456974579745897459974609746197462974639746497465974669746797468974699747097471974729747397474974759747697477974789747997480974819748297483974849748597486974879748897489974909749197492974939749497495974969749797498974999750097501975029750397504975059750697507975089750997510975119751297513975149751597516975179751897519975209752197522975239752497525975269752797528975299753097531975329753397534975359753697537975389753997540975419754297543975449754597546975479754897549975509755197552975539755497555975569755797558975599756097561975629756397564975659756697567975689756997570975719757297573975749757597576975779757897579975809758197582975839758497585975869758797588975899759097591975929759397594975959759697597975989759997600976019760297603976049760597606976079760897609976109761197612976139761497615976169761797618976199762097621976229762397624976259762697627976289762997630976319763297633976349763597636976379763897639976409764197642976439764497645976469764797648976499765097651976529765397654976559765697657976589765997660976619766297663976649766597666976679766897669976709767197672976739767497675976769767797678976799768097681976829768397684976859768697687976889768997690976919769297693976949769597696976979769897699977009770197702977039770497705977069770797708977099771097711977129771397714977159771697717977189771997720977219772297723977249772597726977279772897729977309773197732977339773497735977369773797738977399774097741977429774397744977459774697747977489774997750977519775297753977549775597756977579775897759977609776197762977639776497765977669776797768977699777097771977729777397774977759777697777977789777997780977819778297783977849778597786977879778897789977909779197792977939779497795977969779797798977999780097801978029780397804978059780697807978089780997810978119781297813978149781597816978179781897819978209782197822978239782497825978269782797828978299783097831978329783397834978359783697837978389783997840978419784297843978449784597846978479784897849978509785197852978539785497855978569785797858978599786097861978629786397864978659786697867978689786997870978719787297873978749787597876978779787897879978809788197882978839788497885978869788797888978899789097891978929789397894978959789697897978989789997900979019790297903979049790597906979079790897909979109791197912979139791497915979169791797918979199792097921979229792397924979259792697927979289792997930979319793297933979349793597936979379793897939979409794197942979439794497945979469794797948979499795097951979529795397954979559795697957979589795997960979619796297963979649796597966979679796897969979709797197972979739797497975979769797797978979799798097981979829798397984979859798697987979889798997990979919799297993979949799597996979979799897999980009800198002980039800498005980069800798008980099801098011980129801398014980159801698017980189801998020980219802298023980249802598026980279802898029980309803198032980339803498035980369803798038980399804098041980429804398044980459804698047980489804998050980519805298053980549805598056980579805898059980609806198062980639806498065980669806798068980699807098071980729807398074980759807698077980789807998080980819808298083980849808598086980879808898089980909809198092980939809498095980969809798098980999810098101981029810398104981059810698107981089810998110981119811298113981149811598116981179811898119981209812198122981239812498125981269812798128981299813098131981329813398134981359813698137981389813998140981419814298143981449814598146981479814898149981509815198152981539815498155981569815798158981599816098161981629816398164981659816698167981689816998170981719817298173981749817598176981779817898179981809818198182981839818498185981869818798188981899819098191981929819398194981959819698197981989819998200982019820298203982049820598206982079820898209982109821198212982139821498215982169821798218982199822098221982229822398224982259822698227982289822998230982319823298233982349823598236982379823898239982409824198242982439824498245982469824798248982499825098251982529825398254982559825698257982589825998260982619826298263982649826598266982679826898269982709827198272982739827498275982769827798278982799828098281982829828398284982859828698287982889828998290982919829298293982949829598296982979829898299983009830198302983039830498305983069830798308983099831098311983129831398314983159831698317983189831998320983219832298323983249832598326983279832898329983309833198332983339833498335983369833798338983399834098341983429834398344983459834698347983489834998350983519835298353983549835598356983579835898359983609836198362983639836498365983669836798368983699837098371983729837398374983759837698377983789837998380983819838298383983849838598386983879838898389983909839198392983939839498395983969839798398983999840098401984029840398404984059840698407984089840998410984119841298413984149841598416984179841898419984209842198422984239842498425984269842798428984299843098431984329843398434984359843698437984389843998440984419844298443984449844598446984479844898449984509845198452984539845498455984569845798458984599846098461984629846398464984659846698467984689846998470984719847298473984749847598476984779847898479984809848198482984839848498485984869848798488984899849098491984929849398494984959849698497984989849998500985019850298503985049850598506985079850898509985109851198512985139851498515985169851798518985199852098521985229852398524985259852698527985289852998530985319853298533985349853598536985379853898539985409854198542985439854498545
  1. require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
  2. module.exports=[
  3. {
  4. "constant": true,
  5. "inputs": [
  6. {
  7. "name": "_owner",
  8. "type": "address"
  9. }
  10. ],
  11. "name": "name",
  12. "outputs": [
  13. {
  14. "name": "o_name",
  15. "type": "bytes32"
  16. }
  17. ],
  18. "type": "function"
  19. },
  20. {
  21. "constant": true,
  22. "inputs": [
  23. {
  24. "name": "_name",
  25. "type": "bytes32"
  26. }
  27. ],
  28. "name": "owner",
  29. "outputs": [
  30. {
  31. "name": "",
  32. "type": "address"
  33. }
  34. ],
  35. "type": "function"
  36. },
  37. {
  38. "constant": true,
  39. "inputs": [
  40. {
  41. "name": "_name",
  42. "type": "bytes32"
  43. }
  44. ],
  45. "name": "content",
  46. "outputs": [
  47. {
  48. "name": "",
  49. "type": "bytes32"
  50. }
  51. ],
  52. "type": "function"
  53. },
  54. {
  55. "constant": true,
  56. "inputs": [
  57. {
  58. "name": "_name",
  59. "type": "bytes32"
  60. }
  61. ],
  62. "name": "addr",
  63. "outputs": [
  64. {
  65. "name": "",
  66. "type": "address"
  67. }
  68. ],
  69. "type": "function"
  70. },
  71. {
  72. "constant": false,
  73. "inputs": [
  74. {
  75. "name": "_name",
  76. "type": "bytes32"
  77. }
  78. ],
  79. "name": "reserve",
  80. "outputs": [],
  81. "type": "function"
  82. },
  83. {
  84. "constant": true,
  85. "inputs": [
  86. {
  87. "name": "_name",
  88. "type": "bytes32"
  89. }
  90. ],
  91. "name": "subRegistrar",
  92. "outputs": [
  93. {
  94. "name": "",
  95. "type": "address"
  96. }
  97. ],
  98. "type": "function"
  99. },
  100. {
  101. "constant": false,
  102. "inputs": [
  103. {
  104. "name": "_name",
  105. "type": "bytes32"
  106. },
  107. {
  108. "name": "_newOwner",
  109. "type": "address"
  110. }
  111. ],
  112. "name": "transfer",
  113. "outputs": [],
  114. "type": "function"
  115. },
  116. {
  117. "constant": false,
  118. "inputs": [
  119. {
  120. "name": "_name",
  121. "type": "bytes32"
  122. },
  123. {
  124. "name": "_registrar",
  125. "type": "address"
  126. }
  127. ],
  128. "name": "setSubRegistrar",
  129. "outputs": [],
  130. "type": "function"
  131. },
  132. {
  133. "constant": false,
  134. "inputs": [],
  135. "name": "Registrar",
  136. "outputs": [],
  137. "type": "function"
  138. },
  139. {
  140. "constant": false,
  141. "inputs": [
  142. {
  143. "name": "_name",
  144. "type": "bytes32"
  145. },
  146. {
  147. "name": "_a",
  148. "type": "address"
  149. },
  150. {
  151. "name": "_primary",
  152. "type": "bool"
  153. }
  154. ],
  155. "name": "setAddress",
  156. "outputs": [],
  157. "type": "function"
  158. },
  159. {
  160. "constant": false,
  161. "inputs": [
  162. {
  163. "name": "_name",
  164. "type": "bytes32"
  165. },
  166. {
  167. "name": "_content",
  168. "type": "bytes32"
  169. }
  170. ],
  171. "name": "setContent",
  172. "outputs": [],
  173. "type": "function"
  174. },
  175. {
  176. "constant": false,
  177. "inputs": [
  178. {
  179. "name": "_name",
  180. "type": "bytes32"
  181. }
  182. ],
  183. "name": "disown",
  184. "outputs": [],
  185. "type": "function"
  186. },
  187. {
  188. "anonymous": false,
  189. "inputs": [
  190. {
  191. "indexed": true,
  192. "name": "_name",
  193. "type": "bytes32"
  194. },
  195. {
  196. "indexed": false,
  197. "name": "_winner",
  198. "type": "address"
  199. }
  200. ],
  201. "name": "AuctionEnded",
  202. "type": "event"
  203. },
  204. {
  205. "anonymous": false,
  206. "inputs": [
  207. {
  208. "indexed": true,
  209. "name": "_name",
  210. "type": "bytes32"
  211. },
  212. {
  213. "indexed": false,
  214. "name": "_bidder",
  215. "type": "address"
  216. },
  217. {
  218. "indexed": false,
  219. "name": "_value",
  220. "type": "uint256"
  221. }
  222. ],
  223. "name": "NewBid",
  224. "type": "event"
  225. },
  226. {
  227. "anonymous": false,
  228. "inputs": [
  229. {
  230. "indexed": true,
  231. "name": "name",
  232. "type": "bytes32"
  233. }
  234. ],
  235. "name": "Changed",
  236. "type": "event"
  237. },
  238. {
  239. "anonymous": false,
  240. "inputs": [
  241. {
  242. "indexed": true,
  243. "name": "name",
  244. "type": "bytes32"
  245. },
  246. {
  247. "indexed": true,
  248. "name": "addr",
  249. "type": "address"
  250. }
  251. ],
  252. "name": "PrimaryChanged",
  253. "type": "event"
  254. }
  255. ]
  256. },{}],2:[function(require,module,exports){
  257. module.exports=[
  258. {
  259. "constant": true,
  260. "inputs": [
  261. {
  262. "name": "_name",
  263. "type": "bytes32"
  264. }
  265. ],
  266. "name": "owner",
  267. "outputs": [
  268. {
  269. "name": "",
  270. "type": "address"
  271. }
  272. ],
  273. "type": "function"
  274. },
  275. {
  276. "constant": false,
  277. "inputs": [
  278. {
  279. "name": "_name",
  280. "type": "bytes32"
  281. },
  282. {
  283. "name": "_refund",
  284. "type": "address"
  285. }
  286. ],
  287. "name": "disown",
  288. "outputs": [],
  289. "type": "function"
  290. },
  291. {
  292. "constant": true,
  293. "inputs": [
  294. {
  295. "name": "_name",
  296. "type": "bytes32"
  297. }
  298. ],
  299. "name": "addr",
  300. "outputs": [
  301. {
  302. "name": "",
  303. "type": "address"
  304. }
  305. ],
  306. "type": "function"
  307. },
  308. {
  309. "constant": false,
  310. "inputs": [
  311. {
  312. "name": "_name",
  313. "type": "bytes32"
  314. }
  315. ],
  316. "name": "reserve",
  317. "outputs": [],
  318. "type": "function"
  319. },
  320. {
  321. "constant": false,
  322. "inputs": [
  323. {
  324. "name": "_name",
  325. "type": "bytes32"
  326. },
  327. {
  328. "name": "_newOwner",
  329. "type": "address"
  330. }
  331. ],
  332. "name": "transfer",
  333. "outputs": [],
  334. "type": "function"
  335. },
  336. {
  337. "constant": false,
  338. "inputs": [
  339. {
  340. "name": "_name",
  341. "type": "bytes32"
  342. },
  343. {
  344. "name": "_a",
  345. "type": "address"
  346. }
  347. ],
  348. "name": "setAddr",
  349. "outputs": [],
  350. "type": "function"
  351. },
  352. {
  353. "anonymous": false,
  354. "inputs": [
  355. {
  356. "indexed": true,
  357. "name": "name",
  358. "type": "bytes32"
  359. }
  360. ],
  361. "name": "Changed",
  362. "type": "event"
  363. }
  364. ]
  365. },{}],3:[function(require,module,exports){
  366. module.exports=[
  367. {
  368. "constant": false,
  369. "inputs": [
  370. {
  371. "name": "from",
  372. "type": "bytes32"
  373. },
  374. {
  375. "name": "to",
  376. "type": "address"
  377. },
  378. {
  379. "name": "value",
  380. "type": "uint256"
  381. }
  382. ],
  383. "name": "transfer",
  384. "outputs": [],
  385. "type": "function"
  386. },
  387. {
  388. "constant": false,
  389. "inputs": [
  390. {
  391. "name": "from",
  392. "type": "bytes32"
  393. },
  394. {
  395. "name": "to",
  396. "type": "address"
  397. },
  398. {
  399. "name": "indirectId",
  400. "type": "bytes32"
  401. },
  402. {
  403. "name": "value",
  404. "type": "uint256"
  405. }
  406. ],
  407. "name": "icapTransfer",
  408. "outputs": [],
  409. "type": "function"
  410. },
  411. {
  412. "constant": false,
  413. "inputs": [
  414. {
  415. "name": "to",
  416. "type": "bytes32"
  417. }
  418. ],
  419. "name": "deposit",
  420. "outputs": [],
  421. "payable": true,
  422. "type": "function"
  423. },
  424. {
  425. "anonymous": false,
  426. "inputs": [
  427. {
  428. "indexed": true,
  429. "name": "from",
  430. "type": "address"
  431. },
  432. {
  433. "indexed": false,
  434. "name": "value",
  435. "type": "uint256"
  436. }
  437. ],
  438. "name": "AnonymousDeposit",
  439. "type": "event"
  440. },
  441. {
  442. "anonymous": false,
  443. "inputs": [
  444. {
  445. "indexed": true,
  446. "name": "from",
  447. "type": "address"
  448. },
  449. {
  450. "indexed": true,
  451. "name": "to",
  452. "type": "bytes32"
  453. },
  454. {
  455. "indexed": false,
  456. "name": "value",
  457. "type": "uint256"
  458. }
  459. ],
  460. "name": "Deposit",
  461. "type": "event"
  462. },
  463. {
  464. "anonymous": false,
  465. "inputs": [
  466. {
  467. "indexed": true,
  468. "name": "from",
  469. "type": "bytes32"
  470. },
  471. {
  472. "indexed": true,
  473. "name": "to",
  474. "type": "address"
  475. },
  476. {
  477. "indexed": false,
  478. "name": "value",
  479. "type": "uint256"
  480. }
  481. ],
  482. "name": "Transfer",
  483. "type": "event"
  484. },
  485. {
  486. "anonymous": false,
  487. "inputs": [
  488. {
  489. "indexed": true,
  490. "name": "from",
  491. "type": "bytes32"
  492. },
  493. {
  494. "indexed": true,
  495. "name": "to",
  496. "type": "address"
  497. },
  498. {
  499. "indexed": false,
  500. "name": "indirectId",
  501. "type": "bytes32"
  502. },
  503. {
  504. "indexed": false,
  505. "name": "value",
  506. "type": "uint256"
  507. }
  508. ],
  509. "name": "IcapTransfer",
  510. "type": "event"
  511. }
  512. ]
  513. },{}],4:[function(require,module,exports){
  514. var f = require('./formatters');
  515. var SolidityType = require('./type');
  516. /**
  517. * SolidityTypeAddress is a prootype that represents address type
  518. * It matches:
  519. * address
  520. * address[]
  521. * address[4]
  522. * address[][]
  523. * address[3][]
  524. * address[][6][], ...
  525. */
  526. var SolidityTypeAddress = function () {
  527. this._inputFormatter = f.formatInputInt;
  528. this._outputFormatter = f.formatOutputAddress;
  529. };
  530. SolidityTypeAddress.prototype = new SolidityType({});
  531. SolidityTypeAddress.prototype.constructor = SolidityTypeAddress;
  532. SolidityTypeAddress.prototype.isType = function (name) {
  533. return !!name.match(/address(\[([0-9]*)\])?/);
  534. };
  535. module.exports = SolidityTypeAddress;
  536. },{"./formatters":9,"./type":14}],5:[function(require,module,exports){
  537. var f = require('./formatters');
  538. var SolidityType = require('./type');
  539. /**
  540. * SolidityTypeBool is a prootype that represents bool type
  541. * It matches:
  542. * bool
  543. * bool[]
  544. * bool[4]
  545. * bool[][]
  546. * bool[3][]
  547. * bool[][6][], ...
  548. */
  549. var SolidityTypeBool = function () {
  550. this._inputFormatter = f.formatInputBool;
  551. this._outputFormatter = f.formatOutputBool;
  552. };
  553. SolidityTypeBool.prototype = new SolidityType({});
  554. SolidityTypeBool.prototype.constructor = SolidityTypeBool;
  555. SolidityTypeBool.prototype.isType = function (name) {
  556. return !!name.match(/^bool(\[([0-9]*)\])*$/);
  557. };
  558. module.exports = SolidityTypeBool;
  559. },{"./formatters":9,"./type":14}],6:[function(require,module,exports){
  560. var f = require('./formatters');
  561. var SolidityType = require('./type');
  562. /**
  563. * SolidityTypeBytes is a prototype that represents the bytes type.
  564. * It matches:
  565. * bytes
  566. * bytes[]
  567. * bytes[4]
  568. * bytes[][]
  569. * bytes[3][]
  570. * bytes[][6][], ...
  571. * bytes32
  572. * bytes8[4]
  573. * bytes[3][]
  574. */
  575. var SolidityTypeBytes = function () {
  576. this._inputFormatter = f.formatInputBytes;
  577. this._outputFormatter = f.formatOutputBytes;
  578. };
  579. SolidityTypeBytes.prototype = new SolidityType({});
  580. SolidityTypeBytes.prototype.constructor = SolidityTypeBytes;
  581. SolidityTypeBytes.prototype.isType = function (name) {
  582. return !!name.match(/^bytes([0-9]{1,})(\[([0-9]*)\])*$/);
  583. };
  584. module.exports = SolidityTypeBytes;
  585. },{"./formatters":9,"./type":14}],7:[function(require,module,exports){
  586. /*
  587. This file is part of web3.js.
  588. web3.js is free software: you can redistribute it and/or modify
  589. it under the terms of the GNU Lesser General Public License as published by
  590. the Free Software Foundation, either version 3 of the License, or
  591. (at your option) any later version.
  592. web3.js is distributed in the hope that it will be useful,
  593. but WITHOUT ANY WARRANTY; without even the implied warranty of
  594. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  595. GNU Lesser General Public License for more details.
  596. You should have received a copy of the GNU Lesser General Public License
  597. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  598. */
  599. /**
  600. * @file coder.js
  601. * @author Marek Kotewicz <[email protected]>
  602. * @date 2015
  603. */
  604. var f = require('./formatters');
  605. var SolidityTypeAddress = require('./address');
  606. var SolidityTypeBool = require('./bool');
  607. var SolidityTypeInt = require('./int');
  608. var SolidityTypeUInt = require('./uint');
  609. var SolidityTypeDynamicBytes = require('./dynamicbytes');
  610. var SolidityTypeString = require('./string');
  611. var SolidityTypeReal = require('./real');
  612. var SolidityTypeUReal = require('./ureal');
  613. var SolidityTypeBytes = require('./bytes');
  614. var isDynamic = function (solidityType, type) {
  615. return solidityType.isDynamicType(type) ||
  616. solidityType.isDynamicArray(type);
  617. };
  618. /**
  619. * SolidityCoder prototype should be used to encode/decode solidity params of any type
  620. */
  621. var SolidityCoder = function (types) {
  622. this._types = types;
  623. };
  624. /**
  625. * This method should be used to transform type to SolidityType
  626. *
  627. * @method _requireType
  628. * @param {String} type
  629. * @returns {SolidityType}
  630. * @throws {Error} throws if no matching type is found
  631. */
  632. SolidityCoder.prototype._requireType = function (type) {
  633. var solidityType = this._types.filter(function (t) {
  634. return t.isType(type);
  635. })[0];
  636. if (!solidityType) {
  637. throw Error('invalid solidity type!: ' + type);
  638. }
  639. return solidityType;
  640. };
  641. /**
  642. * Should be used to encode plain param
  643. *
  644. * @method encodeParam
  645. * @param {String} type
  646. * @param {Object} plain param
  647. * @return {String} encoded plain param
  648. */
  649. SolidityCoder.prototype.encodeParam = function (type, param) {
  650. return this.encodeParams([type], [param]);
  651. };
  652. /**
  653. * Should be used to encode list of params
  654. *
  655. * @method encodeParams
  656. * @param {Array} types
  657. * @param {Array} params
  658. * @return {String} encoded list of params
  659. */
  660. SolidityCoder.prototype.encodeParams = function (types, params) {
  661. var solidityTypes = this.getSolidityTypes(types);
  662. var encodeds = solidityTypes.map(function (solidityType, index) {
  663. return solidityType.encode(params[index], types[index]);
  664. });
  665. var dynamicOffset = solidityTypes.reduce(function (acc, solidityType, index) {
  666. var staticPartLength = solidityType.staticPartLength(types[index]);
  667. var roundedStaticPartLength = Math.floor((staticPartLength + 31) / 32) * 32;
  668. return acc + (isDynamic(solidityTypes[index], types[index]) ?
  669. 32 :
  670. roundedStaticPartLength);
  671. }, 0);
  672. var result = this.encodeMultiWithOffset(types, solidityTypes, encodeds, dynamicOffset);
  673. return result;
  674. };
  675. SolidityCoder.prototype.encodeMultiWithOffset = function (types, solidityTypes, encodeds, dynamicOffset) {
  676. var result = "";
  677. var self = this;
  678. types.forEach(function (type, i) {
  679. if (isDynamic(solidityTypes[i], types[i])) {
  680. result += f.formatInputInt(dynamicOffset).encode();
  681. var e = self.encodeWithOffset(types[i], solidityTypes[i], encodeds[i], dynamicOffset);
  682. dynamicOffset += e.length / 2;
  683. } else {
  684. // don't add length to dynamicOffset. it's already counted
  685. result += self.encodeWithOffset(types[i], solidityTypes[i], encodeds[i], dynamicOffset);
  686. }
  687. // TODO: figure out nested arrays
  688. });
  689. types.forEach(function (type, i) {
  690. if (isDynamic(solidityTypes[i], types[i])) {
  691. var e = self.encodeWithOffset(types[i], solidityTypes[i], encodeds[i], dynamicOffset);
  692. dynamicOffset += e.length / 2;
  693. result += e;
  694. }
  695. });
  696. return result;
  697. };
  698. // TODO: refactor whole encoding!
  699. SolidityCoder.prototype.encodeWithOffset = function (type, solidityType, encoded, offset) {
  700. var self = this;
  701. if (solidityType.isDynamicArray(type)) {
  702. return (function () {
  703. // offset was already set
  704. var nestedName = solidityType.nestedName(type);
  705. var nestedStaticPartLength = solidityType.staticPartLength(nestedName);
  706. var result = encoded[0];
  707. (function () {
  708. var previousLength = 2; // in int
  709. if (solidityType.isDynamicArray(nestedName)) {
  710. for (var i = 1; i < encoded.length; i++) {
  711. previousLength += +(encoded[i - 1])[0] || 0;
  712. result += f.formatInputInt(offset + i * nestedStaticPartLength + previousLength * 32).encode();
  713. }
  714. }
  715. })();
  716. // first element is length, skip it
  717. (function () {
  718. for (var i = 0; i < encoded.length - 1; i++) {
  719. var additionalOffset = result / 2;
  720. result += self.encodeWithOffset(nestedName, solidityType, encoded[i + 1], offset + additionalOffset);
  721. }
  722. })();
  723. return result;
  724. })();
  725. } else if (solidityType.isStaticArray(type)) {
  726. return (function () {
  727. var nestedName = solidityType.nestedName(type);
  728. var nestedStaticPartLength = solidityType.staticPartLength(nestedName);
  729. var result = "";
  730. if (solidityType.isDynamicArray(nestedName)) {
  731. (function () {
  732. var previousLength = 0; // in int
  733. for (var i = 0; i < encoded.length; i++) {
  734. // calculate length of previous item
  735. previousLength += +(encoded[i - 1] || [])[0] || 0;
  736. result += f.formatInputInt(offset + i * nestedStaticPartLength + previousLength * 32).encode();
  737. }
  738. })();
  739. }
  740. (function () {
  741. for (var i = 0; i < encoded.length; i++) {
  742. var additionalOffset = result / 2;
  743. result += self.encodeWithOffset(nestedName, solidityType, encoded[i], offset + additionalOffset);
  744. }
  745. })();
  746. return result;
  747. })();
  748. }
  749. return encoded;
  750. };
  751. /**
  752. * Should be used to decode bytes to plain param
  753. *
  754. * @method decodeParam
  755. * @param {String} type
  756. * @param {String} bytes
  757. * @return {Object} plain param
  758. */
  759. SolidityCoder.prototype.decodeParam = function (type, bytes) {
  760. return this.decodeParams([type], bytes)[0];
  761. };
  762. /**
  763. * Should be used to decode list of params
  764. *
  765. * @method decodeParam
  766. * @param {Array} types
  767. * @param {String} bytes
  768. * @return {Array} array of plain params
  769. */
  770. SolidityCoder.prototype.decodeParams = function (types, bytes) {
  771. var solidityTypes = this.getSolidityTypes(types);
  772. var offsets = this.getOffsets(types, solidityTypes);
  773. return solidityTypes.map(function (solidityType, index) {
  774. return solidityType.decode(bytes, offsets[index], types[index], index);
  775. });
  776. };
  777. SolidityCoder.prototype.getOffsets = function (types, solidityTypes) {
  778. var lengths = solidityTypes.map(function (solidityType, index) {
  779. return solidityType.staticPartLength(types[index]);
  780. });
  781. for (var i = 1; i < lengths.length; i++) {
  782. // sum with length of previous element
  783. lengths[i] += lengths[i - 1];
  784. }
  785. return lengths.map(function (length, index) {
  786. // remove the current length, so the length is sum of previous elements
  787. var staticPartLength = solidityTypes[index].staticPartLength(types[index]);
  788. return length - staticPartLength;
  789. });
  790. };
  791. SolidityCoder.prototype.getSolidityTypes = function (types) {
  792. var self = this;
  793. return types.map(function (type) {
  794. return self._requireType(type);
  795. });
  796. };
  797. var coder = new SolidityCoder([
  798. new SolidityTypeAddress(),
  799. new SolidityTypeBool(),
  800. new SolidityTypeInt(),
  801. new SolidityTypeUInt(),
  802. new SolidityTypeDynamicBytes(),
  803. new SolidityTypeBytes(),
  804. new SolidityTypeString(),
  805. new SolidityTypeReal(),
  806. new SolidityTypeUReal()
  807. ]);
  808. module.exports = coder;
  809. },{"./address":4,"./bool":5,"./bytes":6,"./dynamicbytes":8,"./formatters":9,"./int":10,"./real":12,"./string":13,"./uint":15,"./ureal":16}],8:[function(require,module,exports){
  810. var f = require('./formatters');
  811. var SolidityType = require('./type');
  812. var SolidityTypeDynamicBytes = function () {
  813. this._inputFormatter = f.formatInputDynamicBytes;
  814. this._outputFormatter = f.formatOutputDynamicBytes;
  815. };
  816. SolidityTypeDynamicBytes.prototype = new SolidityType({});
  817. SolidityTypeDynamicBytes.prototype.constructor = SolidityTypeDynamicBytes;
  818. SolidityTypeDynamicBytes.prototype.isType = function (name) {
  819. return !!name.match(/^bytes(\[([0-9]*)\])*$/);
  820. };
  821. SolidityTypeDynamicBytes.prototype.isDynamicType = function () {
  822. return true;
  823. };
  824. module.exports = SolidityTypeDynamicBytes;
  825. },{"./formatters":9,"./type":14}],9:[function(require,module,exports){
  826. /*
  827. This file is part of web3.js.
  828. web3.js is free software: you can redistribute it and/or modify
  829. it under the terms of the GNU Lesser General Public License as published by
  830. the Free Software Foundation, either version 3 of the License, or
  831. (at your option) any later version.
  832. web3.js is distributed in the hope that it will be useful,
  833. but WITHOUT ANY WARRANTY; without even the implied warranty of
  834. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  835. GNU Lesser General Public License for more details.
  836. You should have received a copy of the GNU Lesser General Public License
  837. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  838. */
  839. /**
  840. * @file formatters.js
  841. * @author Marek Kotewicz <[email protected]>
  842. * @date 2015
  843. */
  844. var BigNumber = require('bignumber.js');
  845. var utils = require('../utils/utils');
  846. var c = require('../utils/config');
  847. var SolidityParam = require('./param');
  848. /**
  849. * Formats input value to byte representation of int
  850. * If value is negative, return it's two's complement
  851. * If the value is floating point, round it down
  852. *
  853. * @method formatInputInt
  854. * @param {String|Number|BigNumber} value that needs to be formatted
  855. * @returns {SolidityParam}
  856. */
  857. var formatInputInt = function (value) {
  858. BigNumber.config(c.ETH_BIGNUMBER_ROUNDING_MODE);
  859. var result = utils.padLeft(utils.toTwosComplement(value).toString(16), 64);
  860. return new SolidityParam(result);
  861. };
  862. /**
  863. * Formats input bytes
  864. *
  865. * @method formatInputBytes
  866. * @param {String}
  867. * @returns {SolidityParam}
  868. */
  869. var formatInputBytes = function (value) {
  870. var result = utils.toHex(value).substr(2);
  871. var l = Math.floor((result.length + 63) / 64);
  872. result = utils.padRight(result, l * 64);
  873. return new SolidityParam(result);
  874. };
  875. /**
  876. * Formats input bytes
  877. *
  878. * @method formatDynamicInputBytes
  879. * @param {String}
  880. * @returns {SolidityParam}
  881. */
  882. var formatInputDynamicBytes = function (value) {
  883. var result = utils.toHex(value).substr(2);
  884. var length = result.length / 2;
  885. var l = Math.floor((result.length + 63) / 64);
  886. result = utils.padRight(result, l * 64);
  887. return new SolidityParam(formatInputInt(length).value + result);
  888. };
  889. /**
  890. * Formats input value to byte representation of string
  891. *
  892. * @method formatInputString
  893. * @param {String}
  894. * @returns {SolidityParam}
  895. */
  896. var formatInputString = function (value) {
  897. var result = utils.fromUtf8(value).substr(2);
  898. var length = result.length / 2;
  899. var l = Math.floor((result.length + 63) / 64);
  900. result = utils.padRight(result, l * 64);
  901. return new SolidityParam(formatInputInt(length).value + result);
  902. };
  903. /**
  904. * Formats input value to byte representation of bool
  905. *
  906. * @method formatInputBool
  907. * @param {Boolean}
  908. * @returns {SolidityParam}
  909. */
  910. var formatInputBool = function (value) {
  911. var result = '000000000000000000000000000000000000000000000000000000000000000' + (value ? '1' : '0');
  912. return new SolidityParam(result);
  913. };
  914. /**
  915. * Formats input value to byte representation of real
  916. * Values are multiplied by 2^m and encoded as integers
  917. *
  918. * @method formatInputReal
  919. * @param {String|Number|BigNumber}
  920. * @returns {SolidityParam}
  921. */
  922. var formatInputReal = function (value) {
  923. return formatInputInt(new BigNumber(value).times(new BigNumber(2).pow(128)));
  924. };
  925. /**
  926. * Check if input value is negative
  927. *
  928. * @method signedIsNegative
  929. * @param {String} value is hex format
  930. * @returns {Boolean} true if it is negative, otherwise false
  931. */
  932. var signedIsNegative = function (value) {
  933. return (new BigNumber(value.substr(0, 1), 16).toString(2).substr(0, 1)) === '1';
  934. };
  935. /**
  936. * Formats right-aligned output bytes to int
  937. *
  938. * @method formatOutputInt
  939. * @param {SolidityParam} param
  940. * @returns {BigNumber} right-aligned output bytes formatted to big number
  941. */
  942. var formatOutputInt = function (param) {
  943. var value = param.staticPart() || "0";
  944. // check if it's negative number
  945. // it it is, return two's complement
  946. if (signedIsNegative(value)) {
  947. return new BigNumber(value, 16).minus(new BigNumber('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16)).minus(1);
  948. }
  949. return new BigNumber(value, 16);
  950. };
  951. /**
  952. * Formats right-aligned output bytes to uint
  953. *
  954. * @method formatOutputUInt
  955. * @param {SolidityParam}
  956. * @returns {BigNumeber} right-aligned output bytes formatted to uint
  957. */
  958. var formatOutputUInt = function (param) {
  959. var value = param.staticPart() || "0";
  960. return new BigNumber(value, 16);
  961. };
  962. /**
  963. * Formats right-aligned output bytes to real
  964. *
  965. * @method formatOutputReal
  966. * @param {SolidityParam}
  967. * @returns {BigNumber} input bytes formatted to real
  968. */
  969. var formatOutputReal = function (param) {
  970. return formatOutputInt(param).dividedBy(new BigNumber(2).pow(128));
  971. };
  972. /**
  973. * Formats right-aligned output bytes to ureal
  974. *
  975. * @method formatOutputUReal
  976. * @param {SolidityParam}
  977. * @returns {BigNumber} input bytes formatted to ureal
  978. */
  979. var formatOutputUReal = function (param) {
  980. return formatOutputUInt(param).dividedBy(new BigNumber(2).pow(128));
  981. };
  982. /**
  983. * Should be used to format output bool
  984. *
  985. * @method formatOutputBool
  986. * @param {SolidityParam}
  987. * @returns {Boolean} right-aligned input bytes formatted to bool
  988. */
  989. var formatOutputBool = function (param) {
  990. return param.staticPart() === '0000000000000000000000000000000000000000000000000000000000000001' ? true : false;
  991. };
  992. /**
  993. * Should be used to format output bytes
  994. *
  995. * @method formatOutputBytes
  996. * @param {SolidityParam} left-aligned hex representation of string
  997. * @param {String} name type name
  998. * @returns {String} hex string
  999. */
  1000. var formatOutputBytes = function (param, name) {
  1001. var matches = name.match(/^bytes([0-9]*)/);
  1002. var size = parseInt(matches[1]);
  1003. return '0x' + param.staticPart().slice(0, 2 * size);
  1004. };
  1005. /**
  1006. * Should be used to format output bytes
  1007. *
  1008. * @method formatOutputDynamicBytes
  1009. * @param {SolidityParam} left-aligned hex representation of string
  1010. * @returns {String} hex string
  1011. */
  1012. var formatOutputDynamicBytes = function (param) {
  1013. var length = (new BigNumber(param.dynamicPart().slice(0, 64), 16)).toNumber() * 2;
  1014. return '0x' + param.dynamicPart().substr(64, length);
  1015. };
  1016. /**
  1017. * Should be used to format output string
  1018. *
  1019. * @method formatOutputString
  1020. * @param {SolidityParam} left-aligned hex representation of string
  1021. * @returns {String} ascii string
  1022. */
  1023. var formatOutputString = function (param) {
  1024. var length = (new BigNumber(param.dynamicPart().slice(0, 64), 16)).toNumber() * 2;
  1025. return utils.toUtf8(param.dynamicPart().substr(64, length));
  1026. };
  1027. /**
  1028. * Should be used to format output address
  1029. *
  1030. * @method formatOutputAddress
  1031. * @param {SolidityParam} right-aligned input bytes
  1032. * @returns {String} address
  1033. */
  1034. var formatOutputAddress = function (param) {
  1035. var value = param.staticPart();
  1036. return "0x" + value.slice(value.length - 40, value.length);
  1037. };
  1038. module.exports = {
  1039. formatInputInt: formatInputInt,
  1040. formatInputBytes: formatInputBytes,
  1041. formatInputDynamicBytes: formatInputDynamicBytes,
  1042. formatInputString: formatInputString,
  1043. formatInputBool: formatInputBool,
  1044. formatInputReal: formatInputReal,
  1045. formatOutputInt: formatOutputInt,
  1046. formatOutputUInt: formatOutputUInt,
  1047. formatOutputReal: formatOutputReal,
  1048. formatOutputUReal: formatOutputUReal,
  1049. formatOutputBool: formatOutputBool,
  1050. formatOutputBytes: formatOutputBytes,
  1051. formatOutputDynamicBytes: formatOutputDynamicBytes,
  1052. formatOutputString: formatOutputString,
  1053. formatOutputAddress: formatOutputAddress
  1054. };
  1055. },{"../utils/config":18,"../utils/utils":20,"./param":11,"bignumber.js":"bignumber.js"}],10:[function(require,module,exports){
  1056. var f = require('./formatters');
  1057. var SolidityType = require('./type');
  1058. /**
  1059. * SolidityTypeInt is a prootype that represents int type
  1060. * It matches:
  1061. * int
  1062. * int[]
  1063. * int[4]
  1064. * int[][]
  1065. * int[3][]
  1066. * int[][6][], ...
  1067. * int32
  1068. * int64[]
  1069. * int8[4]
  1070. * int256[][]
  1071. * int[3][]
  1072. * int64[][6][], ...
  1073. */
  1074. var SolidityTypeInt = function () {
  1075. this._inputFormatter = f.formatInputInt;
  1076. this._outputFormatter = f.formatOutputInt;
  1077. };
  1078. SolidityTypeInt.prototype = new SolidityType({});
  1079. SolidityTypeInt.prototype.constructor = SolidityTypeInt;
  1080. SolidityTypeInt.prototype.isType = function (name) {
  1081. return !!name.match(/^int([0-9]*)?(\[([0-9]*)\])*$/);
  1082. };
  1083. module.exports = SolidityTypeInt;
  1084. },{"./formatters":9,"./type":14}],11:[function(require,module,exports){
  1085. /*
  1086. This file is part of web3.js.
  1087. web3.js is free software: you can redistribute it and/or modify
  1088. it under the terms of the GNU Lesser General Public License as published by
  1089. the Free Software Foundation, either version 3 of the License, or
  1090. (at your option) any later version.
  1091. web3.js is distributed in the hope that it will be useful,
  1092. but WITHOUT ANY WARRANTY; without even the implied warranty of
  1093. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1094. GNU Lesser General Public License for more details.
  1095. You should have received a copy of the GNU Lesser General Public License
  1096. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  1097. */
  1098. /**
  1099. * @file param.js
  1100. * @author Marek Kotewicz <[email protected]>
  1101. * @date 2015
  1102. */
  1103. var utils = require('../utils/utils');
  1104. /**
  1105. * SolidityParam object prototype.
  1106. * Should be used when encoding, decoding solidity bytes
  1107. */
  1108. var SolidityParam = function (value, offset) {
  1109. this.value = value || '';
  1110. this.offset = offset; // offset in bytes
  1111. };
  1112. /**
  1113. * This method should be used to get length of params's dynamic part
  1114. *
  1115. * @method dynamicPartLength
  1116. * @returns {Number} length of dynamic part (in bytes)
  1117. */
  1118. SolidityParam.prototype.dynamicPartLength = function () {
  1119. return this.dynamicPart().length / 2;
  1120. };
  1121. /**
  1122. * This method should be used to create copy of solidity param with different offset
  1123. *
  1124. * @method withOffset
  1125. * @param {Number} offset length in bytes
  1126. * @returns {SolidityParam} new solidity param with applied offset
  1127. */
  1128. SolidityParam.prototype.withOffset = function (offset) {
  1129. return new SolidityParam(this.value, offset);
  1130. };
  1131. /**
  1132. * This method should be used to combine solidity params together
  1133. * eg. when appending an array
  1134. *
  1135. * @method combine
  1136. * @param {SolidityParam} param with which we should combine
  1137. * @param {SolidityParam} result of combination
  1138. */
  1139. SolidityParam.prototype.combine = function (param) {
  1140. return new SolidityParam(this.value + param.value);
  1141. };
  1142. /**
  1143. * This method should be called to check if param has dynamic size.
  1144. * If it has, it returns true, otherwise false
  1145. *
  1146. * @method isDynamic
  1147. * @returns {Boolean}
  1148. */
  1149. SolidityParam.prototype.isDynamic = function () {
  1150. return this.offset !== undefined;
  1151. };
  1152. /**
  1153. * This method should be called to transform offset to bytes
  1154. *
  1155. * @method offsetAsBytes
  1156. * @returns {String} bytes representation of offset
  1157. */
  1158. SolidityParam.prototype.offsetAsBytes = function () {
  1159. return !this.isDynamic() ? '' : utils.padLeft(utils.toTwosComplement(this.offset).toString(16), 64);
  1160. };
  1161. /**
  1162. * This method should be called to get static part of param
  1163. *
  1164. * @method staticPart
  1165. * @returns {String} offset if it is a dynamic param, otherwise value
  1166. */
  1167. SolidityParam.prototype.staticPart = function () {
  1168. if (!this.isDynamic()) {
  1169. return this.value;
  1170. }
  1171. return this.offsetAsBytes();
  1172. };
  1173. /**
  1174. * This method should be called to get dynamic part of param
  1175. *
  1176. * @method dynamicPart
  1177. * @returns {String} returns a value if it is a dynamic param, otherwise empty string
  1178. */
  1179. SolidityParam.prototype.dynamicPart = function () {
  1180. return this.isDynamic() ? this.value : '';
  1181. };
  1182. /**
  1183. * This method should be called to encode param
  1184. *
  1185. * @method encode
  1186. * @returns {String}
  1187. */
  1188. SolidityParam.prototype.encode = function () {
  1189. return this.staticPart() + this.dynamicPart();
  1190. };
  1191. /**
  1192. * This method should be called to encode array of params
  1193. *
  1194. * @method encodeList
  1195. * @param {Array[SolidityParam]} params
  1196. * @returns {String}
  1197. */
  1198. SolidityParam.encodeList = function (params) {
  1199. // updating offsets
  1200. var totalOffset = params.length * 32;
  1201. var offsetParams = params.map(function (param) {
  1202. if (!param.isDynamic()) {
  1203. return param;
  1204. }
  1205. var offset = totalOffset;
  1206. totalOffset += param.dynamicPartLength();
  1207. return param.withOffset(offset);
  1208. });
  1209. // encode everything!
  1210. return offsetParams.reduce(function (result, param) {
  1211. return result + param.dynamicPart();
  1212. }, offsetParams.reduce(function (result, param) {
  1213. return result + param.staticPart();
  1214. }, ''));
  1215. };
  1216. module.exports = SolidityParam;
  1217. },{"../utils/utils":20}],12:[function(require,module,exports){
  1218. var f = require('./formatters');
  1219. var SolidityType = require('./type');
  1220. /**
  1221. * SolidityTypeReal is a prootype that represents real type
  1222. * It matches:
  1223. * real
  1224. * real[]
  1225. * real[4]
  1226. * real[][]
  1227. * real[3][]
  1228. * real[][6][], ...
  1229. * real32
  1230. * real64[]
  1231. * real8[4]
  1232. * real256[][]
  1233. * real[3][]
  1234. * real64[][6][], ...
  1235. */
  1236. var SolidityTypeReal = function () {
  1237. this._inputFormatter = f.formatInputReal;
  1238. this._outputFormatter = f.formatOutputReal;
  1239. };
  1240. SolidityTypeReal.prototype = new SolidityType({});
  1241. SolidityTypeReal.prototype.constructor = SolidityTypeReal;
  1242. SolidityTypeReal.prototype.isType = function (name) {
  1243. return !!name.match(/real([0-9]*)?(\[([0-9]*)\])?/);
  1244. };
  1245. module.exports = SolidityTypeReal;
  1246. },{"./formatters":9,"./type":14}],13:[function(require,module,exports){
  1247. var f = require('./formatters');
  1248. var SolidityType = require('./type');
  1249. var SolidityTypeString = function () {
  1250. this._inputFormatter = f.formatInputString;
  1251. this._outputFormatter = f.formatOutputString;
  1252. };
  1253. SolidityTypeString.prototype = new SolidityType({});
  1254. SolidityTypeString.prototype.constructor = SolidityTypeString;
  1255. SolidityTypeString.prototype.isType = function (name) {
  1256. return !!name.match(/^string(\[([0-9]*)\])*$/);
  1257. };
  1258. SolidityTypeString.prototype.isDynamicType = function () {
  1259. return true;
  1260. };
  1261. module.exports = SolidityTypeString;
  1262. },{"./formatters":9,"./type":14}],14:[function(require,module,exports){
  1263. var f = require('./formatters');
  1264. var SolidityParam = require('./param');
  1265. /**
  1266. * SolidityType prototype is used to encode/decode solidity params of certain type
  1267. */
  1268. var SolidityType = function (config) {
  1269. this._inputFormatter = config.inputFormatter;
  1270. this._outputFormatter = config.outputFormatter;
  1271. };
  1272. /**
  1273. * Should be used to determine if this SolidityType do match given name
  1274. *
  1275. * @method isType
  1276. * @param {String} name
  1277. * @return {Bool} true if type match this SolidityType, otherwise false
  1278. */
  1279. SolidityType.prototype.isType = function (name) {
  1280. throw "this method should be overrwritten for type " + name;
  1281. };
  1282. /**
  1283. * Should be used to determine what is the length of static part in given type
  1284. *
  1285. * @method staticPartLength
  1286. * @param {String} name
  1287. * @return {Number} length of static part in bytes
  1288. */
  1289. SolidityType.prototype.staticPartLength = function (name) {
  1290. // If name isn't an array then treat it like a single element array.
  1291. return (this.nestedTypes(name) || ['[1]'])
  1292. .map(function (type) {
  1293. // the length of the nested array
  1294. return parseInt(type.slice(1, -1), 10) || 1;
  1295. })
  1296. .reduce(function (previous, current) {
  1297. return previous * current;
  1298. // all basic types are 32 bytes long
  1299. }, 32);
  1300. };
  1301. /**
  1302. * Should be used to determine if type is dynamic array
  1303. * eg:
  1304. * "type[]" => true
  1305. * "type[4]" => false
  1306. *
  1307. * @method isDynamicArray
  1308. * @param {String} name
  1309. * @return {Bool} true if the type is dynamic array
  1310. */
  1311. SolidityType.prototype.isDynamicArray = function (name) {
  1312. var nestedTypes = this.nestedTypes(name);
  1313. return !!nestedTypes && !nestedTypes[nestedTypes.length - 1].match(/[0-9]{1,}/g);
  1314. };
  1315. /**
  1316. * Should be used to determine if type is static array
  1317. * eg:
  1318. * "type[]" => false
  1319. * "type[4]" => true
  1320. *
  1321. * @method isStaticArray
  1322. * @param {String} name
  1323. * @return {Bool} true if the type is static array
  1324. */
  1325. SolidityType.prototype.isStaticArray = function (name) {
  1326. var nestedTypes = this.nestedTypes(name);
  1327. return !!nestedTypes && !!nestedTypes[nestedTypes.length - 1].match(/[0-9]{1,}/g);
  1328. };
  1329. /**
  1330. * Should return length of static array
  1331. * eg.
  1332. * "int[32]" => 32
  1333. * "int256[14]" => 14
  1334. * "int[2][3]" => 3
  1335. * "int" => 1
  1336. * "int[1]" => 1
  1337. * "int[]" => 1
  1338. *
  1339. * @method staticArrayLength
  1340. * @param {String} name
  1341. * @return {Number} static array length
  1342. */
  1343. SolidityType.prototype.staticArrayLength = function (name) {
  1344. var nestedTypes = this.nestedTypes(name);
  1345. if (nestedTypes) {
  1346. return parseInt(nestedTypes[nestedTypes.length - 1].match(/[0-9]{1,}/g) || 1);
  1347. }
  1348. return 1;
  1349. };
  1350. /**
  1351. * Should return nested type
  1352. * eg.
  1353. * "int[32]" => "int"
  1354. * "int256[14]" => "int256"
  1355. * "int[2][3]" => "int[2]"
  1356. * "int" => "int"
  1357. * "int[]" => "int"
  1358. *
  1359. * @method nestedName
  1360. * @param {String} name
  1361. * @return {String} nested name
  1362. */
  1363. SolidityType.prototype.nestedName = function (name) {
  1364. // remove last [] in name
  1365. var nestedTypes = this.nestedTypes(name);
  1366. if (!nestedTypes) {
  1367. return name;
  1368. }
  1369. return name.substr(0, name.length - nestedTypes[nestedTypes.length - 1].length);
  1370. };
  1371. /**
  1372. * Should return true if type has dynamic size by default
  1373. * such types are "string", "bytes"
  1374. *
  1375. * @method isDynamicType
  1376. * @param {String} name
  1377. * @return {Bool} true if is dynamic, otherwise false
  1378. */
  1379. SolidityType.prototype.isDynamicType = function () {
  1380. return false;
  1381. };
  1382. /**
  1383. * Should return array of nested types
  1384. * eg.
  1385. * "int[2][3][]" => ["[2]", "[3]", "[]"]
  1386. * "int[] => ["[]"]
  1387. * "int" => null
  1388. *
  1389. * @method nestedTypes
  1390. * @param {String} name
  1391. * @return {Array} array of nested types
  1392. */
  1393. SolidityType.prototype.nestedTypes = function (name) {
  1394. // return list of strings eg. "[]", "[3]", "[]", "[2]"
  1395. return name.match(/(\[[0-9]*\])/g);
  1396. };
  1397. /**
  1398. * Should be used to encode the value
  1399. *
  1400. * @method encode
  1401. * @param {Object} value
  1402. * @param {String} name
  1403. * @return {String} encoded value
  1404. */
  1405. SolidityType.prototype.encode = function (value, name) {
  1406. var self = this;
  1407. if (this.isDynamicArray(name)) {
  1408. return (function () {
  1409. var length = value.length; // in int
  1410. var nestedName = self.nestedName(name);
  1411. var result = [];
  1412. result.push(f.formatInputInt(length).encode());
  1413. value.forEach(function (v) {
  1414. result.push(self.encode(v, nestedName));
  1415. });
  1416. return result;
  1417. })();
  1418. } else if (this.isStaticArray(name)) {
  1419. return (function () {
  1420. var length = self.staticArrayLength(name); // in int
  1421. var nestedName = self.nestedName(name);
  1422. var result = [];
  1423. for (var i = 0; i < length; i++) {
  1424. result.push(self.encode(value[i], nestedName));
  1425. }
  1426. return result;
  1427. })();
  1428. }
  1429. return this._inputFormatter(value, name).encode();
  1430. };
  1431. /**
  1432. * Should be used to decode value from bytes
  1433. *
  1434. * @method decode
  1435. * @param {String} bytes
  1436. * @param {Number} offset in bytes
  1437. * @param {String} name type name
  1438. * @returns {Object} decoded value
  1439. */
  1440. SolidityType.prototype.decode = function (bytes, offset, name) {
  1441. var self = this;
  1442. if (this.isDynamicArray(name)) {
  1443. return (function () {
  1444. var arrayOffset = parseInt('0x' + bytes.substr(offset * 2, 64)); // in bytes
  1445. var length = parseInt('0x' + bytes.substr(arrayOffset * 2, 64)); // in int
  1446. var arrayStart = arrayOffset + 32; // array starts after length; // in bytes
  1447. var nestedName = self.nestedName(name);
  1448. var nestedStaticPartLength = self.staticPartLength(nestedName); // in bytes
  1449. var roundedNestedStaticPartLength = Math.floor((nestedStaticPartLength + 31) / 32) * 32;
  1450. var result = [];
  1451. for (var i = 0; i < length * roundedNestedStaticPartLength; i += roundedNestedStaticPartLength) {
  1452. result.push(self.decode(bytes, arrayStart + i, nestedName));
  1453. }
  1454. return result;
  1455. })();
  1456. } else if (this.isStaticArray(name)) {
  1457. return (function () {
  1458. var length = self.staticArrayLength(name); // in int
  1459. var arrayStart = offset; // in bytes
  1460. var nestedName = self.nestedName(name);
  1461. var nestedStaticPartLength = self.staticPartLength(nestedName); // in bytes
  1462. var roundedNestedStaticPartLength = Math.floor((nestedStaticPartLength + 31) / 32) * 32;
  1463. var result = [];
  1464. for (var i = 0; i < length * roundedNestedStaticPartLength; i += roundedNestedStaticPartLength) {
  1465. result.push(self.decode(bytes, arrayStart + i, nestedName));
  1466. }
  1467. return result;
  1468. })();
  1469. } else if (this.isDynamicType(name)) {
  1470. return (function () {
  1471. var dynamicOffset = parseInt('0x' + bytes.substr(offset * 2, 64)); // in bytes
  1472. var length = parseInt('0x' + bytes.substr(dynamicOffset * 2, 64)); // in bytes
  1473. var roundedLength = Math.floor((length + 31) / 32); // in int
  1474. var param = new SolidityParam(bytes.substr(dynamicOffset * 2, ( 1 + roundedLength) * 64), 0);
  1475. return self._outputFormatter(param, name);
  1476. })();
  1477. }
  1478. var length = this.staticPartLength(name);
  1479. var param = new SolidityParam(bytes.substr(offset * 2, length * 2));
  1480. return this._outputFormatter(param, name);
  1481. };
  1482. module.exports = SolidityType;
  1483. },{"./formatters":9,"./param":11}],15:[function(require,module,exports){
  1484. var f = require('./formatters');
  1485. var SolidityType = require('./type');
  1486. /**
  1487. * SolidityTypeUInt is a prootype that represents uint type
  1488. * It matches:
  1489. * uint
  1490. * uint[]
  1491. * uint[4]
  1492. * uint[][]
  1493. * uint[3][]
  1494. * uint[][6][], ...
  1495. * uint32
  1496. * uint64[]
  1497. * uint8[4]
  1498. * uint256[][]
  1499. * uint[3][]
  1500. * uint64[][6][], ...
  1501. */
  1502. var SolidityTypeUInt = function () {
  1503. this._inputFormatter = f.formatInputInt;
  1504. this._outputFormatter = f.formatOutputUInt;
  1505. };
  1506. SolidityTypeUInt.prototype = new SolidityType({});
  1507. SolidityTypeUInt.prototype.constructor = SolidityTypeUInt;
  1508. SolidityTypeUInt.prototype.isType = function (name) {
  1509. return !!name.match(/^uint([0-9]*)?(\[([0-9]*)\])*$/);
  1510. };
  1511. module.exports = SolidityTypeUInt;
  1512. },{"./formatters":9,"./type":14}],16:[function(require,module,exports){
  1513. var f = require('./formatters');
  1514. var SolidityType = require('./type');
  1515. /**
  1516. * SolidityTypeUReal is a prootype that represents ureal type
  1517. * It matches:
  1518. * ureal
  1519. * ureal[]
  1520. * ureal[4]
  1521. * ureal[][]
  1522. * ureal[3][]
  1523. * ureal[][6][], ...
  1524. * ureal32
  1525. * ureal64[]
  1526. * ureal8[4]
  1527. * ureal256[][]
  1528. * ureal[3][]
  1529. * ureal64[][6][], ...
  1530. */
  1531. var SolidityTypeUReal = function () {
  1532. this._inputFormatter = f.formatInputReal;
  1533. this._outputFormatter = f.formatOutputUReal;
  1534. };
  1535. SolidityTypeUReal.prototype = new SolidityType({});
  1536. SolidityTypeUReal.prototype.constructor = SolidityTypeUReal;
  1537. SolidityTypeUReal.prototype.isType = function (name) {
  1538. return !!name.match(/^ureal([0-9]*)?(\[([0-9]*)\])*$/);
  1539. };
  1540. module.exports = SolidityTypeUReal;
  1541. },{"./formatters":9,"./type":14}],17:[function(require,module,exports){
  1542. 'use strict';
  1543. // go env doesn't have and need XMLHttpRequest
  1544. if (typeof XMLHttpRequest === 'undefined') {
  1545. exports.XMLHttpRequest = {};
  1546. } else {
  1547. exports.XMLHttpRequest = XMLHttpRequest; // jshint ignore:line
  1548. }
  1549. },{}],18:[function(require,module,exports){
  1550. /*
  1551. This file is part of web3.js.
  1552. web3.js is free software: you can redistribute it and/or modify
  1553. it under the terms of the GNU Lesser General Public License as published by
  1554. the Free Software Foundation, either version 3 of the License, or
  1555. (at your option) any later version.
  1556. web3.js is distributed in the hope that it will be useful,
  1557. but WITHOUT ANY WARRANTY; without even the implied warranty of
  1558. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1559. GNU Lesser General Public License for more details.
  1560. You should have received a copy of the GNU Lesser General Public License
  1561. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  1562. */
  1563. /** @file config.js
  1564. * @authors:
  1565. * Marek Kotewicz <[email protected]>
  1566. * @date 2015
  1567. */
  1568. /**
  1569. * Utils
  1570. *
  1571. * @module utils
  1572. */
  1573. /**
  1574. * Utility functions
  1575. *
  1576. * @class [utils] config
  1577. * @constructor
  1578. */
  1579. /// required to define ETH_BIGNUMBER_ROUNDING_MODE
  1580. var BigNumber = require('bignumber.js');
  1581. var ETH_UNITS = [
  1582. 'wei',
  1583. 'kwei',
  1584. 'Mwei',
  1585. 'Gwei',
  1586. 'szabo',
  1587. 'finney',
  1588. 'femtoether',
  1589. 'picoether',
  1590. 'nanoether',
  1591. 'microether',
  1592. 'milliether',
  1593. 'nano',
  1594. 'micro',
  1595. 'milli',
  1596. 'ether',
  1597. 'grand',
  1598. 'Mether',
  1599. 'Gether',
  1600. 'Tether',
  1601. 'Pether',
  1602. 'Eether',
  1603. 'Zether',
  1604. 'Yether',
  1605. 'Nether',
  1606. 'Dether',
  1607. 'Vether',
  1608. 'Uether'
  1609. ];
  1610. module.exports = {
  1611. ETH_PADDING: 32,
  1612. ETH_SIGNATURE_LENGTH: 4,
  1613. ETH_UNITS: ETH_UNITS,
  1614. ETH_BIGNUMBER_ROUNDING_MODE: { ROUNDING_MODE: BigNumber.ROUND_DOWN },
  1615. ETH_POLLING_TIMEOUT: 1000/2,
  1616. defaultBlock: 'latest',
  1617. defaultAccount: undefined
  1618. };
  1619. },{"bignumber.js":"bignumber.js"}],19:[function(require,module,exports){
  1620. /*
  1621. This file is part of web3.js.
  1622. web3.js is free software: you can redistribute it and/or modify
  1623. it under the terms of the GNU Lesser General Public License as published by
  1624. the Free Software Foundation, either version 3 of the License, or
  1625. (at your option) any later version.
  1626. web3.js is distributed in the hope that it will be useful,
  1627. but WITHOUT ANY WARRANTY; without even the implied warranty of
  1628. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1629. GNU Lesser General Public License for more details.
  1630. You should have received a copy of the GNU Lesser General Public License
  1631. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  1632. */
  1633. /**
  1634. * @file sha3.js
  1635. * @author Marek Kotewicz <[email protected]>
  1636. * @date 2015
  1637. */
  1638. var CryptoJS = require('crypto-js');
  1639. var sha3 = require('crypto-js/sha3');
  1640. module.exports = function (value, options) {
  1641. if (options && options.encoding === 'hex') {
  1642. if (value.length > 2 && value.substr(0, 2) === '0x') {
  1643. value = value.substr(2);
  1644. }
  1645. value = CryptoJS.enc.Hex.parse(value);
  1646. }
  1647. return sha3(value, {
  1648. outputLength: 256
  1649. }).toString();
  1650. };
  1651. },{"crypto-js":59,"crypto-js/sha3":80}],20:[function(require,module,exports){
  1652. /*
  1653. This file is part of web3.js.
  1654. web3.js is free software: you can redistribute it and/or modify
  1655. it under the terms of the GNU Lesser General Public License as published by
  1656. the Free Software Foundation, either version 3 of the License, or
  1657. (at your option) any later version.
  1658. web3.js is distributed in the hope that it will be useful,
  1659. but WITHOUT ANY WARRANTY; without even the implied warranty of
  1660. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1661. GNU Lesser General Public License for more details.
  1662. You should have received a copy of the GNU Lesser General Public License
  1663. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  1664. */
  1665. /**
  1666. * @file utils.js
  1667. * @author Marek Kotewicz <[email protected]>
  1668. * @date 2015
  1669. */
  1670. /**
  1671. * Utils
  1672. *
  1673. * @module utils
  1674. */
  1675. /**
  1676. * Utility functions
  1677. *
  1678. * @class [utils] utils
  1679. * @constructor
  1680. */
  1681. var BigNumber = require('bignumber.js');
  1682. var sha3 = require('./sha3.js');
  1683. var utf8 = require('utf8');
  1684. var unitMap = {
  1685. 'noether': '0',
  1686. 'wei': '1',
  1687. 'kwei': '1000',
  1688. 'Kwei': '1000',
  1689. 'babbage': '1000',
  1690. 'femtoether': '1000',
  1691. 'mwei': '1000000',
  1692. 'Mwei': '1000000',
  1693. 'lovelace': '1000000',
  1694. 'picoether': '1000000',
  1695. 'gwei': '1000000000',
  1696. 'Gwei': '1000000000',
  1697. 'shannon': '1000000000',
  1698. 'nanoether': '1000000000',
  1699. 'nano': '1000000000',
  1700. 'szabo': '1000000000000',
  1701. 'microether': '1000000000000',
  1702. 'micro': '1000000000000',
  1703. 'finney': '1000000000000000',
  1704. 'milliether': '1000000000000000',
  1705. 'milli': '1000000000000000',
  1706. 'ether': '1000000000000000000',
  1707. 'kether': '1000000000000000000000',
  1708. 'grand': '1000000000000000000000',
  1709. 'mether': '1000000000000000000000000',
  1710. 'gether': '1000000000000000000000000000',
  1711. 'tether': '1000000000000000000000000000000'
  1712. };
  1713. /**
  1714. * Should be called to pad string to expected length
  1715. *
  1716. * @method padLeft
  1717. * @param {String} string to be padded
  1718. * @param {Number} characters that result string should have
  1719. * @param {String} sign, by default 0
  1720. * @returns {String} right aligned string
  1721. */
  1722. var padLeft = function (string, chars, sign) {
  1723. return new Array(chars - string.length + 1).join(sign ? sign : "0") + string;
  1724. };
  1725. /**
  1726. * Should be called to pad string to expected length
  1727. *
  1728. * @method padRight
  1729. * @param {String} string to be padded
  1730. * @param {Number} characters that result string should have
  1731. * @param {String} sign, by default 0
  1732. * @returns {String} right aligned string
  1733. */
  1734. var padRight = function (string, chars, sign) {
  1735. return string + (new Array(chars - string.length + 1).join(sign ? sign : "0"));
  1736. };
  1737. /**
  1738. * Should be called to get utf8 from it's hex representation
  1739. *
  1740. * @method toUtf8
  1741. * @param {String} string in hex
  1742. * @returns {String} ascii string representation of hex value
  1743. */
  1744. var toUtf8 = function(hex) {
  1745. // Find termination
  1746. var str = "";
  1747. var i = 0, l = hex.length;
  1748. if (hex.substring(0, 2) === '0x') {
  1749. i = 2;
  1750. }
  1751. for (; i < l; i+=2) {
  1752. var code = parseInt(hex.substr(i, 2), 16);
  1753. if (code === 0)
  1754. break;
  1755. str += String.fromCharCode(code);
  1756. }
  1757. return utf8.decode(str);
  1758. };
  1759. /**
  1760. * Should be called to get ascii from it's hex representation
  1761. *
  1762. * @method toAscii
  1763. * @param {String} string in hex
  1764. * @returns {String} ascii string representation of hex value
  1765. */
  1766. var toAscii = function(hex) {
  1767. // Find termination
  1768. var str = "";
  1769. var i = 0, l = hex.length;
  1770. if (hex.substring(0, 2) === '0x') {
  1771. i = 2;
  1772. }
  1773. for (; i < l; i+=2) {
  1774. var code = parseInt(hex.substr(i, 2), 16);
  1775. str += String.fromCharCode(code);
  1776. }
  1777. return str;
  1778. };
  1779. /**
  1780. * Should be called to get hex representation (prefixed by 0x) of utf8 string
  1781. *
  1782. * @method fromUtf8
  1783. * @param {String} string
  1784. * @param {Number} optional padding
  1785. * @returns {String} hex representation of input string
  1786. */
  1787. var fromUtf8 = function(str) {
  1788. str = utf8.encode(str);
  1789. var hex = "";
  1790. for(var i = 0; i < str.length; i++) {
  1791. var code = str.charCodeAt(i);
  1792. if (code === 0)
  1793. break;
  1794. var n = code.toString(16);
  1795. hex += n.length < 2 ? '0' + n : n;
  1796. }
  1797. return "0x" + hex;
  1798. };
  1799. /**
  1800. * Should be called to get hex representation (prefixed by 0x) of ascii string
  1801. *
  1802. * @method fromAscii
  1803. * @param {String} string
  1804. * @param {Number} optional padding
  1805. * @returns {String} hex representation of input string
  1806. */
  1807. var fromAscii = function(str) {
  1808. var hex = "";
  1809. for(var i = 0; i < str.length; i++) {
  1810. var code = str.charCodeAt(i);
  1811. var n = code.toString(16);
  1812. hex += n.length < 2 ? '0' + n : n;
  1813. }
  1814. return "0x" + hex;
  1815. };
  1816. /**
  1817. * Should be used to create full function/event name from json abi
  1818. *
  1819. * @method transformToFullName
  1820. * @param {Object} json-abi
  1821. * @return {String} full fnction/event name
  1822. */
  1823. var transformToFullName = function (json) {
  1824. if (json.name.indexOf('(') !== -1) {
  1825. return json.name;
  1826. }
  1827. var typeName = json.inputs.map(function(i){return i.type; }).join();
  1828. return json.name + '(' + typeName + ')';
  1829. };
  1830. /**
  1831. * Should be called to get display name of contract function
  1832. *
  1833. * @method extractDisplayName
  1834. * @param {String} name of function/event
  1835. * @returns {String} display name for function/event eg. multiply(uint256) -> multiply
  1836. */
  1837. var extractDisplayName = function (name) {
  1838. var length = name.indexOf('(');
  1839. return length !== -1 ? name.substr(0, length) : name;
  1840. };
  1841. /// @returns overloaded part of function/event name
  1842. var extractTypeName = function (name) {
  1843. /// TODO: make it invulnerable
  1844. var length = name.indexOf('(');
  1845. return length !== -1 ? name.substr(length + 1, name.length - 1 - (length + 1)).replace(' ', '') : "";
  1846. };
  1847. /**
  1848. * Converts value to it's decimal representation in string
  1849. *
  1850. * @method toDecimal
  1851. * @param {String|Number|BigNumber}
  1852. * @return {String}
  1853. */
  1854. var toDecimal = function (value) {
  1855. return toBigNumber(value).toNumber();
  1856. };
  1857. /**
  1858. * Converts value to it's hex representation
  1859. *
  1860. * @method fromDecimal
  1861. * @param {String|Number|BigNumber}
  1862. * @return {String}
  1863. */
  1864. var fromDecimal = function (value) {
  1865. var number = toBigNumber(value);
  1866. var result = number.toString(16);
  1867. return number.lessThan(0) ? '-0x' + result.substr(1) : '0x' + result;
  1868. };
  1869. /**
  1870. * Auto converts any given value into it's hex representation.
  1871. *
  1872. * And even stringifys objects before.
  1873. *
  1874. * @method toHex
  1875. * @param {String|Number|BigNumber|Object}
  1876. * @return {String}
  1877. */
  1878. var toHex = function (val) {
  1879. /*jshint maxcomplexity: 8 */
  1880. if (isBoolean(val))
  1881. return fromDecimal(+val);
  1882. if (isBigNumber(val))
  1883. return fromDecimal(val);
  1884. if (isObject(val))
  1885. return fromUtf8(JSON.stringify(val));
  1886. // if its a negative number, pass it through fromDecimal
  1887. if (isString(val)) {
  1888. if (val.indexOf('-0x') === 0)
  1889. return fromDecimal(val);
  1890. else if(val.indexOf('0x') === 0)
  1891. return val;
  1892. else if (!isFinite(val))
  1893. return fromAscii(val);
  1894. }
  1895. return fromDecimal(val);
  1896. };
  1897. /**
  1898. * Returns value of unit in Wei
  1899. *
  1900. * @method getValueOfUnit
  1901. * @param {String} unit the unit to convert to, default ether
  1902. * @returns {BigNumber} value of the unit (in Wei)
  1903. * @throws error if the unit is not correct:w
  1904. */
  1905. var getValueOfUnit = function (unit) {
  1906. unit = unit ? unit.toLowerCase() : 'ether';
  1907. var unitValue = unitMap[unit];
  1908. if (unitValue === undefined) {
  1909. throw new Error('This unit doesn\'t exists, please use the one of the following units' + JSON.stringify(unitMap, null, 2));
  1910. }
  1911. return new BigNumber(unitValue, 10);
  1912. };
  1913. /**
  1914. * Takes a number of wei and converts it to any other ether unit.
  1915. *
  1916. * Possible units are:
  1917. * SI Short SI Full Effigy Other
  1918. * - kwei femtoether babbage
  1919. * - mwei picoether lovelace
  1920. * - gwei nanoether shannon nano
  1921. * - -- microether szabo micro
  1922. * - -- milliether finney milli
  1923. * - ether -- --
  1924. * - kether -- grand
  1925. * - mether
  1926. * - gether
  1927. * - tether
  1928. *
  1929. * @method fromWei
  1930. * @param {Number|String} number can be a number, number string or a HEX of a decimal
  1931. * @param {String} unit the unit to convert to, default ether
  1932. * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number
  1933. */
  1934. var fromWei = function(number, unit) {
  1935. var returnValue = toBigNumber(number).dividedBy(getValueOfUnit(unit));
  1936. return isBigNumber(number) ? returnValue : returnValue.toString(10);
  1937. };
  1938. /**
  1939. * Takes a number of a unit and converts it to wei.
  1940. *
  1941. * Possible units are:
  1942. * SI Short SI Full Effigy Other
  1943. * - kwei femtoether babbage
  1944. * - mwei picoether lovelace
  1945. * - gwei nanoether shannon nano
  1946. * - -- microether szabo micro
  1947. * - -- microether szabo micro
  1948. * - -- milliether finney milli
  1949. * - ether -- --
  1950. * - kether -- grand
  1951. * - mether
  1952. * - gether
  1953. * - tether
  1954. *
  1955. * @method toWei
  1956. * @param {Number|String|BigNumber} number can be a number, number string or a HEX of a decimal
  1957. * @param {String} unit the unit to convert from, default ether
  1958. * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number
  1959. */
  1960. var toWei = function(number, unit) {
  1961. var returnValue = toBigNumber(number).times(getValueOfUnit(unit));
  1962. return isBigNumber(number) ? returnValue : returnValue.toString(10);
  1963. };
  1964. /**
  1965. * Takes an input and transforms it into an bignumber
  1966. *
  1967. * @method toBigNumber
  1968. * @param {Number|String|BigNumber} a number, string, HEX string or BigNumber
  1969. * @return {BigNumber} BigNumber
  1970. */
  1971. var toBigNumber = function(number) {
  1972. /*jshint maxcomplexity:5 */
  1973. number = number || 0;
  1974. if (isBigNumber(number))
  1975. return number;
  1976. if (isString(number) && (number.indexOf('0x') === 0 || number.indexOf('-0x') === 0)) {
  1977. return new BigNumber(number.replace('0x',''), 16);
  1978. }
  1979. return new BigNumber(number.toString(10), 10);
  1980. };
  1981. /**
  1982. * Takes and input transforms it into bignumber and if it is negative value, into two's complement
  1983. *
  1984. * @method toTwosComplement
  1985. * @param {Number|String|BigNumber}
  1986. * @return {BigNumber}
  1987. */
  1988. var toTwosComplement = function (number) {
  1989. var bigNumber = toBigNumber(number).round();
  1990. if (bigNumber.lessThan(0)) {
  1991. return new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).plus(bigNumber).plus(1);
  1992. }
  1993. return bigNumber;
  1994. };
  1995. /**
  1996. * Checks if the given string is strictly an address
  1997. *
  1998. * @method isStrictAddress
  1999. * @param {String} address the given HEX adress
  2000. * @return {Boolean}
  2001. */
  2002. var isStrictAddress = function (address) {
  2003. return /^0x[0-9a-f]{40}$/i.test(address);
  2004. };
  2005. /**
  2006. * Checks if the given string is an address
  2007. *
  2008. * @method isAddress
  2009. * @param {String} address the given HEX adress
  2010. * @return {Boolean}
  2011. */
  2012. var isAddress = function (address) {
  2013. if (!/^(0x)?[0-9a-f]{40}$/i.test(address)) {
  2014. // check if it has the basic requirements of an address
  2015. return false;
  2016. } else if (/^(0x)?[0-9a-f]{40}$/.test(address) || /^(0x)?[0-9A-F]{40}$/.test(address)) {
  2017. // If it's all small caps or all all caps, return true
  2018. return true;
  2019. } else {
  2020. // Otherwise check each case
  2021. return isChecksumAddress(address);
  2022. }
  2023. };
  2024. /**
  2025. * Checks if the given string is a checksummed address
  2026. *
  2027. * @method isChecksumAddress
  2028. * @param {String} address the given HEX adress
  2029. * @return {Boolean}
  2030. */
  2031. var isChecksumAddress = function (address) {
  2032. // Check each case
  2033. address = address.replace('0x','');
  2034. var addressHash = sha3(address.toLowerCase());
  2035. for (var i = 0; i < 40; i++ ) {
  2036. // the nth letter should be uppercase if the nth digit of casemap is 1
  2037. if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) || (parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) {
  2038. return false;
  2039. }
  2040. }
  2041. return true;
  2042. };
  2043. /**
  2044. * Makes a checksum address
  2045. *
  2046. * @method toChecksumAddress
  2047. * @param {String} address the given HEX adress
  2048. * @return {String}
  2049. */
  2050. var toChecksumAddress = function (address) {
  2051. if (typeof address === 'undefined') return '';
  2052. address = address.toLowerCase().replace('0x','');
  2053. var addressHash = sha3(address);
  2054. var checksumAddress = '0x';
  2055. for (var i = 0; i < address.length; i++ ) {
  2056. // If ith character is 9 to f then make it uppercase
  2057. if (parseInt(addressHash[i], 16) > 7) {
  2058. checksumAddress += address[i].toUpperCase();
  2059. } else {
  2060. checksumAddress += address[i];
  2061. }
  2062. }
  2063. return checksumAddress;
  2064. };
  2065. /**
  2066. * Transforms given string to valid 20 bytes-length addres with 0x prefix
  2067. *
  2068. * @method toAddress
  2069. * @param {String} address
  2070. * @return {String} formatted address
  2071. */
  2072. var toAddress = function (address) {
  2073. if (isStrictAddress(address)) {
  2074. return address;
  2075. }
  2076. if (/^[0-9a-f]{40}$/.test(address)) {
  2077. return '0x' + address;
  2078. }
  2079. return '0x' + padLeft(toHex(address).substr(2), 40);
  2080. };
  2081. /**
  2082. * Returns true if object is BigNumber, otherwise false
  2083. *
  2084. * @method isBigNumber
  2085. * @param {Object}
  2086. * @return {Boolean}
  2087. */
  2088. var isBigNumber = function (object) {
  2089. return object instanceof BigNumber ||
  2090. (object && object.constructor && object.constructor.name === 'BigNumber');
  2091. };
  2092. /**
  2093. * Returns true if object is string, otherwise false
  2094. *
  2095. * @method isString
  2096. * @param {Object}
  2097. * @return {Boolean}
  2098. */
  2099. var isString = function (object) {
  2100. return typeof object === 'string' ||
  2101. (object && object.constructor && object.constructor.name === 'String');
  2102. };
  2103. /**
  2104. * Returns true if object is function, otherwise false
  2105. *
  2106. * @method isFunction
  2107. * @param {Object}
  2108. * @return {Boolean}
  2109. */
  2110. var isFunction = function (object) {
  2111. return typeof object === 'function';
  2112. };
  2113. /**
  2114. * Returns true if object is Objet, otherwise false
  2115. *
  2116. * @method isObject
  2117. * @param {Object}
  2118. * @return {Boolean}
  2119. */
  2120. var isObject = function (object) {
  2121. return typeof object === 'object';
  2122. };
  2123. /**
  2124. * Returns true if object is boolean, otherwise false
  2125. *
  2126. * @method isBoolean
  2127. * @param {Object}
  2128. * @return {Boolean}
  2129. */
  2130. var isBoolean = function (object) {
  2131. return typeof object === 'boolean';
  2132. };
  2133. /**
  2134. * Returns true if object is array, otherwise false
  2135. *
  2136. * @method isArray
  2137. * @param {Object}
  2138. * @return {Boolean}
  2139. */
  2140. var isArray = function (object) {
  2141. return object instanceof Array;
  2142. };
  2143. /**
  2144. * Returns true if given string is valid json object
  2145. *
  2146. * @method isJson
  2147. * @param {String}
  2148. * @return {Boolean}
  2149. */
  2150. var isJson = function (str) {
  2151. try {
  2152. return !!JSON.parse(str);
  2153. } catch (e) {
  2154. return false;
  2155. }
  2156. };
  2157. module.exports = {
  2158. padLeft: padLeft,
  2159. padRight: padRight,
  2160. toHex: toHex,
  2161. toDecimal: toDecimal,
  2162. fromDecimal: fromDecimal,
  2163. toUtf8: toUtf8,
  2164. toAscii: toAscii,
  2165. fromUtf8: fromUtf8,
  2166. fromAscii: fromAscii,
  2167. transformToFullName: transformToFullName,
  2168. extractDisplayName: extractDisplayName,
  2169. extractTypeName: extractTypeName,
  2170. toWei: toWei,
  2171. fromWei: fromWei,
  2172. toBigNumber: toBigNumber,
  2173. toTwosComplement: toTwosComplement,
  2174. toAddress: toAddress,
  2175. isBigNumber: isBigNumber,
  2176. isStrictAddress: isStrictAddress,
  2177. isAddress: isAddress,
  2178. isChecksumAddress: isChecksumAddress,
  2179. toChecksumAddress: toChecksumAddress,
  2180. isFunction: isFunction,
  2181. isString: isString,
  2182. isObject: isObject,
  2183. isBoolean: isBoolean,
  2184. isArray: isArray,
  2185. isJson: isJson
  2186. };
  2187. },{"./sha3.js":19,"bignumber.js":"bignumber.js","utf8":85}],21:[function(require,module,exports){
  2188. module.exports={
  2189. "version": "0.18.2"
  2190. }
  2191. },{}],22:[function(require,module,exports){
  2192. /*
  2193. This file is part of web3.js.
  2194. web3.js is free software: you can redistribute it and/or modify
  2195. it under the terms of the GNU Lesser General Public License as published by
  2196. the Free Software Foundation, either version 3 of the License, or
  2197. (at your option) any later version.
  2198. web3.js is distributed in the hope that it will be useful,
  2199. but WITHOUT ANY WARRANTY; without even the implied warranty of
  2200. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2201. GNU Lesser General Public License for more details.
  2202. You should have received a copy of the GNU Lesser General Public License
  2203. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  2204. */
  2205. /**
  2206. * @file web3.js
  2207. * @authors:
  2208. * Jeffrey Wilcke <[email protected]>
  2209. * Marek Kotewicz <[email protected]>
  2210. * Marian Oancea <[email protected]>
  2211. * Fabian Vogelsteller <[email protected]>
  2212. * Gav Wood <[email protected]>
  2213. * @date 2014
  2214. */
  2215. var RequestManager = require('./web3/requestmanager');
  2216. var Iban = require('./web3/iban');
  2217. var Eth = require('./web3/methods/eth');
  2218. var DB = require('./web3/methods/db');
  2219. var Shh = require('./web3/methods/shh');
  2220. var Net = require('./web3/methods/net');
  2221. var Personal = require('./web3/methods/personal');
  2222. var Swarm = require('./web3/methods/swarm');
  2223. var Settings = require('./web3/settings');
  2224. var version = require('./version.json');
  2225. var utils = require('./utils/utils');
  2226. var sha3 = require('./utils/sha3');
  2227. var extend = require('./web3/extend');
  2228. var Batch = require('./web3/batch');
  2229. var Property = require('./web3/property');
  2230. var HttpProvider = require('./web3/httpprovider');
  2231. var IpcProvider = require('./web3/ipcprovider');
  2232. var BigNumber = require('bignumber.js');
  2233. function Web3 (provider) {
  2234. this._requestManager = new RequestManager(provider);
  2235. this.currentProvider = provider;
  2236. this.eth = new Eth(this);
  2237. this.db = new DB(this);
  2238. this.shh = new Shh(this);
  2239. this.net = new Net(this);
  2240. this.personal = new Personal(this);
  2241. this.bzz = new Swarm(this);
  2242. this.settings = new Settings();
  2243. this.version = {
  2244. api: version.version
  2245. };
  2246. this.providers = {
  2247. HttpProvider: HttpProvider,
  2248. IpcProvider: IpcProvider
  2249. };
  2250. this._extend = extend(this);
  2251. this._extend({
  2252. properties: properties()
  2253. });
  2254. }
  2255. // expose providers on the class
  2256. Web3.providers = {
  2257. HttpProvider: HttpProvider,
  2258. IpcProvider: IpcProvider
  2259. };
  2260. Web3.prototype.setProvider = function (provider) {
  2261. this._requestManager.setProvider(provider);
  2262. this.currentProvider = provider;
  2263. };
  2264. Web3.prototype.reset = function (keepIsSyncing) {
  2265. this._requestManager.reset(keepIsSyncing);
  2266. this.settings = new Settings();
  2267. };
  2268. Web3.prototype.BigNumber = BigNumber;
  2269. Web3.prototype.toHex = utils.toHex;
  2270. Web3.prototype.toAscii = utils.toAscii;
  2271. Web3.prototype.toUtf8 = utils.toUtf8;
  2272. Web3.prototype.fromAscii = utils.fromAscii;
  2273. Web3.prototype.fromUtf8 = utils.fromUtf8;
  2274. Web3.prototype.toDecimal = utils.toDecimal;
  2275. Web3.prototype.fromDecimal = utils.fromDecimal;
  2276. Web3.prototype.toBigNumber = utils.toBigNumber;
  2277. Web3.prototype.toWei = utils.toWei;
  2278. Web3.prototype.fromWei = utils.fromWei;
  2279. Web3.prototype.isAddress = utils.isAddress;
  2280. Web3.prototype.isChecksumAddress = utils.isChecksumAddress;
  2281. Web3.prototype.toChecksumAddress = utils.toChecksumAddress;
  2282. Web3.prototype.isIBAN = utils.isIBAN;
  2283. Web3.prototype.sha3 = function(string, options) {
  2284. return '0x' + sha3(string, options);
  2285. };
  2286. /**
  2287. * Transforms direct icap to address
  2288. */
  2289. Web3.prototype.fromICAP = function (icap) {
  2290. var iban = new Iban(icap);
  2291. return iban.address();
  2292. };
  2293. var properties = function () {
  2294. return [
  2295. new Property({
  2296. name: 'version.node',
  2297. getter: 'web3_clientVersion'
  2298. }),
  2299. new Property({
  2300. name: 'version.network',
  2301. getter: 'net_version',
  2302. inputFormatter: utils.toDecimal
  2303. }),
  2304. new Property({
  2305. name: 'version.ethereum',
  2306. getter: 'eth_protocolVersion',
  2307. inputFormatter: utils.toDecimal
  2308. }),
  2309. new Property({
  2310. name: 'version.whisper',
  2311. getter: 'shh_version',
  2312. inputFormatter: utils.toDecimal
  2313. })
  2314. ];
  2315. };
  2316. Web3.prototype.isConnected = function(){
  2317. return (this.currentProvider && this.currentProvider.isConnected());
  2318. };
  2319. Web3.prototype.createBatch = function () {
  2320. return new Batch(this);
  2321. };
  2322. module.exports = Web3;
  2323. },{"./utils/sha3":19,"./utils/utils":20,"./version.json":21,"./web3/batch":24,"./web3/extend":28,"./web3/httpprovider":32,"./web3/iban":33,"./web3/ipcprovider":34,"./web3/methods/db":37,"./web3/methods/eth":38,"./web3/methods/net":39,"./web3/methods/personal":40,"./web3/methods/shh":41,"./web3/methods/swarm":42,"./web3/property":45,"./web3/requestmanager":46,"./web3/settings":47,"bignumber.js":"bignumber.js"}],23:[function(require,module,exports){
  2324. /*
  2325. This file is part of web3.js.
  2326. web3.js is free software: you can redistribute it and/or modify
  2327. it under the terms of the GNU Lesser General Public License as published by
  2328. the Free Software Foundation, either version 3 of the License, or
  2329. (at your option) any later version.
  2330. web3.js is distributed in the hope that it will be useful,
  2331. but WITHOUT ANY WARRANTY; without even the implied warranty of
  2332. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2333. GNU Lesser General Public License for more details.
  2334. You should have received a copy of the GNU Lesser General Public License
  2335. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  2336. */
  2337. /**
  2338. * @file allevents.js
  2339. * @author Marek Kotewicz <[email protected]>
  2340. * @date 2014
  2341. */
  2342. var sha3 = require('../utils/sha3');
  2343. var SolidityEvent = require('./event');
  2344. var formatters = require('./formatters');
  2345. var utils = require('../utils/utils');
  2346. var Filter = require('./filter');
  2347. var watches = require('./methods/watches');
  2348. var AllSolidityEvents = function (requestManager, json, address) {
  2349. this._requestManager = requestManager;
  2350. this._json = json;
  2351. this._address = address;
  2352. };
  2353. AllSolidityEvents.prototype.encode = function (options) {
  2354. options = options || {};
  2355. var result = {};
  2356. ['fromBlock', 'toBlock'].filter(function (f) {
  2357. return options[f] !== undefined;
  2358. }).forEach(function (f) {
  2359. result[f] = formatters.inputBlockNumberFormatter(options[f]);
  2360. });
  2361. result.address = this._address;
  2362. return result;
  2363. };
  2364. AllSolidityEvents.prototype.decode = function (data) {
  2365. data.data = data.data || '';
  2366. data.topics = data.topics || [];
  2367. var eventTopic = data.topics[0].slice(2);
  2368. var match = this._json.filter(function (j) {
  2369. return eventTopic === sha3(utils.transformToFullName(j));
  2370. })[0];
  2371. if (!match) { // cannot find matching event?
  2372. console.warn('cannot find event for log');
  2373. return data;
  2374. }
  2375. var event = new SolidityEvent(this._requestManager, match, this._address);
  2376. return event.decode(data);
  2377. };
  2378. AllSolidityEvents.prototype.execute = function (options, callback) {
  2379. if (utils.isFunction(arguments[arguments.length - 1])) {
  2380. callback = arguments[arguments.length - 1];
  2381. if(arguments.length === 1)
  2382. options = null;
  2383. }
  2384. var o = this.encode(options);
  2385. var formatter = this.decode.bind(this);
  2386. return new Filter(this._requestManager, o, watches.eth(), formatter, callback);
  2387. };
  2388. AllSolidityEvents.prototype.attachToContract = function (contract) {
  2389. var execute = this.execute.bind(this);
  2390. contract.allEvents = execute;
  2391. };
  2392. module.exports = AllSolidityEvents;
  2393. },{"../utils/sha3":19,"../utils/utils":20,"./event":27,"./filter":29,"./formatters":30,"./methods/watches":43}],24:[function(require,module,exports){
  2394. /*
  2395. This file is part of web3.js.
  2396. web3.js is free software: you can redistribute it and/or modify
  2397. it under the terms of the GNU Lesser General Public License as published by
  2398. the Free Software Foundation, either version 3 of the License, or
  2399. (at your option) any later version.
  2400. web3.js is distributed in the hope that it will be useful,
  2401. but WITHOUT ANY WARRANTY; without even the implied warranty of
  2402. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2403. GNU Lesser General Public License for more details.
  2404. You should have received a copy of the GNU Lesser General Public License
  2405. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  2406. */
  2407. /**
  2408. * @file batch.js
  2409. * @author Marek Kotewicz <[email protected]>
  2410. * @date 2015
  2411. */
  2412. var Jsonrpc = require('./jsonrpc');
  2413. var errors = require('./errors');
  2414. var Batch = function (web3) {
  2415. this.requestManager = web3._requestManager;
  2416. this.requests = [];
  2417. };
  2418. /**
  2419. * Should be called to add create new request to batch request
  2420. *
  2421. * @method add
  2422. * @param {Object} jsonrpc requet object
  2423. */
  2424. Batch.prototype.add = function (request) {
  2425. this.requests.push(request);
  2426. };
  2427. /**
  2428. * Should be called to execute batch request
  2429. *
  2430. * @method execute
  2431. */
  2432. Batch.prototype.execute = function () {
  2433. var requests = this.requests;
  2434. this.requestManager.sendBatch(requests, function (err, results) {
  2435. results = results || [];
  2436. requests.map(function (request, index) {
  2437. return results[index] || {};
  2438. }).forEach(function (result, index) {
  2439. if (requests[index].callback) {
  2440. if (!Jsonrpc.isValidResponse(result)) {
  2441. return requests[index].callback(errors.InvalidResponse(result));
  2442. }
  2443. requests[index].callback(null, (requests[index].format ? requests[index].format(result.result) : result.result));
  2444. }
  2445. });
  2446. });
  2447. };
  2448. module.exports = Batch;
  2449. },{"./errors":26,"./jsonrpc":35}],25:[function(require,module,exports){
  2450. /*
  2451. This file is part of web3.js.
  2452. web3.js is free software: you can redistribute it and/or modify
  2453. it under the terms of the GNU Lesser General Public License as published by
  2454. the Free Software Foundation, either version 3 of the License, or
  2455. (at your option) any later version.
  2456. web3.js is distributed in the hope that it will be useful,
  2457. but WITHOUT ANY WARRANTY; without even the implied warranty of
  2458. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2459. GNU Lesser General Public License for more details.
  2460. You should have received a copy of the GNU Lesser General Public License
  2461. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  2462. */
  2463. /**
  2464. * @file contract.js
  2465. * @author Marek Kotewicz <[email protected]>
  2466. * @date 2014
  2467. */
  2468. var utils = require('../utils/utils');
  2469. var coder = require('../solidity/coder');
  2470. var SolidityEvent = require('./event');
  2471. var SolidityFunction = require('./function');
  2472. var AllEvents = require('./allevents');
  2473. /**
  2474. * Should be called to encode constructor params
  2475. *
  2476. * @method encodeConstructorParams
  2477. * @param {Array} abi
  2478. * @param {Array} constructor params
  2479. */
  2480. var encodeConstructorParams = function (abi, params) {
  2481. return abi.filter(function (json) {
  2482. return json.type === 'constructor' && json.inputs.length === params.length;
  2483. }).map(function (json) {
  2484. return json.inputs.map(function (input) {
  2485. return input.type;
  2486. });
  2487. }).map(function (types) {
  2488. return coder.encodeParams(types, params);
  2489. })[0] || '';
  2490. };
  2491. /**
  2492. * Should be called to add functions to contract object
  2493. *
  2494. * @method addFunctionsToContract
  2495. * @param {Contract} contract
  2496. * @param {Array} abi
  2497. */
  2498. var addFunctionsToContract = function (contract) {
  2499. contract.abi.filter(function (json) {
  2500. return json.type === 'function';
  2501. }).map(function (json) {
  2502. return new SolidityFunction(contract._eth, json, contract.address);
  2503. }).forEach(function (f) {
  2504. f.attachToContract(contract);
  2505. });
  2506. };
  2507. /**
  2508. * Should be called to add events to contract object
  2509. *
  2510. * @method addEventsToContract
  2511. * @param {Contract} contract
  2512. * @param {Array} abi
  2513. */
  2514. var addEventsToContract = function (contract) {
  2515. var events = contract.abi.filter(function (json) {
  2516. return json.type === 'event';
  2517. });
  2518. var All = new AllEvents(contract._eth._requestManager, events, contract.address);
  2519. All.attachToContract(contract);
  2520. events.map(function (json) {
  2521. return new SolidityEvent(contract._eth._requestManager, json, contract.address);
  2522. }).forEach(function (e) {
  2523. e.attachToContract(contract);
  2524. });
  2525. };
  2526. /**
  2527. * Should be called to check if the contract gets properly deployed on the blockchain.
  2528. *
  2529. * @method checkForContractAddress
  2530. * @param {Object} contract
  2531. * @param {Function} callback
  2532. * @returns {Undefined}
  2533. */
  2534. var checkForContractAddress = function(contract, callback){
  2535. var count = 0,
  2536. callbackFired = false;
  2537. // wait for receipt
  2538. var filter = contract._eth.filter('latest', function(e){
  2539. if (!e && !callbackFired) {
  2540. count++;
  2541. // stop watching after 50 blocks (timeout)
  2542. if (count > 50) {
  2543. filter.stopWatching(function() {});
  2544. callbackFired = true;
  2545. if (callback)
  2546. callback(new Error('Contract transaction couldn\'t be found after 50 blocks'));
  2547. else
  2548. throw new Error('Contract transaction couldn\'t be found after 50 blocks');
  2549. } else {
  2550. contract._eth.getTransactionReceipt(contract.transactionHash, function(e, receipt){
  2551. if(receipt && !callbackFired) {
  2552. contract._eth.getCode(receipt.contractAddress, function(e, code){
  2553. /*jshint maxcomplexity: 6 */
  2554. if(callbackFired || !code)
  2555. return;
  2556. filter.stopWatching(function() {});
  2557. callbackFired = true;
  2558. if(code.length > 3) {
  2559. // console.log('Contract code deployed!');
  2560. contract.address = receipt.contractAddress;
  2561. // attach events and methods again after we have
  2562. addFunctionsToContract(contract);
  2563. addEventsToContract(contract);
  2564. // call callback for the second time
  2565. if(callback)
  2566. callback(null, contract);
  2567. } else {
  2568. if(callback)
  2569. callback(new Error('The contract code couldn\'t be stored, please check your gas amount.'));
  2570. else
  2571. throw new Error('The contract code couldn\'t be stored, please check your gas amount.');
  2572. }
  2573. });
  2574. }
  2575. });
  2576. }
  2577. }
  2578. });
  2579. };
  2580. /**
  2581. * Should be called to create new ContractFactory instance
  2582. *
  2583. * @method ContractFactory
  2584. * @param {Array} abi
  2585. */
  2586. var ContractFactory = function (eth, abi) {
  2587. this.eth = eth;
  2588. this.abi = abi;
  2589. /**
  2590. * Should be called to create new contract on a blockchain
  2591. *
  2592. * @method new
  2593. * @param {Any} contract constructor param1 (optional)
  2594. * @param {Any} contract constructor param2 (optional)
  2595. * @param {Object} contract transaction object (required)
  2596. * @param {Function} callback
  2597. * @returns {Contract} returns contract instance
  2598. */
  2599. this.new = function () {
  2600. /*jshint maxcomplexity: 7 */
  2601. var contract = new Contract(this.eth, this.abi);
  2602. // parse arguments
  2603. var options = {}; // required!
  2604. var callback;
  2605. var args = Array.prototype.slice.call(arguments);
  2606. if (utils.isFunction(args[args.length - 1])) {
  2607. callback = args.pop();
  2608. }
  2609. var last = args[args.length - 1];
  2610. if (utils.isObject(last) && !utils.isArray(last)) {
  2611. options = args.pop();
  2612. }
  2613. if (options.value > 0) {
  2614. var constructorAbi = abi.filter(function (json) {
  2615. return json.type === 'constructor' && json.inputs.length === args.length;
  2616. })[0] || {};
  2617. if (!constructorAbi.payable) {
  2618. throw new Error('Cannot send value to non-payable constructor');
  2619. }
  2620. }
  2621. var bytes = encodeConstructorParams(this.abi, args);
  2622. options.data += bytes;
  2623. if (callback) {
  2624. // wait for the contract address adn check if the code was deployed
  2625. this.eth.sendTransaction(options, function (err, hash) {
  2626. if (err) {
  2627. callback(err);
  2628. } else {
  2629. // add the transaction hash
  2630. contract.transactionHash = hash;
  2631. // call callback for the first time
  2632. callback(null, contract);
  2633. checkForContractAddress(contract, callback);
  2634. }
  2635. });
  2636. } else {
  2637. var hash = this.eth.sendTransaction(options);
  2638. // add the transaction hash
  2639. contract.transactionHash = hash;
  2640. checkForContractAddress(contract);
  2641. }
  2642. return contract;
  2643. };
  2644. this.new.getData = this.getData.bind(this);
  2645. };
  2646. /**
  2647. * Should be called to create new ContractFactory
  2648. *
  2649. * @method contract
  2650. * @param {Array} abi
  2651. * @returns {ContractFactory} new contract factory
  2652. */
  2653. //var contract = function (abi) {
  2654. //return new ContractFactory(abi);
  2655. //};
  2656. /**
  2657. * Should be called to get access to existing contract on a blockchain
  2658. *
  2659. * @method at
  2660. * @param {Address} contract address (required)
  2661. * @param {Function} callback {optional)
  2662. * @returns {Contract} returns contract if no callback was passed,
  2663. * otherwise calls callback function (err, contract)
  2664. */
  2665. ContractFactory.prototype.at = function (address, callback) {
  2666. var contract = new Contract(this.eth, this.abi, address);
  2667. // this functions are not part of prototype,
  2668. // because we dont want to spoil the interface
  2669. addFunctionsToContract(contract);
  2670. addEventsToContract(contract);
  2671. if (callback) {
  2672. callback(null, contract);
  2673. }
  2674. return contract;
  2675. };
  2676. /**
  2677. * Gets the data, which is data to deploy plus constructor params
  2678. *
  2679. * @method getData
  2680. */
  2681. ContractFactory.prototype.getData = function () {
  2682. var options = {}; // required!
  2683. var args = Array.prototype.slice.call(arguments);
  2684. var last = args[args.length - 1];
  2685. if (utils.isObject(last) && !utils.isArray(last)) {
  2686. options = args.pop();
  2687. }
  2688. var bytes = encodeConstructorParams(this.abi, args);
  2689. options.data += bytes;
  2690. return options.data;
  2691. };
  2692. /**
  2693. * Should be called to create new contract instance
  2694. *
  2695. * @method Contract
  2696. * @param {Array} abi
  2697. * @param {Address} contract address
  2698. */
  2699. var Contract = function (eth, abi, address) {
  2700. this._eth = eth;
  2701. this.transactionHash = null;
  2702. this.address = address;
  2703. this.abi = abi;
  2704. };
  2705. module.exports = ContractFactory;
  2706. },{"../solidity/coder":7,"../utils/utils":20,"./allevents":23,"./event":27,"./function":31}],26:[function(require,module,exports){
  2707. /*
  2708. This file is part of web3.js.
  2709. web3.js is free software: you can redistribute it and/or modify
  2710. it under the terms of the GNU Lesser General Public License as published by
  2711. the Free Software Foundation, either version 3 of the License, or
  2712. (at your option) any later version.
  2713. web3.js is distributed in the hope that it will be useful,
  2714. but WITHOUT ANY WARRANTY; without even the implied warranty of
  2715. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2716. GNU Lesser General Public License for more details.
  2717. You should have received a copy of the GNU Lesser General Public License
  2718. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  2719. */
  2720. /**
  2721. * @file errors.js
  2722. * @author Marek Kotewicz <[email protected]>
  2723. * @date 2015
  2724. */
  2725. module.exports = {
  2726. InvalidNumberOfParams: function () {
  2727. return new Error('Invalid number of input parameters');
  2728. },
  2729. InvalidConnection: function (host){
  2730. return new Error('CONNECTION ERROR: Couldn\'t connect to node '+ host +'.');
  2731. },
  2732. InvalidProvider: function () {
  2733. return new Error('Provider not set or invalid');
  2734. },
  2735. InvalidResponse: function (result){
  2736. var message = !!result && !!result.error && !!result.error.message ? result.error.message : 'Invalid JSON RPC response: ' + JSON.stringify(result);
  2737. return new Error(message);
  2738. },
  2739. ConnectionTimeout: function (ms){
  2740. return new Error('CONNECTION TIMEOUT: timeout of ' + ms + ' ms achived');
  2741. }
  2742. };
  2743. },{}],27:[function(require,module,exports){
  2744. /*
  2745. This file is part of web3.js.
  2746. web3.js is free software: you can redistribute it and/or modify
  2747. it under the terms of the GNU Lesser General Public License as published by
  2748. the Free Software Foundation, either version 3 of the License, or
  2749. (at your option) any later version.
  2750. web3.js is distributed in the hope that it will be useful,
  2751. but WITHOUT ANY WARRANTY; without even the implied warranty of
  2752. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2753. GNU Lesser General Public License for more details.
  2754. You should have received a copy of the GNU Lesser General Public License
  2755. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  2756. */
  2757. /**
  2758. * @file event.js
  2759. * @author Marek Kotewicz <[email protected]>
  2760. * @date 2014
  2761. */
  2762. var utils = require('../utils/utils');
  2763. var coder = require('../solidity/coder');
  2764. var formatters = require('./formatters');
  2765. var sha3 = require('../utils/sha3');
  2766. var Filter = require('./filter');
  2767. var watches = require('./methods/watches');
  2768. /**
  2769. * This prototype should be used to create event filters
  2770. */
  2771. var SolidityEvent = function (requestManager, json, address) {
  2772. this._requestManager = requestManager;
  2773. this._params = json.inputs;
  2774. this._name = utils.transformToFullName(json);
  2775. this._address = address;
  2776. this._anonymous = json.anonymous;
  2777. };
  2778. /**
  2779. * Should be used to get filtered param types
  2780. *
  2781. * @method types
  2782. * @param {Bool} decide if returned typed should be indexed
  2783. * @return {Array} array of types
  2784. */
  2785. SolidityEvent.prototype.types = function (indexed) {
  2786. return this._params.filter(function (i) {
  2787. return i.indexed === indexed;
  2788. }).map(function (i) {
  2789. return i.type;
  2790. });
  2791. };
  2792. /**
  2793. * Should be used to get event display name
  2794. *
  2795. * @method displayName
  2796. * @return {String} event display name
  2797. */
  2798. SolidityEvent.prototype.displayName = function () {
  2799. return utils.extractDisplayName(this._name);
  2800. };
  2801. /**
  2802. * Should be used to get event type name
  2803. *
  2804. * @method typeName
  2805. * @return {String} event type name
  2806. */
  2807. SolidityEvent.prototype.typeName = function () {
  2808. return utils.extractTypeName(this._name);
  2809. };
  2810. /**
  2811. * Should be used to get event signature
  2812. *
  2813. * @method signature
  2814. * @return {String} event signature
  2815. */
  2816. SolidityEvent.prototype.signature = function () {
  2817. return sha3(this._name);
  2818. };
  2819. /**
  2820. * Should be used to encode indexed params and options to one final object
  2821. *
  2822. * @method encode
  2823. * @param {Object} indexed
  2824. * @param {Object} options
  2825. * @return {Object} everything combined together and encoded
  2826. */
  2827. SolidityEvent.prototype.encode = function (indexed, options) {
  2828. indexed = indexed || {};
  2829. options = options || {};
  2830. var result = {};
  2831. ['fromBlock', 'toBlock'].filter(function (f) {
  2832. return options[f] !== undefined;
  2833. }).forEach(function (f) {
  2834. result[f] = formatters.inputBlockNumberFormatter(options[f]);
  2835. });
  2836. result.topics = [];
  2837. result.address = this._address;
  2838. if (!this._anonymous) {
  2839. result.topics.push('0x' + this.signature());
  2840. }
  2841. var indexedTopics = this._params.filter(function (i) {
  2842. return i.indexed === true;
  2843. }).map(function (i) {
  2844. var value = indexed[i.name];
  2845. if (value === undefined || value === null) {
  2846. return null;
  2847. }
  2848. if (utils.isArray(value)) {
  2849. return value.map(function (v) {
  2850. return '0x' + coder.encodeParam(i.type, v);
  2851. });
  2852. }
  2853. return '0x' + coder.encodeParam(i.type, value);
  2854. });
  2855. result.topics = result.topics.concat(indexedTopics);
  2856. return result;
  2857. };
  2858. /**
  2859. * Should be used to decode indexed params and options
  2860. *
  2861. * @method decode
  2862. * @param {Object} data
  2863. * @return {Object} result object with decoded indexed && not indexed params
  2864. */
  2865. SolidityEvent.prototype.decode = function (data) {
  2866. data.data = data.data || '';
  2867. data.topics = data.topics || [];
  2868. var argTopics = this._anonymous ? data.topics : data.topics.slice(1);
  2869. var indexedData = argTopics.map(function (topics) { return topics.slice(2); }).join("");
  2870. var indexedParams = coder.decodeParams(this.types(true), indexedData);
  2871. var notIndexedData = data.data.slice(2);
  2872. var notIndexedParams = coder.decodeParams(this.types(false), notIndexedData);
  2873. var result = formatters.outputLogFormatter(data);
  2874. result.event = this.displayName();
  2875. result.address = data.address;
  2876. result.args = this._params.reduce(function (acc, current) {
  2877. acc[current.name] = current.indexed ? indexedParams.shift() : notIndexedParams.shift();
  2878. return acc;
  2879. }, {});
  2880. delete result.data;
  2881. delete result.topics;
  2882. return result;
  2883. };
  2884. /**
  2885. * Should be used to create new filter object from event
  2886. *
  2887. * @method execute
  2888. * @param {Object} indexed
  2889. * @param {Object} options
  2890. * @return {Object} filter object
  2891. */
  2892. SolidityEvent.prototype.execute = function (indexed, options, callback) {
  2893. if (utils.isFunction(arguments[arguments.length - 1])) {
  2894. callback = arguments[arguments.length - 1];
  2895. if(arguments.length === 2)
  2896. options = null;
  2897. if(arguments.length === 1) {
  2898. options = null;
  2899. indexed = {};
  2900. }
  2901. }
  2902. var o = this.encode(indexed, options);
  2903. var formatter = this.decode.bind(this);
  2904. return new Filter(this._requestManager, o, watches.eth(), formatter, callback);
  2905. };
  2906. /**
  2907. * Should be used to attach event to contract object
  2908. *
  2909. * @method attachToContract
  2910. * @param {Contract}
  2911. */
  2912. SolidityEvent.prototype.attachToContract = function (contract) {
  2913. var execute = this.execute.bind(this);
  2914. var displayName = this.displayName();
  2915. if (!contract[displayName]) {
  2916. contract[displayName] = execute;
  2917. }
  2918. contract[displayName][this.typeName()] = this.execute.bind(this, contract);
  2919. };
  2920. module.exports = SolidityEvent;
  2921. },{"../solidity/coder":7,"../utils/sha3":19,"../utils/utils":20,"./filter":29,"./formatters":30,"./methods/watches":43}],28:[function(require,module,exports){
  2922. var formatters = require('./formatters');
  2923. var utils = require('./../utils/utils');
  2924. var Method = require('./method');
  2925. var Property = require('./property');
  2926. // TODO: refactor, so the input params are not altered.
  2927. // it's necessary to make same 'extension' work with multiple providers
  2928. var extend = function (web3) {
  2929. /* jshint maxcomplexity:5 */
  2930. var ex = function (extension) {
  2931. var extendedObject;
  2932. if (extension.property) {
  2933. if (!web3[extension.property]) {
  2934. web3[extension.property] = {};
  2935. }
  2936. extendedObject = web3[extension.property];
  2937. } else {
  2938. extendedObject = web3;
  2939. }
  2940. if (extension.methods) {
  2941. extension.methods.forEach(function (method) {
  2942. method.attachToObject(extendedObject);
  2943. method.setRequestManager(web3._requestManager);
  2944. });
  2945. }
  2946. if (extension.properties) {
  2947. extension.properties.forEach(function (property) {
  2948. property.attachToObject(extendedObject);
  2949. property.setRequestManager(web3._requestManager);
  2950. });
  2951. }
  2952. };
  2953. ex.formatters = formatters;
  2954. ex.utils = utils;
  2955. ex.Method = Method;
  2956. ex.Property = Property;
  2957. return ex;
  2958. };
  2959. module.exports = extend;
  2960. },{"./../utils/utils":20,"./formatters":30,"./method":36,"./property":45}],29:[function(require,module,exports){
  2961. /*
  2962. This file is part of web3.js.
  2963. web3.js is free software: you can redistribute it and/or modify
  2964. it under the terms of the GNU Lesser General Public License as published by
  2965. the Free Software Foundation, either version 3 of the License, or
  2966. (at your option) any later version.
  2967. web3.js is distributed in the hope that it will be useful,
  2968. but WITHOUT ANY WARRANTY; without even the implied warranty of
  2969. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2970. GNU Lesser General Public License for more details.
  2971. You should have received a copy of the GNU Lesser General Public License
  2972. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  2973. */
  2974. /** @file filter.js
  2975. * @authors:
  2976. * Jeffrey Wilcke <[email protected]>
  2977. * Marek Kotewicz <[email protected]>
  2978. * Marian Oancea <[email protected]>
  2979. * Fabian Vogelsteller <[email protected]>
  2980. * Gav Wood <[email protected]>
  2981. * @date 2014
  2982. */
  2983. var formatters = require('./formatters');
  2984. var utils = require('../utils/utils');
  2985. /**
  2986. * Converts a given topic to a hex string, but also allows null values.
  2987. *
  2988. * @param {Mixed} value
  2989. * @return {String}
  2990. */
  2991. var toTopic = function(value){
  2992. if(value === null || typeof value === 'undefined')
  2993. return null;
  2994. value = String(value);
  2995. if(value.indexOf('0x') === 0)
  2996. return value;
  2997. else
  2998. return utils.fromUtf8(value);
  2999. };
  3000. /// This method should be called on options object, to verify deprecated properties && lazy load dynamic ones
  3001. /// @param should be string or object
  3002. /// @returns options string or object
  3003. var getOptions = function (options) {
  3004. if (utils.isString(options)) {
  3005. return options;
  3006. }
  3007. options = options || {};
  3008. // make sure topics, get converted to hex
  3009. options.topics = options.topics || [];
  3010. options.topics = options.topics.map(function(topic){
  3011. return (utils.isArray(topic)) ? topic.map(toTopic) : toTopic(topic);
  3012. });
  3013. return {
  3014. topics: options.topics,
  3015. from: options.from,
  3016. to: options.to,
  3017. address: options.address,
  3018. fromBlock: formatters.inputBlockNumberFormatter(options.fromBlock),
  3019. toBlock: formatters.inputBlockNumberFormatter(options.toBlock)
  3020. };
  3021. };
  3022. /**
  3023. Adds the callback and sets up the methods, to iterate over the results.
  3024. @method getLogsAtStart
  3025. @param {Object} self
  3026. @param {funciton}
  3027. */
  3028. var getLogsAtStart = function(self, callback){
  3029. // call getFilterLogs for the first watch callback start
  3030. if (!utils.isString(self.options)) {
  3031. self.get(function (err, messages) {
  3032. // don't send all the responses to all the watches again... just to self one
  3033. if (err) {
  3034. callback(err);
  3035. }
  3036. if(utils.isArray(messages)) {
  3037. messages.forEach(function (message) {
  3038. callback(null, message);
  3039. });
  3040. }
  3041. });
  3042. }
  3043. };
  3044. /**
  3045. Adds the callback and sets up the methods, to iterate over the results.
  3046. @method pollFilter
  3047. @param {Object} self
  3048. */
  3049. var pollFilter = function(self) {
  3050. var onMessage = function (error, messages) {
  3051. if (error) {
  3052. return self.callbacks.forEach(function (callback) {
  3053. callback(error);
  3054. });
  3055. }
  3056. if(utils.isArray(messages)) {
  3057. messages.forEach(function (message) {
  3058. message = self.formatter ? self.formatter(message) : message;
  3059. self.callbacks.forEach(function (callback) {
  3060. callback(null, message);
  3061. });
  3062. });
  3063. }
  3064. };
  3065. self.requestManager.startPolling({
  3066. method: self.implementation.poll.call,
  3067. params: [self.filterId],
  3068. }, self.filterId, onMessage, self.stopWatching.bind(self));
  3069. };
  3070. var Filter = function (requestManager, options, methods, formatter, callback, filterCreationErrorCallback) {
  3071. var self = this;
  3072. var implementation = {};
  3073. methods.forEach(function (method) {
  3074. method.setRequestManager(requestManager);
  3075. method.attachToObject(implementation);
  3076. });
  3077. this.requestManager = requestManager;
  3078. this.options = getOptions(options);
  3079. this.implementation = implementation;
  3080. this.filterId = null;
  3081. this.callbacks = [];
  3082. this.getLogsCallbacks = [];
  3083. this.pollFilters = [];
  3084. this.formatter = formatter;
  3085. this.implementation.newFilter(this.options, function(error, id){
  3086. if(error) {
  3087. self.callbacks.forEach(function(cb){
  3088. cb(error);
  3089. });
  3090. filterCreationErrorCallback(error);
  3091. } else {
  3092. self.filterId = id;
  3093. // check if there are get pending callbacks as a consequence
  3094. // of calling get() with filterId unassigned.
  3095. self.getLogsCallbacks.forEach(function (cb){
  3096. self.get(cb);
  3097. });
  3098. self.getLogsCallbacks = [];
  3099. // get filter logs for the already existing watch calls
  3100. self.callbacks.forEach(function(cb){
  3101. getLogsAtStart(self, cb);
  3102. });
  3103. if(self.callbacks.length > 0)
  3104. pollFilter(self);
  3105. // start to watch immediately
  3106. if(typeof callback === 'function') {
  3107. return self.watch(callback);
  3108. }
  3109. }
  3110. });
  3111. return this;
  3112. };
  3113. Filter.prototype.watch = function (callback) {
  3114. this.callbacks.push(callback);
  3115. if(this.filterId) {
  3116. getLogsAtStart(this, callback);
  3117. pollFilter(this);
  3118. }
  3119. return this;
  3120. };
  3121. Filter.prototype.stopWatching = function (callback) {
  3122. this.requestManager.stopPolling(this.filterId);
  3123. this.callbacks = [];
  3124. // remove filter async
  3125. if (callback) {
  3126. this.implementation.uninstallFilter(this.filterId, callback);
  3127. } else {
  3128. return this.implementation.uninstallFilter(this.filterId);
  3129. }
  3130. };
  3131. Filter.prototype.get = function (callback) {
  3132. var self = this;
  3133. if (utils.isFunction(callback)) {
  3134. if (this.filterId === null) {
  3135. // If filterId is not set yet, call it back
  3136. // when newFilter() assigns it.
  3137. this.getLogsCallbacks.push(callback);
  3138. } else {
  3139. this.implementation.getLogs(this.filterId, function(err, res){
  3140. if (err) {
  3141. callback(err);
  3142. } else {
  3143. callback(null, res.map(function (log) {
  3144. return self.formatter ? self.formatter(log) : log;
  3145. }));
  3146. }
  3147. });
  3148. }
  3149. } else {
  3150. if (this.filterId === null) {
  3151. throw new Error('Filter ID Error: filter().get() can\'t be chained synchronous, please provide a callback for the get() method.');
  3152. }
  3153. var logs = this.implementation.getLogs(this.filterId);
  3154. return logs.map(function (log) {
  3155. return self.formatter ? self.formatter(log) : log;
  3156. });
  3157. }
  3158. return this;
  3159. };
  3160. module.exports = Filter;
  3161. },{"../utils/utils":20,"./formatters":30}],30:[function(require,module,exports){
  3162. /*
  3163. This file is part of web3.js.
  3164. web3.js is free software: you can redistribute it and/or modify
  3165. it under the terms of the GNU Lesser General Public License as published by
  3166. the Free Software Foundation, either version 3 of the License, or
  3167. (at your option) any later version.
  3168. web3.js is distributed in the hope that it will be useful,
  3169. but WITHOUT ANY WARRANTY; without even the implied warranty of
  3170. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3171. GNU Lesser General Public License for more details.
  3172. You should have received a copy of the GNU Lesser General Public License
  3173. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  3174. */
  3175. /**
  3176. * @file formatters.js
  3177. * @author Marek Kotewicz <[email protected]>
  3178. * @author Fabian Vogelsteller <[email protected]>
  3179. * @date 2015
  3180. */
  3181. var utils = require('../utils/utils');
  3182. var config = require('../utils/config');
  3183. var Iban = require('./iban');
  3184. /**
  3185. * Should the format output to a big number
  3186. *
  3187. * @method outputBigNumberFormatter
  3188. * @param {String|Number|BigNumber}
  3189. * @returns {BigNumber} object
  3190. */
  3191. var outputBigNumberFormatter = function (number) {
  3192. return utils.toBigNumber(number);
  3193. };
  3194. var isPredefinedBlockNumber = function (blockNumber) {
  3195. return blockNumber === 'latest' || blockNumber === 'pending' || blockNumber === 'earliest';
  3196. };
  3197. var inputDefaultBlockNumberFormatter = function (blockNumber) {
  3198. if (blockNumber === undefined) {
  3199. return config.defaultBlock;
  3200. }
  3201. return inputBlockNumberFormatter(blockNumber);
  3202. };
  3203. var inputBlockNumberFormatter = function (blockNumber) {
  3204. if (blockNumber === undefined) {
  3205. return undefined;
  3206. } else if (isPredefinedBlockNumber(blockNumber)) {
  3207. return blockNumber;
  3208. }
  3209. return utils.toHex(blockNumber);
  3210. };
  3211. /**
  3212. * Formats the input of a transaction and converts all values to HEX
  3213. *
  3214. * @method inputCallFormatter
  3215. * @param {Object} transaction options
  3216. * @returns object
  3217. */
  3218. var inputCallFormatter = function (options){
  3219. options.from = options.from || config.defaultAccount;
  3220. if (options.from) {
  3221. options.from = inputAddressFormatter(options.from);
  3222. }
  3223. if (options.to) { // it might be contract creation
  3224. options.to = inputAddressFormatter(options.to);
  3225. }
  3226. ['gasPrice', 'gas', 'value', 'nonce'].filter(function (key) {
  3227. return options[key] !== undefined;
  3228. }).forEach(function(key){
  3229. options[key] = utils.fromDecimal(options[key]);
  3230. });
  3231. return options;
  3232. };
  3233. /**
  3234. * Formats the input of a transaction and converts all values to HEX
  3235. *
  3236. * @method inputTransactionFormatter
  3237. * @param {Object} transaction options
  3238. * @returns object
  3239. */
  3240. var inputTransactionFormatter = function (options){
  3241. options.from = options.from || config.defaultAccount;
  3242. options.from = inputAddressFormatter(options.from);
  3243. if (options.to) { // it might be contract creation
  3244. options.to = inputAddressFormatter(options.to);
  3245. }
  3246. ['gasPrice', 'gas', 'value', 'nonce'].filter(function (key) {
  3247. return options[key] !== undefined;
  3248. }).forEach(function(key){
  3249. options[key] = utils.fromDecimal(options[key]);
  3250. });
  3251. return options;
  3252. };
  3253. /**
  3254. * Formats the output of a transaction to its proper values
  3255. *
  3256. * @method outputTransactionFormatter
  3257. * @param {Object} tx
  3258. * @returns {Object}
  3259. */
  3260. var outputTransactionFormatter = function (tx){
  3261. if(tx.blockNumber !== null)
  3262. tx.blockNumber = utils.toDecimal(tx.blockNumber);
  3263. if(tx.transactionIndex !== null)
  3264. tx.transactionIndex = utils.toDecimal(tx.transactionIndex);
  3265. tx.nonce = utils.toDecimal(tx.nonce);
  3266. tx.gas = utils.toDecimal(tx.gas);
  3267. tx.gasPrice = utils.toBigNumber(tx.gasPrice);
  3268. tx.value = utils.toBigNumber(tx.value);
  3269. return tx;
  3270. };
  3271. /**
  3272. * Formats the output of a transaction receipt to its proper values
  3273. *
  3274. * @method outputTransactionReceiptFormatter
  3275. * @param {Object} receipt
  3276. * @returns {Object}
  3277. */
  3278. var outputTransactionReceiptFormatter = function (receipt){
  3279. if(receipt.blockNumber !== null)
  3280. receipt.blockNumber = utils.toDecimal(receipt.blockNumber);
  3281. if(receipt.transactionIndex !== null)
  3282. receipt.transactionIndex = utils.toDecimal(receipt.transactionIndex);
  3283. receipt.cumulativeGasUsed = utils.toDecimal(receipt.cumulativeGasUsed);
  3284. receipt.gasUsed = utils.toDecimal(receipt.gasUsed);
  3285. if(utils.isArray(receipt.logs)) {
  3286. receipt.logs = receipt.logs.map(function(log){
  3287. return outputLogFormatter(log);
  3288. });
  3289. }
  3290. return receipt;
  3291. };
  3292. /**
  3293. * Formats the output of a block to its proper values
  3294. *
  3295. * @method outputBlockFormatter
  3296. * @param {Object} block
  3297. * @returns {Object}
  3298. */
  3299. var outputBlockFormatter = function(block) {
  3300. // transform to number
  3301. block.gasLimit = utils.toDecimal(block.gasLimit);
  3302. block.gasUsed = utils.toDecimal(block.gasUsed);
  3303. block.size = utils.toDecimal(block.size);
  3304. block.timestamp = utils.toDecimal(block.timestamp);
  3305. if(block.number !== null)
  3306. block.number = utils.toDecimal(block.number);
  3307. block.difficulty = utils.toBigNumber(block.difficulty);
  3308. block.totalDifficulty = utils.toBigNumber(block.totalDifficulty);
  3309. if (utils.isArray(block.transactions)) {
  3310. block.transactions.forEach(function(item){
  3311. if(!utils.isString(item))
  3312. return outputTransactionFormatter(item);
  3313. });
  3314. }
  3315. return block;
  3316. };
  3317. /**
  3318. * Formats the output of a log
  3319. *
  3320. * @method outputLogFormatter
  3321. * @param {Object} log object
  3322. * @returns {Object} log
  3323. */
  3324. var outputLogFormatter = function(log) {
  3325. if(log.blockNumber !== null)
  3326. log.blockNumber = utils.toDecimal(log.blockNumber);
  3327. if(log.transactionIndex !== null)
  3328. log.transactionIndex = utils.toDecimal(log.transactionIndex);
  3329. if(log.logIndex !== null)
  3330. log.logIndex = utils.toDecimal(log.logIndex);
  3331. return log;
  3332. };
  3333. /**
  3334. * Formats the input of a whisper post and converts all values to HEX
  3335. *
  3336. * @method inputPostFormatter
  3337. * @param {Object} transaction object
  3338. * @returns {Object}
  3339. */
  3340. var inputPostFormatter = function(post) {
  3341. // post.payload = utils.toHex(post.payload);
  3342. post.ttl = utils.fromDecimal(post.ttl);
  3343. post.workToProve = utils.fromDecimal(post.workToProve);
  3344. post.priority = utils.fromDecimal(post.priority);
  3345. // fallback
  3346. if (!utils.isArray(post.topics)) {
  3347. post.topics = post.topics ? [post.topics] : [];
  3348. }
  3349. // format the following options
  3350. post.topics = post.topics.map(function(topic){
  3351. // convert only if not hex
  3352. return (topic.indexOf('0x') === 0) ? topic : utils.fromUtf8(topic);
  3353. });
  3354. return post;
  3355. };
  3356. /**
  3357. * Formats the output of a received post message
  3358. *
  3359. * @method outputPostFormatter
  3360. * @param {Object}
  3361. * @returns {Object}
  3362. */
  3363. var outputPostFormatter = function(post){
  3364. post.expiry = utils.toDecimal(post.expiry);
  3365. post.sent = utils.toDecimal(post.sent);
  3366. post.ttl = utils.toDecimal(post.ttl);
  3367. post.workProved = utils.toDecimal(post.workProved);
  3368. // post.payloadRaw = post.payload;
  3369. // post.payload = utils.toAscii(post.payload);
  3370. // if (utils.isJson(post.payload)) {
  3371. // post.payload = JSON.parse(post.payload);
  3372. // }
  3373. // format the following options
  3374. if (!post.topics) {
  3375. post.topics = [];
  3376. }
  3377. post.topics = post.topics.map(function(topic){
  3378. return utils.toAscii(topic);
  3379. });
  3380. return post;
  3381. };
  3382. var inputAddressFormatter = function (address) {
  3383. var iban = new Iban(address);
  3384. if (iban.isValid() && iban.isDirect()) {
  3385. return '0x' + iban.address();
  3386. } else if (utils.isStrictAddress(address)) {
  3387. return address;
  3388. } else if (utils.isAddress(address)) {
  3389. return '0x' + address;
  3390. }
  3391. throw new Error('invalid address');
  3392. };
  3393. var outputSyncingFormatter = function(result) {
  3394. result.startingBlock = utils.toDecimal(result.startingBlock);
  3395. result.currentBlock = utils.toDecimal(result.currentBlock);
  3396. result.highestBlock = utils.toDecimal(result.highestBlock);
  3397. if (result.knownStates) {
  3398. result.knownStates = utils.toDecimal(result.knownStates);
  3399. result.pulledStates = utils.toDecimal(result.pulledStates);
  3400. }
  3401. return result;
  3402. };
  3403. module.exports = {
  3404. inputDefaultBlockNumberFormatter: inputDefaultBlockNumberFormatter,
  3405. inputBlockNumberFormatter: inputBlockNumberFormatter,
  3406. inputCallFormatter: inputCallFormatter,
  3407. inputTransactionFormatter: inputTransactionFormatter,
  3408. inputAddressFormatter: inputAddressFormatter,
  3409. inputPostFormatter: inputPostFormatter,
  3410. outputBigNumberFormatter: outputBigNumberFormatter,
  3411. outputTransactionFormatter: outputTransactionFormatter,
  3412. outputTransactionReceiptFormatter: outputTransactionReceiptFormatter,
  3413. outputBlockFormatter: outputBlockFormatter,
  3414. outputLogFormatter: outputLogFormatter,
  3415. outputPostFormatter: outputPostFormatter,
  3416. outputSyncingFormatter: outputSyncingFormatter
  3417. };
  3418. },{"../utils/config":18,"../utils/utils":20,"./iban":33}],31:[function(require,module,exports){
  3419. /*
  3420. This file is part of web3.js.
  3421. web3.js is free software: you can redistribute it and/or modify
  3422. it under the terms of the GNU Lesser General Public License as published by
  3423. the Free Software Foundation, either version 3 of the License, or
  3424. (at your option) any later version.
  3425. web3.js is distributed in the hope that it will be useful,
  3426. but WITHOUT ANY WARRANTY; without even the implied warranty of
  3427. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3428. GNU Lesser General Public License for more details.
  3429. You should have received a copy of the GNU Lesser General Public License
  3430. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  3431. */
  3432. /**
  3433. * @file function.js
  3434. * @author Marek Kotewicz <[email protected]>
  3435. * @date 2015
  3436. */
  3437. var coder = require('../solidity/coder');
  3438. var utils = require('../utils/utils');
  3439. var formatters = require('./formatters');
  3440. var sha3 = require('../utils/sha3');
  3441. /**
  3442. * This prototype should be used to call/sendTransaction to solidity functions
  3443. */
  3444. var SolidityFunction = function (eth, json, address) {
  3445. this._eth = eth;
  3446. this._inputTypes = json.inputs.map(function (i) {
  3447. return i.type;
  3448. });
  3449. this._outputTypes = json.outputs.map(function (i) {
  3450. return i.type;
  3451. });
  3452. this._constant = json.constant;
  3453. this._payable = json.payable;
  3454. this._name = utils.transformToFullName(json);
  3455. this._address = address;
  3456. };
  3457. SolidityFunction.prototype.extractCallback = function (args) {
  3458. if (utils.isFunction(args[args.length - 1])) {
  3459. return args.pop(); // modify the args array!
  3460. }
  3461. };
  3462. SolidityFunction.prototype.extractDefaultBlock = function (args) {
  3463. if (args.length > this._inputTypes.length && !utils.isObject(args[args.length -1])) {
  3464. return formatters.inputDefaultBlockNumberFormatter(args.pop()); // modify the args array!
  3465. }
  3466. };
  3467. /**
  3468. * Should be used to create payload from arguments
  3469. *
  3470. * @method toPayload
  3471. * @param {Array} solidity function params
  3472. * @param {Object} optional payload options
  3473. */
  3474. SolidityFunction.prototype.toPayload = function (args) {
  3475. var options = {};
  3476. if (args.length > this._inputTypes.length && utils.isObject(args[args.length -1])) {
  3477. options = args[args.length - 1];
  3478. }
  3479. options.to = this._address;
  3480. options.data = '0x' + this.signature() + coder.encodeParams(this._inputTypes, args);
  3481. return options;
  3482. };
  3483. /**
  3484. * Should be used to get function signature
  3485. *
  3486. * @method signature
  3487. * @return {String} function signature
  3488. */
  3489. SolidityFunction.prototype.signature = function () {
  3490. return sha3(this._name).slice(0, 8);
  3491. };
  3492. SolidityFunction.prototype.unpackOutput = function (output) {
  3493. if (!output) {
  3494. return;
  3495. }
  3496. output = output.length >= 2 ? output.slice(2) : output;
  3497. var result = coder.decodeParams(this._outputTypes, output);
  3498. return result.length === 1 ? result[0] : result;
  3499. };
  3500. /**
  3501. * Calls a contract function.
  3502. *
  3503. * @method call
  3504. * @param {...Object} Contract function arguments
  3505. * @param {function} If the last argument is a function, the contract function
  3506. * call will be asynchronous, and the callback will be passed the
  3507. * error and result.
  3508. * @return {String} output bytes
  3509. */
  3510. SolidityFunction.prototype.call = function () {
  3511. var args = Array.prototype.slice.call(arguments).filter(function (a) {return a !== undefined; });
  3512. var callback = this.extractCallback(args);
  3513. var defaultBlock = this.extractDefaultBlock(args);
  3514. var payload = this.toPayload(args);
  3515. if (!callback) {
  3516. var output = this._eth.call(payload, defaultBlock);
  3517. return this.unpackOutput(output);
  3518. }
  3519. var self = this;
  3520. this._eth.call(payload, defaultBlock, function (error, output) {
  3521. if (error) return callback(error, null);
  3522. var unpacked = null;
  3523. try {
  3524. unpacked = self.unpackOutput(output);
  3525. }
  3526. catch (e) {
  3527. error = e;
  3528. }
  3529. callback(error, unpacked);
  3530. });
  3531. };
  3532. /**
  3533. * Should be used to sendTransaction to solidity function
  3534. *
  3535. * @method sendTransaction
  3536. */
  3537. SolidityFunction.prototype.sendTransaction = function () {
  3538. var args = Array.prototype.slice.call(arguments).filter(function (a) {return a !== undefined; });
  3539. var callback = this.extractCallback(args);
  3540. var payload = this.toPayload(args);
  3541. if (payload.value > 0 && !this._payable) {
  3542. throw new Error('Cannot send value to non-payable function');
  3543. }
  3544. if (!callback) {
  3545. return this._eth.sendTransaction(payload);
  3546. }
  3547. this._eth.sendTransaction(payload, callback);
  3548. };
  3549. /**
  3550. * Should be used to estimateGas of solidity function
  3551. *
  3552. * @method estimateGas
  3553. */
  3554. SolidityFunction.prototype.estimateGas = function () {
  3555. var args = Array.prototype.slice.call(arguments);
  3556. var callback = this.extractCallback(args);
  3557. var payload = this.toPayload(args);
  3558. if (!callback) {
  3559. return this._eth.estimateGas(payload);
  3560. }
  3561. this._eth.estimateGas(payload, callback);
  3562. };
  3563. /**
  3564. * Return the encoded data of the call
  3565. *
  3566. * @method getData
  3567. * @return {String} the encoded data
  3568. */
  3569. SolidityFunction.prototype.getData = function () {
  3570. var args = Array.prototype.slice.call(arguments);
  3571. var payload = this.toPayload(args);
  3572. return payload.data;
  3573. };
  3574. /**
  3575. * Should be used to get function display name
  3576. *
  3577. * @method displayName
  3578. * @return {String} display name of the function
  3579. */
  3580. SolidityFunction.prototype.displayName = function () {
  3581. return utils.extractDisplayName(this._name);
  3582. };
  3583. /**
  3584. * Should be used to get function type name
  3585. *
  3586. * @method typeName
  3587. * @return {String} type name of the function
  3588. */
  3589. SolidityFunction.prototype.typeName = function () {
  3590. return utils.extractTypeName(this._name);
  3591. };
  3592. /**
  3593. * Should be called to get rpc requests from solidity function
  3594. *
  3595. * @method request
  3596. * @returns {Object}
  3597. */
  3598. SolidityFunction.prototype.request = function () {
  3599. var args = Array.prototype.slice.call(arguments);
  3600. var callback = this.extractCallback(args);
  3601. var payload = this.toPayload(args);
  3602. var format = this.unpackOutput.bind(this);
  3603. return {
  3604. method: this._constant ? 'eth_call' : 'eth_sendTransaction',
  3605. callback: callback,
  3606. params: [payload],
  3607. format: format
  3608. };
  3609. };
  3610. /**
  3611. * Should be called to execute function
  3612. *
  3613. * @method execute
  3614. */
  3615. SolidityFunction.prototype.execute = function () {
  3616. var transaction = !this._constant;
  3617. // send transaction
  3618. if (transaction) {
  3619. return this.sendTransaction.apply(this, Array.prototype.slice.call(arguments));
  3620. }
  3621. // call
  3622. return this.call.apply(this, Array.prototype.slice.call(arguments));
  3623. };
  3624. /**
  3625. * Should be called to attach function to contract
  3626. *
  3627. * @method attachToContract
  3628. * @param {Contract}
  3629. */
  3630. SolidityFunction.prototype.attachToContract = function (contract) {
  3631. var execute = this.execute.bind(this);
  3632. execute.request = this.request.bind(this);
  3633. execute.call = this.call.bind(this);
  3634. execute.sendTransaction = this.sendTransaction.bind(this);
  3635. execute.estimateGas = this.estimateGas.bind(this);
  3636. execute.getData = this.getData.bind(this);
  3637. var displayName = this.displayName();
  3638. if (!contract[displayName]) {
  3639. contract[displayName] = execute;
  3640. }
  3641. contract[displayName][this.typeName()] = execute; // circular!!!!
  3642. };
  3643. module.exports = SolidityFunction;
  3644. },{"../solidity/coder":7,"../utils/sha3":19,"../utils/utils":20,"./formatters":30}],32:[function(require,module,exports){
  3645. /*
  3646. This file is part of web3.js.
  3647. web3.js is free software: you can redistribute it and/or modify
  3648. it under the terms of the GNU Lesser General Public License as published by
  3649. the Free Software Foundation, either version 3 of the License, or
  3650. (at your option) any later version.
  3651. web3.js is distributed in the hope that it will be useful,
  3652. but WITHOUT ANY WARRANTY; without even the implied warranty of
  3653. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3654. GNU Lesser General Public License for more details.
  3655. You should have received a copy of the GNU Lesser General Public License
  3656. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  3657. */
  3658. /** @file httpprovider.js
  3659. * @authors:
  3660. * Marek Kotewicz <[email protected]>
  3661. * Marian Oancea <[email protected]>
  3662. * Fabian Vogelsteller <[email protected]>
  3663. * @date 2015
  3664. */
  3665. var errors = require('./errors');
  3666. // workaround to use httpprovider in different envs
  3667. // browser
  3668. if (typeof window !== 'undefined' && window.XMLHttpRequest) {
  3669. XMLHttpRequest = window.XMLHttpRequest; // jshint ignore: line
  3670. // node
  3671. } else {
  3672. XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; // jshint ignore: line
  3673. }
  3674. var XHR2 = require('xhr2'); // jshint ignore: line
  3675. /**
  3676. * HttpProvider should be used to send rpc calls over http
  3677. */
  3678. var HttpProvider = function (host, timeout) {
  3679. this.host = host || 'http://localhost:8545';
  3680. this.timeout = timeout || 0;
  3681. };
  3682. /**
  3683. * Should be called to prepare new XMLHttpRequest
  3684. *
  3685. * @method prepareRequest
  3686. * @param {Boolean} true if request should be async
  3687. * @return {XMLHttpRequest} object
  3688. */
  3689. HttpProvider.prototype.prepareRequest = function (async) {
  3690. var request;
  3691. if (async) {
  3692. request = new XHR2();
  3693. request.timeout = this.timeout;
  3694. }else {
  3695. request = new XMLHttpRequest();
  3696. }
  3697. request.open('POST', this.host, async);
  3698. request.setRequestHeader('Content-Type','application/json');
  3699. return request;
  3700. };
  3701. /**
  3702. * Should be called to make sync request
  3703. *
  3704. * @method send
  3705. * @param {Object} payload
  3706. * @return {Object} result
  3707. */
  3708. HttpProvider.prototype.send = function (payload) {
  3709. var request = this.prepareRequest(false);
  3710. try {
  3711. request.send(JSON.stringify(payload));
  3712. } catch(error) {
  3713. throw errors.InvalidConnection(this.host);
  3714. }
  3715. var result = request.responseText;
  3716. try {
  3717. result = JSON.parse(result);
  3718. } catch(e) {
  3719. throw errors.InvalidResponse(request.responseText);
  3720. }
  3721. return result;
  3722. };
  3723. /**
  3724. * Should be used to make async request
  3725. *
  3726. * @method sendAsync
  3727. * @param {Object} payload
  3728. * @param {Function} callback triggered on end with (err, result)
  3729. */
  3730. HttpProvider.prototype.sendAsync = function (payload, callback) {
  3731. var request = this.prepareRequest(true);
  3732. request.onreadystatechange = function() {
  3733. if (request.readyState === 4 && request.timeout !== 1) {
  3734. var result = request.responseText;
  3735. var error = null;
  3736. try {
  3737. result = JSON.parse(result);
  3738. } catch(e) {
  3739. error = errors.InvalidResponse(request.responseText);
  3740. }
  3741. callback(error, result);
  3742. }
  3743. };
  3744. request.ontimeout = function() {
  3745. callback(errors.ConnectionTimeout(this.timeout));
  3746. };
  3747. try {
  3748. request.send(JSON.stringify(payload));
  3749. } catch(error) {
  3750. callback(errors.InvalidConnection(this.host));
  3751. }
  3752. };
  3753. /**
  3754. * Synchronously tries to make Http request
  3755. *
  3756. * @method isConnected
  3757. * @return {Boolean} returns true if request haven't failed. Otherwise false
  3758. */
  3759. HttpProvider.prototype.isConnected = function() {
  3760. try {
  3761. this.send({
  3762. id: 9999999999,
  3763. jsonrpc: '2.0',
  3764. method: 'net_listening',
  3765. params: []
  3766. });
  3767. return true;
  3768. } catch(e) {
  3769. return false;
  3770. }
  3771. };
  3772. module.exports = HttpProvider;
  3773. },{"./errors":26,"xhr2":86,"xmlhttprequest":17}],33:[function(require,module,exports){
  3774. /*
  3775. This file is part of web3.js.
  3776. web3.js is free software: you can redistribute it and/or modify
  3777. it under the terms of the GNU Lesser General Public License as published by
  3778. the Free Software Foundation, either version 3 of the License, or
  3779. (at your option) any later version.
  3780. web3.js is distributed in the hope that it will be useful,
  3781. but WITHOUT ANY WARRANTY; without even the implied warranty of
  3782. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3783. GNU Lesser General Public License for more details.
  3784. You should have received a copy of the GNU Lesser General Public License
  3785. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  3786. */
  3787. /**
  3788. * @file iban.js
  3789. * @author Marek Kotewicz <[email protected]>
  3790. * @date 2015
  3791. */
  3792. var BigNumber = require('bignumber.js');
  3793. var padLeft = function (string, bytes) {
  3794. var result = string;
  3795. while (result.length < bytes * 2) {
  3796. result = '0' + result;
  3797. }
  3798. return result;
  3799. };
  3800. /**
  3801. * Prepare an IBAN for mod 97 computation by moving the first 4 chars to the end and transforming the letters to
  3802. * numbers (A = 10, B = 11, ..., Z = 35), as specified in ISO13616.
  3803. *
  3804. * @method iso13616Prepare
  3805. * @param {String} iban the IBAN
  3806. * @returns {String} the prepared IBAN
  3807. */
  3808. var iso13616Prepare = function (iban) {
  3809. var A = 'A'.charCodeAt(0);
  3810. var Z = 'Z'.charCodeAt(0);
  3811. iban = iban.toUpperCase();
  3812. iban = iban.substr(4) + iban.substr(0,4);
  3813. return iban.split('').map(function(n){
  3814. var code = n.charCodeAt(0);
  3815. if (code >= A && code <= Z){
  3816. // A = 10, B = 11, ... Z = 35
  3817. return code - A + 10;
  3818. } else {
  3819. return n;
  3820. }
  3821. }).join('');
  3822. };
  3823. /**
  3824. * Calculates the MOD 97 10 of the passed IBAN as specified in ISO7064.
  3825. *
  3826. * @method mod9710
  3827. * @param {String} iban
  3828. * @returns {Number}
  3829. */
  3830. var mod9710 = function (iban) {
  3831. var remainder = iban,
  3832. block;
  3833. while (remainder.length > 2){
  3834. block = remainder.slice(0, 9);
  3835. remainder = parseInt(block, 10) % 97 + remainder.slice(block.length);
  3836. }
  3837. return parseInt(remainder, 10) % 97;
  3838. };
  3839. /**
  3840. * This prototype should be used to create iban object from iban correct string
  3841. *
  3842. * @param {String} iban
  3843. */
  3844. var Iban = function (iban) {
  3845. this._iban = iban;
  3846. };
  3847. /**
  3848. * This method should be used to create iban object from ethereum address
  3849. *
  3850. * @method fromAddress
  3851. * @param {String} address
  3852. * @return {Iban} the IBAN object
  3853. */
  3854. Iban.fromAddress = function (address) {
  3855. var asBn = new BigNumber(address, 16);
  3856. var base36 = asBn.toString(36);
  3857. var padded = padLeft(base36, 15);
  3858. return Iban.fromBban(padded.toUpperCase());
  3859. };
  3860. /**
  3861. * Convert the passed BBAN to an IBAN for this country specification.
  3862. * Please note that <i>"generation of the IBAN shall be the exclusive responsibility of the bank/branch servicing the account"</i>.
  3863. * This method implements the preferred algorithm described in http://en.wikipedia.org/wiki/International_Bank_Account_Number#Generating_IBAN_check_digits
  3864. *
  3865. * @method fromBban
  3866. * @param {String} bban the BBAN to convert to IBAN
  3867. * @returns {Iban} the IBAN object
  3868. */
  3869. Iban.fromBban = function (bban) {
  3870. var countryCode = 'XE';
  3871. var remainder = mod9710(iso13616Prepare(countryCode + '00' + bban));
  3872. var checkDigit = ('0' + (98 - remainder)).slice(-2);
  3873. return new Iban(countryCode + checkDigit + bban);
  3874. };
  3875. /**
  3876. * Should be used to create IBAN object for given institution and identifier
  3877. *
  3878. * @method createIndirect
  3879. * @param {Object} options, required options are "institution" and "identifier"
  3880. * @return {Iban} the IBAN object
  3881. */
  3882. Iban.createIndirect = function (options) {
  3883. return Iban.fromBban('ETH' + options.institution + options.identifier);
  3884. };
  3885. /**
  3886. * Thos method should be used to check if given string is valid iban object
  3887. *
  3888. * @method isValid
  3889. * @param {String} iban string
  3890. * @return {Boolean} true if it is valid IBAN
  3891. */
  3892. Iban.isValid = function (iban) {
  3893. var i = new Iban(iban);
  3894. return i.isValid();
  3895. };
  3896. /**
  3897. * Should be called to check if iban is correct
  3898. *
  3899. * @method isValid
  3900. * @returns {Boolean} true if it is, otherwise false
  3901. */
  3902. Iban.prototype.isValid = function () {
  3903. return /^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30,31})$/.test(this._iban) &&
  3904. mod9710(iso13616Prepare(this._iban)) === 1;
  3905. };
  3906. /**
  3907. * Should be called to check if iban number is direct
  3908. *
  3909. * @method isDirect
  3910. * @returns {Boolean} true if it is, otherwise false
  3911. */
  3912. Iban.prototype.isDirect = function () {
  3913. return this._iban.length === 34 || this._iban.length === 35;
  3914. };
  3915. /**
  3916. * Should be called to check if iban number if indirect
  3917. *
  3918. * @method isIndirect
  3919. * @returns {Boolean} true if it is, otherwise false
  3920. */
  3921. Iban.prototype.isIndirect = function () {
  3922. return this._iban.length === 20;
  3923. };
  3924. /**
  3925. * Should be called to get iban checksum
  3926. * Uses the mod-97-10 checksumming protocol (ISO/IEC 7064:2003)
  3927. *
  3928. * @method checksum
  3929. * @returns {String} checksum
  3930. */
  3931. Iban.prototype.checksum = function () {
  3932. return this._iban.substr(2, 2);
  3933. };
  3934. /**
  3935. * Should be called to get institution identifier
  3936. * eg. XREG
  3937. *
  3938. * @method institution
  3939. * @returns {String} institution identifier
  3940. */
  3941. Iban.prototype.institution = function () {
  3942. return this.isIndirect() ? this._iban.substr(7, 4) : '';
  3943. };
  3944. /**
  3945. * Should be called to get client identifier within institution
  3946. * eg. GAVOFYORK
  3947. *
  3948. * @method client
  3949. * @returns {String} client identifier
  3950. */
  3951. Iban.prototype.client = function () {
  3952. return this.isIndirect() ? this._iban.substr(11) : '';
  3953. };
  3954. /**
  3955. * Should be called to get client direct address
  3956. *
  3957. * @method address
  3958. * @returns {String} client direct address
  3959. */
  3960. Iban.prototype.address = function () {
  3961. if (this.isDirect()) {
  3962. var base36 = this._iban.substr(4);
  3963. var asBn = new BigNumber(base36, 36);
  3964. return padLeft(asBn.toString(16), 20);
  3965. }
  3966. return '';
  3967. };
  3968. Iban.prototype.toString = function () {
  3969. return this._iban;
  3970. };
  3971. module.exports = Iban;
  3972. },{"bignumber.js":"bignumber.js"}],34:[function(require,module,exports){
  3973. /*
  3974. This file is part of web3.js.
  3975. web3.js is free software: you can redistribute it and/or modify
  3976. it under the terms of the GNU Lesser General Public License as published by
  3977. the Free Software Foundation, either version 3 of the License, or
  3978. (at your option) any later version.
  3979. web3.js is distributed in the hope that it will be useful,
  3980. but WITHOUT ANY WARRANTY; without even the implied warranty of
  3981. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3982. GNU Lesser General Public License for more details.
  3983. You should have received a copy of the GNU Lesser General Public License
  3984. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  3985. */
  3986. /** @file ipcprovider.js
  3987. * @authors:
  3988. * Fabian Vogelsteller <[email protected]>
  3989. * @date 2015
  3990. */
  3991. "use strict";
  3992. var utils = require('../utils/utils');
  3993. var errors = require('./errors');
  3994. var IpcProvider = function (path, net) {
  3995. var _this = this;
  3996. this.responseCallbacks = {};
  3997. this.path = path;
  3998. this.connection = net.connect({path: this.path});
  3999. this.connection.on('error', function(e){
  4000. console.error('IPC Connection Error', e);
  4001. _this._timeout();
  4002. });
  4003. this.connection.on('end', function(){
  4004. _this._timeout();
  4005. });
  4006. // LISTEN FOR CONNECTION RESPONSES
  4007. this.connection.on('data', function(data) {
  4008. /*jshint maxcomplexity: 6 */
  4009. _this._parseResponse(data.toString()).forEach(function(result){
  4010. var id = null;
  4011. // get the id which matches the returned id
  4012. if(utils.isArray(result)) {
  4013. result.forEach(function(load){
  4014. if(_this.responseCallbacks[load.id])
  4015. id = load.id;
  4016. });
  4017. } else {
  4018. id = result.id;
  4019. }
  4020. // fire the callback
  4021. if(_this.responseCallbacks[id]) {
  4022. _this.responseCallbacks[id](null, result);
  4023. delete _this.responseCallbacks[id];
  4024. }
  4025. });
  4026. });
  4027. };
  4028. /**
  4029. Will parse the response and make an array out of it.
  4030. @method _parseResponse
  4031. @param {String} data
  4032. */
  4033. IpcProvider.prototype._parseResponse = function(data) {
  4034. var _this = this,
  4035. returnValues = [];
  4036. // DE-CHUNKER
  4037. var dechunkedData = data
  4038. .replace(/\}[\n\r]?\{/g,'}|--|{') // }{
  4039. .replace(/\}\][\n\r]?\[\{/g,'}]|--|[{') // }][{
  4040. .replace(/\}[\n\r]?\[\{/g,'}|--|[{') // }[{
  4041. .replace(/\}\][\n\r]?\{/g,'}]|--|{') // }]{
  4042. .split('|--|');
  4043. dechunkedData.forEach(function(data){
  4044. // prepend the last chunk
  4045. if(_this.lastChunk)
  4046. data = _this.lastChunk + data;
  4047. var result = null;
  4048. try {
  4049. result = JSON.parse(data);
  4050. } catch(e) {
  4051. _this.lastChunk = data;
  4052. // start timeout to cancel all requests
  4053. clearTimeout(_this.lastChunkTimeout);
  4054. _this.lastChunkTimeout = setTimeout(function(){
  4055. _this._timeout();
  4056. throw errors.InvalidResponse(data);
  4057. }, 1000 * 15);
  4058. return;
  4059. }
  4060. // cancel timeout and set chunk to null
  4061. clearTimeout(_this.lastChunkTimeout);
  4062. _this.lastChunk = null;
  4063. if(result)
  4064. returnValues.push(result);
  4065. });
  4066. return returnValues;
  4067. };
  4068. /**
  4069. Get the adds a callback to the responseCallbacks object,
  4070. which will be called if a response matching the response Id will arrive.
  4071. @method _addResponseCallback
  4072. */
  4073. IpcProvider.prototype._addResponseCallback = function(payload, callback) {
  4074. var id = payload.id || payload[0].id;
  4075. var method = payload.method || payload[0].method;
  4076. this.responseCallbacks[id] = callback;
  4077. this.responseCallbacks[id].method = method;
  4078. };
  4079. /**
  4080. Timeout all requests when the end/error event is fired
  4081. @method _timeout
  4082. */
  4083. IpcProvider.prototype._timeout = function() {
  4084. for(var key in this.responseCallbacks) {
  4085. if(this.responseCallbacks.hasOwnProperty(key)){
  4086. this.responseCallbacks[key](errors.InvalidConnection('on IPC'));
  4087. delete this.responseCallbacks[key];
  4088. }
  4089. }
  4090. };
  4091. /**
  4092. Check if the current connection is still valid.
  4093. @method isConnected
  4094. */
  4095. IpcProvider.prototype.isConnected = function() {
  4096. var _this = this;
  4097. // try reconnect, when connection is gone
  4098. if(!_this.connection.writable)
  4099. _this.connection.connect({path: _this.path});
  4100. return !!this.connection.writable;
  4101. };
  4102. IpcProvider.prototype.send = function (payload) {
  4103. if(this.connection.writeSync) {
  4104. var result;
  4105. // try reconnect, when connection is gone
  4106. if(!this.connection.writable)
  4107. this.connection.connect({path: this.path});
  4108. var data = this.connection.writeSync(JSON.stringify(payload));
  4109. try {
  4110. result = JSON.parse(data);
  4111. } catch(e) {
  4112. throw errors.InvalidResponse(data);
  4113. }
  4114. return result;
  4115. } else {
  4116. throw new Error('You tried to send "'+ payload.method +'" synchronously. Synchronous requests are not supported by the IPC provider.');
  4117. }
  4118. };
  4119. IpcProvider.prototype.sendAsync = function (payload, callback) {
  4120. // try reconnect, when connection is gone
  4121. if(!this.connection.writable)
  4122. this.connection.connect({path: this.path});
  4123. this.connection.write(JSON.stringify(payload));
  4124. this._addResponseCallback(payload, callback);
  4125. };
  4126. module.exports = IpcProvider;
  4127. },{"../utils/utils":20,"./errors":26}],35:[function(require,module,exports){
  4128. /*
  4129. This file is part of web3.js.
  4130. web3.js is free software: you can redistribute it and/or modify
  4131. it under the terms of the GNU Lesser General Public License as published by
  4132. the Free Software Foundation, either version 3 of the License, or
  4133. (at your option) any later version.
  4134. web3.js is distributed in the hope that it will be useful,
  4135. but WITHOUT ANY WARRANTY; without even the implied warranty of
  4136. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4137. GNU Lesser General Public License for more details.
  4138. You should have received a copy of the GNU Lesser General Public License
  4139. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  4140. */
  4141. /** @file jsonrpc.js
  4142. * @authors:
  4143. * Marek Kotewicz <[email protected]>
  4144. * Aaron Kumavis <[email protected]>
  4145. * @date 2015
  4146. */
  4147. // Initialize Jsonrpc as a simple object with utility functions.
  4148. var Jsonrpc = {
  4149. messageId: 0
  4150. };
  4151. /**
  4152. * Should be called to valid json create payload object
  4153. *
  4154. * @method toPayload
  4155. * @param {Function} method of jsonrpc call, required
  4156. * @param {Array} params, an array of method params, optional
  4157. * @returns {Object} valid jsonrpc payload object
  4158. */
  4159. Jsonrpc.toPayload = function (method, params) {
  4160. if (!method)
  4161. console.error('jsonrpc method should be specified!');
  4162. // advance message ID
  4163. Jsonrpc.messageId++;
  4164. return {
  4165. jsonrpc: '2.0',
  4166. id: Jsonrpc.messageId,
  4167. method: method,
  4168. params: params || []
  4169. };
  4170. };
  4171. /**
  4172. * Should be called to check if jsonrpc response is valid
  4173. *
  4174. * @method isValidResponse
  4175. * @param {Object}
  4176. * @returns {Boolean} true if response is valid, otherwise false
  4177. */
  4178. Jsonrpc.isValidResponse = function (response) {
  4179. return Array.isArray(response) ? response.every(validateSingleMessage) : validateSingleMessage(response);
  4180. function validateSingleMessage(message){
  4181. return !!message &&
  4182. !message.error &&
  4183. message.jsonrpc === '2.0' &&
  4184. typeof message.id === 'number' &&
  4185. message.result !== undefined; // only undefined is not valid json object
  4186. }
  4187. };
  4188. /**
  4189. * Should be called to create batch payload object
  4190. *
  4191. * @method toBatchPayload
  4192. * @param {Array} messages, an array of objects with method (required) and params (optional) fields
  4193. * @returns {Array} batch payload
  4194. */
  4195. Jsonrpc.toBatchPayload = function (messages) {
  4196. return messages.map(function (message) {
  4197. return Jsonrpc.toPayload(message.method, message.params);
  4198. });
  4199. };
  4200. module.exports = Jsonrpc;
  4201. },{}],36:[function(require,module,exports){
  4202. /*
  4203. This file is part of web3.js.
  4204. web3.js is free software: you can redistribute it and/or modify
  4205. it under the terms of the GNU Lesser General Public License as published by
  4206. the Free Software Foundation, either version 3 of the License, or
  4207. (at your option) any later version.
  4208. web3.js is distributed in the hope that it will be useful,
  4209. but WITHOUT ANY WARRANTY; without even the implied warranty of
  4210. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4211. GNU Lesser General Public License for more details.
  4212. You should have received a copy of the GNU Lesser General Public License
  4213. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  4214. */
  4215. /**
  4216. * @file method.js
  4217. * @author Marek Kotewicz <[email protected]>
  4218. * @date 2015
  4219. */
  4220. var utils = require('../utils/utils');
  4221. var errors = require('./errors');
  4222. var Method = function (options) {
  4223. this.name = options.name;
  4224. this.call = options.call;
  4225. this.params = options.params || 0;
  4226. this.inputFormatter = options.inputFormatter;
  4227. this.outputFormatter = options.outputFormatter;
  4228. this.requestManager = null;
  4229. };
  4230. Method.prototype.setRequestManager = function (rm) {
  4231. this.requestManager = rm;
  4232. };
  4233. /**
  4234. * Should be used to determine name of the jsonrpc method based on arguments
  4235. *
  4236. * @method getCall
  4237. * @param {Array} arguments
  4238. * @return {String} name of jsonrpc method
  4239. */
  4240. Method.prototype.getCall = function (args) {
  4241. return utils.isFunction(this.call) ? this.call(args) : this.call;
  4242. };
  4243. /**
  4244. * Should be used to extract callback from array of arguments. Modifies input param
  4245. *
  4246. * @method extractCallback
  4247. * @param {Array} arguments
  4248. * @return {Function|Null} callback, if exists
  4249. */
  4250. Method.prototype.extractCallback = function (args) {
  4251. if (utils.isFunction(args[args.length - 1])) {
  4252. return args.pop(); // modify the args array!
  4253. }
  4254. };
  4255. /**
  4256. * Should be called to check if the number of arguments is correct
  4257. *
  4258. * @method validateArgs
  4259. * @param {Array} arguments
  4260. * @throws {Error} if it is not
  4261. */
  4262. Method.prototype.validateArgs = function (args) {
  4263. if (args.length !== this.params) {
  4264. throw errors.InvalidNumberOfParams();
  4265. }
  4266. };
  4267. /**
  4268. * Should be called to format input args of method
  4269. *
  4270. * @method formatInput
  4271. * @param {Array}
  4272. * @return {Array}
  4273. */
  4274. Method.prototype.formatInput = function (args) {
  4275. if (!this.inputFormatter) {
  4276. return args;
  4277. }
  4278. return this.inputFormatter.map(function (formatter, index) {
  4279. return formatter ? formatter(args[index]) : args[index];
  4280. });
  4281. };
  4282. /**
  4283. * Should be called to format output(result) of method
  4284. *
  4285. * @method formatOutput
  4286. * @param {Object}
  4287. * @return {Object}
  4288. */
  4289. Method.prototype.formatOutput = function (result) {
  4290. return this.outputFormatter && result ? this.outputFormatter(result) : result;
  4291. };
  4292. /**
  4293. * Should create payload from given input args
  4294. *
  4295. * @method toPayload
  4296. * @param {Array} args
  4297. * @return {Object}
  4298. */
  4299. Method.prototype.toPayload = function (args) {
  4300. var call = this.getCall(args);
  4301. var callback = this.extractCallback(args);
  4302. var params = this.formatInput(args);
  4303. this.validateArgs(params);
  4304. return {
  4305. method: call,
  4306. params: params,
  4307. callback: callback
  4308. };
  4309. };
  4310. Method.prototype.attachToObject = function (obj) {
  4311. var func = this.buildCall();
  4312. func.call = this.call; // TODO!!! that's ugly. filter.js uses it
  4313. var name = this.name.split('.');
  4314. if (name.length > 1) {
  4315. obj[name[0]] = obj[name[0]] || {};
  4316. obj[name[0]][name[1]] = func;
  4317. } else {
  4318. obj[name[0]] = func;
  4319. }
  4320. };
  4321. Method.prototype.buildCall = function() {
  4322. var method = this;
  4323. var send = function () {
  4324. var payload = method.toPayload(Array.prototype.slice.call(arguments));
  4325. if (payload.callback) {
  4326. return method.requestManager.sendAsync(payload, function (err, result) {
  4327. payload.callback(err, method.formatOutput(result));
  4328. });
  4329. }
  4330. return method.formatOutput(method.requestManager.send(payload));
  4331. };
  4332. send.request = this.request.bind(this);
  4333. return send;
  4334. };
  4335. /**
  4336. * Should be called to create pure JSONRPC request which can be used in batch request
  4337. *
  4338. * @method request
  4339. * @param {...} params
  4340. * @return {Object} jsonrpc request
  4341. */
  4342. Method.prototype.request = function () {
  4343. var payload = this.toPayload(Array.prototype.slice.call(arguments));
  4344. payload.format = this.formatOutput.bind(this);
  4345. return payload;
  4346. };
  4347. module.exports = Method;
  4348. },{"../utils/utils":20,"./errors":26}],37:[function(require,module,exports){
  4349. /*
  4350. This file is part of web3.js.
  4351. web3.js is free software: you can redistribute it and/or modify
  4352. it under the terms of the GNU Lesser General Public License as published by
  4353. the Free Software Foundation, either version 3 of the License, or
  4354. (at your option) any later version.
  4355. web3.js is distributed in the hope that it will be useful,
  4356. but WITHOUT ANY WARRANTY; without even the implied warranty of
  4357. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4358. GNU Lesser General Public License for more details.
  4359. You should have received a copy of the GNU Lesser General Public License
  4360. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  4361. */
  4362. /** @file db.js
  4363. * @authors:
  4364. * Marek Kotewicz <[email protected]>
  4365. * @date 2015
  4366. */
  4367. var Method = require('../method');
  4368. var DB = function (web3) {
  4369. this._requestManager = web3._requestManager;
  4370. var self = this;
  4371. methods().forEach(function(method) {
  4372. method.attachToObject(self);
  4373. method.setRequestManager(web3._requestManager);
  4374. });
  4375. };
  4376. var methods = function () {
  4377. var putString = new Method({
  4378. name: 'putString',
  4379. call: 'db_putString',
  4380. params: 3
  4381. });
  4382. var getString = new Method({
  4383. name: 'getString',
  4384. call: 'db_getString',
  4385. params: 2
  4386. });
  4387. var putHex = new Method({
  4388. name: 'putHex',
  4389. call: 'db_putHex',
  4390. params: 3
  4391. });
  4392. var getHex = new Method({
  4393. name: 'getHex',
  4394. call: 'db_getHex',
  4395. params: 2
  4396. });
  4397. return [
  4398. putString, getString, putHex, getHex
  4399. ];
  4400. };
  4401. module.exports = DB;
  4402. },{"../method":36}],38:[function(require,module,exports){
  4403. /*
  4404. This file is part of web3.js.
  4405. web3.js is free software: you can redistribute it and/or modify
  4406. it under the terms of the GNU Lesser General Public License as published by
  4407. the Free Software Foundation, either version 3 of the License, or
  4408. (at your option) any later version.
  4409. web3.js is distributed in the hope that it will be useful,
  4410. but WITHOUT ANY WARRANTY; without even the implied warranty of
  4411. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4412. GNU Lesser General Public License for more details.
  4413. You should have received a copy of the GNU Lesser General Public License
  4414. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  4415. */
  4416. /**
  4417. * @file eth.js
  4418. * @author Marek Kotewicz <[email protected]>
  4419. * @author Fabian Vogelsteller <[email protected]>
  4420. * @date 2015
  4421. */
  4422. "use strict";
  4423. var formatters = require('../formatters');
  4424. var utils = require('../../utils/utils');
  4425. var Method = require('../method');
  4426. var Property = require('../property');
  4427. var c = require('../../utils/config');
  4428. var Contract = require('../contract');
  4429. var watches = require('./watches');
  4430. var Filter = require('../filter');
  4431. var IsSyncing = require('../syncing');
  4432. var namereg = require('../namereg');
  4433. var Iban = require('../iban');
  4434. var transfer = require('../transfer');
  4435. var blockCall = function (args) {
  4436. return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? "eth_getBlockByHash" : "eth_getBlockByNumber";
  4437. };
  4438. var transactionFromBlockCall = function (args) {
  4439. return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getTransactionByBlockHashAndIndex' : 'eth_getTransactionByBlockNumberAndIndex';
  4440. };
  4441. var uncleCall = function (args) {
  4442. return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleByBlockHashAndIndex' : 'eth_getUncleByBlockNumberAndIndex';
  4443. };
  4444. var getBlockTransactionCountCall = function (args) {
  4445. return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getBlockTransactionCountByHash' : 'eth_getBlockTransactionCountByNumber';
  4446. };
  4447. var uncleCountCall = function (args) {
  4448. return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleCountByBlockHash' : 'eth_getUncleCountByBlockNumber';
  4449. };
  4450. function Eth(web3) {
  4451. this._requestManager = web3._requestManager;
  4452. var self = this;
  4453. methods().forEach(function(method) {
  4454. method.attachToObject(self);
  4455. method.setRequestManager(self._requestManager);
  4456. });
  4457. properties().forEach(function(p) {
  4458. p.attachToObject(self);
  4459. p.setRequestManager(self._requestManager);
  4460. });
  4461. this.iban = Iban;
  4462. this.sendIBANTransaction = transfer.bind(null, this);
  4463. }
  4464. Object.defineProperty(Eth.prototype, 'defaultBlock', {
  4465. get: function () {
  4466. return c.defaultBlock;
  4467. },
  4468. set: function (val) {
  4469. c.defaultBlock = val;
  4470. return val;
  4471. }
  4472. });
  4473. Object.defineProperty(Eth.prototype, 'defaultAccount', {
  4474. get: function () {
  4475. return c.defaultAccount;
  4476. },
  4477. set: function (val) {
  4478. c.defaultAccount = val;
  4479. return val;
  4480. }
  4481. });
  4482. var methods = function () {
  4483. var getBalance = new Method({
  4484. name: 'getBalance',
  4485. call: 'eth_getBalance',
  4486. params: 2,
  4487. inputFormatter: [formatters.inputAddressFormatter, formatters.inputDefaultBlockNumberFormatter],
  4488. outputFormatter: formatters.outputBigNumberFormatter
  4489. });
  4490. var getStorageAt = new Method({
  4491. name: 'getStorageAt',
  4492. call: 'eth_getStorageAt',
  4493. params: 3,
  4494. inputFormatter: [null, utils.toHex, formatters.inputDefaultBlockNumberFormatter]
  4495. });
  4496. var getCode = new Method({
  4497. name: 'getCode',
  4498. call: 'eth_getCode',
  4499. params: 2,
  4500. inputFormatter: [formatters.inputAddressFormatter, formatters.inputDefaultBlockNumberFormatter]
  4501. });
  4502. var getBlock = new Method({
  4503. name: 'getBlock',
  4504. call: blockCall,
  4505. params: 2,
  4506. inputFormatter: [formatters.inputBlockNumberFormatter, function (val) { return !!val; }],
  4507. outputFormatter: formatters.outputBlockFormatter
  4508. });
  4509. var getUncle = new Method({
  4510. name: 'getUncle',
  4511. call: uncleCall,
  4512. params: 2,
  4513. inputFormatter: [formatters.inputBlockNumberFormatter, utils.toHex],
  4514. outputFormatter: formatters.outputBlockFormatter,
  4515. });
  4516. var getCompilers = new Method({
  4517. name: 'getCompilers',
  4518. call: 'eth_getCompilers',
  4519. params: 0
  4520. });
  4521. var getBlockTransactionCount = new Method({
  4522. name: 'getBlockTransactionCount',
  4523. call: getBlockTransactionCountCall,
  4524. params: 1,
  4525. inputFormatter: [formatters.inputBlockNumberFormatter],
  4526. outputFormatter: utils.toDecimal
  4527. });
  4528. var getBlockUncleCount = new Method({
  4529. name: 'getBlockUncleCount',
  4530. call: uncleCountCall,
  4531. params: 1,
  4532. inputFormatter: [formatters.inputBlockNumberFormatter],
  4533. outputFormatter: utils.toDecimal
  4534. });
  4535. var getTransaction = new Method({
  4536. name: 'getTransaction',
  4537. call: 'eth_getTransactionByHash',
  4538. params: 1,
  4539. outputFormatter: formatters.outputTransactionFormatter
  4540. });
  4541. var getTransactionFromBlock = new Method({
  4542. name: 'getTransactionFromBlock',
  4543. call: transactionFromBlockCall,
  4544. params: 2,
  4545. inputFormatter: [formatters.inputBlockNumberFormatter, utils.toHex],
  4546. outputFormatter: formatters.outputTransactionFormatter
  4547. });
  4548. var getTransactionReceipt = new Method({
  4549. name: 'getTransactionReceipt',
  4550. call: 'eth_getTransactionReceipt',
  4551. params: 1,
  4552. outputFormatter: formatters.outputTransactionReceiptFormatter
  4553. });
  4554. var getTransactionCount = new Method({
  4555. name: 'getTransactionCount',
  4556. call: 'eth_getTransactionCount',
  4557. params: 2,
  4558. inputFormatter: [null, formatters.inputDefaultBlockNumberFormatter],
  4559. outputFormatter: utils.toDecimal
  4560. });
  4561. var sendRawTransaction = new Method({
  4562. name: 'sendRawTransaction',
  4563. call: 'eth_sendRawTransaction',
  4564. params: 1,
  4565. inputFormatter: [null]
  4566. });
  4567. var sendTransaction = new Method({
  4568. name: 'sendTransaction',
  4569. call: 'eth_sendTransaction',
  4570. params: 1,
  4571. inputFormatter: [formatters.inputTransactionFormatter]
  4572. });
  4573. var sign = new Method({
  4574. name: 'sign',
  4575. call: 'eth_sign',
  4576. params: 2,
  4577. inputFormatter: [formatters.inputAddressFormatter, null]
  4578. });
  4579. var call = new Method({
  4580. name: 'call',
  4581. call: 'eth_call',
  4582. params: 2,
  4583. inputFormatter: [formatters.inputCallFormatter, formatters.inputDefaultBlockNumberFormatter]
  4584. });
  4585. var estimateGas = new Method({
  4586. name: 'estimateGas',
  4587. call: 'eth_estimateGas',
  4588. params: 1,
  4589. inputFormatter: [formatters.inputCallFormatter],
  4590. outputFormatter: utils.toDecimal
  4591. });
  4592. var compileSolidity = new Method({
  4593. name: 'compile.solidity',
  4594. call: 'eth_compileSolidity',
  4595. params: 1
  4596. });
  4597. var compileLLL = new Method({
  4598. name: 'compile.lll',
  4599. call: 'eth_compileLLL',
  4600. params: 1
  4601. });
  4602. var compileSerpent = new Method({
  4603. name: 'compile.serpent',
  4604. call: 'eth_compileSerpent',
  4605. params: 1
  4606. });
  4607. var submitWork = new Method({
  4608. name: 'submitWork',
  4609. call: 'eth_submitWork',
  4610. params: 3
  4611. });
  4612. var getWork = new Method({
  4613. name: 'getWork',
  4614. call: 'eth_getWork',
  4615. params: 0
  4616. });
  4617. return [
  4618. getBalance,
  4619. getStorageAt,
  4620. getCode,
  4621. getBlock,
  4622. getUncle,
  4623. getCompilers,
  4624. getBlockTransactionCount,
  4625. getBlockUncleCount,
  4626. getTransaction,
  4627. getTransactionFromBlock,
  4628. getTransactionReceipt,
  4629. getTransactionCount,
  4630. call,
  4631. estimateGas,
  4632. sendRawTransaction,
  4633. sendTransaction,
  4634. sign,
  4635. compileSolidity,
  4636. compileLLL,
  4637. compileSerpent,
  4638. submitWork,
  4639. getWork
  4640. ];
  4641. };
  4642. var properties = function () {
  4643. return [
  4644. new Property({
  4645. name: 'coinbase',
  4646. getter: 'eth_coinbase'
  4647. }),
  4648. new Property({
  4649. name: 'mining',
  4650. getter: 'eth_mining'
  4651. }),
  4652. new Property({
  4653. name: 'hashrate',
  4654. getter: 'eth_hashrate',
  4655. outputFormatter: utils.toDecimal
  4656. }),
  4657. new Property({
  4658. name: 'syncing',
  4659. getter: 'eth_syncing',
  4660. outputFormatter: formatters.outputSyncingFormatter
  4661. }),
  4662. new Property({
  4663. name: 'gasPrice',
  4664. getter: 'eth_gasPrice',
  4665. outputFormatter: formatters.outputBigNumberFormatter
  4666. }),
  4667. new Property({
  4668. name: 'accounts',
  4669. getter: 'eth_accounts'
  4670. }),
  4671. new Property({
  4672. name: 'blockNumber',
  4673. getter: 'eth_blockNumber',
  4674. outputFormatter: utils.toDecimal
  4675. }),
  4676. new Property({
  4677. name: 'protocolVersion',
  4678. getter: 'eth_protocolVersion'
  4679. })
  4680. ];
  4681. };
  4682. Eth.prototype.contract = function (abi) {
  4683. var factory = new Contract(this, abi);
  4684. return factory;
  4685. };
  4686. Eth.prototype.filter = function (fil, callback) {
  4687. return new Filter(this._requestManager, fil, watches.eth(), formatters.outputLogFormatter, callback);
  4688. };
  4689. Eth.prototype.namereg = function () {
  4690. return this.contract(namereg.global.abi).at(namereg.global.address);
  4691. };
  4692. Eth.prototype.icapNamereg = function () {
  4693. return this.contract(namereg.icap.abi).at(namereg.icap.address);
  4694. };
  4695. Eth.prototype.isSyncing = function (callback) {
  4696. return new IsSyncing(this._requestManager, callback);
  4697. };
  4698. module.exports = Eth;
  4699. },{"../../utils/config":18,"../../utils/utils":20,"../contract":25,"../filter":29,"../formatters":30,"../iban":33,"../method":36,"../namereg":44,"../property":45,"../syncing":48,"../transfer":49,"./watches":43}],39:[function(require,module,exports){
  4700. /*
  4701. This file is part of web3.js.
  4702. web3.js is free software: you can redistribute it and/or modify
  4703. it under the terms of the GNU Lesser General Public License as published by
  4704. the Free Software Foundation, either version 3 of the License, or
  4705. (at your option) any later version.
  4706. web3.js is distributed in the hope that it will be useful,
  4707. but WITHOUT ANY WARRANTY; without even the implied warranty of
  4708. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4709. GNU Lesser General Public License for more details.
  4710. You should have received a copy of the GNU Lesser General Public License
  4711. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  4712. */
  4713. /** @file eth.js
  4714. * @authors:
  4715. * Marek Kotewicz <[email protected]>
  4716. * @date 2015
  4717. */
  4718. var utils = require('../../utils/utils');
  4719. var Property = require('../property');
  4720. var Net = function (web3) {
  4721. this._requestManager = web3._requestManager;
  4722. var self = this;
  4723. properties().forEach(function(p) {
  4724. p.attachToObject(self);
  4725. p.setRequestManager(web3._requestManager);
  4726. });
  4727. };
  4728. /// @returns an array of objects describing web3.eth api properties
  4729. var properties = function () {
  4730. return [
  4731. new Property({
  4732. name: 'listening',
  4733. getter: 'net_listening'
  4734. }),
  4735. new Property({
  4736. name: 'peerCount',
  4737. getter: 'net_peerCount',
  4738. outputFormatter: utils.toDecimal
  4739. })
  4740. ];
  4741. };
  4742. module.exports = Net;
  4743. },{"../../utils/utils":20,"../property":45}],40:[function(require,module,exports){
  4744. /*
  4745. This file is part of web3.js.
  4746. web3.js is free software: you can redistribute it and/or modify
  4747. it under the terms of the GNU Lesser General Public License as published by
  4748. the Free Software Foundation, either version 3 of the License, or
  4749. (at your option) any later version.
  4750. web3.js is distributed in the hope that it will be useful,
  4751. but WITHOUT ANY WARRANTY; without even the implied warranty of
  4752. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4753. GNU Lesser General Public License for more details.
  4754. You should have received a copy of the GNU Lesser General Public License
  4755. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  4756. */
  4757. /**
  4758. * @file eth.js
  4759. * @author Marek Kotewicz <[email protected]>
  4760. * @author Fabian Vogelsteller <[email protected]>
  4761. * @date 2015
  4762. */
  4763. "use strict";
  4764. var Method = require('../method');
  4765. var Property = require('../property');
  4766. var formatters = require('../formatters');
  4767. function Personal(web3) {
  4768. this._requestManager = web3._requestManager;
  4769. var self = this;
  4770. methods().forEach(function(method) {
  4771. method.attachToObject(self);
  4772. method.setRequestManager(self._requestManager);
  4773. });
  4774. properties().forEach(function(p) {
  4775. p.attachToObject(self);
  4776. p.setRequestManager(self._requestManager);
  4777. });
  4778. }
  4779. var methods = function () {
  4780. var newAccount = new Method({
  4781. name: 'newAccount',
  4782. call: 'personal_newAccount',
  4783. params: 1,
  4784. inputFormatter: [null]
  4785. });
  4786. var unlockAccount = new Method({
  4787. name: 'unlockAccount',
  4788. call: 'personal_unlockAccount',
  4789. params: 3,
  4790. inputFormatter: [formatters.inputAddressFormatter, null, null]
  4791. });
  4792. var sendTransaction = new Method({
  4793. name: 'sendTransaction',
  4794. call: 'personal_sendTransaction',
  4795. params: 2,
  4796. inputFormatter: [formatters.inputTransactionFormatter, null]
  4797. });
  4798. var lockAccount = new Method({
  4799. name: 'lockAccount',
  4800. call: 'personal_lockAccount',
  4801. params: 1,
  4802. inputFormatter: [formatters.inputAddressFormatter]
  4803. });
  4804. return [
  4805. newAccount,
  4806. unlockAccount,
  4807. sendTransaction,
  4808. lockAccount
  4809. ];
  4810. };
  4811. var properties = function () {
  4812. return [
  4813. new Property({
  4814. name: 'listAccounts',
  4815. getter: 'personal_listAccounts'
  4816. })
  4817. ];
  4818. };
  4819. module.exports = Personal;
  4820. },{"../formatters":30,"../method":36,"../property":45}],41:[function(require,module,exports){
  4821. /*
  4822. This file is part of web3.js.
  4823. web3.js is free software: you can redistribute it and/or modify
  4824. it under the terms of the GNU Lesser General Public License as published by
  4825. the Free Software Foundation, either version 3 of the License, or
  4826. (at your option) any later version.
  4827. web3.js is distributed in the hope that it will be useful,
  4828. but WITHOUT ANY WARRANTY; without even the implied warranty of
  4829. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4830. GNU Lesser General Public License for more details.
  4831. You should have received a copy of the GNU Lesser General Public License
  4832. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  4833. */
  4834. /** @file shh.js
  4835. * @authors:
  4836. * Marek Kotewicz <[email protected]>
  4837. * @date 2015
  4838. */
  4839. var Method = require('../method');
  4840. var formatters = require('../formatters');
  4841. var Filter = require('../filter');
  4842. var watches = require('./watches');
  4843. var Shh = function (web3) {
  4844. this._requestManager = web3._requestManager;
  4845. var self = this;
  4846. methods().forEach(function(method) {
  4847. method.attachToObject(self);
  4848. method.setRequestManager(self._requestManager);
  4849. });
  4850. };
  4851. Shh.prototype.filter = function (fil, callback) {
  4852. return new Filter(this._requestManager, fil, watches.shh(), formatters.outputPostFormatter, callback);
  4853. };
  4854. var methods = function () {
  4855. var post = new Method({
  4856. name: 'post',
  4857. call: 'shh_post',
  4858. params: 1,
  4859. inputFormatter: [formatters.inputPostFormatter]
  4860. });
  4861. var newIdentity = new Method({
  4862. name: 'newIdentity',
  4863. call: 'shh_newIdentity',
  4864. params: 0
  4865. });
  4866. var hasIdentity = new Method({
  4867. name: 'hasIdentity',
  4868. call: 'shh_hasIdentity',
  4869. params: 1
  4870. });
  4871. var newGroup = new Method({
  4872. name: 'newGroup',
  4873. call: 'shh_newGroup',
  4874. params: 0
  4875. });
  4876. var addToGroup = new Method({
  4877. name: 'addToGroup',
  4878. call: 'shh_addToGroup',
  4879. params: 0
  4880. });
  4881. return [
  4882. post,
  4883. newIdentity,
  4884. hasIdentity,
  4885. newGroup,
  4886. addToGroup
  4887. ];
  4888. };
  4889. module.exports = Shh;
  4890. },{"../filter":29,"../formatters":30,"../method":36,"./watches":43}],42:[function(require,module,exports){
  4891. /*
  4892. This file is part of web3.js.
  4893. web3.js is free software: you can redistribute it and/or modify
  4894. it under the terms of the GNU Lesser General Public License as published by
  4895. the Free Software Foundation, either version 3 of the License, or
  4896. (at your option) any later version.
  4897. web3.js is distributed in the hope that it will be useful,
  4898. but WITHOUT ANY WARRANTY; without even the implied warranty of
  4899. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4900. GNU Lesser General Public License for more details.
  4901. You should have received a copy of the GNU Lesser General Public License
  4902. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  4903. */
  4904. /**
  4905. * @file bzz.js
  4906. * @author Alex Beregszaszi <[email protected]>
  4907. * @date 2016
  4908. *
  4909. * Reference: https://github.com/ethereum/go-ethereum/blob/swarm/internal/web3ext/web3ext.go#L33
  4910. */
  4911. "use strict";
  4912. var Method = require('../method');
  4913. var Property = require('../property');
  4914. function Swarm(web3) {
  4915. this._requestManager = web3._requestManager;
  4916. var self = this;
  4917. methods().forEach(function(method) {
  4918. method.attachToObject(self);
  4919. method.setRequestManager(self._requestManager);
  4920. });
  4921. properties().forEach(function(p) {
  4922. p.attachToObject(self);
  4923. p.setRequestManager(self._requestManager);
  4924. });
  4925. }
  4926. var methods = function () {
  4927. var blockNetworkRead = new Method({
  4928. name: 'blockNetworkRead',
  4929. call: 'bzz_blockNetworkRead',
  4930. params: 1,
  4931. inputFormatter: [null]
  4932. });
  4933. var syncEnabled = new Method({
  4934. name: 'syncEnabled',
  4935. call: 'bzz_syncEnabled',
  4936. params: 1,
  4937. inputFormatter: [null]
  4938. });
  4939. var swapEnabled = new Method({
  4940. name: 'swapEnabled',
  4941. call: 'bzz_swapEnabled',
  4942. params: 1,
  4943. inputFormatter: [null]
  4944. });
  4945. var download = new Method({
  4946. name: 'download',
  4947. call: 'bzz_download',
  4948. params: 2,
  4949. inputFormatter: [null, null]
  4950. });
  4951. var upload = new Method({
  4952. name: 'upload',
  4953. call: 'bzz_upload',
  4954. params: 2,
  4955. inputFormatter: [null, null]
  4956. });
  4957. var retrieve = new Method({
  4958. name: 'retrieve',
  4959. call: 'bzz_retrieve',
  4960. params: 1,
  4961. inputFormatter: [null]
  4962. });
  4963. var store = new Method({
  4964. name: 'store',
  4965. call: 'bzz_store',
  4966. params: 2,
  4967. inputFormatter: [null, null]
  4968. });
  4969. var get = new Method({
  4970. name: 'get',
  4971. call: 'bzz_get',
  4972. params: 1,
  4973. inputFormatter: [null]
  4974. });
  4975. var put = new Method({
  4976. name: 'put',
  4977. call: 'bzz_put',
  4978. params: 2,
  4979. inputFormatter: [null, null]
  4980. });
  4981. var modify = new Method({
  4982. name: 'modify',
  4983. call: 'bzz_modify',
  4984. params: 4,
  4985. inputFormatter: [null, null, null, null]
  4986. });
  4987. return [
  4988. blockNetworkRead,
  4989. syncEnabled,
  4990. swapEnabled,
  4991. download,
  4992. upload,
  4993. retrieve,
  4994. store,
  4995. get,
  4996. put,
  4997. modify
  4998. ];
  4999. };
  5000. var properties = function () {
  5001. return [
  5002. new Property({
  5003. name: 'hive',
  5004. getter: 'bzz_hive'
  5005. }),
  5006. new Property({
  5007. name: 'info',
  5008. getter: 'bzz_info'
  5009. })
  5010. ];
  5011. };
  5012. module.exports = Swarm;
  5013. },{"../method":36,"../property":45}],43:[function(require,module,exports){
  5014. /*
  5015. This file is part of web3.js.
  5016. web3.js is free software: you can redistribute it and/or modify
  5017. it under the terms of the GNU Lesser General Public License as published by
  5018. the Free Software Foundation, either version 3 of the License, or
  5019. (at your option) any later version.
  5020. web3.js is distributed in the hope that it will be useful,
  5021. but WITHOUT ANY WARRANTY; without even the implied warranty of
  5022. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5023. GNU Lesser General Public License for more details.
  5024. You should have received a copy of the GNU Lesser General Public License
  5025. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  5026. */
  5027. /** @file watches.js
  5028. * @authors:
  5029. * Marek Kotewicz <[email protected]>
  5030. * @date 2015
  5031. */
  5032. var Method = require('../method');
  5033. /// @returns an array of objects describing web3.eth.filter api methods
  5034. var eth = function () {
  5035. var newFilterCall = function (args) {
  5036. var type = args[0];
  5037. switch(type) {
  5038. case 'latest':
  5039. args.shift();
  5040. this.params = 0;
  5041. return 'eth_newBlockFilter';
  5042. case 'pending':
  5043. args.shift();
  5044. this.params = 0;
  5045. return 'eth_newPendingTransactionFilter';
  5046. default:
  5047. return 'eth_newFilter';
  5048. }
  5049. };
  5050. var newFilter = new Method({
  5051. name: 'newFilter',
  5052. call: newFilterCall,
  5053. params: 1
  5054. });
  5055. var uninstallFilter = new Method({
  5056. name: 'uninstallFilter',
  5057. call: 'eth_uninstallFilter',
  5058. params: 1
  5059. });
  5060. var getLogs = new Method({
  5061. name: 'getLogs',
  5062. call: 'eth_getFilterLogs',
  5063. params: 1
  5064. });
  5065. var poll = new Method({
  5066. name: 'poll',
  5067. call: 'eth_getFilterChanges',
  5068. params: 1
  5069. });
  5070. return [
  5071. newFilter,
  5072. uninstallFilter,
  5073. getLogs,
  5074. poll
  5075. ];
  5076. };
  5077. /// @returns an array of objects describing web3.shh.watch api methods
  5078. var shh = function () {
  5079. var newFilter = new Method({
  5080. name: 'newFilter',
  5081. call: 'shh_newFilter',
  5082. params: 1
  5083. });
  5084. var uninstallFilter = new Method({
  5085. name: 'uninstallFilter',
  5086. call: 'shh_uninstallFilter',
  5087. params: 1
  5088. });
  5089. var getLogs = new Method({
  5090. name: 'getLogs',
  5091. call: 'shh_getMessages',
  5092. params: 1
  5093. });
  5094. var poll = new Method({
  5095. name: 'poll',
  5096. call: 'shh_getFilterChanges',
  5097. params: 1
  5098. });
  5099. return [
  5100. newFilter,
  5101. uninstallFilter,
  5102. getLogs,
  5103. poll
  5104. ];
  5105. };
  5106. module.exports = {
  5107. eth: eth,
  5108. shh: shh
  5109. };
  5110. },{"../method":36}],44:[function(require,module,exports){
  5111. /*
  5112. This file is part of web3.js.
  5113. web3.js is free software: you can redistribute it and/or modify
  5114. it under the terms of the GNU Lesser General Public License as published by
  5115. the Free Software Foundation, either version 3 of the License, or
  5116. (at your option) any later version.
  5117. web3.js is distributed in the hope that it will be useful,
  5118. but WITHOUT ANY WARRANTY; without even the implied warranty of
  5119. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5120. GNU Lesser General Public License for more details.
  5121. You should have received a copy of the GNU Lesser General Public License
  5122. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  5123. */
  5124. /**
  5125. * @file namereg.js
  5126. * @author Marek Kotewicz <[email protected]>
  5127. * @date 2015
  5128. */
  5129. var globalRegistrarAbi = require('../contracts/GlobalRegistrar.json');
  5130. var icapRegistrarAbi= require('../contracts/ICAPRegistrar.json');
  5131. var globalNameregAddress = '0xc6d9d2cd449a754c494264e1809c50e34d64562b';
  5132. var icapNameregAddress = '0xa1a111bc074c9cfa781f0c38e63bd51c91b8af00';
  5133. module.exports = {
  5134. global: {
  5135. abi: globalRegistrarAbi,
  5136. address: globalNameregAddress
  5137. },
  5138. icap: {
  5139. abi: icapRegistrarAbi,
  5140. address: icapNameregAddress
  5141. }
  5142. };
  5143. },{"../contracts/GlobalRegistrar.json":1,"../contracts/ICAPRegistrar.json":2}],45:[function(require,module,exports){
  5144. /*
  5145. This file is part of web3.js.
  5146. web3.js is free software: you can redistribute it and/or modify
  5147. it under the terms of the GNU Lesser General Public License as published by
  5148. the Free Software Foundation, either version 3 of the License, or
  5149. (at your option) any later version.
  5150. web3.js is distributed in the hope that it will be useful,
  5151. but WITHOUT ANY WARRANTY; without even the implied warranty of
  5152. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5153. GNU Lesser General Public License for more details.
  5154. You should have received a copy of the GNU Lesser General Public License
  5155. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  5156. */
  5157. /**
  5158. * @file property.js
  5159. * @author Fabian Vogelsteller <[email protected]>
  5160. * @author Marek Kotewicz <[email protected]>
  5161. * @date 2015
  5162. */
  5163. var utils = require('../utils/utils');
  5164. var Property = function (options) {
  5165. this.name = options.name;
  5166. this.getter = options.getter;
  5167. this.setter = options.setter;
  5168. this.outputFormatter = options.outputFormatter;
  5169. this.inputFormatter = options.inputFormatter;
  5170. this.requestManager = null;
  5171. };
  5172. Property.prototype.setRequestManager = function (rm) {
  5173. this.requestManager = rm;
  5174. };
  5175. /**
  5176. * Should be called to format input args of method
  5177. *
  5178. * @method formatInput
  5179. * @param {Array}
  5180. * @return {Array}
  5181. */
  5182. Property.prototype.formatInput = function (arg) {
  5183. return this.inputFormatter ? this.inputFormatter(arg) : arg;
  5184. };
  5185. /**
  5186. * Should be called to format output(result) of method
  5187. *
  5188. * @method formatOutput
  5189. * @param {Object}
  5190. * @return {Object}
  5191. */
  5192. Property.prototype.formatOutput = function (result) {
  5193. return this.outputFormatter && result !== null && result !== undefined ? this.outputFormatter(result) : result;
  5194. };
  5195. /**
  5196. * Should be used to extract callback from array of arguments. Modifies input param
  5197. *
  5198. * @method extractCallback
  5199. * @param {Array} arguments
  5200. * @return {Function|Null} callback, if exists
  5201. */
  5202. Property.prototype.extractCallback = function (args) {
  5203. if (utils.isFunction(args[args.length - 1])) {
  5204. return args.pop(); // modify the args array!
  5205. }
  5206. };
  5207. /**
  5208. * Should attach function to method
  5209. *
  5210. * @method attachToObject
  5211. * @param {Object}
  5212. * @param {Function}
  5213. */
  5214. Property.prototype.attachToObject = function (obj) {
  5215. var proto = {
  5216. get: this.buildGet(),
  5217. enumerable: true
  5218. };
  5219. var names = this.name.split('.');
  5220. var name = names[0];
  5221. if (names.length > 1) {
  5222. obj[names[0]] = obj[names[0]] || {};
  5223. obj = obj[names[0]];
  5224. name = names[1];
  5225. }
  5226. Object.defineProperty(obj, name, proto);
  5227. obj[asyncGetterName(name)] = this.buildAsyncGet();
  5228. };
  5229. var asyncGetterName = function (name) {
  5230. return 'get' + name.charAt(0).toUpperCase() + name.slice(1);
  5231. };
  5232. Property.prototype.buildGet = function () {
  5233. var property = this;
  5234. return function get() {
  5235. return property.formatOutput(property.requestManager.send({
  5236. method: property.getter
  5237. }));
  5238. };
  5239. };
  5240. Property.prototype.buildAsyncGet = function () {
  5241. var property = this;
  5242. var get = function (callback) {
  5243. property.requestManager.sendAsync({
  5244. method: property.getter
  5245. }, function (err, result) {
  5246. callback(err, property.formatOutput(result));
  5247. });
  5248. };
  5249. get.request = this.request.bind(this);
  5250. return get;
  5251. };
  5252. /**
  5253. * Should be called to create pure JSONRPC request which can be used in batch request
  5254. *
  5255. * @method request
  5256. * @param {...} params
  5257. * @return {Object} jsonrpc request
  5258. */
  5259. Property.prototype.request = function () {
  5260. var payload = {
  5261. method: this.getter,
  5262. params: [],
  5263. callback: this.extractCallback(Array.prototype.slice.call(arguments))
  5264. };
  5265. payload.format = this.formatOutput.bind(this);
  5266. return payload;
  5267. };
  5268. module.exports = Property;
  5269. },{"../utils/utils":20}],46:[function(require,module,exports){
  5270. /*
  5271. This file is part of web3.js.
  5272. web3.js is free software: you can redistribute it and/or modify
  5273. it under the terms of the GNU Lesser General Public License as published by
  5274. the Free Software Foundation, either version 3 of the License, or
  5275. (at your option) any later version.
  5276. web3.js is distributed in the hope that it will be useful,
  5277. but WITHOUT ANY WARRANTY; without even the implied warranty of
  5278. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5279. GNU Lesser General Public License for more details.
  5280. You should have received a copy of the GNU Lesser General Public License
  5281. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  5282. */
  5283. /**
  5284. * @file requestmanager.js
  5285. * @author Jeffrey Wilcke <[email protected]>
  5286. * @author Marek Kotewicz <[email protected]>
  5287. * @author Marian Oancea <[email protected]>
  5288. * @author Fabian Vogelsteller <[email protected]>
  5289. * @author Gav Wood <[email protected]>
  5290. * @date 2014
  5291. */
  5292. var Jsonrpc = require('./jsonrpc');
  5293. var utils = require('../utils/utils');
  5294. var c = require('../utils/config');
  5295. var errors = require('./errors');
  5296. /**
  5297. * It's responsible for passing messages to providers
  5298. * It's also responsible for polling the ethereum node for incoming messages
  5299. * Default poll timeout is 1 second
  5300. * Singleton
  5301. */
  5302. var RequestManager = function (provider) {
  5303. this.provider = provider;
  5304. this.polls = {};
  5305. this.timeout = null;
  5306. };
  5307. /**
  5308. * Should be used to synchronously send request
  5309. *
  5310. * @method send
  5311. * @param {Object} data
  5312. * @return {Object}
  5313. */
  5314. RequestManager.prototype.send = function (data) {
  5315. if (!this.provider) {
  5316. console.error(errors.InvalidProvider());
  5317. return null;
  5318. }
  5319. var payload = Jsonrpc.toPayload(data.method, data.params);
  5320. var result = this.provider.send(payload);
  5321. if (!Jsonrpc.isValidResponse(result)) {
  5322. throw errors.InvalidResponse(result);
  5323. }
  5324. return result.result;
  5325. };
  5326. /**
  5327. * Should be used to asynchronously send request
  5328. *
  5329. * @method sendAsync
  5330. * @param {Object} data
  5331. * @param {Function} callback
  5332. */
  5333. RequestManager.prototype.sendAsync = function (data, callback) {
  5334. if (!this.provider) {
  5335. return callback(errors.InvalidProvider());
  5336. }
  5337. var payload = Jsonrpc.toPayload(data.method, data.params);
  5338. this.provider.sendAsync(payload, function (err, result) {
  5339. if (err) {
  5340. return callback(err);
  5341. }
  5342. if (!Jsonrpc.isValidResponse(result)) {
  5343. return callback(errors.InvalidResponse(result));
  5344. }
  5345. callback(null, result.result);
  5346. });
  5347. };
  5348. /**
  5349. * Should be called to asynchronously send batch request
  5350. *
  5351. * @method sendBatch
  5352. * @param {Array} batch data
  5353. * @param {Function} callback
  5354. */
  5355. RequestManager.prototype.sendBatch = function (data, callback) {
  5356. if (!this.provider) {
  5357. return callback(errors.InvalidProvider());
  5358. }
  5359. var payload = Jsonrpc.toBatchPayload(data);
  5360. this.provider.sendAsync(payload, function (err, results) {
  5361. if (err) {
  5362. return callback(err);
  5363. }
  5364. if (!utils.isArray(results)) {
  5365. return callback(errors.InvalidResponse(results));
  5366. }
  5367. callback(err, results);
  5368. });
  5369. };
  5370. /**
  5371. * Should be used to set provider of request manager
  5372. *
  5373. * @method setProvider
  5374. * @param {Object}
  5375. */
  5376. RequestManager.prototype.setProvider = function (p) {
  5377. this.provider = p;
  5378. };
  5379. /**
  5380. * Should be used to start polling
  5381. *
  5382. * @method startPolling
  5383. * @param {Object} data
  5384. * @param {Number} pollId
  5385. * @param {Function} callback
  5386. * @param {Function} uninstall
  5387. *
  5388. * @todo cleanup number of params
  5389. */
  5390. RequestManager.prototype.startPolling = function (data, pollId, callback, uninstall) {
  5391. this.polls[pollId] = {data: data, id: pollId, callback: callback, uninstall: uninstall};
  5392. // start polling
  5393. if (!this.timeout) {
  5394. this.poll();
  5395. }
  5396. };
  5397. /**
  5398. * Should be used to stop polling for filter with given id
  5399. *
  5400. * @method stopPolling
  5401. * @param {Number} pollId
  5402. */
  5403. RequestManager.prototype.stopPolling = function (pollId) {
  5404. delete this.polls[pollId];
  5405. // stop polling
  5406. if(Object.keys(this.polls).length === 0 && this.timeout) {
  5407. clearTimeout(this.timeout);
  5408. this.timeout = null;
  5409. }
  5410. };
  5411. /**
  5412. * Should be called to reset the polling mechanism of the request manager
  5413. *
  5414. * @method reset
  5415. */
  5416. RequestManager.prototype.reset = function (keepIsSyncing) {
  5417. /*jshint maxcomplexity:5 */
  5418. for (var key in this.polls) {
  5419. // remove all polls, except sync polls,
  5420. // they need to be removed manually by calling syncing.stopWatching()
  5421. if(!keepIsSyncing || key.indexOf('syncPoll_') === -1) {
  5422. this.polls[key].uninstall();
  5423. delete this.polls[key];
  5424. }
  5425. }
  5426. // stop polling
  5427. if(Object.keys(this.polls).length === 0 && this.timeout) {
  5428. clearTimeout(this.timeout);
  5429. this.timeout = null;
  5430. }
  5431. };
  5432. /**
  5433. * Should be called to poll for changes on filter with given id
  5434. *
  5435. * @method poll
  5436. */
  5437. RequestManager.prototype.poll = function () {
  5438. /*jshint maxcomplexity: 6 */
  5439. this.timeout = setTimeout(this.poll.bind(this), c.ETH_POLLING_TIMEOUT);
  5440. if (Object.keys(this.polls).length === 0) {
  5441. return;
  5442. }
  5443. if (!this.provider) {
  5444. console.error(errors.InvalidProvider());
  5445. return;
  5446. }
  5447. var pollsData = [];
  5448. var pollsIds = [];
  5449. for (var key in this.polls) {
  5450. pollsData.push(this.polls[key].data);
  5451. pollsIds.push(key);
  5452. }
  5453. if (pollsData.length === 0) {
  5454. return;
  5455. }
  5456. var payload = Jsonrpc.toBatchPayload(pollsData);
  5457. // map the request id to they poll id
  5458. var pollsIdMap = {};
  5459. payload.forEach(function(load, index){
  5460. pollsIdMap[load.id] = pollsIds[index];
  5461. });
  5462. var self = this;
  5463. this.provider.sendAsync(payload, function (error, results) {
  5464. // TODO: console log?
  5465. if (error) {
  5466. return;
  5467. }
  5468. if (!utils.isArray(results)) {
  5469. throw errors.InvalidResponse(results);
  5470. }
  5471. results.map(function (result) {
  5472. var id = pollsIdMap[result.id];
  5473. // make sure the filter is still installed after arrival of the request
  5474. if (self.polls[id]) {
  5475. result.callback = self.polls[id].callback;
  5476. return result;
  5477. } else
  5478. return false;
  5479. }).filter(function (result) {
  5480. return !!result;
  5481. }).filter(function (result) {
  5482. var valid = Jsonrpc.isValidResponse(result);
  5483. if (!valid) {
  5484. result.callback(errors.InvalidResponse(result));
  5485. }
  5486. return valid;
  5487. }).forEach(function (result) {
  5488. result.callback(null, result.result);
  5489. });
  5490. });
  5491. };
  5492. module.exports = RequestManager;
  5493. },{"../utils/config":18,"../utils/utils":20,"./errors":26,"./jsonrpc":35}],47:[function(require,module,exports){
  5494. var Settings = function () {
  5495. this.defaultBlock = 'latest';
  5496. this.defaultAccount = undefined;
  5497. };
  5498. module.exports = Settings;
  5499. },{}],48:[function(require,module,exports){
  5500. /*
  5501. This file is part of web3.js.
  5502. web3.js is free software: you can redistribute it and/or modify
  5503. it under the terms of the GNU Lesser General Public License as published by
  5504. the Free Software Foundation, either version 3 of the License, or
  5505. (at your option) any later version.
  5506. web3.js is distributed in the hope that it will be useful,
  5507. but WITHOUT ANY WARRANTY; without even the implied warranty of
  5508. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5509. GNU Lesser General Public License for more details.
  5510. You should have received a copy of the GNU Lesser General Public License
  5511. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  5512. */
  5513. /** @file syncing.js
  5514. * @authors:
  5515. * Fabian Vogelsteller <[email protected]>
  5516. * @date 2015
  5517. */
  5518. var formatters = require('./formatters');
  5519. var utils = require('../utils/utils');
  5520. var count = 1;
  5521. /**
  5522. Adds the callback and sets up the methods, to iterate over the results.
  5523. @method pollSyncing
  5524. @param {Object} self
  5525. */
  5526. var pollSyncing = function(self) {
  5527. var onMessage = function (error, sync) {
  5528. if (error) {
  5529. return self.callbacks.forEach(function (callback) {
  5530. callback(error);
  5531. });
  5532. }
  5533. if(utils.isObject(sync) && sync.startingBlock)
  5534. sync = formatters.outputSyncingFormatter(sync);
  5535. self.callbacks.forEach(function (callback) {
  5536. if (self.lastSyncState !== sync) {
  5537. // call the callback with true first so the app can stop anything, before receiving the sync data
  5538. if(!self.lastSyncState && utils.isObject(sync))
  5539. callback(null, true);
  5540. // call on the next CPU cycle, so the actions of the sync stop can be processes first
  5541. setTimeout(function() {
  5542. callback(null, sync);
  5543. }, 0);
  5544. self.lastSyncState = sync;
  5545. }
  5546. });
  5547. };
  5548. self.requestManager.startPolling({
  5549. method: 'eth_syncing',
  5550. params: [],
  5551. }, self.pollId, onMessage, self.stopWatching.bind(self));
  5552. };
  5553. var IsSyncing = function (requestManager, callback) {
  5554. this.requestManager = requestManager;
  5555. this.pollId = 'syncPoll_'+ count++;
  5556. this.callbacks = [];
  5557. this.addCallback(callback);
  5558. this.lastSyncState = false;
  5559. pollSyncing(this);
  5560. return this;
  5561. };
  5562. IsSyncing.prototype.addCallback = function (callback) {
  5563. if(callback)
  5564. this.callbacks.push(callback);
  5565. return this;
  5566. };
  5567. IsSyncing.prototype.stopWatching = function () {
  5568. this.requestManager.stopPolling(this.pollId);
  5569. this.callbacks = [];
  5570. };
  5571. module.exports = IsSyncing;
  5572. },{"../utils/utils":20,"./formatters":30}],49:[function(require,module,exports){
  5573. /*
  5574. This file is part of web3.js.
  5575. web3.js is free software: you can redistribute it and/or modify
  5576. it under the terms of the GNU Lesser General Public License as published by
  5577. the Free Software Foundation, either version 3 of the License, or
  5578. (at your option) any later version.
  5579. web3.js is distributed in the hope that it will be useful,
  5580. but WITHOUT ANY WARRANTY; without even the implied warranty of
  5581. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5582. GNU Lesser General Public License for more details.
  5583. You should have received a copy of the GNU Lesser General Public License
  5584. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  5585. */
  5586. /**
  5587. * @file transfer.js
  5588. * @author Marek Kotewicz <[email protected]>
  5589. * @date 2015
  5590. */
  5591. var Iban = require('./iban');
  5592. var exchangeAbi = require('../contracts/SmartExchange.json');
  5593. /**
  5594. * Should be used to make Iban transfer
  5595. *
  5596. * @method transfer
  5597. * @param {String} from
  5598. * @param {String} to iban
  5599. * @param {Value} value to be tranfered
  5600. * @param {Function} callback, callback
  5601. */
  5602. var transfer = function (eth, from, to, value, callback) {
  5603. var iban = new Iban(to);
  5604. if (!iban.isValid()) {
  5605. throw new Error('invalid iban address');
  5606. }
  5607. if (iban.isDirect()) {
  5608. return transferToAddress(eth, from, iban.address(), value, callback);
  5609. }
  5610. if (!callback) {
  5611. var address = eth.icapNamereg().addr(iban.institution());
  5612. return deposit(eth, from, address, value, iban.client());
  5613. }
  5614. eth.icapNamereg().addr(iban.institution(), function (err, address) {
  5615. return deposit(eth, from, address, value, iban.client(), callback);
  5616. });
  5617. };
  5618. /**
  5619. * Should be used to transfer funds to certain address
  5620. *
  5621. * @method transferToAddress
  5622. * @param {String} from
  5623. * @param {String} to
  5624. * @param {Value} value to be tranfered
  5625. * @param {Function} callback, callback
  5626. */
  5627. var transferToAddress = function (eth, from, to, value, callback) {
  5628. return eth.sendTransaction({
  5629. address: to,
  5630. from: from,
  5631. value: value
  5632. }, callback);
  5633. };
  5634. /**
  5635. * Should be used to deposit funds to generic Exchange contract (must implement deposit(bytes32) method!)
  5636. *
  5637. * @method deposit
  5638. * @param {String} from
  5639. * @param {String} to
  5640. * @param {Value} value to be transfered
  5641. * @param {String} client unique identifier
  5642. * @param {Function} callback, callback
  5643. */
  5644. var deposit = function (eth, from, to, value, client, callback) {
  5645. var abi = exchangeAbi;
  5646. return eth.contract(abi).at(to).deposit(client, {
  5647. from: from,
  5648. value: value
  5649. }, callback);
  5650. };
  5651. module.exports = transfer;
  5652. },{"../contracts/SmartExchange.json":3,"./iban":33}],50:[function(require,module,exports){
  5653. },{}],51:[function(require,module,exports){
  5654. ;(function (root, factory, undef) {
  5655. if (typeof exports === "object") {
  5656. // CommonJS
  5657. module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
  5658. }
  5659. else if (typeof define === "function" && define.amd) {
  5660. // AMD
  5661. define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
  5662. }
  5663. else {
  5664. // Global (browser)
  5665. factory(root.CryptoJS);
  5666. }
  5667. }(this, function (CryptoJS) {
  5668. (function () {
  5669. // Shortcuts
  5670. var C = CryptoJS;
  5671. var C_lib = C.lib;
  5672. var BlockCipher = C_lib.BlockCipher;
  5673. var C_algo = C.algo;
  5674. // Lookup tables
  5675. var SBOX = [];
  5676. var INV_SBOX = [];
  5677. var SUB_MIX_0 = [];
  5678. var SUB_MIX_1 = [];
  5679. var SUB_MIX_2 = [];
  5680. var SUB_MIX_3 = [];
  5681. var INV_SUB_MIX_0 = [];
  5682. var INV_SUB_MIX_1 = [];
  5683. var INV_SUB_MIX_2 = [];
  5684. var INV_SUB_MIX_3 = [];
  5685. // Compute lookup tables
  5686. (function () {
  5687. // Compute double table
  5688. var d = [];
  5689. for (var i = 0; i < 256; i++) {
  5690. if (i < 128) {
  5691. d[i] = i << 1;
  5692. } else {
  5693. d[i] = (i << 1) ^ 0x11b;
  5694. }
  5695. }
  5696. // Walk GF(2^8)
  5697. var x = 0;
  5698. var xi = 0;
  5699. for (var i = 0; i < 256; i++) {
  5700. // Compute sbox
  5701. var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
  5702. sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
  5703. SBOX[x] = sx;
  5704. INV_SBOX[sx] = x;
  5705. // Compute multiplication
  5706. var x2 = d[x];
  5707. var x4 = d[x2];
  5708. var x8 = d[x4];
  5709. // Compute sub bytes, mix columns tables
  5710. var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
  5711. SUB_MIX_0[x] = (t << 24) | (t >>> 8);
  5712. SUB_MIX_1[x] = (t << 16) | (t >>> 16);
  5713. SUB_MIX_2[x] = (t << 8) | (t >>> 24);
  5714. SUB_MIX_3[x] = t;
  5715. // Compute inv sub bytes, inv mix columns tables
  5716. var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
  5717. INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
  5718. INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
  5719. INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24);
  5720. INV_SUB_MIX_3[sx] = t;
  5721. // Compute next counter
  5722. if (!x) {
  5723. x = xi = 1;
  5724. } else {
  5725. x = x2 ^ d[d[d[x8 ^ x2]]];
  5726. xi ^= d[d[xi]];
  5727. }
  5728. }
  5729. }());
  5730. // Precomputed Rcon lookup
  5731. var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
  5732. /**
  5733. * AES block cipher algorithm.
  5734. */
  5735. var AES = C_algo.AES = BlockCipher.extend({
  5736. _doReset: function () {
  5737. // Skip reset of nRounds has been set before and key did not change
  5738. if (this._nRounds && this._keyPriorReset === this._key) {
  5739. return;
  5740. }
  5741. // Shortcuts
  5742. var key = this._keyPriorReset = this._key;
  5743. var keyWords = key.words;
  5744. var keySize = key.sigBytes / 4;
  5745. // Compute number of rounds
  5746. var nRounds = this._nRounds = keySize + 6;
  5747. // Compute number of key schedule rows
  5748. var ksRows = (nRounds + 1) * 4;
  5749. // Compute key schedule
  5750. var keySchedule = this._keySchedule = [];
  5751. for (var ksRow = 0; ksRow < ksRows; ksRow++) {
  5752. if (ksRow < keySize) {
  5753. keySchedule[ksRow] = keyWords[ksRow];
  5754. } else {
  5755. var t = keySchedule[ksRow - 1];
  5756. if (!(ksRow % keySize)) {
  5757. // Rot word
  5758. t = (t << 8) | (t >>> 24);
  5759. // Sub word
  5760. t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
  5761. // Mix Rcon
  5762. t ^= RCON[(ksRow / keySize) | 0] << 24;
  5763. } else if (keySize > 6 && ksRow % keySize == 4) {
  5764. // Sub word
  5765. t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
  5766. }
  5767. keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
  5768. }
  5769. }
  5770. // Compute inv key schedule
  5771. var invKeySchedule = this._invKeySchedule = [];
  5772. for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
  5773. var ksRow = ksRows - invKsRow;
  5774. if (invKsRow % 4) {
  5775. var t = keySchedule[ksRow];
  5776. } else {
  5777. var t = keySchedule[ksRow - 4];
  5778. }
  5779. if (invKsRow < 4 || ksRow <= 4) {
  5780. invKeySchedule[invKsRow] = t;
  5781. } else {
  5782. invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
  5783. INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
  5784. }
  5785. }
  5786. },
  5787. encryptBlock: function (M, offset) {
  5788. this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
  5789. },
  5790. decryptBlock: function (M, offset) {
  5791. // Swap 2nd and 4th rows
  5792. var t = M[offset + 1];
  5793. M[offset + 1] = M[offset + 3];
  5794. M[offset + 3] = t;
  5795. this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
  5796. // Inv swap 2nd and 4th rows
  5797. var t = M[offset + 1];
  5798. M[offset + 1] = M[offset + 3];
  5799. M[offset + 3] = t;
  5800. },
  5801. _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
  5802. // Shortcut
  5803. var nRounds = this._nRounds;
  5804. // Get input, add round key
  5805. var s0 = M[offset] ^ keySchedule[0];
  5806. var s1 = M[offset + 1] ^ keySchedule[1];
  5807. var s2 = M[offset + 2] ^ keySchedule[2];
  5808. var s3 = M[offset + 3] ^ keySchedule[3];
  5809. // Key schedule row counter
  5810. var ksRow = 4;
  5811. // Rounds
  5812. for (var round = 1; round < nRounds; round++) {
  5813. // Shift rows, sub bytes, mix columns, add round key
  5814. var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++];
  5815. var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++];
  5816. var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++];
  5817. var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++];
  5818. // Update state
  5819. s0 = t0;
  5820. s1 = t1;
  5821. s2 = t2;
  5822. s3 = t3;
  5823. }
  5824. // Shift rows, sub bytes, add round key
  5825. var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
  5826. var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
  5827. var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
  5828. var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
  5829. // Set output
  5830. M[offset] = t0;
  5831. M[offset + 1] = t1;
  5832. M[offset + 2] = t2;
  5833. M[offset + 3] = t3;
  5834. },
  5835. keySize: 256/32
  5836. });
  5837. /**
  5838. * Shortcut functions to the cipher's object interface.
  5839. *
  5840. * @example
  5841. *
  5842. * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
  5843. * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
  5844. */
  5845. C.AES = BlockCipher._createHelper(AES);
  5846. }());
  5847. return CryptoJS.AES;
  5848. }));
  5849. },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],52:[function(require,module,exports){
  5850. ;(function (root, factory) {
  5851. if (typeof exports === "object") {
  5852. // CommonJS
  5853. module.exports = exports = factory(require("./core"));
  5854. }
  5855. else if (typeof define === "function" && define.amd) {
  5856. // AMD
  5857. define(["./core"], factory);
  5858. }
  5859. else {
  5860. // Global (browser)
  5861. factory(root.CryptoJS);
  5862. }
  5863. }(this, function (CryptoJS) {
  5864. /**
  5865. * Cipher core components.
  5866. */
  5867. CryptoJS.lib.Cipher || (function (undefined) {
  5868. // Shortcuts
  5869. var C = CryptoJS;
  5870. var C_lib = C.lib;
  5871. var Base = C_lib.Base;
  5872. var WordArray = C_lib.WordArray;
  5873. var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
  5874. var C_enc = C.enc;
  5875. var Utf8 = C_enc.Utf8;
  5876. var Base64 = C_enc.Base64;
  5877. var C_algo = C.algo;
  5878. var EvpKDF = C_algo.EvpKDF;
  5879. /**
  5880. * Abstract base cipher template.
  5881. *
  5882. * @property {number} keySize This cipher's key size. Default: 4 (128 bits)
  5883. * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
  5884. * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
  5885. * @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
  5886. */
  5887. var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
  5888. /**
  5889. * Configuration options.
  5890. *
  5891. * @property {WordArray} iv The IV to use for this operation.
  5892. */
  5893. cfg: Base.extend(),
  5894. /**
  5895. * Creates this cipher in encryption mode.
  5896. *
  5897. * @param {WordArray} key The key.
  5898. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  5899. *
  5900. * @return {Cipher} A cipher instance.
  5901. *
  5902. * @static
  5903. *
  5904. * @example
  5905. *
  5906. * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
  5907. */
  5908. createEncryptor: function (key, cfg) {
  5909. return this.create(this._ENC_XFORM_MODE, key, cfg);
  5910. },
  5911. /**
  5912. * Creates this cipher in decryption mode.
  5913. *
  5914. * @param {WordArray} key The key.
  5915. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  5916. *
  5917. * @return {Cipher} A cipher instance.
  5918. *
  5919. * @static
  5920. *
  5921. * @example
  5922. *
  5923. * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
  5924. */
  5925. createDecryptor: function (key, cfg) {
  5926. return this.create(this._DEC_XFORM_MODE, key, cfg);
  5927. },
  5928. /**
  5929. * Initializes a newly created cipher.
  5930. *
  5931. * @param {number} xformMode Either the encryption or decryption transormation mode constant.
  5932. * @param {WordArray} key The key.
  5933. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  5934. *
  5935. * @example
  5936. *
  5937. * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
  5938. */
  5939. init: function (xformMode, key, cfg) {
  5940. // Apply config defaults
  5941. this.cfg = this.cfg.extend(cfg);
  5942. // Store transform mode and key
  5943. this._xformMode = xformMode;
  5944. this._key = key;
  5945. // Set initial values
  5946. this.reset();
  5947. },
  5948. /**
  5949. * Resets this cipher to its initial state.
  5950. *
  5951. * @example
  5952. *
  5953. * cipher.reset();
  5954. */
  5955. reset: function () {
  5956. // Reset data buffer
  5957. BufferedBlockAlgorithm.reset.call(this);
  5958. // Perform concrete-cipher logic
  5959. this._doReset();
  5960. },
  5961. /**
  5962. * Adds data to be encrypted or decrypted.
  5963. *
  5964. * @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
  5965. *
  5966. * @return {WordArray} The data after processing.
  5967. *
  5968. * @example
  5969. *
  5970. * var encrypted = cipher.process('data');
  5971. * var encrypted = cipher.process(wordArray);
  5972. */
  5973. process: function (dataUpdate) {
  5974. // Append
  5975. this._append(dataUpdate);
  5976. // Process available blocks
  5977. return this._process();
  5978. },
  5979. /**
  5980. * Finalizes the encryption or decryption process.
  5981. * Note that the finalize operation is effectively a destructive, read-once operation.
  5982. *
  5983. * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
  5984. *
  5985. * @return {WordArray} The data after final processing.
  5986. *
  5987. * @example
  5988. *
  5989. * var encrypted = cipher.finalize();
  5990. * var encrypted = cipher.finalize('data');
  5991. * var encrypted = cipher.finalize(wordArray);
  5992. */
  5993. finalize: function (dataUpdate) {
  5994. // Final data update
  5995. if (dataUpdate) {
  5996. this._append(dataUpdate);
  5997. }
  5998. // Perform concrete-cipher logic
  5999. var finalProcessedData = this._doFinalize();
  6000. return finalProcessedData;
  6001. },
  6002. keySize: 128/32,
  6003. ivSize: 128/32,
  6004. _ENC_XFORM_MODE: 1,
  6005. _DEC_XFORM_MODE: 2,
  6006. /**
  6007. * Creates shortcut functions to a cipher's object interface.
  6008. *
  6009. * @param {Cipher} cipher The cipher to create a helper for.
  6010. *
  6011. * @return {Object} An object with encrypt and decrypt shortcut functions.
  6012. *
  6013. * @static
  6014. *
  6015. * @example
  6016. *
  6017. * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
  6018. */
  6019. _createHelper: (function () {
  6020. function selectCipherStrategy(key) {
  6021. if (typeof key == 'string') {
  6022. return PasswordBasedCipher;
  6023. } else {
  6024. return SerializableCipher;
  6025. }
  6026. }
  6027. return function (cipher) {
  6028. return {
  6029. encrypt: function (message, key, cfg) {
  6030. return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
  6031. },
  6032. decrypt: function (ciphertext, key, cfg) {
  6033. return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
  6034. }
  6035. };
  6036. };
  6037. }())
  6038. });
  6039. /**
  6040. * Abstract base stream cipher template.
  6041. *
  6042. * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
  6043. */
  6044. var StreamCipher = C_lib.StreamCipher = Cipher.extend({
  6045. _doFinalize: function () {
  6046. // Process partial blocks
  6047. var finalProcessedBlocks = this._process(!!'flush');
  6048. return finalProcessedBlocks;
  6049. },
  6050. blockSize: 1
  6051. });
  6052. /**
  6053. * Mode namespace.
  6054. */
  6055. var C_mode = C.mode = {};
  6056. /**
  6057. * Abstract base block cipher mode template.
  6058. */
  6059. var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
  6060. /**
  6061. * Creates this mode for encryption.
  6062. *
  6063. * @param {Cipher} cipher A block cipher instance.
  6064. * @param {Array} iv The IV words.
  6065. *
  6066. * @static
  6067. *
  6068. * @example
  6069. *
  6070. * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
  6071. */
  6072. createEncryptor: function (cipher, iv) {
  6073. return this.Encryptor.create(cipher, iv);
  6074. },
  6075. /**
  6076. * Creates this mode for decryption.
  6077. *
  6078. * @param {Cipher} cipher A block cipher instance.
  6079. * @param {Array} iv The IV words.
  6080. *
  6081. * @static
  6082. *
  6083. * @example
  6084. *
  6085. * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
  6086. */
  6087. createDecryptor: function (cipher, iv) {
  6088. return this.Decryptor.create(cipher, iv);
  6089. },
  6090. /**
  6091. * Initializes a newly created mode.
  6092. *
  6093. * @param {Cipher} cipher A block cipher instance.
  6094. * @param {Array} iv The IV words.
  6095. *
  6096. * @example
  6097. *
  6098. * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
  6099. */
  6100. init: function (cipher, iv) {
  6101. this._cipher = cipher;
  6102. this._iv = iv;
  6103. }
  6104. });
  6105. /**
  6106. * Cipher Block Chaining mode.
  6107. */
  6108. var CBC = C_mode.CBC = (function () {
  6109. /**
  6110. * Abstract base CBC mode.
  6111. */
  6112. var CBC = BlockCipherMode.extend();
  6113. /**
  6114. * CBC encryptor.
  6115. */
  6116. CBC.Encryptor = CBC.extend({
  6117. /**
  6118. * Processes the data block at offset.
  6119. *
  6120. * @param {Array} words The data words to operate on.
  6121. * @param {number} offset The offset where the block starts.
  6122. *
  6123. * @example
  6124. *
  6125. * mode.processBlock(data.words, offset);
  6126. */
  6127. processBlock: function (words, offset) {
  6128. // Shortcuts
  6129. var cipher = this._cipher;
  6130. var blockSize = cipher.blockSize;
  6131. // XOR and encrypt
  6132. xorBlock.call(this, words, offset, blockSize);
  6133. cipher.encryptBlock(words, offset);
  6134. // Remember this block to use with next block
  6135. this._prevBlock = words.slice(offset, offset + blockSize);
  6136. }
  6137. });
  6138. /**
  6139. * CBC decryptor.
  6140. */
  6141. CBC.Decryptor = CBC.extend({
  6142. /**
  6143. * Processes the data block at offset.
  6144. *
  6145. * @param {Array} words The data words to operate on.
  6146. * @param {number} offset The offset where the block starts.
  6147. *
  6148. * @example
  6149. *
  6150. * mode.processBlock(data.words, offset);
  6151. */
  6152. processBlock: function (words, offset) {
  6153. // Shortcuts
  6154. var cipher = this._cipher;
  6155. var blockSize = cipher.blockSize;
  6156. // Remember this block to use with next block
  6157. var thisBlock = words.slice(offset, offset + blockSize);
  6158. // Decrypt and XOR
  6159. cipher.decryptBlock(words, offset);
  6160. xorBlock.call(this, words, offset, blockSize);
  6161. // This block becomes the previous block
  6162. this._prevBlock = thisBlock;
  6163. }
  6164. });
  6165. function xorBlock(words, offset, blockSize) {
  6166. // Shortcut
  6167. var iv = this._iv;
  6168. // Choose mixing block
  6169. if (iv) {
  6170. var block = iv;
  6171. // Remove IV for subsequent blocks
  6172. this._iv = undefined;
  6173. } else {
  6174. var block = this._prevBlock;
  6175. }
  6176. // XOR blocks
  6177. for (var i = 0; i < blockSize; i++) {
  6178. words[offset + i] ^= block[i];
  6179. }
  6180. }
  6181. return CBC;
  6182. }());
  6183. /**
  6184. * Padding namespace.
  6185. */
  6186. var C_pad = C.pad = {};
  6187. /**
  6188. * PKCS #5/7 padding strategy.
  6189. */
  6190. var Pkcs7 = C_pad.Pkcs7 = {
  6191. /**
  6192. * Pads data using the algorithm defined in PKCS #5/7.
  6193. *
  6194. * @param {WordArray} data The data to pad.
  6195. * @param {number} blockSize The multiple that the data should be padded to.
  6196. *
  6197. * @static
  6198. *
  6199. * @example
  6200. *
  6201. * CryptoJS.pad.Pkcs7.pad(wordArray, 4);
  6202. */
  6203. pad: function (data, blockSize) {
  6204. // Shortcut
  6205. var blockSizeBytes = blockSize * 4;
  6206. // Count padding bytes
  6207. var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
  6208. // Create padding word
  6209. var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;
  6210. // Create padding
  6211. var paddingWords = [];
  6212. for (var i = 0; i < nPaddingBytes; i += 4) {
  6213. paddingWords.push(paddingWord);
  6214. }
  6215. var padding = WordArray.create(paddingWords, nPaddingBytes);
  6216. // Add padding
  6217. data.concat(padding);
  6218. },
  6219. /**
  6220. * Unpads data that had been padded using the algorithm defined in PKCS #5/7.
  6221. *
  6222. * @param {WordArray} data The data to unpad.
  6223. *
  6224. * @static
  6225. *
  6226. * @example
  6227. *
  6228. * CryptoJS.pad.Pkcs7.unpad(wordArray);
  6229. */
  6230. unpad: function (data) {
  6231. // Get number of padding bytes from last byte
  6232. var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
  6233. // Remove padding
  6234. data.sigBytes -= nPaddingBytes;
  6235. }
  6236. };
  6237. /**
  6238. * Abstract base block cipher template.
  6239. *
  6240. * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
  6241. */
  6242. var BlockCipher = C_lib.BlockCipher = Cipher.extend({
  6243. /**
  6244. * Configuration options.
  6245. *
  6246. * @property {Mode} mode The block mode to use. Default: CBC
  6247. * @property {Padding} padding The padding strategy to use. Default: Pkcs7
  6248. */
  6249. cfg: Cipher.cfg.extend({
  6250. mode: CBC,
  6251. padding: Pkcs7
  6252. }),
  6253. reset: function () {
  6254. // Reset cipher
  6255. Cipher.reset.call(this);
  6256. // Shortcuts
  6257. var cfg = this.cfg;
  6258. var iv = cfg.iv;
  6259. var mode = cfg.mode;
  6260. // Reset block mode
  6261. if (this._xformMode == this._ENC_XFORM_MODE) {
  6262. var modeCreator = mode.createEncryptor;
  6263. } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
  6264. var modeCreator = mode.createDecryptor;
  6265. // Keep at least one block in the buffer for unpadding
  6266. this._minBufferSize = 1;
  6267. }
  6268. this._mode = modeCreator.call(mode, this, iv && iv.words);
  6269. },
  6270. _doProcessBlock: function (words, offset) {
  6271. this._mode.processBlock(words, offset);
  6272. },
  6273. _doFinalize: function () {
  6274. // Shortcut
  6275. var padding = this.cfg.padding;
  6276. // Finalize
  6277. if (this._xformMode == this._ENC_XFORM_MODE) {
  6278. // Pad data
  6279. padding.pad(this._data, this.blockSize);
  6280. // Process final blocks
  6281. var finalProcessedBlocks = this._process(!!'flush');
  6282. } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
  6283. // Process final blocks
  6284. var finalProcessedBlocks = this._process(!!'flush');
  6285. // Unpad data
  6286. padding.unpad(finalProcessedBlocks);
  6287. }
  6288. return finalProcessedBlocks;
  6289. },
  6290. blockSize: 128/32
  6291. });
  6292. /**
  6293. * A collection of cipher parameters.
  6294. *
  6295. * @property {WordArray} ciphertext The raw ciphertext.
  6296. * @property {WordArray} key The key to this ciphertext.
  6297. * @property {WordArray} iv The IV used in the ciphering operation.
  6298. * @property {WordArray} salt The salt used with a key derivation function.
  6299. * @property {Cipher} algorithm The cipher algorithm.
  6300. * @property {Mode} mode The block mode used in the ciphering operation.
  6301. * @property {Padding} padding The padding scheme used in the ciphering operation.
  6302. * @property {number} blockSize The block size of the cipher.
  6303. * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
  6304. */
  6305. var CipherParams = C_lib.CipherParams = Base.extend({
  6306. /**
  6307. * Initializes a newly created cipher params object.
  6308. *
  6309. * @param {Object} cipherParams An object with any of the possible cipher parameters.
  6310. *
  6311. * @example
  6312. *
  6313. * var cipherParams = CryptoJS.lib.CipherParams.create({
  6314. * ciphertext: ciphertextWordArray,
  6315. * key: keyWordArray,
  6316. * iv: ivWordArray,
  6317. * salt: saltWordArray,
  6318. * algorithm: CryptoJS.algo.AES,
  6319. * mode: CryptoJS.mode.CBC,
  6320. * padding: CryptoJS.pad.PKCS7,
  6321. * blockSize: 4,
  6322. * formatter: CryptoJS.format.OpenSSL
  6323. * });
  6324. */
  6325. init: function (cipherParams) {
  6326. this.mixIn(cipherParams);
  6327. },
  6328. /**
  6329. * Converts this cipher params object to a string.
  6330. *
  6331. * @param {Format} formatter (Optional) The formatting strategy to use.
  6332. *
  6333. * @return {string} The stringified cipher params.
  6334. *
  6335. * @throws Error If neither the formatter nor the default formatter is set.
  6336. *
  6337. * @example
  6338. *
  6339. * var string = cipherParams + '';
  6340. * var string = cipherParams.toString();
  6341. * var string = cipherParams.toString(CryptoJS.format.OpenSSL);
  6342. */
  6343. toString: function (formatter) {
  6344. return (formatter || this.formatter).stringify(this);
  6345. }
  6346. });
  6347. /**
  6348. * Format namespace.
  6349. */
  6350. var C_format = C.format = {};
  6351. /**
  6352. * OpenSSL formatting strategy.
  6353. */
  6354. var OpenSSLFormatter = C_format.OpenSSL = {
  6355. /**
  6356. * Converts a cipher params object to an OpenSSL-compatible string.
  6357. *
  6358. * @param {CipherParams} cipherParams The cipher params object.
  6359. *
  6360. * @return {string} The OpenSSL-compatible string.
  6361. *
  6362. * @static
  6363. *
  6364. * @example
  6365. *
  6366. * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
  6367. */
  6368. stringify: function (cipherParams) {
  6369. // Shortcuts
  6370. var ciphertext = cipherParams.ciphertext;
  6371. var salt = cipherParams.salt;
  6372. // Format
  6373. if (salt) {
  6374. var wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
  6375. } else {
  6376. var wordArray = ciphertext;
  6377. }
  6378. return wordArray.toString(Base64);
  6379. },
  6380. /**
  6381. * Converts an OpenSSL-compatible string to a cipher params object.
  6382. *
  6383. * @param {string} openSSLStr The OpenSSL-compatible string.
  6384. *
  6385. * @return {CipherParams} The cipher params object.
  6386. *
  6387. * @static
  6388. *
  6389. * @example
  6390. *
  6391. * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
  6392. */
  6393. parse: function (openSSLStr) {
  6394. // Parse base64
  6395. var ciphertext = Base64.parse(openSSLStr);
  6396. // Shortcut
  6397. var ciphertextWords = ciphertext.words;
  6398. // Test for salt
  6399. if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
  6400. // Extract salt
  6401. var salt = WordArray.create(ciphertextWords.slice(2, 4));
  6402. // Remove salt from ciphertext
  6403. ciphertextWords.splice(0, 4);
  6404. ciphertext.sigBytes -= 16;
  6405. }
  6406. return CipherParams.create({ ciphertext: ciphertext, salt: salt });
  6407. }
  6408. };
  6409. /**
  6410. * A cipher wrapper that returns ciphertext as a serializable cipher params object.
  6411. */
  6412. var SerializableCipher = C_lib.SerializableCipher = Base.extend({
  6413. /**
  6414. * Configuration options.
  6415. *
  6416. * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
  6417. */
  6418. cfg: Base.extend({
  6419. format: OpenSSLFormatter
  6420. }),
  6421. /**
  6422. * Encrypts a message.
  6423. *
  6424. * @param {Cipher} cipher The cipher algorithm to use.
  6425. * @param {WordArray|string} message The message to encrypt.
  6426. * @param {WordArray} key The key.
  6427. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  6428. *
  6429. * @return {CipherParams} A cipher params object.
  6430. *
  6431. * @static
  6432. *
  6433. * @example
  6434. *
  6435. * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
  6436. * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
  6437. * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  6438. */
  6439. encrypt: function (cipher, message, key, cfg) {
  6440. // Apply config defaults
  6441. cfg = this.cfg.extend(cfg);
  6442. // Encrypt
  6443. var encryptor = cipher.createEncryptor(key, cfg);
  6444. var ciphertext = encryptor.finalize(message);
  6445. // Shortcut
  6446. var cipherCfg = encryptor.cfg;
  6447. // Create and return serializable cipher params
  6448. return CipherParams.create({
  6449. ciphertext: ciphertext,
  6450. key: key,
  6451. iv: cipherCfg.iv,
  6452. algorithm: cipher,
  6453. mode: cipherCfg.mode,
  6454. padding: cipherCfg.padding,
  6455. blockSize: cipher.blockSize,
  6456. formatter: cfg.format
  6457. });
  6458. },
  6459. /**
  6460. * Decrypts serialized ciphertext.
  6461. *
  6462. * @param {Cipher} cipher The cipher algorithm to use.
  6463. * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
  6464. * @param {WordArray} key The key.
  6465. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  6466. *
  6467. * @return {WordArray} The plaintext.
  6468. *
  6469. * @static
  6470. *
  6471. * @example
  6472. *
  6473. * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  6474. * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  6475. */
  6476. decrypt: function (cipher, ciphertext, key, cfg) {
  6477. // Apply config defaults
  6478. cfg = this.cfg.extend(cfg);
  6479. // Convert string to CipherParams
  6480. ciphertext = this._parse(ciphertext, cfg.format);
  6481. // Decrypt
  6482. var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
  6483. return plaintext;
  6484. },
  6485. /**
  6486. * Converts serialized ciphertext to CipherParams,
  6487. * else assumed CipherParams already and returns ciphertext unchanged.
  6488. *
  6489. * @param {CipherParams|string} ciphertext The ciphertext.
  6490. * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
  6491. *
  6492. * @return {CipherParams} The unserialized ciphertext.
  6493. *
  6494. * @static
  6495. *
  6496. * @example
  6497. *
  6498. * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
  6499. */
  6500. _parse: function (ciphertext, format) {
  6501. if (typeof ciphertext == 'string') {
  6502. return format.parse(ciphertext, this);
  6503. } else {
  6504. return ciphertext;
  6505. }
  6506. }
  6507. });
  6508. /**
  6509. * Key derivation function namespace.
  6510. */
  6511. var C_kdf = C.kdf = {};
  6512. /**
  6513. * OpenSSL key derivation function.
  6514. */
  6515. var OpenSSLKdf = C_kdf.OpenSSL = {
  6516. /**
  6517. * Derives a key and IV from a password.
  6518. *
  6519. * @param {string} password The password to derive from.
  6520. * @param {number} keySize The size in words of the key to generate.
  6521. * @param {number} ivSize The size in words of the IV to generate.
  6522. * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
  6523. *
  6524. * @return {CipherParams} A cipher params object with the key, IV, and salt.
  6525. *
  6526. * @static
  6527. *
  6528. * @example
  6529. *
  6530. * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
  6531. * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
  6532. */
  6533. execute: function (password, keySize, ivSize, salt) {
  6534. // Generate random salt
  6535. if (!salt) {
  6536. salt = WordArray.random(64/8);
  6537. }
  6538. // Derive key and IV
  6539. var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
  6540. // Separate key and IV
  6541. var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
  6542. key.sigBytes = keySize * 4;
  6543. // Return params
  6544. return CipherParams.create({ key: key, iv: iv, salt: salt });
  6545. }
  6546. };
  6547. /**
  6548. * A serializable cipher wrapper that derives the key from a password,
  6549. * and returns ciphertext as a serializable cipher params object.
  6550. */
  6551. var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
  6552. /**
  6553. * Configuration options.
  6554. *
  6555. * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
  6556. */
  6557. cfg: SerializableCipher.cfg.extend({
  6558. kdf: OpenSSLKdf
  6559. }),
  6560. /**
  6561. * Encrypts a message using a password.
  6562. *
  6563. * @param {Cipher} cipher The cipher algorithm to use.
  6564. * @param {WordArray|string} message The message to encrypt.
  6565. * @param {string} password The password.
  6566. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  6567. *
  6568. * @return {CipherParams} A cipher params object.
  6569. *
  6570. * @static
  6571. *
  6572. * @example
  6573. *
  6574. * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
  6575. * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
  6576. */
  6577. encrypt: function (cipher, message, password, cfg) {
  6578. // Apply config defaults
  6579. cfg = this.cfg.extend(cfg);
  6580. // Derive key and other params
  6581. var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize);
  6582. // Add IV to config
  6583. cfg.iv = derivedParams.iv;
  6584. // Encrypt
  6585. var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
  6586. // Mix in derived params
  6587. ciphertext.mixIn(derivedParams);
  6588. return ciphertext;
  6589. },
  6590. /**
  6591. * Decrypts serialized ciphertext using a password.
  6592. *
  6593. * @param {Cipher} cipher The cipher algorithm to use.
  6594. * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
  6595. * @param {string} password The password.
  6596. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  6597. *
  6598. * @return {WordArray} The plaintext.
  6599. *
  6600. * @static
  6601. *
  6602. * @example
  6603. *
  6604. * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
  6605. * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
  6606. */
  6607. decrypt: function (cipher, ciphertext, password, cfg) {
  6608. // Apply config defaults
  6609. cfg = this.cfg.extend(cfg);
  6610. // Convert string to CipherParams
  6611. ciphertext = this._parse(ciphertext, cfg.format);
  6612. // Derive key and other params
  6613. var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt);
  6614. // Add IV to config
  6615. cfg.iv = derivedParams.iv;
  6616. // Decrypt
  6617. var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
  6618. return plaintext;
  6619. }
  6620. });
  6621. }());
  6622. }));
  6623. },{"./core":53}],53:[function(require,module,exports){
  6624. ;(function (root, factory) {
  6625. if (typeof exports === "object") {
  6626. // CommonJS
  6627. module.exports = exports = factory();
  6628. }
  6629. else if (typeof define === "function" && define.amd) {
  6630. // AMD
  6631. define([], factory);
  6632. }
  6633. else {
  6634. // Global (browser)
  6635. root.CryptoJS = factory();
  6636. }
  6637. }(this, function () {
  6638. /**
  6639. * CryptoJS core components.
  6640. */
  6641. var CryptoJS = CryptoJS || (function (Math, undefined) {
  6642. /*
  6643. * Local polyfil of Object.create
  6644. */
  6645. var create = Object.create || (function () {
  6646. function F() {};
  6647. return function (obj) {
  6648. var subtype;
  6649. F.prototype = obj;
  6650. subtype = new F();
  6651. F.prototype = null;
  6652. return subtype;
  6653. };
  6654. }())
  6655. /**
  6656. * CryptoJS namespace.
  6657. */
  6658. var C = {};
  6659. /**
  6660. * Library namespace.
  6661. */
  6662. var C_lib = C.lib = {};
  6663. /**
  6664. * Base object for prototypal inheritance.
  6665. */
  6666. var Base = C_lib.Base = (function () {
  6667. return {
  6668. /**
  6669. * Creates a new object that inherits from this object.
  6670. *
  6671. * @param {Object} overrides Properties to copy into the new object.
  6672. *
  6673. * @return {Object} The new object.
  6674. *
  6675. * @static
  6676. *
  6677. * @example
  6678. *
  6679. * var MyType = CryptoJS.lib.Base.extend({
  6680. * field: 'value',
  6681. *
  6682. * method: function () {
  6683. * }
  6684. * });
  6685. */
  6686. extend: function (overrides) {
  6687. // Spawn
  6688. var subtype = create(this);
  6689. // Augment
  6690. if (overrides) {
  6691. subtype.mixIn(overrides);
  6692. }
  6693. // Create default initializer
  6694. if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
  6695. subtype.init = function () {
  6696. subtype.$super.init.apply(this, arguments);
  6697. };
  6698. }
  6699. // Initializer's prototype is the subtype object
  6700. subtype.init.prototype = subtype;
  6701. // Reference supertype
  6702. subtype.$super = this;
  6703. return subtype;
  6704. },
  6705. /**
  6706. * Extends this object and runs the init method.
  6707. * Arguments to create() will be passed to init().
  6708. *
  6709. * @return {Object} The new object.
  6710. *
  6711. * @static
  6712. *
  6713. * @example
  6714. *
  6715. * var instance = MyType.create();
  6716. */
  6717. create: function () {
  6718. var instance = this.extend();
  6719. instance.init.apply(instance, arguments);
  6720. return instance;
  6721. },
  6722. /**
  6723. * Initializes a newly created object.
  6724. * Override this method to add some logic when your objects are created.
  6725. *
  6726. * @example
  6727. *
  6728. * var MyType = CryptoJS.lib.Base.extend({
  6729. * init: function () {
  6730. * // ...
  6731. * }
  6732. * });
  6733. */
  6734. init: function () {
  6735. },
  6736. /**
  6737. * Copies properties into this object.
  6738. *
  6739. * @param {Object} properties The properties to mix in.
  6740. *
  6741. * @example
  6742. *
  6743. * MyType.mixIn({
  6744. * field: 'value'
  6745. * });
  6746. */
  6747. mixIn: function (properties) {
  6748. for (var propertyName in properties) {
  6749. if (properties.hasOwnProperty(propertyName)) {
  6750. this[propertyName] = properties[propertyName];
  6751. }
  6752. }
  6753. // IE won't copy toString using the loop above
  6754. if (properties.hasOwnProperty('toString')) {
  6755. this.toString = properties.toString;
  6756. }
  6757. },
  6758. /**
  6759. * Creates a copy of this object.
  6760. *
  6761. * @return {Object} The clone.
  6762. *
  6763. * @example
  6764. *
  6765. * var clone = instance.clone();
  6766. */
  6767. clone: function () {
  6768. return this.init.prototype.extend(this);
  6769. }
  6770. };
  6771. }());
  6772. /**
  6773. * An array of 32-bit words.
  6774. *
  6775. * @property {Array} words The array of 32-bit words.
  6776. * @property {number} sigBytes The number of significant bytes in this word array.
  6777. */
  6778. var WordArray = C_lib.WordArray = Base.extend({
  6779. /**
  6780. * Initializes a newly created word array.
  6781. *
  6782. * @param {Array} words (Optional) An array of 32-bit words.
  6783. * @param {number} sigBytes (Optional) The number of significant bytes in the words.
  6784. *
  6785. * @example
  6786. *
  6787. * var wordArray = CryptoJS.lib.WordArray.create();
  6788. * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
  6789. * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
  6790. */
  6791. init: function (words, sigBytes) {
  6792. words = this.words = words || [];
  6793. if (sigBytes != undefined) {
  6794. this.sigBytes = sigBytes;
  6795. } else {
  6796. this.sigBytes = words.length * 4;
  6797. }
  6798. },
  6799. /**
  6800. * Converts this word array to a string.
  6801. *
  6802. * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
  6803. *
  6804. * @return {string} The stringified word array.
  6805. *
  6806. * @example
  6807. *
  6808. * var string = wordArray + '';
  6809. * var string = wordArray.toString();
  6810. * var string = wordArray.toString(CryptoJS.enc.Utf8);
  6811. */
  6812. toString: function (encoder) {
  6813. return (encoder || Hex).stringify(this);
  6814. },
  6815. /**
  6816. * Concatenates a word array to this word array.
  6817. *
  6818. * @param {WordArray} wordArray The word array to append.
  6819. *
  6820. * @return {WordArray} This word array.
  6821. *
  6822. * @example
  6823. *
  6824. * wordArray1.concat(wordArray2);
  6825. */
  6826. concat: function (wordArray) {
  6827. // Shortcuts
  6828. var thisWords = this.words;
  6829. var thatWords = wordArray.words;
  6830. var thisSigBytes = this.sigBytes;
  6831. var thatSigBytes = wordArray.sigBytes;
  6832. // Clamp excess bits
  6833. this.clamp();
  6834. // Concat
  6835. if (thisSigBytes % 4) {
  6836. // Copy one byte at a time
  6837. for (var i = 0; i < thatSigBytes; i++) {
  6838. var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  6839. thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
  6840. }
  6841. } else {
  6842. // Copy one word at a time
  6843. for (var i = 0; i < thatSigBytes; i += 4) {
  6844. thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2];
  6845. }
  6846. }
  6847. this.sigBytes += thatSigBytes;
  6848. // Chainable
  6849. return this;
  6850. },
  6851. /**
  6852. * Removes insignificant bits.
  6853. *
  6854. * @example
  6855. *
  6856. * wordArray.clamp();
  6857. */
  6858. clamp: function () {
  6859. // Shortcuts
  6860. var words = this.words;
  6861. var sigBytes = this.sigBytes;
  6862. // Clamp
  6863. words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
  6864. words.length = Math.ceil(sigBytes / 4);
  6865. },
  6866. /**
  6867. * Creates a copy of this word array.
  6868. *
  6869. * @return {WordArray} The clone.
  6870. *
  6871. * @example
  6872. *
  6873. * var clone = wordArray.clone();
  6874. */
  6875. clone: function () {
  6876. var clone = Base.clone.call(this);
  6877. clone.words = this.words.slice(0);
  6878. return clone;
  6879. },
  6880. /**
  6881. * Creates a word array filled with random bytes.
  6882. *
  6883. * @param {number} nBytes The number of random bytes to generate.
  6884. *
  6885. * @return {WordArray} The random word array.
  6886. *
  6887. * @static
  6888. *
  6889. * @example
  6890. *
  6891. * var wordArray = CryptoJS.lib.WordArray.random(16);
  6892. */
  6893. random: function (nBytes) {
  6894. var words = [];
  6895. var r = (function (m_w) {
  6896. var m_w = m_w;
  6897. var m_z = 0x3ade68b1;
  6898. var mask = 0xffffffff;
  6899. return function () {
  6900. m_z = (0x9069 * (m_z & 0xFFFF) + (m_z >> 0x10)) & mask;
  6901. m_w = (0x4650 * (m_w & 0xFFFF) + (m_w >> 0x10)) & mask;
  6902. var result = ((m_z << 0x10) + m_w) & mask;
  6903. result /= 0x100000000;
  6904. result += 0.5;
  6905. return result * (Math.random() > .5 ? 1 : -1);
  6906. }
  6907. });
  6908. for (var i = 0, rcache; i < nBytes; i += 4) {
  6909. var _r = r((rcache || Math.random()) * 0x100000000);
  6910. rcache = _r() * 0x3ade67b7;
  6911. words.push((_r() * 0x100000000) | 0);
  6912. }
  6913. return new WordArray.init(words, nBytes);
  6914. }
  6915. });
  6916. /**
  6917. * Encoder namespace.
  6918. */
  6919. var C_enc = C.enc = {};
  6920. /**
  6921. * Hex encoding strategy.
  6922. */
  6923. var Hex = C_enc.Hex = {
  6924. /**
  6925. * Converts a word array to a hex string.
  6926. *
  6927. * @param {WordArray} wordArray The word array.
  6928. *
  6929. * @return {string} The hex string.
  6930. *
  6931. * @static
  6932. *
  6933. * @example
  6934. *
  6935. * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
  6936. */
  6937. stringify: function (wordArray) {
  6938. // Shortcuts
  6939. var words = wordArray.words;
  6940. var sigBytes = wordArray.sigBytes;
  6941. // Convert
  6942. var hexChars = [];
  6943. for (var i = 0; i < sigBytes; i++) {
  6944. var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  6945. hexChars.push((bite >>> 4).toString(16));
  6946. hexChars.push((bite & 0x0f).toString(16));
  6947. }
  6948. return hexChars.join('');
  6949. },
  6950. /**
  6951. * Converts a hex string to a word array.
  6952. *
  6953. * @param {string} hexStr The hex string.
  6954. *
  6955. * @return {WordArray} The word array.
  6956. *
  6957. * @static
  6958. *
  6959. * @example
  6960. *
  6961. * var wordArray = CryptoJS.enc.Hex.parse(hexString);
  6962. */
  6963. parse: function (hexStr) {
  6964. // Shortcut
  6965. var hexStrLength = hexStr.length;
  6966. // Convert
  6967. var words = [];
  6968. for (var i = 0; i < hexStrLength; i += 2) {
  6969. words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
  6970. }
  6971. return new WordArray.init(words, hexStrLength / 2);
  6972. }
  6973. };
  6974. /**
  6975. * Latin1 encoding strategy.
  6976. */
  6977. var Latin1 = C_enc.Latin1 = {
  6978. /**
  6979. * Converts a word array to a Latin1 string.
  6980. *
  6981. * @param {WordArray} wordArray The word array.
  6982. *
  6983. * @return {string} The Latin1 string.
  6984. *
  6985. * @static
  6986. *
  6987. * @example
  6988. *
  6989. * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
  6990. */
  6991. stringify: function (wordArray) {
  6992. // Shortcuts
  6993. var words = wordArray.words;
  6994. var sigBytes = wordArray.sigBytes;
  6995. // Convert
  6996. var latin1Chars = [];
  6997. for (var i = 0; i < sigBytes; i++) {
  6998. var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  6999. latin1Chars.push(String.fromCharCode(bite));
  7000. }
  7001. return latin1Chars.join('');
  7002. },
  7003. /**
  7004. * Converts a Latin1 string to a word array.
  7005. *
  7006. * @param {string} latin1Str The Latin1 string.
  7007. *
  7008. * @return {WordArray} The word array.
  7009. *
  7010. * @static
  7011. *
  7012. * @example
  7013. *
  7014. * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
  7015. */
  7016. parse: function (latin1Str) {
  7017. // Shortcut
  7018. var latin1StrLength = latin1Str.length;
  7019. // Convert
  7020. var words = [];
  7021. for (var i = 0; i < latin1StrLength; i++) {
  7022. words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
  7023. }
  7024. return new WordArray.init(words, latin1StrLength);
  7025. }
  7026. };
  7027. /**
  7028. * UTF-8 encoding strategy.
  7029. */
  7030. var Utf8 = C_enc.Utf8 = {
  7031. /**
  7032. * Converts a word array to a UTF-8 string.
  7033. *
  7034. * @param {WordArray} wordArray The word array.
  7035. *
  7036. * @return {string} The UTF-8 string.
  7037. *
  7038. * @static
  7039. *
  7040. * @example
  7041. *
  7042. * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
  7043. */
  7044. stringify: function (wordArray) {
  7045. try {
  7046. return decodeURIComponent(escape(Latin1.stringify(wordArray)));
  7047. } catch (e) {
  7048. throw new Error('Malformed UTF-8 data');
  7049. }
  7050. },
  7051. /**
  7052. * Converts a UTF-8 string to a word array.
  7053. *
  7054. * @param {string} utf8Str The UTF-8 string.
  7055. *
  7056. * @return {WordArray} The word array.
  7057. *
  7058. * @static
  7059. *
  7060. * @example
  7061. *
  7062. * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
  7063. */
  7064. parse: function (utf8Str) {
  7065. return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
  7066. }
  7067. };
  7068. /**
  7069. * Abstract buffered block algorithm template.
  7070. *
  7071. * The property blockSize must be implemented in a concrete subtype.
  7072. *
  7073. * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
  7074. */
  7075. var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
  7076. /**
  7077. * Resets this block algorithm's data buffer to its initial state.
  7078. *
  7079. * @example
  7080. *
  7081. * bufferedBlockAlgorithm.reset();
  7082. */
  7083. reset: function () {
  7084. // Initial values
  7085. this._data = new WordArray.init();
  7086. this._nDataBytes = 0;
  7087. },
  7088. /**
  7089. * Adds new data to this block algorithm's buffer.
  7090. *
  7091. * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
  7092. *
  7093. * @example
  7094. *
  7095. * bufferedBlockAlgorithm._append('data');
  7096. * bufferedBlockAlgorithm._append(wordArray);
  7097. */
  7098. _append: function (data) {
  7099. // Convert string to WordArray, else assume WordArray already
  7100. if (typeof data == 'string') {
  7101. data = Utf8.parse(data);
  7102. }
  7103. // Append
  7104. this._data.concat(data);
  7105. this._nDataBytes += data.sigBytes;
  7106. },
  7107. /**
  7108. * Processes available data blocks.
  7109. *
  7110. * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
  7111. *
  7112. * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
  7113. *
  7114. * @return {WordArray} The processed data.
  7115. *
  7116. * @example
  7117. *
  7118. * var processedData = bufferedBlockAlgorithm._process();
  7119. * var processedData = bufferedBlockAlgorithm._process(!!'flush');
  7120. */
  7121. _process: function (doFlush) {
  7122. // Shortcuts
  7123. var data = this._data;
  7124. var dataWords = data.words;
  7125. var dataSigBytes = data.sigBytes;
  7126. var blockSize = this.blockSize;
  7127. var blockSizeBytes = blockSize * 4;
  7128. // Count blocks ready
  7129. var nBlocksReady = dataSigBytes / blockSizeBytes;
  7130. if (doFlush) {
  7131. // Round up to include partial blocks
  7132. nBlocksReady = Math.ceil(nBlocksReady);
  7133. } else {
  7134. // Round down to include only full blocks,
  7135. // less the number of blocks that must remain in the buffer
  7136. nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
  7137. }
  7138. // Count words ready
  7139. var nWordsReady = nBlocksReady * blockSize;
  7140. // Count bytes ready
  7141. var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
  7142. // Process blocks
  7143. if (nWordsReady) {
  7144. for (var offset = 0; offset < nWordsReady; offset += blockSize) {
  7145. // Perform concrete-algorithm logic
  7146. this._doProcessBlock(dataWords, offset);
  7147. }
  7148. // Remove processed words
  7149. var processedWords = dataWords.splice(0, nWordsReady);
  7150. data.sigBytes -= nBytesReady;
  7151. }
  7152. // Return processed words
  7153. return new WordArray.init(processedWords, nBytesReady);
  7154. },
  7155. /**
  7156. * Creates a copy of this object.
  7157. *
  7158. * @return {Object} The clone.
  7159. *
  7160. * @example
  7161. *
  7162. * var clone = bufferedBlockAlgorithm.clone();
  7163. */
  7164. clone: function () {
  7165. var clone = Base.clone.call(this);
  7166. clone._data = this._data.clone();
  7167. return clone;
  7168. },
  7169. _minBufferSize: 0
  7170. });
  7171. /**
  7172. * Abstract hasher template.
  7173. *
  7174. * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
  7175. */
  7176. var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
  7177. /**
  7178. * Configuration options.
  7179. */
  7180. cfg: Base.extend(),
  7181. /**
  7182. * Initializes a newly created hasher.
  7183. *
  7184. * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
  7185. *
  7186. * @example
  7187. *
  7188. * var hasher = CryptoJS.algo.SHA256.create();
  7189. */
  7190. init: function (cfg) {
  7191. // Apply config defaults
  7192. this.cfg = this.cfg.extend(cfg);
  7193. // Set initial values
  7194. this.reset();
  7195. },
  7196. /**
  7197. * Resets this hasher to its initial state.
  7198. *
  7199. * @example
  7200. *
  7201. * hasher.reset();
  7202. */
  7203. reset: function () {
  7204. // Reset data buffer
  7205. BufferedBlockAlgorithm.reset.call(this);
  7206. // Perform concrete-hasher logic
  7207. this._doReset();
  7208. },
  7209. /**
  7210. * Updates this hasher with a message.
  7211. *
  7212. * @param {WordArray|string} messageUpdate The message to append.
  7213. *
  7214. * @return {Hasher} This hasher.
  7215. *
  7216. * @example
  7217. *
  7218. * hasher.update('message');
  7219. * hasher.update(wordArray);
  7220. */
  7221. update: function (messageUpdate) {
  7222. // Append
  7223. this._append(messageUpdate);
  7224. // Update the hash
  7225. this._process();
  7226. // Chainable
  7227. return this;
  7228. },
  7229. /**
  7230. * Finalizes the hash computation.
  7231. * Note that the finalize operation is effectively a destructive, read-once operation.
  7232. *
  7233. * @param {WordArray|string} messageUpdate (Optional) A final message update.
  7234. *
  7235. * @return {WordArray} The hash.
  7236. *
  7237. * @example
  7238. *
  7239. * var hash = hasher.finalize();
  7240. * var hash = hasher.finalize('message');
  7241. * var hash = hasher.finalize(wordArray);
  7242. */
  7243. finalize: function (messageUpdate) {
  7244. // Final message update
  7245. if (messageUpdate) {
  7246. this._append(messageUpdate);
  7247. }
  7248. // Perform concrete-hasher logic
  7249. var hash = this._doFinalize();
  7250. return hash;
  7251. },
  7252. blockSize: 512/32,
  7253. /**
  7254. * Creates a shortcut function to a hasher's object interface.
  7255. *
  7256. * @param {Hasher} hasher The hasher to create a helper for.
  7257. *
  7258. * @return {Function} The shortcut function.
  7259. *
  7260. * @static
  7261. *
  7262. * @example
  7263. *
  7264. * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
  7265. */
  7266. _createHelper: function (hasher) {
  7267. return function (message, cfg) {
  7268. return new hasher.init(cfg).finalize(message);
  7269. };
  7270. },
  7271. /**
  7272. * Creates a shortcut function to the HMAC's object interface.
  7273. *
  7274. * @param {Hasher} hasher The hasher to use in this HMAC helper.
  7275. *
  7276. * @return {Function} The shortcut function.
  7277. *
  7278. * @static
  7279. *
  7280. * @example
  7281. *
  7282. * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
  7283. */
  7284. _createHmacHelper: function (hasher) {
  7285. return function (message, key) {
  7286. return new C_algo.HMAC.init(hasher, key).finalize(message);
  7287. };
  7288. }
  7289. });
  7290. /**
  7291. * Algorithm namespace.
  7292. */
  7293. var C_algo = C.algo = {};
  7294. return C;
  7295. }(Math));
  7296. return CryptoJS;
  7297. }));
  7298. },{}],54:[function(require,module,exports){
  7299. ;(function (root, factory) {
  7300. if (typeof exports === "object") {
  7301. // CommonJS
  7302. module.exports = exports = factory(require("./core"));
  7303. }
  7304. else if (typeof define === "function" && define.amd) {
  7305. // AMD
  7306. define(["./core"], factory);
  7307. }
  7308. else {
  7309. // Global (browser)
  7310. factory(root.CryptoJS);
  7311. }
  7312. }(this, function (CryptoJS) {
  7313. (function () {
  7314. // Shortcuts
  7315. var C = CryptoJS;
  7316. var C_lib = C.lib;
  7317. var WordArray = C_lib.WordArray;
  7318. var C_enc = C.enc;
  7319. /**
  7320. * Base64 encoding strategy.
  7321. */
  7322. var Base64 = C_enc.Base64 = {
  7323. /**
  7324. * Converts a word array to a Base64 string.
  7325. *
  7326. * @param {WordArray} wordArray The word array.
  7327. *
  7328. * @return {string} The Base64 string.
  7329. *
  7330. * @static
  7331. *
  7332. * @example
  7333. *
  7334. * var base64String = CryptoJS.enc.Base64.stringify(wordArray);
  7335. */
  7336. stringify: function (wordArray) {
  7337. // Shortcuts
  7338. var words = wordArray.words;
  7339. var sigBytes = wordArray.sigBytes;
  7340. var map = this._map;
  7341. // Clamp excess bits
  7342. wordArray.clamp();
  7343. // Convert
  7344. var base64Chars = [];
  7345. for (var i = 0; i < sigBytes; i += 3) {
  7346. var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  7347. var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
  7348. var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
  7349. var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
  7350. for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
  7351. base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
  7352. }
  7353. }
  7354. // Add padding
  7355. var paddingChar = map.charAt(64);
  7356. if (paddingChar) {
  7357. while (base64Chars.length % 4) {
  7358. base64Chars.push(paddingChar);
  7359. }
  7360. }
  7361. return base64Chars.join('');
  7362. },
  7363. /**
  7364. * Converts a Base64 string to a word array.
  7365. *
  7366. * @param {string} base64Str The Base64 string.
  7367. *
  7368. * @return {WordArray} The word array.
  7369. *
  7370. * @static
  7371. *
  7372. * @example
  7373. *
  7374. * var wordArray = CryptoJS.enc.Base64.parse(base64String);
  7375. */
  7376. parse: function (base64Str) {
  7377. // Shortcuts
  7378. var base64StrLength = base64Str.length;
  7379. var map = this._map;
  7380. var reverseMap = this._reverseMap;
  7381. if (!reverseMap) {
  7382. reverseMap = this._reverseMap = [];
  7383. for (var j = 0; j < map.length; j++) {
  7384. reverseMap[map.charCodeAt(j)] = j;
  7385. }
  7386. }
  7387. // Ignore padding
  7388. var paddingChar = map.charAt(64);
  7389. if (paddingChar) {
  7390. var paddingIndex = base64Str.indexOf(paddingChar);
  7391. if (paddingIndex !== -1) {
  7392. base64StrLength = paddingIndex;
  7393. }
  7394. }
  7395. // Convert
  7396. return parseLoop(base64Str, base64StrLength, reverseMap);
  7397. },
  7398. _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
  7399. };
  7400. function parseLoop(base64Str, base64StrLength, reverseMap) {
  7401. var words = [];
  7402. var nBytes = 0;
  7403. for (var i = 0; i < base64StrLength; i++) {
  7404. if (i % 4) {
  7405. var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
  7406. var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
  7407. words[nBytes >>> 2] |= (bits1 | bits2) << (24 - (nBytes % 4) * 8);
  7408. nBytes++;
  7409. }
  7410. }
  7411. return WordArray.create(words, nBytes);
  7412. }
  7413. }());
  7414. return CryptoJS.enc.Base64;
  7415. }));
  7416. },{"./core":53}],55:[function(require,module,exports){
  7417. ;(function (root, factory) {
  7418. if (typeof exports === "object") {
  7419. // CommonJS
  7420. module.exports = exports = factory(require("./core"));
  7421. }
  7422. else if (typeof define === "function" && define.amd) {
  7423. // AMD
  7424. define(["./core"], factory);
  7425. }
  7426. else {
  7427. // Global (browser)
  7428. factory(root.CryptoJS);
  7429. }
  7430. }(this, function (CryptoJS) {
  7431. (function () {
  7432. // Shortcuts
  7433. var C = CryptoJS;
  7434. var C_lib = C.lib;
  7435. var WordArray = C_lib.WordArray;
  7436. var C_enc = C.enc;
  7437. /**
  7438. * UTF-16 BE encoding strategy.
  7439. */
  7440. var Utf16BE = C_enc.Utf16 = C_enc.Utf16BE = {
  7441. /**
  7442. * Converts a word array to a UTF-16 BE string.
  7443. *
  7444. * @param {WordArray} wordArray The word array.
  7445. *
  7446. * @return {string} The UTF-16 BE string.
  7447. *
  7448. * @static
  7449. *
  7450. * @example
  7451. *
  7452. * var utf16String = CryptoJS.enc.Utf16.stringify(wordArray);
  7453. */
  7454. stringify: function (wordArray) {
  7455. // Shortcuts
  7456. var words = wordArray.words;
  7457. var sigBytes = wordArray.sigBytes;
  7458. // Convert
  7459. var utf16Chars = [];
  7460. for (var i = 0; i < sigBytes; i += 2) {
  7461. var codePoint = (words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff;
  7462. utf16Chars.push(String.fromCharCode(codePoint));
  7463. }
  7464. return utf16Chars.join('');
  7465. },
  7466. /**
  7467. * Converts a UTF-16 BE string to a word array.
  7468. *
  7469. * @param {string} utf16Str The UTF-16 BE string.
  7470. *
  7471. * @return {WordArray} The word array.
  7472. *
  7473. * @static
  7474. *
  7475. * @example
  7476. *
  7477. * var wordArray = CryptoJS.enc.Utf16.parse(utf16String);
  7478. */
  7479. parse: function (utf16Str) {
  7480. // Shortcut
  7481. var utf16StrLength = utf16Str.length;
  7482. // Convert
  7483. var words = [];
  7484. for (var i = 0; i < utf16StrLength; i++) {
  7485. words[i >>> 1] |= utf16Str.charCodeAt(i) << (16 - (i % 2) * 16);
  7486. }
  7487. return WordArray.create(words, utf16StrLength * 2);
  7488. }
  7489. };
  7490. /**
  7491. * UTF-16 LE encoding strategy.
  7492. */
  7493. C_enc.Utf16LE = {
  7494. /**
  7495. * Converts a word array to a UTF-16 LE string.
  7496. *
  7497. * @param {WordArray} wordArray The word array.
  7498. *
  7499. * @return {string} The UTF-16 LE string.
  7500. *
  7501. * @static
  7502. *
  7503. * @example
  7504. *
  7505. * var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray);
  7506. */
  7507. stringify: function (wordArray) {
  7508. // Shortcuts
  7509. var words = wordArray.words;
  7510. var sigBytes = wordArray.sigBytes;
  7511. // Convert
  7512. var utf16Chars = [];
  7513. for (var i = 0; i < sigBytes; i += 2) {
  7514. var codePoint = swapEndian((words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff);
  7515. utf16Chars.push(String.fromCharCode(codePoint));
  7516. }
  7517. return utf16Chars.join('');
  7518. },
  7519. /**
  7520. * Converts a UTF-16 LE string to a word array.
  7521. *
  7522. * @param {string} utf16Str The UTF-16 LE string.
  7523. *
  7524. * @return {WordArray} The word array.
  7525. *
  7526. * @static
  7527. *
  7528. * @example
  7529. *
  7530. * var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str);
  7531. */
  7532. parse: function (utf16Str) {
  7533. // Shortcut
  7534. var utf16StrLength = utf16Str.length;
  7535. // Convert
  7536. var words = [];
  7537. for (var i = 0; i < utf16StrLength; i++) {
  7538. words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (16 - (i % 2) * 16));
  7539. }
  7540. return WordArray.create(words, utf16StrLength * 2);
  7541. }
  7542. };
  7543. function swapEndian(word) {
  7544. return ((word << 8) & 0xff00ff00) | ((word >>> 8) & 0x00ff00ff);
  7545. }
  7546. }());
  7547. return CryptoJS.enc.Utf16;
  7548. }));
  7549. },{"./core":53}],56:[function(require,module,exports){
  7550. ;(function (root, factory, undef) {
  7551. if (typeof exports === "object") {
  7552. // CommonJS
  7553. module.exports = exports = factory(require("./core"), require("./sha1"), require("./hmac"));
  7554. }
  7555. else if (typeof define === "function" && define.amd) {
  7556. // AMD
  7557. define(["./core", "./sha1", "./hmac"], factory);
  7558. }
  7559. else {
  7560. // Global (browser)
  7561. factory(root.CryptoJS);
  7562. }
  7563. }(this, function (CryptoJS) {
  7564. (function () {
  7565. // Shortcuts
  7566. var C = CryptoJS;
  7567. var C_lib = C.lib;
  7568. var Base = C_lib.Base;
  7569. var WordArray = C_lib.WordArray;
  7570. var C_algo = C.algo;
  7571. var MD5 = C_algo.MD5;
  7572. /**
  7573. * This key derivation function is meant to conform with EVP_BytesToKey.
  7574. * www.openssl.org/docs/crypto/EVP_BytesToKey.html
  7575. */
  7576. var EvpKDF = C_algo.EvpKDF = Base.extend({
  7577. /**
  7578. * Configuration options.
  7579. *
  7580. * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
  7581. * @property {Hasher} hasher The hash algorithm to use. Default: MD5
  7582. * @property {number} iterations The number of iterations to perform. Default: 1
  7583. */
  7584. cfg: Base.extend({
  7585. keySize: 128/32,
  7586. hasher: MD5,
  7587. iterations: 1
  7588. }),
  7589. /**
  7590. * Initializes a newly created key derivation function.
  7591. *
  7592. * @param {Object} cfg (Optional) The configuration options to use for the derivation.
  7593. *
  7594. * @example
  7595. *
  7596. * var kdf = CryptoJS.algo.EvpKDF.create();
  7597. * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
  7598. * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
  7599. */
  7600. init: function (cfg) {
  7601. this.cfg = this.cfg.extend(cfg);
  7602. },
  7603. /**
  7604. * Derives a key from a password.
  7605. *
  7606. * @param {WordArray|string} password The password.
  7607. * @param {WordArray|string} salt A salt.
  7608. *
  7609. * @return {WordArray} The derived key.
  7610. *
  7611. * @example
  7612. *
  7613. * var key = kdf.compute(password, salt);
  7614. */
  7615. compute: function (password, salt) {
  7616. // Shortcut
  7617. var cfg = this.cfg;
  7618. // Init hasher
  7619. var hasher = cfg.hasher.create();
  7620. // Initial values
  7621. var derivedKey = WordArray.create();
  7622. // Shortcuts
  7623. var derivedKeyWords = derivedKey.words;
  7624. var keySize = cfg.keySize;
  7625. var iterations = cfg.iterations;
  7626. // Generate key
  7627. while (derivedKeyWords.length < keySize) {
  7628. if (block) {
  7629. hasher.update(block);
  7630. }
  7631. var block = hasher.update(password).finalize(salt);
  7632. hasher.reset();
  7633. // Iterations
  7634. for (var i = 1; i < iterations; i++) {
  7635. block = hasher.finalize(block);
  7636. hasher.reset();
  7637. }
  7638. derivedKey.concat(block);
  7639. }
  7640. derivedKey.sigBytes = keySize * 4;
  7641. return derivedKey;
  7642. }
  7643. });
  7644. /**
  7645. * Derives a key from a password.
  7646. *
  7647. * @param {WordArray|string} password The password.
  7648. * @param {WordArray|string} salt A salt.
  7649. * @param {Object} cfg (Optional) The configuration options to use for this computation.
  7650. *
  7651. * @return {WordArray} The derived key.
  7652. *
  7653. * @static
  7654. *
  7655. * @example
  7656. *
  7657. * var key = CryptoJS.EvpKDF(password, salt);
  7658. * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 });
  7659. * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 });
  7660. */
  7661. C.EvpKDF = function (password, salt, cfg) {
  7662. return EvpKDF.create(cfg).compute(password, salt);
  7663. };
  7664. }());
  7665. return CryptoJS.EvpKDF;
  7666. }));
  7667. },{"./core":53,"./hmac":58,"./sha1":77}],57:[function(require,module,exports){
  7668. ;(function (root, factory, undef) {
  7669. if (typeof exports === "object") {
  7670. // CommonJS
  7671. module.exports = exports = factory(require("./core"), require("./cipher-core"));
  7672. }
  7673. else if (typeof define === "function" && define.amd) {
  7674. // AMD
  7675. define(["./core", "./cipher-core"], factory);
  7676. }
  7677. else {
  7678. // Global (browser)
  7679. factory(root.CryptoJS);
  7680. }
  7681. }(this, function (CryptoJS) {
  7682. (function (undefined) {
  7683. // Shortcuts
  7684. var C = CryptoJS;
  7685. var C_lib = C.lib;
  7686. var CipherParams = C_lib.CipherParams;
  7687. var C_enc = C.enc;
  7688. var Hex = C_enc.Hex;
  7689. var C_format = C.format;
  7690. var HexFormatter = C_format.Hex = {
  7691. /**
  7692. * Converts the ciphertext of a cipher params object to a hexadecimally encoded string.
  7693. *
  7694. * @param {CipherParams} cipherParams The cipher params object.
  7695. *
  7696. * @return {string} The hexadecimally encoded string.
  7697. *
  7698. * @static
  7699. *
  7700. * @example
  7701. *
  7702. * var hexString = CryptoJS.format.Hex.stringify(cipherParams);
  7703. */
  7704. stringify: function (cipherParams) {
  7705. return cipherParams.ciphertext.toString(Hex);
  7706. },
  7707. /**
  7708. * Converts a hexadecimally encoded ciphertext string to a cipher params object.
  7709. *
  7710. * @param {string} input The hexadecimally encoded string.
  7711. *
  7712. * @return {CipherParams} The cipher params object.
  7713. *
  7714. * @static
  7715. *
  7716. * @example
  7717. *
  7718. * var cipherParams = CryptoJS.format.Hex.parse(hexString);
  7719. */
  7720. parse: function (input) {
  7721. var ciphertext = Hex.parse(input);
  7722. return CipherParams.create({ ciphertext: ciphertext });
  7723. }
  7724. };
  7725. }());
  7726. return CryptoJS.format.Hex;
  7727. }));
  7728. },{"./cipher-core":52,"./core":53}],58:[function(require,module,exports){
  7729. ;(function (root, factory) {
  7730. if (typeof exports === "object") {
  7731. // CommonJS
  7732. module.exports = exports = factory(require("./core"));
  7733. }
  7734. else if (typeof define === "function" && define.amd) {
  7735. // AMD
  7736. define(["./core"], factory);
  7737. }
  7738. else {
  7739. // Global (browser)
  7740. factory(root.CryptoJS);
  7741. }
  7742. }(this, function (CryptoJS) {
  7743. (function () {
  7744. // Shortcuts
  7745. var C = CryptoJS;
  7746. var C_lib = C.lib;
  7747. var Base = C_lib.Base;
  7748. var C_enc = C.enc;
  7749. var Utf8 = C_enc.Utf8;
  7750. var C_algo = C.algo;
  7751. /**
  7752. * HMAC algorithm.
  7753. */
  7754. var HMAC = C_algo.HMAC = Base.extend({
  7755. /**
  7756. * Initializes a newly created HMAC.
  7757. *
  7758. * @param {Hasher} hasher The hash algorithm to use.
  7759. * @param {WordArray|string} key The secret key.
  7760. *
  7761. * @example
  7762. *
  7763. * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
  7764. */
  7765. init: function (hasher, key) {
  7766. // Init hasher
  7767. hasher = this._hasher = new hasher.init();
  7768. // Convert string to WordArray, else assume WordArray already
  7769. if (typeof key == 'string') {
  7770. key = Utf8.parse(key);
  7771. }
  7772. // Shortcuts
  7773. var hasherBlockSize = hasher.blockSize;
  7774. var hasherBlockSizeBytes = hasherBlockSize * 4;
  7775. // Allow arbitrary length keys
  7776. if (key.sigBytes > hasherBlockSizeBytes) {
  7777. key = hasher.finalize(key);
  7778. }
  7779. // Clamp excess bits
  7780. key.clamp();
  7781. // Clone key for inner and outer pads
  7782. var oKey = this._oKey = key.clone();
  7783. var iKey = this._iKey = key.clone();
  7784. // Shortcuts
  7785. var oKeyWords = oKey.words;
  7786. var iKeyWords = iKey.words;
  7787. // XOR keys with pad constants
  7788. for (var i = 0; i < hasherBlockSize; i++) {
  7789. oKeyWords[i] ^= 0x5c5c5c5c;
  7790. iKeyWords[i] ^= 0x36363636;
  7791. }
  7792. oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
  7793. // Set initial values
  7794. this.reset();
  7795. },
  7796. /**
  7797. * Resets this HMAC to its initial state.
  7798. *
  7799. * @example
  7800. *
  7801. * hmacHasher.reset();
  7802. */
  7803. reset: function () {
  7804. // Shortcut
  7805. var hasher = this._hasher;
  7806. // Reset
  7807. hasher.reset();
  7808. hasher.update(this._iKey);
  7809. },
  7810. /**
  7811. * Updates this HMAC with a message.
  7812. *
  7813. * @param {WordArray|string} messageUpdate The message to append.
  7814. *
  7815. * @return {HMAC} This HMAC instance.
  7816. *
  7817. * @example
  7818. *
  7819. * hmacHasher.update('message');
  7820. * hmacHasher.update(wordArray);
  7821. */
  7822. update: function (messageUpdate) {
  7823. this._hasher.update(messageUpdate);
  7824. // Chainable
  7825. return this;
  7826. },
  7827. /**
  7828. * Finalizes the HMAC computation.
  7829. * Note that the finalize operation is effectively a destructive, read-once operation.
  7830. *
  7831. * @param {WordArray|string} messageUpdate (Optional) A final message update.
  7832. *
  7833. * @return {WordArray} The HMAC.
  7834. *
  7835. * @example
  7836. *
  7837. * var hmac = hmacHasher.finalize();
  7838. * var hmac = hmacHasher.finalize('message');
  7839. * var hmac = hmacHasher.finalize(wordArray);
  7840. */
  7841. finalize: function (messageUpdate) {
  7842. // Shortcut
  7843. var hasher = this._hasher;
  7844. // Compute HMAC
  7845. var innerHash = hasher.finalize(messageUpdate);
  7846. hasher.reset();
  7847. var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
  7848. return hmac;
  7849. }
  7850. });
  7851. }());
  7852. }));
  7853. },{"./core":53}],59:[function(require,module,exports){
  7854. ;(function (root, factory, undef) {
  7855. if (typeof exports === "object") {
  7856. // CommonJS
  7857. module.exports = exports = factory(require("./core"), require("./x64-core"), require("./lib-typedarrays"), require("./enc-utf16"), require("./enc-base64"), require("./md5"), require("./sha1"), require("./sha256"), require("./sha224"), require("./sha512"), require("./sha384"), require("./sha3"), require("./ripemd160"), require("./hmac"), require("./pbkdf2"), require("./evpkdf"), require("./cipher-core"), require("./mode-cfb"), require("./mode-ctr"), require("./mode-ctr-gladman"), require("./mode-ofb"), require("./mode-ecb"), require("./pad-ansix923"), require("./pad-iso10126"), require("./pad-iso97971"), require("./pad-zeropadding"), require("./pad-nopadding"), require("./format-hex"), require("./aes"), require("./tripledes"), require("./rc4"), require("./rabbit"), require("./rabbit-legacy"));
  7858. }
  7859. else if (typeof define === "function" && define.amd) {
  7860. // AMD
  7861. define(["./core", "./x64-core", "./lib-typedarrays", "./enc-utf16", "./enc-base64", "./md5", "./sha1", "./sha256", "./sha224", "./sha512", "./sha384", "./sha3", "./ripemd160", "./hmac", "./pbkdf2", "./evpkdf", "./cipher-core", "./mode-cfb", "./mode-ctr", "./mode-ctr-gladman", "./mode-ofb", "./mode-ecb", "./pad-ansix923", "./pad-iso10126", "./pad-iso97971", "./pad-zeropadding", "./pad-nopadding", "./format-hex", "./aes", "./tripledes", "./rc4", "./rabbit", "./rabbit-legacy"], factory);
  7862. }
  7863. else {
  7864. // Global (browser)
  7865. root.CryptoJS = factory(root.CryptoJS);
  7866. }
  7867. }(this, function (CryptoJS) {
  7868. return CryptoJS;
  7869. }));
  7870. },{"./aes":51,"./cipher-core":52,"./core":53,"./enc-base64":54,"./enc-utf16":55,"./evpkdf":56,"./format-hex":57,"./hmac":58,"./lib-typedarrays":60,"./md5":61,"./mode-cfb":62,"./mode-ctr":64,"./mode-ctr-gladman":63,"./mode-ecb":65,"./mode-ofb":66,"./pad-ansix923":67,"./pad-iso10126":68,"./pad-iso97971":69,"./pad-nopadding":70,"./pad-zeropadding":71,"./pbkdf2":72,"./rabbit":74,"./rabbit-legacy":73,"./rc4":75,"./ripemd160":76,"./sha1":77,"./sha224":78,"./sha256":79,"./sha3":80,"./sha384":81,"./sha512":82,"./tripledes":83,"./x64-core":84}],60:[function(require,module,exports){
  7871. ;(function (root, factory) {
  7872. if (typeof exports === "object") {
  7873. // CommonJS
  7874. module.exports = exports = factory(require("./core"));
  7875. }
  7876. else if (typeof define === "function" && define.amd) {
  7877. // AMD
  7878. define(["./core"], factory);
  7879. }
  7880. else {
  7881. // Global (browser)
  7882. factory(root.CryptoJS);
  7883. }
  7884. }(this, function (CryptoJS) {
  7885. (function () {
  7886. // Check if typed arrays are supported
  7887. if (typeof ArrayBuffer != 'function') {
  7888. return;
  7889. }
  7890. // Shortcuts
  7891. var C = CryptoJS;
  7892. var C_lib = C.lib;
  7893. var WordArray = C_lib.WordArray;
  7894. // Reference original init
  7895. var superInit = WordArray.init;
  7896. // Augment WordArray.init to handle typed arrays
  7897. var subInit = WordArray.init = function (typedArray) {
  7898. // Convert buffers to uint8
  7899. if (typedArray instanceof ArrayBuffer) {
  7900. typedArray = new Uint8Array(typedArray);
  7901. }
  7902. // Convert other array views to uint8
  7903. if (
  7904. typedArray instanceof Int8Array ||
  7905. (typeof Uint8ClampedArray !== "undefined" && typedArray instanceof Uint8ClampedArray) ||
  7906. typedArray instanceof Int16Array ||
  7907. typedArray instanceof Uint16Array ||
  7908. typedArray instanceof Int32Array ||
  7909. typedArray instanceof Uint32Array ||
  7910. typedArray instanceof Float32Array ||
  7911. typedArray instanceof Float64Array
  7912. ) {
  7913. typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength);
  7914. }
  7915. // Handle Uint8Array
  7916. if (typedArray instanceof Uint8Array) {
  7917. // Shortcut
  7918. var typedArrayByteLength = typedArray.byteLength;
  7919. // Extract bytes
  7920. var words = [];
  7921. for (var i = 0; i < typedArrayByteLength; i++) {
  7922. words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8);
  7923. }
  7924. // Initialize this word array
  7925. superInit.call(this, words, typedArrayByteLength);
  7926. } else {
  7927. // Else call normal init
  7928. superInit.apply(this, arguments);
  7929. }
  7930. };
  7931. subInit.prototype = WordArray;
  7932. }());
  7933. return CryptoJS.lib.WordArray;
  7934. }));
  7935. },{"./core":53}],61:[function(require,module,exports){
  7936. ;(function (root, factory) {
  7937. if (typeof exports === "object") {
  7938. // CommonJS
  7939. module.exports = exports = factory(require("./core"));
  7940. }
  7941. else if (typeof define === "function" && define.amd) {
  7942. // AMD
  7943. define(["./core"], factory);
  7944. }
  7945. else {
  7946. // Global (browser)
  7947. factory(root.CryptoJS);
  7948. }
  7949. }(this, function (CryptoJS) {
  7950. (function (Math) {
  7951. // Shortcuts
  7952. var C = CryptoJS;
  7953. var C_lib = C.lib;
  7954. var WordArray = C_lib.WordArray;
  7955. var Hasher = C_lib.Hasher;
  7956. var C_algo = C.algo;
  7957. // Constants table
  7958. var T = [];
  7959. // Compute constants
  7960. (function () {
  7961. for (var i = 0; i < 64; i++) {
  7962. T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
  7963. }
  7964. }());
  7965. /**
  7966. * MD5 hash algorithm.
  7967. */
  7968. var MD5 = C_algo.MD5 = Hasher.extend({
  7969. _doReset: function () {
  7970. this._hash = new WordArray.init([
  7971. 0x67452301, 0xefcdab89,
  7972. 0x98badcfe, 0x10325476
  7973. ]);
  7974. },
  7975. _doProcessBlock: function (M, offset) {
  7976. // Swap endian
  7977. for (var i = 0; i < 16; i++) {
  7978. // Shortcuts
  7979. var offset_i = offset + i;
  7980. var M_offset_i = M[offset_i];
  7981. M[offset_i] = (
  7982. (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
  7983. (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
  7984. );
  7985. }
  7986. // Shortcuts
  7987. var H = this._hash.words;
  7988. var M_offset_0 = M[offset + 0];
  7989. var M_offset_1 = M[offset + 1];
  7990. var M_offset_2 = M[offset + 2];
  7991. var M_offset_3 = M[offset + 3];
  7992. var M_offset_4 = M[offset + 4];
  7993. var M_offset_5 = M[offset + 5];
  7994. var M_offset_6 = M[offset + 6];
  7995. var M_offset_7 = M[offset + 7];
  7996. var M_offset_8 = M[offset + 8];
  7997. var M_offset_9 = M[offset + 9];
  7998. var M_offset_10 = M[offset + 10];
  7999. var M_offset_11 = M[offset + 11];
  8000. var M_offset_12 = M[offset + 12];
  8001. var M_offset_13 = M[offset + 13];
  8002. var M_offset_14 = M[offset + 14];
  8003. var M_offset_15 = M[offset + 15];
  8004. // Working varialbes
  8005. var a = H[0];
  8006. var b = H[1];
  8007. var c = H[2];
  8008. var d = H[3];
  8009. // Computation
  8010. a = FF(a, b, c, d, M_offset_0, 7, T[0]);
  8011. d = FF(d, a, b, c, M_offset_1, 12, T[1]);
  8012. c = FF(c, d, a, b, M_offset_2, 17, T[2]);
  8013. b = FF(b, c, d, a, M_offset_3, 22, T[3]);
  8014. a = FF(a, b, c, d, M_offset_4, 7, T[4]);
  8015. d = FF(d, a, b, c, M_offset_5, 12, T[5]);
  8016. c = FF(c, d, a, b, M_offset_6, 17, T[6]);
  8017. b = FF(b, c, d, a, M_offset_7, 22, T[7]);
  8018. a = FF(a, b, c, d, M_offset_8, 7, T[8]);
  8019. d = FF(d, a, b, c, M_offset_9, 12, T[9]);
  8020. c = FF(c, d, a, b, M_offset_10, 17, T[10]);
  8021. b = FF(b, c, d, a, M_offset_11, 22, T[11]);
  8022. a = FF(a, b, c, d, M_offset_12, 7, T[12]);
  8023. d = FF(d, a, b, c, M_offset_13, 12, T[13]);
  8024. c = FF(c, d, a, b, M_offset_14, 17, T[14]);
  8025. b = FF(b, c, d, a, M_offset_15, 22, T[15]);
  8026. a = GG(a, b, c, d, M_offset_1, 5, T[16]);
  8027. d = GG(d, a, b, c, M_offset_6, 9, T[17]);
  8028. c = GG(c, d, a, b, M_offset_11, 14, T[18]);
  8029. b = GG(b, c, d, a, M_offset_0, 20, T[19]);
  8030. a = GG(a, b, c, d, M_offset_5, 5, T[20]);
  8031. d = GG(d, a, b, c, M_offset_10, 9, T[21]);
  8032. c = GG(c, d, a, b, M_offset_15, 14, T[22]);
  8033. b = GG(b, c, d, a, M_offset_4, 20, T[23]);
  8034. a = GG(a, b, c, d, M_offset_9, 5, T[24]);
  8035. d = GG(d, a, b, c, M_offset_14, 9, T[25]);
  8036. c = GG(c, d, a, b, M_offset_3, 14, T[26]);
  8037. b = GG(b, c, d, a, M_offset_8, 20, T[27]);
  8038. a = GG(a, b, c, d, M_offset_13, 5, T[28]);
  8039. d = GG(d, a, b, c, M_offset_2, 9, T[29]);
  8040. c = GG(c, d, a, b, M_offset_7, 14, T[30]);
  8041. b = GG(b, c, d, a, M_offset_12, 20, T[31]);
  8042. a = HH(a, b, c, d, M_offset_5, 4, T[32]);
  8043. d = HH(d, a, b, c, M_offset_8, 11, T[33]);
  8044. c = HH(c, d, a, b, M_offset_11, 16, T[34]);
  8045. b = HH(b, c, d, a, M_offset_14, 23, T[35]);
  8046. a = HH(a, b, c, d, M_offset_1, 4, T[36]);
  8047. d = HH(d, a, b, c, M_offset_4, 11, T[37]);
  8048. c = HH(c, d, a, b, M_offset_7, 16, T[38]);
  8049. b = HH(b, c, d, a, M_offset_10, 23, T[39]);
  8050. a = HH(a, b, c, d, M_offset_13, 4, T[40]);
  8051. d = HH(d, a, b, c, M_offset_0, 11, T[41]);
  8052. c = HH(c, d, a, b, M_offset_3, 16, T[42]);
  8053. b = HH(b, c, d, a, M_offset_6, 23, T[43]);
  8054. a = HH(a, b, c, d, M_offset_9, 4, T[44]);
  8055. d = HH(d, a, b, c, M_offset_12, 11, T[45]);
  8056. c = HH(c, d, a, b, M_offset_15, 16, T[46]);
  8057. b = HH(b, c, d, a, M_offset_2, 23, T[47]);
  8058. a = II(a, b, c, d, M_offset_0, 6, T[48]);
  8059. d = II(d, a, b, c, M_offset_7, 10, T[49]);
  8060. c = II(c, d, a, b, M_offset_14, 15, T[50]);
  8061. b = II(b, c, d, a, M_offset_5, 21, T[51]);
  8062. a = II(a, b, c, d, M_offset_12, 6, T[52]);
  8063. d = II(d, a, b, c, M_offset_3, 10, T[53]);
  8064. c = II(c, d, a, b, M_offset_10, 15, T[54]);
  8065. b = II(b, c, d, a, M_offset_1, 21, T[55]);
  8066. a = II(a, b, c, d, M_offset_8, 6, T[56]);
  8067. d = II(d, a, b, c, M_offset_15, 10, T[57]);
  8068. c = II(c, d, a, b, M_offset_6, 15, T[58]);
  8069. b = II(b, c, d, a, M_offset_13, 21, T[59]);
  8070. a = II(a, b, c, d, M_offset_4, 6, T[60]);
  8071. d = II(d, a, b, c, M_offset_11, 10, T[61]);
  8072. c = II(c, d, a, b, M_offset_2, 15, T[62]);
  8073. b = II(b, c, d, a, M_offset_9, 21, T[63]);
  8074. // Intermediate hash value
  8075. H[0] = (H[0] + a) | 0;
  8076. H[1] = (H[1] + b) | 0;
  8077. H[2] = (H[2] + c) | 0;
  8078. H[3] = (H[3] + d) | 0;
  8079. },
  8080. _doFinalize: function () {
  8081. // Shortcuts
  8082. var data = this._data;
  8083. var dataWords = data.words;
  8084. var nBitsTotal = this._nDataBytes * 8;
  8085. var nBitsLeft = data.sigBytes * 8;
  8086. // Add padding
  8087. dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  8088. var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
  8089. var nBitsTotalL = nBitsTotal;
  8090. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
  8091. (((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
  8092. (((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00)
  8093. );
  8094. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
  8095. (((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
  8096. (((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00)
  8097. );
  8098. data.sigBytes = (dataWords.length + 1) * 4;
  8099. // Hash final blocks
  8100. this._process();
  8101. // Shortcuts
  8102. var hash = this._hash;
  8103. var H = hash.words;
  8104. // Swap endian
  8105. for (var i = 0; i < 4; i++) {
  8106. // Shortcut
  8107. var H_i = H[i];
  8108. H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
  8109. (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
  8110. }
  8111. // Return final computed hash
  8112. return hash;
  8113. },
  8114. clone: function () {
  8115. var clone = Hasher.clone.call(this);
  8116. clone._hash = this._hash.clone();
  8117. return clone;
  8118. }
  8119. });
  8120. function FF(a, b, c, d, x, s, t) {
  8121. var n = a + ((b & c) | (~b & d)) + x + t;
  8122. return ((n << s) | (n >>> (32 - s))) + b;
  8123. }
  8124. function GG(a, b, c, d, x, s, t) {
  8125. var n = a + ((b & d) | (c & ~d)) + x + t;
  8126. return ((n << s) | (n >>> (32 - s))) + b;
  8127. }
  8128. function HH(a, b, c, d, x, s, t) {
  8129. var n = a + (b ^ c ^ d) + x + t;
  8130. return ((n << s) | (n >>> (32 - s))) + b;
  8131. }
  8132. function II(a, b, c, d, x, s, t) {
  8133. var n = a + (c ^ (b | ~d)) + x + t;
  8134. return ((n << s) | (n >>> (32 - s))) + b;
  8135. }
  8136. /**
  8137. * Shortcut function to the hasher's object interface.
  8138. *
  8139. * @param {WordArray|string} message The message to hash.
  8140. *
  8141. * @return {WordArray} The hash.
  8142. *
  8143. * @static
  8144. *
  8145. * @example
  8146. *
  8147. * var hash = CryptoJS.MD5('message');
  8148. * var hash = CryptoJS.MD5(wordArray);
  8149. */
  8150. C.MD5 = Hasher._createHelper(MD5);
  8151. /**
  8152. * Shortcut function to the HMAC's object interface.
  8153. *
  8154. * @param {WordArray|string} message The message to hash.
  8155. * @param {WordArray|string} key The secret key.
  8156. *
  8157. * @return {WordArray} The HMAC.
  8158. *
  8159. * @static
  8160. *
  8161. * @example
  8162. *
  8163. * var hmac = CryptoJS.HmacMD5(message, key);
  8164. */
  8165. C.HmacMD5 = Hasher._createHmacHelper(MD5);
  8166. }(Math));
  8167. return CryptoJS.MD5;
  8168. }));
  8169. },{"./core":53}],62:[function(require,module,exports){
  8170. ;(function (root, factory, undef) {
  8171. if (typeof exports === "object") {
  8172. // CommonJS
  8173. module.exports = exports = factory(require("./core"), require("./cipher-core"));
  8174. }
  8175. else if (typeof define === "function" && define.amd) {
  8176. // AMD
  8177. define(["./core", "./cipher-core"], factory);
  8178. }
  8179. else {
  8180. // Global (browser)
  8181. factory(root.CryptoJS);
  8182. }
  8183. }(this, function (CryptoJS) {
  8184. /**
  8185. * Cipher Feedback block mode.
  8186. */
  8187. CryptoJS.mode.CFB = (function () {
  8188. var CFB = CryptoJS.lib.BlockCipherMode.extend();
  8189. CFB.Encryptor = CFB.extend({
  8190. processBlock: function (words, offset) {
  8191. // Shortcuts
  8192. var cipher = this._cipher;
  8193. var blockSize = cipher.blockSize;
  8194. generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
  8195. // Remember this block to use with next block
  8196. this._prevBlock = words.slice(offset, offset + blockSize);
  8197. }
  8198. });
  8199. CFB.Decryptor = CFB.extend({
  8200. processBlock: function (words, offset) {
  8201. // Shortcuts
  8202. var cipher = this._cipher;
  8203. var blockSize = cipher.blockSize;
  8204. // Remember this block to use with next block
  8205. var thisBlock = words.slice(offset, offset + blockSize);
  8206. generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
  8207. // This block becomes the previous block
  8208. this._prevBlock = thisBlock;
  8209. }
  8210. });
  8211. function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) {
  8212. // Shortcut
  8213. var iv = this._iv;
  8214. // Generate keystream
  8215. if (iv) {
  8216. var keystream = iv.slice(0);
  8217. // Remove IV for subsequent blocks
  8218. this._iv = undefined;
  8219. } else {
  8220. var keystream = this._prevBlock;
  8221. }
  8222. cipher.encryptBlock(keystream, 0);
  8223. // Encrypt
  8224. for (var i = 0; i < blockSize; i++) {
  8225. words[offset + i] ^= keystream[i];
  8226. }
  8227. }
  8228. return CFB;
  8229. }());
  8230. return CryptoJS.mode.CFB;
  8231. }));
  8232. },{"./cipher-core":52,"./core":53}],63:[function(require,module,exports){
  8233. ;(function (root, factory, undef) {
  8234. if (typeof exports === "object") {
  8235. // CommonJS
  8236. module.exports = exports = factory(require("./core"), require("./cipher-core"));
  8237. }
  8238. else if (typeof define === "function" && define.amd) {
  8239. // AMD
  8240. define(["./core", "./cipher-core"], factory);
  8241. }
  8242. else {
  8243. // Global (browser)
  8244. factory(root.CryptoJS);
  8245. }
  8246. }(this, function (CryptoJS) {
  8247. /** @preserve
  8248. * Counter block mode compatible with Dr Brian Gladman fileenc.c
  8249. * derived from CryptoJS.mode.CTR
  8250. * Jan Hruby [email protected]
  8251. */
  8252. CryptoJS.mode.CTRGladman = (function () {
  8253. var CTRGladman = CryptoJS.lib.BlockCipherMode.extend();
  8254. function incWord(word)
  8255. {
  8256. if (((word >> 24) & 0xff) === 0xff) { //overflow
  8257. var b1 = (word >> 16)&0xff;
  8258. var b2 = (word >> 8)&0xff;
  8259. var b3 = word & 0xff;
  8260. if (b1 === 0xff) // overflow b1
  8261. {
  8262. b1 = 0;
  8263. if (b2 === 0xff)
  8264. {
  8265. b2 = 0;
  8266. if (b3 === 0xff)
  8267. {
  8268. b3 = 0;
  8269. }
  8270. else
  8271. {
  8272. ++b3;
  8273. }
  8274. }
  8275. else
  8276. {
  8277. ++b2;
  8278. }
  8279. }
  8280. else
  8281. {
  8282. ++b1;
  8283. }
  8284. word = 0;
  8285. word += (b1 << 16);
  8286. word += (b2 << 8);
  8287. word += b3;
  8288. }
  8289. else
  8290. {
  8291. word += (0x01 << 24);
  8292. }
  8293. return word;
  8294. }
  8295. function incCounter(counter)
  8296. {
  8297. if ((counter[0] = incWord(counter[0])) === 0)
  8298. {
  8299. // encr_data in fileenc.c from Dr Brian Gladman's counts only with DWORD j < 8
  8300. counter[1] = incWord(counter[1]);
  8301. }
  8302. return counter;
  8303. }
  8304. var Encryptor = CTRGladman.Encryptor = CTRGladman.extend({
  8305. processBlock: function (words, offset) {
  8306. // Shortcuts
  8307. var cipher = this._cipher
  8308. var blockSize = cipher.blockSize;
  8309. var iv = this._iv;
  8310. var counter = this._counter;
  8311. // Generate keystream
  8312. if (iv) {
  8313. counter = this._counter = iv.slice(0);
  8314. // Remove IV for subsequent blocks
  8315. this._iv = undefined;
  8316. }
  8317. incCounter(counter);
  8318. var keystream = counter.slice(0);
  8319. cipher.encryptBlock(keystream, 0);
  8320. // Encrypt
  8321. for (var i = 0; i < blockSize; i++) {
  8322. words[offset + i] ^= keystream[i];
  8323. }
  8324. }
  8325. });
  8326. CTRGladman.Decryptor = Encryptor;
  8327. return CTRGladman;
  8328. }());
  8329. return CryptoJS.mode.CTRGladman;
  8330. }));
  8331. },{"./cipher-core":52,"./core":53}],64:[function(require,module,exports){
  8332. ;(function (root, factory, undef) {
  8333. if (typeof exports === "object") {
  8334. // CommonJS
  8335. module.exports = exports = factory(require("./core"), require("./cipher-core"));
  8336. }
  8337. else if (typeof define === "function" && define.amd) {
  8338. // AMD
  8339. define(["./core", "./cipher-core"], factory);
  8340. }
  8341. else {
  8342. // Global (browser)
  8343. factory(root.CryptoJS);
  8344. }
  8345. }(this, function (CryptoJS) {
  8346. /**
  8347. * Counter block mode.
  8348. */
  8349. CryptoJS.mode.CTR = (function () {
  8350. var CTR = CryptoJS.lib.BlockCipherMode.extend();
  8351. var Encryptor = CTR.Encryptor = CTR.extend({
  8352. processBlock: function (words, offset) {
  8353. // Shortcuts
  8354. var cipher = this._cipher
  8355. var blockSize = cipher.blockSize;
  8356. var iv = this._iv;
  8357. var counter = this._counter;
  8358. // Generate keystream
  8359. if (iv) {
  8360. counter = this._counter = iv.slice(0);
  8361. // Remove IV for subsequent blocks
  8362. this._iv = undefined;
  8363. }
  8364. var keystream = counter.slice(0);
  8365. cipher.encryptBlock(keystream, 0);
  8366. // Increment counter
  8367. counter[blockSize - 1] = (counter[blockSize - 1] + 1) | 0
  8368. // Encrypt
  8369. for (var i = 0; i < blockSize; i++) {
  8370. words[offset + i] ^= keystream[i];
  8371. }
  8372. }
  8373. });
  8374. CTR.Decryptor = Encryptor;
  8375. return CTR;
  8376. }());
  8377. return CryptoJS.mode.CTR;
  8378. }));
  8379. },{"./cipher-core":52,"./core":53}],65:[function(require,module,exports){
  8380. ;(function (root, factory, undef) {
  8381. if (typeof exports === "object") {
  8382. // CommonJS
  8383. module.exports = exports = factory(require("./core"), require("./cipher-core"));
  8384. }
  8385. else if (typeof define === "function" && define.amd) {
  8386. // AMD
  8387. define(["./core", "./cipher-core"], factory);
  8388. }
  8389. else {
  8390. // Global (browser)
  8391. factory(root.CryptoJS);
  8392. }
  8393. }(this, function (CryptoJS) {
  8394. /**
  8395. * Electronic Codebook block mode.
  8396. */
  8397. CryptoJS.mode.ECB = (function () {
  8398. var ECB = CryptoJS.lib.BlockCipherMode.extend();
  8399. ECB.Encryptor = ECB.extend({
  8400. processBlock: function (words, offset) {
  8401. this._cipher.encryptBlock(words, offset);
  8402. }
  8403. });
  8404. ECB.Decryptor = ECB.extend({
  8405. processBlock: function (words, offset) {
  8406. this._cipher.decryptBlock(words, offset);
  8407. }
  8408. });
  8409. return ECB;
  8410. }());
  8411. return CryptoJS.mode.ECB;
  8412. }));
  8413. },{"./cipher-core":52,"./core":53}],66:[function(require,module,exports){
  8414. ;(function (root, factory, undef) {
  8415. if (typeof exports === "object") {
  8416. // CommonJS
  8417. module.exports = exports = factory(require("./core"), require("./cipher-core"));
  8418. }
  8419. else if (typeof define === "function" && define.amd) {
  8420. // AMD
  8421. define(["./core", "./cipher-core"], factory);
  8422. }
  8423. else {
  8424. // Global (browser)
  8425. factory(root.CryptoJS);
  8426. }
  8427. }(this, function (CryptoJS) {
  8428. /**
  8429. * Output Feedback block mode.
  8430. */
  8431. CryptoJS.mode.OFB = (function () {
  8432. var OFB = CryptoJS.lib.BlockCipherMode.extend();
  8433. var Encryptor = OFB.Encryptor = OFB.extend({
  8434. processBlock: function (words, offset) {
  8435. // Shortcuts
  8436. var cipher = this._cipher
  8437. var blockSize = cipher.blockSize;
  8438. var iv = this._iv;
  8439. var keystream = this._keystream;
  8440. // Generate keystream
  8441. if (iv) {
  8442. keystream = this._keystream = iv.slice(0);
  8443. // Remove IV for subsequent blocks
  8444. this._iv = undefined;
  8445. }
  8446. cipher.encryptBlock(keystream, 0);
  8447. // Encrypt
  8448. for (var i = 0; i < blockSize; i++) {
  8449. words[offset + i] ^= keystream[i];
  8450. }
  8451. }
  8452. });
  8453. OFB.Decryptor = Encryptor;
  8454. return OFB;
  8455. }());
  8456. return CryptoJS.mode.OFB;
  8457. }));
  8458. },{"./cipher-core":52,"./core":53}],67:[function(require,module,exports){
  8459. ;(function (root, factory, undef) {
  8460. if (typeof exports === "object") {
  8461. // CommonJS
  8462. module.exports = exports = factory(require("./core"), require("./cipher-core"));
  8463. }
  8464. else if (typeof define === "function" && define.amd) {
  8465. // AMD
  8466. define(["./core", "./cipher-core"], factory);
  8467. }
  8468. else {
  8469. // Global (browser)
  8470. factory(root.CryptoJS);
  8471. }
  8472. }(this, function (CryptoJS) {
  8473. /**
  8474. * ANSI X.923 padding strategy.
  8475. */
  8476. CryptoJS.pad.AnsiX923 = {
  8477. pad: function (data, blockSize) {
  8478. // Shortcuts
  8479. var dataSigBytes = data.sigBytes;
  8480. var blockSizeBytes = blockSize * 4;
  8481. // Count padding bytes
  8482. var nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes;
  8483. // Compute last byte position
  8484. var lastBytePos = dataSigBytes + nPaddingBytes - 1;
  8485. // Pad
  8486. data.clamp();
  8487. data.words[lastBytePos >>> 2] |= nPaddingBytes << (24 - (lastBytePos % 4) * 8);
  8488. data.sigBytes += nPaddingBytes;
  8489. },
  8490. unpad: function (data) {
  8491. // Get number of padding bytes from last byte
  8492. var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
  8493. // Remove padding
  8494. data.sigBytes -= nPaddingBytes;
  8495. }
  8496. };
  8497. return CryptoJS.pad.Ansix923;
  8498. }));
  8499. },{"./cipher-core":52,"./core":53}],68:[function(require,module,exports){
  8500. ;(function (root, factory, undef) {
  8501. if (typeof exports === "object") {
  8502. // CommonJS
  8503. module.exports = exports = factory(require("./core"), require("./cipher-core"));
  8504. }
  8505. else if (typeof define === "function" && define.amd) {
  8506. // AMD
  8507. define(["./core", "./cipher-core"], factory);
  8508. }
  8509. else {
  8510. // Global (browser)
  8511. factory(root.CryptoJS);
  8512. }
  8513. }(this, function (CryptoJS) {
  8514. /**
  8515. * ISO 10126 padding strategy.
  8516. */
  8517. CryptoJS.pad.Iso10126 = {
  8518. pad: function (data, blockSize) {
  8519. // Shortcut
  8520. var blockSizeBytes = blockSize * 4;
  8521. // Count padding bytes
  8522. var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
  8523. // Pad
  8524. data.concat(CryptoJS.lib.WordArray.random(nPaddingBytes - 1)).
  8525. concat(CryptoJS.lib.WordArray.create([nPaddingBytes << 24], 1));
  8526. },
  8527. unpad: function (data) {
  8528. // Get number of padding bytes from last byte
  8529. var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
  8530. // Remove padding
  8531. data.sigBytes -= nPaddingBytes;
  8532. }
  8533. };
  8534. return CryptoJS.pad.Iso10126;
  8535. }));
  8536. },{"./cipher-core":52,"./core":53}],69:[function(require,module,exports){
  8537. ;(function (root, factory, undef) {
  8538. if (typeof exports === "object") {
  8539. // CommonJS
  8540. module.exports = exports = factory(require("./core"), require("./cipher-core"));
  8541. }
  8542. else if (typeof define === "function" && define.amd) {
  8543. // AMD
  8544. define(["./core", "./cipher-core"], factory);
  8545. }
  8546. else {
  8547. // Global (browser)
  8548. factory(root.CryptoJS);
  8549. }
  8550. }(this, function (CryptoJS) {
  8551. /**
  8552. * ISO/IEC 9797-1 Padding Method 2.
  8553. */
  8554. CryptoJS.pad.Iso97971 = {
  8555. pad: function (data, blockSize) {
  8556. // Add 0x80 byte
  8557. data.concat(CryptoJS.lib.WordArray.create([0x80000000], 1));
  8558. // Zero pad the rest
  8559. CryptoJS.pad.ZeroPadding.pad(data, blockSize);
  8560. },
  8561. unpad: function (data) {
  8562. // Remove zero padding
  8563. CryptoJS.pad.ZeroPadding.unpad(data);
  8564. // Remove one more byte -- the 0x80 byte
  8565. data.sigBytes--;
  8566. }
  8567. };
  8568. return CryptoJS.pad.Iso97971;
  8569. }));
  8570. },{"./cipher-core":52,"./core":53}],70:[function(require,module,exports){
  8571. ;(function (root, factory, undef) {
  8572. if (typeof exports === "object") {
  8573. // CommonJS
  8574. module.exports = exports = factory(require("./core"), require("./cipher-core"));
  8575. }
  8576. else if (typeof define === "function" && define.amd) {
  8577. // AMD
  8578. define(["./core", "./cipher-core"], factory);
  8579. }
  8580. else {
  8581. // Global (browser)
  8582. factory(root.CryptoJS);
  8583. }
  8584. }(this, function (CryptoJS) {
  8585. /**
  8586. * A noop padding strategy.
  8587. */
  8588. CryptoJS.pad.NoPadding = {
  8589. pad: function () {
  8590. },
  8591. unpad: function () {
  8592. }
  8593. };
  8594. return CryptoJS.pad.NoPadding;
  8595. }));
  8596. },{"./cipher-core":52,"./core":53}],71:[function(require,module,exports){
  8597. ;(function (root, factory, undef) {
  8598. if (typeof exports === "object") {
  8599. // CommonJS
  8600. module.exports = exports = factory(require("./core"), require("./cipher-core"));
  8601. }
  8602. else if (typeof define === "function" && define.amd) {
  8603. // AMD
  8604. define(["./core", "./cipher-core"], factory);
  8605. }
  8606. else {
  8607. // Global (browser)
  8608. factory(root.CryptoJS);
  8609. }
  8610. }(this, function (CryptoJS) {
  8611. /**
  8612. * Zero padding strategy.
  8613. */
  8614. CryptoJS.pad.ZeroPadding = {
  8615. pad: function (data, blockSize) {
  8616. // Shortcut
  8617. var blockSizeBytes = blockSize * 4;
  8618. // Pad
  8619. data.clamp();
  8620. data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes);
  8621. },
  8622. unpad: function (data) {
  8623. // Shortcut
  8624. var dataWords = data.words;
  8625. // Unpad
  8626. var i = data.sigBytes - 1;
  8627. while (!((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) {
  8628. i--;
  8629. }
  8630. data.sigBytes = i + 1;
  8631. }
  8632. };
  8633. return CryptoJS.pad.ZeroPadding;
  8634. }));
  8635. },{"./cipher-core":52,"./core":53}],72:[function(require,module,exports){
  8636. ;(function (root, factory, undef) {
  8637. if (typeof exports === "object") {
  8638. // CommonJS
  8639. module.exports = exports = factory(require("./core"), require("./sha1"), require("./hmac"));
  8640. }
  8641. else if (typeof define === "function" && define.amd) {
  8642. // AMD
  8643. define(["./core", "./sha1", "./hmac"], factory);
  8644. }
  8645. else {
  8646. // Global (browser)
  8647. factory(root.CryptoJS);
  8648. }
  8649. }(this, function (CryptoJS) {
  8650. (function () {
  8651. // Shortcuts
  8652. var C = CryptoJS;
  8653. var C_lib = C.lib;
  8654. var Base = C_lib.Base;
  8655. var WordArray = C_lib.WordArray;
  8656. var C_algo = C.algo;
  8657. var SHA1 = C_algo.SHA1;
  8658. var HMAC = C_algo.HMAC;
  8659. /**
  8660. * Password-Based Key Derivation Function 2 algorithm.
  8661. */
  8662. var PBKDF2 = C_algo.PBKDF2 = Base.extend({
  8663. /**
  8664. * Configuration options.
  8665. *
  8666. * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
  8667. * @property {Hasher} hasher The hasher to use. Default: SHA1
  8668. * @property {number} iterations The number of iterations to perform. Default: 1
  8669. */
  8670. cfg: Base.extend({
  8671. keySize: 128/32,
  8672. hasher: SHA1,
  8673. iterations: 1
  8674. }),
  8675. /**
  8676. * Initializes a newly created key derivation function.
  8677. *
  8678. * @param {Object} cfg (Optional) The configuration options to use for the derivation.
  8679. *
  8680. * @example
  8681. *
  8682. * var kdf = CryptoJS.algo.PBKDF2.create();
  8683. * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8 });
  8684. * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8, iterations: 1000 });
  8685. */
  8686. init: function (cfg) {
  8687. this.cfg = this.cfg.extend(cfg);
  8688. },
  8689. /**
  8690. * Computes the Password-Based Key Derivation Function 2.
  8691. *
  8692. * @param {WordArray|string} password The password.
  8693. * @param {WordArray|string} salt A salt.
  8694. *
  8695. * @return {WordArray} The derived key.
  8696. *
  8697. * @example
  8698. *
  8699. * var key = kdf.compute(password, salt);
  8700. */
  8701. compute: function (password, salt) {
  8702. // Shortcut
  8703. var cfg = this.cfg;
  8704. // Init HMAC
  8705. var hmac = HMAC.create(cfg.hasher, password);
  8706. // Initial values
  8707. var derivedKey = WordArray.create();
  8708. var blockIndex = WordArray.create([0x00000001]);
  8709. // Shortcuts
  8710. var derivedKeyWords = derivedKey.words;
  8711. var blockIndexWords = blockIndex.words;
  8712. var keySize = cfg.keySize;
  8713. var iterations = cfg.iterations;
  8714. // Generate key
  8715. while (derivedKeyWords.length < keySize) {
  8716. var block = hmac.update(salt).finalize(blockIndex);
  8717. hmac.reset();
  8718. // Shortcuts
  8719. var blockWords = block.words;
  8720. var blockWordsLength = blockWords.length;
  8721. // Iterations
  8722. var intermediate = block;
  8723. for (var i = 1; i < iterations; i++) {
  8724. intermediate = hmac.finalize(intermediate);
  8725. hmac.reset();
  8726. // Shortcut
  8727. var intermediateWords = intermediate.words;
  8728. // XOR intermediate with block
  8729. for (var j = 0; j < blockWordsLength; j++) {
  8730. blockWords[j] ^= intermediateWords[j];
  8731. }
  8732. }
  8733. derivedKey.concat(block);
  8734. blockIndexWords[0]++;
  8735. }
  8736. derivedKey.sigBytes = keySize * 4;
  8737. return derivedKey;
  8738. }
  8739. });
  8740. /**
  8741. * Computes the Password-Based Key Derivation Function 2.
  8742. *
  8743. * @param {WordArray|string} password The password.
  8744. * @param {WordArray|string} salt A salt.
  8745. * @param {Object} cfg (Optional) The configuration options to use for this computation.
  8746. *
  8747. * @return {WordArray} The derived key.
  8748. *
  8749. * @static
  8750. *
  8751. * @example
  8752. *
  8753. * var key = CryptoJS.PBKDF2(password, salt);
  8754. * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8 });
  8755. * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8, iterations: 1000 });
  8756. */
  8757. C.PBKDF2 = function (password, salt, cfg) {
  8758. return PBKDF2.create(cfg).compute(password, salt);
  8759. };
  8760. }());
  8761. return CryptoJS.PBKDF2;
  8762. }));
  8763. },{"./core":53,"./hmac":58,"./sha1":77}],73:[function(require,module,exports){
  8764. ;(function (root, factory, undef) {
  8765. if (typeof exports === "object") {
  8766. // CommonJS
  8767. module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
  8768. }
  8769. else if (typeof define === "function" && define.amd) {
  8770. // AMD
  8771. define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
  8772. }
  8773. else {
  8774. // Global (browser)
  8775. factory(root.CryptoJS);
  8776. }
  8777. }(this, function (CryptoJS) {
  8778. (function () {
  8779. // Shortcuts
  8780. var C = CryptoJS;
  8781. var C_lib = C.lib;
  8782. var StreamCipher = C_lib.StreamCipher;
  8783. var C_algo = C.algo;
  8784. // Reusable objects
  8785. var S = [];
  8786. var C_ = [];
  8787. var G = [];
  8788. /**
  8789. * Rabbit stream cipher algorithm.
  8790. *
  8791. * This is a legacy version that neglected to convert the key to little-endian.
  8792. * This error doesn't affect the cipher's security,
  8793. * but it does affect its compatibility with other implementations.
  8794. */
  8795. var RabbitLegacy = C_algo.RabbitLegacy = StreamCipher.extend({
  8796. _doReset: function () {
  8797. // Shortcuts
  8798. var K = this._key.words;
  8799. var iv = this.cfg.iv;
  8800. // Generate initial state values
  8801. var X = this._X = [
  8802. K[0], (K[3] << 16) | (K[2] >>> 16),
  8803. K[1], (K[0] << 16) | (K[3] >>> 16),
  8804. K[2], (K[1] << 16) | (K[0] >>> 16),
  8805. K[3], (K[2] << 16) | (K[1] >>> 16)
  8806. ];
  8807. // Generate initial counter values
  8808. var C = this._C = [
  8809. (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
  8810. (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
  8811. (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
  8812. (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
  8813. ];
  8814. // Carry bit
  8815. this._b = 0;
  8816. // Iterate the system four times
  8817. for (var i = 0; i < 4; i++) {
  8818. nextState.call(this);
  8819. }
  8820. // Modify the counters
  8821. for (var i = 0; i < 8; i++) {
  8822. C[i] ^= X[(i + 4) & 7];
  8823. }
  8824. // IV setup
  8825. if (iv) {
  8826. // Shortcuts
  8827. var IV = iv.words;
  8828. var IV_0 = IV[0];
  8829. var IV_1 = IV[1];
  8830. // Generate four subvectors
  8831. var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
  8832. var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
  8833. var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
  8834. var i3 = (i2 << 16) | (i0 & 0x0000ffff);
  8835. // Modify counter values
  8836. C[0] ^= i0;
  8837. C[1] ^= i1;
  8838. C[2] ^= i2;
  8839. C[3] ^= i3;
  8840. C[4] ^= i0;
  8841. C[5] ^= i1;
  8842. C[6] ^= i2;
  8843. C[7] ^= i3;
  8844. // Iterate the system four times
  8845. for (var i = 0; i < 4; i++) {
  8846. nextState.call(this);
  8847. }
  8848. }
  8849. },
  8850. _doProcessBlock: function (M, offset) {
  8851. // Shortcut
  8852. var X = this._X;
  8853. // Iterate the system
  8854. nextState.call(this);
  8855. // Generate four keystream words
  8856. S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
  8857. S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
  8858. S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
  8859. S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
  8860. for (var i = 0; i < 4; i++) {
  8861. // Swap endian
  8862. S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) |
  8863. (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00);
  8864. // Encrypt
  8865. M[offset + i] ^= S[i];
  8866. }
  8867. },
  8868. blockSize: 128/32,
  8869. ivSize: 64/32
  8870. });
  8871. function nextState() {
  8872. // Shortcuts
  8873. var X = this._X;
  8874. var C = this._C;
  8875. // Save old counter values
  8876. for (var i = 0; i < 8; i++) {
  8877. C_[i] = C[i];
  8878. }
  8879. // Calculate new counter values
  8880. C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
  8881. C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
  8882. C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
  8883. C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
  8884. C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
  8885. C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
  8886. C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
  8887. C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
  8888. this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
  8889. // Calculate the g-values
  8890. for (var i = 0; i < 8; i++) {
  8891. var gx = X[i] + C[i];
  8892. // Construct high and low argument for squaring
  8893. var ga = gx & 0xffff;
  8894. var gb = gx >>> 16;
  8895. // Calculate high and low result of squaring
  8896. var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
  8897. var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
  8898. // High XOR low
  8899. G[i] = gh ^ gl;
  8900. }
  8901. // Calculate new state values
  8902. X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
  8903. X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0;
  8904. X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
  8905. X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0;
  8906. X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
  8907. X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0;
  8908. X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
  8909. X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0;
  8910. }
  8911. /**
  8912. * Shortcut functions to the cipher's object interface.
  8913. *
  8914. * @example
  8915. *
  8916. * var ciphertext = CryptoJS.RabbitLegacy.encrypt(message, key, cfg);
  8917. * var plaintext = CryptoJS.RabbitLegacy.decrypt(ciphertext, key, cfg);
  8918. */
  8919. C.RabbitLegacy = StreamCipher._createHelper(RabbitLegacy);
  8920. }());
  8921. return CryptoJS.RabbitLegacy;
  8922. }));
  8923. },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],74:[function(require,module,exports){
  8924. ;(function (root, factory, undef) {
  8925. if (typeof exports === "object") {
  8926. // CommonJS
  8927. module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
  8928. }
  8929. else if (typeof define === "function" && define.amd) {
  8930. // AMD
  8931. define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
  8932. }
  8933. else {
  8934. // Global (browser)
  8935. factory(root.CryptoJS);
  8936. }
  8937. }(this, function (CryptoJS) {
  8938. (function () {
  8939. // Shortcuts
  8940. var C = CryptoJS;
  8941. var C_lib = C.lib;
  8942. var StreamCipher = C_lib.StreamCipher;
  8943. var C_algo = C.algo;
  8944. // Reusable objects
  8945. var S = [];
  8946. var C_ = [];
  8947. var G = [];
  8948. /**
  8949. * Rabbit stream cipher algorithm
  8950. */
  8951. var Rabbit = C_algo.Rabbit = StreamCipher.extend({
  8952. _doReset: function () {
  8953. // Shortcuts
  8954. var K = this._key.words;
  8955. var iv = this.cfg.iv;
  8956. // Swap endian
  8957. for (var i = 0; i < 4; i++) {
  8958. K[i] = (((K[i] << 8) | (K[i] >>> 24)) & 0x00ff00ff) |
  8959. (((K[i] << 24) | (K[i] >>> 8)) & 0xff00ff00);
  8960. }
  8961. // Generate initial state values
  8962. var X = this._X = [
  8963. K[0], (K[3] << 16) | (K[2] >>> 16),
  8964. K[1], (K[0] << 16) | (K[3] >>> 16),
  8965. K[2], (K[1] << 16) | (K[0] >>> 16),
  8966. K[3], (K[2] << 16) | (K[1] >>> 16)
  8967. ];
  8968. // Generate initial counter values
  8969. var C = this._C = [
  8970. (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
  8971. (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
  8972. (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
  8973. (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
  8974. ];
  8975. // Carry bit
  8976. this._b = 0;
  8977. // Iterate the system four times
  8978. for (var i = 0; i < 4; i++) {
  8979. nextState.call(this);
  8980. }
  8981. // Modify the counters
  8982. for (var i = 0; i < 8; i++) {
  8983. C[i] ^= X[(i + 4) & 7];
  8984. }
  8985. // IV setup
  8986. if (iv) {
  8987. // Shortcuts
  8988. var IV = iv.words;
  8989. var IV_0 = IV[0];
  8990. var IV_1 = IV[1];
  8991. // Generate four subvectors
  8992. var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
  8993. var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
  8994. var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
  8995. var i3 = (i2 << 16) | (i0 & 0x0000ffff);
  8996. // Modify counter values
  8997. C[0] ^= i0;
  8998. C[1] ^= i1;
  8999. C[2] ^= i2;
  9000. C[3] ^= i3;
  9001. C[4] ^= i0;
  9002. C[5] ^= i1;
  9003. C[6] ^= i2;
  9004. C[7] ^= i3;
  9005. // Iterate the system four times
  9006. for (var i = 0; i < 4; i++) {
  9007. nextState.call(this);
  9008. }
  9009. }
  9010. },
  9011. _doProcessBlock: function (M, offset) {
  9012. // Shortcut
  9013. var X = this._X;
  9014. // Iterate the system
  9015. nextState.call(this);
  9016. // Generate four keystream words
  9017. S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
  9018. S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
  9019. S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
  9020. S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
  9021. for (var i = 0; i < 4; i++) {
  9022. // Swap endian
  9023. S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) |
  9024. (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00);
  9025. // Encrypt
  9026. M[offset + i] ^= S[i];
  9027. }
  9028. },
  9029. blockSize: 128/32,
  9030. ivSize: 64/32
  9031. });
  9032. function nextState() {
  9033. // Shortcuts
  9034. var X = this._X;
  9035. var C = this._C;
  9036. // Save old counter values
  9037. for (var i = 0; i < 8; i++) {
  9038. C_[i] = C[i];
  9039. }
  9040. // Calculate new counter values
  9041. C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
  9042. C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
  9043. C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
  9044. C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
  9045. C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
  9046. C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
  9047. C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
  9048. C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
  9049. this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
  9050. // Calculate the g-values
  9051. for (var i = 0; i < 8; i++) {
  9052. var gx = X[i] + C[i];
  9053. // Construct high and low argument for squaring
  9054. var ga = gx & 0xffff;
  9055. var gb = gx >>> 16;
  9056. // Calculate high and low result of squaring
  9057. var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
  9058. var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
  9059. // High XOR low
  9060. G[i] = gh ^ gl;
  9061. }
  9062. // Calculate new state values
  9063. X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
  9064. X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0;
  9065. X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
  9066. X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0;
  9067. X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
  9068. X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0;
  9069. X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
  9070. X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0;
  9071. }
  9072. /**
  9073. * Shortcut functions to the cipher's object interface.
  9074. *
  9075. * @example
  9076. *
  9077. * var ciphertext = CryptoJS.Rabbit.encrypt(message, key, cfg);
  9078. * var plaintext = CryptoJS.Rabbit.decrypt(ciphertext, key, cfg);
  9079. */
  9080. C.Rabbit = StreamCipher._createHelper(Rabbit);
  9081. }());
  9082. return CryptoJS.Rabbit;
  9083. }));
  9084. },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],75:[function(require,module,exports){
  9085. ;(function (root, factory, undef) {
  9086. if (typeof exports === "object") {
  9087. // CommonJS
  9088. module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
  9089. }
  9090. else if (typeof define === "function" && define.amd) {
  9091. // AMD
  9092. define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
  9093. }
  9094. else {
  9095. // Global (browser)
  9096. factory(root.CryptoJS);
  9097. }
  9098. }(this, function (CryptoJS) {
  9099. (function () {
  9100. // Shortcuts
  9101. var C = CryptoJS;
  9102. var C_lib = C.lib;
  9103. var StreamCipher = C_lib.StreamCipher;
  9104. var C_algo = C.algo;
  9105. /**
  9106. * RC4 stream cipher algorithm.
  9107. */
  9108. var RC4 = C_algo.RC4 = StreamCipher.extend({
  9109. _doReset: function () {
  9110. // Shortcuts
  9111. var key = this._key;
  9112. var keyWords = key.words;
  9113. var keySigBytes = key.sigBytes;
  9114. // Init sbox
  9115. var S = this._S = [];
  9116. for (var i = 0; i < 256; i++) {
  9117. S[i] = i;
  9118. }
  9119. // Key setup
  9120. for (var i = 0, j = 0; i < 256; i++) {
  9121. var keyByteIndex = i % keySigBytes;
  9122. var keyByte = (keyWords[keyByteIndex >>> 2] >>> (24 - (keyByteIndex % 4) * 8)) & 0xff;
  9123. j = (j + S[i] + keyByte) % 256;
  9124. // Swap
  9125. var t = S[i];
  9126. S[i] = S[j];
  9127. S[j] = t;
  9128. }
  9129. // Counters
  9130. this._i = this._j = 0;
  9131. },
  9132. _doProcessBlock: function (M, offset) {
  9133. M[offset] ^= generateKeystreamWord.call(this);
  9134. },
  9135. keySize: 256/32,
  9136. ivSize: 0
  9137. });
  9138. function generateKeystreamWord() {
  9139. // Shortcuts
  9140. var S = this._S;
  9141. var i = this._i;
  9142. var j = this._j;
  9143. // Generate keystream word
  9144. var keystreamWord = 0;
  9145. for (var n = 0; n < 4; n++) {
  9146. i = (i + 1) % 256;
  9147. j = (j + S[i]) % 256;
  9148. // Swap
  9149. var t = S[i];
  9150. S[i] = S[j];
  9151. S[j] = t;
  9152. keystreamWord |= S[(S[i] + S[j]) % 256] << (24 - n * 8);
  9153. }
  9154. // Update counters
  9155. this._i = i;
  9156. this._j = j;
  9157. return keystreamWord;
  9158. }
  9159. /**
  9160. * Shortcut functions to the cipher's object interface.
  9161. *
  9162. * @example
  9163. *
  9164. * var ciphertext = CryptoJS.RC4.encrypt(message, key, cfg);
  9165. * var plaintext = CryptoJS.RC4.decrypt(ciphertext, key, cfg);
  9166. */
  9167. C.RC4 = StreamCipher._createHelper(RC4);
  9168. /**
  9169. * Modified RC4 stream cipher algorithm.
  9170. */
  9171. var RC4Drop = C_algo.RC4Drop = RC4.extend({
  9172. /**
  9173. * Configuration options.
  9174. *
  9175. * @property {number} drop The number of keystream words to drop. Default 192
  9176. */
  9177. cfg: RC4.cfg.extend({
  9178. drop: 192
  9179. }),
  9180. _doReset: function () {
  9181. RC4._doReset.call(this);
  9182. // Drop
  9183. for (var i = this.cfg.drop; i > 0; i--) {
  9184. generateKeystreamWord.call(this);
  9185. }
  9186. }
  9187. });
  9188. /**
  9189. * Shortcut functions to the cipher's object interface.
  9190. *
  9191. * @example
  9192. *
  9193. * var ciphertext = CryptoJS.RC4Drop.encrypt(message, key, cfg);
  9194. * var plaintext = CryptoJS.RC4Drop.decrypt(ciphertext, key, cfg);
  9195. */
  9196. C.RC4Drop = StreamCipher._createHelper(RC4Drop);
  9197. }());
  9198. return CryptoJS.RC4;
  9199. }));
  9200. },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],76:[function(require,module,exports){
  9201. ;(function (root, factory) {
  9202. if (typeof exports === "object") {
  9203. // CommonJS
  9204. module.exports = exports = factory(require("./core"));
  9205. }
  9206. else if (typeof define === "function" && define.amd) {
  9207. // AMD
  9208. define(["./core"], factory);
  9209. }
  9210. else {
  9211. // Global (browser)
  9212. factory(root.CryptoJS);
  9213. }
  9214. }(this, function (CryptoJS) {
  9215. /** @preserve
  9216. (c) 2012 by Cédric Mesnil. All rights reserved.
  9217. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
  9218. - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  9219. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  9220. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9221. */
  9222. (function (Math) {
  9223. // Shortcuts
  9224. var C = CryptoJS;
  9225. var C_lib = C.lib;
  9226. var WordArray = C_lib.WordArray;
  9227. var Hasher = C_lib.Hasher;
  9228. var C_algo = C.algo;
  9229. // Constants table
  9230. var _zl = WordArray.create([
  9231. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
  9232. 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
  9233. 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
  9234. 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
  9235. 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]);
  9236. var _zr = WordArray.create([
  9237. 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
  9238. 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
  9239. 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
  9240. 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
  9241. 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]);
  9242. var _sl = WordArray.create([
  9243. 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
  9244. 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
  9245. 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
  9246. 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
  9247. 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 ]);
  9248. var _sr = WordArray.create([
  9249. 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
  9250. 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
  9251. 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
  9252. 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
  9253. 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ]);
  9254. var _hl = WordArray.create([ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]);
  9255. var _hr = WordArray.create([ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]);
  9256. /**
  9257. * RIPEMD160 hash algorithm.
  9258. */
  9259. var RIPEMD160 = C_algo.RIPEMD160 = Hasher.extend({
  9260. _doReset: function () {
  9261. this._hash = WordArray.create([0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]);
  9262. },
  9263. _doProcessBlock: function (M, offset) {
  9264. // Swap endian
  9265. for (var i = 0; i < 16; i++) {
  9266. // Shortcuts
  9267. var offset_i = offset + i;
  9268. var M_offset_i = M[offset_i];
  9269. // Swap
  9270. M[offset_i] = (
  9271. (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
  9272. (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
  9273. );
  9274. }
  9275. // Shortcut
  9276. var H = this._hash.words;
  9277. var hl = _hl.words;
  9278. var hr = _hr.words;
  9279. var zl = _zl.words;
  9280. var zr = _zr.words;
  9281. var sl = _sl.words;
  9282. var sr = _sr.words;
  9283. // Working variables
  9284. var al, bl, cl, dl, el;
  9285. var ar, br, cr, dr, er;
  9286. ar = al = H[0];
  9287. br = bl = H[1];
  9288. cr = cl = H[2];
  9289. dr = dl = H[3];
  9290. er = el = H[4];
  9291. // Computation
  9292. var t;
  9293. for (var i = 0; i < 80; i += 1) {
  9294. t = (al + M[offset+zl[i]])|0;
  9295. if (i<16){
  9296. t += f1(bl,cl,dl) + hl[0];
  9297. } else if (i<32) {
  9298. t += f2(bl,cl,dl) + hl[1];
  9299. } else if (i<48) {
  9300. t += f3(bl,cl,dl) + hl[2];
  9301. } else if (i<64) {
  9302. t += f4(bl,cl,dl) + hl[3];
  9303. } else {// if (i<80) {
  9304. t += f5(bl,cl,dl) + hl[4];
  9305. }
  9306. t = t|0;
  9307. t = rotl(t,sl[i]);
  9308. t = (t+el)|0;
  9309. al = el;
  9310. el = dl;
  9311. dl = rotl(cl, 10);
  9312. cl = bl;
  9313. bl = t;
  9314. t = (ar + M[offset+zr[i]])|0;
  9315. if (i<16){
  9316. t += f5(br,cr,dr) + hr[0];
  9317. } else if (i<32) {
  9318. t += f4(br,cr,dr) + hr[1];
  9319. } else if (i<48) {
  9320. t += f3(br,cr,dr) + hr[2];
  9321. } else if (i<64) {
  9322. t += f2(br,cr,dr) + hr[3];
  9323. } else {// if (i<80) {
  9324. t += f1(br,cr,dr) + hr[4];
  9325. }
  9326. t = t|0;
  9327. t = rotl(t,sr[i]) ;
  9328. t = (t+er)|0;
  9329. ar = er;
  9330. er = dr;
  9331. dr = rotl(cr, 10);
  9332. cr = br;
  9333. br = t;
  9334. }
  9335. // Intermediate hash value
  9336. t = (H[1] + cl + dr)|0;
  9337. H[1] = (H[2] + dl + er)|0;
  9338. H[2] = (H[3] + el + ar)|0;
  9339. H[3] = (H[4] + al + br)|0;
  9340. H[4] = (H[0] + bl + cr)|0;
  9341. H[0] = t;
  9342. },
  9343. _doFinalize: function () {
  9344. // Shortcuts
  9345. var data = this._data;
  9346. var dataWords = data.words;
  9347. var nBitsTotal = this._nDataBytes * 8;
  9348. var nBitsLeft = data.sigBytes * 8;
  9349. // Add padding
  9350. dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  9351. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
  9352. (((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) |
  9353. (((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00)
  9354. );
  9355. data.sigBytes = (dataWords.length + 1) * 4;
  9356. // Hash final blocks
  9357. this._process();
  9358. // Shortcuts
  9359. var hash = this._hash;
  9360. var H = hash.words;
  9361. // Swap endian
  9362. for (var i = 0; i < 5; i++) {
  9363. // Shortcut
  9364. var H_i = H[i];
  9365. // Swap
  9366. H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
  9367. (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
  9368. }
  9369. // Return final computed hash
  9370. return hash;
  9371. },
  9372. clone: function () {
  9373. var clone = Hasher.clone.call(this);
  9374. clone._hash = this._hash.clone();
  9375. return clone;
  9376. }
  9377. });
  9378. function f1(x, y, z) {
  9379. return ((x) ^ (y) ^ (z));
  9380. }
  9381. function f2(x, y, z) {
  9382. return (((x)&(y)) | ((~x)&(z)));
  9383. }
  9384. function f3(x, y, z) {
  9385. return (((x) | (~(y))) ^ (z));
  9386. }
  9387. function f4(x, y, z) {
  9388. return (((x) & (z)) | ((y)&(~(z))));
  9389. }
  9390. function f5(x, y, z) {
  9391. return ((x) ^ ((y) |(~(z))));
  9392. }
  9393. function rotl(x,n) {
  9394. return (x<<n) | (x>>>(32-n));
  9395. }
  9396. /**
  9397. * Shortcut function to the hasher's object interface.
  9398. *
  9399. * @param {WordArray|string} message The message to hash.
  9400. *
  9401. * @return {WordArray} The hash.
  9402. *
  9403. * @static
  9404. *
  9405. * @example
  9406. *
  9407. * var hash = CryptoJS.RIPEMD160('message');
  9408. * var hash = CryptoJS.RIPEMD160(wordArray);
  9409. */
  9410. C.RIPEMD160 = Hasher._createHelper(RIPEMD160);
  9411. /**
  9412. * Shortcut function to the HMAC's object interface.
  9413. *
  9414. * @param {WordArray|string} message The message to hash.
  9415. * @param {WordArray|string} key The secret key.
  9416. *
  9417. * @return {WordArray} The HMAC.
  9418. *
  9419. * @static
  9420. *
  9421. * @example
  9422. *
  9423. * var hmac = CryptoJS.HmacRIPEMD160(message, key);
  9424. */
  9425. C.HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160);
  9426. }(Math));
  9427. return CryptoJS.RIPEMD160;
  9428. }));
  9429. },{"./core":53}],77:[function(require,module,exports){
  9430. ;(function (root, factory) {
  9431. if (typeof exports === "object") {
  9432. // CommonJS
  9433. module.exports = exports = factory(require("./core"));
  9434. }
  9435. else if (typeof define === "function" && define.amd) {
  9436. // AMD
  9437. define(["./core"], factory);
  9438. }
  9439. else {
  9440. // Global (browser)
  9441. factory(root.CryptoJS);
  9442. }
  9443. }(this, function (CryptoJS) {
  9444. (function () {
  9445. // Shortcuts
  9446. var C = CryptoJS;
  9447. var C_lib = C.lib;
  9448. var WordArray = C_lib.WordArray;
  9449. var Hasher = C_lib.Hasher;
  9450. var C_algo = C.algo;
  9451. // Reusable object
  9452. var W = [];
  9453. /**
  9454. * SHA-1 hash algorithm.
  9455. */
  9456. var SHA1 = C_algo.SHA1 = Hasher.extend({
  9457. _doReset: function () {
  9458. this._hash = new WordArray.init([
  9459. 0x67452301, 0xefcdab89,
  9460. 0x98badcfe, 0x10325476,
  9461. 0xc3d2e1f0
  9462. ]);
  9463. },
  9464. _doProcessBlock: function (M, offset) {
  9465. // Shortcut
  9466. var H = this._hash.words;
  9467. // Working variables
  9468. var a = H[0];
  9469. var b = H[1];
  9470. var c = H[2];
  9471. var d = H[3];
  9472. var e = H[4];
  9473. // Computation
  9474. for (var i = 0; i < 80; i++) {
  9475. if (i < 16) {
  9476. W[i] = M[offset + i] | 0;
  9477. } else {
  9478. var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
  9479. W[i] = (n << 1) | (n >>> 31);
  9480. }
  9481. var t = ((a << 5) | (a >>> 27)) + e + W[i];
  9482. if (i < 20) {
  9483. t += ((b & c) | (~b & d)) + 0x5a827999;
  9484. } else if (i < 40) {
  9485. t += (b ^ c ^ d) + 0x6ed9eba1;
  9486. } else if (i < 60) {
  9487. t += ((b & c) | (b & d) | (c & d)) - 0x70e44324;
  9488. } else /* if (i < 80) */ {
  9489. t += (b ^ c ^ d) - 0x359d3e2a;
  9490. }
  9491. e = d;
  9492. d = c;
  9493. c = (b << 30) | (b >>> 2);
  9494. b = a;
  9495. a = t;
  9496. }
  9497. // Intermediate hash value
  9498. H[0] = (H[0] + a) | 0;
  9499. H[1] = (H[1] + b) | 0;
  9500. H[2] = (H[2] + c) | 0;
  9501. H[3] = (H[3] + d) | 0;
  9502. H[4] = (H[4] + e) | 0;
  9503. },
  9504. _doFinalize: function () {
  9505. // Shortcuts
  9506. var data = this._data;
  9507. var dataWords = data.words;
  9508. var nBitsTotal = this._nDataBytes * 8;
  9509. var nBitsLeft = data.sigBytes * 8;
  9510. // Add padding
  9511. dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  9512. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
  9513. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
  9514. data.sigBytes = dataWords.length * 4;
  9515. // Hash final blocks
  9516. this._process();
  9517. // Return final computed hash
  9518. return this._hash;
  9519. },
  9520. clone: function () {
  9521. var clone = Hasher.clone.call(this);
  9522. clone._hash = this._hash.clone();
  9523. return clone;
  9524. }
  9525. });
  9526. /**
  9527. * Shortcut function to the hasher's object interface.
  9528. *
  9529. * @param {WordArray|string} message The message to hash.
  9530. *
  9531. * @return {WordArray} The hash.
  9532. *
  9533. * @static
  9534. *
  9535. * @example
  9536. *
  9537. * var hash = CryptoJS.SHA1('message');
  9538. * var hash = CryptoJS.SHA1(wordArray);
  9539. */
  9540. C.SHA1 = Hasher._createHelper(SHA1);
  9541. /**
  9542. * Shortcut function to the HMAC's object interface.
  9543. *
  9544. * @param {WordArray|string} message The message to hash.
  9545. * @param {WordArray|string} key The secret key.
  9546. *
  9547. * @return {WordArray} The HMAC.
  9548. *
  9549. * @static
  9550. *
  9551. * @example
  9552. *
  9553. * var hmac = CryptoJS.HmacSHA1(message, key);
  9554. */
  9555. C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
  9556. }());
  9557. return CryptoJS.SHA1;
  9558. }));
  9559. },{"./core":53}],78:[function(require,module,exports){
  9560. ;(function (root, factory, undef) {
  9561. if (typeof exports === "object") {
  9562. // CommonJS
  9563. module.exports = exports = factory(require("./core"), require("./sha256"));
  9564. }
  9565. else if (typeof define === "function" && define.amd) {
  9566. // AMD
  9567. define(["./core", "./sha256"], factory);
  9568. }
  9569. else {
  9570. // Global (browser)
  9571. factory(root.CryptoJS);
  9572. }
  9573. }(this, function (CryptoJS) {
  9574. (function () {
  9575. // Shortcuts
  9576. var C = CryptoJS;
  9577. var C_lib = C.lib;
  9578. var WordArray = C_lib.WordArray;
  9579. var C_algo = C.algo;
  9580. var SHA256 = C_algo.SHA256;
  9581. /**
  9582. * SHA-224 hash algorithm.
  9583. */
  9584. var SHA224 = C_algo.SHA224 = SHA256.extend({
  9585. _doReset: function () {
  9586. this._hash = new WordArray.init([
  9587. 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
  9588. 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4
  9589. ]);
  9590. },
  9591. _doFinalize: function () {
  9592. var hash = SHA256._doFinalize.call(this);
  9593. hash.sigBytes -= 4;
  9594. return hash;
  9595. }
  9596. });
  9597. /**
  9598. * Shortcut function to the hasher's object interface.
  9599. *
  9600. * @param {WordArray|string} message The message to hash.
  9601. *
  9602. * @return {WordArray} The hash.
  9603. *
  9604. * @static
  9605. *
  9606. * @example
  9607. *
  9608. * var hash = CryptoJS.SHA224('message');
  9609. * var hash = CryptoJS.SHA224(wordArray);
  9610. */
  9611. C.SHA224 = SHA256._createHelper(SHA224);
  9612. /**
  9613. * Shortcut function to the HMAC's object interface.
  9614. *
  9615. * @param {WordArray|string} message The message to hash.
  9616. * @param {WordArray|string} key The secret key.
  9617. *
  9618. * @return {WordArray} The HMAC.
  9619. *
  9620. * @static
  9621. *
  9622. * @example
  9623. *
  9624. * var hmac = CryptoJS.HmacSHA224(message, key);
  9625. */
  9626. C.HmacSHA224 = SHA256._createHmacHelper(SHA224);
  9627. }());
  9628. return CryptoJS.SHA224;
  9629. }));
  9630. },{"./core":53,"./sha256":79}],79:[function(require,module,exports){
  9631. ;(function (root, factory) {
  9632. if (typeof exports === "object") {
  9633. // CommonJS
  9634. module.exports = exports = factory(require("./core"));
  9635. }
  9636. else if (typeof define === "function" && define.amd) {
  9637. // AMD
  9638. define(["./core"], factory);
  9639. }
  9640. else {
  9641. // Global (browser)
  9642. factory(root.CryptoJS);
  9643. }
  9644. }(this, function (CryptoJS) {
  9645. (function (Math) {
  9646. // Shortcuts
  9647. var C = CryptoJS;
  9648. var C_lib = C.lib;
  9649. var WordArray = C_lib.WordArray;
  9650. var Hasher = C_lib.Hasher;
  9651. var C_algo = C.algo;
  9652. // Initialization and round constants tables
  9653. var H = [];
  9654. var K = [];
  9655. // Compute constants
  9656. (function () {
  9657. function isPrime(n) {
  9658. var sqrtN = Math.sqrt(n);
  9659. for (var factor = 2; factor <= sqrtN; factor++) {
  9660. if (!(n % factor)) {
  9661. return false;
  9662. }
  9663. }
  9664. return true;
  9665. }
  9666. function getFractionalBits(n) {
  9667. return ((n - (n | 0)) * 0x100000000) | 0;
  9668. }
  9669. var n = 2;
  9670. var nPrime = 0;
  9671. while (nPrime < 64) {
  9672. if (isPrime(n)) {
  9673. if (nPrime < 8) {
  9674. H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
  9675. }
  9676. K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));
  9677. nPrime++;
  9678. }
  9679. n++;
  9680. }
  9681. }());
  9682. // Reusable object
  9683. var W = [];
  9684. /**
  9685. * SHA-256 hash algorithm.
  9686. */
  9687. var SHA256 = C_algo.SHA256 = Hasher.extend({
  9688. _doReset: function () {
  9689. this._hash = new WordArray.init(H.slice(0));
  9690. },
  9691. _doProcessBlock: function (M, offset) {
  9692. // Shortcut
  9693. var H = this._hash.words;
  9694. // Working variables
  9695. var a = H[0];
  9696. var b = H[1];
  9697. var c = H[2];
  9698. var d = H[3];
  9699. var e = H[4];
  9700. var f = H[5];
  9701. var g = H[6];
  9702. var h = H[7];
  9703. // Computation
  9704. for (var i = 0; i < 64; i++) {
  9705. if (i < 16) {
  9706. W[i] = M[offset + i] | 0;
  9707. } else {
  9708. var gamma0x = W[i - 15];
  9709. var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^
  9710. ((gamma0x << 14) | (gamma0x >>> 18)) ^
  9711. (gamma0x >>> 3);
  9712. var gamma1x = W[i - 2];
  9713. var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^
  9714. ((gamma1x << 13) | (gamma1x >>> 19)) ^
  9715. (gamma1x >>> 10);
  9716. W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
  9717. }
  9718. var ch = (e & f) ^ (~e & g);
  9719. var maj = (a & b) ^ (a & c) ^ (b & c);
  9720. var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
  9721. var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25));
  9722. var t1 = h + sigma1 + ch + K[i] + W[i];
  9723. var t2 = sigma0 + maj;
  9724. h = g;
  9725. g = f;
  9726. f = e;
  9727. e = (d + t1) | 0;
  9728. d = c;
  9729. c = b;
  9730. b = a;
  9731. a = (t1 + t2) | 0;
  9732. }
  9733. // Intermediate hash value
  9734. H[0] = (H[0] + a) | 0;
  9735. H[1] = (H[1] + b) | 0;
  9736. H[2] = (H[2] + c) | 0;
  9737. H[3] = (H[3] + d) | 0;
  9738. H[4] = (H[4] + e) | 0;
  9739. H[5] = (H[5] + f) | 0;
  9740. H[6] = (H[6] + g) | 0;
  9741. H[7] = (H[7] + h) | 0;
  9742. },
  9743. _doFinalize: function () {
  9744. // Shortcuts
  9745. var data = this._data;
  9746. var dataWords = data.words;
  9747. var nBitsTotal = this._nDataBytes * 8;
  9748. var nBitsLeft = data.sigBytes * 8;
  9749. // Add padding
  9750. dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  9751. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
  9752. dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
  9753. data.sigBytes = dataWords.length * 4;
  9754. // Hash final blocks
  9755. this._process();
  9756. // Return final computed hash
  9757. return this._hash;
  9758. },
  9759. clone: function () {
  9760. var clone = Hasher.clone.call(this);
  9761. clone._hash = this._hash.clone();
  9762. return clone;
  9763. }
  9764. });
  9765. /**
  9766. * Shortcut function to the hasher's object interface.
  9767. *
  9768. * @param {WordArray|string} message The message to hash.
  9769. *
  9770. * @return {WordArray} The hash.
  9771. *
  9772. * @static
  9773. *
  9774. * @example
  9775. *
  9776. * var hash = CryptoJS.SHA256('message');
  9777. * var hash = CryptoJS.SHA256(wordArray);
  9778. */
  9779. C.SHA256 = Hasher._createHelper(SHA256);
  9780. /**
  9781. * Shortcut function to the HMAC's object interface.
  9782. *
  9783. * @param {WordArray|string} message The message to hash.
  9784. * @param {WordArray|string} key The secret key.
  9785. *
  9786. * @return {WordArray} The HMAC.
  9787. *
  9788. * @static
  9789. *
  9790. * @example
  9791. *
  9792. * var hmac = CryptoJS.HmacSHA256(message, key);
  9793. */
  9794. C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
  9795. }(Math));
  9796. return CryptoJS.SHA256;
  9797. }));
  9798. },{"./core":53}],80:[function(require,module,exports){
  9799. ;(function (root, factory, undef) {
  9800. if (typeof exports === "object") {
  9801. // CommonJS
  9802. module.exports = exports = factory(require("./core"), require("./x64-core"));
  9803. }
  9804. else if (typeof define === "function" && define.amd) {
  9805. // AMD
  9806. define(["./core", "./x64-core"], factory);
  9807. }
  9808. else {
  9809. // Global (browser)
  9810. factory(root.CryptoJS);
  9811. }
  9812. }(this, function (CryptoJS) {
  9813. (function (Math) {
  9814. // Shortcuts
  9815. var C = CryptoJS;
  9816. var C_lib = C.lib;
  9817. var WordArray = C_lib.WordArray;
  9818. var Hasher = C_lib.Hasher;
  9819. var C_x64 = C.x64;
  9820. var X64Word = C_x64.Word;
  9821. var C_algo = C.algo;
  9822. // Constants tables
  9823. var RHO_OFFSETS = [];
  9824. var PI_INDEXES = [];
  9825. var ROUND_CONSTANTS = [];
  9826. // Compute Constants
  9827. (function () {
  9828. // Compute rho offset constants
  9829. var x = 1, y = 0;
  9830. for (var t = 0; t < 24; t++) {
  9831. RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64;
  9832. var newX = y % 5;
  9833. var newY = (2 * x + 3 * y) % 5;
  9834. x = newX;
  9835. y = newY;
  9836. }
  9837. // Compute pi index constants
  9838. for (var x = 0; x < 5; x++) {
  9839. for (var y = 0; y < 5; y++) {
  9840. PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5;
  9841. }
  9842. }
  9843. // Compute round constants
  9844. var LFSR = 0x01;
  9845. for (var i = 0; i < 24; i++) {
  9846. var roundConstantMsw = 0;
  9847. var roundConstantLsw = 0;
  9848. for (var j = 0; j < 7; j++) {
  9849. if (LFSR & 0x01) {
  9850. var bitPosition = (1 << j) - 1;
  9851. if (bitPosition < 32) {
  9852. roundConstantLsw ^= 1 << bitPosition;
  9853. } else /* if (bitPosition >= 32) */ {
  9854. roundConstantMsw ^= 1 << (bitPosition - 32);
  9855. }
  9856. }
  9857. // Compute next LFSR
  9858. if (LFSR & 0x80) {
  9859. // Primitive polynomial over GF(2): x^8 + x^6 + x^5 + x^4 + 1
  9860. LFSR = (LFSR << 1) ^ 0x71;
  9861. } else {
  9862. LFSR <<= 1;
  9863. }
  9864. }
  9865. ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw);
  9866. }
  9867. }());
  9868. // Reusable objects for temporary values
  9869. var T = [];
  9870. (function () {
  9871. for (var i = 0; i < 25; i++) {
  9872. T[i] = X64Word.create();
  9873. }
  9874. }());
  9875. /**
  9876. * SHA-3 hash algorithm.
  9877. */
  9878. var SHA3 = C_algo.SHA3 = Hasher.extend({
  9879. /**
  9880. * Configuration options.
  9881. *
  9882. * @property {number} outputLength
  9883. * The desired number of bits in the output hash.
  9884. * Only values permitted are: 224, 256, 384, 512.
  9885. * Default: 512
  9886. */
  9887. cfg: Hasher.cfg.extend({
  9888. outputLength: 512
  9889. }),
  9890. _doReset: function () {
  9891. var state = this._state = []
  9892. for (var i = 0; i < 25; i++) {
  9893. state[i] = new X64Word.init();
  9894. }
  9895. this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32;
  9896. },
  9897. _doProcessBlock: function (M, offset) {
  9898. // Shortcuts
  9899. var state = this._state;
  9900. var nBlockSizeLanes = this.blockSize / 2;
  9901. // Absorb
  9902. for (var i = 0; i < nBlockSizeLanes; i++) {
  9903. // Shortcuts
  9904. var M2i = M[offset + 2 * i];
  9905. var M2i1 = M[offset + 2 * i + 1];
  9906. // Swap endian
  9907. M2i = (
  9908. (((M2i << 8) | (M2i >>> 24)) & 0x00ff00ff) |
  9909. (((M2i << 24) | (M2i >>> 8)) & 0xff00ff00)
  9910. );
  9911. M2i1 = (
  9912. (((M2i1 << 8) | (M2i1 >>> 24)) & 0x00ff00ff) |
  9913. (((M2i1 << 24) | (M2i1 >>> 8)) & 0xff00ff00)
  9914. );
  9915. // Absorb message into state
  9916. var lane = state[i];
  9917. lane.high ^= M2i1;
  9918. lane.low ^= M2i;
  9919. }
  9920. // Rounds
  9921. for (var round = 0; round < 24; round++) {
  9922. // Theta
  9923. for (var x = 0; x < 5; x++) {
  9924. // Mix column lanes
  9925. var tMsw = 0, tLsw = 0;
  9926. for (var y = 0; y < 5; y++) {
  9927. var lane = state[x + 5 * y];
  9928. tMsw ^= lane.high;
  9929. tLsw ^= lane.low;
  9930. }
  9931. // Temporary values
  9932. var Tx = T[x];
  9933. Tx.high = tMsw;
  9934. Tx.low = tLsw;
  9935. }
  9936. for (var x = 0; x < 5; x++) {
  9937. // Shortcuts
  9938. var Tx4 = T[(x + 4) % 5];
  9939. var Tx1 = T[(x + 1) % 5];
  9940. var Tx1Msw = Tx1.high;
  9941. var Tx1Lsw = Tx1.low;
  9942. // Mix surrounding columns
  9943. var tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31));
  9944. var tLsw = Tx4.low ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31));
  9945. for (var y = 0; y < 5; y++) {
  9946. var lane = state[x + 5 * y];
  9947. lane.high ^= tMsw;
  9948. lane.low ^= tLsw;
  9949. }
  9950. }
  9951. // Rho Pi
  9952. for (var laneIndex = 1; laneIndex < 25; laneIndex++) {
  9953. // Shortcuts
  9954. var lane = state[laneIndex];
  9955. var laneMsw = lane.high;
  9956. var laneLsw = lane.low;
  9957. var rhoOffset = RHO_OFFSETS[laneIndex];
  9958. // Rotate lanes
  9959. if (rhoOffset < 32) {
  9960. var tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));
  9961. var tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));
  9962. } else /* if (rhoOffset >= 32) */ {
  9963. var tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));
  9964. var tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));
  9965. }
  9966. // Transpose lanes
  9967. var TPiLane = T[PI_INDEXES[laneIndex]];
  9968. TPiLane.high = tMsw;
  9969. TPiLane.low = tLsw;
  9970. }
  9971. // Rho pi at x = y = 0
  9972. var T0 = T[0];
  9973. var state0 = state[0];
  9974. T0.high = state0.high;
  9975. T0.low = state0.low;
  9976. // Chi
  9977. for (var x = 0; x < 5; x++) {
  9978. for (var y = 0; y < 5; y++) {
  9979. // Shortcuts
  9980. var laneIndex = x + 5 * y;
  9981. var lane = state[laneIndex];
  9982. var TLane = T[laneIndex];
  9983. var Tx1Lane = T[((x + 1) % 5) + 5 * y];
  9984. var Tx2Lane = T[((x + 2) % 5) + 5 * y];
  9985. // Mix rows
  9986. lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high);
  9987. lane.low = TLane.low ^ (~Tx1Lane.low & Tx2Lane.low);
  9988. }
  9989. }
  9990. // Iota
  9991. var lane = state[0];
  9992. var roundConstant = ROUND_CONSTANTS[round];
  9993. lane.high ^= roundConstant.high;
  9994. lane.low ^= roundConstant.low;;
  9995. }
  9996. },
  9997. _doFinalize: function () {
  9998. // Shortcuts
  9999. var data = this._data;
  10000. var dataWords = data.words;
  10001. var nBitsTotal = this._nDataBytes * 8;
  10002. var nBitsLeft = data.sigBytes * 8;
  10003. var blockSizeBits = this.blockSize * 32;
  10004. // Add padding
  10005. dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32);
  10006. dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80;
  10007. data.sigBytes = dataWords.length * 4;
  10008. // Hash final blocks
  10009. this._process();
  10010. // Shortcuts
  10011. var state = this._state;
  10012. var outputLengthBytes = this.cfg.outputLength / 8;
  10013. var outputLengthLanes = outputLengthBytes / 8;
  10014. // Squeeze
  10015. var hashWords = [];
  10016. for (var i = 0; i < outputLengthLanes; i++) {
  10017. // Shortcuts
  10018. var lane = state[i];
  10019. var laneMsw = lane.high;
  10020. var laneLsw = lane.low;
  10021. // Swap endian
  10022. laneMsw = (
  10023. (((laneMsw << 8) | (laneMsw >>> 24)) & 0x00ff00ff) |
  10024. (((laneMsw << 24) | (laneMsw >>> 8)) & 0xff00ff00)
  10025. );
  10026. laneLsw = (
  10027. (((laneLsw << 8) | (laneLsw >>> 24)) & 0x00ff00ff) |
  10028. (((laneLsw << 24) | (laneLsw >>> 8)) & 0xff00ff00)
  10029. );
  10030. // Squeeze state to retrieve hash
  10031. hashWords.push(laneLsw);
  10032. hashWords.push(laneMsw);
  10033. }
  10034. // Return final computed hash
  10035. return new WordArray.init(hashWords, outputLengthBytes);
  10036. },
  10037. clone: function () {
  10038. var clone = Hasher.clone.call(this);
  10039. var state = clone._state = this._state.slice(0);
  10040. for (var i = 0; i < 25; i++) {
  10041. state[i] = state[i].clone();
  10042. }
  10043. return clone;
  10044. }
  10045. });
  10046. /**
  10047. * Shortcut function to the hasher's object interface.
  10048. *
  10049. * @param {WordArray|string} message The message to hash.
  10050. *
  10051. * @return {WordArray} The hash.
  10052. *
  10053. * @static
  10054. *
  10055. * @example
  10056. *
  10057. * var hash = CryptoJS.SHA3('message');
  10058. * var hash = CryptoJS.SHA3(wordArray);
  10059. */
  10060. C.SHA3 = Hasher._createHelper(SHA3);
  10061. /**
  10062. * Shortcut function to the HMAC's object interface.
  10063. *
  10064. * @param {WordArray|string} message The message to hash.
  10065. * @param {WordArray|string} key The secret key.
  10066. *
  10067. * @return {WordArray} The HMAC.
  10068. *
  10069. * @static
  10070. *
  10071. * @example
  10072. *
  10073. * var hmac = CryptoJS.HmacSHA3(message, key);
  10074. */
  10075. C.HmacSHA3 = Hasher._createHmacHelper(SHA3);
  10076. }(Math));
  10077. return CryptoJS.SHA3;
  10078. }));
  10079. },{"./core":53,"./x64-core":84}],81:[function(require,module,exports){
  10080. ;(function (root, factory, undef) {
  10081. if (typeof exports === "object") {
  10082. // CommonJS
  10083. module.exports = exports = factory(require("./core"), require("./x64-core"), require("./sha512"));
  10084. }
  10085. else if (typeof define === "function" && define.amd) {
  10086. // AMD
  10087. define(["./core", "./x64-core", "./sha512"], factory);
  10088. }
  10089. else {
  10090. // Global (browser)
  10091. factory(root.CryptoJS);
  10092. }
  10093. }(this, function (CryptoJS) {
  10094. (function () {
  10095. // Shortcuts
  10096. var C = CryptoJS;
  10097. var C_x64 = C.x64;
  10098. var X64Word = C_x64.Word;
  10099. var X64WordArray = C_x64.WordArray;
  10100. var C_algo = C.algo;
  10101. var SHA512 = C_algo.SHA512;
  10102. /**
  10103. * SHA-384 hash algorithm.
  10104. */
  10105. var SHA384 = C_algo.SHA384 = SHA512.extend({
  10106. _doReset: function () {
  10107. this._hash = new X64WordArray.init([
  10108. new X64Word.init(0xcbbb9d5d, 0xc1059ed8), new X64Word.init(0x629a292a, 0x367cd507),
  10109. new X64Word.init(0x9159015a, 0x3070dd17), new X64Word.init(0x152fecd8, 0xf70e5939),
  10110. new X64Word.init(0x67332667, 0xffc00b31), new X64Word.init(0x8eb44a87, 0x68581511),
  10111. new X64Word.init(0xdb0c2e0d, 0x64f98fa7), new X64Word.init(0x47b5481d, 0xbefa4fa4)
  10112. ]);
  10113. },
  10114. _doFinalize: function () {
  10115. var hash = SHA512._doFinalize.call(this);
  10116. hash.sigBytes -= 16;
  10117. return hash;
  10118. }
  10119. });
  10120. /**
  10121. * Shortcut function to the hasher's object interface.
  10122. *
  10123. * @param {WordArray|string} message The message to hash.
  10124. *
  10125. * @return {WordArray} The hash.
  10126. *
  10127. * @static
  10128. *
  10129. * @example
  10130. *
  10131. * var hash = CryptoJS.SHA384('message');
  10132. * var hash = CryptoJS.SHA384(wordArray);
  10133. */
  10134. C.SHA384 = SHA512._createHelper(SHA384);
  10135. /**
  10136. * Shortcut function to the HMAC's object interface.
  10137. *
  10138. * @param {WordArray|string} message The message to hash.
  10139. * @param {WordArray|string} key The secret key.
  10140. *
  10141. * @return {WordArray} The HMAC.
  10142. *
  10143. * @static
  10144. *
  10145. * @example
  10146. *
  10147. * var hmac = CryptoJS.HmacSHA384(message, key);
  10148. */
  10149. C.HmacSHA384 = SHA512._createHmacHelper(SHA384);
  10150. }());
  10151. return CryptoJS.SHA384;
  10152. }));
  10153. },{"./core":53,"./sha512":82,"./x64-core":84}],82:[function(require,module,exports){
  10154. ;(function (root, factory, undef) {
  10155. if (typeof exports === "object") {
  10156. // CommonJS
  10157. module.exports = exports = factory(require("./core"), require("./x64-core"));
  10158. }
  10159. else if (typeof define === "function" && define.amd) {
  10160. // AMD
  10161. define(["./core", "./x64-core"], factory);
  10162. }
  10163. else {
  10164. // Global (browser)
  10165. factory(root.CryptoJS);
  10166. }
  10167. }(this, function (CryptoJS) {
  10168. (function () {
  10169. // Shortcuts
  10170. var C = CryptoJS;
  10171. var C_lib = C.lib;
  10172. var Hasher = C_lib.Hasher;
  10173. var C_x64 = C.x64;
  10174. var X64Word = C_x64.Word;
  10175. var X64WordArray = C_x64.WordArray;
  10176. var C_algo = C.algo;
  10177. function X64Word_create() {
  10178. return X64Word.create.apply(X64Word, arguments);
  10179. }
  10180. // Constants
  10181. var K = [
  10182. X64Word_create(0x428a2f98, 0xd728ae22), X64Word_create(0x71374491, 0x23ef65cd),
  10183. X64Word_create(0xb5c0fbcf, 0xec4d3b2f), X64Word_create(0xe9b5dba5, 0x8189dbbc),
  10184. X64Word_create(0x3956c25b, 0xf348b538), X64Word_create(0x59f111f1, 0xb605d019),
  10185. X64Word_create(0x923f82a4, 0xaf194f9b), X64Word_create(0xab1c5ed5, 0xda6d8118),
  10186. X64Word_create(0xd807aa98, 0xa3030242), X64Word_create(0x12835b01, 0x45706fbe),
  10187. X64Word_create(0x243185be, 0x4ee4b28c), X64Word_create(0x550c7dc3, 0xd5ffb4e2),
  10188. X64Word_create(0x72be5d74, 0xf27b896f), X64Word_create(0x80deb1fe, 0x3b1696b1),
  10189. X64Word_create(0x9bdc06a7, 0x25c71235), X64Word_create(0xc19bf174, 0xcf692694),
  10190. X64Word_create(0xe49b69c1, 0x9ef14ad2), X64Word_create(0xefbe4786, 0x384f25e3),
  10191. X64Word_create(0x0fc19dc6, 0x8b8cd5b5), X64Word_create(0x240ca1cc, 0x77ac9c65),
  10192. X64Word_create(0x2de92c6f, 0x592b0275), X64Word_create(0x4a7484aa, 0x6ea6e483),
  10193. X64Word_create(0x5cb0a9dc, 0xbd41fbd4), X64Word_create(0x76f988da, 0x831153b5),
  10194. X64Word_create(0x983e5152, 0xee66dfab), X64Word_create(0xa831c66d, 0x2db43210),
  10195. X64Word_create(0xb00327c8, 0x98fb213f), X64Word_create(0xbf597fc7, 0xbeef0ee4),
  10196. X64Word_create(0xc6e00bf3, 0x3da88fc2), X64Word_create(0xd5a79147, 0x930aa725),
  10197. X64Word_create(0x06ca6351, 0xe003826f), X64Word_create(0x14292967, 0x0a0e6e70),
  10198. X64Word_create(0x27b70a85, 0x46d22ffc), X64Word_create(0x2e1b2138, 0x5c26c926),
  10199. X64Word_create(0x4d2c6dfc, 0x5ac42aed), X64Word_create(0x53380d13, 0x9d95b3df),
  10200. X64Word_create(0x650a7354, 0x8baf63de), X64Word_create(0x766a0abb, 0x3c77b2a8),
  10201. X64Word_create(0x81c2c92e, 0x47edaee6), X64Word_create(0x92722c85, 0x1482353b),
  10202. X64Word_create(0xa2bfe8a1, 0x4cf10364), X64Word_create(0xa81a664b, 0xbc423001),
  10203. X64Word_create(0xc24b8b70, 0xd0f89791), X64Word_create(0xc76c51a3, 0x0654be30),
  10204. X64Word_create(0xd192e819, 0xd6ef5218), X64Word_create(0xd6990624, 0x5565a910),
  10205. X64Word_create(0xf40e3585, 0x5771202a), X64Word_create(0x106aa070, 0x32bbd1b8),
  10206. X64Word_create(0x19a4c116, 0xb8d2d0c8), X64Word_create(0x1e376c08, 0x5141ab53),
  10207. X64Word_create(0x2748774c, 0xdf8eeb99), X64Word_create(0x34b0bcb5, 0xe19b48a8),
  10208. X64Word_create(0x391c0cb3, 0xc5c95a63), X64Word_create(0x4ed8aa4a, 0xe3418acb),
  10209. X64Word_create(0x5b9cca4f, 0x7763e373), X64Word_create(0x682e6ff3, 0xd6b2b8a3),
  10210. X64Word_create(0x748f82ee, 0x5defb2fc), X64Word_create(0x78a5636f, 0x43172f60),
  10211. X64Word_create(0x84c87814, 0xa1f0ab72), X64Word_create(0x8cc70208, 0x1a6439ec),
  10212. X64Word_create(0x90befffa, 0x23631e28), X64Word_create(0xa4506ceb, 0xde82bde9),
  10213. X64Word_create(0xbef9a3f7, 0xb2c67915), X64Word_create(0xc67178f2, 0xe372532b),
  10214. X64Word_create(0xca273ece, 0xea26619c), X64Word_create(0xd186b8c7, 0x21c0c207),
  10215. X64Word_create(0xeada7dd6, 0xcde0eb1e), X64Word_create(0xf57d4f7f, 0xee6ed178),
  10216. X64Word_create(0x06f067aa, 0x72176fba), X64Word_create(0x0a637dc5, 0xa2c898a6),
  10217. X64Word_create(0x113f9804, 0xbef90dae), X64Word_create(0x1b710b35, 0x131c471b),
  10218. X64Word_create(0x28db77f5, 0x23047d84), X64Word_create(0x32caab7b, 0x40c72493),
  10219. X64Word_create(0x3c9ebe0a, 0x15c9bebc), X64Word_create(0x431d67c4, 0x9c100d4c),
  10220. X64Word_create(0x4cc5d4be, 0xcb3e42b6), X64Word_create(0x597f299c, 0xfc657e2a),
  10221. X64Word_create(0x5fcb6fab, 0x3ad6faec), X64Word_create(0x6c44198c, 0x4a475817)
  10222. ];
  10223. // Reusable objects
  10224. var W = [];
  10225. (function () {
  10226. for (var i = 0; i < 80; i++) {
  10227. W[i] = X64Word_create();
  10228. }
  10229. }());
  10230. /**
  10231. * SHA-512 hash algorithm.
  10232. */
  10233. var SHA512 = C_algo.SHA512 = Hasher.extend({
  10234. _doReset: function () {
  10235. this._hash = new X64WordArray.init([
  10236. new X64Word.init(0x6a09e667, 0xf3bcc908), new X64Word.init(0xbb67ae85, 0x84caa73b),
  10237. new X64Word.init(0x3c6ef372, 0xfe94f82b), new X64Word.init(0xa54ff53a, 0x5f1d36f1),
  10238. new X64Word.init(0x510e527f, 0xade682d1), new X64Word.init(0x9b05688c, 0x2b3e6c1f),
  10239. new X64Word.init(0x1f83d9ab, 0xfb41bd6b), new X64Word.init(0x5be0cd19, 0x137e2179)
  10240. ]);
  10241. },
  10242. _doProcessBlock: function (M, offset) {
  10243. // Shortcuts
  10244. var H = this._hash.words;
  10245. var H0 = H[0];
  10246. var H1 = H[1];
  10247. var H2 = H[2];
  10248. var H3 = H[3];
  10249. var H4 = H[4];
  10250. var H5 = H[5];
  10251. var H6 = H[6];
  10252. var H7 = H[7];
  10253. var H0h = H0.high;
  10254. var H0l = H0.low;
  10255. var H1h = H1.high;
  10256. var H1l = H1.low;
  10257. var H2h = H2.high;
  10258. var H2l = H2.low;
  10259. var H3h = H3.high;
  10260. var H3l = H3.low;
  10261. var H4h = H4.high;
  10262. var H4l = H4.low;
  10263. var H5h = H5.high;
  10264. var H5l = H5.low;
  10265. var H6h = H6.high;
  10266. var H6l = H6.low;
  10267. var H7h = H7.high;
  10268. var H7l = H7.low;
  10269. // Working variables
  10270. var ah = H0h;
  10271. var al = H0l;
  10272. var bh = H1h;
  10273. var bl = H1l;
  10274. var ch = H2h;
  10275. var cl = H2l;
  10276. var dh = H3h;
  10277. var dl = H3l;
  10278. var eh = H4h;
  10279. var el = H4l;
  10280. var fh = H5h;
  10281. var fl = H5l;
  10282. var gh = H6h;
  10283. var gl = H6l;
  10284. var hh = H7h;
  10285. var hl = H7l;
  10286. // Rounds
  10287. for (var i = 0; i < 80; i++) {
  10288. // Shortcut
  10289. var Wi = W[i];
  10290. // Extend message
  10291. if (i < 16) {
  10292. var Wih = Wi.high = M[offset + i * 2] | 0;
  10293. var Wil = Wi.low = M[offset + i * 2 + 1] | 0;
  10294. } else {
  10295. // Gamma0
  10296. var gamma0x = W[i - 15];
  10297. var gamma0xh = gamma0x.high;
  10298. var gamma0xl = gamma0x.low;
  10299. var gamma0h = ((gamma0xh >>> 1) | (gamma0xl << 31)) ^ ((gamma0xh >>> 8) | (gamma0xl << 24)) ^ (gamma0xh >>> 7);
  10300. var gamma0l = ((gamma0xl >>> 1) | (gamma0xh << 31)) ^ ((gamma0xl >>> 8) | (gamma0xh << 24)) ^ ((gamma0xl >>> 7) | (gamma0xh << 25));
  10301. // Gamma1
  10302. var gamma1x = W[i - 2];
  10303. var gamma1xh = gamma1x.high;
  10304. var gamma1xl = gamma1x.low;
  10305. var gamma1h = ((gamma1xh >>> 19) | (gamma1xl << 13)) ^ ((gamma1xh << 3) | (gamma1xl >>> 29)) ^ (gamma1xh >>> 6);
  10306. var gamma1l = ((gamma1xl >>> 19) | (gamma1xh << 13)) ^ ((gamma1xl << 3) | (gamma1xh >>> 29)) ^ ((gamma1xl >>> 6) | (gamma1xh << 26));
  10307. // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
  10308. var Wi7 = W[i - 7];
  10309. var Wi7h = Wi7.high;
  10310. var Wi7l = Wi7.low;
  10311. var Wi16 = W[i - 16];
  10312. var Wi16h = Wi16.high;
  10313. var Wi16l = Wi16.low;
  10314. var Wil = gamma0l + Wi7l;
  10315. var Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0);
  10316. var Wil = Wil + gamma1l;
  10317. var Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0);
  10318. var Wil = Wil + Wi16l;
  10319. var Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0);
  10320. Wi.high = Wih;
  10321. Wi.low = Wil;
  10322. }
  10323. var chh = (eh & fh) ^ (~eh & gh);
  10324. var chl = (el & fl) ^ (~el & gl);
  10325. var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
  10326. var majl = (al & bl) ^ (al & cl) ^ (bl & cl);
  10327. var sigma0h = ((ah >>> 28) | (al << 4)) ^ ((ah << 30) | (al >>> 2)) ^ ((ah << 25) | (al >>> 7));
  10328. var sigma0l = ((al >>> 28) | (ah << 4)) ^ ((al << 30) | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7));
  10329. var sigma1h = ((eh >>> 14) | (el << 18)) ^ ((eh >>> 18) | (el << 14)) ^ ((eh << 23) | (el >>> 9));
  10330. var sigma1l = ((el >>> 14) | (eh << 18)) ^ ((el >>> 18) | (eh << 14)) ^ ((el << 23) | (eh >>> 9));
  10331. // t1 = h + sigma1 + ch + K[i] + W[i]
  10332. var Ki = K[i];
  10333. var Kih = Ki.high;
  10334. var Kil = Ki.low;
  10335. var t1l = hl + sigma1l;
  10336. var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0);
  10337. var t1l = t1l + chl;
  10338. var t1h = t1h + chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0);
  10339. var t1l = t1l + Kil;
  10340. var t1h = t1h + Kih + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0);
  10341. var t1l = t1l + Wil;
  10342. var t1h = t1h + Wih + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0);
  10343. // t2 = sigma0 + maj
  10344. var t2l = sigma0l + majl;
  10345. var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0);
  10346. // Update working variables
  10347. hh = gh;
  10348. hl = gl;
  10349. gh = fh;
  10350. gl = fl;
  10351. fh = eh;
  10352. fl = el;
  10353. el = (dl + t1l) | 0;
  10354. eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
  10355. dh = ch;
  10356. dl = cl;
  10357. ch = bh;
  10358. cl = bl;
  10359. bh = ah;
  10360. bl = al;
  10361. al = (t1l + t2l) | 0;
  10362. ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0;
  10363. }
  10364. // Intermediate hash value
  10365. H0l = H0.low = (H0l + al);
  10366. H0.high = (H0h + ah + ((H0l >>> 0) < (al >>> 0) ? 1 : 0));
  10367. H1l = H1.low = (H1l + bl);
  10368. H1.high = (H1h + bh + ((H1l >>> 0) < (bl >>> 0) ? 1 : 0));
  10369. H2l = H2.low = (H2l + cl);
  10370. H2.high = (H2h + ch + ((H2l >>> 0) < (cl >>> 0) ? 1 : 0));
  10371. H3l = H3.low = (H3l + dl);
  10372. H3.high = (H3h + dh + ((H3l >>> 0) < (dl >>> 0) ? 1 : 0));
  10373. H4l = H4.low = (H4l + el);
  10374. H4.high = (H4h + eh + ((H4l >>> 0) < (el >>> 0) ? 1 : 0));
  10375. H5l = H5.low = (H5l + fl);
  10376. H5.high = (H5h + fh + ((H5l >>> 0) < (fl >>> 0) ? 1 : 0));
  10377. H6l = H6.low = (H6l + gl);
  10378. H6.high = (H6h + gh + ((H6l >>> 0) < (gl >>> 0) ? 1 : 0));
  10379. H7l = H7.low = (H7l + hl);
  10380. H7.high = (H7h + hh + ((H7l >>> 0) < (hl >>> 0) ? 1 : 0));
  10381. },
  10382. _doFinalize: function () {
  10383. // Shortcuts
  10384. var data = this._data;
  10385. var dataWords = data.words;
  10386. var nBitsTotal = this._nDataBytes * 8;
  10387. var nBitsLeft = data.sigBytes * 8;
  10388. // Add padding
  10389. dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  10390. dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 30] = Math.floor(nBitsTotal / 0x100000000);
  10391. dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 31] = nBitsTotal;
  10392. data.sigBytes = dataWords.length * 4;
  10393. // Hash final blocks
  10394. this._process();
  10395. // Convert hash to 32-bit word array before returning
  10396. var hash = this._hash.toX32();
  10397. // Return final computed hash
  10398. return hash;
  10399. },
  10400. clone: function () {
  10401. var clone = Hasher.clone.call(this);
  10402. clone._hash = this._hash.clone();
  10403. return clone;
  10404. },
  10405. blockSize: 1024/32
  10406. });
  10407. /**
  10408. * Shortcut function to the hasher's object interface.
  10409. *
  10410. * @param {WordArray|string} message The message to hash.
  10411. *
  10412. * @return {WordArray} The hash.
  10413. *
  10414. * @static
  10415. *
  10416. * @example
  10417. *
  10418. * var hash = CryptoJS.SHA512('message');
  10419. * var hash = CryptoJS.SHA512(wordArray);
  10420. */
  10421. C.SHA512 = Hasher._createHelper(SHA512);
  10422. /**
  10423. * Shortcut function to the HMAC's object interface.
  10424. *
  10425. * @param {WordArray|string} message The message to hash.
  10426. * @param {WordArray|string} key The secret key.
  10427. *
  10428. * @return {WordArray} The HMAC.
  10429. *
  10430. * @static
  10431. *
  10432. * @example
  10433. *
  10434. * var hmac = CryptoJS.HmacSHA512(message, key);
  10435. */
  10436. C.HmacSHA512 = Hasher._createHmacHelper(SHA512);
  10437. }());
  10438. return CryptoJS.SHA512;
  10439. }));
  10440. },{"./core":53,"./x64-core":84}],83:[function(require,module,exports){
  10441. ;(function (root, factory, undef) {
  10442. if (typeof exports === "object") {
  10443. // CommonJS
  10444. module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
  10445. }
  10446. else if (typeof define === "function" && define.amd) {
  10447. // AMD
  10448. define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
  10449. }
  10450. else {
  10451. // Global (browser)
  10452. factory(root.CryptoJS);
  10453. }
  10454. }(this, function (CryptoJS) {
  10455. (function () {
  10456. // Shortcuts
  10457. var C = CryptoJS;
  10458. var C_lib = C.lib;
  10459. var WordArray = C_lib.WordArray;
  10460. var BlockCipher = C_lib.BlockCipher;
  10461. var C_algo = C.algo;
  10462. // Permuted Choice 1 constants
  10463. var PC1 = [
  10464. 57, 49, 41, 33, 25, 17, 9, 1,
  10465. 58, 50, 42, 34, 26, 18, 10, 2,
  10466. 59, 51, 43, 35, 27, 19, 11, 3,
  10467. 60, 52, 44, 36, 63, 55, 47, 39,
  10468. 31, 23, 15, 7, 62, 54, 46, 38,
  10469. 30, 22, 14, 6, 61, 53, 45, 37,
  10470. 29, 21, 13, 5, 28, 20, 12, 4
  10471. ];
  10472. // Permuted Choice 2 constants
  10473. var PC2 = [
  10474. 14, 17, 11, 24, 1, 5,
  10475. 3, 28, 15, 6, 21, 10,
  10476. 23, 19, 12, 4, 26, 8,
  10477. 16, 7, 27, 20, 13, 2,
  10478. 41, 52, 31, 37, 47, 55,
  10479. 30, 40, 51, 45, 33, 48,
  10480. 44, 49, 39, 56, 34, 53,
  10481. 46, 42, 50, 36, 29, 32
  10482. ];
  10483. // Cumulative bit shift constants
  10484. var BIT_SHIFTS = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28];
  10485. // SBOXes and round permutation constants
  10486. var SBOX_P = [
  10487. {
  10488. 0x0: 0x808200,
  10489. 0x10000000: 0x8000,
  10490. 0x20000000: 0x808002,
  10491. 0x30000000: 0x2,
  10492. 0x40000000: 0x200,
  10493. 0x50000000: 0x808202,
  10494. 0x60000000: 0x800202,
  10495. 0x70000000: 0x800000,
  10496. 0x80000000: 0x202,
  10497. 0x90000000: 0x800200,
  10498. 0xa0000000: 0x8200,
  10499. 0xb0000000: 0x808000,
  10500. 0xc0000000: 0x8002,
  10501. 0xd0000000: 0x800002,
  10502. 0xe0000000: 0x0,
  10503. 0xf0000000: 0x8202,
  10504. 0x8000000: 0x0,
  10505. 0x18000000: 0x808202,
  10506. 0x28000000: 0x8202,
  10507. 0x38000000: 0x8000,
  10508. 0x48000000: 0x808200,
  10509. 0x58000000: 0x200,
  10510. 0x68000000: 0x808002,
  10511. 0x78000000: 0x2,
  10512. 0x88000000: 0x800200,
  10513. 0x98000000: 0x8200,
  10514. 0xa8000000: 0x808000,
  10515. 0xb8000000: 0x800202,
  10516. 0xc8000000: 0x800002,
  10517. 0xd8000000: 0x8002,
  10518. 0xe8000000: 0x202,
  10519. 0xf8000000: 0x800000,
  10520. 0x1: 0x8000,
  10521. 0x10000001: 0x2,
  10522. 0x20000001: 0x808200,
  10523. 0x30000001: 0x800000,
  10524. 0x40000001: 0x808002,
  10525. 0x50000001: 0x8200,
  10526. 0x60000001: 0x200,
  10527. 0x70000001: 0x800202,
  10528. 0x80000001: 0x808202,
  10529. 0x90000001: 0x808000,
  10530. 0xa0000001: 0x800002,
  10531. 0xb0000001: 0x8202,
  10532. 0xc0000001: 0x202,
  10533. 0xd0000001: 0x800200,
  10534. 0xe0000001: 0x8002,
  10535. 0xf0000001: 0x0,
  10536. 0x8000001: 0x808202,
  10537. 0x18000001: 0x808000,
  10538. 0x28000001: 0x800000,
  10539. 0x38000001: 0x200,
  10540. 0x48000001: 0x8000,
  10541. 0x58000001: 0x800002,
  10542. 0x68000001: 0x2,
  10543. 0x78000001: 0x8202,
  10544. 0x88000001: 0x8002,
  10545. 0x98000001: 0x800202,
  10546. 0xa8000001: 0x202,
  10547. 0xb8000001: 0x808200,
  10548. 0xc8000001: 0x800200,
  10549. 0xd8000001: 0x0,
  10550. 0xe8000001: 0x8200,
  10551. 0xf8000001: 0x808002
  10552. },
  10553. {
  10554. 0x0: 0x40084010,
  10555. 0x1000000: 0x4000,
  10556. 0x2000000: 0x80000,
  10557. 0x3000000: 0x40080010,
  10558. 0x4000000: 0x40000010,
  10559. 0x5000000: 0x40084000,
  10560. 0x6000000: 0x40004000,
  10561. 0x7000000: 0x10,
  10562. 0x8000000: 0x84000,
  10563. 0x9000000: 0x40004010,
  10564. 0xa000000: 0x40000000,
  10565. 0xb000000: 0x84010,
  10566. 0xc000000: 0x80010,
  10567. 0xd000000: 0x0,
  10568. 0xe000000: 0x4010,
  10569. 0xf000000: 0x40080000,
  10570. 0x800000: 0x40004000,
  10571. 0x1800000: 0x84010,
  10572. 0x2800000: 0x10,
  10573. 0x3800000: 0x40004010,
  10574. 0x4800000: 0x40084010,
  10575. 0x5800000: 0x40000000,
  10576. 0x6800000: 0x80000,
  10577. 0x7800000: 0x40080010,
  10578. 0x8800000: 0x80010,
  10579. 0x9800000: 0x0,
  10580. 0xa800000: 0x4000,
  10581. 0xb800000: 0x40080000,
  10582. 0xc800000: 0x40000010,
  10583. 0xd800000: 0x84000,
  10584. 0xe800000: 0x40084000,
  10585. 0xf800000: 0x4010,
  10586. 0x10000000: 0x0,
  10587. 0x11000000: 0x40080010,
  10588. 0x12000000: 0x40004010,
  10589. 0x13000000: 0x40084000,
  10590. 0x14000000: 0x40080000,
  10591. 0x15000000: 0x10,
  10592. 0x16000000: 0x84010,
  10593. 0x17000000: 0x4000,
  10594. 0x18000000: 0x4010,
  10595. 0x19000000: 0x80000,
  10596. 0x1a000000: 0x80010,
  10597. 0x1b000000: 0x40000010,
  10598. 0x1c000000: 0x84000,
  10599. 0x1d000000: 0x40004000,
  10600. 0x1e000000: 0x40000000,
  10601. 0x1f000000: 0x40084010,
  10602. 0x10800000: 0x84010,
  10603. 0x11800000: 0x80000,
  10604. 0x12800000: 0x40080000,
  10605. 0x13800000: 0x4000,
  10606. 0x14800000: 0x40004000,
  10607. 0x15800000: 0x40084010,
  10608. 0x16800000: 0x10,
  10609. 0x17800000: 0x40000000,
  10610. 0x18800000: 0x40084000,
  10611. 0x19800000: 0x40000010,
  10612. 0x1a800000: 0x40004010,
  10613. 0x1b800000: 0x80010,
  10614. 0x1c800000: 0x0,
  10615. 0x1d800000: 0x4010,
  10616. 0x1e800000: 0x40080010,
  10617. 0x1f800000: 0x84000
  10618. },
  10619. {
  10620. 0x0: 0x104,
  10621. 0x100000: 0x0,
  10622. 0x200000: 0x4000100,
  10623. 0x300000: 0x10104,
  10624. 0x400000: 0x10004,
  10625. 0x500000: 0x4000004,
  10626. 0x600000: 0x4010104,
  10627. 0x700000: 0x4010000,
  10628. 0x800000: 0x4000000,
  10629. 0x900000: 0x4010100,
  10630. 0xa00000: 0x10100,
  10631. 0xb00000: 0x4010004,
  10632. 0xc00000: 0x4000104,
  10633. 0xd00000: 0x10000,
  10634. 0xe00000: 0x4,
  10635. 0xf00000: 0x100,
  10636. 0x80000: 0x4010100,
  10637. 0x180000: 0x4010004,
  10638. 0x280000: 0x0,
  10639. 0x380000: 0x4000100,
  10640. 0x480000: 0x4000004,
  10641. 0x580000: 0x10000,
  10642. 0x680000: 0x10004,
  10643. 0x780000: 0x104,
  10644. 0x880000: 0x4,
  10645. 0x980000: 0x100,
  10646. 0xa80000: 0x4010000,
  10647. 0xb80000: 0x10104,
  10648. 0xc80000: 0x10100,
  10649. 0xd80000: 0x4000104,
  10650. 0xe80000: 0x4010104,
  10651. 0xf80000: 0x4000000,
  10652. 0x1000000: 0x4010100,
  10653. 0x1100000: 0x10004,
  10654. 0x1200000: 0x10000,
  10655. 0x1300000: 0x4000100,
  10656. 0x1400000: 0x100,
  10657. 0x1500000: 0x4010104,
  10658. 0x1600000: 0x4000004,
  10659. 0x1700000: 0x0,
  10660. 0x1800000: 0x4000104,
  10661. 0x1900000: 0x4000000,
  10662. 0x1a00000: 0x4,
  10663. 0x1b00000: 0x10100,
  10664. 0x1c00000: 0x4010000,
  10665. 0x1d00000: 0x104,
  10666. 0x1e00000: 0x10104,
  10667. 0x1f00000: 0x4010004,
  10668. 0x1080000: 0x4000000,
  10669. 0x1180000: 0x104,
  10670. 0x1280000: 0x4010100,
  10671. 0x1380000: 0x0,
  10672. 0x1480000: 0x10004,
  10673. 0x1580000: 0x4000100,
  10674. 0x1680000: 0x100,
  10675. 0x1780000: 0x4010004,
  10676. 0x1880000: 0x10000,
  10677. 0x1980000: 0x4010104,
  10678. 0x1a80000: 0x10104,
  10679. 0x1b80000: 0x4000004,
  10680. 0x1c80000: 0x4000104,
  10681. 0x1d80000: 0x4010000,
  10682. 0x1e80000: 0x4,
  10683. 0x1f80000: 0x10100
  10684. },
  10685. {
  10686. 0x0: 0x80401000,
  10687. 0x10000: 0x80001040,
  10688. 0x20000: 0x401040,
  10689. 0x30000: 0x80400000,
  10690. 0x40000: 0x0,
  10691. 0x50000: 0x401000,
  10692. 0x60000: 0x80000040,
  10693. 0x70000: 0x400040,
  10694. 0x80000: 0x80000000,
  10695. 0x90000: 0x400000,
  10696. 0xa0000: 0x40,
  10697. 0xb0000: 0x80001000,
  10698. 0xc0000: 0x80400040,
  10699. 0xd0000: 0x1040,
  10700. 0xe0000: 0x1000,
  10701. 0xf0000: 0x80401040,
  10702. 0x8000: 0x80001040,
  10703. 0x18000: 0x40,
  10704. 0x28000: 0x80400040,
  10705. 0x38000: 0x80001000,
  10706. 0x48000: 0x401000,
  10707. 0x58000: 0x80401040,
  10708. 0x68000: 0x0,
  10709. 0x78000: 0x80400000,
  10710. 0x88000: 0x1000,
  10711. 0x98000: 0x80401000,
  10712. 0xa8000: 0x400000,
  10713. 0xb8000: 0x1040,
  10714. 0xc8000: 0x80000000,
  10715. 0xd8000: 0x400040,
  10716. 0xe8000: 0x401040,
  10717. 0xf8000: 0x80000040,
  10718. 0x100000: 0x400040,
  10719. 0x110000: 0x401000,
  10720. 0x120000: 0x80000040,
  10721. 0x130000: 0x0,
  10722. 0x140000: 0x1040,
  10723. 0x150000: 0x80400040,
  10724. 0x160000: 0x80401000,
  10725. 0x170000: 0x80001040,
  10726. 0x180000: 0x80401040,
  10727. 0x190000: 0x80000000,
  10728. 0x1a0000: 0x80400000,
  10729. 0x1b0000: 0x401040,
  10730. 0x1c0000: 0x80001000,
  10731. 0x1d0000: 0x400000,
  10732. 0x1e0000: 0x40,
  10733. 0x1f0000: 0x1000,
  10734. 0x108000: 0x80400000,
  10735. 0x118000: 0x80401040,
  10736. 0x128000: 0x0,
  10737. 0x138000: 0x401000,
  10738. 0x148000: 0x400040,
  10739. 0x158000: 0x80000000,
  10740. 0x168000: 0x80001040,
  10741. 0x178000: 0x40,
  10742. 0x188000: 0x80000040,
  10743. 0x198000: 0x1000,
  10744. 0x1a8000: 0x80001000,
  10745. 0x1b8000: 0x80400040,
  10746. 0x1c8000: 0x1040,
  10747. 0x1d8000: 0x80401000,
  10748. 0x1e8000: 0x400000,
  10749. 0x1f8000: 0x401040
  10750. },
  10751. {
  10752. 0x0: 0x80,
  10753. 0x1000: 0x1040000,
  10754. 0x2000: 0x40000,
  10755. 0x3000: 0x20000000,
  10756. 0x4000: 0x20040080,
  10757. 0x5000: 0x1000080,
  10758. 0x6000: 0x21000080,
  10759. 0x7000: 0x40080,
  10760. 0x8000: 0x1000000,
  10761. 0x9000: 0x20040000,
  10762. 0xa000: 0x20000080,
  10763. 0xb000: 0x21040080,
  10764. 0xc000: 0x21040000,
  10765. 0xd000: 0x0,
  10766. 0xe000: 0x1040080,
  10767. 0xf000: 0x21000000,
  10768. 0x800: 0x1040080,
  10769. 0x1800: 0x21000080,
  10770. 0x2800: 0x80,
  10771. 0x3800: 0x1040000,
  10772. 0x4800: 0x40000,
  10773. 0x5800: 0x20040080,
  10774. 0x6800: 0x21040000,
  10775. 0x7800: 0x20000000,
  10776. 0x8800: 0x20040000,
  10777. 0x9800: 0x0,
  10778. 0xa800: 0x21040080,
  10779. 0xb800: 0x1000080,
  10780. 0xc800: 0x20000080,
  10781. 0xd800: 0x21000000,
  10782. 0xe800: 0x1000000,
  10783. 0xf800: 0x40080,
  10784. 0x10000: 0x40000,
  10785. 0x11000: 0x80,
  10786. 0x12000: 0x20000000,
  10787. 0x13000: 0x21000080,
  10788. 0x14000: 0x1000080,
  10789. 0x15000: 0x21040000,
  10790. 0x16000: 0x20040080,
  10791. 0x17000: 0x1000000,
  10792. 0x18000: 0x21040080,
  10793. 0x19000: 0x21000000,
  10794. 0x1a000: 0x1040000,
  10795. 0x1b000: 0x20040000,
  10796. 0x1c000: 0x40080,
  10797. 0x1d000: 0x20000080,
  10798. 0x1e000: 0x0,
  10799. 0x1f000: 0x1040080,
  10800. 0x10800: 0x21000080,
  10801. 0x11800: 0x1000000,
  10802. 0x12800: 0x1040000,
  10803. 0x13800: 0x20040080,
  10804. 0x14800: 0x20000000,
  10805. 0x15800: 0x1040080,
  10806. 0x16800: 0x80,
  10807. 0x17800: 0x21040000,
  10808. 0x18800: 0x40080,
  10809. 0x19800: 0x21040080,
  10810. 0x1a800: 0x0,
  10811. 0x1b800: 0x21000000,
  10812. 0x1c800: 0x1000080,
  10813. 0x1d800: 0x40000,
  10814. 0x1e800: 0x20040000,
  10815. 0x1f800: 0x20000080
  10816. },
  10817. {
  10818. 0x0: 0x10000008,
  10819. 0x100: 0x2000,
  10820. 0x200: 0x10200000,
  10821. 0x300: 0x10202008,
  10822. 0x400: 0x10002000,
  10823. 0x500: 0x200000,
  10824. 0x600: 0x200008,
  10825. 0x700: 0x10000000,
  10826. 0x800: 0x0,
  10827. 0x900: 0x10002008,
  10828. 0xa00: 0x202000,
  10829. 0xb00: 0x8,
  10830. 0xc00: 0x10200008,
  10831. 0xd00: 0x202008,
  10832. 0xe00: 0x2008,
  10833. 0xf00: 0x10202000,
  10834. 0x80: 0x10200000,
  10835. 0x180: 0x10202008,
  10836. 0x280: 0x8,
  10837. 0x380: 0x200000,
  10838. 0x480: 0x202008,
  10839. 0x580: 0x10000008,
  10840. 0x680: 0x10002000,
  10841. 0x780: 0x2008,
  10842. 0x880: 0x200008,
  10843. 0x980: 0x2000,
  10844. 0xa80: 0x10002008,
  10845. 0xb80: 0x10200008,
  10846. 0xc80: 0x0,
  10847. 0xd80: 0x10202000,
  10848. 0xe80: 0x202000,
  10849. 0xf80: 0x10000000,
  10850. 0x1000: 0x10002000,
  10851. 0x1100: 0x10200008,
  10852. 0x1200: 0x10202008,
  10853. 0x1300: 0x2008,
  10854. 0x1400: 0x200000,
  10855. 0x1500: 0x10000000,
  10856. 0x1600: 0x10000008,
  10857. 0x1700: 0x202000,
  10858. 0x1800: 0x202008,
  10859. 0x1900: 0x0,
  10860. 0x1a00: 0x8,
  10861. 0x1b00: 0x10200000,
  10862. 0x1c00: 0x2000,
  10863. 0x1d00: 0x10002008,
  10864. 0x1e00: 0x10202000,
  10865. 0x1f00: 0x200008,
  10866. 0x1080: 0x8,
  10867. 0x1180: 0x202000,
  10868. 0x1280: 0x200000,
  10869. 0x1380: 0x10000008,
  10870. 0x1480: 0x10002000,
  10871. 0x1580: 0x2008,
  10872. 0x1680: 0x10202008,
  10873. 0x1780: 0x10200000,
  10874. 0x1880: 0x10202000,
  10875. 0x1980: 0x10200008,
  10876. 0x1a80: 0x2000,
  10877. 0x1b80: 0x202008,
  10878. 0x1c80: 0x200008,
  10879. 0x1d80: 0x0,
  10880. 0x1e80: 0x10000000,
  10881. 0x1f80: 0x10002008
  10882. },
  10883. {
  10884. 0x0: 0x100000,
  10885. 0x10: 0x2000401,
  10886. 0x20: 0x400,
  10887. 0x30: 0x100401,
  10888. 0x40: 0x2100401,
  10889. 0x50: 0x0,
  10890. 0x60: 0x1,
  10891. 0x70: 0x2100001,
  10892. 0x80: 0x2000400,
  10893. 0x90: 0x100001,
  10894. 0xa0: 0x2000001,
  10895. 0xb0: 0x2100400,
  10896. 0xc0: 0x2100000,
  10897. 0xd0: 0x401,
  10898. 0xe0: 0x100400,
  10899. 0xf0: 0x2000000,
  10900. 0x8: 0x2100001,
  10901. 0x18: 0x0,
  10902. 0x28: 0x2000401,
  10903. 0x38: 0x2100400,
  10904. 0x48: 0x100000,
  10905. 0x58: 0x2000001,
  10906. 0x68: 0x2000000,
  10907. 0x78: 0x401,
  10908. 0x88: 0x100401,
  10909. 0x98: 0x2000400,
  10910. 0xa8: 0x2100000,
  10911. 0xb8: 0x100001,
  10912. 0xc8: 0x400,
  10913. 0xd8: 0x2100401,
  10914. 0xe8: 0x1,
  10915. 0xf8: 0x100400,
  10916. 0x100: 0x2000000,
  10917. 0x110: 0x100000,
  10918. 0x120: 0x2000401,
  10919. 0x130: 0x2100001,
  10920. 0x140: 0x100001,
  10921. 0x150: 0x2000400,
  10922. 0x160: 0x2100400,
  10923. 0x170: 0x100401,
  10924. 0x180: 0x401,
  10925. 0x190: 0x2100401,
  10926. 0x1a0: 0x100400,
  10927. 0x1b0: 0x1,
  10928. 0x1c0: 0x0,
  10929. 0x1d0: 0x2100000,
  10930. 0x1e0: 0x2000001,
  10931. 0x1f0: 0x400,
  10932. 0x108: 0x100400,
  10933. 0x118: 0x2000401,
  10934. 0x128: 0x2100001,
  10935. 0x138: 0x1,
  10936. 0x148: 0x2000000,
  10937. 0x158: 0x100000,
  10938. 0x168: 0x401,
  10939. 0x178: 0x2100400,
  10940. 0x188: 0x2000001,
  10941. 0x198: 0x2100000,
  10942. 0x1a8: 0x0,
  10943. 0x1b8: 0x2100401,
  10944. 0x1c8: 0x100401,
  10945. 0x1d8: 0x400,
  10946. 0x1e8: 0x2000400,
  10947. 0x1f8: 0x100001
  10948. },
  10949. {
  10950. 0x0: 0x8000820,
  10951. 0x1: 0x20000,
  10952. 0x2: 0x8000000,
  10953. 0x3: 0x20,
  10954. 0x4: 0x20020,
  10955. 0x5: 0x8020820,
  10956. 0x6: 0x8020800,
  10957. 0x7: 0x800,
  10958. 0x8: 0x8020000,
  10959. 0x9: 0x8000800,
  10960. 0xa: 0x20800,
  10961. 0xb: 0x8020020,
  10962. 0xc: 0x820,
  10963. 0xd: 0x0,
  10964. 0xe: 0x8000020,
  10965. 0xf: 0x20820,
  10966. 0x80000000: 0x800,
  10967. 0x80000001: 0x8020820,
  10968. 0x80000002: 0x8000820,
  10969. 0x80000003: 0x8000000,
  10970. 0x80000004: 0x8020000,
  10971. 0x80000005: 0x20800,
  10972. 0x80000006: 0x20820,
  10973. 0x80000007: 0x20,
  10974. 0x80000008: 0x8000020,
  10975. 0x80000009: 0x820,
  10976. 0x8000000a: 0x20020,
  10977. 0x8000000b: 0x8020800,
  10978. 0x8000000c: 0x0,
  10979. 0x8000000d: 0x8020020,
  10980. 0x8000000e: 0x8000800,
  10981. 0x8000000f: 0x20000,
  10982. 0x10: 0x20820,
  10983. 0x11: 0x8020800,
  10984. 0x12: 0x20,
  10985. 0x13: 0x800,
  10986. 0x14: 0x8000800,
  10987. 0x15: 0x8000020,
  10988. 0x16: 0x8020020,
  10989. 0x17: 0x20000,
  10990. 0x18: 0x0,
  10991. 0x19: 0x20020,
  10992. 0x1a: 0x8020000,
  10993. 0x1b: 0x8000820,
  10994. 0x1c: 0x8020820,
  10995. 0x1d: 0x20800,
  10996. 0x1e: 0x820,
  10997. 0x1f: 0x8000000,
  10998. 0x80000010: 0x20000,
  10999. 0x80000011: 0x800,
  11000. 0x80000012: 0x8020020,
  11001. 0x80000013: 0x20820,
  11002. 0x80000014: 0x20,
  11003. 0x80000015: 0x8020000,
  11004. 0x80000016: 0x8000000,
  11005. 0x80000017: 0x8000820,
  11006. 0x80000018: 0x8020820,
  11007. 0x80000019: 0x8000020,
  11008. 0x8000001a: 0x8000800,
  11009. 0x8000001b: 0x0,
  11010. 0x8000001c: 0x20800,
  11011. 0x8000001d: 0x820,
  11012. 0x8000001e: 0x20020,
  11013. 0x8000001f: 0x8020800
  11014. }
  11015. ];
  11016. // Masks that select the SBOX input
  11017. var SBOX_MASK = [
  11018. 0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000,
  11019. 0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f
  11020. ];
  11021. /**
  11022. * DES block cipher algorithm.
  11023. */
  11024. var DES = C_algo.DES = BlockCipher.extend({
  11025. _doReset: function () {
  11026. // Shortcuts
  11027. var key = this._key;
  11028. var keyWords = key.words;
  11029. // Select 56 bits according to PC1
  11030. var keyBits = [];
  11031. for (var i = 0; i < 56; i++) {
  11032. var keyBitPos = PC1[i] - 1;
  11033. keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1;
  11034. }
  11035. // Assemble 16 subkeys
  11036. var subKeys = this._subKeys = [];
  11037. for (var nSubKey = 0; nSubKey < 16; nSubKey++) {
  11038. // Create subkey
  11039. var subKey = subKeys[nSubKey] = [];
  11040. // Shortcut
  11041. var bitShift = BIT_SHIFTS[nSubKey];
  11042. // Select 48 bits according to PC2
  11043. for (var i = 0; i < 24; i++) {
  11044. // Select from the left 28 key bits
  11045. subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6);
  11046. // Select from the right 28 key bits
  11047. subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6);
  11048. }
  11049. // Since each subkey is applied to an expanded 32-bit input,
  11050. // the subkey can be broken into 8 values scaled to 32-bits,
  11051. // which allows the key to be used without expansion
  11052. subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31);
  11053. for (var i = 1; i < 7; i++) {
  11054. subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3);
  11055. }
  11056. subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27);
  11057. }
  11058. // Compute inverse subkeys
  11059. var invSubKeys = this._invSubKeys = [];
  11060. for (var i = 0; i < 16; i++) {
  11061. invSubKeys[i] = subKeys[15 - i];
  11062. }
  11063. },
  11064. encryptBlock: function (M, offset) {
  11065. this._doCryptBlock(M, offset, this._subKeys);
  11066. },
  11067. decryptBlock: function (M, offset) {
  11068. this._doCryptBlock(M, offset, this._invSubKeys);
  11069. },
  11070. _doCryptBlock: function (M, offset, subKeys) {
  11071. // Get input
  11072. this._lBlock = M[offset];
  11073. this._rBlock = M[offset + 1];
  11074. // Initial permutation
  11075. exchangeLR.call(this, 4, 0x0f0f0f0f);
  11076. exchangeLR.call(this, 16, 0x0000ffff);
  11077. exchangeRL.call(this, 2, 0x33333333);
  11078. exchangeRL.call(this, 8, 0x00ff00ff);
  11079. exchangeLR.call(this, 1, 0x55555555);
  11080. // Rounds
  11081. for (var round = 0; round < 16; round++) {
  11082. // Shortcuts
  11083. var subKey = subKeys[round];
  11084. var lBlock = this._lBlock;
  11085. var rBlock = this._rBlock;
  11086. // Feistel function
  11087. var f = 0;
  11088. for (var i = 0; i < 8; i++) {
  11089. f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0];
  11090. }
  11091. this._lBlock = rBlock;
  11092. this._rBlock = lBlock ^ f;
  11093. }
  11094. // Undo swap from last round
  11095. var t = this._lBlock;
  11096. this._lBlock = this._rBlock;
  11097. this._rBlock = t;
  11098. // Final permutation
  11099. exchangeLR.call(this, 1, 0x55555555);
  11100. exchangeRL.call(this, 8, 0x00ff00ff);
  11101. exchangeRL.call(this, 2, 0x33333333);
  11102. exchangeLR.call(this, 16, 0x0000ffff);
  11103. exchangeLR.call(this, 4, 0x0f0f0f0f);
  11104. // Set output
  11105. M[offset] = this._lBlock;
  11106. M[offset + 1] = this._rBlock;
  11107. },
  11108. keySize: 64/32,
  11109. ivSize: 64/32,
  11110. blockSize: 64/32
  11111. });
  11112. // Swap bits across the left and right words
  11113. function exchangeLR(offset, mask) {
  11114. var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask;
  11115. this._rBlock ^= t;
  11116. this._lBlock ^= t << offset;
  11117. }
  11118. function exchangeRL(offset, mask) {
  11119. var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask;
  11120. this._lBlock ^= t;
  11121. this._rBlock ^= t << offset;
  11122. }
  11123. /**
  11124. * Shortcut functions to the cipher's object interface.
  11125. *
  11126. * @example
  11127. *
  11128. * var ciphertext = CryptoJS.DES.encrypt(message, key, cfg);
  11129. * var plaintext = CryptoJS.DES.decrypt(ciphertext, key, cfg);
  11130. */
  11131. C.DES = BlockCipher._createHelper(DES);
  11132. /**
  11133. * Triple-DES block cipher algorithm.
  11134. */
  11135. var TripleDES = C_algo.TripleDES = BlockCipher.extend({
  11136. _doReset: function () {
  11137. // Shortcuts
  11138. var key = this._key;
  11139. var keyWords = key.words;
  11140. // Create DES instances
  11141. this._des1 = DES.createEncryptor(WordArray.create(keyWords.slice(0, 2)));
  11142. this._des2 = DES.createEncryptor(WordArray.create(keyWords.slice(2, 4)));
  11143. this._des3 = DES.createEncryptor(WordArray.create(keyWords.slice(4, 6)));
  11144. },
  11145. encryptBlock: function (M, offset) {
  11146. this._des1.encryptBlock(M, offset);
  11147. this._des2.decryptBlock(M, offset);
  11148. this._des3.encryptBlock(M, offset);
  11149. },
  11150. decryptBlock: function (M, offset) {
  11151. this._des3.decryptBlock(M, offset);
  11152. this._des2.encryptBlock(M, offset);
  11153. this._des1.decryptBlock(M, offset);
  11154. },
  11155. keySize: 192/32,
  11156. ivSize: 64/32,
  11157. blockSize: 64/32
  11158. });
  11159. /**
  11160. * Shortcut functions to the cipher's object interface.
  11161. *
  11162. * @example
  11163. *
  11164. * var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg);
  11165. * var plaintext = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg);
  11166. */
  11167. C.TripleDES = BlockCipher._createHelper(TripleDES);
  11168. }());
  11169. return CryptoJS.TripleDES;
  11170. }));
  11171. },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],84:[function(require,module,exports){
  11172. ;(function (root, factory) {
  11173. if (typeof exports === "object") {
  11174. // CommonJS
  11175. module.exports = exports = factory(require("./core"));
  11176. }
  11177. else if (typeof define === "function" && define.amd) {
  11178. // AMD
  11179. define(["./core"], factory);
  11180. }
  11181. else {
  11182. // Global (browser)
  11183. factory(root.CryptoJS);
  11184. }
  11185. }(this, function (CryptoJS) {
  11186. (function (undefined) {
  11187. // Shortcuts
  11188. var C = CryptoJS;
  11189. var C_lib = C.lib;
  11190. var Base = C_lib.Base;
  11191. var X32WordArray = C_lib.WordArray;
  11192. /**
  11193. * x64 namespace.
  11194. */
  11195. var C_x64 = C.x64 = {};
  11196. /**
  11197. * A 64-bit word.
  11198. */
  11199. var X64Word = C_x64.Word = Base.extend({
  11200. /**
  11201. * Initializes a newly created 64-bit word.
  11202. *
  11203. * @param {number} high The high 32 bits.
  11204. * @param {number} low The low 32 bits.
  11205. *
  11206. * @example
  11207. *
  11208. * var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607);
  11209. */
  11210. init: function (high, low) {
  11211. this.high = high;
  11212. this.low = low;
  11213. }
  11214. /**
  11215. * Bitwise NOTs this word.
  11216. *
  11217. * @return {X64Word} A new x64-Word object after negating.
  11218. *
  11219. * @example
  11220. *
  11221. * var negated = x64Word.not();
  11222. */
  11223. // not: function () {
  11224. // var high = ~this.high;
  11225. // var low = ~this.low;
  11226. // return X64Word.create(high, low);
  11227. // },
  11228. /**
  11229. * Bitwise ANDs this word with the passed word.
  11230. *
  11231. * @param {X64Word} word The x64-Word to AND with this word.
  11232. *
  11233. * @return {X64Word} A new x64-Word object after ANDing.
  11234. *
  11235. * @example
  11236. *
  11237. * var anded = x64Word.and(anotherX64Word);
  11238. */
  11239. // and: function (word) {
  11240. // var high = this.high & word.high;
  11241. // var low = this.low & word.low;
  11242. // return X64Word.create(high, low);
  11243. // },
  11244. /**
  11245. * Bitwise ORs this word with the passed word.
  11246. *
  11247. * @param {X64Word} word The x64-Word to OR with this word.
  11248. *
  11249. * @return {X64Word} A new x64-Word object after ORing.
  11250. *
  11251. * @example
  11252. *
  11253. * var ored = x64Word.or(anotherX64Word);
  11254. */
  11255. // or: function (word) {
  11256. // var high = this.high | word.high;
  11257. // var low = this.low | word.low;
  11258. // return X64Word.create(high, low);
  11259. // },
  11260. /**
  11261. * Bitwise XORs this word with the passed word.
  11262. *
  11263. * @param {X64Word} word The x64-Word to XOR with this word.
  11264. *
  11265. * @return {X64Word} A new x64-Word object after XORing.
  11266. *
  11267. * @example
  11268. *
  11269. * var xored = x64Word.xor(anotherX64Word);
  11270. */
  11271. // xor: function (word) {
  11272. // var high = this.high ^ word.high;
  11273. // var low = this.low ^ word.low;
  11274. // return X64Word.create(high, low);
  11275. // },
  11276. /**
  11277. * Shifts this word n bits to the left.
  11278. *
  11279. * @param {number} n The number of bits to shift.
  11280. *
  11281. * @return {X64Word} A new x64-Word object after shifting.
  11282. *
  11283. * @example
  11284. *
  11285. * var shifted = x64Word.shiftL(25);
  11286. */
  11287. // shiftL: function (n) {
  11288. // if (n < 32) {
  11289. // var high = (this.high << n) | (this.low >>> (32 - n));
  11290. // var low = this.low << n;
  11291. // } else {
  11292. // var high = this.low << (n - 32);
  11293. // var low = 0;
  11294. // }
  11295. // return X64Word.create(high, low);
  11296. // },
  11297. /**
  11298. * Shifts this word n bits to the right.
  11299. *
  11300. * @param {number} n The number of bits to shift.
  11301. *
  11302. * @return {X64Word} A new x64-Word object after shifting.
  11303. *
  11304. * @example
  11305. *
  11306. * var shifted = x64Word.shiftR(7);
  11307. */
  11308. // shiftR: function (n) {
  11309. // if (n < 32) {
  11310. // var low = (this.low >>> n) | (this.high << (32 - n));
  11311. // var high = this.high >>> n;
  11312. // } else {
  11313. // var low = this.high >>> (n - 32);
  11314. // var high = 0;
  11315. // }
  11316. // return X64Word.create(high, low);
  11317. // },
  11318. /**
  11319. * Rotates this word n bits to the left.
  11320. *
  11321. * @param {number} n The number of bits to rotate.
  11322. *
  11323. * @return {X64Word} A new x64-Word object after rotating.
  11324. *
  11325. * @example
  11326. *
  11327. * var rotated = x64Word.rotL(25);
  11328. */
  11329. // rotL: function (n) {
  11330. // return this.shiftL(n).or(this.shiftR(64 - n));
  11331. // },
  11332. /**
  11333. * Rotates this word n bits to the right.
  11334. *
  11335. * @param {number} n The number of bits to rotate.
  11336. *
  11337. * @return {X64Word} A new x64-Word object after rotating.
  11338. *
  11339. * @example
  11340. *
  11341. * var rotated = x64Word.rotR(7);
  11342. */
  11343. // rotR: function (n) {
  11344. // return this.shiftR(n).or(this.shiftL(64 - n));
  11345. // },
  11346. /**
  11347. * Adds this word with the passed word.
  11348. *
  11349. * @param {X64Word} word The x64-Word to add with this word.
  11350. *
  11351. * @return {X64Word} A new x64-Word object after adding.
  11352. *
  11353. * @example
  11354. *
  11355. * var added = x64Word.add(anotherX64Word);
  11356. */
  11357. // add: function (word) {
  11358. // var low = (this.low + word.low) | 0;
  11359. // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0;
  11360. // var high = (this.high + word.high + carry) | 0;
  11361. // return X64Word.create(high, low);
  11362. // }
  11363. });
  11364. /**
  11365. * An array of 64-bit words.
  11366. *
  11367. * @property {Array} words The array of CryptoJS.x64.Word objects.
  11368. * @property {number} sigBytes The number of significant bytes in this word array.
  11369. */
  11370. var X64WordArray = C_x64.WordArray = Base.extend({
  11371. /**
  11372. * Initializes a newly created word array.
  11373. *
  11374. * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects.
  11375. * @param {number} sigBytes (Optional) The number of significant bytes in the words.
  11376. *
  11377. * @example
  11378. *
  11379. * var wordArray = CryptoJS.x64.WordArray.create();
  11380. *
  11381. * var wordArray = CryptoJS.x64.WordArray.create([
  11382. * CryptoJS.x64.Word.create(0x00010203, 0x04050607),
  11383. * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
  11384. * ]);
  11385. *
  11386. * var wordArray = CryptoJS.x64.WordArray.create([
  11387. * CryptoJS.x64.Word.create(0x00010203, 0x04050607),
  11388. * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
  11389. * ], 10);
  11390. */
  11391. init: function (words, sigBytes) {
  11392. words = this.words = words || [];
  11393. if (sigBytes != undefined) {
  11394. this.sigBytes = sigBytes;
  11395. } else {
  11396. this.sigBytes = words.length * 8;
  11397. }
  11398. },
  11399. /**
  11400. * Converts this 64-bit word array to a 32-bit word array.
  11401. *
  11402. * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array.
  11403. *
  11404. * @example
  11405. *
  11406. * var x32WordArray = x64WordArray.toX32();
  11407. */
  11408. toX32: function () {
  11409. // Shortcuts
  11410. var x64Words = this.words;
  11411. var x64WordsLength = x64Words.length;
  11412. // Convert
  11413. var x32Words = [];
  11414. for (var i = 0; i < x64WordsLength; i++) {
  11415. var x64Word = x64Words[i];
  11416. x32Words.push(x64Word.high);
  11417. x32Words.push(x64Word.low);
  11418. }
  11419. return X32WordArray.create(x32Words, this.sigBytes);
  11420. },
  11421. /**
  11422. * Creates a copy of this word array.
  11423. *
  11424. * @return {X64WordArray} The clone.
  11425. *
  11426. * @example
  11427. *
  11428. * var clone = x64WordArray.clone();
  11429. */
  11430. clone: function () {
  11431. var clone = Base.clone.call(this);
  11432. // Clone "words" array
  11433. var words = clone.words = this.words.slice(0);
  11434. // Clone each X64Word object
  11435. var wordsLength = words.length;
  11436. for (var i = 0; i < wordsLength; i++) {
  11437. words[i] = words[i].clone();
  11438. }
  11439. return clone;
  11440. }
  11441. });
  11442. }());
  11443. return CryptoJS;
  11444. }));
  11445. },{"./core":53}],85:[function(require,module,exports){
  11446. /*! https://mths.be/utf8js v2.1.2 by @mathias */
  11447. ;(function(root) {
  11448. // Detect free variables `exports`
  11449. var freeExports = typeof exports == 'object' && exports;
  11450. // Detect free variable `module`
  11451. var freeModule = typeof module == 'object' && module &&
  11452. module.exports == freeExports && module;
  11453. // Detect free variable `global`, from Node.js or Browserified code,
  11454. // and use it as `root`
  11455. var freeGlobal = typeof global == 'object' && global;
  11456. if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
  11457. root = freeGlobal;
  11458. }
  11459. /*--------------------------------------------------------------------------*/
  11460. var stringFromCharCode = String.fromCharCode;
  11461. // Taken from https://mths.be/punycode
  11462. function ucs2decode(string) {
  11463. var output = [];
  11464. var counter = 0;
  11465. var length = string.length;
  11466. var value;
  11467. var extra;
  11468. while (counter < length) {
  11469. value = string.charCodeAt(counter++);
  11470. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  11471. // high surrogate, and there is a next character
  11472. extra = string.charCodeAt(counter++);
  11473. if ((extra & 0xFC00) == 0xDC00) { // low surrogate
  11474. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  11475. } else {
  11476. // unmatched surrogate; only append this code unit, in case the next
  11477. // code unit is the high surrogate of a surrogate pair
  11478. output.push(value);
  11479. counter--;
  11480. }
  11481. } else {
  11482. output.push(value);
  11483. }
  11484. }
  11485. return output;
  11486. }
  11487. // Taken from https://mths.be/punycode
  11488. function ucs2encode(array) {
  11489. var length = array.length;
  11490. var index = -1;
  11491. var value;
  11492. var output = '';
  11493. while (++index < length) {
  11494. value = array[index];
  11495. if (value > 0xFFFF) {
  11496. value -= 0x10000;
  11497. output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
  11498. value = 0xDC00 | value & 0x3FF;
  11499. }
  11500. output += stringFromCharCode(value);
  11501. }
  11502. return output;
  11503. }
  11504. function checkScalarValue(codePoint) {
  11505. if (codePoint >= 0xD800 && codePoint <= 0xDFFF) {
  11506. throw Error(
  11507. 'Lone surrogate U+' + codePoint.toString(16).toUpperCase() +
  11508. ' is not a scalar value'
  11509. );
  11510. }
  11511. }
  11512. /*--------------------------------------------------------------------------*/
  11513. function createByte(codePoint, shift) {
  11514. return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80);
  11515. }
  11516. function encodeCodePoint(codePoint) {
  11517. if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence
  11518. return stringFromCharCode(codePoint);
  11519. }
  11520. var symbol = '';
  11521. if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence
  11522. symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0);
  11523. }
  11524. else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence
  11525. checkScalarValue(codePoint);
  11526. symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0);
  11527. symbol += createByte(codePoint, 6);
  11528. }
  11529. else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence
  11530. symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0);
  11531. symbol += createByte(codePoint, 12);
  11532. symbol += createByte(codePoint, 6);
  11533. }
  11534. symbol += stringFromCharCode((codePoint & 0x3F) | 0x80);
  11535. return symbol;
  11536. }
  11537. function utf8encode(string) {
  11538. var codePoints = ucs2decode(string);
  11539. var length = codePoints.length;
  11540. var index = -1;
  11541. var codePoint;
  11542. var byteString = '';
  11543. while (++index < length) {
  11544. codePoint = codePoints[index];
  11545. byteString += encodeCodePoint(codePoint);
  11546. }
  11547. return byteString;
  11548. }
  11549. /*--------------------------------------------------------------------------*/
  11550. function readContinuationByte() {
  11551. if (byteIndex >= byteCount) {
  11552. throw Error('Invalid byte index');
  11553. }
  11554. var continuationByte = byteArray[byteIndex] & 0xFF;
  11555. byteIndex++;
  11556. if ((continuationByte & 0xC0) == 0x80) {
  11557. return continuationByte & 0x3F;
  11558. }
  11559. // If we end up here, it’s not a continuation byte
  11560. throw Error('Invalid continuation byte');
  11561. }
  11562. function decodeSymbol() {
  11563. var byte1;
  11564. var byte2;
  11565. var byte3;
  11566. var byte4;
  11567. var codePoint;
  11568. if (byteIndex > byteCount) {
  11569. throw Error('Invalid byte index');
  11570. }
  11571. if (byteIndex == byteCount) {
  11572. return false;
  11573. }
  11574. // Read first byte
  11575. byte1 = byteArray[byteIndex] & 0xFF;
  11576. byteIndex++;
  11577. // 1-byte sequence (no continuation bytes)
  11578. if ((byte1 & 0x80) == 0) {
  11579. return byte1;
  11580. }
  11581. // 2-byte sequence
  11582. if ((byte1 & 0xE0) == 0xC0) {
  11583. byte2 = readContinuationByte();
  11584. codePoint = ((byte1 & 0x1F) << 6) | byte2;
  11585. if (codePoint >= 0x80) {
  11586. return codePoint;
  11587. } else {
  11588. throw Error('Invalid continuation byte');
  11589. }
  11590. }
  11591. // 3-byte sequence (may include unpaired surrogates)
  11592. if ((byte1 & 0xF0) == 0xE0) {
  11593. byte2 = readContinuationByte();
  11594. byte3 = readContinuationByte();
  11595. codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3;
  11596. if (codePoint >= 0x0800) {
  11597. checkScalarValue(codePoint);
  11598. return codePoint;
  11599. } else {
  11600. throw Error('Invalid continuation byte');
  11601. }
  11602. }
  11603. // 4-byte sequence
  11604. if ((byte1 & 0xF8) == 0xF0) {
  11605. byte2 = readContinuationByte();
  11606. byte3 = readContinuationByte();
  11607. byte4 = readContinuationByte();
  11608. codePoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0C) |
  11609. (byte3 << 0x06) | byte4;
  11610. if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) {
  11611. return codePoint;
  11612. }
  11613. }
  11614. throw Error('Invalid UTF-8 detected');
  11615. }
  11616. var byteArray;
  11617. var byteCount;
  11618. var byteIndex;
  11619. function utf8decode(byteString) {
  11620. byteArray = ucs2decode(byteString);
  11621. byteCount = byteArray.length;
  11622. byteIndex = 0;
  11623. var codePoints = [];
  11624. var tmp;
  11625. while ((tmp = decodeSymbol()) !== false) {
  11626. codePoints.push(tmp);
  11627. }
  11628. return ucs2encode(codePoints);
  11629. }
  11630. /*--------------------------------------------------------------------------*/
  11631. var utf8 = {
  11632. 'version': '2.1.2',
  11633. 'encode': utf8encode,
  11634. 'decode': utf8decode
  11635. };
  11636. // Some AMD build optimizers, like r.js, check for specific condition patterns
  11637. // like the following:
  11638. if (
  11639. typeof define == 'function' &&
  11640. typeof define.amd == 'object' &&
  11641. define.amd
  11642. ) {
  11643. define(function() {
  11644. return utf8;
  11645. });
  11646. } else if (freeExports && !freeExports.nodeType) {
  11647. if (freeModule) { // in Node.js or RingoJS v0.8.0+
  11648. freeModule.exports = utf8;
  11649. } else { // in Narwhal or RingoJS v0.7.0-
  11650. var object = {};
  11651. var hasOwnProperty = object.hasOwnProperty;
  11652. for (var key in utf8) {
  11653. hasOwnProperty.call(utf8, key) && (freeExports[key] = utf8[key]);
  11654. }
  11655. }
  11656. } else { // in Rhino or a web browser
  11657. root.utf8 = utf8;
  11658. }
  11659. }(this));
  11660. },{}],86:[function(require,module,exports){
  11661. module.exports = XMLHttpRequest;
  11662. },{}],"bignumber.js":[function(require,module,exports){
  11663. /*! bignumber.js v2.0.7 https://github.com/MikeMcl/bignumber.js/LICENCE */
  11664. ;(function (global) {
  11665. 'use strict';
  11666. /*
  11667. bignumber.js v2.0.7
  11668. A JavaScript library for arbitrary-precision arithmetic.
  11669. https://github.com/MikeMcl/bignumber.js
  11670. Copyright (c) 2015 Michael Mclaughlin <[email protected]>
  11671. MIT Expat Licence
  11672. */
  11673. var BigNumber, crypto, parseNumeric,
  11674. isNumeric = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,
  11675. mathceil = Math.ceil,
  11676. mathfloor = Math.floor,
  11677. notBool = ' not a boolean or binary digit',
  11678. roundingMode = 'rounding mode',
  11679. tooManyDigits = 'number type has more than 15 significant digits',
  11680. ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_',
  11681. BASE = 1e14,
  11682. LOG_BASE = 14,
  11683. MAX_SAFE_INTEGER = 0x1fffffffffffff, // 2^53 - 1
  11684. // MAX_INT32 = 0x7fffffff, // 2^31 - 1
  11685. POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13],
  11686. SQRT_BASE = 1e7,
  11687. /*
  11688. * The limit on the value of DECIMAL_PLACES, TO_EXP_NEG, TO_EXP_POS, MIN_EXP, MAX_EXP, and
  11689. * the arguments to toExponential, toFixed, toFormat, and toPrecision, beyond which an
  11690. * exception is thrown (if ERRORS is true).
  11691. */
  11692. MAX = 1E9; // 0 to MAX_INT32
  11693. /*
  11694. * Create and return a BigNumber constructor.
  11695. */
  11696. function another(configObj) {
  11697. var div,
  11698. // id tracks the caller function, so its name can be included in error messages.
  11699. id = 0,
  11700. P = BigNumber.prototype,
  11701. ONE = new BigNumber(1),
  11702. /********************************* EDITABLE DEFAULTS **********************************/
  11703. /*
  11704. * The default values below must be integers within the inclusive ranges stated.
  11705. * The values can also be changed at run-time using BigNumber.config.
  11706. */
  11707. // The maximum number of decimal places for operations involving division.
  11708. DECIMAL_PLACES = 20, // 0 to MAX
  11709. /*
  11710. * The rounding mode used when rounding to the above decimal places, and when using
  11711. * toExponential, toFixed, toFormat and toPrecision, and round (default value).
  11712. * UP 0 Away from zero.
  11713. * DOWN 1 Towards zero.
  11714. * CEIL 2 Towards +Infinity.
  11715. * FLOOR 3 Towards -Infinity.
  11716. * HALF_UP 4 Towards nearest neighbour. If equidistant, up.
  11717. * HALF_DOWN 5 Towards nearest neighbour. If equidistant, down.
  11718. * HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour.
  11719. * HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity.
  11720. * HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
  11721. */
  11722. ROUNDING_MODE = 4, // 0 to 8
  11723. // EXPONENTIAL_AT : [TO_EXP_NEG , TO_EXP_POS]
  11724. // The exponent value at and beneath which toString returns exponential notation.
  11725. // Number type: -7
  11726. TO_EXP_NEG = -7, // 0 to -MAX
  11727. // The exponent value at and above which toString returns exponential notation.
  11728. // Number type: 21
  11729. TO_EXP_POS = 21, // 0 to MAX
  11730. // RANGE : [MIN_EXP, MAX_EXP]
  11731. // The minimum exponent value, beneath which underflow to zero occurs.
  11732. // Number type: -324 (5e-324)
  11733. MIN_EXP = -1e7, // -1 to -MAX
  11734. // The maximum exponent value, above which overflow to Infinity occurs.
  11735. // Number type: 308 (1.7976931348623157e+308)
  11736. // For MAX_EXP > 1e7, e.g. new BigNumber('1e100000000').plus(1) may be slow.
  11737. MAX_EXP = 1e7, // 1 to MAX
  11738. // Whether BigNumber Errors are ever thrown.
  11739. ERRORS = true, // true or false
  11740. // Change to intValidatorNoErrors if ERRORS is false.
  11741. isValidInt = intValidatorWithErrors, // intValidatorWithErrors/intValidatorNoErrors
  11742. // Whether to use cryptographically-secure random number generation, if available.
  11743. CRYPTO = false, // true or false
  11744. /*
  11745. * The modulo mode used when calculating the modulus: a mod n.
  11746. * The quotient (q = a / n) is calculated according to the corresponding rounding mode.
  11747. * The remainder (r) is calculated as: r = a - n * q.
  11748. *
  11749. * UP 0 The remainder is positive if the dividend is negative, else is negative.
  11750. * DOWN 1 The remainder has the same sign as the dividend.
  11751. * This modulo mode is commonly known as 'truncated division' and is
  11752. * equivalent to (a % n) in JavaScript.
  11753. * FLOOR 3 The remainder has the same sign as the divisor (Python %).
  11754. * HALF_EVEN 6 This modulo mode implements the IEEE 754 remainder function.
  11755. * EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)).
  11756. * The remainder is always positive.
  11757. *
  11758. * The truncated division, floored division, Euclidian division and IEEE 754 remainder
  11759. * modes are commonly used for the modulus operation.
  11760. * Although the other rounding modes can also be used, they may not give useful results.
  11761. */
  11762. MODULO_MODE = 1, // 0 to 9
  11763. // The maximum number of significant digits of the result of the toPower operation.
  11764. // If POW_PRECISION is 0, there will be unlimited significant digits.
  11765. POW_PRECISION = 100, // 0 to MAX
  11766. // The format specification used by the BigNumber.prototype.toFormat method.
  11767. FORMAT = {
  11768. decimalSeparator: '.',
  11769. groupSeparator: ',',
  11770. groupSize: 3,
  11771. secondaryGroupSize: 0,
  11772. fractionGroupSeparator: '\xA0', // non-breaking space
  11773. fractionGroupSize: 0
  11774. };
  11775. /******************************************************************************************/
  11776. // CONSTRUCTOR
  11777. /*
  11778. * The BigNumber constructor and exported function.
  11779. * Create and return a new instance of a BigNumber object.
  11780. *
  11781. * n {number|string|BigNumber} A numeric value.
  11782. * [b] {number} The base of n. Integer, 2 to 64 inclusive.
  11783. */
  11784. function BigNumber( n, b ) {
  11785. var c, e, i, num, len, str,
  11786. x = this;
  11787. // Enable constructor usage without new.
  11788. if ( !( x instanceof BigNumber ) ) {
  11789. // 'BigNumber() constructor call without new: {n}'
  11790. if (ERRORS) raise( 26, 'constructor call without new', n );
  11791. return new BigNumber( n, b );
  11792. }
  11793. // 'new BigNumber() base not an integer: {b}'
  11794. // 'new BigNumber() base out of range: {b}'
  11795. if ( b == null || !isValidInt( b, 2, 64, id, 'base' ) ) {
  11796. // Duplicate.
  11797. if ( n instanceof BigNumber ) {
  11798. x.s = n.s;
  11799. x.e = n.e;
  11800. x.c = ( n = n.c ) ? n.slice() : n;
  11801. id = 0;
  11802. return;
  11803. }
  11804. if ( ( num = typeof n == 'number' ) && n * 0 == 0 ) {
  11805. x.s = 1 / n < 0 ? ( n = -n, -1 ) : 1;
  11806. // Fast path for integers.
  11807. if ( n === ~~n ) {
  11808. for ( e = 0, i = n; i >= 10; i /= 10, e++ );
  11809. x.e = e;
  11810. x.c = [n];
  11811. id = 0;
  11812. return;
  11813. }
  11814. str = n + '';
  11815. } else {
  11816. if ( !isNumeric.test( str = n + '' ) ) return parseNumeric( x, str, num );
  11817. x.s = str.charCodeAt(0) === 45 ? ( str = str.slice(1), -1 ) : 1;
  11818. }
  11819. } else {
  11820. b = b | 0;
  11821. str = n + '';
  11822. // Ensure return value is rounded to DECIMAL_PLACES as with other bases.
  11823. // Allow exponential notation to be used with base 10 argument.
  11824. if ( b == 10 ) {
  11825. x = new BigNumber( n instanceof BigNumber ? n : str );
  11826. return round( x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE );
  11827. }
  11828. // Avoid potential interpretation of Infinity and NaN as base 44+ values.
  11829. // Any number in exponential form will fail due to the [Ee][+-].
  11830. if ( ( num = typeof n == 'number' ) && n * 0 != 0 ||
  11831. !( new RegExp( '^-?' + ( c = '[' + ALPHABET.slice( 0, b ) + ']+' ) +
  11832. '(?:\\.' + c + ')?$',b < 37 ? 'i' : '' ) ).test(str) ) {
  11833. return parseNumeric( x, str, num, b );
  11834. }
  11835. if (num) {
  11836. x.s = 1 / n < 0 ? ( str = str.slice(1), -1 ) : 1;
  11837. if ( ERRORS && str.replace( /^0\.0*|\./, '' ).length > 15 ) {
  11838. // 'new BigNumber() number type has more than 15 significant digits: {n}'
  11839. raise( id, tooManyDigits, n );
  11840. }
  11841. // Prevent later check for length on converted number.
  11842. num = false;
  11843. } else {
  11844. x.s = str.charCodeAt(0) === 45 ? ( str = str.slice(1), -1 ) : 1;
  11845. }
  11846. str = convertBase( str, 10, b, x.s );
  11847. }
  11848. // Decimal point?
  11849. if ( ( e = str.indexOf('.') ) > -1 ) str = str.replace( '.', '' );
  11850. // Exponential form?
  11851. if ( ( i = str.search( /e/i ) ) > 0 ) {
  11852. // Determine exponent.
  11853. if ( e < 0 ) e = i;
  11854. e += +str.slice( i + 1 );
  11855. str = str.substring( 0, i );
  11856. } else if ( e < 0 ) {
  11857. // Integer.
  11858. e = str.length;
  11859. }
  11860. // Determine leading zeros.
  11861. for ( i = 0; str.charCodeAt(i) === 48; i++ );
  11862. // Determine trailing zeros.
  11863. for ( len = str.length; str.charCodeAt(--len) === 48; );
  11864. str = str.slice( i, len + 1 );
  11865. if (str) {
  11866. len = str.length;
  11867. // Disallow numbers with over 15 significant digits if number type.
  11868. // 'new BigNumber() number type has more than 15 significant digits: {n}'
  11869. if ( num && ERRORS && len > 15 ) raise( id, tooManyDigits, x.s * n );
  11870. e = e - i - 1;
  11871. // Overflow?
  11872. if ( e > MAX_EXP ) {
  11873. // Infinity.
  11874. x.c = x.e = null;
  11875. // Underflow?
  11876. } else if ( e < MIN_EXP ) {
  11877. // Zero.
  11878. x.c = [ x.e = 0 ];
  11879. } else {
  11880. x.e = e;
  11881. x.c = [];
  11882. // Transform base
  11883. // e is the base 10 exponent.
  11884. // i is where to slice str to get the first element of the coefficient array.
  11885. i = ( e + 1 ) % LOG_BASE;
  11886. if ( e < 0 ) i += LOG_BASE;
  11887. if ( i < len ) {
  11888. if (i) x.c.push( +str.slice( 0, i ) );
  11889. for ( len -= LOG_BASE; i < len; ) {
  11890. x.c.push( +str.slice( i, i += LOG_BASE ) );
  11891. }
  11892. str = str.slice(i);
  11893. i = LOG_BASE - str.length;
  11894. } else {
  11895. i -= len;
  11896. }
  11897. for ( ; i--; str += '0' );
  11898. x.c.push( +str );
  11899. }
  11900. } else {
  11901. // Zero.
  11902. x.c = [ x.e = 0 ];
  11903. }
  11904. id = 0;
  11905. }
  11906. // CONSTRUCTOR PROPERTIES
  11907. BigNumber.another = another;
  11908. BigNumber.ROUND_UP = 0;
  11909. BigNumber.ROUND_DOWN = 1;
  11910. BigNumber.ROUND_CEIL = 2;
  11911. BigNumber.ROUND_FLOOR = 3;
  11912. BigNumber.ROUND_HALF_UP = 4;
  11913. BigNumber.ROUND_HALF_DOWN = 5;
  11914. BigNumber.ROUND_HALF_EVEN = 6;
  11915. BigNumber.ROUND_HALF_CEIL = 7;
  11916. BigNumber.ROUND_HALF_FLOOR = 8;
  11917. BigNumber.EUCLID = 9;
  11918. /*
  11919. * Configure infrequently-changing library-wide settings.
  11920. *
  11921. * Accept an object or an argument list, with one or many of the following properties or
  11922. * parameters respectively:
  11923. *
  11924. * DECIMAL_PLACES {number} Integer, 0 to MAX inclusive
  11925. * ROUNDING_MODE {number} Integer, 0 to 8 inclusive
  11926. * EXPONENTIAL_AT {number|number[]} Integer, -MAX to MAX inclusive or
  11927. * [integer -MAX to 0 incl., 0 to MAX incl.]
  11928. * RANGE {number|number[]} Non-zero integer, -MAX to MAX inclusive or
  11929. * [integer -MAX to -1 incl., integer 1 to MAX incl.]
  11930. * ERRORS {boolean|number} true, false, 1 or 0
  11931. * CRYPTO {boolean|number} true, false, 1 or 0
  11932. * MODULO_MODE {number} 0 to 9 inclusive
  11933. * POW_PRECISION {number} 0 to MAX inclusive
  11934. * FORMAT {object} See BigNumber.prototype.toFormat
  11935. * decimalSeparator {string}
  11936. * groupSeparator {string}
  11937. * groupSize {number}
  11938. * secondaryGroupSize {number}
  11939. * fractionGroupSeparator {string}
  11940. * fractionGroupSize {number}
  11941. *
  11942. * (The values assigned to the above FORMAT object properties are not checked for validity.)
  11943. *
  11944. * E.g.
  11945. * BigNumber.config(20, 4) is equivalent to
  11946. * BigNumber.config({ DECIMAL_PLACES : 20, ROUNDING_MODE : 4 })
  11947. *
  11948. * Ignore properties/parameters set to null or undefined.
  11949. * Return an object with the properties current values.
  11950. */
  11951. BigNumber.config = function () {
  11952. var v, p,
  11953. i = 0,
  11954. r = {},
  11955. a = arguments,
  11956. o = a[0],
  11957. has = o && typeof o == 'object'
  11958. ? function () { if ( o.hasOwnProperty(p) ) return ( v = o[p] ) != null; }
  11959. : function () { if ( a.length > i ) return ( v = a[i++] ) != null; };
  11960. // DECIMAL_PLACES {number} Integer, 0 to MAX inclusive.
  11961. // 'config() DECIMAL_PLACES not an integer: {v}'
  11962. // 'config() DECIMAL_PLACES out of range: {v}'
  11963. if ( has( p = 'DECIMAL_PLACES' ) && isValidInt( v, 0, MAX, 2, p ) ) {
  11964. DECIMAL_PLACES = v | 0;
  11965. }
  11966. r[p] = DECIMAL_PLACES;
  11967. // ROUNDING_MODE {number} Integer, 0 to 8 inclusive.
  11968. // 'config() ROUNDING_MODE not an integer: {v}'
  11969. // 'config() ROUNDING_MODE out of range: {v}'
  11970. if ( has( p = 'ROUNDING_MODE' ) && isValidInt( v, 0, 8, 2, p ) ) {
  11971. ROUNDING_MODE = v | 0;
  11972. }
  11973. r[p] = ROUNDING_MODE;
  11974. // EXPONENTIAL_AT {number|number[]}
  11975. // Integer, -MAX to MAX inclusive or [integer -MAX to 0 inclusive, 0 to MAX inclusive].
  11976. // 'config() EXPONENTIAL_AT not an integer: {v}'
  11977. // 'config() EXPONENTIAL_AT out of range: {v}'
  11978. if ( has( p = 'EXPONENTIAL_AT' ) ) {
  11979. if ( isArray(v) ) {
  11980. if ( isValidInt( v[0], -MAX, 0, 2, p ) && isValidInt( v[1], 0, MAX, 2, p ) ) {
  11981. TO_EXP_NEG = v[0] | 0;
  11982. TO_EXP_POS = v[1] | 0;
  11983. }
  11984. } else if ( isValidInt( v, -MAX, MAX, 2, p ) ) {
  11985. TO_EXP_NEG = -( TO_EXP_POS = ( v < 0 ? -v : v ) | 0 );
  11986. }
  11987. }
  11988. r[p] = [ TO_EXP_NEG, TO_EXP_POS ];
  11989. // RANGE {number|number[]} Non-zero integer, -MAX to MAX inclusive or
  11990. // [integer -MAX to -1 inclusive, integer 1 to MAX inclusive].
  11991. // 'config() RANGE not an integer: {v}'
  11992. // 'config() RANGE cannot be zero: {v}'
  11993. // 'config() RANGE out of range: {v}'
  11994. if ( has( p = 'RANGE' ) ) {
  11995. if ( isArray(v) ) {
  11996. if ( isValidInt( v[0], -MAX, -1, 2, p ) && isValidInt( v[1], 1, MAX, 2, p ) ) {
  11997. MIN_EXP = v[0] | 0;
  11998. MAX_EXP = v[1] | 0;
  11999. }
  12000. } else if ( isValidInt( v, -MAX, MAX, 2, p ) ) {
  12001. if ( v | 0 ) MIN_EXP = -( MAX_EXP = ( v < 0 ? -v : v ) | 0 );
  12002. else if (ERRORS) raise( 2, p + ' cannot be zero', v );
  12003. }
  12004. }
  12005. r[p] = [ MIN_EXP, MAX_EXP ];
  12006. // ERRORS {boolean|number} true, false, 1 or 0.
  12007. // 'config() ERRORS not a boolean or binary digit: {v}'
  12008. if ( has( p = 'ERRORS' ) ) {
  12009. if ( v === !!v || v === 1 || v === 0 ) {
  12010. id = 0;
  12011. isValidInt = ( ERRORS = !!v ) ? intValidatorWithErrors : intValidatorNoErrors;
  12012. } else if (ERRORS) {
  12013. raise( 2, p + notBool, v );
  12014. }
  12015. }
  12016. r[p] = ERRORS;
  12017. // CRYPTO {boolean|number} true, false, 1 or 0.
  12018. // 'config() CRYPTO not a boolean or binary digit: {v}'
  12019. // 'config() crypto unavailable: {crypto}'
  12020. if ( has( p = 'CRYPTO' ) ) {
  12021. if ( v === !!v || v === 1 || v === 0 ) {
  12022. CRYPTO = !!( v && crypto && typeof crypto == 'object' );
  12023. if ( v && !CRYPTO && ERRORS ) raise( 2, 'crypto unavailable', crypto );
  12024. } else if (ERRORS) {
  12025. raise( 2, p + notBool, v );
  12026. }
  12027. }
  12028. r[p] = CRYPTO;
  12029. // MODULO_MODE {number} Integer, 0 to 9 inclusive.
  12030. // 'config() MODULO_MODE not an integer: {v}'
  12031. // 'config() MODULO_MODE out of range: {v}'
  12032. if ( has( p = 'MODULO_MODE' ) && isValidInt( v, 0, 9, 2, p ) ) {
  12033. MODULO_MODE = v | 0;
  12034. }
  12035. r[p] = MODULO_MODE;
  12036. // POW_PRECISION {number} Integer, 0 to MAX inclusive.
  12037. // 'config() POW_PRECISION not an integer: {v}'
  12038. // 'config() POW_PRECISION out of range: {v}'
  12039. if ( has( p = 'POW_PRECISION' ) && isValidInt( v, 0, MAX, 2, p ) ) {
  12040. POW_PRECISION = v | 0;
  12041. }
  12042. r[p] = POW_PRECISION;
  12043. // FORMAT {object}
  12044. // 'config() FORMAT not an object: {v}'
  12045. if ( has( p = 'FORMAT' ) ) {
  12046. if ( typeof v == 'object' ) {
  12047. FORMAT = v;
  12048. } else if (ERRORS) {
  12049. raise( 2, p + ' not an object', v );
  12050. }
  12051. }
  12052. r[p] = FORMAT;
  12053. return r;
  12054. };
  12055. /*
  12056. * Return a new BigNumber whose value is the maximum of the arguments.
  12057. *
  12058. * arguments {number|string|BigNumber}
  12059. */
  12060. BigNumber.max = function () { return maxOrMin( arguments, P.lt ); };
  12061. /*
  12062. * Return a new BigNumber whose value is the minimum of the arguments.
  12063. *
  12064. * arguments {number|string|BigNumber}
  12065. */
  12066. BigNumber.min = function () { return maxOrMin( arguments, P.gt ); };
  12067. /*
  12068. * Return a new BigNumber with a random value equal to or greater than 0 and less than 1,
  12069. * and with dp, or DECIMAL_PLACES if dp is omitted, decimal places (or less if trailing
  12070. * zeros are produced).
  12071. *
  12072. * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
  12073. *
  12074. * 'random() decimal places not an integer: {dp}'
  12075. * 'random() decimal places out of range: {dp}'
  12076. * 'random() crypto unavailable: {crypto}'
  12077. */
  12078. BigNumber.random = (function () {
  12079. var pow2_53 = 0x20000000000000;
  12080. // Return a 53 bit integer n, where 0 <= n < 9007199254740992.
  12081. // Check if Math.random() produces more than 32 bits of randomness.
  12082. // If it does, assume at least 53 bits are produced, otherwise assume at least 30 bits.
  12083. // 0x40000000 is 2^30, 0x800000 is 2^23, 0x1fffff is 2^21 - 1.
  12084. var random53bitInt = (Math.random() * pow2_53) & 0x1fffff
  12085. ? function () { return mathfloor( Math.random() * pow2_53 ); }
  12086. : function () { return ((Math.random() * 0x40000000 | 0) * 0x800000) +
  12087. (Math.random() * 0x800000 | 0); };
  12088. return function (dp) {
  12089. var a, b, e, k, v,
  12090. i = 0,
  12091. c = [],
  12092. rand = new BigNumber(ONE);
  12093. dp = dp == null || !isValidInt( dp, 0, MAX, 14 ) ? DECIMAL_PLACES : dp | 0;
  12094. k = mathceil( dp / LOG_BASE );
  12095. if (CRYPTO) {
  12096. // Browsers supporting crypto.getRandomValues.
  12097. if ( crypto && crypto.getRandomValues ) {
  12098. a = crypto.getRandomValues( new Uint32Array( k *= 2 ) );
  12099. for ( ; i < k; ) {
  12100. // 53 bits:
  12101. // ((Math.pow(2, 32) - 1) * Math.pow(2, 21)).toString(2)
  12102. // 11111 11111111 11111111 11111111 11100000 00000000 00000000
  12103. // ((Math.pow(2, 32) - 1) >>> 11).toString(2)
  12104. // 11111 11111111 11111111
  12105. // 0x20000 is 2^21.
  12106. v = a[i] * 0x20000 + (a[i + 1] >>> 11);
  12107. // Rejection sampling:
  12108. // 0 <= v < 9007199254740992
  12109. // Probability that v >= 9e15, is
  12110. // 7199254740992 / 9007199254740992 ~= 0.0008, i.e. 1 in 1251
  12111. if ( v >= 9e15 ) {
  12112. b = crypto.getRandomValues( new Uint32Array(2) );
  12113. a[i] = b[0];
  12114. a[i + 1] = b[1];
  12115. } else {
  12116. // 0 <= v <= 8999999999999999
  12117. // 0 <= (v % 1e14) <= 99999999999999
  12118. c.push( v % 1e14 );
  12119. i += 2;
  12120. }
  12121. }
  12122. i = k / 2;
  12123. // Node.js supporting crypto.randomBytes.
  12124. } else if ( crypto && crypto.randomBytes ) {
  12125. // buffer
  12126. a = crypto.randomBytes( k *= 7 );
  12127. for ( ; i < k; ) {
  12128. // 0x1000000000000 is 2^48, 0x10000000000 is 2^40
  12129. // 0x100000000 is 2^32, 0x1000000 is 2^24
  12130. // 11111 11111111 11111111 11111111 11111111 11111111 11111111
  12131. // 0 <= v < 9007199254740992
  12132. v = ( ( a[i] & 31 ) * 0x1000000000000 ) + ( a[i + 1] * 0x10000000000 ) +
  12133. ( a[i + 2] * 0x100000000 ) + ( a[i + 3] * 0x1000000 ) +
  12134. ( a[i + 4] << 16 ) + ( a[i + 5] << 8 ) + a[i + 6];
  12135. if ( v >= 9e15 ) {
  12136. crypto.randomBytes(7).copy( a, i );
  12137. } else {
  12138. // 0 <= (v % 1e14) <= 99999999999999
  12139. c.push( v % 1e14 );
  12140. i += 7;
  12141. }
  12142. }
  12143. i = k / 7;
  12144. } else if (ERRORS) {
  12145. raise( 14, 'crypto unavailable', crypto );
  12146. }
  12147. }
  12148. // Use Math.random: CRYPTO is false or crypto is unavailable and ERRORS is false.
  12149. if (!i) {
  12150. for ( ; i < k; ) {
  12151. v = random53bitInt();
  12152. if ( v < 9e15 ) c[i++] = v % 1e14;
  12153. }
  12154. }
  12155. k = c[--i];
  12156. dp %= LOG_BASE;
  12157. // Convert trailing digits to zeros according to dp.
  12158. if ( k && dp ) {
  12159. v = POWS_TEN[LOG_BASE - dp];
  12160. c[i] = mathfloor( k / v ) * v;
  12161. }
  12162. // Remove trailing elements which are zero.
  12163. for ( ; c[i] === 0; c.pop(), i-- );
  12164. // Zero?
  12165. if ( i < 0 ) {
  12166. c = [ e = 0 ];
  12167. } else {
  12168. // Remove leading elements which are zero and adjust exponent accordingly.
  12169. for ( e = -1 ; c[0] === 0; c.shift(), e -= LOG_BASE);
  12170. // Count the digits of the first element of c to determine leading zeros, and...
  12171. for ( i = 1, v = c[0]; v >= 10; v /= 10, i++);
  12172. // adjust the exponent accordingly.
  12173. if ( i < LOG_BASE ) e -= LOG_BASE - i;
  12174. }
  12175. rand.e = e;
  12176. rand.c = c;
  12177. return rand;
  12178. };
  12179. })();
  12180. // PRIVATE FUNCTIONS
  12181. // Convert a numeric string of baseIn to a numeric string of baseOut.
  12182. function convertBase( str, baseOut, baseIn, sign ) {
  12183. var d, e, k, r, x, xc, y,
  12184. i = str.indexOf( '.' ),
  12185. dp = DECIMAL_PLACES,
  12186. rm = ROUNDING_MODE;
  12187. if ( baseIn < 37 ) str = str.toLowerCase();
  12188. // Non-integer.
  12189. if ( i >= 0 ) {
  12190. k = POW_PRECISION;
  12191. // Unlimited precision.
  12192. POW_PRECISION = 0;
  12193. str = str.replace( '.', '' );
  12194. y = new BigNumber(baseIn);
  12195. x = y.pow( str.length - i );
  12196. POW_PRECISION = k;
  12197. // Convert str as if an integer, then restore the fraction part by dividing the
  12198. // result by its base raised to a power.
  12199. y.c = toBaseOut( toFixedPoint( coeffToString( x.c ), x.e ), 10, baseOut );
  12200. y.e = y.c.length;
  12201. }
  12202. // Convert the number as integer.
  12203. xc = toBaseOut( str, baseIn, baseOut );
  12204. e = k = xc.length;
  12205. // Remove trailing zeros.
  12206. for ( ; xc[--k] == 0; xc.pop() );
  12207. if ( !xc[0] ) return '0';
  12208. if ( i < 0 ) {
  12209. --e;
  12210. } else {
  12211. x.c = xc;
  12212. x.e = e;
  12213. // sign is needed for correct rounding.
  12214. x.s = sign;
  12215. x = div( x, y, dp, rm, baseOut );
  12216. xc = x.c;
  12217. r = x.r;
  12218. e = x.e;
  12219. }
  12220. d = e + dp + 1;
  12221. // The rounding digit, i.e. the digit to the right of the digit that may be rounded up.
  12222. i = xc[d];
  12223. k = baseOut / 2;
  12224. r = r || d < 0 || xc[d + 1] != null;
  12225. r = rm < 4 ? ( i != null || r ) && ( rm == 0 || rm == ( x.s < 0 ? 3 : 2 ) )
  12226. : i > k || i == k &&( rm == 4 || r || rm == 6 && xc[d - 1] & 1 ||
  12227. rm == ( x.s < 0 ? 8 : 7 ) );
  12228. if ( d < 1 || !xc[0] ) {
  12229. // 1^-dp or 0.
  12230. str = r ? toFixedPoint( '1', -dp ) : '0';
  12231. } else {
  12232. xc.length = d;
  12233. if (r) {
  12234. // Rounding up may mean the previous digit has to be rounded up and so on.
  12235. for ( --baseOut; ++xc[--d] > baseOut; ) {
  12236. xc[d] = 0;
  12237. if ( !d ) {
  12238. ++e;
  12239. xc.unshift(1);
  12240. }
  12241. }
  12242. }
  12243. // Determine trailing zeros.
  12244. for ( k = xc.length; !xc[--k]; );
  12245. // E.g. [4, 11, 15] becomes 4bf.
  12246. for ( i = 0, str = ''; i <= k; str += ALPHABET.charAt( xc[i++] ) );
  12247. str = toFixedPoint( str, e );
  12248. }
  12249. // The caller will add the sign.
  12250. return str;
  12251. }
  12252. // Perform division in the specified base. Called by div and convertBase.
  12253. div = (function () {
  12254. // Assume non-zero x and k.
  12255. function multiply( x, k, base ) {
  12256. var m, temp, xlo, xhi,
  12257. carry = 0,
  12258. i = x.length,
  12259. klo = k % SQRT_BASE,
  12260. khi = k / SQRT_BASE | 0;
  12261. for ( x = x.slice(); i--; ) {
  12262. xlo = x[i] % SQRT_BASE;
  12263. xhi = x[i] / SQRT_BASE | 0;
  12264. m = khi * xlo + xhi * klo;
  12265. temp = klo * xlo + ( ( m % SQRT_BASE ) * SQRT_BASE ) + carry;
  12266. carry = ( temp / base | 0 ) + ( m / SQRT_BASE | 0 ) + khi * xhi;
  12267. x[i] = temp % base;
  12268. }
  12269. if (carry) x.unshift(carry);
  12270. return x;
  12271. }
  12272. function compare( a, b, aL, bL ) {
  12273. var i, cmp;
  12274. if ( aL != bL ) {
  12275. cmp = aL > bL ? 1 : -1;
  12276. } else {
  12277. for ( i = cmp = 0; i < aL; i++ ) {
  12278. if ( a[i] != b[i] ) {
  12279. cmp = a[i] > b[i] ? 1 : -1;
  12280. break;
  12281. }
  12282. }
  12283. }
  12284. return cmp;
  12285. }
  12286. function subtract( a, b, aL, base ) {
  12287. var i = 0;
  12288. // Subtract b from a.
  12289. for ( ; aL--; ) {
  12290. a[aL] -= i;
  12291. i = a[aL] < b[aL] ? 1 : 0;
  12292. a[aL] = i * base + a[aL] - b[aL];
  12293. }
  12294. // Remove leading zeros.
  12295. for ( ; !a[0] && a.length > 1; a.shift() );
  12296. }
  12297. // x: dividend, y: divisor.
  12298. return function ( x, y, dp, rm, base ) {
  12299. var cmp, e, i, more, n, prod, prodL, q, qc, rem, remL, rem0, xi, xL, yc0,
  12300. yL, yz,
  12301. s = x.s == y.s ? 1 : -1,
  12302. xc = x.c,
  12303. yc = y.c;
  12304. // Either NaN, Infinity or 0?
  12305. if ( !xc || !xc[0] || !yc || !yc[0] ) {
  12306. return new BigNumber(
  12307. // Return NaN if either NaN, or both Infinity or 0.
  12308. !x.s || !y.s || ( xc ? yc && xc[0] == yc[0] : !yc ) ? NaN :
  12309. // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
  12310. xc && xc[0] == 0 || !yc ? s * 0 : s / 0
  12311. );
  12312. }
  12313. q = new BigNumber(s);
  12314. qc = q.c = [];
  12315. e = x.e - y.e;
  12316. s = dp + e + 1;
  12317. if ( !base ) {
  12318. base = BASE;
  12319. e = bitFloor( x.e / LOG_BASE ) - bitFloor( y.e / LOG_BASE );
  12320. s = s / LOG_BASE | 0;
  12321. }
  12322. // Result exponent may be one less then the current value of e.
  12323. // The coefficients of the BigNumbers from convertBase may have trailing zeros.
  12324. for ( i = 0; yc[i] == ( xc[i] || 0 ); i++ );
  12325. if ( yc[i] > ( xc[i] || 0 ) ) e--;
  12326. if ( s < 0 ) {
  12327. qc.push(1);
  12328. more = true;
  12329. } else {
  12330. xL = xc.length;
  12331. yL = yc.length;
  12332. i = 0;
  12333. s += 2;
  12334. // Normalise xc and yc so highest order digit of yc is >= base / 2.
  12335. n = mathfloor( base / ( yc[0] + 1 ) );
  12336. // Not necessary, but to handle odd bases where yc[0] == ( base / 2 ) - 1.
  12337. // if ( n > 1 || n++ == 1 && yc[0] < base / 2 ) {
  12338. if ( n > 1 ) {
  12339. yc = multiply( yc, n, base );
  12340. xc = multiply( xc, n, base );
  12341. yL = yc.length;
  12342. xL = xc.length;
  12343. }
  12344. xi = yL;
  12345. rem = xc.slice( 0, yL );
  12346. remL = rem.length;
  12347. // Add zeros to make remainder as long as divisor.
  12348. for ( ; remL < yL; rem[remL++] = 0 );
  12349. yz = yc.slice();
  12350. yz.unshift(0);
  12351. yc0 = yc[0];
  12352. if ( yc[1] >= base / 2 ) yc0++;
  12353. // Not necessary, but to prevent trial digit n > base, when using base 3.
  12354. // else if ( base == 3 && yc0 == 1 ) yc0 = 1 + 1e-15;
  12355. do {
  12356. n = 0;
  12357. // Compare divisor and remainder.
  12358. cmp = compare( yc, rem, yL, remL );
  12359. // If divisor < remainder.
  12360. if ( cmp < 0 ) {
  12361. // Calculate trial digit, n.
  12362. rem0 = rem[0];
  12363. if ( yL != remL ) rem0 = rem0 * base + ( rem[1] || 0 );
  12364. // n is how many times the divisor goes into the current remainder.
  12365. n = mathfloor( rem0 / yc0 );
  12366. // Algorithm:
  12367. // 1. product = divisor * trial digit (n)
  12368. // 2. if product > remainder: product -= divisor, n--
  12369. // 3. remainder -= product
  12370. // 4. if product was < remainder at 2:
  12371. // 5. compare new remainder and divisor
  12372. // 6. If remainder > divisor: remainder -= divisor, n++
  12373. if ( n > 1 ) {
  12374. // n may be > base only when base is 3.
  12375. if (n >= base) n = base - 1;
  12376. // product = divisor * trial digit.
  12377. prod = multiply( yc, n, base );
  12378. prodL = prod.length;
  12379. remL = rem.length;
  12380. // Compare product and remainder.
  12381. // If product > remainder.
  12382. // Trial digit n too high.
  12383. // n is 1 too high about 5% of the time, and is not known to have
  12384. // ever been more than 1 too high.
  12385. while ( compare( prod, rem, prodL, remL ) == 1 ) {
  12386. n--;
  12387. // Subtract divisor from product.
  12388. subtract( prod, yL < prodL ? yz : yc, prodL, base );
  12389. prodL = prod.length;
  12390. cmp = 1;
  12391. }
  12392. } else {
  12393. // n is 0 or 1, cmp is -1.
  12394. // If n is 0, there is no need to compare yc and rem again below,
  12395. // so change cmp to 1 to avoid it.
  12396. // If n is 1, leave cmp as -1, so yc and rem are compared again.
  12397. if ( n == 0 ) {
  12398. // divisor < remainder, so n must be at least 1.
  12399. cmp = n = 1;
  12400. }
  12401. // product = divisor
  12402. prod = yc.slice();
  12403. prodL = prod.length;
  12404. }
  12405. if ( prodL < remL ) prod.unshift(0);
  12406. // Subtract product from remainder.
  12407. subtract( rem, prod, remL, base );
  12408. remL = rem.length;
  12409. // If product was < remainder.
  12410. if ( cmp == -1 ) {
  12411. // Compare divisor and new remainder.
  12412. // If divisor < new remainder, subtract divisor from remainder.
  12413. // Trial digit n too low.
  12414. // n is 1 too low about 5% of the time, and very rarely 2 too low.
  12415. while ( compare( yc, rem, yL, remL ) < 1 ) {
  12416. n++;
  12417. // Subtract divisor from remainder.
  12418. subtract( rem, yL < remL ? yz : yc, remL, base );
  12419. remL = rem.length;
  12420. }
  12421. }
  12422. } else if ( cmp === 0 ) {
  12423. n++;
  12424. rem = [0];
  12425. } // else cmp === 1 and n will be 0
  12426. // Add the next digit, n, to the result array.
  12427. qc[i++] = n;
  12428. // Update the remainder.
  12429. if ( rem[0] ) {
  12430. rem[remL++] = xc[xi] || 0;
  12431. } else {
  12432. rem = [ xc[xi] ];
  12433. remL = 1;
  12434. }
  12435. } while ( ( xi++ < xL || rem[0] != null ) && s-- );
  12436. more = rem[0] != null;
  12437. // Leading zero?
  12438. if ( !qc[0] ) qc.shift();
  12439. }
  12440. if ( base == BASE ) {
  12441. // To calculate q.e, first get the number of digits of qc[0].
  12442. for ( i = 1, s = qc[0]; s >= 10; s /= 10, i++ );
  12443. round( q, dp + ( q.e = i + e * LOG_BASE - 1 ) + 1, rm, more );
  12444. // Caller is convertBase.
  12445. } else {
  12446. q.e = e;
  12447. q.r = +more;
  12448. }
  12449. return q;
  12450. };
  12451. })();
  12452. /*
  12453. * Return a string representing the value of BigNumber n in fixed-point or exponential
  12454. * notation rounded to the specified decimal places or significant digits.
  12455. *
  12456. * n is a BigNumber.
  12457. * i is the index of the last digit required (i.e. the digit that may be rounded up).
  12458. * rm is the rounding mode.
  12459. * caller is caller id: toExponential 19, toFixed 20, toFormat 21, toPrecision 24.
  12460. */
  12461. function format( n, i, rm, caller ) {
  12462. var c0, e, ne, len, str;
  12463. rm = rm != null && isValidInt( rm, 0, 8, caller, roundingMode )
  12464. ? rm | 0 : ROUNDING_MODE;
  12465. if ( !n.c ) return n.toString();
  12466. c0 = n.c[0];
  12467. ne = n.e;
  12468. if ( i == null ) {
  12469. str = coeffToString( n.c );
  12470. str = caller == 19 || caller == 24 && ne <= TO_EXP_NEG
  12471. ? toExponential( str, ne )
  12472. : toFixedPoint( str, ne );
  12473. } else {
  12474. n = round( new BigNumber(n), i, rm );
  12475. // n.e may have changed if the value was rounded up.
  12476. e = n.e;
  12477. str = coeffToString( n.c );
  12478. len = str.length;
  12479. // toPrecision returns exponential notation if the number of significant digits
  12480. // specified is less than the number of digits necessary to represent the integer
  12481. // part of the value in fixed-point notation.
  12482. // Exponential notation.
  12483. if ( caller == 19 || caller == 24 && ( i <= e || e <= TO_EXP_NEG ) ) {
  12484. // Append zeros?
  12485. for ( ; len < i; str += '0', len++ );
  12486. str = toExponential( str, e );
  12487. // Fixed-point notation.
  12488. } else {
  12489. i -= ne;
  12490. str = toFixedPoint( str, e );
  12491. // Append zeros?
  12492. if ( e + 1 > len ) {
  12493. if ( --i > 0 ) for ( str += '.'; i--; str += '0' );
  12494. } else {
  12495. i += e - len;
  12496. if ( i > 0 ) {
  12497. if ( e + 1 == len ) str += '.';
  12498. for ( ; i--; str += '0' );
  12499. }
  12500. }
  12501. }
  12502. }
  12503. return n.s < 0 && c0 ? '-' + str : str;
  12504. }
  12505. // Handle BigNumber.max and BigNumber.min.
  12506. function maxOrMin( args, method ) {
  12507. var m, n,
  12508. i = 0;
  12509. if ( isArray( args[0] ) ) args = args[0];
  12510. m = new BigNumber( args[0] );
  12511. for ( ; ++i < args.length; ) {
  12512. n = new BigNumber( args[i] );
  12513. // If any number is NaN, return NaN.
  12514. if ( !n.s ) {
  12515. m = n;
  12516. break;
  12517. } else if ( method.call( m, n ) ) {
  12518. m = n;
  12519. }
  12520. }
  12521. return m;
  12522. }
  12523. /*
  12524. * Return true if n is an integer in range, otherwise throw.
  12525. * Use for argument validation when ERRORS is true.
  12526. */
  12527. function intValidatorWithErrors( n, min, max, caller, name ) {
  12528. if ( n < min || n > max || n != truncate(n) ) {
  12529. raise( caller, ( name || 'decimal places' ) +
  12530. ( n < min || n > max ? ' out of range' : ' not an integer' ), n );
  12531. }
  12532. return true;
  12533. }
  12534. /*
  12535. * Strip trailing zeros, calculate base 10 exponent and check against MIN_EXP and MAX_EXP.
  12536. * Called by minus, plus and times.
  12537. */
  12538. function normalise( n, c, e ) {
  12539. var i = 1,
  12540. j = c.length;
  12541. // Remove trailing zeros.
  12542. for ( ; !c[--j]; c.pop() );
  12543. // Calculate the base 10 exponent. First get the number of digits of c[0].
  12544. for ( j = c[0]; j >= 10; j /= 10, i++ );
  12545. // Overflow?
  12546. if ( ( e = i + e * LOG_BASE - 1 ) > MAX_EXP ) {
  12547. // Infinity.
  12548. n.c = n.e = null;
  12549. // Underflow?
  12550. } else if ( e < MIN_EXP ) {
  12551. // Zero.
  12552. n.c = [ n.e = 0 ];
  12553. } else {
  12554. n.e = e;
  12555. n.c = c;
  12556. }
  12557. return n;
  12558. }
  12559. // Handle values that fail the validity test in BigNumber.
  12560. parseNumeric = (function () {
  12561. var basePrefix = /^(-?)0([xbo])/i,
  12562. dotAfter = /^([^.]+)\.$/,
  12563. dotBefore = /^\.([^.]+)$/,
  12564. isInfinityOrNaN = /^-?(Infinity|NaN)$/,
  12565. whitespaceOrPlus = /^\s*\+|^\s+|\s+$/g;
  12566. return function ( x, str, num, b ) {
  12567. var base,
  12568. s = num ? str : str.replace( whitespaceOrPlus, '' );
  12569. // No exception on ±Infinity or NaN.
  12570. if ( isInfinityOrNaN.test(s) ) {
  12571. x.s = isNaN(s) ? null : s < 0 ? -1 : 1;
  12572. } else {
  12573. if ( !num ) {
  12574. // basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i
  12575. s = s.replace( basePrefix, function ( m, p1, p2 ) {
  12576. base = ( p2 = p2.toLowerCase() ) == 'x' ? 16 : p2 == 'b' ? 2 : 8;
  12577. return !b || b == base ? p1 : m;
  12578. });
  12579. if (b) {
  12580. base = b;
  12581. // E.g. '1.' to '1', '.1' to '0.1'
  12582. s = s.replace( dotAfter, '$1' ).replace( dotBefore, '0.$1' );
  12583. }
  12584. if ( str != s ) return new BigNumber( s, base );
  12585. }
  12586. // 'new BigNumber() not a number: {n}'
  12587. // 'new BigNumber() not a base {b} number: {n}'
  12588. if (ERRORS) raise( id, 'not a' + ( b ? ' base ' + b : '' ) + ' number', str );
  12589. x.s = null;
  12590. }
  12591. x.c = x.e = null;
  12592. id = 0;
  12593. }
  12594. })();
  12595. // Throw a BigNumber Error.
  12596. function raise( caller, msg, val ) {
  12597. var error = new Error( [
  12598. 'new BigNumber', // 0
  12599. 'cmp', // 1
  12600. 'config', // 2
  12601. 'div', // 3
  12602. 'divToInt', // 4
  12603. 'eq', // 5
  12604. 'gt', // 6
  12605. 'gte', // 7
  12606. 'lt', // 8
  12607. 'lte', // 9
  12608. 'minus', // 10
  12609. 'mod', // 11
  12610. 'plus', // 12
  12611. 'precision', // 13
  12612. 'random', // 14
  12613. 'round', // 15
  12614. 'shift', // 16
  12615. 'times', // 17
  12616. 'toDigits', // 18
  12617. 'toExponential', // 19
  12618. 'toFixed', // 20
  12619. 'toFormat', // 21
  12620. 'toFraction', // 22
  12621. 'pow', // 23
  12622. 'toPrecision', // 24
  12623. 'toString', // 25
  12624. 'BigNumber' // 26
  12625. ][caller] + '() ' + msg + ': ' + val );
  12626. error.name = 'BigNumber Error';
  12627. id = 0;
  12628. throw error;
  12629. }
  12630. /*
  12631. * Round x to sd significant digits using rounding mode rm. Check for over/under-flow.
  12632. * If r is truthy, it is known that there are more digits after the rounding digit.
  12633. */
  12634. function round( x, sd, rm, r ) {
  12635. var d, i, j, k, n, ni, rd,
  12636. xc = x.c,
  12637. pows10 = POWS_TEN;
  12638. // if x is not Infinity or NaN...
  12639. if (xc) {
  12640. // rd is the rounding digit, i.e. the digit after the digit that may be rounded up.
  12641. // n is a base 1e14 number, the value of the element of array x.c containing rd.
  12642. // ni is the index of n within x.c.
  12643. // d is the number of digits of n.
  12644. // i is the index of rd within n including leading zeros.
  12645. // j is the actual index of rd within n (if < 0, rd is a leading zero).
  12646. out: {
  12647. // Get the number of digits of the first element of xc.
  12648. for ( d = 1, k = xc[0]; k >= 10; k /= 10, d++ );
  12649. i = sd - d;
  12650. // If the rounding digit is in the first element of xc...
  12651. if ( i < 0 ) {
  12652. i += LOG_BASE;
  12653. j = sd;
  12654. n = xc[ ni = 0 ];
  12655. // Get the rounding digit at index j of n.
  12656. rd = n / pows10[ d - j - 1 ] % 10 | 0;
  12657. } else {
  12658. ni = mathceil( ( i + 1 ) / LOG_BASE );
  12659. if ( ni >= xc.length ) {
  12660. if (r) {
  12661. // Needed by sqrt.
  12662. for ( ; xc.length <= ni; xc.push(0) );
  12663. n = rd = 0;
  12664. d = 1;
  12665. i %= LOG_BASE;
  12666. j = i - LOG_BASE + 1;
  12667. } else {
  12668. break out;
  12669. }
  12670. } else {
  12671. n = k = xc[ni];
  12672. // Get the number of digits of n.
  12673. for ( d = 1; k >= 10; k /= 10, d++ );
  12674. // Get the index of rd within n.
  12675. i %= LOG_BASE;
  12676. // Get the index of rd within n, adjusted for leading zeros.
  12677. // The number of leading zeros of n is given by LOG_BASE - d.
  12678. j = i - LOG_BASE + d;
  12679. // Get the rounding digit at index j of n.
  12680. rd = j < 0 ? 0 : n / pows10[ d - j - 1 ] % 10 | 0;
  12681. }
  12682. }
  12683. r = r || sd < 0 ||
  12684. // Are there any non-zero digits after the rounding digit?
  12685. // The expression n % pows10[ d - j - 1 ] returns all digits of n to the right
  12686. // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
  12687. xc[ni + 1] != null || ( j < 0 ? n : n % pows10[ d - j - 1 ] );
  12688. r = rm < 4
  12689. ? ( rd || r ) && ( rm == 0 || rm == ( x.s < 0 ? 3 : 2 ) )
  12690. : rd > 5 || rd == 5 && ( rm == 4 || r || rm == 6 &&
  12691. // Check whether the digit to the left of the rounding digit is odd.
  12692. ( ( i > 0 ? j > 0 ? n / pows10[ d - j ] : 0 : xc[ni - 1] ) % 10 ) & 1 ||
  12693. rm == ( x.s < 0 ? 8 : 7 ) );
  12694. if ( sd < 1 || !xc[0] ) {
  12695. xc.length = 0;
  12696. if (r) {
  12697. // Convert sd to decimal places.
  12698. sd -= x.e + 1;
  12699. // 1, 0.1, 0.01, 0.001, 0.0001 etc.
  12700. xc[0] = pows10[ sd % LOG_BASE ];
  12701. x.e = -sd || 0;
  12702. } else {
  12703. // Zero.
  12704. xc[0] = x.e = 0;
  12705. }
  12706. return x;
  12707. }
  12708. // Remove excess digits.
  12709. if ( i == 0 ) {
  12710. xc.length = ni;
  12711. k = 1;
  12712. ni--;
  12713. } else {
  12714. xc.length = ni + 1;
  12715. k = pows10[ LOG_BASE - i ];
  12716. // E.g. 56700 becomes 56000 if 7 is the rounding digit.
  12717. // j > 0 means i > number of leading zeros of n.
  12718. xc[ni] = j > 0 ? mathfloor( n / pows10[ d - j ] % pows10[j] ) * k : 0;
  12719. }
  12720. // Round up?
  12721. if (r) {
  12722. for ( ; ; ) {
  12723. // If the digit to be rounded up is in the first element of xc...
  12724. if ( ni == 0 ) {
  12725. // i will be the length of xc[0] before k is added.
  12726. for ( i = 1, j = xc[0]; j >= 10; j /= 10, i++ );
  12727. j = xc[0] += k;
  12728. for ( k = 1; j >= 10; j /= 10, k++ );
  12729. // if i != k the length has increased.
  12730. if ( i != k ) {
  12731. x.e++;
  12732. if ( xc[0] == BASE ) xc[0] = 1;
  12733. }
  12734. break;
  12735. } else {
  12736. xc[ni] += k;
  12737. if ( xc[ni] != BASE ) break;
  12738. xc[ni--] = 0;
  12739. k = 1;
  12740. }
  12741. }
  12742. }
  12743. // Remove trailing zeros.
  12744. for ( i = xc.length; xc[--i] === 0; xc.pop() );
  12745. }
  12746. // Overflow? Infinity.
  12747. if ( x.e > MAX_EXP ) {
  12748. x.c = x.e = null;
  12749. // Underflow? Zero.
  12750. } else if ( x.e < MIN_EXP ) {
  12751. x.c = [ x.e = 0 ];
  12752. }
  12753. }
  12754. return x;
  12755. }
  12756. // PROTOTYPE/INSTANCE METHODS
  12757. /*
  12758. * Return a new BigNumber whose value is the absolute value of this BigNumber.
  12759. */
  12760. P.absoluteValue = P.abs = function () {
  12761. var x = new BigNumber(this);
  12762. if ( x.s < 0 ) x.s = 1;
  12763. return x;
  12764. };
  12765. /*
  12766. * Return a new BigNumber whose value is the value of this BigNumber rounded to a whole
  12767. * number in the direction of Infinity.
  12768. */
  12769. P.ceil = function () {
  12770. return round( new BigNumber(this), this.e + 1, 2 );
  12771. };
  12772. /*
  12773. * Return
  12774. * 1 if the value of this BigNumber is greater than the value of BigNumber(y, b),
  12775. * -1 if the value of this BigNumber is less than the value of BigNumber(y, b),
  12776. * 0 if they have the same value,
  12777. * or null if the value of either is NaN.
  12778. */
  12779. P.comparedTo = P.cmp = function ( y, b ) {
  12780. id = 1;
  12781. return compare( this, new BigNumber( y, b ) );
  12782. };
  12783. /*
  12784. * Return the number of decimal places of the value of this BigNumber, or null if the value
  12785. * of this BigNumber is ±Infinity or NaN.
  12786. */
  12787. P.decimalPlaces = P.dp = function () {
  12788. var n, v,
  12789. c = this.c;
  12790. if ( !c ) return null;
  12791. n = ( ( v = c.length - 1 ) - bitFloor( this.e / LOG_BASE ) ) * LOG_BASE;
  12792. // Subtract the number of trailing zeros of the last number.
  12793. if ( v = c[v] ) for ( ; v % 10 == 0; v /= 10, n-- );
  12794. if ( n < 0 ) n = 0;
  12795. return n;
  12796. };
  12797. /*
  12798. * n / 0 = I
  12799. * n / N = N
  12800. * n / I = 0
  12801. * 0 / n = 0
  12802. * 0 / 0 = N
  12803. * 0 / N = N
  12804. * 0 / I = 0
  12805. * N / n = N
  12806. * N / 0 = N
  12807. * N / N = N
  12808. * N / I = N
  12809. * I / n = I
  12810. * I / 0 = I
  12811. * I / N = N
  12812. * I / I = N
  12813. *
  12814. * Return a new BigNumber whose value is the value of this BigNumber divided by the value of
  12815. * BigNumber(y, b), rounded according to DECIMAL_PLACES and ROUNDING_MODE.
  12816. */
  12817. P.dividedBy = P.div = function ( y, b ) {
  12818. id = 3;
  12819. return div( this, new BigNumber( y, b ), DECIMAL_PLACES, ROUNDING_MODE );
  12820. };
  12821. /*
  12822. * Return a new BigNumber whose value is the integer part of dividing the value of this
  12823. * BigNumber by the value of BigNumber(y, b).
  12824. */
  12825. P.dividedToIntegerBy = P.divToInt = function ( y, b ) {
  12826. id = 4;
  12827. return div( this, new BigNumber( y, b ), 0, 1 );
  12828. };
  12829. /*
  12830. * Return true if the value of this BigNumber is equal to the value of BigNumber(y, b),
  12831. * otherwise returns false.
  12832. */
  12833. P.equals = P.eq = function ( y, b ) {
  12834. id = 5;
  12835. return compare( this, new BigNumber( y, b ) ) === 0;
  12836. };
  12837. /*
  12838. * Return a new BigNumber whose value is the value of this BigNumber rounded to a whole
  12839. * number in the direction of -Infinity.
  12840. */
  12841. P.floor = function () {
  12842. return round( new BigNumber(this), this.e + 1, 3 );
  12843. };
  12844. /*
  12845. * Return true if the value of this BigNumber is greater than the value of BigNumber(y, b),
  12846. * otherwise returns false.
  12847. */
  12848. P.greaterThan = P.gt = function ( y, b ) {
  12849. id = 6;
  12850. return compare( this, new BigNumber( y, b ) ) > 0;
  12851. };
  12852. /*
  12853. * Return true if the value of this BigNumber is greater than or equal to the value of
  12854. * BigNumber(y, b), otherwise returns false.
  12855. */
  12856. P.greaterThanOrEqualTo = P.gte = function ( y, b ) {
  12857. id = 7;
  12858. return ( b = compare( this, new BigNumber( y, b ) ) ) === 1 || b === 0;
  12859. };
  12860. /*
  12861. * Return true if the value of this BigNumber is a finite number, otherwise returns false.
  12862. */
  12863. P.isFinite = function () {
  12864. return !!this.c;
  12865. };
  12866. /*
  12867. * Return true if the value of this BigNumber is an integer, otherwise return false.
  12868. */
  12869. P.isInteger = P.isInt = function () {
  12870. return !!this.c && bitFloor( this.e / LOG_BASE ) > this.c.length - 2;
  12871. };
  12872. /*
  12873. * Return true if the value of this BigNumber is NaN, otherwise returns false.
  12874. */
  12875. P.isNaN = function () {
  12876. return !this.s;
  12877. };
  12878. /*
  12879. * Return true if the value of this BigNumber is negative, otherwise returns false.
  12880. */
  12881. P.isNegative = P.isNeg = function () {
  12882. return this.s < 0;
  12883. };
  12884. /*
  12885. * Return true if the value of this BigNumber is 0 or -0, otherwise returns false.
  12886. */
  12887. P.isZero = function () {
  12888. return !!this.c && this.c[0] == 0;
  12889. };
  12890. /*
  12891. * Return true if the value of this BigNumber is less than the value of BigNumber(y, b),
  12892. * otherwise returns false.
  12893. */
  12894. P.lessThan = P.lt = function ( y, b ) {
  12895. id = 8;
  12896. return compare( this, new BigNumber( y, b ) ) < 0;
  12897. };
  12898. /*
  12899. * Return true if the value of this BigNumber is less than or equal to the value of
  12900. * BigNumber(y, b), otherwise returns false.
  12901. */
  12902. P.lessThanOrEqualTo = P.lte = function ( y, b ) {
  12903. id = 9;
  12904. return ( b = compare( this, new BigNumber( y, b ) ) ) === -1 || b === 0;
  12905. };
  12906. /*
  12907. * n - 0 = n
  12908. * n - N = N
  12909. * n - I = -I
  12910. * 0 - n = -n
  12911. * 0 - 0 = 0
  12912. * 0 - N = N
  12913. * 0 - I = -I
  12914. * N - n = N
  12915. * N - 0 = N
  12916. * N - N = N
  12917. * N - I = N
  12918. * I - n = I
  12919. * I - 0 = I
  12920. * I - N = N
  12921. * I - I = N
  12922. *
  12923. * Return a new BigNumber whose value is the value of this BigNumber minus the value of
  12924. * BigNumber(y, b).
  12925. */
  12926. P.minus = P.sub = function ( y, b ) {
  12927. var i, j, t, xLTy,
  12928. x = this,
  12929. a = x.s;
  12930. id = 10;
  12931. y = new BigNumber( y, b );
  12932. b = y.s;
  12933. // Either NaN?
  12934. if ( !a || !b ) return new BigNumber(NaN);
  12935. // Signs differ?
  12936. if ( a != b ) {
  12937. y.s = -b;
  12938. return x.plus(y);
  12939. }
  12940. var xe = x.e / LOG_BASE,
  12941. ye = y.e / LOG_BASE,
  12942. xc = x.c,
  12943. yc = y.c;
  12944. if ( !xe || !ye ) {
  12945. // Either Infinity?
  12946. if ( !xc || !yc ) return xc ? ( y.s = -b, y ) : new BigNumber( yc ? x : NaN );
  12947. // Either zero?
  12948. if ( !xc[0] || !yc[0] ) {
  12949. // Return y if y is non-zero, x if x is non-zero, or zero if both are zero.
  12950. return yc[0] ? ( y.s = -b, y ) : new BigNumber( xc[0] ? x :
  12951. // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
  12952. ROUNDING_MODE == 3 ? -0 : 0 );
  12953. }
  12954. }
  12955. xe = bitFloor(xe);
  12956. ye = bitFloor(ye);
  12957. xc = xc.slice();
  12958. // Determine which is the bigger number.
  12959. if ( a = xe - ye ) {
  12960. if ( xLTy = a < 0 ) {
  12961. a = -a;
  12962. t = xc;
  12963. } else {
  12964. ye = xe;
  12965. t = yc;
  12966. }
  12967. t.reverse();
  12968. // Prepend zeros to equalise exponents.
  12969. for ( b = a; b--; t.push(0) );
  12970. t.reverse();
  12971. } else {
  12972. // Exponents equal. Check digit by digit.
  12973. j = ( xLTy = ( a = xc.length ) < ( b = yc.length ) ) ? a : b;
  12974. for ( a = b = 0; b < j; b++ ) {
  12975. if ( xc[b] != yc[b] ) {
  12976. xLTy = xc[b] < yc[b];
  12977. break;
  12978. }
  12979. }
  12980. }
  12981. // x < y? Point xc to the array of the bigger number.
  12982. if (xLTy) t = xc, xc = yc, yc = t, y.s = -y.s;
  12983. b = ( j = yc.length ) - ( i = xc.length );
  12984. // Append zeros to xc if shorter.
  12985. // No need to add zeros to yc if shorter as subtract only needs to start at yc.length.
  12986. if ( b > 0 ) for ( ; b--; xc[i++] = 0 );
  12987. b = BASE - 1;
  12988. // Subtract yc from xc.
  12989. for ( ; j > a; ) {
  12990. if ( xc[--j] < yc[j] ) {
  12991. for ( i = j; i && !xc[--i]; xc[i] = b );
  12992. --xc[i];
  12993. xc[j] += BASE;
  12994. }
  12995. xc[j] -= yc[j];
  12996. }
  12997. // Remove leading zeros and adjust exponent accordingly.
  12998. for ( ; xc[0] == 0; xc.shift(), --ye );
  12999. // Zero?
  13000. if ( !xc[0] ) {
  13001. // Following IEEE 754 (2008) 6.3,
  13002. // n - n = +0 but n - n = -0 when rounding towards -Infinity.
  13003. y.s = ROUNDING_MODE == 3 ? -1 : 1;
  13004. y.c = [ y.e = 0 ];
  13005. return y;
  13006. }
  13007. // No need to check for Infinity as +x - +y != Infinity && -x - -y != Infinity
  13008. // for finite x and y.
  13009. return normalise( y, xc, ye );
  13010. };
  13011. /*
  13012. * n % 0 = N
  13013. * n % N = N
  13014. * n % I = n
  13015. * 0 % n = 0
  13016. * -0 % n = -0
  13017. * 0 % 0 = N
  13018. * 0 % N = N
  13019. * 0 % I = 0
  13020. * N % n = N
  13021. * N % 0 = N
  13022. * N % N = N
  13023. * N % I = N
  13024. * I % n = N
  13025. * I % 0 = N
  13026. * I % N = N
  13027. * I % I = N
  13028. *
  13029. * Return a new BigNumber whose value is the value of this BigNumber modulo the value of
  13030. * BigNumber(y, b). The result depends on the value of MODULO_MODE.
  13031. */
  13032. P.modulo = P.mod = function ( y, b ) {
  13033. var q, s,
  13034. x = this;
  13035. id = 11;
  13036. y = new BigNumber( y, b );
  13037. // Return NaN if x is Infinity or NaN, or y is NaN or zero.
  13038. if ( !x.c || !y.s || y.c && !y.c[0] ) {
  13039. return new BigNumber(NaN);
  13040. // Return x if y is Infinity or x is zero.
  13041. } else if ( !y.c || x.c && !x.c[0] ) {
  13042. return new BigNumber(x);
  13043. }
  13044. if ( MODULO_MODE == 9 ) {
  13045. // Euclidian division: q = sign(y) * floor(x / abs(y))
  13046. // r = x - qy where 0 <= r < abs(y)
  13047. s = y.s;
  13048. y.s = 1;
  13049. q = div( x, y, 0, 3 );
  13050. y.s = s;
  13051. q.s *= s;
  13052. } else {
  13053. q = div( x, y, 0, MODULO_MODE );
  13054. }
  13055. return x.minus( q.times(y) );
  13056. };
  13057. /*
  13058. * Return a new BigNumber whose value is the value of this BigNumber negated,
  13059. * i.e. multiplied by -1.
  13060. */
  13061. P.negated = P.neg = function () {
  13062. var x = new BigNumber(this);
  13063. x.s = -x.s || null;
  13064. return x;
  13065. };
  13066. /*
  13067. * n + 0 = n
  13068. * n + N = N
  13069. * n + I = I
  13070. * 0 + n = n
  13071. * 0 + 0 = 0
  13072. * 0 + N = N
  13073. * 0 + I = I
  13074. * N + n = N
  13075. * N + 0 = N
  13076. * N + N = N
  13077. * N + I = N
  13078. * I + n = I
  13079. * I + 0 = I
  13080. * I + N = N
  13081. * I + I = I
  13082. *
  13083. * Return a new BigNumber whose value is the value of this BigNumber plus the value of
  13084. * BigNumber(y, b).
  13085. */
  13086. P.plus = P.add = function ( y, b ) {
  13087. var t,
  13088. x = this,
  13089. a = x.s;
  13090. id = 12;
  13091. y = new BigNumber( y, b );
  13092. b = y.s;
  13093. // Either NaN?
  13094. if ( !a || !b ) return new BigNumber(NaN);
  13095. // Signs differ?
  13096. if ( a != b ) {
  13097. y.s = -b;
  13098. return x.minus(y);
  13099. }
  13100. var xe = x.e / LOG_BASE,
  13101. ye = y.e / LOG_BASE,
  13102. xc = x.c,
  13103. yc = y.c;
  13104. if ( !xe || !ye ) {
  13105. // Return ±Infinity if either ±Infinity.
  13106. if ( !xc || !yc ) return new BigNumber( a / 0 );
  13107. // Either zero?
  13108. // Return y if y is non-zero, x if x is non-zero, or zero if both are zero.
  13109. if ( !xc[0] || !yc[0] ) return yc[0] ? y : new BigNumber( xc[0] ? x : a * 0 );
  13110. }
  13111. xe = bitFloor(xe);
  13112. ye = bitFloor(ye);
  13113. xc = xc.slice();
  13114. // Prepend zeros to equalise exponents. Faster to use reverse then do unshifts.
  13115. if ( a = xe - ye ) {
  13116. if ( a > 0 ) {
  13117. ye = xe;
  13118. t = yc;
  13119. } else {
  13120. a = -a;
  13121. t = xc;
  13122. }
  13123. t.reverse();
  13124. for ( ; a--; t.push(0) );
  13125. t.reverse();
  13126. }
  13127. a = xc.length;
  13128. b = yc.length;
  13129. // Point xc to the longer array, and b to the shorter length.
  13130. if ( a - b < 0 ) t = yc, yc = xc, xc = t, b = a;
  13131. // Only start adding at yc.length - 1 as the further digits of xc can be ignored.
  13132. for ( a = 0; b; ) {
  13133. a = ( xc[--b] = xc[b] + yc[b] + a ) / BASE | 0;
  13134. xc[b] %= BASE;
  13135. }
  13136. if (a) {
  13137. xc.unshift(a);
  13138. ++ye;
  13139. }
  13140. // No need to check for zero, as +x + +y != 0 && -x + -y != 0
  13141. // ye = MAX_EXP + 1 possible
  13142. return normalise( y, xc, ye );
  13143. };
  13144. /*
  13145. * Return the number of significant digits of the value of this BigNumber.
  13146. *
  13147. * [z] {boolean|number} Whether to count integer-part trailing zeros: true, false, 1 or 0.
  13148. */
  13149. P.precision = P.sd = function (z) {
  13150. var n, v,
  13151. x = this,
  13152. c = x.c;
  13153. // 'precision() argument not a boolean or binary digit: {z}'
  13154. if ( z != null && z !== !!z && z !== 1 && z !== 0 ) {
  13155. if (ERRORS) raise( 13, 'argument' + notBool, z );
  13156. if ( z != !!z ) z = null;
  13157. }
  13158. if ( !c ) return null;
  13159. v = c.length - 1;
  13160. n = v * LOG_BASE + 1;
  13161. if ( v = c[v] ) {
  13162. // Subtract the number of trailing zeros of the last element.
  13163. for ( ; v % 10 == 0; v /= 10, n-- );
  13164. // Add the number of digits of the first element.
  13165. for ( v = c[0]; v >= 10; v /= 10, n++ );
  13166. }
  13167. if ( z && x.e + 1 > n ) n = x.e + 1;
  13168. return n;
  13169. };
  13170. /*
  13171. * Return a new BigNumber whose value is the value of this BigNumber rounded to a maximum of
  13172. * dp decimal places using rounding mode rm, or to 0 and ROUNDING_MODE respectively if
  13173. * omitted.
  13174. *
  13175. * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
  13176. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  13177. *
  13178. * 'round() decimal places out of range: {dp}'
  13179. * 'round() decimal places not an integer: {dp}'
  13180. * 'round() rounding mode not an integer: {rm}'
  13181. * 'round() rounding mode out of range: {rm}'
  13182. */
  13183. P.round = function ( dp, rm ) {
  13184. var n = new BigNumber(this);
  13185. if ( dp == null || isValidInt( dp, 0, MAX, 15 ) ) {
  13186. round( n, ~~dp + this.e + 1, rm == null ||
  13187. !isValidInt( rm, 0, 8, 15, roundingMode ) ? ROUNDING_MODE : rm | 0 );
  13188. }
  13189. return n;
  13190. };
  13191. /*
  13192. * Return a new BigNumber whose value is the value of this BigNumber shifted by k places
  13193. * (powers of 10). Shift to the right if n > 0, and to the left if n < 0.
  13194. *
  13195. * k {number} Integer, -MAX_SAFE_INTEGER to MAX_SAFE_INTEGER inclusive.
  13196. *
  13197. * If k is out of range and ERRORS is false, the result will be ±0 if k < 0, or ±Infinity
  13198. * otherwise.
  13199. *
  13200. * 'shift() argument not an integer: {k}'
  13201. * 'shift() argument out of range: {k}'
  13202. */
  13203. P.shift = function (k) {
  13204. var n = this;
  13205. return isValidInt( k, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER, 16, 'argument' )
  13206. // k < 1e+21, or truncate(k) will produce exponential notation.
  13207. ? n.times( '1e' + truncate(k) )
  13208. : new BigNumber( n.c && n.c[0] && ( k < -MAX_SAFE_INTEGER || k > MAX_SAFE_INTEGER )
  13209. ? n.s * ( k < 0 ? 0 : 1 / 0 )
  13210. : n );
  13211. };
  13212. /*
  13213. * sqrt(-n) = N
  13214. * sqrt( N) = N
  13215. * sqrt(-I) = N
  13216. * sqrt( I) = I
  13217. * sqrt( 0) = 0
  13218. * sqrt(-0) = -0
  13219. *
  13220. * Return a new BigNumber whose value is the square root of the value of this BigNumber,
  13221. * rounded according to DECIMAL_PLACES and ROUNDING_MODE.
  13222. */
  13223. P.squareRoot = P.sqrt = function () {
  13224. var m, n, r, rep, t,
  13225. x = this,
  13226. c = x.c,
  13227. s = x.s,
  13228. e = x.e,
  13229. dp = DECIMAL_PLACES + 4,
  13230. half = new BigNumber('0.5');
  13231. // Negative/NaN/Infinity/zero?
  13232. if ( s !== 1 || !c || !c[0] ) {
  13233. return new BigNumber( !s || s < 0 && ( !c || c[0] ) ? NaN : c ? x : 1 / 0 );
  13234. }
  13235. // Initial estimate.
  13236. s = Math.sqrt( +x );
  13237. // Math.sqrt underflow/overflow?
  13238. // Pass x to Math.sqrt as integer, then adjust the exponent of the result.
  13239. if ( s == 0 || s == 1 / 0 ) {
  13240. n = coeffToString(c);
  13241. if ( ( n.length + e ) % 2 == 0 ) n += '0';
  13242. s = Math.sqrt(n);
  13243. e = bitFloor( ( e + 1 ) / 2 ) - ( e < 0 || e % 2 );
  13244. if ( s == 1 / 0 ) {
  13245. n = '1e' + e;
  13246. } else {
  13247. n = s.toExponential();
  13248. n = n.slice( 0, n.indexOf('e') + 1 ) + e;
  13249. }
  13250. r = new BigNumber(n);
  13251. } else {
  13252. r = new BigNumber( s + '' );
  13253. }
  13254. // Check for zero.
  13255. // r could be zero if MIN_EXP is changed after the this value was created.
  13256. // This would cause a division by zero (x/t) and hence Infinity below, which would cause
  13257. // coeffToString to throw.
  13258. if ( r.c[0] ) {
  13259. e = r.e;
  13260. s = e + dp;
  13261. if ( s < 3 ) s = 0;
  13262. // Newton-Raphson iteration.
  13263. for ( ; ; ) {
  13264. t = r;
  13265. r = half.times( t.plus( div( x, t, dp, 1 ) ) );
  13266. if ( coeffToString( t.c ).slice( 0, s ) === ( n =
  13267. coeffToString( r.c ) ).slice( 0, s ) ) {
  13268. // The exponent of r may here be one less than the final result exponent,
  13269. // e.g 0.0009999 (e-4) --> 0.001 (e-3), so adjust s so the rounding digits
  13270. // are indexed correctly.
  13271. if ( r.e < e ) --s;
  13272. n = n.slice( s - 3, s + 1 );
  13273. // The 4th rounding digit may be in error by -1 so if the 4 rounding digits
  13274. // are 9999 or 4999 (i.e. approaching a rounding boundary) continue the
  13275. // iteration.
  13276. if ( n == '9999' || !rep && n == '4999' ) {
  13277. // On the first iteration only, check to see if rounding up gives the
  13278. // exact result as the nines may infinitely repeat.
  13279. if ( !rep ) {
  13280. round( t, t.e + DECIMAL_PLACES + 2, 0 );
  13281. if ( t.times(t).eq(x) ) {
  13282. r = t;
  13283. break;
  13284. }
  13285. }
  13286. dp += 4;
  13287. s += 4;
  13288. rep = 1;
  13289. } else {
  13290. // If rounding digits are null, 0{0,4} or 50{0,3}, check for exact
  13291. // result. If not, then there are further digits and m will be truthy.
  13292. if ( !+n || !+n.slice(1) && n.charAt(0) == '5' ) {
  13293. // Truncate to the first rounding digit.
  13294. round( r, r.e + DECIMAL_PLACES + 2, 1 );
  13295. m = !r.times(r).eq(x);
  13296. }
  13297. break;
  13298. }
  13299. }
  13300. }
  13301. }
  13302. return round( r, r.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m );
  13303. };
  13304. /*
  13305. * n * 0 = 0
  13306. * n * N = N
  13307. * n * I = I
  13308. * 0 * n = 0
  13309. * 0 * 0 = 0
  13310. * 0 * N = N
  13311. * 0 * I = N
  13312. * N * n = N
  13313. * N * 0 = N
  13314. * N * N = N
  13315. * N * I = N
  13316. * I * n = I
  13317. * I * 0 = N
  13318. * I * N = N
  13319. * I * I = I
  13320. *
  13321. * Return a new BigNumber whose value is the value of this BigNumber times the value of
  13322. * BigNumber(y, b).
  13323. */
  13324. P.times = P.mul = function ( y, b ) {
  13325. var c, e, i, j, k, m, xcL, xlo, xhi, ycL, ylo, yhi, zc,
  13326. base, sqrtBase,
  13327. x = this,
  13328. xc = x.c,
  13329. yc = ( id = 17, y = new BigNumber( y, b ) ).c;
  13330. // Either NaN, ±Infinity or ±0?
  13331. if ( !xc || !yc || !xc[0] || !yc[0] ) {
  13332. // Return NaN if either is NaN, or one is 0 and the other is Infinity.
  13333. if ( !x.s || !y.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc ) {
  13334. y.c = y.e = y.s = null;
  13335. } else {
  13336. y.s *= x.s;
  13337. // Return ±Infinity if either is ±Infinity.
  13338. if ( !xc || !yc ) {
  13339. y.c = y.e = null;
  13340. // Return ±0 if either is ±0.
  13341. } else {
  13342. y.c = [0];
  13343. y.e = 0;
  13344. }
  13345. }
  13346. return y;
  13347. }
  13348. e = bitFloor( x.e / LOG_BASE ) + bitFloor( y.e / LOG_BASE );
  13349. y.s *= x.s;
  13350. xcL = xc.length;
  13351. ycL = yc.length;
  13352. // Ensure xc points to longer array and xcL to its length.
  13353. if ( xcL < ycL ) zc = xc, xc = yc, yc = zc, i = xcL, xcL = ycL, ycL = i;
  13354. // Initialise the result array with zeros.
  13355. for ( i = xcL + ycL, zc = []; i--; zc.push(0) );
  13356. base = BASE;
  13357. sqrtBase = SQRT_BASE;
  13358. for ( i = ycL; --i >= 0; ) {
  13359. c = 0;
  13360. ylo = yc[i] % sqrtBase;
  13361. yhi = yc[i] / sqrtBase | 0;
  13362. for ( k = xcL, j = i + k; j > i; ) {
  13363. xlo = xc[--k] % sqrtBase;
  13364. xhi = xc[k] / sqrtBase | 0;
  13365. m = yhi * xlo + xhi * ylo;
  13366. xlo = ylo * xlo + ( ( m % sqrtBase ) * sqrtBase ) + zc[j] + c;
  13367. c = ( xlo / base | 0 ) + ( m / sqrtBase | 0 ) + yhi * xhi;
  13368. zc[j--] = xlo % base;
  13369. }
  13370. zc[j] = c;
  13371. }
  13372. if (c) {
  13373. ++e;
  13374. } else {
  13375. zc.shift();
  13376. }
  13377. return normalise( y, zc, e );
  13378. };
  13379. /*
  13380. * Return a new BigNumber whose value is the value of this BigNumber rounded to a maximum of
  13381. * sd significant digits using rounding mode rm, or ROUNDING_MODE if rm is omitted.
  13382. *
  13383. * [sd] {number} Significant digits. Integer, 1 to MAX inclusive.
  13384. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  13385. *
  13386. * 'toDigits() precision out of range: {sd}'
  13387. * 'toDigits() precision not an integer: {sd}'
  13388. * 'toDigits() rounding mode not an integer: {rm}'
  13389. * 'toDigits() rounding mode out of range: {rm}'
  13390. */
  13391. P.toDigits = function ( sd, rm ) {
  13392. var n = new BigNumber(this);
  13393. sd = sd == null || !isValidInt( sd, 1, MAX, 18, 'precision' ) ? null : sd | 0;
  13394. rm = rm == null || !isValidInt( rm, 0, 8, 18, roundingMode ) ? ROUNDING_MODE : rm | 0;
  13395. return sd ? round( n, sd, rm ) : n;
  13396. };
  13397. /*
  13398. * Return a string representing the value of this BigNumber in exponential notation and
  13399. * rounded using ROUNDING_MODE to dp fixed decimal places.
  13400. *
  13401. * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
  13402. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  13403. *
  13404. * 'toExponential() decimal places not an integer: {dp}'
  13405. * 'toExponential() decimal places out of range: {dp}'
  13406. * 'toExponential() rounding mode not an integer: {rm}'
  13407. * 'toExponential() rounding mode out of range: {rm}'
  13408. */
  13409. P.toExponential = function ( dp, rm ) {
  13410. return format( this,
  13411. dp != null && isValidInt( dp, 0, MAX, 19 ) ? ~~dp + 1 : null, rm, 19 );
  13412. };
  13413. /*
  13414. * Return a string representing the value of this BigNumber in fixed-point notation rounding
  13415. * to dp fixed decimal places using rounding mode rm, or ROUNDING_MODE if rm is omitted.
  13416. *
  13417. * Note: as with JavaScript's number type, (-0).toFixed(0) is '0',
  13418. * but e.g. (-0.00001).toFixed(0) is '-0'.
  13419. *
  13420. * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
  13421. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  13422. *
  13423. * 'toFixed() decimal places not an integer: {dp}'
  13424. * 'toFixed() decimal places out of range: {dp}'
  13425. * 'toFixed() rounding mode not an integer: {rm}'
  13426. * 'toFixed() rounding mode out of range: {rm}'
  13427. */
  13428. P.toFixed = function ( dp, rm ) {
  13429. return format( this, dp != null && isValidInt( dp, 0, MAX, 20 )
  13430. ? ~~dp + this.e + 1 : null, rm, 20 );
  13431. };
  13432. /*
  13433. * Return a string representing the value of this BigNumber in fixed-point notation rounded
  13434. * using rm or ROUNDING_MODE to dp decimal places, and formatted according to the properties
  13435. * of the FORMAT object (see BigNumber.config).
  13436. *
  13437. * FORMAT = {
  13438. * decimalSeparator : '.',
  13439. * groupSeparator : ',',
  13440. * groupSize : 3,
  13441. * secondaryGroupSize : 0,
  13442. * fractionGroupSeparator : '\xA0', // non-breaking space
  13443. * fractionGroupSize : 0
  13444. * };
  13445. *
  13446. * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
  13447. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  13448. *
  13449. * 'toFormat() decimal places not an integer: {dp}'
  13450. * 'toFormat() decimal places out of range: {dp}'
  13451. * 'toFormat() rounding mode not an integer: {rm}'
  13452. * 'toFormat() rounding mode out of range: {rm}'
  13453. */
  13454. P.toFormat = function ( dp, rm ) {
  13455. var str = format( this, dp != null && isValidInt( dp, 0, MAX, 21 )
  13456. ? ~~dp + this.e + 1 : null, rm, 21 );
  13457. if ( this.c ) {
  13458. var i,
  13459. arr = str.split('.'),
  13460. g1 = +FORMAT.groupSize,
  13461. g2 = +FORMAT.secondaryGroupSize,
  13462. groupSeparator = FORMAT.groupSeparator,
  13463. intPart = arr[0],
  13464. fractionPart = arr[1],
  13465. isNeg = this.s < 0,
  13466. intDigits = isNeg ? intPart.slice(1) : intPart,
  13467. len = intDigits.length;
  13468. if (g2) i = g1, g1 = g2, g2 = i, len -= i;
  13469. if ( g1 > 0 && len > 0 ) {
  13470. i = len % g1 || g1;
  13471. intPart = intDigits.substr( 0, i );
  13472. for ( ; i < len; i += g1 ) {
  13473. intPart += groupSeparator + intDigits.substr( i, g1 );
  13474. }
  13475. if ( g2 > 0 ) intPart += groupSeparator + intDigits.slice(i);
  13476. if (isNeg) intPart = '-' + intPart;
  13477. }
  13478. str = fractionPart
  13479. ? intPart + FORMAT.decimalSeparator + ( ( g2 = +FORMAT.fractionGroupSize )
  13480. ? fractionPart.replace( new RegExp( '\\d{' + g2 + '}\\B', 'g' ),
  13481. '$&' + FORMAT.fractionGroupSeparator )
  13482. : fractionPart )
  13483. : intPart;
  13484. }
  13485. return str;
  13486. };
  13487. /*
  13488. * Return a string array representing the value of this BigNumber as a simple fraction with
  13489. * an integer numerator and an integer denominator. The denominator will be a positive
  13490. * non-zero value less than or equal to the specified maximum denominator. If a maximum
  13491. * denominator is not specified, the denominator will be the lowest value necessary to
  13492. * represent the number exactly.
  13493. *
  13494. * [md] {number|string|BigNumber} Integer >= 1 and < Infinity. The maximum denominator.
  13495. *
  13496. * 'toFraction() max denominator not an integer: {md}'
  13497. * 'toFraction() max denominator out of range: {md}'
  13498. */
  13499. P.toFraction = function (md) {
  13500. var arr, d0, d2, e, exp, n, n0, q, s,
  13501. k = ERRORS,
  13502. x = this,
  13503. xc = x.c,
  13504. d = new BigNumber(ONE),
  13505. n1 = d0 = new BigNumber(ONE),
  13506. d1 = n0 = new BigNumber(ONE);
  13507. if ( md != null ) {
  13508. ERRORS = false;
  13509. n = new BigNumber(md);
  13510. ERRORS = k;
  13511. if ( !( k = n.isInt() ) || n.lt(ONE) ) {
  13512. if (ERRORS) {
  13513. raise( 22,
  13514. 'max denominator ' + ( k ? 'out of range' : 'not an integer' ), md );
  13515. }
  13516. // ERRORS is false:
  13517. // If md is a finite non-integer >= 1, round it to an integer and use it.
  13518. md = !k && n.c && round( n, n.e + 1, 1 ).gte(ONE) ? n : null;
  13519. }
  13520. }
  13521. if ( !xc ) return x.toString();
  13522. s = coeffToString(xc);
  13523. // Determine initial denominator.
  13524. // d is a power of 10 and the minimum max denominator that specifies the value exactly.
  13525. e = d.e = s.length - x.e - 1;
  13526. d.c[0] = POWS_TEN[ ( exp = e % LOG_BASE ) < 0 ? LOG_BASE + exp : exp ];
  13527. md = !md || n.cmp(d) > 0 ? ( e > 0 ? d : n1 ) : n;
  13528. exp = MAX_EXP;
  13529. MAX_EXP = 1 / 0;
  13530. n = new BigNumber(s);
  13531. // n0 = d1 = 0
  13532. n0.c[0] = 0;
  13533. for ( ; ; ) {
  13534. q = div( n, d, 0, 1 );
  13535. d2 = d0.plus( q.times(d1) );
  13536. if ( d2.cmp(md) == 1 ) break;
  13537. d0 = d1;
  13538. d1 = d2;
  13539. n1 = n0.plus( q.times( d2 = n1 ) );
  13540. n0 = d2;
  13541. d = n.minus( q.times( d2 = d ) );
  13542. n = d2;
  13543. }
  13544. d2 = div( md.minus(d0), d1, 0, 1 );
  13545. n0 = n0.plus( d2.times(n1) );
  13546. d0 = d0.plus( d2.times(d1) );
  13547. n0.s = n1.s = x.s;
  13548. e *= 2;
  13549. // Determine which fraction is closer to x, n0/d0 or n1/d1
  13550. arr = div( n1, d1, e, ROUNDING_MODE ).minus(x).abs().cmp(
  13551. div( n0, d0, e, ROUNDING_MODE ).minus(x).abs() ) < 1
  13552. ? [ n1.toString(), d1.toString() ]
  13553. : [ n0.toString(), d0.toString() ];
  13554. MAX_EXP = exp;
  13555. return arr;
  13556. };
  13557. /*
  13558. * Return the value of this BigNumber converted to a number primitive.
  13559. */
  13560. P.toNumber = function () {
  13561. var x = this;
  13562. // Ensure zero has correct sign.
  13563. return +x || ( x.s ? x.s * 0 : NaN );
  13564. };
  13565. /*
  13566. * Return a BigNumber whose value is the value of this BigNumber raised to the power n.
  13567. * If n is negative round according to DECIMAL_PLACES and ROUNDING_MODE.
  13568. * If POW_PRECISION is not 0, round to POW_PRECISION using ROUNDING_MODE.
  13569. *
  13570. * n {number} Integer, -9007199254740992 to 9007199254740992 inclusive.
  13571. * (Performs 54 loop iterations for n of 9007199254740992.)
  13572. *
  13573. * 'pow() exponent not an integer: {n}'
  13574. * 'pow() exponent out of range: {n}'
  13575. */
  13576. P.toPower = P.pow = function (n) {
  13577. var k, y,
  13578. i = mathfloor( n < 0 ? -n : +n ),
  13579. x = this;
  13580. // Pass ±Infinity to Math.pow if exponent is out of range.
  13581. if ( !isValidInt( n, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER, 23, 'exponent' ) &&
  13582. ( !isFinite(n) || i > MAX_SAFE_INTEGER && ( n /= 0 ) ||
  13583. parseFloat(n) != n && !( n = NaN ) ) ) {
  13584. return new BigNumber( Math.pow( +x, n ) );
  13585. }
  13586. // Truncating each coefficient array to a length of k after each multiplication equates
  13587. // to truncating significant digits to POW_PRECISION + [28, 41], i.e. there will be a
  13588. // minimum of 28 guard digits retained. (Using + 1.5 would give [9, 21] guard digits.)
  13589. k = POW_PRECISION ? mathceil( POW_PRECISION / LOG_BASE + 2 ) : 0;
  13590. y = new BigNumber(ONE);
  13591. for ( ; ; ) {
  13592. if ( i % 2 ) {
  13593. y = y.times(x);
  13594. if ( !y.c ) break;
  13595. if ( k && y.c.length > k ) y.c.length = k;
  13596. }
  13597. i = mathfloor( i / 2 );
  13598. if ( !i ) break;
  13599. x = x.times(x);
  13600. if ( k && x.c && x.c.length > k ) x.c.length = k;
  13601. }
  13602. if ( n < 0 ) y = ONE.div(y);
  13603. return k ? round( y, POW_PRECISION, ROUNDING_MODE ) : y;
  13604. };
  13605. /*
  13606. * Return a string representing the value of this BigNumber rounded to sd significant digits
  13607. * using rounding mode rm or ROUNDING_MODE. If sd is less than the number of digits
  13608. * necessary to represent the integer part of the value in fixed-point notation, then use
  13609. * exponential notation.
  13610. *
  13611. * [sd] {number} Significant digits. Integer, 1 to MAX inclusive.
  13612. * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
  13613. *
  13614. * 'toPrecision() precision not an integer: {sd}'
  13615. * 'toPrecision() precision out of range: {sd}'
  13616. * 'toPrecision() rounding mode not an integer: {rm}'
  13617. * 'toPrecision() rounding mode out of range: {rm}'
  13618. */
  13619. P.toPrecision = function ( sd, rm ) {
  13620. return format( this, sd != null && isValidInt( sd, 1, MAX, 24, 'precision' )
  13621. ? sd | 0 : null, rm, 24 );
  13622. };
  13623. /*
  13624. * Return a string representing the value of this BigNumber in base b, or base 10 if b is
  13625. * omitted. If a base is specified, including base 10, round according to DECIMAL_PLACES and
  13626. * ROUNDING_MODE. If a base is not specified, and this BigNumber has a positive exponent
  13627. * that is equal to or greater than TO_EXP_POS, or a negative exponent equal to or less than
  13628. * TO_EXP_NEG, return exponential notation.
  13629. *
  13630. * [b] {number} Integer, 2 to 64 inclusive.
  13631. *
  13632. * 'toString() base not an integer: {b}'
  13633. * 'toString() base out of range: {b}'
  13634. */
  13635. P.toString = function (b) {
  13636. var str,
  13637. n = this,
  13638. s = n.s,
  13639. e = n.e;
  13640. // Infinity or NaN?
  13641. if ( e === null ) {
  13642. if (s) {
  13643. str = 'Infinity';
  13644. if ( s < 0 ) str = '-' + str;
  13645. } else {
  13646. str = 'NaN';
  13647. }
  13648. } else {
  13649. str = coeffToString( n.c );
  13650. if ( b == null || !isValidInt( b, 2, 64, 25, 'base' ) ) {
  13651. str = e <= TO_EXP_NEG || e >= TO_EXP_POS
  13652. ? toExponential( str, e )
  13653. : toFixedPoint( str, e );
  13654. } else {
  13655. str = convertBase( toFixedPoint( str, e ), b | 0, 10, s );
  13656. }
  13657. if ( s < 0 && n.c[0] ) str = '-' + str;
  13658. }
  13659. return str;
  13660. };
  13661. /*
  13662. * Return a new BigNumber whose value is the value of this BigNumber truncated to a whole
  13663. * number.
  13664. */
  13665. P.truncated = P.trunc = function () {
  13666. return round( new BigNumber(this), this.e + 1, 1 );
  13667. };
  13668. /*
  13669. * Return as toString, but do not accept a base argument.
  13670. */
  13671. P.valueOf = P.toJSON = function () {
  13672. return this.toString();
  13673. };
  13674. // Aliases for BigDecimal methods.
  13675. //P.add = P.plus; // P.add included above
  13676. //P.subtract = P.minus; // P.sub included above
  13677. //P.multiply = P.times; // P.mul included above
  13678. //P.divide = P.div;
  13679. //P.remainder = P.mod;
  13680. //P.compareTo = P.cmp;
  13681. //P.negate = P.neg;
  13682. if ( configObj != null ) BigNumber.config(configObj);
  13683. return BigNumber;
  13684. }
  13685. // PRIVATE HELPER FUNCTIONS
  13686. function bitFloor(n) {
  13687. var i = n | 0;
  13688. return n > 0 || n === i ? i : i - 1;
  13689. }
  13690. // Return a coefficient array as a string of base 10 digits.
  13691. function coeffToString(a) {
  13692. var s, z,
  13693. i = 1,
  13694. j = a.length,
  13695. r = a[0] + '';
  13696. for ( ; i < j; ) {
  13697. s = a[i++] + '';
  13698. z = LOG_BASE - s.length;
  13699. for ( ; z--; s = '0' + s );
  13700. r += s;
  13701. }
  13702. // Determine trailing zeros.
  13703. for ( j = r.length; r.charCodeAt(--j) === 48; );
  13704. return r.slice( 0, j + 1 || 1 );
  13705. }
  13706. // Compare the value of BigNumbers x and y.
  13707. function compare( x, y ) {
  13708. var a, b,
  13709. xc = x.c,
  13710. yc = y.c,
  13711. i = x.s,
  13712. j = y.s,
  13713. k = x.e,
  13714. l = y.e;
  13715. // Either NaN?
  13716. if ( !i || !j ) return null;
  13717. a = xc && !xc[0];
  13718. b = yc && !yc[0];
  13719. // Either zero?
  13720. if ( a || b ) return a ? b ? 0 : -j : i;
  13721. // Signs differ?
  13722. if ( i != j ) return i;
  13723. a = i < 0;
  13724. b = k == l;
  13725. // Either Infinity?
  13726. if ( !xc || !yc ) return b ? 0 : !xc ^ a ? 1 : -1;
  13727. // Compare exponents.
  13728. if ( !b ) return k > l ^ a ? 1 : -1;
  13729. j = ( k = xc.length ) < ( l = yc.length ) ? k : l;
  13730. // Compare digit by digit.
  13731. for ( i = 0; i < j; i++ ) if ( xc[i] != yc[i] ) return xc[i] > yc[i] ^ a ? 1 : -1;
  13732. // Compare lengths.
  13733. return k == l ? 0 : k > l ^ a ? 1 : -1;
  13734. }
  13735. /*
  13736. * Return true if n is a valid number in range, otherwise false.
  13737. * Use for argument validation when ERRORS is false.
  13738. * Note: parseInt('1e+1') == 1 but parseFloat('1e+1') == 10.
  13739. */
  13740. function intValidatorNoErrors( n, min, max ) {
  13741. return ( n = truncate(n) ) >= min && n <= max;
  13742. }
  13743. function isArray(obj) {
  13744. return Object.prototype.toString.call(obj) == '[object Array]';
  13745. }
  13746. /*
  13747. * Convert string of baseIn to an array of numbers of baseOut.
  13748. * Eg. convertBase('255', 10, 16) returns [15, 15].
  13749. * Eg. convertBase('ff', 16, 10) returns [2, 5, 5].
  13750. */
  13751. function toBaseOut( str, baseIn, baseOut ) {
  13752. var j,
  13753. arr = [0],
  13754. arrL,
  13755. i = 0,
  13756. len = str.length;
  13757. for ( ; i < len; ) {
  13758. for ( arrL = arr.length; arrL--; arr[arrL] *= baseIn );
  13759. arr[ j = 0 ] += ALPHABET.indexOf( str.charAt( i++ ) );
  13760. for ( ; j < arr.length; j++ ) {
  13761. if ( arr[j] > baseOut - 1 ) {
  13762. if ( arr[j + 1] == null ) arr[j + 1] = 0;
  13763. arr[j + 1] += arr[j] / baseOut | 0;
  13764. arr[j] %= baseOut;
  13765. }
  13766. }
  13767. }
  13768. return arr.reverse();
  13769. }
  13770. function toExponential( str, e ) {
  13771. return ( str.length > 1 ? str.charAt(0) + '.' + str.slice(1) : str ) +
  13772. ( e < 0 ? 'e' : 'e+' ) + e;
  13773. }
  13774. function toFixedPoint( str, e ) {
  13775. var len, z;
  13776. // Negative exponent?
  13777. if ( e < 0 ) {
  13778. // Prepend zeros.
  13779. for ( z = '0.'; ++e; z += '0' );
  13780. str = z + str;
  13781. // Positive exponent
  13782. } else {
  13783. len = str.length;
  13784. // Append zeros.
  13785. if ( ++e > len ) {
  13786. for ( z = '0', e -= len; --e; z += '0' );
  13787. str += z;
  13788. } else if ( e < len ) {
  13789. str = str.slice( 0, e ) + '.' + str.slice(e);
  13790. }
  13791. }
  13792. return str;
  13793. }
  13794. function truncate(n) {
  13795. n = parseFloat(n);
  13796. return n < 0 ? mathceil(n) : mathfloor(n);
  13797. }
  13798. // EXPORT
  13799. BigNumber = another();
  13800. // AMD.
  13801. if ( typeof define == 'function' && define.amd ) {
  13802. define( function () { return BigNumber; } );
  13803. // Node and other environments that support module.exports.
  13804. } else if ( typeof module != 'undefined' && module.exports ) {
  13805. module.exports = BigNumber;
  13806. if ( !crypto ) try { crypto = require('crypto'); } catch (e) {}
  13807. // Browser.
  13808. } else {
  13809. global.BigNumber = BigNumber;
  13810. }
  13811. })(this);
  13812. },{"crypto":50}],"web3":[function(require,module,exports){
  13813. var Web3 = require('./lib/web3');
  13814. // dont override global variable
  13815. if (typeof window !== 'undefined' && typeof window.Web3 === 'undefined') {
  13816. window.Web3 = Web3;
  13817. }
  13818. module.exports = Web3;
  13819. },{"./lib/web3":22}]},{},["web3"])
  13820. //# sourceMappingURL=web3.js.map
  13821. var IpfsApi =
  13822. /******/ (function(modules) { // webpackBootstrap
  13823. /******/ // The module cache
  13824. /******/ var installedModules = {};
  13825. /******/
  13826. /******/ // The require function
  13827. /******/ function __webpack_require__(moduleId) {
  13828. /******/
  13829. /******/ // Check if module is in cache
  13830. /******/ if(installedModules[moduleId])
  13831. /******/ return installedModules[moduleId].exports;
  13832. /******/
  13833. /******/ // Create a new module (and put it into the cache)
  13834. /******/ var module = installedModules[moduleId] = {
  13835. /******/ i: moduleId,
  13836. /******/ l: false,
  13837. /******/ exports: {}
  13838. /******/ };
  13839. /******/
  13840. /******/ // Execute the module function
  13841. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  13842. /******/
  13843. /******/ // Flag the module as loaded
  13844. /******/ module.l = true;
  13845. /******/
  13846. /******/ // Return the exports of the module
  13847. /******/ return module.exports;
  13848. /******/ }
  13849. /******/
  13850. /******/
  13851. /******/ // expose the modules object (__webpack_modules__)
  13852. /******/ __webpack_require__.m = modules;
  13853. /******/
  13854. /******/ // expose the module cache
  13855. /******/ __webpack_require__.c = installedModules;
  13856. /******/
  13857. /******/ // identity function for calling harmory imports with the correct context
  13858. /******/ __webpack_require__.i = function(value) { return value; };
  13859. /******/
  13860. /******/ // define getter function for harmory exports
  13861. /******/ __webpack_require__.d = function(exports, name, getter) {
  13862. /******/ Object.defineProperty(exports, name, {
  13863. /******/ configurable: false,
  13864. /******/ enumerable: true,
  13865. /******/ get: getter
  13866. /******/ });
  13867. /******/ };
  13868. /******/
  13869. /******/ // Object.prototype.hasOwnProperty.call
  13870. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  13871. /******/
  13872. /******/ // __webpack_public_path__
  13873. /******/ __webpack_require__.p = "/_karma_webpack_//";
  13874. /******/
  13875. /******/ // Load entry module and return exports
  13876. /******/ return __webpack_require__(__webpack_require__.s = 588);
  13877. /******/ })
  13878. /************************************************************************/
  13879. /******/ ([
  13880. /* 0 */
  13881. /***/ function(module, exports, __webpack_require__) {
  13882. var global = __webpack_require__(5)
  13883. , core = __webpack_require__(32)
  13884. , hide = __webpack_require__(19)
  13885. , redefine = __webpack_require__(22)
  13886. , ctx = __webpack_require__(35)
  13887. , PROTOTYPE = 'prototype';
  13888. var $export = function(type, name, source){
  13889. var IS_FORCED = type & $export.F
  13890. , IS_GLOBAL = type & $export.G
  13891. , IS_STATIC = type & $export.S
  13892. , IS_PROTO = type & $export.P
  13893. , IS_BIND = type & $export.B
  13894. , target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE]
  13895. , exports = IS_GLOBAL ? core : core[name] || (core[name] = {})
  13896. , expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {})
  13897. , key, own, out, exp;
  13898. if(IS_GLOBAL)source = name;
  13899. for(key in source){
  13900. // contains in native
  13901. own = !IS_FORCED && target && target[key] !== undefined;
  13902. // export native or passed
  13903. out = (own ? target : source)[key];
  13904. // bind timers to global for call from export context
  13905. exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
  13906. // extend global
  13907. if(target)redefine(target, key, out, type & $export.U);
  13908. // export
  13909. if(exports[key] != out)hide(exports, key, exp);
  13910. if(IS_PROTO && expProto[key] != out)expProto[key] = out;
  13911. }
  13912. };
  13913. global.core = core;
  13914. // type bitmap
  13915. $export.F = 1; // forced
  13916. $export.G = 2; // global
  13917. $export.S = 4; // static
  13918. $export.P = 8; // proto
  13919. $export.B = 16; // bind
  13920. $export.W = 32; // wrap
  13921. $export.U = 64; // safe
  13922. $export.R = 128; // real proto method for `library`
  13923. module.exports = $export;
  13924. /***/ },
  13925. /* 1 */
  13926. /***/ function(module, exports, __webpack_require__) {
  13927. "use strict";
  13928. /* WEBPACK VAR INJECTION */(function(Buffer, global) {/*!
  13929. * The buffer module from node.js, for the browser.
  13930. *
  13931. * @author Feross Aboukhadijeh <[email protected]> <http://feross.org>
  13932. * @license MIT
  13933. */
  13934. /* eslint-disable no-proto */
  13935. 'use strict'
  13936. var base64 = __webpack_require__(282)
  13937. var ieee754 = __webpack_require__(511)
  13938. var isArray = __webpack_require__(133)
  13939. exports.Buffer = Buffer
  13940. exports.SlowBuffer = SlowBuffer
  13941. exports.INSPECT_MAX_BYTES = 50
  13942. /**
  13943. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  13944. * === true Use Uint8Array implementation (fastest)
  13945. * === false Use Object implementation (most compatible, even IE6)
  13946. *
  13947. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  13948. * Opera 11.6+, iOS 4.2+.
  13949. *
  13950. * Due to various browser bugs, sometimes the Object implementation will be used even
  13951. * when the browser supports typed arrays.
  13952. *
  13953. * Note:
  13954. *
  13955. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  13956. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  13957. *
  13958. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  13959. *
  13960. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  13961. * incorrect length in some situations.
  13962. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  13963. * get the Object implementation, which is slower but behaves correctly.
  13964. */
  13965. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  13966. ? global.TYPED_ARRAY_SUPPORT
  13967. : typedArraySupport()
  13968. /*
  13969. * Export kMaxLength after typed array support is determined.
  13970. */
  13971. exports.kMaxLength = kMaxLength()
  13972. function typedArraySupport () {
  13973. try {
  13974. var arr = new Uint8Array(1)
  13975. arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
  13976. return arr.foo() === 42 && // typed array instances can be augmented
  13977. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  13978. arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  13979. } catch (e) {
  13980. return false
  13981. }
  13982. }
  13983. function kMaxLength () {
  13984. return Buffer.TYPED_ARRAY_SUPPORT
  13985. ? 0x7fffffff
  13986. : 0x3fffffff
  13987. }
  13988. function createBuffer (that, length) {
  13989. if (kMaxLength() < length) {
  13990. throw new RangeError('Invalid typed array length')
  13991. }
  13992. if (Buffer.TYPED_ARRAY_SUPPORT) {
  13993. // Return an augmented `Uint8Array` instance, for best performance
  13994. that = new Uint8Array(length)
  13995. that.__proto__ = Buffer.prototype
  13996. } else {
  13997. // Fallback: Return an object instance of the Buffer class
  13998. if (that === null) {
  13999. that = new Buffer(length)
  14000. }
  14001. that.length = length
  14002. }
  14003. return that
  14004. }
  14005. /**
  14006. * The Buffer constructor returns instances of `Uint8Array` that have their
  14007. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  14008. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  14009. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  14010. * returns a single octet.
  14011. *
  14012. * The `Uint8Array` prototype remains unmodified.
  14013. */
  14014. function Buffer (arg, encodingOrOffset, length) {
  14015. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  14016. return new Buffer(arg, encodingOrOffset, length)
  14017. }
  14018. // Common case.
  14019. if (typeof arg === 'number') {
  14020. if (typeof encodingOrOffset === 'string') {
  14021. throw new Error(
  14022. 'If encoding is specified then the first argument must be a string'
  14023. )
  14024. }
  14025. return allocUnsafe(this, arg)
  14026. }
  14027. return from(this, arg, encodingOrOffset, length)
  14028. }
  14029. Buffer.poolSize = 8192 // not used by this implementation
  14030. // TODO: Legacy, not needed anymore. Remove in next major version.
  14031. Buffer._augment = function (arr) {
  14032. arr.__proto__ = Buffer.prototype
  14033. return arr
  14034. }
  14035. function from (that, value, encodingOrOffset, length) {
  14036. if (typeof value === 'number') {
  14037. throw new TypeError('"value" argument must not be a number')
  14038. }
  14039. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  14040. return fromArrayBuffer(that, value, encodingOrOffset, length)
  14041. }
  14042. if (typeof value === 'string') {
  14043. return fromString(that, value, encodingOrOffset)
  14044. }
  14045. return fromObject(that, value)
  14046. }
  14047. /**
  14048. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  14049. * if value is a number.
  14050. * Buffer.from(str[, encoding])
  14051. * Buffer.from(array)
  14052. * Buffer.from(buffer)
  14053. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  14054. **/
  14055. Buffer.from = function (value, encodingOrOffset, length) {
  14056. return from(null, value, encodingOrOffset, length)
  14057. }
  14058. if (Buffer.TYPED_ARRAY_SUPPORT) {
  14059. Buffer.prototype.__proto__ = Uint8Array.prototype
  14060. Buffer.__proto__ = Uint8Array
  14061. if (typeof Symbol !== 'undefined' && Symbol.species &&
  14062. Buffer[Symbol.species] === Buffer) {
  14063. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  14064. Object.defineProperty(Buffer, Symbol.species, {
  14065. value: null,
  14066. configurable: true
  14067. })
  14068. }
  14069. }
  14070. function assertSize (size) {
  14071. if (typeof size !== 'number') {
  14072. throw new TypeError('"size" argument must be a number')
  14073. }
  14074. }
  14075. function alloc (that, size, fill, encoding) {
  14076. assertSize(size)
  14077. if (size <= 0) {
  14078. return createBuffer(that, size)
  14079. }
  14080. if (fill !== undefined) {
  14081. // Only pay attention to encoding if it's a string. This
  14082. // prevents accidentally sending in a number that would
  14083. // be interpretted as a start offset.
  14084. return typeof encoding === 'string'
  14085. ? createBuffer(that, size).fill(fill, encoding)
  14086. : createBuffer(that, size).fill(fill)
  14087. }
  14088. return createBuffer(that, size)
  14089. }
  14090. /**
  14091. * Creates a new filled Buffer instance.
  14092. * alloc(size[, fill[, encoding]])
  14093. **/
  14094. Buffer.alloc = function (size, fill, encoding) {
  14095. return alloc(null, size, fill, encoding)
  14096. }
  14097. function allocUnsafe (that, size) {
  14098. assertSize(size)
  14099. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
  14100. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  14101. for (var i = 0; i < size; ++i) {
  14102. that[i] = 0
  14103. }
  14104. }
  14105. return that
  14106. }
  14107. /**
  14108. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  14109. * */
  14110. Buffer.allocUnsafe = function (size) {
  14111. return allocUnsafe(null, size)
  14112. }
  14113. /**
  14114. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  14115. */
  14116. Buffer.allocUnsafeSlow = function (size) {
  14117. return allocUnsafe(null, size)
  14118. }
  14119. function fromString (that, string, encoding) {
  14120. if (typeof encoding !== 'string' || encoding === '') {
  14121. encoding = 'utf8'
  14122. }
  14123. if (!Buffer.isEncoding(encoding)) {
  14124. throw new TypeError('"encoding" must be a valid string encoding')
  14125. }
  14126. var length = byteLength(string, encoding) | 0
  14127. that = createBuffer(that, length)
  14128. that.write(string, encoding)
  14129. return that
  14130. }
  14131. function fromArrayLike (that, array) {
  14132. var length = checked(array.length) | 0
  14133. that = createBuffer(that, length)
  14134. for (var i = 0; i < length; i += 1) {
  14135. that[i] = array[i] & 255
  14136. }
  14137. return that
  14138. }
  14139. function fromArrayBuffer (that, array, byteOffset, length) {
  14140. array.byteLength // this throws if `array` is not a valid ArrayBuffer
  14141. if (byteOffset < 0 || array.byteLength < byteOffset) {
  14142. throw new RangeError('\'offset\' is out of bounds')
  14143. }
  14144. if (array.byteLength < byteOffset + (length || 0)) {
  14145. throw new RangeError('\'length\' is out of bounds')
  14146. }
  14147. if (length === undefined) {
  14148. array = new Uint8Array(array, byteOffset)
  14149. } else {
  14150. array = new Uint8Array(array, byteOffset, length)
  14151. }
  14152. if (Buffer.TYPED_ARRAY_SUPPORT) {
  14153. // Return an augmented `Uint8Array` instance, for best performance
  14154. that = array
  14155. that.__proto__ = Buffer.prototype
  14156. } else {
  14157. // Fallback: Return an object instance of the Buffer class
  14158. that = fromArrayLike(that, array)
  14159. }
  14160. return that
  14161. }
  14162. function fromObject (that, obj) {
  14163. if (Buffer.isBuffer(obj)) {
  14164. var len = checked(obj.length) | 0
  14165. that = createBuffer(that, len)
  14166. if (that.length === 0) {
  14167. return that
  14168. }
  14169. obj.copy(that, 0, 0, len)
  14170. return that
  14171. }
  14172. if (obj) {
  14173. if ((typeof ArrayBuffer !== 'undefined' &&
  14174. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  14175. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  14176. return createBuffer(that, 0)
  14177. }
  14178. return fromArrayLike(that, obj)
  14179. }
  14180. if (obj.type === 'Buffer' && isArray(obj.data)) {
  14181. return fromArrayLike(that, obj.data)
  14182. }
  14183. }
  14184. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  14185. }
  14186. function checked (length) {
  14187. // Note: cannot use `length < kMaxLength` here because that fails when
  14188. // length is NaN (which is otherwise coerced to zero.)
  14189. if (length >= kMaxLength()) {
  14190. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  14191. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  14192. }
  14193. return length | 0
  14194. }
  14195. function SlowBuffer (length) {
  14196. if (+length != length) { // eslint-disable-line eqeqeq
  14197. length = 0
  14198. }
  14199. return Buffer.alloc(+length)
  14200. }
  14201. Buffer.isBuffer = function isBuffer (b) {
  14202. return !!(b != null && b._isBuffer)
  14203. }
  14204. Buffer.compare = function compare (a, b) {
  14205. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  14206. throw new TypeError('Arguments must be Buffers')
  14207. }
  14208. if (a === b) return 0
  14209. var x = a.length
  14210. var y = b.length
  14211. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  14212. if (a[i] !== b[i]) {
  14213. x = a[i]
  14214. y = b[i]
  14215. break
  14216. }
  14217. }
  14218. if (x < y) return -1
  14219. if (y < x) return 1
  14220. return 0
  14221. }
  14222. Buffer.isEncoding = function isEncoding (encoding) {
  14223. switch (String(encoding).toLowerCase()) {
  14224. case 'hex':
  14225. case 'utf8':
  14226. case 'utf-8':
  14227. case 'ascii':
  14228. case 'binary':
  14229. case 'base64':
  14230. case 'raw':
  14231. case 'ucs2':
  14232. case 'ucs-2':
  14233. case 'utf16le':
  14234. case 'utf-16le':
  14235. return true
  14236. default:
  14237. return false
  14238. }
  14239. }
  14240. Buffer.concat = function concat (list, length) {
  14241. if (!isArray(list)) {
  14242. throw new TypeError('"list" argument must be an Array of Buffers')
  14243. }
  14244. if (list.length === 0) {
  14245. return Buffer.alloc(0)
  14246. }
  14247. var i
  14248. if (length === undefined) {
  14249. length = 0
  14250. for (i = 0; i < list.length; ++i) {
  14251. length += list[i].length
  14252. }
  14253. }
  14254. var buffer = Buffer.allocUnsafe(length)
  14255. var pos = 0
  14256. for (i = 0; i < list.length; ++i) {
  14257. var buf = list[i]
  14258. if (!Buffer.isBuffer(buf)) {
  14259. throw new TypeError('"list" argument must be an Array of Buffers')
  14260. }
  14261. buf.copy(buffer, pos)
  14262. pos += buf.length
  14263. }
  14264. return buffer
  14265. }
  14266. function byteLength (string, encoding) {
  14267. if (Buffer.isBuffer(string)) {
  14268. return string.length
  14269. }
  14270. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  14271. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  14272. return string.byteLength
  14273. }
  14274. if (typeof string !== 'string') {
  14275. string = '' + string
  14276. }
  14277. var len = string.length
  14278. if (len === 0) return 0
  14279. // Use a for loop to avoid recursion
  14280. var loweredCase = false
  14281. for (;;) {
  14282. switch (encoding) {
  14283. case 'ascii':
  14284. case 'binary':
  14285. case 'raw':
  14286. case 'raws':
  14287. return len
  14288. case 'utf8':
  14289. case 'utf-8':
  14290. case undefined:
  14291. return utf8ToBytes(string).length
  14292. case 'ucs2':
  14293. case 'ucs-2':
  14294. case 'utf16le':
  14295. case 'utf-16le':
  14296. return len * 2
  14297. case 'hex':
  14298. return len >>> 1
  14299. case 'base64':
  14300. return base64ToBytes(string).length
  14301. default:
  14302. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  14303. encoding = ('' + encoding).toLowerCase()
  14304. loweredCase = true
  14305. }
  14306. }
  14307. }
  14308. Buffer.byteLength = byteLength
  14309. function slowToString (encoding, start, end) {
  14310. var loweredCase = false
  14311. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  14312. // property of a typed array.
  14313. // This behaves neither like String nor Uint8Array in that we set start/end
  14314. // to their upper/lower bounds if the value passed is out of range.
  14315. // undefined is handled specially as per ECMA-262 6th Edition,
  14316. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  14317. if (start === undefined || start < 0) {
  14318. start = 0
  14319. }
  14320. // Return early if start > this.length. Done here to prevent potential uint32
  14321. // coercion fail below.
  14322. if (start > this.length) {
  14323. return ''
  14324. }
  14325. if (end === undefined || end > this.length) {
  14326. end = this.length
  14327. }
  14328. if (end <= 0) {
  14329. return ''
  14330. }
  14331. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  14332. end >>>= 0
  14333. start >>>= 0
  14334. if (end <= start) {
  14335. return ''
  14336. }
  14337. if (!encoding) encoding = 'utf8'
  14338. while (true) {
  14339. switch (encoding) {
  14340. case 'hex':
  14341. return hexSlice(this, start, end)
  14342. case 'utf8':
  14343. case 'utf-8':
  14344. return utf8Slice(this, start, end)
  14345. case 'ascii':
  14346. return asciiSlice(this, start, end)
  14347. case 'binary':
  14348. return binarySlice(this, start, end)
  14349. case 'base64':
  14350. return base64Slice(this, start, end)
  14351. case 'ucs2':
  14352. case 'ucs-2':
  14353. case 'utf16le':
  14354. case 'utf-16le':
  14355. return utf16leSlice(this, start, end)
  14356. default:
  14357. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  14358. encoding = (encoding + '').toLowerCase()
  14359. loweredCase = true
  14360. }
  14361. }
  14362. }
  14363. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  14364. // Buffer instances.
  14365. Buffer.prototype._isBuffer = true
  14366. function swap (b, n, m) {
  14367. var i = b[n]
  14368. b[n] = b[m]
  14369. b[m] = i
  14370. }
  14371. Buffer.prototype.swap16 = function swap16 () {
  14372. var len = this.length
  14373. if (len % 2 !== 0) {
  14374. throw new RangeError('Buffer size must be a multiple of 16-bits')
  14375. }
  14376. for (var i = 0; i < len; i += 2) {
  14377. swap(this, i, i + 1)
  14378. }
  14379. return this
  14380. }
  14381. Buffer.prototype.swap32 = function swap32 () {
  14382. var len = this.length
  14383. if (len % 4 !== 0) {
  14384. throw new RangeError('Buffer size must be a multiple of 32-bits')
  14385. }
  14386. for (var i = 0; i < len; i += 4) {
  14387. swap(this, i, i + 3)
  14388. swap(this, i + 1, i + 2)
  14389. }
  14390. return this
  14391. }
  14392. Buffer.prototype.toString = function toString () {
  14393. var length = this.length | 0
  14394. if (length === 0) return ''
  14395. if (arguments.length === 0) return utf8Slice(this, 0, length)
  14396. return slowToString.apply(this, arguments)
  14397. }
  14398. Buffer.prototype.equals = function equals (b) {
  14399. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  14400. if (this === b) return true
  14401. return Buffer.compare(this, b) === 0
  14402. }
  14403. Buffer.prototype.inspect = function inspect () {
  14404. var str = ''
  14405. var max = exports.INSPECT_MAX_BYTES
  14406. if (this.length > 0) {
  14407. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  14408. if (this.length > max) str += ' ... '
  14409. }
  14410. return '<Buffer ' + str + '>'
  14411. }
  14412. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  14413. if (!Buffer.isBuffer(target)) {
  14414. throw new TypeError('Argument must be a Buffer')
  14415. }
  14416. if (start === undefined) {
  14417. start = 0
  14418. }
  14419. if (end === undefined) {
  14420. end = target ? target.length : 0
  14421. }
  14422. if (thisStart === undefined) {
  14423. thisStart = 0
  14424. }
  14425. if (thisEnd === undefined) {
  14426. thisEnd = this.length
  14427. }
  14428. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  14429. throw new RangeError('out of range index')
  14430. }
  14431. if (thisStart >= thisEnd && start >= end) {
  14432. return 0
  14433. }
  14434. if (thisStart >= thisEnd) {
  14435. return -1
  14436. }
  14437. if (start >= end) {
  14438. return 1
  14439. }
  14440. start >>>= 0
  14441. end >>>= 0
  14442. thisStart >>>= 0
  14443. thisEnd >>>= 0
  14444. if (this === target) return 0
  14445. var x = thisEnd - thisStart
  14446. var y = end - start
  14447. var len = Math.min(x, y)
  14448. var thisCopy = this.slice(thisStart, thisEnd)
  14449. var targetCopy = target.slice(start, end)
  14450. for (var i = 0; i < len; ++i) {
  14451. if (thisCopy[i] !== targetCopy[i]) {
  14452. x = thisCopy[i]
  14453. y = targetCopy[i]
  14454. break
  14455. }
  14456. }
  14457. if (x < y) return -1
  14458. if (y < x) return 1
  14459. return 0
  14460. }
  14461. function arrayIndexOf (arr, val, byteOffset, encoding) {
  14462. var indexSize = 1
  14463. var arrLength = arr.length
  14464. var valLength = val.length
  14465. if (encoding !== undefined) {
  14466. encoding = String(encoding).toLowerCase()
  14467. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  14468. encoding === 'utf16le' || encoding === 'utf-16le') {
  14469. if (arr.length < 2 || val.length < 2) {
  14470. return -1
  14471. }
  14472. indexSize = 2
  14473. arrLength /= 2
  14474. valLength /= 2
  14475. byteOffset /= 2
  14476. }
  14477. }
  14478. function read (buf, i) {
  14479. if (indexSize === 1) {
  14480. return buf[i]
  14481. } else {
  14482. return buf.readUInt16BE(i * indexSize)
  14483. }
  14484. }
  14485. var foundIndex = -1
  14486. for (var i = byteOffset; i < arrLength; ++i) {
  14487. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  14488. if (foundIndex === -1) foundIndex = i
  14489. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  14490. } else {
  14491. if (foundIndex !== -1) i -= i - foundIndex
  14492. foundIndex = -1
  14493. }
  14494. }
  14495. return -1
  14496. }
  14497. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  14498. if (typeof byteOffset === 'string') {
  14499. encoding = byteOffset
  14500. byteOffset = 0
  14501. } else if (byteOffset > 0x7fffffff) {
  14502. byteOffset = 0x7fffffff
  14503. } else if (byteOffset < -0x80000000) {
  14504. byteOffset = -0x80000000
  14505. }
  14506. byteOffset >>= 0
  14507. if (this.length === 0) return -1
  14508. if (byteOffset >= this.length) return -1
  14509. // Negative offsets start from the end of the buffer
  14510. if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0)
  14511. if (typeof val === 'string') {
  14512. val = Buffer.from(val, encoding)
  14513. }
  14514. if (Buffer.isBuffer(val)) {
  14515. // special case: looking for empty string/buffer always fails
  14516. if (val.length === 0) {
  14517. return -1
  14518. }
  14519. return arrayIndexOf(this, val, byteOffset, encoding)
  14520. }
  14521. if (typeof val === 'number') {
  14522. if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') {
  14523. return Uint8Array.prototype.indexOf.call(this, val, byteOffset)
  14524. }
  14525. return arrayIndexOf(this, [ val ], byteOffset, encoding)
  14526. }
  14527. throw new TypeError('val must be string, number or Buffer')
  14528. }
  14529. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  14530. return this.indexOf(val, byteOffset, encoding) !== -1
  14531. }
  14532. function hexWrite (buf, string, offset, length) {
  14533. offset = Number(offset) || 0
  14534. var remaining = buf.length - offset
  14535. if (!length) {
  14536. length = remaining
  14537. } else {
  14538. length = Number(length)
  14539. if (length > remaining) {
  14540. length = remaining
  14541. }
  14542. }
  14543. // must be an even number of digits
  14544. var strLen = string.length
  14545. if (strLen % 2 !== 0) throw new Error('Invalid hex string')
  14546. if (length > strLen / 2) {
  14547. length = strLen / 2
  14548. }
  14549. for (var i = 0; i < length; ++i) {
  14550. var parsed = parseInt(string.substr(i * 2, 2), 16)
  14551. if (isNaN(parsed)) return i
  14552. buf[offset + i] = parsed
  14553. }
  14554. return i
  14555. }
  14556. function utf8Write (buf, string, offset, length) {
  14557. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  14558. }
  14559. function asciiWrite (buf, string, offset, length) {
  14560. return blitBuffer(asciiToBytes(string), buf, offset, length)
  14561. }
  14562. function binaryWrite (buf, string, offset, length) {
  14563. return asciiWrite(buf, string, offset, length)
  14564. }
  14565. function base64Write (buf, string, offset, length) {
  14566. return blitBuffer(base64ToBytes(string), buf, offset, length)
  14567. }
  14568. function ucs2Write (buf, string, offset, length) {
  14569. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  14570. }
  14571. Buffer.prototype.write = function write (string, offset, length, encoding) {
  14572. // Buffer#write(string)
  14573. if (offset === undefined) {
  14574. encoding = 'utf8'
  14575. length = this.length
  14576. offset = 0
  14577. // Buffer#write(string, encoding)
  14578. } else if (length === undefined && typeof offset === 'string') {
  14579. encoding = offset
  14580. length = this.length
  14581. offset = 0
  14582. // Buffer#write(string, offset[, length][, encoding])
  14583. } else if (isFinite(offset)) {
  14584. offset = offset | 0
  14585. if (isFinite(length)) {
  14586. length = length | 0
  14587. if (encoding === undefined) encoding = 'utf8'
  14588. } else {
  14589. encoding = length
  14590. length = undefined
  14591. }
  14592. // legacy write(string, encoding, offset, length) - remove in v0.13
  14593. } else {
  14594. throw new Error(
  14595. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  14596. )
  14597. }
  14598. var remaining = this.length - offset
  14599. if (length === undefined || length > remaining) length = remaining
  14600. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  14601. throw new RangeError('Attempt to write outside buffer bounds')
  14602. }
  14603. if (!encoding) encoding = 'utf8'
  14604. var loweredCase = false
  14605. for (;;) {
  14606. switch (encoding) {
  14607. case 'hex':
  14608. return hexWrite(this, string, offset, length)
  14609. case 'utf8':
  14610. case 'utf-8':
  14611. return utf8Write(this, string, offset, length)
  14612. case 'ascii':
  14613. return asciiWrite(this, string, offset, length)
  14614. case 'binary':
  14615. return binaryWrite(this, string, offset, length)
  14616. case 'base64':
  14617. // Warning: maxLength not taken into account in base64Write
  14618. return base64Write(this, string, offset, length)
  14619. case 'ucs2':
  14620. case 'ucs-2':
  14621. case 'utf16le':
  14622. case 'utf-16le':
  14623. return ucs2Write(this, string, offset, length)
  14624. default:
  14625. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  14626. encoding = ('' + encoding).toLowerCase()
  14627. loweredCase = true
  14628. }
  14629. }
  14630. }
  14631. Buffer.prototype.toJSON = function toJSON () {
  14632. return {
  14633. type: 'Buffer',
  14634. data: Array.prototype.slice.call(this._arr || this, 0)
  14635. }
  14636. }
  14637. function base64Slice (buf, start, end) {
  14638. if (start === 0 && end === buf.length) {
  14639. return base64.fromByteArray(buf)
  14640. } else {
  14641. return base64.fromByteArray(buf.slice(start, end))
  14642. }
  14643. }
  14644. function utf8Slice (buf, start, end) {
  14645. end = Math.min(buf.length, end)
  14646. var res = []
  14647. var i = start
  14648. while (i < end) {
  14649. var firstByte = buf[i]
  14650. var codePoint = null
  14651. var bytesPerSequence = (firstByte > 0xEF) ? 4
  14652. : (firstByte > 0xDF) ? 3
  14653. : (firstByte > 0xBF) ? 2
  14654. : 1
  14655. if (i + bytesPerSequence <= end) {
  14656. var secondByte, thirdByte, fourthByte, tempCodePoint
  14657. switch (bytesPerSequence) {
  14658. case 1:
  14659. if (firstByte < 0x80) {
  14660. codePoint = firstByte
  14661. }
  14662. break
  14663. case 2:
  14664. secondByte = buf[i + 1]
  14665. if ((secondByte & 0xC0) === 0x80) {
  14666. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  14667. if (tempCodePoint > 0x7F) {
  14668. codePoint = tempCodePoint
  14669. }
  14670. }
  14671. break
  14672. case 3:
  14673. secondByte = buf[i + 1]
  14674. thirdByte = buf[i + 2]
  14675. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  14676. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  14677. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  14678. codePoint = tempCodePoint
  14679. }
  14680. }
  14681. break
  14682. case 4:
  14683. secondByte = buf[i + 1]
  14684. thirdByte = buf[i + 2]
  14685. fourthByte = buf[i + 3]
  14686. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  14687. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  14688. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  14689. codePoint = tempCodePoint
  14690. }
  14691. }
  14692. }
  14693. }
  14694. if (codePoint === null) {
  14695. // we did not generate a valid codePoint so insert a
  14696. // replacement char (U+FFFD) and advance only 1 byte
  14697. codePoint = 0xFFFD
  14698. bytesPerSequence = 1
  14699. } else if (codePoint > 0xFFFF) {
  14700. // encode to utf16 (surrogate pair dance)
  14701. codePoint -= 0x10000
  14702. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  14703. codePoint = 0xDC00 | codePoint & 0x3FF
  14704. }
  14705. res.push(codePoint)
  14706. i += bytesPerSequence
  14707. }
  14708. return decodeCodePointsArray(res)
  14709. }
  14710. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  14711. // the lowest limit is Chrome, with 0x10000 args.
  14712. // We go 1 magnitude less, for safety
  14713. var MAX_ARGUMENTS_LENGTH = 0x1000
  14714. function decodeCodePointsArray (codePoints) {
  14715. var len = codePoints.length
  14716. if (len <= MAX_ARGUMENTS_LENGTH) {
  14717. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  14718. }
  14719. // Decode in chunks to avoid "call stack size exceeded".
  14720. var res = ''
  14721. var i = 0
  14722. while (i < len) {
  14723. res += String.fromCharCode.apply(
  14724. String,
  14725. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  14726. )
  14727. }
  14728. return res
  14729. }
  14730. function asciiSlice (buf, start, end) {
  14731. var ret = ''
  14732. end = Math.min(buf.length, end)
  14733. for (var i = start; i < end; ++i) {
  14734. ret += String.fromCharCode(buf[i] & 0x7F)
  14735. }
  14736. return ret
  14737. }
  14738. function binarySlice (buf, start, end) {
  14739. var ret = ''
  14740. end = Math.min(buf.length, end)
  14741. for (var i = start; i < end; ++i) {
  14742. ret += String.fromCharCode(buf[i])
  14743. }
  14744. return ret
  14745. }
  14746. function hexSlice (buf, start, end) {
  14747. var len = buf.length
  14748. if (!start || start < 0) start = 0
  14749. if (!end || end < 0 || end > len) end = len
  14750. var out = ''
  14751. for (var i = start; i < end; ++i) {
  14752. out += toHex(buf[i])
  14753. }
  14754. return out
  14755. }
  14756. function utf16leSlice (buf, start, end) {
  14757. var bytes = buf.slice(start, end)
  14758. var res = ''
  14759. for (var i = 0; i < bytes.length; i += 2) {
  14760. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  14761. }
  14762. return res
  14763. }
  14764. Buffer.prototype.slice = function slice (start, end) {
  14765. var len = this.length
  14766. start = ~~start
  14767. end = end === undefined ? len : ~~end
  14768. if (start < 0) {
  14769. start += len
  14770. if (start < 0) start = 0
  14771. } else if (start > len) {
  14772. start = len
  14773. }
  14774. if (end < 0) {
  14775. end += len
  14776. if (end < 0) end = 0
  14777. } else if (end > len) {
  14778. end = len
  14779. }
  14780. if (end < start) end = start
  14781. var newBuf
  14782. if (Buffer.TYPED_ARRAY_SUPPORT) {
  14783. newBuf = this.subarray(start, end)
  14784. newBuf.__proto__ = Buffer.prototype
  14785. } else {
  14786. var sliceLen = end - start
  14787. newBuf = new Buffer(sliceLen, undefined)
  14788. for (var i = 0; i < sliceLen; ++i) {
  14789. newBuf[i] = this[i + start]
  14790. }
  14791. }
  14792. return newBuf
  14793. }
  14794. /*
  14795. * Need to make sure that buffer isn't trying to write out of bounds.
  14796. */
  14797. function checkOffset (offset, ext, length) {
  14798. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  14799. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  14800. }
  14801. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  14802. offset = offset | 0
  14803. byteLength = byteLength | 0
  14804. if (!noAssert) checkOffset(offset, byteLength, this.length)
  14805. var val = this[offset]
  14806. var mul = 1
  14807. var i = 0
  14808. while (++i < byteLength && (mul *= 0x100)) {
  14809. val += this[offset + i] * mul
  14810. }
  14811. return val
  14812. }
  14813. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  14814. offset = offset | 0
  14815. byteLength = byteLength | 0
  14816. if (!noAssert) {
  14817. checkOffset(offset, byteLength, this.length)
  14818. }
  14819. var val = this[offset + --byteLength]
  14820. var mul = 1
  14821. while (byteLength > 0 && (mul *= 0x100)) {
  14822. val += this[offset + --byteLength] * mul
  14823. }
  14824. return val
  14825. }
  14826. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  14827. if (!noAssert) checkOffset(offset, 1, this.length)
  14828. return this[offset]
  14829. }
  14830. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  14831. if (!noAssert) checkOffset(offset, 2, this.length)
  14832. return this[offset] | (this[offset + 1] << 8)
  14833. }
  14834. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  14835. if (!noAssert) checkOffset(offset, 2, this.length)
  14836. return (this[offset] << 8) | this[offset + 1]
  14837. }
  14838. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  14839. if (!noAssert) checkOffset(offset, 4, this.length)
  14840. return ((this[offset]) |
  14841. (this[offset + 1] << 8) |
  14842. (this[offset + 2] << 16)) +
  14843. (this[offset + 3] * 0x1000000)
  14844. }
  14845. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  14846. if (!noAssert) checkOffset(offset, 4, this.length)
  14847. return (this[offset] * 0x1000000) +
  14848. ((this[offset + 1] << 16) |
  14849. (this[offset + 2] << 8) |
  14850. this[offset + 3])
  14851. }
  14852. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  14853. offset = offset | 0
  14854. byteLength = byteLength | 0
  14855. if (!noAssert) checkOffset(offset, byteLength, this.length)
  14856. var val = this[offset]
  14857. var mul = 1
  14858. var i = 0
  14859. while (++i < byteLength && (mul *= 0x100)) {
  14860. val += this[offset + i] * mul
  14861. }
  14862. mul *= 0x80
  14863. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  14864. return val
  14865. }
  14866. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  14867. offset = offset | 0
  14868. byteLength = byteLength | 0
  14869. if (!noAssert) checkOffset(offset, byteLength, this.length)
  14870. var i = byteLength
  14871. var mul = 1
  14872. var val = this[offset + --i]
  14873. while (i > 0 && (mul *= 0x100)) {
  14874. val += this[offset + --i] * mul
  14875. }
  14876. mul *= 0x80
  14877. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  14878. return val
  14879. }
  14880. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  14881. if (!noAssert) checkOffset(offset, 1, this.length)
  14882. if (!(this[offset] & 0x80)) return (this[offset])
  14883. return ((0xff - this[offset] + 1) * -1)
  14884. }
  14885. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  14886. if (!noAssert) checkOffset(offset, 2, this.length)
  14887. var val = this[offset] | (this[offset + 1] << 8)
  14888. return (val & 0x8000) ? val | 0xFFFF0000 : val
  14889. }
  14890. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  14891. if (!noAssert) checkOffset(offset, 2, this.length)
  14892. var val = this[offset + 1] | (this[offset] << 8)
  14893. return (val & 0x8000) ? val | 0xFFFF0000 : val
  14894. }
  14895. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  14896. if (!noAssert) checkOffset(offset, 4, this.length)
  14897. return (this[offset]) |
  14898. (this[offset + 1] << 8) |
  14899. (this[offset + 2] << 16) |
  14900. (this[offset + 3] << 24)
  14901. }
  14902. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  14903. if (!noAssert) checkOffset(offset, 4, this.length)
  14904. return (this[offset] << 24) |
  14905. (this[offset + 1] << 16) |
  14906. (this[offset + 2] << 8) |
  14907. (this[offset + 3])
  14908. }
  14909. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  14910. if (!noAssert) checkOffset(offset, 4, this.length)
  14911. return ieee754.read(this, offset, true, 23, 4)
  14912. }
  14913. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  14914. if (!noAssert) checkOffset(offset, 4, this.length)
  14915. return ieee754.read(this, offset, false, 23, 4)
  14916. }
  14917. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  14918. if (!noAssert) checkOffset(offset, 8, this.length)
  14919. return ieee754.read(this, offset, true, 52, 8)
  14920. }
  14921. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  14922. if (!noAssert) checkOffset(offset, 8, this.length)
  14923. return ieee754.read(this, offset, false, 52, 8)
  14924. }
  14925. function checkInt (buf, value, offset, ext, max, min) {
  14926. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  14927. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  14928. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  14929. }
  14930. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  14931. value = +value
  14932. offset = offset | 0
  14933. byteLength = byteLength | 0
  14934. if (!noAssert) {
  14935. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  14936. checkInt(this, value, offset, byteLength, maxBytes, 0)
  14937. }
  14938. var mul = 1
  14939. var i = 0
  14940. this[offset] = value & 0xFF
  14941. while (++i < byteLength && (mul *= 0x100)) {
  14942. this[offset + i] = (value / mul) & 0xFF
  14943. }
  14944. return offset + byteLength
  14945. }
  14946. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  14947. value = +value
  14948. offset = offset | 0
  14949. byteLength = byteLength | 0
  14950. if (!noAssert) {
  14951. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  14952. checkInt(this, value, offset, byteLength, maxBytes, 0)
  14953. }
  14954. var i = byteLength - 1
  14955. var mul = 1
  14956. this[offset + i] = value & 0xFF
  14957. while (--i >= 0 && (mul *= 0x100)) {
  14958. this[offset + i] = (value / mul) & 0xFF
  14959. }
  14960. return offset + byteLength
  14961. }
  14962. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  14963. value = +value
  14964. offset = offset | 0
  14965. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  14966. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  14967. this[offset] = (value & 0xff)
  14968. return offset + 1
  14969. }
  14970. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  14971. if (value < 0) value = 0xffff + value + 1
  14972. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  14973. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  14974. (littleEndian ? i : 1 - i) * 8
  14975. }
  14976. }
  14977. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  14978. value = +value
  14979. offset = offset | 0
  14980. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  14981. if (Buffer.TYPED_ARRAY_SUPPORT) {
  14982. this[offset] = (value & 0xff)
  14983. this[offset + 1] = (value >>> 8)
  14984. } else {
  14985. objectWriteUInt16(this, value, offset, true)
  14986. }
  14987. return offset + 2
  14988. }
  14989. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  14990. value = +value
  14991. offset = offset | 0
  14992. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  14993. if (Buffer.TYPED_ARRAY_SUPPORT) {
  14994. this[offset] = (value >>> 8)
  14995. this[offset + 1] = (value & 0xff)
  14996. } else {
  14997. objectWriteUInt16(this, value, offset, false)
  14998. }
  14999. return offset + 2
  15000. }
  15001. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  15002. if (value < 0) value = 0xffffffff + value + 1
  15003. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  15004. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  15005. }
  15006. }
  15007. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  15008. value = +value
  15009. offset = offset | 0
  15010. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  15011. if (Buffer.TYPED_ARRAY_SUPPORT) {
  15012. this[offset + 3] = (value >>> 24)
  15013. this[offset + 2] = (value >>> 16)
  15014. this[offset + 1] = (value >>> 8)
  15015. this[offset] = (value & 0xff)
  15016. } else {
  15017. objectWriteUInt32(this, value, offset, true)
  15018. }
  15019. return offset + 4
  15020. }
  15021. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  15022. value = +value
  15023. offset = offset | 0
  15024. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  15025. if (Buffer.TYPED_ARRAY_SUPPORT) {
  15026. this[offset] = (value >>> 24)
  15027. this[offset + 1] = (value >>> 16)
  15028. this[offset + 2] = (value >>> 8)
  15029. this[offset + 3] = (value & 0xff)
  15030. } else {
  15031. objectWriteUInt32(this, value, offset, false)
  15032. }
  15033. return offset + 4
  15034. }
  15035. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  15036. value = +value
  15037. offset = offset | 0
  15038. if (!noAssert) {
  15039. var limit = Math.pow(2, 8 * byteLength - 1)
  15040. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  15041. }
  15042. var i = 0
  15043. var mul = 1
  15044. var sub = 0
  15045. this[offset] = value & 0xFF
  15046. while (++i < byteLength && (mul *= 0x100)) {
  15047. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  15048. sub = 1
  15049. }
  15050. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  15051. }
  15052. return offset + byteLength
  15053. }
  15054. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  15055. value = +value
  15056. offset = offset | 0
  15057. if (!noAssert) {
  15058. var limit = Math.pow(2, 8 * byteLength - 1)
  15059. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  15060. }
  15061. var i = byteLength - 1
  15062. var mul = 1
  15063. var sub = 0
  15064. this[offset + i] = value & 0xFF
  15065. while (--i >= 0 && (mul *= 0x100)) {
  15066. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  15067. sub = 1
  15068. }
  15069. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  15070. }
  15071. return offset + byteLength
  15072. }
  15073. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  15074. value = +value
  15075. offset = offset | 0
  15076. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  15077. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  15078. if (value < 0) value = 0xff + value + 1
  15079. this[offset] = (value & 0xff)
  15080. return offset + 1
  15081. }
  15082. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  15083. value = +value
  15084. offset = offset | 0
  15085. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  15086. if (Buffer.TYPED_ARRAY_SUPPORT) {
  15087. this[offset] = (value & 0xff)
  15088. this[offset + 1] = (value >>> 8)
  15089. } else {
  15090. objectWriteUInt16(this, value, offset, true)
  15091. }
  15092. return offset + 2
  15093. }
  15094. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  15095. value = +value
  15096. offset = offset | 0
  15097. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  15098. if (Buffer.TYPED_ARRAY_SUPPORT) {
  15099. this[offset] = (value >>> 8)
  15100. this[offset + 1] = (value & 0xff)
  15101. } else {
  15102. objectWriteUInt16(this, value, offset, false)
  15103. }
  15104. return offset + 2
  15105. }
  15106. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  15107. value = +value
  15108. offset = offset | 0
  15109. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  15110. if (Buffer.TYPED_ARRAY_SUPPORT) {
  15111. this[offset] = (value & 0xff)
  15112. this[offset + 1] = (value >>> 8)
  15113. this[offset + 2] = (value >>> 16)
  15114. this[offset + 3] = (value >>> 24)
  15115. } else {
  15116. objectWriteUInt32(this, value, offset, true)
  15117. }
  15118. return offset + 4
  15119. }
  15120. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  15121. value = +value
  15122. offset = offset | 0
  15123. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  15124. if (value < 0) value = 0xffffffff + value + 1
  15125. if (Buffer.TYPED_ARRAY_SUPPORT) {
  15126. this[offset] = (value >>> 24)
  15127. this[offset + 1] = (value >>> 16)
  15128. this[offset + 2] = (value >>> 8)
  15129. this[offset + 3] = (value & 0xff)
  15130. } else {
  15131. objectWriteUInt32(this, value, offset, false)
  15132. }
  15133. return offset + 4
  15134. }
  15135. function checkIEEE754 (buf, value, offset, ext, max, min) {
  15136. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  15137. if (offset < 0) throw new RangeError('Index out of range')
  15138. }
  15139. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  15140. if (!noAssert) {
  15141. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  15142. }
  15143. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  15144. return offset + 4
  15145. }
  15146. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  15147. return writeFloat(this, value, offset, true, noAssert)
  15148. }
  15149. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  15150. return writeFloat(this, value, offset, false, noAssert)
  15151. }
  15152. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  15153. if (!noAssert) {
  15154. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  15155. }
  15156. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  15157. return offset + 8
  15158. }
  15159. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  15160. return writeDouble(this, value, offset, true, noAssert)
  15161. }
  15162. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  15163. return writeDouble(this, value, offset, false, noAssert)
  15164. }
  15165. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  15166. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  15167. if (!start) start = 0
  15168. if (!end && end !== 0) end = this.length
  15169. if (targetStart >= target.length) targetStart = target.length
  15170. if (!targetStart) targetStart = 0
  15171. if (end > 0 && end < start) end = start
  15172. // Copy 0 bytes; we're done
  15173. if (end === start) return 0
  15174. if (target.length === 0 || this.length === 0) return 0
  15175. // Fatal error conditions
  15176. if (targetStart < 0) {
  15177. throw new RangeError('targetStart out of bounds')
  15178. }
  15179. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  15180. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  15181. // Are we oob?
  15182. if (end > this.length) end = this.length
  15183. if (target.length - targetStart < end - start) {
  15184. end = target.length - targetStart + start
  15185. }
  15186. var len = end - start
  15187. var i
  15188. if (this === target && start < targetStart && targetStart < end) {
  15189. // descending copy from end
  15190. for (i = len - 1; i >= 0; --i) {
  15191. target[i + targetStart] = this[i + start]
  15192. }
  15193. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  15194. // ascending copy from start
  15195. for (i = 0; i < len; ++i) {
  15196. target[i + targetStart] = this[i + start]
  15197. }
  15198. } else {
  15199. Uint8Array.prototype.set.call(
  15200. target,
  15201. this.subarray(start, start + len),
  15202. targetStart
  15203. )
  15204. }
  15205. return len
  15206. }
  15207. // Usage:
  15208. // buffer.fill(number[, offset[, end]])
  15209. // buffer.fill(buffer[, offset[, end]])
  15210. // buffer.fill(string[, offset[, end]][, encoding])
  15211. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  15212. // Handle string cases:
  15213. if (typeof val === 'string') {
  15214. if (typeof start === 'string') {
  15215. encoding = start
  15216. start = 0
  15217. end = this.length
  15218. } else if (typeof end === 'string') {
  15219. encoding = end
  15220. end = this.length
  15221. }
  15222. if (val.length === 1) {
  15223. var code = val.charCodeAt(0)
  15224. if (code < 256) {
  15225. val = code
  15226. }
  15227. }
  15228. if (encoding !== undefined && typeof encoding !== 'string') {
  15229. throw new TypeError('encoding must be a string')
  15230. }
  15231. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  15232. throw new TypeError('Unknown encoding: ' + encoding)
  15233. }
  15234. } else if (typeof val === 'number') {
  15235. val = val & 255
  15236. }
  15237. // Invalid ranges are not set to a default, so can range check early.
  15238. if (start < 0 || this.length < start || this.length < end) {
  15239. throw new RangeError('Out of range index')
  15240. }
  15241. if (end <= start) {
  15242. return this
  15243. }
  15244. start = start >>> 0
  15245. end = end === undefined ? this.length : end >>> 0
  15246. if (!val) val = 0
  15247. var i
  15248. if (typeof val === 'number') {
  15249. for (i = start; i < end; ++i) {
  15250. this[i] = val
  15251. }
  15252. } else {
  15253. var bytes = Buffer.isBuffer(val)
  15254. ? val
  15255. : utf8ToBytes(new Buffer(val, encoding).toString())
  15256. var len = bytes.length
  15257. for (i = 0; i < end - start; ++i) {
  15258. this[i + start] = bytes[i % len]
  15259. }
  15260. }
  15261. return this
  15262. }
  15263. // HELPER FUNCTIONS
  15264. // ================
  15265. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  15266. function base64clean (str) {
  15267. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  15268. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  15269. // Node converts strings with length < 2 to ''
  15270. if (str.length < 2) return ''
  15271. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  15272. while (str.length % 4 !== 0) {
  15273. str = str + '='
  15274. }
  15275. return str
  15276. }
  15277. function stringtrim (str) {
  15278. if (str.trim) return str.trim()
  15279. return str.replace(/^\s+|\s+$/g, '')
  15280. }
  15281. function toHex (n) {
  15282. if (n < 16) return '0' + n.toString(16)
  15283. return n.toString(16)
  15284. }
  15285. function utf8ToBytes (string, units) {
  15286. units = units || Infinity
  15287. var codePoint
  15288. var length = string.length
  15289. var leadSurrogate = null
  15290. var bytes = []
  15291. for (var i = 0; i < length; ++i) {
  15292. codePoint = string.charCodeAt(i)
  15293. // is surrogate component
  15294. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  15295. // last char was a lead
  15296. if (!leadSurrogate) {
  15297. // no lead yet
  15298. if (codePoint > 0xDBFF) {
  15299. // unexpected trail
  15300. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  15301. continue
  15302. } else if (i + 1 === length) {
  15303. // unpaired lead
  15304. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  15305. continue
  15306. }
  15307. // valid lead
  15308. leadSurrogate = codePoint
  15309. continue
  15310. }
  15311. // 2 leads in a row
  15312. if (codePoint < 0xDC00) {
  15313. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  15314. leadSurrogate = codePoint
  15315. continue
  15316. }
  15317. // valid surrogate pair
  15318. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  15319. } else if (leadSurrogate) {
  15320. // valid bmp char, but last char was a lead
  15321. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  15322. }
  15323. leadSurrogate = null
  15324. // encode utf8
  15325. if (codePoint < 0x80) {
  15326. if ((units -= 1) < 0) break
  15327. bytes.push(codePoint)
  15328. } else if (codePoint < 0x800) {
  15329. if ((units -= 2) < 0) break
  15330. bytes.push(
  15331. codePoint >> 0x6 | 0xC0,
  15332. codePoint & 0x3F | 0x80
  15333. )
  15334. } else if (codePoint < 0x10000) {
  15335. if ((units -= 3) < 0) break
  15336. bytes.push(
  15337. codePoint >> 0xC | 0xE0,
  15338. codePoint >> 0x6 & 0x3F | 0x80,
  15339. codePoint & 0x3F | 0x80
  15340. )
  15341. } else if (codePoint < 0x110000) {
  15342. if ((units -= 4) < 0) break
  15343. bytes.push(
  15344. codePoint >> 0x12 | 0xF0,
  15345. codePoint >> 0xC & 0x3F | 0x80,
  15346. codePoint >> 0x6 & 0x3F | 0x80,
  15347. codePoint & 0x3F | 0x80
  15348. )
  15349. } else {
  15350. throw new Error('Invalid code point')
  15351. }
  15352. }
  15353. return bytes
  15354. }
  15355. function asciiToBytes (str) {
  15356. var byteArray = []
  15357. for (var i = 0; i < str.length; ++i) {
  15358. // Node's code seems to be doing this and not & 0x7F..
  15359. byteArray.push(str.charCodeAt(i) & 0xFF)
  15360. }
  15361. return byteArray
  15362. }
  15363. function utf16leToBytes (str, units) {
  15364. var c, hi, lo
  15365. var byteArray = []
  15366. for (var i = 0; i < str.length; ++i) {
  15367. if ((units -= 2) < 0) break
  15368. c = str.charCodeAt(i)
  15369. hi = c >> 8
  15370. lo = c % 256
  15371. byteArray.push(lo)
  15372. byteArray.push(hi)
  15373. }
  15374. return byteArray
  15375. }
  15376. function base64ToBytes (str) {
  15377. return base64.toByteArray(base64clean(str))
  15378. }
  15379. function blitBuffer (src, dst, offset, length) {
  15380. for (var i = 0; i < length; ++i) {
  15381. if ((i + offset >= dst.length) || (i >= src.length)) break
  15382. dst[i + offset] = src[i]
  15383. }
  15384. return i
  15385. }
  15386. function isnan (val) {
  15387. return val !== val // eslint-disable-line no-self-compare
  15388. }
  15389. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer, __webpack_require__(13)))
  15390. /***/ },
  15391. /* 2 */
  15392. /***/ function(module, exports) {
  15393. if (typeof Object.create === 'function') {
  15394. // implementation from standard node.js 'util' module
  15395. module.exports = function inherits(ctor, superCtor) {
  15396. ctor.super_ = superCtor
  15397. ctor.prototype = Object.create(superCtor.prototype, {
  15398. constructor: {
  15399. value: ctor,
  15400. enumerable: false,
  15401. writable: true,
  15402. configurable: true
  15403. }
  15404. });
  15405. };
  15406. } else {
  15407. // old school shim for old browsers
  15408. module.exports = function inherits(ctor, superCtor) {
  15409. ctor.super_ = superCtor
  15410. var TempCtor = function () {}
  15411. TempCtor.prototype = superCtor.prototype
  15412. ctor.prototype = new TempCtor()
  15413. ctor.prototype.constructor = ctor
  15414. }
  15415. }
  15416. /***/ },
  15417. /* 3 */
  15418. /***/ function(module, exports, __webpack_require__) {
  15419. var isObject = __webpack_require__(7);
  15420. module.exports = function(it){
  15421. if(!isObject(it))throw TypeError(it + ' is not an object!');
  15422. return it;
  15423. };
  15424. /***/ },
  15425. /* 4 */
  15426. /***/ function(module, exports) {
  15427. // shim for using process in browser
  15428. var process = module.exports = {};
  15429. // cached from whatever global is present so that test runners that stub it
  15430. // don't break things. But we need to wrap it in a try catch in case it is
  15431. // wrapped in strict mode code which doesn't define any globals. It's inside a
  15432. // function because try/catches deoptimize in certain engines.
  15433. var cachedSetTimeout;
  15434. var cachedClearTimeout;
  15435. (function () {
  15436. try {
  15437. cachedSetTimeout = setTimeout;
  15438. } catch (e) {
  15439. cachedSetTimeout = function () {
  15440. throw new Error('setTimeout is not defined');
  15441. }
  15442. }
  15443. try {
  15444. cachedClearTimeout = clearTimeout;
  15445. } catch (e) {
  15446. cachedClearTimeout = function () {
  15447. throw new Error('clearTimeout is not defined');
  15448. }
  15449. }
  15450. } ())
  15451. var queue = [];
  15452. var draining = false;
  15453. var currentQueue;
  15454. var queueIndex = -1;
  15455. function cleanUpNextTick() {
  15456. if (!draining || !currentQueue) {
  15457. return;
  15458. }
  15459. draining = false;
  15460. if (currentQueue.length) {
  15461. queue = currentQueue.concat(queue);
  15462. } else {
  15463. queueIndex = -1;
  15464. }
  15465. if (queue.length) {
  15466. drainQueue();
  15467. }
  15468. }
  15469. function drainQueue() {
  15470. if (draining) {
  15471. return;
  15472. }
  15473. var timeout = cachedSetTimeout(cleanUpNextTick);
  15474. draining = true;
  15475. var len = queue.length;
  15476. while(len) {
  15477. currentQueue = queue;
  15478. queue = [];
  15479. while (++queueIndex < len) {
  15480. if (currentQueue) {
  15481. currentQueue[queueIndex].run();
  15482. }
  15483. }
  15484. queueIndex = -1;
  15485. len = queue.length;
  15486. }
  15487. currentQueue = null;
  15488. draining = false;
  15489. cachedClearTimeout(timeout);
  15490. }
  15491. process.nextTick = function (fun) {
  15492. var args = new Array(arguments.length - 1);
  15493. if (arguments.length > 1) {
  15494. for (var i = 1; i < arguments.length; i++) {
  15495. args[i - 1] = arguments[i];
  15496. }
  15497. }
  15498. queue.push(new Item(fun, args));
  15499. if (queue.length === 1 && !draining) {
  15500. cachedSetTimeout(drainQueue, 0);
  15501. }
  15502. };
  15503. // v8 likes predictible objects
  15504. function Item(fun, array) {
  15505. this.fun = fun;
  15506. this.array = array;
  15507. }
  15508. Item.prototype.run = function () {
  15509. this.fun.apply(null, this.array);
  15510. };
  15511. process.title = 'browser';
  15512. process.browser = true;
  15513. process.env = {};
  15514. process.argv = [];
  15515. process.version = ''; // empty string to avoid regexp issues
  15516. process.versions = {};
  15517. function noop() {}
  15518. process.on = noop;
  15519. process.addListener = noop;
  15520. process.once = noop;
  15521. process.off = noop;
  15522. process.removeListener = noop;
  15523. process.removeAllListeners = noop;
  15524. process.emit = noop;
  15525. process.binding = function (name) {
  15526. throw new Error('process.binding is not supported');
  15527. };
  15528. process.cwd = function () { return '/' };
  15529. process.chdir = function (dir) {
  15530. throw new Error('process.chdir is not supported');
  15531. };
  15532. process.umask = function() { return 0; };
  15533. /***/ },
  15534. /* 5 */
  15535. /***/ function(module, exports) {
  15536. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  15537. var global = module.exports = typeof window != 'undefined' && window.Math == Math
  15538. ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')();
  15539. if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef
  15540. /***/ },
  15541. /* 6 */
  15542. /***/ function(module, exports) {
  15543. module.exports = function(exec){
  15544. try {
  15545. return !!exec();
  15546. } catch(e){
  15547. return true;
  15548. }
  15549. };
  15550. /***/ },
  15551. /* 7 */
  15552. /***/ function(module, exports) {
  15553. module.exports = function(it){
  15554. return typeof it === 'object' ? it !== null : typeof it === 'function';
  15555. };
  15556. /***/ },
  15557. /* 8 */
  15558. /***/ function(module, exports, __webpack_require__) {
  15559. var store = __webpack_require__(92)('wks')
  15560. , uid = __webpack_require__(53)
  15561. , Symbol = __webpack_require__(5).Symbol
  15562. , USE_SYMBOL = typeof Symbol == 'function';
  15563. var $exports = module.exports = function(name){
  15564. return store[name] || (store[name] =
  15565. USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
  15566. };
  15567. $exports.store = store;
  15568. /***/ },
  15569. /* 9 */
  15570. /***/ function(module, exports, __webpack_require__) {
  15571. // Copyright Joyent, Inc. and other Node contributors.
  15572. //
  15573. // Permission is hereby granted, free of charge, to any person obtaining a
  15574. // copy of this software and associated documentation files (the
  15575. // "Software"), to deal in the Software without restriction, including
  15576. // without limitation the rights to use, copy, modify, merge, publish,
  15577. // distribute, sublicense, and/or sell copies of the Software, and to permit
  15578. // persons to whom the Software is furnished to do so, subject to the
  15579. // following conditions:
  15580. //
  15581. // The above copyright notice and this permission notice shall be included
  15582. // in all copies or substantial portions of the Software.
  15583. //
  15584. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  15585. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  15586. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  15587. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  15588. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  15589. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  15590. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  15591. module.exports = Stream;
  15592. var EE = __webpack_require__(30).EventEmitter;
  15593. var inherits = __webpack_require__(2);
  15594. inherits(Stream, EE);
  15595. Stream.Readable = __webpack_require__(550);
  15596. Stream.Writable = __webpack_require__(552);
  15597. Stream.Duplex = __webpack_require__(214);
  15598. Stream.Transform = __webpack_require__(551);
  15599. Stream.PassThrough = __webpack_require__(549);
  15600. // Backwards-compat with node 0.4.x
  15601. Stream.Stream = Stream;
  15602. // old-style streams. Note that the pipe method (the only relevant
  15603. // part of this class) is overridden in the Readable class.
  15604. function Stream() {
  15605. EE.call(this);
  15606. }
  15607. Stream.prototype.pipe = function(dest, options) {
  15608. var source = this;
  15609. function ondata(chunk) {
  15610. if (dest.writable) {
  15611. if (false === dest.write(chunk) && source.pause) {
  15612. source.pause();
  15613. }
  15614. }
  15615. }
  15616. source.on('data', ondata);
  15617. function ondrain() {
  15618. if (source.readable && source.resume) {
  15619. source.resume();
  15620. }
  15621. }
  15622. dest.on('drain', ondrain);
  15623. // If the 'end' option is not supplied, dest.end() will be called when
  15624. // source gets the 'end' or 'close' events. Only dest.end() once.
  15625. if (!dest._isStdio && (!options || options.end !== false)) {
  15626. source.on('end', onend);
  15627. source.on('close', onclose);
  15628. }
  15629. var didOnEnd = false;
  15630. function onend() {
  15631. if (didOnEnd) return;
  15632. didOnEnd = true;
  15633. dest.end();
  15634. }
  15635. function onclose() {
  15636. if (didOnEnd) return;
  15637. didOnEnd = true;
  15638. if (typeof dest.destroy === 'function') dest.destroy();
  15639. }
  15640. // don't leave dangling pipes when there are errors.
  15641. function onerror(er) {
  15642. cleanup();
  15643. if (EE.listenerCount(this, 'error') === 0) {
  15644. throw er; // Unhandled stream error in pipe.
  15645. }
  15646. }
  15647. source.on('error', onerror);
  15648. dest.on('error', onerror);
  15649. // remove all the event listeners that were added.
  15650. function cleanup() {
  15651. source.removeListener('data', ondata);
  15652. dest.removeListener('drain', ondrain);
  15653. source.removeListener('end', onend);
  15654. source.removeListener('close', onclose);
  15655. source.removeListener('error', onerror);
  15656. dest.removeListener('error', onerror);
  15657. source.removeListener('end', cleanup);
  15658. source.removeListener('close', cleanup);
  15659. dest.removeListener('close', cleanup);
  15660. }
  15661. source.on('end', cleanup);
  15662. source.on('close', cleanup);
  15663. dest.on('close', cleanup);
  15664. dest.emit('pipe', source);
  15665. // Allow for unix-like usage: A.pipe(B).pipe(C)
  15666. return dest;
  15667. };
  15668. /***/ },
  15669. /* 10 */
  15670. /***/ function(module, exports, __webpack_require__) {
  15671. // Thank's IE8 for his funny defineProperty
  15672. module.exports = !__webpack_require__(6)(function(){
  15673. return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7;
  15674. });
  15675. /***/ },
  15676. /* 11 */
  15677. /***/ function(module, exports, __webpack_require__) {
  15678. var anObject = __webpack_require__(3)
  15679. , IE8_DOM_DEFINE = __webpack_require__(176)
  15680. , toPrimitive = __webpack_require__(34)
  15681. , dP = Object.defineProperty;
  15682. exports.f = __webpack_require__(10) ? Object.defineProperty : function defineProperty(O, P, Attributes){
  15683. anObject(O);
  15684. P = toPrimitive(P, true);
  15685. anObject(Attributes);
  15686. if(IE8_DOM_DEFINE)try {
  15687. return dP(O, P, Attributes);
  15688. } catch(e){ /* empty */ }
  15689. if('get' in Attributes || 'set' in Attributes)throw TypeError('Accessors not supported!');
  15690. if('value' in Attributes)O[P] = Attributes.value;
  15691. return O;
  15692. };
  15693. /***/ },
  15694. /* 12 */
  15695. /***/ function(module, exports, __webpack_require__) {
  15696. /* WEBPACK VAR INJECTION */(function(module) {(function (module, exports) {
  15697. 'use strict';
  15698. // Utils
  15699. function assert (val, msg) {
  15700. if (!val) throw new Error(msg || 'Assertion failed');
  15701. }
  15702. // Could use `inherits` module, but don't want to move from single file
  15703. // architecture yet.
  15704. function inherits (ctor, superCtor) {
  15705. ctor.super_ = superCtor;
  15706. var TempCtor = function () {};
  15707. TempCtor.prototype = superCtor.prototype;
  15708. ctor.prototype = new TempCtor();
  15709. ctor.prototype.constructor = ctor;
  15710. }
  15711. // BN
  15712. function BN (number, base, endian) {
  15713. if (BN.isBN(number)) {
  15714. return number;
  15715. }
  15716. this.negative = 0;
  15717. this.words = null;
  15718. this.length = 0;
  15719. // Reduction context
  15720. this.red = null;
  15721. if (number !== null) {
  15722. if (base === 'le' || base === 'be') {
  15723. endian = base;
  15724. base = 10;
  15725. }
  15726. this._init(number || 0, base || 10, endian || 'be');
  15727. }
  15728. }
  15729. if (typeof module === 'object') {
  15730. module.exports = BN;
  15731. } else {
  15732. exports.BN = BN;
  15733. }
  15734. BN.BN = BN;
  15735. BN.wordSize = 26;
  15736. var Buffer;
  15737. try {
  15738. Buffer = __webpack_require__(1).Buffer;
  15739. } catch (e) {
  15740. }
  15741. BN.isBN = function isBN (num) {
  15742. return num !== null && typeof num === 'object' &&
  15743. num.constructor.name === 'BN' && Array.isArray(num.words);
  15744. };
  15745. BN.max = function max (left, right) {
  15746. if (left.cmp(right) > 0) return left;
  15747. return right;
  15748. };
  15749. BN.min = function min (left, right) {
  15750. if (left.cmp(right) < 0) return left;
  15751. return right;
  15752. };
  15753. BN.prototype._init = function init (number, base, endian) {
  15754. if (typeof number === 'number') {
  15755. return this._initNumber(number, base, endian);
  15756. }
  15757. if (typeof number === 'object') {
  15758. return this._initArray(number, base, endian);
  15759. }
  15760. if (base === 'hex') {
  15761. base = 16;
  15762. }
  15763. assert(base === (base | 0) && base >= 2 && base <= 36);
  15764. number = number.toString().replace(/\s+/g, '');
  15765. var start = 0;
  15766. if (number[0] === '-') {
  15767. start++;
  15768. }
  15769. if (base === 16) {
  15770. this._parseHex(number, start);
  15771. } else {
  15772. this._parseBase(number, base, start);
  15773. }
  15774. if (number[0] === '-') {
  15775. this.negative = 1;
  15776. }
  15777. this.strip();
  15778. if (endian !== 'le') return;
  15779. this._initArray(this.toArray(), base, endian);
  15780. };
  15781. BN.prototype._initNumber = function _initNumber (number, base, endian) {
  15782. if (number < 0) {
  15783. this.negative = 1;
  15784. number = -number;
  15785. }
  15786. if (number < 0x4000000) {
  15787. this.words = [ number & 0x3ffffff ];
  15788. this.length = 1;
  15789. } else if (number < 0x10000000000000) {
  15790. this.words = [
  15791. number & 0x3ffffff,
  15792. (number / 0x4000000) & 0x3ffffff
  15793. ];
  15794. this.length = 2;
  15795. } else {
  15796. assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
  15797. this.words = [
  15798. number & 0x3ffffff,
  15799. (number / 0x4000000) & 0x3ffffff,
  15800. 1
  15801. ];
  15802. this.length = 3;
  15803. }
  15804. if (endian !== 'le') return;
  15805. // Reverse the bytes
  15806. this._initArray(this.toArray(), base, endian);
  15807. };
  15808. BN.prototype._initArray = function _initArray (number, base, endian) {
  15809. // Perhaps a Uint8Array
  15810. assert(typeof number.length === 'number');
  15811. if (number.length <= 0) {
  15812. this.words = [ 0 ];
  15813. this.length = 1;
  15814. return this;
  15815. }
  15816. this.length = Math.ceil(number.length / 3);
  15817. this.words = new Array(this.length);
  15818. for (var i = 0; i < this.length; i++) {
  15819. this.words[i] = 0;
  15820. }
  15821. var j, w;
  15822. var off = 0;
  15823. if (endian === 'be') {
  15824. for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
  15825. w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);
  15826. this.words[j] |= (w << off) & 0x3ffffff;
  15827. this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
  15828. off += 24;
  15829. if (off >= 26) {
  15830. off -= 26;
  15831. j++;
  15832. }
  15833. }
  15834. } else if (endian === 'le') {
  15835. for (i = 0, j = 0; i < number.length; i += 3) {
  15836. w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);
  15837. this.words[j] |= (w << off) & 0x3ffffff;
  15838. this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
  15839. off += 24;
  15840. if (off >= 26) {
  15841. off -= 26;
  15842. j++;
  15843. }
  15844. }
  15845. }
  15846. return this.strip();
  15847. };
  15848. function parseHex (str, start, end) {
  15849. var r = 0;
  15850. var len = Math.min(str.length, end);
  15851. for (var i = start; i < len; i++) {
  15852. var c = str.charCodeAt(i) - 48;
  15853. r <<= 4;
  15854. // 'a' - 'f'
  15855. if (c >= 49 && c <= 54) {
  15856. r |= c - 49 + 0xa;
  15857. // 'A' - 'F'
  15858. } else if (c >= 17 && c <= 22) {
  15859. r |= c - 17 + 0xa;
  15860. // '0' - '9'
  15861. } else {
  15862. r |= c & 0xf;
  15863. }
  15864. }
  15865. return r;
  15866. }
  15867. BN.prototype._parseHex = function _parseHex (number, start) {
  15868. // Create possibly bigger array to ensure that it fits the number
  15869. this.length = Math.ceil((number.length - start) / 6);
  15870. this.words = new Array(this.length);
  15871. for (var i = 0; i < this.length; i++) {
  15872. this.words[i] = 0;
  15873. }
  15874. var j, w;
  15875. // Scan 24-bit chunks and add them to the number
  15876. var off = 0;
  15877. for (i = number.length - 6, j = 0; i >= start; i -= 6) {
  15878. w = parseHex(number, i, i + 6);
  15879. this.words[j] |= (w << off) & 0x3ffffff;
  15880. // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb
  15881. this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;
  15882. off += 24;
  15883. if (off >= 26) {
  15884. off -= 26;
  15885. j++;
  15886. }
  15887. }
  15888. if (i + 6 !== start) {
  15889. w = parseHex(number, start, i + 6);
  15890. this.words[j] |= (w << off) & 0x3ffffff;
  15891. this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;
  15892. }
  15893. this.strip();
  15894. };
  15895. function parseBase (str, start, end, mul) {
  15896. var r = 0;
  15897. var len = Math.min(str.length, end);
  15898. for (var i = start; i < len; i++) {
  15899. var c = str.charCodeAt(i) - 48;
  15900. r *= mul;
  15901. // 'a'
  15902. if (c >= 49) {
  15903. r += c - 49 + 0xa;
  15904. // 'A'
  15905. } else if (c >= 17) {
  15906. r += c - 17 + 0xa;
  15907. // '0' - '9'
  15908. } else {
  15909. r += c;
  15910. }
  15911. }
  15912. return r;
  15913. }
  15914. BN.prototype._parseBase = function _parseBase (number, base, start) {
  15915. // Initialize as zero
  15916. this.words = [ 0 ];
  15917. this.length = 1;
  15918. // Find length of limb in base
  15919. for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {
  15920. limbLen++;
  15921. }
  15922. limbLen--;
  15923. limbPow = (limbPow / base) | 0;
  15924. var total = number.length - start;
  15925. var mod = total % limbLen;
  15926. var end = Math.min(total, total - mod) + start;
  15927. var word = 0;
  15928. for (var i = start; i < end; i += limbLen) {
  15929. word = parseBase(number, i, i + limbLen, base);
  15930. this.imuln(limbPow);
  15931. if (this.words[0] + word < 0x4000000) {
  15932. this.words[0] += word;
  15933. } else {
  15934. this._iaddn(word);
  15935. }
  15936. }
  15937. if (mod !== 0) {
  15938. var pow = 1;
  15939. word = parseBase(number, i, number.length, base);
  15940. for (i = 0; i < mod; i++) {
  15941. pow *= base;
  15942. }
  15943. this.imuln(pow);
  15944. if (this.words[0] + word < 0x4000000) {
  15945. this.words[0] += word;
  15946. } else {
  15947. this._iaddn(word);
  15948. }
  15949. }
  15950. };
  15951. BN.prototype.copy = function copy (dest) {
  15952. dest.words = new Array(this.length);
  15953. for (var i = 0; i < this.length; i++) {
  15954. dest.words[i] = this.words[i];
  15955. }
  15956. dest.length = this.length;
  15957. dest.negative = this.negative;
  15958. dest.red = this.red;
  15959. };
  15960. BN.prototype.clone = function clone () {
  15961. var r = new BN(null);
  15962. this.copy(r);
  15963. return r;
  15964. };
  15965. BN.prototype._expand = function _expand (size) {
  15966. while (this.length < size) {
  15967. this.words[this.length++] = 0;
  15968. }
  15969. return this;
  15970. };
  15971. // Remove leading `0` from `this`
  15972. BN.prototype.strip = function strip () {
  15973. while (this.length > 1 && this.words[this.length - 1] === 0) {
  15974. this.length--;
  15975. }
  15976. return this._normSign();
  15977. };
  15978. BN.prototype._normSign = function _normSign () {
  15979. // -0 = 0
  15980. if (this.length === 1 && this.words[0] === 0) {
  15981. this.negative = 0;
  15982. }
  15983. return this;
  15984. };
  15985. BN.prototype.inspect = function inspect () {
  15986. return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
  15987. };
  15988. /*
  15989. var zeros = [];
  15990. var groupSizes = [];
  15991. var groupBases = [];
  15992. var s = '';
  15993. var i = -1;
  15994. while (++i < BN.wordSize) {
  15995. zeros[i] = s;
  15996. s += '0';
  15997. }
  15998. groupSizes[0] = 0;
  15999. groupSizes[1] = 0;
  16000. groupBases[0] = 0;
  16001. groupBases[1] = 0;
  16002. var base = 2 - 1;
  16003. while (++base < 36 + 1) {
  16004. var groupSize = 0;
  16005. var groupBase = 1;
  16006. while (groupBase < (1 << BN.wordSize) / base) {
  16007. groupBase *= base;
  16008. groupSize += 1;
  16009. }
  16010. groupSizes[base] = groupSize;
  16011. groupBases[base] = groupBase;
  16012. }
  16013. */
  16014. var zeros = [
  16015. '',
  16016. '0',
  16017. '00',
  16018. '000',
  16019. '0000',
  16020. '00000',
  16021. '000000',
  16022. '0000000',
  16023. '00000000',
  16024. '000000000',
  16025. '0000000000',
  16026. '00000000000',
  16027. '000000000000',
  16028. '0000000000000',
  16029. '00000000000000',
  16030. '000000000000000',
  16031. '0000000000000000',
  16032. '00000000000000000',
  16033. '000000000000000000',
  16034. '0000000000000000000',
  16035. '00000000000000000000',
  16036. '000000000000000000000',
  16037. '0000000000000000000000',
  16038. '00000000000000000000000',
  16039. '000000000000000000000000',
  16040. '0000000000000000000000000'
  16041. ];
  16042. var groupSizes = [
  16043. 0, 0,
  16044. 25, 16, 12, 11, 10, 9, 8,
  16045. 8, 7, 7, 7, 7, 6, 6,
  16046. 6, 6, 6, 6, 6, 5, 5,
  16047. 5, 5, 5, 5, 5, 5, 5,
  16048. 5, 5, 5, 5, 5, 5, 5
  16049. ];
  16050. var groupBases = [
  16051. 0, 0,
  16052. 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,
  16053. 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,
  16054. 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,
  16055. 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,
  16056. 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176
  16057. ];
  16058. BN.prototype.toString = function toString (base, padding) {
  16059. base = base || 10;
  16060. padding = padding | 0 || 1;
  16061. var out;
  16062. if (base === 16 || base === 'hex') {
  16063. out = '';
  16064. var off = 0;
  16065. var carry = 0;
  16066. for (var i = 0; i < this.length; i++) {
  16067. var w = this.words[i];
  16068. var word = (((w << off) | carry) & 0xffffff).toString(16);
  16069. carry = (w >>> (24 - off)) & 0xffffff;
  16070. if (carry !== 0 || i !== this.length - 1) {
  16071. out = zeros[6 - word.length] + word + out;
  16072. } else {
  16073. out = word + out;
  16074. }
  16075. off += 2;
  16076. if (off >= 26) {
  16077. off -= 26;
  16078. i--;
  16079. }
  16080. }
  16081. if (carry !== 0) {
  16082. out = carry.toString(16) + out;
  16083. }
  16084. while (out.length % padding !== 0) {
  16085. out = '0' + out;
  16086. }
  16087. if (this.negative !== 0) {
  16088. out = '-' + out;
  16089. }
  16090. return out;
  16091. }
  16092. if (base === (base | 0) && base >= 2 && base <= 36) {
  16093. // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));
  16094. var groupSize = groupSizes[base];
  16095. // var groupBase = Math.pow(base, groupSize);
  16096. var groupBase = groupBases[base];
  16097. out = '';
  16098. var c = this.clone();
  16099. c.negative = 0;
  16100. while (!c.isZero()) {
  16101. var r = c.modn(groupBase).toString(base);
  16102. c = c.idivn(groupBase);
  16103. if (!c.isZero()) {
  16104. out = zeros[groupSize - r.length] + r + out;
  16105. } else {
  16106. out = r + out;
  16107. }
  16108. }
  16109. if (this.isZero()) {
  16110. out = '0' + out;
  16111. }
  16112. while (out.length % padding !== 0) {
  16113. out = '0' + out;
  16114. }
  16115. if (this.negative !== 0) {
  16116. out = '-' + out;
  16117. }
  16118. return out;
  16119. }
  16120. assert(false, 'Base should be between 2 and 36');
  16121. };
  16122. BN.prototype.toNumber = function toNumber () {
  16123. var ret = this.words[0];
  16124. if (this.length === 2) {
  16125. ret += this.words[1] * 0x4000000;
  16126. } else if (this.length === 3 && this.words[2] === 0x01) {
  16127. // NOTE: at this stage it is known that the top bit is set
  16128. ret += 0x10000000000000 + (this.words[1] * 0x4000000);
  16129. } else if (this.length > 2) {
  16130. assert(false, 'Number can only safely store up to 53 bits');
  16131. }
  16132. return (this.negative !== 0) ? -ret : ret;
  16133. };
  16134. BN.prototype.toJSON = function toJSON () {
  16135. return this.toString(16);
  16136. };
  16137. BN.prototype.toBuffer = function toBuffer (endian, length) {
  16138. assert(typeof Buffer !== 'undefined');
  16139. return this.toArrayLike(Buffer, endian, length);
  16140. };
  16141. BN.prototype.toArray = function toArray (endian, length) {
  16142. return this.toArrayLike(Array, endian, length);
  16143. };
  16144. BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {
  16145. var byteLength = this.byteLength();
  16146. var reqLength = length || Math.max(1, byteLength);
  16147. assert(byteLength <= reqLength, 'byte array longer than desired length');
  16148. assert(reqLength > 0, 'Requested array length <= 0');
  16149. this.strip();
  16150. var littleEndian = endian === 'le';
  16151. var res = new ArrayType(reqLength);
  16152. var b, i;
  16153. var q = this.clone();
  16154. if (!littleEndian) {
  16155. // Assume big-endian
  16156. for (i = 0; i < reqLength - byteLength; i++) {
  16157. res[i] = 0;
  16158. }
  16159. for (i = 0; !q.isZero(); i++) {
  16160. b = q.andln(0xff);
  16161. q.iushrn(8);
  16162. res[reqLength - i - 1] = b;
  16163. }
  16164. } else {
  16165. for (i = 0; !q.isZero(); i++) {
  16166. b = q.andln(0xff);
  16167. q.iushrn(8);
  16168. res[i] = b;
  16169. }
  16170. for (; i < reqLength; i++) {
  16171. res[i] = 0;
  16172. }
  16173. }
  16174. return res;
  16175. };
  16176. if (Math.clz32) {
  16177. BN.prototype._countBits = function _countBits (w) {
  16178. return 32 - Math.clz32(w);
  16179. };
  16180. } else {
  16181. BN.prototype._countBits = function _countBits (w) {
  16182. var t = w;
  16183. var r = 0;
  16184. if (t >= 0x1000) {
  16185. r += 13;
  16186. t >>>= 13;
  16187. }
  16188. if (t >= 0x40) {
  16189. r += 7;
  16190. t >>>= 7;
  16191. }
  16192. if (t >= 0x8) {
  16193. r += 4;
  16194. t >>>= 4;
  16195. }
  16196. if (t >= 0x02) {
  16197. r += 2;
  16198. t >>>= 2;
  16199. }
  16200. return r + t;
  16201. };
  16202. }
  16203. BN.prototype._zeroBits = function _zeroBits (w) {
  16204. // Short-cut
  16205. if (w === 0) return 26;
  16206. var t = w;
  16207. var r = 0;
  16208. if ((t & 0x1fff) === 0) {
  16209. r += 13;
  16210. t >>>= 13;
  16211. }
  16212. if ((t & 0x7f) === 0) {
  16213. r += 7;
  16214. t >>>= 7;
  16215. }
  16216. if ((t & 0xf) === 0) {
  16217. r += 4;
  16218. t >>>= 4;
  16219. }
  16220. if ((t & 0x3) === 0) {
  16221. r += 2;
  16222. t >>>= 2;
  16223. }
  16224. if ((t & 0x1) === 0) {
  16225. r++;
  16226. }
  16227. return r;
  16228. };
  16229. // Return number of used bits in a BN
  16230. BN.prototype.bitLength = function bitLength () {
  16231. var w = this.words[this.length - 1];
  16232. var hi = this._countBits(w);
  16233. return (this.length - 1) * 26 + hi;
  16234. };
  16235. function toBitArray (num) {
  16236. var w = new Array(num.bitLength());
  16237. for (var bit = 0; bit < w.length; bit++) {
  16238. var off = (bit / 26) | 0;
  16239. var wbit = bit % 26;
  16240. w[bit] = (num.words[off] & (1 << wbit)) >>> wbit;
  16241. }
  16242. return w;
  16243. }
  16244. // Number of trailing zero bits
  16245. BN.prototype.zeroBits = function zeroBits () {
  16246. if (this.isZero()) return 0;
  16247. var r = 0;
  16248. for (var i = 0; i < this.length; i++) {
  16249. var b = this._zeroBits(this.words[i]);
  16250. r += b;
  16251. if (b !== 26) break;
  16252. }
  16253. return r;
  16254. };
  16255. BN.prototype.byteLength = function byteLength () {
  16256. return Math.ceil(this.bitLength() / 8);
  16257. };
  16258. BN.prototype.toTwos = function toTwos (width) {
  16259. if (this.negative !== 0) {
  16260. return this.abs().inotn(width).iaddn(1);
  16261. }
  16262. return this.clone();
  16263. };
  16264. BN.prototype.fromTwos = function fromTwos (width) {
  16265. if (this.testn(width - 1)) {
  16266. return this.notn(width).iaddn(1).ineg();
  16267. }
  16268. return this.clone();
  16269. };
  16270. BN.prototype.isNeg = function isNeg () {
  16271. return this.negative !== 0;
  16272. };
  16273. // Return negative clone of `this`
  16274. BN.prototype.neg = function neg () {
  16275. return this.clone().ineg();
  16276. };
  16277. BN.prototype.ineg = function ineg () {
  16278. if (!this.isZero()) {
  16279. this.negative ^= 1;
  16280. }
  16281. return this;
  16282. };
  16283. // Or `num` with `this` in-place
  16284. BN.prototype.iuor = function iuor (num) {
  16285. while (this.length < num.length) {
  16286. this.words[this.length++] = 0;
  16287. }
  16288. for (var i = 0; i < num.length; i++) {
  16289. this.words[i] = this.words[i] | num.words[i];
  16290. }
  16291. return this.strip();
  16292. };
  16293. BN.prototype.ior = function ior (num) {
  16294. assert((this.negative | num.negative) === 0);
  16295. return this.iuor(num);
  16296. };
  16297. // Or `num` with `this`
  16298. BN.prototype.or = function or (num) {
  16299. if (this.length > num.length) return this.clone().ior(num);
  16300. return num.clone().ior(this);
  16301. };
  16302. BN.prototype.uor = function uor (num) {
  16303. if (this.length > num.length) return this.clone().iuor(num);
  16304. return num.clone().iuor(this);
  16305. };
  16306. // And `num` with `this` in-place
  16307. BN.prototype.iuand = function iuand (num) {
  16308. // b = min-length(num, this)
  16309. var b;
  16310. if (this.length > num.length) {
  16311. b = num;
  16312. } else {
  16313. b = this;
  16314. }
  16315. for (var i = 0; i < b.length; i++) {
  16316. this.words[i] = this.words[i] & num.words[i];
  16317. }
  16318. this.length = b.length;
  16319. return this.strip();
  16320. };
  16321. BN.prototype.iand = function iand (num) {
  16322. assert((this.negative | num.negative) === 0);
  16323. return this.iuand(num);
  16324. };
  16325. // And `num` with `this`
  16326. BN.prototype.and = function and (num) {
  16327. if (this.length > num.length) return this.clone().iand(num);
  16328. return num.clone().iand(this);
  16329. };
  16330. BN.prototype.uand = function uand (num) {
  16331. if (this.length > num.length) return this.clone().iuand(num);
  16332. return num.clone().iuand(this);
  16333. };
  16334. // Xor `num` with `this` in-place
  16335. BN.prototype.iuxor = function iuxor (num) {
  16336. // a.length > b.length
  16337. var a;
  16338. var b;
  16339. if (this.length > num.length) {
  16340. a = this;
  16341. b = num;
  16342. } else {
  16343. a = num;
  16344. b = this;
  16345. }
  16346. for (var i = 0; i < b.length; i++) {
  16347. this.words[i] = a.words[i] ^ b.words[i];
  16348. }
  16349. if (this !== a) {
  16350. for (; i < a.length; i++) {
  16351. this.words[i] = a.words[i];
  16352. }
  16353. }
  16354. this.length = a.length;
  16355. return this.strip();
  16356. };
  16357. BN.prototype.ixor = function ixor (num) {
  16358. assert((this.negative | num.negative) === 0);
  16359. return this.iuxor(num);
  16360. };
  16361. // Xor `num` with `this`
  16362. BN.prototype.xor = function xor (num) {
  16363. if (this.length > num.length) return this.clone().ixor(num);
  16364. return num.clone().ixor(this);
  16365. };
  16366. BN.prototype.uxor = function uxor (num) {
  16367. if (this.length > num.length) return this.clone().iuxor(num);
  16368. return num.clone().iuxor(this);
  16369. };
  16370. // Not ``this`` with ``width`` bitwidth
  16371. BN.prototype.inotn = function inotn (width) {
  16372. assert(typeof width === 'number' && width >= 0);
  16373. var bytesNeeded = Math.ceil(width / 26) | 0;
  16374. var bitsLeft = width % 26;
  16375. // Extend the buffer with leading zeroes
  16376. this._expand(bytesNeeded);
  16377. if (bitsLeft > 0) {
  16378. bytesNeeded--;
  16379. }
  16380. // Handle complete words
  16381. for (var i = 0; i < bytesNeeded; i++) {
  16382. this.words[i] = ~this.words[i] & 0x3ffffff;
  16383. }
  16384. // Handle the residue
  16385. if (bitsLeft > 0) {
  16386. this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));
  16387. }
  16388. // And remove leading zeroes
  16389. return this.strip();
  16390. };
  16391. BN.prototype.notn = function notn (width) {
  16392. return this.clone().inotn(width);
  16393. };
  16394. // Set `bit` of `this`
  16395. BN.prototype.setn = function setn (bit, val) {
  16396. assert(typeof bit === 'number' && bit >= 0);
  16397. var off = (bit / 26) | 0;
  16398. var wbit = bit % 26;
  16399. this._expand(off + 1);
  16400. if (val) {
  16401. this.words[off] = this.words[off] | (1 << wbit);
  16402. } else {
  16403. this.words[off] = this.words[off] & ~(1 << wbit);
  16404. }
  16405. return this.strip();
  16406. };
  16407. // Add `num` to `this` in-place
  16408. BN.prototype.iadd = function iadd (num) {
  16409. var r;
  16410. // negative + positive
  16411. if (this.negative !== 0 && num.negative === 0) {
  16412. this.negative = 0;
  16413. r = this.isub(num);
  16414. this.negative ^= 1;
  16415. return this._normSign();
  16416. // positive + negative
  16417. } else if (this.negative === 0 && num.negative !== 0) {
  16418. num.negative = 0;
  16419. r = this.isub(num);
  16420. num.negative = 1;
  16421. return r._normSign();
  16422. }
  16423. // a.length > b.length
  16424. var a, b;
  16425. if (this.length > num.length) {
  16426. a = this;
  16427. b = num;
  16428. } else {
  16429. a = num;
  16430. b = this;
  16431. }
  16432. var carry = 0;
  16433. for (var i = 0; i < b.length; i++) {
  16434. r = (a.words[i] | 0) + (b.words[i] | 0) + carry;
  16435. this.words[i] = r & 0x3ffffff;
  16436. carry = r >>> 26;
  16437. }
  16438. for (; carry !== 0 && i < a.length; i++) {
  16439. r = (a.words[i] | 0) + carry;
  16440. this.words[i] = r & 0x3ffffff;
  16441. carry = r >>> 26;
  16442. }
  16443. this.length = a.length;
  16444. if (carry !== 0) {
  16445. this.words[this.length] = carry;
  16446. this.length++;
  16447. // Copy the rest of the words
  16448. } else if (a !== this) {
  16449. for (; i < a.length; i++) {
  16450. this.words[i] = a.words[i];
  16451. }
  16452. }
  16453. return this;
  16454. };
  16455. // Add `num` to `this`
  16456. BN.prototype.add = function add (num) {
  16457. var res;
  16458. if (num.negative !== 0 && this.negative === 0) {
  16459. num.negative = 0;
  16460. res = this.sub(num);
  16461. num.negative ^= 1;
  16462. return res;
  16463. } else if (num.negative === 0 && this.negative !== 0) {
  16464. this.negative = 0;
  16465. res = num.sub(this);
  16466. this.negative = 1;
  16467. return res;
  16468. }
  16469. if (this.length > num.length) return this.clone().iadd(num);
  16470. return num.clone().iadd(this);
  16471. };
  16472. // Subtract `num` from `this` in-place
  16473. BN.prototype.isub = function isub (num) {
  16474. // this - (-num) = this + num
  16475. if (num.negative !== 0) {
  16476. num.negative = 0;
  16477. var r = this.iadd(num);
  16478. num.negative = 1;
  16479. return r._normSign();
  16480. // -this - num = -(this + num)
  16481. } else if (this.negative !== 0) {
  16482. this.negative = 0;
  16483. this.iadd(num);
  16484. this.negative = 1;
  16485. return this._normSign();
  16486. }
  16487. // At this point both numbers are positive
  16488. var cmp = this.cmp(num);
  16489. // Optimization - zeroify
  16490. if (cmp === 0) {
  16491. this.negative = 0;
  16492. this.length = 1;
  16493. this.words[0] = 0;
  16494. return this;
  16495. }
  16496. // a > b
  16497. var a, b;
  16498. if (cmp > 0) {
  16499. a = this;
  16500. b = num;
  16501. } else {
  16502. a = num;
  16503. b = this;
  16504. }
  16505. var carry = 0;
  16506. for (var i = 0; i < b.length; i++) {
  16507. r = (a.words[i] | 0) - (b.words[i] | 0) + carry;
  16508. carry = r >> 26;
  16509. this.words[i] = r & 0x3ffffff;
  16510. }
  16511. for (; carry !== 0 && i < a.length; i++) {
  16512. r = (a.words[i] | 0) + carry;
  16513. carry = r >> 26;
  16514. this.words[i] = r & 0x3ffffff;
  16515. }
  16516. // Copy rest of the words
  16517. if (carry === 0 && i < a.length && a !== this) {
  16518. for (; i < a.length; i++) {
  16519. this.words[i] = a.words[i];
  16520. }
  16521. }
  16522. this.length = Math.max(this.length, i);
  16523. if (a !== this) {
  16524. this.negative = 1;
  16525. }
  16526. return this.strip();
  16527. };
  16528. // Subtract `num` from `this`
  16529. BN.prototype.sub = function sub (num) {
  16530. return this.clone().isub(num);
  16531. };
  16532. function smallMulTo (self, num, out) {
  16533. out.negative = num.negative ^ self.negative;
  16534. var len = (self.length + num.length) | 0;
  16535. out.length = len;
  16536. len = (len - 1) | 0;
  16537. // Peel one iteration (compiler can't do it, because of code complexity)
  16538. var a = self.words[0] | 0;
  16539. var b = num.words[0] | 0;
  16540. var r = a * b;
  16541. var lo = r & 0x3ffffff;
  16542. var carry = (r / 0x4000000) | 0;
  16543. out.words[0] = lo;
  16544. for (var k = 1; k < len; k++) {
  16545. // Sum all words with the same `i + j = k` and accumulate `ncarry`,
  16546. // note that ncarry could be >= 0x3ffffff
  16547. var ncarry = carry >>> 26;
  16548. var rword = carry & 0x3ffffff;
  16549. var maxJ = Math.min(k, num.length - 1);
  16550. for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
  16551. var i = (k - j) | 0;
  16552. a = self.words[i] | 0;
  16553. b = num.words[j] | 0;
  16554. r = a * b + rword;
  16555. ncarry += (r / 0x4000000) | 0;
  16556. rword = r & 0x3ffffff;
  16557. }
  16558. out.words[k] = rword | 0;
  16559. carry = ncarry | 0;
  16560. }
  16561. if (carry !== 0) {
  16562. out.words[k] = carry | 0;
  16563. } else {
  16564. out.length--;
  16565. }
  16566. return out.strip();
  16567. }
  16568. // TODO(indutny): it may be reasonable to omit it for users who don't need
  16569. // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit
  16570. // multiplication (like elliptic secp256k1).
  16571. var comb10MulTo = function comb10MulTo (self, num, out) {
  16572. var a = self.words;
  16573. var b = num.words;
  16574. var o = out.words;
  16575. var c = 0;
  16576. var lo;
  16577. var mid;
  16578. var hi;
  16579. var a0 = a[0] | 0;
  16580. var al0 = a0 & 0x1fff;
  16581. var ah0 = a0 >>> 13;
  16582. var a1 = a[1] | 0;
  16583. var al1 = a1 & 0x1fff;
  16584. var ah1 = a1 >>> 13;
  16585. var a2 = a[2] | 0;
  16586. var al2 = a2 & 0x1fff;
  16587. var ah2 = a2 >>> 13;
  16588. var a3 = a[3] | 0;
  16589. var al3 = a3 & 0x1fff;
  16590. var ah3 = a3 >>> 13;
  16591. var a4 = a[4] | 0;
  16592. var al4 = a4 & 0x1fff;
  16593. var ah4 = a4 >>> 13;
  16594. var a5 = a[5] | 0;
  16595. var al5 = a5 & 0x1fff;
  16596. var ah5 = a5 >>> 13;
  16597. var a6 = a[6] | 0;
  16598. var al6 = a6 & 0x1fff;
  16599. var ah6 = a6 >>> 13;
  16600. var a7 = a[7] | 0;
  16601. var al7 = a7 & 0x1fff;
  16602. var ah7 = a7 >>> 13;
  16603. var a8 = a[8] | 0;
  16604. var al8 = a8 & 0x1fff;
  16605. var ah8 = a8 >>> 13;
  16606. var a9 = a[9] | 0;
  16607. var al9 = a9 & 0x1fff;
  16608. var ah9 = a9 >>> 13;
  16609. var b0 = b[0] | 0;
  16610. var bl0 = b0 & 0x1fff;
  16611. var bh0 = b0 >>> 13;
  16612. var b1 = b[1] | 0;
  16613. var bl1 = b1 & 0x1fff;
  16614. var bh1 = b1 >>> 13;
  16615. var b2 = b[2] | 0;
  16616. var bl2 = b2 & 0x1fff;
  16617. var bh2 = b2 >>> 13;
  16618. var b3 = b[3] | 0;
  16619. var bl3 = b3 & 0x1fff;
  16620. var bh3 = b3 >>> 13;
  16621. var b4 = b[4] | 0;
  16622. var bl4 = b4 & 0x1fff;
  16623. var bh4 = b4 >>> 13;
  16624. var b5 = b[5] | 0;
  16625. var bl5 = b5 & 0x1fff;
  16626. var bh5 = b5 >>> 13;
  16627. var b6 = b[6] | 0;
  16628. var bl6 = b6 & 0x1fff;
  16629. var bh6 = b6 >>> 13;
  16630. var b7 = b[7] | 0;
  16631. var bl7 = b7 & 0x1fff;
  16632. var bh7 = b7 >>> 13;
  16633. var b8 = b[8] | 0;
  16634. var bl8 = b8 & 0x1fff;
  16635. var bh8 = b8 >>> 13;
  16636. var b9 = b[9] | 0;
  16637. var bl9 = b9 & 0x1fff;
  16638. var bh9 = b9 >>> 13;
  16639. out.negative = self.negative ^ num.negative;
  16640. out.length = 19;
  16641. /* k = 0 */
  16642. lo = Math.imul(al0, bl0);
  16643. mid = Math.imul(al0, bh0);
  16644. mid = (mid + Math.imul(ah0, bl0)) | 0;
  16645. hi = Math.imul(ah0, bh0);
  16646. var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  16647. c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;
  16648. w0 &= 0x3ffffff;
  16649. /* k = 1 */
  16650. lo = Math.imul(al1, bl0);
  16651. mid = Math.imul(al1, bh0);
  16652. mid = (mid + Math.imul(ah1, bl0)) | 0;
  16653. hi = Math.imul(ah1, bh0);
  16654. lo = (lo + Math.imul(al0, bl1)) | 0;
  16655. mid = (mid + Math.imul(al0, bh1)) | 0;
  16656. mid = (mid + Math.imul(ah0, bl1)) | 0;
  16657. hi = (hi + Math.imul(ah0, bh1)) | 0;
  16658. var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  16659. c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;
  16660. w1 &= 0x3ffffff;
  16661. /* k = 2 */
  16662. lo = Math.imul(al2, bl0);
  16663. mid = Math.imul(al2, bh0);
  16664. mid = (mid + Math.imul(ah2, bl0)) | 0;
  16665. hi = Math.imul(ah2, bh0);
  16666. lo = (lo + Math.imul(al1, bl1)) | 0;
  16667. mid = (mid + Math.imul(al1, bh1)) | 0;
  16668. mid = (mid + Math.imul(ah1, bl1)) | 0;
  16669. hi = (hi + Math.imul(ah1, bh1)) | 0;
  16670. lo = (lo + Math.imul(al0, bl2)) | 0;
  16671. mid = (mid + Math.imul(al0, bh2)) | 0;
  16672. mid = (mid + Math.imul(ah0, bl2)) | 0;
  16673. hi = (hi + Math.imul(ah0, bh2)) | 0;
  16674. var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  16675. c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;
  16676. w2 &= 0x3ffffff;
  16677. /* k = 3 */
  16678. lo = Math.imul(al3, bl0);
  16679. mid = Math.imul(al3, bh0);
  16680. mid = (mid + Math.imul(ah3, bl0)) | 0;
  16681. hi = Math.imul(ah3, bh0);
  16682. lo = (lo + Math.imul(al2, bl1)) | 0;
  16683. mid = (mid + Math.imul(al2, bh1)) | 0;
  16684. mid = (mid + Math.imul(ah2, bl1)) | 0;
  16685. hi = (hi + Math.imul(ah2, bh1)) | 0;
  16686. lo = (lo + Math.imul(al1, bl2)) | 0;
  16687. mid = (mid + Math.imul(al1, bh2)) | 0;
  16688. mid = (mid + Math.imul(ah1, bl2)) | 0;
  16689. hi = (hi + Math.imul(ah1, bh2)) | 0;
  16690. lo = (lo + Math.imul(al0, bl3)) | 0;
  16691. mid = (mid + Math.imul(al0, bh3)) | 0;
  16692. mid = (mid + Math.imul(ah0, bl3)) | 0;
  16693. hi = (hi + Math.imul(ah0, bh3)) | 0;
  16694. var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  16695. c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;
  16696. w3 &= 0x3ffffff;
  16697. /* k = 4 */
  16698. lo = Math.imul(al4, bl0);
  16699. mid = Math.imul(al4, bh0);
  16700. mid = (mid + Math.imul(ah4, bl0)) | 0;
  16701. hi = Math.imul(ah4, bh0);
  16702. lo = (lo + Math.imul(al3, bl1)) | 0;
  16703. mid = (mid + Math.imul(al3, bh1)) | 0;
  16704. mid = (mid + Math.imul(ah3, bl1)) | 0;
  16705. hi = (hi + Math.imul(ah3, bh1)) | 0;
  16706. lo = (lo + Math.imul(al2, bl2)) | 0;
  16707. mid = (mid + Math.imul(al2, bh2)) | 0;
  16708. mid = (mid + Math.imul(ah2, bl2)) | 0;
  16709. hi = (hi + Math.imul(ah2, bh2)) | 0;
  16710. lo = (lo + Math.imul(al1, bl3)) | 0;
  16711. mid = (mid + Math.imul(al1, bh3)) | 0;
  16712. mid = (mid + Math.imul(ah1, bl3)) | 0;
  16713. hi = (hi + Math.imul(ah1, bh3)) | 0;
  16714. lo = (lo + Math.imul(al0, bl4)) | 0;
  16715. mid = (mid + Math.imul(al0, bh4)) | 0;
  16716. mid = (mid + Math.imul(ah0, bl4)) | 0;
  16717. hi = (hi + Math.imul(ah0, bh4)) | 0;
  16718. var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  16719. c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;
  16720. w4 &= 0x3ffffff;
  16721. /* k = 5 */
  16722. lo = Math.imul(al5, bl0);
  16723. mid = Math.imul(al5, bh0);
  16724. mid = (mid + Math.imul(ah5, bl0)) | 0;
  16725. hi = Math.imul(ah5, bh0);
  16726. lo = (lo + Math.imul(al4, bl1)) | 0;
  16727. mid = (mid + Math.imul(al4, bh1)) | 0;
  16728. mid = (mid + Math.imul(ah4, bl1)) | 0;
  16729. hi = (hi + Math.imul(ah4, bh1)) | 0;
  16730. lo = (lo + Math.imul(al3, bl2)) | 0;
  16731. mid = (mid + Math.imul(al3, bh2)) | 0;
  16732. mid = (mid + Math.imul(ah3, bl2)) | 0;
  16733. hi = (hi + Math.imul(ah3, bh2)) | 0;
  16734. lo = (lo + Math.imul(al2, bl3)) | 0;
  16735. mid = (mid + Math.imul(al2, bh3)) | 0;
  16736. mid = (mid + Math.imul(ah2, bl3)) | 0;
  16737. hi = (hi + Math.imul(ah2, bh3)) | 0;
  16738. lo = (lo + Math.imul(al1, bl4)) | 0;
  16739. mid = (mid + Math.imul(al1, bh4)) | 0;
  16740. mid = (mid + Math.imul(ah1, bl4)) | 0;
  16741. hi = (hi + Math.imul(ah1, bh4)) | 0;
  16742. lo = (lo + Math.imul(al0, bl5)) | 0;
  16743. mid = (mid + Math.imul(al0, bh5)) | 0;
  16744. mid = (mid + Math.imul(ah0, bl5)) | 0;
  16745. hi = (hi + Math.imul(ah0, bh5)) | 0;
  16746. var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  16747. c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;
  16748. w5 &= 0x3ffffff;
  16749. /* k = 6 */
  16750. lo = Math.imul(al6, bl0);
  16751. mid = Math.imul(al6, bh0);
  16752. mid = (mid + Math.imul(ah6, bl0)) | 0;
  16753. hi = Math.imul(ah6, bh0);
  16754. lo = (lo + Math.imul(al5, bl1)) | 0;
  16755. mid = (mid + Math.imul(al5, bh1)) | 0;
  16756. mid = (mid + Math.imul(ah5, bl1)) | 0;
  16757. hi = (hi + Math.imul(ah5, bh1)) | 0;
  16758. lo = (lo + Math.imul(al4, bl2)) | 0;
  16759. mid = (mid + Math.imul(al4, bh2)) | 0;
  16760. mid = (mid + Math.imul(ah4, bl2)) | 0;
  16761. hi = (hi + Math.imul(ah4, bh2)) | 0;
  16762. lo = (lo + Math.imul(al3, bl3)) | 0;
  16763. mid = (mid + Math.imul(al3, bh3)) | 0;
  16764. mid = (mid + Math.imul(ah3, bl3)) | 0;
  16765. hi = (hi + Math.imul(ah3, bh3)) | 0;
  16766. lo = (lo + Math.imul(al2, bl4)) | 0;
  16767. mid = (mid + Math.imul(al2, bh4)) | 0;
  16768. mid = (mid + Math.imul(ah2, bl4)) | 0;
  16769. hi = (hi + Math.imul(ah2, bh4)) | 0;
  16770. lo = (lo + Math.imul(al1, bl5)) | 0;
  16771. mid = (mid + Math.imul(al1, bh5)) | 0;
  16772. mid = (mid + Math.imul(ah1, bl5)) | 0;
  16773. hi = (hi + Math.imul(ah1, bh5)) | 0;
  16774. lo = (lo + Math.imul(al0, bl6)) | 0;
  16775. mid = (mid + Math.imul(al0, bh6)) | 0;
  16776. mid = (mid + Math.imul(ah0, bl6)) | 0;
  16777. hi = (hi + Math.imul(ah0, bh6)) | 0;
  16778. var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  16779. c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;
  16780. w6 &= 0x3ffffff;
  16781. /* k = 7 */
  16782. lo = Math.imul(al7, bl0);
  16783. mid = Math.imul(al7, bh0);
  16784. mid = (mid + Math.imul(ah7, bl0)) | 0;
  16785. hi = Math.imul(ah7, bh0);
  16786. lo = (lo + Math.imul(al6, bl1)) | 0;
  16787. mid = (mid + Math.imul(al6, bh1)) | 0;
  16788. mid = (mid + Math.imul(ah6, bl1)) | 0;
  16789. hi = (hi + Math.imul(ah6, bh1)) | 0;
  16790. lo = (lo + Math.imul(al5, bl2)) | 0;
  16791. mid = (mid + Math.imul(al5, bh2)) | 0;
  16792. mid = (mid + Math.imul(ah5, bl2)) | 0;
  16793. hi = (hi + Math.imul(ah5, bh2)) | 0;
  16794. lo = (lo + Math.imul(al4, bl3)) | 0;
  16795. mid = (mid + Math.imul(al4, bh3)) | 0;
  16796. mid = (mid + Math.imul(ah4, bl3)) | 0;
  16797. hi = (hi + Math.imul(ah4, bh3)) | 0;
  16798. lo = (lo + Math.imul(al3, bl4)) | 0;
  16799. mid = (mid + Math.imul(al3, bh4)) | 0;
  16800. mid = (mid + Math.imul(ah3, bl4)) | 0;
  16801. hi = (hi + Math.imul(ah3, bh4)) | 0;
  16802. lo = (lo + Math.imul(al2, bl5)) | 0;
  16803. mid = (mid + Math.imul(al2, bh5)) | 0;
  16804. mid = (mid + Math.imul(ah2, bl5)) | 0;
  16805. hi = (hi + Math.imul(ah2, bh5)) | 0;
  16806. lo = (lo + Math.imul(al1, bl6)) | 0;
  16807. mid = (mid + Math.imul(al1, bh6)) | 0;
  16808. mid = (mid + Math.imul(ah1, bl6)) | 0;
  16809. hi = (hi + Math.imul(ah1, bh6)) | 0;
  16810. lo = (lo + Math.imul(al0, bl7)) | 0;
  16811. mid = (mid + Math.imul(al0, bh7)) | 0;
  16812. mid = (mid + Math.imul(ah0, bl7)) | 0;
  16813. hi = (hi + Math.imul(ah0, bh7)) | 0;
  16814. var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  16815. c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;
  16816. w7 &= 0x3ffffff;
  16817. /* k = 8 */
  16818. lo = Math.imul(al8, bl0);
  16819. mid = Math.imul(al8, bh0);
  16820. mid = (mid + Math.imul(ah8, bl0)) | 0;
  16821. hi = Math.imul(ah8, bh0);
  16822. lo = (lo + Math.imul(al7, bl1)) | 0;
  16823. mid = (mid + Math.imul(al7, bh1)) | 0;
  16824. mid = (mid + Math.imul(ah7, bl1)) | 0;
  16825. hi = (hi + Math.imul(ah7, bh1)) | 0;
  16826. lo = (lo + Math.imul(al6, bl2)) | 0;
  16827. mid = (mid + Math.imul(al6, bh2)) | 0;
  16828. mid = (mid + Math.imul(ah6, bl2)) | 0;
  16829. hi = (hi + Math.imul(ah6, bh2)) | 0;
  16830. lo = (lo + Math.imul(al5, bl3)) | 0;
  16831. mid = (mid + Math.imul(al5, bh3)) | 0;
  16832. mid = (mid + Math.imul(ah5, bl3)) | 0;
  16833. hi = (hi + Math.imul(ah5, bh3)) | 0;
  16834. lo = (lo + Math.imul(al4, bl4)) | 0;
  16835. mid = (mid + Math.imul(al4, bh4)) | 0;
  16836. mid = (mid + Math.imul(ah4, bl4)) | 0;
  16837. hi = (hi + Math.imul(ah4, bh4)) | 0;
  16838. lo = (lo + Math.imul(al3, bl5)) | 0;
  16839. mid = (mid + Math.imul(al3, bh5)) | 0;
  16840. mid = (mid + Math.imul(ah3, bl5)) | 0;
  16841. hi = (hi + Math.imul(ah3, bh5)) | 0;
  16842. lo = (lo + Math.imul(al2, bl6)) | 0;
  16843. mid = (mid + Math.imul(al2, bh6)) | 0;
  16844. mid = (mid + Math.imul(ah2, bl6)) | 0;
  16845. hi = (hi + Math.imul(ah2, bh6)) | 0;
  16846. lo = (lo + Math.imul(al1, bl7)) | 0;
  16847. mid = (mid + Math.imul(al1, bh7)) | 0;
  16848. mid = (mid + Math.imul(ah1, bl7)) | 0;
  16849. hi = (hi + Math.imul(ah1, bh7)) | 0;
  16850. lo = (lo + Math.imul(al0, bl8)) | 0;
  16851. mid = (mid + Math.imul(al0, bh8)) | 0;
  16852. mid = (mid + Math.imul(ah0, bl8)) | 0;
  16853. hi = (hi + Math.imul(ah0, bh8)) | 0;
  16854. var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  16855. c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;
  16856. w8 &= 0x3ffffff;
  16857. /* k = 9 */
  16858. lo = Math.imul(al9, bl0);
  16859. mid = Math.imul(al9, bh0);
  16860. mid = (mid + Math.imul(ah9, bl0)) | 0;
  16861. hi = Math.imul(ah9, bh0);
  16862. lo = (lo + Math.imul(al8, bl1)) | 0;
  16863. mid = (mid + Math.imul(al8, bh1)) | 0;
  16864. mid = (mid + Math.imul(ah8, bl1)) | 0;
  16865. hi = (hi + Math.imul(ah8, bh1)) | 0;
  16866. lo = (lo + Math.imul(al7, bl2)) | 0;
  16867. mid = (mid + Math.imul(al7, bh2)) | 0;
  16868. mid = (mid + Math.imul(ah7, bl2)) | 0;
  16869. hi = (hi + Math.imul(ah7, bh2)) | 0;
  16870. lo = (lo + Math.imul(al6, bl3)) | 0;
  16871. mid = (mid + Math.imul(al6, bh3)) | 0;
  16872. mid = (mid + Math.imul(ah6, bl3)) | 0;
  16873. hi = (hi + Math.imul(ah6, bh3)) | 0;
  16874. lo = (lo + Math.imul(al5, bl4)) | 0;
  16875. mid = (mid + Math.imul(al5, bh4)) | 0;
  16876. mid = (mid + Math.imul(ah5, bl4)) | 0;
  16877. hi = (hi + Math.imul(ah5, bh4)) | 0;
  16878. lo = (lo + Math.imul(al4, bl5)) | 0;
  16879. mid = (mid + Math.imul(al4, bh5)) | 0;
  16880. mid = (mid + Math.imul(ah4, bl5)) | 0;
  16881. hi = (hi + Math.imul(ah4, bh5)) | 0;
  16882. lo = (lo + Math.imul(al3, bl6)) | 0;
  16883. mid = (mid + Math.imul(al3, bh6)) | 0;
  16884. mid = (mid + Math.imul(ah3, bl6)) | 0;
  16885. hi = (hi + Math.imul(ah3, bh6)) | 0;
  16886. lo = (lo + Math.imul(al2, bl7)) | 0;
  16887. mid = (mid + Math.imul(al2, bh7)) | 0;
  16888. mid = (mid + Math.imul(ah2, bl7)) | 0;
  16889. hi = (hi + Math.imul(ah2, bh7)) | 0;
  16890. lo = (lo + Math.imul(al1, bl8)) | 0;
  16891. mid = (mid + Math.imul(al1, bh8)) | 0;
  16892. mid = (mid + Math.imul(ah1, bl8)) | 0;
  16893. hi = (hi + Math.imul(ah1, bh8)) | 0;
  16894. lo = (lo + Math.imul(al0, bl9)) | 0;
  16895. mid = (mid + Math.imul(al0, bh9)) | 0;
  16896. mid = (mid + Math.imul(ah0, bl9)) | 0;
  16897. hi = (hi + Math.imul(ah0, bh9)) | 0;
  16898. var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  16899. c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;
  16900. w9 &= 0x3ffffff;
  16901. /* k = 10 */
  16902. lo = Math.imul(al9, bl1);
  16903. mid = Math.imul(al9, bh1);
  16904. mid = (mid + Math.imul(ah9, bl1)) | 0;
  16905. hi = Math.imul(ah9, bh1);
  16906. lo = (lo + Math.imul(al8, bl2)) | 0;
  16907. mid = (mid + Math.imul(al8, bh2)) | 0;
  16908. mid = (mid + Math.imul(ah8, bl2)) | 0;
  16909. hi = (hi + Math.imul(ah8, bh2)) | 0;
  16910. lo = (lo + Math.imul(al7, bl3)) | 0;
  16911. mid = (mid + Math.imul(al7, bh3)) | 0;
  16912. mid = (mid + Math.imul(ah7, bl3)) | 0;
  16913. hi = (hi + Math.imul(ah7, bh3)) | 0;
  16914. lo = (lo + Math.imul(al6, bl4)) | 0;
  16915. mid = (mid + Math.imul(al6, bh4)) | 0;
  16916. mid = (mid + Math.imul(ah6, bl4)) | 0;
  16917. hi = (hi + Math.imul(ah6, bh4)) | 0;
  16918. lo = (lo + Math.imul(al5, bl5)) | 0;
  16919. mid = (mid + Math.imul(al5, bh5)) | 0;
  16920. mid = (mid + Math.imul(ah5, bl5)) | 0;
  16921. hi = (hi + Math.imul(ah5, bh5)) | 0;
  16922. lo = (lo + Math.imul(al4, bl6)) | 0;
  16923. mid = (mid + Math.imul(al4, bh6)) | 0;
  16924. mid = (mid + Math.imul(ah4, bl6)) | 0;
  16925. hi = (hi + Math.imul(ah4, bh6)) | 0;
  16926. lo = (lo + Math.imul(al3, bl7)) | 0;
  16927. mid = (mid + Math.imul(al3, bh7)) | 0;
  16928. mid = (mid + Math.imul(ah3, bl7)) | 0;
  16929. hi = (hi + Math.imul(ah3, bh7)) | 0;
  16930. lo = (lo + Math.imul(al2, bl8)) | 0;
  16931. mid = (mid + Math.imul(al2, bh8)) | 0;
  16932. mid = (mid + Math.imul(ah2, bl8)) | 0;
  16933. hi = (hi + Math.imul(ah2, bh8)) | 0;
  16934. lo = (lo + Math.imul(al1, bl9)) | 0;
  16935. mid = (mid + Math.imul(al1, bh9)) | 0;
  16936. mid = (mid + Math.imul(ah1, bl9)) | 0;
  16937. hi = (hi + Math.imul(ah1, bh9)) | 0;
  16938. var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  16939. c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;
  16940. w10 &= 0x3ffffff;
  16941. /* k = 11 */
  16942. lo = Math.imul(al9, bl2);
  16943. mid = Math.imul(al9, bh2);
  16944. mid = (mid + Math.imul(ah9, bl2)) | 0;
  16945. hi = Math.imul(ah9, bh2);
  16946. lo = (lo + Math.imul(al8, bl3)) | 0;
  16947. mid = (mid + Math.imul(al8, bh3)) | 0;
  16948. mid = (mid + Math.imul(ah8, bl3)) | 0;
  16949. hi = (hi + Math.imul(ah8, bh3)) | 0;
  16950. lo = (lo + Math.imul(al7, bl4)) | 0;
  16951. mid = (mid + Math.imul(al7, bh4)) | 0;
  16952. mid = (mid + Math.imul(ah7, bl4)) | 0;
  16953. hi = (hi + Math.imul(ah7, bh4)) | 0;
  16954. lo = (lo + Math.imul(al6, bl5)) | 0;
  16955. mid = (mid + Math.imul(al6, bh5)) | 0;
  16956. mid = (mid + Math.imul(ah6, bl5)) | 0;
  16957. hi = (hi + Math.imul(ah6, bh5)) | 0;
  16958. lo = (lo + Math.imul(al5, bl6)) | 0;
  16959. mid = (mid + Math.imul(al5, bh6)) | 0;
  16960. mid = (mid + Math.imul(ah5, bl6)) | 0;
  16961. hi = (hi + Math.imul(ah5, bh6)) | 0;
  16962. lo = (lo + Math.imul(al4, bl7)) | 0;
  16963. mid = (mid + Math.imul(al4, bh7)) | 0;
  16964. mid = (mid + Math.imul(ah4, bl7)) | 0;
  16965. hi = (hi + Math.imul(ah4, bh7)) | 0;
  16966. lo = (lo + Math.imul(al3, bl8)) | 0;
  16967. mid = (mid + Math.imul(al3, bh8)) | 0;
  16968. mid = (mid + Math.imul(ah3, bl8)) | 0;
  16969. hi = (hi + Math.imul(ah3, bh8)) | 0;
  16970. lo = (lo + Math.imul(al2, bl9)) | 0;
  16971. mid = (mid + Math.imul(al2, bh9)) | 0;
  16972. mid = (mid + Math.imul(ah2, bl9)) | 0;
  16973. hi = (hi + Math.imul(ah2, bh9)) | 0;
  16974. var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  16975. c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;
  16976. w11 &= 0x3ffffff;
  16977. /* k = 12 */
  16978. lo = Math.imul(al9, bl3);
  16979. mid = Math.imul(al9, bh3);
  16980. mid = (mid + Math.imul(ah9, bl3)) | 0;
  16981. hi = Math.imul(ah9, bh3);
  16982. lo = (lo + Math.imul(al8, bl4)) | 0;
  16983. mid = (mid + Math.imul(al8, bh4)) | 0;
  16984. mid = (mid + Math.imul(ah8, bl4)) | 0;
  16985. hi = (hi + Math.imul(ah8, bh4)) | 0;
  16986. lo = (lo + Math.imul(al7, bl5)) | 0;
  16987. mid = (mid + Math.imul(al7, bh5)) | 0;
  16988. mid = (mid + Math.imul(ah7, bl5)) | 0;
  16989. hi = (hi + Math.imul(ah7, bh5)) | 0;
  16990. lo = (lo + Math.imul(al6, bl6)) | 0;
  16991. mid = (mid + Math.imul(al6, bh6)) | 0;
  16992. mid = (mid + Math.imul(ah6, bl6)) | 0;
  16993. hi = (hi + Math.imul(ah6, bh6)) | 0;
  16994. lo = (lo + Math.imul(al5, bl7)) | 0;
  16995. mid = (mid + Math.imul(al5, bh7)) | 0;
  16996. mid = (mid + Math.imul(ah5, bl7)) | 0;
  16997. hi = (hi + Math.imul(ah5, bh7)) | 0;
  16998. lo = (lo + Math.imul(al4, bl8)) | 0;
  16999. mid = (mid + Math.imul(al4, bh8)) | 0;
  17000. mid = (mid + Math.imul(ah4, bl8)) | 0;
  17001. hi = (hi + Math.imul(ah4, bh8)) | 0;
  17002. lo = (lo + Math.imul(al3, bl9)) | 0;
  17003. mid = (mid + Math.imul(al3, bh9)) | 0;
  17004. mid = (mid + Math.imul(ah3, bl9)) | 0;
  17005. hi = (hi + Math.imul(ah3, bh9)) | 0;
  17006. var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  17007. c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;
  17008. w12 &= 0x3ffffff;
  17009. /* k = 13 */
  17010. lo = Math.imul(al9, bl4);
  17011. mid = Math.imul(al9, bh4);
  17012. mid = (mid + Math.imul(ah9, bl4)) | 0;
  17013. hi = Math.imul(ah9, bh4);
  17014. lo = (lo + Math.imul(al8, bl5)) | 0;
  17015. mid = (mid + Math.imul(al8, bh5)) | 0;
  17016. mid = (mid + Math.imul(ah8, bl5)) | 0;
  17017. hi = (hi + Math.imul(ah8, bh5)) | 0;
  17018. lo = (lo + Math.imul(al7, bl6)) | 0;
  17019. mid = (mid + Math.imul(al7, bh6)) | 0;
  17020. mid = (mid + Math.imul(ah7, bl6)) | 0;
  17021. hi = (hi + Math.imul(ah7, bh6)) | 0;
  17022. lo = (lo + Math.imul(al6, bl7)) | 0;
  17023. mid = (mid + Math.imul(al6, bh7)) | 0;
  17024. mid = (mid + Math.imul(ah6, bl7)) | 0;
  17025. hi = (hi + Math.imul(ah6, bh7)) | 0;
  17026. lo = (lo + Math.imul(al5, bl8)) | 0;
  17027. mid = (mid + Math.imul(al5, bh8)) | 0;
  17028. mid = (mid + Math.imul(ah5, bl8)) | 0;
  17029. hi = (hi + Math.imul(ah5, bh8)) | 0;
  17030. lo = (lo + Math.imul(al4, bl9)) | 0;
  17031. mid = (mid + Math.imul(al4, bh9)) | 0;
  17032. mid = (mid + Math.imul(ah4, bl9)) | 0;
  17033. hi = (hi + Math.imul(ah4, bh9)) | 0;
  17034. var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  17035. c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;
  17036. w13 &= 0x3ffffff;
  17037. /* k = 14 */
  17038. lo = Math.imul(al9, bl5);
  17039. mid = Math.imul(al9, bh5);
  17040. mid = (mid + Math.imul(ah9, bl5)) | 0;
  17041. hi = Math.imul(ah9, bh5);
  17042. lo = (lo + Math.imul(al8, bl6)) | 0;
  17043. mid = (mid + Math.imul(al8, bh6)) | 0;
  17044. mid = (mid + Math.imul(ah8, bl6)) | 0;
  17045. hi = (hi + Math.imul(ah8, bh6)) | 0;
  17046. lo = (lo + Math.imul(al7, bl7)) | 0;
  17047. mid = (mid + Math.imul(al7, bh7)) | 0;
  17048. mid = (mid + Math.imul(ah7, bl7)) | 0;
  17049. hi = (hi + Math.imul(ah7, bh7)) | 0;
  17050. lo = (lo + Math.imul(al6, bl8)) | 0;
  17051. mid = (mid + Math.imul(al6, bh8)) | 0;
  17052. mid = (mid + Math.imul(ah6, bl8)) | 0;
  17053. hi = (hi + Math.imul(ah6, bh8)) | 0;
  17054. lo = (lo + Math.imul(al5, bl9)) | 0;
  17055. mid = (mid + Math.imul(al5, bh9)) | 0;
  17056. mid = (mid + Math.imul(ah5, bl9)) | 0;
  17057. hi = (hi + Math.imul(ah5, bh9)) | 0;
  17058. var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  17059. c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;
  17060. w14 &= 0x3ffffff;
  17061. /* k = 15 */
  17062. lo = Math.imul(al9, bl6);
  17063. mid = Math.imul(al9, bh6);
  17064. mid = (mid + Math.imul(ah9, bl6)) | 0;
  17065. hi = Math.imul(ah9, bh6);
  17066. lo = (lo + Math.imul(al8, bl7)) | 0;
  17067. mid = (mid + Math.imul(al8, bh7)) | 0;
  17068. mid = (mid + Math.imul(ah8, bl7)) | 0;
  17069. hi = (hi + Math.imul(ah8, bh7)) | 0;
  17070. lo = (lo + Math.imul(al7, bl8)) | 0;
  17071. mid = (mid + Math.imul(al7, bh8)) | 0;
  17072. mid = (mid + Math.imul(ah7, bl8)) | 0;
  17073. hi = (hi + Math.imul(ah7, bh8)) | 0;
  17074. lo = (lo + Math.imul(al6, bl9)) | 0;
  17075. mid = (mid + Math.imul(al6, bh9)) | 0;
  17076. mid = (mid + Math.imul(ah6, bl9)) | 0;
  17077. hi = (hi + Math.imul(ah6, bh9)) | 0;
  17078. var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  17079. c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;
  17080. w15 &= 0x3ffffff;
  17081. /* k = 16 */
  17082. lo = Math.imul(al9, bl7);
  17083. mid = Math.imul(al9, bh7);
  17084. mid = (mid + Math.imul(ah9, bl7)) | 0;
  17085. hi = Math.imul(ah9, bh7);
  17086. lo = (lo + Math.imul(al8, bl8)) | 0;
  17087. mid = (mid + Math.imul(al8, bh8)) | 0;
  17088. mid = (mid + Math.imul(ah8, bl8)) | 0;
  17089. hi = (hi + Math.imul(ah8, bh8)) | 0;
  17090. lo = (lo + Math.imul(al7, bl9)) | 0;
  17091. mid = (mid + Math.imul(al7, bh9)) | 0;
  17092. mid = (mid + Math.imul(ah7, bl9)) | 0;
  17093. hi = (hi + Math.imul(ah7, bh9)) | 0;
  17094. var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  17095. c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;
  17096. w16 &= 0x3ffffff;
  17097. /* k = 17 */
  17098. lo = Math.imul(al9, bl8);
  17099. mid = Math.imul(al9, bh8);
  17100. mid = (mid + Math.imul(ah9, bl8)) | 0;
  17101. hi = Math.imul(ah9, bh8);
  17102. lo = (lo + Math.imul(al8, bl9)) | 0;
  17103. mid = (mid + Math.imul(al8, bh9)) | 0;
  17104. mid = (mid + Math.imul(ah8, bl9)) | 0;
  17105. hi = (hi + Math.imul(ah8, bh9)) | 0;
  17106. var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  17107. c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;
  17108. w17 &= 0x3ffffff;
  17109. /* k = 18 */
  17110. lo = Math.imul(al9, bl9);
  17111. mid = Math.imul(al9, bh9);
  17112. mid = (mid + Math.imul(ah9, bl9)) | 0;
  17113. hi = Math.imul(ah9, bh9);
  17114. var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  17115. c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;
  17116. w18 &= 0x3ffffff;
  17117. o[0] = w0;
  17118. o[1] = w1;
  17119. o[2] = w2;
  17120. o[3] = w3;
  17121. o[4] = w4;
  17122. o[5] = w5;
  17123. o[6] = w6;
  17124. o[7] = w7;
  17125. o[8] = w8;
  17126. o[9] = w9;
  17127. o[10] = w10;
  17128. o[11] = w11;
  17129. o[12] = w12;
  17130. o[13] = w13;
  17131. o[14] = w14;
  17132. o[15] = w15;
  17133. o[16] = w16;
  17134. o[17] = w17;
  17135. o[18] = w18;
  17136. if (c !== 0) {
  17137. o[19] = c;
  17138. out.length++;
  17139. }
  17140. return out;
  17141. };
  17142. // Polyfill comb
  17143. if (!Math.imul) {
  17144. comb10MulTo = smallMulTo;
  17145. }
  17146. function bigMulTo (self, num, out) {
  17147. out.negative = num.negative ^ self.negative;
  17148. out.length = self.length + num.length;
  17149. var carry = 0;
  17150. var hncarry = 0;
  17151. for (var k = 0; k < out.length - 1; k++) {
  17152. // Sum all words with the same `i + j = k` and accumulate `ncarry`,
  17153. // note that ncarry could be >= 0x3ffffff
  17154. var ncarry = hncarry;
  17155. hncarry = 0;
  17156. var rword = carry & 0x3ffffff;
  17157. var maxJ = Math.min(k, num.length - 1);
  17158. for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
  17159. var i = k - j;
  17160. var a = self.words[i] | 0;
  17161. var b = num.words[j] | 0;
  17162. var r = a * b;
  17163. var lo = r & 0x3ffffff;
  17164. ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;
  17165. lo = (lo + rword) | 0;
  17166. rword = lo & 0x3ffffff;
  17167. ncarry = (ncarry + (lo >>> 26)) | 0;
  17168. hncarry += ncarry >>> 26;
  17169. ncarry &= 0x3ffffff;
  17170. }
  17171. out.words[k] = rword;
  17172. carry = ncarry;
  17173. ncarry = hncarry;
  17174. }
  17175. if (carry !== 0) {
  17176. out.words[k] = carry;
  17177. } else {
  17178. out.length--;
  17179. }
  17180. return out.strip();
  17181. }
  17182. function jumboMulTo (self, num, out) {
  17183. var fftm = new FFTM();
  17184. return fftm.mulp(self, num, out);
  17185. }
  17186. BN.prototype.mulTo = function mulTo (num, out) {
  17187. var res;
  17188. var len = this.length + num.length;
  17189. if (this.length === 10 && num.length === 10) {
  17190. res = comb10MulTo(this, num, out);
  17191. } else if (len < 63) {
  17192. res = smallMulTo(this, num, out);
  17193. } else if (len < 1024) {
  17194. res = bigMulTo(this, num, out);
  17195. } else {
  17196. res = jumboMulTo(this, num, out);
  17197. }
  17198. return res;
  17199. };
  17200. // Cooley-Tukey algorithm for FFT
  17201. // slightly revisited to rely on looping instead of recursion
  17202. function FFTM (x, y) {
  17203. this.x = x;
  17204. this.y = y;
  17205. }
  17206. FFTM.prototype.makeRBT = function makeRBT (N) {
  17207. var t = new Array(N);
  17208. var l = BN.prototype._countBits(N) - 1;
  17209. for (var i = 0; i < N; i++) {
  17210. t[i] = this.revBin(i, l, N);
  17211. }
  17212. return t;
  17213. };
  17214. // Returns binary-reversed representation of `x`
  17215. FFTM.prototype.revBin = function revBin (x, l, N) {
  17216. if (x === 0 || x === N - 1) return x;
  17217. var rb = 0;
  17218. for (var i = 0; i < l; i++) {
  17219. rb |= (x & 1) << (l - i - 1);
  17220. x >>= 1;
  17221. }
  17222. return rb;
  17223. };
  17224. // Performs "tweedling" phase, therefore 'emulating'
  17225. // behaviour of the recursive algorithm
  17226. FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {
  17227. for (var i = 0; i < N; i++) {
  17228. rtws[i] = rws[rbt[i]];
  17229. itws[i] = iws[rbt[i]];
  17230. }
  17231. };
  17232. FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {
  17233. this.permute(rbt, rws, iws, rtws, itws, N);
  17234. for (var s = 1; s < N; s <<= 1) {
  17235. var l = s << 1;
  17236. var rtwdf = Math.cos(2 * Math.PI / l);
  17237. var itwdf = Math.sin(2 * Math.PI / l);
  17238. for (var p = 0; p < N; p += l) {
  17239. var rtwdf_ = rtwdf;
  17240. var itwdf_ = itwdf;
  17241. for (var j = 0; j < s; j++) {
  17242. var re = rtws[p + j];
  17243. var ie = itws[p + j];
  17244. var ro = rtws[p + j + s];
  17245. var io = itws[p + j + s];
  17246. var rx = rtwdf_ * ro - itwdf_ * io;
  17247. io = rtwdf_ * io + itwdf_ * ro;
  17248. ro = rx;
  17249. rtws[p + j] = re + ro;
  17250. itws[p + j] = ie + io;
  17251. rtws[p + j + s] = re - ro;
  17252. itws[p + j + s] = ie - io;
  17253. /* jshint maxdepth : false */
  17254. if (j !== l) {
  17255. rx = rtwdf * rtwdf_ - itwdf * itwdf_;
  17256. itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
  17257. rtwdf_ = rx;
  17258. }
  17259. }
  17260. }
  17261. }
  17262. };
  17263. FFTM.prototype.guessLen13b = function guessLen13b (n, m) {
  17264. var N = Math.max(m, n) | 1;
  17265. var odd = N & 1;
  17266. var i = 0;
  17267. for (N = N / 2 | 0; N; N = N >>> 1) {
  17268. i++;
  17269. }
  17270. return 1 << i + 1 + odd;
  17271. };
  17272. FFTM.prototype.conjugate = function conjugate (rws, iws, N) {
  17273. if (N <= 1) return;
  17274. for (var i = 0; i < N / 2; i++) {
  17275. var t = rws[i];
  17276. rws[i] = rws[N - i - 1];
  17277. rws[N - i - 1] = t;
  17278. t = iws[i];
  17279. iws[i] = -iws[N - i - 1];
  17280. iws[N - i - 1] = -t;
  17281. }
  17282. };
  17283. FFTM.prototype.normalize13b = function normalize13b (ws, N) {
  17284. var carry = 0;
  17285. for (var i = 0; i < N / 2; i++) {
  17286. var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +
  17287. Math.round(ws[2 * i] / N) +
  17288. carry;
  17289. ws[i] = w & 0x3ffffff;
  17290. if (w < 0x4000000) {
  17291. carry = 0;
  17292. } else {
  17293. carry = w / 0x4000000 | 0;
  17294. }
  17295. }
  17296. return ws;
  17297. };
  17298. FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {
  17299. var carry = 0;
  17300. for (var i = 0; i < len; i++) {
  17301. carry = carry + (ws[i] | 0);
  17302. rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;
  17303. rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;
  17304. }
  17305. // Pad with zeroes
  17306. for (i = 2 * len; i < N; ++i) {
  17307. rws[i] = 0;
  17308. }
  17309. assert(carry === 0);
  17310. assert((carry & ~0x1fff) === 0);
  17311. };
  17312. FFTM.prototype.stub = function stub (N) {
  17313. var ph = new Array(N);
  17314. for (var i = 0; i < N; i++) {
  17315. ph[i] = 0;
  17316. }
  17317. return ph;
  17318. };
  17319. FFTM.prototype.mulp = function mulp (x, y, out) {
  17320. var N = 2 * this.guessLen13b(x.length, y.length);
  17321. var rbt = this.makeRBT(N);
  17322. var _ = this.stub(N);
  17323. var rws = new Array(N);
  17324. var rwst = new Array(N);
  17325. var iwst = new Array(N);
  17326. var nrws = new Array(N);
  17327. var nrwst = new Array(N);
  17328. var niwst = new Array(N);
  17329. var rmws = out.words;
  17330. rmws.length = N;
  17331. this.convert13b(x.words, x.length, rws, N);
  17332. this.convert13b(y.words, y.length, nrws, N);
  17333. this.transform(rws, _, rwst, iwst, N, rbt);
  17334. this.transform(nrws, _, nrwst, niwst, N, rbt);
  17335. for (var i = 0; i < N; i++) {
  17336. var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];
  17337. iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];
  17338. rwst[i] = rx;
  17339. }
  17340. this.conjugate(rwst, iwst, N);
  17341. this.transform(rwst, iwst, rmws, _, N, rbt);
  17342. this.conjugate(rmws, _, N);
  17343. this.normalize13b(rmws, N);
  17344. out.negative = x.negative ^ y.negative;
  17345. out.length = x.length + y.length;
  17346. return out.strip();
  17347. };
  17348. // Multiply `this` by `num`
  17349. BN.prototype.mul = function mul (num) {
  17350. var out = new BN(null);
  17351. out.words = new Array(this.length + num.length);
  17352. return this.mulTo(num, out);
  17353. };
  17354. // Multiply employing FFT
  17355. BN.prototype.mulf = function mulf (num) {
  17356. var out = new BN(null);
  17357. out.words = new Array(this.length + num.length);
  17358. return jumboMulTo(this, num, out);
  17359. };
  17360. // In-place Multiplication
  17361. BN.prototype.imul = function imul (num) {
  17362. return this.clone().mulTo(num, this);
  17363. };
  17364. BN.prototype.imuln = function imuln (num) {
  17365. assert(typeof num === 'number');
  17366. assert(num < 0x4000000);
  17367. // Carry
  17368. var carry = 0;
  17369. for (var i = 0; i < this.length; i++) {
  17370. var w = (this.words[i] | 0) * num;
  17371. var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);
  17372. carry >>= 26;
  17373. carry += (w / 0x4000000) | 0;
  17374. // NOTE: lo is 27bit maximum
  17375. carry += lo >>> 26;
  17376. this.words[i] = lo & 0x3ffffff;
  17377. }
  17378. if (carry !== 0) {
  17379. this.words[i] = carry;
  17380. this.length++;
  17381. }
  17382. return this;
  17383. };
  17384. BN.prototype.muln = function muln (num) {
  17385. return this.clone().imuln(num);
  17386. };
  17387. // `this` * `this`
  17388. BN.prototype.sqr = function sqr () {
  17389. return this.mul(this);
  17390. };
  17391. // `this` * `this` in-place
  17392. BN.prototype.isqr = function isqr () {
  17393. return this.imul(this.clone());
  17394. };
  17395. // Math.pow(`this`, `num`)
  17396. BN.prototype.pow = function pow (num) {
  17397. var w = toBitArray(num);
  17398. if (w.length === 0) return new BN(1);
  17399. // Skip leading zeroes
  17400. var res = this;
  17401. for (var i = 0; i < w.length; i++, res = res.sqr()) {
  17402. if (w[i] !== 0) break;
  17403. }
  17404. if (++i < w.length) {
  17405. for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {
  17406. if (w[i] === 0) continue;
  17407. res = res.mul(q);
  17408. }
  17409. }
  17410. return res;
  17411. };
  17412. // Shift-left in-place
  17413. BN.prototype.iushln = function iushln (bits) {
  17414. assert(typeof bits === 'number' && bits >= 0);
  17415. var r = bits % 26;
  17416. var s = (bits - r) / 26;
  17417. var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);
  17418. var i;
  17419. if (r !== 0) {
  17420. var carry = 0;
  17421. for (i = 0; i < this.length; i++) {
  17422. var newCarry = this.words[i] & carryMask;
  17423. var c = ((this.words[i] | 0) - newCarry) << r;
  17424. this.words[i] = c | carry;
  17425. carry = newCarry >>> (26 - r);
  17426. }
  17427. if (carry) {
  17428. this.words[i] = carry;
  17429. this.length++;
  17430. }
  17431. }
  17432. if (s !== 0) {
  17433. for (i = this.length - 1; i >= 0; i--) {
  17434. this.words[i + s] = this.words[i];
  17435. }
  17436. for (i = 0; i < s; i++) {
  17437. this.words[i] = 0;
  17438. }
  17439. this.length += s;
  17440. }
  17441. return this.strip();
  17442. };
  17443. BN.prototype.ishln = function ishln (bits) {
  17444. // TODO(indutny): implement me
  17445. assert(this.negative === 0);
  17446. return this.iushln(bits);
  17447. };
  17448. // Shift-right in-place
  17449. // NOTE: `hint` is a lowest bit before trailing zeroes
  17450. // NOTE: if `extended` is present - it will be filled with destroyed bits
  17451. BN.prototype.iushrn = function iushrn (bits, hint, extended) {
  17452. assert(typeof bits === 'number' && bits >= 0);
  17453. var h;
  17454. if (hint) {
  17455. h = (hint - (hint % 26)) / 26;
  17456. } else {
  17457. h = 0;
  17458. }
  17459. var r = bits % 26;
  17460. var s = Math.min((bits - r) / 26, this.length);
  17461. var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
  17462. var maskedWords = extended;
  17463. h -= s;
  17464. h = Math.max(0, h);
  17465. // Extended mode, copy masked part
  17466. if (maskedWords) {
  17467. for (var i = 0; i < s; i++) {
  17468. maskedWords.words[i] = this.words[i];
  17469. }
  17470. maskedWords.length = s;
  17471. }
  17472. if (s === 0) {
  17473. // No-op, we should not move anything at all
  17474. } else if (this.length > s) {
  17475. this.length -= s;
  17476. for (i = 0; i < this.length; i++) {
  17477. this.words[i] = this.words[i + s];
  17478. }
  17479. } else {
  17480. this.words[0] = 0;
  17481. this.length = 1;
  17482. }
  17483. var carry = 0;
  17484. for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {
  17485. var word = this.words[i] | 0;
  17486. this.words[i] = (carry << (26 - r)) | (word >>> r);
  17487. carry = word & mask;
  17488. }
  17489. // Push carried bits as a mask
  17490. if (maskedWords && carry !== 0) {
  17491. maskedWords.words[maskedWords.length++] = carry;
  17492. }
  17493. if (this.length === 0) {
  17494. this.words[0] = 0;
  17495. this.length = 1;
  17496. }
  17497. return this.strip();
  17498. };
  17499. BN.prototype.ishrn = function ishrn (bits, hint, extended) {
  17500. // TODO(indutny): implement me
  17501. assert(this.negative === 0);
  17502. return this.iushrn(bits, hint, extended);
  17503. };
  17504. // Shift-left
  17505. BN.prototype.shln = function shln (bits) {
  17506. return this.clone().ishln(bits);
  17507. };
  17508. BN.prototype.ushln = function ushln (bits) {
  17509. return this.clone().iushln(bits);
  17510. };
  17511. // Shift-right
  17512. BN.prototype.shrn = function shrn (bits) {
  17513. return this.clone().ishrn(bits);
  17514. };
  17515. BN.prototype.ushrn = function ushrn (bits) {
  17516. return this.clone().iushrn(bits);
  17517. };
  17518. // Test if n bit is set
  17519. BN.prototype.testn = function testn (bit) {
  17520. assert(typeof bit === 'number' && bit >= 0);
  17521. var r = bit % 26;
  17522. var s = (bit - r) / 26;
  17523. var q = 1 << r;
  17524. // Fast case: bit is much higher than all existing words
  17525. if (this.length <= s) return false;
  17526. // Check bit and return
  17527. var w = this.words[s];
  17528. return !!(w & q);
  17529. };
  17530. // Return only lowers bits of number (in-place)
  17531. BN.prototype.imaskn = function imaskn (bits) {
  17532. assert(typeof bits === 'number' && bits >= 0);
  17533. var r = bits % 26;
  17534. var s = (bits - r) / 26;
  17535. assert(this.negative === 0, 'imaskn works only with positive numbers');
  17536. if (r !== 0) {
  17537. s++;
  17538. }
  17539. this.length = Math.min(s, this.length);
  17540. if (r !== 0) {
  17541. var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
  17542. this.words[this.length - 1] &= mask;
  17543. }
  17544. return this.strip();
  17545. };
  17546. // Return only lowers bits of number
  17547. BN.prototype.maskn = function maskn (bits) {
  17548. return this.clone().imaskn(bits);
  17549. };
  17550. // Add plain number `num` to `this`
  17551. BN.prototype.iaddn = function iaddn (num) {
  17552. assert(typeof num === 'number');
  17553. assert(num < 0x4000000);
  17554. if (num < 0) return this.isubn(-num);
  17555. // Possible sign change
  17556. if (this.negative !== 0) {
  17557. if (this.length === 1 && (this.words[0] | 0) < num) {
  17558. this.words[0] = num - (this.words[0] | 0);
  17559. this.negative = 0;
  17560. return this;
  17561. }
  17562. this.negative = 0;
  17563. this.isubn(num);
  17564. this.negative = 1;
  17565. return this;
  17566. }
  17567. // Add without checks
  17568. return this._iaddn(num);
  17569. };
  17570. BN.prototype._iaddn = function _iaddn (num) {
  17571. this.words[0] += num;
  17572. // Carry
  17573. for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {
  17574. this.words[i] -= 0x4000000;
  17575. if (i === this.length - 1) {
  17576. this.words[i + 1] = 1;
  17577. } else {
  17578. this.words[i + 1]++;
  17579. }
  17580. }
  17581. this.length = Math.max(this.length, i + 1);
  17582. return this;
  17583. };
  17584. // Subtract plain number `num` from `this`
  17585. BN.prototype.isubn = function isubn (num) {
  17586. assert(typeof num === 'number');
  17587. assert(num < 0x4000000);
  17588. if (num < 0) return this.iaddn(-num);
  17589. if (this.negative !== 0) {
  17590. this.negative = 0;
  17591. this.iaddn(num);
  17592. this.negative = 1;
  17593. return this;
  17594. }
  17595. this.words[0] -= num;
  17596. if (this.length === 1 && this.words[0] < 0) {
  17597. this.words[0] = -this.words[0];
  17598. this.negative = 1;
  17599. } else {
  17600. // Carry
  17601. for (var i = 0; i < this.length && this.words[i] < 0; i++) {
  17602. this.words[i] += 0x4000000;
  17603. this.words[i + 1] -= 1;
  17604. }
  17605. }
  17606. return this.strip();
  17607. };
  17608. BN.prototype.addn = function addn (num) {
  17609. return this.clone().iaddn(num);
  17610. };
  17611. BN.prototype.subn = function subn (num) {
  17612. return this.clone().isubn(num);
  17613. };
  17614. BN.prototype.iabs = function iabs () {
  17615. this.negative = 0;
  17616. return this;
  17617. };
  17618. BN.prototype.abs = function abs () {
  17619. return this.clone().iabs();
  17620. };
  17621. BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {
  17622. var len = num.length + shift;
  17623. var i;
  17624. this._expand(len);
  17625. var w;
  17626. var carry = 0;
  17627. for (i = 0; i < num.length; i++) {
  17628. w = (this.words[i + shift] | 0) + carry;
  17629. var right = (num.words[i] | 0) * mul;
  17630. w -= right & 0x3ffffff;
  17631. carry = (w >> 26) - ((right / 0x4000000) | 0);
  17632. this.words[i + shift] = w & 0x3ffffff;
  17633. }
  17634. for (; i < this.length - shift; i++) {
  17635. w = (this.words[i + shift] | 0) + carry;
  17636. carry = w >> 26;
  17637. this.words[i + shift] = w & 0x3ffffff;
  17638. }
  17639. if (carry === 0) return this.strip();
  17640. // Subtraction overflow
  17641. assert(carry === -1);
  17642. carry = 0;
  17643. for (i = 0; i < this.length; i++) {
  17644. w = -(this.words[i] | 0) + carry;
  17645. carry = w >> 26;
  17646. this.words[i] = w & 0x3ffffff;
  17647. }
  17648. this.negative = 1;
  17649. return this.strip();
  17650. };
  17651. BN.prototype._wordDiv = function _wordDiv (num, mode) {
  17652. var shift = this.length - num.length;
  17653. var a = this.clone();
  17654. var b = num;
  17655. // Normalize
  17656. var bhi = b.words[b.length - 1] | 0;
  17657. var bhiBits = this._countBits(bhi);
  17658. shift = 26 - bhiBits;
  17659. if (shift !== 0) {
  17660. b = b.ushln(shift);
  17661. a.iushln(shift);
  17662. bhi = b.words[b.length - 1] | 0;
  17663. }
  17664. // Initialize quotient
  17665. var m = a.length - b.length;
  17666. var q;
  17667. if (mode !== 'mod') {
  17668. q = new BN(null);
  17669. q.length = m + 1;
  17670. q.words = new Array(q.length);
  17671. for (var i = 0; i < q.length; i++) {
  17672. q.words[i] = 0;
  17673. }
  17674. }
  17675. var diff = a.clone()._ishlnsubmul(b, 1, m);
  17676. if (diff.negative === 0) {
  17677. a = diff;
  17678. if (q) {
  17679. q.words[m] = 1;
  17680. }
  17681. }
  17682. for (var j = m - 1; j >= 0; j--) {
  17683. var qj = (a.words[b.length + j] | 0) * 0x4000000 +
  17684. (a.words[b.length + j - 1] | 0);
  17685. // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
  17686. // (0x7ffffff)
  17687. qj = Math.min((qj / bhi) | 0, 0x3ffffff);
  17688. a._ishlnsubmul(b, qj, j);
  17689. while (a.negative !== 0) {
  17690. qj--;
  17691. a.negative = 0;
  17692. a._ishlnsubmul(b, 1, j);
  17693. if (!a.isZero()) {
  17694. a.negative ^= 1;
  17695. }
  17696. }
  17697. if (q) {
  17698. q.words[j] = qj;
  17699. }
  17700. }
  17701. if (q) {
  17702. q.strip();
  17703. }
  17704. a.strip();
  17705. // Denormalize
  17706. if (mode !== 'div' && shift !== 0) {
  17707. a.iushrn(shift);
  17708. }
  17709. return {
  17710. div: q || null,
  17711. mod: a
  17712. };
  17713. };
  17714. // NOTE: 1) `mode` can be set to `mod` to request mod only,
  17715. // to `div` to request div only, or be absent to
  17716. // request both div & mod
  17717. // 2) `positive` is true if unsigned mod is requested
  17718. BN.prototype.divmod = function divmod (num, mode, positive) {
  17719. assert(!num.isZero());
  17720. if (this.isZero()) {
  17721. return {
  17722. div: new BN(0),
  17723. mod: new BN(0)
  17724. };
  17725. }
  17726. var div, mod, res;
  17727. if (this.negative !== 0 && num.negative === 0) {
  17728. res = this.neg().divmod(num, mode);
  17729. if (mode !== 'mod') {
  17730. div = res.div.neg();
  17731. }
  17732. if (mode !== 'div') {
  17733. mod = res.mod.neg();
  17734. if (positive && mod.negative !== 0) {
  17735. mod.iadd(num);
  17736. }
  17737. }
  17738. return {
  17739. div: div,
  17740. mod: mod
  17741. };
  17742. }
  17743. if (this.negative === 0 && num.negative !== 0) {
  17744. res = this.divmod(num.neg(), mode);
  17745. if (mode !== 'mod') {
  17746. div = res.div.neg();
  17747. }
  17748. return {
  17749. div: div,
  17750. mod: res.mod
  17751. };
  17752. }
  17753. if ((this.negative & num.negative) !== 0) {
  17754. res = this.neg().divmod(num.neg(), mode);
  17755. if (mode !== 'div') {
  17756. mod = res.mod.neg();
  17757. if (positive && mod.negative !== 0) {
  17758. mod.isub(num);
  17759. }
  17760. }
  17761. return {
  17762. div: res.div,
  17763. mod: mod
  17764. };
  17765. }
  17766. // Both numbers are positive at this point
  17767. // Strip both numbers to approximate shift value
  17768. if (num.length > this.length || this.cmp(num) < 0) {
  17769. return {
  17770. div: new BN(0),
  17771. mod: this
  17772. };
  17773. }
  17774. // Very short reduction
  17775. if (num.length === 1) {
  17776. if (mode === 'div') {
  17777. return {
  17778. div: this.divn(num.words[0]),
  17779. mod: null
  17780. };
  17781. }
  17782. if (mode === 'mod') {
  17783. return {
  17784. div: null,
  17785. mod: new BN(this.modn(num.words[0]))
  17786. };
  17787. }
  17788. return {
  17789. div: this.divn(num.words[0]),
  17790. mod: new BN(this.modn(num.words[0]))
  17791. };
  17792. }
  17793. return this._wordDiv(num, mode);
  17794. };
  17795. // Find `this` / `num`
  17796. BN.prototype.div = function div (num) {
  17797. return this.divmod(num, 'div', false).div;
  17798. };
  17799. // Find `this` % `num`
  17800. BN.prototype.mod = function mod (num) {
  17801. return this.divmod(num, 'mod', false).mod;
  17802. };
  17803. BN.prototype.umod = function umod (num) {
  17804. return this.divmod(num, 'mod', true).mod;
  17805. };
  17806. // Find Round(`this` / `num`)
  17807. BN.prototype.divRound = function divRound (num) {
  17808. var dm = this.divmod(num);
  17809. // Fast case - exact division
  17810. if (dm.mod.isZero()) return dm.div;
  17811. var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
  17812. var half = num.ushrn(1);
  17813. var r2 = num.andln(1);
  17814. var cmp = mod.cmp(half);
  17815. // Round down
  17816. if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;
  17817. // Round up
  17818. return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
  17819. };
  17820. BN.prototype.modn = function modn (num) {
  17821. assert(num <= 0x3ffffff);
  17822. var p = (1 << 26) % num;
  17823. var acc = 0;
  17824. for (var i = this.length - 1; i >= 0; i--) {
  17825. acc = (p * acc + (this.words[i] | 0)) % num;
  17826. }
  17827. return acc;
  17828. };
  17829. // In-place division by number
  17830. BN.prototype.idivn = function idivn (num) {
  17831. assert(num <= 0x3ffffff);
  17832. var carry = 0;
  17833. for (var i = this.length - 1; i >= 0; i--) {
  17834. var w = (this.words[i] | 0) + carry * 0x4000000;
  17835. this.words[i] = (w / num) | 0;
  17836. carry = w % num;
  17837. }
  17838. return this.strip();
  17839. };
  17840. BN.prototype.divn = function divn (num) {
  17841. return this.clone().idivn(num);
  17842. };
  17843. BN.prototype.egcd = function egcd (p) {
  17844. assert(p.negative === 0);
  17845. assert(!p.isZero());
  17846. var x = this;
  17847. var y = p.clone();
  17848. if (x.negative !== 0) {
  17849. x = x.umod(p);
  17850. } else {
  17851. x = x.clone();
  17852. }
  17853. // A * x + B * y = x
  17854. var A = new BN(1);
  17855. var B = new BN(0);
  17856. // C * x + D * y = y
  17857. var C = new BN(0);
  17858. var D = new BN(1);
  17859. var g = 0;
  17860. while (x.isEven() && y.isEven()) {
  17861. x.iushrn(1);
  17862. y.iushrn(1);
  17863. ++g;
  17864. }
  17865. var yp = y.clone();
  17866. var xp = x.clone();
  17867. while (!x.isZero()) {
  17868. for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
  17869. if (i > 0) {
  17870. x.iushrn(i);
  17871. while (i-- > 0) {
  17872. if (A.isOdd() || B.isOdd()) {
  17873. A.iadd(yp);
  17874. B.isub(xp);
  17875. }
  17876. A.iushrn(1);
  17877. B.iushrn(1);
  17878. }
  17879. }
  17880. for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
  17881. if (j > 0) {
  17882. y.iushrn(j);
  17883. while (j-- > 0) {
  17884. if (C.isOdd() || D.isOdd()) {
  17885. C.iadd(yp);
  17886. D.isub(xp);
  17887. }
  17888. C.iushrn(1);
  17889. D.iushrn(1);
  17890. }
  17891. }
  17892. if (x.cmp(y) >= 0) {
  17893. x.isub(y);
  17894. A.isub(C);
  17895. B.isub(D);
  17896. } else {
  17897. y.isub(x);
  17898. C.isub(A);
  17899. D.isub(B);
  17900. }
  17901. }
  17902. return {
  17903. a: C,
  17904. b: D,
  17905. gcd: y.iushln(g)
  17906. };
  17907. };
  17908. // This is reduced incarnation of the binary EEA
  17909. // above, designated to invert members of the
  17910. // _prime_ fields F(p) at a maximal speed
  17911. BN.prototype._invmp = function _invmp (p) {
  17912. assert(p.negative === 0);
  17913. assert(!p.isZero());
  17914. var a = this;
  17915. var b = p.clone();
  17916. if (a.negative !== 0) {
  17917. a = a.umod(p);
  17918. } else {
  17919. a = a.clone();
  17920. }
  17921. var x1 = new BN(1);
  17922. var x2 = new BN(0);
  17923. var delta = b.clone();
  17924. while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
  17925. for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
  17926. if (i > 0) {
  17927. a.iushrn(i);
  17928. while (i-- > 0) {
  17929. if (x1.isOdd()) {
  17930. x1.iadd(delta);
  17931. }
  17932. x1.iushrn(1);
  17933. }
  17934. }
  17935. for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
  17936. if (j > 0) {
  17937. b.iushrn(j);
  17938. while (j-- > 0) {
  17939. if (x2.isOdd()) {
  17940. x2.iadd(delta);
  17941. }
  17942. x2.iushrn(1);
  17943. }
  17944. }
  17945. if (a.cmp(b) >= 0) {
  17946. a.isub(b);
  17947. x1.isub(x2);
  17948. } else {
  17949. b.isub(a);
  17950. x2.isub(x1);
  17951. }
  17952. }
  17953. var res;
  17954. if (a.cmpn(1) === 0) {
  17955. res = x1;
  17956. } else {
  17957. res = x2;
  17958. }
  17959. if (res.cmpn(0) < 0) {
  17960. res.iadd(p);
  17961. }
  17962. return res;
  17963. };
  17964. BN.prototype.gcd = function gcd (num) {
  17965. if (this.isZero()) return num.abs();
  17966. if (num.isZero()) return this.abs();
  17967. var a = this.clone();
  17968. var b = num.clone();
  17969. a.negative = 0;
  17970. b.negative = 0;
  17971. // Remove common factor of two
  17972. for (var shift = 0; a.isEven() && b.isEven(); shift++) {
  17973. a.iushrn(1);
  17974. b.iushrn(1);
  17975. }
  17976. do {
  17977. while (a.isEven()) {
  17978. a.iushrn(1);
  17979. }
  17980. while (b.isEven()) {
  17981. b.iushrn(1);
  17982. }
  17983. var r = a.cmp(b);
  17984. if (r < 0) {
  17985. // Swap `a` and `b` to make `a` always bigger than `b`
  17986. var t = a;
  17987. a = b;
  17988. b = t;
  17989. } else if (r === 0 || b.cmpn(1) === 0) {
  17990. break;
  17991. }
  17992. a.isub(b);
  17993. } while (true);
  17994. return b.iushln(shift);
  17995. };
  17996. // Invert number in the field F(num)
  17997. BN.prototype.invm = function invm (num) {
  17998. return this.egcd(num).a.umod(num);
  17999. };
  18000. BN.prototype.isEven = function isEven () {
  18001. return (this.words[0] & 1) === 0;
  18002. };
  18003. BN.prototype.isOdd = function isOdd () {
  18004. return (this.words[0] & 1) === 1;
  18005. };
  18006. // And first word and num
  18007. BN.prototype.andln = function andln (num) {
  18008. return this.words[0] & num;
  18009. };
  18010. // Increment at the bit position in-line
  18011. BN.prototype.bincn = function bincn (bit) {
  18012. assert(typeof bit === 'number');
  18013. var r = bit % 26;
  18014. var s = (bit - r) / 26;
  18015. var q = 1 << r;
  18016. // Fast case: bit is much higher than all existing words
  18017. if (this.length <= s) {
  18018. this._expand(s + 1);
  18019. this.words[s] |= q;
  18020. return this;
  18021. }
  18022. // Add bit and propagate, if needed
  18023. var carry = q;
  18024. for (var i = s; carry !== 0 && i < this.length; i++) {
  18025. var w = this.words[i] | 0;
  18026. w += carry;
  18027. carry = w >>> 26;
  18028. w &= 0x3ffffff;
  18029. this.words[i] = w;
  18030. }
  18031. if (carry !== 0) {
  18032. this.words[i] = carry;
  18033. this.length++;
  18034. }
  18035. return this;
  18036. };
  18037. BN.prototype.isZero = function isZero () {
  18038. return this.length === 1 && this.words[0] === 0;
  18039. };
  18040. BN.prototype.cmpn = function cmpn (num) {
  18041. var negative = num < 0;
  18042. if (this.negative !== 0 && !negative) return -1;
  18043. if (this.negative === 0 && negative) return 1;
  18044. this.strip();
  18045. var res;
  18046. if (this.length > 1) {
  18047. res = 1;
  18048. } else {
  18049. if (negative) {
  18050. num = -num;
  18051. }
  18052. assert(num <= 0x3ffffff, 'Number is too big');
  18053. var w = this.words[0] | 0;
  18054. res = w === num ? 0 : w < num ? -1 : 1;
  18055. }
  18056. if (this.negative !== 0) return -res | 0;
  18057. return res;
  18058. };
  18059. // Compare two numbers and return:
  18060. // 1 - if `this` > `num`
  18061. // 0 - if `this` == `num`
  18062. // -1 - if `this` < `num`
  18063. BN.prototype.cmp = function cmp (num) {
  18064. if (this.negative !== 0 && num.negative === 0) return -1;
  18065. if (this.negative === 0 && num.negative !== 0) return 1;
  18066. var res = this.ucmp(num);
  18067. if (this.negative !== 0) return -res | 0;
  18068. return res;
  18069. };
  18070. // Unsigned comparison
  18071. BN.prototype.ucmp = function ucmp (num) {
  18072. // At this point both numbers have the same sign
  18073. if (this.length > num.length) return 1;
  18074. if (this.length < num.length) return -1;
  18075. var res = 0;
  18076. for (var i = this.length - 1; i >= 0; i--) {
  18077. var a = this.words[i] | 0;
  18078. var b = num.words[i] | 0;
  18079. if (a === b) continue;
  18080. if (a < b) {
  18081. res = -1;
  18082. } else if (a > b) {
  18083. res = 1;
  18084. }
  18085. break;
  18086. }
  18087. return res;
  18088. };
  18089. BN.prototype.gtn = function gtn (num) {
  18090. return this.cmpn(num) === 1;
  18091. };
  18092. BN.prototype.gt = function gt (num) {
  18093. return this.cmp(num) === 1;
  18094. };
  18095. BN.prototype.gten = function gten (num) {
  18096. return this.cmpn(num) >= 0;
  18097. };
  18098. BN.prototype.gte = function gte (num) {
  18099. return this.cmp(num) >= 0;
  18100. };
  18101. BN.prototype.ltn = function ltn (num) {
  18102. return this.cmpn(num) === -1;
  18103. };
  18104. BN.prototype.lt = function lt (num) {
  18105. return this.cmp(num) === -1;
  18106. };
  18107. BN.prototype.lten = function lten (num) {
  18108. return this.cmpn(num) <= 0;
  18109. };
  18110. BN.prototype.lte = function lte (num) {
  18111. return this.cmp(num) <= 0;
  18112. };
  18113. BN.prototype.eqn = function eqn (num) {
  18114. return this.cmpn(num) === 0;
  18115. };
  18116. BN.prototype.eq = function eq (num) {
  18117. return this.cmp(num) === 0;
  18118. };
  18119. //
  18120. // A reduce context, could be using montgomery or something better, depending
  18121. // on the `m` itself.
  18122. //
  18123. BN.red = function red (num) {
  18124. return new Red(num);
  18125. };
  18126. BN.prototype.toRed = function toRed (ctx) {
  18127. assert(!this.red, 'Already a number in reduction context');
  18128. assert(this.negative === 0, 'red works only with positives');
  18129. return ctx.convertTo(this)._forceRed(ctx);
  18130. };
  18131. BN.prototype.fromRed = function fromRed () {
  18132. assert(this.red, 'fromRed works only with numbers in reduction context');
  18133. return this.red.convertFrom(this);
  18134. };
  18135. BN.prototype._forceRed = function _forceRed (ctx) {
  18136. this.red = ctx;
  18137. return this;
  18138. };
  18139. BN.prototype.forceRed = function forceRed (ctx) {
  18140. assert(!this.red, 'Already a number in reduction context');
  18141. return this._forceRed(ctx);
  18142. };
  18143. BN.prototype.redAdd = function redAdd (num) {
  18144. assert(this.red, 'redAdd works only with red numbers');
  18145. return this.red.add(this, num);
  18146. };
  18147. BN.prototype.redIAdd = function redIAdd (num) {
  18148. assert(this.red, 'redIAdd works only with red numbers');
  18149. return this.red.iadd(this, num);
  18150. };
  18151. BN.prototype.redSub = function redSub (num) {
  18152. assert(this.red, 'redSub works only with red numbers');
  18153. return this.red.sub(this, num);
  18154. };
  18155. BN.prototype.redISub = function redISub (num) {
  18156. assert(this.red, 'redISub works only with red numbers');
  18157. return this.red.isub(this, num);
  18158. };
  18159. BN.prototype.redShl = function redShl (num) {
  18160. assert(this.red, 'redShl works only with red numbers');
  18161. return this.red.shl(this, num);
  18162. };
  18163. BN.prototype.redMul = function redMul (num) {
  18164. assert(this.red, 'redMul works only with red numbers');
  18165. this.red._verify2(this, num);
  18166. return this.red.mul(this, num);
  18167. };
  18168. BN.prototype.redIMul = function redIMul (num) {
  18169. assert(this.red, 'redMul works only with red numbers');
  18170. this.red._verify2(this, num);
  18171. return this.red.imul(this, num);
  18172. };
  18173. BN.prototype.redSqr = function redSqr () {
  18174. assert(this.red, 'redSqr works only with red numbers');
  18175. this.red._verify1(this);
  18176. return this.red.sqr(this);
  18177. };
  18178. BN.prototype.redISqr = function redISqr () {
  18179. assert(this.red, 'redISqr works only with red numbers');
  18180. this.red._verify1(this);
  18181. return this.red.isqr(this);
  18182. };
  18183. // Square root over p
  18184. BN.prototype.redSqrt = function redSqrt () {
  18185. assert(this.red, 'redSqrt works only with red numbers');
  18186. this.red._verify1(this);
  18187. return this.red.sqrt(this);
  18188. };
  18189. BN.prototype.redInvm = function redInvm () {
  18190. assert(this.red, 'redInvm works only with red numbers');
  18191. this.red._verify1(this);
  18192. return this.red.invm(this);
  18193. };
  18194. // Return negative clone of `this` % `red modulo`
  18195. BN.prototype.redNeg = function redNeg () {
  18196. assert(this.red, 'redNeg works only with red numbers');
  18197. this.red._verify1(this);
  18198. return this.red.neg(this);
  18199. };
  18200. BN.prototype.redPow = function redPow (num) {
  18201. assert(this.red && !num.red, 'redPow(normalNum)');
  18202. this.red._verify1(this);
  18203. return this.red.pow(this, num);
  18204. };
  18205. // Prime numbers with efficient reduction
  18206. var primes = {
  18207. k256: null,
  18208. p224: null,
  18209. p192: null,
  18210. p25519: null
  18211. };
  18212. // Pseudo-Mersenne prime
  18213. function MPrime (name, p) {
  18214. // P = 2 ^ N - K
  18215. this.name = name;
  18216. this.p = new BN(p, 16);
  18217. this.n = this.p.bitLength();
  18218. this.k = new BN(1).iushln(this.n).isub(this.p);
  18219. this.tmp = this._tmp();
  18220. }
  18221. MPrime.prototype._tmp = function _tmp () {
  18222. var tmp = new BN(null);
  18223. tmp.words = new Array(Math.ceil(this.n / 13));
  18224. return tmp;
  18225. };
  18226. MPrime.prototype.ireduce = function ireduce (num) {
  18227. // Assumes that `num` is less than `P^2`
  18228. // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)
  18229. var r = num;
  18230. var rlen;
  18231. do {
  18232. this.split(r, this.tmp);
  18233. r = this.imulK(r);
  18234. r = r.iadd(this.tmp);
  18235. rlen = r.bitLength();
  18236. } while (rlen > this.n);
  18237. var cmp = rlen < this.n ? -1 : r.ucmp(this.p);
  18238. if (cmp === 0) {
  18239. r.words[0] = 0;
  18240. r.length = 1;
  18241. } else if (cmp > 0) {
  18242. r.isub(this.p);
  18243. } else {
  18244. r.strip();
  18245. }
  18246. return r;
  18247. };
  18248. MPrime.prototype.split = function split (input, out) {
  18249. input.iushrn(this.n, 0, out);
  18250. };
  18251. MPrime.prototype.imulK = function imulK (num) {
  18252. return num.imul(this.k);
  18253. };
  18254. function K256 () {
  18255. MPrime.call(
  18256. this,
  18257. 'k256',
  18258. 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');
  18259. }
  18260. inherits(K256, MPrime);
  18261. K256.prototype.split = function split (input, output) {
  18262. // 256 = 9 * 26 + 22
  18263. var mask = 0x3fffff;
  18264. var outLen = Math.min(input.length, 9);
  18265. for (var i = 0; i < outLen; i++) {
  18266. output.words[i] = input.words[i];
  18267. }
  18268. output.length = outLen;
  18269. if (input.length <= 9) {
  18270. input.words[0] = 0;
  18271. input.length = 1;
  18272. return;
  18273. }
  18274. // Shift by 9 limbs
  18275. var prev = input.words[9];
  18276. output.words[output.length++] = prev & mask;
  18277. for (i = 10; i < input.length; i++) {
  18278. var next = input.words[i] | 0;
  18279. input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);
  18280. prev = next;
  18281. }
  18282. prev >>>= 22;
  18283. input.words[i - 10] = prev;
  18284. if (prev === 0 && input.length > 10) {
  18285. input.length -= 10;
  18286. } else {
  18287. input.length -= 9;
  18288. }
  18289. };
  18290. K256.prototype.imulK = function imulK (num) {
  18291. // K = 0x1000003d1 = [ 0x40, 0x3d1 ]
  18292. num.words[num.length] = 0;
  18293. num.words[num.length + 1] = 0;
  18294. num.length += 2;
  18295. // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
  18296. var lo = 0;
  18297. for (var i = 0; i < num.length; i++) {
  18298. var w = num.words[i] | 0;
  18299. lo += w * 0x3d1;
  18300. num.words[i] = lo & 0x3ffffff;
  18301. lo = w * 0x40 + ((lo / 0x4000000) | 0);
  18302. }
  18303. // Fast length reduction
  18304. if (num.words[num.length - 1] === 0) {
  18305. num.length--;
  18306. if (num.words[num.length - 1] === 0) {
  18307. num.length--;
  18308. }
  18309. }
  18310. return num;
  18311. };
  18312. function P224 () {
  18313. MPrime.call(
  18314. this,
  18315. 'p224',
  18316. 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');
  18317. }
  18318. inherits(P224, MPrime);
  18319. function P192 () {
  18320. MPrime.call(
  18321. this,
  18322. 'p192',
  18323. 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');
  18324. }
  18325. inherits(P192, MPrime);
  18326. function P25519 () {
  18327. // 2 ^ 255 - 19
  18328. MPrime.call(
  18329. this,
  18330. '25519',
  18331. '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');
  18332. }
  18333. inherits(P25519, MPrime);
  18334. P25519.prototype.imulK = function imulK (num) {
  18335. // K = 0x13
  18336. var carry = 0;
  18337. for (var i = 0; i < num.length; i++) {
  18338. var hi = (num.words[i] | 0) * 0x13 + carry;
  18339. var lo = hi & 0x3ffffff;
  18340. hi >>>= 26;
  18341. num.words[i] = lo;
  18342. carry = hi;
  18343. }
  18344. if (carry !== 0) {
  18345. num.words[num.length++] = carry;
  18346. }
  18347. return num;
  18348. };
  18349. // Exported mostly for testing purposes, use plain name instead
  18350. BN._prime = function prime (name) {
  18351. // Cached version of prime
  18352. if (primes[name]) return primes[name];
  18353. var prime;
  18354. if (name === 'k256') {
  18355. prime = new K256();
  18356. } else if (name === 'p224') {
  18357. prime = new P224();
  18358. } else if (name === 'p192') {
  18359. prime = new P192();
  18360. } else if (name === 'p25519') {
  18361. prime = new P25519();
  18362. } else {
  18363. throw new Error('Unknown prime ' + name);
  18364. }
  18365. primes[name] = prime;
  18366. return prime;
  18367. };
  18368. //
  18369. // Base reduction engine
  18370. //
  18371. function Red (m) {
  18372. if (typeof m === 'string') {
  18373. var prime = BN._prime(m);
  18374. this.m = prime.p;
  18375. this.prime = prime;
  18376. } else {
  18377. assert(m.gtn(1), 'modulus must be greater than 1');
  18378. this.m = m;
  18379. this.prime = null;
  18380. }
  18381. }
  18382. Red.prototype._verify1 = function _verify1 (a) {
  18383. assert(a.negative === 0, 'red works only with positives');
  18384. assert(a.red, 'red works only with red numbers');
  18385. };
  18386. Red.prototype._verify2 = function _verify2 (a, b) {
  18387. assert((a.negative | b.negative) === 0, 'red works only with positives');
  18388. assert(a.red && a.red === b.red,
  18389. 'red works only with red numbers');
  18390. };
  18391. Red.prototype.imod = function imod (a) {
  18392. if (this.prime) return this.prime.ireduce(a)._forceRed(this);
  18393. return a.umod(this.m)._forceRed(this);
  18394. };
  18395. Red.prototype.neg = function neg (a) {
  18396. if (a.isZero()) {
  18397. return a.clone();
  18398. }
  18399. return this.m.sub(a)._forceRed(this);
  18400. };
  18401. Red.prototype.add = function add (a, b) {
  18402. this._verify2(a, b);
  18403. var res = a.add(b);
  18404. if (res.cmp(this.m) >= 0) {
  18405. res.isub(this.m);
  18406. }
  18407. return res._forceRed(this);
  18408. };
  18409. Red.prototype.iadd = function iadd (a, b) {
  18410. this._verify2(a, b);
  18411. var res = a.iadd(b);
  18412. if (res.cmp(this.m) >= 0) {
  18413. res.isub(this.m);
  18414. }
  18415. return res;
  18416. };
  18417. Red.prototype.sub = function sub (a, b) {
  18418. this._verify2(a, b);
  18419. var res = a.sub(b);
  18420. if (res.cmpn(0) < 0) {
  18421. res.iadd(this.m);
  18422. }
  18423. return res._forceRed(this);
  18424. };
  18425. Red.prototype.isub = function isub (a, b) {
  18426. this._verify2(a, b);
  18427. var res = a.isub(b);
  18428. if (res.cmpn(0) < 0) {
  18429. res.iadd(this.m);
  18430. }
  18431. return res;
  18432. };
  18433. Red.prototype.shl = function shl (a, num) {
  18434. this._verify1(a);
  18435. return this.imod(a.ushln(num));
  18436. };
  18437. Red.prototype.imul = function imul (a, b) {
  18438. this._verify2(a, b);
  18439. return this.imod(a.imul(b));
  18440. };
  18441. Red.prototype.mul = function mul (a, b) {
  18442. this._verify2(a, b);
  18443. return this.imod(a.mul(b));
  18444. };
  18445. Red.prototype.isqr = function isqr (a) {
  18446. return this.imul(a, a.clone());
  18447. };
  18448. Red.prototype.sqr = function sqr (a) {
  18449. return this.mul(a, a);
  18450. };
  18451. Red.prototype.sqrt = function sqrt (a) {
  18452. if (a.isZero()) return a.clone();
  18453. var mod3 = this.m.andln(3);
  18454. assert(mod3 % 2 === 1);
  18455. // Fast case
  18456. if (mod3 === 3) {
  18457. var pow = this.m.add(new BN(1)).iushrn(2);
  18458. return this.pow(a, pow);
  18459. }
  18460. // Tonelli-Shanks algorithm (Totally unoptimized and slow)
  18461. //
  18462. // Find Q and S, that Q * 2 ^ S = (P - 1)
  18463. var q = this.m.subn(1);
  18464. var s = 0;
  18465. while (!q.isZero() && q.andln(1) === 0) {
  18466. s++;
  18467. q.iushrn(1);
  18468. }
  18469. assert(!q.isZero());
  18470. var one = new BN(1).toRed(this);
  18471. var nOne = one.redNeg();
  18472. // Find quadratic non-residue
  18473. // NOTE: Max is such because of generalized Riemann hypothesis.
  18474. var lpow = this.m.subn(1).iushrn(1);
  18475. var z = this.m.bitLength();
  18476. z = new BN(2 * z * z).toRed(this);
  18477. while (this.pow(z, lpow).cmp(nOne) !== 0) {
  18478. z.redIAdd(nOne);
  18479. }
  18480. var c = this.pow(z, q);
  18481. var r = this.pow(a, q.addn(1).iushrn(1));
  18482. var t = this.pow(a, q);
  18483. var m = s;
  18484. while (t.cmp(one) !== 0) {
  18485. var tmp = t;
  18486. for (var i = 0; tmp.cmp(one) !== 0; i++) {
  18487. tmp = tmp.redSqr();
  18488. }
  18489. assert(i < m);
  18490. var b = this.pow(c, new BN(1).iushln(m - i - 1));
  18491. r = r.redMul(b);
  18492. c = b.redSqr();
  18493. t = t.redMul(c);
  18494. m = i;
  18495. }
  18496. return r;
  18497. };
  18498. Red.prototype.invm = function invm (a) {
  18499. var inv = a._invmp(this.m);
  18500. if (inv.negative !== 0) {
  18501. inv.negative = 0;
  18502. return this.imod(inv).redNeg();
  18503. } else {
  18504. return this.imod(inv);
  18505. }
  18506. };
  18507. Red.prototype.pow = function pow (a, num) {
  18508. if (num.isZero()) return new BN(1);
  18509. if (num.cmpn(1) === 0) return a.clone();
  18510. var windowSize = 4;
  18511. var wnd = new Array(1 << windowSize);
  18512. wnd[0] = new BN(1).toRed(this);
  18513. wnd[1] = a;
  18514. for (var i = 2; i < wnd.length; i++) {
  18515. wnd[i] = this.mul(wnd[i - 1], a);
  18516. }
  18517. var res = wnd[0];
  18518. var current = 0;
  18519. var currentLen = 0;
  18520. var start = num.bitLength() % 26;
  18521. if (start === 0) {
  18522. start = 26;
  18523. }
  18524. for (i = num.length - 1; i >= 0; i--) {
  18525. var word = num.words[i];
  18526. for (var j = start - 1; j >= 0; j--) {
  18527. var bit = (word >> j) & 1;
  18528. if (res !== wnd[0]) {
  18529. res = this.sqr(res);
  18530. }
  18531. if (bit === 0 && current === 0) {
  18532. currentLen = 0;
  18533. continue;
  18534. }
  18535. current <<= 1;
  18536. current |= bit;
  18537. currentLen++;
  18538. if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;
  18539. res = this.mul(res, wnd[current]);
  18540. currentLen = 0;
  18541. current = 0;
  18542. }
  18543. start = 26;
  18544. }
  18545. return res;
  18546. };
  18547. Red.prototype.convertTo = function convertTo (num) {
  18548. var r = num.umod(this.m);
  18549. return r === num ? r.clone() : r;
  18550. };
  18551. Red.prototype.convertFrom = function convertFrom (num) {
  18552. var res = num.clone();
  18553. res.red = null;
  18554. return res;
  18555. };
  18556. //
  18557. // Montgomery method engine
  18558. //
  18559. BN.mont = function mont (num) {
  18560. return new Mont(num);
  18561. };
  18562. function Mont (m) {
  18563. Red.call(this, m);
  18564. this.shift = this.m.bitLength();
  18565. if (this.shift % 26 !== 0) {
  18566. this.shift += 26 - (this.shift % 26);
  18567. }
  18568. this.r = new BN(1).iushln(this.shift);
  18569. this.r2 = this.imod(this.r.sqr());
  18570. this.rinv = this.r._invmp(this.m);
  18571. this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
  18572. this.minv = this.minv.umod(this.r);
  18573. this.minv = this.r.sub(this.minv);
  18574. }
  18575. inherits(Mont, Red);
  18576. Mont.prototype.convertTo = function convertTo (num) {
  18577. return this.imod(num.ushln(this.shift));
  18578. };
  18579. Mont.prototype.convertFrom = function convertFrom (num) {
  18580. var r = this.imod(num.mul(this.rinv));
  18581. r.red = null;
  18582. return r;
  18583. };
  18584. Mont.prototype.imul = function imul (a, b) {
  18585. if (a.isZero() || b.isZero()) {
  18586. a.words[0] = 0;
  18587. a.length = 1;
  18588. return a;
  18589. }
  18590. var t = a.imul(b);
  18591. var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
  18592. var u = t.isub(c).iushrn(this.shift);
  18593. var res = u;
  18594. if (u.cmp(this.m) >= 0) {
  18595. res = u.isub(this.m);
  18596. } else if (u.cmpn(0) < 0) {
  18597. res = u.iadd(this.m);
  18598. }
  18599. return res._forceRed(this);
  18600. };
  18601. Mont.prototype.mul = function mul (a, b) {
  18602. if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);
  18603. var t = a.mul(b);
  18604. var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
  18605. var u = t.isub(c).iushrn(this.shift);
  18606. var res = u;
  18607. if (u.cmp(this.m) >= 0) {
  18608. res = u.isub(this.m);
  18609. } else if (u.cmpn(0) < 0) {
  18610. res = u.iadd(this.m);
  18611. }
  18612. return res._forceRed(this);
  18613. };
  18614. Mont.prototype.invm = function invm (a) {
  18615. // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R
  18616. var res = this.imod(a._invmp(this.m).mul(this.r2));
  18617. return res._forceRed(this);
  18618. };
  18619. })(typeof module === 'undefined' || module, this);
  18620. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(76)(module)))
  18621. /***/ },
  18622. /* 13 */
  18623. /***/ function(module, exports) {
  18624. var g;
  18625. // This works in non-strict mode
  18626. g = (function() { return this; })();
  18627. try {
  18628. // This works if eval is allowed (see CSP)
  18629. g = g || Function("return this")() || (1,eval)("this");
  18630. } catch(e) {
  18631. // This works if the window reference is available
  18632. if(typeof window === "object")
  18633. g = window;
  18634. }
  18635. // g can still be undefined, but nothing to do about it...
  18636. // We return undefined, instead of nothing here, so it's
  18637. // easier to handle this case. if(!global) { ...}
  18638. module.exports = g;
  18639. /***/ },
  18640. /* 14 */
  18641. /***/ function(module, exports, __webpack_require__) {
  18642. /* WEBPACK VAR INJECTION */(function(Buffer) {// Copyright Joyent, Inc. and other Node contributors.
  18643. //
  18644. // Permission is hereby granted, free of charge, to any person obtaining a
  18645. // copy of this software and associated documentation files (the
  18646. // "Software"), to deal in the Software without restriction, including
  18647. // without limitation the rights to use, copy, modify, merge, publish,
  18648. // distribute, sublicense, and/or sell copies of the Software, and to permit
  18649. // persons to whom the Software is furnished to do so, subject to the
  18650. // following conditions:
  18651. //
  18652. // The above copyright notice and this permission notice shall be included
  18653. // in all copies or substantial portions of the Software.
  18654. //
  18655. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  18656. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  18657. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  18658. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  18659. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  18660. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  18661. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  18662. // NOTE: These type checking functions intentionally don't use `instanceof`
  18663. // because it is fragile and can be easily faked with `Object.create()`.
  18664. function isArray(arg) {
  18665. if (Array.isArray) {
  18666. return Array.isArray(arg);
  18667. }
  18668. return objectToString(arg) === '[object Array]';
  18669. }
  18670. exports.isArray = isArray;
  18671. function isBoolean(arg) {
  18672. return typeof arg === 'boolean';
  18673. }
  18674. exports.isBoolean = isBoolean;
  18675. function isNull(arg) {
  18676. return arg === null;
  18677. }
  18678. exports.isNull = isNull;
  18679. function isNullOrUndefined(arg) {
  18680. return arg == null;
  18681. }
  18682. exports.isNullOrUndefined = isNullOrUndefined;
  18683. function isNumber(arg) {
  18684. return typeof arg === 'number';
  18685. }
  18686. exports.isNumber = isNumber;
  18687. function isString(arg) {
  18688. return typeof arg === 'string';
  18689. }
  18690. exports.isString = isString;
  18691. function isSymbol(arg) {
  18692. return typeof arg === 'symbol';
  18693. }
  18694. exports.isSymbol = isSymbol;
  18695. function isUndefined(arg) {
  18696. return arg === void 0;
  18697. }
  18698. exports.isUndefined = isUndefined;
  18699. function isRegExp(re) {
  18700. return objectToString(re) === '[object RegExp]';
  18701. }
  18702. exports.isRegExp = isRegExp;
  18703. function isObject(arg) {
  18704. return typeof arg === 'object' && arg !== null;
  18705. }
  18706. exports.isObject = isObject;
  18707. function isDate(d) {
  18708. return objectToString(d) === '[object Date]';
  18709. }
  18710. exports.isDate = isDate;
  18711. function isError(e) {
  18712. return (objectToString(e) === '[object Error]' || e instanceof Error);
  18713. }
  18714. exports.isError = isError;
  18715. function isFunction(arg) {
  18716. return typeof arg === 'function';
  18717. }
  18718. exports.isFunction = isFunction;
  18719. function isPrimitive(arg) {
  18720. return arg === null ||
  18721. typeof arg === 'boolean' ||
  18722. typeof arg === 'number' ||
  18723. typeof arg === 'string' ||
  18724. typeof arg === 'symbol' || // ES6 symbol
  18725. typeof arg === 'undefined';
  18726. }
  18727. exports.isPrimitive = isPrimitive;
  18728. exports.isBuffer = Buffer.isBuffer;
  18729. function objectToString(o) {
  18730. return Object.prototype.toString.call(o);
  18731. }
  18732. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  18733. /***/ },
  18734. /* 15 */
  18735. /***/ function(module, exports, __webpack_require__) {
  18736. // 7.1.15 ToLength
  18737. var toInteger = __webpack_require__(42)
  18738. , min = Math.min;
  18739. module.exports = function(it){
  18740. return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
  18741. };
  18742. /***/ },
  18743. /* 16 */
  18744. /***/ function(module, exports, __webpack_require__) {
  18745. // 7.1.13 ToObject(argument)
  18746. var defined = __webpack_require__(28);
  18747. module.exports = function(it){
  18748. return Object(defined(it));
  18749. };
  18750. /***/ },
  18751. /* 17 */
  18752. /***/ function(module, exports) {
  18753. var hasOwnProperty = {}.hasOwnProperty;
  18754. module.exports = function(it, key){
  18755. return hasOwnProperty.call(it, key);
  18756. };
  18757. /***/ },
  18758. /* 18 */
  18759. /***/ function(module, exports) {
  18760. "use strict";
  18761. 'use strict';
  18762. exports.command = function command(send, name) {
  18763. return function (opts, cb) {
  18764. if (typeof opts === 'function') {
  18765. cb = opts;
  18766. opts = {};
  18767. }
  18768. return send(name, null, opts, null, cb);
  18769. };
  18770. };
  18771. exports.argCommand = function argCommand(send, name) {
  18772. return function (arg, opts, cb) {
  18773. if (typeof opts === 'function') {
  18774. cb = opts;
  18775. opts = {};
  18776. }
  18777. return send(name, arg, opts, null, cb);
  18778. };
  18779. };
  18780. /***/ },
  18781. /* 19 */
  18782. /***/ function(module, exports, __webpack_require__) {
  18783. var dP = __webpack_require__(11)
  18784. , createDesc = __webpack_require__(41);
  18785. module.exports = __webpack_require__(10) ? function(object, key, value){
  18786. return dP.f(object, key, createDesc(1, value));
  18787. } : function(object, key, value){
  18788. object[key] = value;
  18789. return object;
  18790. };
  18791. /***/ },
  18792. /* 20 */
  18793. /***/ function(module, exports, __webpack_require__) {
  18794. "use strict";
  18795. 'use strict';
  18796. var elliptic = exports;
  18797. elliptic.version = __webpack_require__(232).version;
  18798. elliptic.utils = __webpack_require__(499);
  18799. elliptic.rand = __webpack_require__(156);
  18800. elliptic.hmacDRBG = __webpack_require__(497);
  18801. elliptic.curve = __webpack_require__(94);
  18802. elliptic.curves = __webpack_require__(490);
  18803. // Protocols
  18804. elliptic.ec = __webpack_require__(491);
  18805. elliptic.eddsa = __webpack_require__(494);
  18806. /***/ },
  18807. /* 21 */
  18808. /***/ function(module, exports) {
  18809. module.exports = function(it){
  18810. if(typeof it != 'function')throw TypeError(it + ' is not a function!');
  18811. return it;
  18812. };
  18813. /***/ },
  18814. /* 22 */
  18815. /***/ function(module, exports, __webpack_require__) {
  18816. var global = __webpack_require__(5)
  18817. , hide = __webpack_require__(19)
  18818. , has = __webpack_require__(17)
  18819. , SRC = __webpack_require__(53)('src')
  18820. , TO_STRING = 'toString'
  18821. , $toString = Function[TO_STRING]
  18822. , TPL = ('' + $toString).split(TO_STRING);
  18823. __webpack_require__(32).inspectSource = function(it){
  18824. return $toString.call(it);
  18825. };
  18826. (module.exports = function(O, key, val, safe){
  18827. var isFunction = typeof val == 'function';
  18828. if(isFunction)has(val, 'name') || hide(val, 'name', key);
  18829. if(O[key] === val)return;
  18830. if(isFunction)has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));
  18831. if(O === global){
  18832. O[key] = val;
  18833. } else {
  18834. if(!safe){
  18835. delete O[key];
  18836. hide(O, key, val);
  18837. } else {
  18838. if(O[key])O[key] = val;
  18839. else hide(O, key, val);
  18840. }
  18841. }
  18842. // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
  18843. })(Function.prototype, TO_STRING, function toString(){
  18844. return typeof this == 'function' && this[SRC] || $toString.call(this);
  18845. });
  18846. /***/ },
  18847. /* 23 */
  18848. /***/ function(module, exports, __webpack_require__) {
  18849. var $export = __webpack_require__(0)
  18850. , fails = __webpack_require__(6)
  18851. , defined = __webpack_require__(28)
  18852. , quot = /"/g;
  18853. // B.2.3.2.1 CreateHTML(string, tag, attribute, value)
  18854. var createHTML = function(string, tag, attribute, value) {
  18855. var S = String(defined(string))
  18856. , p1 = '<' + tag;
  18857. if(attribute !== '')p1 += ' ' + attribute + '="' + String(value).replace(quot, '&quot;') + '"';
  18858. return p1 + '>' + S + '</' + tag + '>';
  18859. };
  18860. module.exports = function(NAME, exec){
  18861. var O = {};
  18862. O[NAME] = exec(createHTML);
  18863. $export($export.P + $export.F * fails(function(){
  18864. var test = ''[NAME]('"');
  18865. return test !== test.toLowerCase() || test.split('"').length > 3;
  18866. }), 'String', O);
  18867. };
  18868. /***/ },
  18869. /* 24 */
  18870. /***/ function(module, exports, __webpack_require__) {
  18871. // to indexed object, toObject with fallback for non-array-like ES3 strings
  18872. var IObject = __webpack_require__(70)
  18873. , defined = __webpack_require__(28);
  18874. module.exports = function(it){
  18875. return IObject(defined(it));
  18876. };
  18877. /***/ },
  18878. /* 25 */
  18879. /***/ function(module, exports, __webpack_require__) {
  18880. var pIE = __webpack_require__(71)
  18881. , createDesc = __webpack_require__(41)
  18882. , toIObject = __webpack_require__(24)
  18883. , toPrimitive = __webpack_require__(34)
  18884. , has = __webpack_require__(17)
  18885. , IE8_DOM_DEFINE = __webpack_require__(176)
  18886. , gOPD = Object.getOwnPropertyDescriptor;
  18887. exports.f = __webpack_require__(10) ? gOPD : function getOwnPropertyDescriptor(O, P){
  18888. O = toIObject(O);
  18889. P = toPrimitive(P, true);
  18890. if(IE8_DOM_DEFINE)try {
  18891. return gOPD(O, P);
  18892. } catch(e){ /* empty */ }
  18893. if(has(O, P))return createDesc(!pIE.f.call(O, P), O[P]);
  18894. };
  18895. /***/ },
  18896. /* 26 */
  18897. /***/ function(module, exports, __webpack_require__) {
  18898. // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
  18899. var has = __webpack_require__(17)
  18900. , toObject = __webpack_require__(16)
  18901. , IE_PROTO = __webpack_require__(119)('IE_PROTO')
  18902. , ObjectProto = Object.prototype;
  18903. module.exports = Object.getPrototypeOf || function(O){
  18904. O = toObject(O);
  18905. if(has(O, IE_PROTO))return O[IE_PROTO];
  18906. if(typeof O.constructor == 'function' && O instanceof O.constructor){
  18907. return O.constructor.prototype;
  18908. } return O instanceof Object ? ObjectProto : null;
  18909. };
  18910. /***/ },
  18911. /* 27 */
  18912. /***/ function(module, exports) {
  18913. var toString = {}.toString;
  18914. module.exports = function(it){
  18915. return toString.call(it).slice(8, -1);
  18916. };
  18917. /***/ },
  18918. /* 28 */
  18919. /***/ function(module, exports) {
  18920. // 7.2.1 RequireObjectCoercible(argument)
  18921. module.exports = function(it){
  18922. if(it == undefined)throw TypeError("Can't call method on " + it);
  18923. return it;
  18924. };
  18925. /***/ },
  18926. /* 29 */
  18927. /***/ function(module, exports, __webpack_require__) {
  18928. var fails = __webpack_require__(6);
  18929. module.exports = function(method, arg){
  18930. return !!method && fails(function(){
  18931. arg ? method.call(null, function(){}, 1) : method.call(null);
  18932. });
  18933. };
  18934. /***/ },
  18935. /* 30 */
  18936. /***/ function(module, exports) {
  18937. // Copyright Joyent, Inc. and other Node contributors.
  18938. //
  18939. // Permission is hereby granted, free of charge, to any person obtaining a
  18940. // copy of this software and associated documentation files (the
  18941. // "Software"), to deal in the Software without restriction, including
  18942. // without limitation the rights to use, copy, modify, merge, publish,
  18943. // distribute, sublicense, and/or sell copies of the Software, and to permit
  18944. // persons to whom the Software is furnished to do so, subject to the
  18945. // following conditions:
  18946. //
  18947. // The above copyright notice and this permission notice shall be included
  18948. // in all copies or substantial portions of the Software.
  18949. //
  18950. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  18951. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  18952. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  18953. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  18954. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  18955. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  18956. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  18957. function EventEmitter() {
  18958. this._events = this._events || {};
  18959. this._maxListeners = this._maxListeners || undefined;
  18960. }
  18961. module.exports = EventEmitter;
  18962. // Backwards-compat with node 0.10.x
  18963. EventEmitter.EventEmitter = EventEmitter;
  18964. EventEmitter.prototype._events = undefined;
  18965. EventEmitter.prototype._maxListeners = undefined;
  18966. // By default EventEmitters will print a warning if more than 10 listeners are
  18967. // added to it. This is a useful default which helps finding memory leaks.
  18968. EventEmitter.defaultMaxListeners = 10;
  18969. // Obviously not all Emitters should be limited to 10. This function allows
  18970. // that to be increased. Set to zero for unlimited.
  18971. EventEmitter.prototype.setMaxListeners = function(n) {
  18972. if (!isNumber(n) || n < 0 || isNaN(n))
  18973. throw TypeError('n must be a positive number');
  18974. this._maxListeners = n;
  18975. return this;
  18976. };
  18977. EventEmitter.prototype.emit = function(type) {
  18978. var er, handler, len, args, i, listeners;
  18979. if (!this._events)
  18980. this._events = {};
  18981. // If there is no 'error' event listener then throw.
  18982. if (type === 'error') {
  18983. if (!this._events.error ||
  18984. (isObject(this._events.error) && !this._events.error.length)) {
  18985. er = arguments[1];
  18986. if (er instanceof Error) {
  18987. throw er; // Unhandled 'error' event
  18988. } else {
  18989. // At least give some kind of context to the user
  18990. var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
  18991. err.context = er;
  18992. throw err;
  18993. }
  18994. }
  18995. }
  18996. handler = this._events[type];
  18997. if (isUndefined(handler))
  18998. return false;
  18999. if (isFunction(handler)) {
  19000. switch (arguments.length) {
  19001. // fast cases
  19002. case 1:
  19003. handler.call(this);
  19004. break;
  19005. case 2:
  19006. handler.call(this, arguments[1]);
  19007. break;
  19008. case 3:
  19009. handler.call(this, arguments[1], arguments[2]);
  19010. break;
  19011. // slower
  19012. default:
  19013. args = Array.prototype.slice.call(arguments, 1);
  19014. handler.apply(this, args);
  19015. }
  19016. } else if (isObject(handler)) {
  19017. args = Array.prototype.slice.call(arguments, 1);
  19018. listeners = handler.slice();
  19019. len = listeners.length;
  19020. for (i = 0; i < len; i++)
  19021. listeners[i].apply(this, args);
  19022. }
  19023. return true;
  19024. };
  19025. EventEmitter.prototype.addListener = function(type, listener) {
  19026. var m;
  19027. if (!isFunction(listener))
  19028. throw TypeError('listener must be a function');
  19029. if (!this._events)
  19030. this._events = {};
  19031. // To avoid recursion in the case that type === "newListener"! Before
  19032. // adding it to the listeners, first emit "newListener".
  19033. if (this._events.newListener)
  19034. this.emit('newListener', type,
  19035. isFunction(listener.listener) ?
  19036. listener.listener : listener);
  19037. if (!this._events[type])
  19038. // Optimize the case of one listener. Don't need the extra array object.
  19039. this._events[type] = listener;
  19040. else if (isObject(this._events[type]))
  19041. // If we've already got an array, just append.
  19042. this._events[type].push(listener);
  19043. else
  19044. // Adding the second element, need to change to array.
  19045. this._events[type] = [this._events[type], listener];
  19046. // Check for listener leak
  19047. if (isObject(this._events[type]) && !this._events[type].warned) {
  19048. if (!isUndefined(this._maxListeners)) {
  19049. m = this._maxListeners;
  19050. } else {
  19051. m = EventEmitter.defaultMaxListeners;
  19052. }
  19053. if (m && m > 0 && this._events[type].length > m) {
  19054. this._events[type].warned = true;
  19055. console.error('(node) warning: possible EventEmitter memory ' +
  19056. 'leak detected. %d listeners added. ' +
  19057. 'Use emitter.setMaxListeners() to increase limit.',
  19058. this._events[type].length);
  19059. if (typeof console.trace === 'function') {
  19060. // not supported in IE 10
  19061. console.trace();
  19062. }
  19063. }
  19064. }
  19065. return this;
  19066. };
  19067. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  19068. EventEmitter.prototype.once = function(type, listener) {
  19069. if (!isFunction(listener))
  19070. throw TypeError('listener must be a function');
  19071. var fired = false;
  19072. function g() {
  19073. this.removeListener(type, g);
  19074. if (!fired) {
  19075. fired = true;
  19076. listener.apply(this, arguments);
  19077. }
  19078. }
  19079. g.listener = listener;
  19080. this.on(type, g);
  19081. return this;
  19082. };
  19083. // emits a 'removeListener' event iff the listener was removed
  19084. EventEmitter.prototype.removeListener = function(type, listener) {
  19085. var list, position, length, i;
  19086. if (!isFunction(listener))
  19087. throw TypeError('listener must be a function');
  19088. if (!this._events || !this._events[type])
  19089. return this;
  19090. list = this._events[type];
  19091. length = list.length;
  19092. position = -1;
  19093. if (list === listener ||
  19094. (isFunction(list.listener) && list.listener === listener)) {
  19095. delete this._events[type];
  19096. if (this._events.removeListener)
  19097. this.emit('removeListener', type, listener);
  19098. } else if (isObject(list)) {
  19099. for (i = length; i-- > 0;) {
  19100. if (list[i] === listener ||
  19101. (list[i].listener && list[i].listener === listener)) {
  19102. position = i;
  19103. break;
  19104. }
  19105. }
  19106. if (position < 0)
  19107. return this;
  19108. if (list.length === 1) {
  19109. list.length = 0;
  19110. delete this._events[type];
  19111. } else {
  19112. list.splice(position, 1);
  19113. }
  19114. if (this._events.removeListener)
  19115. this.emit('removeListener', type, listener);
  19116. }
  19117. return this;
  19118. };
  19119. EventEmitter.prototype.removeAllListeners = function(type) {
  19120. var key, listeners;
  19121. if (!this._events)
  19122. return this;
  19123. // not listening for removeListener, no need to emit
  19124. if (!this._events.removeListener) {
  19125. if (arguments.length === 0)
  19126. this._events = {};
  19127. else if (this._events[type])
  19128. delete this._events[type];
  19129. return this;
  19130. }
  19131. // emit removeListener for all listeners on all events
  19132. if (arguments.length === 0) {
  19133. for (key in this._events) {
  19134. if (key === 'removeListener') continue;
  19135. this.removeAllListeners(key);
  19136. }
  19137. this.removeAllListeners('removeListener');
  19138. this._events = {};
  19139. return this;
  19140. }
  19141. listeners = this._events[type];
  19142. if (isFunction(listeners)) {
  19143. this.removeListener(type, listeners);
  19144. } else if (listeners) {
  19145. // LIFO order
  19146. while (listeners.length)
  19147. this.removeListener(type, listeners[listeners.length - 1]);
  19148. }
  19149. delete this._events[type];
  19150. return this;
  19151. };
  19152. EventEmitter.prototype.listeners = function(type) {
  19153. var ret;
  19154. if (!this._events || !this._events[type])
  19155. ret = [];
  19156. else if (isFunction(this._events[type]))
  19157. ret = [this._events[type]];
  19158. else
  19159. ret = this._events[type].slice();
  19160. return ret;
  19161. };
  19162. EventEmitter.prototype.listenerCount = function(type) {
  19163. if (this._events) {
  19164. var evlistener = this._events[type];
  19165. if (isFunction(evlistener))
  19166. return 1;
  19167. else if (evlistener)
  19168. return evlistener.length;
  19169. }
  19170. return 0;
  19171. };
  19172. EventEmitter.listenerCount = function(emitter, type) {
  19173. return emitter.listenerCount(type);
  19174. };
  19175. function isFunction(arg) {
  19176. return typeof arg === 'function';
  19177. }
  19178. function isNumber(arg) {
  19179. return typeof arg === 'number';
  19180. }
  19181. function isObject(arg) {
  19182. return typeof arg === 'object' && arg !== null;
  19183. }
  19184. function isUndefined(arg) {
  19185. return arg === void 0;
  19186. }
  19187. /***/ },
  19188. /* 31 */
  19189. /***/ function(module, exports, __webpack_require__) {
  19190. // 0 -> Array#forEach
  19191. // 1 -> Array#map
  19192. // 2 -> Array#filter
  19193. // 3 -> Array#some
  19194. // 4 -> Array#every
  19195. // 5 -> Array#find
  19196. // 6 -> Array#findIndex
  19197. var ctx = __webpack_require__(35)
  19198. , IObject = __webpack_require__(70)
  19199. , toObject = __webpack_require__(16)
  19200. , toLength = __webpack_require__(15)
  19201. , asc = __webpack_require__(297);
  19202. module.exports = function(TYPE, $create){
  19203. var IS_MAP = TYPE == 1
  19204. , IS_FILTER = TYPE == 2
  19205. , IS_SOME = TYPE == 3
  19206. , IS_EVERY = TYPE == 4
  19207. , IS_FIND_INDEX = TYPE == 6
  19208. , NO_HOLES = TYPE == 5 || IS_FIND_INDEX
  19209. , create = $create || asc;
  19210. return function($this, callbackfn, that){
  19211. var O = toObject($this)
  19212. , self = IObject(O)
  19213. , f = ctx(callbackfn, that, 3)
  19214. , length = toLength(self.length)
  19215. , index = 0
  19216. , result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined
  19217. , val, res;
  19218. for(;length > index; index++)if(NO_HOLES || index in self){
  19219. val = self[index];
  19220. res = f(val, index, O);
  19221. if(TYPE){
  19222. if(IS_MAP)result[index] = res; // map
  19223. else if(res)switch(TYPE){
  19224. case 3: return true; // some
  19225. case 5: return val; // find
  19226. case 6: return index; // findIndex
  19227. case 2: result.push(val); // filter
  19228. } else if(IS_EVERY)return false; // every
  19229. }
  19230. }
  19231. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
  19232. };
  19233. };
  19234. /***/ },
  19235. /* 32 */
  19236. /***/ function(module, exports) {
  19237. var core = module.exports = {version: '2.4.0'};
  19238. if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef
  19239. /***/ },
  19240. /* 33 */
  19241. /***/ function(module, exports, __webpack_require__) {
  19242. // most Object methods by ES6 should accept primitives
  19243. var $export = __webpack_require__(0)
  19244. , core = __webpack_require__(32)
  19245. , fails = __webpack_require__(6);
  19246. module.exports = function(KEY, exec){
  19247. var fn = (core.Object || {})[KEY] || Object[KEY]
  19248. , exp = {};
  19249. exp[KEY] = exec(fn);
  19250. $export($export.S + $export.F * fails(function(){ fn(1); }), 'Object', exp);
  19251. };
  19252. /***/ },
  19253. /* 34 */
  19254. /***/ function(module, exports, __webpack_require__) {
  19255. // 7.1.1 ToPrimitive(input [, PreferredType])
  19256. var isObject = __webpack_require__(7);
  19257. // instead of the ES6 spec version, we didn't implement @@toPrimitive case
  19258. // and the second argument - flag - preferred type is a string
  19259. module.exports = function(it, S){
  19260. if(!isObject(it))return it;
  19261. var fn, val;
  19262. if(S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val;
  19263. if(typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it)))return val;
  19264. if(!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val;
  19265. throw TypeError("Can't convert object to primitive value");
  19266. };
  19267. /***/ },
  19268. /* 35 */
  19269. /***/ function(module, exports, __webpack_require__) {
  19270. // optional / simple context binding
  19271. var aFunction = __webpack_require__(21);
  19272. module.exports = function(fn, that, length){
  19273. aFunction(fn);
  19274. if(that === undefined)return fn;
  19275. switch(length){
  19276. case 1: return function(a){
  19277. return fn.call(that, a);
  19278. };
  19279. case 2: return function(a, b){
  19280. return fn.call(that, a, b);
  19281. };
  19282. case 3: return function(a, b, c){
  19283. return fn.call(that, a, b, c);
  19284. };
  19285. }
  19286. return function(/* ...args */){
  19287. return fn.apply(that, arguments);
  19288. };
  19289. };
  19290. /***/ },
  19291. /* 36 */
  19292. /***/ function(module, exports, __webpack_require__) {
  19293. var Map = __webpack_require__(191)
  19294. , $export = __webpack_require__(0)
  19295. , shared = __webpack_require__(92)('metadata')
  19296. , store = shared.store || (shared.store = new (__webpack_require__(194)));
  19297. var getOrCreateMetadataMap = function(target, targetKey, create){
  19298. var targetMetadata = store.get(target);
  19299. if(!targetMetadata){
  19300. if(!create)return undefined;
  19301. store.set(target, targetMetadata = new Map);
  19302. }
  19303. var keyMetadata = targetMetadata.get(targetKey);
  19304. if(!keyMetadata){
  19305. if(!create)return undefined;
  19306. targetMetadata.set(targetKey, keyMetadata = new Map);
  19307. } return keyMetadata;
  19308. };
  19309. var ordinaryHasOwnMetadata = function(MetadataKey, O, P){
  19310. var metadataMap = getOrCreateMetadataMap(O, P, false);
  19311. return metadataMap === undefined ? false : metadataMap.has(MetadataKey);
  19312. };
  19313. var ordinaryGetOwnMetadata = function(MetadataKey, O, P){
  19314. var metadataMap = getOrCreateMetadataMap(O, P, false);
  19315. return metadataMap === undefined ? undefined : metadataMap.get(MetadataKey);
  19316. };
  19317. var ordinaryDefineOwnMetadata = function(MetadataKey, MetadataValue, O, P){
  19318. getOrCreateMetadataMap(O, P, true).set(MetadataKey, MetadataValue);
  19319. };
  19320. var ordinaryOwnMetadataKeys = function(target, targetKey){
  19321. var metadataMap = getOrCreateMetadataMap(target, targetKey, false)
  19322. , keys = [];
  19323. if(metadataMap)metadataMap.forEach(function(_, key){ keys.push(key); });
  19324. return keys;
  19325. };
  19326. var toMetaKey = function(it){
  19327. return it === undefined || typeof it == 'symbol' ? it : String(it);
  19328. };
  19329. var exp = function(O){
  19330. $export($export.S, 'Reflect', O);
  19331. };
  19332. module.exports = {
  19333. store: store,
  19334. map: getOrCreateMetadataMap,
  19335. has: ordinaryHasOwnMetadata,
  19336. get: ordinaryGetOwnMetadata,
  19337. set: ordinaryDefineOwnMetadata,
  19338. keys: ordinaryOwnMetadataKeys,
  19339. key: toMetaKey,
  19340. exp: exp
  19341. };
  19342. /***/ },
  19343. /* 37 */
  19344. /***/ function(module, exports, __webpack_require__) {
  19345. "use strict";
  19346. 'use strict';
  19347. if(__webpack_require__(10)){
  19348. var LIBRARY = __webpack_require__(46)
  19349. , global = __webpack_require__(5)
  19350. , fails = __webpack_require__(6)
  19351. , $export = __webpack_require__(0)
  19352. , $typed = __webpack_require__(93)
  19353. , $buffer = __webpack_require__(126)
  19354. , ctx = __webpack_require__(35)
  19355. , anInstance = __webpack_require__(39)
  19356. , propertyDesc = __webpack_require__(41)
  19357. , hide = __webpack_require__(19)
  19358. , redefineAll = __webpack_require__(50)
  19359. , isInteger = __webpack_require__(113)
  19360. , toInteger = __webpack_require__(42)
  19361. , toLength = __webpack_require__(15)
  19362. , toIndex = __webpack_require__(52)
  19363. , toPrimitive = __webpack_require__(34)
  19364. , has = __webpack_require__(17)
  19365. , same = __webpack_require__(188)
  19366. , classof = __webpack_require__(59)
  19367. , isObject = __webpack_require__(7)
  19368. , toObject = __webpack_require__(16)
  19369. , isArrayIter = __webpack_require__(111)
  19370. , create = __webpack_require__(47)
  19371. , getPrototypeOf = __webpack_require__(26)
  19372. , gOPN = __webpack_require__(48).f
  19373. , isIterable = __webpack_require__(304)
  19374. , getIterFn = __webpack_require__(128)
  19375. , uid = __webpack_require__(53)
  19376. , wks = __webpack_require__(8)
  19377. , createArrayMethod = __webpack_require__(31)
  19378. , createArrayIncludes = __webpack_require__(82)
  19379. , speciesConstructor = __webpack_require__(120)
  19380. , ArrayIterators = __webpack_require__(129)
  19381. , Iterators = __webpack_require__(45)
  19382. , $iterDetect = __webpack_require__(88)
  19383. , setSpecies = __webpack_require__(51)
  19384. , arrayFill = __webpack_require__(104)
  19385. , arrayCopyWithin = __webpack_require__(169)
  19386. , $DP = __webpack_require__(11)
  19387. , $GOPD = __webpack_require__(25)
  19388. , dP = $DP.f
  19389. , gOPD = $GOPD.f
  19390. , RangeError = global.RangeError
  19391. , TypeError = global.TypeError
  19392. , Uint8Array = global.Uint8Array
  19393. , ARRAY_BUFFER = 'ArrayBuffer'
  19394. , SHARED_BUFFER = 'Shared' + ARRAY_BUFFER
  19395. , BYTES_PER_ELEMENT = 'BYTES_PER_ELEMENT'
  19396. , PROTOTYPE = 'prototype'
  19397. , ArrayProto = Array[PROTOTYPE]
  19398. , $ArrayBuffer = $buffer.ArrayBuffer
  19399. , $DataView = $buffer.DataView
  19400. , arrayForEach = createArrayMethod(0)
  19401. , arrayFilter = createArrayMethod(2)
  19402. , arraySome = createArrayMethod(3)
  19403. , arrayEvery = createArrayMethod(4)
  19404. , arrayFind = createArrayMethod(5)
  19405. , arrayFindIndex = createArrayMethod(6)
  19406. , arrayIncludes = createArrayIncludes(true)
  19407. , arrayIndexOf = createArrayIncludes(false)
  19408. , arrayValues = ArrayIterators.values
  19409. , arrayKeys = ArrayIterators.keys
  19410. , arrayEntries = ArrayIterators.entries
  19411. , arrayLastIndexOf = ArrayProto.lastIndexOf
  19412. , arrayReduce = ArrayProto.reduce
  19413. , arrayReduceRight = ArrayProto.reduceRight
  19414. , arrayJoin = ArrayProto.join
  19415. , arraySort = ArrayProto.sort
  19416. , arraySlice = ArrayProto.slice
  19417. , arrayToString = ArrayProto.toString
  19418. , arrayToLocaleString = ArrayProto.toLocaleString
  19419. , ITERATOR = wks('iterator')
  19420. , TAG = wks('toStringTag')
  19421. , TYPED_CONSTRUCTOR = uid('typed_constructor')
  19422. , DEF_CONSTRUCTOR = uid('def_constructor')
  19423. , ALL_CONSTRUCTORS = $typed.CONSTR
  19424. , TYPED_ARRAY = $typed.TYPED
  19425. , VIEW = $typed.VIEW
  19426. , WRONG_LENGTH = 'Wrong length!';
  19427. var $map = createArrayMethod(1, function(O, length){
  19428. return allocate(speciesConstructor(O, O[DEF_CONSTRUCTOR]), length);
  19429. });
  19430. var LITTLE_ENDIAN = fails(function(){
  19431. return new Uint8Array(new Uint16Array([1]).buffer)[0] === 1;
  19432. });
  19433. var FORCED_SET = !!Uint8Array && !!Uint8Array[PROTOTYPE].set && fails(function(){
  19434. new Uint8Array(1).set({});
  19435. });
  19436. var strictToLength = function(it, SAME){
  19437. if(it === undefined)throw TypeError(WRONG_LENGTH);
  19438. var number = +it
  19439. , length = toLength(it);
  19440. if(SAME && !same(number, length))throw RangeError(WRONG_LENGTH);
  19441. return length;
  19442. };
  19443. var toOffset = function(it, BYTES){
  19444. var offset = toInteger(it);
  19445. if(offset < 0 || offset % BYTES)throw RangeError('Wrong offset!');
  19446. return offset;
  19447. };
  19448. var validate = function(it){
  19449. if(isObject(it) && TYPED_ARRAY in it)return it;
  19450. throw TypeError(it + ' is not a typed array!');
  19451. };
  19452. var allocate = function(C, length){
  19453. if(!(isObject(C) && TYPED_CONSTRUCTOR in C)){
  19454. throw TypeError('It is not a typed array constructor!');
  19455. } return new C(length);
  19456. };
  19457. var speciesFromList = function(O, list){
  19458. return fromList(speciesConstructor(O, O[DEF_CONSTRUCTOR]), list);
  19459. };
  19460. var fromList = function(C, list){
  19461. var index = 0
  19462. , length = list.length
  19463. , result = allocate(C, length);
  19464. while(length > index)result[index] = list[index++];
  19465. return result;
  19466. };
  19467. var addGetter = function(it, key, internal){
  19468. dP(it, key, {get: function(){ return this._d[internal]; }});
  19469. };
  19470. var $from = function from(source /*, mapfn, thisArg */){
  19471. var O = toObject(source)
  19472. , aLen = arguments.length
  19473. , mapfn = aLen > 1 ? arguments[1] : undefined
  19474. , mapping = mapfn !== undefined
  19475. , iterFn = getIterFn(O)
  19476. , i, length, values, result, step, iterator;
  19477. if(iterFn != undefined && !isArrayIter(iterFn)){
  19478. for(iterator = iterFn.call(O), values = [], i = 0; !(step = iterator.next()).done; i++){
  19479. values.push(step.value);
  19480. } O = values;
  19481. }
  19482. if(mapping && aLen > 2)mapfn = ctx(mapfn, arguments[2], 2);
  19483. for(i = 0, length = toLength(O.length), result = allocate(this, length); length > i; i++){
  19484. result[i] = mapping ? mapfn(O[i], i) : O[i];
  19485. }
  19486. return result;
  19487. };
  19488. var $of = function of(/*...items*/){
  19489. var index = 0
  19490. , length = arguments.length
  19491. , result = allocate(this, length);
  19492. while(length > index)result[index] = arguments[index++];
  19493. return result;
  19494. };
  19495. // iOS Safari 6.x fails here
  19496. var TO_LOCALE_BUG = !!Uint8Array && fails(function(){ arrayToLocaleString.call(new Uint8Array(1)); });
  19497. var $toLocaleString = function toLocaleString(){
  19498. return arrayToLocaleString.apply(TO_LOCALE_BUG ? arraySlice.call(validate(this)) : validate(this), arguments);
  19499. };
  19500. var proto = {
  19501. copyWithin: function copyWithin(target, start /*, end */){
  19502. return arrayCopyWithin.call(validate(this), target, start, arguments.length > 2 ? arguments[2] : undefined);
  19503. },
  19504. every: function every(callbackfn /*, thisArg */){
  19505. return arrayEvery(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  19506. },
  19507. fill: function fill(value /*, start, end */){ // eslint-disable-line no-unused-vars
  19508. return arrayFill.apply(validate(this), arguments);
  19509. },
  19510. filter: function filter(callbackfn /*, thisArg */){
  19511. return speciesFromList(this, arrayFilter(validate(this), callbackfn,
  19512. arguments.length > 1 ? arguments[1] : undefined));
  19513. },
  19514. find: function find(predicate /*, thisArg */){
  19515. return arrayFind(validate(this), predicate, arguments.length > 1 ? arguments[1] : undefined);
  19516. },
  19517. findIndex: function findIndex(predicate /*, thisArg */){
  19518. return arrayFindIndex(validate(this), predicate, arguments.length > 1 ? arguments[1] : undefined);
  19519. },
  19520. forEach: function forEach(callbackfn /*, thisArg */){
  19521. arrayForEach(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  19522. },
  19523. indexOf: function indexOf(searchElement /*, fromIndex */){
  19524. return arrayIndexOf(validate(this), searchElement, arguments.length > 1 ? arguments[1] : undefined);
  19525. },
  19526. includes: function includes(searchElement /*, fromIndex */){
  19527. return arrayIncludes(validate(this), searchElement, arguments.length > 1 ? arguments[1] : undefined);
  19528. },
  19529. join: function join(separator){ // eslint-disable-line no-unused-vars
  19530. return arrayJoin.apply(validate(this), arguments);
  19531. },
  19532. lastIndexOf: function lastIndexOf(searchElement /*, fromIndex */){ // eslint-disable-line no-unused-vars
  19533. return arrayLastIndexOf.apply(validate(this), arguments);
  19534. },
  19535. map: function map(mapfn /*, thisArg */){
  19536. return $map(validate(this), mapfn, arguments.length > 1 ? arguments[1] : undefined);
  19537. },
  19538. reduce: function reduce(callbackfn /*, initialValue */){ // eslint-disable-line no-unused-vars
  19539. return arrayReduce.apply(validate(this), arguments);
  19540. },
  19541. reduceRight: function reduceRight(callbackfn /*, initialValue */){ // eslint-disable-line no-unused-vars
  19542. return arrayReduceRight.apply(validate(this), arguments);
  19543. },
  19544. reverse: function reverse(){
  19545. var that = this
  19546. , length = validate(that).length
  19547. , middle = Math.floor(length / 2)
  19548. , index = 0
  19549. , value;
  19550. while(index < middle){
  19551. value = that[index];
  19552. that[index++] = that[--length];
  19553. that[length] = value;
  19554. } return that;
  19555. },
  19556. some: function some(callbackfn /*, thisArg */){
  19557. return arraySome(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  19558. },
  19559. sort: function sort(comparefn){
  19560. return arraySort.call(validate(this), comparefn);
  19561. },
  19562. subarray: function subarray(begin, end){
  19563. var O = validate(this)
  19564. , length = O.length
  19565. , $begin = toIndex(begin, length);
  19566. return new (speciesConstructor(O, O[DEF_CONSTRUCTOR]))(
  19567. O.buffer,
  19568. O.byteOffset + $begin * O.BYTES_PER_ELEMENT,
  19569. toLength((end === undefined ? length : toIndex(end, length)) - $begin)
  19570. );
  19571. }
  19572. };
  19573. var $slice = function slice(start, end){
  19574. return speciesFromList(this, arraySlice.call(validate(this), start, end));
  19575. };
  19576. var $set = function set(arrayLike /*, offset */){
  19577. validate(this);
  19578. var offset = toOffset(arguments[1], 1)
  19579. , length = this.length
  19580. , src = toObject(arrayLike)
  19581. , len = toLength(src.length)
  19582. , index = 0;
  19583. if(len + offset > length)throw RangeError(WRONG_LENGTH);
  19584. while(index < len)this[offset + index] = src[index++];
  19585. };
  19586. var $iterators = {
  19587. entries: function entries(){
  19588. return arrayEntries.call(validate(this));
  19589. },
  19590. keys: function keys(){
  19591. return arrayKeys.call(validate(this));
  19592. },
  19593. values: function values(){
  19594. return arrayValues.call(validate(this));
  19595. }
  19596. };
  19597. var isTAIndex = function(target, key){
  19598. return isObject(target)
  19599. && target[TYPED_ARRAY]
  19600. && typeof key != 'symbol'
  19601. && key in target
  19602. && String(+key) == String(key);
  19603. };
  19604. var $getDesc = function getOwnPropertyDescriptor(target, key){
  19605. return isTAIndex(target, key = toPrimitive(key, true))
  19606. ? propertyDesc(2, target[key])
  19607. : gOPD(target, key);
  19608. };
  19609. var $setDesc = function defineProperty(target, key, desc){
  19610. if(isTAIndex(target, key = toPrimitive(key, true))
  19611. && isObject(desc)
  19612. && has(desc, 'value')
  19613. && !has(desc, 'get')
  19614. && !has(desc, 'set')
  19615. // TODO: add validation descriptor w/o calling accessors
  19616. && !desc.configurable
  19617. && (!has(desc, 'writable') || desc.writable)
  19618. && (!has(desc, 'enumerable') || desc.enumerable)
  19619. ){
  19620. target[key] = desc.value;
  19621. return target;
  19622. } else return dP(target, key, desc);
  19623. };
  19624. if(!ALL_CONSTRUCTORS){
  19625. $GOPD.f = $getDesc;
  19626. $DP.f = $setDesc;
  19627. }
  19628. $export($export.S + $export.F * !ALL_CONSTRUCTORS, 'Object', {
  19629. getOwnPropertyDescriptor: $getDesc,
  19630. defineProperty: $setDesc
  19631. });
  19632. if(fails(function(){ arrayToString.call({}); })){
  19633. arrayToString = arrayToLocaleString = function toString(){
  19634. return arrayJoin.call(this);
  19635. }
  19636. }
  19637. var $TypedArrayPrototype$ = redefineAll({}, proto);
  19638. redefineAll($TypedArrayPrototype$, $iterators);
  19639. hide($TypedArrayPrototype$, ITERATOR, $iterators.values);
  19640. redefineAll($TypedArrayPrototype$, {
  19641. slice: $slice,
  19642. set: $set,
  19643. constructor: function(){ /* noop */ },
  19644. toString: arrayToString,
  19645. toLocaleString: $toLocaleString
  19646. });
  19647. addGetter($TypedArrayPrototype$, 'buffer', 'b');
  19648. addGetter($TypedArrayPrototype$, 'byteOffset', 'o');
  19649. addGetter($TypedArrayPrototype$, 'byteLength', 'l');
  19650. addGetter($TypedArrayPrototype$, 'length', 'e');
  19651. dP($TypedArrayPrototype$, TAG, {
  19652. get: function(){ return this[TYPED_ARRAY]; }
  19653. });
  19654. module.exports = function(KEY, BYTES, wrapper, CLAMPED){
  19655. CLAMPED = !!CLAMPED;
  19656. var NAME = KEY + (CLAMPED ? 'Clamped' : '') + 'Array'
  19657. , ISNT_UINT8 = NAME != 'Uint8Array'
  19658. , GETTER = 'get' + KEY
  19659. , SETTER = 'set' + KEY
  19660. , TypedArray = global[NAME]
  19661. , Base = TypedArray || {}
  19662. , TAC = TypedArray && getPrototypeOf(TypedArray)
  19663. , FORCED = !TypedArray || !$typed.ABV
  19664. , O = {}
  19665. , TypedArrayPrototype = TypedArray && TypedArray[PROTOTYPE];
  19666. var getter = function(that, index){
  19667. var data = that._d;
  19668. return data.v[GETTER](index * BYTES + data.o, LITTLE_ENDIAN);
  19669. };
  19670. var setter = function(that, index, value){
  19671. var data = that._d;
  19672. if(CLAMPED)value = (value = Math.round(value)) < 0 ? 0 : value > 0xff ? 0xff : value & 0xff;
  19673. data.v[SETTER](index * BYTES + data.o, value, LITTLE_ENDIAN);
  19674. };
  19675. var addElement = function(that, index){
  19676. dP(that, index, {
  19677. get: function(){
  19678. return getter(this, index);
  19679. },
  19680. set: function(value){
  19681. return setter(this, index, value);
  19682. },
  19683. enumerable: true
  19684. });
  19685. };
  19686. if(FORCED){
  19687. TypedArray = wrapper(function(that, data, $offset, $length){
  19688. anInstance(that, TypedArray, NAME, '_d');
  19689. var index = 0
  19690. , offset = 0
  19691. , buffer, byteLength, length, klass;
  19692. if(!isObject(data)){
  19693. length = strictToLength(data, true)
  19694. byteLength = length * BYTES;
  19695. buffer = new $ArrayBuffer(byteLength);
  19696. } else if(data instanceof $ArrayBuffer || (klass = classof(data)) == ARRAY_BUFFER || klass == SHARED_BUFFER){
  19697. buffer = data;
  19698. offset = toOffset($offset, BYTES);
  19699. var $len = data.byteLength;
  19700. if($length === undefined){
  19701. if($len % BYTES)throw RangeError(WRONG_LENGTH);
  19702. byteLength = $len - offset;
  19703. if(byteLength < 0)throw RangeError(WRONG_LENGTH);
  19704. } else {
  19705. byteLength = toLength($length) * BYTES;
  19706. if(byteLength + offset > $len)throw RangeError(WRONG_LENGTH);
  19707. }
  19708. length = byteLength / BYTES;
  19709. } else if(TYPED_ARRAY in data){
  19710. return fromList(TypedArray, data);
  19711. } else {
  19712. return $from.call(TypedArray, data);
  19713. }
  19714. hide(that, '_d', {
  19715. b: buffer,
  19716. o: offset,
  19717. l: byteLength,
  19718. e: length,
  19719. v: new $DataView(buffer)
  19720. });
  19721. while(index < length)addElement(that, index++);
  19722. });
  19723. TypedArrayPrototype = TypedArray[PROTOTYPE] = create($TypedArrayPrototype$);
  19724. hide(TypedArrayPrototype, 'constructor', TypedArray);
  19725. } else if(!$iterDetect(function(iter){
  19726. // V8 works with iterators, but fails in many other cases
  19727. // https://code.google.com/p/v8/issues/detail?id=4552
  19728. new TypedArray(null); // eslint-disable-line no-new
  19729. new TypedArray(iter); // eslint-disable-line no-new
  19730. }, true)){
  19731. TypedArray = wrapper(function(that, data, $offset, $length){
  19732. anInstance(that, TypedArray, NAME);
  19733. var klass;
  19734. // `ws` module bug, temporarily remove validation length for Uint8Array
  19735. // https://github.com/websockets/ws/pull/645
  19736. if(!isObject(data))return new Base(strictToLength(data, ISNT_UINT8));
  19737. if(data instanceof $ArrayBuffer || (klass = classof(data)) == ARRAY_BUFFER || klass == SHARED_BUFFER){
  19738. return $length !== undefined
  19739. ? new Base(data, toOffset($offset, BYTES), $length)
  19740. : $offset !== undefined
  19741. ? new Base(data, toOffset($offset, BYTES))
  19742. : new Base(data);
  19743. }
  19744. if(TYPED_ARRAY in data)return fromList(TypedArray, data);
  19745. return $from.call(TypedArray, data);
  19746. });
  19747. arrayForEach(TAC !== Function.prototype ? gOPN(Base).concat(gOPN(TAC)) : gOPN(Base), function(key){
  19748. if(!(key in TypedArray))hide(TypedArray, key, Base[key]);
  19749. });
  19750. TypedArray[PROTOTYPE] = TypedArrayPrototype;
  19751. if(!LIBRARY)TypedArrayPrototype.constructor = TypedArray;
  19752. }
  19753. var $nativeIterator = TypedArrayPrototype[ITERATOR]
  19754. , CORRECT_ITER_NAME = !!$nativeIterator && ($nativeIterator.name == 'values' || $nativeIterator.name == undefined)
  19755. , $iterator = $iterators.values;
  19756. hide(TypedArray, TYPED_CONSTRUCTOR, true);
  19757. hide(TypedArrayPrototype, TYPED_ARRAY, NAME);
  19758. hide(TypedArrayPrototype, VIEW, true);
  19759. hide(TypedArrayPrototype, DEF_CONSTRUCTOR, TypedArray);
  19760. if(CLAMPED ? new TypedArray(1)[TAG] != NAME : !(TAG in TypedArrayPrototype)){
  19761. dP(TypedArrayPrototype, TAG, {
  19762. get: function(){ return NAME; }
  19763. });
  19764. }
  19765. O[NAME] = TypedArray;
  19766. $export($export.G + $export.W + $export.F * (TypedArray != Base), O);
  19767. $export($export.S, NAME, {
  19768. BYTES_PER_ELEMENT: BYTES,
  19769. from: $from,
  19770. of: $of
  19771. });
  19772. if(!(BYTES_PER_ELEMENT in TypedArrayPrototype))hide(TypedArrayPrototype, BYTES_PER_ELEMENT, BYTES);
  19773. $export($export.P, NAME, proto);
  19774. setSpecies(NAME);
  19775. $export($export.P + $export.F * FORCED_SET, NAME, {set: $set});
  19776. $export($export.P + $export.F * !CORRECT_ITER_NAME, NAME, $iterators);
  19777. $export($export.P + $export.F * (TypedArrayPrototype.toString != arrayToString), NAME, {toString: arrayToString});
  19778. $export($export.P + $export.F * fails(function(){
  19779. new TypedArray(1).slice();
  19780. }), NAME, {slice: $slice});
  19781. $export($export.P + $export.F * (fails(function(){
  19782. return [1, 2].toLocaleString() != new TypedArray([1, 2]).toLocaleString()
  19783. }) || !fails(function(){
  19784. TypedArrayPrototype.toLocaleString.call([1, 2]);
  19785. })), NAME, {toLocaleString: $toLocaleString});
  19786. Iterators[NAME] = CORRECT_ITER_NAME ? $nativeIterator : $iterator;
  19787. if(!LIBRARY && !CORRECT_ITER_NAME)hide(TypedArrayPrototype, ITERATOR, $iterator);
  19788. };
  19789. } else module.exports = function(){ /* empty */ };
  19790. /***/ },
  19791. /* 38 */
  19792. /***/ function(module, exports, __webpack_require__) {
  19793. // Copyright Joyent, Inc. and other Node contributors.
  19794. //
  19795. // Permission is hereby granted, free of charge, to any person obtaining a
  19796. // copy of this software and associated documentation files (the
  19797. // "Software"), to deal in the Software without restriction, including
  19798. // without limitation the rights to use, copy, modify, merge, publish,
  19799. // distribute, sublicense, and/or sell copies of the Software, and to permit
  19800. // persons to whom the Software is furnished to do so, subject to the
  19801. // following conditions:
  19802. //
  19803. // The above copyright notice and this permission notice shall be included
  19804. // in all copies or substantial portions of the Software.
  19805. //
  19806. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  19807. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19808. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  19809. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  19810. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  19811. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  19812. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  19813. var Buffer = __webpack_require__(1).Buffer;
  19814. var isBufferEncoding = Buffer.isEncoding
  19815. || function(encoding) {
  19816. switch (encoding && encoding.toLowerCase()) {
  19817. 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': return true;
  19818. default: return false;
  19819. }
  19820. }
  19821. function assertEncoding(encoding) {
  19822. if (encoding && !isBufferEncoding(encoding)) {
  19823. throw new Error('Unknown encoding: ' + encoding);
  19824. }
  19825. }
  19826. // StringDecoder provides an interface for efficiently splitting a series of
  19827. // buffers into a series of JS strings without breaking apart multi-byte
  19828. // characters. CESU-8 is handled as part of the UTF-8 encoding.
  19829. //
  19830. // @TODO Handling all encodings inside a single object makes it very difficult
  19831. // to reason about this code, so it should be split up in the future.
  19832. // @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code
  19833. // points as used by CESU-8.
  19834. var StringDecoder = exports.StringDecoder = function(encoding) {
  19835. this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
  19836. assertEncoding(encoding);
  19837. switch (this.encoding) {
  19838. case 'utf8':
  19839. // CESU-8 represents each of Surrogate Pair by 3-bytes
  19840. this.surrogateSize = 3;
  19841. break;
  19842. case 'ucs2':
  19843. case 'utf16le':
  19844. // UTF-16 represents each of Surrogate Pair by 2-bytes
  19845. this.surrogateSize = 2;
  19846. this.detectIncompleteChar = utf16DetectIncompleteChar;
  19847. break;
  19848. case 'base64':
  19849. // Base-64 stores 3 bytes in 4 chars, and pads the remainder.
  19850. this.surrogateSize = 3;
  19851. this.detectIncompleteChar = base64DetectIncompleteChar;
  19852. break;
  19853. default:
  19854. this.write = passThroughWrite;
  19855. return;
  19856. }
  19857. // Enough space to store all bytes of a single character. UTF-8 needs 4
  19858. // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate).
  19859. this.charBuffer = new Buffer(6);
  19860. // Number of bytes received for the current incomplete multi-byte character.
  19861. this.charReceived = 0;
  19862. // Number of bytes expected for the current incomplete multi-byte character.
  19863. this.charLength = 0;
  19864. };
  19865. // write decodes the given buffer and returns it as JS string that is
  19866. // guaranteed to not contain any partial multi-byte characters. Any partial
  19867. // character found at the end of the buffer is buffered up, and will be
  19868. // returned when calling write again with the remaining bytes.
  19869. //
  19870. // Note: Converting a Buffer containing an orphan surrogate to a String
  19871. // currently works, but converting a String to a Buffer (via `new Buffer`, or
  19872. // Buffer#write) will replace incomplete surrogates with the unicode
  19873. // replacement character. See https://codereview.chromium.org/121173009/ .
  19874. StringDecoder.prototype.write = function(buffer) {
  19875. var charStr = '';
  19876. // if our last write ended with an incomplete multibyte character
  19877. while (this.charLength) {
  19878. // determine how many remaining bytes this buffer has to offer for this char
  19879. var available = (buffer.length >= this.charLength - this.charReceived) ?
  19880. this.charLength - this.charReceived :
  19881. buffer.length;
  19882. // add the new bytes to the char buffer
  19883. buffer.copy(this.charBuffer, this.charReceived, 0, available);
  19884. this.charReceived += available;
  19885. if (this.charReceived < this.charLength) {
  19886. // still not enough chars in this buffer? wait for more ...
  19887. return '';
  19888. }
  19889. // remove bytes belonging to the current character from the buffer
  19890. buffer = buffer.slice(available, buffer.length);
  19891. // get the character that was split
  19892. charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
  19893. // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
  19894. var charCode = charStr.charCodeAt(charStr.length - 1);
  19895. if (charCode >= 0xD800 && charCode <= 0xDBFF) {
  19896. this.charLength += this.surrogateSize;
  19897. charStr = '';
  19898. continue;
  19899. }
  19900. this.charReceived = this.charLength = 0;
  19901. // if there are no more bytes in this buffer, just emit our char
  19902. if (buffer.length === 0) {
  19903. return charStr;
  19904. }
  19905. break;
  19906. }
  19907. // determine and set charLength / charReceived
  19908. this.detectIncompleteChar(buffer);
  19909. var end = buffer.length;
  19910. if (this.charLength) {
  19911. // buffer the incomplete character bytes we got
  19912. buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end);
  19913. end -= this.charReceived;
  19914. }
  19915. charStr += buffer.toString(this.encoding, 0, end);
  19916. var end = charStr.length - 1;
  19917. var charCode = charStr.charCodeAt(end);
  19918. // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
  19919. if (charCode >= 0xD800 && charCode <= 0xDBFF) {
  19920. var size = this.surrogateSize;
  19921. this.charLength += size;
  19922. this.charReceived += size;
  19923. this.charBuffer.copy(this.charBuffer, size, 0, size);
  19924. buffer.copy(this.charBuffer, 0, 0, size);
  19925. return charStr.substring(0, end);
  19926. }
  19927. // or just emit the charStr
  19928. return charStr;
  19929. };
  19930. // detectIncompleteChar determines if there is an incomplete UTF-8 character at
  19931. // the end of the given buffer. If so, it sets this.charLength to the byte
  19932. // length that character, and sets this.charReceived to the number of bytes
  19933. // that are available for this character.
  19934. StringDecoder.prototype.detectIncompleteChar = function(buffer) {
  19935. // determine how many bytes we have to check at the end of this buffer
  19936. var i = (buffer.length >= 3) ? 3 : buffer.length;
  19937. // Figure out if one of the last i bytes of our buffer announces an
  19938. // incomplete char.
  19939. for (; i > 0; i--) {
  19940. var c = buffer[buffer.length - i];
  19941. // See http://en.wikipedia.org/wiki/UTF-8#Description
  19942. // 110XXXXX
  19943. if (i == 1 && c >> 5 == 0x06) {
  19944. this.charLength = 2;
  19945. break;
  19946. }
  19947. // 1110XXXX
  19948. if (i <= 2 && c >> 4 == 0x0E) {
  19949. this.charLength = 3;
  19950. break;
  19951. }
  19952. // 11110XXX
  19953. if (i <= 3 && c >> 3 == 0x1E) {
  19954. this.charLength = 4;
  19955. break;
  19956. }
  19957. }
  19958. this.charReceived = i;
  19959. };
  19960. StringDecoder.prototype.end = function(buffer) {
  19961. var res = '';
  19962. if (buffer && buffer.length)
  19963. res = this.write(buffer);
  19964. if (this.charReceived) {
  19965. var cr = this.charReceived;
  19966. var buf = this.charBuffer;
  19967. var enc = this.encoding;
  19968. res += buf.slice(0, cr).toString(enc);
  19969. }
  19970. return res;
  19971. };
  19972. function passThroughWrite(buffer) {
  19973. return buffer.toString(this.encoding);
  19974. }
  19975. function utf16DetectIncompleteChar(buffer) {
  19976. this.charReceived = buffer.length % 2;
  19977. this.charLength = this.charReceived ? 2 : 0;
  19978. }
  19979. function base64DetectIncompleteChar(buffer) {
  19980. this.charReceived = buffer.length % 3;
  19981. this.charLength = this.charReceived ? 3 : 0;
  19982. }
  19983. /***/ },
  19984. /* 39 */
  19985. /***/ function(module, exports) {
  19986. module.exports = function(it, Constructor, name, forbiddenField){
  19987. if(!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)){
  19988. throw TypeError(name + ': incorrect invocation!');
  19989. } return it;
  19990. };
  19991. /***/ },
  19992. /* 40 */
  19993. /***/ function(module, exports, __webpack_require__) {
  19994. var META = __webpack_require__(53)('meta')
  19995. , isObject = __webpack_require__(7)
  19996. , has = __webpack_require__(17)
  19997. , setDesc = __webpack_require__(11).f
  19998. , id = 0;
  19999. var isExtensible = Object.isExtensible || function(){
  20000. return true;
  20001. };
  20002. var FREEZE = !__webpack_require__(6)(function(){
  20003. return isExtensible(Object.preventExtensions({}));
  20004. });
  20005. var setMeta = function(it){
  20006. setDesc(it, META, {value: {
  20007. i: 'O' + ++id, // object ID
  20008. w: {} // weak collections IDs
  20009. }});
  20010. };
  20011. var fastKey = function(it, create){
  20012. // return primitive with prefix
  20013. if(!isObject(it))return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
  20014. if(!has(it, META)){
  20015. // can't set metadata to uncaught frozen object
  20016. if(!isExtensible(it))return 'F';
  20017. // not necessary to add metadata
  20018. if(!create)return 'E';
  20019. // add missing metadata
  20020. setMeta(it);
  20021. // return object ID
  20022. } return it[META].i;
  20023. };
  20024. var getWeak = function(it, create){
  20025. if(!has(it, META)){
  20026. // can't set metadata to uncaught frozen object
  20027. if(!isExtensible(it))return true;
  20028. // not necessary to add metadata
  20029. if(!create)return false;
  20030. // add missing metadata
  20031. setMeta(it);
  20032. // return hash weak collections IDs
  20033. } return it[META].w;
  20034. };
  20035. // add metadata on freeze-family methods calling
  20036. var onFreeze = function(it){
  20037. if(FREEZE && meta.NEED && isExtensible(it) && !has(it, META))setMeta(it);
  20038. return it;
  20039. };
  20040. var meta = module.exports = {
  20041. KEY: META,
  20042. NEED: false,
  20043. fastKey: fastKey,
  20044. getWeak: getWeak,
  20045. onFreeze: onFreeze
  20046. };
  20047. /***/ },
  20048. /* 41 */
  20049. /***/ function(module, exports) {
  20050. module.exports = function(bitmap, value){
  20051. return {
  20052. enumerable : !(bitmap & 1),
  20053. configurable: !(bitmap & 2),
  20054. writable : !(bitmap & 4),
  20055. value : value
  20056. };
  20057. };
  20058. /***/ },
  20059. /* 42 */
  20060. /***/ function(module, exports) {
  20061. // 7.1.4 ToInteger
  20062. var ceil = Math.ceil
  20063. , floor = Math.floor;
  20064. module.exports = function(it){
  20065. return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
  20066. };
  20067. /***/ },
  20068. /* 43 */
  20069. /***/ function(module, exports, __webpack_require__) {
  20070. /* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors.
  20071. //
  20072. // Permission is hereby granted, free of charge, to any person obtaining a
  20073. // copy of this software and associated documentation files (the
  20074. // "Software"), to deal in the Software without restriction, including
  20075. // without limitation the rights to use, copy, modify, merge, publish,
  20076. // distribute, sublicense, and/or sell copies of the Software, and to permit
  20077. // persons to whom the Software is furnished to do so, subject to the
  20078. // following conditions:
  20079. //
  20080. // The above copyright notice and this permission notice shall be included
  20081. // in all copies or substantial portions of the Software.
  20082. //
  20083. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  20084. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20085. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  20086. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  20087. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  20088. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  20089. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  20090. // resolves . and .. elements in a path array with directory names there
  20091. // must be no slashes, empty elements, or device names (c:\) in the array
  20092. // (so also no leading and trailing slashes - it does not distinguish
  20093. // relative and absolute paths)
  20094. function normalizeArray(parts, allowAboveRoot) {
  20095. // if the path tries to go above the root, `up` ends up > 0
  20096. var up = 0;
  20097. for (var i = parts.length - 1; i >= 0; i--) {
  20098. var last = parts[i];
  20099. if (last === '.') {
  20100. parts.splice(i, 1);
  20101. } else if (last === '..') {
  20102. parts.splice(i, 1);
  20103. up++;
  20104. } else if (up) {
  20105. parts.splice(i, 1);
  20106. up--;
  20107. }
  20108. }
  20109. // if the path is allowed to go above the root, restore leading ..s
  20110. if (allowAboveRoot) {
  20111. for (; up--; up) {
  20112. parts.unshift('..');
  20113. }
  20114. }
  20115. return parts;
  20116. }
  20117. // Split a filename into [root, dir, basename, ext], unix version
  20118. // 'root' is just a slash, or nothing.
  20119. var splitPathRe =
  20120. /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
  20121. var splitPath = function(filename) {
  20122. return splitPathRe.exec(filename).slice(1);
  20123. };
  20124. // path.resolve([from ...], to)
  20125. // posix version
  20126. exports.resolve = function() {
  20127. var resolvedPath = '',
  20128. resolvedAbsolute = false;
  20129. for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
  20130. var path = (i >= 0) ? arguments[i] : process.cwd();
  20131. // Skip empty and invalid entries
  20132. if (typeof path !== 'string') {
  20133. throw new TypeError('Arguments to path.resolve must be strings');
  20134. } else if (!path) {
  20135. continue;
  20136. }
  20137. resolvedPath = path + '/' + resolvedPath;
  20138. resolvedAbsolute = path.charAt(0) === '/';
  20139. }
  20140. // At this point the path should be resolved to a full absolute path, but
  20141. // handle relative paths to be safe (might happen when process.cwd() fails)
  20142. // Normalize the path
  20143. resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
  20144. return !!p;
  20145. }), !resolvedAbsolute).join('/');
  20146. return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
  20147. };
  20148. // path.normalize(path)
  20149. // posix version
  20150. exports.normalize = function(path) {
  20151. var isAbsolute = exports.isAbsolute(path),
  20152. trailingSlash = substr(path, -1) === '/';
  20153. // Normalize the path
  20154. path = normalizeArray(filter(path.split('/'), function(p) {
  20155. return !!p;
  20156. }), !isAbsolute).join('/');
  20157. if (!path && !isAbsolute) {
  20158. path = '.';
  20159. }
  20160. if (path && trailingSlash) {
  20161. path += '/';
  20162. }
  20163. return (isAbsolute ? '/' : '') + path;
  20164. };
  20165. // posix version
  20166. exports.isAbsolute = function(path) {
  20167. return path.charAt(0) === '/';
  20168. };
  20169. // posix version
  20170. exports.join = function() {
  20171. var paths = Array.prototype.slice.call(arguments, 0);
  20172. return exports.normalize(filter(paths, function(p, index) {
  20173. if (typeof p !== 'string') {
  20174. throw new TypeError('Arguments to path.join must be strings');
  20175. }
  20176. return p;
  20177. }).join('/'));
  20178. };
  20179. // path.relative(from, to)
  20180. // posix version
  20181. exports.relative = function(from, to) {
  20182. from = exports.resolve(from).substr(1);
  20183. to = exports.resolve(to).substr(1);
  20184. function trim(arr) {
  20185. var start = 0;
  20186. for (; start < arr.length; start++) {
  20187. if (arr[start] !== '') break;
  20188. }
  20189. var end = arr.length - 1;
  20190. for (; end >= 0; end--) {
  20191. if (arr[end] !== '') break;
  20192. }
  20193. if (start > end) return [];
  20194. return arr.slice(start, end - start + 1);
  20195. }
  20196. var fromParts = trim(from.split('/'));
  20197. var toParts = trim(to.split('/'));
  20198. var length = Math.min(fromParts.length, toParts.length);
  20199. var samePartsLength = length;
  20200. for (var i = 0; i < length; i++) {
  20201. if (fromParts[i] !== toParts[i]) {
  20202. samePartsLength = i;
  20203. break;
  20204. }
  20205. }
  20206. var outputParts = [];
  20207. for (var i = samePartsLength; i < fromParts.length; i++) {
  20208. outputParts.push('..');
  20209. }
  20210. outputParts = outputParts.concat(toParts.slice(samePartsLength));
  20211. return outputParts.join('/');
  20212. };
  20213. exports.sep = '/';
  20214. exports.delimiter = ':';
  20215. exports.dirname = function(path) {
  20216. var result = splitPath(path),
  20217. root = result[0],
  20218. dir = result[1];
  20219. if (!root && !dir) {
  20220. // No dirname whatsoever
  20221. return '.';
  20222. }
  20223. if (dir) {
  20224. // It has a dirname, strip trailing slash
  20225. dir = dir.substr(0, dir.length - 1);
  20226. }
  20227. return root + dir;
  20228. };
  20229. exports.basename = function(path, ext) {
  20230. var f = splitPath(path)[2];
  20231. // TODO: make this comparison case-insensitive on windows?
  20232. if (ext && f.substr(-1 * ext.length) === ext) {
  20233. f = f.substr(0, f.length - ext.length);
  20234. }
  20235. return f;
  20236. };
  20237. exports.extname = function(path) {
  20238. return splitPath(path)[3];
  20239. };
  20240. function filter (xs, f) {
  20241. if (xs.filter) return xs.filter(f);
  20242. var res = [];
  20243. for (var i = 0; i < xs.length; i++) {
  20244. if (f(xs[i], i, xs)) res.push(xs[i]);
  20245. }
  20246. return res;
  20247. }
  20248. // String.prototype.substr - negative index don't work in IE8
  20249. var substr = 'ab'.substr(-1) === 'b'
  20250. ? function (str, start, len) { return str.substr(start, len) }
  20251. : function (str, start, len) {
  20252. if (start < 0) start = str.length + start;
  20253. return str.substr(start, len);
  20254. }
  20255. ;
  20256. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  20257. /***/ },
  20258. /* 44 */
  20259. /***/ function(module, exports, __webpack_require__) {
  20260. /* WEBPACK VAR INJECTION */(function(global, process) {// Copyright Joyent, Inc. and other Node contributors.
  20261. //
  20262. // Permission is hereby granted, free of charge, to any person obtaining a
  20263. // copy of this software and associated documentation files (the
  20264. // "Software"), to deal in the Software without restriction, including
  20265. // without limitation the rights to use, copy, modify, merge, publish,
  20266. // distribute, sublicense, and/or sell copies of the Software, and to permit
  20267. // persons to whom the Software is furnished to do so, subject to the
  20268. // following conditions:
  20269. //
  20270. // The above copyright notice and this permission notice shall be included
  20271. // in all copies or substantial portions of the Software.
  20272. //
  20273. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  20274. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20275. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  20276. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  20277. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  20278. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  20279. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  20280. var formatRegExp = /%[sdj%]/g;
  20281. exports.format = function(f) {
  20282. if (!isString(f)) {
  20283. var objects = [];
  20284. for (var i = 0; i < arguments.length; i++) {
  20285. objects.push(inspect(arguments[i]));
  20286. }
  20287. return objects.join(' ');
  20288. }
  20289. var i = 1;
  20290. var args = arguments;
  20291. var len = args.length;
  20292. var str = String(f).replace(formatRegExp, function(x) {
  20293. if (x === '%%') return '%';
  20294. if (i >= len) return x;
  20295. switch (x) {
  20296. case '%s': return String(args[i++]);
  20297. case '%d': return Number(args[i++]);
  20298. case '%j':
  20299. try {
  20300. return JSON.stringify(args[i++]);
  20301. } catch (_) {
  20302. return '[Circular]';
  20303. }
  20304. default:
  20305. return x;
  20306. }
  20307. });
  20308. for (var x = args[i]; i < len; x = args[++i]) {
  20309. if (isNull(x) || !isObject(x)) {
  20310. str += ' ' + x;
  20311. } else {
  20312. str += ' ' + inspect(x);
  20313. }
  20314. }
  20315. return str;
  20316. };
  20317. // Mark that a method should not be used.
  20318. // Returns a modified function which warns once by default.
  20319. // If --no-deprecation is set, then it is a no-op.
  20320. exports.deprecate = function(fn, msg) {
  20321. // Allow for deprecating things in the process of starting up.
  20322. if (isUndefined(global.process)) {
  20323. return function() {
  20324. return exports.deprecate(fn, msg).apply(this, arguments);
  20325. };
  20326. }
  20327. if (process.noDeprecation === true) {
  20328. return fn;
  20329. }
  20330. var warned = false;
  20331. function deprecated() {
  20332. if (!warned) {
  20333. if (process.throwDeprecation) {
  20334. throw new Error(msg);
  20335. } else if (process.traceDeprecation) {
  20336. console.trace(msg);
  20337. } else {
  20338. console.error(msg);
  20339. }
  20340. warned = true;
  20341. }
  20342. return fn.apply(this, arguments);
  20343. }
  20344. return deprecated;
  20345. };
  20346. var debugs = {};
  20347. var debugEnviron;
  20348. exports.debuglog = function(set) {
  20349. if (isUndefined(debugEnviron))
  20350. debugEnviron = process.env.NODE_DEBUG || '';
  20351. set = set.toUpperCase();
  20352. if (!debugs[set]) {
  20353. if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
  20354. var pid = process.pid;
  20355. debugs[set] = function() {
  20356. var msg = exports.format.apply(exports, arguments);
  20357. console.error('%s %d: %s', set, pid, msg);
  20358. };
  20359. } else {
  20360. debugs[set] = function() {};
  20361. }
  20362. }
  20363. return debugs[set];
  20364. };
  20365. /**
  20366. * Echos the value of a value. Trys to print the value out
  20367. * in the best way possible given the different types.
  20368. *
  20369. * @param {Object} obj The object to print out.
  20370. * @param {Object} opts Optional options object that alters the output.
  20371. */
  20372. /* legacy: obj, showHidden, depth, colors*/
  20373. function inspect(obj, opts) {
  20374. // default options
  20375. var ctx = {
  20376. seen: [],
  20377. stylize: stylizeNoColor
  20378. };
  20379. // legacy...
  20380. if (arguments.length >= 3) ctx.depth = arguments[2];
  20381. if (arguments.length >= 4) ctx.colors = arguments[3];
  20382. if (isBoolean(opts)) {
  20383. // legacy...
  20384. ctx.showHidden = opts;
  20385. } else if (opts) {
  20386. // got an "options" object
  20387. exports._extend(ctx, opts);
  20388. }
  20389. // set default options
  20390. if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
  20391. if (isUndefined(ctx.depth)) ctx.depth = 2;
  20392. if (isUndefined(ctx.colors)) ctx.colors = false;
  20393. if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
  20394. if (ctx.colors) ctx.stylize = stylizeWithColor;
  20395. return formatValue(ctx, obj, ctx.depth);
  20396. }
  20397. exports.inspect = inspect;
  20398. // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  20399. inspect.colors = {
  20400. 'bold' : [1, 22],
  20401. 'italic' : [3, 23],
  20402. 'underline' : [4, 24],
  20403. 'inverse' : [7, 27],
  20404. 'white' : [37, 39],
  20405. 'grey' : [90, 39],
  20406. 'black' : [30, 39],
  20407. 'blue' : [34, 39],
  20408. 'cyan' : [36, 39],
  20409. 'green' : [32, 39],
  20410. 'magenta' : [35, 39],
  20411. 'red' : [31, 39],
  20412. 'yellow' : [33, 39]
  20413. };
  20414. // Don't use 'blue' not visible on cmd.exe
  20415. inspect.styles = {
  20416. 'special': 'cyan',
  20417. 'number': 'yellow',
  20418. 'boolean': 'yellow',
  20419. 'undefined': 'grey',
  20420. 'null': 'bold',
  20421. 'string': 'green',
  20422. 'date': 'magenta',
  20423. // "name": intentionally not styling
  20424. 'regexp': 'red'
  20425. };
  20426. function stylizeWithColor(str, styleType) {
  20427. var style = inspect.styles[styleType];
  20428. if (style) {
  20429. return '\u001b[' + inspect.colors[style][0] + 'm' + str +
  20430. '\u001b[' + inspect.colors[style][1] + 'm';
  20431. } else {
  20432. return str;
  20433. }
  20434. }
  20435. function stylizeNoColor(str, styleType) {
  20436. return str;
  20437. }
  20438. function arrayToHash(array) {
  20439. var hash = {};
  20440. array.forEach(function(val, idx) {
  20441. hash[val] = true;
  20442. });
  20443. return hash;
  20444. }
  20445. function formatValue(ctx, value, recurseTimes) {
  20446. // Provide a hook for user-specified inspect functions.
  20447. // Check that value is an object with an inspect function on it
  20448. if (ctx.customInspect &&
  20449. value &&
  20450. isFunction(value.inspect) &&
  20451. // Filter out the util module, it's inspect function is special
  20452. value.inspect !== exports.inspect &&
  20453. // Also filter out any prototype objects using the circular check.
  20454. !(value.constructor && value.constructor.prototype === value)) {
  20455. var ret = value.inspect(recurseTimes, ctx);
  20456. if (!isString(ret)) {
  20457. ret = formatValue(ctx, ret, recurseTimes);
  20458. }
  20459. return ret;
  20460. }
  20461. // Primitive types cannot have properties
  20462. var primitive = formatPrimitive(ctx, value);
  20463. if (primitive) {
  20464. return primitive;
  20465. }
  20466. // Look up the keys of the object.
  20467. var keys = Object.keys(value);
  20468. var visibleKeys = arrayToHash(keys);
  20469. if (ctx.showHidden) {
  20470. keys = Object.getOwnPropertyNames(value);
  20471. }
  20472. // IE doesn't make error fields non-enumerable
  20473. // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
  20474. if (isError(value)
  20475. && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
  20476. return formatError(value);
  20477. }
  20478. // Some type of object without properties can be shortcutted.
  20479. if (keys.length === 0) {
  20480. if (isFunction(value)) {
  20481. var name = value.name ? ': ' + value.name : '';
  20482. return ctx.stylize('[Function' + name + ']', 'special');
  20483. }
  20484. if (isRegExp(value)) {
  20485. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  20486. }
  20487. if (isDate(value)) {
  20488. return ctx.stylize(Date.prototype.toString.call(value), 'date');
  20489. }
  20490. if (isError(value)) {
  20491. return formatError(value);
  20492. }
  20493. }
  20494. var base = '', array = false, braces = ['{', '}'];
  20495. // Make Array say that they are Array
  20496. if (isArray(value)) {
  20497. array = true;
  20498. braces = ['[', ']'];
  20499. }
  20500. // Make functions say that they are functions
  20501. if (isFunction(value)) {
  20502. var n = value.name ? ': ' + value.name : '';
  20503. base = ' [Function' + n + ']';
  20504. }
  20505. // Make RegExps say that they are RegExps
  20506. if (isRegExp(value)) {
  20507. base = ' ' + RegExp.prototype.toString.call(value);
  20508. }
  20509. // Make dates with properties first say the date
  20510. if (isDate(value)) {
  20511. base = ' ' + Date.prototype.toUTCString.call(value);
  20512. }
  20513. // Make error with message first say the error
  20514. if (isError(value)) {
  20515. base = ' ' + formatError(value);
  20516. }
  20517. if (keys.length === 0 && (!array || value.length == 0)) {
  20518. return braces[0] + base + braces[1];
  20519. }
  20520. if (recurseTimes < 0) {
  20521. if (isRegExp(value)) {
  20522. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  20523. } else {
  20524. return ctx.stylize('[Object]', 'special');
  20525. }
  20526. }
  20527. ctx.seen.push(value);
  20528. var output;
  20529. if (array) {
  20530. output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
  20531. } else {
  20532. output = keys.map(function(key) {
  20533. return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
  20534. });
  20535. }
  20536. ctx.seen.pop();
  20537. return reduceToSingleString(output, base, braces);
  20538. }
  20539. function formatPrimitive(ctx, value) {
  20540. if (isUndefined(value))
  20541. return ctx.stylize('undefined', 'undefined');
  20542. if (isString(value)) {
  20543. var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
  20544. .replace(/'/g, "\\'")
  20545. .replace(/\\"/g, '"') + '\'';
  20546. return ctx.stylize(simple, 'string');
  20547. }
  20548. if (isNumber(value))
  20549. return ctx.stylize('' + value, 'number');
  20550. if (isBoolean(value))
  20551. return ctx.stylize('' + value, 'boolean');
  20552. // For some reason typeof null is "object", so special case here.
  20553. if (isNull(value))
  20554. return ctx.stylize('null', 'null');
  20555. }
  20556. function formatError(value) {
  20557. return '[' + Error.prototype.toString.call(value) + ']';
  20558. }
  20559. function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
  20560. var output = [];
  20561. for (var i = 0, l = value.length; i < l; ++i) {
  20562. if (hasOwnProperty(value, String(i))) {
  20563. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  20564. String(i), true));
  20565. } else {
  20566. output.push('');
  20567. }
  20568. }
  20569. keys.forEach(function(key) {
  20570. if (!key.match(/^\d+$/)) {
  20571. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  20572. key, true));
  20573. }
  20574. });
  20575. return output;
  20576. }
  20577. function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
  20578. var name, str, desc;
  20579. desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
  20580. if (desc.get) {
  20581. if (desc.set) {
  20582. str = ctx.stylize('[Getter/Setter]', 'special');
  20583. } else {
  20584. str = ctx.stylize('[Getter]', 'special');
  20585. }
  20586. } else {
  20587. if (desc.set) {
  20588. str = ctx.stylize('[Setter]', 'special');
  20589. }
  20590. }
  20591. if (!hasOwnProperty(visibleKeys, key)) {
  20592. name = '[' + key + ']';
  20593. }
  20594. if (!str) {
  20595. if (ctx.seen.indexOf(desc.value) < 0) {
  20596. if (isNull(recurseTimes)) {
  20597. str = formatValue(ctx, desc.value, null);
  20598. } else {
  20599. str = formatValue(ctx, desc.value, recurseTimes - 1);
  20600. }
  20601. if (str.indexOf('\n') > -1) {
  20602. if (array) {
  20603. str = str.split('\n').map(function(line) {
  20604. return ' ' + line;
  20605. }).join('\n').substr(2);
  20606. } else {
  20607. str = '\n' + str.split('\n').map(function(line) {
  20608. return ' ' + line;
  20609. }).join('\n');
  20610. }
  20611. }
  20612. } else {
  20613. str = ctx.stylize('[Circular]', 'special');
  20614. }
  20615. }
  20616. if (isUndefined(name)) {
  20617. if (array && key.match(/^\d+$/)) {
  20618. return str;
  20619. }
  20620. name = JSON.stringify('' + key);
  20621. if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
  20622. name = name.substr(1, name.length - 2);
  20623. name = ctx.stylize(name, 'name');
  20624. } else {
  20625. name = name.replace(/'/g, "\\'")
  20626. .replace(/\\"/g, '"')
  20627. .replace(/(^"|"$)/g, "'");
  20628. name = ctx.stylize(name, 'string');
  20629. }
  20630. }
  20631. return name + ': ' + str;
  20632. }
  20633. function reduceToSingleString(output, base, braces) {
  20634. var numLinesEst = 0;
  20635. var length = output.reduce(function(prev, cur) {
  20636. numLinesEst++;
  20637. if (cur.indexOf('\n') >= 0) numLinesEst++;
  20638. return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
  20639. }, 0);
  20640. if (length > 60) {
  20641. return braces[0] +
  20642. (base === '' ? '' : base + '\n ') +
  20643. ' ' +
  20644. output.join(',\n ') +
  20645. ' ' +
  20646. braces[1];
  20647. }
  20648. return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  20649. }
  20650. // NOTE: These type checking functions intentionally don't use `instanceof`
  20651. // because it is fragile and can be easily faked with `Object.create()`.
  20652. function isArray(ar) {
  20653. return Array.isArray(ar);
  20654. }
  20655. exports.isArray = isArray;
  20656. function isBoolean(arg) {
  20657. return typeof arg === 'boolean';
  20658. }
  20659. exports.isBoolean = isBoolean;
  20660. function isNull(arg) {
  20661. return arg === null;
  20662. }
  20663. exports.isNull = isNull;
  20664. function isNullOrUndefined(arg) {
  20665. return arg == null;
  20666. }
  20667. exports.isNullOrUndefined = isNullOrUndefined;
  20668. function isNumber(arg) {
  20669. return typeof arg === 'number';
  20670. }
  20671. exports.isNumber = isNumber;
  20672. function isString(arg) {
  20673. return typeof arg === 'string';
  20674. }
  20675. exports.isString = isString;
  20676. function isSymbol(arg) {
  20677. return typeof arg === 'symbol';
  20678. }
  20679. exports.isSymbol = isSymbol;
  20680. function isUndefined(arg) {
  20681. return arg === void 0;
  20682. }
  20683. exports.isUndefined = isUndefined;
  20684. function isRegExp(re) {
  20685. return isObject(re) && objectToString(re) === '[object RegExp]';
  20686. }
  20687. exports.isRegExp = isRegExp;
  20688. function isObject(arg) {
  20689. return typeof arg === 'object' && arg !== null;
  20690. }
  20691. exports.isObject = isObject;
  20692. function isDate(d) {
  20693. return isObject(d) && objectToString(d) === '[object Date]';
  20694. }
  20695. exports.isDate = isDate;
  20696. function isError(e) {
  20697. return isObject(e) &&
  20698. (objectToString(e) === '[object Error]' || e instanceof Error);
  20699. }
  20700. exports.isError = isError;
  20701. function isFunction(arg) {
  20702. return typeof arg === 'function';
  20703. }
  20704. exports.isFunction = isFunction;
  20705. function isPrimitive(arg) {
  20706. return arg === null ||
  20707. typeof arg === 'boolean' ||
  20708. typeof arg === 'number' ||
  20709. typeof arg === 'string' ||
  20710. typeof arg === 'symbol' || // ES6 symbol
  20711. typeof arg === 'undefined';
  20712. }
  20713. exports.isPrimitive = isPrimitive;
  20714. exports.isBuffer = __webpack_require__(579);
  20715. function objectToString(o) {
  20716. return Object.prototype.toString.call(o);
  20717. }
  20718. function pad(n) {
  20719. return n < 10 ? '0' + n.toString(10) : n.toString(10);
  20720. }
  20721. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
  20722. 'Oct', 'Nov', 'Dec'];
  20723. // 26 Feb 16:19:34
  20724. function timestamp() {
  20725. var d = new Date();
  20726. var time = [pad(d.getHours()),
  20727. pad(d.getMinutes()),
  20728. pad(d.getSeconds())].join(':');
  20729. return [d.getDate(), months[d.getMonth()], time].join(' ');
  20730. }
  20731. // log is just a thin wrapper to console.log that prepends a timestamp
  20732. exports.log = function() {
  20733. console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
  20734. };
  20735. /**
  20736. * Inherit the prototype methods from one constructor into another.
  20737. *
  20738. * The Function.prototype.inherits from lang.js rewritten as a standalone
  20739. * function (not on Function.prototype). NOTE: If this file is to be loaded
  20740. * during bootstrapping this function needs to be rewritten using some native
  20741. * functions as prototype setup using normal JavaScript does not work as
  20742. * expected during bootstrapping (see mirror.js in r114903).
  20743. *
  20744. * @param {function} ctor Constructor function which needs to inherit the
  20745. * prototype.
  20746. * @param {function} superCtor Constructor function to inherit prototype from.
  20747. */
  20748. exports.inherits = __webpack_require__(2);
  20749. exports._extend = function(origin, add) {
  20750. // Don't do anything if add isn't an object
  20751. if (!add || !isObject(add)) return origin;
  20752. var keys = Object.keys(add);
  20753. var i = keys.length;
  20754. while (i--) {
  20755. origin[keys[i]] = add[keys[i]];
  20756. }
  20757. return origin;
  20758. };
  20759. function hasOwnProperty(obj, prop) {
  20760. return Object.prototype.hasOwnProperty.call(obj, prop);
  20761. }
  20762. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(13), __webpack_require__(4)))
  20763. /***/ },
  20764. /* 45 */
  20765. /***/ function(module, exports) {
  20766. module.exports = {};
  20767. /***/ },
  20768. /* 46 */
  20769. /***/ function(module, exports) {
  20770. module.exports = false;
  20771. /***/ },
  20772. /* 47 */
  20773. /***/ function(module, exports, __webpack_require__) {
  20774. // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
  20775. var anObject = __webpack_require__(3)
  20776. , dPs = __webpack_require__(181)
  20777. , enumBugKeys = __webpack_require__(107)
  20778. , IE_PROTO = __webpack_require__(119)('IE_PROTO')
  20779. , Empty = function(){ /* empty */ }
  20780. , PROTOTYPE = 'prototype';
  20781. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  20782. var createDict = function(){
  20783. // Thrash, waste and sodomy: IE GC bug
  20784. var iframe = __webpack_require__(106)('iframe')
  20785. , i = enumBugKeys.length
  20786. , gt = '>'
  20787. , iframeDocument;
  20788. iframe.style.display = 'none';
  20789. __webpack_require__(109).appendChild(iframe);
  20790. iframe.src = 'javascript:'; // eslint-disable-line no-script-url
  20791. // createDict = iframe.contentWindow.Object;
  20792. // html.removeChild(iframe);
  20793. iframeDocument = iframe.contentWindow.document;
  20794. iframeDocument.open();
  20795. iframeDocument.write('<script>document.F=Object</script' + gt);
  20796. iframeDocument.close();
  20797. createDict = iframeDocument.F;
  20798. while(i--)delete createDict[PROTOTYPE][enumBugKeys[i]];
  20799. return createDict();
  20800. };
  20801. module.exports = Object.create || function create(O, Properties){
  20802. var result;
  20803. if(O !== null){
  20804. Empty[PROTOTYPE] = anObject(O);
  20805. result = new Empty;
  20806. Empty[PROTOTYPE] = null;
  20807. // add "__proto__" for Object.getPrototypeOf polyfill
  20808. result[IE_PROTO] = O;
  20809. } else result = createDict();
  20810. return Properties === undefined ? result : dPs(result, Properties);
  20811. };
  20812. /***/ },
  20813. /* 48 */
  20814. /***/ function(module, exports, __webpack_require__) {
  20815. // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
  20816. var $keys = __webpack_require__(183)
  20817. , hiddenKeys = __webpack_require__(107).concat('length', 'prototype');
  20818. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O){
  20819. return $keys(O, hiddenKeys);
  20820. };
  20821. /***/ },
  20822. /* 49 */
  20823. /***/ function(module, exports, __webpack_require__) {
  20824. // 19.1.2.14 / 15.2.3.14 Object.keys(O)
  20825. var $keys = __webpack_require__(183)
  20826. , enumBugKeys = __webpack_require__(107);
  20827. module.exports = Object.keys || function keys(O){
  20828. return $keys(O, enumBugKeys);
  20829. };
  20830. /***/ },
  20831. /* 50 */
  20832. /***/ function(module, exports, __webpack_require__) {
  20833. var redefine = __webpack_require__(22);
  20834. module.exports = function(target, src, safe){
  20835. for(var key in src)redefine(target, key, src[key], safe);
  20836. return target;
  20837. };
  20838. /***/ },
  20839. /* 51 */
  20840. /***/ function(module, exports, __webpack_require__) {
  20841. "use strict";
  20842. 'use strict';
  20843. var global = __webpack_require__(5)
  20844. , dP = __webpack_require__(11)
  20845. , DESCRIPTORS = __webpack_require__(10)
  20846. , SPECIES = __webpack_require__(8)('species');
  20847. module.exports = function(KEY){
  20848. var C = global[KEY];
  20849. if(DESCRIPTORS && C && !C[SPECIES])dP.f(C, SPECIES, {
  20850. configurable: true,
  20851. get: function(){ return this; }
  20852. });
  20853. };
  20854. /***/ },
  20855. /* 52 */
  20856. /***/ function(module, exports, __webpack_require__) {
  20857. var toInteger = __webpack_require__(42)
  20858. , max = Math.max
  20859. , min = Math.min;
  20860. module.exports = function(index, length){
  20861. index = toInteger(index);
  20862. return index < 0 ? max(index + length, 0) : min(index, length);
  20863. };
  20864. /***/ },
  20865. /* 53 */
  20866. /***/ function(module, exports) {
  20867. var id = 0
  20868. , px = Math.random();
  20869. module.exports = function(key){
  20870. return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
  20871. };
  20872. /***/ },
  20873. /* 54 */
  20874. /***/ function(module, exports, __webpack_require__) {
  20875. var hash = exports;
  20876. hash.utils = __webpack_require__(509);
  20877. hash.common = __webpack_require__(505);
  20878. hash.sha = __webpack_require__(508);
  20879. hash.ripemd = __webpack_require__(507);
  20880. hash.hmac = __webpack_require__(506);
  20881. // Proxy hash functions to the main object
  20882. hash.sha1 = hash.sha.sha1;
  20883. hash.sha256 = hash.sha.sha256;
  20884. hash.sha224 = hash.sha.sha224;
  20885. hash.sha384 = hash.sha.sha384;
  20886. hash.sha512 = hash.sha.sha512;
  20887. hash.ripemd160 = hash.ripemd.ripemd160;
  20888. /***/ },
  20889. /* 55 */
  20890. /***/ function(module, exports, __webpack_require__) {
  20891. "use strict";
  20892. // a duplex stream is just a stream that is both readable and writable.
  20893. // Since JS doesn't have multiple prototypal inheritance, this class
  20894. // prototypally inherits from Readable, and then parasitically from
  20895. // Writable.
  20896. 'use strict';
  20897. /*<replacement>*/
  20898. var objectKeys = Object.keys || function (obj) {
  20899. var keys = [];
  20900. for (var key in obj) {
  20901. keys.push(key);
  20902. }return keys;
  20903. };
  20904. /*</replacement>*/
  20905. module.exports = Duplex;
  20906. /*<replacement>*/
  20907. var processNextTick = __webpack_require__(64);
  20908. /*</replacement>*/
  20909. /*<replacement>*/
  20910. var util = __webpack_require__(14);
  20911. util.inherits = __webpack_require__(2);
  20912. /*</replacement>*/
  20913. var Readable = __webpack_require__(216);
  20914. var Writable = __webpack_require__(139);
  20915. util.inherits(Duplex, Readable);
  20916. var keys = objectKeys(Writable.prototype);
  20917. for (var v = 0; v < keys.length; v++) {
  20918. var method = keys[v];
  20919. if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
  20920. }
  20921. function Duplex(options) {
  20922. if (!(this instanceof Duplex)) return new Duplex(options);
  20923. Readable.call(this, options);
  20924. Writable.call(this, options);
  20925. if (options && options.readable === false) this.readable = false;
  20926. if (options && options.writable === false) this.writable = false;
  20927. this.allowHalfOpen = true;
  20928. if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
  20929. this.once('end', onend);
  20930. }
  20931. // the no-half-open enforcer
  20932. function onend() {
  20933. // if we allow half-open state, or if the writable side ended,
  20934. // then we're ok.
  20935. if (this.allowHalfOpen || this._writableState.ended) return;
  20936. // no more data can be written.
  20937. // But allow more writes to happen in this tick.
  20938. processNextTick(onEndNT, this);
  20939. }
  20940. function onEndNT(self) {
  20941. self.end();
  20942. }
  20943. function forEach(xs, f) {
  20944. for (var i = 0, l = xs.length; i < l; i++) {
  20945. f(xs[i], i);
  20946. }
  20947. }
  20948. /***/ },
  20949. /* 56 */
  20950. /***/ function(module, exports, __webpack_require__) {
  20951. var basex = __webpack_require__(281)
  20952. var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
  20953. var base58 = basex(ALPHABET)
  20954. module.exports = {
  20955. encode: base58.encode,
  20956. decode: base58.decode
  20957. }
  20958. /***/ },
  20959. /* 57 */
  20960. /***/ function(module, exports, __webpack_require__) {
  20961. /* WEBPACK VAR INJECTION */(function(Buffer) {var Transform = __webpack_require__(9).Transform
  20962. var inherits = __webpack_require__(2)
  20963. var StringDecoder = __webpack_require__(38).StringDecoder
  20964. module.exports = CipherBase
  20965. inherits(CipherBase, Transform)
  20966. function CipherBase (hashMode) {
  20967. Transform.call(this)
  20968. this.hashMode = typeof hashMode === 'string'
  20969. if (this.hashMode) {
  20970. this[hashMode] = this._finalOrDigest
  20971. } else {
  20972. this.final = this._finalOrDigest
  20973. }
  20974. this._decoder = null
  20975. this._encoding = null
  20976. }
  20977. CipherBase.prototype.update = function (data, inputEnc, outputEnc) {
  20978. if (typeof data === 'string') {
  20979. data = new Buffer(data, inputEnc)
  20980. }
  20981. var outData = this._update(data)
  20982. if (this.hashMode) {
  20983. return this
  20984. }
  20985. if (outputEnc) {
  20986. outData = this._toString(outData, outputEnc)
  20987. }
  20988. return outData
  20989. }
  20990. CipherBase.prototype.setAutoPadding = function () {}
  20991. CipherBase.prototype.getAuthTag = function () {
  20992. throw new Error('trying to get auth tag in unsupported state')
  20993. }
  20994. CipherBase.prototype.setAuthTag = function () {
  20995. throw new Error('trying to set auth tag in unsupported state')
  20996. }
  20997. CipherBase.prototype.setAAD = function () {
  20998. throw new Error('trying to set aad in unsupported state')
  20999. }
  21000. CipherBase.prototype._transform = function (data, _, next) {
  21001. var err
  21002. try {
  21003. if (this.hashMode) {
  21004. this._update(data)
  21005. } else {
  21006. this.push(this._update(data))
  21007. }
  21008. } catch (e) {
  21009. err = e
  21010. } finally {
  21011. next(err)
  21012. }
  21013. }
  21014. CipherBase.prototype._flush = function (done) {
  21015. var err
  21016. try {
  21017. this.push(this._final())
  21018. } catch (e) {
  21019. err = e
  21020. } finally {
  21021. done(err)
  21022. }
  21023. }
  21024. CipherBase.prototype._finalOrDigest = function (outputEnc) {
  21025. var outData = this._final() || new Buffer('')
  21026. if (outputEnc) {
  21027. outData = this._toString(outData, outputEnc, true)
  21028. }
  21029. return outData
  21030. }
  21031. CipherBase.prototype._toString = function (value, enc, final) {
  21032. if (!this._decoder) {
  21033. this._decoder = new StringDecoder(enc)
  21034. this._encoding = enc
  21035. }
  21036. if (this._encoding !== enc) {
  21037. throw new Error('can\'t switch encodings')
  21038. }
  21039. var out = this._decoder.write(value)
  21040. if (final) {
  21041. out += this._decoder.end()
  21042. }
  21043. return out
  21044. }
  21045. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  21046. /***/ },
  21047. /* 58 */
  21048. /***/ function(module, exports, __webpack_require__) {
  21049. // 22.1.3.31 Array.prototype[@@unscopables]
  21050. var UNSCOPABLES = __webpack_require__(8)('unscopables')
  21051. , ArrayProto = Array.prototype;
  21052. if(ArrayProto[UNSCOPABLES] == undefined)__webpack_require__(19)(ArrayProto, UNSCOPABLES, {});
  21053. module.exports = function(key){
  21054. ArrayProto[UNSCOPABLES][key] = true;
  21055. };
  21056. /***/ },
  21057. /* 59 */
  21058. /***/ function(module, exports, __webpack_require__) {
  21059. // getting tag from 19.1.3.6 Object.prototype.toString()
  21060. var cof = __webpack_require__(27)
  21061. , TAG = __webpack_require__(8)('toStringTag')
  21062. // ES3 wrong here
  21063. , ARG = cof(function(){ return arguments; }()) == 'Arguments';
  21064. // fallback for IE11 Script Access Denied error
  21065. var tryGet = function(it, key){
  21066. try {
  21067. return it[key];
  21068. } catch(e){ /* empty */ }
  21069. };
  21070. module.exports = function(it){
  21071. var O, T, B;
  21072. return it === undefined ? 'Undefined' : it === null ? 'Null'
  21073. // @@toStringTag case
  21074. : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T
  21075. // builtinTag case
  21076. : ARG ? cof(O)
  21077. // ES3 arguments fallback
  21078. : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
  21079. };
  21080. /***/ },
  21081. /* 60 */
  21082. /***/ function(module, exports, __webpack_require__) {
  21083. var ctx = __webpack_require__(35)
  21084. , call = __webpack_require__(177)
  21085. , isArrayIter = __webpack_require__(111)
  21086. , anObject = __webpack_require__(3)
  21087. , toLength = __webpack_require__(15)
  21088. , getIterFn = __webpack_require__(128)
  21089. , BREAK = {}
  21090. , RETURN = {};
  21091. var exports = module.exports = function(iterable, entries, fn, that, ITERATOR){
  21092. var iterFn = ITERATOR ? function(){ return iterable; } : getIterFn(iterable)
  21093. , f = ctx(fn, that, entries ? 2 : 1)
  21094. , index = 0
  21095. , length, step, iterator, result;
  21096. if(typeof iterFn != 'function')throw TypeError(iterable + ' is not iterable!');
  21097. // fast case for arrays with default iterator
  21098. if(isArrayIter(iterFn))for(length = toLength(iterable.length); length > index; index++){
  21099. result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
  21100. if(result === BREAK || result === RETURN)return result;
  21101. } else for(iterator = iterFn.call(iterable); !(step = iterator.next()).done; ){
  21102. result = call(iterator, f, step.value, entries);
  21103. if(result === BREAK || result === RETURN)return result;
  21104. }
  21105. };
  21106. exports.BREAK = BREAK;
  21107. exports.RETURN = RETURN;
  21108. /***/ },
  21109. /* 61 */
  21110. /***/ function(module, exports, __webpack_require__) {
  21111. var def = __webpack_require__(11).f
  21112. , has = __webpack_require__(17)
  21113. , TAG = __webpack_require__(8)('toStringTag');
  21114. module.exports = function(it, tag, stat){
  21115. if(it && !has(it = stat ? it : it.prototype, TAG))def(it, TAG, {configurable: true, value: tag});
  21116. };
  21117. /***/ },
  21118. /* 62 */
  21119. /***/ function(module, exports, __webpack_require__) {
  21120. var $export = __webpack_require__(0)
  21121. , defined = __webpack_require__(28)
  21122. , fails = __webpack_require__(6)
  21123. , spaces = __webpack_require__(124)
  21124. , space = '[' + spaces + ']'
  21125. , non = '\u200b\u0085'
  21126. , ltrim = RegExp('^' + space + space + '*')
  21127. , rtrim = RegExp(space + space + '*$');
  21128. var exporter = function(KEY, exec, ALIAS){
  21129. var exp = {};
  21130. var FORCE = fails(function(){
  21131. return !!spaces[KEY]() || non[KEY]() != non;
  21132. });
  21133. var fn = exp[KEY] = FORCE ? exec(trim) : spaces[KEY];
  21134. if(ALIAS)exp[ALIAS] = fn;
  21135. $export($export.P + $export.F * FORCE, 'String', exp);
  21136. };
  21137. // 1 -> String#trimLeft
  21138. // 2 -> String#trimRight
  21139. // 3 -> String#trim
  21140. var trim = exporter.trim = function(string, TYPE){
  21141. string = String(defined(string));
  21142. if(TYPE & 1)string = string.replace(ltrim, '');
  21143. if(TYPE & 2)string = string.replace(rtrim, '');
  21144. return string;
  21145. };
  21146. module.exports = exporter;
  21147. /***/ },
  21148. /* 63 */
  21149. /***/ function(module, exports, __webpack_require__) {
  21150. "use strict";
  21151. /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
  21152. var inherits = __webpack_require__(2)
  21153. var md5 = __webpack_require__(195)
  21154. var rmd160 = __webpack_require__(554)
  21155. var sha = __webpack_require__(556)
  21156. var Base = __webpack_require__(57)
  21157. function HashNoConstructor(hash) {
  21158. Base.call(this, 'digest')
  21159. this._hash = hash
  21160. this.buffers = []
  21161. }
  21162. inherits(HashNoConstructor, Base)
  21163. HashNoConstructor.prototype._update = function (data) {
  21164. this.buffers.push(data)
  21165. }
  21166. HashNoConstructor.prototype._final = function () {
  21167. var buf = Buffer.concat(this.buffers)
  21168. var r = this._hash(buf)
  21169. this.buffers = null
  21170. return r
  21171. }
  21172. function Hash(hash) {
  21173. Base.call(this, 'digest')
  21174. this._hash = hash
  21175. }
  21176. inherits(Hash, Base)
  21177. Hash.prototype._update = function (data) {
  21178. this._hash.update(data)
  21179. }
  21180. Hash.prototype._final = function () {
  21181. return this._hash.digest()
  21182. }
  21183. module.exports = function createHash (alg) {
  21184. alg = alg.toLowerCase()
  21185. if ('md5' === alg) return new HashNoConstructor(md5)
  21186. if ('rmd160' === alg || 'ripemd160' === alg) return new HashNoConstructor(rmd160)
  21187. return new Hash(sha(alg))
  21188. }
  21189. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  21190. /***/ },
  21191. /* 64 */
  21192. /***/ function(module, exports, __webpack_require__) {
  21193. "use strict";
  21194. /* WEBPACK VAR INJECTION */(function(process) {'use strict';
  21195. if (!process.version ||
  21196. process.version.indexOf('v0.') === 0 ||
  21197. process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
  21198. module.exports = nextTick;
  21199. } else {
  21200. module.exports = process.nextTick;
  21201. }
  21202. function nextTick(fn, arg1, arg2, arg3) {
  21203. if (typeof fn !== 'function') {
  21204. throw new TypeError('"callback" argument must be a function');
  21205. }
  21206. var len = arguments.length;
  21207. var args, i;
  21208. switch (len) {
  21209. case 0:
  21210. case 1:
  21211. return process.nextTick(fn);
  21212. case 2:
  21213. return process.nextTick(function afterTickOne() {
  21214. fn.call(null, arg1);
  21215. });
  21216. case 3:
  21217. return process.nextTick(function afterTickTwo() {
  21218. fn.call(null, arg1, arg2);
  21219. });
  21220. case 4:
  21221. return process.nextTick(function afterTickThree() {
  21222. fn.call(null, arg1, arg2, arg3);
  21223. });
  21224. default:
  21225. args = new Array(len - 1);
  21226. i = 0;
  21227. while (i < args.length) {
  21228. args[i++] = arguments[i];
  21229. }
  21230. return process.nextTick(function afterTick() {
  21231. fn.apply(null, args);
  21232. });
  21233. }
  21234. }
  21235. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  21236. /***/ },
  21237. /* 65 */
  21238. /***/ function(module, exports, __webpack_require__) {
  21239. /* WEBPACK VAR INJECTION */(function(Buffer) {// prototype class for hash functions
  21240. function Hash (blockSize, finalSize) {
  21241. this._block = new Buffer(blockSize)
  21242. this._finalSize = finalSize
  21243. this._blockSize = blockSize
  21244. this._len = 0
  21245. this._s = 0
  21246. }
  21247. Hash.prototype.update = function (data, enc) {
  21248. if (typeof data === 'string') {
  21249. enc = enc || 'utf8'
  21250. data = new Buffer(data, enc)
  21251. }
  21252. var l = this._len += data.length
  21253. var s = this._s || 0
  21254. var f = 0
  21255. var buffer = this._block
  21256. while (s < l) {
  21257. var t = Math.min(data.length, f + this._blockSize - (s % this._blockSize))
  21258. var ch = (t - f)
  21259. for (var i = 0; i < ch; i++) {
  21260. buffer[(s % this._blockSize) + i] = data[i + f]
  21261. }
  21262. s += ch
  21263. f += ch
  21264. if ((s % this._blockSize) === 0) {
  21265. this._update(buffer)
  21266. }
  21267. }
  21268. this._s = s
  21269. return this
  21270. }
  21271. Hash.prototype.digest = function (enc) {
  21272. // Suppose the length of the message M, in bits, is l
  21273. var l = this._len * 8
  21274. // Append the bit 1 to the end of the message
  21275. this._block[this._len % this._blockSize] = 0x80
  21276. // and then k zero bits, where k is the smallest non-negative solution to the equation (l + 1 + k) === finalSize mod blockSize
  21277. this._block.fill(0, this._len % this._blockSize + 1)
  21278. if (l % (this._blockSize * 8) >= this._finalSize * 8) {
  21279. this._update(this._block)
  21280. this._block.fill(0)
  21281. }
  21282. // to this append the block which is equal to the number l written in binary
  21283. // TODO: handle case where l is > Math.pow(2, 29)
  21284. this._block.writeInt32BE(l, this._blockSize - 4)
  21285. var hash = this._update(this._block) || this._hash()
  21286. return enc ? hash.toString(enc) : hash
  21287. }
  21288. Hash.prototype._update = function () {
  21289. throw new Error('_update must be implemented by subclass')
  21290. }
  21291. module.exports = Hash
  21292. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  21293. /***/ },
  21294. /* 66 */
  21295. /***/ function(module, exports, __webpack_require__) {
  21296. "use strict";
  21297. // a duplex stream is just a stream that is both readable and writable.
  21298. // Since JS doesn't have multiple prototypal inheritance, this class
  21299. // prototypally inherits from Readable, and then parasitically from
  21300. // Writable.
  21301. 'use strict';
  21302. /*<replacement>*/
  21303. var objectKeys = Object.keys || function (obj) {
  21304. var keys = [];
  21305. for (var key in obj) {
  21306. keys.push(key);
  21307. }return keys;
  21308. };
  21309. /*</replacement>*/
  21310. module.exports = Duplex;
  21311. /*<replacement>*/
  21312. var processNextTick = __webpack_require__(64);
  21313. /*</replacement>*/
  21314. /*<replacement>*/
  21315. var util = __webpack_require__(14);
  21316. util.inherits = __webpack_require__(2);
  21317. /*</replacement>*/
  21318. var Readable = __webpack_require__(222);
  21319. var Writable = __webpack_require__(224);
  21320. util.inherits(Duplex, Readable);
  21321. var keys = objectKeys(Writable.prototype);
  21322. for (var v = 0; v < keys.length; v++) {
  21323. var method = keys[v];
  21324. if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
  21325. }
  21326. function Duplex(options) {
  21327. if (!(this instanceof Duplex)) return new Duplex(options);
  21328. Readable.call(this, options);
  21329. Writable.call(this, options);
  21330. if (options && options.readable === false) this.readable = false;
  21331. if (options && options.writable === false) this.writable = false;
  21332. this.allowHalfOpen = true;
  21333. if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
  21334. this.once('end', onend);
  21335. }
  21336. // the no-half-open enforcer
  21337. function onend() {
  21338. // if we allow half-open state, or if the writable side ended,
  21339. // then we're ok.
  21340. if (this.allowHalfOpen || this._writableState.ended) return;
  21341. // no more data can be written.
  21342. // But allow more writes to happen in this tick.
  21343. processNextTick(onEndNT, this);
  21344. }
  21345. function onEndNT(self) {
  21346. self.end();
  21347. }
  21348. function forEach(xs, f) {
  21349. for (var i = 0, l = xs.length; i < l; i++) {
  21350. f(xs[i], i);
  21351. }
  21352. }
  21353. /***/ },
  21354. /* 67 */
  21355. /***/ function(module, exports, __webpack_require__) {
  21356. var base = exports;
  21357. base.Reporter = __webpack_require__(237).Reporter;
  21358. base.DecoderBuffer = __webpack_require__(140).DecoderBuffer;
  21359. base.EncoderBuffer = __webpack_require__(140).EncoderBuffer;
  21360. base.Node = __webpack_require__(236);
  21361. /***/ },
  21362. /* 68 */
  21363. /***/ function(module, exports, __webpack_require__) {
  21364. "use strict";
  21365. /* WEBPACK VAR INJECTION */(function(Buffer, process) {'use strict';
  21366. // Load modules
  21367. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
  21368. var Crypto = __webpack_require__(131);
  21369. var Path = __webpack_require__(43);
  21370. var Util = __webpack_require__(44);
  21371. var Escape = __webpack_require__(243);
  21372. // Declare internals
  21373. var internals = {};
  21374. // Clone object or array
  21375. exports.clone = function (obj, seen) {
  21376. if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object' || obj === null) {
  21377. return obj;
  21378. }
  21379. seen = seen || new Map();
  21380. var lookup = seen.get(obj);
  21381. if (lookup) {
  21382. return lookup;
  21383. }
  21384. var newObj = void 0;
  21385. var cloneDeep = false;
  21386. if (!Array.isArray(obj)) {
  21387. if (Buffer.isBuffer(obj)) {
  21388. newObj = new Buffer(obj);
  21389. } else if (obj instanceof Date) {
  21390. newObj = new Date(obj.getTime());
  21391. } else if (obj instanceof RegExp) {
  21392. newObj = new RegExp(obj);
  21393. } else {
  21394. var proto = Object.getPrototypeOf(obj);
  21395. if (proto && proto.isImmutable) {
  21396. newObj = obj;
  21397. } else {
  21398. newObj = Object.create(proto);
  21399. cloneDeep = true;
  21400. }
  21401. }
  21402. } else {
  21403. newObj = [];
  21404. cloneDeep = true;
  21405. }
  21406. seen.set(obj, newObj);
  21407. if (cloneDeep) {
  21408. var keys = Object.getOwnPropertyNames(obj);
  21409. for (var i = 0; i < keys.length; ++i) {
  21410. var key = keys[i];
  21411. var descriptor = Object.getOwnPropertyDescriptor(obj, key);
  21412. if (descriptor && (descriptor.get || descriptor.set)) {
  21413. Object.defineProperty(newObj, key, descriptor);
  21414. } else {
  21415. newObj[key] = exports.clone(obj[key], seen);
  21416. }
  21417. }
  21418. }
  21419. return newObj;
  21420. };
  21421. // Merge all the properties of source into target, source wins in conflict, and by default null and undefined from source are applied
  21422. /*eslint-disable */
  21423. exports.merge = function (target, source, isNullOverride /* = true */, isMergeArrays /* = true */) {
  21424. /*eslint-enable */
  21425. exports.assert(target && (typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object', 'Invalid target value: must be an object');
  21426. exports.assert(source === null || source === undefined || (typeof source === 'undefined' ? 'undefined' : _typeof(source)) === 'object', 'Invalid source value: must be null, undefined, or an object');
  21427. if (!source) {
  21428. return target;
  21429. }
  21430. if (Array.isArray(source)) {
  21431. exports.assert(Array.isArray(target), 'Cannot merge array onto an object');
  21432. if (isMergeArrays === false) {
  21433. // isMergeArrays defaults to true
  21434. target.length = 0; // Must not change target assignment
  21435. }
  21436. for (var i = 0; i < source.length; ++i) {
  21437. target.push(exports.clone(source[i]));
  21438. }
  21439. return target;
  21440. }
  21441. var keys = Object.keys(source);
  21442. for (var _i = 0; _i < keys.length; ++_i) {
  21443. var key = keys[_i];
  21444. var value = source[key];
  21445. if (value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') {
  21446. if (!target[key] || _typeof(target[key]) !== 'object' || Array.isArray(target[key]) !== Array.isArray(value) || value instanceof Date || Buffer.isBuffer(value) || value instanceof RegExp) {
  21447. target[key] = exports.clone(value);
  21448. } else {
  21449. exports.merge(target[key], value, isNullOverride, isMergeArrays);
  21450. }
  21451. } else {
  21452. if (value !== null && value !== undefined) {
  21453. // Explicit to preserve empty strings
  21454. target[key] = value;
  21455. } else if (isNullOverride !== false) {
  21456. // Defaults to true
  21457. target[key] = value;
  21458. }
  21459. }
  21460. }
  21461. return target;
  21462. };
  21463. // Apply options to a copy of the defaults
  21464. exports.applyToDefaults = function (defaults, options, isNullOverride) {
  21465. exports.assert(defaults && (typeof defaults === 'undefined' ? 'undefined' : _typeof(defaults)) === 'object', 'Invalid defaults value: must be an object');
  21466. exports.assert(!options || options === true || (typeof options === 'undefined' ? 'undefined' : _typeof(options)) === 'object', 'Invalid options value: must be true, falsy or an object');
  21467. if (!options) {
  21468. // If no options, return null
  21469. return null;
  21470. }
  21471. var copy = exports.clone(defaults);
  21472. if (options === true) {
  21473. // If options is set to true, use defaults
  21474. return copy;
  21475. }
  21476. return exports.merge(copy, options, isNullOverride === true, false);
  21477. };
  21478. // Clone an object except for the listed keys which are shallow copied
  21479. exports.cloneWithShallow = function (source, keys) {
  21480. if (!source || (typeof source === 'undefined' ? 'undefined' : _typeof(source)) !== 'object') {
  21481. return source;
  21482. }
  21483. var storage = internals.store(source, keys); // Move shallow copy items to storage
  21484. var copy = exports.clone(source); // Deep copy the rest
  21485. internals.restore(copy, source, storage); // Shallow copy the stored items and restore
  21486. return copy;
  21487. };
  21488. internals.store = function (source, keys) {
  21489. var storage = {};
  21490. for (var i = 0; i < keys.length; ++i) {
  21491. var key = keys[i];
  21492. var value = exports.reach(source, key);
  21493. if (value !== undefined) {
  21494. storage[key] = value;
  21495. internals.reachSet(source, key, undefined);
  21496. }
  21497. }
  21498. return storage;
  21499. };
  21500. internals.restore = function (copy, source, storage) {
  21501. var keys = Object.keys(storage);
  21502. for (var i = 0; i < keys.length; ++i) {
  21503. var key = keys[i];
  21504. internals.reachSet(copy, key, storage[key]);
  21505. internals.reachSet(source, key, storage[key]);
  21506. }
  21507. };
  21508. internals.reachSet = function (obj, key, value) {
  21509. var path = key.split('.');
  21510. var ref = obj;
  21511. for (var i = 0; i < path.length; ++i) {
  21512. var segment = path[i];
  21513. if (i + 1 === path.length) {
  21514. ref[segment] = value;
  21515. }
  21516. ref = ref[segment];
  21517. }
  21518. };
  21519. // Apply options to defaults except for the listed keys which are shallow copied from option without merging
  21520. exports.applyToDefaultsWithShallow = function (defaults, options, keys) {
  21521. exports.assert(defaults && (typeof defaults === 'undefined' ? 'undefined' : _typeof(defaults)) === 'object', 'Invalid defaults value: must be an object');
  21522. exports.assert(!options || options === true || (typeof options === 'undefined' ? 'undefined' : _typeof(options)) === 'object', 'Invalid options value: must be true, falsy or an object');
  21523. exports.assert(keys && Array.isArray(keys), 'Invalid keys');
  21524. if (!options) {
  21525. // If no options, return null
  21526. return null;
  21527. }
  21528. var copy = exports.cloneWithShallow(defaults, keys);
  21529. if (options === true) {
  21530. // If options is set to true, use defaults
  21531. return copy;
  21532. }
  21533. var storage = internals.store(options, keys); // Move shallow copy items to storage
  21534. exports.merge(copy, options, false, false); // Deep copy the rest
  21535. internals.restore(copy, options, storage); // Shallow copy the stored items and restore
  21536. return copy;
  21537. };
  21538. // Deep object or array comparison
  21539. exports.deepEqual = function (obj, ref, options, seen) {
  21540. options = options || { prototype: true };
  21541. var type = typeof obj === 'undefined' ? 'undefined' : _typeof(obj);
  21542. if (type !== (typeof ref === 'undefined' ? 'undefined' : _typeof(ref))) {
  21543. return false;
  21544. }
  21545. if (type !== 'object' || obj === null || ref === null) {
  21546. if (obj === ref) {
  21547. // Copied from Deep-eql, copyright(c) 2013 Jake Luer, [email protected], MIT Licensed, https://github.com/chaijs/deep-eql
  21548. return obj !== 0 || 1 / obj === 1 / ref; // -0 / +0
  21549. }
  21550. return obj !== obj && ref !== ref; // NaN
  21551. }
  21552. seen = seen || [];
  21553. if (seen.indexOf(obj) !== -1) {
  21554. return true; // If previous comparison failed, it would have stopped execution
  21555. }
  21556. seen.push(obj);
  21557. if (Array.isArray(obj)) {
  21558. if (!Array.isArray(ref)) {
  21559. return false;
  21560. }
  21561. if (!options.part && obj.length !== ref.length) {
  21562. return false;
  21563. }
  21564. for (var i = 0; i < obj.length; ++i) {
  21565. if (options.part) {
  21566. var found = false;
  21567. for (var j = 0; j < ref.length; ++j) {
  21568. if (exports.deepEqual(obj[i], ref[j], options)) {
  21569. found = true;
  21570. break;
  21571. }
  21572. }
  21573. return found;
  21574. }
  21575. if (!exports.deepEqual(obj[i], ref[i], options)) {
  21576. return false;
  21577. }
  21578. }
  21579. return true;
  21580. }
  21581. if (Buffer.isBuffer(obj)) {
  21582. if (!Buffer.isBuffer(ref)) {
  21583. return false;
  21584. }
  21585. if (obj.length !== ref.length) {
  21586. return false;
  21587. }
  21588. for (var _i2 = 0; _i2 < obj.length; ++_i2) {
  21589. if (obj[_i2] !== ref[_i2]) {
  21590. return false;
  21591. }
  21592. }
  21593. return true;
  21594. }
  21595. if (obj instanceof Date) {
  21596. return ref instanceof Date && obj.getTime() === ref.getTime();
  21597. }
  21598. if (obj instanceof RegExp) {
  21599. return ref instanceof RegExp && obj.toString() === ref.toString();
  21600. }
  21601. if (options.prototype) {
  21602. if (Object.getPrototypeOf(obj) !== Object.getPrototypeOf(ref)) {
  21603. return false;
  21604. }
  21605. }
  21606. var keys = Object.getOwnPropertyNames(obj);
  21607. if (!options.part && keys.length !== Object.getOwnPropertyNames(ref).length) {
  21608. return false;
  21609. }
  21610. for (var _i3 = 0; _i3 < keys.length; ++_i3) {
  21611. var key = keys[_i3];
  21612. var descriptor = Object.getOwnPropertyDescriptor(obj, key);
  21613. if (descriptor.get) {
  21614. if (!exports.deepEqual(descriptor, Object.getOwnPropertyDescriptor(ref, key), options, seen)) {
  21615. return false;
  21616. }
  21617. } else if (!exports.deepEqual(obj[key], ref[key], options, seen)) {
  21618. return false;
  21619. }
  21620. }
  21621. return true;
  21622. };
  21623. // Remove duplicate items from array
  21624. exports.unique = function (array, key) {
  21625. var result = void 0;
  21626. if (key) {
  21627. (function () {
  21628. result = [];
  21629. var index = new Set();
  21630. array.forEach(function (item) {
  21631. var identifier = item[key];
  21632. if (!index.has(identifier)) {
  21633. index.add(identifier);
  21634. result.push(item);
  21635. }
  21636. });
  21637. })();
  21638. } else {
  21639. result = Array.from(new Set(array));
  21640. }
  21641. return result;
  21642. };
  21643. // Convert array into object
  21644. exports.mapToObject = function (array, key) {
  21645. if (!array) {
  21646. return null;
  21647. }
  21648. var obj = {};
  21649. for (var i = 0; i < array.length; ++i) {
  21650. if (key) {
  21651. if (array[i][key]) {
  21652. obj[array[i][key]] = true;
  21653. }
  21654. } else {
  21655. obj[array[i]] = true;
  21656. }
  21657. }
  21658. return obj;
  21659. };
  21660. // Find the common unique items in two arrays
  21661. exports.intersect = function (array1, array2, justFirst) {
  21662. if (!array1 || !array2) {
  21663. return [];
  21664. }
  21665. var common = [];
  21666. var hash = Array.isArray(array1) ? exports.mapToObject(array1) : array1;
  21667. var found = {};
  21668. for (var i = 0; i < array2.length; ++i) {
  21669. if (hash[array2[i]] && !found[array2[i]]) {
  21670. if (justFirst) {
  21671. return array2[i];
  21672. }
  21673. common.push(array2[i]);
  21674. found[array2[i]] = true;
  21675. }
  21676. }
  21677. return justFirst ? null : common;
  21678. };
  21679. // Test if the reference contains the values
  21680. exports.contain = function (ref, values, options) {
  21681. /*
  21682. string -> string(s)
  21683. array -> item(s)
  21684. object -> key(s)
  21685. object -> object (key:value)
  21686. */
  21687. var valuePairs = null;
  21688. if ((typeof ref === 'undefined' ? 'undefined' : _typeof(ref)) === 'object' && (typeof values === 'undefined' ? 'undefined' : _typeof(values)) === 'object' && !Array.isArray(ref) && !Array.isArray(values)) {
  21689. valuePairs = values;
  21690. values = Object.keys(values);
  21691. } else {
  21692. values = [].concat(values);
  21693. }
  21694. options = options || {}; // deep, once, only, part
  21695. exports.assert(arguments.length >= 2, 'Insufficient arguments');
  21696. exports.assert(typeof ref === 'string' || (typeof ref === 'undefined' ? 'undefined' : _typeof(ref)) === 'object', 'Reference must be string or an object');
  21697. exports.assert(values.length, 'Values array cannot be empty');
  21698. var compare = void 0;
  21699. var compareFlags = void 0;
  21700. if (options.deep) {
  21701. compare = exports.deepEqual;
  21702. var hasOnly = options.hasOwnProperty('only');
  21703. var hasPart = options.hasOwnProperty('part');
  21704. compareFlags = {
  21705. prototype: hasOnly ? options.only : hasPart ? !options.part : false,
  21706. part: hasOnly ? !options.only : hasPart ? options.part : true
  21707. };
  21708. } else {
  21709. compare = function compare(a, b) {
  21710. return a === b;
  21711. };
  21712. }
  21713. var misses = false;
  21714. var matches = new Array(values.length);
  21715. for (var i = 0; i < matches.length; ++i) {
  21716. matches[i] = 0;
  21717. }
  21718. if (typeof ref === 'string') {
  21719. var pattern = '(';
  21720. for (var _i4 = 0; _i4 < values.length; ++_i4) {
  21721. var value = values[_i4];
  21722. exports.assert(typeof value === 'string', 'Cannot compare string reference to non-string value');
  21723. pattern += (_i4 ? '|' : '') + exports.escapeRegex(value);
  21724. }
  21725. var regex = new RegExp(pattern + ')', 'g');
  21726. var leftovers = ref.replace(regex, function ($0, $1) {
  21727. var index = values.indexOf($1);
  21728. ++matches[index];
  21729. return ''; // Remove from string
  21730. });
  21731. misses = !!leftovers;
  21732. } else if (Array.isArray(ref)) {
  21733. for (var _i5 = 0; _i5 < ref.length; ++_i5) {
  21734. var matched = false;
  21735. for (var j = 0; j < values.length && matched === false; ++j) {
  21736. matched = compare(values[j], ref[_i5], compareFlags) && j;
  21737. }
  21738. if (matched !== false) {
  21739. ++matches[matched];
  21740. } else {
  21741. misses = true;
  21742. }
  21743. }
  21744. } else {
  21745. var keys = Object.keys(ref);
  21746. for (var _i6 = 0; _i6 < keys.length; ++_i6) {
  21747. var key = keys[_i6];
  21748. var pos = values.indexOf(key);
  21749. if (pos !== -1) {
  21750. if (valuePairs && !compare(valuePairs[key], ref[key], compareFlags)) {
  21751. return false;
  21752. }
  21753. ++matches[pos];
  21754. } else {
  21755. misses = true;
  21756. }
  21757. }
  21758. }
  21759. var result = false;
  21760. for (var _i7 = 0; _i7 < matches.length; ++_i7) {
  21761. result = result || !!matches[_i7];
  21762. if (options.once && matches[_i7] > 1 || !options.part && !matches[_i7]) {
  21763. return false;
  21764. }
  21765. }
  21766. if (options.only && misses) {
  21767. return false;
  21768. }
  21769. return result;
  21770. };
  21771. // Flatten array
  21772. exports.flatten = function (array, target) {
  21773. var result = target || [];
  21774. for (var i = 0; i < array.length; ++i) {
  21775. if (Array.isArray(array[i])) {
  21776. exports.flatten(array[i], result);
  21777. } else {
  21778. result.push(array[i]);
  21779. }
  21780. }
  21781. return result;
  21782. };
  21783. // Convert an object key chain string ('a.b.c') to reference (object[a][b][c])
  21784. exports.reach = function (obj, chain, options) {
  21785. if (chain === false || chain === null || typeof chain === 'undefined') {
  21786. return obj;
  21787. }
  21788. options = options || {};
  21789. if (typeof options === 'string') {
  21790. options = { separator: options };
  21791. }
  21792. var path = chain.split(options.separator || '.');
  21793. var ref = obj;
  21794. for (var i = 0; i < path.length; ++i) {
  21795. var key = path[i];
  21796. if (key[0] === '-' && Array.isArray(ref)) {
  21797. key = key.slice(1, key.length);
  21798. key = ref.length - key;
  21799. }
  21800. if (!ref || !(((typeof ref === 'undefined' ? 'undefined' : _typeof(ref)) === 'object' || typeof ref === 'function') && key in ref) || (typeof ref === 'undefined' ? 'undefined' : _typeof(ref)) !== 'object' && options.functions === false) {
  21801. // Only object and function can have properties
  21802. exports.assert(!options.strict || i + 1 === path.length, 'Missing segment', key, 'in reach path ', chain);
  21803. exports.assert((typeof ref === 'undefined' ? 'undefined' : _typeof(ref)) === 'object' || options.functions === true || typeof ref !== 'function', 'Invalid segment', key, 'in reach path ', chain);
  21804. ref = options.default;
  21805. break;
  21806. }
  21807. ref = ref[key];
  21808. }
  21809. return ref;
  21810. };
  21811. exports.reachTemplate = function (obj, template, options) {
  21812. return template.replace(/{([^}]+)}/g, function ($0, chain) {
  21813. var value = exports.reach(obj, chain, options);
  21814. return value === undefined || value === null ? '' : value;
  21815. });
  21816. };
  21817. exports.formatStack = function (stack) {
  21818. var trace = [];
  21819. for (var i = 0; i < stack.length; ++i) {
  21820. var item = stack[i];
  21821. trace.push([item.getFileName(), item.getLineNumber(), item.getColumnNumber(), item.getFunctionName(), item.isConstructor()]);
  21822. }
  21823. return trace;
  21824. };
  21825. exports.formatTrace = function (trace) {
  21826. var display = [];
  21827. for (var i = 0; i < trace.length; ++i) {
  21828. var row = trace[i];
  21829. display.push((row[4] ? 'new ' : '') + row[3] + ' (' + row[0] + ':' + row[1] + ':' + row[2] + ')');
  21830. }
  21831. return display;
  21832. };
  21833. exports.callStack = function (slice) {
  21834. // http://code.google.com/p/v8/wiki/JavaScriptStackTraceApi
  21835. var v8 = Error.prepareStackTrace;
  21836. Error.prepareStackTrace = function (_, stack) {
  21837. return stack;
  21838. };
  21839. var capture = {};
  21840. Error.captureStackTrace(capture, this); // arguments.callee is not supported in strict mode so we use this and slice the trace of this off the result
  21841. var stack = capture.stack;
  21842. Error.prepareStackTrace = v8;
  21843. var trace = exports.formatStack(stack);
  21844. return trace.slice(1 + slice);
  21845. };
  21846. exports.displayStack = function (slice) {
  21847. var trace = exports.callStack(slice === undefined ? 1 : slice + 1);
  21848. return exports.formatTrace(trace);
  21849. };
  21850. exports.abortThrow = false;
  21851. exports.abort = function (message, hideStack) {
  21852. if (process.env.NODE_ENV === 'test' || exports.abortThrow === true) {
  21853. throw new Error(message || 'Unknown error');
  21854. }
  21855. var stack = '';
  21856. if (!hideStack) {
  21857. stack = exports.displayStack(1).join('\n\t');
  21858. }
  21859. console.log('ABORT: ' + message + '\n\t' + stack);
  21860. process.exit(1);
  21861. };
  21862. exports.assert = function (condition /*, msg1, msg2, msg3 */) {
  21863. if (condition) {
  21864. return;
  21865. }
  21866. if (arguments.length === 2 && arguments[1] instanceof Error) {
  21867. throw arguments[1];
  21868. }
  21869. var msgs = [];
  21870. for (var i = 1; i < arguments.length; ++i) {
  21871. if (arguments[i] !== '') {
  21872. msgs.push(arguments[i]); // Avoids Array.slice arguments leak, allowing for V8 optimizations
  21873. }
  21874. }
  21875. msgs = msgs.map(function (msg) {
  21876. return typeof msg === 'string' ? msg : msg instanceof Error ? msg.message : exports.stringify(msg);
  21877. });
  21878. throw new Error(msgs.join(' ') || 'Unknown error');
  21879. };
  21880. exports.Timer = function () {
  21881. this.ts = 0;
  21882. this.reset();
  21883. };
  21884. exports.Timer.prototype.reset = function () {
  21885. this.ts = Date.now();
  21886. };
  21887. exports.Timer.prototype.elapsed = function () {
  21888. return Date.now() - this.ts;
  21889. };
  21890. exports.Bench = function () {
  21891. this.ts = 0;
  21892. this.reset();
  21893. };
  21894. exports.Bench.prototype.reset = function () {
  21895. this.ts = exports.Bench.now();
  21896. };
  21897. exports.Bench.prototype.elapsed = function () {
  21898. return exports.Bench.now() - this.ts;
  21899. };
  21900. exports.Bench.now = function () {
  21901. var ts = process.hrtime();
  21902. return ts[0] * 1e3 + ts[1] / 1e6;
  21903. };
  21904. // Escape string for Regex construction
  21905. exports.escapeRegex = function (string) {
  21906. // Escape ^$.*+-?=!:|\/()[]{},
  21907. return string.replace(/[\^\$\.\*\+\-\?\=\!\:\|\\\/\(\)\[\]\{\}\,]/g, '\\$&');
  21908. };
  21909. // Base64url (RFC 4648) encode
  21910. exports.base64urlEncode = function (value, encoding) {
  21911. exports.assert(typeof value === 'string' || Buffer.isBuffer(value), 'value must be string or buffer');
  21912. var buf = Buffer.isBuffer(value) ? value : new Buffer(value, encoding || 'binary');
  21913. return buf.toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/\=/g, '');
  21914. };
  21915. // Base64url (RFC 4648) decode
  21916. exports.base64urlDecode = function (value, encoding) {
  21917. if (typeof value !== 'string') {
  21918. return new Error('Value not a string');
  21919. }
  21920. if (!/^[\w\-]*$/.test(value)) {
  21921. return new Error('Invalid character');
  21922. }
  21923. var buf = new Buffer(value, 'base64');
  21924. return encoding === 'buffer' ? buf : buf.toString(encoding || 'binary');
  21925. };
  21926. // Escape attribute value for use in HTTP header
  21927. exports.escapeHeaderAttribute = function (attribute) {
  21928. // Allowed value characters: !#$%&'()*+,-./:;<=>?@[]^_`{|}~ and space, a-z, A-Z, 0-9, \, "
  21929. exports.assert(/^[ \w\!#\$%&'\(\)\*\+,\-\.\/\:;<\=>\?@\[\]\^`\{\|\}~\"\\]*$/.test(attribute), 'Bad attribute value (' + attribute + ')');
  21930. return attribute.replace(/\\/g, '\\\\').replace(/\"/g, '\\"'); // Escape quotes and slash
  21931. };
  21932. exports.escapeHtml = function (string) {
  21933. return Escape.escapeHtml(string);
  21934. };
  21935. exports.escapeJavaScript = function (string) {
  21936. return Escape.escapeJavaScript(string);
  21937. };
  21938. exports.nextTick = function (callback) {
  21939. return function () {
  21940. var args = arguments;
  21941. process.nextTick(function () {
  21942. callback.apply(null, args);
  21943. });
  21944. };
  21945. };
  21946. exports.once = function (method) {
  21947. if (method._hoekOnce) {
  21948. return method;
  21949. }
  21950. var once = false;
  21951. var wrapped = function wrapped() {
  21952. if (!once) {
  21953. once = true;
  21954. method.apply(null, arguments);
  21955. }
  21956. };
  21957. wrapped._hoekOnce = true;
  21958. return wrapped;
  21959. };
  21960. exports.isInteger = function (value) {
  21961. return typeof value === 'number' && parseFloat(value) === parseInt(value, 10) && !isNaN(value);
  21962. };
  21963. exports.ignore = function () {};
  21964. exports.inherits = Util.inherits;
  21965. exports.format = Util.format;
  21966. exports.transform = function (source, transform, options) {
  21967. exports.assert(source === null || source === undefined || (typeof source === 'undefined' ? 'undefined' : _typeof(source)) === 'object' || Array.isArray(source), 'Invalid source object: must be null, undefined, an object, or an array');
  21968. var separator = (typeof options === 'undefined' ? 'undefined' : _typeof(options)) === 'object' && options !== null ? options.separator || '.' : '.';
  21969. if (Array.isArray(source)) {
  21970. var results = [];
  21971. for (var i = 0; i < source.length; ++i) {
  21972. results.push(exports.transform(source[i], transform, options));
  21973. }
  21974. return results;
  21975. }
  21976. var result = {};
  21977. var keys = Object.keys(transform);
  21978. for (var _i8 = 0; _i8 < keys.length; ++_i8) {
  21979. var key = keys[_i8];
  21980. var path = key.split(separator);
  21981. var sourcePath = transform[key];
  21982. exports.assert(typeof sourcePath === 'string', 'All mappings must be "." delineated strings');
  21983. var segment = void 0;
  21984. var res = result;
  21985. while (path.length > 1) {
  21986. segment = path.shift();
  21987. if (!res[segment]) {
  21988. res[segment] = {};
  21989. }
  21990. res = res[segment];
  21991. }
  21992. segment = path.shift();
  21993. res[segment] = exports.reach(source, sourcePath, options);
  21994. }
  21995. return result;
  21996. };
  21997. exports.uniqueFilename = function (path, extension) {
  21998. if (extension) {
  21999. extension = extension[0] !== '.' ? '.' + extension : extension;
  22000. } else {
  22001. extension = '';
  22002. }
  22003. path = Path.resolve(path);
  22004. var name = [Date.now(), process.pid, Crypto.randomBytes(8).toString('hex')].join('-') + extension;
  22005. return Path.join(path, name);
  22006. };
  22007. exports.stringify = function () {
  22008. try {
  22009. return JSON.stringify.apply(null, arguments);
  22010. } catch (err) {
  22011. return '[Cannot display object: ' + err.message + ']';
  22012. }
  22013. };
  22014. exports.shallow = function (source) {
  22015. var target = {};
  22016. var keys = Object.keys(source);
  22017. for (var i = 0; i < keys.length; ++i) {
  22018. var key = keys[i];
  22019. target[key] = source[key];
  22020. }
  22021. return target;
  22022. };
  22023. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer, __webpack_require__(4)))
  22024. /***/ },
  22025. /* 69 */
  22026. /***/ function(module, exports, __webpack_require__) {
  22027. /* WEBPACK VAR INJECTION */(function(Buffer) {module.exports = function xor (a, b) {
  22028. var length = Math.min(a.length, b.length)
  22029. var buffer = new Buffer(length)
  22030. for (var i = 0; i < length; ++i) {
  22031. buffer[i] = a[i] ^ b[i]
  22032. }
  22033. return buffer
  22034. }
  22035. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  22036. /***/ },
  22037. /* 70 */
  22038. /***/ function(module, exports, __webpack_require__) {
  22039. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  22040. var cof = __webpack_require__(27);
  22041. module.exports = Object('z').propertyIsEnumerable(0) ? Object : function(it){
  22042. return cof(it) == 'String' ? it.split('') : Object(it);
  22043. };
  22044. /***/ },
  22045. /* 71 */
  22046. /***/ function(module, exports) {
  22047. exports.f = {}.propertyIsEnumerable;
  22048. /***/ },
  22049. /* 72 */
  22050. /***/ function(module, exports) {
  22051. module.exports = assert;
  22052. function assert(val, msg) {
  22053. if (!val)
  22054. throw new Error(msg || 'Assertion failed');
  22055. }
  22056. assert.equal = function assertEqual(l, r, msg) {
  22057. if (l != r)
  22058. throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
  22059. };
  22060. /***/ },
  22061. /* 73 */
  22062. /***/ function(module, exports, __webpack_require__) {
  22063. "use strict";
  22064. /* WEBPACK VAR INJECTION */(function(global, Buffer, process) {'use strict'
  22065. function oldBrowser () {
  22066. throw new Error('secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11')
  22067. }
  22068. var crypto = global.crypto || global.msCrypto
  22069. if (crypto && crypto.getRandomValues) {
  22070. module.exports = randomBytes
  22071. } else {
  22072. module.exports = oldBrowser
  22073. }
  22074. function randomBytes (size, cb) {
  22075. // phantomjs needs to throw
  22076. if (size > 65536) throw new Error('requested too many random bytes')
  22077. // in case browserify isn't using the Uint8Array version
  22078. var rawBytes = new global.Uint8Array(size)
  22079. // This will not work in older browsers.
  22080. // See https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues
  22081. if (size > 0) { // getRandomValues fails on IE if size == 0
  22082. crypto.getRandomValues(rawBytes)
  22083. }
  22084. // phantomjs doesn't like a buffer being passed here
  22085. var bytes = new Buffer(rawBytes.buffer)
  22086. if (typeof cb === 'function') {
  22087. return process.nextTick(function () {
  22088. cb(null, bytes)
  22089. })
  22090. }
  22091. return bytes
  22092. }
  22093. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(13), __webpack_require__(1).Buffer, __webpack_require__(4)))
  22094. /***/ },
  22095. /* 74 */
  22096. /***/ function(module, exports, __webpack_require__) {
  22097. /* WEBPACK VAR INJECTION */(function(setImmediate, clearImmediate) {var nextTick = __webpack_require__(4).nextTick;
  22098. var apply = Function.prototype.apply;
  22099. var slice = Array.prototype.slice;
  22100. var immediateIds = {};
  22101. var nextImmediateId = 0;
  22102. // DOM APIs, for completeness
  22103. exports.setTimeout = function() {
  22104. return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
  22105. };
  22106. exports.setInterval = function() {
  22107. return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
  22108. };
  22109. exports.clearTimeout =
  22110. exports.clearInterval = function(timeout) { timeout.close(); };
  22111. function Timeout(id, clearFn) {
  22112. this._id = id;
  22113. this._clearFn = clearFn;
  22114. }
  22115. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  22116. Timeout.prototype.close = function() {
  22117. this._clearFn.call(window, this._id);
  22118. };
  22119. // Does not start the time, just sets up the members needed.
  22120. exports.enroll = function(item, msecs) {
  22121. clearTimeout(item._idleTimeoutId);
  22122. item._idleTimeout = msecs;
  22123. };
  22124. exports.unenroll = function(item) {
  22125. clearTimeout(item._idleTimeoutId);
  22126. item._idleTimeout = -1;
  22127. };
  22128. exports._unrefActive = exports.active = function(item) {
  22129. clearTimeout(item._idleTimeoutId);
  22130. var msecs = item._idleTimeout;
  22131. if (msecs >= 0) {
  22132. item._idleTimeoutId = setTimeout(function onTimeout() {
  22133. if (item._onTimeout)
  22134. item._onTimeout();
  22135. }, msecs);
  22136. }
  22137. };
  22138. // That's not how node.js implements it but the exposed api is the same.
  22139. exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) {
  22140. var id = nextImmediateId++;
  22141. var args = arguments.length < 2 ? false : slice.call(arguments, 1);
  22142. immediateIds[id] = true;
  22143. nextTick(function onNextTick() {
  22144. if (immediateIds[id]) {
  22145. // fn.call() is faster so we optimize for the common use-case
  22146. // @see http://jsperf.com/call-apply-segu
  22147. if (args) {
  22148. fn.apply(null, args);
  22149. } else {
  22150. fn.call(null);
  22151. }
  22152. // Prevent ids from leaking
  22153. exports.clearImmediate(id);
  22154. }
  22155. });
  22156. return id;
  22157. };
  22158. exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) {
  22159. delete immediateIds[id];
  22160. };
  22161. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(74).setImmediate, __webpack_require__(74).clearImmediate))
  22162. /***/ },
  22163. /* 75 */
  22164. /***/ function(module, exports, __webpack_require__) {
  22165. module.exports = {
  22166. encode: __webpack_require__(581)
  22167. , decode: __webpack_require__(580)
  22168. , encodingLength: __webpack_require__(582)
  22169. }
  22170. /***/ },
  22171. /* 76 */
  22172. /***/ function(module, exports) {
  22173. module.exports = function(module) {
  22174. if(!module.webpackPolyfill) {
  22175. module.deprecate = function() {};
  22176. module.paths = [];
  22177. // module.parent = undefined by default
  22178. if(!module.children) module.children = [];
  22179. Object.defineProperty(module, "loaded", {
  22180. enumerable: true,
  22181. configurable: false,
  22182. get: function() { return module.l; }
  22183. });
  22184. Object.defineProperty(module, "id", {
  22185. enumerable: true,
  22186. configurable: false,
  22187. get: function() { return module.i; }
  22188. });
  22189. module.webpackPolyfill = 1;
  22190. }
  22191. return module;
  22192. }
  22193. /***/ },
  22194. /* 77 */
  22195. /***/ function(module, exports, __webpack_require__) {
  22196. var asn1 = exports;
  22197. asn1.bignum = __webpack_require__(12);
  22198. asn1.define = __webpack_require__(235).define;
  22199. asn1.base = __webpack_require__(67);
  22200. asn1.constants = __webpack_require__(141);
  22201. asn1.decoders = __webpack_require__(239);
  22202. asn1.encoders = __webpack_require__(241);
  22203. /***/ },
  22204. /* 78 */
  22205. /***/ function(module, exports) {
  22206. "use strict";
  22207. /** PROMISIFY CALLBACK-STYLE FUNCTIONS TO ES6 PROMISES
  22208. *
  22209. * EXAMPLE:
  22210. * const fn = promisify( (callback) => callback(null, "Hello world!") );
  22211. * fn((err, str) => console.log(str));
  22212. * fn().then((str) => console.log(str));
  22213. * //Both functions, will log 'Hello world!'
  22214. *
  22215. * Note: The function you pass, may have any arguments you want, but the latest
  22216. * have to be the callback, which you will call with: next(err, value)
  22217. *
  22218. * @param method: Function/Array/Map = The function(s) to promisify
  22219. * @param options: Map =
  22220. * "context" (default is function): The context which to apply the called function
  22221. * "replace" (default is falsy): When passed an array/map, if to replace the original object
  22222. *
  22223. * @return: A promise if passed a function, otherwise the object with the promises
  22224. *
  22225. * @license: MIT
  22226. * @version: 1.0.1
  22227. * @author: Manuel Di Iorio
  22228. **/
  22229. "use strict";
  22230. var createCallback = function createCallback(method, context) {
  22231. return function () {
  22232. var args = Array.prototype.slice.call(arguments);
  22233. return new Promise(function (solve, reject) {
  22234. args.push(function (err, val) {
  22235. if (err) return reject(err);
  22236. solve(val);
  22237. });
  22238. method.apply(context, args);
  22239. });
  22240. };
  22241. };
  22242. module.exports = function (methods, options) {
  22243. options = options || {};
  22244. var type = Object.prototype.toString.call(methods);
  22245. if (type === "[object Object]" || type === "[object Array]") {
  22246. var obj = options.replace ? methods : {};
  22247. for (var key in methods) {
  22248. if (methods.hasOwnProperty(key)) obj[key] = createCallback(methods[key]);
  22249. }return obj;
  22250. }
  22251. return createCallback(methods, options.context || methods);
  22252. };
  22253. /***/ },
  22254. /* 79 */
  22255. /***/ function(module, exports, __webpack_require__) {
  22256. /* WEBPACK VAR INJECTION */(function(Buffer) {// based on the aes implimentation in triple sec
  22257. // https://github.com/keybase/triplesec
  22258. // which is in turn based on the one from crypto-js
  22259. // https://code.google.com/p/crypto-js/
  22260. var uint_max = Math.pow(2, 32)
  22261. function fixup_uint32 (x) {
  22262. var ret, x_pos
  22263. ret = x > uint_max || x < 0 ? (x_pos = Math.abs(x) % uint_max, x < 0 ? uint_max - x_pos : x_pos) : x
  22264. return ret
  22265. }
  22266. function scrub_vec (v) {
  22267. for (var i = 0; i < v.length; v++) {
  22268. v[i] = 0
  22269. }
  22270. return false
  22271. }
  22272. function Global () {
  22273. this.SBOX = []
  22274. this.INV_SBOX = []
  22275. this.SUB_MIX = [[], [], [], []]
  22276. this.INV_SUB_MIX = [[], [], [], []]
  22277. this.init()
  22278. this.RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36]
  22279. }
  22280. Global.prototype.init = function () {
  22281. var d, i, sx, t, x, x2, x4, x8, xi, _i
  22282. d = (function () {
  22283. var _i, _results
  22284. _results = []
  22285. for (i = _i = 0; _i < 256; i = ++_i) {
  22286. if (i < 128) {
  22287. _results.push(i << 1)
  22288. } else {
  22289. _results.push((i << 1) ^ 0x11b)
  22290. }
  22291. }
  22292. return _results
  22293. })()
  22294. x = 0
  22295. xi = 0
  22296. for (i = _i = 0; _i < 256; i = ++_i) {
  22297. sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4)
  22298. sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63
  22299. this.SBOX[x] = sx
  22300. this.INV_SBOX[sx] = x
  22301. x2 = d[x]
  22302. x4 = d[x2]
  22303. x8 = d[x4]
  22304. t = (d[sx] * 0x101) ^ (sx * 0x1010100)
  22305. this.SUB_MIX[0][x] = (t << 24) | (t >>> 8)
  22306. this.SUB_MIX[1][x] = (t << 16) | (t >>> 16)
  22307. this.SUB_MIX[2][x] = (t << 8) | (t >>> 24)
  22308. this.SUB_MIX[3][x] = t
  22309. t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100)
  22310. this.INV_SUB_MIX[0][sx] = (t << 24) | (t >>> 8)
  22311. this.INV_SUB_MIX[1][sx] = (t << 16) | (t >>> 16)
  22312. this.INV_SUB_MIX[2][sx] = (t << 8) | (t >>> 24)
  22313. this.INV_SUB_MIX[3][sx] = t
  22314. if (x === 0) {
  22315. x = xi = 1
  22316. } else {
  22317. x = x2 ^ d[d[d[x8 ^ x2]]]
  22318. xi ^= d[d[xi]]
  22319. }
  22320. }
  22321. return true
  22322. }
  22323. var G = new Global()
  22324. AES.blockSize = 4 * 4
  22325. AES.prototype.blockSize = AES.blockSize
  22326. AES.keySize = 256 / 8
  22327. AES.prototype.keySize = AES.keySize
  22328. function bufferToArray (buf) {
  22329. var len = buf.length / 4
  22330. var out = new Array(len)
  22331. var i = -1
  22332. while (++i < len) {
  22333. out[i] = buf.readUInt32BE(i * 4)
  22334. }
  22335. return out
  22336. }
  22337. function AES (key) {
  22338. this._key = bufferToArray(key)
  22339. this._doReset()
  22340. }
  22341. AES.prototype._doReset = function () {
  22342. var invKsRow, keySize, keyWords, ksRow, ksRows, t
  22343. keyWords = this._key
  22344. keySize = keyWords.length
  22345. this._nRounds = keySize + 6
  22346. ksRows = (this._nRounds + 1) * 4
  22347. this._keySchedule = []
  22348. for (ksRow = 0; ksRow < ksRows; ksRow++) {
  22349. this._keySchedule[ksRow] = ksRow < keySize ? keyWords[ksRow] : (t = this._keySchedule[ksRow - 1], (ksRow % keySize) === 0 ? (t = (t << 8) | (t >>> 24), t = (G.SBOX[t >>> 24] << 24) | (G.SBOX[(t >>> 16) & 0xff] << 16) | (G.SBOX[(t >>> 8) & 0xff] << 8) | G.SBOX[t & 0xff], t ^= G.RCON[(ksRow / keySize) | 0] << 24) : keySize > 6 && ksRow % keySize === 4 ? t = (G.SBOX[t >>> 24] << 24) | (G.SBOX[(t >>> 16) & 0xff] << 16) | (G.SBOX[(t >>> 8) & 0xff] << 8) | G.SBOX[t & 0xff] : void 0, this._keySchedule[ksRow - keySize] ^ t)
  22350. }
  22351. this._invKeySchedule = []
  22352. for (invKsRow = 0; invKsRow < ksRows; invKsRow++) {
  22353. ksRow = ksRows - invKsRow
  22354. t = this._keySchedule[ksRow - (invKsRow % 4 ? 0 : 4)]
  22355. this._invKeySchedule[invKsRow] = invKsRow < 4 || ksRow <= 4 ? t : G.INV_SUB_MIX[0][G.SBOX[t >>> 24]] ^ G.INV_SUB_MIX[1][G.SBOX[(t >>> 16) & 0xff]] ^ G.INV_SUB_MIX[2][G.SBOX[(t >>> 8) & 0xff]] ^ G.INV_SUB_MIX[3][G.SBOX[t & 0xff]]
  22356. }
  22357. return true
  22358. }
  22359. AES.prototype.encryptBlock = function (M) {
  22360. M = bufferToArray(new Buffer(M))
  22361. var out = this._doCryptBlock(M, this._keySchedule, G.SUB_MIX, G.SBOX)
  22362. var buf = new Buffer(16)
  22363. buf.writeUInt32BE(out[0], 0)
  22364. buf.writeUInt32BE(out[1], 4)
  22365. buf.writeUInt32BE(out[2], 8)
  22366. buf.writeUInt32BE(out[3], 12)
  22367. return buf
  22368. }
  22369. AES.prototype.decryptBlock = function (M) {
  22370. M = bufferToArray(new Buffer(M))
  22371. var temp = [M[3], M[1]]
  22372. M[1] = temp[0]
  22373. M[3] = temp[1]
  22374. var out = this._doCryptBlock(M, this._invKeySchedule, G.INV_SUB_MIX, G.INV_SBOX)
  22375. var buf = new Buffer(16)
  22376. buf.writeUInt32BE(out[0], 0)
  22377. buf.writeUInt32BE(out[3], 4)
  22378. buf.writeUInt32BE(out[2], 8)
  22379. buf.writeUInt32BE(out[1], 12)
  22380. return buf
  22381. }
  22382. AES.prototype.scrub = function () {
  22383. scrub_vec(this._keySchedule)
  22384. scrub_vec(this._invKeySchedule)
  22385. scrub_vec(this._key)
  22386. }
  22387. AES.prototype._doCryptBlock = function (M, keySchedule, SUB_MIX, SBOX) {
  22388. var ksRow, s0, s1, s2, s3, t0, t1, t2, t3
  22389. s0 = M[0] ^ keySchedule[0]
  22390. s1 = M[1] ^ keySchedule[1]
  22391. s2 = M[2] ^ keySchedule[2]
  22392. s3 = M[3] ^ keySchedule[3]
  22393. ksRow = 4
  22394. for (var round = 1; round < this._nRounds; round++) {
  22395. t0 = SUB_MIX[0][s0 >>> 24] ^ SUB_MIX[1][(s1 >>> 16) & 0xff] ^ SUB_MIX[2][(s2 >>> 8) & 0xff] ^ SUB_MIX[3][s3 & 0xff] ^ keySchedule[ksRow++]
  22396. t1 = SUB_MIX[0][s1 >>> 24] ^ SUB_MIX[1][(s2 >>> 16) & 0xff] ^ SUB_MIX[2][(s3 >>> 8) & 0xff] ^ SUB_MIX[3][s0 & 0xff] ^ keySchedule[ksRow++]
  22397. t2 = SUB_MIX[0][s2 >>> 24] ^ SUB_MIX[1][(s3 >>> 16) & 0xff] ^ SUB_MIX[2][(s0 >>> 8) & 0xff] ^ SUB_MIX[3][s1 & 0xff] ^ keySchedule[ksRow++]
  22398. t3 = SUB_MIX[0][s3 >>> 24] ^ SUB_MIX[1][(s0 >>> 16) & 0xff] ^ SUB_MIX[2][(s1 >>> 8) & 0xff] ^ SUB_MIX[3][s2 & 0xff] ^ keySchedule[ksRow++]
  22399. s0 = t0
  22400. s1 = t1
  22401. s2 = t2
  22402. s3 = t3
  22403. }
  22404. t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++]
  22405. t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++]
  22406. t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++]
  22407. t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++]
  22408. return [
  22409. fixup_uint32(t0),
  22410. fixup_uint32(t1),
  22411. fixup_uint32(t2),
  22412. fixup_uint32(t3)
  22413. ]
  22414. }
  22415. exports.AES = AES
  22416. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  22417. /***/ },
  22418. /* 80 */
  22419. /***/ function(module, exports) {
  22420. exports['aes-128-ecb'] = {
  22421. cipher: 'AES',
  22422. key: 128,
  22423. iv: 0,
  22424. mode: 'ECB',
  22425. type: 'block'
  22426. }
  22427. exports['aes-192-ecb'] = {
  22428. cipher: 'AES',
  22429. key: 192,
  22430. iv: 0,
  22431. mode: 'ECB',
  22432. type: 'block'
  22433. }
  22434. exports['aes-256-ecb'] = {
  22435. cipher: 'AES',
  22436. key: 256,
  22437. iv: 0,
  22438. mode: 'ECB',
  22439. type: 'block'
  22440. }
  22441. exports['aes-128-cbc'] = {
  22442. cipher: 'AES',
  22443. key: 128,
  22444. iv: 16,
  22445. mode: 'CBC',
  22446. type: 'block'
  22447. }
  22448. exports['aes-192-cbc'] = {
  22449. cipher: 'AES',
  22450. key: 192,
  22451. iv: 16,
  22452. mode: 'CBC',
  22453. type: 'block'
  22454. }
  22455. exports['aes-256-cbc'] = {
  22456. cipher: 'AES',
  22457. key: 256,
  22458. iv: 16,
  22459. mode: 'CBC',
  22460. type: 'block'
  22461. }
  22462. exports['aes128'] = exports['aes-128-cbc']
  22463. exports['aes192'] = exports['aes-192-cbc']
  22464. exports['aes256'] = exports['aes-256-cbc']
  22465. exports['aes-128-cfb'] = {
  22466. cipher: 'AES',
  22467. key: 128,
  22468. iv: 16,
  22469. mode: 'CFB',
  22470. type: 'stream'
  22471. }
  22472. exports['aes-192-cfb'] = {
  22473. cipher: 'AES',
  22474. key: 192,
  22475. iv: 16,
  22476. mode: 'CFB',
  22477. type: 'stream'
  22478. }
  22479. exports['aes-256-cfb'] = {
  22480. cipher: 'AES',
  22481. key: 256,
  22482. iv: 16,
  22483. mode: 'CFB',
  22484. type: 'stream'
  22485. }
  22486. exports['aes-128-cfb8'] = {
  22487. cipher: 'AES',
  22488. key: 128,
  22489. iv: 16,
  22490. mode: 'CFB8',
  22491. type: 'stream'
  22492. }
  22493. exports['aes-192-cfb8'] = {
  22494. cipher: 'AES',
  22495. key: 192,
  22496. iv: 16,
  22497. mode: 'CFB8',
  22498. type: 'stream'
  22499. }
  22500. exports['aes-256-cfb8'] = {
  22501. cipher: 'AES',
  22502. key: 256,
  22503. iv: 16,
  22504. mode: 'CFB8',
  22505. type: 'stream'
  22506. }
  22507. exports['aes-128-cfb1'] = {
  22508. cipher: 'AES',
  22509. key: 128,
  22510. iv: 16,
  22511. mode: 'CFB1',
  22512. type: 'stream'
  22513. }
  22514. exports['aes-192-cfb1'] = {
  22515. cipher: 'AES',
  22516. key: 192,
  22517. iv: 16,
  22518. mode: 'CFB1',
  22519. type: 'stream'
  22520. }
  22521. exports['aes-256-cfb1'] = {
  22522. cipher: 'AES',
  22523. key: 256,
  22524. iv: 16,
  22525. mode: 'CFB1',
  22526. type: 'stream'
  22527. }
  22528. exports['aes-128-ofb'] = {
  22529. cipher: 'AES',
  22530. key: 128,
  22531. iv: 16,
  22532. mode: 'OFB',
  22533. type: 'stream'
  22534. }
  22535. exports['aes-192-ofb'] = {
  22536. cipher: 'AES',
  22537. key: 192,
  22538. iv: 16,
  22539. mode: 'OFB',
  22540. type: 'stream'
  22541. }
  22542. exports['aes-256-ofb'] = {
  22543. cipher: 'AES',
  22544. key: 256,
  22545. iv: 16,
  22546. mode: 'OFB',
  22547. type: 'stream'
  22548. }
  22549. exports['aes-128-ctr'] = {
  22550. cipher: 'AES',
  22551. key: 128,
  22552. iv: 16,
  22553. mode: 'CTR',
  22554. type: 'stream'
  22555. }
  22556. exports['aes-192-ctr'] = {
  22557. cipher: 'AES',
  22558. key: 192,
  22559. iv: 16,
  22560. mode: 'CTR',
  22561. type: 'stream'
  22562. }
  22563. exports['aes-256-ctr'] = {
  22564. cipher: 'AES',
  22565. key: 256,
  22566. iv: 16,
  22567. mode: 'CTR',
  22568. type: 'stream'
  22569. }
  22570. exports['aes-128-gcm'] = {
  22571. cipher: 'AES',
  22572. key: 128,
  22573. iv: 12,
  22574. mode: 'GCM',
  22575. type: 'auth'
  22576. }
  22577. exports['aes-192-gcm'] = {
  22578. cipher: 'AES',
  22579. key: 192,
  22580. iv: 12,
  22581. mode: 'GCM',
  22582. type: 'auth'
  22583. }
  22584. exports['aes-256-gcm'] = {
  22585. cipher: 'AES',
  22586. key: 256,
  22587. iv: 12,
  22588. mode: 'GCM',
  22589. type: 'auth'
  22590. }
  22591. /***/ },
  22592. /* 81 */
  22593. /***/ function(module, exports, __webpack_require__) {
  22594. /* WEBPACK VAR INJECTION */(function(Buffer) {var xor = __webpack_require__(69)
  22595. function incr32 (iv) {
  22596. var len = iv.length
  22597. var item
  22598. while (len--) {
  22599. item = iv.readUInt8(len)
  22600. if (item === 255) {
  22601. iv.writeUInt8(0, len)
  22602. } else {
  22603. item++
  22604. iv.writeUInt8(item, len)
  22605. break
  22606. }
  22607. }
  22608. }
  22609. function getBlock (self) {
  22610. var out = self._cipher.encryptBlock(self._prev)
  22611. incr32(self._prev)
  22612. return out
  22613. }
  22614. exports.encrypt = function (self, chunk) {
  22615. while (self._cache.length < chunk.length) {
  22616. self._cache = Buffer.concat([self._cache, getBlock(self)])
  22617. }
  22618. var pad = self._cache.slice(0, chunk.length)
  22619. self._cache = self._cache.slice(chunk.length)
  22620. return xor(chunk, pad)
  22621. }
  22622. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  22623. /***/ },
  22624. /* 82 */
  22625. /***/ function(module, exports, __webpack_require__) {
  22626. // false -> Array#indexOf
  22627. // true -> Array#includes
  22628. var toIObject = __webpack_require__(24)
  22629. , toLength = __webpack_require__(15)
  22630. , toIndex = __webpack_require__(52);
  22631. module.exports = function(IS_INCLUDES){
  22632. return function($this, el, fromIndex){
  22633. var O = toIObject($this)
  22634. , length = toLength(O.length)
  22635. , index = toIndex(fromIndex, length)
  22636. , value;
  22637. // Array#includes uses SameValueZero equality algorithm
  22638. if(IS_INCLUDES && el != el)while(length > index){
  22639. value = O[index++];
  22640. if(value != value)return true;
  22641. // Array#toIndex ignores holes, Array#includes - not
  22642. } else for(;length > index; index++)if(IS_INCLUDES || index in O){
  22643. if(O[index] === el)return IS_INCLUDES || index || 0;
  22644. } return !IS_INCLUDES && -1;
  22645. };
  22646. };
  22647. /***/ },
  22648. /* 83 */
  22649. /***/ function(module, exports, __webpack_require__) {
  22650. "use strict";
  22651. 'use strict';
  22652. var global = __webpack_require__(5)
  22653. , $export = __webpack_require__(0)
  22654. , redefine = __webpack_require__(22)
  22655. , redefineAll = __webpack_require__(50)
  22656. , meta = __webpack_require__(40)
  22657. , forOf = __webpack_require__(60)
  22658. , anInstance = __webpack_require__(39)
  22659. , isObject = __webpack_require__(7)
  22660. , fails = __webpack_require__(6)
  22661. , $iterDetect = __webpack_require__(88)
  22662. , setToStringTag = __webpack_require__(61)
  22663. , inheritIfRequired = __webpack_require__(110);
  22664. module.exports = function(NAME, wrapper, methods, common, IS_MAP, IS_WEAK){
  22665. var Base = global[NAME]
  22666. , C = Base
  22667. , ADDER = IS_MAP ? 'set' : 'add'
  22668. , proto = C && C.prototype
  22669. , O = {};
  22670. var fixMethod = function(KEY){
  22671. var fn = proto[KEY];
  22672. redefine(proto, KEY,
  22673. KEY == 'delete' ? function(a){
  22674. return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
  22675. } : KEY == 'has' ? function has(a){
  22676. return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
  22677. } : KEY == 'get' ? function get(a){
  22678. return IS_WEAK && !isObject(a) ? undefined : fn.call(this, a === 0 ? 0 : a);
  22679. } : KEY == 'add' ? function add(a){ fn.call(this, a === 0 ? 0 : a); return this; }
  22680. : function set(a, b){ fn.call(this, a === 0 ? 0 : a, b); return this; }
  22681. );
  22682. };
  22683. if(typeof C != 'function' || !(IS_WEAK || proto.forEach && !fails(function(){
  22684. new C().entries().next();
  22685. }))){
  22686. // create collection constructor
  22687. C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
  22688. redefineAll(C.prototype, methods);
  22689. meta.NEED = true;
  22690. } else {
  22691. var instance = new C
  22692. // early implementations not supports chaining
  22693. , HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance
  22694. // V8 ~ Chromium 40- weak-collections throws on primitives, but should return false
  22695. , THROWS_ON_PRIMITIVES = fails(function(){ instance.has(1); })
  22696. // most early implementations doesn't supports iterables, most modern - not close it correctly
  22697. , ACCEPT_ITERABLES = $iterDetect(function(iter){ new C(iter); }) // eslint-disable-line no-new
  22698. // for early implementations -0 and +0 not the same
  22699. , BUGGY_ZERO = !IS_WEAK && fails(function(){
  22700. // V8 ~ Chromium 42- fails only with 5+ elements
  22701. var $instance = new C()
  22702. , index = 5;
  22703. while(index--)$instance[ADDER](index, index);
  22704. return !$instance.has(-0);
  22705. });
  22706. if(!ACCEPT_ITERABLES){
  22707. C = wrapper(function(target, iterable){
  22708. anInstance(target, C, NAME);
  22709. var that = inheritIfRequired(new Base, target, C);
  22710. if(iterable != undefined)forOf(iterable, IS_MAP, that[ADDER], that);
  22711. return that;
  22712. });
  22713. C.prototype = proto;
  22714. proto.constructor = C;
  22715. }
  22716. if(THROWS_ON_PRIMITIVES || BUGGY_ZERO){
  22717. fixMethod('delete');
  22718. fixMethod('has');
  22719. IS_MAP && fixMethod('get');
  22720. }
  22721. if(BUGGY_ZERO || HASNT_CHAINING)fixMethod(ADDER);
  22722. // weak collections should not contains .clear method
  22723. if(IS_WEAK && proto.clear)delete proto.clear;
  22724. }
  22725. setToStringTag(C, NAME);
  22726. O[NAME] = C;
  22727. $export($export.G + $export.W + $export.F * (C != Base), O);
  22728. if(!IS_WEAK)common.setStrong(C, NAME, IS_MAP);
  22729. return C;
  22730. };
  22731. /***/ },
  22732. /* 84 */
  22733. /***/ function(module, exports, __webpack_require__) {
  22734. "use strict";
  22735. 'use strict';
  22736. var hide = __webpack_require__(19)
  22737. , redefine = __webpack_require__(22)
  22738. , fails = __webpack_require__(6)
  22739. , defined = __webpack_require__(28)
  22740. , wks = __webpack_require__(8);
  22741. module.exports = function(KEY, length, exec){
  22742. var SYMBOL = wks(KEY)
  22743. , fns = exec(defined, SYMBOL, ''[KEY])
  22744. , strfn = fns[0]
  22745. , rxfn = fns[1];
  22746. if(fails(function(){
  22747. var O = {};
  22748. O[SYMBOL] = function(){ return 7; };
  22749. return ''[KEY](O) != 7;
  22750. })){
  22751. redefine(String.prototype, KEY, strfn);
  22752. hide(RegExp.prototype, SYMBOL, length == 2
  22753. // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
  22754. // 21.2.5.11 RegExp.prototype[@@split](string, limit)
  22755. ? function(string, arg){ return rxfn.call(string, this, arg); }
  22756. // 21.2.5.6 RegExp.prototype[@@match](string)
  22757. // 21.2.5.9 RegExp.prototype[@@search](string)
  22758. : function(string){ return rxfn.call(string, this); }
  22759. );
  22760. }
  22761. };
  22762. /***/ },
  22763. /* 85 */
  22764. /***/ function(module, exports, __webpack_require__) {
  22765. "use strict";
  22766. 'use strict';
  22767. // 21.2.5.3 get RegExp.prototype.flags
  22768. var anObject = __webpack_require__(3);
  22769. module.exports = function(){
  22770. var that = anObject(this)
  22771. , result = '';
  22772. if(that.global) result += 'g';
  22773. if(that.ignoreCase) result += 'i';
  22774. if(that.multiline) result += 'm';
  22775. if(that.unicode) result += 'u';
  22776. if(that.sticky) result += 'y';
  22777. return result;
  22778. };
  22779. /***/ },
  22780. /* 86 */
  22781. /***/ function(module, exports) {
  22782. // fast apply, http://jsperf.lnkit.com/fast-apply/5
  22783. module.exports = function(fn, args, that){
  22784. var un = that === undefined;
  22785. switch(args.length){
  22786. case 0: return un ? fn()
  22787. : fn.call(that);
  22788. case 1: return un ? fn(args[0])
  22789. : fn.call(that, args[0]);
  22790. case 2: return un ? fn(args[0], args[1])
  22791. : fn.call(that, args[0], args[1]);
  22792. case 3: return un ? fn(args[0], args[1], args[2])
  22793. : fn.call(that, args[0], args[1], args[2]);
  22794. case 4: return un ? fn(args[0], args[1], args[2], args[3])
  22795. : fn.call(that, args[0], args[1], args[2], args[3]);
  22796. } return fn.apply(that, args);
  22797. };
  22798. /***/ },
  22799. /* 87 */
  22800. /***/ function(module, exports, __webpack_require__) {
  22801. // 7.2.8 IsRegExp(argument)
  22802. var isObject = __webpack_require__(7)
  22803. , cof = __webpack_require__(27)
  22804. , MATCH = __webpack_require__(8)('match');
  22805. module.exports = function(it){
  22806. var isRegExp;
  22807. return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : cof(it) == 'RegExp');
  22808. };
  22809. /***/ },
  22810. /* 88 */
  22811. /***/ function(module, exports, __webpack_require__) {
  22812. var ITERATOR = __webpack_require__(8)('iterator')
  22813. , SAFE_CLOSING = false;
  22814. try {
  22815. var riter = [7][ITERATOR]();
  22816. riter['return'] = function(){ SAFE_CLOSING = true; };
  22817. Array.from(riter, function(){ throw 2; });
  22818. } catch(e){ /* empty */ }
  22819. module.exports = function(exec, skipClosing){
  22820. if(!skipClosing && !SAFE_CLOSING)return false;
  22821. var safe = false;
  22822. try {
  22823. var arr = [7]
  22824. , iter = arr[ITERATOR]();
  22825. iter.next = function(){ return {done: safe = true}; };
  22826. arr[ITERATOR] = function(){ return iter; };
  22827. exec(arr);
  22828. } catch(e){ /* empty */ }
  22829. return safe;
  22830. };
  22831. /***/ },
  22832. /* 89 */
  22833. /***/ function(module, exports, __webpack_require__) {
  22834. // Forced replacement prototype accessors methods
  22835. module.exports = __webpack_require__(46)|| !__webpack_require__(6)(function(){
  22836. var K = Math.random();
  22837. // In FF throws only define methods
  22838. __defineSetter__.call(null, K, function(){ /* empty */});
  22839. delete __webpack_require__(5)[K];
  22840. });
  22841. /***/ },
  22842. /* 90 */
  22843. /***/ function(module, exports) {
  22844. exports.f = Object.getOwnPropertySymbols;
  22845. /***/ },
  22846. /* 91 */
  22847. /***/ function(module, exports, __webpack_require__) {
  22848. // Works with __proto__ only. Old v8 can't work with null proto objects.
  22849. /* eslint-disable no-proto */
  22850. var isObject = __webpack_require__(7)
  22851. , anObject = __webpack_require__(3);
  22852. var check = function(O, proto){
  22853. anObject(O);
  22854. if(!isObject(proto) && proto !== null)throw TypeError(proto + ": can't set as prototype!");
  22855. };
  22856. module.exports = {
  22857. set: Object.setPrototypeOf || ('__proto__' in {} ? // eslint-disable-line
  22858. function(test, buggy, set){
  22859. try {
  22860. set = __webpack_require__(35)(Function.call, __webpack_require__(25).f(Object.prototype, '__proto__').set, 2);
  22861. set(test, []);
  22862. buggy = !(test instanceof Array);
  22863. } catch(e){ buggy = true; }
  22864. return function setPrototypeOf(O, proto){
  22865. check(O, proto);
  22866. if(buggy)O.__proto__ = proto;
  22867. else set(O, proto);
  22868. return O;
  22869. };
  22870. }({}, false) : undefined),
  22871. check: check
  22872. };
  22873. /***/ },
  22874. /* 92 */
  22875. /***/ function(module, exports, __webpack_require__) {
  22876. var global = __webpack_require__(5)
  22877. , SHARED = '__core-js_shared__'
  22878. , store = global[SHARED] || (global[SHARED] = {});
  22879. module.exports = function(key){
  22880. return store[key] || (store[key] = {});
  22881. };
  22882. /***/ },
  22883. /* 93 */
  22884. /***/ function(module, exports, __webpack_require__) {
  22885. var global = __webpack_require__(5)
  22886. , hide = __webpack_require__(19)
  22887. , uid = __webpack_require__(53)
  22888. , TYPED = uid('typed_array')
  22889. , VIEW = uid('view')
  22890. , ABV = !!(global.ArrayBuffer && global.DataView)
  22891. , CONSTR = ABV
  22892. , i = 0, l = 9, Typed;
  22893. var TypedArrayConstructors = (
  22894. 'Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array'
  22895. ).split(',');
  22896. while(i < l){
  22897. if(Typed = global[TypedArrayConstructors[i++]]){
  22898. hide(Typed.prototype, TYPED, true);
  22899. hide(Typed.prototype, VIEW, true);
  22900. } else CONSTR = false;
  22901. }
  22902. module.exports = {
  22903. ABV: ABV,
  22904. CONSTR: CONSTR,
  22905. TYPED: TYPED,
  22906. VIEW: VIEW
  22907. };
  22908. /***/ },
  22909. /* 94 */
  22910. /***/ function(module, exports, __webpack_require__) {
  22911. "use strict";
  22912. 'use strict';
  22913. var curve = exports;
  22914. curve.base = __webpack_require__(486);
  22915. curve.short = __webpack_require__(489);
  22916. curve.mont = __webpack_require__(488);
  22917. curve.edwards = __webpack_require__(487);
  22918. /***/ },
  22919. /* 95 */
  22920. /***/ function(module, exports, __webpack_require__) {
  22921. /* WEBPACK VAR INJECTION */(function(Buffer) {var md5 = __webpack_require__(195)
  22922. module.exports = EVP_BytesToKey
  22923. function EVP_BytesToKey (password, salt, keyLen, ivLen) {
  22924. if (!Buffer.isBuffer(password)) {
  22925. password = new Buffer(password, 'binary')
  22926. }
  22927. if (salt && !Buffer.isBuffer(salt)) {
  22928. salt = new Buffer(salt, 'binary')
  22929. }
  22930. keyLen = keyLen / 8
  22931. ivLen = ivLen || 0
  22932. var ki = 0
  22933. var ii = 0
  22934. var key = new Buffer(keyLen)
  22935. var iv = new Buffer(ivLen)
  22936. var addmd = 0
  22937. var md_buf
  22938. var i
  22939. var bufs = []
  22940. while (true) {
  22941. if (addmd++ > 0) {
  22942. bufs.push(md_buf)
  22943. }
  22944. bufs.push(password)
  22945. if (salt) {
  22946. bufs.push(salt)
  22947. }
  22948. md_buf = md5(Buffer.concat(bufs))
  22949. bufs = []
  22950. i = 0
  22951. if (keyLen > 0) {
  22952. while (true) {
  22953. if (keyLen === 0) {
  22954. break
  22955. }
  22956. if (i === md_buf.length) {
  22957. break
  22958. }
  22959. key[ki++] = md_buf[i]
  22960. keyLen--
  22961. i++
  22962. }
  22963. }
  22964. if (ivLen > 0 && i !== md_buf.length) {
  22965. while (true) {
  22966. if (ivLen === 0) {
  22967. break
  22968. }
  22969. if (i === md_buf.length) {
  22970. break
  22971. }
  22972. iv[ii++] = md_buf[i]
  22973. ivLen--
  22974. i++
  22975. }
  22976. }
  22977. if (keyLen === 0 && ivLen === 0) {
  22978. break
  22979. }
  22980. }
  22981. for (i = 0; i < md_buf.length; i++) {
  22982. md_buf[i] = 0
  22983. }
  22984. return {
  22985. key: key,
  22986. iv: iv
  22987. }
  22988. }
  22989. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  22990. /***/ },
  22991. /* 96 */
  22992. /***/ function(module, exports, __webpack_require__) {
  22993. "use strict";
  22994. /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
  22995. var bs58 = __webpack_require__(56);
  22996. var cs = __webpack_require__(525);
  22997. exports.toHexString = function toHexString(m) {
  22998. if (!Buffer.isBuffer(m)) {
  22999. throw new Error('must be passed a buffer');
  23000. }
  23001. return m.toString('hex');
  23002. };
  23003. exports.fromHexString = function fromHexString(s) {
  23004. return new Buffer(s, 'hex');
  23005. };
  23006. exports.toB58String = function toB58String(m) {
  23007. if (!Buffer.isBuffer(m)) {
  23008. throw new Error('must be passed a buffer');
  23009. }
  23010. return bs58.encode(m);
  23011. };
  23012. exports.fromB58String = function fromB58String(s) {
  23013. var encoded = s;
  23014. if (Buffer.isBuffer(s)) {
  23015. encoded = s.toString();
  23016. }
  23017. return new Buffer(bs58.decode(encoded));
  23018. };
  23019. // Decode a hash from the given Multihash.
  23020. exports.decode = function decode(buf) {
  23021. exports.validate(buf);
  23022. var code = buf[0];
  23023. return {
  23024. code: code,
  23025. name: cs.codes[code],
  23026. length: buf[1],
  23027. digest: buf.slice(2)
  23028. };
  23029. };
  23030. // Encode a hash digest along with the specified function code.
  23031. // Note: the length is derived from the length of the digest itself.
  23032. exports.encode = function encode(digest, code, length) {
  23033. if (!digest || !code) {
  23034. throw new Error('multihash encode requires at least two args: digest, code');
  23035. }
  23036. // ensure it's a hashfunction code.
  23037. var hashfn = exports.coerceCode(code);
  23038. if (!Buffer.isBuffer(digest)) {
  23039. throw new Error('digest should be a Buffer');
  23040. }
  23041. if (length == null) {
  23042. length = digest.length;
  23043. }
  23044. if (length && digest.length !== length) {
  23045. throw new Error('digest length should be equal to specified length.');
  23046. }
  23047. if (length > 127) {
  23048. throw new Error('multihash does not yet support digest lengths greater than 127 bytes.');
  23049. }
  23050. return Buffer.concat([new Buffer([hashfn, length]), digest]);
  23051. };
  23052. // Converts a hashfn name into the matching code
  23053. exports.coerceCode = function coerceCode(name) {
  23054. var code = name;
  23055. if (typeof name === 'string') {
  23056. if (!cs.names[name]) {
  23057. throw new Error('Unrecognized hash function named: ' + name);
  23058. }
  23059. code = cs.names[name];
  23060. }
  23061. if (typeof code !== 'number') {
  23062. throw new Error('Hash function code should be a number. Got: ' + code);
  23063. }
  23064. if (!cs.codes[code] && !exports.isAppCode(code)) {
  23065. throw new Error('Unrecognized function code: ' + code);
  23066. }
  23067. return code;
  23068. };
  23069. // Checks wether a code is part of the app range
  23070. exports.isAppCode = function appCode(code) {
  23071. return code > 0 && code < 0x10;
  23072. };
  23073. // Checks whether a multihash code is valid.
  23074. exports.isValidCode = function validCode(code) {
  23075. if (exports.isAppCode(code)) {
  23076. return true;
  23077. }
  23078. if (cs.codes[code]) {
  23079. return true;
  23080. }
  23081. return false;
  23082. };
  23083. exports.validate = function validate(multihash) {
  23084. if (!Buffer.isBuffer(multihash)) {
  23085. throw new Error('multihash must be a Buffer');
  23086. }
  23087. if (multihash.length < 3) {
  23088. throw new Error('multihash too short. must be > 3 bytes.');
  23089. }
  23090. if (multihash.length > 129) {
  23091. throw new Error('multihash too long. must be < 129 bytes.');
  23092. }
  23093. var code = multihash[0];
  23094. if (!exports.isValidCode(code)) {
  23095. throw new Error('multihash unknown function code: 0x' + code.toString(16));
  23096. }
  23097. if (multihash.slice(2).length !== multihash[1]) {
  23098. throw new Error('multihash length inconsistent: 0x' + multihash.toString('hex'));
  23099. }
  23100. };
  23101. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  23102. /***/ },
  23103. /* 97 */
  23104. /***/ function(module, exports, __webpack_require__) {
  23105. /* WEBPACK VAR INJECTION */(function(Buffer) {var asn1 = __webpack_require__(533)
  23106. var aesid = __webpack_require__(233)
  23107. var fixProc = __webpack_require__(534)
  23108. var ciphers = __webpack_require__(102)
  23109. var compat = __webpack_require__(210)
  23110. module.exports = parseKeys
  23111. function parseKeys (buffer) {
  23112. var password
  23113. if (typeof buffer === 'object' && !Buffer.isBuffer(buffer)) {
  23114. password = buffer.passphrase
  23115. buffer = buffer.key
  23116. }
  23117. if (typeof buffer === 'string') {
  23118. buffer = new Buffer(buffer)
  23119. }
  23120. var stripped = fixProc(buffer, password)
  23121. var type = stripped.tag
  23122. var data = stripped.data
  23123. var subtype, ndata
  23124. switch (type) {
  23125. case 'PUBLIC KEY':
  23126. ndata = asn1.PublicKey.decode(data, 'der')
  23127. subtype = ndata.algorithm.algorithm.join('.')
  23128. switch (subtype) {
  23129. case '1.2.840.113549.1.1.1':
  23130. return asn1.RSAPublicKey.decode(ndata.subjectPublicKey.data, 'der')
  23131. case '1.2.840.10045.2.1':
  23132. ndata.subjectPrivateKey = ndata.subjectPublicKey
  23133. return {
  23134. type: 'ec',
  23135. data: ndata
  23136. }
  23137. case '1.2.840.10040.4.1':
  23138. ndata.algorithm.params.pub_key = asn1.DSAparam.decode(ndata.subjectPublicKey.data, 'der')
  23139. return {
  23140. type: 'dsa',
  23141. data: ndata.algorithm.params
  23142. }
  23143. default: throw new Error('unknown key id ' + subtype)
  23144. }
  23145. throw new Error('unknown key type ' + type)
  23146. case 'ENCRYPTED PRIVATE KEY':
  23147. data = asn1.EncryptedPrivateKey.decode(data, 'der')
  23148. data = decrypt(data, password)
  23149. // falls through
  23150. case 'PRIVATE KEY':
  23151. ndata = asn1.PrivateKey.decode(data, 'der')
  23152. subtype = ndata.algorithm.algorithm.join('.')
  23153. switch (subtype) {
  23154. case '1.2.840.113549.1.1.1':
  23155. return asn1.RSAPrivateKey.decode(ndata.subjectPrivateKey, 'der')
  23156. case '1.2.840.10045.2.1':
  23157. return {
  23158. curve: ndata.algorithm.curve,
  23159. privateKey: asn1.ECPrivateKey.decode(ndata.subjectPrivateKey, 'der').privateKey
  23160. }
  23161. case '1.2.840.10040.4.1':
  23162. ndata.algorithm.params.priv_key = asn1.DSAparam.decode(ndata.subjectPrivateKey, 'der')
  23163. return {
  23164. type: 'dsa',
  23165. params: ndata.algorithm.params
  23166. }
  23167. default: throw new Error('unknown key id ' + subtype)
  23168. }
  23169. throw new Error('unknown key type ' + type)
  23170. case 'RSA PUBLIC KEY':
  23171. return asn1.RSAPublicKey.decode(data, 'der')
  23172. case 'RSA PRIVATE KEY':
  23173. return asn1.RSAPrivateKey.decode(data, 'der')
  23174. case 'DSA PRIVATE KEY':
  23175. return {
  23176. type: 'dsa',
  23177. params: asn1.DSAPrivateKey.decode(data, 'der')
  23178. }
  23179. case 'EC PRIVATE KEY':
  23180. data = asn1.ECPrivateKey.decode(data, 'der')
  23181. return {
  23182. curve: data.parameters.value,
  23183. privateKey: data.privateKey
  23184. }
  23185. default: throw new Error('unknown key type ' + type)
  23186. }
  23187. }
  23188. parseKeys.signature = asn1.signature
  23189. function decrypt (data, password) {
  23190. var salt = data.algorithm.decrypt.kde.kdeparams.salt
  23191. var iters = parseInt(data.algorithm.decrypt.kde.kdeparams.iters.toString(), 10)
  23192. var algo = aesid[data.algorithm.decrypt.cipher.algo.join('.')]
  23193. var iv = data.algorithm.decrypt.cipher.iv
  23194. var cipherText = data.subjectPrivateKey
  23195. var keylen = parseInt(algo.split('-')[1], 10) / 8
  23196. var key = compat.pbkdf2Sync(password, salt, iters, keylen)
  23197. var cipher = ciphers.createDecipheriv(algo, key, iv)
  23198. var out = []
  23199. out.push(cipher.update(cipherText))
  23200. out.push(cipher.final())
  23201. return Buffer.concat(out)
  23202. }
  23203. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  23204. /***/ },
  23205. /* 98 */
  23206. /***/ function(module, exports) {
  23207. module.exports = extend
  23208. var hasOwnProperty = Object.prototype.hasOwnProperty;
  23209. function extend() {
  23210. var target = {}
  23211. for (var i = 0; i < arguments.length; i++) {
  23212. var source = arguments[i]
  23213. for (var key in source) {
  23214. if (hasOwnProperty.call(source, key)) {
  23215. target[key] = source[key]
  23216. }
  23217. }
  23218. }
  23219. return target
  23220. }
  23221. /***/ },
  23222. /* 99 */
  23223. /***/ function(module, exports, __webpack_require__) {
  23224. "use strict";
  23225. 'use strict';
  23226. exports.DAGNode = __webpack_require__(149);
  23227. exports.DAGLink = __webpack_require__(148);
  23228. exports.DAGService = __webpack_require__(246);
  23229. exports.Batch = __webpack_require__(245);
  23230. exports.util = __webpack_require__(150);
  23231. /***/ },
  23232. /* 100 */
  23233. /***/ function(module, exports, __webpack_require__) {
  23234. "use strict";
  23235. 'use strict';
  23236. var async = __webpack_require__(145);
  23237. var getDagNode = __webpack_require__(276);
  23238. // transform { Hash: '...' } objects into { path: 'string', node: DAGNode }
  23239. module.exports = function (err, res, send, done) {
  23240. if (err) {
  23241. return done(err);
  23242. }
  23243. async.map(res, function map(entry, next) {
  23244. getDagNode(send, entry.Hash, function (err, node) {
  23245. if (err) {
  23246. return next(err);
  23247. }
  23248. var obj = {
  23249. path: entry.Name,
  23250. node: node
  23251. };
  23252. next(null, obj);
  23253. });
  23254. }, function (err, res) {
  23255. done(err, res);
  23256. });
  23257. };
  23258. /***/ },
  23259. /* 101 */
  23260. /***/ function(module, exports, __webpack_require__) {
  23261. "use strict";
  23262. /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
  23263. var isStream = __webpack_require__(517);
  23264. var addToDagNodesTransform = __webpack_require__(100);
  23265. var promisify = __webpack_require__(78);
  23266. module.exports = function (send) {
  23267. return promisify(function (files, callback) {
  23268. var good = Buffer.isBuffer(files) || isStream.isReadable(files) || Array.isArray(files);
  23269. if (!good) {
  23270. callback(new Error('"files" must be a buffer, readable stream, or array of objects'));
  23271. }
  23272. var sendWithTransform = send.withTransform(addToDagNodesTransform);
  23273. sendWithTransform('add', null, {}, files, callback);
  23274. });
  23275. };
  23276. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  23277. /***/ },
  23278. /* 102 */
  23279. /***/ function(module, exports, __webpack_require__) {
  23280. var ciphers = __webpack_require__(285)
  23281. exports.createCipher = exports.Cipher = ciphers.createCipher
  23282. exports.createCipheriv = exports.Cipheriv = ciphers.createCipheriv
  23283. var deciphers = __webpack_require__(284)
  23284. exports.createDecipher = exports.Decipher = deciphers.createDecipher
  23285. exports.createDecipheriv = exports.Decipheriv = deciphers.createDecipheriv
  23286. var modes = __webpack_require__(80)
  23287. function getCiphers () {
  23288. return Object.keys(modes)
  23289. }
  23290. exports.listCiphers = exports.getCiphers = getCiphers
  23291. /***/ },
  23292. /* 103 */
  23293. /***/ function(module, exports, __webpack_require__) {
  23294. /* WEBPACK VAR INJECTION */(function(Buffer) {var bn = __webpack_require__(12);
  23295. var randomBytes = __webpack_require__(73);
  23296. module.exports = crt;
  23297. function blind(priv) {
  23298. var r = getr(priv);
  23299. var blinder = r.toRed(bn.mont(priv.modulus))
  23300. .redPow(new bn(priv.publicExponent)).fromRed();
  23301. return {
  23302. blinder: blinder,
  23303. unblinder:r.invm(priv.modulus)
  23304. };
  23305. }
  23306. function crt(msg, priv) {
  23307. var blinds = blind(priv);
  23308. var len = priv.modulus.byteLength();
  23309. var mod = bn.mont(priv.modulus);
  23310. var blinded = new bn(msg).mul(blinds.blinder).umod(priv.modulus);
  23311. var c1 = blinded.toRed(bn.mont(priv.prime1));
  23312. var c2 = blinded.toRed(bn.mont(priv.prime2));
  23313. var qinv = priv.coefficient;
  23314. var p = priv.prime1;
  23315. var q = priv.prime2;
  23316. var m1 = c1.redPow(priv.exponent1);
  23317. var m2 = c2.redPow(priv.exponent2);
  23318. m1 = m1.fromRed();
  23319. m2 = m2.fromRed();
  23320. var h = m1.isub(m2).imul(qinv).umod(p);
  23321. h.imul(q);
  23322. m2.iadd(h);
  23323. return new Buffer(m2.imul(blinds.unblinder).umod(priv.modulus).toArray(false, len));
  23324. }
  23325. crt.getr = getr;
  23326. function getr(priv) {
  23327. var len = priv.modulus.byteLength();
  23328. var r = new bn(randomBytes(len));
  23329. while (r.cmp(priv.modulus) >= 0 || !r.umod(priv.prime1) || !r.umod(priv.prime2)) {
  23330. r = new bn(randomBytes(len));
  23331. }
  23332. return r;
  23333. }
  23334. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  23335. /***/ },
  23336. /* 104 */
  23337. /***/ function(module, exports, __webpack_require__) {
  23338. "use strict";
  23339. // 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length)
  23340. 'use strict';
  23341. var toObject = __webpack_require__(16)
  23342. , toIndex = __webpack_require__(52)
  23343. , toLength = __webpack_require__(15);
  23344. module.exports = function fill(value /*, start = 0, end = @length */){
  23345. var O = toObject(this)
  23346. , length = toLength(O.length)
  23347. , aLen = arguments.length
  23348. , index = toIndex(aLen > 1 ? arguments[1] : undefined, length)
  23349. , end = aLen > 2 ? arguments[2] : undefined
  23350. , endPos = end === undefined ? length : toIndex(end, length);
  23351. while(endPos > index)O[index++] = value;
  23352. return O;
  23353. };
  23354. /***/ },
  23355. /* 105 */
  23356. /***/ function(module, exports, __webpack_require__) {
  23357. "use strict";
  23358. 'use strict';
  23359. var $defineProperty = __webpack_require__(11)
  23360. , createDesc = __webpack_require__(41);
  23361. module.exports = function(object, index, value){
  23362. if(index in object)$defineProperty.f(object, index, createDesc(0, value));
  23363. else object[index] = value;
  23364. };
  23365. /***/ },
  23366. /* 106 */
  23367. /***/ function(module, exports, __webpack_require__) {
  23368. var isObject = __webpack_require__(7)
  23369. , document = __webpack_require__(5).document
  23370. // in old IE typeof document.createElement is 'object'
  23371. , is = isObject(document) && isObject(document.createElement);
  23372. module.exports = function(it){
  23373. return is ? document.createElement(it) : {};
  23374. };
  23375. /***/ },
  23376. /* 107 */
  23377. /***/ function(module, exports) {
  23378. // IE 8- don't enum bug keys
  23379. module.exports = (
  23380. 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
  23381. ).split(',');
  23382. /***/ },
  23383. /* 108 */
  23384. /***/ function(module, exports, __webpack_require__) {
  23385. var MATCH = __webpack_require__(8)('match');
  23386. module.exports = function(KEY){
  23387. var re = /./;
  23388. try {
  23389. '/./'[KEY](re);
  23390. } catch(e){
  23391. try {
  23392. re[MATCH] = false;
  23393. return !'/./'[KEY](re);
  23394. } catch(f){ /* empty */ }
  23395. } return true;
  23396. };
  23397. /***/ },
  23398. /* 109 */
  23399. /***/ function(module, exports, __webpack_require__) {
  23400. module.exports = __webpack_require__(5).document && document.documentElement;
  23401. /***/ },
  23402. /* 110 */
  23403. /***/ function(module, exports, __webpack_require__) {
  23404. var isObject = __webpack_require__(7)
  23405. , setPrototypeOf = __webpack_require__(91).set;
  23406. module.exports = function(that, target, C){
  23407. var P, S = target.constructor;
  23408. if(S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && isObject(P) && setPrototypeOf){
  23409. setPrototypeOf(that, P);
  23410. } return that;
  23411. };
  23412. /***/ },
  23413. /* 111 */
  23414. /***/ function(module, exports, __webpack_require__) {
  23415. // check on default Array iterator
  23416. var Iterators = __webpack_require__(45)
  23417. , ITERATOR = __webpack_require__(8)('iterator')
  23418. , ArrayProto = Array.prototype;
  23419. module.exports = function(it){
  23420. return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);
  23421. };
  23422. /***/ },
  23423. /* 112 */
  23424. /***/ function(module, exports, __webpack_require__) {
  23425. // 7.2.2 IsArray(argument)
  23426. var cof = __webpack_require__(27);
  23427. module.exports = Array.isArray || function isArray(arg){
  23428. return cof(arg) == 'Array';
  23429. };
  23430. /***/ },
  23431. /* 113 */
  23432. /***/ function(module, exports, __webpack_require__) {
  23433. // 20.1.2.3 Number.isInteger(number)
  23434. var isObject = __webpack_require__(7)
  23435. , floor = Math.floor;
  23436. module.exports = function isInteger(it){
  23437. return !isObject(it) && isFinite(it) && floor(it) === it;
  23438. };
  23439. /***/ },
  23440. /* 114 */
  23441. /***/ function(module, exports, __webpack_require__) {
  23442. "use strict";
  23443. 'use strict';
  23444. var create = __webpack_require__(47)
  23445. , descriptor = __webpack_require__(41)
  23446. , setToStringTag = __webpack_require__(61)
  23447. , IteratorPrototype = {};
  23448. // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
  23449. __webpack_require__(19)(IteratorPrototype, __webpack_require__(8)('iterator'), function(){ return this; });
  23450. module.exports = function(Constructor, NAME, next){
  23451. Constructor.prototype = create(IteratorPrototype, {next: descriptor(1, next)});
  23452. setToStringTag(Constructor, NAME + ' Iterator');
  23453. };
  23454. /***/ },
  23455. /* 115 */
  23456. /***/ function(module, exports, __webpack_require__) {
  23457. "use strict";
  23458. 'use strict';
  23459. var LIBRARY = __webpack_require__(46)
  23460. , $export = __webpack_require__(0)
  23461. , redefine = __webpack_require__(22)
  23462. , hide = __webpack_require__(19)
  23463. , has = __webpack_require__(17)
  23464. , Iterators = __webpack_require__(45)
  23465. , $iterCreate = __webpack_require__(114)
  23466. , setToStringTag = __webpack_require__(61)
  23467. , getPrototypeOf = __webpack_require__(26)
  23468. , ITERATOR = __webpack_require__(8)('iterator')
  23469. , BUGGY = !([].keys && 'next' in [].keys()) // Safari has buggy iterators w/o `next`
  23470. , FF_ITERATOR = '@@iterator'
  23471. , KEYS = 'keys'
  23472. , VALUES = 'values';
  23473. var returnThis = function(){ return this; };
  23474. module.exports = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED){
  23475. $iterCreate(Constructor, NAME, next);
  23476. var getMethod = function(kind){
  23477. if(!BUGGY && kind in proto)return proto[kind];
  23478. switch(kind){
  23479. case KEYS: return function keys(){ return new Constructor(this, kind); };
  23480. case VALUES: return function values(){ return new Constructor(this, kind); };
  23481. } return function entries(){ return new Constructor(this, kind); };
  23482. };
  23483. var TAG = NAME + ' Iterator'
  23484. , DEF_VALUES = DEFAULT == VALUES
  23485. , VALUES_BUG = false
  23486. , proto = Base.prototype
  23487. , $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT]
  23488. , $default = $native || getMethod(DEFAULT)
  23489. , $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined
  23490. , $anyNative = NAME == 'Array' ? proto.entries || $native : $native
  23491. , methods, key, IteratorPrototype;
  23492. // Fix native
  23493. if($anyNative){
  23494. IteratorPrototype = getPrototypeOf($anyNative.call(new Base));
  23495. if(IteratorPrototype !== Object.prototype){
  23496. // Set @@toStringTag to native iterators
  23497. setToStringTag(IteratorPrototype, TAG, true);
  23498. // fix for some old engines
  23499. if(!LIBRARY && !has(IteratorPrototype, ITERATOR))hide(IteratorPrototype, ITERATOR, returnThis);
  23500. }
  23501. }
  23502. // fix Array#{values, @@iterator}.name in V8 / FF
  23503. if(DEF_VALUES && $native && $native.name !== VALUES){
  23504. VALUES_BUG = true;
  23505. $default = function values(){ return $native.call(this); };
  23506. }
  23507. // Define iterator
  23508. if((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])){
  23509. hide(proto, ITERATOR, $default);
  23510. }
  23511. // Plug for library
  23512. Iterators[NAME] = $default;
  23513. Iterators[TAG] = returnThis;
  23514. if(DEFAULT){
  23515. methods = {
  23516. values: DEF_VALUES ? $default : getMethod(VALUES),
  23517. keys: IS_SET ? $default : getMethod(KEYS),
  23518. entries: $entries
  23519. };
  23520. if(FORCED)for(key in methods){
  23521. if(!(key in proto))redefine(proto, key, methods[key]);
  23522. } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
  23523. }
  23524. return methods;
  23525. };
  23526. /***/ },
  23527. /* 116 */
  23528. /***/ function(module, exports) {
  23529. // 20.2.2.14 Math.expm1(x)
  23530. var $expm1 = Math.expm1;
  23531. module.exports = (!$expm1
  23532. // Old FF bug
  23533. || $expm1(10) > 22025.465794806719 || $expm1(10) < 22025.4657948067165168
  23534. // Tor Browser bug
  23535. || $expm1(-2e-17) != -2e-17
  23536. ) ? function expm1(x){
  23537. return (x = +x) == 0 ? x : x > -1e-6 && x < 1e-6 ? x + x * x / 2 : Math.exp(x) - 1;
  23538. } : $expm1;
  23539. /***/ },
  23540. /* 117 */
  23541. /***/ function(module, exports) {
  23542. // 20.2.2.28 Math.sign(x)
  23543. module.exports = Math.sign || function sign(x){
  23544. return (x = +x) == 0 || x != x ? x : x < 0 ? -1 : 1;
  23545. };
  23546. /***/ },
  23547. /* 118 */
  23548. /***/ function(module, exports, __webpack_require__) {
  23549. var global = __webpack_require__(5)
  23550. , macrotask = __webpack_require__(125).set
  23551. , Observer = global.MutationObserver || global.WebKitMutationObserver
  23552. , process = global.process
  23553. , Promise = global.Promise
  23554. , isNode = __webpack_require__(27)(process) == 'process';
  23555. module.exports = function(){
  23556. var head, last, notify;
  23557. var flush = function(){
  23558. var parent, fn;
  23559. if(isNode && (parent = process.domain))parent.exit();
  23560. while(head){
  23561. fn = head.fn;
  23562. head = head.next;
  23563. try {
  23564. fn();
  23565. } catch(e){
  23566. if(head)notify();
  23567. else last = undefined;
  23568. throw e;
  23569. }
  23570. } last = undefined;
  23571. if(parent)parent.enter();
  23572. };
  23573. // Node.js
  23574. if(isNode){
  23575. notify = function(){
  23576. process.nextTick(flush);
  23577. };
  23578. // browsers with MutationObserver
  23579. } else if(Observer){
  23580. var toggle = true
  23581. , node = document.createTextNode('');
  23582. new Observer(flush).observe(node, {characterData: true}); // eslint-disable-line no-new
  23583. notify = function(){
  23584. node.data = toggle = !toggle;
  23585. };
  23586. // environments with maybe non-completely correct, but existent Promise
  23587. } else if(Promise && Promise.resolve){
  23588. var promise = Promise.resolve();
  23589. notify = function(){
  23590. promise.then(flush);
  23591. };
  23592. // for other environments - macrotask based on:
  23593. // - setImmediate
  23594. // - MessageChannel
  23595. // - window.postMessag
  23596. // - onreadystatechange
  23597. // - setTimeout
  23598. } else {
  23599. notify = function(){
  23600. // strange IE + webpack dev server bug - use .call(global)
  23601. macrotask.call(global, flush);
  23602. };
  23603. }
  23604. return function(fn){
  23605. var task = {fn: fn, next: undefined};
  23606. if(last)last.next = task;
  23607. if(!head){
  23608. head = task;
  23609. notify();
  23610. } last = task;
  23611. };
  23612. };
  23613. /***/ },
  23614. /* 119 */
  23615. /***/ function(module, exports, __webpack_require__) {
  23616. var shared = __webpack_require__(92)('keys')
  23617. , uid = __webpack_require__(53);
  23618. module.exports = function(key){
  23619. return shared[key] || (shared[key] = uid(key));
  23620. };
  23621. /***/ },
  23622. /* 120 */
  23623. /***/ function(module, exports, __webpack_require__) {
  23624. // 7.3.20 SpeciesConstructor(O, defaultConstructor)
  23625. var anObject = __webpack_require__(3)
  23626. , aFunction = __webpack_require__(21)
  23627. , SPECIES = __webpack_require__(8)('species');
  23628. module.exports = function(O, D){
  23629. var C = anObject(O).constructor, S;
  23630. return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S);
  23631. };
  23632. /***/ },
  23633. /* 121 */
  23634. /***/ function(module, exports, __webpack_require__) {
  23635. var toInteger = __webpack_require__(42)
  23636. , defined = __webpack_require__(28);
  23637. // true -> String#at
  23638. // false -> String#codePointAt
  23639. module.exports = function(TO_STRING){
  23640. return function(that, pos){
  23641. var s = String(defined(that))
  23642. , i = toInteger(pos)
  23643. , l = s.length
  23644. , a, b;
  23645. if(i < 0 || i >= l)return TO_STRING ? '' : undefined;
  23646. a = s.charCodeAt(i);
  23647. return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
  23648. ? TO_STRING ? s.charAt(i) : a
  23649. : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
  23650. };
  23651. };
  23652. /***/ },
  23653. /* 122 */
  23654. /***/ function(module, exports, __webpack_require__) {
  23655. // helper for String#{startsWith, endsWith, includes}
  23656. var isRegExp = __webpack_require__(87)
  23657. , defined = __webpack_require__(28);
  23658. module.exports = function(that, searchString, NAME){
  23659. if(isRegExp(searchString))throw TypeError('String#' + NAME + " doesn't accept regex!");
  23660. return String(defined(that));
  23661. };
  23662. /***/ },
  23663. /* 123 */
  23664. /***/ function(module, exports, __webpack_require__) {
  23665. "use strict";
  23666. 'use strict';
  23667. var toInteger = __webpack_require__(42)
  23668. , defined = __webpack_require__(28);
  23669. module.exports = function repeat(count){
  23670. var str = String(defined(this))
  23671. , res = ''
  23672. , n = toInteger(count);
  23673. if(n < 0 || n == Infinity)throw RangeError("Count can't be negative");
  23674. for(;n > 0; (n >>>= 1) && (str += str))if(n & 1)res += str;
  23675. return res;
  23676. };
  23677. /***/ },
  23678. /* 124 */
  23679. /***/ function(module, exports) {
  23680. module.exports = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' +
  23681. '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
  23682. /***/ },
  23683. /* 125 */
  23684. /***/ function(module, exports, __webpack_require__) {
  23685. var ctx = __webpack_require__(35)
  23686. , invoke = __webpack_require__(86)
  23687. , html = __webpack_require__(109)
  23688. , cel = __webpack_require__(106)
  23689. , global = __webpack_require__(5)
  23690. , process = global.process
  23691. , setTask = global.setImmediate
  23692. , clearTask = global.clearImmediate
  23693. , MessageChannel = global.MessageChannel
  23694. , counter = 0
  23695. , queue = {}
  23696. , ONREADYSTATECHANGE = 'onreadystatechange'
  23697. , defer, channel, port;
  23698. var run = function(){
  23699. var id = +this;
  23700. if(queue.hasOwnProperty(id)){
  23701. var fn = queue[id];
  23702. delete queue[id];
  23703. fn();
  23704. }
  23705. };
  23706. var listener = function(event){
  23707. run.call(event.data);
  23708. };
  23709. // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
  23710. if(!setTask || !clearTask){
  23711. setTask = function setImmediate(fn){
  23712. var args = [], i = 1;
  23713. while(arguments.length > i)args.push(arguments[i++]);
  23714. queue[++counter] = function(){
  23715. invoke(typeof fn == 'function' ? fn : Function(fn), args);
  23716. };
  23717. defer(counter);
  23718. return counter;
  23719. };
  23720. clearTask = function clearImmediate(id){
  23721. delete queue[id];
  23722. };
  23723. // Node.js 0.8-
  23724. if(__webpack_require__(27)(process) == 'process'){
  23725. defer = function(id){
  23726. process.nextTick(ctx(run, id, 1));
  23727. };
  23728. // Browsers with MessageChannel, includes WebWorkers
  23729. } else if(MessageChannel){
  23730. channel = new MessageChannel;
  23731. port = channel.port2;
  23732. channel.port1.onmessage = listener;
  23733. defer = ctx(port.postMessage, port, 1);
  23734. // Browsers with postMessage, skip WebWorkers
  23735. // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
  23736. } else if(global.addEventListener && typeof postMessage == 'function' && !global.importScripts){
  23737. defer = function(id){
  23738. global.postMessage(id + '', '*');
  23739. };
  23740. global.addEventListener('message', listener, false);
  23741. // IE8-
  23742. } else if(ONREADYSTATECHANGE in cel('script')){
  23743. defer = function(id){
  23744. html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function(){
  23745. html.removeChild(this);
  23746. run.call(id);
  23747. };
  23748. };
  23749. // Rest old browsers
  23750. } else {
  23751. defer = function(id){
  23752. setTimeout(ctx(run, id, 1), 0);
  23753. };
  23754. }
  23755. }
  23756. module.exports = {
  23757. set: setTask,
  23758. clear: clearTask
  23759. };
  23760. /***/ },
  23761. /* 126 */
  23762. /***/ function(module, exports, __webpack_require__) {
  23763. "use strict";
  23764. 'use strict';
  23765. var global = __webpack_require__(5)
  23766. , DESCRIPTORS = __webpack_require__(10)
  23767. , LIBRARY = __webpack_require__(46)
  23768. , $typed = __webpack_require__(93)
  23769. , hide = __webpack_require__(19)
  23770. , redefineAll = __webpack_require__(50)
  23771. , fails = __webpack_require__(6)
  23772. , anInstance = __webpack_require__(39)
  23773. , toInteger = __webpack_require__(42)
  23774. , toLength = __webpack_require__(15)
  23775. , gOPN = __webpack_require__(48).f
  23776. , dP = __webpack_require__(11).f
  23777. , arrayFill = __webpack_require__(104)
  23778. , setToStringTag = __webpack_require__(61)
  23779. , ARRAY_BUFFER = 'ArrayBuffer'
  23780. , DATA_VIEW = 'DataView'
  23781. , PROTOTYPE = 'prototype'
  23782. , WRONG_LENGTH = 'Wrong length!'
  23783. , WRONG_INDEX = 'Wrong index!'
  23784. , $ArrayBuffer = global[ARRAY_BUFFER]
  23785. , $DataView = global[DATA_VIEW]
  23786. , Math = global.Math
  23787. , parseInt = global.parseInt
  23788. , RangeError = global.RangeError
  23789. , Infinity = global.Infinity
  23790. , BaseBuffer = $ArrayBuffer
  23791. , abs = Math.abs
  23792. , pow = Math.pow
  23793. , min = Math.min
  23794. , floor = Math.floor
  23795. , log = Math.log
  23796. , LN2 = Math.LN2
  23797. , BUFFER = 'buffer'
  23798. , BYTE_LENGTH = 'byteLength'
  23799. , BYTE_OFFSET = 'byteOffset'
  23800. , $BUFFER = DESCRIPTORS ? '_b' : BUFFER
  23801. , $LENGTH = DESCRIPTORS ? '_l' : BYTE_LENGTH
  23802. , $OFFSET = DESCRIPTORS ? '_o' : BYTE_OFFSET;
  23803. // IEEE754 conversions based on https://github.com/feross/ieee754
  23804. var packIEEE754 = function(value, mLen, nBytes){
  23805. var buffer = Array(nBytes)
  23806. , eLen = nBytes * 8 - mLen - 1
  23807. , eMax = (1 << eLen) - 1
  23808. , eBias = eMax >> 1
  23809. , rt = mLen === 23 ? pow(2, -24) - pow(2, -77) : 0
  23810. , i = 0
  23811. , s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0
  23812. , e, m, c;
  23813. value = abs(value)
  23814. if(value != value || value === Infinity){
  23815. m = value != value ? 1 : 0;
  23816. e = eMax;
  23817. } else {
  23818. e = floor(log(value) / LN2);
  23819. if(value * (c = pow(2, -e)) < 1){
  23820. e--;
  23821. c *= 2;
  23822. }
  23823. if(e + eBias >= 1){
  23824. value += rt / c;
  23825. } else {
  23826. value += rt * pow(2, 1 - eBias);
  23827. }
  23828. if(value * c >= 2){
  23829. e++;
  23830. c /= 2;
  23831. }
  23832. if(e + eBias >= eMax){
  23833. m = 0;
  23834. e = eMax;
  23835. } else if(e + eBias >= 1){
  23836. m = (value * c - 1) * pow(2, mLen);
  23837. e = e + eBias;
  23838. } else {
  23839. m = value * pow(2, eBias - 1) * pow(2, mLen);
  23840. e = 0;
  23841. }
  23842. }
  23843. for(; mLen >= 8; buffer[i++] = m & 255, m /= 256, mLen -= 8);
  23844. e = e << mLen | m;
  23845. eLen += mLen;
  23846. for(; eLen > 0; buffer[i++] = e & 255, e /= 256, eLen -= 8);
  23847. buffer[--i] |= s * 128;
  23848. return buffer;
  23849. };
  23850. var unpackIEEE754 = function(buffer, mLen, nBytes){
  23851. var eLen = nBytes * 8 - mLen - 1
  23852. , eMax = (1 << eLen) - 1
  23853. , eBias = eMax >> 1
  23854. , nBits = eLen - 7
  23855. , i = nBytes - 1
  23856. , s = buffer[i--]
  23857. , e = s & 127
  23858. , m;
  23859. s >>= 7;
  23860. for(; nBits > 0; e = e * 256 + buffer[i], i--, nBits -= 8);
  23861. m = e & (1 << -nBits) - 1;
  23862. e >>= -nBits;
  23863. nBits += mLen;
  23864. for(; nBits > 0; m = m * 256 + buffer[i], i--, nBits -= 8);
  23865. if(e === 0){
  23866. e = 1 - eBias;
  23867. } else if(e === eMax){
  23868. return m ? NaN : s ? -Infinity : Infinity;
  23869. } else {
  23870. m = m + pow(2, mLen);
  23871. e = e - eBias;
  23872. } return (s ? -1 : 1) * m * pow(2, e - mLen);
  23873. };
  23874. var unpackI32 = function(bytes){
  23875. return bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0];
  23876. };
  23877. var packI8 = function(it){
  23878. return [it & 0xff];
  23879. };
  23880. var packI16 = function(it){
  23881. return [it & 0xff, it >> 8 & 0xff];
  23882. };
  23883. var packI32 = function(it){
  23884. return [it & 0xff, it >> 8 & 0xff, it >> 16 & 0xff, it >> 24 & 0xff];
  23885. };
  23886. var packF64 = function(it){
  23887. return packIEEE754(it, 52, 8);
  23888. };
  23889. var packF32 = function(it){
  23890. return packIEEE754(it, 23, 4);
  23891. };
  23892. var addGetter = function(C, key, internal){
  23893. dP(C[PROTOTYPE], key, {get: function(){ return this[internal]; }});
  23894. };
  23895. var get = function(view, bytes, index, isLittleEndian){
  23896. var numIndex = +index
  23897. , intIndex = toInteger(numIndex);
  23898. if(numIndex != intIndex || intIndex < 0 || intIndex + bytes > view[$LENGTH])throw RangeError(WRONG_INDEX);
  23899. var store = view[$BUFFER]._b
  23900. , start = intIndex + view[$OFFSET]
  23901. , pack = store.slice(start, start + bytes);
  23902. return isLittleEndian ? pack : pack.reverse();
  23903. };
  23904. var set = function(view, bytes, index, conversion, value, isLittleEndian){
  23905. var numIndex = +index
  23906. , intIndex = toInteger(numIndex);
  23907. if(numIndex != intIndex || intIndex < 0 || intIndex + bytes > view[$LENGTH])throw RangeError(WRONG_INDEX);
  23908. var store = view[$BUFFER]._b
  23909. , start = intIndex + view[$OFFSET]
  23910. , pack = conversion(+value);
  23911. for(var i = 0; i < bytes; i++)store[start + i] = pack[isLittleEndian ? i : bytes - i - 1];
  23912. };
  23913. var validateArrayBufferArguments = function(that, length){
  23914. anInstance(that, $ArrayBuffer, ARRAY_BUFFER);
  23915. var numberLength = +length
  23916. , byteLength = toLength(numberLength);
  23917. if(numberLength != byteLength)throw RangeError(WRONG_LENGTH);
  23918. return byteLength;
  23919. };
  23920. if(!$typed.ABV){
  23921. $ArrayBuffer = function ArrayBuffer(length){
  23922. var byteLength = validateArrayBufferArguments(this, length);
  23923. this._b = arrayFill.call(Array(byteLength), 0);
  23924. this[$LENGTH] = byteLength;
  23925. };
  23926. $DataView = function DataView(buffer, byteOffset, byteLength){
  23927. anInstance(this, $DataView, DATA_VIEW);
  23928. anInstance(buffer, $ArrayBuffer, DATA_VIEW);
  23929. var bufferLength = buffer[$LENGTH]
  23930. , offset = toInteger(byteOffset);
  23931. if(offset < 0 || offset > bufferLength)throw RangeError('Wrong offset!');
  23932. byteLength = byteLength === undefined ? bufferLength - offset : toLength(byteLength);
  23933. if(offset + byteLength > bufferLength)throw RangeError(WRONG_LENGTH);
  23934. this[$BUFFER] = buffer;
  23935. this[$OFFSET] = offset;
  23936. this[$LENGTH] = byteLength;
  23937. };
  23938. if(DESCRIPTORS){
  23939. addGetter($ArrayBuffer, BYTE_LENGTH, '_l');
  23940. addGetter($DataView, BUFFER, '_b');
  23941. addGetter($DataView, BYTE_LENGTH, '_l');
  23942. addGetter($DataView, BYTE_OFFSET, '_o');
  23943. }
  23944. redefineAll($DataView[PROTOTYPE], {
  23945. getInt8: function getInt8(byteOffset){
  23946. return get(this, 1, byteOffset)[0] << 24 >> 24;
  23947. },
  23948. getUint8: function getUint8(byteOffset){
  23949. return get(this, 1, byteOffset)[0];
  23950. },
  23951. getInt16: function getInt16(byteOffset /*, littleEndian */){
  23952. var bytes = get(this, 2, byteOffset, arguments[1]);
  23953. return (bytes[1] << 8 | bytes[0]) << 16 >> 16;
  23954. },
  23955. getUint16: function getUint16(byteOffset /*, littleEndian */){
  23956. var bytes = get(this, 2, byteOffset, arguments[1]);
  23957. return bytes[1] << 8 | bytes[0];
  23958. },
  23959. getInt32: function getInt32(byteOffset /*, littleEndian */){
  23960. return unpackI32(get(this, 4, byteOffset, arguments[1]));
  23961. },
  23962. getUint32: function getUint32(byteOffset /*, littleEndian */){
  23963. return unpackI32(get(this, 4, byteOffset, arguments[1])) >>> 0;
  23964. },
  23965. getFloat32: function getFloat32(byteOffset /*, littleEndian */){
  23966. return unpackIEEE754(get(this, 4, byteOffset, arguments[1]), 23, 4);
  23967. },
  23968. getFloat64: function getFloat64(byteOffset /*, littleEndian */){
  23969. return unpackIEEE754(get(this, 8, byteOffset, arguments[1]), 52, 8);
  23970. },
  23971. setInt8: function setInt8(byteOffset, value){
  23972. set(this, 1, byteOffset, packI8, value);
  23973. },
  23974. setUint8: function setUint8(byteOffset, value){
  23975. set(this, 1, byteOffset, packI8, value);
  23976. },
  23977. setInt16: function setInt16(byteOffset, value /*, littleEndian */){
  23978. set(this, 2, byteOffset, packI16, value, arguments[2]);
  23979. },
  23980. setUint16: function setUint16(byteOffset, value /*, littleEndian */){
  23981. set(this, 2, byteOffset, packI16, value, arguments[2]);
  23982. },
  23983. setInt32: function setInt32(byteOffset, value /*, littleEndian */){
  23984. set(this, 4, byteOffset, packI32, value, arguments[2]);
  23985. },
  23986. setUint32: function setUint32(byteOffset, value /*, littleEndian */){
  23987. set(this, 4, byteOffset, packI32, value, arguments[2]);
  23988. },
  23989. setFloat32: function setFloat32(byteOffset, value /*, littleEndian */){
  23990. set(this, 4, byteOffset, packF32, value, arguments[2]);
  23991. },
  23992. setFloat64: function setFloat64(byteOffset, value /*, littleEndian */){
  23993. set(this, 8, byteOffset, packF64, value, arguments[2]);
  23994. }
  23995. });
  23996. } else {
  23997. if(!fails(function(){
  23998. new $ArrayBuffer; // eslint-disable-line no-new
  23999. }) || !fails(function(){
  24000. new $ArrayBuffer(.5); // eslint-disable-line no-new
  24001. })){
  24002. $ArrayBuffer = function ArrayBuffer(length){
  24003. return new BaseBuffer(validateArrayBufferArguments(this, length));
  24004. };
  24005. var ArrayBufferProto = $ArrayBuffer[PROTOTYPE] = BaseBuffer[PROTOTYPE];
  24006. for(var keys = gOPN(BaseBuffer), j = 0, key; keys.length > j; ){
  24007. if(!((key = keys[j++]) in $ArrayBuffer))hide($ArrayBuffer, key, BaseBuffer[key]);
  24008. };
  24009. if(!LIBRARY)ArrayBufferProto.constructor = $ArrayBuffer;
  24010. }
  24011. // iOS Safari 7.x bug
  24012. var view = new $DataView(new $ArrayBuffer(2))
  24013. , $setInt8 = $DataView[PROTOTYPE].setInt8;
  24014. view.setInt8(0, 2147483648);
  24015. view.setInt8(1, 2147483649);
  24016. if(view.getInt8(0) || !view.getInt8(1))redefineAll($DataView[PROTOTYPE], {
  24017. setInt8: function setInt8(byteOffset, value){
  24018. $setInt8.call(this, byteOffset, value << 24 >> 24);
  24019. },
  24020. setUint8: function setUint8(byteOffset, value){
  24021. $setInt8.call(this, byteOffset, value << 24 >> 24);
  24022. }
  24023. }, true);
  24024. }
  24025. setToStringTag($ArrayBuffer, ARRAY_BUFFER);
  24026. setToStringTag($DataView, DATA_VIEW);
  24027. hide($DataView[PROTOTYPE], $typed.VIEW, true);
  24028. exports[ARRAY_BUFFER] = $ArrayBuffer;
  24029. exports[DATA_VIEW] = $DataView;
  24030. /***/ },
  24031. /* 127 */
  24032. /***/ function(module, exports, __webpack_require__) {
  24033. var global = __webpack_require__(5)
  24034. , core = __webpack_require__(32)
  24035. , LIBRARY = __webpack_require__(46)
  24036. , wksExt = __webpack_require__(190)
  24037. , defineProperty = __webpack_require__(11).f;
  24038. module.exports = function(name){
  24039. var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {});
  24040. if(name.charAt(0) != '_' && !(name in $Symbol))defineProperty($Symbol, name, {value: wksExt.f(name)});
  24041. };
  24042. /***/ },
  24043. /* 128 */
  24044. /***/ function(module, exports, __webpack_require__) {
  24045. var classof = __webpack_require__(59)
  24046. , ITERATOR = __webpack_require__(8)('iterator')
  24047. , Iterators = __webpack_require__(45);
  24048. module.exports = __webpack_require__(32).getIteratorMethod = function(it){
  24049. if(it != undefined)return it[ITERATOR]
  24050. || it['@@iterator']
  24051. || Iterators[classof(it)];
  24052. };
  24053. /***/ },
  24054. /* 129 */
  24055. /***/ function(module, exports, __webpack_require__) {
  24056. "use strict";
  24057. 'use strict';
  24058. var addToUnscopables = __webpack_require__(58)
  24059. , step = __webpack_require__(178)
  24060. , Iterators = __webpack_require__(45)
  24061. , toIObject = __webpack_require__(24);
  24062. // 22.1.3.4 Array.prototype.entries()
  24063. // 22.1.3.13 Array.prototype.keys()
  24064. // 22.1.3.29 Array.prototype.values()
  24065. // 22.1.3.30 Array.prototype[@@iterator]()
  24066. module.exports = __webpack_require__(115)(Array, 'Array', function(iterated, kind){
  24067. this._t = toIObject(iterated); // target
  24068. this._i = 0; // next index
  24069. this._k = kind; // kind
  24070. // 22.1.5.2.1 %ArrayIteratorPrototype%.next()
  24071. }, function(){
  24072. var O = this._t
  24073. , kind = this._k
  24074. , index = this._i++;
  24075. if(!O || index >= O.length){
  24076. this._t = undefined;
  24077. return step(1);
  24078. }
  24079. if(kind == 'keys' )return step(0, index);
  24080. if(kind == 'values')return step(0, O[index]);
  24081. return step(0, [index, O[index]]);
  24082. }, 'values');
  24083. // argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
  24084. Iterators.Arguments = Iterators.Array;
  24085. addToUnscopables('keys');
  24086. addToUnscopables('values');
  24087. addToUnscopables('entries');
  24088. /***/ },
  24089. /* 130 */
  24090. /***/ function(module, exports, __webpack_require__) {
  24091. "use strict";
  24092. /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
  24093. var createHash = __webpack_require__(63);
  24094. var inherits = __webpack_require__(2)
  24095. var Transform = __webpack_require__(9).Transform
  24096. var ZEROS = new Buffer(128)
  24097. ZEROS.fill(0)
  24098. function Hmac(alg, key) {
  24099. Transform.call(this)
  24100. alg = alg.toLowerCase()
  24101. if (typeof key === 'string') {
  24102. key = new Buffer(key)
  24103. }
  24104. var blocksize = (alg === 'sha512' || alg === 'sha384') ? 128 : 64
  24105. this._alg = alg
  24106. this._key = key
  24107. if (key.length > blocksize) {
  24108. key = createHash(alg).update(key).digest()
  24109. } else if (key.length < blocksize) {
  24110. key = Buffer.concat([key, ZEROS], blocksize)
  24111. }
  24112. var ipad = this._ipad = new Buffer(blocksize)
  24113. var opad = this._opad = new Buffer(blocksize)
  24114. for (var i = 0; i < blocksize; i++) {
  24115. ipad[i] = key[i] ^ 0x36
  24116. opad[i] = key[i] ^ 0x5C
  24117. }
  24118. this._hash = createHash(alg).update(ipad)
  24119. }
  24120. inherits(Hmac, Transform)
  24121. Hmac.prototype.update = function (data, enc) {
  24122. this._hash.update(data, enc)
  24123. return this
  24124. }
  24125. Hmac.prototype._transform = function (data, _, next) {
  24126. this._hash.update(data)
  24127. next()
  24128. }
  24129. Hmac.prototype._flush = function (next) {
  24130. this.push(this.digest())
  24131. next()
  24132. }
  24133. Hmac.prototype.digest = function (enc) {
  24134. var h = this._hash.digest()
  24135. return createHash(this._alg).update(this._opad).update(h).digest(enc)
  24136. }
  24137. module.exports = function createHmac(alg, key) {
  24138. return new Hmac(alg, key)
  24139. }
  24140. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  24141. /***/ },
  24142. /* 131 */
  24143. /***/ function(module, exports, __webpack_require__) {
  24144. "use strict";
  24145. 'use strict'
  24146. exports.randomBytes = exports.rng = exports.pseudoRandomBytes = exports.prng = __webpack_require__(73)
  24147. exports.createHash = exports.Hash = __webpack_require__(63)
  24148. exports.createHmac = exports.Hmac = __webpack_require__(130)
  24149. var hashes = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160'].concat(Object.keys(__webpack_require__(165)))
  24150. exports.getHashes = function () {
  24151. return hashes
  24152. }
  24153. var p = __webpack_require__(210)
  24154. exports.pbkdf2 = p.pbkdf2
  24155. exports.pbkdf2Sync = p.pbkdf2Sync
  24156. var aes = __webpack_require__(287)
  24157. ;[
  24158. 'Cipher',
  24159. 'createCipher',
  24160. 'Cipheriv',
  24161. 'createCipheriv',
  24162. 'Decipher',
  24163. 'createDecipher',
  24164. 'Decipheriv',
  24165. 'createDecipheriv',
  24166. 'getCiphers',
  24167. 'listCiphers'
  24168. ].forEach(function (key) {
  24169. exports[key] = aes[key]
  24170. })
  24171. var dh = __webpack_require__(484)
  24172. ;[
  24173. 'DiffieHellmanGroup',
  24174. 'createDiffieHellmanGroup',
  24175. 'getDiffieHellman',
  24176. 'createDiffieHellman',
  24177. 'DiffieHellman'
  24178. ].forEach(function (key) {
  24179. exports[key] = dh[key]
  24180. })
  24181. var sign = __webpack_require__(290)
  24182. ;[
  24183. 'createSign',
  24184. 'Sign',
  24185. 'createVerify',
  24186. 'Verify'
  24187. ].forEach(function (key) {
  24188. exports[key] = sign[key]
  24189. })
  24190. exports.createECDH = __webpack_require__(477)
  24191. var publicEncrypt = __webpack_require__(542)
  24192. ;[
  24193. 'publicEncrypt',
  24194. 'privateEncrypt',
  24195. 'publicDecrypt',
  24196. 'privateDecrypt'
  24197. ].forEach(function (key) {
  24198. exports[key] = publicEncrypt[key]
  24199. })
  24200. // the least I can do is make error messages for the rest of the node.js/crypto api.
  24201. ;[
  24202. 'createCredentials'
  24203. ].forEach(function (name) {
  24204. exports[name] = function () {
  24205. throw new Error([
  24206. 'sorry, ' + name + ' is not implemented yet',
  24207. 'we accept pull requests',
  24208. 'https://github.com/crypto-browserify/crypto-browserify'
  24209. ].join('\n'))
  24210. }
  24211. })
  24212. /***/ },
  24213. /* 132 */
  24214. /***/ function(module, exports, __webpack_require__) {
  24215. "use strict";
  24216. 'use strict';
  24217. exports.utils = __webpack_require__(483);
  24218. exports.Cipher = __webpack_require__(480);
  24219. exports.DES = __webpack_require__(481);
  24220. exports.CBC = __webpack_require__(479);
  24221. exports.EDE = __webpack_require__(482);
  24222. /***/ },
  24223. /* 133 */
  24224. /***/ function(module, exports) {
  24225. var toString = {}.toString;
  24226. module.exports = Array.isArray || function (arr) {
  24227. return toString.call(arr) == '[object Array]';
  24228. };
  24229. /***/ },
  24230. /* 134 */
  24231. /***/ function(module, exports, __webpack_require__) {
  24232. /**
  24233. * lodash (Custom Build) <https://lodash.com/>
  24234. * Build: `lodash modularize exports="npm" -o ./`
  24235. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  24236. * Released under MIT license <https://lodash.com/license>
  24237. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  24238. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  24239. */
  24240. var baseEach = __webpack_require__(202),
  24241. baseIteratee = __webpack_require__(203);
  24242. /** Used as references for various `Number` constants. */
  24243. var MAX_SAFE_INTEGER = 9007199254740991;
  24244. /** `Object#toString` result references. */
  24245. var funcTag = '[object Function]',
  24246. genTag = '[object GeneratorFunction]';
  24247. /**
  24248. * A specialized version of `_.map` for arrays without support for iteratee
  24249. * shorthands.
  24250. *
  24251. * @private
  24252. * @param {Array} array The array to iterate over.
  24253. * @param {Function} iteratee The function invoked per iteration.
  24254. * @returns {Array} Returns the new mapped array.
  24255. */
  24256. function arrayMap(array, iteratee) {
  24257. var index = -1,
  24258. length = array.length,
  24259. result = Array(length);
  24260. while (++index < length) {
  24261. result[index] = iteratee(array[index], index, array);
  24262. }
  24263. return result;
  24264. }
  24265. /** Used for built-in method references. */
  24266. var objectProto = Object.prototype;
  24267. /**
  24268. * Used to resolve the
  24269. * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  24270. * of values.
  24271. */
  24272. var objectToString = objectProto.toString;
  24273. /**
  24274. * The base implementation of `_.map` without support for iteratee shorthands.
  24275. *
  24276. * @private
  24277. * @param {Array|Object} collection The collection to iterate over.
  24278. * @param {Function} iteratee The function invoked per iteration.
  24279. * @returns {Array} Returns the new mapped array.
  24280. */
  24281. function baseMap(collection, iteratee) {
  24282. var index = -1,
  24283. result = isArrayLike(collection) ? Array(collection.length) : [];
  24284. baseEach(collection, function(value, key, collection) {
  24285. result[++index] = iteratee(value, key, collection);
  24286. });
  24287. return result;
  24288. }
  24289. /**
  24290. * The base implementation of `_.property` without support for deep paths.
  24291. *
  24292. * @private
  24293. * @param {string} key The key of the property to get.
  24294. * @returns {Function} Returns the new accessor function.
  24295. */
  24296. function baseProperty(key) {
  24297. return function(object) {
  24298. return object == null ? undefined : object[key];
  24299. };
  24300. }
  24301. /**
  24302. * Gets the "length" property value of `object`.
  24303. *
  24304. * **Note:** This function is used to avoid a
  24305. * [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) that affects
  24306. * Safari on at least iOS 8.1-8.3 ARM64.
  24307. *
  24308. * @private
  24309. * @param {Object} object The object to query.
  24310. * @returns {*} Returns the "length" value.
  24311. */
  24312. var getLength = baseProperty('length');
  24313. /**
  24314. * Creates an array of values by running each element in `collection` thru
  24315. * `iteratee`. The iteratee is invoked with three arguments:
  24316. * (value, index|key, collection).
  24317. *
  24318. * Many lodash methods are guarded to work as iteratees for methods like
  24319. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  24320. *
  24321. * The guarded methods are:
  24322. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  24323. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  24324. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  24325. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  24326. *
  24327. * @static
  24328. * @memberOf _
  24329. * @since 0.1.0
  24330. * @category Collection
  24331. * @param {Array|Object} collection The collection to iterate over.
  24332. * @param {Array|Function|Object|string} [iteratee=_.identity]
  24333. * The function invoked per iteration.
  24334. * @returns {Array} Returns the new mapped array.
  24335. * @example
  24336. *
  24337. * function square(n) {
  24338. * return n * n;
  24339. * }
  24340. *
  24341. * _.map([4, 8], square);
  24342. * // => [16, 64]
  24343. *
  24344. * _.map({ 'a': 4, 'b': 8 }, square);
  24345. * // => [16, 64] (iteration order is not guaranteed)
  24346. *
  24347. * var users = [
  24348. * { 'user': 'barney' },
  24349. * { 'user': 'fred' }
  24350. * ];
  24351. *
  24352. * // The `_.property` iteratee shorthand.
  24353. * _.map(users, 'user');
  24354. * // => ['barney', 'fred']
  24355. */
  24356. function map(collection, iteratee) {
  24357. var func = isArray(collection) ? arrayMap : baseMap;
  24358. return func(collection, baseIteratee(iteratee, 3));
  24359. }
  24360. /**
  24361. * Checks if `value` is classified as an `Array` object.
  24362. *
  24363. * @static
  24364. * @memberOf _
  24365. * @since 0.1.0
  24366. * @type {Function}
  24367. * @category Lang
  24368. * @param {*} value The value to check.
  24369. * @returns {boolean} Returns `true` if `value` is correctly classified,
  24370. * else `false`.
  24371. * @example
  24372. *
  24373. * _.isArray([1, 2, 3]);
  24374. * // => true
  24375. *
  24376. * _.isArray(document.body.children);
  24377. * // => false
  24378. *
  24379. * _.isArray('abc');
  24380. * // => false
  24381. *
  24382. * _.isArray(_.noop);
  24383. * // => false
  24384. */
  24385. var isArray = Array.isArray;
  24386. /**
  24387. * Checks if `value` is array-like. A value is considered array-like if it's
  24388. * not a function and has a `value.length` that's an integer greater than or
  24389. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  24390. *
  24391. * @static
  24392. * @memberOf _
  24393. * @since 4.0.0
  24394. * @category Lang
  24395. * @param {*} value The value to check.
  24396. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  24397. * @example
  24398. *
  24399. * _.isArrayLike([1, 2, 3]);
  24400. * // => true
  24401. *
  24402. * _.isArrayLike(document.body.children);
  24403. * // => true
  24404. *
  24405. * _.isArrayLike('abc');
  24406. * // => true
  24407. *
  24408. * _.isArrayLike(_.noop);
  24409. * // => false
  24410. */
  24411. function isArrayLike(value) {
  24412. return value != null && isLength(getLength(value)) && !isFunction(value);
  24413. }
  24414. /**
  24415. * Checks if `value` is classified as a `Function` object.
  24416. *
  24417. * @static
  24418. * @memberOf _
  24419. * @since 0.1.0
  24420. * @category Lang
  24421. * @param {*} value The value to check.
  24422. * @returns {boolean} Returns `true` if `value` is correctly classified,
  24423. * else `false`.
  24424. * @example
  24425. *
  24426. * _.isFunction(_);
  24427. * // => true
  24428. *
  24429. * _.isFunction(/abc/);
  24430. * // => false
  24431. */
  24432. function isFunction(value) {
  24433. // The use of `Object#toString` avoids issues with the `typeof` operator
  24434. // in Safari 8 which returns 'object' for typed array and weak map constructors,
  24435. // and PhantomJS 1.9 which returns 'function' for `NodeList` instances.
  24436. var tag = isObject(value) ? objectToString.call(value) : '';
  24437. return tag == funcTag || tag == genTag;
  24438. }
  24439. /**
  24440. * Checks if `value` is a valid array-like length.
  24441. *
  24442. * **Note:** This function is loosely based on
  24443. * [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
  24444. *
  24445. * @static
  24446. * @memberOf _
  24447. * @since 4.0.0
  24448. * @category Lang
  24449. * @param {*} value The value to check.
  24450. * @returns {boolean} Returns `true` if `value` is a valid length,
  24451. * else `false`.
  24452. * @example
  24453. *
  24454. * _.isLength(3);
  24455. * // => true
  24456. *
  24457. * _.isLength(Number.MIN_VALUE);
  24458. * // => false
  24459. *
  24460. * _.isLength(Infinity);
  24461. * // => false
  24462. *
  24463. * _.isLength('3');
  24464. * // => false
  24465. */
  24466. function isLength(value) {
  24467. return typeof value == 'number' &&
  24468. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  24469. }
  24470. /**
  24471. * Checks if `value` is the
  24472. * [language type](http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types)
  24473. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  24474. *
  24475. * @static
  24476. * @memberOf _
  24477. * @since 0.1.0
  24478. * @category Lang
  24479. * @param {*} value The value to check.
  24480. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  24481. * @example
  24482. *
  24483. * _.isObject({});
  24484. * // => true
  24485. *
  24486. * _.isObject([1, 2, 3]);
  24487. * // => true
  24488. *
  24489. * _.isObject(_.noop);
  24490. * // => true
  24491. *
  24492. * _.isObject(null);
  24493. * // => false
  24494. */
  24495. function isObject(value) {
  24496. var type = typeof value;
  24497. return !!value && (type == 'object' || type == 'function');
  24498. }
  24499. module.exports = map;
  24500. /***/ },
  24501. /* 135 */
  24502. /***/ function(module, exports, __webpack_require__) {
  24503. module.exports = minimatch
  24504. minimatch.Minimatch = Minimatch
  24505. var path = { sep: '/' }
  24506. try {
  24507. path = __webpack_require__(43)
  24508. } catch (er) {}
  24509. var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}
  24510. var expand = __webpack_require__(283)
  24511. // any single thing other than /
  24512. // don't need to escape / when using new RegExp()
  24513. var qmark = '[^/]'
  24514. // * => any number of characters
  24515. var star = qmark + '*?'
  24516. // ** when dots are allowed. Anything goes, except .. and .
  24517. // not (^ or / followed by one or two dots followed by $ or /),
  24518. // followed by anything, any number of times.
  24519. var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?'
  24520. // not a ^ or / followed by a dot,
  24521. // followed by anything, any number of times.
  24522. var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?'
  24523. // characters that need to be escaped in RegExp.
  24524. var reSpecials = charSet('().*{}+?[]^$\\!')
  24525. // "abc" -> { a:true, b:true, c:true }
  24526. function charSet (s) {
  24527. return s.split('').reduce(function (set, c) {
  24528. set[c] = true
  24529. return set
  24530. }, {})
  24531. }
  24532. // normalizes slashes.
  24533. var slashSplit = /\/+/
  24534. minimatch.filter = filter
  24535. function filter (pattern, options) {
  24536. options = options || {}
  24537. return function (p, i, list) {
  24538. return minimatch(p, pattern, options)
  24539. }
  24540. }
  24541. function ext (a, b) {
  24542. a = a || {}
  24543. b = b || {}
  24544. var t = {}
  24545. Object.keys(b).forEach(function (k) {
  24546. t[k] = b[k]
  24547. })
  24548. Object.keys(a).forEach(function (k) {
  24549. t[k] = a[k]
  24550. })
  24551. return t
  24552. }
  24553. minimatch.defaults = function (def) {
  24554. if (!def || !Object.keys(def).length) return minimatch
  24555. var orig = minimatch
  24556. var m = function minimatch (p, pattern, options) {
  24557. return orig.minimatch(p, pattern, ext(def, options))
  24558. }
  24559. m.Minimatch = function Minimatch (pattern, options) {
  24560. return new orig.Minimatch(pattern, ext(def, options))
  24561. }
  24562. return m
  24563. }
  24564. Minimatch.defaults = function (def) {
  24565. if (!def || !Object.keys(def).length) return Minimatch
  24566. return minimatch.defaults(def).Minimatch
  24567. }
  24568. function minimatch (p, pattern, options) {
  24569. if (typeof pattern !== 'string') {
  24570. throw new TypeError('glob pattern string required')
  24571. }
  24572. if (!options) options = {}
  24573. // shortcut: comments match nothing.
  24574. if (!options.nocomment && pattern.charAt(0) === '#') {
  24575. return false
  24576. }
  24577. // "" only matches ""
  24578. if (pattern.trim() === '') return p === ''
  24579. return new Minimatch(pattern, options).match(p)
  24580. }
  24581. function Minimatch (pattern, options) {
  24582. if (!(this instanceof Minimatch)) {
  24583. return new Minimatch(pattern, options)
  24584. }
  24585. if (typeof pattern !== 'string') {
  24586. throw new TypeError('glob pattern string required')
  24587. }
  24588. if (!options) options = {}
  24589. pattern = pattern.trim()
  24590. // windows support: need to use /, not \
  24591. if (path.sep !== '/') {
  24592. pattern = pattern.split(path.sep).join('/')
  24593. }
  24594. this.options = options
  24595. this.set = []
  24596. this.pattern = pattern
  24597. this.regexp = null
  24598. this.negate = false
  24599. this.comment = false
  24600. this.empty = false
  24601. // make the set of regexps etc.
  24602. this.make()
  24603. }
  24604. Minimatch.prototype.debug = function () {}
  24605. Minimatch.prototype.make = make
  24606. function make () {
  24607. // don't do it more than once.
  24608. if (this._made) return
  24609. var pattern = this.pattern
  24610. var options = this.options
  24611. // empty patterns and comments match nothing.
  24612. if (!options.nocomment && pattern.charAt(0) === '#') {
  24613. this.comment = true
  24614. return
  24615. }
  24616. if (!pattern) {
  24617. this.empty = true
  24618. return
  24619. }
  24620. // step 1: figure out negation, etc.
  24621. this.parseNegate()
  24622. // step 2: expand braces
  24623. var set = this.globSet = this.braceExpand()
  24624. if (options.debug) this.debug = console.error
  24625. this.debug(this.pattern, set)
  24626. // step 3: now we have a set, so turn each one into a series of path-portion
  24627. // matching patterns.
  24628. // These will be regexps, except in the case of "**", which is
  24629. // set to the GLOBSTAR object for globstar behavior,
  24630. // and will not contain any / characters
  24631. set = this.globParts = set.map(function (s) {
  24632. return s.split(slashSplit)
  24633. })
  24634. this.debug(this.pattern, set)
  24635. // glob --> regexps
  24636. set = set.map(function (s, si, set) {
  24637. return s.map(this.parse, this)
  24638. }, this)
  24639. this.debug(this.pattern, set)
  24640. // filter out everything that didn't compile properly.
  24641. set = set.filter(function (s) {
  24642. return s.indexOf(false) === -1
  24643. })
  24644. this.debug(this.pattern, set)
  24645. this.set = set
  24646. }
  24647. Minimatch.prototype.parseNegate = parseNegate
  24648. function parseNegate () {
  24649. var pattern = this.pattern
  24650. var negate = false
  24651. var options = this.options
  24652. var negateOffset = 0
  24653. if (options.nonegate) return
  24654. for (var i = 0, l = pattern.length
  24655. ; i < l && pattern.charAt(i) === '!'
  24656. ; i++) {
  24657. negate = !negate
  24658. negateOffset++
  24659. }
  24660. if (negateOffset) this.pattern = pattern.substr(negateOffset)
  24661. this.negate = negate
  24662. }
  24663. // Brace expansion:
  24664. // a{b,c}d -> abd acd
  24665. // a{b,}c -> abc ac
  24666. // a{0..3}d -> a0d a1d a2d a3d
  24667. // a{b,c{d,e}f}g -> abg acdfg acefg
  24668. // a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
  24669. //
  24670. // Invalid sets are not expanded.
  24671. // a{2..}b -> a{2..}b
  24672. // a{b}c -> a{b}c
  24673. minimatch.braceExpand = function (pattern, options) {
  24674. return braceExpand(pattern, options)
  24675. }
  24676. Minimatch.prototype.braceExpand = braceExpand
  24677. function braceExpand (pattern, options) {
  24678. if (!options) {
  24679. if (this instanceof Minimatch) {
  24680. options = this.options
  24681. } else {
  24682. options = {}
  24683. }
  24684. }
  24685. pattern = typeof pattern === 'undefined'
  24686. ? this.pattern : pattern
  24687. if (typeof pattern === 'undefined') {
  24688. throw new TypeError('undefined pattern')
  24689. }
  24690. if (options.nobrace ||
  24691. !pattern.match(/\{.*\}/)) {
  24692. // shortcut. no need to expand.
  24693. return [pattern]
  24694. }
  24695. return expand(pattern)
  24696. }
  24697. // parse a component of the expanded set.
  24698. // At this point, no pattern may contain "/" in it
  24699. // so we're going to return a 2d array, where each entry is the full
  24700. // pattern, split on '/', and then turned into a regular expression.
  24701. // A regexp is made at the end which joins each array with an
  24702. // escaped /, and another full one which joins each regexp with |.
  24703. //
  24704. // Following the lead of Bash 4.1, note that "**" only has special meaning
  24705. // when it is the *only* thing in a path portion. Otherwise, any series
  24706. // of * is equivalent to a single *. Globstar behavior is enabled by
  24707. // default, and can be disabled by setting options.noglobstar.
  24708. Minimatch.prototype.parse = parse
  24709. var SUBPARSE = {}
  24710. function parse (pattern, isSub) {
  24711. if (pattern.length > 1024 * 64) {
  24712. throw new TypeError('pattern is too long')
  24713. }
  24714. var options = this.options
  24715. // shortcuts
  24716. if (!options.noglobstar && pattern === '**') return GLOBSTAR
  24717. if (pattern === '') return ''
  24718. var re = ''
  24719. var hasMagic = !!options.nocase
  24720. var escaping = false
  24721. // ? => one single character
  24722. var patternListStack = []
  24723. var negativeLists = []
  24724. var plType
  24725. var stateChar
  24726. var inClass = false
  24727. var reClassStart = -1
  24728. var classStart = -1
  24729. // . and .. never match anything that doesn't start with .,
  24730. // even when options.dot is set.
  24731. var patternStart = pattern.charAt(0) === '.' ? '' // anything
  24732. // not (start or / followed by . or .. followed by / or end)
  24733. : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))'
  24734. : '(?!\\.)'
  24735. var self = this
  24736. function clearStateChar () {
  24737. if (stateChar) {
  24738. // we had some state-tracking character
  24739. // that wasn't consumed by this pass.
  24740. switch (stateChar) {
  24741. case '*':
  24742. re += star
  24743. hasMagic = true
  24744. break
  24745. case '?':
  24746. re += qmark
  24747. hasMagic = true
  24748. break
  24749. default:
  24750. re += '\\' + stateChar
  24751. break
  24752. }
  24753. self.debug('clearStateChar %j %j', stateChar, re)
  24754. stateChar = false
  24755. }
  24756. }
  24757. for (var i = 0, len = pattern.length, c
  24758. ; (i < len) && (c = pattern.charAt(i))
  24759. ; i++) {
  24760. this.debug('%s\t%s %s %j', pattern, i, re, c)
  24761. // skip over any that are escaped.
  24762. if (escaping && reSpecials[c]) {
  24763. re += '\\' + c
  24764. escaping = false
  24765. continue
  24766. }
  24767. switch (c) {
  24768. case '/':
  24769. // completely not allowed, even escaped.
  24770. // Should already be path-split by now.
  24771. return false
  24772. case '\\':
  24773. clearStateChar()
  24774. escaping = true
  24775. continue
  24776. // the various stateChar values
  24777. // for the "extglob" stuff.
  24778. case '?':
  24779. case '*':
  24780. case '+':
  24781. case '@':
  24782. case '!':
  24783. this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c)
  24784. // all of those are literals inside a class, except that
  24785. // the glob [!a] means [^a] in regexp
  24786. if (inClass) {
  24787. this.debug(' in class')
  24788. if (c === '!' && i === classStart + 1) c = '^'
  24789. re += c
  24790. continue
  24791. }
  24792. // if we already have a stateChar, then it means
  24793. // that there was something like ** or +? in there.
  24794. // Handle the stateChar, then proceed with this one.
  24795. self.debug('call clearStateChar %j', stateChar)
  24796. clearStateChar()
  24797. stateChar = c
  24798. // if extglob is disabled, then +(asdf|foo) isn't a thing.
  24799. // just clear the statechar *now*, rather than even diving into
  24800. // the patternList stuff.
  24801. if (options.noext) clearStateChar()
  24802. continue
  24803. case '(':
  24804. if (inClass) {
  24805. re += '('
  24806. continue
  24807. }
  24808. if (!stateChar) {
  24809. re += '\\('
  24810. continue
  24811. }
  24812. plType = stateChar
  24813. patternListStack.push({
  24814. type: plType,
  24815. start: i - 1,
  24816. reStart: re.length
  24817. })
  24818. // negation is (?:(?!js)[^/]*)
  24819. re += stateChar === '!' ? '(?:(?!(?:' : '(?:'
  24820. this.debug('plType %j %j', stateChar, re)
  24821. stateChar = false
  24822. continue
  24823. case ')':
  24824. if (inClass || !patternListStack.length) {
  24825. re += '\\)'
  24826. continue
  24827. }
  24828. clearStateChar()
  24829. hasMagic = true
  24830. re += ')'
  24831. var pl = patternListStack.pop()
  24832. plType = pl.type
  24833. // negation is (?:(?!js)[^/]*)
  24834. // The others are (?:<pattern>)<type>
  24835. switch (plType) {
  24836. case '!':
  24837. negativeLists.push(pl)
  24838. re += ')[^/]*?)'
  24839. pl.reEnd = re.length
  24840. break
  24841. case '?':
  24842. case '+':
  24843. case '*':
  24844. re += plType
  24845. break
  24846. case '@': break // the default anyway
  24847. }
  24848. continue
  24849. case '|':
  24850. if (inClass || !patternListStack.length || escaping) {
  24851. re += '\\|'
  24852. escaping = false
  24853. continue
  24854. }
  24855. clearStateChar()
  24856. re += '|'
  24857. continue
  24858. // these are mostly the same in regexp and glob
  24859. case '[':
  24860. // swallow any state-tracking char before the [
  24861. clearStateChar()
  24862. if (inClass) {
  24863. re += '\\' + c
  24864. continue
  24865. }
  24866. inClass = true
  24867. classStart = i
  24868. reClassStart = re.length
  24869. re += c
  24870. continue
  24871. case ']':
  24872. // a right bracket shall lose its special
  24873. // meaning and represent itself in
  24874. // a bracket expression if it occurs
  24875. // first in the list. -- POSIX.2 2.8.3.2
  24876. if (i === classStart + 1 || !inClass) {
  24877. re += '\\' + c
  24878. escaping = false
  24879. continue
  24880. }
  24881. // handle the case where we left a class open.
  24882. // "[z-a]" is valid, equivalent to "\[z-a\]"
  24883. if (inClass) {
  24884. // split where the last [ was, make sure we don't have
  24885. // an invalid re. if so, re-walk the contents of the
  24886. // would-be class to re-translate any characters that
  24887. // were passed through as-is
  24888. // TODO: It would probably be faster to determine this
  24889. // without a try/catch and a new RegExp, but it's tricky
  24890. // to do safely. For now, this is safe and works.
  24891. var cs = pattern.substring(classStart + 1, i)
  24892. try {
  24893. RegExp('[' + cs + ']')
  24894. } catch (er) {
  24895. // not a valid class!
  24896. var sp = this.parse(cs, SUBPARSE)
  24897. re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'
  24898. hasMagic = hasMagic || sp[1]
  24899. inClass = false
  24900. continue
  24901. }
  24902. }
  24903. // finish up the class.
  24904. hasMagic = true
  24905. inClass = false
  24906. re += c
  24907. continue
  24908. default:
  24909. // swallow any state char that wasn't consumed
  24910. clearStateChar()
  24911. if (escaping) {
  24912. // no need
  24913. escaping = false
  24914. } else if (reSpecials[c]
  24915. && !(c === '^' && inClass)) {
  24916. re += '\\'
  24917. }
  24918. re += c
  24919. } // switch
  24920. } // for
  24921. // handle the case where we left a class open.
  24922. // "[abc" is valid, equivalent to "\[abc"
  24923. if (inClass) {
  24924. // split where the last [ was, and escape it
  24925. // this is a huge pita. We now have to re-walk
  24926. // the contents of the would-be class to re-translate
  24927. // any characters that were passed through as-is
  24928. cs = pattern.substr(classStart + 1)
  24929. sp = this.parse(cs, SUBPARSE)
  24930. re = re.substr(0, reClassStart) + '\\[' + sp[0]
  24931. hasMagic = hasMagic || sp[1]
  24932. }
  24933. // handle the case where we had a +( thing at the *end*
  24934. // of the pattern.
  24935. // each pattern list stack adds 3 chars, and we need to go through
  24936. // and escape any | chars that were passed through as-is for the regexp.
  24937. // Go through and escape them, taking care not to double-escape any
  24938. // | chars that were already escaped.
  24939. for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
  24940. var tail = re.slice(pl.reStart + 3)
  24941. // maybe some even number of \, then maybe 1 \, followed by a |
  24942. tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) {
  24943. if (!$2) {
  24944. // the | isn't already escaped, so escape it.
  24945. $2 = '\\'
  24946. }
  24947. // need to escape all those slashes *again*, without escaping the
  24948. // one that we need for escaping the | character. As it works out,
  24949. // escaping an even number of slashes can be done by simply repeating
  24950. // it exactly after itself. That's why this trick works.
  24951. //
  24952. // I am sorry that you have to see this.
  24953. return $1 + $1 + $2 + '|'
  24954. })
  24955. this.debug('tail=%j\n %s', tail, tail)
  24956. var t = pl.type === '*' ? star
  24957. : pl.type === '?' ? qmark
  24958. : '\\' + pl.type
  24959. hasMagic = true
  24960. re = re.slice(0, pl.reStart) + t + '\\(' + tail
  24961. }
  24962. // handle trailing things that only matter at the very end.
  24963. clearStateChar()
  24964. if (escaping) {
  24965. // trailing \\
  24966. re += '\\\\'
  24967. }
  24968. // only need to apply the nodot start if the re starts with
  24969. // something that could conceivably capture a dot
  24970. var addPatternStart = false
  24971. switch (re.charAt(0)) {
  24972. case '.':
  24973. case '[':
  24974. case '(': addPatternStart = true
  24975. }
  24976. // Hack to work around lack of negative lookbehind in JS
  24977. // A pattern like: *.!(x).!(y|z) needs to ensure that a name
  24978. // like 'a.xyz.yz' doesn't match. So, the first negative
  24979. // lookahead, has to look ALL the way ahead, to the end of
  24980. // the pattern.
  24981. for (var n = negativeLists.length - 1; n > -1; n--) {
  24982. var nl = negativeLists[n]
  24983. var nlBefore = re.slice(0, nl.reStart)
  24984. var nlFirst = re.slice(nl.reStart, nl.reEnd - 8)
  24985. var nlLast = re.slice(nl.reEnd - 8, nl.reEnd)
  24986. var nlAfter = re.slice(nl.reEnd)
  24987. nlLast += nlAfter
  24988. // Handle nested stuff like *(*.js|!(*.json)), where open parens
  24989. // mean that we should *not* include the ) in the bit that is considered
  24990. // "after" the negated section.
  24991. var openParensBefore = nlBefore.split('(').length - 1
  24992. var cleanAfter = nlAfter
  24993. for (i = 0; i < openParensBefore; i++) {
  24994. cleanAfter = cleanAfter.replace(/\)[+*?]?/, '')
  24995. }
  24996. nlAfter = cleanAfter
  24997. var dollar = ''
  24998. if (nlAfter === '' && isSub !== SUBPARSE) {
  24999. dollar = '$'
  25000. }
  25001. var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast
  25002. re = newRe
  25003. }
  25004. // if the re is not "" at this point, then we need to make sure
  25005. // it doesn't match against an empty path part.
  25006. // Otherwise a/* will match a/, which it should not.
  25007. if (re !== '' && hasMagic) {
  25008. re = '(?=.)' + re
  25009. }
  25010. if (addPatternStart) {
  25011. re = patternStart + re
  25012. }
  25013. // parsing just a piece of a larger pattern.
  25014. if (isSub === SUBPARSE) {
  25015. return [re, hasMagic]
  25016. }
  25017. // skip the regexp for non-magical patterns
  25018. // unescape anything in it, though, so that it'll be
  25019. // an exact match against a file etc.
  25020. if (!hasMagic) {
  25021. return globUnescape(pattern)
  25022. }
  25023. var flags = options.nocase ? 'i' : ''
  25024. try {
  25025. var regExp = new RegExp('^' + re + '$', flags)
  25026. } catch (er) {
  25027. // If it was an invalid regular expression, then it can't match
  25028. // anything. This trick looks for a character after the end of
  25029. // the string, which is of course impossible, except in multi-line
  25030. // mode, but it's not a /m regex.
  25031. return new RegExp('$.')
  25032. }
  25033. regExp._glob = pattern
  25034. regExp._src = re
  25035. return regExp
  25036. }
  25037. minimatch.makeRe = function (pattern, options) {
  25038. return new Minimatch(pattern, options || {}).makeRe()
  25039. }
  25040. Minimatch.prototype.makeRe = makeRe
  25041. function makeRe () {
  25042. if (this.regexp || this.regexp === false) return this.regexp
  25043. // at this point, this.set is a 2d array of partial
  25044. // pattern strings, or "**".
  25045. //
  25046. // It's better to use .match(). This function shouldn't
  25047. // be used, really, but it's pretty convenient sometimes,
  25048. // when you just want to work with a regex.
  25049. var set = this.set
  25050. if (!set.length) {
  25051. this.regexp = false
  25052. return this.regexp
  25053. }
  25054. var options = this.options
  25055. var twoStar = options.noglobstar ? star
  25056. : options.dot ? twoStarDot
  25057. : twoStarNoDot
  25058. var flags = options.nocase ? 'i' : ''
  25059. var re = set.map(function (pattern) {
  25060. return pattern.map(function (p) {
  25061. return (p === GLOBSTAR) ? twoStar
  25062. : (typeof p === 'string') ? regExpEscape(p)
  25063. : p._src
  25064. }).join('\\\/')
  25065. }).join('|')
  25066. // must match entire pattern
  25067. // ending in a * or ** will make it less strict.
  25068. re = '^(?:' + re + ')$'
  25069. // can match anything, as long as it's not this.
  25070. if (this.negate) re = '^(?!' + re + ').*$'
  25071. try {
  25072. this.regexp = new RegExp(re, flags)
  25073. } catch (ex) {
  25074. this.regexp = false
  25075. }
  25076. return this.regexp
  25077. }
  25078. minimatch.match = function (list, pattern, options) {
  25079. options = options || {}
  25080. var mm = new Minimatch(pattern, options)
  25081. list = list.filter(function (f) {
  25082. return mm.match(f)
  25083. })
  25084. if (mm.options.nonull && !list.length) {
  25085. list.push(pattern)
  25086. }
  25087. return list
  25088. }
  25089. Minimatch.prototype.match = match
  25090. function match (f, partial) {
  25091. this.debug('match', f, this.pattern)
  25092. // short-circuit in the case of busted things.
  25093. // comments, etc.
  25094. if (this.comment) return false
  25095. if (this.empty) return f === ''
  25096. if (f === '/' && partial) return true
  25097. var options = this.options
  25098. // windows: need to use /, not \
  25099. if (path.sep !== '/') {
  25100. f = f.split(path.sep).join('/')
  25101. }
  25102. // treat the test path as a set of pathparts.
  25103. f = f.split(slashSplit)
  25104. this.debug(this.pattern, 'split', f)
  25105. // just ONE of the pattern sets in this.set needs to match
  25106. // in order for it to be valid. If negating, then just one
  25107. // match means that we have failed.
  25108. // Either way, return on the first hit.
  25109. var set = this.set
  25110. this.debug(this.pattern, 'set', set)
  25111. // Find the basename of the path by looking for the last non-empty segment
  25112. var filename
  25113. var i
  25114. for (i = f.length - 1; i >= 0; i--) {
  25115. filename = f[i]
  25116. if (filename) break
  25117. }
  25118. for (i = 0; i < set.length; i++) {
  25119. var pattern = set[i]
  25120. var file = f
  25121. if (options.matchBase && pattern.length === 1) {
  25122. file = [filename]
  25123. }
  25124. var hit = this.matchOne(file, pattern, partial)
  25125. if (hit) {
  25126. if (options.flipNegate) return true
  25127. return !this.negate
  25128. }
  25129. }
  25130. // didn't get any hits. this is success if it's a negative
  25131. // pattern, failure otherwise.
  25132. if (options.flipNegate) return false
  25133. return this.negate
  25134. }
  25135. // set partial to true to test if, for example,
  25136. // "/a/b" matches the start of "/*/b/*/d"
  25137. // Partial means, if you run out of file before you run
  25138. // out of pattern, then that's fine, as long as all
  25139. // the parts match.
  25140. Minimatch.prototype.matchOne = function (file, pattern, partial) {
  25141. var options = this.options
  25142. this.debug('matchOne',
  25143. { 'this': this, file: file, pattern: pattern })
  25144. this.debug('matchOne', file.length, pattern.length)
  25145. for (var fi = 0,
  25146. pi = 0,
  25147. fl = file.length,
  25148. pl = pattern.length
  25149. ; (fi < fl) && (pi < pl)
  25150. ; fi++, pi++) {
  25151. this.debug('matchOne loop')
  25152. var p = pattern[pi]
  25153. var f = file[fi]
  25154. this.debug(pattern, p, f)
  25155. // should be impossible.
  25156. // some invalid regexp stuff in the set.
  25157. if (p === false) return false
  25158. if (p === GLOBSTAR) {
  25159. this.debug('GLOBSTAR', [pattern, p, f])
  25160. // "**"
  25161. // a/**/b/**/c would match the following:
  25162. // a/b/x/y/z/c
  25163. // a/x/y/z/b/c
  25164. // a/b/x/b/x/c
  25165. // a/b/c
  25166. // To do this, take the rest of the pattern after
  25167. // the **, and see if it would match the file remainder.
  25168. // If so, return success.
  25169. // If not, the ** "swallows" a segment, and try again.
  25170. // This is recursively awful.
  25171. //
  25172. // a/**/b/**/c matching a/b/x/y/z/c
  25173. // - a matches a
  25174. // - doublestar
  25175. // - matchOne(b/x/y/z/c, b/**/c)
  25176. // - b matches b
  25177. // - doublestar
  25178. // - matchOne(x/y/z/c, c) -> no
  25179. // - matchOne(y/z/c, c) -> no
  25180. // - matchOne(z/c, c) -> no
  25181. // - matchOne(c, c) yes, hit
  25182. var fr = fi
  25183. var pr = pi + 1
  25184. if (pr === pl) {
  25185. this.debug('** at the end')
  25186. // a ** at the end will just swallow the rest.
  25187. // We have found a match.
  25188. // however, it will not swallow /.x, unless
  25189. // options.dot is set.
  25190. // . and .. are *never* matched by **, for explosively
  25191. // exponential reasons.
  25192. for (; fi < fl; fi++) {
  25193. if (file[fi] === '.' || file[fi] === '..' ||
  25194. (!options.dot && file[fi].charAt(0) === '.')) return false
  25195. }
  25196. return true
  25197. }
  25198. // ok, let's see if we can swallow whatever we can.
  25199. while (fr < fl) {
  25200. var swallowee = file[fr]
  25201. this.debug('\nglobstar while', file, fr, pattern, pr, swallowee)
  25202. // XXX remove this slice. Just pass the start index.
  25203. if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
  25204. this.debug('globstar found match!', fr, fl, swallowee)
  25205. // found a match.
  25206. return true
  25207. } else {
  25208. // can't swallow "." or ".." ever.
  25209. // can only swallow ".foo" when explicitly asked.
  25210. if (swallowee === '.' || swallowee === '..' ||
  25211. (!options.dot && swallowee.charAt(0) === '.')) {
  25212. this.debug('dot detected!', file, fr, pattern, pr)
  25213. break
  25214. }
  25215. // ** swallows a segment, and continue.
  25216. this.debug('globstar swallow a segment, and continue')
  25217. fr++
  25218. }
  25219. }
  25220. // no match was found.
  25221. // However, in partial mode, we can't say this is necessarily over.
  25222. // If there's more *pattern* left, then
  25223. if (partial) {
  25224. // ran out of file
  25225. this.debug('\n>>> no match, partial?', file, fr, pattern, pr)
  25226. if (fr === fl) return true
  25227. }
  25228. return false
  25229. }
  25230. // something other than **
  25231. // non-magic patterns just have to match exactly
  25232. // patterns with magic have been turned into regexps.
  25233. var hit
  25234. if (typeof p === 'string') {
  25235. if (options.nocase) {
  25236. hit = f.toLowerCase() === p.toLowerCase()
  25237. } else {
  25238. hit = f === p
  25239. }
  25240. this.debug('string match', p, f, hit)
  25241. } else {
  25242. hit = f.match(p)
  25243. this.debug('pattern match', p, f, hit)
  25244. }
  25245. if (!hit) return false
  25246. }
  25247. // Note: ending in / means that we'll get a final ""
  25248. // at the end of the pattern. This can only match a
  25249. // corresponding "" at the end of the file.
  25250. // If the file ends in /, then it can only match a
  25251. // a pattern that ends in /, unless the pattern just
  25252. // doesn't have any more for it. But, a/b/ should *not*
  25253. // match "a/b/*", even though "" matches against the
  25254. // [^/]*? pattern, except in partial mode, where it might
  25255. // simply not be reached yet.
  25256. // However, a/b/ should still satisfy a/*
  25257. // now either we fell off the end of the pattern, or we're done.
  25258. if (fi === fl && pi === pl) {
  25259. // ran out of pattern and filename at the same time.
  25260. // an exact hit!
  25261. return true
  25262. } else if (fi === fl) {
  25263. // ran out of file, but still had pattern left.
  25264. // this is ok if we're doing the match as part of
  25265. // a glob fs traversal.
  25266. return partial
  25267. } else if (pi === pl) {
  25268. // ran out of pattern, still have file left.
  25269. // this is only acceptable if we're on the very last
  25270. // empty segment of a file with a trailing slash.
  25271. // a/* should match a/b/
  25272. var emptyFileEnd = (fi === fl - 1) && (file[fi] === '')
  25273. return emptyFileEnd
  25274. }
  25275. // should be unreachable.
  25276. throw new Error('wtf?')
  25277. }
  25278. // replace stuff like \* with *
  25279. function globUnescape (s) {
  25280. return s.replace(/\\(.)/g, '$1')
  25281. }
  25282. function regExpEscape (s) {
  25283. return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')
  25284. }
  25285. /***/ },
  25286. /* 136 */
  25287. /***/ function(module, exports, __webpack_require__) {
  25288. "use strict";
  25289. 'use strict';
  25290. var map = __webpack_require__(134);
  25291. module.exports = Protocols;
  25292. function Protocols(proto) {
  25293. if (typeof proto === 'number') {
  25294. if (Protocols.codes[proto]) {
  25295. return Protocols.codes[proto];
  25296. }
  25297. throw new Error('no protocol with code: ' + proto);
  25298. } else if (typeof proto === 'string' || proto instanceof String) {
  25299. if (Protocols.names[proto]) {
  25300. return Protocols.names[proto];
  25301. }
  25302. throw new Error('no protocol with name: ' + proto);
  25303. }
  25304. throw new Error('invalid protocol id type: ' + proto);
  25305. }
  25306. Protocols.lengthPrefixedVarSize = -1;
  25307. // replicating table here to:
  25308. // 1. avoid parsing the csv
  25309. // 2. ensuring errors in the csv don't screw up code.
  25310. // 3. changing a number has to happen in two places.
  25311. Protocols.table = [[4, 32, 'ip4'], [6, 16, 'tcp'], [17, 16, 'udp'], [33, 16, 'dccp'], [41, 128, 'ip6'], [132, 16, 'sctp'],
  25312. // these require varint for the protocol code
  25313. [302, 0, 'utp'], [421, Protocols.lengthPrefixedVarSize, 'ipfs'], [480, 0, 'http'], [443, 0, 'https'], [477, 0, 'ws'], [275, 0, 'libp2p-webrtc-star']];
  25314. Protocols.names = {};
  25315. Protocols.codes = {};
  25316. // populate tables
  25317. map(Protocols.table, function (e) {
  25318. var proto = p.apply(this, e);
  25319. Protocols.codes[proto.code] = proto;
  25320. Protocols.names[proto.name] = proto;
  25321. });
  25322. Protocols.object = p;
  25323. function p(code, size, name) {
  25324. return { code: code, size: size, name: name };
  25325. }
  25326. /***/ },
  25327. /* 137 */
  25328. /***/ function(module, exports, __webpack_require__) {
  25329. "use strict";
  25330. /* WEBPACK VAR INJECTION */(function(process) {'use strict';
  25331. function posix(path) {
  25332. return path.charAt(0) === '/';
  25333. };
  25334. function win32(path) {
  25335. // https://github.com/joyent/node/blob/b3fcc245fb25539909ef1d5eaa01dbf92e168633/lib/path.js#L56
  25336. var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;
  25337. var result = splitDeviceRe.exec(path);
  25338. var device = result[1] || '';
  25339. var isUnc = !!device && device.charAt(1) !== ':';
  25340. // UNC paths are always absolute
  25341. return !!result[2] || isUnc;
  25342. };
  25343. module.exports = process.platform === 'win32' ? win32 : posix;
  25344. module.exports.posix = posix;
  25345. module.exports.win32 = win32;
  25346. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  25347. /***/ },
  25348. /* 138 */
  25349. /***/ function(module, exports, __webpack_require__) {
  25350. "use strict";
  25351. // a transform stream is a readable/writable stream where you do
  25352. // something with the data. Sometimes it's called a "filter",
  25353. // but that's not a great name for it, since that implies a thing where
  25354. // some bits pass through, and others are simply ignored. (That would
  25355. // be a valid example of a transform, of course.)
  25356. //
  25357. // While the output is causally related to the input, it's not a
  25358. // necessarily symmetric or synchronous transformation. For example,
  25359. // a zlib stream might take multiple plain-text writes(), and then
  25360. // emit a single compressed chunk some time in the future.
  25361. //
  25362. // Here's how this works:
  25363. //
  25364. // The Transform stream has all the aspects of the readable and writable
  25365. // stream classes. When you write(chunk), that calls _write(chunk,cb)
  25366. // internally, and returns false if there's a lot of pending writes
  25367. // buffered up. When you call read(), that calls _read(n) until
  25368. // there's enough pending readable data buffered up.
  25369. //
  25370. // In a transform stream, the written data is placed in a buffer. When
  25371. // _read(n) is called, it transforms the queued up data, calling the
  25372. // buffered _write cb's as it consumes chunks. If consuming a single
  25373. // written chunk would result in multiple output chunks, then the first
  25374. // outputted bit calls the readcb, and subsequent chunks just go into
  25375. // the read buffer, and will cause it to emit 'readable' if necessary.
  25376. //
  25377. // This way, back-pressure is actually determined by the reading side,
  25378. // since _read has to be called to start processing a new chunk. However,
  25379. // a pathological inflate type of transform can cause excessive buffering
  25380. // here. For example, imagine a stream where every byte of input is
  25381. // interpreted as an integer from 0-255, and then results in that many
  25382. // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
  25383. // 1kb of data being output. In this case, you could write a very small
  25384. // amount of input, and end up with a very large amount of output. In
  25385. // such a pathological inflating mechanism, there'd be no way to tell
  25386. // the system to stop doing the transform. A single 4MB write could
  25387. // cause the system to run out of memory.
  25388. //
  25389. // However, even in such a pathological case, only a single written chunk
  25390. // would be consumed, and then the rest would wait (un-transformed) until
  25391. // the results of the previous transformed chunk were consumed.
  25392. 'use strict';
  25393. module.exports = Transform;
  25394. var Duplex = __webpack_require__(55);
  25395. /*<replacement>*/
  25396. var util = __webpack_require__(14);
  25397. util.inherits = __webpack_require__(2);
  25398. /*</replacement>*/
  25399. util.inherits(Transform, Duplex);
  25400. function TransformState(stream) {
  25401. this.afterTransform = function (er, data) {
  25402. return afterTransform(stream, er, data);
  25403. };
  25404. this.needTransform = false;
  25405. this.transforming = false;
  25406. this.writecb = null;
  25407. this.writechunk = null;
  25408. this.writeencoding = null;
  25409. }
  25410. function afterTransform(stream, er, data) {
  25411. var ts = stream._transformState;
  25412. ts.transforming = false;
  25413. var cb = ts.writecb;
  25414. if (!cb) return stream.emit('error', new Error('no writecb in Transform class'));
  25415. ts.writechunk = null;
  25416. ts.writecb = null;
  25417. if (data !== null && data !== undefined) stream.push(data);
  25418. cb(er);
  25419. var rs = stream._readableState;
  25420. rs.reading = false;
  25421. if (rs.needReadable || rs.length < rs.highWaterMark) {
  25422. stream._read(rs.highWaterMark);
  25423. }
  25424. }
  25425. function Transform(options) {
  25426. if (!(this instanceof Transform)) return new Transform(options);
  25427. Duplex.call(this, options);
  25428. this._transformState = new TransformState(this);
  25429. // when the writable side finishes, then flush out anything remaining.
  25430. var stream = this;
  25431. // start out asking for a readable event once data is transformed.
  25432. this._readableState.needReadable = true;
  25433. // we have implemented the _read method, and done the other things
  25434. // that Readable wants before the first _read call, so unset the
  25435. // sync guard flag.
  25436. this._readableState.sync = false;
  25437. if (options) {
  25438. if (typeof options.transform === 'function') this._transform = options.transform;
  25439. if (typeof options.flush === 'function') this._flush = options.flush;
  25440. }
  25441. this.once('prefinish', function () {
  25442. if (typeof this._flush === 'function') this._flush(function (er) {
  25443. done(stream, er);
  25444. });else done(stream);
  25445. });
  25446. }
  25447. Transform.prototype.push = function (chunk, encoding) {
  25448. this._transformState.needTransform = false;
  25449. return Duplex.prototype.push.call(this, chunk, encoding);
  25450. };
  25451. // This is the part where you do stuff!
  25452. // override this function in implementation classes.
  25453. // 'chunk' is an input chunk.
  25454. //
  25455. // Call `push(newChunk)` to pass along transformed output
  25456. // to the readable side. You may call 'push' zero or more times.
  25457. //
  25458. // Call `cb(err)` when you are done with this chunk. If you pass
  25459. // an error, then that'll put the hurt on the whole operation. If you
  25460. // never call cb(), then you'll never get another chunk.
  25461. Transform.prototype._transform = function (chunk, encoding, cb) {
  25462. throw new Error('not implemented');
  25463. };
  25464. Transform.prototype._write = function (chunk, encoding, cb) {
  25465. var ts = this._transformState;
  25466. ts.writecb = cb;
  25467. ts.writechunk = chunk;
  25468. ts.writeencoding = encoding;
  25469. if (!ts.transforming) {
  25470. var rs = this._readableState;
  25471. if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
  25472. }
  25473. };
  25474. // Doesn't matter what the args are here.
  25475. // _transform does all the work.
  25476. // That we got here means that the readable side wants more data.
  25477. Transform.prototype._read = function (n) {
  25478. var ts = this._transformState;
  25479. if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
  25480. ts.transforming = true;
  25481. this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
  25482. } else {
  25483. // mark that we need a transform, so that any data that comes in
  25484. // will get processed, now that we've asked for it.
  25485. ts.needTransform = true;
  25486. }
  25487. };
  25488. function done(stream, er) {
  25489. if (er) return stream.emit('error', er);
  25490. // if there's nothing in the write buffer, then that means
  25491. // that nothing more will ever be provided
  25492. var ws = stream._writableState;
  25493. var ts = stream._transformState;
  25494. if (ws.length) throw new Error('calling transform done when ws.length != 0');
  25495. if (ts.transforming) throw new Error('calling transform done when still transforming');
  25496. return stream.push(null);
  25497. }
  25498. /***/ },
  25499. /* 139 */
  25500. /***/ function(module, exports, __webpack_require__) {
  25501. "use strict";
  25502. /* WEBPACK VAR INJECTION */(function(process, setImmediate) {// A bit simpler than readable streams.
  25503. // Implement an async ._write(chunk, encoding, cb), and it'll handle all
  25504. // the drain event emission and buffering.
  25505. 'use strict';
  25506. module.exports = Writable;
  25507. /*<replacement>*/
  25508. var processNextTick = __webpack_require__(64);
  25509. /*</replacement>*/
  25510. /*<replacement>*/
  25511. var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick;
  25512. /*</replacement>*/
  25513. /*<replacement>*/
  25514. var Buffer = __webpack_require__(1).Buffer;
  25515. /*</replacement>*/
  25516. Writable.WritableState = WritableState;
  25517. /*<replacement>*/
  25518. var util = __webpack_require__(14);
  25519. util.inherits = __webpack_require__(2);
  25520. /*</replacement>*/
  25521. /*<replacement>*/
  25522. var internalUtil = {
  25523. deprecate: __webpack_require__(227)
  25524. };
  25525. /*</replacement>*/
  25526. /*<replacement>*/
  25527. var Stream;
  25528. (function () {
  25529. try {
  25530. Stream = __webpack_require__(9);
  25531. } catch (_) {} finally {
  25532. if (!Stream) Stream = __webpack_require__(30).EventEmitter;
  25533. }
  25534. })();
  25535. /*</replacement>*/
  25536. var Buffer = __webpack_require__(1).Buffer;
  25537. util.inherits(Writable, Stream);
  25538. function nop() {}
  25539. function WriteReq(chunk, encoding, cb) {
  25540. this.chunk = chunk;
  25541. this.encoding = encoding;
  25542. this.callback = cb;
  25543. this.next = null;
  25544. }
  25545. var Duplex;
  25546. function WritableState(options, stream) {
  25547. Duplex = Duplex || __webpack_require__(55);
  25548. options = options || {};
  25549. // object stream flag to indicate whether or not this stream
  25550. // contains buffers or objects.
  25551. this.objectMode = !!options.objectMode;
  25552. if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
  25553. // the point at which write() starts returning false
  25554. // Note: 0 is a valid value, means that we always return false if
  25555. // the entire buffer is not flushed immediately on write()
  25556. var hwm = options.highWaterMark;
  25557. var defaultHwm = this.objectMode ? 16 : 16 * 1024;
  25558. this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
  25559. // cast to ints.
  25560. this.highWaterMark = ~ ~this.highWaterMark;
  25561. this.needDrain = false;
  25562. // at the start of calling end()
  25563. this.ending = false;
  25564. // when end() has been called, and returned
  25565. this.ended = false;
  25566. // when 'finish' is emitted
  25567. this.finished = false;
  25568. // should we decode strings into buffers before passing to _write?
  25569. // this is here so that some node-core streams can optimize string
  25570. // handling at a lower level.
  25571. var noDecode = options.decodeStrings === false;
  25572. this.decodeStrings = !noDecode;
  25573. // Crypto is kind of old and crusty. Historically, its default string
  25574. // encoding is 'binary' so we have to make this configurable.
  25575. // Everything else in the universe uses 'utf8', though.
  25576. this.defaultEncoding = options.defaultEncoding || 'utf8';
  25577. // not an actual buffer we keep track of, but a measurement
  25578. // of how much we're waiting to get pushed to some underlying
  25579. // socket or file.
  25580. this.length = 0;
  25581. // a flag to see when we're in the middle of a write.
  25582. this.writing = false;
  25583. // when true all writes will be buffered until .uncork() call
  25584. this.corked = 0;
  25585. // a flag to be able to tell if the onwrite cb is called immediately,
  25586. // or on a later tick. We set this to true at first, because any
  25587. // actions that shouldn't happen until "later" should generally also
  25588. // not happen before the first write call.
  25589. this.sync = true;
  25590. // a flag to know if we're processing previously buffered items, which
  25591. // may call the _write() callback in the same tick, so that we don't
  25592. // end up in an overlapped onwrite situation.
  25593. this.bufferProcessing = false;
  25594. // the callback that's passed to _write(chunk,cb)
  25595. this.onwrite = function (er) {
  25596. onwrite(stream, er);
  25597. };
  25598. // the callback that the user supplies to write(chunk,encoding,cb)
  25599. this.writecb = null;
  25600. // the amount that is being written when _write is called.
  25601. this.writelen = 0;
  25602. this.bufferedRequest = null;
  25603. this.lastBufferedRequest = null;
  25604. // number of pending user-supplied write callbacks
  25605. // this must be 0 before 'finish' can be emitted
  25606. this.pendingcb = 0;
  25607. // emit prefinish if the only thing we're waiting for is _write cbs
  25608. // This is relevant for synchronous Transform streams
  25609. this.prefinished = false;
  25610. // True if the error was already emitted and should not be thrown again
  25611. this.errorEmitted = false;
  25612. // count buffered requests
  25613. this.bufferedRequestCount = 0;
  25614. // create the two objects needed to store the corked requests
  25615. // they are not a linked list, as no new elements are inserted in there
  25616. this.corkedRequestsFree = new CorkedRequest(this);
  25617. this.corkedRequestsFree.next = new CorkedRequest(this);
  25618. }
  25619. WritableState.prototype.getBuffer = function writableStateGetBuffer() {
  25620. var current = this.bufferedRequest;
  25621. var out = [];
  25622. while (current) {
  25623. out.push(current);
  25624. current = current.next;
  25625. }
  25626. return out;
  25627. };
  25628. (function () {
  25629. try {
  25630. Object.defineProperty(WritableState.prototype, 'buffer', {
  25631. get: internalUtil.deprecate(function () {
  25632. return this.getBuffer();
  25633. }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.')
  25634. });
  25635. } catch (_) {}
  25636. })();
  25637. var Duplex;
  25638. function Writable(options) {
  25639. Duplex = Duplex || __webpack_require__(55);
  25640. // Writable ctor is applied to Duplexes, though they're not
  25641. // instanceof Writable, they're instanceof Readable.
  25642. if (!(this instanceof Writable) && !(this instanceof Duplex)) return new Writable(options);
  25643. this._writableState = new WritableState(options, this);
  25644. // legacy.
  25645. this.writable = true;
  25646. if (options) {
  25647. if (typeof options.write === 'function') this._write = options.write;
  25648. if (typeof options.writev === 'function') this._writev = options.writev;
  25649. }
  25650. Stream.call(this);
  25651. }
  25652. // Otherwise people can pipe Writable streams, which is just wrong.
  25653. Writable.prototype.pipe = function () {
  25654. this.emit('error', new Error('Cannot pipe. Not readable.'));
  25655. };
  25656. function writeAfterEnd(stream, cb) {
  25657. var er = new Error('write after end');
  25658. // TODO: defer error events consistently everywhere, not just the cb
  25659. stream.emit('error', er);
  25660. processNextTick(cb, er);
  25661. }
  25662. // If we get something that is not a buffer, string, null, or undefined,
  25663. // and we're not in objectMode, then that's an error.
  25664. // Otherwise stream chunks are all considered to be of length=1, and the
  25665. // watermarks determine how many objects to keep in the buffer, rather than
  25666. // how many bytes or characters.
  25667. function validChunk(stream, state, chunk, cb) {
  25668. var valid = true;
  25669. if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== null && chunk !== undefined && !state.objectMode) {
  25670. var er = new TypeError('Invalid non-string/buffer chunk');
  25671. stream.emit('error', er);
  25672. processNextTick(cb, er);
  25673. valid = false;
  25674. }
  25675. return valid;
  25676. }
  25677. Writable.prototype.write = function (chunk, encoding, cb) {
  25678. var state = this._writableState;
  25679. var ret = false;
  25680. if (typeof encoding === 'function') {
  25681. cb = encoding;
  25682. encoding = null;
  25683. }
  25684. if (Buffer.isBuffer(chunk)) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
  25685. if (typeof cb !== 'function') cb = nop;
  25686. if (state.ended) writeAfterEnd(this, cb);else if (validChunk(this, state, chunk, cb)) {
  25687. state.pendingcb++;
  25688. ret = writeOrBuffer(this, state, chunk, encoding, cb);
  25689. }
  25690. return ret;
  25691. };
  25692. Writable.prototype.cork = function () {
  25693. var state = this._writableState;
  25694. state.corked++;
  25695. };
  25696. Writable.prototype.uncork = function () {
  25697. var state = this._writableState;
  25698. if (state.corked) {
  25699. state.corked--;
  25700. if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
  25701. }
  25702. };
  25703. Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
  25704. // node::ParseEncoding() requires lower case.
  25705. if (typeof encoding === 'string') encoding = encoding.toLowerCase();
  25706. if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
  25707. this._writableState.defaultEncoding = encoding;
  25708. };
  25709. function decodeChunk(state, chunk, encoding) {
  25710. if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
  25711. chunk = new Buffer(chunk, encoding);
  25712. }
  25713. return chunk;
  25714. }
  25715. // if we're already writing something, then just put this
  25716. // in the queue, and wait our turn. Otherwise, call _write
  25717. // If we return false, then we need a drain event, so set that flag.
  25718. function writeOrBuffer(stream, state, chunk, encoding, cb) {
  25719. chunk = decodeChunk(state, chunk, encoding);
  25720. if (Buffer.isBuffer(chunk)) encoding = 'buffer';
  25721. var len = state.objectMode ? 1 : chunk.length;
  25722. state.length += len;
  25723. var ret = state.length < state.highWaterMark;
  25724. // we must ensure that previous needDrain will not be reset to false.
  25725. if (!ret) state.needDrain = true;
  25726. if (state.writing || state.corked) {
  25727. var last = state.lastBufferedRequest;
  25728. state.lastBufferedRequest = new WriteReq(chunk, encoding, cb);
  25729. if (last) {
  25730. last.next = state.lastBufferedRequest;
  25731. } else {
  25732. state.bufferedRequest = state.lastBufferedRequest;
  25733. }
  25734. state.bufferedRequestCount += 1;
  25735. } else {
  25736. doWrite(stream, state, false, len, chunk, encoding, cb);
  25737. }
  25738. return ret;
  25739. }
  25740. function doWrite(stream, state, writev, len, chunk, encoding, cb) {
  25741. state.writelen = len;
  25742. state.writecb = cb;
  25743. state.writing = true;
  25744. state.sync = true;
  25745. if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
  25746. state.sync = false;
  25747. }
  25748. function onwriteError(stream, state, sync, er, cb) {
  25749. --state.pendingcb;
  25750. if (sync) processNextTick(cb, er);else cb(er);
  25751. stream._writableState.errorEmitted = true;
  25752. stream.emit('error', er);
  25753. }
  25754. function onwriteStateUpdate(state) {
  25755. state.writing = false;
  25756. state.writecb = null;
  25757. state.length -= state.writelen;
  25758. state.writelen = 0;
  25759. }
  25760. function onwrite(stream, er) {
  25761. var state = stream._writableState;
  25762. var sync = state.sync;
  25763. var cb = state.writecb;
  25764. onwriteStateUpdate(state);
  25765. if (er) onwriteError(stream, state, sync, er, cb);else {
  25766. // Check if we're actually ready to finish, but don't emit yet
  25767. var finished = needFinish(state);
  25768. if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
  25769. clearBuffer(stream, state);
  25770. }
  25771. if (sync) {
  25772. /*<replacement>*/
  25773. asyncWrite(afterWrite, stream, state, finished, cb);
  25774. /*</replacement>*/
  25775. } else {
  25776. afterWrite(stream, state, finished, cb);
  25777. }
  25778. }
  25779. }
  25780. function afterWrite(stream, state, finished, cb) {
  25781. if (!finished) onwriteDrain(stream, state);
  25782. state.pendingcb--;
  25783. cb();
  25784. finishMaybe(stream, state);
  25785. }
  25786. // Must force callback to be called on nextTick, so that we don't
  25787. // emit 'drain' before the write() consumer gets the 'false' return
  25788. // value, and has a chance to attach a 'drain' listener.
  25789. function onwriteDrain(stream, state) {
  25790. if (state.length === 0 && state.needDrain) {
  25791. state.needDrain = false;
  25792. stream.emit('drain');
  25793. }
  25794. }
  25795. // if there's something in the buffer waiting, then process it
  25796. function clearBuffer(stream, state) {
  25797. state.bufferProcessing = true;
  25798. var entry = state.bufferedRequest;
  25799. if (stream._writev && entry && entry.next) {
  25800. // Fast case, write everything using _writev()
  25801. var l = state.bufferedRequestCount;
  25802. var buffer = new Array(l);
  25803. var holder = state.corkedRequestsFree;
  25804. holder.entry = entry;
  25805. var count = 0;
  25806. while (entry) {
  25807. buffer[count] = entry;
  25808. entry = entry.next;
  25809. count += 1;
  25810. }
  25811. doWrite(stream, state, true, state.length, buffer, '', holder.finish);
  25812. // doWrite is always async, defer these to save a bit of time
  25813. // as the hot path ends with doWrite
  25814. state.pendingcb++;
  25815. state.lastBufferedRequest = null;
  25816. state.corkedRequestsFree = holder.next;
  25817. holder.next = null;
  25818. } else {
  25819. // Slow case, write chunks one-by-one
  25820. while (entry) {
  25821. var chunk = entry.chunk;
  25822. var encoding = entry.encoding;
  25823. var cb = entry.callback;
  25824. var len = state.objectMode ? 1 : chunk.length;
  25825. doWrite(stream, state, false, len, chunk, encoding, cb);
  25826. entry = entry.next;
  25827. // if we didn't call the onwrite immediately, then
  25828. // it means that we need to wait until it does.
  25829. // also, that means that the chunk and cb are currently
  25830. // being processed, so move the buffer counter past them.
  25831. if (state.writing) {
  25832. break;
  25833. }
  25834. }
  25835. if (entry === null) state.lastBufferedRequest = null;
  25836. }
  25837. state.bufferedRequestCount = 0;
  25838. state.bufferedRequest = entry;
  25839. state.bufferProcessing = false;
  25840. }
  25841. Writable.prototype._write = function (chunk, encoding, cb) {
  25842. cb(new Error('not implemented'));
  25843. };
  25844. Writable.prototype._writev = null;
  25845. Writable.prototype.end = function (chunk, encoding, cb) {
  25846. var state = this._writableState;
  25847. if (typeof chunk === 'function') {
  25848. cb = chunk;
  25849. chunk = null;
  25850. encoding = null;
  25851. } else if (typeof encoding === 'function') {
  25852. cb = encoding;
  25853. encoding = null;
  25854. }
  25855. if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
  25856. // .end() fully uncorks
  25857. if (state.corked) {
  25858. state.corked = 1;
  25859. this.uncork();
  25860. }
  25861. // ignore unnecessary end() calls.
  25862. if (!state.ending && !state.finished) endWritable(this, state, cb);
  25863. };
  25864. function needFinish(state) {
  25865. return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
  25866. }
  25867. function prefinish(stream, state) {
  25868. if (!state.prefinished) {
  25869. state.prefinished = true;
  25870. stream.emit('prefinish');
  25871. }
  25872. }
  25873. function finishMaybe(stream, state) {
  25874. var need = needFinish(state);
  25875. if (need) {
  25876. if (state.pendingcb === 0) {
  25877. prefinish(stream, state);
  25878. state.finished = true;
  25879. stream.emit('finish');
  25880. } else {
  25881. prefinish(stream, state);
  25882. }
  25883. }
  25884. return need;
  25885. }
  25886. function endWritable(stream, state, cb) {
  25887. state.ending = true;
  25888. finishMaybe(stream, state);
  25889. if (cb) {
  25890. if (state.finished) processNextTick(cb);else stream.once('finish', cb);
  25891. }
  25892. state.ended = true;
  25893. stream.writable = false;
  25894. }
  25895. // It seems a linked list but it is not
  25896. // there will be only 2 of these for each stream
  25897. function CorkedRequest(state) {
  25898. var _this = this;
  25899. this.next = null;
  25900. this.entry = null;
  25901. this.finish = function (err) {
  25902. var entry = _this.entry;
  25903. _this.entry = null;
  25904. while (entry) {
  25905. var cb = entry.callback;
  25906. state.pendingcb--;
  25907. cb(err);
  25908. entry = entry.next;
  25909. }
  25910. if (state.corkedRequestsFree) {
  25911. state.corkedRequestsFree.next = _this;
  25912. } else {
  25913. state.corkedRequestsFree = _this;
  25914. }
  25915. };
  25916. }
  25917. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4), __webpack_require__(74).setImmediate))
  25918. /***/ },
  25919. /* 140 */
  25920. /***/ function(module, exports, __webpack_require__) {
  25921. var inherits = __webpack_require__(2);
  25922. var Reporter = __webpack_require__(67).Reporter;
  25923. var Buffer = __webpack_require__(1).Buffer;
  25924. function DecoderBuffer(base, options) {
  25925. Reporter.call(this, options);
  25926. if (!Buffer.isBuffer(base)) {
  25927. this.error('Input not Buffer');
  25928. return;
  25929. }
  25930. this.base = base;
  25931. this.offset = 0;
  25932. this.length = base.length;
  25933. }
  25934. inherits(DecoderBuffer, Reporter);
  25935. exports.DecoderBuffer = DecoderBuffer;
  25936. DecoderBuffer.prototype.save = function save() {
  25937. return { offset: this.offset, reporter: Reporter.prototype.save.call(this) };
  25938. };
  25939. DecoderBuffer.prototype.restore = function restore(save) {
  25940. // Return skipped data
  25941. var res = new DecoderBuffer(this.base);
  25942. res.offset = save.offset;
  25943. res.length = this.offset;
  25944. this.offset = save.offset;
  25945. Reporter.prototype.restore.call(this, save.reporter);
  25946. return res;
  25947. };
  25948. DecoderBuffer.prototype.isEmpty = function isEmpty() {
  25949. return this.offset === this.length;
  25950. };
  25951. DecoderBuffer.prototype.readUInt8 = function readUInt8(fail) {
  25952. if (this.offset + 1 <= this.length)
  25953. return this.base.readUInt8(this.offset++, true);
  25954. else
  25955. return this.error(fail || 'DecoderBuffer overrun');
  25956. }
  25957. DecoderBuffer.prototype.skip = function skip(bytes, fail) {
  25958. if (!(this.offset + bytes <= this.length))
  25959. return this.error(fail || 'DecoderBuffer overrun');
  25960. var res = new DecoderBuffer(this.base);
  25961. // Share reporter state
  25962. res._reporterState = this._reporterState;
  25963. res.offset = this.offset;
  25964. res.length = this.offset + bytes;
  25965. this.offset += bytes;
  25966. return res;
  25967. }
  25968. DecoderBuffer.prototype.raw = function raw(save) {
  25969. return this.base.slice(save ? save.offset : this.offset, this.length);
  25970. }
  25971. function EncoderBuffer(value, reporter) {
  25972. if (Array.isArray(value)) {
  25973. this.length = 0;
  25974. this.value = value.map(function(item) {
  25975. if (!(item instanceof EncoderBuffer))
  25976. item = new EncoderBuffer(item, reporter);
  25977. this.length += item.length;
  25978. return item;
  25979. }, this);
  25980. } else if (typeof value === 'number') {
  25981. if (!(0 <= value && value <= 0xff))
  25982. return reporter.error('non-byte EncoderBuffer value');
  25983. this.value = value;
  25984. this.length = 1;
  25985. } else if (typeof value === 'string') {
  25986. this.value = value;
  25987. this.length = Buffer.byteLength(value);
  25988. } else if (Buffer.isBuffer(value)) {
  25989. this.value = value;
  25990. this.length = value.length;
  25991. } else {
  25992. return reporter.error('Unsupported type: ' + typeof value);
  25993. }
  25994. }
  25995. exports.EncoderBuffer = EncoderBuffer;
  25996. EncoderBuffer.prototype.join = function join(out, offset) {
  25997. if (!out)
  25998. out = new Buffer(this.length);
  25999. if (!offset)
  26000. offset = 0;
  26001. if (this.length === 0)
  26002. return out;
  26003. if (Array.isArray(this.value)) {
  26004. this.value.forEach(function(item) {
  26005. item.join(out, offset);
  26006. offset += item.length;
  26007. });
  26008. } else {
  26009. if (typeof this.value === 'number')
  26010. out[offset] = this.value;
  26011. else if (typeof this.value === 'string')
  26012. out.write(this.value, offset);
  26013. else if (Buffer.isBuffer(this.value))
  26014. this.value.copy(out, offset);
  26015. offset += this.length;
  26016. }
  26017. return out;
  26018. };
  26019. /***/ },
  26020. /* 141 */
  26021. /***/ function(module, exports, __webpack_require__) {
  26022. var constants = exports;
  26023. // Helper
  26024. constants._reverse = function reverse(map) {
  26025. var res = {};
  26026. Object.keys(map).forEach(function(key) {
  26027. // Convert key to integer if it is stringified
  26028. if ((key | 0) == key)
  26029. key = key | 0;
  26030. var value = map[key];
  26031. res[value] = key;
  26032. });
  26033. return res;
  26034. };
  26035. constants.der = __webpack_require__(238);
  26036. /***/ },
  26037. /* 142 */
  26038. /***/ function(module, exports, __webpack_require__) {
  26039. var inherits = __webpack_require__(2);
  26040. var asn1 = __webpack_require__(77);
  26041. var base = asn1.base;
  26042. var bignum = asn1.bignum;
  26043. // Import DER constants
  26044. var der = asn1.constants.der;
  26045. function DERDecoder(entity) {
  26046. this.enc = 'der';
  26047. this.name = entity.name;
  26048. this.entity = entity;
  26049. // Construct base tree
  26050. this.tree = new DERNode();
  26051. this.tree._init(entity.body);
  26052. };
  26053. module.exports = DERDecoder;
  26054. DERDecoder.prototype.decode = function decode(data, options) {
  26055. if (!(data instanceof base.DecoderBuffer))
  26056. data = new base.DecoderBuffer(data, options);
  26057. return this.tree._decode(data, options);
  26058. };
  26059. // Tree methods
  26060. function DERNode(parent) {
  26061. base.Node.call(this, 'der', parent);
  26062. }
  26063. inherits(DERNode, base.Node);
  26064. DERNode.prototype._peekTag = function peekTag(buffer, tag, any) {
  26065. if (buffer.isEmpty())
  26066. return false;
  26067. var state = buffer.save();
  26068. var decodedTag = derDecodeTag(buffer, 'Failed to peek tag: "' + tag + '"');
  26069. if (buffer.isError(decodedTag))
  26070. return decodedTag;
  26071. buffer.restore(state);
  26072. return decodedTag.tag === tag || decodedTag.tagStr === tag ||
  26073. (decodedTag.tagStr + 'of') === tag || any;
  26074. };
  26075. DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) {
  26076. var decodedTag = derDecodeTag(buffer,
  26077. 'Failed to decode tag of "' + tag + '"');
  26078. if (buffer.isError(decodedTag))
  26079. return decodedTag;
  26080. var len = derDecodeLen(buffer,
  26081. decodedTag.primitive,
  26082. 'Failed to get length of "' + tag + '"');
  26083. // Failure
  26084. if (buffer.isError(len))
  26085. return len;
  26086. if (!any &&
  26087. decodedTag.tag !== tag &&
  26088. decodedTag.tagStr !== tag &&
  26089. decodedTag.tagStr + 'of' !== tag) {
  26090. return buffer.error('Failed to match tag: "' + tag + '"');
  26091. }
  26092. if (decodedTag.primitive || len !== null)
  26093. return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
  26094. // Indefinite length... find END tag
  26095. var state = buffer.save();
  26096. var res = this._skipUntilEnd(
  26097. buffer,
  26098. 'Failed to skip indefinite length body: "' + this.tag + '"');
  26099. if (buffer.isError(res))
  26100. return res;
  26101. len = buffer.offset - state.offset;
  26102. buffer.restore(state);
  26103. return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
  26104. };
  26105. DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer, fail) {
  26106. while (true) {
  26107. var tag = derDecodeTag(buffer, fail);
  26108. if (buffer.isError(tag))
  26109. return tag;
  26110. var len = derDecodeLen(buffer, tag.primitive, fail);
  26111. if (buffer.isError(len))
  26112. return len;
  26113. var res;
  26114. if (tag.primitive || len !== null)
  26115. res = buffer.skip(len)
  26116. else
  26117. res = this._skipUntilEnd(buffer, fail);
  26118. // Failure
  26119. if (buffer.isError(res))
  26120. return res;
  26121. if (tag.tagStr === 'end')
  26122. break;
  26123. }
  26124. };
  26125. DERNode.prototype._decodeList = function decodeList(buffer, tag, decoder) {
  26126. var result = [];
  26127. while (!buffer.isEmpty()) {
  26128. var possibleEnd = this._peekTag(buffer, 'end');
  26129. if (buffer.isError(possibleEnd))
  26130. return possibleEnd;
  26131. var res = decoder.decode(buffer, 'der');
  26132. if (buffer.isError(res) && possibleEnd)
  26133. break;
  26134. result.push(res);
  26135. }
  26136. return result;
  26137. };
  26138. DERNode.prototype._decodeStr = function decodeStr(buffer, tag) {
  26139. if (tag === 'bitstr') {
  26140. var unused = buffer.readUInt8();
  26141. if (buffer.isError(unused))
  26142. return unused;
  26143. return { unused: unused, data: buffer.raw() };
  26144. } else if (tag === 'bmpstr') {
  26145. var raw = buffer.raw();
  26146. if (raw.length % 2 === 1)
  26147. return buffer.error('Decoding of string type: bmpstr length mismatch');
  26148. var str = '';
  26149. for (var i = 0; i < raw.length / 2; i++) {
  26150. str += String.fromCharCode(raw.readUInt16BE(i * 2));
  26151. }
  26152. return str;
  26153. } else if (tag === 'numstr') {
  26154. var numstr = buffer.raw().toString('ascii');
  26155. if (!this._isNumstr(numstr)) {
  26156. return buffer.error('Decoding of string type: ' +
  26157. 'numstr unsupported characters');
  26158. }
  26159. return numstr;
  26160. } else if (tag === 'octstr') {
  26161. return buffer.raw();
  26162. } else if (tag === 'printstr') {
  26163. var printstr = buffer.raw().toString('ascii');
  26164. if (!this._isPrintstr(printstr)) {
  26165. return buffer.error('Decoding of string type: ' +
  26166. 'printstr unsupported characters');
  26167. }
  26168. return printstr;
  26169. } else if (/str$/.test(tag)) {
  26170. return buffer.raw().toString();
  26171. } else {
  26172. return buffer.error('Decoding of string type: ' + tag + ' unsupported');
  26173. }
  26174. };
  26175. DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) {
  26176. var result;
  26177. var identifiers = [];
  26178. var ident = 0;
  26179. while (!buffer.isEmpty()) {
  26180. var subident = buffer.readUInt8();
  26181. ident <<= 7;
  26182. ident |= subident & 0x7f;
  26183. if ((subident & 0x80) === 0) {
  26184. identifiers.push(ident);
  26185. ident = 0;
  26186. }
  26187. }
  26188. if (subident & 0x80)
  26189. identifiers.push(ident);
  26190. var first = (identifiers[0] / 40) | 0;
  26191. var second = identifiers[0] % 40;
  26192. if (relative)
  26193. result = identifiers;
  26194. else
  26195. result = [first, second].concat(identifiers.slice(1));
  26196. if (values) {
  26197. var tmp = values[result.join(' ')];
  26198. if (tmp === undefined)
  26199. tmp = values[result.join('.')];
  26200. if (tmp !== undefined)
  26201. result = tmp;
  26202. }
  26203. return result;
  26204. };
  26205. DERNode.prototype._decodeTime = function decodeTime(buffer, tag) {
  26206. var str = buffer.raw().toString();
  26207. if (tag === 'gentime') {
  26208. var year = str.slice(0, 4) | 0;
  26209. var mon = str.slice(4, 6) | 0;
  26210. var day = str.slice(6, 8) | 0;
  26211. var hour = str.slice(8, 10) | 0;
  26212. var min = str.slice(10, 12) | 0;
  26213. var sec = str.slice(12, 14) | 0;
  26214. } else if (tag === 'utctime') {
  26215. var year = str.slice(0, 2) | 0;
  26216. var mon = str.slice(2, 4) | 0;
  26217. var day = str.slice(4, 6) | 0;
  26218. var hour = str.slice(6, 8) | 0;
  26219. var min = str.slice(8, 10) | 0;
  26220. var sec = str.slice(10, 12) | 0;
  26221. if (year < 70)
  26222. year = 2000 + year;
  26223. else
  26224. year = 1900 + year;
  26225. } else {
  26226. return buffer.error('Decoding ' + tag + ' time is not supported yet');
  26227. }
  26228. return Date.UTC(year, mon - 1, day, hour, min, sec, 0);
  26229. };
  26230. DERNode.prototype._decodeNull = function decodeNull(buffer) {
  26231. return null;
  26232. };
  26233. DERNode.prototype._decodeBool = function decodeBool(buffer) {
  26234. var res = buffer.readUInt8();
  26235. if (buffer.isError(res))
  26236. return res;
  26237. else
  26238. return res !== 0;
  26239. };
  26240. DERNode.prototype._decodeInt = function decodeInt(buffer, values) {
  26241. // Bigint, return as it is (assume big endian)
  26242. var raw = buffer.raw();
  26243. var res = new bignum(raw);
  26244. if (values)
  26245. res = values[res.toString(10)] || res;
  26246. return res;
  26247. };
  26248. DERNode.prototype._use = function use(entity, obj) {
  26249. if (typeof entity === 'function')
  26250. entity = entity(obj);
  26251. return entity._getDecoder('der').tree;
  26252. };
  26253. // Utility methods
  26254. function derDecodeTag(buf, fail) {
  26255. var tag = buf.readUInt8(fail);
  26256. if (buf.isError(tag))
  26257. return tag;
  26258. var cls = der.tagClass[tag >> 6];
  26259. var primitive = (tag & 0x20) === 0;
  26260. // Multi-octet tag - load
  26261. if ((tag & 0x1f) === 0x1f) {
  26262. var oct = tag;
  26263. tag = 0;
  26264. while ((oct & 0x80) === 0x80) {
  26265. oct = buf.readUInt8(fail);
  26266. if (buf.isError(oct))
  26267. return oct;
  26268. tag <<= 7;
  26269. tag |= oct & 0x7f;
  26270. }
  26271. } else {
  26272. tag &= 0x1f;
  26273. }
  26274. var tagStr = der.tag[tag];
  26275. return {
  26276. cls: cls,
  26277. primitive: primitive,
  26278. tag: tag,
  26279. tagStr: tagStr
  26280. };
  26281. }
  26282. function derDecodeLen(buf, primitive, fail) {
  26283. var len = buf.readUInt8(fail);
  26284. if (buf.isError(len))
  26285. return len;
  26286. // Indefinite form
  26287. if (!primitive && len === 0x80)
  26288. return null;
  26289. // Definite form
  26290. if ((len & 0x80) === 0) {
  26291. // Short form
  26292. return len;
  26293. }
  26294. // Long form
  26295. var num = len & 0x7f;
  26296. if (num >= 4)
  26297. return buf.error('length octect is too long');
  26298. len = 0;
  26299. for (var i = 0; i < num; i++) {
  26300. len <<= 8;
  26301. var j = buf.readUInt8(fail);
  26302. if (buf.isError(j))
  26303. return j;
  26304. len |= j;
  26305. }
  26306. return len;
  26307. }
  26308. /***/ },
  26309. /* 143 */
  26310. /***/ function(module, exports, __webpack_require__) {
  26311. var inherits = __webpack_require__(2);
  26312. var Buffer = __webpack_require__(1).Buffer;
  26313. var asn1 = __webpack_require__(77);
  26314. var base = asn1.base;
  26315. // Import DER constants
  26316. var der = asn1.constants.der;
  26317. function DEREncoder(entity) {
  26318. this.enc = 'der';
  26319. this.name = entity.name;
  26320. this.entity = entity;
  26321. // Construct base tree
  26322. this.tree = new DERNode();
  26323. this.tree._init(entity.body);
  26324. };
  26325. module.exports = DEREncoder;
  26326. DEREncoder.prototype.encode = function encode(data, reporter) {
  26327. return this.tree._encode(data, reporter).join();
  26328. };
  26329. // Tree methods
  26330. function DERNode(parent) {
  26331. base.Node.call(this, 'der', parent);
  26332. }
  26333. inherits(DERNode, base.Node);
  26334. DERNode.prototype._encodeComposite = function encodeComposite(tag,
  26335. primitive,
  26336. cls,
  26337. content) {
  26338. var encodedTag = encodeTag(tag, primitive, cls, this.reporter);
  26339. // Short form
  26340. if (content.length < 0x80) {
  26341. var header = new Buffer(2);
  26342. header[0] = encodedTag;
  26343. header[1] = content.length;
  26344. return this._createEncoderBuffer([ header, content ]);
  26345. }
  26346. // Long form
  26347. // Count octets required to store length
  26348. var lenOctets = 1;
  26349. for (var i = content.length; i >= 0x100; i >>= 8)
  26350. lenOctets++;
  26351. var header = new Buffer(1 + 1 + lenOctets);
  26352. header[0] = encodedTag;
  26353. header[1] = 0x80 | lenOctets;
  26354. for (var i = 1 + lenOctets, j = content.length; j > 0; i--, j >>= 8)
  26355. header[i] = j & 0xff;
  26356. return this._createEncoderBuffer([ header, content ]);
  26357. };
  26358. DERNode.prototype._encodeStr = function encodeStr(str, tag) {
  26359. if (tag === 'bitstr') {
  26360. return this._createEncoderBuffer([ str.unused | 0, str.data ]);
  26361. } else if (tag === 'bmpstr') {
  26362. var buf = new Buffer(str.length * 2);
  26363. for (var i = 0; i < str.length; i++) {
  26364. buf.writeUInt16BE(str.charCodeAt(i), i * 2);
  26365. }
  26366. return this._createEncoderBuffer(buf);
  26367. } else if (tag === 'numstr') {
  26368. if (!this._isNumstr(str)) {
  26369. return this.reporter.error('Encoding of string type: numstr supports ' +
  26370. 'only digits and space');
  26371. }
  26372. return this._createEncoderBuffer(str);
  26373. } else if (tag === 'printstr') {
  26374. if (!this._isPrintstr(str)) {
  26375. return this.reporter.error('Encoding of string type: printstr supports ' +
  26376. 'only latin upper and lower case letters, ' +
  26377. 'digits, space, apostrophe, left and rigth ' +
  26378. 'parenthesis, plus sign, comma, hyphen, ' +
  26379. 'dot, slash, colon, equal sign, ' +
  26380. 'question mark');
  26381. }
  26382. return this._createEncoderBuffer(str);
  26383. } else if (/str$/.test(tag)) {
  26384. return this._createEncoderBuffer(str);
  26385. } else {
  26386. return this.reporter.error('Encoding of string type: ' + tag +
  26387. ' unsupported');
  26388. }
  26389. };
  26390. DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) {
  26391. if (typeof id === 'string') {
  26392. if (!values)
  26393. return this.reporter.error('string objid given, but no values map found');
  26394. if (!values.hasOwnProperty(id))
  26395. return this.reporter.error('objid not found in values map');
  26396. id = values[id].split(/[\s\.]+/g);
  26397. for (var i = 0; i < id.length; i++)
  26398. id[i] |= 0;
  26399. } else if (Array.isArray(id)) {
  26400. id = id.slice();
  26401. for (var i = 0; i < id.length; i++)
  26402. id[i] |= 0;
  26403. }
  26404. if (!Array.isArray(id)) {
  26405. return this.reporter.error('objid() should be either array or string, ' +
  26406. 'got: ' + JSON.stringify(id));
  26407. }
  26408. if (!relative) {
  26409. if (id[1] >= 40)
  26410. return this.reporter.error('Second objid identifier OOB');
  26411. id.splice(0, 2, id[0] * 40 + id[1]);
  26412. }
  26413. // Count number of octets
  26414. var size = 0;
  26415. for (var i = 0; i < id.length; i++) {
  26416. var ident = id[i];
  26417. for (size++; ident >= 0x80; ident >>= 7)
  26418. size++;
  26419. }
  26420. var objid = new Buffer(size);
  26421. var offset = objid.length - 1;
  26422. for (var i = id.length - 1; i >= 0; i--) {
  26423. var ident = id[i];
  26424. objid[offset--] = ident & 0x7f;
  26425. while ((ident >>= 7) > 0)
  26426. objid[offset--] = 0x80 | (ident & 0x7f);
  26427. }
  26428. return this._createEncoderBuffer(objid);
  26429. };
  26430. function two(num) {
  26431. if (num < 10)
  26432. return '0' + num;
  26433. else
  26434. return num;
  26435. }
  26436. DERNode.prototype._encodeTime = function encodeTime(time, tag) {
  26437. var str;
  26438. var date = new Date(time);
  26439. if (tag === 'gentime') {
  26440. str = [
  26441. two(date.getFullYear()),
  26442. two(date.getUTCMonth() + 1),
  26443. two(date.getUTCDate()),
  26444. two(date.getUTCHours()),
  26445. two(date.getUTCMinutes()),
  26446. two(date.getUTCSeconds()),
  26447. 'Z'
  26448. ].join('');
  26449. } else if (tag === 'utctime') {
  26450. str = [
  26451. two(date.getFullYear() % 100),
  26452. two(date.getUTCMonth() + 1),
  26453. two(date.getUTCDate()),
  26454. two(date.getUTCHours()),
  26455. two(date.getUTCMinutes()),
  26456. two(date.getUTCSeconds()),
  26457. 'Z'
  26458. ].join('');
  26459. } else {
  26460. this.reporter.error('Encoding ' + tag + ' time is not supported yet');
  26461. }
  26462. return this._encodeStr(str, 'octstr');
  26463. };
  26464. DERNode.prototype._encodeNull = function encodeNull() {
  26465. return this._createEncoderBuffer('');
  26466. };
  26467. DERNode.prototype._encodeInt = function encodeInt(num, values) {
  26468. if (typeof num === 'string') {
  26469. if (!values)
  26470. return this.reporter.error('String int or enum given, but no values map');
  26471. if (!values.hasOwnProperty(num)) {
  26472. return this.reporter.error('Values map doesn\'t contain: ' +
  26473. JSON.stringify(num));
  26474. }
  26475. num = values[num];
  26476. }
  26477. // Bignum, assume big endian
  26478. if (typeof num !== 'number' && !Buffer.isBuffer(num)) {
  26479. var numArray = num.toArray();
  26480. if (!num.sign && numArray[0] & 0x80) {
  26481. numArray.unshift(0);
  26482. }
  26483. num = new Buffer(numArray);
  26484. }
  26485. if (Buffer.isBuffer(num)) {
  26486. var size = num.length;
  26487. if (num.length === 0)
  26488. size++;
  26489. var out = new Buffer(size);
  26490. num.copy(out);
  26491. if (num.length === 0)
  26492. out[0] = 0
  26493. return this._createEncoderBuffer(out);
  26494. }
  26495. if (num < 0x80)
  26496. return this._createEncoderBuffer(num);
  26497. if (num < 0x100)
  26498. return this._createEncoderBuffer([0, num]);
  26499. var size = 1;
  26500. for (var i = num; i >= 0x100; i >>= 8)
  26501. size++;
  26502. var out = new Array(size);
  26503. for (var i = out.length - 1; i >= 0; i--) {
  26504. out[i] = num & 0xff;
  26505. num >>= 8;
  26506. }
  26507. if(out[0] & 0x80) {
  26508. out.unshift(0);
  26509. }
  26510. return this._createEncoderBuffer(new Buffer(out));
  26511. };
  26512. DERNode.prototype._encodeBool = function encodeBool(value) {
  26513. return this._createEncoderBuffer(value ? 0xff : 0);
  26514. };
  26515. DERNode.prototype._use = function use(entity, obj) {
  26516. if (typeof entity === 'function')
  26517. entity = entity(obj);
  26518. return entity._getEncoder('der').tree;
  26519. };
  26520. DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, parent) {
  26521. var state = this._baseState;
  26522. var i;
  26523. if (state['default'] === null)
  26524. return false;
  26525. var data = dataBuffer.join();
  26526. if (state.defaultBuffer === undefined)
  26527. state.defaultBuffer = this._encodeValue(state['default'], reporter, parent).join();
  26528. if (data.length !== state.defaultBuffer.length)
  26529. return false;
  26530. for (i=0; i < data.length; i++)
  26531. if (data[i] !== state.defaultBuffer[i])
  26532. return false;
  26533. return true;
  26534. };
  26535. // Utility methods
  26536. function encodeTag(tag, primitive, cls, reporter) {
  26537. var res;
  26538. if (tag === 'seqof')
  26539. tag = 'seq';
  26540. else if (tag === 'setof')
  26541. tag = 'set';
  26542. if (der.tagByName.hasOwnProperty(tag))
  26543. res = der.tagByName[tag];
  26544. else if (typeof tag === 'number' && (tag | 0) === tag)
  26545. res = tag;
  26546. else
  26547. return reporter.error('Unknown tag: ' + tag);
  26548. if (res >= 0x1f)
  26549. return reporter.error('Multi-octet tag encoding unsupported');
  26550. if (!primitive)
  26551. res |= 0x20;
  26552. res |= (der.tagClassByName[cls || 'universal'] << 6);
  26553. return res;
  26554. }
  26555. /***/ },
  26556. /* 144 */
  26557. /***/ function(module, exports, __webpack_require__) {
  26558. "use strict";
  26559. /* WEBPACK VAR INJECTION */(function(global) {'use strict';
  26560. // compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js
  26561. // original notice:
  26562. /*!
  26563. * The buffer module from node.js, for the browser.
  26564. *
  26565. * @author Feross Aboukhadijeh <[email protected]> <http://feross.org>
  26566. * @license MIT
  26567. */
  26568. function compare(a, b) {
  26569. if (a === b) {
  26570. return 0;
  26571. }
  26572. var x = a.length;
  26573. var y = b.length;
  26574. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  26575. if (a[i] !== b[i]) {
  26576. x = a[i];
  26577. y = b[i];
  26578. break;
  26579. }
  26580. }
  26581. if (x < y) {
  26582. return -1;
  26583. }
  26584. if (y < x) {
  26585. return 1;
  26586. }
  26587. return 0;
  26588. }
  26589. function isBuffer(b) {
  26590. if (global.Buffer && typeof global.Buffer.isBuffer === 'function') {
  26591. return global.Buffer.isBuffer(b);
  26592. }
  26593. return !!(b != null && b._isBuffer);
  26594. }
  26595. // based on node assert, original notice:
  26596. // http://wiki.commonjs.org/wiki/Unit_Testing/1.0
  26597. //
  26598. // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
  26599. //
  26600. // Originally from narwhal.js (http://narwhaljs.org)
  26601. // Copyright (c) 2009 Thomas Robinson <280north.com>
  26602. //
  26603. // Permission is hereby granted, free of charge, to any person obtaining a copy
  26604. // of this software and associated documentation files (the 'Software'), to
  26605. // deal in the Software without restriction, including without limitation the
  26606. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  26607. // sell copies of the Software, and to permit persons to whom the Software is
  26608. // furnished to do so, subject to the following conditions:
  26609. //
  26610. // The above copyright notice and this permission notice shall be included in
  26611. // all copies or substantial portions of the Software.
  26612. //
  26613. // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  26614. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  26615. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  26616. // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  26617. // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  26618. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  26619. var util = __webpack_require__(44);
  26620. var hasOwn = Object.prototype.hasOwnProperty;
  26621. var pSlice = Array.prototype.slice;
  26622. var functionsHaveNames = (function () {
  26623. return function foo() {}.name === 'foo';
  26624. }());
  26625. function pToString (obj) {
  26626. return Object.prototype.toString.call(obj);
  26627. }
  26628. function isView(arrbuf) {
  26629. if (isBuffer(arrbuf)) {
  26630. return false;
  26631. }
  26632. if (typeof global.ArrayBuffer !== 'function') {
  26633. return false;
  26634. }
  26635. if (typeof ArrayBuffer.isView === 'function') {
  26636. return ArrayBuffer.isView(arrbuf);
  26637. }
  26638. if (!arrbuf) {
  26639. return false;
  26640. }
  26641. if (arrbuf instanceof DataView) {
  26642. return true;
  26643. }
  26644. if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) {
  26645. return true;
  26646. }
  26647. return false;
  26648. }
  26649. // 1. The assert module provides functions that throw
  26650. // AssertionError's when particular conditions are not met. The
  26651. // assert module must conform to the following interface.
  26652. var assert = module.exports = ok;
  26653. // 2. The AssertionError is defined in assert.
  26654. // new assert.AssertionError({ message: message,
  26655. // actual: actual,
  26656. // expected: expected })
  26657. var regex = /\s*function\s+([^\(\s]*)\s*/;
  26658. // based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js
  26659. function getName(func) {
  26660. if (!util.isFunction(func)) {
  26661. return;
  26662. }
  26663. if (functionsHaveNames) {
  26664. return func.name;
  26665. }
  26666. var str = func.toString();
  26667. var match = str.match(regex);
  26668. return match && match[1];
  26669. }
  26670. assert.AssertionError = function AssertionError(options) {
  26671. this.name = 'AssertionError';
  26672. this.actual = options.actual;
  26673. this.expected = options.expected;
  26674. this.operator = options.operator;
  26675. if (options.message) {
  26676. this.message = options.message;
  26677. this.generatedMessage = false;
  26678. } else {
  26679. this.message = getMessage(this);
  26680. this.generatedMessage = true;
  26681. }
  26682. var stackStartFunction = options.stackStartFunction || fail;
  26683. if (Error.captureStackTrace) {
  26684. Error.captureStackTrace(this, stackStartFunction);
  26685. } else {
  26686. // non v8 browsers so we can have a stacktrace
  26687. var err = new Error();
  26688. if (err.stack) {
  26689. var out = err.stack;
  26690. // try to strip useless frames
  26691. var fn_name = getName(stackStartFunction);
  26692. var idx = out.indexOf('\n' + fn_name);
  26693. if (idx >= 0) {
  26694. // once we have located the function frame
  26695. // we need to strip out everything before it (and its line)
  26696. var next_line = out.indexOf('\n', idx + 1);
  26697. out = out.substring(next_line + 1);
  26698. }
  26699. this.stack = out;
  26700. }
  26701. }
  26702. };
  26703. // assert.AssertionError instanceof Error
  26704. util.inherits(assert.AssertionError, Error);
  26705. function truncate(s, n) {
  26706. if (typeof s === 'string') {
  26707. return s.length < n ? s : s.slice(0, n);
  26708. } else {
  26709. return s;
  26710. }
  26711. }
  26712. function inspect(something) {
  26713. if (functionsHaveNames || !util.isFunction(something)) {
  26714. return util.inspect(something);
  26715. }
  26716. var rawname = getName(something);
  26717. var name = rawname ? ': ' + rawname : '';
  26718. return '[Function' + name + ']';
  26719. }
  26720. function getMessage(self) {
  26721. return truncate(inspect(self.actual), 128) + ' ' +
  26722. self.operator + ' ' +
  26723. truncate(inspect(self.expected), 128);
  26724. }
  26725. // At present only the three keys mentioned above are used and
  26726. // understood by the spec. Implementations or sub modules can pass
  26727. // other keys to the AssertionError's constructor - they will be
  26728. // ignored.
  26729. // 3. All of the following functions must throw an AssertionError
  26730. // when a corresponding condition is not met, with a message that
  26731. // may be undefined if not provided. All assertion methods provide
  26732. // both the actual and expected values to the assertion error for
  26733. // display purposes.
  26734. function fail(actual, expected, message, operator, stackStartFunction) {
  26735. throw new assert.AssertionError({
  26736. message: message,
  26737. actual: actual,
  26738. expected: expected,
  26739. operator: operator,
  26740. stackStartFunction: stackStartFunction
  26741. });
  26742. }
  26743. // EXTENSION! allows for well behaved errors defined elsewhere.
  26744. assert.fail = fail;
  26745. // 4. Pure assertion tests whether a value is truthy, as determined
  26746. // by !!guard.
  26747. // assert.ok(guard, message_opt);
  26748. // This statement is equivalent to assert.equal(true, !!guard,
  26749. // message_opt);. To test strictly for the value true, use
  26750. // assert.strictEqual(true, guard, message_opt);.
  26751. function ok(value, message) {
  26752. if (!value) fail(value, true, message, '==', assert.ok);
  26753. }
  26754. assert.ok = ok;
  26755. // 5. The equality assertion tests shallow, coercive equality with
  26756. // ==.
  26757. // assert.equal(actual, expected, message_opt);
  26758. assert.equal = function equal(actual, expected, message) {
  26759. if (actual != expected) fail(actual, expected, message, '==', assert.equal);
  26760. };
  26761. // 6. The non-equality assertion tests for whether two objects are not equal
  26762. // with != assert.notEqual(actual, expected, message_opt);
  26763. assert.notEqual = function notEqual(actual, expected, message) {
  26764. if (actual == expected) {
  26765. fail(actual, expected, message, '!=', assert.notEqual);
  26766. }
  26767. };
  26768. // 7. The equivalence assertion tests a deep equality relation.
  26769. // assert.deepEqual(actual, expected, message_opt);
  26770. assert.deepEqual = function deepEqual(actual, expected, message) {
  26771. if (!_deepEqual(actual, expected, false)) {
  26772. fail(actual, expected, message, 'deepEqual', assert.deepEqual);
  26773. }
  26774. };
  26775. assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {
  26776. if (!_deepEqual(actual, expected, true)) {
  26777. fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual);
  26778. }
  26779. };
  26780. function _deepEqual(actual, expected, strict, memos) {
  26781. // 7.1. All identical values are equivalent, as determined by ===.
  26782. if (actual === expected) {
  26783. return true;
  26784. } else if (isBuffer(actual) && isBuffer(expected)) {
  26785. return compare(actual, expected) === 0;
  26786. // 7.2. If the expected value is a Date object, the actual value is
  26787. // equivalent if it is also a Date object that refers to the same time.
  26788. } else if (util.isDate(actual) && util.isDate(expected)) {
  26789. return actual.getTime() === expected.getTime();
  26790. // 7.3 If the expected value is a RegExp object, the actual value is
  26791. // equivalent if it is also a RegExp object with the same source and
  26792. // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
  26793. } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
  26794. return actual.source === expected.source &&
  26795. actual.global === expected.global &&
  26796. actual.multiline === expected.multiline &&
  26797. actual.lastIndex === expected.lastIndex &&
  26798. actual.ignoreCase === expected.ignoreCase;
  26799. // 7.4. Other pairs that do not both pass typeof value == 'object',
  26800. // equivalence is determined by ==.
  26801. } else if ((actual === null || typeof actual !== 'object') &&
  26802. (expected === null || typeof expected !== 'object')) {
  26803. return strict ? actual === expected : actual == expected;
  26804. // If both values are instances of typed arrays, wrap their underlying
  26805. // ArrayBuffers in a Buffer each to increase performance
  26806. // This optimization requires the arrays to have the same type as checked by
  26807. // Object.prototype.toString (aka pToString). Never perform binary
  26808. // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their
  26809. // bit patterns are not identical.
  26810. } else if (isView(actual) && isView(expected) &&
  26811. pToString(actual) === pToString(expected) &&
  26812. !(actual instanceof Float32Array ||
  26813. actual instanceof Float64Array)) {
  26814. return compare(new Uint8Array(actual.buffer),
  26815. new Uint8Array(expected.buffer)) === 0;
  26816. // 7.5 For all other Object pairs, including Array objects, equivalence is
  26817. // determined by having the same number of owned properties (as verified
  26818. // with Object.prototype.hasOwnProperty.call), the same set of keys
  26819. // (although not necessarily the same order), equivalent values for every
  26820. // corresponding key, and an identical 'prototype' property. Note: this
  26821. // accounts for both named and indexed properties on Arrays.
  26822. } else if (isBuffer(actual) !== isBuffer(expected)) {
  26823. return false;
  26824. } else {
  26825. memos = memos || {actual: [], expected: []};
  26826. var actualIndex = memos.actual.indexOf(actual);
  26827. if (actualIndex !== -1) {
  26828. if (actualIndex === memos.expected.indexOf(expected)) {
  26829. return true;
  26830. }
  26831. }
  26832. memos.actual.push(actual);
  26833. memos.expected.push(expected);
  26834. return objEquiv(actual, expected, strict, memos);
  26835. }
  26836. }
  26837. function isArguments(object) {
  26838. return Object.prototype.toString.call(object) == '[object Arguments]';
  26839. }
  26840. function objEquiv(a, b, strict, actualVisitedObjects) {
  26841. if (a === null || a === undefined || b === null || b === undefined)
  26842. return false;
  26843. // if one is a primitive, the other must be same
  26844. if (util.isPrimitive(a) || util.isPrimitive(b))
  26845. return a === b;
  26846. if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))
  26847. return false;
  26848. var aIsArgs = isArguments(a);
  26849. var bIsArgs = isArguments(b);
  26850. if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
  26851. return false;
  26852. if (aIsArgs) {
  26853. a = pSlice.call(a);
  26854. b = pSlice.call(b);
  26855. return _deepEqual(a, b, strict);
  26856. }
  26857. var ka = objectKeys(a);
  26858. var kb = objectKeys(b);
  26859. var key, i;
  26860. // having the same number of owned properties (keys incorporates
  26861. // hasOwnProperty)
  26862. if (ka.length !== kb.length)
  26863. return false;
  26864. //the same set of keys (although not necessarily the same order),
  26865. ka.sort();
  26866. kb.sort();
  26867. //~~~cheap key test
  26868. for (i = ka.length - 1; i >= 0; i--) {
  26869. if (ka[i] !== kb[i])
  26870. return false;
  26871. }
  26872. //equivalent values for every corresponding key, and
  26873. //~~~possibly expensive deep test
  26874. for (i = ka.length - 1; i >= 0; i--) {
  26875. key = ka[i];
  26876. if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects))
  26877. return false;
  26878. }
  26879. return true;
  26880. }
  26881. // 8. The non-equivalence assertion tests for any deep inequality.
  26882. // assert.notDeepEqual(actual, expected, message_opt);
  26883. assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
  26884. if (_deepEqual(actual, expected, false)) {
  26885. fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
  26886. }
  26887. };
  26888. assert.notDeepStrictEqual = notDeepStrictEqual;
  26889. function notDeepStrictEqual(actual, expected, message) {
  26890. if (_deepEqual(actual, expected, true)) {
  26891. fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual);
  26892. }
  26893. }
  26894. // 9. The strict equality assertion tests strict equality, as determined by ===.
  26895. // assert.strictEqual(actual, expected, message_opt);
  26896. assert.strictEqual = function strictEqual(actual, expected, message) {
  26897. if (actual !== expected) {
  26898. fail(actual, expected, message, '===', assert.strictEqual);
  26899. }
  26900. };
  26901. // 10. The strict non-equality assertion tests for strict inequality, as
  26902. // determined by !==. assert.notStrictEqual(actual, expected, message_opt);
  26903. assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
  26904. if (actual === expected) {
  26905. fail(actual, expected, message, '!==', assert.notStrictEqual);
  26906. }
  26907. };
  26908. function expectedException(actual, expected) {
  26909. if (!actual || !expected) {
  26910. return false;
  26911. }
  26912. if (Object.prototype.toString.call(expected) == '[object RegExp]') {
  26913. return expected.test(actual);
  26914. }
  26915. try {
  26916. if (actual instanceof expected) {
  26917. return true;
  26918. }
  26919. } catch (e) {
  26920. // Ignore. The instanceof check doesn't work for arrow functions.
  26921. }
  26922. if (Error.isPrototypeOf(expected)) {
  26923. return false;
  26924. }
  26925. return expected.call({}, actual) === true;
  26926. }
  26927. function _tryBlock(block) {
  26928. var error;
  26929. try {
  26930. block();
  26931. } catch (e) {
  26932. error = e;
  26933. }
  26934. return error;
  26935. }
  26936. function _throws(shouldThrow, block, expected, message) {
  26937. var actual;
  26938. if (typeof block !== 'function') {
  26939. throw new TypeError('"block" argument must be a function');
  26940. }
  26941. if (typeof expected === 'string') {
  26942. message = expected;
  26943. expected = null;
  26944. }
  26945. actual = _tryBlock(block);
  26946. message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
  26947. (message ? ' ' + message : '.');
  26948. if (shouldThrow && !actual) {
  26949. fail(actual, expected, 'Missing expected exception' + message);
  26950. }
  26951. var userProvidedMessage = typeof message === 'string';
  26952. var isUnwantedException = !shouldThrow && util.isError(actual);
  26953. var isUnexpectedException = !shouldThrow && actual && !expected;
  26954. if ((isUnwantedException &&
  26955. userProvidedMessage &&
  26956. expectedException(actual, expected)) ||
  26957. isUnexpectedException) {
  26958. fail(actual, expected, 'Got unwanted exception' + message);
  26959. }
  26960. if ((shouldThrow && actual && expected &&
  26961. !expectedException(actual, expected)) || (!shouldThrow && actual)) {
  26962. throw actual;
  26963. }
  26964. }
  26965. // 11. Expected to throw an error:
  26966. // assert.throws(block, Error_opt, message_opt);
  26967. assert.throws = function(block, /*optional*/error, /*optional*/message) {
  26968. _throws(true, block, error, message);
  26969. };
  26970. // EXTENSION! This is annoying to write outside this module.
  26971. assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) {
  26972. _throws(false, block, error, message);
  26973. };
  26974. assert.ifError = function(err) { if (err) throw err; };
  26975. var objectKeys = Object.keys || function (obj) {
  26976. var keys = [];
  26977. for (var key in obj) {
  26978. if (hasOwn.call(obj, key)) keys.push(key);
  26979. }
  26980. return keys;
  26981. };
  26982. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(13)))
  26983. /***/ },
  26984. /* 145 */
  26985. /***/ function(module, exports, __webpack_require__) {
  26986. /* WEBPACK VAR INJECTION */(function(global, setImmediate, process) {(function (global, factory) {
  26987. true ? factory(exports) :
  26988. typeof define === 'function' && define.amd ? define(['exports'], factory) :
  26989. (factory((global.async = global.async || {})));
  26990. }(this, function (exports) { 'use strict';
  26991. /**
  26992. * A faster alternative to `Function#apply`, this function invokes `func`
  26993. * with the `this` binding of `thisArg` and the arguments of `args`.
  26994. *
  26995. * @private
  26996. * @param {Function} func The function to invoke.
  26997. * @param {*} thisArg The `this` binding of `func`.
  26998. * @param {Array} args The arguments to invoke `func` with.
  26999. * @returns {*} Returns the result of `func`.
  27000. */
  27001. function apply(func, thisArg, args) {
  27002. var length = args.length;
  27003. switch (length) {
  27004. case 0: return func.call(thisArg);
  27005. case 1: return func.call(thisArg, args[0]);
  27006. case 2: return func.call(thisArg, args[0], args[1]);
  27007. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  27008. }
  27009. return func.apply(thisArg, args);
  27010. }
  27011. /**
  27012. * Checks if `value` is the
  27013. * [language type](http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types)
  27014. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  27015. *
  27016. * @static
  27017. * @memberOf _
  27018. * @since 0.1.0
  27019. * @category Lang
  27020. * @param {*} value The value to check.
  27021. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  27022. * @example
  27023. *
  27024. * _.isObject({});
  27025. * // => true
  27026. *
  27027. * _.isObject([1, 2, 3]);
  27028. * // => true
  27029. *
  27030. * _.isObject(_.noop);
  27031. * // => true
  27032. *
  27033. * _.isObject(null);
  27034. * // => false
  27035. */
  27036. function isObject(value) {
  27037. var type = typeof value;
  27038. return !!value && (type == 'object' || type == 'function');
  27039. }
  27040. var funcTag = '[object Function]';
  27041. var genTag = '[object GeneratorFunction]';
  27042. /** Used for built-in method references. */
  27043. var objectProto = Object.prototype;
  27044. /**
  27045. * Used to resolve the
  27046. * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  27047. * of values.
  27048. */
  27049. var objectToString = objectProto.toString;
  27050. /**
  27051. * Checks if `value` is classified as a `Function` object.
  27052. *
  27053. * @static
  27054. * @memberOf _
  27055. * @since 0.1.0
  27056. * @category Lang
  27057. * @param {*} value The value to check.
  27058. * @returns {boolean} Returns `true` if `value` is correctly classified,
  27059. * else `false`.
  27060. * @example
  27061. *
  27062. * _.isFunction(_);
  27063. * // => true
  27064. *
  27065. * _.isFunction(/abc/);
  27066. * // => false
  27067. */
  27068. function isFunction(value) {
  27069. // The use of `Object#toString` avoids issues with the `typeof` operator
  27070. // in Safari 8 which returns 'object' for typed array and weak map constructors,
  27071. // and PhantomJS 1.9 which returns 'function' for `NodeList` instances.
  27072. var tag = isObject(value) ? objectToString.call(value) : '';
  27073. return tag == funcTag || tag == genTag;
  27074. }
  27075. /**
  27076. * Checks if `value` is object-like. A value is object-like if it's not `null`
  27077. * and has a `typeof` result of "object".
  27078. *
  27079. * @static
  27080. * @memberOf _
  27081. * @since 4.0.0
  27082. * @category Lang
  27083. * @param {*} value The value to check.
  27084. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  27085. * @example
  27086. *
  27087. * _.isObjectLike({});
  27088. * // => true
  27089. *
  27090. * _.isObjectLike([1, 2, 3]);
  27091. * // => true
  27092. *
  27093. * _.isObjectLike(_.noop);
  27094. * // => false
  27095. *
  27096. * _.isObjectLike(null);
  27097. * // => false
  27098. */
  27099. function isObjectLike(value) {
  27100. return !!value && typeof value == 'object';
  27101. }
  27102. /** `Object#toString` result references. */
  27103. var symbolTag = '[object Symbol]';
  27104. /** Used for built-in method references. */
  27105. var objectProto$1 = Object.prototype;
  27106. /**
  27107. * Used to resolve the
  27108. * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  27109. * of values.
  27110. */
  27111. var objectToString$1 = objectProto$1.toString;
  27112. /**
  27113. * Checks if `value` is classified as a `Symbol` primitive or object.
  27114. *
  27115. * @static
  27116. * @memberOf _
  27117. * @since 4.0.0
  27118. * @category Lang
  27119. * @param {*} value The value to check.
  27120. * @returns {boolean} Returns `true` if `value` is correctly classified,
  27121. * else `false`.
  27122. * @example
  27123. *
  27124. * _.isSymbol(Symbol.iterator);
  27125. * // => true
  27126. *
  27127. * _.isSymbol('abc');
  27128. * // => false
  27129. */
  27130. function isSymbol(value) {
  27131. return typeof value == 'symbol' ||
  27132. (isObjectLike(value) && objectToString$1.call(value) == symbolTag);
  27133. }
  27134. /** Used as references for various `Number` constants. */
  27135. var NAN = 0 / 0;
  27136. /** Used to match leading and trailing whitespace. */
  27137. var reTrim = /^\s+|\s+$/g;
  27138. /** Used to detect bad signed hexadecimal string values. */
  27139. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  27140. /** Used to detect binary string values. */
  27141. var reIsBinary = /^0b[01]+$/i;
  27142. /** Used to detect octal string values. */
  27143. var reIsOctal = /^0o[0-7]+$/i;
  27144. /** Built-in method references without a dependency on `root`. */
  27145. var freeParseInt = parseInt;
  27146. /**
  27147. * Converts `value` to a number.
  27148. *
  27149. * @static
  27150. * @memberOf _
  27151. * @since 4.0.0
  27152. * @category Lang
  27153. * @param {*} value The value to process.
  27154. * @returns {number} Returns the number.
  27155. * @example
  27156. *
  27157. * _.toNumber(3.2);
  27158. * // => 3.2
  27159. *
  27160. * _.toNumber(Number.MIN_VALUE);
  27161. * // => 5e-324
  27162. *
  27163. * _.toNumber(Infinity);
  27164. * // => Infinity
  27165. *
  27166. * _.toNumber('3.2');
  27167. * // => 3.2
  27168. */
  27169. function toNumber(value) {
  27170. if (typeof value == 'number') {
  27171. return value;
  27172. }
  27173. if (isSymbol(value)) {
  27174. return NAN;
  27175. }
  27176. if (isObject(value)) {
  27177. var other = isFunction(value.valueOf) ? value.valueOf() : value;
  27178. value = isObject(other) ? (other + '') : other;
  27179. }
  27180. if (typeof value != 'string') {
  27181. return value === 0 ? value : +value;
  27182. }
  27183. value = value.replace(reTrim, '');
  27184. var isBinary = reIsBinary.test(value);
  27185. return (isBinary || reIsOctal.test(value))
  27186. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  27187. : (reIsBadHex.test(value) ? NAN : +value);
  27188. }
  27189. var INFINITY = 1 / 0;
  27190. var MAX_INTEGER = 1.7976931348623157e+308;
  27191. /**
  27192. * Converts `value` to a finite number.
  27193. *
  27194. * @static
  27195. * @memberOf _
  27196. * @since 4.12.0
  27197. * @category Lang
  27198. * @param {*} value The value to convert.
  27199. * @returns {number} Returns the converted number.
  27200. * @example
  27201. *
  27202. * _.toFinite(3.2);
  27203. * // => 3.2
  27204. *
  27205. * _.toFinite(Number.MIN_VALUE);
  27206. * // => 5e-324
  27207. *
  27208. * _.toFinite(Infinity);
  27209. * // => 1.7976931348623157e+308
  27210. *
  27211. * _.toFinite('3.2');
  27212. * // => 3.2
  27213. */
  27214. function toFinite(value) {
  27215. if (!value) {
  27216. return value === 0 ? value : 0;
  27217. }
  27218. value = toNumber(value);
  27219. if (value === INFINITY || value === -INFINITY) {
  27220. var sign = (value < 0 ? -1 : 1);
  27221. return sign * MAX_INTEGER;
  27222. }
  27223. return value === value ? value : 0;
  27224. }
  27225. /**
  27226. * Converts `value` to an integer.
  27227. *
  27228. * **Note:** This method is loosely based on
  27229. * [`ToInteger`](http://www.ecma-international.org/ecma-262/6.0/#sec-tointeger).
  27230. *
  27231. * @static
  27232. * @memberOf _
  27233. * @since 4.0.0
  27234. * @category Lang
  27235. * @param {*} value The value to convert.
  27236. * @returns {number} Returns the converted integer.
  27237. * @example
  27238. *
  27239. * _.toInteger(3.2);
  27240. * // => 3
  27241. *
  27242. * _.toInteger(Number.MIN_VALUE);
  27243. * // => 0
  27244. *
  27245. * _.toInteger(Infinity);
  27246. * // => 1.7976931348623157e+308
  27247. *
  27248. * _.toInteger('3.2');
  27249. * // => 3
  27250. */
  27251. function toInteger(value) {
  27252. var result = toFinite(value),
  27253. remainder = result % 1;
  27254. return result === result ? (remainder ? result - remainder : result) : 0;
  27255. }
  27256. /** Used as the `TypeError` message for "Functions" methods. */
  27257. var FUNC_ERROR_TEXT = 'Expected a function';
  27258. /* Built-in method references for those with the same name as other `lodash` methods. */
  27259. var nativeMax = Math.max;
  27260. /**
  27261. * Creates a function that invokes `func` with the `this` binding of the
  27262. * created function and arguments from `start` and beyond provided as
  27263. * an array.
  27264. *
  27265. * **Note:** This method is based on the
  27266. * [rest parameter](https://mdn.io/rest_parameters).
  27267. *
  27268. * @static
  27269. * @memberOf _
  27270. * @since 4.0.0
  27271. * @category Function
  27272. * @param {Function} func The function to apply a rest parameter to.
  27273. * @param {number} [start=func.length-1] The start position of the rest parameter.
  27274. * @returns {Function} Returns the new function.
  27275. * @example
  27276. *
  27277. * var say = _.rest(function(what, names) {
  27278. * return what + ' ' + _.initial(names).join(', ') +
  27279. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  27280. * });
  27281. *
  27282. * say('hello', 'fred', 'barney', 'pebbles');
  27283. * // => 'hello fred, barney, & pebbles'
  27284. */
  27285. function rest(func, start) {
  27286. if (typeof func != 'function') {
  27287. throw new TypeError(FUNC_ERROR_TEXT);
  27288. }
  27289. start = nativeMax(start === undefined ? (func.length - 1) : toInteger(start), 0);
  27290. return function() {
  27291. var args = arguments,
  27292. index = -1,
  27293. length = nativeMax(args.length - start, 0),
  27294. array = Array(length);
  27295. while (++index < length) {
  27296. array[index] = args[start + index];
  27297. }
  27298. switch (start) {
  27299. case 0: return func.call(this, array);
  27300. case 1: return func.call(this, args[0], array);
  27301. case 2: return func.call(this, args[0], args[1], array);
  27302. }
  27303. var otherArgs = Array(start + 1);
  27304. index = -1;
  27305. while (++index < start) {
  27306. otherArgs[index] = args[index];
  27307. }
  27308. otherArgs[start] = array;
  27309. return apply(func, this, otherArgs);
  27310. };
  27311. }
  27312. function initialParams (fn) {
  27313. return rest(function (args /*..., callback*/) {
  27314. var callback = args.pop();
  27315. fn.call(this, args, callback);
  27316. });
  27317. }
  27318. function applyEach$1(eachfn) {
  27319. return rest(function (fns, args) {
  27320. var go = initialParams(function (args, callback) {
  27321. var that = this;
  27322. return eachfn(fns, function (fn, cb) {
  27323. fn.apply(that, args.concat([cb]));
  27324. }, callback);
  27325. });
  27326. if (args.length) {
  27327. return go.apply(this, args);
  27328. } else {
  27329. return go;
  27330. }
  27331. });
  27332. }
  27333. /**
  27334. * A method that returns `undefined`.
  27335. *
  27336. * @static
  27337. * @memberOf _
  27338. * @since 2.3.0
  27339. * @category Util
  27340. * @example
  27341. *
  27342. * _.times(2, _.noop);
  27343. * // => [undefined, undefined]
  27344. */
  27345. function noop() {
  27346. // No operation performed.
  27347. }
  27348. function once(fn) {
  27349. return function () {
  27350. if (fn === null) return;
  27351. var callFn = fn;
  27352. fn = null;
  27353. callFn.apply(this, arguments);
  27354. };
  27355. }
  27356. /**
  27357. * The base implementation of `_.property` without support for deep paths.
  27358. *
  27359. * @private
  27360. * @param {string} key The key of the property to get.
  27361. * @returns {Function} Returns the new accessor function.
  27362. */
  27363. function baseProperty(key) {
  27364. return function(object) {
  27365. return object == null ? undefined : object[key];
  27366. };
  27367. }
  27368. /**
  27369. * Gets the "length" property value of `object`.
  27370. *
  27371. * **Note:** This function is used to avoid a
  27372. * [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) that affects
  27373. * Safari on at least iOS 8.1-8.3 ARM64.
  27374. *
  27375. * @private
  27376. * @param {Object} object The object to query.
  27377. * @returns {*} Returns the "length" value.
  27378. */
  27379. var getLength = baseProperty('length');
  27380. /** Used as references for various `Number` constants. */
  27381. var MAX_SAFE_INTEGER = 9007199254740991;
  27382. /**
  27383. * Checks if `value` is a valid array-like length.
  27384. *
  27385. * **Note:** This function is loosely based on
  27386. * [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
  27387. *
  27388. * @static
  27389. * @memberOf _
  27390. * @since 4.0.0
  27391. * @category Lang
  27392. * @param {*} value The value to check.
  27393. * @returns {boolean} Returns `true` if `value` is a valid length,
  27394. * else `false`.
  27395. * @example
  27396. *
  27397. * _.isLength(3);
  27398. * // => true
  27399. *
  27400. * _.isLength(Number.MIN_VALUE);
  27401. * // => false
  27402. *
  27403. * _.isLength(Infinity);
  27404. * // => false
  27405. *
  27406. * _.isLength('3');
  27407. * // => false
  27408. */
  27409. function isLength(value) {
  27410. return typeof value == 'number' &&
  27411. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  27412. }
  27413. /**
  27414. * Checks if `value` is array-like. A value is considered array-like if it's
  27415. * not a function and has a `value.length` that's an integer greater than or
  27416. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  27417. *
  27418. * @static
  27419. * @memberOf _
  27420. * @since 4.0.0
  27421. * @category Lang
  27422. * @param {*} value The value to check.
  27423. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  27424. * @example
  27425. *
  27426. * _.isArrayLike([1, 2, 3]);
  27427. * // => true
  27428. *
  27429. * _.isArrayLike(document.body.children);
  27430. * // => true
  27431. *
  27432. * _.isArrayLike('abc');
  27433. * // => true
  27434. *
  27435. * _.isArrayLike(_.noop);
  27436. * // => false
  27437. */
  27438. function isArrayLike(value) {
  27439. return value != null && isLength(getLength(value)) && !isFunction(value);
  27440. }
  27441. var iteratorSymbol = typeof Symbol === 'function' && Symbol.iterator;
  27442. function getIterator (coll) {
  27443. return iteratorSymbol && coll[iteratorSymbol] && coll[iteratorSymbol]();
  27444. }
  27445. /* Built-in method references for those with the same name as other `lodash` methods. */
  27446. var nativeGetPrototype = Object.getPrototypeOf;
  27447. /**
  27448. * Gets the `[[Prototype]]` of `value`.
  27449. *
  27450. * @private
  27451. * @param {*} value The value to query.
  27452. * @returns {null|Object} Returns the `[[Prototype]]`.
  27453. */
  27454. function getPrototype(value) {
  27455. return nativeGetPrototype(Object(value));
  27456. }
  27457. /** Used for built-in method references. */
  27458. var objectProto$2 = Object.prototype;
  27459. /** Used to check objects for own properties. */
  27460. var hasOwnProperty = objectProto$2.hasOwnProperty;
  27461. /**
  27462. * The base implementation of `_.has` without support for deep paths.
  27463. *
  27464. * @private
  27465. * @param {Object} [object] The object to query.
  27466. * @param {Array|string} key The key to check.
  27467. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  27468. */
  27469. function baseHas(object, key) {
  27470. // Avoid a bug in IE 10-11 where objects with a [[Prototype]] of `null`,
  27471. // that are composed entirely of index properties, return `false` for
  27472. // `hasOwnProperty` checks of them.
  27473. return object != null &&
  27474. (hasOwnProperty.call(object, key) ||
  27475. (typeof object == 'object' && key in object && getPrototype(object) === null));
  27476. }
  27477. /* Built-in method references for those with the same name as other `lodash` methods. */
  27478. var nativeKeys = Object.keys;
  27479. /**
  27480. * The base implementation of `_.keys` which doesn't skip the constructor
  27481. * property of prototypes or treat sparse arrays as dense.
  27482. *
  27483. * @private
  27484. * @param {Object} object The object to query.
  27485. * @returns {Array} Returns the array of property names.
  27486. */
  27487. function baseKeys(object) {
  27488. return nativeKeys(Object(object));
  27489. }
  27490. /**
  27491. * The base implementation of `_.times` without support for iteratee shorthands
  27492. * or max array length checks.
  27493. *
  27494. * @private
  27495. * @param {number} n The number of times to invoke `iteratee`.
  27496. * @param {Function} iteratee The function invoked per iteration.
  27497. * @returns {Array} Returns the array of results.
  27498. */
  27499. function baseTimes(n, iteratee) {
  27500. var index = -1,
  27501. result = Array(n);
  27502. while (++index < n) {
  27503. result[index] = iteratee(index);
  27504. }
  27505. return result;
  27506. }
  27507. /**
  27508. * This method is like `_.isArrayLike` except that it also checks if `value`
  27509. * is an object.
  27510. *
  27511. * @static
  27512. * @memberOf _
  27513. * @since 4.0.0
  27514. * @category Lang
  27515. * @param {*} value The value to check.
  27516. * @returns {boolean} Returns `true` if `value` is an array-like object,
  27517. * else `false`.
  27518. * @example
  27519. *
  27520. * _.isArrayLikeObject([1, 2, 3]);
  27521. * // => true
  27522. *
  27523. * _.isArrayLikeObject(document.body.children);
  27524. * // => true
  27525. *
  27526. * _.isArrayLikeObject('abc');
  27527. * // => false
  27528. *
  27529. * _.isArrayLikeObject(_.noop);
  27530. * // => false
  27531. */
  27532. function isArrayLikeObject(value) {
  27533. return isObjectLike(value) && isArrayLike(value);
  27534. }
  27535. /** `Object#toString` result references. */
  27536. var argsTag = '[object Arguments]';
  27537. /** Used for built-in method references. */
  27538. var objectProto$3 = Object.prototype;
  27539. /** Used to check objects for own properties. */
  27540. var hasOwnProperty$1 = objectProto$3.hasOwnProperty;
  27541. /**
  27542. * Used to resolve the
  27543. * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  27544. * of values.
  27545. */
  27546. var objectToString$2 = objectProto$3.toString;
  27547. /** Built-in value references. */
  27548. var propertyIsEnumerable = objectProto$3.propertyIsEnumerable;
  27549. /**
  27550. * Checks if `value` is likely an `arguments` object.
  27551. *
  27552. * @static
  27553. * @memberOf _
  27554. * @since 0.1.0
  27555. * @category Lang
  27556. * @param {*} value The value to check.
  27557. * @returns {boolean} Returns `true` if `value` is correctly classified,
  27558. * else `false`.
  27559. * @example
  27560. *
  27561. * _.isArguments(function() { return arguments; }());
  27562. * // => true
  27563. *
  27564. * _.isArguments([1, 2, 3]);
  27565. * // => false
  27566. */
  27567. function isArguments(value) {
  27568. // Safari 8.1 incorrectly makes `arguments.callee` enumerable in strict mode.
  27569. return isArrayLikeObject(value) && hasOwnProperty$1.call(value, 'callee') &&
  27570. (!propertyIsEnumerable.call(value, 'callee') || objectToString$2.call(value) == argsTag);
  27571. }
  27572. /**
  27573. * Checks if `value` is classified as an `Array` object.
  27574. *
  27575. * @static
  27576. * @memberOf _
  27577. * @since 0.1.0
  27578. * @type {Function}
  27579. * @category Lang
  27580. * @param {*} value The value to check.
  27581. * @returns {boolean} Returns `true` if `value` is correctly classified,
  27582. * else `false`.
  27583. * @example
  27584. *
  27585. * _.isArray([1, 2, 3]);
  27586. * // => true
  27587. *
  27588. * _.isArray(document.body.children);
  27589. * // => false
  27590. *
  27591. * _.isArray('abc');
  27592. * // => false
  27593. *
  27594. * _.isArray(_.noop);
  27595. * // => false
  27596. */
  27597. var isArray = Array.isArray;
  27598. /** `Object#toString` result references. */
  27599. var stringTag = '[object String]';
  27600. /** Used for built-in method references. */
  27601. var objectProto$4 = Object.prototype;
  27602. /**
  27603. * Used to resolve the
  27604. * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  27605. * of values.
  27606. */
  27607. var objectToString$3 = objectProto$4.toString;
  27608. /**
  27609. * Checks if `value` is classified as a `String` primitive or object.
  27610. *
  27611. * @static
  27612. * @since 0.1.0
  27613. * @memberOf _
  27614. * @category Lang
  27615. * @param {*} value The value to check.
  27616. * @returns {boolean} Returns `true` if `value` is correctly classified,
  27617. * else `false`.
  27618. * @example
  27619. *
  27620. * _.isString('abc');
  27621. * // => true
  27622. *
  27623. * _.isString(1);
  27624. * // => false
  27625. */
  27626. function isString(value) {
  27627. return typeof value == 'string' ||
  27628. (!isArray(value) && isObjectLike(value) && objectToString$3.call(value) == stringTag);
  27629. }
  27630. /**
  27631. * Creates an array of index keys for `object` values of arrays,
  27632. * `arguments` objects, and strings, otherwise `null` is returned.
  27633. *
  27634. * @private
  27635. * @param {Object} object The object to query.
  27636. * @returns {Array|null} Returns index keys, else `null`.
  27637. */
  27638. function indexKeys(object) {
  27639. var length = object ? object.length : undefined;
  27640. if (isLength(length) &&
  27641. (isArray(object) || isString(object) || isArguments(object))) {
  27642. return baseTimes(length, String);
  27643. }
  27644. return null;
  27645. }
  27646. /** Used as references for various `Number` constants. */
  27647. var MAX_SAFE_INTEGER$1 = 9007199254740991;
  27648. /** Used to detect unsigned integer values. */
  27649. var reIsUint = /^(?:0|[1-9]\d*)$/;
  27650. /**
  27651. * Checks if `value` is a valid array-like index.
  27652. *
  27653. * @private
  27654. * @param {*} value The value to check.
  27655. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  27656. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  27657. */
  27658. function isIndex(value, length) {
  27659. length = length == null ? MAX_SAFE_INTEGER$1 : length;
  27660. return !!length &&
  27661. (typeof value == 'number' || reIsUint.test(value)) &&
  27662. (value > -1 && value % 1 == 0 && value < length);
  27663. }
  27664. /** Used for built-in method references. */
  27665. var objectProto$5 = Object.prototype;
  27666. /**
  27667. * Checks if `value` is likely a prototype object.
  27668. *
  27669. * @private
  27670. * @param {*} value The value to check.
  27671. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  27672. */
  27673. function isPrototype(value) {
  27674. var Ctor = value && value.constructor,
  27675. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$5;
  27676. return value === proto;
  27677. }
  27678. /**
  27679. * Creates an array of the own enumerable property names of `object`.
  27680. *
  27681. * **Note:** Non-object values are coerced to objects. See the
  27682. * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
  27683. * for more details.
  27684. *
  27685. * @static
  27686. * @since 0.1.0
  27687. * @memberOf _
  27688. * @category Object
  27689. * @param {Object} object The object to query.
  27690. * @returns {Array} Returns the array of property names.
  27691. * @example
  27692. *
  27693. * function Foo() {
  27694. * this.a = 1;
  27695. * this.b = 2;
  27696. * }
  27697. *
  27698. * Foo.prototype.c = 3;
  27699. *
  27700. * _.keys(new Foo);
  27701. * // => ['a', 'b'] (iteration order is not guaranteed)
  27702. *
  27703. * _.keys('hi');
  27704. * // => ['0', '1']
  27705. */
  27706. function keys(object) {
  27707. var isProto = isPrototype(object);
  27708. if (!(isProto || isArrayLike(object))) {
  27709. return baseKeys(object);
  27710. }
  27711. var indexes = indexKeys(object),
  27712. skipIndexes = !!indexes,
  27713. result = indexes || [],
  27714. length = result.length;
  27715. for (var key in object) {
  27716. if (baseHas(object, key) &&
  27717. !(skipIndexes && (key == 'length' || isIndex(key, length))) &&
  27718. !(isProto && key == 'constructor')) {
  27719. result.push(key);
  27720. }
  27721. }
  27722. return result;
  27723. }
  27724. function iterator(coll) {
  27725. var i = -1;
  27726. var len;
  27727. if (isArrayLike(coll)) {
  27728. len = coll.length;
  27729. return function next() {
  27730. i++;
  27731. return i < len ? { value: coll[i], key: i } : null;
  27732. };
  27733. }
  27734. var iterate = getIterator(coll);
  27735. if (iterate) {
  27736. return function next() {
  27737. var item = iterate.next();
  27738. if (item.done) return null;
  27739. i++;
  27740. return { value: item.value, key: i };
  27741. };
  27742. }
  27743. var okeys = keys(coll);
  27744. len = okeys.length;
  27745. return function next() {
  27746. i++;
  27747. var key = okeys[i];
  27748. return i < len ? { value: coll[key], key: key } : null;
  27749. };
  27750. }
  27751. function onlyOnce(fn) {
  27752. return function () {
  27753. if (fn === null) throw new Error("Callback was already called.");
  27754. var callFn = fn;
  27755. fn = null;
  27756. callFn.apply(this, arguments);
  27757. };
  27758. }
  27759. function _eachOfLimit(limit) {
  27760. return function (obj, iteratee, callback) {
  27761. callback = once(callback || noop);
  27762. obj = obj || [];
  27763. var nextElem = iterator(obj);
  27764. if (limit <= 0) {
  27765. return callback(null);
  27766. }
  27767. var done = false;
  27768. var running = 0;
  27769. var errored = false;
  27770. (function replenish() {
  27771. if (done && running <= 0) {
  27772. return callback(null);
  27773. }
  27774. while (running < limit && !errored) {
  27775. var elem = nextElem();
  27776. if (elem === null) {
  27777. done = true;
  27778. if (running <= 0) {
  27779. callback(null);
  27780. }
  27781. return;
  27782. }
  27783. running += 1;
  27784. iteratee(elem.value, elem.key, onlyOnce(function (err) {
  27785. running -= 1;
  27786. if (err) {
  27787. callback(err);
  27788. errored = true;
  27789. } else {
  27790. replenish();
  27791. }
  27792. }));
  27793. }
  27794. })();
  27795. };
  27796. }
  27797. function doParallelLimit(fn) {
  27798. return function (obj, limit, iteratee, callback) {
  27799. return fn(_eachOfLimit(limit), obj, iteratee, callback);
  27800. };
  27801. }
  27802. function _asyncMap(eachfn, arr, iteratee, callback) {
  27803. callback = once(callback || noop);
  27804. arr = arr || [];
  27805. var results = [];
  27806. var counter = 0;
  27807. eachfn(arr, function (value, _, callback) {
  27808. var index = counter++;
  27809. iteratee(value, function (err, v) {
  27810. results[index] = v;
  27811. callback(err);
  27812. });
  27813. }, function (err) {
  27814. callback(err, results);
  27815. });
  27816. }
  27817. /**
  27818. * The same as `map` but runs a maximum of `limit` async operations at a time.
  27819. *
  27820. * @name mapLimit
  27821. * @static
  27822. * @memberOf async
  27823. * @see async.map
  27824. * @category Collection
  27825. * @param {Array|Object} coll - A collection to iterate over.
  27826. * @param {number} limit - The maximum number of async operations at a time.
  27827. * @param {Function} iteratee - A function to apply to each item in `coll`.
  27828. * The iteratee is passed a `callback(err, transformed)` which must be called
  27829. * once it has completed with an error (which can be `null`) and a transformed
  27830. * item. Invoked with (item, callback).
  27831. * @param {Function} [callback] - A callback which is called when all `iteratee`
  27832. * functions have finished, or an error occurs. Results is an array of the
  27833. * transformed items from the `coll`. Invoked with (err, results).
  27834. */
  27835. var mapLimit = doParallelLimit(_asyncMap);
  27836. function doLimit(fn, limit) {
  27837. return function (iterable, iteratee, callback) {
  27838. return fn(iterable, limit, iteratee, callback);
  27839. };
  27840. }
  27841. /**
  27842. * Produces a new collection of values by mapping each value in `coll` through
  27843. * the `iteratee` function. The `iteratee` is called with an item from `coll`
  27844. * and a callback for when it has finished processing. Each of these callback
  27845. * takes 2 arguments: an `error`, and the transformed item from `coll`. If
  27846. * `iteratee` passes an error to its callback, the main `callback` (for the
  27847. * `map` function) is immediately called with the error.
  27848. *
  27849. * Note, that since this function applies the `iteratee` to each item in
  27850. * parallel, there is no guarantee that the `iteratee` functions will complete
  27851. * in order. However, the results array will be in the same order as the
  27852. * original `coll`.
  27853. *
  27854. * If `map` is passed an Object, the results will be an Array. The results
  27855. * will roughly be in the order of the original Objects' keys (but this can
  27856. * vary across JavaScript engines)
  27857. *
  27858. * @name map
  27859. * @static
  27860. * @memberOf async
  27861. * @category Collection
  27862. * @param {Array|Object} coll - A collection to iterate over.
  27863. * @param {Function} iteratee - A function to apply to each item in `coll`.
  27864. * The iteratee is passed a `callback(err, transformed)` which must be called
  27865. * once it has completed with an error (which can be `null`) and a
  27866. * transformed item. Invoked with (item, callback).
  27867. * @param {Function} [callback] - A callback which is called when all `iteratee`
  27868. * functions have finished, or an error occurs. Results is an Array of the
  27869. * transformed items from the `coll`. Invoked with (err, results).
  27870. * @example
  27871. *
  27872. * async.map(['file1','file2','file3'], fs.stat, function(err, results) {
  27873. * // results is now an array of stats for each file
  27874. * });
  27875. */
  27876. var map = doLimit(mapLimit, Infinity);
  27877. /**
  27878. * Applies the provided arguments to each function in the array, calling
  27879. * `callback` after all functions have completed. If you only provide the first
  27880. * argument, then it will return a function which lets you pass in the
  27881. * arguments as if it were a single function call.
  27882. *
  27883. * @name applyEach
  27884. * @static
  27885. * @memberOf async
  27886. * @category Control Flow
  27887. * @param {Array|Object} fns - A collection of asynchronous functions to all
  27888. * call with the same arguments
  27889. * @param {...*} [args] - any number of separate arguments to pass to the
  27890. * function.
  27891. * @param {Function} [callback] - the final argument should be the callback,
  27892. * called when all functions have completed processing.
  27893. * @returns {Function} - If only the first argument is provided, it will return
  27894. * a function which lets you pass in the arguments as if it were a single
  27895. * function call.
  27896. * @example
  27897. *
  27898. * async.applyEach([enableSearch, updateSchema], 'bucket', callback);
  27899. *
  27900. * // partial application example:
  27901. * async.each(
  27902. * buckets,
  27903. * async.applyEach([enableSearch, updateSchema]),
  27904. * callback
  27905. * );
  27906. */
  27907. var applyEach = applyEach$1(map);
  27908. /**
  27909. * The same as `map` but runs only a single async operation at a time.
  27910. *
  27911. * @name mapSeries
  27912. * @static
  27913. * @memberOf async
  27914. * @see async.map
  27915. * @category Collection
  27916. * @param {Array|Object} coll - A collection to iterate over.
  27917. * @param {Function} iteratee - A function to apply to each item in `coll`.
  27918. * The iteratee is passed a `callback(err, transformed)` which must be called
  27919. * once it has completed with an error (which can be `null`) and a
  27920. * transformed item. Invoked with (item, callback).
  27921. * @param {Function} [callback] - A callback which is called when all `iteratee`
  27922. * functions have finished, or an error occurs. Results is an array of the
  27923. * transformed items from the `coll`. Invoked with (err, results).
  27924. */
  27925. var mapSeries = doLimit(mapLimit, 1);
  27926. /**
  27927. * The same as `applyEach` but runs only a single async operation at a time.
  27928. *
  27929. * @name applyEachSeries
  27930. * @static
  27931. * @memberOf async
  27932. * @see async.applyEach
  27933. * @category Control Flow
  27934. * @param {Array|Object} fns - A collection of asynchronous functions to all
  27935. * call with the same arguments
  27936. * @param {...*} [args] - any number of separate arguments to pass to the
  27937. * function.
  27938. * @param {Function} [callback] - the final argument should be the callback,
  27939. * called when all functions have completed processing.
  27940. * @returns {Function} - If only the first argument is provided, it will return
  27941. * a function which lets you pass in the arguments as if it were a single
  27942. * function call.
  27943. */
  27944. var applyEachSeries = applyEach$1(mapSeries);
  27945. /**
  27946. * Creates a continuation function with some arguments already applied.
  27947. *
  27948. * Useful as a shorthand when combined with other control flow functions. Any
  27949. * arguments passed to the returned function are added to the arguments
  27950. * originally passed to apply.
  27951. *
  27952. * @name apply
  27953. * @static
  27954. * @memberOf async
  27955. * @category Util
  27956. * @param {Function} function - The function you want to eventually apply all
  27957. * arguments to. Invokes with (arguments...).
  27958. * @param {...*} arguments... - Any number of arguments to automatically apply
  27959. * when the continuation is called.
  27960. * @example
  27961. *
  27962. * // using apply
  27963. * async.parallel([
  27964. * async.apply(fs.writeFile, 'testfile1', 'test1'),
  27965. * async.apply(fs.writeFile, 'testfile2', 'test2')
  27966. * ]);
  27967. *
  27968. *
  27969. * // the same process without using apply
  27970. * async.parallel([
  27971. * function(callback) {
  27972. * fs.writeFile('testfile1', 'test1', callback);
  27973. * },
  27974. * function(callback) {
  27975. * fs.writeFile('testfile2', 'test2', callback);
  27976. * }
  27977. * ]);
  27978. *
  27979. * // It's possible to pass any number of additional arguments when calling the
  27980. * // continuation:
  27981. *
  27982. * node> var fn = async.apply(sys.puts, 'one');
  27983. * node> fn('two', 'three');
  27984. * one
  27985. * two
  27986. * three
  27987. */
  27988. var apply$1 = rest(function (fn, args) {
  27989. return rest(function (callArgs) {
  27990. return fn.apply(null, args.concat(callArgs));
  27991. });
  27992. });
  27993. /**
  27994. * Take a sync function and make it async, passing its return value to a
  27995. * callback. This is useful for plugging sync functions into a waterfall,
  27996. * series, or other async functions. Any arguments passed to the generated
  27997. * function will be passed to the wrapped function (except for the final
  27998. * callback argument). Errors thrown will be passed to the callback.
  27999. *
  28000. * If the function passed to `asyncify` returns a Promise, that promises's
  28001. * resolved/rejected state will be used to call the callback, rather than simply
  28002. * the synchronous return value.
  28003. *
  28004. * This also means you can asyncify ES2016 `async` functions.
  28005. *
  28006. * @name asyncify
  28007. * @static
  28008. * @memberOf async
  28009. * @alias wrapSync
  28010. * @category Util
  28011. * @param {Function} func - The synchronous function to convert to an
  28012. * asynchronous function.
  28013. * @returns {Function} An asynchronous wrapper of the `func`. To be invoked with
  28014. * (callback).
  28015. * @example
  28016. *
  28017. * // passing a regular synchronous function
  28018. * async.waterfall([
  28019. * async.apply(fs.readFile, filename, "utf8"),
  28020. * async.asyncify(JSON.parse),
  28021. * function (data, next) {
  28022. * // data is the result of parsing the text.
  28023. * // If there was a parsing error, it would have been caught.
  28024. * }
  28025. * ], callback);
  28026. *
  28027. * // passing a function returning a promise
  28028. * async.waterfall([
  28029. * async.apply(fs.readFile, filename, "utf8"),
  28030. * async.asyncify(function (contents) {
  28031. * return db.model.create(contents);
  28032. * }),
  28033. * function (model, next) {
  28034. * // `model` is the instantiated model object.
  28035. * // If there was an error, this function would be skipped.
  28036. * }
  28037. * ], callback);
  28038. *
  28039. * // es6 example
  28040. * var q = async.queue(async.asyncify(async function(file) {
  28041. * var intermediateStep = await processFile(file);
  28042. * return await somePromise(intermediateStep)
  28043. * }));
  28044. *
  28045. * q.push(files);
  28046. */
  28047. function asyncify(func) {
  28048. return initialParams(function (args, callback) {
  28049. var result;
  28050. try {
  28051. result = func.apply(this, args);
  28052. } catch (e) {
  28053. return callback(e);
  28054. }
  28055. // if result is Promise object
  28056. if (isObject(result) && typeof result.then === 'function') {
  28057. result.then(function (value) {
  28058. callback(null, value);
  28059. })['catch'](function (err) {
  28060. callback(err.message ? err : new Error(err));
  28061. });
  28062. } else {
  28063. callback(null, result);
  28064. }
  28065. });
  28066. }
  28067. /**
  28068. * A specialized version of `_.forEach` for arrays without support for
  28069. * iteratee shorthands.
  28070. *
  28071. * @private
  28072. * @param {Array} [array] The array to iterate over.
  28073. * @param {Function} iteratee The function invoked per iteration.
  28074. * @returns {Array} Returns `array`.
  28075. */
  28076. function arrayEach(array, iteratee) {
  28077. var index = -1,
  28078. length = array ? array.length : 0;
  28079. while (++index < length) {
  28080. if (iteratee(array[index], index, array) === false) {
  28081. break;
  28082. }
  28083. }
  28084. return array;
  28085. }
  28086. /**
  28087. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  28088. *
  28089. * @private
  28090. * @param {boolean} [fromRight] Specify iterating from right to left.
  28091. * @returns {Function} Returns the new base function.
  28092. */
  28093. function createBaseFor(fromRight) {
  28094. return function(object, iteratee, keysFunc) {
  28095. var index = -1,
  28096. iterable = Object(object),
  28097. props = keysFunc(object),
  28098. length = props.length;
  28099. while (length--) {
  28100. var key = props[fromRight ? length : ++index];
  28101. if (iteratee(iterable[key], key, iterable) === false) {
  28102. break;
  28103. }
  28104. }
  28105. return object;
  28106. };
  28107. }
  28108. /**
  28109. * The base implementation of `baseForOwn` which iterates over `object`
  28110. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  28111. * Iteratee functions may exit iteration early by explicitly returning `false`.
  28112. *
  28113. * @private
  28114. * @param {Object} object The object to iterate over.
  28115. * @param {Function} iteratee The function invoked per iteration.
  28116. * @param {Function} keysFunc The function to get the keys of `object`.
  28117. * @returns {Object} Returns `object`.
  28118. */
  28119. var baseFor = createBaseFor();
  28120. /**
  28121. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  28122. *
  28123. * @private
  28124. * @param {Object} object The object to iterate over.
  28125. * @param {Function} iteratee The function invoked per iteration.
  28126. * @returns {Object} Returns `object`.
  28127. */
  28128. function baseForOwn(object, iteratee) {
  28129. return object && baseFor(object, iteratee, keys);
  28130. }
  28131. /**
  28132. * Removes all key-value entries from the list cache.
  28133. *
  28134. * @private
  28135. * @name clear
  28136. * @memberOf ListCache
  28137. */
  28138. function listCacheClear() {
  28139. this.__data__ = [];
  28140. }
  28141. /**
  28142. * Performs a
  28143. * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
  28144. * comparison between two values to determine if they are equivalent.
  28145. *
  28146. * @static
  28147. * @memberOf _
  28148. * @since 4.0.0
  28149. * @category Lang
  28150. * @param {*} value The value to compare.
  28151. * @param {*} other The other value to compare.
  28152. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  28153. * @example
  28154. *
  28155. * var object = { 'user': 'fred' };
  28156. * var other = { 'user': 'fred' };
  28157. *
  28158. * _.eq(object, object);
  28159. * // => true
  28160. *
  28161. * _.eq(object, other);
  28162. * // => false
  28163. *
  28164. * _.eq('a', 'a');
  28165. * // => true
  28166. *
  28167. * _.eq('a', Object('a'));
  28168. * // => false
  28169. *
  28170. * _.eq(NaN, NaN);
  28171. * // => true
  28172. */
  28173. function eq(value, other) {
  28174. return value === other || (value !== value && other !== other);
  28175. }
  28176. /**
  28177. * Gets the index at which the `key` is found in `array` of key-value pairs.
  28178. *
  28179. * @private
  28180. * @param {Array} array The array to search.
  28181. * @param {*} key The key to search for.
  28182. * @returns {number} Returns the index of the matched value, else `-1`.
  28183. */
  28184. function assocIndexOf(array, key) {
  28185. var length = array.length;
  28186. while (length--) {
  28187. if (eq(array[length][0], key)) {
  28188. return length;
  28189. }
  28190. }
  28191. return -1;
  28192. }
  28193. /** Used for built-in method references. */
  28194. var arrayProto = Array.prototype;
  28195. /** Built-in value references. */
  28196. var splice = arrayProto.splice;
  28197. /**
  28198. * Removes `key` and its value from the list cache.
  28199. *
  28200. * @private
  28201. * @name delete
  28202. * @memberOf ListCache
  28203. * @param {string} key The key of the value to remove.
  28204. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  28205. */
  28206. function listCacheDelete(key) {
  28207. var data = this.__data__,
  28208. index = assocIndexOf(data, key);
  28209. if (index < 0) {
  28210. return false;
  28211. }
  28212. var lastIndex = data.length - 1;
  28213. if (index == lastIndex) {
  28214. data.pop();
  28215. } else {
  28216. splice.call(data, index, 1);
  28217. }
  28218. return true;
  28219. }
  28220. /**
  28221. * Gets the list cache value for `key`.
  28222. *
  28223. * @private
  28224. * @name get
  28225. * @memberOf ListCache
  28226. * @param {string} key The key of the value to get.
  28227. * @returns {*} Returns the entry value.
  28228. */
  28229. function listCacheGet(key) {
  28230. var data = this.__data__,
  28231. index = assocIndexOf(data, key);
  28232. return index < 0 ? undefined : data[index][1];
  28233. }
  28234. /**
  28235. * Checks if a list cache value for `key` exists.
  28236. *
  28237. * @private
  28238. * @name has
  28239. * @memberOf ListCache
  28240. * @param {string} key The key of the entry to check.
  28241. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  28242. */
  28243. function listCacheHas(key) {
  28244. return assocIndexOf(this.__data__, key) > -1;
  28245. }
  28246. /**
  28247. * Sets the list cache `key` to `value`.
  28248. *
  28249. * @private
  28250. * @name set
  28251. * @memberOf ListCache
  28252. * @param {string} key The key of the value to set.
  28253. * @param {*} value The value to set.
  28254. * @returns {Object} Returns the list cache instance.
  28255. */
  28256. function listCacheSet(key, value) {
  28257. var data = this.__data__,
  28258. index = assocIndexOf(data, key);
  28259. if (index < 0) {
  28260. data.push([key, value]);
  28261. } else {
  28262. data[index][1] = value;
  28263. }
  28264. return this;
  28265. }
  28266. /**
  28267. * Creates an list cache object.
  28268. *
  28269. * @private
  28270. * @constructor
  28271. * @param {Array} [entries] The key-value pairs to cache.
  28272. */
  28273. function ListCache(entries) {
  28274. var index = -1,
  28275. length = entries ? entries.length : 0;
  28276. this.clear();
  28277. while (++index < length) {
  28278. var entry = entries[index];
  28279. this.set(entry[0], entry[1]);
  28280. }
  28281. }
  28282. // Add methods to `ListCache`.
  28283. ListCache.prototype.clear = listCacheClear;
  28284. ListCache.prototype['delete'] = listCacheDelete;
  28285. ListCache.prototype.get = listCacheGet;
  28286. ListCache.prototype.has = listCacheHas;
  28287. ListCache.prototype.set = listCacheSet;
  28288. /**
  28289. * Removes all key-value entries from the stack.
  28290. *
  28291. * @private
  28292. * @name clear
  28293. * @memberOf Stack
  28294. */
  28295. function stackClear() {
  28296. this.__data__ = new ListCache;
  28297. }
  28298. /**
  28299. * Removes `key` and its value from the stack.
  28300. *
  28301. * @private
  28302. * @name delete
  28303. * @memberOf Stack
  28304. * @param {string} key The key of the value to remove.
  28305. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  28306. */
  28307. function stackDelete(key) {
  28308. return this.__data__['delete'](key);
  28309. }
  28310. /**
  28311. * Gets the stack value for `key`.
  28312. *
  28313. * @private
  28314. * @name get
  28315. * @memberOf Stack
  28316. * @param {string} key The key of the value to get.
  28317. * @returns {*} Returns the entry value.
  28318. */
  28319. function stackGet(key) {
  28320. return this.__data__.get(key);
  28321. }
  28322. /**
  28323. * Checks if a stack value for `key` exists.
  28324. *
  28325. * @private
  28326. * @name has
  28327. * @memberOf Stack
  28328. * @param {string} key The key of the entry to check.
  28329. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  28330. */
  28331. function stackHas(key) {
  28332. return this.__data__.has(key);
  28333. }
  28334. /**
  28335. * Checks if `value` is a host object in IE < 9.
  28336. *
  28337. * @private
  28338. * @param {*} value The value to check.
  28339. * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
  28340. */
  28341. function isHostObject(value) {
  28342. // Many host objects are `Object` objects that can coerce to strings
  28343. // despite having improperly defined `toString` methods.
  28344. var result = false;
  28345. if (value != null && typeof value.toString != 'function') {
  28346. try {
  28347. result = !!(value + '');
  28348. } catch (e) {}
  28349. }
  28350. return result;
  28351. }
  28352. /**
  28353. * Checks if `value` is a global object.
  28354. *
  28355. * @private
  28356. * @param {*} value The value to check.
  28357. * @returns {null|Object} Returns `value` if it's a global object, else `null`.
  28358. */
  28359. function checkGlobal(value) {
  28360. return (value && value.Object === Object) ? value : null;
  28361. }
  28362. /** Detect free variable `global` from Node.js. */
  28363. var freeGlobal = checkGlobal(typeof global == 'object' && global);
  28364. /** Detect free variable `self`. */
  28365. var freeSelf = checkGlobal(typeof self == 'object' && self);
  28366. /** Detect `this` as the global object. */
  28367. var thisGlobal = checkGlobal(typeof this == 'object' && this);
  28368. /** Used as a reference to the global object. */
  28369. var root = freeGlobal || freeSelf || thisGlobal || Function('return this')();
  28370. /** Used to detect overreaching core-js shims. */
  28371. var coreJsData = root['__core-js_shared__'];
  28372. /** Used to detect methods masquerading as native. */
  28373. var maskSrcKey = (function() {
  28374. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  28375. return uid ? ('Symbol(src)_1.' + uid) : '';
  28376. }());
  28377. /**
  28378. * Checks if `func` has its source masked.
  28379. *
  28380. * @private
  28381. * @param {Function} func The function to check.
  28382. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  28383. */
  28384. function isMasked(func) {
  28385. return !!maskSrcKey && (maskSrcKey in func);
  28386. }
  28387. /** Used to resolve the decompiled source of functions. */
  28388. var funcToString$1 = Function.prototype.toString;
  28389. /**
  28390. * Converts `func` to its source code.
  28391. *
  28392. * @private
  28393. * @param {Function} func The function to process.
  28394. * @returns {string} Returns the source code.
  28395. */
  28396. function toSource(func) {
  28397. if (func != null) {
  28398. try {
  28399. return funcToString$1.call(func);
  28400. } catch (e) {}
  28401. try {
  28402. return (func + '');
  28403. } catch (e) {}
  28404. }
  28405. return '';
  28406. }
  28407. /**
  28408. * Used to match `RegExp`
  28409. * [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns).
  28410. */
  28411. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  28412. /** Used to detect host constructors (Safari). */
  28413. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  28414. /** Used for built-in method references. */
  28415. var objectProto$6 = Object.prototype;
  28416. /** Used to resolve the decompiled source of functions. */
  28417. var funcToString = Function.prototype.toString;
  28418. /** Used to check objects for own properties. */
  28419. var hasOwnProperty$2 = objectProto$6.hasOwnProperty;
  28420. /** Used to detect if a method is native. */
  28421. var reIsNative = RegExp('^' +
  28422. funcToString.call(hasOwnProperty$2).replace(reRegExpChar, '\\$&')
  28423. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  28424. );
  28425. /**
  28426. * The base implementation of `_.isNative` without bad shim checks.
  28427. *
  28428. * @private
  28429. * @param {*} value The value to check.
  28430. * @returns {boolean} Returns `true` if `value` is a native function,
  28431. * else `false`.
  28432. */
  28433. function baseIsNative(value) {
  28434. if (!isObject(value) || isMasked(value)) {
  28435. return false;
  28436. }
  28437. var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
  28438. return pattern.test(toSource(value));
  28439. }
  28440. /**
  28441. * Gets the value at `key` of `object`.
  28442. *
  28443. * @private
  28444. * @param {Object} [object] The object to query.
  28445. * @param {string} key The key of the property to get.
  28446. * @returns {*} Returns the property value.
  28447. */
  28448. function getValue(object, key) {
  28449. return object == null ? undefined : object[key];
  28450. }
  28451. /**
  28452. * Gets the native function at `key` of `object`.
  28453. *
  28454. * @private
  28455. * @param {Object} object The object to query.
  28456. * @param {string} key The key of the method to get.
  28457. * @returns {*} Returns the function if it's native, else `undefined`.
  28458. */
  28459. function getNative(object, key) {
  28460. var value = getValue(object, key);
  28461. return baseIsNative(value) ? value : undefined;
  28462. }
  28463. /* Built-in method references that are verified to be native. */
  28464. var nativeCreate = getNative(Object, 'create');
  28465. /**
  28466. * Removes all key-value entries from the hash.
  28467. *
  28468. * @private
  28469. * @name clear
  28470. * @memberOf Hash
  28471. */
  28472. function hashClear() {
  28473. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  28474. }
  28475. /**
  28476. * Removes `key` and its value from the hash.
  28477. *
  28478. * @private
  28479. * @name delete
  28480. * @memberOf Hash
  28481. * @param {Object} hash The hash to modify.
  28482. * @param {string} key The key of the value to remove.
  28483. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  28484. */
  28485. function hashDelete(key) {
  28486. return this.has(key) && delete this.__data__[key];
  28487. }
  28488. /** Used to stand-in for `undefined` hash values. */
  28489. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  28490. /** Used for built-in method references. */
  28491. var objectProto$7 = Object.prototype;
  28492. /** Used to check objects for own properties. */
  28493. var hasOwnProperty$3 = objectProto$7.hasOwnProperty;
  28494. /**
  28495. * Gets the hash value for `key`.
  28496. *
  28497. * @private
  28498. * @name get
  28499. * @memberOf Hash
  28500. * @param {string} key The key of the value to get.
  28501. * @returns {*} Returns the entry value.
  28502. */
  28503. function hashGet(key) {
  28504. var data = this.__data__;
  28505. if (nativeCreate) {
  28506. var result = data[key];
  28507. return result === HASH_UNDEFINED ? undefined : result;
  28508. }
  28509. return hasOwnProperty$3.call(data, key) ? data[key] : undefined;
  28510. }
  28511. /** Used for built-in method references. */
  28512. var objectProto$8 = Object.prototype;
  28513. /** Used to check objects for own properties. */
  28514. var hasOwnProperty$4 = objectProto$8.hasOwnProperty;
  28515. /**
  28516. * Checks if a hash value for `key` exists.
  28517. *
  28518. * @private
  28519. * @name has
  28520. * @memberOf Hash
  28521. * @param {string} key The key of the entry to check.
  28522. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  28523. */
  28524. function hashHas(key) {
  28525. var data = this.__data__;
  28526. return nativeCreate ? data[key] !== undefined : hasOwnProperty$4.call(data, key);
  28527. }
  28528. /** Used to stand-in for `undefined` hash values. */
  28529. var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
  28530. /**
  28531. * Sets the hash `key` to `value`.
  28532. *
  28533. * @private
  28534. * @name set
  28535. * @memberOf Hash
  28536. * @param {string} key The key of the value to set.
  28537. * @param {*} value The value to set.
  28538. * @returns {Object} Returns the hash instance.
  28539. */
  28540. function hashSet(key, value) {
  28541. var data = this.__data__;
  28542. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
  28543. return this;
  28544. }
  28545. /**
  28546. * Creates a hash object.
  28547. *
  28548. * @private
  28549. * @constructor
  28550. * @param {Array} [entries] The key-value pairs to cache.
  28551. */
  28552. function Hash(entries) {
  28553. var index = -1,
  28554. length = entries ? entries.length : 0;
  28555. this.clear();
  28556. while (++index < length) {
  28557. var entry = entries[index];
  28558. this.set(entry[0], entry[1]);
  28559. }
  28560. }
  28561. // Add methods to `Hash`.
  28562. Hash.prototype.clear = hashClear;
  28563. Hash.prototype['delete'] = hashDelete;
  28564. Hash.prototype.get = hashGet;
  28565. Hash.prototype.has = hashHas;
  28566. Hash.prototype.set = hashSet;
  28567. /* Built-in method references that are verified to be native. */
  28568. var Map = getNative(root, 'Map');
  28569. /**
  28570. * Removes all key-value entries from the map.
  28571. *
  28572. * @private
  28573. * @name clear
  28574. * @memberOf MapCache
  28575. */
  28576. function mapCacheClear() {
  28577. this.__data__ = {
  28578. 'hash': new Hash,
  28579. 'map': new (Map || ListCache),
  28580. 'string': new Hash
  28581. };
  28582. }
  28583. /**
  28584. * Checks if `value` is suitable for use as unique object key.
  28585. *
  28586. * @private
  28587. * @param {*} value The value to check.
  28588. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  28589. */
  28590. function isKeyable(value) {
  28591. var type = typeof value;
  28592. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  28593. ? (value !== '__proto__')
  28594. : (value === null);
  28595. }
  28596. /**
  28597. * Gets the data for `map`.
  28598. *
  28599. * @private
  28600. * @param {Object} map The map to query.
  28601. * @param {string} key The reference key.
  28602. * @returns {*} Returns the map data.
  28603. */
  28604. function getMapData(map, key) {
  28605. var data = map.__data__;
  28606. return isKeyable(key)
  28607. ? data[typeof key == 'string' ? 'string' : 'hash']
  28608. : data.map;
  28609. }
  28610. /**
  28611. * Removes `key` and its value from the map.
  28612. *
  28613. * @private
  28614. * @name delete
  28615. * @memberOf MapCache
  28616. * @param {string} key The key of the value to remove.
  28617. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  28618. */
  28619. function mapCacheDelete(key) {
  28620. return getMapData(this, key)['delete'](key);
  28621. }
  28622. /**
  28623. * Gets the map value for `key`.
  28624. *
  28625. * @private
  28626. * @name get
  28627. * @memberOf MapCache
  28628. * @param {string} key The key of the value to get.
  28629. * @returns {*} Returns the entry value.
  28630. */
  28631. function mapCacheGet(key) {
  28632. return getMapData(this, key).get(key);
  28633. }
  28634. /**
  28635. * Checks if a map value for `key` exists.
  28636. *
  28637. * @private
  28638. * @name has
  28639. * @memberOf MapCache
  28640. * @param {string} key The key of the entry to check.
  28641. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  28642. */
  28643. function mapCacheHas(key) {
  28644. return getMapData(this, key).has(key);
  28645. }
  28646. /**
  28647. * Sets the map `key` to `value`.
  28648. *
  28649. * @private
  28650. * @name set
  28651. * @memberOf MapCache
  28652. * @param {string} key The key of the value to set.
  28653. * @param {*} value The value to set.
  28654. * @returns {Object} Returns the map cache instance.
  28655. */
  28656. function mapCacheSet(key, value) {
  28657. getMapData(this, key).set(key, value);
  28658. return this;
  28659. }
  28660. /**
  28661. * Creates a map cache object to store key-value pairs.
  28662. *
  28663. * @private
  28664. * @constructor
  28665. * @param {Array} [entries] The key-value pairs to cache.
  28666. */
  28667. function MapCache(entries) {
  28668. var index = -1,
  28669. length = entries ? entries.length : 0;
  28670. this.clear();
  28671. while (++index < length) {
  28672. var entry = entries[index];
  28673. this.set(entry[0], entry[1]);
  28674. }
  28675. }
  28676. // Add methods to `MapCache`.
  28677. MapCache.prototype.clear = mapCacheClear;
  28678. MapCache.prototype['delete'] = mapCacheDelete;
  28679. MapCache.prototype.get = mapCacheGet;
  28680. MapCache.prototype.has = mapCacheHas;
  28681. MapCache.prototype.set = mapCacheSet;
  28682. /** Used as the size to enable large array optimizations. */
  28683. var LARGE_ARRAY_SIZE = 200;
  28684. /**
  28685. * Sets the stack `key` to `value`.
  28686. *
  28687. * @private
  28688. * @name set
  28689. * @memberOf Stack
  28690. * @param {string} key The key of the value to set.
  28691. * @param {*} value The value to set.
  28692. * @returns {Object} Returns the stack cache instance.
  28693. */
  28694. function stackSet(key, value) {
  28695. var cache = this.__data__;
  28696. if (cache instanceof ListCache && cache.__data__.length == LARGE_ARRAY_SIZE) {
  28697. cache = this.__data__ = new MapCache(cache.__data__);
  28698. }
  28699. cache.set(key, value);
  28700. return this;
  28701. }
  28702. /**
  28703. * Creates a stack cache object to store key-value pairs.
  28704. *
  28705. * @private
  28706. * @constructor
  28707. * @param {Array} [entries] The key-value pairs to cache.
  28708. */
  28709. function Stack(entries) {
  28710. this.__data__ = new ListCache(entries);
  28711. }
  28712. // Add methods to `Stack`.
  28713. Stack.prototype.clear = stackClear;
  28714. Stack.prototype['delete'] = stackDelete;
  28715. Stack.prototype.get = stackGet;
  28716. Stack.prototype.has = stackHas;
  28717. Stack.prototype.set = stackSet;
  28718. /** Used to stand-in for `undefined` hash values. */
  28719. var HASH_UNDEFINED$2 = '__lodash_hash_undefined__';
  28720. /**
  28721. * Adds `value` to the array cache.
  28722. *
  28723. * @private
  28724. * @name add
  28725. * @memberOf SetCache
  28726. * @alias push
  28727. * @param {*} value The value to cache.
  28728. * @returns {Object} Returns the cache instance.
  28729. */
  28730. function setCacheAdd(value) {
  28731. this.__data__.set(value, HASH_UNDEFINED$2);
  28732. return this;
  28733. }
  28734. /**
  28735. * Checks if `value` is in the array cache.
  28736. *
  28737. * @private
  28738. * @name has
  28739. * @memberOf SetCache
  28740. * @param {*} value The value to search for.
  28741. * @returns {number} Returns `true` if `value` is found, else `false`.
  28742. */
  28743. function setCacheHas(value) {
  28744. return this.__data__.has(value);
  28745. }
  28746. /**
  28747. *
  28748. * Creates an array cache object to store unique values.
  28749. *
  28750. * @private
  28751. * @constructor
  28752. * @param {Array} [values] The values to cache.
  28753. */
  28754. function SetCache(values) {
  28755. var index = -1,
  28756. length = values ? values.length : 0;
  28757. this.__data__ = new MapCache;
  28758. while (++index < length) {
  28759. this.add(values[index]);
  28760. }
  28761. }
  28762. // Add methods to `SetCache`.
  28763. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  28764. SetCache.prototype.has = setCacheHas;
  28765. /**
  28766. * A specialized version of `_.some` for arrays without support for iteratee
  28767. * shorthands.
  28768. *
  28769. * @private
  28770. * @param {Array} [array] The array to iterate over.
  28771. * @param {Function} predicate The function invoked per iteration.
  28772. * @returns {boolean} Returns `true` if any element passes the predicate check,
  28773. * else `false`.
  28774. */
  28775. function arraySome(array, predicate) {
  28776. var index = -1,
  28777. length = array ? array.length : 0;
  28778. while (++index < length) {
  28779. if (predicate(array[index], index, array)) {
  28780. return true;
  28781. }
  28782. }
  28783. return false;
  28784. }
  28785. var UNORDERED_COMPARE_FLAG$1 = 1;
  28786. var PARTIAL_COMPARE_FLAG$2 = 2;
  28787. /**
  28788. * A specialized version of `baseIsEqualDeep` for arrays with support for
  28789. * partial deep comparisons.
  28790. *
  28791. * @private
  28792. * @param {Array} array The array to compare.
  28793. * @param {Array} other The other array to compare.
  28794. * @param {Function} equalFunc The function to determine equivalents of values.
  28795. * @param {Function} customizer The function to customize comparisons.
  28796. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
  28797. * for more details.
  28798. * @param {Object} stack Tracks traversed `array` and `other` objects.
  28799. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  28800. */
  28801. function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
  28802. var isPartial = bitmask & PARTIAL_COMPARE_FLAG$2,
  28803. arrLength = array.length,
  28804. othLength = other.length;
  28805. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  28806. return false;
  28807. }
  28808. // Assume cyclic values are equal.
  28809. var stacked = stack.get(array);
  28810. if (stacked) {
  28811. return stacked == other;
  28812. }
  28813. var index = -1,
  28814. result = true,
  28815. seen = (bitmask & UNORDERED_COMPARE_FLAG$1) ? new SetCache : undefined;
  28816. stack.set(array, other);
  28817. // Ignore non-index properties.
  28818. while (++index < arrLength) {
  28819. var arrValue = array[index],
  28820. othValue = other[index];
  28821. if (customizer) {
  28822. var compared = isPartial
  28823. ? customizer(othValue, arrValue, index, other, array, stack)
  28824. : customizer(arrValue, othValue, index, array, other, stack);
  28825. }
  28826. if (compared !== undefined) {
  28827. if (compared) {
  28828. continue;
  28829. }
  28830. result = false;
  28831. break;
  28832. }
  28833. // Recursively compare arrays (susceptible to call stack limits).
  28834. if (seen) {
  28835. if (!arraySome(other, function(othValue, othIndex) {
  28836. if (!seen.has(othIndex) &&
  28837. (arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
  28838. return seen.add(othIndex);
  28839. }
  28840. })) {
  28841. result = false;
  28842. break;
  28843. }
  28844. } else if (!(
  28845. arrValue === othValue ||
  28846. equalFunc(arrValue, othValue, customizer, bitmask, stack)
  28847. )) {
  28848. result = false;
  28849. break;
  28850. }
  28851. }
  28852. stack['delete'](array);
  28853. return result;
  28854. }
  28855. /** Built-in value references. */
  28856. var Symbol$1 = root.Symbol;
  28857. /** Built-in value references. */
  28858. var Uint8Array = root.Uint8Array;
  28859. /**
  28860. * Converts `map` to its key-value pairs.
  28861. *
  28862. * @private
  28863. * @param {Object} map The map to convert.
  28864. * @returns {Array} Returns the key-value pairs.
  28865. */
  28866. function mapToArray(map) {
  28867. var index = -1,
  28868. result = Array(map.size);
  28869. map.forEach(function(value, key) {
  28870. result[++index] = [key, value];
  28871. });
  28872. return result;
  28873. }
  28874. /**
  28875. * Converts `set` to an array of its values.
  28876. *
  28877. * @private
  28878. * @param {Object} set The set to convert.
  28879. * @returns {Array} Returns the values.
  28880. */
  28881. function setToArray(set) {
  28882. var index = -1,
  28883. result = Array(set.size);
  28884. set.forEach(function(value) {
  28885. result[++index] = value;
  28886. });
  28887. return result;
  28888. }
  28889. var UNORDERED_COMPARE_FLAG$2 = 1;
  28890. var PARTIAL_COMPARE_FLAG$3 = 2;
  28891. var boolTag = '[object Boolean]';
  28892. var dateTag = '[object Date]';
  28893. var errorTag = '[object Error]';
  28894. var mapTag = '[object Map]';
  28895. var numberTag = '[object Number]';
  28896. var regexpTag = '[object RegExp]';
  28897. var setTag = '[object Set]';
  28898. var stringTag$1 = '[object String]';
  28899. var symbolTag$1 = '[object Symbol]';
  28900. var arrayBufferTag = '[object ArrayBuffer]';
  28901. var dataViewTag = '[object DataView]';
  28902. var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined;
  28903. var symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
  28904. /**
  28905. * A specialized version of `baseIsEqualDeep` for comparing objects of
  28906. * the same `toStringTag`.
  28907. *
  28908. * **Note:** This function only supports comparing values with tags of
  28909. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  28910. *
  28911. * @private
  28912. * @param {Object} object The object to compare.
  28913. * @param {Object} other The other object to compare.
  28914. * @param {string} tag The `toStringTag` of the objects to compare.
  28915. * @param {Function} equalFunc The function to determine equivalents of values.
  28916. * @param {Function} customizer The function to customize comparisons.
  28917. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
  28918. * for more details.
  28919. * @param {Object} stack Tracks traversed `object` and `other` objects.
  28920. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  28921. */
  28922. function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
  28923. switch (tag) {
  28924. case dataViewTag:
  28925. if ((object.byteLength != other.byteLength) ||
  28926. (object.byteOffset != other.byteOffset)) {
  28927. return false;
  28928. }
  28929. object = object.buffer;
  28930. other = other.buffer;
  28931. case arrayBufferTag:
  28932. if ((object.byteLength != other.byteLength) ||
  28933. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  28934. return false;
  28935. }
  28936. return true;
  28937. case boolTag:
  28938. case dateTag:
  28939. // Coerce dates and booleans to numbers, dates to milliseconds and
  28940. // booleans to `1` or `0` treating invalid dates coerced to `NaN` as
  28941. // not equal.
  28942. return +object == +other;
  28943. case errorTag:
  28944. return object.name == other.name && object.message == other.message;
  28945. case numberTag:
  28946. // Treat `NaN` vs. `NaN` as equal.
  28947. return (object != +object) ? other != +other : object == +other;
  28948. case regexpTag:
  28949. case stringTag$1:
  28950. // Coerce regexes to strings and treat strings, primitives and objects,
  28951. // as equal. See http://www.ecma-international.org/ecma-262/6.0/#sec-regexp.prototype.tostring
  28952. // for more details.
  28953. return object == (other + '');
  28954. case mapTag:
  28955. var convert = mapToArray;
  28956. case setTag:
  28957. var isPartial = bitmask & PARTIAL_COMPARE_FLAG$3;
  28958. convert || (convert = setToArray);
  28959. if (object.size != other.size && !isPartial) {
  28960. return false;
  28961. }
  28962. // Assume cyclic values are equal.
  28963. var stacked = stack.get(object);
  28964. if (stacked) {
  28965. return stacked == other;
  28966. }
  28967. bitmask |= UNORDERED_COMPARE_FLAG$2;
  28968. stack.set(object, other);
  28969. // Recursively compare objects (susceptible to call stack limits).
  28970. return equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack);
  28971. case symbolTag$1:
  28972. if (symbolValueOf) {
  28973. return symbolValueOf.call(object) == symbolValueOf.call(other);
  28974. }
  28975. }
  28976. return false;
  28977. }
  28978. /** Used to compose bitmasks for comparison styles. */
  28979. var PARTIAL_COMPARE_FLAG$4 = 2;
  28980. /**
  28981. * A specialized version of `baseIsEqualDeep` for objects with support for
  28982. * partial deep comparisons.
  28983. *
  28984. * @private
  28985. * @param {Object} object The object to compare.
  28986. * @param {Object} other The other object to compare.
  28987. * @param {Function} equalFunc The function to determine equivalents of values.
  28988. * @param {Function} customizer The function to customize comparisons.
  28989. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
  28990. * for more details.
  28991. * @param {Object} stack Tracks traversed `object` and `other` objects.
  28992. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  28993. */
  28994. function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
  28995. var isPartial = bitmask & PARTIAL_COMPARE_FLAG$4,
  28996. objProps = keys(object),
  28997. objLength = objProps.length,
  28998. othProps = keys(other),
  28999. othLength = othProps.length;
  29000. if (objLength != othLength && !isPartial) {
  29001. return false;
  29002. }
  29003. var index = objLength;
  29004. while (index--) {
  29005. var key = objProps[index];
  29006. if (!(isPartial ? key in other : baseHas(other, key))) {
  29007. return false;
  29008. }
  29009. }
  29010. // Assume cyclic values are equal.
  29011. var stacked = stack.get(object);
  29012. if (stacked) {
  29013. return stacked == other;
  29014. }
  29015. var result = true;
  29016. stack.set(object, other);
  29017. var skipCtor = isPartial;
  29018. while (++index < objLength) {
  29019. key = objProps[index];
  29020. var objValue = object[key],
  29021. othValue = other[key];
  29022. if (customizer) {
  29023. var compared = isPartial
  29024. ? customizer(othValue, objValue, key, other, object, stack)
  29025. : customizer(objValue, othValue, key, object, other, stack);
  29026. }
  29027. // Recursively compare objects (susceptible to call stack limits).
  29028. if (!(compared === undefined
  29029. ? (objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack))
  29030. : compared
  29031. )) {
  29032. result = false;
  29033. break;
  29034. }
  29035. skipCtor || (skipCtor = key == 'constructor');
  29036. }
  29037. if (result && !skipCtor) {
  29038. var objCtor = object.constructor,
  29039. othCtor = other.constructor;
  29040. // Non `Object` object instances with different constructors are not equal.
  29041. if (objCtor != othCtor &&
  29042. ('constructor' in object && 'constructor' in other) &&
  29043. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  29044. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  29045. result = false;
  29046. }
  29047. }
  29048. stack['delete'](object);
  29049. return result;
  29050. }
  29051. /* Built-in method references that are verified to be native. */
  29052. var DataView = getNative(root, 'DataView');
  29053. /* Built-in method references that are verified to be native. */
  29054. var Promise = getNative(root, 'Promise');
  29055. /* Built-in method references that are verified to be native. */
  29056. var Set = getNative(root, 'Set');
  29057. /* Built-in method references that are verified to be native. */
  29058. var WeakMap = getNative(root, 'WeakMap');
  29059. var mapTag$1 = '[object Map]';
  29060. var objectTag$1 = '[object Object]';
  29061. var promiseTag = '[object Promise]';
  29062. var setTag$1 = '[object Set]';
  29063. var weakMapTag = '[object WeakMap]';
  29064. var dataViewTag$1 = '[object DataView]';
  29065. /** Used for built-in method references. */
  29066. var objectProto$10 = Object.prototype;
  29067. /**
  29068. * Used to resolve the
  29069. * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  29070. * of values.
  29071. */
  29072. var objectToString$4 = objectProto$10.toString;
  29073. /** Used to detect maps, sets, and weakmaps. */
  29074. var dataViewCtorString = toSource(DataView);
  29075. var mapCtorString = toSource(Map);
  29076. var promiseCtorString = toSource(Promise);
  29077. var setCtorString = toSource(Set);
  29078. var weakMapCtorString = toSource(WeakMap);
  29079. /**
  29080. * Gets the `toStringTag` of `value`.
  29081. *
  29082. * @private
  29083. * @param {*} value The value to query.
  29084. * @returns {string} Returns the `toStringTag`.
  29085. */
  29086. function getTag(value) {
  29087. return objectToString$4.call(value);
  29088. }
  29089. // Fallback for data views, maps, sets, and weak maps in IE 11,
  29090. // for data views in Edge, and promises in Node.js.
  29091. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag$1) ||
  29092. (Map && getTag(new Map) != mapTag$1) ||
  29093. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  29094. (Set && getTag(new Set) != setTag$1) ||
  29095. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  29096. getTag = function(value) {
  29097. var result = objectToString$4.call(value),
  29098. Ctor = result == objectTag$1 ? value.constructor : undefined,
  29099. ctorString = Ctor ? toSource(Ctor) : undefined;
  29100. if (ctorString) {
  29101. switch (ctorString) {
  29102. case dataViewCtorString: return dataViewTag$1;
  29103. case mapCtorString: return mapTag$1;
  29104. case promiseCtorString: return promiseTag;
  29105. case setCtorString: return setTag$1;
  29106. case weakMapCtorString: return weakMapTag;
  29107. }
  29108. }
  29109. return result;
  29110. };
  29111. }
  29112. var getTag$1 = getTag;
  29113. var argsTag$2 = '[object Arguments]';
  29114. var arrayTag$1 = '[object Array]';
  29115. var boolTag$1 = '[object Boolean]';
  29116. var dateTag$1 = '[object Date]';
  29117. var errorTag$1 = '[object Error]';
  29118. var funcTag$1 = '[object Function]';
  29119. var mapTag$2 = '[object Map]';
  29120. var numberTag$1 = '[object Number]';
  29121. var objectTag$2 = '[object Object]';
  29122. var regexpTag$1 = '[object RegExp]';
  29123. var setTag$2 = '[object Set]';
  29124. var stringTag$2 = '[object String]';
  29125. var weakMapTag$1 = '[object WeakMap]';
  29126. var arrayBufferTag$1 = '[object ArrayBuffer]';
  29127. var dataViewTag$2 = '[object DataView]';
  29128. var float32Tag = '[object Float32Array]';
  29129. var float64Tag = '[object Float64Array]';
  29130. var int8Tag = '[object Int8Array]';
  29131. var int16Tag = '[object Int16Array]';
  29132. var int32Tag = '[object Int32Array]';
  29133. var uint8Tag = '[object Uint8Array]';
  29134. var uint8ClampedTag = '[object Uint8ClampedArray]';
  29135. var uint16Tag = '[object Uint16Array]';
  29136. var uint32Tag = '[object Uint32Array]';
  29137. /** Used to identify `toStringTag` values of typed arrays. */
  29138. var typedArrayTags = {};
  29139. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  29140. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  29141. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  29142. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  29143. typedArrayTags[uint32Tag] = true;
  29144. typedArrayTags[argsTag$2] = typedArrayTags[arrayTag$1] =
  29145. typedArrayTags[arrayBufferTag$1] = typedArrayTags[boolTag$1] =
  29146. typedArrayTags[dataViewTag$2] = typedArrayTags[dateTag$1] =
  29147. typedArrayTags[errorTag$1] = typedArrayTags[funcTag$1] =
  29148. typedArrayTags[mapTag$2] = typedArrayTags[numberTag$1] =
  29149. typedArrayTags[objectTag$2] = typedArrayTags[regexpTag$1] =
  29150. typedArrayTags[setTag$2] = typedArrayTags[stringTag$2] =
  29151. typedArrayTags[weakMapTag$1] = false;
  29152. /** Used for built-in method references. */
  29153. var objectProto$11 = Object.prototype;
  29154. /**
  29155. * Used to resolve the
  29156. * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  29157. * of values.
  29158. */
  29159. var objectToString$5 = objectProto$11.toString;
  29160. /**
  29161. * Checks if `value` is classified as a typed array.
  29162. *
  29163. * @static
  29164. * @memberOf _
  29165. * @since 3.0.0
  29166. * @category Lang
  29167. * @param {*} value The value to check.
  29168. * @returns {boolean} Returns `true` if `value` is correctly classified,
  29169. * else `false`.
  29170. * @example
  29171. *
  29172. * _.isTypedArray(new Uint8Array);
  29173. * // => true
  29174. *
  29175. * _.isTypedArray([]);
  29176. * // => false
  29177. */
  29178. function isTypedArray(value) {
  29179. return isObjectLike(value) &&
  29180. isLength(value.length) && !!typedArrayTags[objectToString$5.call(value)];
  29181. }
  29182. /** Used to compose bitmasks for comparison styles. */
  29183. var PARTIAL_COMPARE_FLAG$1 = 2;
  29184. /** `Object#toString` result references. */
  29185. var argsTag$1 = '[object Arguments]';
  29186. var arrayTag = '[object Array]';
  29187. var objectTag = '[object Object]';
  29188. /** Used for built-in method references. */
  29189. var objectProto$9 = Object.prototype;
  29190. /** Used to check objects for own properties. */
  29191. var hasOwnProperty$5 = objectProto$9.hasOwnProperty;
  29192. /**
  29193. * A specialized version of `baseIsEqual` for arrays and objects which performs
  29194. * deep comparisons and tracks traversed objects enabling objects with circular
  29195. * references to be compared.
  29196. *
  29197. * @private
  29198. * @param {Object} object The object to compare.
  29199. * @param {Object} other The other object to compare.
  29200. * @param {Function} equalFunc The function to determine equivalents of values.
  29201. * @param {Function} [customizer] The function to customize comparisons.
  29202. * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual`
  29203. * for more details.
  29204. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  29205. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  29206. */
  29207. function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
  29208. var objIsArr = isArray(object),
  29209. othIsArr = isArray(other),
  29210. objTag = arrayTag,
  29211. othTag = arrayTag;
  29212. if (!objIsArr) {
  29213. objTag = getTag$1(object);
  29214. objTag = objTag == argsTag$1 ? objectTag : objTag;
  29215. }
  29216. if (!othIsArr) {
  29217. othTag = getTag$1(other);
  29218. othTag = othTag == argsTag$1 ? objectTag : othTag;
  29219. }
  29220. var objIsObj = objTag == objectTag && !isHostObject(object),
  29221. othIsObj = othTag == objectTag && !isHostObject(other),
  29222. isSameTag = objTag == othTag;
  29223. if (isSameTag && !objIsObj) {
  29224. stack || (stack = new Stack);
  29225. return (objIsArr || isTypedArray(object))
  29226. ? equalArrays(object, other, equalFunc, customizer, bitmask, stack)
  29227. : equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
  29228. }
  29229. if (!(bitmask & PARTIAL_COMPARE_FLAG$1)) {
  29230. var objIsWrapped = objIsObj && hasOwnProperty$5.call(object, '__wrapped__'),
  29231. othIsWrapped = othIsObj && hasOwnProperty$5.call(other, '__wrapped__');
  29232. if (objIsWrapped || othIsWrapped) {
  29233. var objUnwrapped = objIsWrapped ? object.value() : object,
  29234. othUnwrapped = othIsWrapped ? other.value() : other;
  29235. stack || (stack = new Stack);
  29236. return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);
  29237. }
  29238. }
  29239. if (!isSameTag) {
  29240. return false;
  29241. }
  29242. stack || (stack = new Stack);
  29243. return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
  29244. }
  29245. /**
  29246. * The base implementation of `_.isEqual` which supports partial comparisons
  29247. * and tracks traversed objects.
  29248. *
  29249. * @private
  29250. * @param {*} value The value to compare.
  29251. * @param {*} other The other value to compare.
  29252. * @param {Function} [customizer] The function to customize comparisons.
  29253. * @param {boolean} [bitmask] The bitmask of comparison flags.
  29254. * The bitmask may be composed of the following flags:
  29255. * 1 - Unordered comparison
  29256. * 2 - Partial comparison
  29257. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  29258. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  29259. */
  29260. function baseIsEqual(value, other, customizer, bitmask, stack) {
  29261. if (value === other) {
  29262. return true;
  29263. }
  29264. if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
  29265. return value !== value && other !== other;
  29266. }
  29267. return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack);
  29268. }
  29269. var UNORDERED_COMPARE_FLAG = 1;
  29270. var PARTIAL_COMPARE_FLAG = 2;
  29271. /**
  29272. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  29273. *
  29274. * @private
  29275. * @param {Object} object The object to inspect.
  29276. * @param {Object} source The object of property values to match.
  29277. * @param {Array} matchData The property names, values, and compare flags to match.
  29278. * @param {Function} [customizer] The function to customize comparisons.
  29279. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  29280. */
  29281. function baseIsMatch(object, source, matchData, customizer) {
  29282. var index = matchData.length,
  29283. length = index,
  29284. noCustomizer = !customizer;
  29285. if (object == null) {
  29286. return !length;
  29287. }
  29288. object = Object(object);
  29289. while (index--) {
  29290. var data = matchData[index];
  29291. if ((noCustomizer && data[2])
  29292. ? data[1] !== object[data[0]]
  29293. : !(data[0] in object)
  29294. ) {
  29295. return false;
  29296. }
  29297. }
  29298. while (++index < length) {
  29299. data = matchData[index];
  29300. var key = data[0],
  29301. objValue = object[key],
  29302. srcValue = data[1];
  29303. if (noCustomizer && data[2]) {
  29304. if (objValue === undefined && !(key in object)) {
  29305. return false;
  29306. }
  29307. } else {
  29308. var stack = new Stack;
  29309. if (customizer) {
  29310. var result = customizer(objValue, srcValue, key, object, source, stack);
  29311. }
  29312. if (!(result === undefined
  29313. ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack)
  29314. : result
  29315. )) {
  29316. return false;
  29317. }
  29318. }
  29319. }
  29320. return true;
  29321. }
  29322. /**
  29323. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  29324. *
  29325. * @private
  29326. * @param {*} value The value to check.
  29327. * @returns {boolean} Returns `true` if `value` if suitable for strict
  29328. * equality comparisons, else `false`.
  29329. */
  29330. function isStrictComparable(value) {
  29331. return value === value && !isObject(value);
  29332. }
  29333. /**
  29334. * Gets the property names, values, and compare flags of `object`.
  29335. *
  29336. * @private
  29337. * @param {Object} object The object to query.
  29338. * @returns {Array} Returns the match data of `object`.
  29339. */
  29340. function getMatchData(object) {
  29341. var result = keys(object),
  29342. length = result.length;
  29343. while (length--) {
  29344. var key = result[length],
  29345. value = object[key];
  29346. result[length] = [key, value, isStrictComparable(value)];
  29347. }
  29348. return result;
  29349. }
  29350. /**
  29351. * A specialized version of `matchesProperty` for source values suitable
  29352. * for strict equality comparisons, i.e. `===`.
  29353. *
  29354. * @private
  29355. * @param {string} key The key of the property to get.
  29356. * @param {*} srcValue The value to match.
  29357. * @returns {Function} Returns the new spec function.
  29358. */
  29359. function matchesStrictComparable(key, srcValue) {
  29360. return function(object) {
  29361. if (object == null) {
  29362. return false;
  29363. }
  29364. return object[key] === srcValue &&
  29365. (srcValue !== undefined || (key in Object(object)));
  29366. };
  29367. }
  29368. /**
  29369. * The base implementation of `_.matches` which doesn't clone `source`.
  29370. *
  29371. * @private
  29372. * @param {Object} source The object of property values to match.
  29373. * @returns {Function} Returns the new spec function.
  29374. */
  29375. function baseMatches(source) {
  29376. var matchData = getMatchData(source);
  29377. if (matchData.length == 1 && matchData[0][2]) {
  29378. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  29379. }
  29380. return function(object) {
  29381. return object === source || baseIsMatch(object, source, matchData);
  29382. };
  29383. }
  29384. /** Used as the `TypeError` message for "Functions" methods. */
  29385. var FUNC_ERROR_TEXT$1 = 'Expected a function';
  29386. /**
  29387. * Creates a function that memoizes the result of `func`. If `resolver` is
  29388. * provided, it determines the cache key for storing the result based on the
  29389. * arguments provided to the memoized function. By default, the first argument
  29390. * provided to the memoized function is used as the map cache key. The `func`
  29391. * is invoked with the `this` binding of the memoized function.
  29392. *
  29393. * **Note:** The cache is exposed as the `cache` property on the memoized
  29394. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  29395. * constructor with one whose instances implement the
  29396. * [`Map`](http://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-map-prototype-object)
  29397. * method interface of `delete`, `get`, `has`, and `set`.
  29398. *
  29399. * @static
  29400. * @memberOf _
  29401. * @since 0.1.0
  29402. * @category Function
  29403. * @param {Function} func The function to have its output memoized.
  29404. * @param {Function} [resolver] The function to resolve the cache key.
  29405. * @returns {Function} Returns the new memoized function.
  29406. * @example
  29407. *
  29408. * var object = { 'a': 1, 'b': 2 };
  29409. * var other = { 'c': 3, 'd': 4 };
  29410. *
  29411. * var values = _.memoize(_.values);
  29412. * values(object);
  29413. * // => [1, 2]
  29414. *
  29415. * values(other);
  29416. * // => [3, 4]
  29417. *
  29418. * object.a = 2;
  29419. * values(object);
  29420. * // => [1, 2]
  29421. *
  29422. * // Modify the result cache.
  29423. * values.cache.set(object, ['a', 'b']);
  29424. * values(object);
  29425. * // => ['a', 'b']
  29426. *
  29427. * // Replace `_.memoize.Cache`.
  29428. * _.memoize.Cache = WeakMap;
  29429. */
  29430. function memoize(func, resolver) {
  29431. if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
  29432. throw new TypeError(FUNC_ERROR_TEXT$1);
  29433. }
  29434. var memoized = function() {
  29435. var args = arguments,
  29436. key = resolver ? resolver.apply(this, args) : args[0],
  29437. cache = memoized.cache;
  29438. if (cache.has(key)) {
  29439. return cache.get(key);
  29440. }
  29441. var result = func.apply(this, args);
  29442. memoized.cache = cache.set(key, result);
  29443. return result;
  29444. };
  29445. memoized.cache = new (memoize.Cache || MapCache);
  29446. return memoized;
  29447. }
  29448. // Assign cache to `_.memoize`.
  29449. memoize.Cache = MapCache;
  29450. /** Used as references for various `Number` constants. */
  29451. var INFINITY$1 = 1 / 0;
  29452. /** Used to convert symbols to primitives and strings. */
  29453. var symbolProto$1 = Symbol$1 ? Symbol$1.prototype : undefined;
  29454. var symbolToString = symbolProto$1 ? symbolProto$1.toString : undefined;
  29455. /**
  29456. * The base implementation of `_.toString` which doesn't convert nullish
  29457. * values to empty strings.
  29458. *
  29459. * @private
  29460. * @param {*} value The value to process.
  29461. * @returns {string} Returns the string.
  29462. */
  29463. function baseToString(value) {
  29464. // Exit early for strings to avoid a performance hit in some environments.
  29465. if (typeof value == 'string') {
  29466. return value;
  29467. }
  29468. if (isSymbol(value)) {
  29469. return symbolToString ? symbolToString.call(value) : '';
  29470. }
  29471. var result = (value + '');
  29472. return (result == '0' && (1 / value) == -INFINITY$1) ? '-0' : result;
  29473. }
  29474. /**
  29475. * Converts `value` to a string. An empty string is returned for `null`
  29476. * and `undefined` values. The sign of `-0` is preserved.
  29477. *
  29478. * @static
  29479. * @memberOf _
  29480. * @since 4.0.0
  29481. * @category Lang
  29482. * @param {*} value The value to process.
  29483. * @returns {string} Returns the string.
  29484. * @example
  29485. *
  29486. * _.toString(null);
  29487. * // => ''
  29488. *
  29489. * _.toString(-0);
  29490. * // => '-0'
  29491. *
  29492. * _.toString([1, 2, 3]);
  29493. * // => '1,2,3'
  29494. */
  29495. function toString(value) {
  29496. return value == null ? '' : baseToString(value);
  29497. }
  29498. /** Used to match property names within property paths. */
  29499. var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(\.|\[\])(?:\4|$))/g;
  29500. /** Used to match backslashes in property paths. */
  29501. var reEscapeChar = /\\(\\)?/g;
  29502. /**
  29503. * Converts `string` to a property path array.
  29504. *
  29505. * @private
  29506. * @param {string} string The string to convert.
  29507. * @returns {Array} Returns the property path array.
  29508. */
  29509. var stringToPath = memoize(function(string) {
  29510. var result = [];
  29511. toString(string).replace(rePropName, function(match, number, quote, string) {
  29512. result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
  29513. });
  29514. return result;
  29515. });
  29516. /**
  29517. * Casts `value` to a path array if it's not one.
  29518. *
  29519. * @private
  29520. * @param {*} value The value to inspect.
  29521. * @returns {Array} Returns the cast property path array.
  29522. */
  29523. function castPath(value) {
  29524. return isArray(value) ? value : stringToPath(value);
  29525. }
  29526. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
  29527. var reIsPlainProp = /^\w*$/;
  29528. /**
  29529. * Checks if `value` is a property name and not a property path.
  29530. *
  29531. * @private
  29532. * @param {*} value The value to check.
  29533. * @param {Object} [object] The object to query keys on.
  29534. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  29535. */
  29536. function isKey(value, object) {
  29537. if (isArray(value)) {
  29538. return false;
  29539. }
  29540. var type = typeof value;
  29541. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  29542. value == null || isSymbol(value)) {
  29543. return true;
  29544. }
  29545. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  29546. (object != null && value in Object(object));
  29547. }
  29548. /** Used as references for various `Number` constants. */
  29549. var INFINITY$2 = 1 / 0;
  29550. /**
  29551. * Converts `value` to a string key if it's not a string or symbol.
  29552. *
  29553. * @private
  29554. * @param {*} value The value to inspect.
  29555. * @returns {string|symbol} Returns the key.
  29556. */
  29557. function toKey(value) {
  29558. if (typeof value == 'string' || isSymbol(value)) {
  29559. return value;
  29560. }
  29561. var result = (value + '');
  29562. return (result == '0' && (1 / value) == -INFINITY$2) ? '-0' : result;
  29563. }
  29564. /**
  29565. * The base implementation of `_.get` without support for default values.
  29566. *
  29567. * @private
  29568. * @param {Object} object The object to query.
  29569. * @param {Array|string} path The path of the property to get.
  29570. * @returns {*} Returns the resolved value.
  29571. */
  29572. function baseGet(object, path) {
  29573. path = isKey(path, object) ? [path] : castPath(path);
  29574. var index = 0,
  29575. length = path.length;
  29576. while (object != null && index < length) {
  29577. object = object[toKey(path[index++])];
  29578. }
  29579. return (index && index == length) ? object : undefined;
  29580. }
  29581. /**
  29582. * Gets the value at `path` of `object`. If the resolved value is
  29583. * `undefined`, the `defaultValue` is used in its place.
  29584. *
  29585. * @static
  29586. * @memberOf _
  29587. * @since 3.7.0
  29588. * @category Object
  29589. * @param {Object} object The object to query.
  29590. * @param {Array|string} path The path of the property to get.
  29591. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  29592. * @returns {*} Returns the resolved value.
  29593. * @example
  29594. *
  29595. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  29596. *
  29597. * _.get(object, 'a[0].b.c');
  29598. * // => 3
  29599. *
  29600. * _.get(object, ['a', '0', 'b', 'c']);
  29601. * // => 3
  29602. *
  29603. * _.get(object, 'a.b.c', 'default');
  29604. * // => 'default'
  29605. */
  29606. function get(object, path, defaultValue) {
  29607. var result = object == null ? undefined : baseGet(object, path);
  29608. return result === undefined ? defaultValue : result;
  29609. }
  29610. /**
  29611. * The base implementation of `_.hasIn` without support for deep paths.
  29612. *
  29613. * @private
  29614. * @param {Object} [object] The object to query.
  29615. * @param {Array|string} key The key to check.
  29616. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  29617. */
  29618. function baseHasIn(object, key) {
  29619. return object != null && key in Object(object);
  29620. }
  29621. /**
  29622. * Checks if `path` exists on `object`.
  29623. *
  29624. * @private
  29625. * @param {Object} object The object to query.
  29626. * @param {Array|string} path The path to check.
  29627. * @param {Function} hasFunc The function to check properties.
  29628. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  29629. */
  29630. function hasPath(object, path, hasFunc) {
  29631. path = isKey(path, object) ? [path] : castPath(path);
  29632. var result,
  29633. index = -1,
  29634. length = path.length;
  29635. while (++index < length) {
  29636. var key = toKey(path[index]);
  29637. if (!(result = object != null && hasFunc(object, key))) {
  29638. break;
  29639. }
  29640. object = object[key];
  29641. }
  29642. if (result) {
  29643. return result;
  29644. }
  29645. var length = object ? object.length : 0;
  29646. return !!length && isLength(length) && isIndex(key, length) &&
  29647. (isArray(object) || isString(object) || isArguments(object));
  29648. }
  29649. /**
  29650. * Checks if `path` is a direct or inherited property of `object`.
  29651. *
  29652. * @static
  29653. * @memberOf _
  29654. * @since 4.0.0
  29655. * @category Object
  29656. * @param {Object} object The object to query.
  29657. * @param {Array|string} path The path to check.
  29658. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  29659. * @example
  29660. *
  29661. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  29662. *
  29663. * _.hasIn(object, 'a');
  29664. * // => true
  29665. *
  29666. * _.hasIn(object, 'a.b');
  29667. * // => true
  29668. *
  29669. * _.hasIn(object, ['a', 'b']);
  29670. * // => true
  29671. *
  29672. * _.hasIn(object, 'b');
  29673. * // => false
  29674. */
  29675. function hasIn(object, path) {
  29676. return object != null && hasPath(object, path, baseHasIn);
  29677. }
  29678. var UNORDERED_COMPARE_FLAG$3 = 1;
  29679. var PARTIAL_COMPARE_FLAG$5 = 2;
  29680. /**
  29681. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  29682. *
  29683. * @private
  29684. * @param {string} path The path of the property to get.
  29685. * @param {*} srcValue The value to match.
  29686. * @returns {Function} Returns the new spec function.
  29687. */
  29688. function baseMatchesProperty(path, srcValue) {
  29689. if (isKey(path) && isStrictComparable(srcValue)) {
  29690. return matchesStrictComparable(toKey(path), srcValue);
  29691. }
  29692. return function(object) {
  29693. var objValue = get(object, path);
  29694. return (objValue === undefined && objValue === srcValue)
  29695. ? hasIn(object, path)
  29696. : baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG$3 | PARTIAL_COMPARE_FLAG$5);
  29697. };
  29698. }
  29699. /**
  29700. * This method returns the first argument given to it.
  29701. *
  29702. * @static
  29703. * @since 0.1.0
  29704. * @memberOf _
  29705. * @category Util
  29706. * @param {*} value Any value.
  29707. * @returns {*} Returns `value`.
  29708. * @example
  29709. *
  29710. * var object = { 'user': 'fred' };
  29711. *
  29712. * console.log(_.identity(object) === object);
  29713. * // => true
  29714. */
  29715. function identity(value) {
  29716. return value;
  29717. }
  29718. /**
  29719. * A specialized version of `baseProperty` which supports deep paths.
  29720. *
  29721. * @private
  29722. * @param {Array|string} path The path of the property to get.
  29723. * @returns {Function} Returns the new accessor function.
  29724. */
  29725. function basePropertyDeep(path) {
  29726. return function(object) {
  29727. return baseGet(object, path);
  29728. };
  29729. }
  29730. /**
  29731. * Creates a function that returns the value at `path` of a given object.
  29732. *
  29733. * @static
  29734. * @memberOf _
  29735. * @since 2.4.0
  29736. * @category Util
  29737. * @param {Array|string} path The path of the property to get.
  29738. * @returns {Function} Returns the new accessor function.
  29739. * @example
  29740. *
  29741. * var objects = [
  29742. * { 'a': { 'b': 2 } },
  29743. * { 'a': { 'b': 1 } }
  29744. * ];
  29745. *
  29746. * _.map(objects, _.property('a.b'));
  29747. * // => [2, 1]
  29748. *
  29749. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  29750. * // => [1, 2]
  29751. */
  29752. function property(path) {
  29753. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  29754. }
  29755. /**
  29756. * The base implementation of `_.iteratee`.
  29757. *
  29758. * @private
  29759. * @param {*} [value=_.identity] The value to convert to an iteratee.
  29760. * @returns {Function} Returns the iteratee.
  29761. */
  29762. function baseIteratee(value) {
  29763. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  29764. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  29765. if (typeof value == 'function') {
  29766. return value;
  29767. }
  29768. if (value == null) {
  29769. return identity;
  29770. }
  29771. if (typeof value == 'object') {
  29772. return isArray(value)
  29773. ? baseMatchesProperty(value[0], value[1])
  29774. : baseMatches(value);
  29775. }
  29776. return property(value);
  29777. }
  29778. /**
  29779. * Iterates over own enumerable string keyed properties of an object and
  29780. * invokes `iteratee` for each property. The iteratee is invoked with three
  29781. * arguments: (value, key, object). Iteratee functions may exit iteration
  29782. * early by explicitly returning `false`.
  29783. *
  29784. * @static
  29785. * @memberOf _
  29786. * @since 0.3.0
  29787. * @category Object
  29788. * @param {Object} object The object to iterate over.
  29789. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29790. * @returns {Object} Returns `object`.
  29791. * @see _.forOwnRight
  29792. * @example
  29793. *
  29794. * function Foo() {
  29795. * this.a = 1;
  29796. * this.b = 2;
  29797. * }
  29798. *
  29799. * Foo.prototype.c = 3;
  29800. *
  29801. * _.forOwn(new Foo, function(value, key) {
  29802. * console.log(key);
  29803. * });
  29804. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  29805. */
  29806. function forOwn(object, iteratee) {
  29807. return object && baseForOwn(object, baseIteratee(iteratee, 3));
  29808. }
  29809. /**
  29810. * Gets the index at which the first occurrence of `NaN` is found in `array`.
  29811. *
  29812. * @private
  29813. * @param {Array} array The array to search.
  29814. * @param {number} fromIndex The index to search from.
  29815. * @param {boolean} [fromRight] Specify iterating from right to left.
  29816. * @returns {number} Returns the index of the matched `NaN`, else `-1`.
  29817. */
  29818. function indexOfNaN(array, fromIndex, fromRight) {
  29819. var length = array.length,
  29820. index = fromIndex + (fromRight ? 1 : -1);
  29821. while ((fromRight ? index-- : ++index < length)) {
  29822. var other = array[index];
  29823. if (other !== other) {
  29824. return index;
  29825. }
  29826. }
  29827. return -1;
  29828. }
  29829. /**
  29830. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  29831. *
  29832. * @private
  29833. * @param {Array} array The array to search.
  29834. * @param {*} value The value to search for.
  29835. * @param {number} fromIndex The index to search from.
  29836. * @returns {number} Returns the index of the matched value, else `-1`.
  29837. */
  29838. function baseIndexOf(array, value, fromIndex) {
  29839. if (value !== value) {
  29840. return indexOfNaN(array, fromIndex);
  29841. }
  29842. var index = fromIndex - 1,
  29843. length = array.length;
  29844. while (++index < length) {
  29845. if (array[index] === value) {
  29846. return index;
  29847. }
  29848. }
  29849. return -1;
  29850. }
  29851. /**
  29852. * Determines the best order for running the functions in `tasks`, based on
  29853. * their requirements. Each function can optionally depend on other functions
  29854. * being completed first, and each function is run as soon as its requirements
  29855. * are satisfied.
  29856. *
  29857. * If any of the functions pass an error to their callback, the `auto` sequence
  29858. * will stop. Further tasks will not execute (so any other functions depending
  29859. * on it will not run), and the main `callback` is immediately called with the
  29860. * error.
  29861. *
  29862. * Functions also receive an object containing the results of functions which
  29863. * have completed so far as the first argument, if they have dependencies. If a
  29864. * task function has no dependencies, it will only be passed a callback.
  29865. *
  29866. * @name auto
  29867. * @static
  29868. * @memberOf async
  29869. * @category Control Flow
  29870. * @param {Object} tasks - An object. Each of its properties is either a
  29871. * function or an array of requirements, with the function itself the last item
  29872. * in the array. The object's key of a property serves as the name of the task
  29873. * defined by that property, i.e. can be used when specifying requirements for
  29874. * other tasks. The function receives one or two arguments:
  29875. * * a `results` object, containing the results of the previously executed
  29876. * functions, only passed if the task has any dependencies,
  29877. * * a `callback(err, result)` function, which must be called when finished,
  29878. * passing an `error` (which can be `null`) and the result of the function's
  29879. * execution.
  29880. * @param {number} [concurrency=Infinity] - An optional `integer` for
  29881. * determining the maximum number of tasks that can be run in parallel. By
  29882. * default, as many as possible.
  29883. * @param {Function} [callback] - An optional callback which is called when all
  29884. * the tasks have been completed. It receives the `err` argument if any `tasks`
  29885. * pass an error to their callback. Results are always returned; however, if an
  29886. * error occurs, no further `tasks` will be performed, and the results object
  29887. * will only contain partial results. Invoked with (err, results).
  29888. * @example
  29889. *
  29890. * async.auto({
  29891. * // this function will just be passed a callback
  29892. * readData: async.apply(fs.readFile, 'data.txt', 'utf-8'),
  29893. * showData: ['readData', function(results, cb) {
  29894. * // results.readData is the file's contents
  29895. * // ...
  29896. * }]
  29897. * }, callback);
  29898. *
  29899. * async.auto({
  29900. * get_data: function(callback) {
  29901. * console.log('in get_data');
  29902. * // async code to get some data
  29903. * callback(null, 'data', 'converted to array');
  29904. * },
  29905. * make_folder: function(callback) {
  29906. * console.log('in make_folder');
  29907. * // async code to create a directory to store a file in
  29908. * // this is run at the same time as getting the data
  29909. * callback(null, 'folder');
  29910. * },
  29911. * write_file: ['get_data', 'make_folder', function(results, callback) {
  29912. * console.log('in write_file', JSON.stringify(results));
  29913. * // once there is some data and the directory exists,
  29914. * // write the data to a file in the directory
  29915. * callback(null, 'filename');
  29916. * }],
  29917. * email_link: ['write_file', function(results, callback) {
  29918. * console.log('in email_link', JSON.stringify(results));
  29919. * // once the file is written let's email a link to it...
  29920. * // results.write_file contains the filename returned by write_file.
  29921. * callback(null, {'file':results.write_file, 'email':'[email protected]'});
  29922. * }]
  29923. * }, function(err, results) {
  29924. * console.log('err = ', err);
  29925. * console.log('results = ', results);
  29926. * });
  29927. */
  29928. function auto (tasks, concurrency, callback) {
  29929. if (typeof concurrency === 'function') {
  29930. // concurrency is optional, shift the args.
  29931. callback = concurrency;
  29932. concurrency = null;
  29933. }
  29934. callback = once(callback || noop);
  29935. var keys$$ = keys(tasks);
  29936. var numTasks = keys$$.length;
  29937. if (!numTasks) {
  29938. return callback(null);
  29939. }
  29940. if (!concurrency) {
  29941. concurrency = numTasks;
  29942. }
  29943. var results = {};
  29944. var runningTasks = 0;
  29945. var hasError = false;
  29946. var listeners = {};
  29947. var readyTasks = [];
  29948. // for cycle detection:
  29949. var readyToCheck = []; // tasks that have been identified as reachable
  29950. // without the possibility of returning to an ancestor task
  29951. var uncheckedDependencies = {};
  29952. forOwn(tasks, function (task, key) {
  29953. if (!isArray(task)) {
  29954. // no dependencies
  29955. enqueueTask(key, [task]);
  29956. readyToCheck.push(key);
  29957. return;
  29958. }
  29959. var dependencies = task.slice(0, task.length - 1);
  29960. var remainingDependencies = dependencies.length;
  29961. if (remainingDependencies === 0) {
  29962. enqueueTask(key, task);
  29963. readyToCheck.push(key);
  29964. return;
  29965. }
  29966. uncheckedDependencies[key] = remainingDependencies;
  29967. arrayEach(dependencies, function (dependencyName) {
  29968. if (!tasks[dependencyName]) {
  29969. throw new Error('async.auto task `' + key + '` has a non-existent dependency in ' + dependencies.join(', '));
  29970. }
  29971. addListener(dependencyName, function () {
  29972. remainingDependencies--;
  29973. if (remainingDependencies === 0) {
  29974. enqueueTask(key, task);
  29975. }
  29976. });
  29977. });
  29978. });
  29979. checkForDeadlocks();
  29980. processQueue();
  29981. function enqueueTask(key, task) {
  29982. readyTasks.push(function () {
  29983. runTask(key, task);
  29984. });
  29985. }
  29986. function processQueue() {
  29987. if (readyTasks.length === 0 && runningTasks === 0) {
  29988. return callback(null, results);
  29989. }
  29990. while (readyTasks.length && runningTasks < concurrency) {
  29991. var run = readyTasks.shift();
  29992. run();
  29993. }
  29994. }
  29995. function addListener(taskName, fn) {
  29996. var taskListeners = listeners[taskName];
  29997. if (!taskListeners) {
  29998. taskListeners = listeners[taskName] = [];
  29999. }
  30000. taskListeners.push(fn);
  30001. }
  30002. function taskComplete(taskName) {
  30003. var taskListeners = listeners[taskName] || [];
  30004. arrayEach(taskListeners, function (fn) {
  30005. fn();
  30006. });
  30007. processQueue();
  30008. }
  30009. function runTask(key, task) {
  30010. if (hasError) return;
  30011. var taskCallback = onlyOnce(rest(function (err, args) {
  30012. runningTasks--;
  30013. if (args.length <= 1) {
  30014. args = args[0];
  30015. }
  30016. if (err) {
  30017. var safeResults = {};
  30018. forOwn(results, function (val, rkey) {
  30019. safeResults[rkey] = val;
  30020. });
  30021. safeResults[key] = args;
  30022. hasError = true;
  30023. listeners = [];
  30024. callback(err, safeResults);
  30025. } else {
  30026. results[key] = args;
  30027. taskComplete(key);
  30028. }
  30029. }));
  30030. runningTasks++;
  30031. var taskFn = task[task.length - 1];
  30032. if (task.length > 1) {
  30033. taskFn(results, taskCallback);
  30034. } else {
  30035. taskFn(taskCallback);
  30036. }
  30037. }
  30038. function checkForDeadlocks() {
  30039. // Kahn's algorithm
  30040. // https://en.wikipedia.org/wiki/Topological_sorting#Kahn.27s_algorithm
  30041. // http://connalle.blogspot.com/2013/10/topological-sortingkahn-algorithm.html
  30042. var currentTask;
  30043. var counter = 0;
  30044. while (readyToCheck.length) {
  30045. currentTask = readyToCheck.pop();
  30046. counter++;
  30047. arrayEach(getDependents(currentTask), function (dependent) {
  30048. if (! --uncheckedDependencies[dependent]) {
  30049. readyToCheck.push(dependent);
  30050. }
  30051. });
  30052. }
  30053. if (counter !== numTasks) {
  30054. throw new Error('async.auto cannot execute tasks due to a recursive dependency');
  30055. }
  30056. }
  30057. function getDependents(taskName) {
  30058. var result = [];
  30059. forOwn(tasks, function (task, key) {
  30060. if (isArray(task) && baseIndexOf(task, taskName, 0) >= 0) {
  30061. result.push(key);
  30062. }
  30063. });
  30064. return result;
  30065. }
  30066. }
  30067. /**
  30068. * A specialized version of `_.map` for arrays without support for iteratee
  30069. * shorthands.
  30070. *
  30071. * @private
  30072. * @param {Array} [array] The array to iterate over.
  30073. * @param {Function} iteratee The function invoked per iteration.
  30074. * @returns {Array} Returns the new mapped array.
  30075. */
  30076. function arrayMap(array, iteratee) {
  30077. var index = -1,
  30078. length = array ? array.length : 0,
  30079. result = Array(length);
  30080. while (++index < length) {
  30081. result[index] = iteratee(array[index], index, array);
  30082. }
  30083. return result;
  30084. }
  30085. /**
  30086. * Copies the values of `source` to `array`.
  30087. *
  30088. * @private
  30089. * @param {Array} source The array to copy values from.
  30090. * @param {Array} [array=[]] The array to copy values to.
  30091. * @returns {Array} Returns `array`.
  30092. */
  30093. function copyArray(source, array) {
  30094. var index = -1,
  30095. length = source.length;
  30096. array || (array = Array(length));
  30097. while (++index < length) {
  30098. array[index] = source[index];
  30099. }
  30100. return array;
  30101. }
  30102. /**
  30103. * The base implementation of `_.slice` without an iteratee call guard.
  30104. *
  30105. * @private
  30106. * @param {Array} array The array to slice.
  30107. * @param {number} [start=0] The start position.
  30108. * @param {number} [end=array.length] The end position.
  30109. * @returns {Array} Returns the slice of `array`.
  30110. */
  30111. function baseSlice(array, start, end) {
  30112. var index = -1,
  30113. length = array.length;
  30114. if (start < 0) {
  30115. start = -start > length ? 0 : (length + start);
  30116. }
  30117. end = end > length ? length : end;
  30118. if (end < 0) {
  30119. end += length;
  30120. }
  30121. length = start > end ? 0 : ((end - start) >>> 0);
  30122. start >>>= 0;
  30123. var result = Array(length);
  30124. while (++index < length) {
  30125. result[index] = array[index + start];
  30126. }
  30127. return result;
  30128. }
  30129. /**
  30130. * Casts `array` to a slice if it's needed.
  30131. *
  30132. * @private
  30133. * @param {Array} array The array to inspect.
  30134. * @param {number} start The start position.
  30135. * @param {number} [end=array.length] The end position.
  30136. * @returns {Array} Returns the cast slice.
  30137. */
  30138. function castSlice(array, start, end) {
  30139. var length = array.length;
  30140. end = end === undefined ? length : end;
  30141. return (!start && end >= length) ? array : baseSlice(array, start, end);
  30142. }
  30143. /**
  30144. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  30145. * that is not found in the character symbols.
  30146. *
  30147. * @private
  30148. * @param {Array} strSymbols The string symbols to inspect.
  30149. * @param {Array} chrSymbols The character symbols to find.
  30150. * @returns {number} Returns the index of the last unmatched string symbol.
  30151. */
  30152. function charsEndIndex(strSymbols, chrSymbols) {
  30153. var index = strSymbols.length;
  30154. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  30155. return index;
  30156. }
  30157. /**
  30158. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  30159. * that is not found in the character symbols.
  30160. *
  30161. * @private
  30162. * @param {Array} strSymbols The string symbols to inspect.
  30163. * @param {Array} chrSymbols The character symbols to find.
  30164. * @returns {number} Returns the index of the first unmatched string symbol.
  30165. */
  30166. function charsStartIndex(strSymbols, chrSymbols) {
  30167. var index = -1,
  30168. length = strSymbols.length;
  30169. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  30170. return index;
  30171. }
  30172. /** Used to compose unicode character classes. */
  30173. var rsAstralRange = '\\ud800-\\udfff';
  30174. var rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23';
  30175. var rsComboSymbolsRange = '\\u20d0-\\u20f0';
  30176. var rsVarRange = '\\ufe0e\\ufe0f';
  30177. var rsAstral = '[' + rsAstralRange + ']';
  30178. var rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']';
  30179. var rsFitz = '\\ud83c[\\udffb-\\udfff]';
  30180. var rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')';
  30181. var rsNonAstral = '[^' + rsAstralRange + ']';
  30182. var rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}';
  30183. var rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]';
  30184. var rsZWJ = '\\u200d';
  30185. var reOptMod = rsModifier + '?';
  30186. var rsOptVar = '[' + rsVarRange + ']?';
  30187. var rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*';
  30188. var rsSeq = rsOptVar + reOptMod + rsOptJoin;
  30189. var rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  30190. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  30191. var reComplexSymbol = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  30192. /**
  30193. * Converts `string` to an array.
  30194. *
  30195. * @private
  30196. * @param {string} string The string to convert.
  30197. * @returns {Array} Returns the converted array.
  30198. */
  30199. function stringToArray(string) {
  30200. return string.match(reComplexSymbol);
  30201. }
  30202. /** Used to match leading and trailing whitespace. */
  30203. var reTrim$1 = /^\s+|\s+$/g;
  30204. /**
  30205. * Removes leading and trailing whitespace or specified characters from `string`.
  30206. *
  30207. * @static
  30208. * @memberOf _
  30209. * @since 3.0.0
  30210. * @category String
  30211. * @param {string} [string=''] The string to trim.
  30212. * @param {string} [chars=whitespace] The characters to trim.
  30213. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30214. * @returns {string} Returns the trimmed string.
  30215. * @example
  30216. *
  30217. * _.trim(' abc ');
  30218. * // => 'abc'
  30219. *
  30220. * _.trim('-_-abc-_-', '_-');
  30221. * // => 'abc'
  30222. *
  30223. * _.map([' foo ', ' bar '], _.trim);
  30224. * // => ['foo', 'bar']
  30225. */
  30226. function trim(string, chars, guard) {
  30227. string = toString(string);
  30228. if (string && (guard || chars === undefined)) {
  30229. return string.replace(reTrim$1, '');
  30230. }
  30231. if (!string || !(chars = baseToString(chars))) {
  30232. return string;
  30233. }
  30234. var strSymbols = stringToArray(string),
  30235. chrSymbols = stringToArray(chars),
  30236. start = charsStartIndex(strSymbols, chrSymbols),
  30237. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  30238. return castSlice(strSymbols, start, end).join('');
  30239. }
  30240. var argsRegex = /^(function[^\(]*)?\(?\s*([^\)=]*)/m;
  30241. function parseParams(func) {
  30242. return trim(func.toString().match(argsRegex)[2]).split(/\s*\,\s*/);
  30243. }
  30244. /**
  30245. * A dependency-injected version of the {@link async.auto} function. Dependent
  30246. * tasks are specified as parameters to the function, after the usual callback
  30247. * parameter, with the parameter names matching the names of the tasks it
  30248. * depends on. This can provide even more readable task graphs which can be
  30249. * easier to maintain.
  30250. *
  30251. * If a final callback is specified, the task results are similarly injected,
  30252. * specified as named parameters after the initial error parameter.
  30253. *
  30254. * The autoInject function is purely syntactic sugar and its semantics are
  30255. * otherwise equivalent to {@link async.auto}.
  30256. *
  30257. * @name autoInject
  30258. * @static
  30259. * @memberOf async
  30260. * @see async.auto
  30261. * @category Control Flow
  30262. * @param {Object} tasks - An object, each of whose properties is a function of
  30263. * the form 'func([dependencies...], callback). The object's key of a property
  30264. * serves as the name of the task defined by that property, i.e. can be used
  30265. * when specifying requirements for other tasks.
  30266. * * The `callback` parameter is a `callback(err, result)` which must be called
  30267. * when finished, passing an `error` (which can be `null`) and the result of
  30268. * the function's execution. The remaining parameters name other tasks on
  30269. * which the task is dependent, and the results from those tasks are the
  30270. * arguments of those parameters.
  30271. * @param {Function} [callback] - An optional callback which is called when all
  30272. * the tasks have been completed. It receives the `err` argument if any `tasks`
  30273. * pass an error to their callback. The remaining parameters are task names
  30274. * whose results you are interested in. This callback will only be called when
  30275. * all tasks have finished or an error has occurred, and so do not specify
  30276. * dependencies in the same way as `tasks` do. If an error occurs, no further
  30277. * `tasks` will be performed, and `results` will only be valid for those tasks
  30278. * which managed to complete. Invoked with (err, [results...]).
  30279. * @example
  30280. *
  30281. * // The example from `auto` can be rewritten as follows:
  30282. * async.autoInject({
  30283. * get_data: function(callback) {
  30284. * // async code to get some data
  30285. * callback(null, 'data', 'converted to array');
  30286. * },
  30287. * make_folder: function(callback) {
  30288. * // async code to create a directory to store a file in
  30289. * // this is run at the same time as getting the data
  30290. * callback(null, 'folder');
  30291. * },
  30292. * write_file: function(get_data, make_folder, callback) {
  30293. * // once there is some data and the directory exists,
  30294. * // write the data to a file in the directory
  30295. * callback(null, 'filename');
  30296. * },
  30297. * email_link: function(write_file, callback) {
  30298. * // once the file is written let's email a link to it...
  30299. * // write_file contains the filename returned by write_file.
  30300. * callback(null, {'file':write_file, 'email':'[email protected]'});
  30301. * }
  30302. * }, function(err, email_link) {
  30303. * console.log('err = ', err);
  30304. * console.log('email_link = ', email_link);
  30305. * });
  30306. *
  30307. * // If you are using a JS minifier that mangles parameter names, `autoInject`
  30308. * // will not work with plain functions, since the parameter names will be
  30309. * // collapsed to a single letter identifier. To work around this, you can
  30310. * // explicitly specify the names of the parameters your task function needs
  30311. * // in an array, similar to Angular.js dependency injection. The final
  30312. * // results callback can be provided as an array in the same way.
  30313. *
  30314. * // This still has an advantage over plain `auto`, since the results a task
  30315. * // depends on are still spread into arguments.
  30316. * async.autoInject({
  30317. * //...
  30318. * write_file: ['get_data', 'make_folder', function(get_data, make_folder, callback) {
  30319. * callback(null, 'filename');
  30320. * }],
  30321. * email_link: ['write_file', function(write_file, callback) {
  30322. * callback(null, {'file':write_file, 'email':'[email protected]'});
  30323. * }]
  30324. * //...
  30325. * }, ['email_link', function(err, email_link) {
  30326. * console.log('err = ', err);
  30327. * console.log('email_link = ', email_link);
  30328. * }]);
  30329. */
  30330. function autoInject(tasks, callback) {
  30331. var newTasks = {};
  30332. forOwn(tasks, function (taskFn, key) {
  30333. var params;
  30334. if (isArray(taskFn)) {
  30335. params = copyArray(taskFn);
  30336. taskFn = params.pop();
  30337. newTasks[key] = params.concat(params.length > 0 ? newTask : taskFn);
  30338. } else if (taskFn.length === 0) {
  30339. throw new Error("autoInject task functions require explicit parameters.");
  30340. } else if (taskFn.length === 1) {
  30341. // no dependencies, use the function as-is
  30342. newTasks[key] = taskFn;
  30343. } else {
  30344. params = parseParams(taskFn);
  30345. params.pop();
  30346. newTasks[key] = params.concat(newTask);
  30347. }
  30348. function newTask(results, taskCb) {
  30349. var newArgs = arrayMap(params, function (name) {
  30350. return results[name];
  30351. });
  30352. newArgs.push(taskCb);
  30353. taskFn.apply(null, newArgs);
  30354. }
  30355. });
  30356. auto(newTasks, callback);
  30357. }
  30358. var hasSetImmediate = typeof setImmediate === 'function' && setImmediate;
  30359. var hasNextTick = typeof process === 'object' && typeof process.nextTick === 'function';
  30360. function fallback(fn) {
  30361. setTimeout(fn, 0);
  30362. }
  30363. function wrap(defer) {
  30364. return rest(function (fn, args) {
  30365. defer(function () {
  30366. fn.apply(null, args);
  30367. });
  30368. });
  30369. }
  30370. var _defer;
  30371. if (hasSetImmediate) {
  30372. _defer = setImmediate;
  30373. } else if (hasNextTick) {
  30374. _defer = process.nextTick;
  30375. } else {
  30376. _defer = fallback;
  30377. }
  30378. var setImmediate$1 = wrap(_defer);
  30379. function queue(worker, concurrency, payload) {
  30380. if (concurrency == null) {
  30381. concurrency = 1;
  30382. } else if (concurrency === 0) {
  30383. throw new Error('Concurrency must not be zero');
  30384. }
  30385. function _insert(q, data, pos, callback) {
  30386. if (callback != null && typeof callback !== 'function') {
  30387. throw new Error('task callback must be a function');
  30388. }
  30389. q.started = true;
  30390. if (!isArray(data)) {
  30391. data = [data];
  30392. }
  30393. if (data.length === 0 && q.idle()) {
  30394. // call drain immediately if there are no tasks
  30395. return setImmediate$1(function () {
  30396. q.drain();
  30397. });
  30398. }
  30399. arrayEach(data, function (task) {
  30400. var item = {
  30401. data: task,
  30402. callback: callback || noop
  30403. };
  30404. if (pos) {
  30405. q.tasks.unshift(item);
  30406. } else {
  30407. q.tasks.push(item);
  30408. }
  30409. });
  30410. setImmediate$1(q.process);
  30411. }
  30412. function _next(q, tasks) {
  30413. return function () {
  30414. workers -= 1;
  30415. var removed = false;
  30416. var args = arguments;
  30417. arrayEach(tasks, function (task) {
  30418. arrayEach(workersList, function (worker, index) {
  30419. if (worker === task && !removed) {
  30420. workersList.splice(index, 1);
  30421. removed = true;
  30422. }
  30423. });
  30424. task.callback.apply(task, args);
  30425. if (args[0] != null) {
  30426. q.error(args[0], task.data);
  30427. }
  30428. });
  30429. if (workers <= q.concurrency - q.buffer) {
  30430. q.unsaturated();
  30431. }
  30432. if (q.tasks.length + workers === 0) {
  30433. q.drain();
  30434. }
  30435. q.process();
  30436. };
  30437. }
  30438. var workers = 0;
  30439. var workersList = [];
  30440. var q = {
  30441. tasks: [],
  30442. concurrency: concurrency,
  30443. payload: payload,
  30444. saturated: noop,
  30445. unsaturated: noop,
  30446. buffer: concurrency / 4,
  30447. empty: noop,
  30448. drain: noop,
  30449. error: noop,
  30450. started: false,
  30451. paused: false,
  30452. push: function (data, callback) {
  30453. _insert(q, data, false, callback);
  30454. },
  30455. kill: function () {
  30456. q.drain = noop;
  30457. q.tasks = [];
  30458. },
  30459. unshift: function (data, callback) {
  30460. _insert(q, data, true, callback);
  30461. },
  30462. process: function () {
  30463. while (!q.paused && workers < q.concurrency && q.tasks.length) {
  30464. var tasks = q.payload ? q.tasks.splice(0, q.payload) : q.tasks.splice(0, q.tasks.length);
  30465. var data = arrayMap(tasks, baseProperty('data'));
  30466. if (q.tasks.length === 0) {
  30467. q.empty();
  30468. }
  30469. workers += 1;
  30470. workersList.push(tasks[0]);
  30471. if (workers === q.concurrency) {
  30472. q.saturated();
  30473. }
  30474. var cb = onlyOnce(_next(q, tasks));
  30475. worker(data, cb);
  30476. }
  30477. },
  30478. length: function () {
  30479. return q.tasks.length;
  30480. },
  30481. running: function () {
  30482. return workers;
  30483. },
  30484. workersList: function () {
  30485. return workersList;
  30486. },
  30487. idle: function () {
  30488. return q.tasks.length + workers === 0;
  30489. },
  30490. pause: function () {
  30491. q.paused = true;
  30492. },
  30493. resume: function () {
  30494. if (q.paused === false) {
  30495. return;
  30496. }
  30497. q.paused = false;
  30498. var resumeCount = Math.min(q.concurrency, q.tasks.length);
  30499. // Need to call q.process once per concurrent
  30500. // worker to preserve full concurrency after pause
  30501. for (var w = 1; w <= resumeCount; w++) {
  30502. setImmediate$1(q.process);
  30503. }
  30504. }
  30505. };
  30506. return q;
  30507. }
  30508. /**
  30509. * A cargo of tasks for the worker function to complete. Cargo inherits all of
  30510. * the same methods and event callbacks as {@link async.queue}.
  30511. * @typedef {Object} cargo
  30512. * @property {Function} length - A function returning the number of items
  30513. * waiting to be processed. Invoke with ().
  30514. * @property {number} payload - An `integer` for determining how many tasks
  30515. * should be process per round. This property can be changed after a `cargo` is
  30516. * created to alter the payload on-the-fly.
  30517. * @property {Function} push - Adds `task` to the `queue`. The callback is
  30518. * called once the `worker` has finished processing the task. Instead of a
  30519. * single task, an array of `tasks` can be submitted. The respective callback is
  30520. * used for every task in the list. Invoke with (task, [callback]).
  30521. * @property {Function} saturated - A callback that is called when the
  30522. * `queue.length()` hits the concurrency and further tasks will be queued.
  30523. * @property {Function} empty - A callback that is called when the last item
  30524. * from the `queue` is given to a `worker`.
  30525. * @property {Function} drain - A callback that is called when the last item
  30526. * from the `queue` has returned from the `worker`.
  30527. * @property {Function} idle - a function returning false if there are items
  30528. * waiting or being processed, or true if not. Invoke with ().
  30529. * @property {Function} pause - a function that pauses the processing of tasks
  30530. * until `resume()` is called. Invoke with ().
  30531. * @property {Function} resume - a function that resumes the processing of
  30532. * queued tasks when the queue is paused. Invoke with ().
  30533. * @property {Function} kill - a function that removes the `drain` callback and
  30534. * empties remaining tasks from the queue forcing it to go idle. Invoke with ().
  30535. */
  30536. /**
  30537. * Creates a `cargo` object with the specified payload. Tasks added to the
  30538. * cargo will be processed altogether (up to the `payload` limit). If the
  30539. * `worker` is in progress, the task is queued until it becomes available. Once
  30540. * the `worker` has completed some tasks, each callback of those tasks is
  30541. * called. Check out [these](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) [animations](https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966)
  30542. * for how `cargo` and `queue` work.
  30543. *
  30544. * While [queue](#queue) passes only one task to one of a group of workers
  30545. * at a time, cargo passes an array of tasks to a single worker, repeating
  30546. * when the worker is finished.
  30547. *
  30548. * @name cargo
  30549. * @static
  30550. * @memberOf async
  30551. * @see async.queue
  30552. * @category Control Flow
  30553. * @param {Function} worker - An asynchronous function for processing an array
  30554. * of queued tasks, which must call its `callback(err)` argument when finished,
  30555. * with an optional `err` argument. Invoked with (tasks, callback).
  30556. * @param {number} [payload=Infinity] - An optional `integer` for determining
  30557. * how many tasks should be processed per round; if omitted, the default is
  30558. * unlimited.
  30559. * @returns {cargo} A cargo object to manage the tasks. Callbacks can
  30560. * attached as certain properties to listen for specific events during the
  30561. * lifecycle of the cargo and inner queue.
  30562. * @example
  30563. *
  30564. * // create a cargo object with payload 2
  30565. * var cargo = async.cargo(function(tasks, callback) {
  30566. * for (var i=0; i<tasks.length; i++) {
  30567. * console.log('hello ' + tasks[i].name);
  30568. * }
  30569. * callback();
  30570. * }, 2);
  30571. *
  30572. * // add some items
  30573. * cargo.push({name: 'foo'}, function(err) {
  30574. * console.log('finished processing foo');
  30575. * });
  30576. * cargo.push({name: 'bar'}, function(err) {
  30577. * console.log('finished processing bar');
  30578. * });
  30579. * cargo.push({name: 'baz'}, function(err) {
  30580. * console.log('finished processing baz');
  30581. * });
  30582. */
  30583. function cargo(worker, payload) {
  30584. return queue(worker, 1, payload);
  30585. }
  30586. /**
  30587. * The same as `eachOf` but runs a maximum of `limit` async operations at a
  30588. * time.
  30589. *
  30590. * @name eachOfLimit
  30591. * @static
  30592. * @memberOf async
  30593. * @see async.eachOf
  30594. * @alias forEachOfLimit
  30595. * @category Collection
  30596. * @param {Array|Object} coll - A collection to iterate over.
  30597. * @param {number} limit - The maximum number of async operations at a time.
  30598. * @param {Function} iteratee - A function to apply to each
  30599. * item in `coll`. The `key` is the item's key, or index in the case of an
  30600. * array. The iteratee is passed a `callback(err)` which must be called once it
  30601. * has completed. If no error has occurred, the callback should be run without
  30602. * arguments or with an explicit `null` argument. Invoked with
  30603. * (item, key, callback).
  30604. * @param {Function} [callback] - A callback which is called when all
  30605. * `iteratee` functions have finished, or an error occurs. Invoked with (err).
  30606. */
  30607. function eachOfLimit(obj, limit, iteratee, cb) {
  30608. _eachOfLimit(limit)(obj, iteratee, cb);
  30609. }
  30610. /**
  30611. * The same as `eachOf` but runs only a single async operation at a time.
  30612. *
  30613. * @name eachOfSeries
  30614. * @static
  30615. * @memberOf async
  30616. * @see async.eachOf
  30617. * @alias forEachOfSeries
  30618. * @category Collection
  30619. * @param {Array|Object} coll - A collection to iterate over.
  30620. * @param {Function} iteratee - A function to apply to each item in `coll`. The
  30621. * `key` is the item's key, or index in the case of an array. The iteratee is
  30622. * passed a `callback(err)` which must be called once it has completed. If no
  30623. * error has occurred, the callback should be run without arguments or with an
  30624. * explicit `null` argument. Invoked with (item, key, callback).
  30625. * @param {Function} [callback] - A callback which is called when all `iteratee`
  30626. * functions have finished, or an error occurs. Invoked with (err).
  30627. */
  30628. var eachOfSeries = doLimit(eachOfLimit, 1);
  30629. /**
  30630. * Reduces `coll` into a single value using an async `iteratee` to return each
  30631. * successive step. `memo` is the initial state of the reduction. This function
  30632. * only operates in series.
  30633. *
  30634. * For performance reasons, it may make sense to split a call to this function
  30635. * into a parallel map, and then use the normal `Array.prototype.reduce` on the
  30636. * results. This function is for situations where each step in the reduction
  30637. * needs to be async; if you can get the data before reducing it, then it's
  30638. * probably a good idea to do so.
  30639. *
  30640. * @name reduce
  30641. * @static
  30642. * @memberOf async
  30643. * @alias inject, foldl
  30644. * @category Collection
  30645. * @param {Array|Object} coll - A collection to iterate over.
  30646. * @param {*} memo - The initial state of the reduction.
  30647. * @param {Function} iteratee - A function applied to each item in the
  30648. * array to produce the next step in the reduction. The `iteratee` is passed a
  30649. * `callback(err, reduction)` which accepts an optional error as its first
  30650. * argument, and the state of the reduction as the second. If an error is
  30651. * passed to the callback, the reduction is stopped and the main `callback` is
  30652. * immediately called with the error. Invoked with (memo, item, callback).
  30653. * @param {Function} [callback] - A callback which is called after all the
  30654. * `iteratee` functions have finished. Result is the reduced value. Invoked with
  30655. * (err, result).
  30656. * @example
  30657. *
  30658. * async.reduce([1,2,3], 0, function(memo, item, callback) {
  30659. * // pointless async:
  30660. * process.nextTick(function() {
  30661. * callback(null, memo + item)
  30662. * });
  30663. * }, function(err, result) {
  30664. * // result is now equal to the last value of memo, which is 6
  30665. * });
  30666. */
  30667. function reduce(arr, memo, iteratee, cb) {
  30668. eachOfSeries(arr, function (x, i, cb) {
  30669. iteratee(memo, x, function (err, v) {
  30670. memo = v;
  30671. cb(err);
  30672. });
  30673. }, function (err) {
  30674. cb(err, memo);
  30675. });
  30676. }
  30677. /**
  30678. * Version of the compose function that is more natural to read. Each function
  30679. * consumes the return value of the previous function. It is the equivalent of
  30680. * {@link async.compose} with the arguments reversed.
  30681. *
  30682. * Each function is executed with the `this` binding of the composed function.
  30683. *
  30684. * @name seq
  30685. * @static
  30686. * @memberOf async
  30687. * @see async.compose
  30688. * @category Control Flow
  30689. * @param {...Function} functions - the asynchronous functions to compose
  30690. * @example
  30691. *
  30692. * // Requires lodash (or underscore), express3 and dresende's orm2.
  30693. * // Part of an app, that fetches cats of the logged user.
  30694. * // This example uses `seq` function to avoid overnesting and error
  30695. * // handling clutter.
  30696. * app.get('/cats', function(request, response) {
  30697. * var User = request.models.User;
  30698. * async.seq(
  30699. * _.bind(User.get, User), // 'User.get' has signature (id, callback(err, data))
  30700. * function(user, fn) {
  30701. * user.getCats(fn); // 'getCats' has signature (callback(err, data))
  30702. * }
  30703. * )(req.session.user_id, function (err, cats) {
  30704. * if (err) {
  30705. * console.error(err);
  30706. * response.json({ status: 'error', message: err.message });
  30707. * } else {
  30708. * response.json({ status: 'ok', message: 'Cats found', data: cats });
  30709. * }
  30710. * });
  30711. * });
  30712. */
  30713. function seq() /* functions... */{
  30714. var fns = arguments;
  30715. return rest(function (args) {
  30716. var that = this;
  30717. var cb = args[args.length - 1];
  30718. if (typeof cb == 'function') {
  30719. args.pop();
  30720. } else {
  30721. cb = noop;
  30722. }
  30723. reduce(fns, args, function (newargs, fn, cb) {
  30724. fn.apply(that, newargs.concat([rest(function (err, nextargs) {
  30725. cb(err, nextargs);
  30726. })]));
  30727. }, function (err, results) {
  30728. cb.apply(that, [err].concat(results));
  30729. });
  30730. });
  30731. }
  30732. var reverse = Array.prototype.reverse;
  30733. /**
  30734. * Creates a function which is a composition of the passed asynchronous
  30735. * functions. Each function consumes the return value of the function that
  30736. * follows. Composing functions `f()`, `g()`, and `h()` would produce the result
  30737. * of `f(g(h()))`, only this version uses callbacks to obtain the return values.
  30738. *
  30739. * Each function is executed with the `this` binding of the composed function.
  30740. *
  30741. * @name compose
  30742. * @static
  30743. * @memberOf async
  30744. * @category Control Flow
  30745. * @param {...Function} functions - the asynchronous functions to compose
  30746. * @example
  30747. *
  30748. * function add1(n, callback) {
  30749. * setTimeout(function () {
  30750. * callback(null, n + 1);
  30751. * }, 10);
  30752. * }
  30753. *
  30754. * function mul3(n, callback) {
  30755. * setTimeout(function () {
  30756. * callback(null, n * 3);
  30757. * }, 10);
  30758. * }
  30759. *
  30760. * var add1mul3 = async.compose(mul3, add1);
  30761. * add1mul3(4, function (err, result) {
  30762. * // result now equals 15
  30763. * });
  30764. */
  30765. function compose() /* functions... */{
  30766. return seq.apply(null, reverse.call(arguments));
  30767. }
  30768. function concat$1(eachfn, arr, fn, callback) {
  30769. var result = [];
  30770. eachfn(arr, function (x, index, cb) {
  30771. fn(x, function (err, y) {
  30772. result = result.concat(y || []);
  30773. cb(err);
  30774. });
  30775. }, function (err) {
  30776. callback(err, result);
  30777. });
  30778. }
  30779. /**
  30780. * Like `each`, except that it passes the key (or index) as the second argument
  30781. * to the iteratee.
  30782. *
  30783. * @name eachOf
  30784. * @static
  30785. * @memberOf async
  30786. * @alias forEachOf
  30787. * @category Collection
  30788. * @param {Array|Object} coll - A collection to iterate over.
  30789. * @param {Function} iteratee - A function to apply to each
  30790. * item in `coll`. The `key` is the item's key, or index in the case of an
  30791. * array. The iteratee is passed a `callback(err)` which must be called once it
  30792. * has completed. If no error has occurred, the callback should be run without
  30793. * arguments or with an explicit `null` argument. Invoked with
  30794. * (item, key, callback).
  30795. * @param {Function} [callback] - A callback which is called when all
  30796. * `iteratee` functions have finished, or an error occurs. Invoked with (err).
  30797. * @example
  30798. *
  30799. * var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"};
  30800. * var configs = {};
  30801. *
  30802. * async.forEachOf(obj, function (value, key, callback) {
  30803. * fs.readFile(__dirname + value, "utf8", function (err, data) {
  30804. * if (err) return callback(err);
  30805. * try {
  30806. * configs[key] = JSON.parse(data);
  30807. * } catch (e) {
  30808. * return callback(e);
  30809. * }
  30810. * callback();
  30811. * });
  30812. * }, function (err) {
  30813. * if (err) console.error(err.message);
  30814. * // configs is now a map of JSON data
  30815. * doSomethingWith(configs);
  30816. * });
  30817. */
  30818. var eachOf = doLimit(eachOfLimit, Infinity);
  30819. function doParallel(fn) {
  30820. return function (obj, iteratee, callback) {
  30821. return fn(eachOf, obj, iteratee, callback);
  30822. };
  30823. }
  30824. /**
  30825. * Applies `iteratee` to each item in `coll`, concatenating the results. Returns
  30826. * the concatenated list. The `iteratee`s are called in parallel, and the
  30827. * results are concatenated as they return. There is no guarantee that the
  30828. * results array will be returned in the original order of `coll` passed to the
  30829. * `iteratee` function.
  30830. *
  30831. * @name concat
  30832. * @static
  30833. * @memberOf async
  30834. * @category Collection
  30835. * @param {Array|Object} coll - A collection to iterate over.
  30836. * @param {Function} iteratee - A function to apply to each item in `coll`.
  30837. * The iteratee is passed a `callback(err, results)` which must be called once
  30838. * it has completed with an error (which can be `null`) and an array of results.
  30839. * Invoked with (item, callback).
  30840. * @param {Function} [callback(err)] - A callback which is called after all the
  30841. * `iteratee` functions have finished, or an error occurs. Results is an array
  30842. * containing the concatenated results of the `iteratee` function. Invoked with
  30843. * (err, results).
  30844. * @example
  30845. *
  30846. * async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files) {
  30847. * // files is now a list of filenames that exist in the 3 directories
  30848. * });
  30849. */
  30850. var concat = doParallel(concat$1);
  30851. function doSeries(fn) {
  30852. return function (obj, iteratee, callback) {
  30853. return fn(eachOfSeries, obj, iteratee, callback);
  30854. };
  30855. }
  30856. /**
  30857. * The same as `concat` but runs only a single async operation at a time.
  30858. *
  30859. * @name concatSeries
  30860. * @static
  30861. * @memberOf async
  30862. * @see async.concat
  30863. * @category Collection
  30864. * @param {Array|Object} coll - A collection to iterate over.
  30865. * @param {Function} iteratee - A function to apply to each item in `coll`.
  30866. * The iteratee is passed a `callback(err, results)` which must be called once
  30867. * it has completed with an error (which can be `null`) and an array of results.
  30868. * Invoked with (item, callback).
  30869. * @param {Function} [callback(err)] - A callback which is called after all the
  30870. * `iteratee` functions have finished, or an error occurs. Results is an array
  30871. * containing the concatenated results of the `iteratee` function. Invoked with
  30872. * (err, results).
  30873. */
  30874. var concatSeries = doSeries(concat$1);
  30875. /**
  30876. * Returns a function that when called, calls-back with the values provided.
  30877. * Useful as the first function in a `waterfall`, or for plugging values in to
  30878. * `auto`.
  30879. *
  30880. * @name constant
  30881. * @static
  30882. * @memberOf async
  30883. * @category Util
  30884. * @param {...*} arguments... - Any number of arguments to automatically invoke
  30885. * callback with.
  30886. * @returns {Function} Returns a function that when invoked, automatically
  30887. * invokes the callback with the previous given arguments.
  30888. * @example
  30889. *
  30890. * async.waterfall([
  30891. * async.constant(42),
  30892. * function (value, next) {
  30893. * // value === 42
  30894. * },
  30895. * //...
  30896. * ], callback);
  30897. *
  30898. * async.waterfall([
  30899. * async.constant(filename, "utf8"),
  30900. * fs.readFile,
  30901. * function (fileData, next) {
  30902. * //...
  30903. * }
  30904. * //...
  30905. * ], callback);
  30906. *
  30907. * async.auto({
  30908. * hostname: async.constant("https://server.net/"),
  30909. * port: findFreePort,
  30910. * launchServer: ["hostname", "port", function (options, cb) {
  30911. * startServer(options, cb);
  30912. * }],
  30913. * //...
  30914. * }, callback);
  30915. */
  30916. var constant = rest(function (values) {
  30917. var args = [null].concat(values);
  30918. return initialParams(function (ignoredArgs, callback) {
  30919. return callback.apply(this, args);
  30920. });
  30921. });
  30922. function _createTester(eachfn, check, getResult) {
  30923. return function (arr, limit, iteratee, cb) {
  30924. function done(err) {
  30925. if (cb) {
  30926. if (err) {
  30927. cb(err);
  30928. } else {
  30929. cb(null, getResult(false));
  30930. }
  30931. }
  30932. }
  30933. function wrappedIteratee(x, _, callback) {
  30934. if (!cb) return callback();
  30935. iteratee(x, function (err, v) {
  30936. if (cb) {
  30937. if (err) {
  30938. cb(err);
  30939. cb = iteratee = false;
  30940. } else if (check(v)) {
  30941. cb(null, getResult(true, x));
  30942. cb = iteratee = false;
  30943. }
  30944. }
  30945. callback();
  30946. });
  30947. }
  30948. if (arguments.length > 3) {
  30949. cb = cb || noop;
  30950. eachfn(arr, limit, wrappedIteratee, done);
  30951. } else {
  30952. cb = iteratee;
  30953. cb = cb || noop;
  30954. iteratee = limit;
  30955. eachfn(arr, wrappedIteratee, done);
  30956. }
  30957. };
  30958. }
  30959. function _findGetResult(v, x) {
  30960. return x;
  30961. }
  30962. /**
  30963. * Returns the first value in `coll` that passes an async truth test. The
  30964. * `iteratee` is applied in parallel, meaning the first iteratee to return
  30965. * `true` will fire the detect `callback` with that result. That means the
  30966. * result might not be the first item in the original `coll` (in terms of order)
  30967. * that passes the test.
  30968. * If order within the original `coll` is important, then look at
  30969. * `detectSeries`.
  30970. *
  30971. * @name detect
  30972. * @static
  30973. * @memberOf async
  30974. * @alias find
  30975. * @category Collection
  30976. * @param {Array|Object} coll - A collection to iterate over.
  30977. * @param {Function} iteratee - A truth test to apply to each item in `coll`.
  30978. * The iteratee is passed a `callback(err, truthValue)` which must be called
  30979. * with a boolean argument once it has completed. Invoked with (item, callback).
  30980. * @param {Function} [callback] - A callback which is called as soon as any
  30981. * iteratee returns `true`, or after all the `iteratee` functions have finished.
  30982. * Result will be the first item in the array that passes the truth test
  30983. * (iteratee) or the value `undefined` if none passed. Invoked with
  30984. * (err, result).
  30985. * @example
  30986. *
  30987. * async.detect(['file1','file2','file3'], function(filePath, callback) {
  30988. * fs.access(filePath, function(err) {
  30989. * callback(null, !err)
  30990. * });
  30991. * }, function(err, result) {
  30992. * // result now equals the first file in the list that exists
  30993. * });
  30994. */
  30995. var detect = _createTester(eachOf, identity, _findGetResult);
  30996. /**
  30997. * The same as `detect` but runs a maximum of `limit` async operations at a
  30998. * time.
  30999. *
  31000. * @name detectLimit
  31001. * @static
  31002. * @memberOf async
  31003. * @see async.detect
  31004. * @alias findLimit
  31005. * @category Collection
  31006. * @param {Array|Object} coll - A collection to iterate over.
  31007. * @param {number} limit - The maximum number of async operations at a time.
  31008. * @param {Function} iteratee - A truth test to apply to each item in `coll`.
  31009. * The iteratee is passed a `callback(err, truthValue)` which must be called
  31010. * with a boolean argument once it has completed. Invoked with (item, callback).
  31011. * @param {Function} [callback] - A callback which is called as soon as any
  31012. * iteratee returns `true`, or after all the `iteratee` functions have finished.
  31013. * Result will be the first item in the array that passes the truth test
  31014. * (iteratee) or the value `undefined` if none passed. Invoked with
  31015. * (err, result).
  31016. */
  31017. var detectLimit = _createTester(eachOfLimit, identity, _findGetResult);
  31018. /**
  31019. * The same as `detect` but runs only a single async operation at a time.
  31020. *
  31021. * @name detectSeries
  31022. * @static
  31023. * @memberOf async
  31024. * @see async.detect
  31025. * @alias findSeries
  31026. * @category Collection
  31027. * @param {Array|Object} coll - A collection to iterate over.
  31028. * @param {Function} iteratee - A truth test to apply to each item in `coll`.
  31029. * The iteratee is passed a `callback(err, truthValue)` which must be called
  31030. * with a boolean argument once it has completed. Invoked with (item, callback).
  31031. * @param {Function} [callback] - A callback which is called as soon as any
  31032. * iteratee returns `true`, or after all the `iteratee` functions have finished.
  31033. * Result will be the first item in the array that passes the truth test
  31034. * (iteratee) or the value `undefined` if none passed. Invoked with
  31035. * (err, result).
  31036. */
  31037. var detectSeries = _createTester(eachOfSeries, identity, _findGetResult);
  31038. function consoleFunc(name) {
  31039. return rest(function (fn, args) {
  31040. fn.apply(null, args.concat([rest(function (err, args) {
  31041. if (typeof console === 'object') {
  31042. if (err) {
  31043. if (console.error) {
  31044. console.error(err);
  31045. }
  31046. } else if (console[name]) {
  31047. arrayEach(args, function (x) {
  31048. console[name](x);
  31049. });
  31050. }
  31051. }
  31052. })]));
  31053. });
  31054. }
  31055. /**
  31056. * Logs the result of an `async` function to the `console` using `console.dir`
  31057. * to display the properties of the resulting object. Only works in Node.js or
  31058. * in browsers that support `console.dir` and `console.error` (such as FF and
  31059. * Chrome). If multiple arguments are returned from the async function,
  31060. * `console.dir` is called on each argument in order.
  31061. *
  31062. * @name log
  31063. * @static
  31064. * @memberOf async
  31065. * @category Util
  31066. * @param {Function} function - The function you want to eventually apply all
  31067. * arguments to.
  31068. * @param {...*} arguments... - Any number of arguments to apply to the function.
  31069. * @example
  31070. *
  31071. * // in a module
  31072. * var hello = function(name, callback) {
  31073. * setTimeout(function() {
  31074. * callback(null, {hello: name});
  31075. * }, 1000);
  31076. * };
  31077. *
  31078. * // in the node repl
  31079. * node> async.dir(hello, 'world');
  31080. * {hello: 'world'}
  31081. */
  31082. var dir = consoleFunc('dir');
  31083. /**
  31084. * Like {@link async.whilst}, except the `test` is an asynchronous function that
  31085. * is passed a callback in the form of `function (err, truth)`. If error is
  31086. * passed to `test` or `fn`, the main callback is immediately called with the
  31087. * value of the error.
  31088. *
  31089. * @name during
  31090. * @static
  31091. * @memberOf async
  31092. * @see async.whilst
  31093. * @category Control Flow
  31094. * @param {Function} test - asynchronous truth test to perform before each
  31095. * execution of `fn`. Invoked with (callback).
  31096. * @param {Function} fn - A function which is called each time `test` passes.
  31097. * The function is passed a `callback(err)`, which must be called once it has
  31098. * completed with an optional `err` argument. Invoked with (callback).
  31099. * @param {Function} [callback] - A callback which is called after the test
  31100. * function has failed and repeated execution of `fn` has stopped. `callback`
  31101. * will be passed an error and any arguments passed to the final `fn`'s
  31102. * callback. Invoked with (err, [results]);
  31103. * @example
  31104. *
  31105. * var count = 0;
  31106. *
  31107. * async.during(
  31108. * function (callback) {
  31109. * return callback(null, count < 5);
  31110. * },
  31111. * function (callback) {
  31112. * count++;
  31113. * setTimeout(callback, 1000);
  31114. * },
  31115. * function (err) {
  31116. * // 5 seconds have passed
  31117. * }
  31118. * );
  31119. */
  31120. function during(test, iteratee, cb) {
  31121. cb = cb || noop;
  31122. var next = rest(function (err, args) {
  31123. if (err) {
  31124. cb(err);
  31125. } else {
  31126. args.push(check);
  31127. test.apply(this, args);
  31128. }
  31129. });
  31130. var check = function (err, truth) {
  31131. if (err) return cb(err);
  31132. if (!truth) return cb(null);
  31133. iteratee(next);
  31134. };
  31135. test(check);
  31136. }
  31137. /**
  31138. * The post-check version of {@link async.during}. To reflect the difference in
  31139. * the order of operations, the arguments `test` and `fn` are switched.
  31140. *
  31141. * Also a version of {@link async.doWhilst} with asynchronous `test` function.
  31142. * @name doDuring
  31143. * @static
  31144. * @memberOf async
  31145. * @see async.during
  31146. * @category Control Flow
  31147. * @param {Function} fn - A function which is called each time `test` passes.
  31148. * The function is passed a `callback(err)`, which must be called once it has
  31149. * completed with an optional `err` argument. Invoked with (callback).
  31150. * @param {Function} test - asynchronous truth test to perform before each
  31151. * execution of `fn`. Invoked with (callback).
  31152. * @param {Function} [callback] - A callback which is called after the test
  31153. * function has failed and repeated execution of `fn` has stopped. `callback`
  31154. * will be passed an error and any arguments passed to the final `fn`'s
  31155. * callback. Invoked with (err, [results]);
  31156. */
  31157. function doDuring(iteratee, test, cb) {
  31158. var calls = 0;
  31159. during(function (next) {
  31160. if (calls++ < 1) return next(null, true);
  31161. test.apply(this, arguments);
  31162. }, iteratee, cb);
  31163. }
  31164. /**
  31165. * Repeatedly call `fn`, while `test` returns `true`. Calls `callback` when
  31166. * stopped, or an error occurs.
  31167. *
  31168. * @name whilst
  31169. * @static
  31170. * @memberOf async
  31171. * @category Control Flow
  31172. * @param {Function} test - synchronous truth test to perform before each
  31173. * execution of `fn`. Invoked with ().
  31174. * @param {Function} fn - A function which is called each time `test` passes.
  31175. * The function is passed a `callback(err)`, which must be called once it has
  31176. * completed with an optional `err` argument. Invoked with (callback).
  31177. * @param {Function} [callback] - A callback which is called after the test
  31178. * function has failed and repeated execution of `fn` has stopped. `callback`
  31179. * will be passed an error and any arguments passed to the final `fn`'s
  31180. * callback. Invoked with (err, [results]);
  31181. * @example
  31182. *
  31183. * var count = 0;
  31184. * async.whilst(
  31185. * function() { return count < 5; },
  31186. * function(callback) {
  31187. * count++;
  31188. * setTimeout(function() {
  31189. * callback(null, count);
  31190. * }, 1000);
  31191. * },
  31192. * function (err, n) {
  31193. * // 5 seconds have passed, n = 5
  31194. * }
  31195. * );
  31196. */
  31197. function whilst(test, iteratee, cb) {
  31198. cb = cb || noop;
  31199. if (!test()) return cb(null);
  31200. var next = rest(function (err, args) {
  31201. if (err) return cb(err);
  31202. if (test.apply(this, args)) return iteratee(next);
  31203. cb.apply(null, [null].concat(args));
  31204. });
  31205. iteratee(next);
  31206. }
  31207. /**
  31208. * The post-check version of {@link async.whilst}. To reflect the difference in
  31209. * the order of operations, the arguments `test` and `fn` are switched.
  31210. *
  31211. * `doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript.
  31212. *
  31213. * @name doWhilst
  31214. * @static
  31215. * @memberOf async
  31216. * @see async.whilst
  31217. * @category Control Flow
  31218. * @param {Function} fn - A function which is called each time `test` passes.
  31219. * The function is passed a `callback(err)`, which must be called once it has
  31220. * completed with an optional `err` argument. Invoked with (callback).
  31221. * @param {Function} test - synchronous truth test to perform after each
  31222. * execution of `fn`. Invoked with Invoked with the non-error callback results
  31223. * of `fn`.
  31224. * @param {Function} [callback] - A callback which is called after the test
  31225. * function has failed and repeated execution of `fn` has stopped. `callback`
  31226. * will be passed an error and any arguments passed to the final `fn`'s
  31227. * callback. Invoked with (err, [results]);
  31228. */
  31229. function doWhilst(iteratee, test, cb) {
  31230. var calls = 0;
  31231. return whilst(function () {
  31232. return ++calls <= 1 || test.apply(this, arguments);
  31233. }, iteratee, cb);
  31234. }
  31235. /**
  31236. * Like {@link async.doWhilst}, except the `test` is inverted. Note the
  31237. * argument ordering differs from `until`.
  31238. *
  31239. * @name doUntil
  31240. * @static
  31241. * @memberOf async
  31242. * @see async.doWhilst
  31243. * @category Control Flow
  31244. * @param {Function} fn - A function which is called each time `test` fails.
  31245. * The function is passed a `callback(err)`, which must be called once it has
  31246. * completed with an optional `err` argument. Invoked with (callback).
  31247. * @param {Function} test - synchronous truth test to perform after each
  31248. * execution of `fn`. Invoked with the non-error callback results of `fn`.
  31249. * @param {Function} [callback] - A callback which is called after the test
  31250. * function has passed and repeated execution of `fn` has stopped. `callback`
  31251. * will be passed an error and any arguments passed to the final `fn`'s
  31252. * callback. Invoked with (err, [results]);
  31253. */
  31254. function doUntil(iteratee, test, cb) {
  31255. return doWhilst(iteratee, function () {
  31256. return !test.apply(this, arguments);
  31257. }, cb);
  31258. }
  31259. function _withoutIndex(iteratee) {
  31260. return function (value, index, callback) {
  31261. return iteratee(value, callback);
  31262. };
  31263. }
  31264. /**
  31265. * The same as `each` but runs a maximum of `limit` async operations at a time.
  31266. *
  31267. * @name eachLimit
  31268. * @static
  31269. * @memberOf async
  31270. * @see async.each
  31271. * @alias forEachLimit
  31272. * @category Collection
  31273. * @param {Array|Object} coll - A colleciton to iterate over.
  31274. * @param {number} limit - The maximum number of async operations at a time.
  31275. * @param {Function} iteratee - A function to apply to each item in `coll`. The
  31276. * iteratee is passed a `callback(err)` which must be called once it has
  31277. * completed. If no error has occurred, the `callback` should be run without
  31278. * arguments or with an explicit `null` argument. The array index is not passed
  31279. * to the iteratee. Invoked with (item, callback). If you need the index, use
  31280. * `eachOfLimit`.
  31281. * @param {Function} [callback] - A callback which is called when all
  31282. * `iteratee` functions have finished, or an error occurs. Invoked with (err).
  31283. */
  31284. function eachLimit(arr, limit, iteratee, cb) {
  31285. return _eachOfLimit(limit)(arr, _withoutIndex(iteratee), cb);
  31286. }
  31287. /**
  31288. * Applies the function `iteratee` to each item in `coll`, in parallel.
  31289. * The `iteratee` is called with an item from the list, and a callback for when
  31290. * it has finished. If the `iteratee` passes an error to its `callback`, the
  31291. * main `callback` (for the `each` function) is immediately called with the
  31292. * error.
  31293. *
  31294. * Note, that since this function applies `iteratee` to each item in parallel,
  31295. * there is no guarantee that the iteratee functions will complete in order.
  31296. *
  31297. * @name each
  31298. * @static
  31299. * @memberOf async
  31300. * @alias forEach
  31301. * @category Collection
  31302. * @param {Array|Object} coll - A collection to iterate over.
  31303. * @param {Function} iteratee - A function to apply to each item
  31304. * in `coll`. The iteratee is passed a `callback(err)` which must be called once
  31305. * it has completed. If no error has occurred, the `callback` should be run
  31306. * without arguments or with an explicit `null` argument. The array index is not
  31307. * passed to the iteratee. Invoked with (item, callback). If you need the index,
  31308. * use `eachOf`.
  31309. * @param {Function} [callback] - A callback which is called when all
  31310. * `iteratee` functions have finished, or an error occurs. Invoked with (err).
  31311. * @example
  31312. *
  31313. * // assuming openFiles is an array of file names and saveFile is a function
  31314. * // to save the modified contents of that file:
  31315. *
  31316. * async.each(openFiles, saveFile, function(err){
  31317. * // if any of the saves produced an error, err would equal that error
  31318. * });
  31319. *
  31320. * // assuming openFiles is an array of file names
  31321. * async.each(openFiles, function(file, callback) {
  31322. *
  31323. * // Perform operation on file here.
  31324. * console.log('Processing file ' + file);
  31325. *
  31326. * if( file.length > 32 ) {
  31327. * console.log('This file name is too long');
  31328. * callback('File name too long');
  31329. * } else {
  31330. * // Do work to process file here
  31331. * console.log('File processed');
  31332. * callback();
  31333. * }
  31334. * }, function(err) {
  31335. * // if any of the file processing produced an error, err would equal that error
  31336. * if( err ) {
  31337. * // One of the iterations produced an error.
  31338. * // All processing will now stop.
  31339. * console.log('A file failed to process');
  31340. * } else {
  31341. * console.log('All files have been processed successfully');
  31342. * }
  31343. * });
  31344. */
  31345. var each = doLimit(eachLimit, Infinity);
  31346. /**
  31347. * The same as `each` but runs only a single async operation at a time.
  31348. *
  31349. * @name eachSeries
  31350. * @static
  31351. * @memberOf async
  31352. * @see async.each
  31353. * @alias forEachSeries
  31354. * @category Collection
  31355. * @param {Array|Object} coll - A collection to iterate over.
  31356. * @param {Function} iteratee - A function to apply to each
  31357. * item in `coll`. The iteratee is passed a `callback(err)` which must be called
  31358. * once it has completed. If no error has occurred, the `callback` should be run
  31359. * without arguments or with an explicit `null` argument. The array index is
  31360. * not passed to the iteratee. Invoked with (item, callback). If you need the
  31361. * index, use `eachOfSeries`.
  31362. * @param {Function} [callback] - A callback which is called when all
  31363. * `iteratee` functions have finished, or an error occurs. Invoked with (err).
  31364. */
  31365. var eachSeries = doLimit(eachLimit, 1);
  31366. /**
  31367. * Wrap an async function and ensure it calls its callback on a later tick of
  31368. * the event loop. If the function already calls its callback on a next tick,
  31369. * no extra deferral is added. This is useful for preventing stack overflows
  31370. * (`RangeError: Maximum call stack size exceeded`) and generally keeping
  31371. * [Zalgo](http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony)
  31372. * contained.
  31373. *
  31374. * @name ensureAsync
  31375. * @static
  31376. * @memberOf async
  31377. * @category Util
  31378. * @param {Function} fn - an async function, one that expects a node-style
  31379. * callback as its last argument.
  31380. * @returns {Function} Returns a wrapped function with the exact same call
  31381. * signature as the function passed in.
  31382. * @example
  31383. *
  31384. * function sometimesAsync(arg, callback) {
  31385. * if (cache[arg]) {
  31386. * return callback(null, cache[arg]); // this would be synchronous!!
  31387. * } else {
  31388. * doSomeIO(arg, callback); // this IO would be asynchronous
  31389. * }
  31390. * }
  31391. *
  31392. * // this has a risk of stack overflows if many results are cached in a row
  31393. * async.mapSeries(args, sometimesAsync, done);
  31394. *
  31395. * // this will defer sometimesAsync's callback if necessary,
  31396. * // preventing stack overflows
  31397. * async.mapSeries(args, async.ensureAsync(sometimesAsync), done);
  31398. */
  31399. function ensureAsync(fn) {
  31400. return initialParams(function (args, callback) {
  31401. var sync = true;
  31402. args.push(function () {
  31403. var innerArgs = arguments;
  31404. if (sync) {
  31405. setImmediate$1(function () {
  31406. callback.apply(null, innerArgs);
  31407. });
  31408. } else {
  31409. callback.apply(null, innerArgs);
  31410. }
  31411. });
  31412. fn.apply(this, args);
  31413. sync = false;
  31414. });
  31415. }
  31416. function notId(v) {
  31417. return !v;
  31418. }
  31419. /**
  31420. * The same as `every` but runs a maximum of `limit` async operations at a time.
  31421. *
  31422. * @name everyLimit
  31423. * @static
  31424. * @memberOf async
  31425. * @see async.every
  31426. * @alias allLimit
  31427. * @category Collection
  31428. * @param {Array|Object} coll - A collection to iterate over.
  31429. * @param {number} limit - The maximum number of async operations at a time.
  31430. * @param {Function} iteratee - A truth test to apply to each item in the
  31431. * collection in parallel. The iteratee is passed a `callback(err, truthValue)`
  31432. * which must be called with a boolean argument once it has completed. Invoked
  31433. * with (item, callback).
  31434. * @param {Function} [callback] - A callback which is called after all the
  31435. * `iteratee` functions have finished. Result will be either `true` or `false`
  31436. * depending on the values of the async tests. Invoked with (err, result).
  31437. */
  31438. var everyLimit = _createTester(eachOfLimit, notId, notId);
  31439. /**
  31440. * Returns `true` if every element in `coll` satisfies an async test. If any
  31441. * iteratee call returns `false`, the main `callback` is immediately called.
  31442. *
  31443. * @name every
  31444. * @static
  31445. * @memberOf async
  31446. * @alias all
  31447. * @category Collection
  31448. * @param {Array|Object} coll - A collection to iterate over.
  31449. * @param {Function} iteratee - A truth test to apply to each item in the
  31450. * collection in parallel. The iteratee is passed a `callback(err, truthValue)`
  31451. * which must be called with a boolean argument once it has completed. Invoked
  31452. * with (item, callback).
  31453. * @param {Function} [callback] - A callback which is called after all the
  31454. * `iteratee` functions have finished. Result will be either `true` or `false`
  31455. * depending on the values of the async tests. Invoked with (err, result).
  31456. * @example
  31457. *
  31458. * async.every(['file1','file2','file3'], function(filePath, callback) {
  31459. * fs.access(filePath, function(err) {
  31460. * callback(null, !err)
  31461. * });
  31462. * }, function(err, result) {
  31463. * // if result is true then every file exists
  31464. * });
  31465. */
  31466. var every = doLimit(everyLimit, Infinity);
  31467. /**
  31468. * The same as `every` but runs only a single async operation at a time.
  31469. *
  31470. * @name everySeries
  31471. * @static
  31472. * @memberOf async
  31473. * @see async.every
  31474. * @alias allSeries
  31475. * @category Collection
  31476. * @param {Array|Object} coll - A collection to iterate over.
  31477. * @param {Function} iteratee - A truth test to apply to each item in the
  31478. * collection in parallel. The iteratee is passed a `callback(err, truthValue)`
  31479. * which must be called with a boolean argument once it has completed. Invoked
  31480. * with (item, callback).
  31481. * @param {Function} [callback] - A callback which is called after all the
  31482. * `iteratee` functions have finished. Result will be either `true` or `false`
  31483. * depending on the values of the async tests. Invoked with (err, result).
  31484. */
  31485. var everySeries = doLimit(everyLimit, 1);
  31486. function _filter(eachfn, arr, iteratee, callback) {
  31487. var results = [];
  31488. eachfn(arr, function (x, index, callback) {
  31489. iteratee(x, function (err, v) {
  31490. if (err) {
  31491. callback(err);
  31492. } else {
  31493. if (v) {
  31494. results.push({ index: index, value: x });
  31495. }
  31496. callback();
  31497. }
  31498. });
  31499. }, function (err) {
  31500. if (err) {
  31501. callback(err);
  31502. } else {
  31503. callback(null, arrayMap(results.sort(function (a, b) {
  31504. return a.index - b.index;
  31505. }), baseProperty('value')));
  31506. }
  31507. });
  31508. }
  31509. /**
  31510. * The same as `filter` but runs a maximum of `limit` async operations at a
  31511. * time.
  31512. *
  31513. * @name filterLimit
  31514. * @static
  31515. * @memberOf async
  31516. * @see async.filter
  31517. * @alias selectLimit
  31518. * @category Collection
  31519. * @param {Array|Object} coll - A collection to iterate over.
  31520. * @param {number} limit - The maximum number of async operations at a time.
  31521. * @param {Function} iteratee - A truth test to apply to each item in `coll`.
  31522. * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
  31523. * with a boolean argument once it has completed. Invoked with (item, callback).
  31524. * @param {Function} [callback] - A callback which is called after all the
  31525. * `iteratee` functions have finished. Invoked with (err, results).
  31526. */
  31527. var filterLimit = doParallelLimit(_filter);
  31528. /**
  31529. * Returns a new array of all the values in `coll` which pass an async truth
  31530. * test. This operation is performed in parallel, but the results array will be
  31531. * in the same order as the original.
  31532. *
  31533. * @name filter
  31534. * @static
  31535. * @memberOf async
  31536. * @alias select
  31537. * @category Collection
  31538. * @param {Array|Object} coll - A collection to iterate over.
  31539. * @param {Function} iteratee - A truth test to apply to each item in `coll`.
  31540. * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
  31541. * with a boolean argument once it has completed. Invoked with (item, callback).
  31542. * @param {Function} [callback] - A callback which is called after all the
  31543. * `iteratee` functions have finished. Invoked with (err, results).
  31544. * @example
  31545. *
  31546. * async.filter(['file1','file2','file3'], function(filePath, callback) {
  31547. * fs.access(filePath, function(err) {
  31548. * callback(null, !err)
  31549. * });
  31550. * }, function(err, results) {
  31551. * // results now equals an array of the existing files
  31552. * });
  31553. */
  31554. var filter = doLimit(filterLimit, Infinity);
  31555. /**
  31556. * The same as `filter` but runs only a single async operation at a time.
  31557. *
  31558. * @name filterSeries
  31559. * @static
  31560. * @memberOf async
  31561. * @see async.filter
  31562. * @alias selectSeries
  31563. * @category Collection
  31564. * @param {Array|Object} coll - A collection to iterate over.
  31565. * @param {Function} iteratee - A truth test to apply to each item in `coll`.
  31566. * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
  31567. * with a boolean argument once it has completed. Invoked with (item, callback).
  31568. * @param {Function} [callback] - A callback which is called after all the
  31569. * `iteratee` functions have finished. Invoked with (err, results)
  31570. */
  31571. var filterSeries = doLimit(filterLimit, 1);
  31572. /**
  31573. * Calls the asynchronous function `fn` with a callback parameter that allows it
  31574. * to call itself again, in series, indefinitely.
  31575. * If an error is passed to the
  31576. * callback then `errback` is called with the error, and execution stops,
  31577. * otherwise it will never be called.
  31578. *
  31579. * @name forever
  31580. * @static
  31581. * @memberOf async
  31582. * @category Control Flow
  31583. * @param {Function} fn - a function to call repeatedly. Invoked with (next).
  31584. * @param {Function} [errback] - when `fn` passes an error to it's callback,
  31585. * this function will be called, and execution stops. Invoked with (err).
  31586. * @example
  31587. *
  31588. * async.forever(
  31589. * function(next) {
  31590. * // next is suitable for passing to things that need a callback(err [, whatever]);
  31591. * // it will result in this function being called again.
  31592. * },
  31593. * function(err) {
  31594. * // if next is called with a value in its first parameter, it will appear
  31595. * // in here as 'err', and execution will stop.
  31596. * }
  31597. * );
  31598. */
  31599. function forever(fn, cb) {
  31600. var done = onlyOnce(cb || noop);
  31601. var task = ensureAsync(fn);
  31602. function next(err) {
  31603. if (err) return done(err);
  31604. task(next);
  31605. }
  31606. next();
  31607. }
  31608. /**
  31609. * Creates an iterator function which calls the next function in the `tasks`
  31610. * array, returning a continuation to call the next one after that. It's also
  31611. * possible to “peek” at the next iterator with `iterator.next()`.
  31612. *
  31613. * This function is used internally by the `async` module, but can be useful
  31614. * when you want to manually control the flow of functions in series.
  31615. *
  31616. * @name iterator
  31617. * @static
  31618. * @memberOf async
  31619. * @category Control Flow
  31620. * @param {Array} tasks - An array of functions to run.
  31621. * @returns The next function to run in the series.
  31622. * @example
  31623. *
  31624. * var iterator = async.iterator([
  31625. * function() { sys.p('one'); },
  31626. * function() { sys.p('two'); },
  31627. * function() { sys.p('three'); }
  31628. * ]);
  31629. *
  31630. * node> var iterator2 = iterator();
  31631. * 'one'
  31632. * node> var iterator3 = iterator2();
  31633. * 'two'
  31634. * node> iterator3();
  31635. * 'three'
  31636. * node> var nextfn = iterator2.next();
  31637. * node> nextfn();
  31638. * 'three'
  31639. */
  31640. function iterator$1 (tasks) {
  31641. function makeCallback(index) {
  31642. function fn() {
  31643. if (tasks.length) {
  31644. tasks[index].apply(null, arguments);
  31645. }
  31646. return fn.next();
  31647. }
  31648. fn.next = function () {
  31649. return index < tasks.length - 1 ? makeCallback(index + 1) : null;
  31650. };
  31651. return fn;
  31652. }
  31653. return makeCallback(0);
  31654. }
  31655. /**
  31656. * Logs the result of an `async` function to the `console`. Only works in
  31657. * Node.js or in browsers that support `console.log` and `console.error` (such
  31658. * as FF and Chrome). If multiple arguments are returned from the async
  31659. * function, `console.log` is called on each argument in order.
  31660. *
  31661. * @name log
  31662. * @static
  31663. * @memberOf async
  31664. * @category Util
  31665. * @param {Function} function - The function you want to eventually apply all
  31666. * arguments to.
  31667. * @param {...*} arguments... - Any number of arguments to apply to the function.
  31668. * @example
  31669. *
  31670. * // in a module
  31671. * var hello = function(name, callback) {
  31672. * setTimeout(function() {
  31673. * callback(null, 'hello ' + name);
  31674. * }, 1000);
  31675. * };
  31676. *
  31677. * // in the node repl
  31678. * node> async.log(hello, 'world');
  31679. * 'hello world'
  31680. */
  31681. var log = consoleFunc('log');
  31682. /**
  31683. * The same as `mapValues` but runs a maximum of `limit` async operations at a
  31684. * time.
  31685. *
  31686. * @name mapValuesLimit
  31687. * @static
  31688. * @memberOf async
  31689. * @see async.mapValues
  31690. * @category Collection
  31691. * @param {Object} obj - A collection to iterate over.
  31692. * @param {number} limit - The maximum number of async operations at a time.
  31693. * @param {Function} iteratee - A function to apply to each value in `obj`.
  31694. * The iteratee is passed a `callback(err, transformed)` which must be called
  31695. * once it has completed with an error (which can be `null`) and a
  31696. * transformed value. Invoked with (value, key, callback).
  31697. * @param {Function} [callback] - A callback which is called when all `iteratee`
  31698. * functions have finished, or an error occurs. Result is an object of the
  31699. * transformed values from the `obj`. Invoked with (err, result).
  31700. */
  31701. function mapValuesLimit(obj, limit, iteratee, callback) {
  31702. var newObj = {};
  31703. eachOfLimit(obj, limit, function (val, key, next) {
  31704. iteratee(val, key, function (err, result) {
  31705. if (err) return next(err);
  31706. newObj[key] = result;
  31707. next();
  31708. });
  31709. }, function (err) {
  31710. callback(err, newObj);
  31711. });
  31712. }
  31713. /**
  31714. * A relative of `map`, designed for use with objects.
  31715. *
  31716. * Produces a new Object by mapping each value of `obj` through the `iteratee`
  31717. * function. The `iteratee` is called each `value` and `key` from `obj` and a
  31718. * callback for when it has finished processing. Each of these callbacks takes
  31719. * two arguments: an `error`, and the transformed item from `obj`. If `iteratee`
  31720. * passes an error to its callback, the main `callback` (for the `mapValues`
  31721. * function) is immediately called with the error.
  31722. *
  31723. * Note, the order of the keys in the result is not guaranteed. The keys will
  31724. * be roughly in the order they complete, (but this is very engine-specific)
  31725. *
  31726. * @name mapValues
  31727. * @static
  31728. * @memberOf async
  31729. * @category Collection
  31730. * @param {Object} obj - A collection to iterate over.
  31731. * @param {Function} iteratee - A function to apply to each value and key in
  31732. * `coll`. The iteratee is passed a `callback(err, transformed)` which must be
  31733. * called once it has completed with an error (which can be `null`) and a
  31734. * transformed value. Invoked with (value, key, callback).
  31735. * @param {Function} [callback] - A callback which is called when all `iteratee`
  31736. * functions have finished, or an error occurs. Results is an array of the
  31737. * transformed items from the `obj`. Invoked with (err, result).
  31738. * @example
  31739. *
  31740. * async.mapValues({
  31741. * f1: 'file1',
  31742. * f2: 'file2',
  31743. * f3: 'file3'
  31744. * }, fs.stat, function(err, result) {
  31745. * // results is now a map of stats for each file, e.g.
  31746. * // {
  31747. * // f1: [stats for file1],
  31748. * // f2: [stats for file2],
  31749. * // f3: [stats for file3]
  31750. * // }
  31751. * });
  31752. */
  31753. var mapValues = doLimit(mapValuesLimit, Infinity);
  31754. /**
  31755. * The same as `mapValues` but runs only a single async operation at a time.
  31756. *
  31757. * @name mapValuesSeries
  31758. * @static
  31759. * @memberOf async
  31760. * @see async.mapValues
  31761. * @category Collection
  31762. * @param {Object} obj - A collection to iterate over.
  31763. * @param {Function} iteratee - A function to apply to each value in `obj`.
  31764. * The iteratee is passed a `callback(err, transformed)` which must be called
  31765. * once it has completed with an error (which can be `null`) and a
  31766. * transformed value. Invoked with (value, key, callback).
  31767. * @param {Function} [callback] - A callback which is called when all `iteratee`
  31768. * functions have finished, or an error occurs. Result is an object of the
  31769. * transformed values from the `obj`. Invoked with (err, result).
  31770. */
  31771. var mapValuesSeries = doLimit(mapValuesLimit, 1);
  31772. function has(obj, key) {
  31773. return key in obj;
  31774. }
  31775. /**
  31776. * Caches the results of an `async` function. When creating a hash to store
  31777. * function results against, the callback is omitted from the hash and an
  31778. * optional hash function can be used.
  31779. *
  31780. * If no hash function is specified, the first argument is used as a hash key,
  31781. * which may work reasonably if it is a string or a data type that converts to a
  31782. * distinct string. Note that objects and arrays will not behave reasonably.
  31783. * Neither will cases where the other arguments are significant. In such cases,
  31784. * specify your own hash function.
  31785. *
  31786. * The cache of results is exposed as the `memo` property of the function
  31787. * returned by `memoize`.
  31788. *
  31789. * @name memoize
  31790. * @static
  31791. * @memberOf async
  31792. * @category Util
  31793. * @param {Function} fn - The function to proxy and cache results from.
  31794. * @param {Function} hasher - An optional function for generating a custom hash
  31795. * for storing results. It has all the arguments applied to it apart from the
  31796. * callback, and must be synchronous.
  31797. * @example
  31798. *
  31799. * var slow_fn = function(name, callback) {
  31800. * // do something
  31801. * callback(null, result);
  31802. * };
  31803. * var fn = async.memoize(slow_fn);
  31804. *
  31805. * // fn can now be used as if it were slow_fn
  31806. * fn('some name', function() {
  31807. * // callback
  31808. * });
  31809. */
  31810. function memoize$1(fn, hasher) {
  31811. var memo = Object.create(null);
  31812. var queues = Object.create(null);
  31813. hasher = hasher || identity;
  31814. var memoized = initialParams(function memoized(args, callback) {
  31815. var key = hasher.apply(null, args);
  31816. if (has(memo, key)) {
  31817. setImmediate$1(function () {
  31818. callback.apply(null, memo[key]);
  31819. });
  31820. } else if (has(queues, key)) {
  31821. queues[key].push(callback);
  31822. } else {
  31823. queues[key] = [callback];
  31824. fn.apply(null, args.concat([rest(function (args) {
  31825. memo[key] = args;
  31826. var q = queues[key];
  31827. delete queues[key];
  31828. for (var i = 0, l = q.length; i < l; i++) {
  31829. q[i].apply(null, args);
  31830. }
  31831. })]));
  31832. }
  31833. });
  31834. memoized.memo = memo;
  31835. memoized.unmemoized = fn;
  31836. return memoized;
  31837. }
  31838. /**
  31839. * Calls `callback` on a later loop around the event loop. In Node.js this just
  31840. * calls `setImmediate`. In the browser it will use `setImmediate` if
  31841. * available, otherwise `setTimeout(callback, 0)`, which means other higher
  31842. * priority events may precede the execution of `callback`.
  31843. *
  31844. * This is used internally for browser-compatibility purposes.
  31845. *
  31846. * @name nextTick
  31847. * @static
  31848. * @memberOf async
  31849. * @alias setImmediate
  31850. * @category Util
  31851. * @param {Function} callback - The function to call on a later loop around
  31852. * the event loop. Invoked with (args...).
  31853. * @param {...*} args... - any number of additional arguments to pass to the
  31854. * callback on the next tick.
  31855. * @example
  31856. *
  31857. * var call_order = [];
  31858. * async.nextTick(function() {
  31859. * call_order.push('two');
  31860. * // call_order now equals ['one','two']
  31861. * });
  31862. * call_order.push('one');
  31863. *
  31864. * async.setImmediate(function (a, b, c) {
  31865. * // a, b, and c equal 1, 2, and 3
  31866. * }, 1, 2, 3);
  31867. */
  31868. var _defer$1;
  31869. if (hasNextTick) {
  31870. _defer$1 = process.nextTick;
  31871. } else if (hasSetImmediate) {
  31872. _defer$1 = setImmediate;
  31873. } else {
  31874. _defer$1 = fallback;
  31875. }
  31876. var nextTick = wrap(_defer$1);
  31877. function _parallel(eachfn, tasks, callback) {
  31878. callback = callback || noop;
  31879. var results = isArrayLike(tasks) ? [] : {};
  31880. eachfn(tasks, function (task, key, callback) {
  31881. task(rest(function (err, args) {
  31882. if (args.length <= 1) {
  31883. args = args[0];
  31884. }
  31885. results[key] = args;
  31886. callback(err);
  31887. }));
  31888. }, function (err) {
  31889. callback(err, results);
  31890. });
  31891. }
  31892. /**
  31893. * The same as `parallel` but runs a maximum of `limit` async operations at a
  31894. * time.
  31895. *
  31896. * @name parallel
  31897. * @static
  31898. * @memberOf async
  31899. * @see async.parallel
  31900. * @category Control Flow
  31901. * @param {Array|Collection} tasks - A collection containing functions to run.
  31902. * Each function is passed a `callback(err, result)` which it must call on
  31903. * completion with an error `err` (which can be `null`) and an optional `result`
  31904. * value.
  31905. * @param {number} limit - The maximum number of async operations at a time.
  31906. * @param {Function} [callback] - An optional callback to run once all the
  31907. * functions have completed successfully. This function gets a results array
  31908. * (or object) containing all the result arguments passed to the task callbacks.
  31909. * Invoked with (err, results).
  31910. */
  31911. function parallelLimit(tasks, limit, cb) {
  31912. return _parallel(_eachOfLimit(limit), tasks, cb);
  31913. }
  31914. /**
  31915. * Run the `tasks` collection of functions in parallel, without waiting until
  31916. * the previous function has completed. If any of the functions pass an error to
  31917. * its callback, the main `callback` is immediately called with the value of the
  31918. * error. Once the `tasks` have completed, the results are passed to the final
  31919. * `callback` as an array.
  31920. *
  31921. * **Note:** `parallel` is about kicking-off I/O tasks in parallel, not about
  31922. * parallel execution of code. If your tasks do not use any timers or perform
  31923. * any I/O, they will actually be executed in series. Any synchronous setup
  31924. * sections for each task will happen one after the other. JavaScript remains
  31925. * single-threaded.
  31926. *
  31927. * It is also possible to use an object instead of an array. Each property will
  31928. * be run as a function and the results will be passed to the final `callback`
  31929. * as an object instead of an array. This can be a more readable way of handling
  31930. * results from {@link async.parallel}.
  31931. *
  31932. * @name parallel
  31933. * @static
  31934. * @memberOf async
  31935. * @category Control Flow
  31936. * @param {Array|Object} tasks - A collection containing functions to run.
  31937. * Each function is passed a `callback(err, result)` which it must call on
  31938. * completion with an error `err` (which can be `null`) and an optional `result`
  31939. * value.
  31940. * @param {Function} [callback] - An optional callback to run once all the
  31941. * functions have completed successfully. This function gets a results array
  31942. * (or object) containing all the result arguments passed to the task callbacks.
  31943. * Invoked with (err, results).
  31944. * @example
  31945. * async.parallel([
  31946. * function(callback) {
  31947. * setTimeout(function() {
  31948. * callback(null, 'one');
  31949. * }, 200);
  31950. * },
  31951. * function(callback) {
  31952. * setTimeout(function() {
  31953. * callback(null, 'two');
  31954. * }, 100);
  31955. * }
  31956. * ],
  31957. * // optional callback
  31958. * function(err, results) {
  31959. * // the results array will equal ['one','two'] even though
  31960. * // the second function had a shorter timeout.
  31961. * });
  31962. *
  31963. * // an example using an object instead of an array
  31964. * async.parallel({
  31965. * one: function(callback) {
  31966. * setTimeout(function() {
  31967. * callback(null, 1);
  31968. * }, 200);
  31969. * },
  31970. * two: function(callback) {
  31971. * setTimeout(function() {
  31972. * callback(null, 2);
  31973. * }, 100);
  31974. * }
  31975. * }, function(err, results) {
  31976. * // results is now equals to: {one: 1, two: 2}
  31977. * });
  31978. */
  31979. var parallel = doLimit(parallelLimit, Infinity);
  31980. /**
  31981. * A queue of tasks for the worker function to complete.
  31982. * @typedef {Object} queue
  31983. * @property {Function} length - a function returning the number of items
  31984. * waiting to be processed. Invoke with ().
  31985. * @property {Function} started - a function returning whether or not any
  31986. * items have been pushed and processed by the queue. Invoke with ().
  31987. * @property {Function} running - a function returning the number of items
  31988. * currently being processed. Invoke with ().
  31989. * @property {Function} workersList - a function returning the array of items
  31990. * currently being processed. Invoke with ().
  31991. * @property {Function} idle - a function returning false if there are items
  31992. * waiting or being processed, or true if not. Invoke with ().
  31993. * @property {number} concurrency - an integer for determining how many `worker`
  31994. * functions should be run in parallel. This property can be changed after a
  31995. * `queue` is created to alter the concurrency on-the-fly.
  31996. * @property {Function} push - add a new task to the `queue`. Calls `callback`
  31997. * once the `worker` has finished processing the task. Instead of a single task,
  31998. * a `tasks` array can be submitted. The respective callback is used for every
  31999. * task in the list. Invoke with (task, [callback]),
  32000. * @property {Function} unshift - add a new task to the front of the `queue`.
  32001. * Invoke with (task, [callback]).
  32002. * @property {Function} saturated - a callback that is called when the number of
  32003. * running workers hits the `concurrency` limit, and further tasks will be
  32004. * queued.
  32005. * @property {Function} unsaturated - a callback that is called when the number
  32006. * of running workers is less than the `concurrency` & `buffer` limits, and
  32007. * further tasks will not be queued.
  32008. * @property {number} buffer - A minimum threshold buffer in order to say that
  32009. * the `queue` is `unsaturated`.
  32010. * @property {Function} empty - a callback that is called when the last item
  32011. * from the `queue` is given to a `worker`.
  32012. * @property {Function} drain - a callback that is called when the last item
  32013. * from the `queue` has returned from the `worker`.
  32014. * @property {Function} error - a callback that is called when a task errors.
  32015. * Has the signature `function(error, task)`.
  32016. * @property {boolean} paused - a boolean for determining whether the queue is
  32017. * in a paused state.
  32018. * @property {Function} pause - a function that pauses the processing of tasks
  32019. * until `resume()` is called. Invoke with ().
  32020. * @property {Function} resume - a function that resumes the processing of
  32021. * queued tasks when the queue is paused. Invoke with ().
  32022. * @property {Function} kill - a function that removes the `drain` callback and
  32023. * empties remaining tasks from the queue forcing it to go idle. Invoke with ().
  32024. */
  32025. /**
  32026. * Creates a `queue` object with the specified `concurrency`. Tasks added to the
  32027. * `queue` are processed in parallel (up to the `concurrency` limit). If all
  32028. * `worker`s are in progress, the task is queued until one becomes available.
  32029. * Once a `worker` completes a `task`, that `task`'s callback is called.
  32030. *
  32031. * @name queue
  32032. * @static
  32033. * @memberOf async
  32034. * @category Control Flow
  32035. * @param {Function} worker - An asynchronous function for processing a queued
  32036. * task, which must call its `callback(err)` argument when finished, with an
  32037. * optional `error` as an argument. If you want to handle errors from an
  32038. * individual task, pass a callback to `q.push()`. Invoked with
  32039. * (task, callback).
  32040. * @param {number} [concurrency=1] - An `integer` for determining how many
  32041. * `worker` functions should be run in parallel. If omitted, the concurrency
  32042. * defaults to `1`. If the concurrency is `0`, an error is thrown.
  32043. * @returns {queue} A queue object to manage the tasks. Callbacks can
  32044. * attached as certain properties to listen for specific events during the
  32045. * lifecycle of the queue.
  32046. * @example
  32047. *
  32048. * // create a queue object with concurrency 2
  32049. * var q = async.queue(function(task, callback) {
  32050. * console.log('hello ' + task.name);
  32051. * callback();
  32052. * }, 2);
  32053. *
  32054. * // assign a callback
  32055. * q.drain = function() {
  32056. * console.log('all items have been processed');
  32057. * };
  32058. *
  32059. * // add some items to the queue
  32060. * q.push({name: 'foo'}, function(err) {
  32061. * console.log('finished processing foo');
  32062. * });
  32063. * q.push({name: 'bar'}, function (err) {
  32064. * console.log('finished processing bar');
  32065. * });
  32066. *
  32067. * // add some items to the queue (batch-wise)
  32068. * q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function(err) {
  32069. * console.log('finished processing item');
  32070. * });
  32071. *
  32072. * // add some items to the front of the queue
  32073. * q.unshift({name: 'bar'}, function (err) {
  32074. * console.log('finished processing bar');
  32075. * });
  32076. */
  32077. function queue$1 (worker, concurrency) {
  32078. return queue(function (items, cb) {
  32079. worker(items[0], cb);
  32080. }, concurrency, 1);
  32081. }
  32082. /**
  32083. * The same as {@link async.queue} only tasks are assigned a priority and
  32084. * completed in ascending priority order.
  32085. *
  32086. * @name priorityQueue
  32087. * @static
  32088. * @memberOf async
  32089. * @see async.queue
  32090. * @category Control Flow
  32091. * @param {Function} worker - An asynchronous function for processing a queued
  32092. * task, which must call its `callback(err)` argument when finished, with an
  32093. * optional `error` as an argument. If you want to handle errors from an
  32094. * individual task, pass a callback to `q.push()`. Invoked with
  32095. * (task, callback).
  32096. * @param {number} concurrency - An `integer` for determining how many `worker`
  32097. * functions should be run in parallel. If omitted, the concurrency defaults to
  32098. * `1`. If the concurrency is `0`, an error is thrown.
  32099. * @returns {queue} A priorityQueue object to manage the tasks. There are two
  32100. * differences between `queue` and `priorityQueue` objects:
  32101. * * `push(task, priority, [callback])` - `priority` should be a number. If an
  32102. * array of `tasks` is given, all tasks will be assigned the same priority.
  32103. * * The `unshift` method was removed.
  32104. */
  32105. function priorityQueue (worker, concurrency) {
  32106. function _compareTasks(a, b) {
  32107. return a.priority - b.priority;
  32108. }
  32109. function _binarySearch(sequence, item, compare) {
  32110. var beg = -1,
  32111. end = sequence.length - 1;
  32112. while (beg < end) {
  32113. var mid = beg + (end - beg + 1 >>> 1);
  32114. if (compare(item, sequence[mid]) >= 0) {
  32115. beg = mid;
  32116. } else {
  32117. end = mid - 1;
  32118. }
  32119. }
  32120. return beg;
  32121. }
  32122. function _insert(q, data, priority, callback) {
  32123. if (callback != null && typeof callback !== 'function') {
  32124. throw new Error('task callback must be a function');
  32125. }
  32126. q.started = true;
  32127. if (!isArray(data)) {
  32128. data = [data];
  32129. }
  32130. if (data.length === 0) {
  32131. // call drain immediately if there are no tasks
  32132. return setImmediate$1(function () {
  32133. q.drain();
  32134. });
  32135. }
  32136. arrayEach(data, function (task) {
  32137. var item = {
  32138. data: task,
  32139. priority: priority,
  32140. callback: typeof callback === 'function' ? callback : noop
  32141. };
  32142. q.tasks.splice(_binarySearch(q.tasks, item, _compareTasks) + 1, 0, item);
  32143. setImmediate$1(q.process);
  32144. });
  32145. }
  32146. // Start with a normal queue
  32147. var q = queue$1(worker, concurrency);
  32148. // Override push to accept second parameter representing priority
  32149. q.push = function (data, priority, callback) {
  32150. _insert(q, data, priority, callback);
  32151. };
  32152. // Remove unshift function
  32153. delete q.unshift;
  32154. return q;
  32155. }
  32156. /**
  32157. * Creates a `baseEach` or `baseEachRight` function.
  32158. *
  32159. * @private
  32160. * @param {Function} eachFunc The function to iterate over a collection.
  32161. * @param {boolean} [fromRight] Specify iterating from right to left.
  32162. * @returns {Function} Returns the new base function.
  32163. */
  32164. function createBaseEach(eachFunc, fromRight) {
  32165. return function(collection, iteratee) {
  32166. if (collection == null) {
  32167. return collection;
  32168. }
  32169. if (!isArrayLike(collection)) {
  32170. return eachFunc(collection, iteratee);
  32171. }
  32172. var length = collection.length,
  32173. index = fromRight ? length : -1,
  32174. iterable = Object(collection);
  32175. while ((fromRight ? index-- : ++index < length)) {
  32176. if (iteratee(iterable[index], index, iterable) === false) {
  32177. break;
  32178. }
  32179. }
  32180. return collection;
  32181. };
  32182. }
  32183. /**
  32184. * The base implementation of `_.forEach` without support for iteratee shorthands.
  32185. *
  32186. * @private
  32187. * @param {Array|Object} collection The collection to iterate over.
  32188. * @param {Function} iteratee The function invoked per iteration.
  32189. * @returns {Array|Object} Returns `collection`.
  32190. */
  32191. var baseEach = createBaseEach(baseForOwn);
  32192. /**
  32193. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  32194. * The iteratee is invoked with three arguments: (value, index|key, collection).
  32195. * Iteratee functions may exit iteration early by explicitly returning `false`.
  32196. *
  32197. * **Note:** As with other "Collections" methods, objects with a "length"
  32198. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  32199. * or `_.forOwn` for object iteration.
  32200. *
  32201. * @static
  32202. * @memberOf _
  32203. * @since 0.1.0
  32204. * @alias each
  32205. * @category Collection
  32206. * @param {Array|Object} collection The collection to iterate over.
  32207. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  32208. * @returns {Array|Object} Returns `collection`.
  32209. * @see _.forEachRight
  32210. * @example
  32211. *
  32212. * _([1, 2]).forEach(function(value) {
  32213. * console.log(value);
  32214. * });
  32215. * // => Logs `1` then `2`.
  32216. *
  32217. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  32218. * console.log(key);
  32219. * });
  32220. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  32221. */
  32222. function forEach(collection, iteratee) {
  32223. var func = isArray(collection) ? arrayEach : baseEach;
  32224. return func(collection, baseIteratee(iteratee, 3));
  32225. }
  32226. /**
  32227. * Runs the `tasks` array of functions in parallel, without waiting until the
  32228. * previous function has completed. Once any the `tasks` completed or pass an
  32229. * error to its callback, the main `callback` is immediately called. It's
  32230. * equivalent to `Promise.race()`.
  32231. *
  32232. * @name race
  32233. * @static
  32234. * @memberOf async
  32235. * @category Control Flow
  32236. * @param {Array} tasks - An array containing functions to run. Each function
  32237. * is passed a `callback(err, result)` which it must call on completion with an
  32238. * error `err` (which can be `null`) and an optional `result` value.
  32239. * @param {Function} callback - A callback to run once any of the functions have
  32240. * completed. This function gets an error or result from the first function that
  32241. * completed. Invoked with (err, result).
  32242. * @example
  32243. *
  32244. * async.race([
  32245. * function(callback) {
  32246. * setTimeout(function() {
  32247. * callback(null, 'one');
  32248. * }, 200);
  32249. * },
  32250. * function(callback) {
  32251. * setTimeout(function() {
  32252. * callback(null, 'two');
  32253. * }, 100);
  32254. * }
  32255. * ],
  32256. * // main callback
  32257. * function(err, result) {
  32258. * // the result will be equal to 'two' as it finishes earlier
  32259. * });
  32260. */
  32261. function race(tasks, cb) {
  32262. cb = once(cb || noop);
  32263. if (!isArray(tasks)) return cb(new TypeError('First argument to race must be an array of functions'));
  32264. if (!tasks.length) return cb();
  32265. forEach(tasks, function (task) {
  32266. task(cb);
  32267. });
  32268. }
  32269. var slice = Array.prototype.slice;
  32270. /**
  32271. * Same as `reduce`, only operates on `coll` in reverse order.
  32272. *
  32273. * @name reduceRight
  32274. * @static
  32275. * @memberOf async
  32276. * @see async.reduce
  32277. * @alias foldr
  32278. * @category Collection
  32279. * @param {Array|Object} coll - A collection to iterate over.
  32280. * @param {*} memo - The initial state of the reduction.
  32281. * @param {Function} iteratee - A function applied to each item in the
  32282. * array to produce the next step in the reduction. The `iteratee` is passed a
  32283. * `callback(err, reduction)` which accepts an optional error as its first
  32284. * argument, and the state of the reduction as the second. If an error is
  32285. * passed to the callback, the reduction is stopped and the main `callback` is
  32286. * immediately called with the error. Invoked with (memo, item, callback).
  32287. * @param {Function} [callback] - A callback which is called after all the
  32288. * `iteratee` functions have finished. Result is the reduced value. Invoked with
  32289. * (err, result).
  32290. */
  32291. function reduceRight(arr, memo, iteratee, cb) {
  32292. var reversed = slice.call(arr).reverse();
  32293. reduce(reversed, memo, iteratee, cb);
  32294. }
  32295. /**
  32296. * Wraps the function in another function that always returns data even when it
  32297. * errors.
  32298. *
  32299. * The object returned has either the property `error` or `value`.
  32300. *
  32301. * @name reflect
  32302. * @static
  32303. * @memberOf async
  32304. * @category Util
  32305. * @param {Function} function - The function you want to wrap
  32306. * @returns {Function} - A function that always passes null to it's callback as
  32307. * the error. The second argument to the callback will be an `object` with
  32308. * either an `error` or a `value` property.
  32309. * @example
  32310. *
  32311. * async.parallel([
  32312. * async.reflect(function(callback) {
  32313. * // do some stuff ...
  32314. * callback(null, 'one');
  32315. * }),
  32316. * async.reflect(function(callback) {
  32317. * // do some more stuff but error ...
  32318. * callback('bad stuff happened');
  32319. * }),
  32320. * async.reflect(function(callback) {
  32321. * // do some more stuff ...
  32322. * callback(null, 'two');
  32323. * })
  32324. * ],
  32325. * // optional callback
  32326. * function(err, results) {
  32327. * // values
  32328. * // results[0].value = 'one'
  32329. * // results[1].error = 'bad stuff happened'
  32330. * // results[2].value = 'two'
  32331. * });
  32332. */
  32333. function reflect(fn) {
  32334. return initialParams(function reflectOn(args, reflectCallback) {
  32335. args.push(rest(function callback(err, cbArgs) {
  32336. if (err) {
  32337. reflectCallback(null, {
  32338. error: err
  32339. });
  32340. } else {
  32341. var value = null;
  32342. if (cbArgs.length === 1) {
  32343. value = cbArgs[0];
  32344. } else if (cbArgs.length > 1) {
  32345. value = cbArgs;
  32346. }
  32347. reflectCallback(null, {
  32348. value: value
  32349. });
  32350. }
  32351. }));
  32352. return fn.apply(this, args);
  32353. });
  32354. }
  32355. function reject$1(eachfn, arr, iteratee, callback) {
  32356. _filter(eachfn, arr, function (value, cb) {
  32357. iteratee(value, function (err, v) {
  32358. if (err) {
  32359. cb(err);
  32360. } else {
  32361. cb(null, !v);
  32362. }
  32363. });
  32364. }, callback);
  32365. }
  32366. /**
  32367. * The same as `reject` but runs a maximum of `limit` async operations at a
  32368. * time.
  32369. *
  32370. * @name rejectLimit
  32371. * @static
  32372. * @memberOf async
  32373. * @see async.reject
  32374. * @category Collection
  32375. * @param {Array|Object} coll - A collection to iterate over.
  32376. * @param {number} limit - The maximum number of async operations at a time.
  32377. * @param {Function} iteratee - A truth test to apply to each item in `coll`.
  32378. * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
  32379. * with a boolean argument once it has completed. Invoked with (item, callback).
  32380. * @param {Function} [callback] - A callback which is called after all the
  32381. * `iteratee` functions have finished. Invoked with (err, results).
  32382. */
  32383. var rejectLimit = doParallelLimit(reject$1);
  32384. /**
  32385. * The opposite of `filter`. Removes values that pass an `async` truth test.
  32386. *
  32387. * @name reject
  32388. * @static
  32389. * @memberOf async
  32390. * @see async.filter
  32391. * @category Collection
  32392. * @param {Array|Object} coll - A collection to iterate over.
  32393. * @param {Function} iteratee - A truth test to apply to each item in `coll`.
  32394. * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
  32395. * with a boolean argument once it has completed. Invoked with (item, callback).
  32396. * @param {Function} [callback] - A callback which is called after all the
  32397. * `iteratee` functions have finished. Invoked with (err, results).
  32398. * @example
  32399. *
  32400. * async.reject(['file1','file2','file3'], function(filePath, callback) {
  32401. * fs.access(filePath, function(err) {
  32402. * callback(null, !err)
  32403. * });
  32404. * }, function(err, results) {
  32405. * // results now equals an array of missing files
  32406. * createFiles(results);
  32407. * });
  32408. */
  32409. var reject = doLimit(rejectLimit, Infinity);
  32410. /**
  32411. * A helper function that wraps an array of functions with reflect.
  32412. *
  32413. * @name reflectAll
  32414. * @static
  32415. * @memberOf async
  32416. * @see async.reflect
  32417. * @category Util
  32418. * @param {Array} tasks - The array of functions to wrap in `async.reflect`.
  32419. * @returns {Array} Returns an array of functions, each function wrapped in
  32420. * `async.reflect`
  32421. * @example
  32422. *
  32423. * let tasks = [
  32424. * function(callback) {
  32425. * setTimeout(function() {
  32426. * callback(null, 'one');
  32427. * }, 200);
  32428. * },
  32429. * function(callback) {
  32430. * // do some more stuff but error ...
  32431. * callback(new Error('bad stuff happened'));
  32432. * },
  32433. * function(callback) {
  32434. * setTimeout(function() {
  32435. * callback(null, 'two');
  32436. * }, 100);
  32437. * }
  32438. * ];
  32439. *
  32440. * async.parallel(async.reflectAll(tasks),
  32441. * // optional callback
  32442. * function(err, results) {
  32443. * // values
  32444. * // results[0].value = 'one'
  32445. * // results[1].error = Error('bad stuff happened')
  32446. * // results[2].value = 'two'
  32447. * });
  32448. */
  32449. function reflectAll(tasks) {
  32450. return tasks.map(reflect);
  32451. }
  32452. /**
  32453. * The same as `reject` but runs only a single async operation at a time.
  32454. *
  32455. * @name rejectSeries
  32456. * @static
  32457. * @memberOf async
  32458. * @see async.reject
  32459. * @category Collection
  32460. * @param {Array|Object} coll - A collection to iterate over.
  32461. * @param {Function} iteratee - A truth test to apply to each item in `coll`.
  32462. * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
  32463. * with a boolean argument once it has completed. Invoked with (item, callback).
  32464. * @param {Function} [callback] - A callback which is called after all the
  32465. * `iteratee` functions have finished. Invoked with (err, results).
  32466. */
  32467. var rejectSeries = doLimit(rejectLimit, 1);
  32468. /**
  32469. * Run the functions in the `tasks` collection in series, each one running once
  32470. * the previous function has completed. If any functions in the series pass an
  32471. * error to its callback, no more functions are run, and `callback` is
  32472. * immediately called with the value of the error. Otherwise, `callback`
  32473. * receives an array of results when `tasks` have completed.
  32474. *
  32475. * It is also possible to use an object instead of an array. Each property will
  32476. * be run as a function, and the results will be passed to the final `callback`
  32477. * as an object instead of an array. This can be a more readable way of handling
  32478. * results from {@link async.series}.
  32479. *
  32480. * **Note** that while many implementations preserve the order of object
  32481. * properties, the [ECMAScript Language Specification](http://www.ecma-international.org/ecma-262/5.1/#sec-8.6)
  32482. * explicitly states that
  32483. *
  32484. * > The mechanics and order of enumerating the properties is not specified.
  32485. *
  32486. * So if you rely on the order in which your series of functions are executed,
  32487. * and want this to work on all platforms, consider using an array.
  32488. *
  32489. * @name series
  32490. * @static
  32491. * @memberOf async
  32492. * @category Control Flow
  32493. * @param {Array|Object} tasks - A collection containing functions to run, each
  32494. * function is passed a `callback(err, result)` it must call on completion with
  32495. * an error `err` (which can be `null`) and an optional `result` value.
  32496. * @param {Function} [callback] - An optional callback to run once all the
  32497. * functions have completed. This function gets a results array (or object)
  32498. * containing all the result arguments passed to the `task` callbacks. Invoked
  32499. * with (err, result).
  32500. * @example
  32501. * async.series([
  32502. * function(callback) {
  32503. * // do some stuff ...
  32504. * callback(null, 'one');
  32505. * },
  32506. * function(callback) {
  32507. * // do some more stuff ...
  32508. * callback(null, 'two');
  32509. * }
  32510. * ],
  32511. * // optional callback
  32512. * function(err, results) {
  32513. * // results is now equal to ['one', 'two']
  32514. * });
  32515. *
  32516. * async.series({
  32517. * one: function(callback) {
  32518. * setTimeout(function() {
  32519. * callback(null, 1);
  32520. * }, 200);
  32521. * },
  32522. * two: function(callback){
  32523. * setTimeout(function() {
  32524. * callback(null, 2);
  32525. * }, 100);
  32526. * }
  32527. * }, function(err, results) {
  32528. * // results is now equal to: {one: 1, two: 2}
  32529. * });
  32530. */
  32531. function series(tasks, cb) {
  32532. return _parallel(eachOfSeries, tasks, cb);
  32533. }
  32534. /**
  32535. * Creates a function that returns `value`.
  32536. *
  32537. * @static
  32538. * @memberOf _
  32539. * @since 2.4.0
  32540. * @category Util
  32541. * @param {*} value The value to return from the new function.
  32542. * @returns {Function} Returns the new constant function.
  32543. * @example
  32544. *
  32545. * var objects = _.times(2, _.constant({ 'a': 1 }));
  32546. *
  32547. * console.log(objects);
  32548. * // => [{ 'a': 1 }, { 'a': 1 }]
  32549. *
  32550. * console.log(objects[0] === objects[1]);
  32551. * // => true
  32552. */
  32553. function constant$1(value) {
  32554. return function() {
  32555. return value;
  32556. };
  32557. }
  32558. /**
  32559. * Attempts to get a successful response from `task` no more than `times` times
  32560. * before returning an error. If the task is successful, the `callback` will be
  32561. * passed the result of the successful task. If all attempts fail, the callback
  32562. * will be passed the error and result (if any) of the final attempt.
  32563. *
  32564. * @name retry
  32565. * @static
  32566. * @memberOf async
  32567. * @category Control Flow
  32568. * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - Can be either an
  32569. * object with `times` and `interval` or a number.
  32570. * * `times` - The number of attempts to make before giving up. The default
  32571. * is `5`.
  32572. * * `interval` - The time to wait between retries, in milliseconds. The
  32573. * default is `0`. The interval may also be specified as a function of the
  32574. * retry count (see example).
  32575. * * If `opts` is a number, the number specifies the number of times to retry,
  32576. * with the default interval of `0`.
  32577. * @param {Function} task - A function which receives two arguments: (1) a
  32578. * `callback(err, result)` which must be called when finished, passing `err`
  32579. * (which can be `null`) and the `result` of the function's execution, and (2)
  32580. * a `results` object, containing the results of the previously executed
  32581. * functions (if nested inside another control flow). Invoked with
  32582. * (callback, results).
  32583. * @param {Function} [callback] - An optional callback which is called when the
  32584. * task has succeeded, or after the final failed attempt. It receives the `err`
  32585. * and `result` arguments of the last attempt at completing the `task`. Invoked
  32586. * with (err, results).
  32587. * @example
  32588. *
  32589. * // The `retry` function can be used as a stand-alone control flow by passing
  32590. * // a callback, as shown below:
  32591. *
  32592. * // try calling apiMethod 3 times
  32593. * async.retry(3, apiMethod, function(err, result) {
  32594. * // do something with the result
  32595. * });
  32596. *
  32597. * // try calling apiMethod 3 times, waiting 200 ms between each retry
  32598. * async.retry({times: 3, interval: 200}, apiMethod, function(err, result) {
  32599. * // do something with the result
  32600. * });
  32601. *
  32602. * // try calling apiMethod 10 times with exponential backoff
  32603. * // (i.e. intervals of 100, 200, 400, 800, 1600, ... milliseconds)
  32604. * async.retry({
  32605. * times: 10,
  32606. * interval: function(retryCount) {
  32607. * return 50 * Math.pow(2, retryCount);
  32608. * }
  32609. * }, apiMethod, function(err, result) {
  32610. * // do something with the result
  32611. * });
  32612. *
  32613. * // try calling apiMethod the default 5 times no delay between each retry
  32614. * async.retry(apiMethod, function(err, result) {
  32615. * // do something with the result
  32616. * });
  32617. *
  32618. * // It can also be embedded within other control flow functions to retry
  32619. * // individual methods that are not as reliable, like this:
  32620. * async.auto({
  32621. * users: api.getUsers.bind(api),
  32622. * payments: async.retry(3, api.getPayments.bind(api))
  32623. * }, function(err, results) {
  32624. * // do something with the results
  32625. * });
  32626. */
  32627. function retry(times, task, callback) {
  32628. var DEFAULT_TIMES = 5;
  32629. var DEFAULT_INTERVAL = 0;
  32630. var opts = {
  32631. times: DEFAULT_TIMES,
  32632. intervalFunc: constant$1(DEFAULT_INTERVAL)
  32633. };
  32634. function parseTimes(acc, t) {
  32635. if (typeof t === 'object') {
  32636. acc.times = +t.times || DEFAULT_TIMES;
  32637. acc.intervalFunc = typeof t.interval === 'function' ? t.interval : constant$1(+t.interval || DEFAULT_INTERVAL);
  32638. } else if (typeof t === 'number' || typeof t === 'string') {
  32639. acc.times = +t || DEFAULT_TIMES;
  32640. } else {
  32641. throw new Error("Invalid arguments for async.retry");
  32642. }
  32643. }
  32644. if (arguments.length < 3 && typeof times === 'function') {
  32645. callback = task || noop;
  32646. task = times;
  32647. } else {
  32648. parseTimes(opts, times);
  32649. callback = callback || noop;
  32650. }
  32651. if (typeof task !== 'function') {
  32652. throw new Error("Invalid arguments for async.retry");
  32653. }
  32654. var attempts = [];
  32655. for (var i = 1; i < opts.times + 1; i++) {
  32656. var isFinalAttempt = i == opts.times;
  32657. attempts.push(retryAttempt(isFinalAttempt));
  32658. var interval = opts.intervalFunc(i);
  32659. if (!isFinalAttempt && interval > 0) {
  32660. attempts.push(retryInterval(interval));
  32661. }
  32662. }
  32663. series(attempts, function (done, data) {
  32664. data = data[data.length - 1];
  32665. callback(data.err, data.result);
  32666. });
  32667. function retryAttempt(isFinalAttempt) {
  32668. return function (seriesCallback) {
  32669. task(function (err, result) {
  32670. seriesCallback(!err || isFinalAttempt, {
  32671. err: err,
  32672. result: result
  32673. });
  32674. });
  32675. };
  32676. }
  32677. function retryInterval(interval) {
  32678. return function (seriesCallback) {
  32679. setTimeout(function () {
  32680. seriesCallback(null);
  32681. }, interval);
  32682. };
  32683. }
  32684. }
  32685. /**
  32686. * A close relative of `retry`. This method wraps a task and makes it
  32687. * retryable, rather than immediately calling it with retries.
  32688. *
  32689. * @name retryable
  32690. * @static
  32691. * @memberOf async
  32692. * @see async.retry
  32693. * @category Control Flow
  32694. * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - optional
  32695. * options, exactly the same as from `retry`
  32696. * @param {Function} task - the asynchronous function to wrap
  32697. * @returns {Functions} The wrapped function, which when invoked, will retry on
  32698. * an error, based on the parameters specified in `opts`.
  32699. * @example
  32700. *
  32701. * async.auto({
  32702. * dep1: async.retryable(3, getFromFlakyService),
  32703. * process: ["dep1", async.retryable(3, function (results, cb) {
  32704. * maybeProcessData(results.dep1, cb);
  32705. * })]
  32706. * }, callback);
  32707. */
  32708. function retryable (opts, task) {
  32709. if (!task) {
  32710. task = opts;
  32711. opts = null;
  32712. }
  32713. return initialParams(function (args, callback) {
  32714. function taskFn(cb) {
  32715. task.apply(null, args.concat([cb]));
  32716. }
  32717. if (opts) retry(opts, taskFn, callback);else retry(taskFn, callback);
  32718. });
  32719. }
  32720. /**
  32721. * The same as `some` but runs a maximum of `limit` async operations at a time.
  32722. *
  32723. * @name someLimit
  32724. * @static
  32725. * @memberOf async
  32726. * @see async.some
  32727. * @alias anyLimit
  32728. * @category Collection
  32729. * @param {Array|Object} coll - A collection to iterate over.
  32730. * @param {number} limit - The maximum number of async operations at a time.
  32731. * @param {Function} iteratee - A truth test to apply to each item in the array
  32732. * in parallel. The iteratee is passed a `callback(err, truthValue)` which must
  32733. * be called with a boolean argument once it has completed. Invoked with
  32734. * (item, callback).
  32735. * @param {Function} [callback] - A callback which is called as soon as any
  32736. * iteratee returns `true`, or after all the iteratee functions have finished.
  32737. * Result will be either `true` or `false` depending on the values of the async
  32738. * tests. Invoked with (err, result).
  32739. */
  32740. var someLimit = _createTester(eachOfLimit, Boolean, identity);
  32741. /**
  32742. * Returns `true` if at least one element in the `coll` satisfies an async test.
  32743. * If any iteratee call returns `true`, the main `callback` is immediately
  32744. * called.
  32745. *
  32746. * @name some
  32747. * @static
  32748. * @memberOf async
  32749. * @alias any
  32750. * @category Collection
  32751. * @param {Array|Object} coll - A collection to iterate over.
  32752. * @param {Function} iteratee - A truth test to apply to each item in the array
  32753. * in parallel. The iteratee is passed a `callback(err, truthValue)` which must
  32754. * be called with a boolean argument once it has completed. Invoked with
  32755. * (item, callback).
  32756. * @param {Function} [callback] - A callback which is called as soon as any
  32757. * iteratee returns `true`, or after all the iteratee functions have finished.
  32758. * Result will be either `true` or `false` depending on the values of the async
  32759. * tests. Invoked with (err, result).
  32760. * @example
  32761. *
  32762. * async.some(['file1','file2','file3'], function(filePath, callback) {
  32763. * fs.access(filePath, function(err) {
  32764. * callback(null, !err)
  32765. * });
  32766. * }, function(err, result) {
  32767. * // if result is true then at least one of the files exists
  32768. * });
  32769. */
  32770. var some = doLimit(someLimit, Infinity);
  32771. /**
  32772. * The same as `some` but runs only a single async operation at a time.
  32773. *
  32774. * @name someSeries
  32775. * @static
  32776. * @memberOf async
  32777. * @see async.some
  32778. * @alias anySeries
  32779. * @category Collection
  32780. * @param {Array|Object} coll - A collection to iterate over.
  32781. * @param {Function} iteratee - A truth test to apply to each item in the array
  32782. * in parallel. The iteratee is passed a `callback(err, truthValue)` which must
  32783. * be called with a boolean argument once it has completed. Invoked with
  32784. * (item, callback).
  32785. * @param {Function} [callback] - A callback which is called as soon as any
  32786. * iteratee returns `true`, or after all the iteratee functions have finished.
  32787. * Result will be either `true` or `false` depending on the values of the async
  32788. * tests. Invoked with (err, result).
  32789. */
  32790. var someSeries = doLimit(someLimit, 1);
  32791. /**
  32792. * Sorts a list by the results of running each `coll` value through an async
  32793. * `iteratee`.
  32794. *
  32795. * @name sortBy
  32796. * @static
  32797. * @memberOf async
  32798. * @category Collection
  32799. * @param {Array|Object} coll - A collection to iterate over.
  32800. * @param {Function} iteratee - A function to apply to each item in `coll`.
  32801. * The iteratee is passed a `callback(err, sortValue)` which must be called once
  32802. * it has completed with an error (which can be `null`) and a value to use as
  32803. * the sort criteria. Invoked with (item, callback).
  32804. * @param {Function} [callback] - A callback which is called after all the
  32805. * `iteratee` functions have finished, or an error occurs. Results is the items
  32806. * from the original `coll` sorted by the values returned by the `iteratee`
  32807. * calls. Invoked with (err, results).
  32808. * @example
  32809. *
  32810. * async.sortBy(['file1','file2','file3'], function(file, callback) {
  32811. * fs.stat(file, function(err, stats) {
  32812. * callback(err, stats.mtime);
  32813. * });
  32814. * }, function(err, results) {
  32815. * // results is now the original array of files sorted by
  32816. * // modified date
  32817. * });
  32818. *
  32819. * // By modifying the callback parameter the
  32820. * // sorting order can be influenced:
  32821. *
  32822. * // ascending order
  32823. * async.sortBy([1,9,3,5], function(x, callback) {
  32824. * callback(null, x);
  32825. * }, function(err,result) {
  32826. * // result callback
  32827. * });
  32828. *
  32829. * // descending order
  32830. * async.sortBy([1,9,3,5], function(x, callback) {
  32831. * callback(null, x*-1); //<- x*-1 instead of x, turns the order around
  32832. * }, function(err,result) {
  32833. * // result callback
  32834. * });
  32835. */
  32836. function sortBy(arr, iteratee, cb) {
  32837. map(arr, function (x, cb) {
  32838. iteratee(x, function (err, criteria) {
  32839. if (err) return cb(err);
  32840. cb(null, { value: x, criteria: criteria });
  32841. });
  32842. }, function (err, results) {
  32843. if (err) return cb(err);
  32844. cb(null, arrayMap(results.sort(comparator), baseProperty('value')));
  32845. });
  32846. function comparator(left, right) {
  32847. var a = left.criteria,
  32848. b = right.criteria;
  32849. return a < b ? -1 : a > b ? 1 : 0;
  32850. }
  32851. }
  32852. /**
  32853. * Sets a time limit on an asynchronous function. If the function does not call
  32854. * its callback within the specified miliseconds, it will be called with a
  32855. * timeout error. The code property for the error object will be `'ETIMEDOUT'`.
  32856. *
  32857. * @name timeout
  32858. * @static
  32859. * @memberOf async
  32860. * @category Util
  32861. * @param {Function} function - The asynchronous function you want to set the
  32862. * time limit.
  32863. * @param {number} miliseconds - The specified time limit.
  32864. * @param {*} [info] - Any variable you want attached (`string`, `object`, etc)
  32865. * to timeout Error for more information..
  32866. * @returns {Function} Returns a wrapped function that can be used with any of
  32867. * the control flow functions.
  32868. * @example
  32869. *
  32870. * async.timeout(function(callback) {
  32871. * doAsyncTask(callback);
  32872. * }, 1000);
  32873. */
  32874. function timeout(asyncFn, miliseconds, info) {
  32875. var originalCallback, timer;
  32876. var timedOut = false;
  32877. function injectedCallback() {
  32878. if (!timedOut) {
  32879. originalCallback.apply(null, arguments);
  32880. clearTimeout(timer);
  32881. }
  32882. }
  32883. function timeoutCallback() {
  32884. var name = asyncFn.name || 'anonymous';
  32885. var error = new Error('Callback function "' + name + '" timed out.');
  32886. error.code = 'ETIMEDOUT';
  32887. if (info) {
  32888. error.info = info;
  32889. }
  32890. timedOut = true;
  32891. originalCallback(error);
  32892. }
  32893. return initialParams(function (args, origCallback) {
  32894. originalCallback = origCallback;
  32895. // setup timer and call original function
  32896. timer = setTimeout(timeoutCallback, miliseconds);
  32897. asyncFn.apply(null, args.concat(injectedCallback));
  32898. });
  32899. }
  32900. /* Built-in method references for those with the same name as other `lodash` methods. */
  32901. var nativeCeil = Math.ceil;
  32902. var nativeMax$1 = Math.max;
  32903. /**
  32904. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  32905. * coerce arguments to numbers.
  32906. *
  32907. * @private
  32908. * @param {number} start The start of the range.
  32909. * @param {number} end The end of the range.
  32910. * @param {number} step The value to increment or decrement by.
  32911. * @param {boolean} [fromRight] Specify iterating from right to left.
  32912. * @returns {Array} Returns the range of numbers.
  32913. */
  32914. function baseRange(start, end, step, fromRight) {
  32915. var index = -1,
  32916. length = nativeMax$1(nativeCeil((end - start) / (step || 1)), 0),
  32917. result = Array(length);
  32918. while (length--) {
  32919. result[fromRight ? length : ++index] = start;
  32920. start += step;
  32921. }
  32922. return result;
  32923. }
  32924. /**
  32925. * The same as {@link times} but runs a maximum of `limit` async operations at a
  32926. * time.
  32927. *
  32928. * @name timesLimit
  32929. * @static
  32930. * @memberOf async
  32931. * @see async.times
  32932. * @category Control Flow
  32933. * @param {number} n - The number of times to run the function.
  32934. * @param {number} limit - The maximum number of async operations at a time.
  32935. * @param {Function} iteratee - The function to call `n` times. Invoked with the
  32936. * iteration index and a callback (n, next).
  32937. * @param {Function} callback - see {@link async.map}.
  32938. */
  32939. function timeLimit(count, limit, iteratee, cb) {
  32940. return mapLimit(baseRange(0, count, 1), limit, iteratee, cb);
  32941. }
  32942. /**
  32943. * Calls the `iteratee` function `n` times, and accumulates results in the same
  32944. * manner you would use with {@link async.map}.
  32945. *
  32946. * @name times
  32947. * @static
  32948. * @memberOf async
  32949. * @see async.map
  32950. * @category Control Flow
  32951. * @param {number} n - The number of times to run the function.
  32952. * @param {Function} iteratee - The function to call `n` times. Invoked with the
  32953. * iteration index and a callback (n, next).
  32954. * @param {Function} callback - see {@link async.map}.
  32955. * @example
  32956. *
  32957. * // Pretend this is some complicated async factory
  32958. * var createUser = function(id, callback) {
  32959. * callback(null, {
  32960. * id: 'user' + id
  32961. * });
  32962. * };
  32963. *
  32964. * // generate 5 users
  32965. * async.times(5, function(n, next) {
  32966. * createUser(n, function(err, user) {
  32967. * next(err, user);
  32968. * });
  32969. * }, function(err, users) {
  32970. * // we should now have 5 users
  32971. * });
  32972. */
  32973. var times = doLimit(timeLimit, Infinity);
  32974. /**
  32975. * The same as {@link async.times} but runs only a single async operation at a time.
  32976. *
  32977. * @name timesSeries
  32978. * @static
  32979. * @memberOf async
  32980. * @see async.times
  32981. * @category Control Flow
  32982. * @param {number} n - The number of times to run the function.
  32983. * @param {Function} iteratee - The function to call `n` times. Invoked with the
  32984. * iteration index and a callback (n, next).
  32985. * @param {Function} callback - see {@link async.map}.
  32986. */
  32987. var timesSeries = doLimit(timeLimit, 1);
  32988. /**
  32989. * A relative of `reduce`. Takes an Object or Array, and iterates over each
  32990. * element in series, each step potentially mutating an `accumulator` value.
  32991. * The type of the accumulator defaults to the type of collection passed in.
  32992. *
  32993. * @name transform
  32994. * @static
  32995. * @memberOf async
  32996. * @category Collection
  32997. * @param {Array|Object} coll - A collection to iterate over.
  32998. * @param {*} [accumulator] - The initial state of the transform. If omitted,
  32999. * it will default to an empty Object or Array, depending on the type of `coll`
  33000. * @param {Function} iteratee - A function applied to each item in the
  33001. * collection that potentially modifies the accumulator. The `iteratee` is
  33002. * passed a `callback(err)` which accepts an optional error as its first
  33003. * argument. If an error is passed to the callback, the transform is stopped
  33004. * and the main `callback` is immediately called with the error.
  33005. * Invoked with (accumulator, item, key, callback).
  33006. * @param {Function} [callback] - A callback which is called after all the
  33007. * `iteratee` functions have finished. Result is the transformed accumulator.
  33008. * Invoked with (err, result).
  33009. * @example
  33010. *
  33011. * async.transform([1,2,3], function(acc, item, index, callback) {
  33012. * // pointless async:
  33013. * process.nextTick(function() {
  33014. * acc.push(item * 2)
  33015. * callback(null)
  33016. * });
  33017. * }, function(err, result) {
  33018. * // result is now equal to [2, 4, 6]
  33019. * });
  33020. *
  33021. * @example
  33022. *
  33023. * async.transform({a: 1, b: 2, c: 3}, function (obj, val, key, callback) {
  33024. * setImmediate(function () {
  33025. * obj[key] = val * 2;
  33026. * callback();
  33027. * })
  33028. * }, function (err, result) {
  33029. * // result is equal to {a: 2, b: 4, c: 6}
  33030. * })
  33031. */
  33032. function transform(arr, acc, iteratee, callback) {
  33033. if (arguments.length === 3) {
  33034. callback = iteratee;
  33035. iteratee = acc;
  33036. acc = isArray(arr) ? [] : {};
  33037. }
  33038. eachOf(arr, function (v, k, cb) {
  33039. iteratee(acc, v, k, cb);
  33040. }, function (err) {
  33041. callback(err, acc);
  33042. });
  33043. }
  33044. /**
  33045. * Undoes a {@link async.memoize}d function, reverting it to the original,
  33046. * unmemoized form. Handy for testing.
  33047. *
  33048. * @name unmemoize
  33049. * @static
  33050. * @memberOf async
  33051. * @see async.memoize
  33052. * @category Util
  33053. * @param {Function} fn - the memoized function
  33054. */
  33055. function unmemoize(fn) {
  33056. return function () {
  33057. return (fn.unmemoized || fn).apply(null, arguments);
  33058. };
  33059. }
  33060. /**
  33061. * Repeatedly call `fn` until `test` returns `true`. Calls `callback` when
  33062. * stopped, or an error occurs. `callback` will be passed an error and any
  33063. * arguments passed to the final `fn`'s callback.
  33064. *
  33065. * The inverse of {@link async.whilst}.
  33066. *
  33067. * @name until
  33068. * @static
  33069. * @memberOf async
  33070. * @see async.whilst
  33071. * @category Control Flow
  33072. * @param {Function} test - synchronous truth test to perform before each
  33073. * execution of `fn`. Invoked with ().
  33074. * @param {Function} fn - A function which is called each time `test` fails.
  33075. * The function is passed a `callback(err)`, which must be called once it has
  33076. * completed with an optional `err` argument. Invoked with (callback).
  33077. * @param {Function} [callback] - A callback which is called after the test
  33078. * function has passed and repeated execution of `fn` has stopped. `callback`
  33079. * will be passed an error and any arguments passed to the final `fn`'s
  33080. * callback. Invoked with (err, [results]);
  33081. */
  33082. function until(test, iteratee, cb) {
  33083. return whilst(function () {
  33084. return !test.apply(this, arguments);
  33085. }, iteratee, cb);
  33086. }
  33087. /**
  33088. * Runs the `tasks` array of functions in series, each passing their results to
  33089. * the next in the array. However, if any of the `tasks` pass an error to their
  33090. * own callback, the next function is not executed, and the main `callback` is
  33091. * immediately called with the error.
  33092. *
  33093. * @name waterfall
  33094. * @static
  33095. * @memberOf async
  33096. * @category Control Flow
  33097. * @param {Array} tasks - An array of functions to run, each function is passed
  33098. * a `callback(err, result1, result2, ...)` it must call on completion. The
  33099. * first argument is an error (which can be `null`) and any further arguments
  33100. * will be passed as arguments in order to the next task.
  33101. * @param {Function} [callback] - An optional callback to run once all the
  33102. * functions have completed. This will be passed the results of the last task's
  33103. * callback. Invoked with (err, [results]).
  33104. * @example
  33105. *
  33106. * async.waterfall([
  33107. * function(callback) {
  33108. * callback(null, 'one', 'two');
  33109. * },
  33110. * function(arg1, arg2, callback) {
  33111. * // arg1 now equals 'one' and arg2 now equals 'two'
  33112. * callback(null, 'three');
  33113. * },
  33114. * function(arg1, callback) {
  33115. * // arg1 now equals 'three'
  33116. * callback(null, 'done');
  33117. * }
  33118. * ], function (err, result) {
  33119. * // result now equals 'done'
  33120. * });
  33121. *
  33122. * // Or, with named functions:
  33123. * async.waterfall([
  33124. * myFirstFunction,
  33125. * mySecondFunction,
  33126. * myLastFunction,
  33127. * ], function (err, result) {
  33128. * // result now equals 'done'
  33129. * });
  33130. * function myFirstFunction(callback) {
  33131. * callback(null, 'one', 'two');
  33132. * }
  33133. * function mySecondFunction(arg1, arg2, callback) {
  33134. * // arg1 now equals 'one' and arg2 now equals 'two'
  33135. * callback(null, 'three');
  33136. * }
  33137. * function myLastFunction(arg1, callback) {
  33138. * // arg1 now equals 'three'
  33139. * callback(null, 'done');
  33140. * }
  33141. */
  33142. function waterfall (tasks, cb) {
  33143. cb = once(cb || noop);
  33144. if (!isArray(tasks)) return cb(new Error('First argument to waterfall must be an array of functions'));
  33145. if (!tasks.length) return cb();
  33146. var taskIndex = 0;
  33147. function nextTask(args) {
  33148. if (taskIndex === tasks.length) {
  33149. return cb.apply(null, [null].concat(args));
  33150. }
  33151. var taskCallback = onlyOnce(rest(function (err, args) {
  33152. if (err) {
  33153. return cb.apply(null, [err].concat(args));
  33154. }
  33155. nextTask(args);
  33156. }));
  33157. args.push(taskCallback);
  33158. var task = tasks[taskIndex++];
  33159. task.apply(null, args);
  33160. }
  33161. nextTask([]);
  33162. }
  33163. var index = {
  33164. applyEach: applyEach,
  33165. applyEachSeries: applyEachSeries,
  33166. apply: apply$1,
  33167. asyncify: asyncify,
  33168. auto: auto,
  33169. autoInject: autoInject,
  33170. cargo: cargo,
  33171. compose: compose,
  33172. concat: concat,
  33173. concatSeries: concatSeries,
  33174. constant: constant,
  33175. detect: detect,
  33176. detectLimit: detectLimit,
  33177. detectSeries: detectSeries,
  33178. dir: dir,
  33179. doDuring: doDuring,
  33180. doUntil: doUntil,
  33181. doWhilst: doWhilst,
  33182. during: during,
  33183. each: each,
  33184. eachLimit: eachLimit,
  33185. eachOf: eachOf,
  33186. eachOfLimit: eachOfLimit,
  33187. eachOfSeries: eachOfSeries,
  33188. eachSeries: eachSeries,
  33189. ensureAsync: ensureAsync,
  33190. every: every,
  33191. everyLimit: everyLimit,
  33192. everySeries: everySeries,
  33193. filter: filter,
  33194. filterLimit: filterLimit,
  33195. filterSeries: filterSeries,
  33196. forever: forever,
  33197. iterator: iterator$1,
  33198. log: log,
  33199. map: map,
  33200. mapLimit: mapLimit,
  33201. mapSeries: mapSeries,
  33202. mapValues: mapValues,
  33203. mapValuesLimit: mapValuesLimit,
  33204. mapValuesSeries: mapValuesSeries,
  33205. memoize: memoize$1,
  33206. nextTick: nextTick,
  33207. parallel: parallel,
  33208. parallelLimit: parallelLimit,
  33209. priorityQueue: priorityQueue,
  33210. queue: queue$1,
  33211. race: race,
  33212. reduce: reduce,
  33213. reduceRight: reduceRight,
  33214. reflect: reflect,
  33215. reflectAll: reflectAll,
  33216. reject: reject,
  33217. rejectLimit: rejectLimit,
  33218. rejectSeries: rejectSeries,
  33219. retry: retry,
  33220. retryable: retryable,
  33221. seq: seq,
  33222. series: series,
  33223. setImmediate: setImmediate$1,
  33224. some: some,
  33225. someLimit: someLimit,
  33226. someSeries: someSeries,
  33227. sortBy: sortBy,
  33228. timeout: timeout,
  33229. times: times,
  33230. timesLimit: timeLimit,
  33231. timesSeries: timesSeries,
  33232. transform: transform,
  33233. unmemoize: unmemoize,
  33234. until: until,
  33235. waterfall: waterfall,
  33236. whilst: whilst,
  33237. // aliases
  33238. all: every,
  33239. any: some,
  33240. forEach: each,
  33241. forEachSeries: eachSeries,
  33242. forEachLimit: eachLimit,
  33243. forEachOf: eachOf,
  33244. forEachOfSeries: eachOfSeries,
  33245. forEachOfLimit: eachOfLimit,
  33246. inject: reduce,
  33247. foldl: reduce,
  33248. foldr: reduceRight,
  33249. select: filter,
  33250. selectLimit: filterLimit,
  33251. selectSeries: filterSeries,
  33252. wrapSync: asyncify
  33253. };
  33254. exports['default'] = index;
  33255. exports.applyEach = applyEach;
  33256. exports.applyEachSeries = applyEachSeries;
  33257. exports.apply = apply$1;
  33258. exports.asyncify = asyncify;
  33259. exports.auto = auto;
  33260. exports.autoInject = autoInject;
  33261. exports.cargo = cargo;
  33262. exports.compose = compose;
  33263. exports.concat = concat;
  33264. exports.concatSeries = concatSeries;
  33265. exports.constant = constant;
  33266. exports.detect = detect;
  33267. exports.detectLimit = detectLimit;
  33268. exports.detectSeries = detectSeries;
  33269. exports.dir = dir;
  33270. exports.doDuring = doDuring;
  33271. exports.doUntil = doUntil;
  33272. exports.doWhilst = doWhilst;
  33273. exports.during = during;
  33274. exports.each = each;
  33275. exports.eachLimit = eachLimit;
  33276. exports.eachOf = eachOf;
  33277. exports.eachOfLimit = eachOfLimit;
  33278. exports.eachOfSeries = eachOfSeries;
  33279. exports.eachSeries = eachSeries;
  33280. exports.ensureAsync = ensureAsync;
  33281. exports.every = every;
  33282. exports.everyLimit = everyLimit;
  33283. exports.everySeries = everySeries;
  33284. exports.filter = filter;
  33285. exports.filterLimit = filterLimit;
  33286. exports.filterSeries = filterSeries;
  33287. exports.forever = forever;
  33288. exports.iterator = iterator$1;
  33289. exports.log = log;
  33290. exports.map = map;
  33291. exports.mapLimit = mapLimit;
  33292. exports.mapSeries = mapSeries;
  33293. exports.mapValues = mapValues;
  33294. exports.mapValuesLimit = mapValuesLimit;
  33295. exports.mapValuesSeries = mapValuesSeries;
  33296. exports.memoize = memoize$1;
  33297. exports.nextTick = nextTick;
  33298. exports.parallel = parallel;
  33299. exports.parallelLimit = parallelLimit;
  33300. exports.priorityQueue = priorityQueue;
  33301. exports.queue = queue$1;
  33302. exports.race = race;
  33303. exports.reduce = reduce;
  33304. exports.reduceRight = reduceRight;
  33305. exports.reflect = reflect;
  33306. exports.reflectAll = reflectAll;
  33307. exports.reject = reject;
  33308. exports.rejectLimit = rejectLimit;
  33309. exports.rejectSeries = rejectSeries;
  33310. exports.retry = retry;
  33311. exports.retryable = retryable;
  33312. exports.seq = seq;
  33313. exports.series = series;
  33314. exports.setImmediate = setImmediate$1;
  33315. exports.some = some;
  33316. exports.someLimit = someLimit;
  33317. exports.someSeries = someSeries;
  33318. exports.sortBy = sortBy;
  33319. exports.timeout = timeout;
  33320. exports.times = times;
  33321. exports.timesLimit = timeLimit;
  33322. exports.timesSeries = timesSeries;
  33323. exports.transform = transform;
  33324. exports.unmemoize = unmemoize;
  33325. exports.until = until;
  33326. exports.waterfall = waterfall;
  33327. exports.whilst = whilst;
  33328. exports.all = every;
  33329. exports.allLimit = everyLimit;
  33330. exports.allSeries = everySeries;
  33331. exports.any = some;
  33332. exports.anyLimit = someLimit;
  33333. exports.anySeries = someSeries;
  33334. exports.find = detect;
  33335. exports.findLimit = detectLimit;
  33336. exports.findSeries = detectSeries;
  33337. exports.forEach = each;
  33338. exports.forEachSeries = eachSeries;
  33339. exports.forEachLimit = eachLimit;
  33340. exports.forEachOf = eachOf;
  33341. exports.forEachOfSeries = eachOfSeries;
  33342. exports.forEachOfLimit = eachOfLimit;
  33343. exports.inject = reduce;
  33344. exports.foldl = reduce;
  33345. exports.foldr = reduceRight;
  33346. exports.select = filter;
  33347. exports.selectLimit = filterLimit;
  33348. exports.selectSeries = filterSeries;
  33349. exports.wrapSync = asyncify;
  33350. }));
  33351. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(13), __webpack_require__(74).setImmediate, __webpack_require__(4)))
  33352. /***/ },
  33353. /* 146 */
  33354. /***/ function(module, exports, __webpack_require__) {
  33355. "use strict";
  33356. 'use strict';
  33357. // Load modules
  33358. var Hoek = __webpack_require__(68);
  33359. // Declare internals
  33360. var internals = {
  33361. STATUS_CODES: Object.setPrototypeOf({
  33362. '100': 'Continue',
  33363. '101': 'Switching Protocols',
  33364. '102': 'Processing',
  33365. '200': 'OK',
  33366. '201': 'Created',
  33367. '202': 'Accepted',
  33368. '203': 'Non-Authoritative Information',
  33369. '204': 'No Content',
  33370. '205': 'Reset Content',
  33371. '206': 'Partial Content',
  33372. '207': 'Multi-Status',
  33373. '300': 'Multiple Choices',
  33374. '301': 'Moved Permanently',
  33375. '302': 'Moved Temporarily',
  33376. '303': 'See Other',
  33377. '304': 'Not Modified',
  33378. '305': 'Use Proxy',
  33379. '307': 'Temporary Redirect',
  33380. '400': 'Bad Request',
  33381. '401': 'Unauthorized',
  33382. '402': 'Payment Required',
  33383. '403': 'Forbidden',
  33384. '404': 'Not Found',
  33385. '405': 'Method Not Allowed',
  33386. '406': 'Not Acceptable',
  33387. '407': 'Proxy Authentication Required',
  33388. '408': 'Request Time-out',
  33389. '409': 'Conflict',
  33390. '410': 'Gone',
  33391. '411': 'Length Required',
  33392. '412': 'Precondition Failed',
  33393. '413': 'Request Entity Too Large',
  33394. '414': 'Request-URI Too Large',
  33395. '415': 'Unsupported Media Type',
  33396. '416': 'Requested Range Not Satisfiable',
  33397. '417': 'Expectation Failed',
  33398. '418': 'I\'m a teapot',
  33399. '422': 'Unprocessable Entity',
  33400. '423': 'Locked',
  33401. '424': 'Failed Dependency',
  33402. '425': 'Unordered Collection',
  33403. '426': 'Upgrade Required',
  33404. '428': 'Precondition Required',
  33405. '429': 'Too Many Requests',
  33406. '431': 'Request Header Fields Too Large',
  33407. '451': 'Unavailable For Legal Reasons',
  33408. '500': 'Internal Server Error',
  33409. '501': 'Not Implemented',
  33410. '502': 'Bad Gateway',
  33411. '503': 'Service Unavailable',
  33412. '504': 'Gateway Time-out',
  33413. '505': 'HTTP Version Not Supported',
  33414. '506': 'Variant Also Negotiates',
  33415. '507': 'Insufficient Storage',
  33416. '509': 'Bandwidth Limit Exceeded',
  33417. '510': 'Not Extended',
  33418. '511': 'Network Authentication Required'
  33419. }, null)
  33420. };
  33421. exports.wrap = function (error, statusCode, message) {
  33422. Hoek.assert(error instanceof Error, 'Cannot wrap non-Error object');
  33423. return error.isBoom ? error : internals.initialize(error, statusCode || 500, message);
  33424. };
  33425. exports.create = function (statusCode, message, data) {
  33426. return internals.create(statusCode, message, data, exports.create);
  33427. };
  33428. internals.create = function (statusCode, message, data, ctor) {
  33429. var error = new Error(message ? message : undefined); // Avoids settings null message
  33430. Error.captureStackTrace(error, ctor); // Filter the stack to our external API
  33431. error.data = data || null;
  33432. internals.initialize(error, statusCode);
  33433. return error;
  33434. };
  33435. internals.initialize = function (error, statusCode, message) {
  33436. var numberCode = parseInt(statusCode, 10);
  33437. Hoek.assert(!isNaN(numberCode) && numberCode >= 400, 'First argument must be a number (400+):', statusCode);
  33438. error.isBoom = true;
  33439. error.isServer = numberCode >= 500;
  33440. if (!error.hasOwnProperty('data')) {
  33441. error.data = null;
  33442. }
  33443. error.output = {
  33444. statusCode: numberCode,
  33445. payload: {},
  33446. headers: {}
  33447. };
  33448. error.reformat = internals.reformat;
  33449. error.reformat();
  33450. if (!message && !error.message) {
  33451. message = error.output.payload.error;
  33452. }
  33453. if (message) {
  33454. error.message = message + (error.message ? ': ' + error.message : '');
  33455. }
  33456. return error;
  33457. };
  33458. internals.reformat = function () {
  33459. this.output.payload.statusCode = this.output.statusCode;
  33460. this.output.payload.error = internals.STATUS_CODES[this.output.statusCode] || 'Unknown';
  33461. if (this.output.statusCode === 500) {
  33462. this.output.payload.message = 'An internal server error occurred'; // Hide actual error from user
  33463. } else if (this.message) {
  33464. this.output.payload.message = this.message;
  33465. }
  33466. };
  33467. // 4xx Client Errors
  33468. exports.badRequest = function (message, data) {
  33469. return internals.create(400, message, data, exports.badRequest);
  33470. };
  33471. exports.unauthorized = function (message, scheme, attributes) {
  33472. // Or function (message, wwwAuthenticate[])
  33473. var err = internals.create(401, message, undefined, exports.unauthorized);
  33474. if (!scheme) {
  33475. return err;
  33476. }
  33477. var wwwAuthenticate = '';
  33478. if (typeof scheme === 'string') {
  33479. // function (message, scheme, attributes)
  33480. wwwAuthenticate = scheme;
  33481. if (attributes || message) {
  33482. err.output.payload.attributes = {};
  33483. }
  33484. if (attributes) {
  33485. var names = Object.keys(attributes);
  33486. for (var i = 0; i < names.length; ++i) {
  33487. var name = names[i];
  33488. if (i) {
  33489. wwwAuthenticate = wwwAuthenticate + ',';
  33490. }
  33491. var value = attributes[name];
  33492. if (value === null || value === undefined) {
  33493. // Value can be zero
  33494. value = '';
  33495. }
  33496. wwwAuthenticate = wwwAuthenticate + ' ' + name + '="' + Hoek.escapeHeaderAttribute(value.toString()) + '"';
  33497. err.output.payload.attributes[name] = value;
  33498. }
  33499. }
  33500. if (message) {
  33501. if (attributes) {
  33502. wwwAuthenticate = wwwAuthenticate + ',';
  33503. }
  33504. wwwAuthenticate = wwwAuthenticate + ' error="' + Hoek.escapeHeaderAttribute(message) + '"';
  33505. err.output.payload.attributes.error = message;
  33506. } else {
  33507. err.isMissing = true;
  33508. }
  33509. } else {
  33510. // function (message, wwwAuthenticate[])
  33511. var wwwArray = scheme;
  33512. for (var _i = 0; _i < wwwArray.length; ++_i) {
  33513. if (_i) {
  33514. wwwAuthenticate = wwwAuthenticate + ', ';
  33515. }
  33516. wwwAuthenticate = wwwAuthenticate + wwwArray[_i];
  33517. }
  33518. }
  33519. err.output.headers['WWW-Authenticate'] = wwwAuthenticate;
  33520. return err;
  33521. };
  33522. exports.forbidden = function (message, data) {
  33523. return internals.create(403, message, data, exports.forbidden);
  33524. };
  33525. exports.notFound = function (message, data) {
  33526. return internals.create(404, message, data, exports.notFound);
  33527. };
  33528. exports.methodNotAllowed = function (message, data) {
  33529. return internals.create(405, message, data, exports.methodNotAllowed);
  33530. };
  33531. exports.notAcceptable = function (message, data) {
  33532. return internals.create(406, message, data, exports.notAcceptable);
  33533. };
  33534. exports.proxyAuthRequired = function (message, data) {
  33535. return internals.create(407, message, data, exports.proxyAuthRequired);
  33536. };
  33537. exports.clientTimeout = function (message, data) {
  33538. return internals.create(408, message, data, exports.clientTimeout);
  33539. };
  33540. exports.conflict = function (message, data) {
  33541. return internals.create(409, message, data, exports.conflict);
  33542. };
  33543. exports.resourceGone = function (message, data) {
  33544. return internals.create(410, message, data, exports.resourceGone);
  33545. };
  33546. exports.lengthRequired = function (message, data) {
  33547. return internals.create(411, message, data, exports.lengthRequired);
  33548. };
  33549. exports.preconditionFailed = function (message, data) {
  33550. return internals.create(412, message, data, exports.preconditionFailed);
  33551. };
  33552. exports.entityTooLarge = function (message, data) {
  33553. return internals.create(413, message, data, exports.entityTooLarge);
  33554. };
  33555. exports.uriTooLong = function (message, data) {
  33556. return internals.create(414, message, data, exports.uriTooLong);
  33557. };
  33558. exports.unsupportedMediaType = function (message, data) {
  33559. return internals.create(415, message, data, exports.unsupportedMediaType);
  33560. };
  33561. exports.rangeNotSatisfiable = function (message, data) {
  33562. return internals.create(416, message, data, exports.rangeNotSatisfiable);
  33563. };
  33564. exports.expectationFailed = function (message, data) {
  33565. return internals.create(417, message, data, exports.expectationFailed);
  33566. };
  33567. exports.badData = function (message, data) {
  33568. return internals.create(422, message, data, exports.badData);
  33569. };
  33570. exports.locked = function (message, data) {
  33571. return internals.create(423, message, data, exports.locked);
  33572. };
  33573. exports.preconditionRequired = function (message, data) {
  33574. return internals.create(428, message, data, exports.preconditionRequired);
  33575. };
  33576. exports.tooManyRequests = function (message, data) {
  33577. return internals.create(429, message, data, exports.tooManyRequests);
  33578. };
  33579. exports.illegal = function (message, data) {
  33580. return internals.create(451, message, data, exports.illegal);
  33581. };
  33582. // 5xx Server Errors
  33583. exports.internal = function (message, data, statusCode) {
  33584. return internals.serverError(message, data, statusCode, exports.internal);
  33585. };
  33586. internals.serverError = function (message, data, statusCode, ctor) {
  33587. var error = void 0;
  33588. if (data instanceof Error) {
  33589. error = exports.wrap(data, statusCode, message);
  33590. } else {
  33591. error = internals.create(statusCode || 500, message, undefined, ctor);
  33592. error.data = data;
  33593. }
  33594. return error;
  33595. };
  33596. exports.notImplemented = function (message, data) {
  33597. return internals.serverError(message, data, 501, exports.notImplemented);
  33598. };
  33599. exports.badGateway = function (message, data) {
  33600. return internals.serverError(message, data, 502, exports.badGateway);
  33601. };
  33602. exports.serverUnavailable = function (message, data) {
  33603. return internals.serverError(message, data, 503, exports.serverUnavailable);
  33604. };
  33605. // Deprecated
  33606. exports.serverTimeout = exports.serverUnavailable;
  33607. exports.gatewayTimeout = function (message, data) {
  33608. return internals.serverError(message, data, 504, exports.gatewayTimeout);
  33609. };
  33610. exports.badImplementation = function (message, data) {
  33611. var err = internals.serverError(message, data, 500, exports.badImplementation);
  33612. err.isDeveloperError = true;
  33613. return err;
  33614. };
  33615. /***/ },
  33616. /* 147 */
  33617. /***/ function(module, exports, __webpack_require__) {
  33618. "use strict";
  33619. /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
  33620. var util = __webpack_require__(244);
  33621. // Immutable block of data
  33622. function Block(data, type) {
  33623. if (!data) {
  33624. throw new Error('Block must be constructed with data');
  33625. }
  33626. if (!(this instanceof Block)) {
  33627. return new Block(data);
  33628. }
  33629. if (data instanceof Buffer) {
  33630. this.data = data;
  33631. } else {
  33632. this.data = new Buffer(data);
  33633. }
  33634. this.key = util.hash(this.data);
  33635. this.type = type || 'protobuf';
  33636. }
  33637. Object.defineProperty(Block.prototype, 'extension', {
  33638. get: function get() {
  33639. switch (this.type) {
  33640. case 'protobuf':
  33641. return 'data';
  33642. case 'ipld':
  33643. return 'ipld';
  33644. default:
  33645. return this.type;
  33646. }
  33647. }
  33648. });
  33649. module.exports = Block;
  33650. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  33651. /***/ },
  33652. /* 148 */
  33653. /***/ function(module, exports, __webpack_require__) {
  33654. "use strict";
  33655. /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
  33656. var _createClass = function () {
  33657. function defineProperties(target, props) {
  33658. for (var i = 0; i < props.length; i++) {
  33659. 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);
  33660. }
  33661. }return function (Constructor, protoProps, staticProps) {
  33662. if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;
  33663. };
  33664. }();
  33665. function _classCallCheck(instance, Constructor) {
  33666. if (!(instance instanceof Constructor)) {
  33667. throw new TypeError("Cannot call a class as a function");
  33668. }
  33669. }
  33670. var mh = __webpack_require__(96);
  33671. // Link represents an IPFS Merkle DAG Link between Nodes.
  33672. module.exports = function () {
  33673. function DAGLink(name, size, hash) {
  33674. _classCallCheck(this, DAGLink);
  33675. this.name = name;
  33676. this.size = size;
  33677. if (typeof hash === 'string') {
  33678. this.hash = mh.fromB58String(hash);
  33679. } else if (Buffer.isBuffer(hash)) {
  33680. this.hash = hash;
  33681. }
  33682. }
  33683. _createClass(DAGLink, [{
  33684. key: 'toJSON',
  33685. value: function toJSON() {
  33686. return {
  33687. Name: this.name,
  33688. Size: this.size,
  33689. Hash: mh.toB58String(this.hash)
  33690. };
  33691. }
  33692. }, {
  33693. key: 'toString',
  33694. value: function toString() {
  33695. var hash = mh.toB58String(this.hash);
  33696. return 'DAGLink <' + hash + ' - name: "' + this.name + '", size: ' + this.size + '>';
  33697. }
  33698. }]);
  33699. return DAGLink;
  33700. }();
  33701. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  33702. /***/ },
  33703. /* 149 */
  33704. /***/ function(module, exports, __webpack_require__) {
  33705. "use strict";
  33706. /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
  33707. var _createClass = function () {
  33708. function defineProperties(target, props) {
  33709. for (var i = 0; i < props.length; i++) {
  33710. 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);
  33711. }
  33712. }return function (Constructor, protoProps, staticProps) {
  33713. if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;
  33714. };
  33715. }();
  33716. function _classCallCheck(instance, Constructor) {
  33717. if (!(instance instanceof Constructor)) {
  33718. throw new TypeError("Cannot call a class as a function");
  33719. }
  33720. }
  33721. var protobuf = __webpack_require__(541);
  33722. var stable = __webpack_require__(573);
  33723. var path = __webpack_require__(43);
  33724. var mh = __webpack_require__(96);
  33725. var util = __webpack_require__(150);
  33726. var DAGLink = __webpack_require__(148);
  33727. var proto = protobuf(Buffer("Ly8gQW4gSVBGUyBNZXJrbGVEQUcgTGluawptZXNzYWdlIFBCTGluayB7CgogIC8vIG11bHRpaGFzaCBvZiB0aGUgdGFyZ2V0IG9iamVjdAogIG9wdGlvbmFsIGJ5dGVzIEhhc2ggPSAxOwoKICAvLyB1dGYgc3RyaW5nIG5hbWUuIHNob3VsZCBiZSB1bmlxdWUgcGVyIG9iamVjdAogIG9wdGlvbmFsIHN0cmluZyBOYW1lID0gMjsKCiAgLy8gY3VtdWxhdGl2ZSBzaXplIG9mIHRhcmdldCBvYmplY3QKICBvcHRpb25hbCB1aW50NjQgVHNpemUgPSAzOwp9CgovLyBBbiBJUEZTIE1lcmtsZURBRyBOb2RlCm1lc3NhZ2UgUEJOb2RlIHsKCiAgLy8gcmVmcyB0byBvdGhlciBvYmplY3RzCiAgcmVwZWF0ZWQgUEJMaW5rIExpbmtzID0gMjsKCiAgLy8gb3BhcXVlIHVzZXIgZGF0YQogIG9wdGlvbmFsIGJ5dGVzIERhdGEgPSAxOwp9Cg==","base64"));
  33728. function linkSort(a, b) {
  33729. return new Buffer(a.name, 'ascii').compare(new Buffer(b.name, 'ascii'));
  33730. }
  33731. // Helper method to get a protobuf object equivalent
  33732. function toProtoBuf(node) {
  33733. var pbn = {};
  33734. if (node.data && node.data.length > 0) {
  33735. pbn.Data = node.data;
  33736. } else {
  33737. pbn.Data = null; // new Buffer(0)
  33738. }
  33739. if (node.links.length > 0) {
  33740. pbn.Links = node.links.map(function (link) {
  33741. return {
  33742. Hash: link.hash,
  33743. Name: link.name,
  33744. Tsize: link.size
  33745. };
  33746. });
  33747. } else {
  33748. pbn.Links = null;
  33749. }
  33750. return pbn;
  33751. }
  33752. module.exports = function () {
  33753. function DAGNode(data, links) {
  33754. var _this = this;
  33755. _classCallCheck(this, DAGNode);
  33756. this._cached = null;
  33757. this._encoded = null;
  33758. this.data = data;
  33759. this.links = [];
  33760. // ensure links are instances of DAGLink
  33761. if (links) {
  33762. links.forEach(function (l) {
  33763. if (l.name && typeof l.toJSON === 'function') {
  33764. _this.links.push(l);
  33765. } else {
  33766. _this.links.push(new DAGLink(l.Name, l.Size, l.Hash));
  33767. }
  33768. });
  33769. stable.inplace(this.links, linkSort);
  33770. }
  33771. }
  33772. // copy - returns a clone of the DAGNode
  33773. _createClass(DAGNode, [{
  33774. key: 'copy',
  33775. value: function copy() {
  33776. var clone = new DAGNode();
  33777. if (this.data && this.data.length > 0) {
  33778. var buf = new Buffer(this.data.length);
  33779. this.data.copy(buf);
  33780. clone.data = buf;
  33781. }
  33782. if (this.links.length > 0) {
  33783. clone.links = this.links.slice();
  33784. }
  33785. return clone;
  33786. }
  33787. // addNodeLink - adds a DAGLink to this node that points to node by a name
  33788. }, {
  33789. key: 'addNodeLink',
  33790. value: function addNodeLink(name, node) {
  33791. if (typeof name !== 'string') {
  33792. return;
  33793. }
  33794. var link = this.makeLink(node);
  33795. link.name = name;
  33796. this.addRawLink(link);
  33797. }
  33798. // addRawLink adds a Link to this node from a DAGLink
  33799. }, {
  33800. key: 'addRawLink',
  33801. value: function addRawLink(link) {
  33802. this._encoded = null;
  33803. this.links.push(new DAGLink(link.name, link.size, link.hash));
  33804. stable.inplace(this.links, linkSort);
  33805. }
  33806. // UpdateNodeLink return a copy of the node with the link name set to point to
  33807. // that. If a link of the same name existed, it is replaced.
  33808. // TODO this would make more sense as an utility
  33809. }, {
  33810. key: 'updateNodeLink',
  33811. value: function updateNodeLink(name, node) {
  33812. var newnode = this.copy();
  33813. newnode.removeNodeLink(name);
  33814. newnode.addNodeLink(name, node);
  33815. return newnode;
  33816. }
  33817. // removeNodeLink removes a Link from this node based on name
  33818. }, {
  33819. key: 'removeNodeLink',
  33820. value: function removeNodeLink(name) {
  33821. this._encoded = null; // uncache
  33822. this.links = this.links.filter(function (link) {
  33823. if (link.name === name) {
  33824. return false;
  33825. } else {
  33826. return true;
  33827. }
  33828. });
  33829. }
  33830. // removeNodeLink removes a Link from this node based on a multihash
  33831. }, {
  33832. key: 'removeNodeLinkByHash',
  33833. value: function removeNodeLinkByHash(multihash) {
  33834. this._encoded = null; // uncache
  33835. this.links = this.links.filter(function (link) {
  33836. if (link.hash.equals(multihash)) {
  33837. return false;
  33838. } else {
  33839. return true;
  33840. }
  33841. });
  33842. }
  33843. // makeLink returns a DAGLink node from a DAGNode
  33844. // TODO: this would make more sense as an utility
  33845. }, {
  33846. key: 'makeLink',
  33847. value: function makeLink(node) {
  33848. return new DAGLink(null, node.size(), node.multihash());
  33849. }
  33850. // multihash - returns the multihash value of this DAGNode
  33851. }, {
  33852. key: 'multihash',
  33853. value: function multihash() {
  33854. this.encoded();
  33855. return this._cached;
  33856. }
  33857. // Size returns the total size of the data addressed by node,
  33858. // including the total sizes of references.
  33859. }, {
  33860. key: 'size',
  33861. value: function size() {
  33862. var buf = this.encoded();
  33863. if (!buf) {
  33864. return 0;
  33865. }
  33866. return this.links.reduce(function (sum, l) {
  33867. return sum + l.size;
  33868. }, buf.length);
  33869. }
  33870. // Encoded returns the encoded raw data version of a Node instance.
  33871. // It may use a cached encoded version, unless the force flag is given.
  33872. }, {
  33873. key: 'encoded',
  33874. value: function encoded(force) {
  33875. if (force || !this._encoded) {
  33876. this._encoded = this.marshal();
  33877. if (this._encoded) {
  33878. this._cached = util.hash(this._encoded);
  33879. }
  33880. }
  33881. return this._encoded;
  33882. }
  33883. // marshal - encodes the DAGNode into a probuf
  33884. }, {
  33885. key: 'marshal',
  33886. value: function marshal() {
  33887. return proto.PBNode.encode(toProtoBuf(this));
  33888. }
  33889. // unMarshal - decodes a protobuf into a DAGNode
  33890. // TODO: this would make more sense as an utility
  33891. }, {
  33892. key: 'unMarshal',
  33893. value: function unMarshal(data) {
  33894. var pbn = proto.PBNode.decode(data);
  33895. this.links = pbn.Links.map(function (link) {
  33896. return new DAGLink(link.Name, link.Tsize, link.Hash);
  33897. });
  33898. stable.inplace(this.links, linkSort);
  33899. this.data = pbn.Data || new Buffer(0);
  33900. return this;
  33901. }
  33902. }, {
  33903. key: 'toJSON',
  33904. value: function toJSON() {
  33905. return {
  33906. Data: this.data,
  33907. Links: this.links.map(function (l) {
  33908. return l.toJSON();
  33909. }),
  33910. Hash: mh.toB58String(this.multihash()),
  33911. Size: this.size()
  33912. };
  33913. }
  33914. }, {
  33915. key: 'toString',
  33916. value: function toString() {
  33917. var hash = mh.toB58String(this.multihash());
  33918. return 'DAGNode <' + hash + ' - data: "' + this.data.toString() + '", links: ' + this.links.length + ', size: ' + this.size() + '>';
  33919. }
  33920. }]);
  33921. return DAGNode;
  33922. }();
  33923. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  33924. /***/ },
  33925. /* 150 */
  33926. /***/ function(module, exports, __webpack_require__) {
  33927. "use strict";
  33928. 'use strict';
  33929. var multihashing = __webpack_require__(205);
  33930. exports = module.exports;
  33931. // Hash is the global IPFS hash function. uses multihash SHA2_256, 256 bits
  33932. exports.hash = function (data) {
  33933. return multihashing(data, 'sha2-256');
  33934. };
  33935. /***/ },
  33936. /* 151 */
  33937. /***/ function(module, exports) {
  33938. "use strict";
  33939. 'use strict';
  33940. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
  33941. var hexTable = function () {
  33942. var array = new Array(256);
  33943. for (var i = 0; i < 256; ++i) {
  33944. array[i] = '%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase();
  33945. }
  33946. return array;
  33947. }();
  33948. exports.arrayToObject = function (source, options) {
  33949. var obj = options.plainObjects ? Object.create(null) : {};
  33950. for (var i = 0; i < source.length; ++i) {
  33951. if (typeof source[i] !== 'undefined') {
  33952. obj[i] = source[i];
  33953. }
  33954. }
  33955. return obj;
  33956. };
  33957. exports.merge = function (target, source, options) {
  33958. if (!source) {
  33959. return target;
  33960. }
  33961. if ((typeof source === 'undefined' ? 'undefined' : _typeof(source)) !== 'object') {
  33962. if (Array.isArray(target)) {
  33963. target.push(source);
  33964. } else if ((typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object') {
  33965. target[source] = true;
  33966. } else {
  33967. return [target, source];
  33968. }
  33969. return target;
  33970. }
  33971. if ((typeof target === 'undefined' ? 'undefined' : _typeof(target)) !== 'object') {
  33972. return [target].concat(source);
  33973. }
  33974. var mergeTarget = target;
  33975. if (Array.isArray(target) && !Array.isArray(source)) {
  33976. mergeTarget = exports.arrayToObject(target, options);
  33977. }
  33978. return Object.keys(source).reduce(function (acc, key) {
  33979. var value = source[key];
  33980. if (Object.prototype.hasOwnProperty.call(acc, key)) {
  33981. acc[key] = exports.merge(acc[key], value, options);
  33982. } else {
  33983. acc[key] = value;
  33984. }
  33985. return acc;
  33986. }, mergeTarget);
  33987. };
  33988. exports.decode = function (str) {
  33989. try {
  33990. return decodeURIComponent(str.replace(/\+/g, ' '));
  33991. } catch (e) {
  33992. return str;
  33993. }
  33994. };
  33995. exports.encode = function (str) {
  33996. // This code was originally written by Brian White (mscdex) for the io.js core querystring library.
  33997. // It has been adapted here for stricter adherence to RFC 3986
  33998. if (str.length === 0) {
  33999. return str;
  34000. }
  34001. var string = typeof str === 'string' ? str : String(str);
  34002. var out = '';
  34003. for (var i = 0; i < string.length; ++i) {
  34004. var c = string.charCodeAt(i);
  34005. if (c === 0x2D || // -
  34006. c === 0x2E || // .
  34007. c === 0x5F || // _
  34008. c === 0x7E || // ~
  34009. c >= 0x30 && c <= 0x39 || // 0-9
  34010. c >= 0x41 && c <= 0x5A || // a-z
  34011. c >= 0x61 && c <= 0x7A // A-Z
  34012. ) {
  34013. out += string.charAt(i);
  34014. continue;
  34015. }
  34016. if (c < 0x80) {
  34017. out = out + hexTable[c];
  34018. continue;
  34019. }
  34020. if (c < 0x800) {
  34021. out = out + (hexTable[0xC0 | c >> 6] + hexTable[0x80 | c & 0x3F]);
  34022. continue;
  34023. }
  34024. if (c < 0xD800 || c >= 0xE000) {
  34025. out = out + (hexTable[0xE0 | c >> 12] + hexTable[0x80 | c >> 6 & 0x3F] + hexTable[0x80 | c & 0x3F]);
  34026. continue;
  34027. }
  34028. i += 1;
  34029. c = 0x10000 + ((c & 0x3FF) << 10 | string.charCodeAt(i) & 0x3FF);
  34030. out += hexTable[0xF0 | c >> 18] + hexTable[0x80 | c >> 12 & 0x3F] + hexTable[0x80 | c >> 6 & 0x3F] + hexTable[0x80 | c & 0x3F];
  34031. }
  34032. return out;
  34033. };
  34034. exports.compact = function (obj, references) {
  34035. if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object' || obj === null) {
  34036. return obj;
  34037. }
  34038. var refs = references || [];
  34039. var lookup = refs.indexOf(obj);
  34040. if (lookup !== -1) {
  34041. return refs[lookup];
  34042. }
  34043. refs.push(obj);
  34044. if (Array.isArray(obj)) {
  34045. var compacted = [];
  34046. for (var i = 0; i < obj.length; ++i) {
  34047. if (obj[i] && _typeof(obj[i]) === 'object') {
  34048. compacted.push(exports.compact(obj[i], refs));
  34049. } else if (typeof obj[i] !== 'undefined') {
  34050. compacted.push(obj[i]);
  34051. }
  34052. }
  34053. return compacted;
  34054. }
  34055. var keys = Object.keys(obj);
  34056. for (var j = 0; j < keys.length; ++j) {
  34057. var key = keys[j];
  34058. obj[key] = exports.compact(obj[key], refs);
  34059. }
  34060. return obj;
  34061. };
  34062. exports.isRegExp = function (obj) {
  34063. return Object.prototype.toString.call(obj) === '[object RegExp]';
  34064. };
  34065. exports.isBuffer = function (obj) {
  34066. if (obj === null || typeof obj === 'undefined') {
  34067. return false;
  34068. }
  34069. return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
  34070. };
  34071. /***/ },
  34072. /* 152 */
  34073. /***/ function(module, exports, __webpack_require__) {
  34074. "use strict";
  34075. /* WEBPACK VAR INJECTION */(function(process, Buffer) {'use strict';
  34076. // Load modules
  34077. var Events = __webpack_require__(30);
  34078. var Url = __webpack_require__(226);
  34079. var Http = __webpack_require__(220);
  34080. var Https = __webpack_require__(510);
  34081. var Stream = __webpack_require__(9);
  34082. var Hoek = __webpack_require__(68);
  34083. var Boom = __webpack_require__(146);
  34084. var Payload = __webpack_require__(153);
  34085. var Recorder = __webpack_require__(250);
  34086. var Tap = __webpack_require__(251);
  34087. // Declare internals
  34088. var internals = {
  34089. jsonRegex: /^application\/[a-z.+-]*json$/,
  34090. shallowOptions: ['agent', 'payload', 'downstreamRes', 'beforeRedirect', 'redirected'],
  34091. emitSymbol: Symbol.for('wreck')
  34092. };
  34093. process[internals.emitSymbol] = process[internals.emitSymbol] || new Events.EventEmitter();
  34094. // new instance is exported as module.exports
  34095. internals.Client = function (defaults) {
  34096. // Use a single emitter instance for events
  34097. Object.assign(this, process[internals.emitSymbol]);
  34098. this.agents = {
  34099. https: new Https.Agent({ maxSockets: Infinity }),
  34100. http: new Http.Agent({ maxSockets: Infinity }),
  34101. httpsAllowUnauthorized: new Https.Agent({ maxSockets: Infinity, rejectUnauthorized: false })
  34102. };
  34103. this._defaults = defaults || {};
  34104. };
  34105. Hoek.inherits(internals.Client, Events.EventEmitter);
  34106. internals.Client.prototype.defaults = function (options) {
  34107. options = Hoek.applyToDefaultsWithShallow(options, this._defaults, internals.shallowOptions);
  34108. return new internals.Client(options);
  34109. };
  34110. internals.resolveUrl = function (baseUrl, path) {
  34111. if (!path) {
  34112. return baseUrl;
  34113. }
  34114. var parsedBase = Url.parse(baseUrl);
  34115. var parsedPath = Url.parse(path);
  34116. parsedBase.pathname = parsedBase.pathname + parsedPath.pathname;
  34117. parsedBase.pathname = parsedBase.pathname.replace(/[/]{2,}/g, '/');
  34118. parsedBase.search = parsedPath.search; // Always use the querystring from the path argument
  34119. return Url.format(parsedBase);
  34120. };
  34121. internals.Client.prototype.request = function (method, url, options, callback, _trace) {
  34122. var _this = this;
  34123. options = Hoek.applyToDefaultsWithShallow(this._defaults, options || {}, internals.shallowOptions);
  34124. Hoek.assert(options.payload === null || options.payload === undefined || typeof options.payload === 'string' || options.payload instanceof Stream || Buffer.isBuffer(options.payload), 'options.payload must be a string, a Buffer, or a Stream');
  34125. Hoek.assert(options.agent === undefined || options.agent === null || typeof options.rejectUnauthorized !== 'boolean', 'options.agent cannot be set to an Agent at the same time as options.rejectUnauthorized is set');
  34126. Hoek.assert(options.beforeRedirect === undefined || options.beforeRedirect === null || typeof options.beforeRedirect === 'function', 'options.beforeRedirect must be a function');
  34127. Hoek.assert(options.redirected === undefined || options.redirected === null || typeof options.redirected === 'function', 'options.redirected must be a function');
  34128. if (options.baseUrl) {
  34129. url = internals.resolveUrl(options.baseUrl, url);
  34130. delete options.baseUrl;
  34131. }
  34132. var uri = Url.parse(url);
  34133. if (options.socketPath) {
  34134. uri.socketPath = options.socketPath;
  34135. delete options.socketPath;
  34136. }
  34137. uri.method = method.toUpperCase();
  34138. uri.headers = options.headers || {};
  34139. var hasContentLength = Object.keys(uri.headers).some(function (key) {
  34140. return key.toLowerCase() === 'content-length';
  34141. });
  34142. var payloadSupported = uri.method !== 'GET' && uri.method !== 'HEAD' && options.payload !== null && options.payload !== undefined;
  34143. if (payloadSupported && (typeof options.payload === 'string' || Buffer.isBuffer(options.payload)) && !hasContentLength) {
  34144. uri.headers = Hoek.clone(uri.headers);
  34145. uri.headers['content-length'] = Buffer.isBuffer(options.payload) ? options.payload.length : Buffer.byteLength(options.payload);
  34146. }
  34147. var redirects = options.hasOwnProperty('redirects') ? options.redirects : false; // Needed to allow 0 as valid value when passed recursively
  34148. _trace = _trace || [];
  34149. _trace.push({ method: uri.method, url: url });
  34150. var client = uri.protocol === 'https:' ? Https : Http;
  34151. if (options.rejectUnauthorized !== undefined && uri.protocol === 'https:') {
  34152. uri.agent = options.rejectUnauthorized ? this.agents.https : this.agents.httpsAllowUnauthorized;
  34153. } else if (options.agent || options.agent === false) {
  34154. uri.agent = options.agent;
  34155. } else {
  34156. uri.agent = uri.protocol === 'https:' ? this.agents.https : this.agents.http;
  34157. }
  34158. if (options.secureProtocol !== undefined) {
  34159. uri.secureProtocol = options.secureProtocol;
  34160. }
  34161. this.emit('request', uri, options);
  34162. var start = Date.now();
  34163. var req = client.request(uri);
  34164. var shadow = null; // A copy of the streamed request payload when redirects are enabled
  34165. var timeoutId = void 0;
  34166. var onError = function onError(err) {
  34167. err.trace = _trace;
  34168. return finishOnce(Boom.badGateway('Client request error', err));
  34169. };
  34170. req.once('error', onError);
  34171. var onResponse = function onResponse(res) {
  34172. // Pass-through response
  34173. var statusCode = res.statusCode;
  34174. if (redirects === false || [301, 302, 307, 308].indexOf(statusCode) === -1) {
  34175. return finishOnce(null, res);
  34176. }
  34177. // Redirection
  34178. var redirectMethod = statusCode === 301 || statusCode === 302 ? 'GET' : uri.method;
  34179. var location = res.headers.location;
  34180. res.destroy();
  34181. if (redirects === 0) {
  34182. return finishOnce(Boom.badGateway('Maximum redirections reached', _trace));
  34183. }
  34184. if (!location) {
  34185. return finishOnce(Boom.badGateway('Received redirection without location', _trace));
  34186. }
  34187. if (!/^https?:/i.test(location)) {
  34188. location = Url.resolve(uri.href, location);
  34189. }
  34190. var redirectOptions = Hoek.cloneWithShallow(options, internals.shallowOptions);
  34191. redirectOptions.payload = shadow || options.payload; // shadow must be ready at this point if set
  34192. redirectOptions.redirects = --redirects;
  34193. if (options.beforeRedirect) {
  34194. options.beforeRedirect(redirectMethod, statusCode, location, redirectOptions);
  34195. }
  34196. var redirectReq = _this.request(redirectMethod, location, redirectOptions, finishOnce, _trace);
  34197. if (options.redirected) {
  34198. options.redirected(statusCode, location, redirectReq);
  34199. }
  34200. };
  34201. // Register handlers
  34202. var finish = function finish(err, res) {
  34203. if (err) {
  34204. req.abort();
  34205. }
  34206. req.removeListener('response', onResponse);
  34207. req.removeListener('error', onError);
  34208. req.on('error', Hoek.ignore);
  34209. clearTimeout(timeoutId);
  34210. _this.emit('response', err, req, res, start, uri);
  34211. if (callback) {
  34212. return callback(err, res);
  34213. }
  34214. };
  34215. var finishOnce = Hoek.once(finish);
  34216. req.once('response', onResponse);
  34217. if (options.timeout) {
  34218. timeoutId = setTimeout(function () {
  34219. return finishOnce(Boom.gatewayTimeout('Client request timeout'));
  34220. }, options.timeout);
  34221. delete options.timeout;
  34222. }
  34223. // Custom abort method to detect early aborts
  34224. var _abort = req.abort;
  34225. var aborted = false;
  34226. req.abort = function () {
  34227. if (!aborted && !req.res && !req.socket) {
  34228. process.nextTick(function () {
  34229. // Fake an ECONNRESET error
  34230. var error = new Error('socket hang up');
  34231. error.code = 'ECONNRESET';
  34232. finishOnce(error);
  34233. });
  34234. }
  34235. aborted = true;
  34236. return _abort.call(req);
  34237. };
  34238. // Write payload
  34239. if (payloadSupported) {
  34240. if (options.payload instanceof Stream) {
  34241. var stream = options.payload;
  34242. if (redirects) {
  34243. (function () {
  34244. var collector = new Tap();
  34245. collector.once('finish', function () {
  34246. shadow = collector.collect();
  34247. });
  34248. stream = options.payload.pipe(collector);
  34249. })();
  34250. }
  34251. stream.pipe(req);
  34252. return req;
  34253. }
  34254. req.write(options.payload);
  34255. }
  34256. // Finalize request
  34257. req.end();
  34258. return req;
  34259. };
  34260. // read()
  34261. internals.Client.prototype.read = function (res, options, callback) {
  34262. options = Hoek.applyToDefaultsWithShallow(options || {}, this._defaults, internals.shallowOptions);
  34263. // Set stream timeout
  34264. var clientTimeout = options.timeout;
  34265. var clientTimeoutId = null;
  34266. // Finish once
  34267. var finish = function finish(err, buffer) {
  34268. clearTimeout(clientTimeoutId);
  34269. reader.removeListener('error', onReaderError);
  34270. reader.removeListener('finish', onReaderFinish);
  34271. res.removeListener('error', onResError);
  34272. res.removeListener('close', onResClose);
  34273. res.on('error', Hoek.ignore);
  34274. if (err || !options.json) {
  34275. return callback(err, buffer);
  34276. }
  34277. // Parse JSON
  34278. var result = void 0;
  34279. if (buffer.length === 0) {
  34280. return callback(null, null);
  34281. }
  34282. if (options.json === 'force') {
  34283. result = internals.tryParseBuffer(buffer);
  34284. return callback(result.err, result.json);
  34285. }
  34286. // mode is "smart" or true
  34287. var contentType = res.headers && res.headers['content-type'] || '';
  34288. var mime = contentType.split(';')[0].trim().toLowerCase();
  34289. if (!internals.jsonRegex.test(mime)) {
  34290. return callback(null, buffer);
  34291. }
  34292. result = internals.tryParseBuffer(buffer);
  34293. return callback(result.err, result.json);
  34294. };
  34295. var finishOnce = Hoek.once(finish);
  34296. if (clientTimeout && clientTimeout > 0) {
  34297. clientTimeoutId = setTimeout(function () {
  34298. finishOnce(Boom.clientTimeout());
  34299. }, clientTimeout);
  34300. }
  34301. // Hander errors
  34302. var onResError = function onResError(err) {
  34303. return finishOnce(Boom.internal('Payload stream error', err));
  34304. };
  34305. var onResClose = function onResClose() {
  34306. return finishOnce(Boom.internal('Payload stream closed prematurely'));
  34307. };
  34308. res.once('error', onResError);
  34309. res.once('close', onResClose);
  34310. // Read payload
  34311. var reader = new Recorder({ maxBytes: options.maxBytes });
  34312. var onReaderError = function onReaderError(err) {
  34313. if (res.destroy) {
  34314. // GZip stream has no destroy() method
  34315. res.destroy();
  34316. }
  34317. return finishOnce(err);
  34318. };
  34319. reader.once('error', onReaderError);
  34320. var onReaderFinish = function onReaderFinish() {
  34321. return finishOnce(null, reader.collect());
  34322. };
  34323. reader.once('finish', onReaderFinish);
  34324. res.pipe(reader);
  34325. };
  34326. // toReadableStream()
  34327. internals.Client.prototype.toReadableStream = function (payload, encoding) {
  34328. return new Payload(payload, encoding);
  34329. };
  34330. // parseCacheControl()
  34331. internals.Client.prototype.parseCacheControl = function (field) {
  34332. /*
  34333. Cache-Control = 1#cache-directive
  34334. cache-directive = token [ "=" ( token / quoted-string ) ]
  34335. token = [^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+
  34336. quoted-string = "(?:[^"\\]|\\.)*"
  34337. */
  34338. // 1: directive = 2: token 3: quoted-string
  34339. var regex = /(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g;
  34340. var header = {};
  34341. var error = field.replace(regex, function ($0, $1, $2, $3) {
  34342. var value = $2 || $3;
  34343. header[$1] = value ? value.toLowerCase() : true;
  34344. return '';
  34345. });
  34346. if (header['max-age']) {
  34347. try {
  34348. var maxAge = parseInt(header['max-age'], 10);
  34349. if (isNaN(maxAge)) {
  34350. return null;
  34351. }
  34352. header['max-age'] = maxAge;
  34353. } catch (err) {}
  34354. }
  34355. return error ? null : header;
  34356. };
  34357. // Shortcuts
  34358. internals.Client.prototype.get = function (uri, options, callback) {
  34359. return this._shortcutWrap('GET', uri, options, callback);
  34360. };
  34361. internals.Client.prototype.post = function (uri, options, callback) {
  34362. return this._shortcutWrap('POST', uri, options, callback);
  34363. };
  34364. internals.Client.prototype.patch = function (uri, options, callback) {
  34365. return this._shortcutWrap('PATCH', uri, options, callback);
  34366. };
  34367. internals.Client.prototype.put = function (uri, options, callback) {
  34368. return this._shortcutWrap('PUT', uri, options, callback);
  34369. };
  34370. internals.Client.prototype.delete = function (uri, options, callback) {
  34371. return this._shortcutWrap('DELETE', uri, options, callback);
  34372. };
  34373. // Wrapper so that shortcut can be optimized with required params
  34374. internals.Client.prototype._shortcutWrap = function (method, uri /* [options], callback */) {
  34375. var options = typeof arguments[2] === 'function' ? {} : arguments[2];
  34376. var callback = typeof arguments[2] === 'function' ? arguments[2] : arguments[3];
  34377. return this._shortcut(method, uri, options, callback);
  34378. };
  34379. internals.Client.prototype._shortcut = function (method, uri, options, callback) {
  34380. var _this2 = this;
  34381. return this.request(method, uri, options, function (err, res) {
  34382. if (err) {
  34383. return callback(err);
  34384. }
  34385. _this2.read(res, options, function (err, payload) {
  34386. return callback(err, res, payload);
  34387. });
  34388. });
  34389. };
  34390. internals.tryParseBuffer = function (buffer) {
  34391. var result = {
  34392. json: null,
  34393. err: null
  34394. };
  34395. try {
  34396. var json = JSON.parse(buffer.toString());
  34397. result.json = json;
  34398. } catch (err) {
  34399. result.err = err;
  34400. }
  34401. return result;
  34402. };
  34403. module.exports = new internals.Client();
  34404. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4), __webpack_require__(1).Buffer))
  34405. /***/ },
  34406. /* 153 */
  34407. /***/ function(module, exports, __webpack_require__) {
  34408. "use strict";
  34409. /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
  34410. // Load modules
  34411. var Hoek = __webpack_require__(68);
  34412. var Stream = __webpack_require__(9);
  34413. // Declare internals
  34414. var internals = {};
  34415. module.exports = internals.Payload = function (payload, encoding) {
  34416. Stream.Readable.call(this);
  34417. var data = [].concat(payload || '');
  34418. var size = 0;
  34419. for (var i = 0; i < data.length; ++i) {
  34420. var chunk = data[i];
  34421. size = size + chunk.length;
  34422. data[i] = Buffer.isBuffer(chunk) ? chunk : new Buffer(chunk);
  34423. }
  34424. this._data = Buffer.concat(data, size);
  34425. this._position = 0;
  34426. this._encoding = encoding || 'utf8';
  34427. };
  34428. Hoek.inherits(internals.Payload, Stream.Readable);
  34429. internals.Payload.prototype._read = function (size) {
  34430. var chunk = this._data.slice(this._position, this._position + size);
  34431. this.push(chunk, this._encoding);
  34432. this._position = this._position + chunk.length;
  34433. if (this._position >= this._data.length) {
  34434. this.push(null);
  34435. }
  34436. };
  34437. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  34438. /***/ },
  34439. /* 154 */
  34440. /***/ function(module, exports, __webpack_require__) {
  34441. "use strict";
  34442. 'use strict';
  34443. var addCmd = __webpack_require__(101);
  34444. var Duplex = __webpack_require__(9).Duplex;
  34445. var promisify = __webpack_require__(78);
  34446. module.exports = function (send) {
  34447. var add = addCmd(send);
  34448. return promisify(function createAddStream(callback) {
  34449. var tuples = [];
  34450. var ds = new Duplex({ objectMode: true });
  34451. ds._read = function (n) {};
  34452. ds._write = function (file, enc, next) {
  34453. tuples.push(file);
  34454. next();
  34455. };
  34456. ds.end = function () {
  34457. add(tuples, function (err, res) {
  34458. if (err) {
  34459. return ds.emit('error', err);
  34460. }
  34461. res.forEach(function (tuple) {
  34462. ds.push(tuple);
  34463. });
  34464. ds.push(null);
  34465. });
  34466. };
  34467. callback(null, ds);
  34468. });
  34469. };
  34470. /***/ },
  34471. /* 155 */
  34472. /***/ function(module, exports, __webpack_require__) {
  34473. /* WEBPACK VAR INJECTION */(function(Buffer) {var DuplexStream = __webpack_require__(214)
  34474. , util = __webpack_require__(44)
  34475. function BufferList (callback) {
  34476. if (!(this instanceof BufferList))
  34477. return new BufferList(callback)
  34478. this._bufs = []
  34479. this.length = 0
  34480. if (typeof callback == 'function') {
  34481. this._callback = callback
  34482. var piper = function piper (err) {
  34483. if (this._callback) {
  34484. this._callback(err)
  34485. this._callback = null
  34486. }
  34487. }.bind(this)
  34488. this.on('pipe', function onPipe (src) {
  34489. src.on('error', piper)
  34490. })
  34491. this.on('unpipe', function onUnpipe (src) {
  34492. src.removeListener('error', piper)
  34493. })
  34494. } else {
  34495. this.append(callback)
  34496. }
  34497. DuplexStream.call(this)
  34498. }
  34499. util.inherits(BufferList, DuplexStream)
  34500. BufferList.prototype._offset = function _offset (offset) {
  34501. var tot = 0, i = 0, _t
  34502. for (; i < this._bufs.length; i++) {
  34503. _t = tot + this._bufs[i].length
  34504. if (offset < _t)
  34505. return [ i, offset - tot ]
  34506. tot = _t
  34507. }
  34508. }
  34509. BufferList.prototype.append = function append (buf) {
  34510. var i = 0
  34511. , newBuf
  34512. if (Array.isArray(buf)) {
  34513. for (; i < buf.length; i++)
  34514. this.append(buf[i])
  34515. } else if (buf instanceof BufferList) {
  34516. // unwrap argument into individual BufferLists
  34517. for (; i < buf._bufs.length; i++)
  34518. this.append(buf._bufs[i])
  34519. } else if (buf != null) {
  34520. // coerce number arguments to strings, since Buffer(number) does
  34521. // uninitialized memory allocation
  34522. if (typeof buf == 'number')
  34523. buf = buf.toString()
  34524. newBuf = Buffer.isBuffer(buf) ? buf : new Buffer(buf)
  34525. this._bufs.push(newBuf)
  34526. this.length += newBuf.length
  34527. }
  34528. return this
  34529. }
  34530. BufferList.prototype._write = function _write (buf, encoding, callback) {
  34531. this.append(buf)
  34532. if (typeof callback == 'function')
  34533. callback()
  34534. }
  34535. BufferList.prototype._read = function _read (size) {
  34536. if (!this.length)
  34537. return this.push(null)
  34538. size = Math.min(size, this.length)
  34539. this.push(this.slice(0, size))
  34540. this.consume(size)
  34541. }
  34542. BufferList.prototype.end = function end (chunk) {
  34543. DuplexStream.prototype.end.call(this, chunk)
  34544. if (this._callback) {
  34545. this._callback(null, this.slice())
  34546. this._callback = null
  34547. }
  34548. }
  34549. BufferList.prototype.get = function get (index) {
  34550. return this.slice(index, index + 1)[0]
  34551. }
  34552. BufferList.prototype.slice = function slice (start, end) {
  34553. return this.copy(null, 0, start, end)
  34554. }
  34555. BufferList.prototype.copy = function copy (dst, dstStart, srcStart, srcEnd) {
  34556. if (typeof srcStart != 'number' || srcStart < 0)
  34557. srcStart = 0
  34558. if (typeof srcEnd != 'number' || srcEnd > this.length)
  34559. srcEnd = this.length
  34560. if (srcStart >= this.length)
  34561. return dst || new Buffer(0)
  34562. if (srcEnd <= 0)
  34563. return dst || new Buffer(0)
  34564. var copy = !!dst
  34565. , off = this._offset(srcStart)
  34566. , len = srcEnd - srcStart
  34567. , bytes = len
  34568. , bufoff = (copy && dstStart) || 0
  34569. , start = off[1]
  34570. , l
  34571. , i
  34572. // copy/slice everything
  34573. if (srcStart === 0 && srcEnd == this.length) {
  34574. if (!copy) // slice, just return a full concat
  34575. return Buffer.concat(this._bufs)
  34576. // copy, need to copy individual buffers
  34577. for (i = 0; i < this._bufs.length; i++) {
  34578. this._bufs[i].copy(dst, bufoff)
  34579. bufoff += this._bufs[i].length
  34580. }
  34581. return dst
  34582. }
  34583. // easy, cheap case where it's a subset of one of the buffers
  34584. if (bytes <= this._bufs[off[0]].length - start) {
  34585. return copy
  34586. ? this._bufs[off[0]].copy(dst, dstStart, start, start + bytes)
  34587. : this._bufs[off[0]].slice(start, start + bytes)
  34588. }
  34589. if (!copy) // a slice, we need something to copy in to
  34590. dst = new Buffer(len)
  34591. for (i = off[0]; i < this._bufs.length; i++) {
  34592. l = this._bufs[i].length - start
  34593. if (bytes > l) {
  34594. this._bufs[i].copy(dst, bufoff, start)
  34595. } else {
  34596. this._bufs[i].copy(dst, bufoff, start, start + bytes)
  34597. break
  34598. }
  34599. bufoff += l
  34600. bytes -= l
  34601. if (start)
  34602. start = 0
  34603. }
  34604. return dst
  34605. }
  34606. BufferList.prototype.toString = function toString (encoding, start, end) {
  34607. return this.slice(start, end).toString(encoding)
  34608. }
  34609. BufferList.prototype.consume = function consume (bytes) {
  34610. while (this._bufs.length) {
  34611. if (bytes >= this._bufs[0].length) {
  34612. bytes -= this._bufs[0].length
  34613. this.length -= this._bufs[0].length
  34614. this._bufs.shift()
  34615. } else {
  34616. this._bufs[0] = this._bufs[0].slice(bytes)
  34617. this.length -= bytes
  34618. break
  34619. }
  34620. }
  34621. return this
  34622. }
  34623. BufferList.prototype.duplicate = function duplicate () {
  34624. var i = 0
  34625. , copy = new BufferList()
  34626. for (; i < this._bufs.length; i++)
  34627. copy.append(this._bufs[i])
  34628. return copy
  34629. }
  34630. BufferList.prototype.destroy = function destroy () {
  34631. this._bufs.length = 0
  34632. this.length = 0
  34633. this.push(null)
  34634. }
  34635. ;(function () {
  34636. var methods = {
  34637. 'readDoubleBE' : 8
  34638. , 'readDoubleLE' : 8
  34639. , 'readFloatBE' : 4
  34640. , 'readFloatLE' : 4
  34641. , 'readInt32BE' : 4
  34642. , 'readInt32LE' : 4
  34643. , 'readUInt32BE' : 4
  34644. , 'readUInt32LE' : 4
  34645. , 'readInt16BE' : 2
  34646. , 'readInt16LE' : 2
  34647. , 'readUInt16BE' : 2
  34648. , 'readUInt16LE' : 2
  34649. , 'readInt8' : 1
  34650. , 'readUInt8' : 1
  34651. }
  34652. for (var m in methods) {
  34653. (function (m) {
  34654. BufferList.prototype[m] = function (offset) {
  34655. return this.slice(offset, offset + methods[m])[m](0)
  34656. }
  34657. }(m))
  34658. }
  34659. }())
  34660. module.exports = BufferList
  34661. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  34662. /***/ },
  34663. /* 156 */
  34664. /***/ function(module, exports, __webpack_require__) {
  34665. var r;
  34666. module.exports = function rand(len) {
  34667. if (!r)
  34668. r = new Rand(null);
  34669. return r.generate(len);
  34670. };
  34671. function Rand(rand) {
  34672. this.rand = rand;
  34673. }
  34674. module.exports.Rand = Rand;
  34675. Rand.prototype.generate = function generate(len) {
  34676. return this._rand(len);
  34677. };
  34678. if (typeof window === 'object') {
  34679. if (window.crypto && window.crypto.getRandomValues) {
  34680. // Modern browsers
  34681. Rand.prototype._rand = function _rand(n) {
  34682. var arr = new Uint8Array(n);
  34683. window.crypto.getRandomValues(arr);
  34684. return arr;
  34685. };
  34686. } else if (window.msCrypto && window.msCrypto.getRandomValues) {
  34687. // IE
  34688. Rand.prototype._rand = function _rand(n) {
  34689. var arr = new Uint8Array(n);
  34690. window.msCrypto.getRandomValues(arr);
  34691. return arr;
  34692. };
  34693. } else {
  34694. // Old junk
  34695. Rand.prototype._rand = function() {
  34696. throw new Error('Not implemented yet');
  34697. };
  34698. }
  34699. } else {
  34700. // Node.js or Web worker
  34701. try {
  34702. var crypto = __webpack_require__(131);
  34703. Rand.prototype._rand = function _rand(n) {
  34704. return crypto.randomBytes(n);
  34705. };
  34706. } catch (e) {
  34707. // Emulate crypto API using randy
  34708. Rand.prototype._rand = function _rand(n) {
  34709. var res = new Uint8Array(n);
  34710. for (var i = 0; i < res.length; i++)
  34711. res[i] = this.rand.getByte();
  34712. return res;
  34713. };
  34714. }
  34715. }
  34716. /***/ },
  34717. /* 157 */
  34718. /***/ function(module, exports, __webpack_require__) {
  34719. /* WEBPACK VAR INJECTION */(function(Buffer) {var aes = __webpack_require__(79)
  34720. var Transform = __webpack_require__(57)
  34721. var inherits = __webpack_require__(2)
  34722. var GHASH = __webpack_require__(286)
  34723. var xor = __webpack_require__(69)
  34724. inherits(StreamCipher, Transform)
  34725. module.exports = StreamCipher
  34726. function StreamCipher (mode, key, iv, decrypt) {
  34727. if (!(this instanceof StreamCipher)) {
  34728. return new StreamCipher(mode, key, iv)
  34729. }
  34730. Transform.call(this)
  34731. this._finID = Buffer.concat([iv, new Buffer([0, 0, 0, 1])])
  34732. iv = Buffer.concat([iv, new Buffer([0, 0, 0, 2])])
  34733. this._cipher = new aes.AES(key)
  34734. this._prev = new Buffer(iv.length)
  34735. this._cache = new Buffer('')
  34736. this._secCache = new Buffer('')
  34737. this._decrypt = decrypt
  34738. this._alen = 0
  34739. this._len = 0
  34740. iv.copy(this._prev)
  34741. this._mode = mode
  34742. var h = new Buffer(4)
  34743. h.fill(0)
  34744. this._ghash = new GHASH(this._cipher.encryptBlock(h))
  34745. this._authTag = null
  34746. this._called = false
  34747. }
  34748. StreamCipher.prototype._update = function (chunk) {
  34749. if (!this._called && this._alen) {
  34750. var rump = 16 - (this._alen % 16)
  34751. if (rump < 16) {
  34752. rump = new Buffer(rump)
  34753. rump.fill(0)
  34754. this._ghash.update(rump)
  34755. }
  34756. }
  34757. this._called = true
  34758. var out = this._mode.encrypt(this, chunk)
  34759. if (this._decrypt) {
  34760. this._ghash.update(chunk)
  34761. } else {
  34762. this._ghash.update(out)
  34763. }
  34764. this._len += chunk.length
  34765. return out
  34766. }
  34767. StreamCipher.prototype._final = function () {
  34768. if (this._decrypt && !this._authTag) {
  34769. throw new Error('Unsupported state or unable to authenticate data')
  34770. }
  34771. var tag = xor(this._ghash.final(this._alen * 8, this._len * 8), this._cipher.encryptBlock(this._finID))
  34772. if (this._decrypt) {
  34773. if (xorTest(tag, this._authTag)) {
  34774. throw new Error('Unsupported state or unable to authenticate data')
  34775. }
  34776. } else {
  34777. this._authTag = tag
  34778. }
  34779. this._cipher.scrub()
  34780. }
  34781. StreamCipher.prototype.getAuthTag = function getAuthTag () {
  34782. if (!this._decrypt && Buffer.isBuffer(this._authTag)) {
  34783. return this._authTag
  34784. } else {
  34785. throw new Error('Attempting to get auth tag in unsupported state')
  34786. }
  34787. }
  34788. StreamCipher.prototype.setAuthTag = function setAuthTag (tag) {
  34789. if (this._decrypt) {
  34790. this._authTag = tag
  34791. } else {
  34792. throw new Error('Attempting to set auth tag in unsupported state')
  34793. }
  34794. }
  34795. StreamCipher.prototype.setAAD = function setAAD (buf) {
  34796. if (!this._called) {
  34797. this._ghash.update(buf)
  34798. this._alen += buf.length
  34799. } else {
  34800. throw new Error('Attempting to set AAD in unsupported state')
  34801. }
  34802. }
  34803. function xorTest (a, b) {
  34804. var out = 0
  34805. if (a.length !== b.length) {
  34806. out++
  34807. }
  34808. var len = Math.min(a.length, b.length)
  34809. var i = -1
  34810. while (++i < len) {
  34811. out += (a[i] ^ b[i])
  34812. }
  34813. return out
  34814. }
  34815. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  34816. /***/ },
  34817. /* 158 */
  34818. /***/ function(module, exports, __webpack_require__) {
  34819. var xor = __webpack_require__(69)
  34820. exports.encrypt = function (self, block) {
  34821. var data = xor(block, self._prev)
  34822. self._prev = self._cipher.encryptBlock(data)
  34823. return self._prev
  34824. }
  34825. exports.decrypt = function (self, block) {
  34826. var pad = self._prev
  34827. self._prev = block
  34828. var out = self._cipher.decryptBlock(block)
  34829. return xor(out, pad)
  34830. }
  34831. /***/ },
  34832. /* 159 */
  34833. /***/ function(module, exports, __webpack_require__) {
  34834. /* WEBPACK VAR INJECTION */(function(Buffer) {var xor = __webpack_require__(69)
  34835. exports.encrypt = function (self, data, decrypt) {
  34836. var out = new Buffer('')
  34837. var len
  34838. while (data.length) {
  34839. if (self._cache.length === 0) {
  34840. self._cache = self._cipher.encryptBlock(self._prev)
  34841. self._prev = new Buffer('')
  34842. }
  34843. if (self._cache.length <= data.length) {
  34844. len = self._cache.length
  34845. out = Buffer.concat([out, encryptStart(self, data.slice(0, len), decrypt)])
  34846. data = data.slice(len)
  34847. } else {
  34848. out = Buffer.concat([out, encryptStart(self, data, decrypt)])
  34849. break
  34850. }
  34851. }
  34852. return out
  34853. }
  34854. function encryptStart (self, data, decrypt) {
  34855. var len = data.length
  34856. var out = xor(data, self._cache)
  34857. self._cache = self._cache.slice(len)
  34858. self._prev = Buffer.concat([self._prev, decrypt ? data : out])
  34859. return out
  34860. }
  34861. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  34862. /***/ },
  34863. /* 160 */
  34864. /***/ function(module, exports, __webpack_require__) {
  34865. /* WEBPACK VAR INJECTION */(function(Buffer) {function encryptByte (self, byteParam, decrypt) {
  34866. var pad
  34867. var i = -1
  34868. var len = 8
  34869. var out = 0
  34870. var bit, value
  34871. while (++i < len) {
  34872. pad = self._cipher.encryptBlock(self._prev)
  34873. bit = (byteParam & (1 << (7 - i))) ? 0x80 : 0
  34874. value = pad[0] ^ bit
  34875. out += ((value & 0x80) >> (i % 8))
  34876. self._prev = shiftIn(self._prev, decrypt ? bit : value)
  34877. }
  34878. return out
  34879. }
  34880. exports.encrypt = function (self, chunk, decrypt) {
  34881. var len = chunk.length
  34882. var out = new Buffer(len)
  34883. var i = -1
  34884. while (++i < len) {
  34885. out[i] = encryptByte(self, chunk[i], decrypt)
  34886. }
  34887. return out
  34888. }
  34889. function shiftIn (buffer, value) {
  34890. var len = buffer.length
  34891. var i = -1
  34892. var out = new Buffer(buffer.length)
  34893. buffer = Buffer.concat([buffer, new Buffer([value])])
  34894. while (++i < len) {
  34895. out[i] = buffer[i] << 1 | buffer[i + 1] >> (7)
  34896. }
  34897. return out
  34898. }
  34899. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  34900. /***/ },
  34901. /* 161 */
  34902. /***/ function(module, exports, __webpack_require__) {
  34903. /* WEBPACK VAR INJECTION */(function(Buffer) {function encryptByte (self, byteParam, decrypt) {
  34904. var pad = self._cipher.encryptBlock(self._prev)
  34905. var out = pad[0] ^ byteParam
  34906. self._prev = Buffer.concat([self._prev.slice(1), new Buffer([decrypt ? byteParam : out])])
  34907. return out
  34908. }
  34909. exports.encrypt = function (self, chunk, decrypt) {
  34910. var len = chunk.length
  34911. var out = new Buffer(len)
  34912. var i = -1
  34913. while (++i < len) {
  34914. out[i] = encryptByte(self, chunk[i], decrypt)
  34915. }
  34916. return out
  34917. }
  34918. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  34919. /***/ },
  34920. /* 162 */
  34921. /***/ function(module, exports) {
  34922. exports.encrypt = function (self, block) {
  34923. return self._cipher.encryptBlock(block)
  34924. }
  34925. exports.decrypt = function (self, block) {
  34926. return self._cipher.decryptBlock(block)
  34927. }
  34928. /***/ },
  34929. /* 163 */
  34930. /***/ function(module, exports, __webpack_require__) {
  34931. /* WEBPACK VAR INJECTION */(function(Buffer) {var xor = __webpack_require__(69)
  34932. function getBlock (self) {
  34933. self._prev = self._cipher.encryptBlock(self._prev)
  34934. return self._prev
  34935. }
  34936. exports.encrypt = function (self, chunk) {
  34937. while (self._cache.length < chunk.length) {
  34938. self._cache = Buffer.concat([self._cache, getBlock(self)])
  34939. }
  34940. var pad = self._cache.slice(0, chunk.length)
  34941. self._cache = self._cache.slice(chunk.length)
  34942. return xor(chunk, pad)
  34943. }
  34944. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  34945. /***/ },
  34946. /* 164 */
  34947. /***/ function(module, exports, __webpack_require__) {
  34948. /* WEBPACK VAR INJECTION */(function(Buffer) {var aes = __webpack_require__(79)
  34949. var Transform = __webpack_require__(57)
  34950. var inherits = __webpack_require__(2)
  34951. inherits(StreamCipher, Transform)
  34952. module.exports = StreamCipher
  34953. function StreamCipher (mode, key, iv, decrypt) {
  34954. if (!(this instanceof StreamCipher)) {
  34955. return new StreamCipher(mode, key, iv)
  34956. }
  34957. Transform.call(this)
  34958. this._cipher = new aes.AES(key)
  34959. this._prev = new Buffer(iv.length)
  34960. this._cache = new Buffer('')
  34961. this._secCache = new Buffer('')
  34962. this._decrypt = decrypt
  34963. iv.copy(this._prev)
  34964. this._mode = mode
  34965. }
  34966. StreamCipher.prototype._update = function (chunk) {
  34967. return this._mode.encrypt(this, chunk, this._decrypt)
  34968. }
  34969. StreamCipher.prototype._final = function () {
  34970. this._cipher.scrub()
  34971. }
  34972. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  34973. /***/ },
  34974. /* 165 */
  34975. /***/ function(module, exports, __webpack_require__) {
  34976. "use strict";
  34977. /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict'
  34978. exports['RSA-SHA224'] = exports.sha224WithRSAEncryption = {
  34979. sign: 'rsa',
  34980. hash: 'sha224',
  34981. id: new Buffer('302d300d06096086480165030402040500041c', 'hex')
  34982. }
  34983. exports['RSA-SHA256'] = exports.sha256WithRSAEncryption = {
  34984. sign: 'rsa',
  34985. hash: 'sha256',
  34986. id: new Buffer('3031300d060960864801650304020105000420', 'hex')
  34987. }
  34988. exports['RSA-SHA384'] = exports.sha384WithRSAEncryption = {
  34989. sign: 'rsa',
  34990. hash: 'sha384',
  34991. id: new Buffer('3041300d060960864801650304020205000430', 'hex')
  34992. }
  34993. exports['RSA-SHA512'] = exports.sha512WithRSAEncryption = {
  34994. sign: 'rsa',
  34995. hash: 'sha512',
  34996. id: new Buffer('3051300d060960864801650304020305000440', 'hex')
  34997. }
  34998. exports['RSA-SHA1'] = {
  34999. sign: 'rsa',
  35000. hash: 'sha1',
  35001. id: new Buffer('3021300906052b0e03021a05000414', 'hex')
  35002. }
  35003. exports['ecdsa-with-SHA1'] = {
  35004. sign: 'ecdsa',
  35005. hash: 'sha1',
  35006. id: new Buffer('', 'hex')
  35007. }
  35008. exports.DSA = exports['DSA-SHA1'] = exports['DSA-SHA'] = {
  35009. sign: 'dsa',
  35010. hash: 'sha1',
  35011. id: new Buffer('', 'hex')
  35012. }
  35013. exports['DSA-SHA224'] = exports['DSA-WITH-SHA224'] = {
  35014. sign: 'dsa',
  35015. hash: 'sha224',
  35016. id: new Buffer('', 'hex')
  35017. }
  35018. exports['DSA-SHA256'] = exports['DSA-WITH-SHA256'] = {
  35019. sign: 'dsa',
  35020. hash: 'sha256',
  35021. id: new Buffer('', 'hex')
  35022. }
  35023. exports['DSA-SHA384'] = exports['DSA-WITH-SHA384'] = {
  35024. sign: 'dsa',
  35025. hash: 'sha384',
  35026. id: new Buffer('', 'hex')
  35027. }
  35028. exports['DSA-SHA512'] = exports['DSA-WITH-SHA512'] = {
  35029. sign: 'dsa',
  35030. hash: 'sha512',
  35031. id: new Buffer('', 'hex')
  35032. }
  35033. exports['DSA-RIPEMD160'] = {
  35034. sign: 'dsa',
  35035. hash: 'rmd160',
  35036. id: new Buffer('', 'hex')
  35037. }
  35038. exports['RSA-RIPEMD160'] = exports.ripemd160WithRSA = {
  35039. sign: 'rsa',
  35040. hash: 'rmd160',
  35041. id: new Buffer('3021300906052b2403020105000414', 'hex')
  35042. }
  35043. exports['RSA-MD5'] = exports.md5WithRSAEncryption = {
  35044. sign: 'rsa',
  35045. hash: 'md5',
  35046. id: new Buffer('3020300c06082a864886f70d020505000410', 'hex')
  35047. }
  35048. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  35049. /***/ },
  35050. /* 166 */
  35051. /***/ function(module, exports) {
  35052. "use strict";
  35053. 'use strict'
  35054. exports['1.3.132.0.10'] = 'secp256k1'
  35055. exports['1.3.132.0.33'] = 'p224'
  35056. exports['1.2.840.10045.3.1.1'] = 'p192'
  35057. exports['1.2.840.10045.3.1.7'] = 'p256'
  35058. exports['1.3.132.0.34'] = 'p384'
  35059. exports['1.3.132.0.35'] = 'p521'
  35060. /***/ },
  35061. /* 167 */
  35062. /***/ function(module, exports, __webpack_require__) {
  35063. "use strict";
  35064. /* WEBPACK VAR INJECTION */(function(global) {'use strict';
  35065. var buffer = __webpack_require__(1);
  35066. var Buffer = buffer.Buffer;
  35067. var SlowBuffer = buffer.SlowBuffer;
  35068. var MAX_LEN = buffer.kMaxLength || 2147483647;
  35069. exports.alloc = function alloc(size, fill, encoding) {
  35070. if (typeof Buffer.alloc === 'function') {
  35071. return Buffer.alloc(size, fill, encoding);
  35072. }
  35073. if (typeof encoding === 'number') {
  35074. throw new TypeError('encoding must not be number');
  35075. }
  35076. if (typeof size !== 'number') {
  35077. throw new TypeError('size must be a number');
  35078. }
  35079. if (size > MAX_LEN) {
  35080. throw new RangeError('size is too large');
  35081. }
  35082. var enc = encoding;
  35083. var _fill = fill;
  35084. if (_fill === undefined) {
  35085. enc = undefined;
  35086. _fill = 0;
  35087. }
  35088. var buf = new Buffer(size);
  35089. if (typeof _fill === 'string') {
  35090. var fillBuf = new Buffer(_fill, enc);
  35091. var flen = fillBuf.length;
  35092. var i = -1;
  35093. while (++i < size) {
  35094. buf[i] = fillBuf[i % flen];
  35095. }
  35096. } else {
  35097. buf.fill(_fill);
  35098. }
  35099. return buf;
  35100. }
  35101. exports.allocUnsafe = function allocUnsafe(size) {
  35102. if (typeof Buffer.allocUnsafe === 'function') {
  35103. return Buffer.allocUnsafe(size);
  35104. }
  35105. if (typeof size !== 'number') {
  35106. throw new TypeError('size must be a number');
  35107. }
  35108. if (size > MAX_LEN) {
  35109. throw new RangeError('size is too large');
  35110. }
  35111. return new Buffer(size);
  35112. }
  35113. exports.from = function from(value, encodingOrOffset, length) {
  35114. if (typeof Buffer.from === 'function' && (!global.Uint8Array || Uint8Array.from !== Buffer.from)) {
  35115. return Buffer.from(value, encodingOrOffset, length);
  35116. }
  35117. if (typeof value === 'number') {
  35118. throw new TypeError('"value" argument must not be a number');
  35119. }
  35120. if (typeof value === 'string') {
  35121. return new Buffer(value, encodingOrOffset);
  35122. }
  35123. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  35124. var offset = encodingOrOffset;
  35125. if (arguments.length === 1) {
  35126. return new Buffer(value);
  35127. }
  35128. if (typeof offset === 'undefined') {
  35129. offset = 0;
  35130. }
  35131. var len = length;
  35132. if (typeof len === 'undefined') {
  35133. len = value.byteLength - offset;
  35134. }
  35135. if (offset >= value.byteLength) {
  35136. throw new RangeError('\'offset\' is out of bounds');
  35137. }
  35138. if (len > value.byteLength - offset) {
  35139. throw new RangeError('\'length\' is out of bounds');
  35140. }
  35141. return new Buffer(value.slice(offset, offset + len));
  35142. }
  35143. if (Buffer.isBuffer(value)) {
  35144. var out = new Buffer(value.length);
  35145. value.copy(out, 0, 0, value.length);
  35146. return out;
  35147. }
  35148. if (value) {
  35149. if (Array.isArray(value) || (typeof ArrayBuffer !== 'undefined' && value.buffer instanceof ArrayBuffer) || 'length' in value) {
  35150. return new Buffer(value);
  35151. }
  35152. if (value.type === 'Buffer' && Array.isArray(value.data)) {
  35153. return new Buffer(value.data);
  35154. }
  35155. }
  35156. throw new TypeError('First argument must be a string, Buffer, ' + 'ArrayBuffer, Array, or array-like object.');
  35157. }
  35158. exports.allocUnsafeSlow = function allocUnsafeSlow(size) {
  35159. if (typeof Buffer.allocUnsafeSlow === 'function') {
  35160. return Buffer.allocUnsafeSlow(size);
  35161. }
  35162. if (typeof size !== 'number') {
  35163. throw new TypeError('size must be a number');
  35164. }
  35165. if (size >= MAX_LEN) {
  35166. throw new RangeError('size is too large');
  35167. }
  35168. return new SlowBuffer(size);
  35169. }
  35170. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(13)))
  35171. /***/ },
  35172. /* 168 */
  35173. /***/ function(module, exports, __webpack_require__) {
  35174. var cof = __webpack_require__(27);
  35175. module.exports = function(it, msg){
  35176. if(typeof it != 'number' && cof(it) != 'Number')throw TypeError(msg);
  35177. return +it;
  35178. };
  35179. /***/ },
  35180. /* 169 */
  35181. /***/ function(module, exports, __webpack_require__) {
  35182. "use strict";
  35183. // 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length)
  35184. 'use strict';
  35185. var toObject = __webpack_require__(16)
  35186. , toIndex = __webpack_require__(52)
  35187. , toLength = __webpack_require__(15);
  35188. module.exports = [].copyWithin || function copyWithin(target/*= 0*/, start/*= 0, end = @length*/){
  35189. var O = toObject(this)
  35190. , len = toLength(O.length)
  35191. , to = toIndex(target, len)
  35192. , from = toIndex(start, len)
  35193. , end = arguments.length > 2 ? arguments[2] : undefined
  35194. , count = Math.min((end === undefined ? len : toIndex(end, len)) - from, len - to)
  35195. , inc = 1;
  35196. if(from < to && to < from + count){
  35197. inc = -1;
  35198. from += count - 1;
  35199. to += count - 1;
  35200. }
  35201. while(count-- > 0){
  35202. if(from in O)O[to] = O[from];
  35203. else delete O[to];
  35204. to += inc;
  35205. from += inc;
  35206. } return O;
  35207. };
  35208. /***/ },
  35209. /* 170 */
  35210. /***/ function(module, exports, __webpack_require__) {
  35211. var forOf = __webpack_require__(60);
  35212. module.exports = function(iter, ITERATOR){
  35213. var result = [];
  35214. forOf(iter, false, result.push, result, ITERATOR);
  35215. return result;
  35216. };
  35217. /***/ },
  35218. /* 171 */
  35219. /***/ function(module, exports, __webpack_require__) {
  35220. var aFunction = __webpack_require__(21)
  35221. , toObject = __webpack_require__(16)
  35222. , IObject = __webpack_require__(70)
  35223. , toLength = __webpack_require__(15);
  35224. module.exports = function(that, callbackfn, aLen, memo, isRight){
  35225. aFunction(callbackfn);
  35226. var O = toObject(that)
  35227. , self = IObject(O)
  35228. , length = toLength(O.length)
  35229. , index = isRight ? length - 1 : 0
  35230. , i = isRight ? -1 : 1;
  35231. if(aLen < 2)for(;;){
  35232. if(index in self){
  35233. memo = self[index];
  35234. index += i;
  35235. break;
  35236. }
  35237. index += i;
  35238. if(isRight ? index < 0 : length <= index){
  35239. throw TypeError('Reduce of empty array with no initial value');
  35240. }
  35241. }
  35242. for(;isRight ? index >= 0 : length > index; index += i)if(index in self){
  35243. memo = callbackfn(memo, self[index], index, O);
  35244. }
  35245. return memo;
  35246. };
  35247. /***/ },
  35248. /* 172 */
  35249. /***/ function(module, exports, __webpack_require__) {
  35250. "use strict";
  35251. 'use strict';
  35252. var aFunction = __webpack_require__(21)
  35253. , isObject = __webpack_require__(7)
  35254. , invoke = __webpack_require__(86)
  35255. , arraySlice = [].slice
  35256. , factories = {};
  35257. var construct = function(F, len, args){
  35258. if(!(len in factories)){
  35259. for(var n = [], i = 0; i < len; i++)n[i] = 'a[' + i + ']';
  35260. factories[len] = Function('F,a', 'return new F(' + n.join(',') + ')');
  35261. } return factories[len](F, args);
  35262. };
  35263. module.exports = Function.bind || function bind(that /*, args... */){
  35264. var fn = aFunction(this)
  35265. , partArgs = arraySlice.call(arguments, 1);
  35266. var bound = function(/* args... */){
  35267. var args = partArgs.concat(arraySlice.call(arguments));
  35268. return this instanceof bound ? construct(fn, args.length, args) : invoke(fn, args, that);
  35269. };
  35270. if(isObject(fn.prototype))bound.prototype = fn.prototype;
  35271. return bound;
  35272. };
  35273. /***/ },
  35274. /* 173 */
  35275. /***/ function(module, exports, __webpack_require__) {
  35276. "use strict";
  35277. 'use strict';
  35278. var dP = __webpack_require__(11).f
  35279. , create = __webpack_require__(47)
  35280. , hide = __webpack_require__(19)
  35281. , redefineAll = __webpack_require__(50)
  35282. , ctx = __webpack_require__(35)
  35283. , anInstance = __webpack_require__(39)
  35284. , defined = __webpack_require__(28)
  35285. , forOf = __webpack_require__(60)
  35286. , $iterDefine = __webpack_require__(115)
  35287. , step = __webpack_require__(178)
  35288. , setSpecies = __webpack_require__(51)
  35289. , DESCRIPTORS = __webpack_require__(10)
  35290. , fastKey = __webpack_require__(40).fastKey
  35291. , SIZE = DESCRIPTORS ? '_s' : 'size';
  35292. var getEntry = function(that, key){
  35293. // fast case
  35294. var index = fastKey(key), entry;
  35295. if(index !== 'F')return that._i[index];
  35296. // frozen object case
  35297. for(entry = that._f; entry; entry = entry.n){
  35298. if(entry.k == key)return entry;
  35299. }
  35300. };
  35301. module.exports = {
  35302. getConstructor: function(wrapper, NAME, IS_MAP, ADDER){
  35303. var C = wrapper(function(that, iterable){
  35304. anInstance(that, C, NAME, '_i');
  35305. that._i = create(null); // index
  35306. that._f = undefined; // first entry
  35307. that._l = undefined; // last entry
  35308. that[SIZE] = 0; // size
  35309. if(iterable != undefined)forOf(iterable, IS_MAP, that[ADDER], that);
  35310. });
  35311. redefineAll(C.prototype, {
  35312. // 23.1.3.1 Map.prototype.clear()
  35313. // 23.2.3.2 Set.prototype.clear()
  35314. clear: function clear(){
  35315. for(var that = this, data = that._i, entry = that._f; entry; entry = entry.n){
  35316. entry.r = true;
  35317. if(entry.p)entry.p = entry.p.n = undefined;
  35318. delete data[entry.i];
  35319. }
  35320. that._f = that._l = undefined;
  35321. that[SIZE] = 0;
  35322. },
  35323. // 23.1.3.3 Map.prototype.delete(key)
  35324. // 23.2.3.4 Set.prototype.delete(value)
  35325. 'delete': function(key){
  35326. var that = this
  35327. , entry = getEntry(that, key);
  35328. if(entry){
  35329. var next = entry.n
  35330. , prev = entry.p;
  35331. delete that._i[entry.i];
  35332. entry.r = true;
  35333. if(prev)prev.n = next;
  35334. if(next)next.p = prev;
  35335. if(that._f == entry)that._f = next;
  35336. if(that._l == entry)that._l = prev;
  35337. that[SIZE]--;
  35338. } return !!entry;
  35339. },
  35340. // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined)
  35341. // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined)
  35342. forEach: function forEach(callbackfn /*, that = undefined */){
  35343. anInstance(this, C, 'forEach');
  35344. var f = ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3)
  35345. , entry;
  35346. while(entry = entry ? entry.n : this._f){
  35347. f(entry.v, entry.k, this);
  35348. // revert to the last existing entry
  35349. while(entry && entry.r)entry = entry.p;
  35350. }
  35351. },
  35352. // 23.1.3.7 Map.prototype.has(key)
  35353. // 23.2.3.7 Set.prototype.has(value)
  35354. has: function has(key){
  35355. return !!getEntry(this, key);
  35356. }
  35357. });
  35358. if(DESCRIPTORS)dP(C.prototype, 'size', {
  35359. get: function(){
  35360. return defined(this[SIZE]);
  35361. }
  35362. });
  35363. return C;
  35364. },
  35365. def: function(that, key, value){
  35366. var entry = getEntry(that, key)
  35367. , prev, index;
  35368. // change existing entry
  35369. if(entry){
  35370. entry.v = value;
  35371. // create new entry
  35372. } else {
  35373. that._l = entry = {
  35374. i: index = fastKey(key, true), // <- index
  35375. k: key, // <- key
  35376. v: value, // <- value
  35377. p: prev = that._l, // <- previous entry
  35378. n: undefined, // <- next entry
  35379. r: false // <- removed
  35380. };
  35381. if(!that._f)that._f = entry;
  35382. if(prev)prev.n = entry;
  35383. that[SIZE]++;
  35384. // add to index
  35385. if(index !== 'F')that._i[index] = entry;
  35386. } return that;
  35387. },
  35388. getEntry: getEntry,
  35389. setStrong: function(C, NAME, IS_MAP){
  35390. // add .keys, .values, .entries, [@@iterator]
  35391. // 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11
  35392. $iterDefine(C, NAME, function(iterated, kind){
  35393. this._t = iterated; // target
  35394. this._k = kind; // kind
  35395. this._l = undefined; // previous
  35396. }, function(){
  35397. var that = this
  35398. , kind = that._k
  35399. , entry = that._l;
  35400. // revert to the last existing entry
  35401. while(entry && entry.r)entry = entry.p;
  35402. // get next entry
  35403. if(!that._t || !(that._l = entry = entry ? entry.n : that._t._f)){
  35404. // or finish the iteration
  35405. that._t = undefined;
  35406. return step(1);
  35407. }
  35408. // return step by kind
  35409. if(kind == 'keys' )return step(0, entry.k);
  35410. if(kind == 'values')return step(0, entry.v);
  35411. return step(0, [entry.k, entry.v]);
  35412. }, IS_MAP ? 'entries' : 'values' , !IS_MAP, true);
  35413. // add [@@species], 23.1.2.2, 23.2.2.2
  35414. setSpecies(NAME);
  35415. }
  35416. };
  35417. /***/ },
  35418. /* 174 */
  35419. /***/ function(module, exports, __webpack_require__) {
  35420. // https://github.com/DavidBruant/Map-Set.prototype.toJSON
  35421. var classof = __webpack_require__(59)
  35422. , from = __webpack_require__(170);
  35423. module.exports = function(NAME){
  35424. return function toJSON(){
  35425. if(classof(this) != NAME)throw TypeError(NAME + "#toJSON isn't generic");
  35426. return from(this);
  35427. };
  35428. };
  35429. /***/ },
  35430. /* 175 */
  35431. /***/ function(module, exports, __webpack_require__) {
  35432. "use strict";
  35433. 'use strict';
  35434. var redefineAll = __webpack_require__(50)
  35435. , getWeak = __webpack_require__(40).getWeak
  35436. , anObject = __webpack_require__(3)
  35437. , isObject = __webpack_require__(7)
  35438. , anInstance = __webpack_require__(39)
  35439. , forOf = __webpack_require__(60)
  35440. , createArrayMethod = __webpack_require__(31)
  35441. , $has = __webpack_require__(17)
  35442. , arrayFind = createArrayMethod(5)
  35443. , arrayFindIndex = createArrayMethod(6)
  35444. , id = 0;
  35445. // fallback for uncaught frozen keys
  35446. var uncaughtFrozenStore = function(that){
  35447. return that._l || (that._l = new UncaughtFrozenStore);
  35448. };
  35449. var UncaughtFrozenStore = function(){
  35450. this.a = [];
  35451. };
  35452. var findUncaughtFrozen = function(store, key){
  35453. return arrayFind(store.a, function(it){
  35454. return it[0] === key;
  35455. });
  35456. };
  35457. UncaughtFrozenStore.prototype = {
  35458. get: function(key){
  35459. var entry = findUncaughtFrozen(this, key);
  35460. if(entry)return entry[1];
  35461. },
  35462. has: function(key){
  35463. return !!findUncaughtFrozen(this, key);
  35464. },
  35465. set: function(key, value){
  35466. var entry = findUncaughtFrozen(this, key);
  35467. if(entry)entry[1] = value;
  35468. else this.a.push([key, value]);
  35469. },
  35470. 'delete': function(key){
  35471. var index = arrayFindIndex(this.a, function(it){
  35472. return it[0] === key;
  35473. });
  35474. if(~index)this.a.splice(index, 1);
  35475. return !!~index;
  35476. }
  35477. };
  35478. module.exports = {
  35479. getConstructor: function(wrapper, NAME, IS_MAP, ADDER){
  35480. var C = wrapper(function(that, iterable){
  35481. anInstance(that, C, NAME, '_i');
  35482. that._i = id++; // collection id
  35483. that._l = undefined; // leak store for uncaught frozen objects
  35484. if(iterable != undefined)forOf(iterable, IS_MAP, that[ADDER], that);
  35485. });
  35486. redefineAll(C.prototype, {
  35487. // 23.3.3.2 WeakMap.prototype.delete(key)
  35488. // 23.4.3.3 WeakSet.prototype.delete(value)
  35489. 'delete': function(key){
  35490. if(!isObject(key))return false;
  35491. var data = getWeak(key);
  35492. if(data === true)return uncaughtFrozenStore(this)['delete'](key);
  35493. return data && $has(data, this._i) && delete data[this._i];
  35494. },
  35495. // 23.3.3.4 WeakMap.prototype.has(key)
  35496. // 23.4.3.4 WeakSet.prototype.has(value)
  35497. has: function has(key){
  35498. if(!isObject(key))return false;
  35499. var data = getWeak(key);
  35500. if(data === true)return uncaughtFrozenStore(this).has(key);
  35501. return data && $has(data, this._i);
  35502. }
  35503. });
  35504. return C;
  35505. },
  35506. def: function(that, key, value){
  35507. var data = getWeak(anObject(key), true);
  35508. if(data === true)uncaughtFrozenStore(that).set(key, value);
  35509. else data[that._i] = value;
  35510. return that;
  35511. },
  35512. ufstore: uncaughtFrozenStore
  35513. };
  35514. /***/ },
  35515. /* 176 */
  35516. /***/ function(module, exports, __webpack_require__) {
  35517. module.exports = !__webpack_require__(10) && !__webpack_require__(6)(function(){
  35518. return Object.defineProperty(__webpack_require__(106)('div'), 'a', {get: function(){ return 7; }}).a != 7;
  35519. });
  35520. /***/ },
  35521. /* 177 */
  35522. /***/ function(module, exports, __webpack_require__) {
  35523. // call something on iterator step with safe closing on error
  35524. var anObject = __webpack_require__(3);
  35525. module.exports = function(iterator, fn, value, entries){
  35526. try {
  35527. return entries ? fn(anObject(value)[0], value[1]) : fn(value);
  35528. // 7.4.6 IteratorClose(iterator, completion)
  35529. } catch(e){
  35530. var ret = iterator['return'];
  35531. if(ret !== undefined)anObject(ret.call(iterator));
  35532. throw e;
  35533. }
  35534. };
  35535. /***/ },
  35536. /* 178 */
  35537. /***/ function(module, exports) {
  35538. module.exports = function(done, value){
  35539. return {value: value, done: !!done};
  35540. };
  35541. /***/ },
  35542. /* 179 */
  35543. /***/ function(module, exports) {
  35544. // 20.2.2.20 Math.log1p(x)
  35545. module.exports = Math.log1p || function log1p(x){
  35546. return (x = +x) > -1e-8 && x < 1e-8 ? x - x * x / 2 : Math.log(1 + x);
  35547. };
  35548. /***/ },
  35549. /* 180 */
  35550. /***/ function(module, exports, __webpack_require__) {
  35551. "use strict";
  35552. 'use strict';
  35553. // 19.1.2.1 Object.assign(target, source, ...)
  35554. var getKeys = __webpack_require__(49)
  35555. , gOPS = __webpack_require__(90)
  35556. , pIE = __webpack_require__(71)
  35557. , toObject = __webpack_require__(16)
  35558. , IObject = __webpack_require__(70)
  35559. , $assign = Object.assign;
  35560. // should work with symbols and should have deterministic property order (V8 bug)
  35561. module.exports = !$assign || __webpack_require__(6)(function(){
  35562. var A = {}
  35563. , B = {}
  35564. , S = Symbol()
  35565. , K = 'abcdefghijklmnopqrst';
  35566. A[S] = 7;
  35567. K.split('').forEach(function(k){ B[k] = k; });
  35568. return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
  35569. }) ? function assign(target, source){ // eslint-disable-line no-unused-vars
  35570. var T = toObject(target)
  35571. , aLen = arguments.length
  35572. , index = 1
  35573. , getSymbols = gOPS.f
  35574. , isEnum = pIE.f;
  35575. while(aLen > index){
  35576. var S = IObject(arguments[index++])
  35577. , keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S)
  35578. , length = keys.length
  35579. , j = 0
  35580. , key;
  35581. while(length > j)if(isEnum.call(S, key = keys[j++]))T[key] = S[key];
  35582. } return T;
  35583. } : $assign;
  35584. /***/ },
  35585. /* 181 */
  35586. /***/ function(module, exports, __webpack_require__) {
  35587. var dP = __webpack_require__(11)
  35588. , anObject = __webpack_require__(3)
  35589. , getKeys = __webpack_require__(49);
  35590. module.exports = __webpack_require__(10) ? Object.defineProperties : function defineProperties(O, Properties){
  35591. anObject(O);
  35592. var keys = getKeys(Properties)
  35593. , length = keys.length
  35594. , i = 0
  35595. , P;
  35596. while(length > i)dP.f(O, P = keys[i++], Properties[P]);
  35597. return O;
  35598. };
  35599. /***/ },
  35600. /* 182 */
  35601. /***/ function(module, exports, __webpack_require__) {
  35602. // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
  35603. var toIObject = __webpack_require__(24)
  35604. , gOPN = __webpack_require__(48).f
  35605. , toString = {}.toString;
  35606. var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
  35607. ? Object.getOwnPropertyNames(window) : [];
  35608. var getWindowNames = function(it){
  35609. try {
  35610. return gOPN(it);
  35611. } catch(e){
  35612. return windowNames.slice();
  35613. }
  35614. };
  35615. module.exports.f = function getOwnPropertyNames(it){
  35616. return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it));
  35617. };
  35618. /***/ },
  35619. /* 183 */
  35620. /***/ function(module, exports, __webpack_require__) {
  35621. var has = __webpack_require__(17)
  35622. , toIObject = __webpack_require__(24)
  35623. , arrayIndexOf = __webpack_require__(82)(false)
  35624. , IE_PROTO = __webpack_require__(119)('IE_PROTO');
  35625. module.exports = function(object, names){
  35626. var O = toIObject(object)
  35627. , i = 0
  35628. , result = []
  35629. , key;
  35630. for(key in O)if(key != IE_PROTO)has(O, key) && result.push(key);
  35631. // Don't enum bug & hidden keys
  35632. while(names.length > i)if(has(O, key = names[i++])){
  35633. ~arrayIndexOf(result, key) || result.push(key);
  35634. }
  35635. return result;
  35636. };
  35637. /***/ },
  35638. /* 184 */
  35639. /***/ function(module, exports, __webpack_require__) {
  35640. var getKeys = __webpack_require__(49)
  35641. , toIObject = __webpack_require__(24)
  35642. , isEnum = __webpack_require__(71).f;
  35643. module.exports = function(isEntries){
  35644. return function(it){
  35645. var O = toIObject(it)
  35646. , keys = getKeys(O)
  35647. , length = keys.length
  35648. , i = 0
  35649. , result = []
  35650. , key;
  35651. while(length > i)if(isEnum.call(O, key = keys[i++])){
  35652. result.push(isEntries ? [key, O[key]] : O[key]);
  35653. } return result;
  35654. };
  35655. };
  35656. /***/ },
  35657. /* 185 */
  35658. /***/ function(module, exports, __webpack_require__) {
  35659. // all object keys, includes non-enumerable and symbols
  35660. var gOPN = __webpack_require__(48)
  35661. , gOPS = __webpack_require__(90)
  35662. , anObject = __webpack_require__(3)
  35663. , Reflect = __webpack_require__(5).Reflect;
  35664. module.exports = Reflect && Reflect.ownKeys || function ownKeys(it){
  35665. var keys = gOPN.f(anObject(it))
  35666. , getSymbols = gOPS.f;
  35667. return getSymbols ? keys.concat(getSymbols(it)) : keys;
  35668. };
  35669. /***/ },
  35670. /* 186 */
  35671. /***/ function(module, exports, __webpack_require__) {
  35672. var $parseFloat = __webpack_require__(5).parseFloat
  35673. , $trim = __webpack_require__(62).trim;
  35674. module.exports = 1 / $parseFloat(__webpack_require__(124) + '-0') !== -Infinity ? function parseFloat(str){
  35675. var string = $trim(String(str), 3)
  35676. , result = $parseFloat(string);
  35677. return result === 0 && string.charAt(0) == '-' ? -0 : result;
  35678. } : $parseFloat;
  35679. /***/ },
  35680. /* 187 */
  35681. /***/ function(module, exports, __webpack_require__) {
  35682. var $parseInt = __webpack_require__(5).parseInt
  35683. , $trim = __webpack_require__(62).trim
  35684. , ws = __webpack_require__(124)
  35685. , hex = /^[\-+]?0[xX]/;
  35686. module.exports = $parseInt(ws + '08') !== 8 || $parseInt(ws + '0x16') !== 22 ? function parseInt(str, radix){
  35687. var string = $trim(String(str), 3);
  35688. return $parseInt(string, (radix >>> 0) || (hex.test(string) ? 16 : 10));
  35689. } : $parseInt;
  35690. /***/ },
  35691. /* 188 */
  35692. /***/ function(module, exports) {
  35693. // 7.2.9 SameValue(x, y)
  35694. module.exports = Object.is || function is(x, y){
  35695. return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y;
  35696. };
  35697. /***/ },
  35698. /* 189 */
  35699. /***/ function(module, exports, __webpack_require__) {
  35700. // https://github.com/tc39/proposal-string-pad-start-end
  35701. var toLength = __webpack_require__(15)
  35702. , repeat = __webpack_require__(123)
  35703. , defined = __webpack_require__(28);
  35704. module.exports = function(that, maxLength, fillString, left){
  35705. var S = String(defined(that))
  35706. , stringLength = S.length
  35707. , fillStr = fillString === undefined ? ' ' : String(fillString)
  35708. , intMaxLength = toLength(maxLength);
  35709. if(intMaxLength <= stringLength || fillStr == '')return S;
  35710. var fillLen = intMaxLength - stringLength
  35711. , stringFiller = repeat.call(fillStr, Math.ceil(fillLen / fillStr.length));
  35712. if(stringFiller.length > fillLen)stringFiller = stringFiller.slice(0, fillLen);
  35713. return left ? stringFiller + S : S + stringFiller;
  35714. };
  35715. /***/ },
  35716. /* 190 */
  35717. /***/ function(module, exports, __webpack_require__) {
  35718. exports.f = __webpack_require__(8);
  35719. /***/ },
  35720. /* 191 */
  35721. /***/ function(module, exports, __webpack_require__) {
  35722. "use strict";
  35723. 'use strict';
  35724. var strong = __webpack_require__(173);
  35725. // 23.1 Map Objects
  35726. module.exports = __webpack_require__(83)('Map', function(get){
  35727. return function Map(){ return get(this, arguments.length > 0 ? arguments[0] : undefined); };
  35728. }, {
  35729. // 23.1.3.6 Map.prototype.get(key)
  35730. get: function get(key){
  35731. var entry = strong.getEntry(this, key);
  35732. return entry && entry.v;
  35733. },
  35734. // 23.1.3.9 Map.prototype.set(key, value)
  35735. set: function set(key, value){
  35736. return strong.def(this, key === 0 ? 0 : key, value);
  35737. }
  35738. }, strong, true);
  35739. /***/ },
  35740. /* 192 */
  35741. /***/ function(module, exports, __webpack_require__) {
  35742. // 21.2.5.3 get RegExp.prototype.flags()
  35743. if(__webpack_require__(10) && /./g.flags != 'g')__webpack_require__(11).f(RegExp.prototype, 'flags', {
  35744. configurable: true,
  35745. get: __webpack_require__(85)
  35746. });
  35747. /***/ },
  35748. /* 193 */
  35749. /***/ function(module, exports, __webpack_require__) {
  35750. "use strict";
  35751. 'use strict';
  35752. var strong = __webpack_require__(173);
  35753. // 23.2 Set Objects
  35754. module.exports = __webpack_require__(83)('Set', function(get){
  35755. return function Set(){ return get(this, arguments.length > 0 ? arguments[0] : undefined); };
  35756. }, {
  35757. // 23.2.3.1 Set.prototype.add(value)
  35758. add: function add(value){
  35759. return strong.def(this, value = value === 0 ? 0 : value, value);
  35760. }
  35761. }, strong);
  35762. /***/ },
  35763. /* 194 */
  35764. /***/ function(module, exports, __webpack_require__) {
  35765. "use strict";
  35766. 'use strict';
  35767. var each = __webpack_require__(31)(0)
  35768. , redefine = __webpack_require__(22)
  35769. , meta = __webpack_require__(40)
  35770. , assign = __webpack_require__(180)
  35771. , weak = __webpack_require__(175)
  35772. , isObject = __webpack_require__(7)
  35773. , has = __webpack_require__(17)
  35774. , getWeak = meta.getWeak
  35775. , isExtensible = Object.isExtensible
  35776. , uncaughtFrozenStore = weak.ufstore
  35777. , tmp = {}
  35778. , InternalMap;
  35779. var wrapper = function(get){
  35780. return function WeakMap(){
  35781. return get(this, arguments.length > 0 ? arguments[0] : undefined);
  35782. };
  35783. };
  35784. var methods = {
  35785. // 23.3.3.3 WeakMap.prototype.get(key)
  35786. get: function get(key){
  35787. if(isObject(key)){
  35788. var data = getWeak(key);
  35789. if(data === true)return uncaughtFrozenStore(this).get(key);
  35790. return data ? data[this._i] : undefined;
  35791. }
  35792. },
  35793. // 23.3.3.5 WeakMap.prototype.set(key, value)
  35794. set: function set(key, value){
  35795. return weak.def(this, key, value);
  35796. }
  35797. };
  35798. // 23.3 WeakMap Objects
  35799. var $WeakMap = module.exports = __webpack_require__(83)('WeakMap', wrapper, methods, weak, true, true);
  35800. // IE11 WeakMap frozen keys fix
  35801. if(new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7){
  35802. InternalMap = weak.getConstructor(wrapper);
  35803. assign(InternalMap.prototype, methods);
  35804. meta.NEED = true;
  35805. each(['delete', 'has', 'get', 'set'], function(key){
  35806. var proto = $WeakMap.prototype
  35807. , method = proto[key];
  35808. redefine(proto, key, function(a, b){
  35809. // store frozen objects on internal weakmap shim
  35810. if(isObject(a) && !isExtensible(a)){
  35811. if(!this._f)this._f = new InternalMap;
  35812. var result = this._f[key](a, b);
  35813. return key == 'set' ? this : result;
  35814. // store all the rest on native weakmap
  35815. } return method.call(this, a, b);
  35816. });
  35817. });
  35818. }
  35819. /***/ },
  35820. /* 195 */
  35821. /***/ function(module, exports, __webpack_require__) {
  35822. "use strict";
  35823. 'use strict';
  35824. /*
  35825. * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  35826. * Digest Algorithm, as defined in RFC 1321.
  35827. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
  35828. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  35829. * Distributed under the BSD License
  35830. * See http://pajhome.org.uk/crypt/md5 for more info.
  35831. */
  35832. var helpers = __webpack_require__(478);
  35833. /*
  35834. * Calculate the MD5 of an array of little-endian words, and a bit length
  35835. */
  35836. function core_md5(x, len)
  35837. {
  35838. /* append padding */
  35839. x[len >> 5] |= 0x80 << ((len) % 32);
  35840. x[(((len + 64) >>> 9) << 4) + 14] = len;
  35841. var a = 1732584193;
  35842. var b = -271733879;
  35843. var c = -1732584194;
  35844. var d = 271733878;
  35845. for(var i = 0; i < x.length; i += 16)
  35846. {
  35847. var olda = a;
  35848. var oldb = b;
  35849. var oldc = c;
  35850. var oldd = d;
  35851. a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
  35852. d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
  35853. c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
  35854. b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
  35855. a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
  35856. d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
  35857. c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
  35858. b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
  35859. a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
  35860. d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
  35861. c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
  35862. b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
  35863. a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
  35864. d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
  35865. c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
  35866. b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
  35867. a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
  35868. d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
  35869. c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
  35870. b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
  35871. a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
  35872. d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
  35873. c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
  35874. b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
  35875. a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
  35876. d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
  35877. c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
  35878. b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
  35879. a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
  35880. d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
  35881. c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
  35882. b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
  35883. a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
  35884. d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
  35885. c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
  35886. b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
  35887. a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
  35888. d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
  35889. c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
  35890. b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
  35891. a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
  35892. d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
  35893. c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
  35894. b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
  35895. a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
  35896. d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
  35897. c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
  35898. b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
  35899. a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
  35900. d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
  35901. c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
  35902. b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
  35903. a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
  35904. d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
  35905. c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
  35906. b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
  35907. a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
  35908. d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
  35909. c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
  35910. b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
  35911. a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
  35912. d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
  35913. c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
  35914. b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
  35915. a = safe_add(a, olda);
  35916. b = safe_add(b, oldb);
  35917. c = safe_add(c, oldc);
  35918. d = safe_add(d, oldd);
  35919. }
  35920. return Array(a, b, c, d);
  35921. }
  35922. /*
  35923. * These functions implement the four basic operations the algorithm uses.
  35924. */
  35925. function md5_cmn(q, a, b, x, s, t)
  35926. {
  35927. return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
  35928. }
  35929. function md5_ff(a, b, c, d, x, s, t)
  35930. {
  35931. return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
  35932. }
  35933. function md5_gg(a, b, c, d, x, s, t)
  35934. {
  35935. return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
  35936. }
  35937. function md5_hh(a, b, c, d, x, s, t)
  35938. {
  35939. return md5_cmn(b ^ c ^ d, a, b, x, s, t);
  35940. }
  35941. function md5_ii(a, b, c, d, x, s, t)
  35942. {
  35943. return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
  35944. }
  35945. /*
  35946. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  35947. * to work around bugs in some JS interpreters.
  35948. */
  35949. function safe_add(x, y)
  35950. {
  35951. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  35952. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  35953. return (msw << 16) | (lsw & 0xFFFF);
  35954. }
  35955. /*
  35956. * Bitwise rotate a 32-bit number to the left.
  35957. */
  35958. function bit_rol(num, cnt)
  35959. {
  35960. return (num << cnt) | (num >>> (32 - cnt));
  35961. }
  35962. module.exports = function md5(buf) {
  35963. return helpers.hash(buf, core_md5, 16);
  35964. };
  35965. /***/ },
  35966. /* 196 */
  35967. /***/ function(module, exports, __webpack_require__) {
  35968. /* WEBPACK VAR INJECTION */(function(global) {module.exports = false;
  35969. // Only Node.JS has a process variable that is of [[Class]] process
  35970. try {
  35971. module.exports = Object.prototype.toString.call(global.process) === '[object process]'
  35972. } catch(e) {}
  35973. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(13)))
  35974. /***/ },
  35975. /* 197 */
  35976. /***/ function(module, exports, __webpack_require__) {
  35977. var randomBytes = __webpack_require__(73);
  35978. module.exports = findPrime;
  35979. findPrime.simpleSieve = simpleSieve;
  35980. findPrime.fermatTest = fermatTest;
  35981. var BN = __webpack_require__(12);
  35982. var TWENTYFOUR = new BN(24);
  35983. var MillerRabin = __webpack_require__(204);
  35984. var millerRabin = new MillerRabin();
  35985. var ONE = new BN(1);
  35986. var TWO = new BN(2);
  35987. var FIVE = new BN(5);
  35988. var SIXTEEN = new BN(16);
  35989. var EIGHT = new BN(8);
  35990. var TEN = new BN(10);
  35991. var THREE = new BN(3);
  35992. var SEVEN = new BN(7);
  35993. var ELEVEN = new BN(11);
  35994. var FOUR = new BN(4);
  35995. var TWELVE = new BN(12);
  35996. var primes = null;
  35997. function _getPrimes() {
  35998. if (primes !== null)
  35999. return primes;
  36000. var limit = 0x100000;
  36001. var res = [];
  36002. res[0] = 2;
  36003. for (var i = 1, k = 3; k < limit; k += 2) {
  36004. var sqrt = Math.ceil(Math.sqrt(k));
  36005. for (var j = 0; j < i && res[j] <= sqrt; j++)
  36006. if (k % res[j] === 0)
  36007. break;
  36008. if (i !== j && res[j] <= sqrt)
  36009. continue;
  36010. res[i++] = k;
  36011. }
  36012. primes = res;
  36013. return res;
  36014. }
  36015. function simpleSieve(p) {
  36016. var primes = _getPrimes();
  36017. for (var i = 0; i < primes.length; i++)
  36018. if (p.modn(primes[i]) === 0) {
  36019. if (p.cmpn(primes[i]) === 0) {
  36020. return true;
  36021. } else {
  36022. return false;
  36023. }
  36024. }
  36025. return true;
  36026. }
  36027. function fermatTest(p) {
  36028. var red = BN.mont(p);
  36029. return TWO.toRed(red).redPow(p.subn(1)).fromRed().cmpn(1) === 0;
  36030. }
  36031. function findPrime(bits, gen) {
  36032. if (bits < 16) {
  36033. // this is what openssl does
  36034. if (gen === 2 || gen === 5) {
  36035. return new BN([0x8c, 0x7b]);
  36036. } else {
  36037. return new BN([0x8c, 0x27]);
  36038. }
  36039. }
  36040. gen = new BN(gen);
  36041. var num, n2;
  36042. while (true) {
  36043. num = new BN(randomBytes(Math.ceil(bits / 8)));
  36044. while (num.bitLength() > bits) {
  36045. num.ishrn(1);
  36046. }
  36047. if (num.isEven()) {
  36048. num.iadd(ONE);
  36049. }
  36050. if (!num.testn(1)) {
  36051. num.iadd(TWO);
  36052. }
  36053. if (!gen.cmp(TWO)) {
  36054. while (num.mod(TWENTYFOUR).cmp(ELEVEN)) {
  36055. num.iadd(FOUR);
  36056. }
  36057. } else if (!gen.cmp(FIVE)) {
  36058. while (num.mod(TEN).cmp(THREE)) {
  36059. num.iadd(FOUR);
  36060. }
  36061. }
  36062. n2 = num.shrn(1);
  36063. if (simpleSieve(n2) && simpleSieve(num) &&
  36064. fermatTest(n2) && fermatTest(num) &&
  36065. millerRabin.test(n2) && millerRabin.test(num)) {
  36066. return num;
  36067. }
  36068. }
  36069. }
  36070. /***/ },
  36071. /* 198 */
  36072. /***/ function(module, exports, __webpack_require__) {
  36073. /* WEBPACK VAR INJECTION */(function(process) {module.exports = realpath
  36074. realpath.realpath = realpath
  36075. realpath.sync = realpathSync
  36076. realpath.realpathSync = realpathSync
  36077. realpath.monkeypatch = monkeypatch
  36078. realpath.unmonkeypatch = unmonkeypatch
  36079. var origRealpath = fs.realpath
  36080. var origRealpathSync = fs.realpathSync
  36081. var version = process.version
  36082. var ok = /^v[0-5]\./.test(version)
  36083. var old = __webpack_require__(501)
  36084. function newError (er) {
  36085. return er && er.syscall === 'realpath' && (
  36086. er.code === 'ELOOP' ||
  36087. er.code === 'ENOMEM' ||
  36088. er.code === 'ENAMETOOLONG'
  36089. )
  36090. }
  36091. function realpath (p, cache, cb) {
  36092. if (ok) {
  36093. return origRealpath(p, cache, cb)
  36094. }
  36095. if (typeof cache === 'function') {
  36096. cb = cache
  36097. cache = null
  36098. }
  36099. origRealpath(p, cache, function (er, result) {
  36100. if (newError(er)) {
  36101. old.realpath(p, cache, cb)
  36102. } else {
  36103. cb(er, result)
  36104. }
  36105. })
  36106. }
  36107. function realpathSync (p, cache) {
  36108. if (ok) {
  36109. return origRealpathSync(p, cache)
  36110. }
  36111. try {
  36112. return origRealpathSync(p, cache)
  36113. } catch (er) {
  36114. if (newError(er)) {
  36115. return old.realpathSync(p, cache)
  36116. } else {
  36117. throw er
  36118. }
  36119. }
  36120. }
  36121. function monkeypatch () {
  36122. fs.realpath = realpath
  36123. fs.realpathSync = realpathSync
  36124. }
  36125. function unmonkeypatch () {
  36126. fs.realpath = origRealpath
  36127. fs.realpathSync = origRealpathSync
  36128. }
  36129. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  36130. /***/ },
  36131. /* 199 */
  36132. /***/ function(module, exports, __webpack_require__) {
  36133. /* WEBPACK VAR INJECTION */(function(process) {exports.alphasort = alphasort
  36134. exports.alphasorti = alphasorti
  36135. exports.setopts = setopts
  36136. exports.ownProp = ownProp
  36137. exports.makeAbs = makeAbs
  36138. exports.finish = finish
  36139. exports.mark = mark
  36140. exports.isIgnored = isIgnored
  36141. exports.childrenIgnored = childrenIgnored
  36142. function ownProp (obj, field) {
  36143. return Object.prototype.hasOwnProperty.call(obj, field)
  36144. }
  36145. var path = __webpack_require__(43)
  36146. var minimatch = __webpack_require__(135)
  36147. var isAbsolute = __webpack_require__(137)
  36148. var Minimatch = minimatch.Minimatch
  36149. function alphasorti (a, b) {
  36150. return a.toLowerCase().localeCompare(b.toLowerCase())
  36151. }
  36152. function alphasort (a, b) {
  36153. return a.localeCompare(b)
  36154. }
  36155. function setupIgnores (self, options) {
  36156. self.ignore = options.ignore || []
  36157. if (!Array.isArray(self.ignore))
  36158. self.ignore = [self.ignore]
  36159. if (self.ignore.length) {
  36160. self.ignore = self.ignore.map(ignoreMap)
  36161. }
  36162. }
  36163. // ignore patterns are always in dot:true mode.
  36164. function ignoreMap (pattern) {
  36165. var gmatcher = null
  36166. if (pattern.slice(-3) === '/**') {
  36167. var gpattern = pattern.replace(/(\/\*\*)+$/, '')
  36168. gmatcher = new Minimatch(gpattern, { dot: true })
  36169. }
  36170. return {
  36171. matcher: new Minimatch(pattern, { dot: true }),
  36172. gmatcher: gmatcher
  36173. }
  36174. }
  36175. function setopts (self, pattern, options) {
  36176. if (!options)
  36177. options = {}
  36178. // base-matching: just use globstar for that.
  36179. if (options.matchBase && -1 === pattern.indexOf("/")) {
  36180. if (options.noglobstar) {
  36181. throw new Error("base matching requires globstar")
  36182. }
  36183. pattern = "**/" + pattern
  36184. }
  36185. self.silent = !!options.silent
  36186. self.pattern = pattern
  36187. self.strict = options.strict !== false
  36188. self.realpath = !!options.realpath
  36189. self.realpathCache = options.realpathCache || Object.create(null)
  36190. self.follow = !!options.follow
  36191. self.dot = !!options.dot
  36192. self.mark = !!options.mark
  36193. self.nodir = !!options.nodir
  36194. if (self.nodir)
  36195. self.mark = true
  36196. self.sync = !!options.sync
  36197. self.nounique = !!options.nounique
  36198. self.nonull = !!options.nonull
  36199. self.nosort = !!options.nosort
  36200. self.nocase = !!options.nocase
  36201. self.stat = !!options.stat
  36202. self.noprocess = !!options.noprocess
  36203. self.maxLength = options.maxLength || Infinity
  36204. self.cache = options.cache || Object.create(null)
  36205. self.statCache = options.statCache || Object.create(null)
  36206. self.symlinks = options.symlinks || Object.create(null)
  36207. setupIgnores(self, options)
  36208. self.changedCwd = false
  36209. var cwd = process.cwd()
  36210. if (!ownProp(options, "cwd"))
  36211. self.cwd = cwd
  36212. else {
  36213. self.cwd = path.resolve(options.cwd)
  36214. self.changedCwd = self.cwd !== cwd
  36215. }
  36216. self.root = options.root || path.resolve(self.cwd, "/")
  36217. self.root = path.resolve(self.root)
  36218. if (process.platform === "win32")
  36219. self.root = self.root.replace(/\\/g, "/")
  36220. self.cwdAbs = makeAbs(self, self.cwd)
  36221. self.nomount = !!options.nomount
  36222. // disable comments and negation in Minimatch.
  36223. // Note that they are not supported in Glob itself anyway.
  36224. options.nonegate = true
  36225. options.nocomment = true
  36226. self.minimatch = new Minimatch(pattern, options)
  36227. self.options = self.minimatch.options
  36228. }
  36229. function finish (self) {
  36230. var nou = self.nounique
  36231. var all = nou ? [] : Object.create(null)
  36232. for (var i = 0, l = self.matches.length; i < l; i ++) {
  36233. var matches = self.matches[i]
  36234. if (!matches || Object.keys(matches).length === 0) {
  36235. if (self.nonull) {
  36236. // do like the shell, and spit out the literal glob
  36237. var literal = self.minimatch.globSet[i]
  36238. if (nou)
  36239. all.push(literal)
  36240. else
  36241. all[literal] = true
  36242. }
  36243. } else {
  36244. // had matches
  36245. var m = Object.keys(matches)
  36246. if (nou)
  36247. all.push.apply(all, m)
  36248. else
  36249. m.forEach(function (m) {
  36250. all[m] = true
  36251. })
  36252. }
  36253. }
  36254. if (!nou)
  36255. all = Object.keys(all)
  36256. if (!self.nosort)
  36257. all = all.sort(self.nocase ? alphasorti : alphasort)
  36258. // at *some* point we statted all of these
  36259. if (self.mark) {
  36260. for (var i = 0; i < all.length; i++) {
  36261. all[i] = self._mark(all[i])
  36262. }
  36263. if (self.nodir) {
  36264. all = all.filter(function (e) {
  36265. var notDir = !(/\/$/.test(e))
  36266. var c = self.cache[e] || self.cache[makeAbs(self, e)]
  36267. if (notDir && c)
  36268. notDir = c !== 'DIR' && !Array.isArray(c)
  36269. return notDir
  36270. })
  36271. }
  36272. }
  36273. if (self.ignore.length)
  36274. all = all.filter(function(m) {
  36275. return !isIgnored(self, m)
  36276. })
  36277. self.found = all
  36278. }
  36279. function mark (self, p) {
  36280. var abs = makeAbs(self, p)
  36281. var c = self.cache[abs]
  36282. var m = p
  36283. if (c) {
  36284. var isDir = c === 'DIR' || Array.isArray(c)
  36285. var slash = p.slice(-1) === '/'
  36286. if (isDir && !slash)
  36287. m += '/'
  36288. else if (!isDir && slash)
  36289. m = m.slice(0, -1)
  36290. if (m !== p) {
  36291. var mabs = makeAbs(self, m)
  36292. self.statCache[mabs] = self.statCache[abs]
  36293. self.cache[mabs] = self.cache[abs]
  36294. }
  36295. }
  36296. return m
  36297. }
  36298. // lotta situps...
  36299. function makeAbs (self, f) {
  36300. var abs = f
  36301. if (f.charAt(0) === '/') {
  36302. abs = path.join(self.root, f)
  36303. } else if (isAbsolute(f) || f === '') {
  36304. abs = f
  36305. } else if (self.changedCwd) {
  36306. abs = path.resolve(self.cwd, f)
  36307. } else {
  36308. abs = path.resolve(f)
  36309. }
  36310. if (process.platform === 'win32')
  36311. abs = abs.replace(/\\/g, '/')
  36312. return abs
  36313. }
  36314. // Return true, if pattern ends with globstar '**', for the accompanying parent directory.
  36315. // Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents
  36316. function isIgnored (self, path) {
  36317. if (!self.ignore.length)
  36318. return false
  36319. return self.ignore.some(function(item) {
  36320. return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path))
  36321. })
  36322. }
  36323. function childrenIgnored (self, path) {
  36324. if (!self.ignore.length)
  36325. return false
  36326. return self.ignore.some(function(item) {
  36327. return !!(item.gmatcher && item.gmatcher.match(path))
  36328. })
  36329. }
  36330. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  36331. /***/ },
  36332. /* 200 */
  36333. /***/ function(module, exports, __webpack_require__) {
  36334. /* WEBPACK VAR INJECTION */(function(process) {// Approach:
  36335. //
  36336. // 1. Get the minimatch set
  36337. // 2. For each pattern in the set, PROCESS(pattern, false)
  36338. // 3. Store matches per-set, then uniq them
  36339. //
  36340. // PROCESS(pattern, inGlobStar)
  36341. // Get the first [n] items from pattern that are all strings
  36342. // Join these together. This is PREFIX.
  36343. // If there is no more remaining, then stat(PREFIX) and
  36344. // add to matches if it succeeds. END.
  36345. //
  36346. // If inGlobStar and PREFIX is symlink and points to dir
  36347. // set ENTRIES = []
  36348. // else readdir(PREFIX) as ENTRIES
  36349. // If fail, END
  36350. //
  36351. // with ENTRIES
  36352. // If pattern[n] is GLOBSTAR
  36353. // // handle the case where the globstar match is empty
  36354. // // by pruning it out, and testing the resulting pattern
  36355. // PROCESS(pattern[0..n] + pattern[n+1 .. $], false)
  36356. // // handle other cases.
  36357. // for ENTRY in ENTRIES (not dotfiles)
  36358. // // attach globstar + tail onto the entry
  36359. // // Mark that this entry is a globstar match
  36360. // PROCESS(pattern[0..n] + ENTRY + pattern[n .. $], true)
  36361. //
  36362. // else // not globstar
  36363. // for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot)
  36364. // Test ENTRY against pattern[n]
  36365. // If fails, continue
  36366. // If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $])
  36367. //
  36368. // Caveat:
  36369. // Cache all stats and readdirs results to minimize syscall. Since all
  36370. // we ever care about is existence and directory-ness, we can just keep
  36371. // `true` for files, and [children,...] for directories, or `false` for
  36372. // things that don't exist.
  36373. module.exports = glob
  36374. var rp = __webpack_require__(198)
  36375. var minimatch = __webpack_require__(135)
  36376. var Minimatch = minimatch.Minimatch
  36377. var inherits = __webpack_require__(2)
  36378. var EE = __webpack_require__(30).EventEmitter
  36379. var path = __webpack_require__(43)
  36380. var assert = __webpack_require__(144)
  36381. var isAbsolute = __webpack_require__(137)
  36382. var globSync = __webpack_require__(504)
  36383. var common = __webpack_require__(199)
  36384. var alphasort = common.alphasort
  36385. var alphasorti = common.alphasorti
  36386. var setopts = common.setopts
  36387. var ownProp = common.ownProp
  36388. var inflight = __webpack_require__(513)
  36389. var util = __webpack_require__(44)
  36390. var childrenIgnored = common.childrenIgnored
  36391. var isIgnored = common.isIgnored
  36392. var once = __webpack_require__(208)
  36393. function glob (pattern, options, cb) {
  36394. if (typeof options === 'function') cb = options, options = {}
  36395. if (!options) options = {}
  36396. if (options.sync) {
  36397. if (cb)
  36398. throw new TypeError('callback provided to sync glob')
  36399. return globSync(pattern, options)
  36400. }
  36401. return new Glob(pattern, options, cb)
  36402. }
  36403. glob.sync = globSync
  36404. var GlobSync = glob.GlobSync = globSync.GlobSync
  36405. // old api surface
  36406. glob.glob = glob
  36407. function extend (origin, add) {
  36408. if (add === null || typeof add !== 'object') {
  36409. return origin
  36410. }
  36411. var keys = Object.keys(add)
  36412. var i = keys.length
  36413. while (i--) {
  36414. origin[keys[i]] = add[keys[i]]
  36415. }
  36416. return origin
  36417. }
  36418. glob.hasMagic = function (pattern, options_) {
  36419. var options = extend({}, options_)
  36420. options.noprocess = true
  36421. var g = new Glob(pattern, options)
  36422. var set = g.minimatch.set
  36423. if (set.length > 1)
  36424. return true
  36425. for (var j = 0; j < set[0].length; j++) {
  36426. if (typeof set[0][j] !== 'string')
  36427. return true
  36428. }
  36429. return false
  36430. }
  36431. glob.Glob = Glob
  36432. inherits(Glob, EE)
  36433. function Glob (pattern, options, cb) {
  36434. if (typeof options === 'function') {
  36435. cb = options
  36436. options = null
  36437. }
  36438. if (options && options.sync) {
  36439. if (cb)
  36440. throw new TypeError('callback provided to sync glob')
  36441. return new GlobSync(pattern, options)
  36442. }
  36443. if (!(this instanceof Glob))
  36444. return new Glob(pattern, options, cb)
  36445. setopts(this, pattern, options)
  36446. this._didRealPath = false
  36447. // process each pattern in the minimatch set
  36448. var n = this.minimatch.set.length
  36449. // The matches are stored as {<filename>: true,...} so that
  36450. // duplicates are automagically pruned.
  36451. // Later, we do an Object.keys() on these.
  36452. // Keep them as a list so we can fill in when nonull is set.
  36453. this.matches = new Array(n)
  36454. if (typeof cb === 'function') {
  36455. cb = once(cb)
  36456. this.on('error', cb)
  36457. this.on('end', function (matches) {
  36458. cb(null, matches)
  36459. })
  36460. }
  36461. var self = this
  36462. var n = this.minimatch.set.length
  36463. this._processing = 0
  36464. this.matches = new Array(n)
  36465. this._emitQueue = []
  36466. this._processQueue = []
  36467. this.paused = false
  36468. if (this.noprocess)
  36469. return this
  36470. if (n === 0)
  36471. return done()
  36472. var sync = true
  36473. for (var i = 0; i < n; i ++) {
  36474. this._process(this.minimatch.set[i], i, false, done)
  36475. }
  36476. sync = false
  36477. function done () {
  36478. --self._processing
  36479. if (self._processing <= 0) {
  36480. if (sync) {
  36481. process.nextTick(function () {
  36482. self._finish()
  36483. })
  36484. } else {
  36485. self._finish()
  36486. }
  36487. }
  36488. }
  36489. }
  36490. Glob.prototype._finish = function () {
  36491. assert(this instanceof Glob)
  36492. if (this.aborted)
  36493. return
  36494. if (this.realpath && !this._didRealpath)
  36495. return this._realpath()
  36496. common.finish(this)
  36497. this.emit('end', this.found)
  36498. }
  36499. Glob.prototype._realpath = function () {
  36500. if (this._didRealpath)
  36501. return
  36502. this._didRealpath = true
  36503. var n = this.matches.length
  36504. if (n === 0)
  36505. return this._finish()
  36506. var self = this
  36507. for (var i = 0; i < this.matches.length; i++)
  36508. this._realpathSet(i, next)
  36509. function next () {
  36510. if (--n === 0)
  36511. self._finish()
  36512. }
  36513. }
  36514. Glob.prototype._realpathSet = function (index, cb) {
  36515. var matchset = this.matches[index]
  36516. if (!matchset)
  36517. return cb()
  36518. var found = Object.keys(matchset)
  36519. var self = this
  36520. var n = found.length
  36521. if (n === 0)
  36522. return cb()
  36523. var set = this.matches[index] = Object.create(null)
  36524. found.forEach(function (p, i) {
  36525. // If there's a problem with the stat, then it means that
  36526. // one or more of the links in the realpath couldn't be
  36527. // resolved. just return the abs value in that case.
  36528. p = self._makeAbs(p)
  36529. rp.realpath(p, self.realpathCache, function (er, real) {
  36530. if (!er)
  36531. set[real] = true
  36532. else if (er.syscall === 'stat')
  36533. set[p] = true
  36534. else
  36535. self.emit('error', er) // srsly wtf right here
  36536. if (--n === 0) {
  36537. self.matches[index] = set
  36538. cb()
  36539. }
  36540. })
  36541. })
  36542. }
  36543. Glob.prototype._mark = function (p) {
  36544. return common.mark(this, p)
  36545. }
  36546. Glob.prototype._makeAbs = function (f) {
  36547. return common.makeAbs(this, f)
  36548. }
  36549. Glob.prototype.abort = function () {
  36550. this.aborted = true
  36551. this.emit('abort')
  36552. }
  36553. Glob.prototype.pause = function () {
  36554. if (!this.paused) {
  36555. this.paused = true
  36556. this.emit('pause')
  36557. }
  36558. }
  36559. Glob.prototype.resume = function () {
  36560. if (this.paused) {
  36561. this.emit('resume')
  36562. this.paused = false
  36563. if (this._emitQueue.length) {
  36564. var eq = this._emitQueue.slice(0)
  36565. this._emitQueue.length = 0
  36566. for (var i = 0; i < eq.length; i ++) {
  36567. var e = eq[i]
  36568. this._emitMatch(e[0], e[1])
  36569. }
  36570. }
  36571. if (this._processQueue.length) {
  36572. var pq = this._processQueue.slice(0)
  36573. this._processQueue.length = 0
  36574. for (var i = 0; i < pq.length; i ++) {
  36575. var p = pq[i]
  36576. this._processing--
  36577. this._process(p[0], p[1], p[2], p[3])
  36578. }
  36579. }
  36580. }
  36581. }
  36582. Glob.prototype._process = function (pattern, index, inGlobStar, cb) {
  36583. assert(this instanceof Glob)
  36584. assert(typeof cb === 'function')
  36585. if (this.aborted)
  36586. return
  36587. this._processing++
  36588. if (this.paused) {
  36589. this._processQueue.push([pattern, index, inGlobStar, cb])
  36590. return
  36591. }
  36592. //console.error('PROCESS %d', this._processing, pattern)
  36593. // Get the first [n] parts of pattern that are all strings.
  36594. var n = 0
  36595. while (typeof pattern[n] === 'string') {
  36596. n ++
  36597. }
  36598. // now n is the index of the first one that is *not* a string.
  36599. // see if there's anything else
  36600. var prefix
  36601. switch (n) {
  36602. // if not, then this is rather simple
  36603. case pattern.length:
  36604. this._processSimple(pattern.join('/'), index, cb)
  36605. return
  36606. case 0:
  36607. // pattern *starts* with some non-trivial item.
  36608. // going to readdir(cwd), but not include the prefix in matches.
  36609. prefix = null
  36610. break
  36611. default:
  36612. // pattern has some string bits in the front.
  36613. // whatever it starts with, whether that's 'absolute' like /foo/bar,
  36614. // or 'relative' like '../baz'
  36615. prefix = pattern.slice(0, n).join('/')
  36616. break
  36617. }
  36618. var remain = pattern.slice(n)
  36619. // get the list of entries.
  36620. var read
  36621. if (prefix === null)
  36622. read = '.'
  36623. else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) {
  36624. if (!prefix || !isAbsolute(prefix))
  36625. prefix = '/' + prefix
  36626. read = prefix
  36627. } else
  36628. read = prefix
  36629. var abs = this._makeAbs(read)
  36630. //if ignored, skip _processing
  36631. if (childrenIgnored(this, read))
  36632. return cb()
  36633. var isGlobStar = remain[0] === minimatch.GLOBSTAR
  36634. if (isGlobStar)
  36635. this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb)
  36636. else
  36637. this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb)
  36638. }
  36639. Glob.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar, cb) {
  36640. var self = this
  36641. this._readdir(abs, inGlobStar, function (er, entries) {
  36642. return self._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb)
  36643. })
  36644. }
  36645. Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {
  36646. // if the abs isn't a dir, then nothing can match!
  36647. if (!entries)
  36648. return cb()
  36649. // It will only match dot entries if it starts with a dot, or if
  36650. // dot is set. Stuff like @(.foo|.bar) isn't allowed.
  36651. var pn = remain[0]
  36652. var negate = !!this.minimatch.negate
  36653. var rawGlob = pn._glob
  36654. var dotOk = this.dot || rawGlob.charAt(0) === '.'
  36655. var matchedEntries = []
  36656. for (var i = 0; i < entries.length; i++) {
  36657. var e = entries[i]
  36658. if (e.charAt(0) !== '.' || dotOk) {
  36659. var m
  36660. if (negate && !prefix) {
  36661. m = !e.match(pn)
  36662. } else {
  36663. m = e.match(pn)
  36664. }
  36665. if (m)
  36666. matchedEntries.push(e)
  36667. }
  36668. }
  36669. //console.error('prd2', prefix, entries, remain[0]._glob, matchedEntries)
  36670. var len = matchedEntries.length
  36671. // If there are no matched entries, then nothing matches.
  36672. if (len === 0)
  36673. return cb()
  36674. // if this is the last remaining pattern bit, then no need for
  36675. // an additional stat *unless* the user has specified mark or
  36676. // stat explicitly. We know they exist, since readdir returned
  36677. // them.
  36678. if (remain.length === 1 && !this.mark && !this.stat) {
  36679. if (!this.matches[index])
  36680. this.matches[index] = Object.create(null)
  36681. for (var i = 0; i < len; i ++) {
  36682. var e = matchedEntries[i]
  36683. if (prefix) {
  36684. if (prefix !== '/')
  36685. e = prefix + '/' + e
  36686. else
  36687. e = prefix + e
  36688. }
  36689. if (e.charAt(0) === '/' && !this.nomount) {
  36690. e = path.join(this.root, e)
  36691. }
  36692. this._emitMatch(index, e)
  36693. }
  36694. // This was the last one, and no stats were needed
  36695. return cb()
  36696. }
  36697. // now test all matched entries as stand-ins for that part
  36698. // of the pattern.
  36699. remain.shift()
  36700. for (var i = 0; i < len; i ++) {
  36701. var e = matchedEntries[i]
  36702. var newPattern
  36703. if (prefix) {
  36704. if (prefix !== '/')
  36705. e = prefix + '/' + e
  36706. else
  36707. e = prefix + e
  36708. }
  36709. this._process([e].concat(remain), index, inGlobStar, cb)
  36710. }
  36711. cb()
  36712. }
  36713. Glob.prototype._emitMatch = function (index, e) {
  36714. if (this.aborted)
  36715. return
  36716. if (this.matches[index][e])
  36717. return
  36718. if (isIgnored(this, e))
  36719. return
  36720. if (this.paused) {
  36721. this._emitQueue.push([index, e])
  36722. return
  36723. }
  36724. var abs = this._makeAbs(e)
  36725. if (this.nodir) {
  36726. var c = this.cache[abs]
  36727. if (c === 'DIR' || Array.isArray(c))
  36728. return
  36729. }
  36730. if (this.mark)
  36731. e = this._mark(e)
  36732. this.matches[index][e] = true
  36733. var st = this.statCache[abs]
  36734. if (st)
  36735. this.emit('stat', e, st)
  36736. this.emit('match', e)
  36737. }
  36738. Glob.prototype._readdirInGlobStar = function (abs, cb) {
  36739. if (this.aborted)
  36740. return
  36741. // follow all symlinked directories forever
  36742. // just proceed as if this is a non-globstar situation
  36743. if (this.follow)
  36744. return this._readdir(abs, false, cb)
  36745. var lstatkey = 'lstat\0' + abs
  36746. var self = this
  36747. var lstatcb = inflight(lstatkey, lstatcb_)
  36748. if (lstatcb)
  36749. fs.lstat(abs, lstatcb)
  36750. function lstatcb_ (er, lstat) {
  36751. if (er)
  36752. return cb()
  36753. var isSym = lstat.isSymbolicLink()
  36754. self.symlinks[abs] = isSym
  36755. // If it's not a symlink or a dir, then it's definitely a regular file.
  36756. // don't bother doing a readdir in that case.
  36757. if (!isSym && !lstat.isDirectory()) {
  36758. self.cache[abs] = 'FILE'
  36759. cb()
  36760. } else
  36761. self._readdir(abs, false, cb)
  36762. }
  36763. }
  36764. Glob.prototype._readdir = function (abs, inGlobStar, cb) {
  36765. if (this.aborted)
  36766. return
  36767. cb = inflight('readdir\0'+abs+'\0'+inGlobStar, cb)
  36768. if (!cb)
  36769. return
  36770. //console.error('RD %j %j', +inGlobStar, abs)
  36771. if (inGlobStar && !ownProp(this.symlinks, abs))
  36772. return this._readdirInGlobStar(abs, cb)
  36773. if (ownProp(this.cache, abs)) {
  36774. var c = this.cache[abs]
  36775. if (!c || c === 'FILE')
  36776. return cb()
  36777. if (Array.isArray(c))
  36778. return cb(null, c)
  36779. }
  36780. var self = this
  36781. fs.readdir(abs, readdirCb(this, abs, cb))
  36782. }
  36783. function readdirCb (self, abs, cb) {
  36784. return function (er, entries) {
  36785. if (er)
  36786. self._readdirError(abs, er, cb)
  36787. else
  36788. self._readdirEntries(abs, entries, cb)
  36789. }
  36790. }
  36791. Glob.prototype._readdirEntries = function (abs, entries, cb) {
  36792. if (this.aborted)
  36793. return
  36794. // if we haven't asked to stat everything, then just
  36795. // assume that everything in there exists, so we can avoid
  36796. // having to stat it a second time.
  36797. if (!this.mark && !this.stat) {
  36798. for (var i = 0; i < entries.length; i ++) {
  36799. var e = entries[i]
  36800. if (abs === '/')
  36801. e = abs + e
  36802. else
  36803. e = abs + '/' + e
  36804. this.cache[e] = true
  36805. }
  36806. }
  36807. this.cache[abs] = entries
  36808. return cb(null, entries)
  36809. }
  36810. Glob.prototype._readdirError = function (f, er, cb) {
  36811. if (this.aborted)
  36812. return
  36813. // handle errors, and cache the information
  36814. switch (er.code) {
  36815. case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205
  36816. case 'ENOTDIR': // totally normal. means it *does* exist.
  36817. var abs = this._makeAbs(f)
  36818. this.cache[abs] = 'FILE'
  36819. if (abs === this.cwdAbs) {
  36820. var error = new Error(er.code + ' invalid cwd ' + this.cwd)
  36821. error.path = this.cwd
  36822. error.code = er.code
  36823. this.emit('error', error)
  36824. this.abort()
  36825. }
  36826. break
  36827. case 'ENOENT': // not terribly unusual
  36828. case 'ELOOP':
  36829. case 'ENAMETOOLONG':
  36830. case 'UNKNOWN':
  36831. this.cache[this._makeAbs(f)] = false
  36832. break
  36833. default: // some unusual error. Treat as failure.
  36834. this.cache[this._makeAbs(f)] = false
  36835. if (this.strict) {
  36836. this.emit('error', er)
  36837. // If the error is handled, then we abort
  36838. // if not, we threw out of here
  36839. this.abort()
  36840. }
  36841. if (!this.silent)
  36842. console.error('glob error', er)
  36843. break
  36844. }
  36845. return cb()
  36846. }
  36847. Glob.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar, cb) {
  36848. var self = this
  36849. this._readdir(abs, inGlobStar, function (er, entries) {
  36850. self._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb)
  36851. })
  36852. }
  36853. Glob.prototype._processGlobStar2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {
  36854. //console.error('pgs2', prefix, remain[0], entries)
  36855. // no entries means not a dir, so it can never have matches
  36856. // foo.txt/** doesn't match foo.txt
  36857. if (!entries)
  36858. return cb()
  36859. // test without the globstar, and with every child both below
  36860. // and replacing the globstar.
  36861. var remainWithoutGlobStar = remain.slice(1)
  36862. var gspref = prefix ? [ prefix ] : []
  36863. var noGlobStar = gspref.concat(remainWithoutGlobStar)
  36864. // the noGlobStar pattern exits the inGlobStar state
  36865. this._process(noGlobStar, index, false, cb)
  36866. var isSym = this.symlinks[abs]
  36867. var len = entries.length
  36868. // If it's a symlink, and we're in a globstar, then stop
  36869. if (isSym && inGlobStar)
  36870. return cb()
  36871. for (var i = 0; i < len; i++) {
  36872. var e = entries[i]
  36873. if (e.charAt(0) === '.' && !this.dot)
  36874. continue
  36875. // these two cases enter the inGlobStar state
  36876. var instead = gspref.concat(entries[i], remainWithoutGlobStar)
  36877. this._process(instead, index, true, cb)
  36878. var below = gspref.concat(entries[i], remain)
  36879. this._process(below, index, true, cb)
  36880. }
  36881. cb()
  36882. }
  36883. Glob.prototype._processSimple = function (prefix, index, cb) {
  36884. // XXX review this. Shouldn't it be doing the mounting etc
  36885. // before doing stat? kinda weird?
  36886. var self = this
  36887. this._stat(prefix, function (er, exists) {
  36888. self._processSimple2(prefix, index, er, exists, cb)
  36889. })
  36890. }
  36891. Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) {
  36892. //console.error('ps2', prefix, exists)
  36893. if (!this.matches[index])
  36894. this.matches[index] = Object.create(null)
  36895. // If it doesn't exist, then just mark the lack of results
  36896. if (!exists)
  36897. return cb()
  36898. if (prefix && isAbsolute(prefix) && !this.nomount) {
  36899. var trail = /[\/\\]$/.test(prefix)
  36900. if (prefix.charAt(0) === '/') {
  36901. prefix = path.join(this.root, prefix)
  36902. } else {
  36903. prefix = path.resolve(this.root, prefix)
  36904. if (trail)
  36905. prefix += '/'
  36906. }
  36907. }
  36908. if (process.platform === 'win32')
  36909. prefix = prefix.replace(/\\/g, '/')
  36910. // Mark this as a match
  36911. this._emitMatch(index, prefix)
  36912. cb()
  36913. }
  36914. // Returns either 'DIR', 'FILE', or false
  36915. Glob.prototype._stat = function (f, cb) {
  36916. var abs = this._makeAbs(f)
  36917. var needDir = f.slice(-1) === '/'
  36918. if (f.length > this.maxLength)
  36919. return cb()
  36920. if (!this.stat && ownProp(this.cache, abs)) {
  36921. var c = this.cache[abs]
  36922. if (Array.isArray(c))
  36923. c = 'DIR'
  36924. // It exists, but maybe not how we need it
  36925. if (!needDir || c === 'DIR')
  36926. return cb(null, c)
  36927. if (needDir && c === 'FILE')
  36928. return cb()
  36929. // otherwise we have to stat, because maybe c=true
  36930. // if we know it exists, but not what it is.
  36931. }
  36932. var exists
  36933. var stat = this.statCache[abs]
  36934. if (stat !== undefined) {
  36935. if (stat === false)
  36936. return cb(null, stat)
  36937. else {
  36938. var type = stat.isDirectory() ? 'DIR' : 'FILE'
  36939. if (needDir && type === 'FILE')
  36940. return cb()
  36941. else
  36942. return cb(null, type, stat)
  36943. }
  36944. }
  36945. var self = this
  36946. var statcb = inflight('stat\0' + abs, lstatcb_)
  36947. if (statcb)
  36948. fs.lstat(abs, statcb)
  36949. function lstatcb_ (er, lstat) {
  36950. if (lstat && lstat.isSymbolicLink()) {
  36951. // If it's a symlink, then treat it as the target, unless
  36952. // the target does not exist, then treat it as a file.
  36953. return fs.stat(abs, function (er, stat) {
  36954. if (er)
  36955. self._stat2(f, abs, null, lstat, cb)
  36956. else
  36957. self._stat2(f, abs, er, stat, cb)
  36958. })
  36959. } else {
  36960. self._stat2(f, abs, er, lstat, cb)
  36961. }
  36962. }
  36963. }
  36964. Glob.prototype._stat2 = function (f, abs, er, stat, cb) {
  36965. if (er) {
  36966. this.statCache[abs] = false
  36967. return cb()
  36968. }
  36969. var needDir = f.slice(-1) === '/'
  36970. this.statCache[abs] = stat
  36971. if (abs.slice(-1) === '/' && !stat.isDirectory())
  36972. return cb(null, false, stat)
  36973. var c = stat.isDirectory() ? 'DIR' : 'FILE'
  36974. this.cache[abs] = this.cache[abs] || c
  36975. if (needDir && c !== 'DIR')
  36976. return cb()
  36977. return cb(null, c, stat)
  36978. }
  36979. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  36980. /***/ },
  36981. /* 201 */
  36982. /***/ function(module, exports, __webpack_require__) {
  36983. "use strict";
  36984. /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
  36985. var base58 = __webpack_require__(56);
  36986. var multihash = __webpack_require__(96);
  36987. var urlPattern = /^https?:\/\/[^\/]+\/(ip(f|n)s)\/((\w+).*)/;
  36988. var pathPattern = /^\/(ip(f|n)s)\/((\w+).*)/;
  36989. function isMultihash(hash) {
  36990. var formatted = convertToString(hash);
  36991. try {
  36992. var buffer = new Buffer(base58.decode(formatted));
  36993. multihash.decode(buffer);
  36994. return true;
  36995. } catch (e) {
  36996. return false;
  36997. }
  36998. }
  36999. function isIpfs(input, pattern) {
  37000. var formatted = convertToString(input);
  37001. if (!formatted) {
  37002. return false;
  37003. }
  37004. var match = formatted.match(pattern);
  37005. if (!match) {
  37006. return false;
  37007. }
  37008. if (match[1] !== 'ipfs') {
  37009. return false;
  37010. }
  37011. var hash = match[4];
  37012. return isMultihash(hash);
  37013. }
  37014. function isIpns(input, pattern) {
  37015. var formatted = convertToString(input);
  37016. if (!formatted) {
  37017. return false;
  37018. }
  37019. var match = formatted.match(pattern);
  37020. if (!match) {
  37021. return false;
  37022. }
  37023. if (match[1] !== 'ipns') {
  37024. return false;
  37025. }
  37026. return true;
  37027. }
  37028. function convertToString(input) {
  37029. if (Buffer.isBuffer(input)) {
  37030. return base58.encode(input);
  37031. }
  37032. if (typeof input === 'string') {
  37033. return input;
  37034. }
  37035. return false;
  37036. }
  37037. module.exports = {
  37038. multihash: isMultihash,
  37039. ipfsUrl: function ipfsUrl(url) {
  37040. return isIpfs(url, urlPattern);
  37041. },
  37042. ipnsUrl: function ipnsUrl(url) {
  37043. return isIpns(url, urlPattern);
  37044. },
  37045. url: function url(_url) {
  37046. return isIpfs(_url, urlPattern) || isIpns(_url, urlPattern);
  37047. },
  37048. urlPattern: urlPattern,
  37049. ipfsPath: function ipfsPath(path) {
  37050. return isIpfs(path, pathPattern);
  37051. },
  37052. ipnsPath: function ipnsPath(path) {
  37053. return isIpns(path, pathPattern);
  37054. },
  37055. path: function path(_path) {
  37056. return isIpfs(_path, pathPattern) || isIpns(_path, pathPattern);
  37057. },
  37058. pathPattern: pathPattern,
  37059. urlOrPath: function urlOrPath(x) {
  37060. return isIpfs(x, urlPattern) || isIpns(x, urlPattern) || isIpfs(x, pathPattern) || isIpns(x, pathPattern);
  37061. }
  37062. };
  37063. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  37064. /***/ },
  37065. /* 202 */
  37066. /***/ function(module, exports) {
  37067. /**
  37068. * lodash (Custom Build) <https://lodash.com/>
  37069. * Build: `lodash modularize exports="npm" -o ./`
  37070. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  37071. * Released under MIT license <https://lodash.com/license>
  37072. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  37073. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  37074. */
  37075. /** Used as references for various `Number` constants. */
  37076. var MAX_SAFE_INTEGER = 9007199254740991;
  37077. /** `Object#toString` result references. */
  37078. var argsTag = '[object Arguments]',
  37079. funcTag = '[object Function]',
  37080. genTag = '[object GeneratorFunction]',
  37081. stringTag = '[object String]';
  37082. /** Used to detect unsigned integer values. */
  37083. var reIsUint = /^(?:0|[1-9]\d*)$/;
  37084. /**
  37085. * The base implementation of `_.times` without support for iteratee shorthands
  37086. * or max array length checks.
  37087. *
  37088. * @private
  37089. * @param {number} n The number of times to invoke `iteratee`.
  37090. * @param {Function} iteratee The function invoked per iteration.
  37091. * @returns {Array} Returns the array of results.
  37092. */
  37093. function baseTimes(n, iteratee) {
  37094. var index = -1,
  37095. result = Array(n);
  37096. while (++index < n) {
  37097. result[index] = iteratee(index);
  37098. }
  37099. return result;
  37100. }
  37101. /** Used for built-in method references. */
  37102. var objectProto = Object.prototype;
  37103. /** Used to check objects for own properties. */
  37104. var hasOwnProperty = objectProto.hasOwnProperty;
  37105. /**
  37106. * Used to resolve the
  37107. * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  37108. * of values.
  37109. */
  37110. var objectToString = objectProto.toString;
  37111. /** Built-in value references. */
  37112. var propertyIsEnumerable = objectProto.propertyIsEnumerable;
  37113. /* Built-in method references for those with the same name as other `lodash` methods. */
  37114. var nativeGetPrototype = Object.getPrototypeOf,
  37115. nativeKeys = Object.keys;
  37116. /**
  37117. * The base implementation of `_.forEach` without support for iteratee shorthands.
  37118. *
  37119. * @private
  37120. * @param {Array|Object} collection The collection to iterate over.
  37121. * @param {Function} iteratee The function invoked per iteration.
  37122. * @returns {Array|Object} Returns `collection`.
  37123. */
  37124. var baseEach = createBaseEach(baseForOwn);
  37125. /**
  37126. * The base implementation of `baseForOwn` which iterates over `object`
  37127. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  37128. * Iteratee functions may exit iteration early by explicitly returning `false`.
  37129. *
  37130. * @private
  37131. * @param {Object} object The object to iterate over.
  37132. * @param {Function} iteratee The function invoked per iteration.
  37133. * @param {Function} keysFunc The function to get the keys of `object`.
  37134. * @returns {Object} Returns `object`.
  37135. */
  37136. var baseFor = createBaseFor();
  37137. /**
  37138. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  37139. *
  37140. * @private
  37141. * @param {Object} object The object to iterate over.
  37142. * @param {Function} iteratee The function invoked per iteration.
  37143. * @returns {Object} Returns `object`.
  37144. */
  37145. function baseForOwn(object, iteratee) {
  37146. return object && baseFor(object, iteratee, keys);
  37147. }
  37148. /**
  37149. * The base implementation of `_.has` without support for deep paths.
  37150. *
  37151. * @private
  37152. * @param {Object} object The object to query.
  37153. * @param {Array|string} key The key to check.
  37154. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  37155. */
  37156. function baseHas(object, key) {
  37157. // Avoid a bug in IE 10-11 where objects with a [[Prototype]] of `null`,
  37158. // that are composed entirely of index properties, return `false` for
  37159. // `hasOwnProperty` checks of them.
  37160. return hasOwnProperty.call(object, key) ||
  37161. (typeof object == 'object' && key in object && getPrototype(object) === null);
  37162. }
  37163. /**
  37164. * The base implementation of `_.keys` which doesn't skip the constructor
  37165. * property of prototypes or treat sparse arrays as dense.
  37166. *
  37167. * @private
  37168. * @param {Object} object The object to query.
  37169. * @returns {Array} Returns the array of property names.
  37170. */
  37171. function baseKeys(object) {
  37172. return nativeKeys(Object(object));
  37173. }
  37174. /**
  37175. * The base implementation of `_.property` without support for deep paths.
  37176. *
  37177. * @private
  37178. * @param {string} key The key of the property to get.
  37179. * @returns {Function} Returns the new accessor function.
  37180. */
  37181. function baseProperty(key) {
  37182. return function(object) {
  37183. return object == null ? undefined : object[key];
  37184. };
  37185. }
  37186. /**
  37187. * Creates a `baseEach` or `baseEachRight` function.
  37188. *
  37189. * @private
  37190. * @param {Function} eachFunc The function to iterate over a collection.
  37191. * @param {boolean} [fromRight] Specify iterating from right to left.
  37192. * @returns {Function} Returns the new base function.
  37193. */
  37194. function createBaseEach(eachFunc, fromRight) {
  37195. return function(collection, iteratee) {
  37196. if (collection == null) {
  37197. return collection;
  37198. }
  37199. if (!isArrayLike(collection)) {
  37200. return eachFunc(collection, iteratee);
  37201. }
  37202. var length = collection.length,
  37203. index = fromRight ? length : -1,
  37204. iterable = Object(collection);
  37205. while ((fromRight ? index-- : ++index < length)) {
  37206. if (iteratee(iterable[index], index, iterable) === false) {
  37207. break;
  37208. }
  37209. }
  37210. return collection;
  37211. };
  37212. }
  37213. /**
  37214. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  37215. *
  37216. * @private
  37217. * @param {boolean} [fromRight] Specify iterating from right to left.
  37218. * @returns {Function} Returns the new base function.
  37219. */
  37220. function createBaseFor(fromRight) {
  37221. return function(object, iteratee, keysFunc) {
  37222. var index = -1,
  37223. iterable = Object(object),
  37224. props = keysFunc(object),
  37225. length = props.length;
  37226. while (length--) {
  37227. var key = props[fromRight ? length : ++index];
  37228. if (iteratee(iterable[key], key, iterable) === false) {
  37229. break;
  37230. }
  37231. }
  37232. return object;
  37233. };
  37234. }
  37235. /**
  37236. * Gets the "length" property value of `object`.
  37237. *
  37238. * **Note:** This function is used to avoid a
  37239. * [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) that affects
  37240. * Safari on at least iOS 8.1-8.3 ARM64.
  37241. *
  37242. * @private
  37243. * @param {Object} object The object to query.
  37244. * @returns {*} Returns the "length" value.
  37245. */
  37246. var getLength = baseProperty('length');
  37247. /**
  37248. * Gets the `[[Prototype]]` of `value`.
  37249. *
  37250. * @private
  37251. * @param {*} value The value to query.
  37252. * @returns {null|Object} Returns the `[[Prototype]]`.
  37253. */
  37254. function getPrototype(value) {
  37255. return nativeGetPrototype(Object(value));
  37256. }
  37257. /**
  37258. * Creates an array of index keys for `object` values of arrays,
  37259. * `arguments` objects, and strings, otherwise `null` is returned.
  37260. *
  37261. * @private
  37262. * @param {Object} object The object to query.
  37263. * @returns {Array|null} Returns index keys, else `null`.
  37264. */
  37265. function indexKeys(object) {
  37266. var length = object ? object.length : undefined;
  37267. if (isLength(length) &&
  37268. (isArray(object) || isString(object) || isArguments(object))) {
  37269. return baseTimes(length, String);
  37270. }
  37271. return null;
  37272. }
  37273. /**
  37274. * Checks if `value` is a valid array-like index.
  37275. *
  37276. * @private
  37277. * @param {*} value The value to check.
  37278. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  37279. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  37280. */
  37281. function isIndex(value, length) {
  37282. length = length == null ? MAX_SAFE_INTEGER : length;
  37283. return !!length &&
  37284. (typeof value == 'number' || reIsUint.test(value)) &&
  37285. (value > -1 && value % 1 == 0 && value < length);
  37286. }
  37287. /**
  37288. * Checks if `value` is likely a prototype object.
  37289. *
  37290. * @private
  37291. * @param {*} value The value to check.
  37292. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  37293. */
  37294. function isPrototype(value) {
  37295. var Ctor = value && value.constructor,
  37296. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  37297. return value === proto;
  37298. }
  37299. /**
  37300. * Checks if `value` is likely an `arguments` object.
  37301. *
  37302. * @static
  37303. * @memberOf _
  37304. * @since 0.1.0
  37305. * @category Lang
  37306. * @param {*} value The value to check.
  37307. * @returns {boolean} Returns `true` if `value` is correctly classified,
  37308. * else `false`.
  37309. * @example
  37310. *
  37311. * _.isArguments(function() { return arguments; }());
  37312. * // => true
  37313. *
  37314. * _.isArguments([1, 2, 3]);
  37315. * // => false
  37316. */
  37317. function isArguments(value) {
  37318. // Safari 8.1 incorrectly makes `arguments.callee` enumerable in strict mode.
  37319. return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
  37320. (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
  37321. }
  37322. /**
  37323. * Checks if `value` is classified as an `Array` object.
  37324. *
  37325. * @static
  37326. * @memberOf _
  37327. * @since 0.1.0
  37328. * @type {Function}
  37329. * @category Lang
  37330. * @param {*} value The value to check.
  37331. * @returns {boolean} Returns `true` if `value` is correctly classified,
  37332. * else `false`.
  37333. * @example
  37334. *
  37335. * _.isArray([1, 2, 3]);
  37336. * // => true
  37337. *
  37338. * _.isArray(document.body.children);
  37339. * // => false
  37340. *
  37341. * _.isArray('abc');
  37342. * // => false
  37343. *
  37344. * _.isArray(_.noop);
  37345. * // => false
  37346. */
  37347. var isArray = Array.isArray;
  37348. /**
  37349. * Checks if `value` is array-like. A value is considered array-like if it's
  37350. * not a function and has a `value.length` that's an integer greater than or
  37351. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  37352. *
  37353. * @static
  37354. * @memberOf _
  37355. * @since 4.0.0
  37356. * @category Lang
  37357. * @param {*} value The value to check.
  37358. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  37359. * @example
  37360. *
  37361. * _.isArrayLike([1, 2, 3]);
  37362. * // => true
  37363. *
  37364. * _.isArrayLike(document.body.children);
  37365. * // => true
  37366. *
  37367. * _.isArrayLike('abc');
  37368. * // => true
  37369. *
  37370. * _.isArrayLike(_.noop);
  37371. * // => false
  37372. */
  37373. function isArrayLike(value) {
  37374. return value != null && isLength(getLength(value)) && !isFunction(value);
  37375. }
  37376. /**
  37377. * This method is like `_.isArrayLike` except that it also checks if `value`
  37378. * is an object.
  37379. *
  37380. * @static
  37381. * @memberOf _
  37382. * @since 4.0.0
  37383. * @category Lang
  37384. * @param {*} value The value to check.
  37385. * @returns {boolean} Returns `true` if `value` is an array-like object,
  37386. * else `false`.
  37387. * @example
  37388. *
  37389. * _.isArrayLikeObject([1, 2, 3]);
  37390. * // => true
  37391. *
  37392. * _.isArrayLikeObject(document.body.children);
  37393. * // => true
  37394. *
  37395. * _.isArrayLikeObject('abc');
  37396. * // => false
  37397. *
  37398. * _.isArrayLikeObject(_.noop);
  37399. * // => false
  37400. */
  37401. function isArrayLikeObject(value) {
  37402. return isObjectLike(value) && isArrayLike(value);
  37403. }
  37404. /**
  37405. * Checks if `value` is classified as a `Function` object.
  37406. *
  37407. * @static
  37408. * @memberOf _
  37409. * @since 0.1.0
  37410. * @category Lang
  37411. * @param {*} value The value to check.
  37412. * @returns {boolean} Returns `true` if `value` is correctly classified,
  37413. * else `false`.
  37414. * @example
  37415. *
  37416. * _.isFunction(_);
  37417. * // => true
  37418. *
  37419. * _.isFunction(/abc/);
  37420. * // => false
  37421. */
  37422. function isFunction(value) {
  37423. // The use of `Object#toString` avoids issues with the `typeof` operator
  37424. // in Safari 8 which returns 'object' for typed array and weak map constructors,
  37425. // and PhantomJS 1.9 which returns 'function' for `NodeList` instances.
  37426. var tag = isObject(value) ? objectToString.call(value) : '';
  37427. return tag == funcTag || tag == genTag;
  37428. }
  37429. /**
  37430. * Checks if `value` is a valid array-like length.
  37431. *
  37432. * **Note:** This function is loosely based on
  37433. * [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
  37434. *
  37435. * @static
  37436. * @memberOf _
  37437. * @since 4.0.0
  37438. * @category Lang
  37439. * @param {*} value The value to check.
  37440. * @returns {boolean} Returns `true` if `value` is a valid length,
  37441. * else `false`.
  37442. * @example
  37443. *
  37444. * _.isLength(3);
  37445. * // => true
  37446. *
  37447. * _.isLength(Number.MIN_VALUE);
  37448. * // => false
  37449. *
  37450. * _.isLength(Infinity);
  37451. * // => false
  37452. *
  37453. * _.isLength('3');
  37454. * // => false
  37455. */
  37456. function isLength(value) {
  37457. return typeof value == 'number' &&
  37458. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  37459. }
  37460. /**
  37461. * Checks if `value` is the
  37462. * [language type](http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types)
  37463. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  37464. *
  37465. * @static
  37466. * @memberOf _
  37467. * @since 0.1.0
  37468. * @category Lang
  37469. * @param {*} value The value to check.
  37470. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  37471. * @example
  37472. *
  37473. * _.isObject({});
  37474. * // => true
  37475. *
  37476. * _.isObject([1, 2, 3]);
  37477. * // => true
  37478. *
  37479. * _.isObject(_.noop);
  37480. * // => true
  37481. *
  37482. * _.isObject(null);
  37483. * // => false
  37484. */
  37485. function isObject(value) {
  37486. var type = typeof value;
  37487. return !!value && (type == 'object' || type == 'function');
  37488. }
  37489. /**
  37490. * Checks if `value` is object-like. A value is object-like if it's not `null`
  37491. * and has a `typeof` result of "object".
  37492. *
  37493. * @static
  37494. * @memberOf _
  37495. * @since 4.0.0
  37496. * @category Lang
  37497. * @param {*} value The value to check.
  37498. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  37499. * @example
  37500. *
  37501. * _.isObjectLike({});
  37502. * // => true
  37503. *
  37504. * _.isObjectLike([1, 2, 3]);
  37505. * // => true
  37506. *
  37507. * _.isObjectLike(_.noop);
  37508. * // => false
  37509. *
  37510. * _.isObjectLike(null);
  37511. * // => false
  37512. */
  37513. function isObjectLike(value) {
  37514. return !!value && typeof value == 'object';
  37515. }
  37516. /**
  37517. * Checks if `value` is classified as a `String` primitive or object.
  37518. *
  37519. * @static
  37520. * @since 0.1.0
  37521. * @memberOf _
  37522. * @category Lang
  37523. * @param {*} value The value to check.
  37524. * @returns {boolean} Returns `true` if `value` is correctly classified,
  37525. * else `false`.
  37526. * @example
  37527. *
  37528. * _.isString('abc');
  37529. * // => true
  37530. *
  37531. * _.isString(1);
  37532. * // => false
  37533. */
  37534. function isString(value) {
  37535. return typeof value == 'string' ||
  37536. (!isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag);
  37537. }
  37538. /**
  37539. * Creates an array of the own enumerable property names of `object`.
  37540. *
  37541. * **Note:** Non-object values are coerced to objects. See the
  37542. * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
  37543. * for more details.
  37544. *
  37545. * @static
  37546. * @since 0.1.0
  37547. * @memberOf _
  37548. * @category Object
  37549. * @param {Object} object The object to query.
  37550. * @returns {Array} Returns the array of property names.
  37551. * @example
  37552. *
  37553. * function Foo() {
  37554. * this.a = 1;
  37555. * this.b = 2;
  37556. * }
  37557. *
  37558. * Foo.prototype.c = 3;
  37559. *
  37560. * _.keys(new Foo);
  37561. * // => ['a', 'b'] (iteration order is not guaranteed)
  37562. *
  37563. * _.keys('hi');
  37564. * // => ['0', '1']
  37565. */
  37566. function keys(object) {
  37567. var isProto = isPrototype(object);
  37568. if (!(isProto || isArrayLike(object))) {
  37569. return baseKeys(object);
  37570. }
  37571. var indexes = indexKeys(object),
  37572. skipIndexes = !!indexes,
  37573. result = indexes || [],
  37574. length = result.length;
  37575. for (var key in object) {
  37576. if (baseHas(object, key) &&
  37577. !(skipIndexes && (key == 'length' || isIndex(key, length))) &&
  37578. !(isProto && key == 'constructor')) {
  37579. result.push(key);
  37580. }
  37581. }
  37582. return result;
  37583. }
  37584. module.exports = baseEach;
  37585. /***/ },
  37586. /* 203 */
  37587. /***/ function(module, exports, __webpack_require__) {
  37588. /* WEBPACK VAR INJECTION */(function(module, global) {/**
  37589. * lodash (Custom Build) <https://lodash.com/>
  37590. * Build: `lodash modularize exports="npm" -o ./`
  37591. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  37592. * Released under MIT license <https://lodash.com/license>
  37593. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  37594. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  37595. */
  37596. var stringToPath = __webpack_require__(520);
  37597. /** Used as the size to enable large array optimizations. */
  37598. var LARGE_ARRAY_SIZE = 200;
  37599. /** Used to stand-in for `undefined` hash values. */
  37600. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  37601. /** Used to compose bitmasks for comparison styles. */
  37602. var UNORDERED_COMPARE_FLAG = 1,
  37603. PARTIAL_COMPARE_FLAG = 2;
  37604. /** Used as references for various `Number` constants. */
  37605. var INFINITY = 1 / 0,
  37606. MAX_SAFE_INTEGER = 9007199254740991;
  37607. /** `Object#toString` result references. */
  37608. var argsTag = '[object Arguments]',
  37609. arrayTag = '[object Array]',
  37610. boolTag = '[object Boolean]',
  37611. dateTag = '[object Date]',
  37612. errorTag = '[object Error]',
  37613. funcTag = '[object Function]',
  37614. genTag = '[object GeneratorFunction]',
  37615. mapTag = '[object Map]',
  37616. numberTag = '[object Number]',
  37617. objectTag = '[object Object]',
  37618. promiseTag = '[object Promise]',
  37619. regexpTag = '[object RegExp]',
  37620. setTag = '[object Set]',
  37621. stringTag = '[object String]',
  37622. symbolTag = '[object Symbol]',
  37623. weakMapTag = '[object WeakMap]';
  37624. var arrayBufferTag = '[object ArrayBuffer]',
  37625. dataViewTag = '[object DataView]',
  37626. float32Tag = '[object Float32Array]',
  37627. float64Tag = '[object Float64Array]',
  37628. int8Tag = '[object Int8Array]',
  37629. int16Tag = '[object Int16Array]',
  37630. int32Tag = '[object Int32Array]',
  37631. uint8Tag = '[object Uint8Array]',
  37632. uint8ClampedTag = '[object Uint8ClampedArray]',
  37633. uint16Tag = '[object Uint16Array]',
  37634. uint32Tag = '[object Uint32Array]';
  37635. /** Used to match property names within property paths. */
  37636. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  37637. reIsPlainProp = /^\w*$/;
  37638. /**
  37639. * Used to match `RegExp`
  37640. * [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns).
  37641. */
  37642. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  37643. /** Used to detect host constructors (Safari). */
  37644. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  37645. /** Used to detect unsigned integer values. */
  37646. var reIsUint = /^(?:0|[1-9]\d*)$/;
  37647. /** Used to identify `toStringTag` values of typed arrays. */
  37648. var typedArrayTags = {};
  37649. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  37650. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  37651. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  37652. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  37653. typedArrayTags[uint32Tag] = true;
  37654. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  37655. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  37656. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  37657. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  37658. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  37659. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  37660. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  37661. typedArrayTags[weakMapTag] = false;
  37662. /** Used to determine if values are of the language type `Object`. */
  37663. var objectTypes = {
  37664. 'function': true,
  37665. 'object': true
  37666. };
  37667. /** Detect free variable `exports`. */
  37668. var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType)
  37669. ? exports
  37670. : undefined;
  37671. /** Detect free variable `module`. */
  37672. var freeModule = (objectTypes[typeof module] && module && !module.nodeType)
  37673. ? module
  37674. : undefined;
  37675. /** Detect free variable `global` from Node.js. */
  37676. var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global);
  37677. /** Detect free variable `self`. */
  37678. var freeSelf = checkGlobal(objectTypes[typeof self] && self);
  37679. /** Detect free variable `window`. */
  37680. var freeWindow = checkGlobal(objectTypes[typeof window] && window);
  37681. /** Detect `this` as the global object. */
  37682. var thisGlobal = checkGlobal(objectTypes[typeof this] && this);
  37683. /**
  37684. * Used as a reference to the global object.
  37685. *
  37686. * The `this` value is used if it's the global object to avoid Greasemonkey's
  37687. * restricted `window` object, otherwise the `window` object is used.
  37688. */
  37689. var root = freeGlobal ||
  37690. ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) ||
  37691. freeSelf || thisGlobal || Function('return this')();
  37692. /**
  37693. * A specialized version of `_.map` for arrays without support for iteratee
  37694. * shorthands.
  37695. *
  37696. * @private
  37697. * @param {Array} array The array to iterate over.
  37698. * @param {Function} iteratee The function invoked per iteration.
  37699. * @returns {Array} Returns the new mapped array.
  37700. */
  37701. function arrayMap(array, iteratee) {
  37702. var index = -1,
  37703. length = array.length,
  37704. result = Array(length);
  37705. while (++index < length) {
  37706. result[index] = iteratee(array[index], index, array);
  37707. }
  37708. return result;
  37709. }
  37710. /**
  37711. * A specialized version of `_.some` for arrays without support for iteratee
  37712. * shorthands.
  37713. *
  37714. * @private
  37715. * @param {Array} array The array to iterate over.
  37716. * @param {Function} predicate The function invoked per iteration.
  37717. * @returns {boolean} Returns `true` if any element passes the predicate check,
  37718. * else `false`.
  37719. */
  37720. function arraySome(array, predicate) {
  37721. var index = -1,
  37722. length = array.length;
  37723. while (++index < length) {
  37724. if (predicate(array[index], index, array)) {
  37725. return true;
  37726. }
  37727. }
  37728. return false;
  37729. }
  37730. /**
  37731. * The base implementation of `_.times` without support for iteratee shorthands
  37732. * or max array length checks.
  37733. *
  37734. * @private
  37735. * @param {number} n The number of times to invoke `iteratee`.
  37736. * @param {Function} iteratee The function invoked per iteration.
  37737. * @returns {Array} Returns the array of results.
  37738. */
  37739. function baseTimes(n, iteratee) {
  37740. var index = -1,
  37741. result = Array(n);
  37742. while (++index < n) {
  37743. result[index] = iteratee(index);
  37744. }
  37745. return result;
  37746. }
  37747. /**
  37748. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  37749. * of key-value pairs for `object` corresponding to the property names of `props`.
  37750. *
  37751. * @private
  37752. * @param {Object} object The object to query.
  37753. * @param {Array} props The property names to get values for.
  37754. * @returns {Object} Returns the key-value pairs.
  37755. */
  37756. function baseToPairs(object, props) {
  37757. return arrayMap(props, function(key) {
  37758. return [key, object[key]];
  37759. });
  37760. }
  37761. /**
  37762. * Checks if `value` is a global object.
  37763. *
  37764. * @private
  37765. * @param {*} value The value to check.
  37766. * @returns {null|Object} Returns `value` if it's a global object, else `null`.
  37767. */
  37768. function checkGlobal(value) {
  37769. return (value && value.Object === Object) ? value : null;
  37770. }
  37771. /**
  37772. * Checks if `value` is a host object in IE < 9.
  37773. *
  37774. * @private
  37775. * @param {*} value The value to check.
  37776. * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
  37777. */
  37778. function isHostObject(value) {
  37779. // Many host objects are `Object` objects that can coerce to strings
  37780. // despite having improperly defined `toString` methods.
  37781. var result = false;
  37782. if (value != null && typeof value.toString != 'function') {
  37783. try {
  37784. result = !!(value + '');
  37785. } catch (e) {}
  37786. }
  37787. return result;
  37788. }
  37789. /**
  37790. * Converts `map` to its key-value pairs.
  37791. *
  37792. * @private
  37793. * @param {Object} map The map to convert.
  37794. * @returns {Array} Returns the key-value pairs.
  37795. */
  37796. function mapToArray(map) {
  37797. var index = -1,
  37798. result = Array(map.size);
  37799. map.forEach(function(value, key) {
  37800. result[++index] = [key, value];
  37801. });
  37802. return result;
  37803. }
  37804. /**
  37805. * Converts `set` to an array of its values.
  37806. *
  37807. * @private
  37808. * @param {Object} set The set to convert.
  37809. * @returns {Array} Returns the values.
  37810. */
  37811. function setToArray(set) {
  37812. var index = -1,
  37813. result = Array(set.size);
  37814. set.forEach(function(value) {
  37815. result[++index] = value;
  37816. });
  37817. return result;
  37818. }
  37819. /**
  37820. * Converts `set` to its value-value pairs.
  37821. *
  37822. * @private
  37823. * @param {Object} set The set to convert.
  37824. * @returns {Array} Returns the value-value pairs.
  37825. */
  37826. function setToPairs(set) {
  37827. var index = -1,
  37828. result = Array(set.size);
  37829. set.forEach(function(value) {
  37830. result[++index] = [value, value];
  37831. });
  37832. return result;
  37833. }
  37834. /** Used for built-in method references. */
  37835. var arrayProto = Array.prototype,
  37836. objectProto = Object.prototype;
  37837. /** Used to resolve the decompiled source of functions. */
  37838. var funcToString = Function.prototype.toString;
  37839. /** Used to check objects for own properties. */
  37840. var hasOwnProperty = objectProto.hasOwnProperty;
  37841. /**
  37842. * Used to resolve the
  37843. * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  37844. * of values.
  37845. */
  37846. var objectToString = objectProto.toString;
  37847. /** Used to detect if a method is native. */
  37848. var reIsNative = RegExp('^' +
  37849. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  37850. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  37851. );
  37852. /** Built-in value references. */
  37853. var Symbol = root.Symbol,
  37854. Uint8Array = root.Uint8Array,
  37855. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  37856. splice = arrayProto.splice;
  37857. /* Built-in method references for those with the same name as other `lodash` methods. */
  37858. var nativeGetPrototype = Object.getPrototypeOf,
  37859. nativeKeys = Object.keys;
  37860. /* Built-in method references that are verified to be native. */
  37861. var DataView = getNative(root, 'DataView'),
  37862. Map = getNative(root, 'Map'),
  37863. Promise = getNative(root, 'Promise'),
  37864. Set = getNative(root, 'Set'),
  37865. WeakMap = getNative(root, 'WeakMap'),
  37866. nativeCreate = getNative(Object, 'create');
  37867. /** Used to detect maps, sets, and weakmaps. */
  37868. var dataViewCtorString = toSource(DataView),
  37869. mapCtorString = toSource(Map),
  37870. promiseCtorString = toSource(Promise),
  37871. setCtorString = toSource(Set),
  37872. weakMapCtorString = toSource(WeakMap);
  37873. /** Used to convert symbols to primitives and strings. */
  37874. var symbolProto = Symbol ? Symbol.prototype : undefined,
  37875. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
  37876. /**
  37877. * Creates a hash object.
  37878. *
  37879. * @private
  37880. * @constructor
  37881. * @param {Array} [entries] The key-value pairs to cache.
  37882. */
  37883. function Hash(entries) {
  37884. var index = -1,
  37885. length = entries ? entries.length : 0;
  37886. this.clear();
  37887. while (++index < length) {
  37888. var entry = entries[index];
  37889. this.set(entry[0], entry[1]);
  37890. }
  37891. }
  37892. /**
  37893. * Removes all key-value entries from the hash.
  37894. *
  37895. * @private
  37896. * @name clear
  37897. * @memberOf Hash
  37898. */
  37899. function hashClear() {
  37900. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  37901. }
  37902. /**
  37903. * Removes `key` and its value from the hash.
  37904. *
  37905. * @private
  37906. * @name delete
  37907. * @memberOf Hash
  37908. * @param {Object} hash The hash to modify.
  37909. * @param {string} key The key of the value to remove.
  37910. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  37911. */
  37912. function hashDelete(key) {
  37913. return this.has(key) && delete this.__data__[key];
  37914. }
  37915. /**
  37916. * Gets the hash value for `key`.
  37917. *
  37918. * @private
  37919. * @name get
  37920. * @memberOf Hash
  37921. * @param {string} key The key of the value to get.
  37922. * @returns {*} Returns the entry value.
  37923. */
  37924. function hashGet(key) {
  37925. var data = this.__data__;
  37926. if (nativeCreate) {
  37927. var result = data[key];
  37928. return result === HASH_UNDEFINED ? undefined : result;
  37929. }
  37930. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  37931. }
  37932. /**
  37933. * Checks if a hash value for `key` exists.
  37934. *
  37935. * @private
  37936. * @name has
  37937. * @memberOf Hash
  37938. * @param {string} key The key of the entry to check.
  37939. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  37940. */
  37941. function hashHas(key) {
  37942. var data = this.__data__;
  37943. return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
  37944. }
  37945. /**
  37946. * Sets the hash `key` to `value`.
  37947. *
  37948. * @private
  37949. * @name set
  37950. * @memberOf Hash
  37951. * @param {string} key The key of the value to set.
  37952. * @param {*} value The value to set.
  37953. * @returns {Object} Returns the hash instance.
  37954. */
  37955. function hashSet(key, value) {
  37956. var data = this.__data__;
  37957. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  37958. return this;
  37959. }
  37960. // Add methods to `Hash`.
  37961. Hash.prototype.clear = hashClear;
  37962. Hash.prototype['delete'] = hashDelete;
  37963. Hash.prototype.get = hashGet;
  37964. Hash.prototype.has = hashHas;
  37965. Hash.prototype.set = hashSet;
  37966. /**
  37967. * Creates an list cache object.
  37968. *
  37969. * @private
  37970. * @constructor
  37971. * @param {Array} [entries] The key-value pairs to cache.
  37972. */
  37973. function ListCache(entries) {
  37974. var index = -1,
  37975. length = entries ? entries.length : 0;
  37976. this.clear();
  37977. while (++index < length) {
  37978. var entry = entries[index];
  37979. this.set(entry[0], entry[1]);
  37980. }
  37981. }
  37982. /**
  37983. * Removes all key-value entries from the list cache.
  37984. *
  37985. * @private
  37986. * @name clear
  37987. * @memberOf ListCache
  37988. */
  37989. function listCacheClear() {
  37990. this.__data__ = [];
  37991. }
  37992. /**
  37993. * Removes `key` and its value from the list cache.
  37994. *
  37995. * @private
  37996. * @name delete
  37997. * @memberOf ListCache
  37998. * @param {string} key The key of the value to remove.
  37999. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  38000. */
  38001. function listCacheDelete(key) {
  38002. var data = this.__data__,
  38003. index = assocIndexOf(data, key);
  38004. if (index < 0) {
  38005. return false;
  38006. }
  38007. var lastIndex = data.length - 1;
  38008. if (index == lastIndex) {
  38009. data.pop();
  38010. } else {
  38011. splice.call(data, index, 1);
  38012. }
  38013. return true;
  38014. }
  38015. /**
  38016. * Gets the list cache value for `key`.
  38017. *
  38018. * @private
  38019. * @name get
  38020. * @memberOf ListCache
  38021. * @param {string} key The key of the value to get.
  38022. * @returns {*} Returns the entry value.
  38023. */
  38024. function listCacheGet(key) {
  38025. var data = this.__data__,
  38026. index = assocIndexOf(data, key);
  38027. return index < 0 ? undefined : data[index][1];
  38028. }
  38029. /**
  38030. * Checks if a list cache value for `key` exists.
  38031. *
  38032. * @private
  38033. * @name has
  38034. * @memberOf ListCache
  38035. * @param {string} key The key of the entry to check.
  38036. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  38037. */
  38038. function listCacheHas(key) {
  38039. return assocIndexOf(this.__data__, key) > -1;
  38040. }
  38041. /**
  38042. * Sets the list cache `key` to `value`.
  38043. *
  38044. * @private
  38045. * @name set
  38046. * @memberOf ListCache
  38047. * @param {string} key The key of the value to set.
  38048. * @param {*} value The value to set.
  38049. * @returns {Object} Returns the list cache instance.
  38050. */
  38051. function listCacheSet(key, value) {
  38052. var data = this.__data__,
  38053. index = assocIndexOf(data, key);
  38054. if (index < 0) {
  38055. data.push([key, value]);
  38056. } else {
  38057. data[index][1] = value;
  38058. }
  38059. return this;
  38060. }
  38061. // Add methods to `ListCache`.
  38062. ListCache.prototype.clear = listCacheClear;
  38063. ListCache.prototype['delete'] = listCacheDelete;
  38064. ListCache.prototype.get = listCacheGet;
  38065. ListCache.prototype.has = listCacheHas;
  38066. ListCache.prototype.set = listCacheSet;
  38067. /**
  38068. * Creates a map cache object to store key-value pairs.
  38069. *
  38070. * @private
  38071. * @constructor
  38072. * @param {Array} [entries] The key-value pairs to cache.
  38073. */
  38074. function MapCache(entries) {
  38075. var index = -1,
  38076. length = entries ? entries.length : 0;
  38077. this.clear();
  38078. while (++index < length) {
  38079. var entry = entries[index];
  38080. this.set(entry[0], entry[1]);
  38081. }
  38082. }
  38083. /**
  38084. * Removes all key-value entries from the map.
  38085. *
  38086. * @private
  38087. * @name clear
  38088. * @memberOf MapCache
  38089. */
  38090. function mapCacheClear() {
  38091. this.__data__ = {
  38092. 'hash': new Hash,
  38093. 'map': new (Map || ListCache),
  38094. 'string': new Hash
  38095. };
  38096. }
  38097. /**
  38098. * Removes `key` and its value from the map.
  38099. *
  38100. * @private
  38101. * @name delete
  38102. * @memberOf MapCache
  38103. * @param {string} key The key of the value to remove.
  38104. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  38105. */
  38106. function mapCacheDelete(key) {
  38107. return getMapData(this, key)['delete'](key);
  38108. }
  38109. /**
  38110. * Gets the map value for `key`.
  38111. *
  38112. * @private
  38113. * @name get
  38114. * @memberOf MapCache
  38115. * @param {string} key The key of the value to get.
  38116. * @returns {*} Returns the entry value.
  38117. */
  38118. function mapCacheGet(key) {
  38119. return getMapData(this, key).get(key);
  38120. }
  38121. /**
  38122. * Checks if a map value for `key` exists.
  38123. *
  38124. * @private
  38125. * @name has
  38126. * @memberOf MapCache
  38127. * @param {string} key The key of the entry to check.
  38128. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  38129. */
  38130. function mapCacheHas(key) {
  38131. return getMapData(this, key).has(key);
  38132. }
  38133. /**
  38134. * Sets the map `key` to `value`.
  38135. *
  38136. * @private
  38137. * @name set
  38138. * @memberOf MapCache
  38139. * @param {string} key The key of the value to set.
  38140. * @param {*} value The value to set.
  38141. * @returns {Object} Returns the map cache instance.
  38142. */
  38143. function mapCacheSet(key, value) {
  38144. getMapData(this, key).set(key, value);
  38145. return this;
  38146. }
  38147. // Add methods to `MapCache`.
  38148. MapCache.prototype.clear = mapCacheClear;
  38149. MapCache.prototype['delete'] = mapCacheDelete;
  38150. MapCache.prototype.get = mapCacheGet;
  38151. MapCache.prototype.has = mapCacheHas;
  38152. MapCache.prototype.set = mapCacheSet;
  38153. /**
  38154. *
  38155. * Creates an array cache object to store unique values.
  38156. *
  38157. * @private
  38158. * @constructor
  38159. * @param {Array} [values] The values to cache.
  38160. */
  38161. function SetCache(values) {
  38162. var index = -1,
  38163. length = values ? values.length : 0;
  38164. this.__data__ = new MapCache;
  38165. while (++index < length) {
  38166. this.add(values[index]);
  38167. }
  38168. }
  38169. /**
  38170. * Adds `value` to the array cache.
  38171. *
  38172. * @private
  38173. * @name add
  38174. * @memberOf SetCache
  38175. * @alias push
  38176. * @param {*} value The value to cache.
  38177. * @returns {Object} Returns the cache instance.
  38178. */
  38179. function setCacheAdd(value) {
  38180. this.__data__.set(value, HASH_UNDEFINED);
  38181. return this;
  38182. }
  38183. /**
  38184. * Checks if `value` is in the array cache.
  38185. *
  38186. * @private
  38187. * @name has
  38188. * @memberOf SetCache
  38189. * @param {*} value The value to search for.
  38190. * @returns {number} Returns `true` if `value` is found, else `false`.
  38191. */
  38192. function setCacheHas(value) {
  38193. return this.__data__.has(value);
  38194. }
  38195. // Add methods to `SetCache`.
  38196. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  38197. SetCache.prototype.has = setCacheHas;
  38198. /**
  38199. * Creates a stack cache object to store key-value pairs.
  38200. *
  38201. * @private
  38202. * @constructor
  38203. * @param {Array} [entries] The key-value pairs to cache.
  38204. */
  38205. function Stack(entries) {
  38206. this.__data__ = new ListCache(entries);
  38207. }
  38208. /**
  38209. * Removes all key-value entries from the stack.
  38210. *
  38211. * @private
  38212. * @name clear
  38213. * @memberOf Stack
  38214. */
  38215. function stackClear() {
  38216. this.__data__ = new ListCache;
  38217. }
  38218. /**
  38219. * Removes `key` and its value from the stack.
  38220. *
  38221. * @private
  38222. * @name delete
  38223. * @memberOf Stack
  38224. * @param {string} key The key of the value to remove.
  38225. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  38226. */
  38227. function stackDelete(key) {
  38228. return this.__data__['delete'](key);
  38229. }
  38230. /**
  38231. * Gets the stack value for `key`.
  38232. *
  38233. * @private
  38234. * @name get
  38235. * @memberOf Stack
  38236. * @param {string} key The key of the value to get.
  38237. * @returns {*} Returns the entry value.
  38238. */
  38239. function stackGet(key) {
  38240. return this.__data__.get(key);
  38241. }
  38242. /**
  38243. * Checks if a stack value for `key` exists.
  38244. *
  38245. * @private
  38246. * @name has
  38247. * @memberOf Stack
  38248. * @param {string} key The key of the entry to check.
  38249. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  38250. */
  38251. function stackHas(key) {
  38252. return this.__data__.has(key);
  38253. }
  38254. /**
  38255. * Sets the stack `key` to `value`.
  38256. *
  38257. * @private
  38258. * @name set
  38259. * @memberOf Stack
  38260. * @param {string} key The key of the value to set.
  38261. * @param {*} value The value to set.
  38262. * @returns {Object} Returns the stack cache instance.
  38263. */
  38264. function stackSet(key, value) {
  38265. var cache = this.__data__;
  38266. if (cache instanceof ListCache && cache.__data__.length == LARGE_ARRAY_SIZE) {
  38267. cache = this.__data__ = new MapCache(cache.__data__);
  38268. }
  38269. cache.set(key, value);
  38270. return this;
  38271. }
  38272. // Add methods to `Stack`.
  38273. Stack.prototype.clear = stackClear;
  38274. Stack.prototype['delete'] = stackDelete;
  38275. Stack.prototype.get = stackGet;
  38276. Stack.prototype.has = stackHas;
  38277. Stack.prototype.set = stackSet;
  38278. /**
  38279. * Gets the index at which the `key` is found in `array` of key-value pairs.
  38280. *
  38281. * @private
  38282. * @param {Array} array The array to search.
  38283. * @param {*} key The key to search for.
  38284. * @returns {number} Returns the index of the matched value, else `-1`.
  38285. */
  38286. function assocIndexOf(array, key) {
  38287. var length = array.length;
  38288. while (length--) {
  38289. if (eq(array[length][0], key)) {
  38290. return length;
  38291. }
  38292. }
  38293. return -1;
  38294. }
  38295. /**
  38296. * The base implementation of `_.get` without support for default values.
  38297. *
  38298. * @private
  38299. * @param {Object} object The object to query.
  38300. * @param {Array|string} path The path of the property to get.
  38301. * @returns {*} Returns the resolved value.
  38302. */
  38303. function baseGet(object, path) {
  38304. path = isKey(path, object) ? [path] : castPath(path);
  38305. var index = 0,
  38306. length = path.length;
  38307. while (object != null && index < length) {
  38308. object = object[toKey(path[index++])];
  38309. }
  38310. return (index && index == length) ? object : undefined;
  38311. }
  38312. /**
  38313. * The base implementation of `_.has` without support for deep paths.
  38314. *
  38315. * @private
  38316. * @param {Object} object The object to query.
  38317. * @param {Array|string} key The key to check.
  38318. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  38319. */
  38320. function baseHas(object, key) {
  38321. // Avoid a bug in IE 10-11 where objects with a [[Prototype]] of `null`,
  38322. // that are composed entirely of index properties, return `false` for
  38323. // `hasOwnProperty` checks of them.
  38324. return hasOwnProperty.call(object, key) ||
  38325. (typeof object == 'object' && key in object && getPrototype(object) === null);
  38326. }
  38327. /**
  38328. * The base implementation of `_.hasIn` without support for deep paths.
  38329. *
  38330. * @private
  38331. * @param {Object} object The object to query.
  38332. * @param {Array|string} key The key to check.
  38333. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  38334. */
  38335. function baseHasIn(object, key) {
  38336. return key in Object(object);
  38337. }
  38338. /**
  38339. * The base implementation of `_.isEqual` which supports partial comparisons
  38340. * and tracks traversed objects.
  38341. *
  38342. * @private
  38343. * @param {*} value The value to compare.
  38344. * @param {*} other The other value to compare.
  38345. * @param {Function} [customizer] The function to customize comparisons.
  38346. * @param {boolean} [bitmask] The bitmask of comparison flags.
  38347. * The bitmask may be composed of the following flags:
  38348. * 1 - Unordered comparison
  38349. * 2 - Partial comparison
  38350. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  38351. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  38352. */
  38353. function baseIsEqual(value, other, customizer, bitmask, stack) {
  38354. if (value === other) {
  38355. return true;
  38356. }
  38357. if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
  38358. return value !== value && other !== other;
  38359. }
  38360. return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack);
  38361. }
  38362. /**
  38363. * A specialized version of `baseIsEqual` for arrays and objects which performs
  38364. * deep comparisons and tracks traversed objects enabling objects with circular
  38365. * references to be compared.
  38366. *
  38367. * @private
  38368. * @param {Object} object The object to compare.
  38369. * @param {Object} other The other object to compare.
  38370. * @param {Function} equalFunc The function to determine equivalents of values.
  38371. * @param {Function} [customizer] The function to customize comparisons.
  38372. * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual`
  38373. * for more details.
  38374. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  38375. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  38376. */
  38377. function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
  38378. var objIsArr = isArray(object),
  38379. othIsArr = isArray(other),
  38380. objTag = arrayTag,
  38381. othTag = arrayTag;
  38382. if (!objIsArr) {
  38383. objTag = getTag(object);
  38384. objTag = objTag == argsTag ? objectTag : objTag;
  38385. }
  38386. if (!othIsArr) {
  38387. othTag = getTag(other);
  38388. othTag = othTag == argsTag ? objectTag : othTag;
  38389. }
  38390. var objIsObj = objTag == objectTag && !isHostObject(object),
  38391. othIsObj = othTag == objectTag && !isHostObject(other),
  38392. isSameTag = objTag == othTag;
  38393. if (isSameTag && !objIsObj) {
  38394. stack || (stack = new Stack);
  38395. return (objIsArr || isTypedArray(object))
  38396. ? equalArrays(object, other, equalFunc, customizer, bitmask, stack)
  38397. : equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
  38398. }
  38399. if (!(bitmask & PARTIAL_COMPARE_FLAG)) {
  38400. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  38401. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  38402. if (objIsWrapped || othIsWrapped) {
  38403. var objUnwrapped = objIsWrapped ? object.value() : object,
  38404. othUnwrapped = othIsWrapped ? other.value() : other;
  38405. stack || (stack = new Stack);
  38406. return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);
  38407. }
  38408. }
  38409. if (!isSameTag) {
  38410. return false;
  38411. }
  38412. stack || (stack = new Stack);
  38413. return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
  38414. }
  38415. /**
  38416. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  38417. *
  38418. * @private
  38419. * @param {Object} object The object to inspect.
  38420. * @param {Object} source The object of property values to match.
  38421. * @param {Array} matchData The property names, values, and compare flags to match.
  38422. * @param {Function} [customizer] The function to customize comparisons.
  38423. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  38424. */
  38425. function baseIsMatch(object, source, matchData, customizer) {
  38426. var index = matchData.length,
  38427. length = index,
  38428. noCustomizer = !customizer;
  38429. if (object == null) {
  38430. return !length;
  38431. }
  38432. object = Object(object);
  38433. while (index--) {
  38434. var data = matchData[index];
  38435. if ((noCustomizer && data[2])
  38436. ? data[1] !== object[data[0]]
  38437. : !(data[0] in object)
  38438. ) {
  38439. return false;
  38440. }
  38441. }
  38442. while (++index < length) {
  38443. data = matchData[index];
  38444. var key = data[0],
  38445. objValue = object[key],
  38446. srcValue = data[1];
  38447. if (noCustomizer && data[2]) {
  38448. if (objValue === undefined && !(key in object)) {
  38449. return false;
  38450. }
  38451. } else {
  38452. var stack = new Stack;
  38453. if (customizer) {
  38454. var result = customizer(objValue, srcValue, key, object, source, stack);
  38455. }
  38456. if (!(result === undefined
  38457. ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack)
  38458. : result
  38459. )) {
  38460. return false;
  38461. }
  38462. }
  38463. }
  38464. return true;
  38465. }
  38466. /**
  38467. * The base implementation of `_.iteratee`.
  38468. *
  38469. * @private
  38470. * @param {*} [value=_.identity] The value to convert to an iteratee.
  38471. * @returns {Function} Returns the iteratee.
  38472. */
  38473. function baseIteratee(value) {
  38474. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  38475. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  38476. if (typeof value == 'function') {
  38477. return value;
  38478. }
  38479. if (value == null) {
  38480. return identity;
  38481. }
  38482. if (typeof value == 'object') {
  38483. return isArray(value)
  38484. ? baseMatchesProperty(value[0], value[1])
  38485. : baseMatches(value);
  38486. }
  38487. return property(value);
  38488. }
  38489. /**
  38490. * The base implementation of `_.keys` which doesn't skip the constructor
  38491. * property of prototypes or treat sparse arrays as dense.
  38492. *
  38493. * @private
  38494. * @param {Object} object The object to query.
  38495. * @returns {Array} Returns the array of property names.
  38496. */
  38497. function baseKeys(object) {
  38498. return nativeKeys(Object(object));
  38499. }
  38500. /**
  38501. * The base implementation of `_.matches` which doesn't clone `source`.
  38502. *
  38503. * @private
  38504. * @param {Object} source The object of property values to match.
  38505. * @returns {Function} Returns the new spec function.
  38506. */
  38507. function baseMatches(source) {
  38508. var matchData = getMatchData(source);
  38509. if (matchData.length == 1 && matchData[0][2]) {
  38510. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  38511. }
  38512. return function(object) {
  38513. return object === source || baseIsMatch(object, source, matchData);
  38514. };
  38515. }
  38516. /**
  38517. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  38518. *
  38519. * @private
  38520. * @param {string} path The path of the property to get.
  38521. * @param {*} srcValue The value to match.
  38522. * @returns {Function} Returns the new spec function.
  38523. */
  38524. function baseMatchesProperty(path, srcValue) {
  38525. if (isKey(path) && isStrictComparable(srcValue)) {
  38526. return matchesStrictComparable(toKey(path), srcValue);
  38527. }
  38528. return function(object) {
  38529. var objValue = get(object, path);
  38530. return (objValue === undefined && objValue === srcValue)
  38531. ? hasIn(object, path)
  38532. : baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG);
  38533. };
  38534. }
  38535. /**
  38536. * The base implementation of `_.property` without support for deep paths.
  38537. *
  38538. * @private
  38539. * @param {string} key The key of the property to get.
  38540. * @returns {Function} Returns the new accessor function.
  38541. */
  38542. function baseProperty(key) {
  38543. return function(object) {
  38544. return object == null ? undefined : object[key];
  38545. };
  38546. }
  38547. /**
  38548. * A specialized version of `baseProperty` which supports deep paths.
  38549. *
  38550. * @private
  38551. * @param {Array|string} path The path of the property to get.
  38552. * @returns {Function} Returns the new accessor function.
  38553. */
  38554. function basePropertyDeep(path) {
  38555. return function(object) {
  38556. return baseGet(object, path);
  38557. };
  38558. }
  38559. /**
  38560. * Casts `value` to a path array if it's not one.
  38561. *
  38562. * @private
  38563. * @param {*} value The value to inspect.
  38564. * @returns {Array} Returns the cast property path array.
  38565. */
  38566. function castPath(value) {
  38567. return isArray(value) ? value : stringToPath(value);
  38568. }
  38569. /**
  38570. * Creates a `_.toPairs` or `_.toPairsIn` function.
  38571. *
  38572. * @private
  38573. * @param {Function} keysFunc The function to get the keys of a given object.
  38574. * @returns {Function} Returns the new pairs function.
  38575. */
  38576. function createToPairs(keysFunc) {
  38577. return function(object) {
  38578. var tag = getTag(object);
  38579. if (tag == mapTag) {
  38580. return mapToArray(object);
  38581. }
  38582. if (tag == setTag) {
  38583. return setToPairs(object);
  38584. }
  38585. return baseToPairs(object, keysFunc(object));
  38586. };
  38587. }
  38588. /**
  38589. * A specialized version of `baseIsEqualDeep` for arrays with support for
  38590. * partial deep comparisons.
  38591. *
  38592. * @private
  38593. * @param {Array} array The array to compare.
  38594. * @param {Array} other The other array to compare.
  38595. * @param {Function} equalFunc The function to determine equivalents of values.
  38596. * @param {Function} customizer The function to customize comparisons.
  38597. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
  38598. * for more details.
  38599. * @param {Object} stack Tracks traversed `array` and `other` objects.
  38600. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  38601. */
  38602. function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
  38603. var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
  38604. arrLength = array.length,
  38605. othLength = other.length;
  38606. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  38607. return false;
  38608. }
  38609. // Assume cyclic values are equal.
  38610. var stacked = stack.get(array);
  38611. if (stacked) {
  38612. return stacked == other;
  38613. }
  38614. var index = -1,
  38615. result = true,
  38616. seen = (bitmask & UNORDERED_COMPARE_FLAG) ? new SetCache : undefined;
  38617. stack.set(array, other);
  38618. // Ignore non-index properties.
  38619. while (++index < arrLength) {
  38620. var arrValue = array[index],
  38621. othValue = other[index];
  38622. if (customizer) {
  38623. var compared = isPartial
  38624. ? customizer(othValue, arrValue, index, other, array, stack)
  38625. : customizer(arrValue, othValue, index, array, other, stack);
  38626. }
  38627. if (compared !== undefined) {
  38628. if (compared) {
  38629. continue;
  38630. }
  38631. result = false;
  38632. break;
  38633. }
  38634. // Recursively compare arrays (susceptible to call stack limits).
  38635. if (seen) {
  38636. if (!arraySome(other, function(othValue, othIndex) {
  38637. if (!seen.has(othIndex) &&
  38638. (arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
  38639. return seen.add(othIndex);
  38640. }
  38641. })) {
  38642. result = false;
  38643. break;
  38644. }
  38645. } else if (!(
  38646. arrValue === othValue ||
  38647. equalFunc(arrValue, othValue, customizer, bitmask, stack)
  38648. )) {
  38649. result = false;
  38650. break;
  38651. }
  38652. }
  38653. stack['delete'](array);
  38654. return result;
  38655. }
  38656. /**
  38657. * A specialized version of `baseIsEqualDeep` for comparing objects of
  38658. * the same `toStringTag`.
  38659. *
  38660. * **Note:** This function only supports comparing values with tags of
  38661. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  38662. *
  38663. * @private
  38664. * @param {Object} object The object to compare.
  38665. * @param {Object} other The other object to compare.
  38666. * @param {string} tag The `toStringTag` of the objects to compare.
  38667. * @param {Function} equalFunc The function to determine equivalents of values.
  38668. * @param {Function} customizer The function to customize comparisons.
  38669. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
  38670. * for more details.
  38671. * @param {Object} stack Tracks traversed `object` and `other` objects.
  38672. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  38673. */
  38674. function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
  38675. switch (tag) {
  38676. case dataViewTag:
  38677. if ((object.byteLength != other.byteLength) ||
  38678. (object.byteOffset != other.byteOffset)) {
  38679. return false;
  38680. }
  38681. object = object.buffer;
  38682. other = other.buffer;
  38683. case arrayBufferTag:
  38684. if ((object.byteLength != other.byteLength) ||
  38685. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  38686. return false;
  38687. }
  38688. return true;
  38689. case boolTag:
  38690. case dateTag:
  38691. // Coerce dates and booleans to numbers, dates to milliseconds and
  38692. // booleans to `1` or `0` treating invalid dates coerced to `NaN` as
  38693. // not equal.
  38694. return +object == +other;
  38695. case errorTag:
  38696. return object.name == other.name && object.message == other.message;
  38697. case numberTag:
  38698. // Treat `NaN` vs. `NaN` as equal.
  38699. return (object != +object) ? other != +other : object == +other;
  38700. case regexpTag:
  38701. case stringTag:
  38702. // Coerce regexes to strings and treat strings, primitives and objects,
  38703. // as equal. See http://www.ecma-international.org/ecma-262/6.0/#sec-regexp.prototype.tostring
  38704. // for more details.
  38705. return object == (other + '');
  38706. case mapTag:
  38707. var convert = mapToArray;
  38708. case setTag:
  38709. var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
  38710. convert || (convert = setToArray);
  38711. if (object.size != other.size && !isPartial) {
  38712. return false;
  38713. }
  38714. // Assume cyclic values are equal.
  38715. var stacked = stack.get(object);
  38716. if (stacked) {
  38717. return stacked == other;
  38718. }
  38719. bitmask |= UNORDERED_COMPARE_FLAG;
  38720. stack.set(object, other);
  38721. // Recursively compare objects (susceptible to call stack limits).
  38722. return equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack);
  38723. case symbolTag:
  38724. if (symbolValueOf) {
  38725. return symbolValueOf.call(object) == symbolValueOf.call(other);
  38726. }
  38727. }
  38728. return false;
  38729. }
  38730. /**
  38731. * A specialized version of `baseIsEqualDeep` for objects with support for
  38732. * partial deep comparisons.
  38733. *
  38734. * @private
  38735. * @param {Object} object The object to compare.
  38736. * @param {Object} other The other object to compare.
  38737. * @param {Function} equalFunc The function to determine equivalents of values.
  38738. * @param {Function} customizer The function to customize comparisons.
  38739. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
  38740. * for more details.
  38741. * @param {Object} stack Tracks traversed `object` and `other` objects.
  38742. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  38743. */
  38744. function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
  38745. var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
  38746. objProps = keys(object),
  38747. objLength = objProps.length,
  38748. othProps = keys(other),
  38749. othLength = othProps.length;
  38750. if (objLength != othLength && !isPartial) {
  38751. return false;
  38752. }
  38753. var index = objLength;
  38754. while (index--) {
  38755. var key = objProps[index];
  38756. if (!(isPartial ? key in other : baseHas(other, key))) {
  38757. return false;
  38758. }
  38759. }
  38760. // Assume cyclic values are equal.
  38761. var stacked = stack.get(object);
  38762. if (stacked) {
  38763. return stacked == other;
  38764. }
  38765. var result = true;
  38766. stack.set(object, other);
  38767. var skipCtor = isPartial;
  38768. while (++index < objLength) {
  38769. key = objProps[index];
  38770. var objValue = object[key],
  38771. othValue = other[key];
  38772. if (customizer) {
  38773. var compared = isPartial
  38774. ? customizer(othValue, objValue, key, other, object, stack)
  38775. : customizer(objValue, othValue, key, object, other, stack);
  38776. }
  38777. // Recursively compare objects (susceptible to call stack limits).
  38778. if (!(compared === undefined
  38779. ? (objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack))
  38780. : compared
  38781. )) {
  38782. result = false;
  38783. break;
  38784. }
  38785. skipCtor || (skipCtor = key == 'constructor');
  38786. }
  38787. if (result && !skipCtor) {
  38788. var objCtor = object.constructor,
  38789. othCtor = other.constructor;
  38790. // Non `Object` object instances with different constructors are not equal.
  38791. if (objCtor != othCtor &&
  38792. ('constructor' in object && 'constructor' in other) &&
  38793. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  38794. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  38795. result = false;
  38796. }
  38797. }
  38798. stack['delete'](object);
  38799. return result;
  38800. }
  38801. /**
  38802. * Gets the "length" property value of `object`.
  38803. *
  38804. * **Note:** This function is used to avoid a
  38805. * [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) that affects
  38806. * Safari on at least iOS 8.1-8.3 ARM64.
  38807. *
  38808. * @private
  38809. * @param {Object} object The object to query.
  38810. * @returns {*} Returns the "length" value.
  38811. */
  38812. var getLength = baseProperty('length');
  38813. /**
  38814. * Gets the data for `map`.
  38815. *
  38816. * @private
  38817. * @param {Object} map The map to query.
  38818. * @param {string} key The reference key.
  38819. * @returns {*} Returns the map data.
  38820. */
  38821. function getMapData(map, key) {
  38822. var data = map.__data__;
  38823. return isKeyable(key)
  38824. ? data[typeof key == 'string' ? 'string' : 'hash']
  38825. : data.map;
  38826. }
  38827. /**
  38828. * Gets the property names, values, and compare flags of `object`.
  38829. *
  38830. * @private
  38831. * @param {Object} object The object to query.
  38832. * @returns {Array} Returns the match data of `object`.
  38833. */
  38834. function getMatchData(object) {
  38835. var result = toPairs(object),
  38836. length = result.length;
  38837. while (length--) {
  38838. result[length][2] = isStrictComparable(result[length][1]);
  38839. }
  38840. return result;
  38841. }
  38842. /**
  38843. * Gets the native function at `key` of `object`.
  38844. *
  38845. * @private
  38846. * @param {Object} object The object to query.
  38847. * @param {string} key The key of the method to get.
  38848. * @returns {*} Returns the function if it's native, else `undefined`.
  38849. */
  38850. function getNative(object, key) {
  38851. var value = object[key];
  38852. return isNative(value) ? value : undefined;
  38853. }
  38854. /**
  38855. * Gets the `[[Prototype]]` of `value`.
  38856. *
  38857. * @private
  38858. * @param {*} value The value to query.
  38859. * @returns {null|Object} Returns the `[[Prototype]]`.
  38860. */
  38861. function getPrototype(value) {
  38862. return nativeGetPrototype(Object(value));
  38863. }
  38864. /**
  38865. * Gets the `toStringTag` of `value`.
  38866. *
  38867. * @private
  38868. * @param {*} value The value to query.
  38869. * @returns {string} Returns the `toStringTag`.
  38870. */
  38871. function getTag(value) {
  38872. return objectToString.call(value);
  38873. }
  38874. // Fallback for data views, maps, sets, and weak maps in IE 11,
  38875. // for data views in Edge, and promises in Node.js.
  38876. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  38877. (Map && getTag(new Map) != mapTag) ||
  38878. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  38879. (Set && getTag(new Set) != setTag) ||
  38880. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  38881. getTag = function(value) {
  38882. var result = objectToString.call(value),
  38883. Ctor = result == objectTag ? value.constructor : undefined,
  38884. ctorString = Ctor ? toSource(Ctor) : undefined;
  38885. if (ctorString) {
  38886. switch (ctorString) {
  38887. case dataViewCtorString: return dataViewTag;
  38888. case mapCtorString: return mapTag;
  38889. case promiseCtorString: return promiseTag;
  38890. case setCtorString: return setTag;
  38891. case weakMapCtorString: return weakMapTag;
  38892. }
  38893. }
  38894. return result;
  38895. };
  38896. }
  38897. /**
  38898. * Checks if `path` exists on `object`.
  38899. *
  38900. * @private
  38901. * @param {Object} object The object to query.
  38902. * @param {Array|string} path The path to check.
  38903. * @param {Function} hasFunc The function to check properties.
  38904. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  38905. */
  38906. function hasPath(object, path, hasFunc) {
  38907. path = isKey(path, object) ? [path] : castPath(path);
  38908. var result,
  38909. index = -1,
  38910. length = path.length;
  38911. while (++index < length) {
  38912. var key = toKey(path[index]);
  38913. if (!(result = object != null && hasFunc(object, key))) {
  38914. break;
  38915. }
  38916. object = object[key];
  38917. }
  38918. if (result) {
  38919. return result;
  38920. }
  38921. var length = object ? object.length : 0;
  38922. return !!length && isLength(length) && isIndex(key, length) &&
  38923. (isArray(object) || isString(object) || isArguments(object));
  38924. }
  38925. /**
  38926. * Creates an array of index keys for `object` values of arrays,
  38927. * `arguments` objects, and strings, otherwise `null` is returned.
  38928. *
  38929. * @private
  38930. * @param {Object} object The object to query.
  38931. * @returns {Array|null} Returns index keys, else `null`.
  38932. */
  38933. function indexKeys(object) {
  38934. var length = object ? object.length : undefined;
  38935. if (isLength(length) &&
  38936. (isArray(object) || isString(object) || isArguments(object))) {
  38937. return baseTimes(length, String);
  38938. }
  38939. return null;
  38940. }
  38941. /**
  38942. * Checks if `value` is a valid array-like index.
  38943. *
  38944. * @private
  38945. * @param {*} value The value to check.
  38946. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  38947. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  38948. */
  38949. function isIndex(value, length) {
  38950. length = length == null ? MAX_SAFE_INTEGER : length;
  38951. return !!length &&
  38952. (typeof value == 'number' || reIsUint.test(value)) &&
  38953. (value > -1 && value % 1 == 0 && value < length);
  38954. }
  38955. /**
  38956. * Checks if `value` is a property name and not a property path.
  38957. *
  38958. * @private
  38959. * @param {*} value The value to check.
  38960. * @param {Object} [object] The object to query keys on.
  38961. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  38962. */
  38963. function isKey(value, object) {
  38964. if (isArray(value)) {
  38965. return false;
  38966. }
  38967. var type = typeof value;
  38968. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  38969. value == null || isSymbol(value)) {
  38970. return true;
  38971. }
  38972. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  38973. (object != null && value in Object(object));
  38974. }
  38975. /**
  38976. * Checks if `value` is suitable for use as unique object key.
  38977. *
  38978. * @private
  38979. * @param {*} value The value to check.
  38980. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  38981. */
  38982. function isKeyable(value) {
  38983. var type = typeof value;
  38984. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  38985. ? (value !== '__proto__')
  38986. : (value === null);
  38987. }
  38988. /**
  38989. * Checks if `value` is likely a prototype object.
  38990. *
  38991. * @private
  38992. * @param {*} value The value to check.
  38993. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  38994. */
  38995. function isPrototype(value) {
  38996. var Ctor = value && value.constructor,
  38997. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  38998. return value === proto;
  38999. }
  39000. /**
  39001. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  39002. *
  39003. * @private
  39004. * @param {*} value The value to check.
  39005. * @returns {boolean} Returns `true` if `value` if suitable for strict
  39006. * equality comparisons, else `false`.
  39007. */
  39008. function isStrictComparable(value) {
  39009. return value === value && !isObject(value);
  39010. }
  39011. /**
  39012. * A specialized version of `matchesProperty` for source values suitable
  39013. * for strict equality comparisons, i.e. `===`.
  39014. *
  39015. * @private
  39016. * @param {string} key The key of the property to get.
  39017. * @param {*} srcValue The value to match.
  39018. * @returns {Function} Returns the new spec function.
  39019. */
  39020. function matchesStrictComparable(key, srcValue) {
  39021. return function(object) {
  39022. if (object == null) {
  39023. return false;
  39024. }
  39025. return object[key] === srcValue &&
  39026. (srcValue !== undefined || (key in Object(object)));
  39027. };
  39028. }
  39029. /**
  39030. * Converts `value` to a string key if it's not a string or symbol.
  39031. *
  39032. * @private
  39033. * @param {*} value The value to inspect.
  39034. * @returns {string|symbol} Returns the key.
  39035. */
  39036. function toKey(value) {
  39037. if (typeof value == 'string' || isSymbol(value)) {
  39038. return value;
  39039. }
  39040. var result = (value + '');
  39041. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  39042. }
  39043. /**
  39044. * Converts `func` to its source code.
  39045. *
  39046. * @private
  39047. * @param {Function} func The function to process.
  39048. * @returns {string} Returns the source code.
  39049. */
  39050. function toSource(func) {
  39051. if (func != null) {
  39052. try {
  39053. return funcToString.call(func);
  39054. } catch (e) {}
  39055. try {
  39056. return (func + '');
  39057. } catch (e) {}
  39058. }
  39059. return '';
  39060. }
  39061. /**
  39062. * Performs a
  39063. * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
  39064. * comparison between two values to determine if they are equivalent.
  39065. *
  39066. * @static
  39067. * @memberOf _
  39068. * @since 4.0.0
  39069. * @category Lang
  39070. * @param {*} value The value to compare.
  39071. * @param {*} other The other value to compare.
  39072. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  39073. * @example
  39074. *
  39075. * var object = { 'user': 'fred' };
  39076. * var other = { 'user': 'fred' };
  39077. *
  39078. * _.eq(object, object);
  39079. * // => true
  39080. *
  39081. * _.eq(object, other);
  39082. * // => false
  39083. *
  39084. * _.eq('a', 'a');
  39085. * // => true
  39086. *
  39087. * _.eq('a', Object('a'));
  39088. * // => false
  39089. *
  39090. * _.eq(NaN, NaN);
  39091. * // => true
  39092. */
  39093. function eq(value, other) {
  39094. return value === other || (value !== value && other !== other);
  39095. }
  39096. /**
  39097. * Checks if `value` is likely an `arguments` object.
  39098. *
  39099. * @static
  39100. * @memberOf _
  39101. * @since 0.1.0
  39102. * @category Lang
  39103. * @param {*} value The value to check.
  39104. * @returns {boolean} Returns `true` if `value` is correctly classified,
  39105. * else `false`.
  39106. * @example
  39107. *
  39108. * _.isArguments(function() { return arguments; }());
  39109. * // => true
  39110. *
  39111. * _.isArguments([1, 2, 3]);
  39112. * // => false
  39113. */
  39114. function isArguments(value) {
  39115. // Safari 8.1 incorrectly makes `arguments.callee` enumerable in strict mode.
  39116. return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
  39117. (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
  39118. }
  39119. /**
  39120. * Checks if `value` is classified as an `Array` object.
  39121. *
  39122. * @static
  39123. * @memberOf _
  39124. * @since 0.1.0
  39125. * @type {Function}
  39126. * @category Lang
  39127. * @param {*} value The value to check.
  39128. * @returns {boolean} Returns `true` if `value` is correctly classified,
  39129. * else `false`.
  39130. * @example
  39131. *
  39132. * _.isArray([1, 2, 3]);
  39133. * // => true
  39134. *
  39135. * _.isArray(document.body.children);
  39136. * // => false
  39137. *
  39138. * _.isArray('abc');
  39139. * // => false
  39140. *
  39141. * _.isArray(_.noop);
  39142. * // => false
  39143. */
  39144. var isArray = Array.isArray;
  39145. /**
  39146. * Checks if `value` is array-like. A value is considered array-like if it's
  39147. * not a function and has a `value.length` that's an integer greater than or
  39148. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  39149. *
  39150. * @static
  39151. * @memberOf _
  39152. * @since 4.0.0
  39153. * @category Lang
  39154. * @param {*} value The value to check.
  39155. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  39156. * @example
  39157. *
  39158. * _.isArrayLike([1, 2, 3]);
  39159. * // => true
  39160. *
  39161. * _.isArrayLike(document.body.children);
  39162. * // => true
  39163. *
  39164. * _.isArrayLike('abc');
  39165. * // => true
  39166. *
  39167. * _.isArrayLike(_.noop);
  39168. * // => false
  39169. */
  39170. function isArrayLike(value) {
  39171. return value != null && isLength(getLength(value)) && !isFunction(value);
  39172. }
  39173. /**
  39174. * This method is like `_.isArrayLike` except that it also checks if `value`
  39175. * is an object.
  39176. *
  39177. * @static
  39178. * @memberOf _
  39179. * @since 4.0.0
  39180. * @category Lang
  39181. * @param {*} value The value to check.
  39182. * @returns {boolean} Returns `true` if `value` is an array-like object,
  39183. * else `false`.
  39184. * @example
  39185. *
  39186. * _.isArrayLikeObject([1, 2, 3]);
  39187. * // => true
  39188. *
  39189. * _.isArrayLikeObject(document.body.children);
  39190. * // => true
  39191. *
  39192. * _.isArrayLikeObject('abc');
  39193. * // => false
  39194. *
  39195. * _.isArrayLikeObject(_.noop);
  39196. * // => false
  39197. */
  39198. function isArrayLikeObject(value) {
  39199. return isObjectLike(value) && isArrayLike(value);
  39200. }
  39201. /**
  39202. * Checks if `value` is classified as a `Function` object.
  39203. *
  39204. * @static
  39205. * @memberOf _
  39206. * @since 0.1.0
  39207. * @category Lang
  39208. * @param {*} value The value to check.
  39209. * @returns {boolean} Returns `true` if `value` is correctly classified,
  39210. * else `false`.
  39211. * @example
  39212. *
  39213. * _.isFunction(_);
  39214. * // => true
  39215. *
  39216. * _.isFunction(/abc/);
  39217. * // => false
  39218. */
  39219. function isFunction(value) {
  39220. // The use of `Object#toString` avoids issues with the `typeof` operator
  39221. // in Safari 8 which returns 'object' for typed array and weak map constructors,
  39222. // and PhantomJS 1.9 which returns 'function' for `NodeList` instances.
  39223. var tag = isObject(value) ? objectToString.call(value) : '';
  39224. return tag == funcTag || tag == genTag;
  39225. }
  39226. /**
  39227. * Checks if `value` is a valid array-like length.
  39228. *
  39229. * **Note:** This function is loosely based on
  39230. * [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
  39231. *
  39232. * @static
  39233. * @memberOf _
  39234. * @since 4.0.0
  39235. * @category Lang
  39236. * @param {*} value The value to check.
  39237. * @returns {boolean} Returns `true` if `value` is a valid length,
  39238. * else `false`.
  39239. * @example
  39240. *
  39241. * _.isLength(3);
  39242. * // => true
  39243. *
  39244. * _.isLength(Number.MIN_VALUE);
  39245. * // => false
  39246. *
  39247. * _.isLength(Infinity);
  39248. * // => false
  39249. *
  39250. * _.isLength('3');
  39251. * // => false
  39252. */
  39253. function isLength(value) {
  39254. return typeof value == 'number' &&
  39255. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  39256. }
  39257. /**
  39258. * Checks if `value` is the
  39259. * [language type](http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types)
  39260. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  39261. *
  39262. * @static
  39263. * @memberOf _
  39264. * @since 0.1.0
  39265. * @category Lang
  39266. * @param {*} value The value to check.
  39267. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  39268. * @example
  39269. *
  39270. * _.isObject({});
  39271. * // => true
  39272. *
  39273. * _.isObject([1, 2, 3]);
  39274. * // => true
  39275. *
  39276. * _.isObject(_.noop);
  39277. * // => true
  39278. *
  39279. * _.isObject(null);
  39280. * // => false
  39281. */
  39282. function isObject(value) {
  39283. var type = typeof value;
  39284. return !!value && (type == 'object' || type == 'function');
  39285. }
  39286. /**
  39287. * Checks if `value` is object-like. A value is object-like if it's not `null`
  39288. * and has a `typeof` result of "object".
  39289. *
  39290. * @static
  39291. * @memberOf _
  39292. * @since 4.0.0
  39293. * @category Lang
  39294. * @param {*} value The value to check.
  39295. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  39296. * @example
  39297. *
  39298. * _.isObjectLike({});
  39299. * // => true
  39300. *
  39301. * _.isObjectLike([1, 2, 3]);
  39302. * // => true
  39303. *
  39304. * _.isObjectLike(_.noop);
  39305. * // => false
  39306. *
  39307. * _.isObjectLike(null);
  39308. * // => false
  39309. */
  39310. function isObjectLike(value) {
  39311. return !!value && typeof value == 'object';
  39312. }
  39313. /**
  39314. * Checks if `value` is a native function.
  39315. *
  39316. * @static
  39317. * @memberOf _
  39318. * @since 3.0.0
  39319. * @category Lang
  39320. * @param {*} value The value to check.
  39321. * @returns {boolean} Returns `true` if `value` is a native function,
  39322. * else `false`.
  39323. * @example
  39324. *
  39325. * _.isNative(Array.prototype.push);
  39326. * // => true
  39327. *
  39328. * _.isNative(_);
  39329. * // => false
  39330. */
  39331. function isNative(value) {
  39332. if (!isObject(value)) {
  39333. return false;
  39334. }
  39335. var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
  39336. return pattern.test(toSource(value));
  39337. }
  39338. /**
  39339. * Checks if `value` is classified as a `String` primitive or object.
  39340. *
  39341. * @static
  39342. * @since 0.1.0
  39343. * @memberOf _
  39344. * @category Lang
  39345. * @param {*} value The value to check.
  39346. * @returns {boolean} Returns `true` if `value` is correctly classified,
  39347. * else `false`.
  39348. * @example
  39349. *
  39350. * _.isString('abc');
  39351. * // => true
  39352. *
  39353. * _.isString(1);
  39354. * // => false
  39355. */
  39356. function isString(value) {
  39357. return typeof value == 'string' ||
  39358. (!isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag);
  39359. }
  39360. /**
  39361. * Checks if `value` is classified as a `Symbol` primitive or object.
  39362. *
  39363. * @static
  39364. * @memberOf _
  39365. * @since 4.0.0
  39366. * @category Lang
  39367. * @param {*} value The value to check.
  39368. * @returns {boolean} Returns `true` if `value` is correctly classified,
  39369. * else `false`.
  39370. * @example
  39371. *
  39372. * _.isSymbol(Symbol.iterator);
  39373. * // => true
  39374. *
  39375. * _.isSymbol('abc');
  39376. * // => false
  39377. */
  39378. function isSymbol(value) {
  39379. return typeof value == 'symbol' ||
  39380. (isObjectLike(value) && objectToString.call(value) == symbolTag);
  39381. }
  39382. /**
  39383. * Checks if `value` is classified as a typed array.
  39384. *
  39385. * @static
  39386. * @memberOf _
  39387. * @since 3.0.0
  39388. * @category Lang
  39389. * @param {*} value The value to check.
  39390. * @returns {boolean} Returns `true` if `value` is correctly classified,
  39391. * else `false`.
  39392. * @example
  39393. *
  39394. * _.isTypedArray(new Uint8Array);
  39395. * // => true
  39396. *
  39397. * _.isTypedArray([]);
  39398. * // => false
  39399. */
  39400. function isTypedArray(value) {
  39401. return isObjectLike(value) &&
  39402. isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
  39403. }
  39404. /**
  39405. * Gets the value at `path` of `object`. If the resolved value is
  39406. * `undefined`, the `defaultValue` is used in its place.
  39407. *
  39408. * @static
  39409. * @memberOf _
  39410. * @since 3.7.0
  39411. * @category Object
  39412. * @param {Object} object The object to query.
  39413. * @param {Array|string} path The path of the property to get.
  39414. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  39415. * @returns {*} Returns the resolved value.
  39416. * @example
  39417. *
  39418. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  39419. *
  39420. * _.get(object, 'a[0].b.c');
  39421. * // => 3
  39422. *
  39423. * _.get(object, ['a', '0', 'b', 'c']);
  39424. * // => 3
  39425. *
  39426. * _.get(object, 'a.b.c', 'default');
  39427. * // => 'default'
  39428. */
  39429. function get(object, path, defaultValue) {
  39430. var result = object == null ? undefined : baseGet(object, path);
  39431. return result === undefined ? defaultValue : result;
  39432. }
  39433. /**
  39434. * Checks if `path` is a direct or inherited property of `object`.
  39435. *
  39436. * @static
  39437. * @memberOf _
  39438. * @since 4.0.0
  39439. * @category Object
  39440. * @param {Object} object The object to query.
  39441. * @param {Array|string} path The path to check.
  39442. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  39443. * @example
  39444. *
  39445. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  39446. *
  39447. * _.hasIn(object, 'a');
  39448. * // => true
  39449. *
  39450. * _.hasIn(object, 'a.b');
  39451. * // => true
  39452. *
  39453. * _.hasIn(object, ['a', 'b']);
  39454. * // => true
  39455. *
  39456. * _.hasIn(object, 'b');
  39457. * // => false
  39458. */
  39459. function hasIn(object, path) {
  39460. return object != null && hasPath(object, path, baseHasIn);
  39461. }
  39462. /**
  39463. * Creates an array of the own enumerable property names of `object`.
  39464. *
  39465. * **Note:** Non-object values are coerced to objects. See the
  39466. * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
  39467. * for more details.
  39468. *
  39469. * @static
  39470. * @since 0.1.0
  39471. * @memberOf _
  39472. * @category Object
  39473. * @param {Object} object The object to query.
  39474. * @returns {Array} Returns the array of property names.
  39475. * @example
  39476. *
  39477. * function Foo() {
  39478. * this.a = 1;
  39479. * this.b = 2;
  39480. * }
  39481. *
  39482. * Foo.prototype.c = 3;
  39483. *
  39484. * _.keys(new Foo);
  39485. * // => ['a', 'b'] (iteration order is not guaranteed)
  39486. *
  39487. * _.keys('hi');
  39488. * // => ['0', '1']
  39489. */
  39490. function keys(object) {
  39491. var isProto = isPrototype(object);
  39492. if (!(isProto || isArrayLike(object))) {
  39493. return baseKeys(object);
  39494. }
  39495. var indexes = indexKeys(object),
  39496. skipIndexes = !!indexes,
  39497. result = indexes || [],
  39498. length = result.length;
  39499. for (var key in object) {
  39500. if (baseHas(object, key) &&
  39501. !(skipIndexes && (key == 'length' || isIndex(key, length))) &&
  39502. !(isProto && key == 'constructor')) {
  39503. result.push(key);
  39504. }
  39505. }
  39506. return result;
  39507. }
  39508. /**
  39509. * Creates an array of own enumerable string keyed-value pairs for `object`
  39510. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  39511. * entries are returned.
  39512. *
  39513. * @static
  39514. * @memberOf _
  39515. * @since 4.0.0
  39516. * @alias entries
  39517. * @category Object
  39518. * @param {Object} object The object to query.
  39519. * @returns {Array} Returns the key-value pairs.
  39520. * @example
  39521. *
  39522. * function Foo() {
  39523. * this.a = 1;
  39524. * this.b = 2;
  39525. * }
  39526. *
  39527. * Foo.prototype.c = 3;
  39528. *
  39529. * _.toPairs(new Foo);
  39530. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  39531. */
  39532. var toPairs = createToPairs(keys);
  39533. /**
  39534. * This method returns the first argument given to it.
  39535. *
  39536. * @static
  39537. * @since 0.1.0
  39538. * @memberOf _
  39539. * @category Util
  39540. * @param {*} value Any value.
  39541. * @returns {*} Returns `value`.
  39542. * @example
  39543. *
  39544. * var object = { 'user': 'fred' };
  39545. *
  39546. * _.identity(object) === object;
  39547. * // => true
  39548. */
  39549. function identity(value) {
  39550. return value;
  39551. }
  39552. /**
  39553. * Creates a function that returns the value at `path` of a given object.
  39554. *
  39555. * @static
  39556. * @memberOf _
  39557. * @since 2.4.0
  39558. * @category Util
  39559. * @param {Array|string} path The path of the property to get.
  39560. * @returns {Function} Returns the new accessor function.
  39561. * @example
  39562. *
  39563. * var objects = [
  39564. * { 'a': { 'b': 2 } },
  39565. * { 'a': { 'b': 1 } }
  39566. * ];
  39567. *
  39568. * _.map(objects, _.property('a.b'));
  39569. * // => [2, 1]
  39570. *
  39571. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  39572. * // => [1, 2]
  39573. */
  39574. function property(path) {
  39575. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  39576. }
  39577. module.exports = baseIteratee;
  39578. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(76)(module), __webpack_require__(13)))
  39579. /***/ },
  39580. /* 204 */
  39581. /***/ function(module, exports, __webpack_require__) {
  39582. var bn = __webpack_require__(12);
  39583. var brorand = __webpack_require__(156);
  39584. function MillerRabin(rand) {
  39585. this.rand = rand || new brorand.Rand();
  39586. }
  39587. module.exports = MillerRabin;
  39588. MillerRabin.create = function create(rand) {
  39589. return new MillerRabin(rand);
  39590. };
  39591. MillerRabin.prototype._rand = function _rand(n) {
  39592. var len = n.bitLength();
  39593. var buf = this.rand.generate(Math.ceil(len / 8));
  39594. // Set low bits
  39595. buf[0] |= 3;
  39596. // Mask high bits
  39597. var mask = len & 0x7;
  39598. if (mask !== 0)
  39599. buf[buf.length - 1] >>= 7 - mask;
  39600. return new bn(buf);
  39601. }
  39602. MillerRabin.prototype.test = function test(n, k, cb) {
  39603. var len = n.bitLength();
  39604. var red = bn.mont(n);
  39605. var rone = new bn(1).toRed(red);
  39606. if (!k)
  39607. k = Math.max(1, (len / 48) | 0);
  39608. // Find d and s, (n - 1) = (2 ^ s) * d;
  39609. var n1 = n.subn(1);
  39610. var n2 = n1.subn(1);
  39611. for (var s = 0; !n1.testn(s); s++) {}
  39612. var d = n.shrn(s);
  39613. var rn1 = n1.toRed(red);
  39614. var prime = true;
  39615. for (; k > 0; k--) {
  39616. var a = this._rand(n2);
  39617. if (cb)
  39618. cb(a);
  39619. var x = a.toRed(red).redPow(d);
  39620. if (x.cmp(rone) === 0 || x.cmp(rn1) === 0)
  39621. continue;
  39622. for (var i = 1; i < s; i++) {
  39623. x = x.redSqr();
  39624. if (x.cmp(rone) === 0)
  39625. return false;
  39626. if (x.cmp(rn1) === 0)
  39627. break;
  39628. }
  39629. if (i === s)
  39630. return false;
  39631. }
  39632. return prime;
  39633. };
  39634. MillerRabin.prototype.getDivisor = function getDivisor(n, k) {
  39635. var len = n.bitLength();
  39636. var red = bn.mont(n);
  39637. var rone = new bn(1).toRed(red);
  39638. if (!k)
  39639. k = Math.max(1, (len / 48) | 0);
  39640. // Find d and s, (n - 1) = (2 ^ s) * d;
  39641. var n1 = n.subn(1);
  39642. var n2 = n1.subn(1);
  39643. for (var s = 0; !n1.testn(s); s++) {}
  39644. var d = n.shrn(s);
  39645. var rn1 = n1.toRed(red);
  39646. for (; k > 0; k--) {
  39647. var a = this._rand(n2);
  39648. var g = n.gcd(a);
  39649. if (g.cmpn(1) !== 0)
  39650. return g;
  39651. var x = a.toRed(red).redPow(d);
  39652. if (x.cmp(rone) === 0 || x.cmp(rn1) === 0)
  39653. continue;
  39654. for (var i = 1; i < s; i++) {
  39655. x = x.redSqr();
  39656. if (x.cmp(rone) === 0)
  39657. return x.fromRed().subn(1).gcd(n);
  39658. if (x.cmp(rn1) === 0)
  39659. break;
  39660. }
  39661. if (i === s) {
  39662. x = x.redSqr();
  39663. return x.fromRed().subn(1).gcd(n);
  39664. }
  39665. }
  39666. return false;
  39667. };
  39668. /***/ },
  39669. /* 205 */
  39670. /***/ function(module, exports, __webpack_require__) {
  39671. "use strict";
  39672. /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
  39673. var multihash = __webpack_require__(96);
  39674. var crypto = __webpack_require__(584);
  39675. var mh = module.exports = Multihashing;
  39676. mh.Buffer = Buffer; // for browser things
  39677. function Multihashing(buf, func, length) {
  39678. return multihash.encode(mh.digest(buf, func, length), func, length);
  39679. }
  39680. // expose multihash itself, to avoid silly double requires.
  39681. mh.multihash = multihash;
  39682. mh.digest = function (buf, func, length) {
  39683. var digest = mh.createHash(func).update(buf).digest();
  39684. if (length) {
  39685. digest = digest.slice(0, length);
  39686. }
  39687. return digest;
  39688. };
  39689. mh.createHash = function (func, length) {
  39690. func = multihash.coerceCode(func);
  39691. if (!mh.functions[func]) {
  39692. throw new Error('multihash function ' + func + ' not yet supported');
  39693. }
  39694. return mh.functions[func]();
  39695. };
  39696. mh.functions = {
  39697. 0x11: gsha1,
  39698. 0x12: gsha2_256,
  39699. 0x13: gsha2_512
  39700. // 0x14: gsha3 // not implemented yet
  39701. // 0x40: blake2b, // not implemented yet
  39702. // 0x41: blake2s, // not implemented yet
  39703. };
  39704. function gsha1() {
  39705. return crypto.createHash('sha1');
  39706. }
  39707. function gsha2_256() {
  39708. return crypto.createHash('sha256');
  39709. }
  39710. function gsha2_512() {
  39711. return crypto.createHash('sha512');
  39712. }
  39713. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  39714. /***/ },
  39715. /* 206 */
  39716. /***/ function(module, exports, __webpack_require__) {
  39717. var through = __webpack_require__(532)
  39718. var split = __webpack_require__(566)
  39719. var EOL = __webpack_require__(209).EOL
  39720. module.exports = parse
  39721. module.exports.serialize = module.exports.stringify = serialize
  39722. module.exports.parse = parse
  39723. function parse (opts) {
  39724. opts = opts || {}
  39725. opts.strict = opts.strict !== false
  39726. function parseRow (row) {
  39727. try {
  39728. if (row) return JSON.parse(row)
  39729. } catch (e) {
  39730. if (opts.strict) {
  39731. this.emit('error', new Error('Could not parse row ' + row.slice(0, 50) + '...'))
  39732. }
  39733. }
  39734. }
  39735. return split(parseRow)
  39736. }
  39737. function serialize (opts) {
  39738. return through.obj(opts, function(obj, enc, cb) {
  39739. cb(null, JSON.stringify(obj) + EOL)
  39740. })
  39741. }
  39742. /***/ },
  39743. /* 207 */
  39744. /***/ function(module, exports, __webpack_require__) {
  39745. /* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors.
  39746. //
  39747. // Permission is hereby granted, free of charge, to any person obtaining a
  39748. // copy of this software and associated documentation files (the
  39749. // "Software"), to deal in the Software without restriction, including
  39750. // without limitation the rights to use, copy, modify, merge, publish,
  39751. // distribute, sublicense, and/or sell copies of the Software, and to permit
  39752. // persons to whom the Software is furnished to do so, subject to the
  39753. // following conditions:
  39754. //
  39755. // The above copyright notice and this permission notice shall be included
  39756. // in all copies or substantial portions of the Software.
  39757. //
  39758. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  39759. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  39760. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  39761. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  39762. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  39763. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  39764. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  39765. // a duplex stream is just a stream that is both readable and writable.
  39766. // Since JS doesn't have multiple prototypal inheritance, this class
  39767. // prototypally inherits from Readable, and then parasitically from
  39768. // Writable.
  39769. module.exports = Duplex;
  39770. /*<replacement>*/
  39771. var objectKeys = Object.keys || function (obj) {
  39772. var keys = [];
  39773. for (var key in obj) keys.push(key);
  39774. return keys;
  39775. }
  39776. /*</replacement>*/
  39777. /*<replacement>*/
  39778. var util = __webpack_require__(14);
  39779. util.inherits = __webpack_require__(2);
  39780. /*</replacement>*/
  39781. var Readable = __webpack_require__(528);
  39782. var Writable = __webpack_require__(530);
  39783. util.inherits(Duplex, Readable);
  39784. forEach(objectKeys(Writable.prototype), function(method) {
  39785. if (!Duplex.prototype[method])
  39786. Duplex.prototype[method] = Writable.prototype[method];
  39787. });
  39788. function Duplex(options) {
  39789. if (!(this instanceof Duplex))
  39790. return new Duplex(options);
  39791. Readable.call(this, options);
  39792. Writable.call(this, options);
  39793. if (options && options.readable === false)
  39794. this.readable = false;
  39795. if (options && options.writable === false)
  39796. this.writable = false;
  39797. this.allowHalfOpen = true;
  39798. if (options && options.allowHalfOpen === false)
  39799. this.allowHalfOpen = false;
  39800. this.once('end', onend);
  39801. }
  39802. // the no-half-open enforcer
  39803. function onend() {
  39804. // if we allow half-open state, or if the writable side ended,
  39805. // then we're ok.
  39806. if (this.allowHalfOpen || this._writableState.ended)
  39807. return;
  39808. // no more data can be written.
  39809. // But allow more writes to happen in this tick.
  39810. process.nextTick(this.end.bind(this));
  39811. }
  39812. function forEach (xs, f) {
  39813. for (var i = 0, l = xs.length; i < l; i++) {
  39814. f(xs[i], i);
  39815. }
  39816. }
  39817. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  39818. /***/ },
  39819. /* 208 */
  39820. /***/ function(module, exports, __webpack_require__) {
  39821. var wrappy = __webpack_require__(228)
  39822. module.exports = wrappy(once)
  39823. once.proto = once(function () {
  39824. Object.defineProperty(Function.prototype, 'once', {
  39825. value: function () {
  39826. return once(this)
  39827. },
  39828. configurable: true
  39829. })
  39830. })
  39831. function once (fn) {
  39832. var f = function () {
  39833. if (f.called) return f.value
  39834. f.called = true
  39835. return f.value = fn.apply(this, arguments)
  39836. }
  39837. f.called = false
  39838. return f
  39839. }
  39840. /***/ },
  39841. /* 209 */
  39842. /***/ function(module, exports) {
  39843. exports.endianness = function () { return 'LE' };
  39844. exports.hostname = function () {
  39845. if (typeof location !== 'undefined') {
  39846. return location.hostname
  39847. }
  39848. else return '';
  39849. };
  39850. exports.loadavg = function () { return [] };
  39851. exports.uptime = function () { return 0 };
  39852. exports.freemem = function () {
  39853. return Number.MAX_VALUE;
  39854. };
  39855. exports.totalmem = function () {
  39856. return Number.MAX_VALUE;
  39857. };
  39858. exports.cpus = function () { return [] };
  39859. exports.type = function () { return 'Browser' };
  39860. exports.release = function () {
  39861. if (typeof navigator !== 'undefined') {
  39862. return navigator.appVersion;
  39863. }
  39864. return '';
  39865. };
  39866. exports.networkInterfaces
  39867. = exports.getNetworkInterfaces
  39868. = function () { return {} };
  39869. exports.arch = function () { return 'javascript' };
  39870. exports.platform = function () { return 'browser' };
  39871. exports.tmpdir = exports.tmpDir = function () {
  39872. return '/tmp';
  39873. };
  39874. exports.EOL = '\n';
  39875. /***/ },
  39876. /* 210 */
  39877. /***/ function(module, exports, __webpack_require__) {
  39878. /* WEBPACK VAR INJECTION */(function(Buffer) {var createHmac = __webpack_require__(130)
  39879. var MAX_ALLOC = Math.pow(2, 30) - 1 // default in iojs
  39880. exports.pbkdf2 = pbkdf2
  39881. function pbkdf2 (password, salt, iterations, keylen, digest, callback) {
  39882. if (typeof digest === 'function') {
  39883. callback = digest
  39884. digest = undefined
  39885. }
  39886. if (typeof callback !== 'function') {
  39887. throw new Error('No callback provided to pbkdf2')
  39888. }
  39889. var result = pbkdf2Sync(password, salt, iterations, keylen, digest)
  39890. setTimeout(function () {
  39891. callback(undefined, result)
  39892. })
  39893. }
  39894. exports.pbkdf2Sync = pbkdf2Sync
  39895. function pbkdf2Sync (password, salt, iterations, keylen, digest) {
  39896. if (typeof iterations !== 'number') {
  39897. throw new TypeError('Iterations not a number')
  39898. }
  39899. if (iterations < 0) {
  39900. throw new TypeError('Bad iterations')
  39901. }
  39902. if (typeof keylen !== 'number') {
  39903. throw new TypeError('Key length not a number')
  39904. }
  39905. if (keylen < 0 || keylen > MAX_ALLOC) {
  39906. throw new TypeError('Bad key length')
  39907. }
  39908. digest = digest || 'sha1'
  39909. if (!Buffer.isBuffer(password)) password = new Buffer(password, 'binary')
  39910. if (!Buffer.isBuffer(salt)) salt = new Buffer(salt, 'binary')
  39911. var hLen
  39912. var l = 1
  39913. var DK = new Buffer(keylen)
  39914. var block1 = new Buffer(salt.length + 4)
  39915. salt.copy(block1, 0, 0, salt.length)
  39916. var r
  39917. var T
  39918. for (var i = 1; i <= l; i++) {
  39919. block1.writeUInt32BE(i, salt.length)
  39920. var U = createHmac(digest, password).update(block1).digest()
  39921. if (!hLen) {
  39922. hLen = U.length
  39923. T = new Buffer(hLen)
  39924. l = Math.ceil(keylen / hLen)
  39925. r = keylen - (l - 1) * hLen
  39926. }
  39927. U.copy(T, 0, 0, hLen)
  39928. for (var j = 1; j < iterations; j++) {
  39929. U = createHmac(digest, password).update(U).digest()
  39930. for (var k = 0; k < hLen; k++) {
  39931. T[k] ^= U[k]
  39932. }
  39933. }
  39934. var destPos = (i - 1) * hLen
  39935. var len = (i === l ? r : hLen)
  39936. T.copy(DK, destPos, 0, len)
  39937. }
  39938. return DK
  39939. }
  39940. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  39941. /***/ },
  39942. /* 211 */
  39943. /***/ function(module, exports, __webpack_require__) {
  39944. /* WEBPACK VAR INJECTION */(function(Buffer) {var createHash = __webpack_require__(63);
  39945. module.exports = function (seed, len) {
  39946. var t = new Buffer('');
  39947. var i = 0, c;
  39948. while (t.length < len) {
  39949. c = i2ops(i++);
  39950. t = Buffer.concat([t, createHash('sha1').update(seed).update(c).digest()]);
  39951. }
  39952. return t.slice(0, len);
  39953. };
  39954. function i2ops(c) {
  39955. var out = new Buffer(4);
  39956. out.writeUInt32BE(c,0);
  39957. return out;
  39958. }
  39959. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  39960. /***/ },
  39961. /* 212 */
  39962. /***/ function(module, exports, __webpack_require__) {
  39963. /* WEBPACK VAR INJECTION */(function(Buffer) {var bn = __webpack_require__(12);
  39964. function withPublic(paddedMsg, key) {
  39965. return new Buffer(paddedMsg
  39966. .toRed(bn.mont(key.modulus))
  39967. .redPow(new bn(key.publicExponent))
  39968. .fromRed()
  39969. .toArray());
  39970. }
  39971. module.exports = withPublic;
  39972. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  39973. /***/ },
  39974. /* 213 */
  39975. /***/ function(module, exports) {
  39976. module.exports = function xor(a, b) {
  39977. var len = a.length;
  39978. var i = -1;
  39979. while (++i < len) {
  39980. a[i] ^= b[i];
  39981. }
  39982. return a
  39983. };
  39984. /***/ },
  39985. /* 214 */
  39986. /***/ function(module, exports, __webpack_require__) {
  39987. module.exports = __webpack_require__(55)
  39988. /***/ },
  39989. /* 215 */
  39990. /***/ function(module, exports, __webpack_require__) {
  39991. "use strict";
  39992. // a passthrough stream.
  39993. // basically just the most minimal sort of Transform stream.
  39994. // Every written chunk gets output as-is.
  39995. 'use strict';
  39996. module.exports = PassThrough;
  39997. var Transform = __webpack_require__(138);
  39998. /*<replacement>*/
  39999. var util = __webpack_require__(14);
  40000. util.inherits = __webpack_require__(2);
  40001. /*</replacement>*/
  40002. util.inherits(PassThrough, Transform);
  40003. function PassThrough(options) {
  40004. if (!(this instanceof PassThrough)) return new PassThrough(options);
  40005. Transform.call(this, options);
  40006. }
  40007. PassThrough.prototype._transform = function (chunk, encoding, cb) {
  40008. cb(null, chunk);
  40009. };
  40010. /***/ },
  40011. /* 216 */
  40012. /***/ function(module, exports, __webpack_require__) {
  40013. "use strict";
  40014. /* WEBPACK VAR INJECTION */(function(process) {'use strict';
  40015. module.exports = Readable;
  40016. /*<replacement>*/
  40017. var processNextTick = __webpack_require__(64);
  40018. /*</replacement>*/
  40019. /*<replacement>*/
  40020. var isArray = __webpack_require__(133);
  40021. /*</replacement>*/
  40022. /*<replacement>*/
  40023. var Buffer = __webpack_require__(1).Buffer;
  40024. /*</replacement>*/
  40025. Readable.ReadableState = ReadableState;
  40026. var EE = __webpack_require__(30);
  40027. /*<replacement>*/
  40028. var EElistenerCount = function (emitter, type) {
  40029. return emitter.listeners(type).length;
  40030. };
  40031. /*</replacement>*/
  40032. /*<replacement>*/
  40033. var Stream;
  40034. (function () {
  40035. try {
  40036. Stream = __webpack_require__(9);
  40037. } catch (_) {} finally {
  40038. if (!Stream) Stream = __webpack_require__(30).EventEmitter;
  40039. }
  40040. })();
  40041. /*</replacement>*/
  40042. var Buffer = __webpack_require__(1).Buffer;
  40043. /*<replacement>*/
  40044. var util = __webpack_require__(14);
  40045. util.inherits = __webpack_require__(2);
  40046. /*</replacement>*/
  40047. /*<replacement>*/
  40048. var debugUtil = __webpack_require__(585);
  40049. var debug = undefined;
  40050. if (debugUtil && debugUtil.debuglog) {
  40051. debug = debugUtil.debuglog('stream');
  40052. } else {
  40053. debug = function () {};
  40054. }
  40055. /*</replacement>*/
  40056. var StringDecoder;
  40057. util.inherits(Readable, Stream);
  40058. var Duplex;
  40059. function ReadableState(options, stream) {
  40060. Duplex = Duplex || __webpack_require__(55);
  40061. options = options || {};
  40062. // object stream flag. Used to make read(n) ignore n and to
  40063. // make all the buffer merging and length checks go away
  40064. this.objectMode = !!options.objectMode;
  40065. if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
  40066. // the point at which it stops calling _read() to fill the buffer
  40067. // Note: 0 is a valid value, means "don't call _read preemptively ever"
  40068. var hwm = options.highWaterMark;
  40069. var defaultHwm = this.objectMode ? 16 : 16 * 1024;
  40070. this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
  40071. // cast to ints.
  40072. this.highWaterMark = ~ ~this.highWaterMark;
  40073. this.buffer = [];
  40074. this.length = 0;
  40075. this.pipes = null;
  40076. this.pipesCount = 0;
  40077. this.flowing = null;
  40078. this.ended = false;
  40079. this.endEmitted = false;
  40080. this.reading = false;
  40081. // a flag to be able to tell if the onwrite cb is called immediately,
  40082. // or on a later tick. We set this to true at first, because any
  40083. // actions that shouldn't happen until "later" should generally also
  40084. // not happen before the first write call.
  40085. this.sync = true;
  40086. // whenever we return null, then we set a flag to say
  40087. // that we're awaiting a 'readable' event emission.
  40088. this.needReadable = false;
  40089. this.emittedReadable = false;
  40090. this.readableListening = false;
  40091. this.resumeScheduled = false;
  40092. // Crypto is kind of old and crusty. Historically, its default string
  40093. // encoding is 'binary' so we have to make this configurable.
  40094. // Everything else in the universe uses 'utf8', though.
  40095. this.defaultEncoding = options.defaultEncoding || 'utf8';
  40096. // when piping, we only care about 'readable' events that happen
  40097. // after read()ing all the bytes and not getting any pushback.
  40098. this.ranOut = false;
  40099. // the number of writers that are awaiting a drain event in .pipe()s
  40100. this.awaitDrain = 0;
  40101. // if true, a maybeReadMore has been scheduled
  40102. this.readingMore = false;
  40103. this.decoder = null;
  40104. this.encoding = null;
  40105. if (options.encoding) {
  40106. if (!StringDecoder) StringDecoder = __webpack_require__(38).StringDecoder;
  40107. this.decoder = new StringDecoder(options.encoding);
  40108. this.encoding = options.encoding;
  40109. }
  40110. }
  40111. var Duplex;
  40112. function Readable(options) {
  40113. Duplex = Duplex || __webpack_require__(55);
  40114. if (!(this instanceof Readable)) return new Readable(options);
  40115. this._readableState = new ReadableState(options, this);
  40116. // legacy
  40117. this.readable = true;
  40118. if (options && typeof options.read === 'function') this._read = options.read;
  40119. Stream.call(this);
  40120. }
  40121. // Manually shove something into the read() buffer.
  40122. // This returns true if the highWaterMark has not been hit yet,
  40123. // similar to how Writable.write() returns true if you should
  40124. // write() some more.
  40125. Readable.prototype.push = function (chunk, encoding) {
  40126. var state = this._readableState;
  40127. if (!state.objectMode && typeof chunk === 'string') {
  40128. encoding = encoding || state.defaultEncoding;
  40129. if (encoding !== state.encoding) {
  40130. chunk = new Buffer(chunk, encoding);
  40131. encoding = '';
  40132. }
  40133. }
  40134. return readableAddChunk(this, state, chunk, encoding, false);
  40135. };
  40136. // Unshift should *always* be something directly out of read()
  40137. Readable.prototype.unshift = function (chunk) {
  40138. var state = this._readableState;
  40139. return readableAddChunk(this, state, chunk, '', true);
  40140. };
  40141. Readable.prototype.isPaused = function () {
  40142. return this._readableState.flowing === false;
  40143. };
  40144. function readableAddChunk(stream, state, chunk, encoding, addToFront) {
  40145. var er = chunkInvalid(state, chunk);
  40146. if (er) {
  40147. stream.emit('error', er);
  40148. } else if (chunk === null) {
  40149. state.reading = false;
  40150. onEofChunk(stream, state);
  40151. } else if (state.objectMode || chunk && chunk.length > 0) {
  40152. if (state.ended && !addToFront) {
  40153. var e = new Error('stream.push() after EOF');
  40154. stream.emit('error', e);
  40155. } else if (state.endEmitted && addToFront) {
  40156. var e = new Error('stream.unshift() after end event');
  40157. stream.emit('error', e);
  40158. } else {
  40159. var skipAdd;
  40160. if (state.decoder && !addToFront && !encoding) {
  40161. chunk = state.decoder.write(chunk);
  40162. skipAdd = !state.objectMode && chunk.length === 0;
  40163. }
  40164. if (!addToFront) state.reading = false;
  40165. // Don't add to the buffer if we've decoded to an empty string chunk and
  40166. // we're not in object mode
  40167. if (!skipAdd) {
  40168. // if we want the data now, just emit it.
  40169. if (state.flowing && state.length === 0 && !state.sync) {
  40170. stream.emit('data', chunk);
  40171. stream.read(0);
  40172. } else {
  40173. // update the buffer info.
  40174. state.length += state.objectMode ? 1 : chunk.length;
  40175. if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
  40176. if (state.needReadable) emitReadable(stream);
  40177. }
  40178. }
  40179. maybeReadMore(stream, state);
  40180. }
  40181. } else if (!addToFront) {
  40182. state.reading = false;
  40183. }
  40184. return needMoreData(state);
  40185. }
  40186. // if it's past the high water mark, we can push in some more.
  40187. // Also, if we have no data yet, we can stand some
  40188. // more bytes. This is to work around cases where hwm=0,
  40189. // such as the repl. Also, if the push() triggered a
  40190. // readable event, and the user called read(largeNumber) such that
  40191. // needReadable was set, then we ought to push more, so that another
  40192. // 'readable' event will be triggered.
  40193. function needMoreData(state) {
  40194. return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
  40195. }
  40196. // backwards compatibility.
  40197. Readable.prototype.setEncoding = function (enc) {
  40198. if (!StringDecoder) StringDecoder = __webpack_require__(38).StringDecoder;
  40199. this._readableState.decoder = new StringDecoder(enc);
  40200. this._readableState.encoding = enc;
  40201. return this;
  40202. };
  40203. // Don't raise the hwm > 8MB
  40204. var MAX_HWM = 0x800000;
  40205. function computeNewHighWaterMark(n) {
  40206. if (n >= MAX_HWM) {
  40207. n = MAX_HWM;
  40208. } else {
  40209. // Get the next highest power of 2
  40210. n--;
  40211. n |= n >>> 1;
  40212. n |= n >>> 2;
  40213. n |= n >>> 4;
  40214. n |= n >>> 8;
  40215. n |= n >>> 16;
  40216. n++;
  40217. }
  40218. return n;
  40219. }
  40220. function howMuchToRead(n, state) {
  40221. if (state.length === 0 && state.ended) return 0;
  40222. if (state.objectMode) return n === 0 ? 0 : 1;
  40223. if (n === null || isNaN(n)) {
  40224. // only flow one buffer at a time
  40225. if (state.flowing && state.buffer.length) return state.buffer[0].length;else return state.length;
  40226. }
  40227. if (n <= 0) return 0;
  40228. // If we're asking for more than the target buffer level,
  40229. // then raise the water mark. Bump up to the next highest
  40230. // power of 2, to prevent increasing it excessively in tiny
  40231. // amounts.
  40232. if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
  40233. // don't have that much. return null, unless we've ended.
  40234. if (n > state.length) {
  40235. if (!state.ended) {
  40236. state.needReadable = true;
  40237. return 0;
  40238. } else {
  40239. return state.length;
  40240. }
  40241. }
  40242. return n;
  40243. }
  40244. // you can override either this method, or the async _read(n) below.
  40245. Readable.prototype.read = function (n) {
  40246. debug('read', n);
  40247. var state = this._readableState;
  40248. var nOrig = n;
  40249. if (typeof n !== 'number' || n > 0) state.emittedReadable = false;
  40250. // if we're doing read(0) to trigger a readable event, but we
  40251. // already have a bunch of data in the buffer, then just trigger
  40252. // the 'readable' event and move on.
  40253. if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
  40254. debug('read: emitReadable', state.length, state.ended);
  40255. if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
  40256. return null;
  40257. }
  40258. n = howMuchToRead(n, state);
  40259. // if we've ended, and we're now clear, then finish it up.
  40260. if (n === 0 && state.ended) {
  40261. if (state.length === 0) endReadable(this);
  40262. return null;
  40263. }
  40264. // All the actual chunk generation logic needs to be
  40265. // *below* the call to _read. The reason is that in certain
  40266. // synthetic stream cases, such as passthrough streams, _read
  40267. // may be a completely synchronous operation which may change
  40268. // the state of the read buffer, providing enough data when
  40269. // before there was *not* enough.
  40270. //
  40271. // So, the steps are:
  40272. // 1. Figure out what the state of things will be after we do
  40273. // a read from the buffer.
  40274. //
  40275. // 2. If that resulting state will trigger a _read, then call _read.
  40276. // Note that this may be asynchronous, or synchronous. Yes, it is
  40277. // deeply ugly to write APIs this way, but that still doesn't mean
  40278. // that the Readable class should behave improperly, as streams are
  40279. // designed to be sync/async agnostic.
  40280. // Take note if the _read call is sync or async (ie, if the read call
  40281. // has returned yet), so that we know whether or not it's safe to emit
  40282. // 'readable' etc.
  40283. //
  40284. // 3. Actually pull the requested chunks out of the buffer and return.
  40285. // if we need a readable event, then we need to do some reading.
  40286. var doRead = state.needReadable;
  40287. debug('need readable', doRead);
  40288. // if we currently have less than the highWaterMark, then also read some
  40289. if (state.length === 0 || state.length - n < state.highWaterMark) {
  40290. doRead = true;
  40291. debug('length less than watermark', doRead);
  40292. }
  40293. // however, if we've ended, then there's no point, and if we're already
  40294. // reading, then it's unnecessary.
  40295. if (state.ended || state.reading) {
  40296. doRead = false;
  40297. debug('reading or ended', doRead);
  40298. }
  40299. if (doRead) {
  40300. debug('do read');
  40301. state.reading = true;
  40302. state.sync = true;
  40303. // if the length is currently zero, then we *need* a readable event.
  40304. if (state.length === 0) state.needReadable = true;
  40305. // call internal read method
  40306. this._read(state.highWaterMark);
  40307. state.sync = false;
  40308. }
  40309. // If _read pushed data synchronously, then `reading` will be false,
  40310. // and we need to re-evaluate how much data we can return to the user.
  40311. if (doRead && !state.reading) n = howMuchToRead(nOrig, state);
  40312. var ret;
  40313. if (n > 0) ret = fromList(n, state);else ret = null;
  40314. if (ret === null) {
  40315. state.needReadable = true;
  40316. n = 0;
  40317. }
  40318. state.length -= n;
  40319. // If we have nothing in the buffer, then we want to know
  40320. // as soon as we *do* get something into the buffer.
  40321. if (state.length === 0 && !state.ended) state.needReadable = true;
  40322. // If we tried to read() past the EOF, then emit end on the next tick.
  40323. if (nOrig !== n && state.ended && state.length === 0) endReadable(this);
  40324. if (ret !== null) this.emit('data', ret);
  40325. return ret;
  40326. };
  40327. function chunkInvalid(state, chunk) {
  40328. var er = null;
  40329. if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== null && chunk !== undefined && !state.objectMode) {
  40330. er = new TypeError('Invalid non-string/buffer chunk');
  40331. }
  40332. return er;
  40333. }
  40334. function onEofChunk(stream, state) {
  40335. if (state.ended) return;
  40336. if (state.decoder) {
  40337. var chunk = state.decoder.end();
  40338. if (chunk && chunk.length) {
  40339. state.buffer.push(chunk);
  40340. state.length += state.objectMode ? 1 : chunk.length;
  40341. }
  40342. }
  40343. state.ended = true;
  40344. // emit 'readable' now to make sure it gets picked up.
  40345. emitReadable(stream);
  40346. }
  40347. // Don't emit readable right away in sync mode, because this can trigger
  40348. // another read() call => stack overflow. This way, it might trigger
  40349. // a nextTick recursion warning, but that's not so bad.
  40350. function emitReadable(stream) {
  40351. var state = stream._readableState;
  40352. state.needReadable = false;
  40353. if (!state.emittedReadable) {
  40354. debug('emitReadable', state.flowing);
  40355. state.emittedReadable = true;
  40356. if (state.sync) processNextTick(emitReadable_, stream);else emitReadable_(stream);
  40357. }
  40358. }
  40359. function emitReadable_(stream) {
  40360. debug('emit readable');
  40361. stream.emit('readable');
  40362. flow(stream);
  40363. }
  40364. // at this point, the user has presumably seen the 'readable' event,
  40365. // and called read() to consume some data. that may have triggered
  40366. // in turn another _read(n) call, in which case reading = true if
  40367. // it's in progress.
  40368. // However, if we're not ended, or reading, and the length < hwm,
  40369. // then go ahead and try to read some more preemptively.
  40370. function maybeReadMore(stream, state) {
  40371. if (!state.readingMore) {
  40372. state.readingMore = true;
  40373. processNextTick(maybeReadMore_, stream, state);
  40374. }
  40375. }
  40376. function maybeReadMore_(stream, state) {
  40377. var len = state.length;
  40378. while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
  40379. debug('maybeReadMore read 0');
  40380. stream.read(0);
  40381. if (len === state.length)
  40382. // didn't get any data, stop spinning.
  40383. break;else len = state.length;
  40384. }
  40385. state.readingMore = false;
  40386. }
  40387. // abstract method. to be overridden in specific implementation classes.
  40388. // call cb(er, data) where data is <= n in length.
  40389. // for virtual (non-string, non-buffer) streams, "length" is somewhat
  40390. // arbitrary, and perhaps not very meaningful.
  40391. Readable.prototype._read = function (n) {
  40392. this.emit('error', new Error('not implemented'));
  40393. };
  40394. Readable.prototype.pipe = function (dest, pipeOpts) {
  40395. var src = this;
  40396. var state = this._readableState;
  40397. switch (state.pipesCount) {
  40398. case 0:
  40399. state.pipes = dest;
  40400. break;
  40401. case 1:
  40402. state.pipes = [state.pipes, dest];
  40403. break;
  40404. default:
  40405. state.pipes.push(dest);
  40406. break;
  40407. }
  40408. state.pipesCount += 1;
  40409. debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
  40410. var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
  40411. var endFn = doEnd ? onend : cleanup;
  40412. if (state.endEmitted) processNextTick(endFn);else src.once('end', endFn);
  40413. dest.on('unpipe', onunpipe);
  40414. function onunpipe(readable) {
  40415. debug('onunpipe');
  40416. if (readable === src) {
  40417. cleanup();
  40418. }
  40419. }
  40420. function onend() {
  40421. debug('onend');
  40422. dest.end();
  40423. }
  40424. // when the dest drains, it reduces the awaitDrain counter
  40425. // on the source. This would be more elegant with a .once()
  40426. // handler in flow(), but adding and removing repeatedly is
  40427. // too slow.
  40428. var ondrain = pipeOnDrain(src);
  40429. dest.on('drain', ondrain);
  40430. var cleanedUp = false;
  40431. function cleanup() {
  40432. debug('cleanup');
  40433. // cleanup event handlers once the pipe is broken
  40434. dest.removeListener('close', onclose);
  40435. dest.removeListener('finish', onfinish);
  40436. dest.removeListener('drain', ondrain);
  40437. dest.removeListener('error', onerror);
  40438. dest.removeListener('unpipe', onunpipe);
  40439. src.removeListener('end', onend);
  40440. src.removeListener('end', cleanup);
  40441. src.removeListener('data', ondata);
  40442. cleanedUp = true;
  40443. // if the reader is waiting for a drain event from this
  40444. // specific writer, then it would cause it to never start
  40445. // flowing again.
  40446. // So, if this is awaiting a drain, then we just call it now.
  40447. // If we don't know, then assume that we are waiting for one.
  40448. if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
  40449. }
  40450. src.on('data', ondata);
  40451. function ondata(chunk) {
  40452. debug('ondata');
  40453. var ret = dest.write(chunk);
  40454. if (false === ret) {
  40455. // If the user unpiped during `dest.write()`, it is possible
  40456. // to get stuck in a permanently paused state if that write
  40457. // also returned false.
  40458. if (state.pipesCount === 1 && state.pipes[0] === dest && src.listenerCount('data') === 1 && !cleanedUp) {
  40459. debug('false write response, pause', src._readableState.awaitDrain);
  40460. src._readableState.awaitDrain++;
  40461. }
  40462. src.pause();
  40463. }
  40464. }
  40465. // if the dest has an error, then stop piping into it.
  40466. // however, don't suppress the throwing behavior for this.
  40467. function onerror(er) {
  40468. debug('onerror', er);
  40469. unpipe();
  40470. dest.removeListener('error', onerror);
  40471. if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
  40472. }
  40473. // This is a brutally ugly hack to make sure that our error handler
  40474. // is attached before any userland ones. NEVER DO THIS.
  40475. if (!dest._events || !dest._events.error) dest.on('error', onerror);else if (isArray(dest._events.error)) dest._events.error.unshift(onerror);else dest._events.error = [onerror, dest._events.error];
  40476. // Both close and finish should trigger unpipe, but only once.
  40477. function onclose() {
  40478. dest.removeListener('finish', onfinish);
  40479. unpipe();
  40480. }
  40481. dest.once('close', onclose);
  40482. function onfinish() {
  40483. debug('onfinish');
  40484. dest.removeListener('close', onclose);
  40485. unpipe();
  40486. }
  40487. dest.once('finish', onfinish);
  40488. function unpipe() {
  40489. debug('unpipe');
  40490. src.unpipe(dest);
  40491. }
  40492. // tell the dest that it's being piped to
  40493. dest.emit('pipe', src);
  40494. // start the flow if it hasn't been started already.
  40495. if (!state.flowing) {
  40496. debug('pipe resume');
  40497. src.resume();
  40498. }
  40499. return dest;
  40500. };
  40501. function pipeOnDrain(src) {
  40502. return function () {
  40503. var state = src._readableState;
  40504. debug('pipeOnDrain', state.awaitDrain);
  40505. if (state.awaitDrain) state.awaitDrain--;
  40506. if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
  40507. state.flowing = true;
  40508. flow(src);
  40509. }
  40510. };
  40511. }
  40512. Readable.prototype.unpipe = function (dest) {
  40513. var state = this._readableState;
  40514. // if we're not piping anywhere, then do nothing.
  40515. if (state.pipesCount === 0) return this;
  40516. // just one destination. most common case.
  40517. if (state.pipesCount === 1) {
  40518. // passed in one, but it's not the right one.
  40519. if (dest && dest !== state.pipes) return this;
  40520. if (!dest) dest = state.pipes;
  40521. // got a match.
  40522. state.pipes = null;
  40523. state.pipesCount = 0;
  40524. state.flowing = false;
  40525. if (dest) dest.emit('unpipe', this);
  40526. return this;
  40527. }
  40528. // slow case. multiple pipe destinations.
  40529. if (!dest) {
  40530. // remove all.
  40531. var dests = state.pipes;
  40532. var len = state.pipesCount;
  40533. state.pipes = null;
  40534. state.pipesCount = 0;
  40535. state.flowing = false;
  40536. for (var _i = 0; _i < len; _i++) {
  40537. dests[_i].emit('unpipe', this);
  40538. }return this;
  40539. }
  40540. // try to find the right one.
  40541. var i = indexOf(state.pipes, dest);
  40542. if (i === -1) return this;
  40543. state.pipes.splice(i, 1);
  40544. state.pipesCount -= 1;
  40545. if (state.pipesCount === 1) state.pipes = state.pipes[0];
  40546. dest.emit('unpipe', this);
  40547. return this;
  40548. };
  40549. // set up data events if they are asked for
  40550. // Ensure readable listeners eventually get something
  40551. Readable.prototype.on = function (ev, fn) {
  40552. var res = Stream.prototype.on.call(this, ev, fn);
  40553. // If listening to data, and it has not explicitly been paused,
  40554. // then call resume to start the flow of data on the next tick.
  40555. if (ev === 'data' && false !== this._readableState.flowing) {
  40556. this.resume();
  40557. }
  40558. if (ev === 'readable' && !this._readableState.endEmitted) {
  40559. var state = this._readableState;
  40560. if (!state.readableListening) {
  40561. state.readableListening = true;
  40562. state.emittedReadable = false;
  40563. state.needReadable = true;
  40564. if (!state.reading) {
  40565. processNextTick(nReadingNextTick, this);
  40566. } else if (state.length) {
  40567. emitReadable(this, state);
  40568. }
  40569. }
  40570. }
  40571. return res;
  40572. };
  40573. Readable.prototype.addListener = Readable.prototype.on;
  40574. function nReadingNextTick(self) {
  40575. debug('readable nexttick read 0');
  40576. self.read(0);
  40577. }
  40578. // pause() and resume() are remnants of the legacy readable stream API
  40579. // If the user uses them, then switch into old mode.
  40580. Readable.prototype.resume = function () {
  40581. var state = this._readableState;
  40582. if (!state.flowing) {
  40583. debug('resume');
  40584. state.flowing = true;
  40585. resume(this, state);
  40586. }
  40587. return this;
  40588. };
  40589. function resume(stream, state) {
  40590. if (!state.resumeScheduled) {
  40591. state.resumeScheduled = true;
  40592. processNextTick(resume_, stream, state);
  40593. }
  40594. }
  40595. function resume_(stream, state) {
  40596. if (!state.reading) {
  40597. debug('resume read 0');
  40598. stream.read(0);
  40599. }
  40600. state.resumeScheduled = false;
  40601. stream.emit('resume');
  40602. flow(stream);
  40603. if (state.flowing && !state.reading) stream.read(0);
  40604. }
  40605. Readable.prototype.pause = function () {
  40606. debug('call pause flowing=%j', this._readableState.flowing);
  40607. if (false !== this._readableState.flowing) {
  40608. debug('pause');
  40609. this._readableState.flowing = false;
  40610. this.emit('pause');
  40611. }
  40612. return this;
  40613. };
  40614. function flow(stream) {
  40615. var state = stream._readableState;
  40616. debug('flow', state.flowing);
  40617. if (state.flowing) {
  40618. do {
  40619. var chunk = stream.read();
  40620. } while (null !== chunk && state.flowing);
  40621. }
  40622. }
  40623. // wrap an old-style stream as the async data source.
  40624. // This is *not* part of the readable stream interface.
  40625. // It is an ugly unfortunate mess of history.
  40626. Readable.prototype.wrap = function (stream) {
  40627. var state = this._readableState;
  40628. var paused = false;
  40629. var self = this;
  40630. stream.on('end', function () {
  40631. debug('wrapped end');
  40632. if (state.decoder && !state.ended) {
  40633. var chunk = state.decoder.end();
  40634. if (chunk && chunk.length) self.push(chunk);
  40635. }
  40636. self.push(null);
  40637. });
  40638. stream.on('data', function (chunk) {
  40639. debug('wrapped data');
  40640. if (state.decoder) chunk = state.decoder.write(chunk);
  40641. // don't skip over falsy values in objectMode
  40642. if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
  40643. var ret = self.push(chunk);
  40644. if (!ret) {
  40645. paused = true;
  40646. stream.pause();
  40647. }
  40648. });
  40649. // proxy all the other methods.
  40650. // important when wrapping filters and duplexes.
  40651. for (var i in stream) {
  40652. if (this[i] === undefined && typeof stream[i] === 'function') {
  40653. this[i] = function (method) {
  40654. return function () {
  40655. return stream[method].apply(stream, arguments);
  40656. };
  40657. }(i);
  40658. }
  40659. }
  40660. // proxy certain important events.
  40661. var events = ['error', 'close', 'destroy', 'pause', 'resume'];
  40662. forEach(events, function (ev) {
  40663. stream.on(ev, self.emit.bind(self, ev));
  40664. });
  40665. // when we try to consume some more bytes, simply unpause the
  40666. // underlying stream.
  40667. self._read = function (n) {
  40668. debug('wrapped _read', n);
  40669. if (paused) {
  40670. paused = false;
  40671. stream.resume();
  40672. }
  40673. };
  40674. return self;
  40675. };
  40676. // exposed for testing purposes only.
  40677. Readable._fromList = fromList;
  40678. // Pluck off n bytes from an array of buffers.
  40679. // Length is the combined lengths of all the buffers in the list.
  40680. function fromList(n, state) {
  40681. var list = state.buffer;
  40682. var length = state.length;
  40683. var stringMode = !!state.decoder;
  40684. var objectMode = !!state.objectMode;
  40685. var ret;
  40686. // nothing in the list, definitely empty.
  40687. if (list.length === 0) return null;
  40688. if (length === 0) ret = null;else if (objectMode) ret = list.shift();else if (!n || n >= length) {
  40689. // read it all, truncate the array.
  40690. if (stringMode) ret = list.join('');else if (list.length === 1) ret = list[0];else ret = Buffer.concat(list, length);
  40691. list.length = 0;
  40692. } else {
  40693. // read just some of it.
  40694. if (n < list[0].length) {
  40695. // just take a part of the first list item.
  40696. // slice is the same for buffers and strings.
  40697. var buf = list[0];
  40698. ret = buf.slice(0, n);
  40699. list[0] = buf.slice(n);
  40700. } else if (n === list[0].length) {
  40701. // first list is a perfect match
  40702. ret = list.shift();
  40703. } else {
  40704. // complex case.
  40705. // we have enough to cover it, but it spans past the first buffer.
  40706. if (stringMode) ret = '';else ret = new Buffer(n);
  40707. var c = 0;
  40708. for (var i = 0, l = list.length; i < l && c < n; i++) {
  40709. var buf = list[0];
  40710. var cpy = Math.min(n - c, buf.length);
  40711. if (stringMode) ret += buf.slice(0, cpy);else buf.copy(ret, c, 0, cpy);
  40712. if (cpy < buf.length) list[0] = buf.slice(cpy);else list.shift();
  40713. c += cpy;
  40714. }
  40715. }
  40716. }
  40717. return ret;
  40718. }
  40719. function endReadable(stream) {
  40720. var state = stream._readableState;
  40721. // If we get here before consuming all the bytes, then that is a
  40722. // bug in node. Should never happen.
  40723. if (state.length > 0) throw new Error('endReadable called on non-empty stream');
  40724. if (!state.endEmitted) {
  40725. state.ended = true;
  40726. processNextTick(endReadableNT, state, stream);
  40727. }
  40728. }
  40729. function endReadableNT(state, stream) {
  40730. // Check that we didn't get one last unshift.
  40731. if (!state.endEmitted && state.length === 0) {
  40732. state.endEmitted = true;
  40733. stream.readable = false;
  40734. stream.emit('end');
  40735. }
  40736. }
  40737. function forEach(xs, f) {
  40738. for (var i = 0, l = xs.length; i < l; i++) {
  40739. f(xs[i], i);
  40740. }
  40741. }
  40742. function indexOf(xs, x) {
  40743. for (var i = 0, l = xs.length; i < l; i++) {
  40744. if (xs[i] === x) return i;
  40745. }
  40746. return -1;
  40747. }
  40748. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  40749. /***/ },
  40750. /* 217 */
  40751. /***/ function(module, exports, __webpack_require__) {
  40752. /* WEBPACK VAR INJECTION */(function(Buffer) {/**
  40753. * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
  40754. * in FIPS 180-2
  40755. * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
  40756. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  40757. *
  40758. */
  40759. var inherits = __webpack_require__(2)
  40760. var Hash = __webpack_require__(65)
  40761. var K = [
  40762. 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
  40763. 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
  40764. 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
  40765. 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
  40766. 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
  40767. 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
  40768. 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
  40769. 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
  40770. 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
  40771. 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
  40772. 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
  40773. 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
  40774. 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
  40775. 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
  40776. 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
  40777. 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2
  40778. ]
  40779. var W = new Array(64)
  40780. function Sha256 () {
  40781. this.init()
  40782. this._w = W // new Array(64)
  40783. Hash.call(this, 64, 56)
  40784. }
  40785. inherits(Sha256, Hash)
  40786. Sha256.prototype.init = function () {
  40787. this._a = 0x6a09e667
  40788. this._b = 0xbb67ae85
  40789. this._c = 0x3c6ef372
  40790. this._d = 0xa54ff53a
  40791. this._e = 0x510e527f
  40792. this._f = 0x9b05688c
  40793. this._g = 0x1f83d9ab
  40794. this._h = 0x5be0cd19
  40795. return this
  40796. }
  40797. function ch (x, y, z) {
  40798. return z ^ (x & (y ^ z))
  40799. }
  40800. function maj (x, y, z) {
  40801. return (x & y) | (z & (x | y))
  40802. }
  40803. function sigma0 (x) {
  40804. return (x >>> 2 | x << 30) ^ (x >>> 13 | x << 19) ^ (x >>> 22 | x << 10)
  40805. }
  40806. function sigma1 (x) {
  40807. return (x >>> 6 | x << 26) ^ (x >>> 11 | x << 21) ^ (x >>> 25 | x << 7)
  40808. }
  40809. function gamma0 (x) {
  40810. return (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ (x >>> 3)
  40811. }
  40812. function gamma1 (x) {
  40813. return (x >>> 17 | x << 15) ^ (x >>> 19 | x << 13) ^ (x >>> 10)
  40814. }
  40815. Sha256.prototype._update = function (M) {
  40816. var W = this._w
  40817. var a = this._a | 0
  40818. var b = this._b | 0
  40819. var c = this._c | 0
  40820. var d = this._d | 0
  40821. var e = this._e | 0
  40822. var f = this._f | 0
  40823. var g = this._g | 0
  40824. var h = this._h | 0
  40825. for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
  40826. for (; i < 64; ++i) W[i] = (gamma1(W[i - 2]) + W[i - 7] + gamma0(W[i - 15]) + W[i - 16]) | 0
  40827. for (var j = 0; j < 64; ++j) {
  40828. var T1 = (h + sigma1(e) + ch(e, f, g) + K[j] + W[j]) | 0
  40829. var T2 = (sigma0(a) + maj(a, b, c)) | 0
  40830. h = g
  40831. g = f
  40832. f = e
  40833. e = (d + T1) | 0
  40834. d = c
  40835. c = b
  40836. b = a
  40837. a = (T1 + T2) | 0
  40838. }
  40839. this._a = (a + this._a) | 0
  40840. this._b = (b + this._b) | 0
  40841. this._c = (c + this._c) | 0
  40842. this._d = (d + this._d) | 0
  40843. this._e = (e + this._e) | 0
  40844. this._f = (f + this._f) | 0
  40845. this._g = (g + this._g) | 0
  40846. this._h = (h + this._h) | 0
  40847. }
  40848. Sha256.prototype._hash = function () {
  40849. var H = new Buffer(32)
  40850. H.writeInt32BE(this._a, 0)
  40851. H.writeInt32BE(this._b, 4)
  40852. H.writeInt32BE(this._c, 8)
  40853. H.writeInt32BE(this._d, 12)
  40854. H.writeInt32BE(this._e, 16)
  40855. H.writeInt32BE(this._f, 20)
  40856. H.writeInt32BE(this._g, 24)
  40857. H.writeInt32BE(this._h, 28)
  40858. return H
  40859. }
  40860. module.exports = Sha256
  40861. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  40862. /***/ },
  40863. /* 218 */
  40864. /***/ function(module, exports, __webpack_require__) {
  40865. /* WEBPACK VAR INJECTION */(function(Buffer) {var inherits = __webpack_require__(2)
  40866. var Hash = __webpack_require__(65)
  40867. var K = [
  40868. 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
  40869. 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
  40870. 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
  40871. 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
  40872. 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
  40873. 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
  40874. 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
  40875. 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
  40876. 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
  40877. 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
  40878. 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
  40879. 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
  40880. 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
  40881. 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
  40882. 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
  40883. 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
  40884. 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
  40885. 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
  40886. 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
  40887. 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
  40888. 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
  40889. 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
  40890. 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
  40891. 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
  40892. 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
  40893. 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
  40894. 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
  40895. 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
  40896. 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
  40897. 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
  40898. 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
  40899. 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
  40900. 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
  40901. 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
  40902. 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
  40903. 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
  40904. 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
  40905. 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
  40906. 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
  40907. 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
  40908. ]
  40909. var W = new Array(160)
  40910. function Sha512 () {
  40911. this.init()
  40912. this._w = W
  40913. Hash.call(this, 128, 112)
  40914. }
  40915. inherits(Sha512, Hash)
  40916. Sha512.prototype.init = function () {
  40917. this._ah = 0x6a09e667
  40918. this._bh = 0xbb67ae85
  40919. this._ch = 0x3c6ef372
  40920. this._dh = 0xa54ff53a
  40921. this._eh = 0x510e527f
  40922. this._fh = 0x9b05688c
  40923. this._gh = 0x1f83d9ab
  40924. this._hh = 0x5be0cd19
  40925. this._al = 0xf3bcc908
  40926. this._bl = 0x84caa73b
  40927. this._cl = 0xfe94f82b
  40928. this._dl = 0x5f1d36f1
  40929. this._el = 0xade682d1
  40930. this._fl = 0x2b3e6c1f
  40931. this._gl = 0xfb41bd6b
  40932. this._hl = 0x137e2179
  40933. return this
  40934. }
  40935. function Ch (x, y, z) {
  40936. return z ^ (x & (y ^ z))
  40937. }
  40938. function maj (x, y, z) {
  40939. return (x & y) | (z & (x | y))
  40940. }
  40941. function sigma0 (x, xl) {
  40942. return (x >>> 28 | xl << 4) ^ (xl >>> 2 | x << 30) ^ (xl >>> 7 | x << 25)
  40943. }
  40944. function sigma1 (x, xl) {
  40945. return (x >>> 14 | xl << 18) ^ (x >>> 18 | xl << 14) ^ (xl >>> 9 | x << 23)
  40946. }
  40947. function Gamma0 (x, xl) {
  40948. return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7)
  40949. }
  40950. function Gamma0l (x, xl) {
  40951. return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7 | xl << 25)
  40952. }
  40953. function Gamma1 (x, xl) {
  40954. return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6)
  40955. }
  40956. function Gamma1l (x, xl) {
  40957. return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6 | xl << 26)
  40958. }
  40959. function getCarry (a, b) {
  40960. return (a >>> 0) < (b >>> 0) ? 1 : 0
  40961. }
  40962. Sha512.prototype._update = function (M) {
  40963. var W = this._w
  40964. var ah = this._ah | 0
  40965. var bh = this._bh | 0
  40966. var ch = this._ch | 0
  40967. var dh = this._dh | 0
  40968. var eh = this._eh | 0
  40969. var fh = this._fh | 0
  40970. var gh = this._gh | 0
  40971. var hh = this._hh | 0
  40972. var al = this._al | 0
  40973. var bl = this._bl | 0
  40974. var cl = this._cl | 0
  40975. var dl = this._dl | 0
  40976. var el = this._el | 0
  40977. var fl = this._fl | 0
  40978. var gl = this._gl | 0
  40979. var hl = this._hl | 0
  40980. for (var i = 0; i < 32; i += 2) {
  40981. W[i] = M.readInt32BE(i * 4)
  40982. W[i + 1] = M.readInt32BE(i * 4 + 4)
  40983. }
  40984. for (; i < 160; i += 2) {
  40985. var xh = W[i - 15 * 2]
  40986. var xl = W[i - 15 * 2 + 1]
  40987. var gamma0 = Gamma0(xh, xl)
  40988. var gamma0l = Gamma0l(xl, xh)
  40989. xh = W[i - 2 * 2]
  40990. xl = W[i - 2 * 2 + 1]
  40991. var gamma1 = Gamma1(xh, xl)
  40992. var gamma1l = Gamma1l(xl, xh)
  40993. // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
  40994. var Wi7h = W[i - 7 * 2]
  40995. var Wi7l = W[i - 7 * 2 + 1]
  40996. var Wi16h = W[i - 16 * 2]
  40997. var Wi16l = W[i - 16 * 2 + 1]
  40998. var Wil = (gamma0l + Wi7l) | 0
  40999. var Wih = (gamma0 + Wi7h + getCarry(Wil, gamma0l)) | 0
  41000. Wil = (Wil + gamma1l) | 0
  41001. Wih = (Wih + gamma1 + getCarry(Wil, gamma1l)) | 0
  41002. Wil = (Wil + Wi16l) | 0
  41003. Wih = (Wih + Wi16h + getCarry(Wil, Wi16l)) | 0
  41004. W[i] = Wih
  41005. W[i + 1] = Wil
  41006. }
  41007. for (var j = 0; j < 160; j += 2) {
  41008. Wih = W[j]
  41009. Wil = W[j + 1]
  41010. var majh = maj(ah, bh, ch)
  41011. var majl = maj(al, bl, cl)
  41012. var sigma0h = sigma0(ah, al)
  41013. var sigma0l = sigma0(al, ah)
  41014. var sigma1h = sigma1(eh, el)
  41015. var sigma1l = sigma1(el, eh)
  41016. // t1 = h + sigma1 + ch + K[j] + W[j]
  41017. var Kih = K[j]
  41018. var Kil = K[j + 1]
  41019. var chh = Ch(eh, fh, gh)
  41020. var chl = Ch(el, fl, gl)
  41021. var t1l = (hl + sigma1l) | 0
  41022. var t1h = (hh + sigma1h + getCarry(t1l, hl)) | 0
  41023. t1l = (t1l + chl) | 0
  41024. t1h = (t1h + chh + getCarry(t1l, chl)) | 0
  41025. t1l = (t1l + Kil) | 0
  41026. t1h = (t1h + Kih + getCarry(t1l, Kil)) | 0
  41027. t1l = (t1l + Wil) | 0
  41028. t1h = (t1h + Wih + getCarry(t1l, Wil)) | 0
  41029. // t2 = sigma0 + maj
  41030. var t2l = (sigma0l + majl) | 0
  41031. var t2h = (sigma0h + majh + getCarry(t2l, sigma0l)) | 0
  41032. hh = gh
  41033. hl = gl
  41034. gh = fh
  41035. gl = fl
  41036. fh = eh
  41037. fl = el
  41038. el = (dl + t1l) | 0
  41039. eh = (dh + t1h + getCarry(el, dl)) | 0
  41040. dh = ch
  41041. dl = cl
  41042. ch = bh
  41043. cl = bl
  41044. bh = ah
  41045. bl = al
  41046. al = (t1l + t2l) | 0
  41047. ah = (t1h + t2h + getCarry(al, t1l)) | 0
  41048. }
  41049. this._al = (this._al + al) | 0
  41050. this._bl = (this._bl + bl) | 0
  41051. this._cl = (this._cl + cl) | 0
  41052. this._dl = (this._dl + dl) | 0
  41053. this._el = (this._el + el) | 0
  41054. this._fl = (this._fl + fl) | 0
  41055. this._gl = (this._gl + gl) | 0
  41056. this._hl = (this._hl + hl) | 0
  41057. this._ah = (this._ah + ah + getCarry(this._al, al)) | 0
  41058. this._bh = (this._bh + bh + getCarry(this._bl, bl)) | 0
  41059. this._ch = (this._ch + ch + getCarry(this._cl, cl)) | 0
  41060. this._dh = (this._dh + dh + getCarry(this._dl, dl)) | 0
  41061. this._eh = (this._eh + eh + getCarry(this._el, el)) | 0
  41062. this._fh = (this._fh + fh + getCarry(this._fl, fl)) | 0
  41063. this._gh = (this._gh + gh + getCarry(this._gl, gl)) | 0
  41064. this._hh = (this._hh + hh + getCarry(this._hl, hl)) | 0
  41065. }
  41066. Sha512.prototype._hash = function () {
  41067. var H = new Buffer(64)
  41068. function writeInt64BE (h, l, offset) {
  41069. H.writeInt32BE(h, offset)
  41070. H.writeInt32BE(l, offset + 4)
  41071. }
  41072. writeInt64BE(this._ah, this._al, 0)
  41073. writeInt64BE(this._bh, this._bl, 8)
  41074. writeInt64BE(this._ch, this._cl, 16)
  41075. writeInt64BE(this._dh, this._dl, 24)
  41076. writeInt64BE(this._eh, this._el, 32)
  41077. writeInt64BE(this._fh, this._fl, 40)
  41078. writeInt64BE(this._gh, this._gl, 48)
  41079. writeInt64BE(this._hh, this._hl, 56)
  41080. return H
  41081. }
  41082. module.exports = Sha512
  41083. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  41084. /***/ },
  41085. /* 219 */
  41086. /***/ function(module, exports, __webpack_require__) {
  41087. /* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors.
  41088. //
  41089. // Permission is hereby granted, free of charge, to any person obtaining a
  41090. // copy of this software and associated documentation files (the
  41091. // "Software"), to deal in the Software without restriction, including
  41092. // without limitation the rights to use, copy, modify, merge, publish,
  41093. // distribute, sublicense, and/or sell copies of the Software, and to permit
  41094. // persons to whom the Software is furnished to do so, subject to the
  41095. // following conditions:
  41096. //
  41097. // The above copyright notice and this permission notice shall be included
  41098. // in all copies or substantial portions of the Software.
  41099. //
  41100. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  41101. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  41102. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  41103. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  41104. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  41105. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  41106. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  41107. // a duplex stream is just a stream that is both readable and writable.
  41108. // Since JS doesn't have multiple prototypal inheritance, this class
  41109. // prototypally inherits from Readable, and then parasitically from
  41110. // Writable.
  41111. module.exports = Duplex;
  41112. /*<replacement>*/
  41113. var objectKeys = Object.keys || function (obj) {
  41114. var keys = [];
  41115. for (var key in obj) keys.push(key);
  41116. return keys;
  41117. }
  41118. /*</replacement>*/
  41119. /*<replacement>*/
  41120. var util = __webpack_require__(14);
  41121. util.inherits = __webpack_require__(2);
  41122. /*</replacement>*/
  41123. var Readable = __webpack_require__(568);
  41124. var Writable = __webpack_require__(570);
  41125. util.inherits(Duplex, Readable);
  41126. forEach(objectKeys(Writable.prototype), function(method) {
  41127. if (!Duplex.prototype[method])
  41128. Duplex.prototype[method] = Writable.prototype[method];
  41129. });
  41130. function Duplex(options) {
  41131. if (!(this instanceof Duplex))
  41132. return new Duplex(options);
  41133. Readable.call(this, options);
  41134. Writable.call(this, options);
  41135. if (options && options.readable === false)
  41136. this.readable = false;
  41137. if (options && options.writable === false)
  41138. this.writable = false;
  41139. this.allowHalfOpen = true;
  41140. if (options && options.allowHalfOpen === false)
  41141. this.allowHalfOpen = false;
  41142. this.once('end', onend);
  41143. }
  41144. // the no-half-open enforcer
  41145. function onend() {
  41146. // if we allow half-open state, or if the writable side ended,
  41147. // then we're ok.
  41148. if (this.allowHalfOpen || this._writableState.ended)
  41149. return;
  41150. // no more data can be written.
  41151. // But allow more writes to happen in this tick.
  41152. process.nextTick(this.end.bind(this));
  41153. }
  41154. function forEach (xs, f) {
  41155. for (var i = 0, l = xs.length; i < l; i++) {
  41156. f(xs[i], i);
  41157. }
  41158. }
  41159. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  41160. /***/ },
  41161. /* 220 */
  41162. /***/ function(module, exports, __webpack_require__) {
  41163. /* WEBPACK VAR INJECTION */(function(global) {var ClientRequest = __webpack_require__(574)
  41164. var extend = __webpack_require__(98)
  41165. var statusCodes = __webpack_require__(293)
  41166. var url = __webpack_require__(226)
  41167. var http = exports
  41168. http.request = function (opts, cb) {
  41169. if (typeof opts === 'string')
  41170. opts = url.parse(opts)
  41171. else
  41172. opts = extend(opts)
  41173. // Normally, the page is loaded from http or https, so not specifying a protocol
  41174. // will result in a (valid) protocol-relative url. However, this won't work if
  41175. // the protocol is something else, like 'file:'
  41176. var defaultProtocol = global.location.protocol.search(/^https?:$/) === -1 ? 'http:' : ''
  41177. var protocol = opts.protocol || defaultProtocol
  41178. var host = opts.hostname || opts.host
  41179. var port = opts.port
  41180. var path = opts.path || '/'
  41181. // Necessary for IPv6 addresses
  41182. if (host && host.indexOf(':') !== -1)
  41183. host = '[' + host + ']'
  41184. // This may be a relative url. The browser should always be able to interpret it correctly.
  41185. opts.url = (host ? (protocol + '//' + host) : '') + (port ? ':' + port : '') + path
  41186. opts.method = (opts.method || 'GET').toUpperCase()
  41187. opts.headers = opts.headers || {}
  41188. // Also valid opts.auth, opts.mode
  41189. var req = new ClientRequest(opts)
  41190. if (cb)
  41191. req.on('response', cb)
  41192. return req
  41193. }
  41194. http.get = function get (opts, cb) {
  41195. var req = http.request(opts, cb)
  41196. req.end()
  41197. return req
  41198. }
  41199. http.Agent = function () {}
  41200. http.Agent.defaultMaxSockets = 4
  41201. http.STATUS_CODES = statusCodes
  41202. http.METHODS = [
  41203. 'CHECKOUT',
  41204. 'CONNECT',
  41205. 'COPY',
  41206. 'DELETE',
  41207. 'GET',
  41208. 'HEAD',
  41209. 'LOCK',
  41210. 'M-SEARCH',
  41211. 'MERGE',
  41212. 'MKACTIVITY',
  41213. 'MKCOL',
  41214. 'MOVE',
  41215. 'NOTIFY',
  41216. 'OPTIONS',
  41217. 'PATCH',
  41218. 'POST',
  41219. 'PROPFIND',
  41220. 'PROPPATCH',
  41221. 'PURGE',
  41222. 'PUT',
  41223. 'REPORT',
  41224. 'SEARCH',
  41225. 'SUBSCRIBE',
  41226. 'TRACE',
  41227. 'UNLOCK',
  41228. 'UNSUBSCRIBE'
  41229. ]
  41230. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(13)))
  41231. /***/ },
  41232. /* 221 */
  41233. /***/ function(module, exports, __webpack_require__) {
  41234. /* WEBPACK VAR INJECTION */(function(global) {exports.fetch = isFunction(global.fetch) && isFunction(global.ReadableByteStream)
  41235. exports.blobConstructor = false
  41236. try {
  41237. new Blob([new ArrayBuffer(1)])
  41238. exports.blobConstructor = true
  41239. } catch (e) {}
  41240. var xhr = new global.XMLHttpRequest()
  41241. // If location.host is empty, e.g. if this page/worker was loaded
  41242. // from a Blob, then use example.com to avoid an error
  41243. xhr.open('GET', global.location.host ? '/' : 'https://example.com')
  41244. function checkTypeSupport (type) {
  41245. try {
  41246. xhr.responseType = type
  41247. return xhr.responseType === type
  41248. } catch (e) {}
  41249. return false
  41250. }
  41251. // For some strange reason, Safari 7.0 reports typeof global.ArrayBuffer === 'object'.
  41252. // Safari 7.1 appears to have fixed this bug.
  41253. var haveArrayBuffer = typeof global.ArrayBuffer !== 'undefined'
  41254. var haveSlice = haveArrayBuffer && isFunction(global.ArrayBuffer.prototype.slice)
  41255. exports.arraybuffer = haveArrayBuffer && checkTypeSupport('arraybuffer')
  41256. // These next two tests unavoidably show warnings in Chrome. Since fetch will always
  41257. // be used if it's available, just return false for these to avoid the warnings.
  41258. exports.msstream = !exports.fetch && haveSlice && checkTypeSupport('ms-stream')
  41259. exports.mozchunkedarraybuffer = !exports.fetch && haveArrayBuffer &&
  41260. checkTypeSupport('moz-chunked-arraybuffer')
  41261. exports.overrideMimeType = isFunction(xhr.overrideMimeType)
  41262. exports.vbArray = isFunction(global.VBArray)
  41263. function isFunction (value) {
  41264. return typeof value === 'function'
  41265. }
  41266. xhr = null // Help gc
  41267. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(13)))
  41268. /***/ },
  41269. /* 222 */
  41270. /***/ function(module, exports, __webpack_require__) {
  41271. "use strict";
  41272. /* WEBPACK VAR INJECTION */(function(process) {'use strict';
  41273. module.exports = Readable;
  41274. /*<replacement>*/
  41275. var processNextTick = __webpack_require__(64);
  41276. /*</replacement>*/
  41277. /*<replacement>*/
  41278. var isArray = __webpack_require__(133);
  41279. /*</replacement>*/
  41280. Readable.ReadableState = ReadableState;
  41281. /*<replacement>*/
  41282. var EE = __webpack_require__(30).EventEmitter;
  41283. var EElistenerCount = function (emitter, type) {
  41284. return emitter.listeners(type).length;
  41285. };
  41286. /*</replacement>*/
  41287. /*<replacement>*/
  41288. var Stream;
  41289. (function () {
  41290. try {
  41291. Stream = __webpack_require__(9);
  41292. } catch (_) {} finally {
  41293. if (!Stream) Stream = __webpack_require__(30).EventEmitter;
  41294. }
  41295. })();
  41296. /*</replacement>*/
  41297. var Buffer = __webpack_require__(1).Buffer;
  41298. /*<replacement>*/
  41299. var bufferShim = __webpack_require__(167);
  41300. /*</replacement>*/
  41301. /*<replacement>*/
  41302. var util = __webpack_require__(14);
  41303. util.inherits = __webpack_require__(2);
  41304. /*</replacement>*/
  41305. /*<replacement>*/
  41306. var debugUtil = __webpack_require__(586);
  41307. var debug = void 0;
  41308. if (debugUtil && debugUtil.debuglog) {
  41309. debug = debugUtil.debuglog('stream');
  41310. } else {
  41311. debug = function () {};
  41312. }
  41313. /*</replacement>*/
  41314. var StringDecoder;
  41315. util.inherits(Readable, Stream);
  41316. var hasPrependListener = typeof EE.prototype.prependListener === 'function';
  41317. function prependListener(emitter, event, fn) {
  41318. if (hasPrependListener) return emitter.prependListener(event, fn);
  41319. // This is a brutally ugly hack to make sure that our error handler
  41320. // is attached before any userland ones. NEVER DO THIS. This is here
  41321. // only because this code needs to continue to work with older versions
  41322. // of Node.js that do not include the prependListener() method. The goal
  41323. // is to eventually remove this hack.
  41324. if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
  41325. }
  41326. var Duplex;
  41327. function ReadableState(options, stream) {
  41328. Duplex = Duplex || __webpack_require__(66);
  41329. options = options || {};
  41330. // object stream flag. Used to make read(n) ignore n and to
  41331. // make all the buffer merging and length checks go away
  41332. this.objectMode = !!options.objectMode;
  41333. if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
  41334. // the point at which it stops calling _read() to fill the buffer
  41335. // Note: 0 is a valid value, means "don't call _read preemptively ever"
  41336. var hwm = options.highWaterMark;
  41337. var defaultHwm = this.objectMode ? 16 : 16 * 1024;
  41338. this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
  41339. // cast to ints.
  41340. this.highWaterMark = ~ ~this.highWaterMark;
  41341. this.buffer = [];
  41342. this.length = 0;
  41343. this.pipes = null;
  41344. this.pipesCount = 0;
  41345. this.flowing = null;
  41346. this.ended = false;
  41347. this.endEmitted = false;
  41348. this.reading = false;
  41349. // a flag to be able to tell if the onwrite cb is called immediately,
  41350. // or on a later tick. We set this to true at first, because any
  41351. // actions that shouldn't happen until "later" should generally also
  41352. // not happen before the first write call.
  41353. this.sync = true;
  41354. // whenever we return null, then we set a flag to say
  41355. // that we're awaiting a 'readable' event emission.
  41356. this.needReadable = false;
  41357. this.emittedReadable = false;
  41358. this.readableListening = false;
  41359. this.resumeScheduled = false;
  41360. // Crypto is kind of old and crusty. Historically, its default string
  41361. // encoding is 'binary' so we have to make this configurable.
  41362. // Everything else in the universe uses 'utf8', though.
  41363. this.defaultEncoding = options.defaultEncoding || 'utf8';
  41364. // when piping, we only care about 'readable' events that happen
  41365. // after read()ing all the bytes and not getting any pushback.
  41366. this.ranOut = false;
  41367. // the number of writers that are awaiting a drain event in .pipe()s
  41368. this.awaitDrain = 0;
  41369. // if true, a maybeReadMore has been scheduled
  41370. this.readingMore = false;
  41371. this.decoder = null;
  41372. this.encoding = null;
  41373. if (options.encoding) {
  41374. if (!StringDecoder) StringDecoder = __webpack_require__(38).StringDecoder;
  41375. this.decoder = new StringDecoder(options.encoding);
  41376. this.encoding = options.encoding;
  41377. }
  41378. }
  41379. var Duplex;
  41380. function Readable(options) {
  41381. Duplex = Duplex || __webpack_require__(66);
  41382. if (!(this instanceof Readable)) return new Readable(options);
  41383. this._readableState = new ReadableState(options, this);
  41384. // legacy
  41385. this.readable = true;
  41386. if (options && typeof options.read === 'function') this._read = options.read;
  41387. Stream.call(this);
  41388. }
  41389. // Manually shove something into the read() buffer.
  41390. // This returns true if the highWaterMark has not been hit yet,
  41391. // similar to how Writable.write() returns true if you should
  41392. // write() some more.
  41393. Readable.prototype.push = function (chunk, encoding) {
  41394. var state = this._readableState;
  41395. if (!state.objectMode && typeof chunk === 'string') {
  41396. encoding = encoding || state.defaultEncoding;
  41397. if (encoding !== state.encoding) {
  41398. chunk = bufferShim.from(chunk, encoding);
  41399. encoding = '';
  41400. }
  41401. }
  41402. return readableAddChunk(this, state, chunk, encoding, false);
  41403. };
  41404. // Unshift should *always* be something directly out of read()
  41405. Readable.prototype.unshift = function (chunk) {
  41406. var state = this._readableState;
  41407. return readableAddChunk(this, state, chunk, '', true);
  41408. };
  41409. Readable.prototype.isPaused = function () {
  41410. return this._readableState.flowing === false;
  41411. };
  41412. function readableAddChunk(stream, state, chunk, encoding, addToFront) {
  41413. var er = chunkInvalid(state, chunk);
  41414. if (er) {
  41415. stream.emit('error', er);
  41416. } else if (chunk === null) {
  41417. state.reading = false;
  41418. onEofChunk(stream, state);
  41419. } else if (state.objectMode || chunk && chunk.length > 0) {
  41420. if (state.ended && !addToFront) {
  41421. var e = new Error('stream.push() after EOF');
  41422. stream.emit('error', e);
  41423. } else if (state.endEmitted && addToFront) {
  41424. var _e = new Error('stream.unshift() after end event');
  41425. stream.emit('error', _e);
  41426. } else {
  41427. var skipAdd;
  41428. if (state.decoder && !addToFront && !encoding) {
  41429. chunk = state.decoder.write(chunk);
  41430. skipAdd = !state.objectMode && chunk.length === 0;
  41431. }
  41432. if (!addToFront) state.reading = false;
  41433. // Don't add to the buffer if we've decoded to an empty string chunk and
  41434. // we're not in object mode
  41435. if (!skipAdd) {
  41436. // if we want the data now, just emit it.
  41437. if (state.flowing && state.length === 0 && !state.sync) {
  41438. stream.emit('data', chunk);
  41439. stream.read(0);
  41440. } else {
  41441. // update the buffer info.
  41442. state.length += state.objectMode ? 1 : chunk.length;
  41443. if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
  41444. if (state.needReadable) emitReadable(stream);
  41445. }
  41446. }
  41447. maybeReadMore(stream, state);
  41448. }
  41449. } else if (!addToFront) {
  41450. state.reading = false;
  41451. }
  41452. return needMoreData(state);
  41453. }
  41454. // if it's past the high water mark, we can push in some more.
  41455. // Also, if we have no data yet, we can stand some
  41456. // more bytes. This is to work around cases where hwm=0,
  41457. // such as the repl. Also, if the push() triggered a
  41458. // readable event, and the user called read(largeNumber) such that
  41459. // needReadable was set, then we ought to push more, so that another
  41460. // 'readable' event will be triggered.
  41461. function needMoreData(state) {
  41462. return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
  41463. }
  41464. // backwards compatibility.
  41465. Readable.prototype.setEncoding = function (enc) {
  41466. if (!StringDecoder) StringDecoder = __webpack_require__(38).StringDecoder;
  41467. this._readableState.decoder = new StringDecoder(enc);
  41468. this._readableState.encoding = enc;
  41469. return this;
  41470. };
  41471. // Don't raise the hwm > 8MB
  41472. var MAX_HWM = 0x800000;
  41473. function computeNewHighWaterMark(n) {
  41474. if (n >= MAX_HWM) {
  41475. n = MAX_HWM;
  41476. } else {
  41477. // Get the next highest power of 2
  41478. n--;
  41479. n |= n >>> 1;
  41480. n |= n >>> 2;
  41481. n |= n >>> 4;
  41482. n |= n >>> 8;
  41483. n |= n >>> 16;
  41484. n++;
  41485. }
  41486. return n;
  41487. }
  41488. function howMuchToRead(n, state) {
  41489. if (state.length === 0 && state.ended) return 0;
  41490. if (state.objectMode) return n === 0 ? 0 : 1;
  41491. if (n === null || isNaN(n)) {
  41492. // only flow one buffer at a time
  41493. if (state.flowing && state.buffer.length) return state.buffer[0].length;else return state.length;
  41494. }
  41495. if (n <= 0) return 0;
  41496. // If we're asking for more than the target buffer level,
  41497. // then raise the water mark. Bump up to the next highest
  41498. // power of 2, to prevent increasing it excessively in tiny
  41499. // amounts.
  41500. if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
  41501. // don't have that much. return null, unless we've ended.
  41502. if (n > state.length) {
  41503. if (!state.ended) {
  41504. state.needReadable = true;
  41505. return 0;
  41506. } else {
  41507. return state.length;
  41508. }
  41509. }
  41510. return n;
  41511. }
  41512. // you can override either this method, or the async _read(n) below.
  41513. Readable.prototype.read = function (n) {
  41514. debug('read', n);
  41515. var state = this._readableState;
  41516. var nOrig = n;
  41517. if (typeof n !== 'number' || n > 0) state.emittedReadable = false;
  41518. // if we're doing read(0) to trigger a readable event, but we
  41519. // already have a bunch of data in the buffer, then just trigger
  41520. // the 'readable' event and move on.
  41521. if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
  41522. debug('read: emitReadable', state.length, state.ended);
  41523. if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
  41524. return null;
  41525. }
  41526. n = howMuchToRead(n, state);
  41527. // if we've ended, and we're now clear, then finish it up.
  41528. if (n === 0 && state.ended) {
  41529. if (state.length === 0) endReadable(this);
  41530. return null;
  41531. }
  41532. // All the actual chunk generation logic needs to be
  41533. // *below* the call to _read. The reason is that in certain
  41534. // synthetic stream cases, such as passthrough streams, _read
  41535. // may be a completely synchronous operation which may change
  41536. // the state of the read buffer, providing enough data when
  41537. // before there was *not* enough.
  41538. //
  41539. // So, the steps are:
  41540. // 1. Figure out what the state of things will be after we do
  41541. // a read from the buffer.
  41542. //
  41543. // 2. If that resulting state will trigger a _read, then call _read.
  41544. // Note that this may be asynchronous, or synchronous. Yes, it is
  41545. // deeply ugly to write APIs this way, but that still doesn't mean
  41546. // that the Readable class should behave improperly, as streams are
  41547. // designed to be sync/async agnostic.
  41548. // Take note if the _read call is sync or async (ie, if the read call
  41549. // has returned yet), so that we know whether or not it's safe to emit
  41550. // 'readable' etc.
  41551. //
  41552. // 3. Actually pull the requested chunks out of the buffer and return.
  41553. // if we need a readable event, then we need to do some reading.
  41554. var doRead = state.needReadable;
  41555. debug('need readable', doRead);
  41556. // if we currently have less than the highWaterMark, then also read some
  41557. if (state.length === 0 || state.length - n < state.highWaterMark) {
  41558. doRead = true;
  41559. debug('length less than watermark', doRead);
  41560. }
  41561. // however, if we've ended, then there's no point, and if we're already
  41562. // reading, then it's unnecessary.
  41563. if (state.ended || state.reading) {
  41564. doRead = false;
  41565. debug('reading or ended', doRead);
  41566. }
  41567. if (doRead) {
  41568. debug('do read');
  41569. state.reading = true;
  41570. state.sync = true;
  41571. // if the length is currently zero, then we *need* a readable event.
  41572. if (state.length === 0) state.needReadable = true;
  41573. // call internal read method
  41574. this._read(state.highWaterMark);
  41575. state.sync = false;
  41576. }
  41577. // If _read pushed data synchronously, then `reading` will be false,
  41578. // and we need to re-evaluate how much data we can return to the user.
  41579. if (doRead && !state.reading) n = howMuchToRead(nOrig, state);
  41580. var ret;
  41581. if (n > 0) ret = fromList(n, state);else ret = null;
  41582. if (ret === null) {
  41583. state.needReadable = true;
  41584. n = 0;
  41585. }
  41586. state.length -= n;
  41587. // If we have nothing in the buffer, then we want to know
  41588. // as soon as we *do* get something into the buffer.
  41589. if (state.length === 0 && !state.ended) state.needReadable = true;
  41590. // If we tried to read() past the EOF, then emit end on the next tick.
  41591. if (nOrig !== n && state.ended && state.length === 0) endReadable(this);
  41592. if (ret !== null) this.emit('data', ret);
  41593. return ret;
  41594. };
  41595. function chunkInvalid(state, chunk) {
  41596. var er = null;
  41597. if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== null && chunk !== undefined && !state.objectMode) {
  41598. er = new TypeError('Invalid non-string/buffer chunk');
  41599. }
  41600. return er;
  41601. }
  41602. function onEofChunk(stream, state) {
  41603. if (state.ended) return;
  41604. if (state.decoder) {
  41605. var chunk = state.decoder.end();
  41606. if (chunk && chunk.length) {
  41607. state.buffer.push(chunk);
  41608. state.length += state.objectMode ? 1 : chunk.length;
  41609. }
  41610. }
  41611. state.ended = true;
  41612. // emit 'readable' now to make sure it gets picked up.
  41613. emitReadable(stream);
  41614. }
  41615. // Don't emit readable right away in sync mode, because this can trigger
  41616. // another read() call => stack overflow. This way, it might trigger
  41617. // a nextTick recursion warning, but that's not so bad.
  41618. function emitReadable(stream) {
  41619. var state = stream._readableState;
  41620. state.needReadable = false;
  41621. if (!state.emittedReadable) {
  41622. debug('emitReadable', state.flowing);
  41623. state.emittedReadable = true;
  41624. if (state.sync) processNextTick(emitReadable_, stream);else emitReadable_(stream);
  41625. }
  41626. }
  41627. function emitReadable_(stream) {
  41628. debug('emit readable');
  41629. stream.emit('readable');
  41630. flow(stream);
  41631. }
  41632. // at this point, the user has presumably seen the 'readable' event,
  41633. // and called read() to consume some data. that may have triggered
  41634. // in turn another _read(n) call, in which case reading = true if
  41635. // it's in progress.
  41636. // However, if we're not ended, or reading, and the length < hwm,
  41637. // then go ahead and try to read some more preemptively.
  41638. function maybeReadMore(stream, state) {
  41639. if (!state.readingMore) {
  41640. state.readingMore = true;
  41641. processNextTick(maybeReadMore_, stream, state);
  41642. }
  41643. }
  41644. function maybeReadMore_(stream, state) {
  41645. var len = state.length;
  41646. while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
  41647. debug('maybeReadMore read 0');
  41648. stream.read(0);
  41649. if (len === state.length)
  41650. // didn't get any data, stop spinning.
  41651. break;else len = state.length;
  41652. }
  41653. state.readingMore = false;
  41654. }
  41655. // abstract method. to be overridden in specific implementation classes.
  41656. // call cb(er, data) where data is <= n in length.
  41657. // for virtual (non-string, non-buffer) streams, "length" is somewhat
  41658. // arbitrary, and perhaps not very meaningful.
  41659. Readable.prototype._read = function (n) {
  41660. this.emit('error', new Error('not implemented'));
  41661. };
  41662. Readable.prototype.pipe = function (dest, pipeOpts) {
  41663. var src = this;
  41664. var state = this._readableState;
  41665. switch (state.pipesCount) {
  41666. case 0:
  41667. state.pipes = dest;
  41668. break;
  41669. case 1:
  41670. state.pipes = [state.pipes, dest];
  41671. break;
  41672. default:
  41673. state.pipes.push(dest);
  41674. break;
  41675. }
  41676. state.pipesCount += 1;
  41677. debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
  41678. var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
  41679. var endFn = doEnd ? onend : cleanup;
  41680. if (state.endEmitted) processNextTick(endFn);else src.once('end', endFn);
  41681. dest.on('unpipe', onunpipe);
  41682. function onunpipe(readable) {
  41683. debug('onunpipe');
  41684. if (readable === src) {
  41685. cleanup();
  41686. }
  41687. }
  41688. function onend() {
  41689. debug('onend');
  41690. dest.end();
  41691. }
  41692. // when the dest drains, it reduces the awaitDrain counter
  41693. // on the source. This would be more elegant with a .once()
  41694. // handler in flow(), but adding and removing repeatedly is
  41695. // too slow.
  41696. var ondrain = pipeOnDrain(src);
  41697. dest.on('drain', ondrain);
  41698. var cleanedUp = false;
  41699. function cleanup() {
  41700. debug('cleanup');
  41701. // cleanup event handlers once the pipe is broken
  41702. dest.removeListener('close', onclose);
  41703. dest.removeListener('finish', onfinish);
  41704. dest.removeListener('drain', ondrain);
  41705. dest.removeListener('error', onerror);
  41706. dest.removeListener('unpipe', onunpipe);
  41707. src.removeListener('end', onend);
  41708. src.removeListener('end', cleanup);
  41709. src.removeListener('data', ondata);
  41710. cleanedUp = true;
  41711. // if the reader is waiting for a drain event from this
  41712. // specific writer, then it would cause it to never start
  41713. // flowing again.
  41714. // So, if this is awaiting a drain, then we just call it now.
  41715. // If we don't know, then assume that we are waiting for one.
  41716. if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
  41717. }
  41718. src.on('data', ondata);
  41719. function ondata(chunk) {
  41720. debug('ondata');
  41721. var ret = dest.write(chunk);
  41722. if (false === ret) {
  41723. // If the user unpiped during `dest.write()`, it is possible
  41724. // to get stuck in a permanently paused state if that write
  41725. // also returned false.
  41726. // => Check whether `dest` is still a piping destination.
  41727. if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
  41728. debug('false write response, pause', src._readableState.awaitDrain);
  41729. src._readableState.awaitDrain++;
  41730. }
  41731. src.pause();
  41732. }
  41733. }
  41734. // if the dest has an error, then stop piping into it.
  41735. // however, don't suppress the throwing behavior for this.
  41736. function onerror(er) {
  41737. debug('onerror', er);
  41738. unpipe();
  41739. dest.removeListener('error', onerror);
  41740. if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
  41741. }
  41742. // Make sure our error handler is attached before userland ones.
  41743. prependListener(dest, 'error', onerror);
  41744. // Both close and finish should trigger unpipe, but only once.
  41745. function onclose() {
  41746. dest.removeListener('finish', onfinish);
  41747. unpipe();
  41748. }
  41749. dest.once('close', onclose);
  41750. function onfinish() {
  41751. debug('onfinish');
  41752. dest.removeListener('close', onclose);
  41753. unpipe();
  41754. }
  41755. dest.once('finish', onfinish);
  41756. function unpipe() {
  41757. debug('unpipe');
  41758. src.unpipe(dest);
  41759. }
  41760. // tell the dest that it's being piped to
  41761. dest.emit('pipe', src);
  41762. // start the flow if it hasn't been started already.
  41763. if (!state.flowing) {
  41764. debug('pipe resume');
  41765. src.resume();
  41766. }
  41767. return dest;
  41768. };
  41769. function pipeOnDrain(src) {
  41770. return function () {
  41771. var state = src._readableState;
  41772. debug('pipeOnDrain', state.awaitDrain);
  41773. if (state.awaitDrain) state.awaitDrain--;
  41774. if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
  41775. state.flowing = true;
  41776. flow(src);
  41777. }
  41778. };
  41779. }
  41780. Readable.prototype.unpipe = function (dest) {
  41781. var state = this._readableState;
  41782. // if we're not piping anywhere, then do nothing.
  41783. if (state.pipesCount === 0) return this;
  41784. // just one destination. most common case.
  41785. if (state.pipesCount === 1) {
  41786. // passed in one, but it's not the right one.
  41787. if (dest && dest !== state.pipes) return this;
  41788. if (!dest) dest = state.pipes;
  41789. // got a match.
  41790. state.pipes = null;
  41791. state.pipesCount = 0;
  41792. state.flowing = false;
  41793. if (dest) dest.emit('unpipe', this);
  41794. return this;
  41795. }
  41796. // slow case. multiple pipe destinations.
  41797. if (!dest) {
  41798. // remove all.
  41799. var dests = state.pipes;
  41800. var len = state.pipesCount;
  41801. state.pipes = null;
  41802. state.pipesCount = 0;
  41803. state.flowing = false;
  41804. for (var _i = 0; _i < len; _i++) {
  41805. dests[_i].emit('unpipe', this);
  41806. }return this;
  41807. }
  41808. // try to find the right one.
  41809. var i = indexOf(state.pipes, dest);
  41810. if (i === -1) return this;
  41811. state.pipes.splice(i, 1);
  41812. state.pipesCount -= 1;
  41813. if (state.pipesCount === 1) state.pipes = state.pipes[0];
  41814. dest.emit('unpipe', this);
  41815. return this;
  41816. };
  41817. // set up data events if they are asked for
  41818. // Ensure readable listeners eventually get something
  41819. Readable.prototype.on = function (ev, fn) {
  41820. var res = Stream.prototype.on.call(this, ev, fn);
  41821. // If listening to data, and it has not explicitly been paused,
  41822. // then call resume to start the flow of data on the next tick.
  41823. if (ev === 'data' && false !== this._readableState.flowing) {
  41824. this.resume();
  41825. }
  41826. if (ev === 'readable' && !this._readableState.endEmitted) {
  41827. var state = this._readableState;
  41828. if (!state.readableListening) {
  41829. state.readableListening = true;
  41830. state.emittedReadable = false;
  41831. state.needReadable = true;
  41832. if (!state.reading) {
  41833. processNextTick(nReadingNextTick, this);
  41834. } else if (state.length) {
  41835. emitReadable(this, state);
  41836. }
  41837. }
  41838. }
  41839. return res;
  41840. };
  41841. Readable.prototype.addListener = Readable.prototype.on;
  41842. function nReadingNextTick(self) {
  41843. debug('readable nexttick read 0');
  41844. self.read(0);
  41845. }
  41846. // pause() and resume() are remnants of the legacy readable stream API
  41847. // If the user uses them, then switch into old mode.
  41848. Readable.prototype.resume = function () {
  41849. var state = this._readableState;
  41850. if (!state.flowing) {
  41851. debug('resume');
  41852. state.flowing = true;
  41853. resume(this, state);
  41854. }
  41855. return this;
  41856. };
  41857. function resume(stream, state) {
  41858. if (!state.resumeScheduled) {
  41859. state.resumeScheduled = true;
  41860. processNextTick(resume_, stream, state);
  41861. }
  41862. }
  41863. function resume_(stream, state) {
  41864. if (!state.reading) {
  41865. debug('resume read 0');
  41866. stream.read(0);
  41867. }
  41868. state.resumeScheduled = false;
  41869. stream.emit('resume');
  41870. flow(stream);
  41871. if (state.flowing && !state.reading) stream.read(0);
  41872. }
  41873. Readable.prototype.pause = function () {
  41874. debug('call pause flowing=%j', this._readableState.flowing);
  41875. if (false !== this._readableState.flowing) {
  41876. debug('pause');
  41877. this._readableState.flowing = false;
  41878. this.emit('pause');
  41879. }
  41880. return this;
  41881. };
  41882. function flow(stream) {
  41883. var state = stream._readableState;
  41884. debug('flow', state.flowing);
  41885. if (state.flowing) {
  41886. do {
  41887. var chunk = stream.read();
  41888. } while (null !== chunk && state.flowing);
  41889. }
  41890. }
  41891. // wrap an old-style stream as the async data source.
  41892. // This is *not* part of the readable stream interface.
  41893. // It is an ugly unfortunate mess of history.
  41894. Readable.prototype.wrap = function (stream) {
  41895. var state = this._readableState;
  41896. var paused = false;
  41897. var self = this;
  41898. stream.on('end', function () {
  41899. debug('wrapped end');
  41900. if (state.decoder && !state.ended) {
  41901. var chunk = state.decoder.end();
  41902. if (chunk && chunk.length) self.push(chunk);
  41903. }
  41904. self.push(null);
  41905. });
  41906. stream.on('data', function (chunk) {
  41907. debug('wrapped data');
  41908. if (state.decoder) chunk = state.decoder.write(chunk);
  41909. // don't skip over falsy values in objectMode
  41910. if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
  41911. var ret = self.push(chunk);
  41912. if (!ret) {
  41913. paused = true;
  41914. stream.pause();
  41915. }
  41916. });
  41917. // proxy all the other methods.
  41918. // important when wrapping filters and duplexes.
  41919. for (var i in stream) {
  41920. if (this[i] === undefined && typeof stream[i] === 'function') {
  41921. this[i] = function (method) {
  41922. return function () {
  41923. return stream[method].apply(stream, arguments);
  41924. };
  41925. }(i);
  41926. }
  41927. }
  41928. // proxy certain important events.
  41929. var events = ['error', 'close', 'destroy', 'pause', 'resume'];
  41930. forEach(events, function (ev) {
  41931. stream.on(ev, self.emit.bind(self, ev));
  41932. });
  41933. // when we try to consume some more bytes, simply unpause the
  41934. // underlying stream.
  41935. self._read = function (n) {
  41936. debug('wrapped _read', n);
  41937. if (paused) {
  41938. paused = false;
  41939. stream.resume();
  41940. }
  41941. };
  41942. return self;
  41943. };
  41944. // exposed for testing purposes only.
  41945. Readable._fromList = fromList;
  41946. // Pluck off n bytes from an array of buffers.
  41947. // Length is the combined lengths of all the buffers in the list.
  41948. function fromList(n, state) {
  41949. var list = state.buffer;
  41950. var length = state.length;
  41951. var stringMode = !!state.decoder;
  41952. var objectMode = !!state.objectMode;
  41953. var ret;
  41954. // nothing in the list, definitely empty.
  41955. if (list.length === 0) return null;
  41956. if (length === 0) ret = null;else if (objectMode) ret = list.shift();else if (!n || n >= length) {
  41957. // read it all, truncate the array.
  41958. if (stringMode) ret = list.join('');else if (list.length === 1) ret = list[0];else ret = Buffer.concat(list, length);
  41959. list.length = 0;
  41960. } else {
  41961. // read just some of it.
  41962. if (n < list[0].length) {
  41963. // just take a part of the first list item.
  41964. // slice is the same for buffers and strings.
  41965. var buf = list[0];
  41966. ret = buf.slice(0, n);
  41967. list[0] = buf.slice(n);
  41968. } else if (n === list[0].length) {
  41969. // first list is a perfect match
  41970. ret = list.shift();
  41971. } else {
  41972. // complex case.
  41973. // we have enough to cover it, but it spans past the first buffer.
  41974. if (stringMode) ret = '';else ret = bufferShim.allocUnsafe(n);
  41975. var c = 0;
  41976. for (var i = 0, l = list.length; i < l && c < n; i++) {
  41977. var _buf = list[0];
  41978. var cpy = Math.min(n - c, _buf.length);
  41979. if (stringMode) ret += _buf.slice(0, cpy);else _buf.copy(ret, c, 0, cpy);
  41980. if (cpy < _buf.length) list[0] = _buf.slice(cpy);else list.shift();
  41981. c += cpy;
  41982. }
  41983. }
  41984. }
  41985. return ret;
  41986. }
  41987. function endReadable(stream) {
  41988. var state = stream._readableState;
  41989. // If we get here before consuming all the bytes, then that is a
  41990. // bug in node. Should never happen.
  41991. if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
  41992. if (!state.endEmitted) {
  41993. state.ended = true;
  41994. processNextTick(endReadableNT, state, stream);
  41995. }
  41996. }
  41997. function endReadableNT(state, stream) {
  41998. // Check that we didn't get one last unshift.
  41999. if (!state.endEmitted && state.length === 0) {
  42000. state.endEmitted = true;
  42001. stream.readable = false;
  42002. stream.emit('end');
  42003. }
  42004. }
  42005. function forEach(xs, f) {
  42006. for (var i = 0, l = xs.length; i < l; i++) {
  42007. f(xs[i], i);
  42008. }
  42009. }
  42010. function indexOf(xs, x) {
  42011. for (var i = 0, l = xs.length; i < l; i++) {
  42012. if (xs[i] === x) return i;
  42013. }
  42014. return -1;
  42015. }
  42016. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  42017. /***/ },
  42018. /* 223 */
  42019. /***/ function(module, exports, __webpack_require__) {
  42020. "use strict";
  42021. // a transform stream is a readable/writable stream where you do
  42022. // something with the data. Sometimes it's called a "filter",
  42023. // but that's not a great name for it, since that implies a thing where
  42024. // some bits pass through, and others are simply ignored. (That would
  42025. // be a valid example of a transform, of course.)
  42026. //
  42027. // While the output is causally related to the input, it's not a
  42028. // necessarily symmetric or synchronous transformation. For example,
  42029. // a zlib stream might take multiple plain-text writes(), and then
  42030. // emit a single compressed chunk some time in the future.
  42031. //
  42032. // Here's how this works:
  42033. //
  42034. // The Transform stream has all the aspects of the readable and writable
  42035. // stream classes. When you write(chunk), that calls _write(chunk,cb)
  42036. // internally, and returns false if there's a lot of pending writes
  42037. // buffered up. When you call read(), that calls _read(n) until
  42038. // there's enough pending readable data buffered up.
  42039. //
  42040. // In a transform stream, the written data is placed in a buffer. When
  42041. // _read(n) is called, it transforms the queued up data, calling the
  42042. // buffered _write cb's as it consumes chunks. If consuming a single
  42043. // written chunk would result in multiple output chunks, then the first
  42044. // outputted bit calls the readcb, and subsequent chunks just go into
  42045. // the read buffer, and will cause it to emit 'readable' if necessary.
  42046. //
  42047. // This way, back-pressure is actually determined by the reading side,
  42048. // since _read has to be called to start processing a new chunk. However,
  42049. // a pathological inflate type of transform can cause excessive buffering
  42050. // here. For example, imagine a stream where every byte of input is
  42051. // interpreted as an integer from 0-255, and then results in that many
  42052. // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
  42053. // 1kb of data being output. In this case, you could write a very small
  42054. // amount of input, and end up with a very large amount of output. In
  42055. // such a pathological inflating mechanism, there'd be no way to tell
  42056. // the system to stop doing the transform. A single 4MB write could
  42057. // cause the system to run out of memory.
  42058. //
  42059. // However, even in such a pathological case, only a single written chunk
  42060. // would be consumed, and then the rest would wait (un-transformed) until
  42061. // the results of the previous transformed chunk were consumed.
  42062. 'use strict';
  42063. module.exports = Transform;
  42064. var Duplex = __webpack_require__(66);
  42065. /*<replacement>*/
  42066. var util = __webpack_require__(14);
  42067. util.inherits = __webpack_require__(2);
  42068. /*</replacement>*/
  42069. util.inherits(Transform, Duplex);
  42070. function TransformState(stream) {
  42071. this.afterTransform = function (er, data) {
  42072. return afterTransform(stream, er, data);
  42073. };
  42074. this.needTransform = false;
  42075. this.transforming = false;
  42076. this.writecb = null;
  42077. this.writechunk = null;
  42078. this.writeencoding = null;
  42079. }
  42080. function afterTransform(stream, er, data) {
  42081. var ts = stream._transformState;
  42082. ts.transforming = false;
  42083. var cb = ts.writecb;
  42084. if (!cb) return stream.emit('error', new Error('no writecb in Transform class'));
  42085. ts.writechunk = null;
  42086. ts.writecb = null;
  42087. if (data !== null && data !== undefined) stream.push(data);
  42088. cb(er);
  42089. var rs = stream._readableState;
  42090. rs.reading = false;
  42091. if (rs.needReadable || rs.length < rs.highWaterMark) {
  42092. stream._read(rs.highWaterMark);
  42093. }
  42094. }
  42095. function Transform(options) {
  42096. if (!(this instanceof Transform)) return new Transform(options);
  42097. Duplex.call(this, options);
  42098. this._transformState = new TransformState(this);
  42099. // when the writable side finishes, then flush out anything remaining.
  42100. var stream = this;
  42101. // start out asking for a readable event once data is transformed.
  42102. this._readableState.needReadable = true;
  42103. // we have implemented the _read method, and done the other things
  42104. // that Readable wants before the first _read call, so unset the
  42105. // sync guard flag.
  42106. this._readableState.sync = false;
  42107. if (options) {
  42108. if (typeof options.transform === 'function') this._transform = options.transform;
  42109. if (typeof options.flush === 'function') this._flush = options.flush;
  42110. }
  42111. this.once('prefinish', function () {
  42112. if (typeof this._flush === 'function') this._flush(function (er) {
  42113. done(stream, er);
  42114. });else done(stream);
  42115. });
  42116. }
  42117. Transform.prototype.push = function (chunk, encoding) {
  42118. this._transformState.needTransform = false;
  42119. return Duplex.prototype.push.call(this, chunk, encoding);
  42120. };
  42121. // This is the part where you do stuff!
  42122. // override this function in implementation classes.
  42123. // 'chunk' is an input chunk.
  42124. //
  42125. // Call `push(newChunk)` to pass along transformed output
  42126. // to the readable side. You may call 'push' zero or more times.
  42127. //
  42128. // Call `cb(err)` when you are done with this chunk. If you pass
  42129. // an error, then that'll put the hurt on the whole operation. If you
  42130. // never call cb(), then you'll never get another chunk.
  42131. Transform.prototype._transform = function (chunk, encoding, cb) {
  42132. throw new Error('Not implemented');
  42133. };
  42134. Transform.prototype._write = function (chunk, encoding, cb) {
  42135. var ts = this._transformState;
  42136. ts.writecb = cb;
  42137. ts.writechunk = chunk;
  42138. ts.writeencoding = encoding;
  42139. if (!ts.transforming) {
  42140. var rs = this._readableState;
  42141. if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
  42142. }
  42143. };
  42144. // Doesn't matter what the args are here.
  42145. // _transform does all the work.
  42146. // That we got here means that the readable side wants more data.
  42147. Transform.prototype._read = function (n) {
  42148. var ts = this._transformState;
  42149. if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
  42150. ts.transforming = true;
  42151. this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
  42152. } else {
  42153. // mark that we need a transform, so that any data that comes in
  42154. // will get processed, now that we've asked for it.
  42155. ts.needTransform = true;
  42156. }
  42157. };
  42158. function done(stream, er) {
  42159. if (er) return stream.emit('error', er);
  42160. // if there's nothing in the write buffer, then that means
  42161. // that nothing more will ever be provided
  42162. var ws = stream._writableState;
  42163. var ts = stream._transformState;
  42164. if (ws.length) throw new Error('Calling transform done when ws.length != 0');
  42165. if (ts.transforming) throw new Error('Calling transform done when still transforming');
  42166. return stream.push(null);
  42167. }
  42168. /***/ },
  42169. /* 224 */
  42170. /***/ function(module, exports, __webpack_require__) {
  42171. "use strict";
  42172. /* WEBPACK VAR INJECTION */(function(process, setImmediate) {// A bit simpler than readable streams.
  42173. // Implement an async ._write(chunk, encoding, cb), and it'll handle all
  42174. // the drain event emission and buffering.
  42175. 'use strict';
  42176. module.exports = Writable;
  42177. /*<replacement>*/
  42178. var processNextTick = __webpack_require__(64);
  42179. /*</replacement>*/
  42180. /*<replacement>*/
  42181. var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick;
  42182. /*</replacement>*/
  42183. Writable.WritableState = WritableState;
  42184. /*<replacement>*/
  42185. var util = __webpack_require__(14);
  42186. util.inherits = __webpack_require__(2);
  42187. /*</replacement>*/
  42188. /*<replacement>*/
  42189. var internalUtil = {
  42190. deprecate: __webpack_require__(227)
  42191. };
  42192. /*</replacement>*/
  42193. /*<replacement>*/
  42194. var Stream;
  42195. (function () {
  42196. try {
  42197. Stream = __webpack_require__(9);
  42198. } catch (_) {} finally {
  42199. if (!Stream) Stream = __webpack_require__(30).EventEmitter;
  42200. }
  42201. })();
  42202. /*</replacement>*/
  42203. var Buffer = __webpack_require__(1).Buffer;
  42204. /*<replacement>*/
  42205. var bufferShim = __webpack_require__(167);
  42206. /*</replacement>*/
  42207. util.inherits(Writable, Stream);
  42208. function nop() {}
  42209. function WriteReq(chunk, encoding, cb) {
  42210. this.chunk = chunk;
  42211. this.encoding = encoding;
  42212. this.callback = cb;
  42213. this.next = null;
  42214. }
  42215. var Duplex;
  42216. function WritableState(options, stream) {
  42217. Duplex = Duplex || __webpack_require__(66);
  42218. options = options || {};
  42219. // object stream flag to indicate whether or not this stream
  42220. // contains buffers or objects.
  42221. this.objectMode = !!options.objectMode;
  42222. if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
  42223. // the point at which write() starts returning false
  42224. // Note: 0 is a valid value, means that we always return false if
  42225. // the entire buffer is not flushed immediately on write()
  42226. var hwm = options.highWaterMark;
  42227. var defaultHwm = this.objectMode ? 16 : 16 * 1024;
  42228. this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
  42229. // cast to ints.
  42230. this.highWaterMark = ~ ~this.highWaterMark;
  42231. this.needDrain = false;
  42232. // at the start of calling end()
  42233. this.ending = false;
  42234. // when end() has been called, and returned
  42235. this.ended = false;
  42236. // when 'finish' is emitted
  42237. this.finished = false;
  42238. // should we decode strings into buffers before passing to _write?
  42239. // this is here so that some node-core streams can optimize string
  42240. // handling at a lower level.
  42241. var noDecode = options.decodeStrings === false;
  42242. this.decodeStrings = !noDecode;
  42243. // Crypto is kind of old and crusty. Historically, its default string
  42244. // encoding is 'binary' so we have to make this configurable.
  42245. // Everything else in the universe uses 'utf8', though.
  42246. this.defaultEncoding = options.defaultEncoding || 'utf8';
  42247. // not an actual buffer we keep track of, but a measurement
  42248. // of how much we're waiting to get pushed to some underlying
  42249. // socket or file.
  42250. this.length = 0;
  42251. // a flag to see when we're in the middle of a write.
  42252. this.writing = false;
  42253. // when true all writes will be buffered until .uncork() call
  42254. this.corked = 0;
  42255. // a flag to be able to tell if the onwrite cb is called immediately,
  42256. // or on a later tick. We set this to true at first, because any
  42257. // actions that shouldn't happen until "later" should generally also
  42258. // not happen before the first write call.
  42259. this.sync = true;
  42260. // a flag to know if we're processing previously buffered items, which
  42261. // may call the _write() callback in the same tick, so that we don't
  42262. // end up in an overlapped onwrite situation.
  42263. this.bufferProcessing = false;
  42264. // the callback that's passed to _write(chunk,cb)
  42265. this.onwrite = function (er) {
  42266. onwrite(stream, er);
  42267. };
  42268. // the callback that the user supplies to write(chunk,encoding,cb)
  42269. this.writecb = null;
  42270. // the amount that is being written when _write is called.
  42271. this.writelen = 0;
  42272. this.bufferedRequest = null;
  42273. this.lastBufferedRequest = null;
  42274. // number of pending user-supplied write callbacks
  42275. // this must be 0 before 'finish' can be emitted
  42276. this.pendingcb = 0;
  42277. // emit prefinish if the only thing we're waiting for is _write cbs
  42278. // This is relevant for synchronous Transform streams
  42279. this.prefinished = false;
  42280. // True if the error was already emitted and should not be thrown again
  42281. this.errorEmitted = false;
  42282. // count buffered requests
  42283. this.bufferedRequestCount = 0;
  42284. // allocate the first CorkedRequest, there is always
  42285. // one allocated and free to use, and we maintain at most two
  42286. this.corkedRequestsFree = new CorkedRequest(this);
  42287. }
  42288. WritableState.prototype.getBuffer = function writableStateGetBuffer() {
  42289. var current = this.bufferedRequest;
  42290. var out = [];
  42291. while (current) {
  42292. out.push(current);
  42293. current = current.next;
  42294. }
  42295. return out;
  42296. };
  42297. (function () {
  42298. try {
  42299. Object.defineProperty(WritableState.prototype, 'buffer', {
  42300. get: internalUtil.deprecate(function () {
  42301. return this.getBuffer();
  42302. }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.')
  42303. });
  42304. } catch (_) {}
  42305. })();
  42306. var Duplex;
  42307. function Writable(options) {
  42308. Duplex = Duplex || __webpack_require__(66);
  42309. // Writable ctor is applied to Duplexes, though they're not
  42310. // instanceof Writable, they're instanceof Readable.
  42311. if (!(this instanceof Writable) && !(this instanceof Duplex)) return new Writable(options);
  42312. this._writableState = new WritableState(options, this);
  42313. // legacy.
  42314. this.writable = true;
  42315. if (options) {
  42316. if (typeof options.write === 'function') this._write = options.write;
  42317. if (typeof options.writev === 'function') this._writev = options.writev;
  42318. }
  42319. Stream.call(this);
  42320. }
  42321. // Otherwise people can pipe Writable streams, which is just wrong.
  42322. Writable.prototype.pipe = function () {
  42323. this.emit('error', new Error('Cannot pipe, not readable'));
  42324. };
  42325. function writeAfterEnd(stream, cb) {
  42326. var er = new Error('write after end');
  42327. // TODO: defer error events consistently everywhere, not just the cb
  42328. stream.emit('error', er);
  42329. processNextTick(cb, er);
  42330. }
  42331. // If we get something that is not a buffer, string, null, or undefined,
  42332. // and we're not in objectMode, then that's an error.
  42333. // Otherwise stream chunks are all considered to be of length=1, and the
  42334. // watermarks determine how many objects to keep in the buffer, rather than
  42335. // how many bytes or characters.
  42336. function validChunk(stream, state, chunk, cb) {
  42337. var valid = true;
  42338. var er = false;
  42339. // Always throw error if a null is written
  42340. // if we are not in object mode then throw
  42341. // if it is not a buffer, string, or undefined.
  42342. if (chunk === null) {
  42343. er = new TypeError('May not write null values to stream');
  42344. } else if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
  42345. er = new TypeError('Invalid non-string/buffer chunk');
  42346. }
  42347. if (er) {
  42348. stream.emit('error', er);
  42349. processNextTick(cb, er);
  42350. valid = false;
  42351. }
  42352. return valid;
  42353. }
  42354. Writable.prototype.write = function (chunk, encoding, cb) {
  42355. var state = this._writableState;
  42356. var ret = false;
  42357. if (typeof encoding === 'function') {
  42358. cb = encoding;
  42359. encoding = null;
  42360. }
  42361. if (Buffer.isBuffer(chunk)) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
  42362. if (typeof cb !== 'function') cb = nop;
  42363. if (state.ended) writeAfterEnd(this, cb);else if (validChunk(this, state, chunk, cb)) {
  42364. state.pendingcb++;
  42365. ret = writeOrBuffer(this, state, chunk, encoding, cb);
  42366. }
  42367. return ret;
  42368. };
  42369. Writable.prototype.cork = function () {
  42370. var state = this._writableState;
  42371. state.corked++;
  42372. };
  42373. Writable.prototype.uncork = function () {
  42374. var state = this._writableState;
  42375. if (state.corked) {
  42376. state.corked--;
  42377. if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
  42378. }
  42379. };
  42380. Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
  42381. // node::ParseEncoding() requires lower case.
  42382. if (typeof encoding === 'string') encoding = encoding.toLowerCase();
  42383. if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
  42384. this._writableState.defaultEncoding = encoding;
  42385. return this;
  42386. };
  42387. function decodeChunk(state, chunk, encoding) {
  42388. if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
  42389. chunk = bufferShim.from(chunk, encoding);
  42390. }
  42391. return chunk;
  42392. }
  42393. // if we're already writing something, then just put this
  42394. // in the queue, and wait our turn. Otherwise, call _write
  42395. // If we return false, then we need a drain event, so set that flag.
  42396. function writeOrBuffer(stream, state, chunk, encoding, cb) {
  42397. chunk = decodeChunk(state, chunk, encoding);
  42398. if (Buffer.isBuffer(chunk)) encoding = 'buffer';
  42399. var len = state.objectMode ? 1 : chunk.length;
  42400. state.length += len;
  42401. var ret = state.length < state.highWaterMark;
  42402. // we must ensure that previous needDrain will not be reset to false.
  42403. if (!ret) state.needDrain = true;
  42404. if (state.writing || state.corked) {
  42405. var last = state.lastBufferedRequest;
  42406. state.lastBufferedRequest = new WriteReq(chunk, encoding, cb);
  42407. if (last) {
  42408. last.next = state.lastBufferedRequest;
  42409. } else {
  42410. state.bufferedRequest = state.lastBufferedRequest;
  42411. }
  42412. state.bufferedRequestCount += 1;
  42413. } else {
  42414. doWrite(stream, state, false, len, chunk, encoding, cb);
  42415. }
  42416. return ret;
  42417. }
  42418. function doWrite(stream, state, writev, len, chunk, encoding, cb) {
  42419. state.writelen = len;
  42420. state.writecb = cb;
  42421. state.writing = true;
  42422. state.sync = true;
  42423. if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
  42424. state.sync = false;
  42425. }
  42426. function onwriteError(stream, state, sync, er, cb) {
  42427. --state.pendingcb;
  42428. if (sync) processNextTick(cb, er);else cb(er);
  42429. stream._writableState.errorEmitted = true;
  42430. stream.emit('error', er);
  42431. }
  42432. function onwriteStateUpdate(state) {
  42433. state.writing = false;
  42434. state.writecb = null;
  42435. state.length -= state.writelen;
  42436. state.writelen = 0;
  42437. }
  42438. function onwrite(stream, er) {
  42439. var state = stream._writableState;
  42440. var sync = state.sync;
  42441. var cb = state.writecb;
  42442. onwriteStateUpdate(state);
  42443. if (er) onwriteError(stream, state, sync, er, cb);else {
  42444. // Check if we're actually ready to finish, but don't emit yet
  42445. var finished = needFinish(state);
  42446. if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
  42447. clearBuffer(stream, state);
  42448. }
  42449. if (sync) {
  42450. /*<replacement>*/
  42451. asyncWrite(afterWrite, stream, state, finished, cb);
  42452. /*</replacement>*/
  42453. } else {
  42454. afterWrite(stream, state, finished, cb);
  42455. }
  42456. }
  42457. }
  42458. function afterWrite(stream, state, finished, cb) {
  42459. if (!finished) onwriteDrain(stream, state);
  42460. state.pendingcb--;
  42461. cb();
  42462. finishMaybe(stream, state);
  42463. }
  42464. // Must force callback to be called on nextTick, so that we don't
  42465. // emit 'drain' before the write() consumer gets the 'false' return
  42466. // value, and has a chance to attach a 'drain' listener.
  42467. function onwriteDrain(stream, state) {
  42468. if (state.length === 0 && state.needDrain) {
  42469. state.needDrain = false;
  42470. stream.emit('drain');
  42471. }
  42472. }
  42473. // if there's something in the buffer waiting, then process it
  42474. function clearBuffer(stream, state) {
  42475. state.bufferProcessing = true;
  42476. var entry = state.bufferedRequest;
  42477. if (stream._writev && entry && entry.next) {
  42478. // Fast case, write everything using _writev()
  42479. var l = state.bufferedRequestCount;
  42480. var buffer = new Array(l);
  42481. var holder = state.corkedRequestsFree;
  42482. holder.entry = entry;
  42483. var count = 0;
  42484. while (entry) {
  42485. buffer[count] = entry;
  42486. entry = entry.next;
  42487. count += 1;
  42488. }
  42489. doWrite(stream, state, true, state.length, buffer, '', holder.finish);
  42490. // doWrite is almost always async, defer these to save a bit of time
  42491. // as the hot path ends with doWrite
  42492. state.pendingcb++;
  42493. state.lastBufferedRequest = null;
  42494. if (holder.next) {
  42495. state.corkedRequestsFree = holder.next;
  42496. holder.next = null;
  42497. } else {
  42498. state.corkedRequestsFree = new CorkedRequest(state);
  42499. }
  42500. } else {
  42501. // Slow case, write chunks one-by-one
  42502. while (entry) {
  42503. var chunk = entry.chunk;
  42504. var encoding = entry.encoding;
  42505. var cb = entry.callback;
  42506. var len = state.objectMode ? 1 : chunk.length;
  42507. doWrite(stream, state, false, len, chunk, encoding, cb);
  42508. entry = entry.next;
  42509. // if we didn't call the onwrite immediately, then
  42510. // it means that we need to wait until it does.
  42511. // also, that means that the chunk and cb are currently
  42512. // being processed, so move the buffer counter past them.
  42513. if (state.writing) {
  42514. break;
  42515. }
  42516. }
  42517. if (entry === null) state.lastBufferedRequest = null;
  42518. }
  42519. state.bufferedRequestCount = 0;
  42520. state.bufferedRequest = entry;
  42521. state.bufferProcessing = false;
  42522. }
  42523. Writable.prototype._write = function (chunk, encoding, cb) {
  42524. cb(new Error('not implemented'));
  42525. };
  42526. Writable.prototype._writev = null;
  42527. Writable.prototype.end = function (chunk, encoding, cb) {
  42528. var state = this._writableState;
  42529. if (typeof chunk === 'function') {
  42530. cb = chunk;
  42531. chunk = null;
  42532. encoding = null;
  42533. } else if (typeof encoding === 'function') {
  42534. cb = encoding;
  42535. encoding = null;
  42536. }
  42537. if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
  42538. // .end() fully uncorks
  42539. if (state.corked) {
  42540. state.corked = 1;
  42541. this.uncork();
  42542. }
  42543. // ignore unnecessary end() calls.
  42544. if (!state.ending && !state.finished) endWritable(this, state, cb);
  42545. };
  42546. function needFinish(state) {
  42547. return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
  42548. }
  42549. function prefinish(stream, state) {
  42550. if (!state.prefinished) {
  42551. state.prefinished = true;
  42552. stream.emit('prefinish');
  42553. }
  42554. }
  42555. function finishMaybe(stream, state) {
  42556. var need = needFinish(state);
  42557. if (need) {
  42558. if (state.pendingcb === 0) {
  42559. prefinish(stream, state);
  42560. state.finished = true;
  42561. stream.emit('finish');
  42562. } else {
  42563. prefinish(stream, state);
  42564. }
  42565. }
  42566. return need;
  42567. }
  42568. function endWritable(stream, state, cb) {
  42569. state.ending = true;
  42570. finishMaybe(stream, state);
  42571. if (cb) {
  42572. if (state.finished) processNextTick(cb);else stream.once('finish', cb);
  42573. }
  42574. state.ended = true;
  42575. stream.writable = false;
  42576. }
  42577. // It seems a linked list but it is not
  42578. // there will be only 2 of these for each stream
  42579. function CorkedRequest(state) {
  42580. var _this = this;
  42581. this.next = null;
  42582. this.entry = null;
  42583. this.finish = function (err) {
  42584. var entry = _this.entry;
  42585. _this.entry = null;
  42586. while (entry) {
  42587. var cb = entry.callback;
  42588. state.pendingcb--;
  42589. cb(err);
  42590. entry = entry.next;
  42591. }
  42592. if (state.corkedRequestsFree) {
  42593. state.corkedRequestsFree.next = _this;
  42594. } else {
  42595. state.corkedRequestsFree = _this;
  42596. }
  42597. };
  42598. }
  42599. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4), __webpack_require__(74).setImmediate))
  42600. /***/ },
  42601. /* 225 */
  42602. /***/ function(module, exports, __webpack_require__) {
  42603. /* WEBPACK VAR INJECTION */(function(process) {var Stream = (function (){
  42604. try {
  42605. return __webpack_require__(9); // hack to fix a circular dependency issue when used with browserify
  42606. } catch(_){}
  42607. }());
  42608. exports = module.exports = __webpack_require__(222);
  42609. exports.Stream = Stream || exports;
  42610. exports.Readable = exports;
  42611. exports.Writable = __webpack_require__(224);
  42612. exports.Duplex = __webpack_require__(66);
  42613. exports.Transform = __webpack_require__(223);
  42614. exports.PassThrough = __webpack_require__(576);
  42615. if (!process.browser && process.env.READABLE_STREAM === 'disable' && Stream) {
  42616. module.exports = Stream;
  42617. }
  42618. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  42619. /***/ },
  42620. /* 226 */
  42621. /***/ function(module, exports, __webpack_require__) {
  42622. "use strict";
  42623. // Copyright Joyent, Inc. and other Node contributors.
  42624. //
  42625. // Permission is hereby granted, free of charge, to any person obtaining a
  42626. // copy of this software and associated documentation files (the
  42627. // "Software"), to deal in the Software without restriction, including
  42628. // without limitation the rights to use, copy, modify, merge, publish,
  42629. // distribute, sublicense, and/or sell copies of the Software, and to permit
  42630. // persons to whom the Software is furnished to do so, subject to the
  42631. // following conditions:
  42632. //
  42633. // The above copyright notice and this permission notice shall be included
  42634. // in all copies or substantial portions of the Software.
  42635. //
  42636. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  42637. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  42638. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  42639. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  42640. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  42641. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  42642. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  42643. 'use strict';
  42644. var punycode = __webpack_require__(545);
  42645. var util = __webpack_require__(578);
  42646. exports.parse = urlParse;
  42647. exports.resolve = urlResolve;
  42648. exports.resolveObject = urlResolveObject;
  42649. exports.format = urlFormat;
  42650. exports.Url = Url;
  42651. function Url() {
  42652. this.protocol = null;
  42653. this.slashes = null;
  42654. this.auth = null;
  42655. this.host = null;
  42656. this.port = null;
  42657. this.hostname = null;
  42658. this.hash = null;
  42659. this.search = null;
  42660. this.query = null;
  42661. this.pathname = null;
  42662. this.path = null;
  42663. this.href = null;
  42664. }
  42665. // Reference: RFC 3986, RFC 1808, RFC 2396
  42666. // define these here so at least they only have to be
  42667. // compiled once on the first module load.
  42668. var protocolPattern = /^([a-z0-9.+-]+:)/i,
  42669. portPattern = /:[0-9]*$/,
  42670. // Special case for a simple path URL
  42671. simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
  42672. // RFC 2396: characters reserved for delimiting URLs.
  42673. // We actually just auto-escape these.
  42674. delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
  42675. // RFC 2396: characters not allowed for various reasons.
  42676. unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
  42677. // Allowed by RFCs, but cause of XSS attacks. Always escape these.
  42678. autoEscape = ['\''].concat(unwise),
  42679. // Characters that are never ever allowed in a hostname.
  42680. // Note that any invalid chars are also handled, but these
  42681. // are the ones that are *expected* to be seen, so we fast-path
  42682. // them.
  42683. nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
  42684. hostEndingChars = ['/', '?', '#'],
  42685. hostnameMaxLen = 255,
  42686. hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
  42687. hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
  42688. // protocols that can allow "unsafe" and "unwise" chars.
  42689. unsafeProtocol = {
  42690. 'javascript': true,
  42691. 'javascript:': true
  42692. },
  42693. // protocols that never have a hostname.
  42694. hostlessProtocol = {
  42695. 'javascript': true,
  42696. 'javascript:': true
  42697. },
  42698. // protocols that always contain a // bit.
  42699. slashedProtocol = {
  42700. 'http': true,
  42701. 'https': true,
  42702. 'ftp': true,
  42703. 'gopher': true,
  42704. 'file': true,
  42705. 'http:': true,
  42706. 'https:': true,
  42707. 'ftp:': true,
  42708. 'gopher:': true,
  42709. 'file:': true
  42710. },
  42711. querystring = __webpack_require__(548);
  42712. function urlParse(url, parseQueryString, slashesDenoteHost) {
  42713. if (url && util.isObject(url) && url instanceof Url) return url;
  42714. var u = new Url;
  42715. u.parse(url, parseQueryString, slashesDenoteHost);
  42716. return u;
  42717. }
  42718. Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
  42719. if (!util.isString(url)) {
  42720. throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
  42721. }
  42722. // Copy chrome, IE, opera backslash-handling behavior.
  42723. // Back slashes before the query string get converted to forward slashes
  42724. // See: https://code.google.com/p/chromium/issues/detail?id=25916
  42725. var queryIndex = url.indexOf('?'),
  42726. splitter =
  42727. (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#',
  42728. uSplit = url.split(splitter),
  42729. slashRegex = /\\/g;
  42730. uSplit[0] = uSplit[0].replace(slashRegex, '/');
  42731. url = uSplit.join(splitter);
  42732. var rest = url;
  42733. // trim before proceeding.
  42734. // This is to support parse stuff like " http://foo.com \n"
  42735. rest = rest.trim();
  42736. if (!slashesDenoteHost && url.split('#').length === 1) {
  42737. // Try fast path regexp
  42738. var simplePath = simplePathPattern.exec(rest);
  42739. if (simplePath) {
  42740. this.path = rest;
  42741. this.href = rest;
  42742. this.pathname = simplePath[1];
  42743. if (simplePath[2]) {
  42744. this.search = simplePath[2];
  42745. if (parseQueryString) {
  42746. this.query = querystring.parse(this.search.substr(1));
  42747. } else {
  42748. this.query = this.search.substr(1);
  42749. }
  42750. } else if (parseQueryString) {
  42751. this.search = '';
  42752. this.query = {};
  42753. }
  42754. return this;
  42755. }
  42756. }
  42757. var proto = protocolPattern.exec(rest);
  42758. if (proto) {
  42759. proto = proto[0];
  42760. var lowerProto = proto.toLowerCase();
  42761. this.protocol = lowerProto;
  42762. rest = rest.substr(proto.length);
  42763. }
  42764. // figure out if it's got a host
  42765. // user@server is *always* interpreted as a hostname, and url
  42766. // resolution will treat //foo/bar as host=foo,path=bar because that's
  42767. // how the browser resolves relative URLs.
  42768. if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
  42769. var slashes = rest.substr(0, 2) === '//';
  42770. if (slashes && !(proto && hostlessProtocol[proto])) {
  42771. rest = rest.substr(2);
  42772. this.slashes = true;
  42773. }
  42774. }
  42775. if (!hostlessProtocol[proto] &&
  42776. (slashes || (proto && !slashedProtocol[proto]))) {
  42777. // there's a hostname.
  42778. // the first instance of /, ?, ;, or # ends the host.
  42779. //
  42780. // If there is an @ in the hostname, then non-host chars *are* allowed
  42781. // to the left of the last @ sign, unless some host-ending character
  42782. // comes *before* the @-sign.
  42783. // URLs are obnoxious.
  42784. //
  42785. // ex:
  42786. // http://a@b@c/ => user:a@b host:c
  42787. // http://a@b?@c => user:a host:c path:/?@c
  42788. // v0.12 TODO(isaacs): This is not quite how Chrome does things.
  42789. // Review our test case against browsers more comprehensively.
  42790. // find the first instance of any hostEndingChars
  42791. var hostEnd = -1;
  42792. for (var i = 0; i < hostEndingChars.length; i++) {
  42793. var hec = rest.indexOf(hostEndingChars[i]);
  42794. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  42795. hostEnd = hec;
  42796. }
  42797. // at this point, either we have an explicit point where the
  42798. // auth portion cannot go past, or the last @ char is the decider.
  42799. var auth, atSign;
  42800. if (hostEnd === -1) {
  42801. // atSign can be anywhere.
  42802. atSign = rest.lastIndexOf('@');
  42803. } else {
  42804. // atSign must be in auth portion.
  42805. // http://a@b/c@d => host:b auth:a path:/c@d
  42806. atSign = rest.lastIndexOf('@', hostEnd);
  42807. }
  42808. // Now we have a portion which is definitely the auth.
  42809. // Pull that off.
  42810. if (atSign !== -1) {
  42811. auth = rest.slice(0, atSign);
  42812. rest = rest.slice(atSign + 1);
  42813. this.auth = decodeURIComponent(auth);
  42814. }
  42815. // the host is the remaining to the left of the first non-host char
  42816. hostEnd = -1;
  42817. for (var i = 0; i < nonHostChars.length; i++) {
  42818. var hec = rest.indexOf(nonHostChars[i]);
  42819. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  42820. hostEnd = hec;
  42821. }
  42822. // if we still have not hit it, then the entire thing is a host.
  42823. if (hostEnd === -1)
  42824. hostEnd = rest.length;
  42825. this.host = rest.slice(0, hostEnd);
  42826. rest = rest.slice(hostEnd);
  42827. // pull out port.
  42828. this.parseHost();
  42829. // we've indicated that there is a hostname,
  42830. // so even if it's empty, it has to be present.
  42831. this.hostname = this.hostname || '';
  42832. // if hostname begins with [ and ends with ]
  42833. // assume that it's an IPv6 address.
  42834. var ipv6Hostname = this.hostname[0] === '[' &&
  42835. this.hostname[this.hostname.length - 1] === ']';
  42836. // validate a little.
  42837. if (!ipv6Hostname) {
  42838. var hostparts = this.hostname.split(/\./);
  42839. for (var i = 0, l = hostparts.length; i < l; i++) {
  42840. var part = hostparts[i];
  42841. if (!part) continue;
  42842. if (!part.match(hostnamePartPattern)) {
  42843. var newpart = '';
  42844. for (var j = 0, k = part.length; j < k; j++) {
  42845. if (part.charCodeAt(j) > 127) {
  42846. // we replace non-ASCII char with a temporary placeholder
  42847. // we need this to make sure size of hostname is not
  42848. // broken by replacing non-ASCII by nothing
  42849. newpart += 'x';
  42850. } else {
  42851. newpart += part[j];
  42852. }
  42853. }
  42854. // we test again with ASCII char only
  42855. if (!newpart.match(hostnamePartPattern)) {
  42856. var validParts = hostparts.slice(0, i);
  42857. var notHost = hostparts.slice(i + 1);
  42858. var bit = part.match(hostnamePartStart);
  42859. if (bit) {
  42860. validParts.push(bit[1]);
  42861. notHost.unshift(bit[2]);
  42862. }
  42863. if (notHost.length) {
  42864. rest = '/' + notHost.join('.') + rest;
  42865. }
  42866. this.hostname = validParts.join('.');
  42867. break;
  42868. }
  42869. }
  42870. }
  42871. }
  42872. if (this.hostname.length > hostnameMaxLen) {
  42873. this.hostname = '';
  42874. } else {
  42875. // hostnames are always lower case.
  42876. this.hostname = this.hostname.toLowerCase();
  42877. }
  42878. if (!ipv6Hostname) {
  42879. // IDNA Support: Returns a punycoded representation of "domain".
  42880. // It only converts parts of the domain name that
  42881. // have non-ASCII characters, i.e. it doesn't matter if
  42882. // you call it with a domain that already is ASCII-only.
  42883. this.hostname = punycode.toASCII(this.hostname);
  42884. }
  42885. var p = this.port ? ':' + this.port : '';
  42886. var h = this.hostname || '';
  42887. this.host = h + p;
  42888. this.href += this.host;
  42889. // strip [ and ] from the hostname
  42890. // the host field still retains them, though
  42891. if (ipv6Hostname) {
  42892. this.hostname = this.hostname.substr(1, this.hostname.length - 2);
  42893. if (rest[0] !== '/') {
  42894. rest = '/' + rest;
  42895. }
  42896. }
  42897. }
  42898. // now rest is set to the post-host stuff.
  42899. // chop off any delim chars.
  42900. if (!unsafeProtocol[lowerProto]) {
  42901. // First, make 100% sure that any "autoEscape" chars get
  42902. // escaped, even if encodeURIComponent doesn't think they
  42903. // need to be.
  42904. for (var i = 0, l = autoEscape.length; i < l; i++) {
  42905. var ae = autoEscape[i];
  42906. if (rest.indexOf(ae) === -1)
  42907. continue;
  42908. var esc = encodeURIComponent(ae);
  42909. if (esc === ae) {
  42910. esc = escape(ae);
  42911. }
  42912. rest = rest.split(ae).join(esc);
  42913. }
  42914. }
  42915. // chop off from the tail first.
  42916. var hash = rest.indexOf('#');
  42917. if (hash !== -1) {
  42918. // got a fragment string.
  42919. this.hash = rest.substr(hash);
  42920. rest = rest.slice(0, hash);
  42921. }
  42922. var qm = rest.indexOf('?');
  42923. if (qm !== -1) {
  42924. this.search = rest.substr(qm);
  42925. this.query = rest.substr(qm + 1);
  42926. if (parseQueryString) {
  42927. this.query = querystring.parse(this.query);
  42928. }
  42929. rest = rest.slice(0, qm);
  42930. } else if (parseQueryString) {
  42931. // no query string, but parseQueryString still requested
  42932. this.search = '';
  42933. this.query = {};
  42934. }
  42935. if (rest) this.pathname = rest;
  42936. if (slashedProtocol[lowerProto] &&
  42937. this.hostname && !this.pathname) {
  42938. this.pathname = '/';
  42939. }
  42940. //to support http.request
  42941. if (this.pathname || this.search) {
  42942. var p = this.pathname || '';
  42943. var s = this.search || '';
  42944. this.path = p + s;
  42945. }
  42946. // finally, reconstruct the href based on what has been validated.
  42947. this.href = this.format();
  42948. return this;
  42949. };
  42950. // format a parsed object into a url string
  42951. function urlFormat(obj) {
  42952. // ensure it's an object, and not a string url.
  42953. // If it's an obj, this is a no-op.
  42954. // this way, you can call url_format() on strings
  42955. // to clean up potentially wonky urls.
  42956. if (util.isString(obj)) obj = urlParse(obj);
  42957. if (!(obj instanceof Url)) return Url.prototype.format.call(obj);
  42958. return obj.format();
  42959. }
  42960. Url.prototype.format = function() {
  42961. var auth = this.auth || '';
  42962. if (auth) {
  42963. auth = encodeURIComponent(auth);
  42964. auth = auth.replace(/%3A/i, ':');
  42965. auth += '@';
  42966. }
  42967. var protocol = this.protocol || '',
  42968. pathname = this.pathname || '',
  42969. hash = this.hash || '',
  42970. host = false,
  42971. query = '';
  42972. if (this.host) {
  42973. host = auth + this.host;
  42974. } else if (this.hostname) {
  42975. host = auth + (this.hostname.indexOf(':') === -1 ?
  42976. this.hostname :
  42977. '[' + this.hostname + ']');
  42978. if (this.port) {
  42979. host += ':' + this.port;
  42980. }
  42981. }
  42982. if (this.query &&
  42983. util.isObject(this.query) &&
  42984. Object.keys(this.query).length) {
  42985. query = querystring.stringify(this.query);
  42986. }
  42987. var search = this.search || (query && ('?' + query)) || '';
  42988. if (protocol && protocol.substr(-1) !== ':') protocol += ':';
  42989. // only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
  42990. // unless they had them to begin with.
  42991. if (this.slashes ||
  42992. (!protocol || slashedProtocol[protocol]) && host !== false) {
  42993. host = '//' + (host || '');
  42994. if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
  42995. } else if (!host) {
  42996. host = '';
  42997. }
  42998. if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
  42999. if (search && search.charAt(0) !== '?') search = '?' + search;
  43000. pathname = pathname.replace(/[?#]/g, function(match) {
  43001. return encodeURIComponent(match);
  43002. });
  43003. search = search.replace('#', '%23');
  43004. return protocol + host + pathname + search + hash;
  43005. };
  43006. function urlResolve(source, relative) {
  43007. return urlParse(source, false, true).resolve(relative);
  43008. }
  43009. Url.prototype.resolve = function(relative) {
  43010. return this.resolveObject(urlParse(relative, false, true)).format();
  43011. };
  43012. function urlResolveObject(source, relative) {
  43013. if (!source) return relative;
  43014. return urlParse(source, false, true).resolveObject(relative);
  43015. }
  43016. Url.prototype.resolveObject = function(relative) {
  43017. if (util.isString(relative)) {
  43018. var rel = new Url();
  43019. rel.parse(relative, false, true);
  43020. relative = rel;
  43021. }
  43022. var result = new Url();
  43023. var tkeys = Object.keys(this);
  43024. for (var tk = 0; tk < tkeys.length; tk++) {
  43025. var tkey = tkeys[tk];
  43026. result[tkey] = this[tkey];
  43027. }
  43028. // hash is always overridden, no matter what.
  43029. // even href="" will remove it.
  43030. result.hash = relative.hash;
  43031. // if the relative url is empty, then there's nothing left to do here.
  43032. if (relative.href === '') {
  43033. result.href = result.format();
  43034. return result;
  43035. }
  43036. // hrefs like //foo/bar always cut to the protocol.
  43037. if (relative.slashes && !relative.protocol) {
  43038. // take everything except the protocol from relative
  43039. var rkeys = Object.keys(relative);
  43040. for (var rk = 0; rk < rkeys.length; rk++) {
  43041. var rkey = rkeys[rk];
  43042. if (rkey !== 'protocol')
  43043. result[rkey] = relative[rkey];
  43044. }
  43045. //urlParse appends trailing / to urls like http://www.example.com
  43046. if (slashedProtocol[result.protocol] &&
  43047. result.hostname && !result.pathname) {
  43048. result.path = result.pathname = '/';
  43049. }
  43050. result.href = result.format();
  43051. return result;
  43052. }
  43053. if (relative.protocol && relative.protocol !== result.protocol) {
  43054. // if it's a known url protocol, then changing
  43055. // the protocol does weird things
  43056. // first, if it's not file:, then we MUST have a host,
  43057. // and if there was a path
  43058. // to begin with, then we MUST have a path.
  43059. // if it is file:, then the host is dropped,
  43060. // because that's known to be hostless.
  43061. // anything else is assumed to be absolute.
  43062. if (!slashedProtocol[relative.protocol]) {
  43063. var keys = Object.keys(relative);
  43064. for (var v = 0; v < keys.length; v++) {
  43065. var k = keys[v];
  43066. result[k] = relative[k];
  43067. }
  43068. result.href = result.format();
  43069. return result;
  43070. }
  43071. result.protocol = relative.protocol;
  43072. if (!relative.host && !hostlessProtocol[relative.protocol]) {
  43073. var relPath = (relative.pathname || '').split('/');
  43074. while (relPath.length && !(relative.host = relPath.shift()));
  43075. if (!relative.host) relative.host = '';
  43076. if (!relative.hostname) relative.hostname = '';
  43077. if (relPath[0] !== '') relPath.unshift('');
  43078. if (relPath.length < 2) relPath.unshift('');
  43079. result.pathname = relPath.join('/');
  43080. } else {
  43081. result.pathname = relative.pathname;
  43082. }
  43083. result.search = relative.search;
  43084. result.query = relative.query;
  43085. result.host = relative.host || '';
  43086. result.auth = relative.auth;
  43087. result.hostname = relative.hostname || relative.host;
  43088. result.port = relative.port;
  43089. // to support http.request
  43090. if (result.pathname || result.search) {
  43091. var p = result.pathname || '';
  43092. var s = result.search || '';
  43093. result.path = p + s;
  43094. }
  43095. result.slashes = result.slashes || relative.slashes;
  43096. result.href = result.format();
  43097. return result;
  43098. }
  43099. var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
  43100. isRelAbs = (
  43101. relative.host ||
  43102. relative.pathname && relative.pathname.charAt(0) === '/'
  43103. ),
  43104. mustEndAbs = (isRelAbs || isSourceAbs ||
  43105. (result.host && relative.pathname)),
  43106. removeAllDots = mustEndAbs,
  43107. srcPath = result.pathname && result.pathname.split('/') || [],
  43108. relPath = relative.pathname && relative.pathname.split('/') || [],
  43109. psychotic = result.protocol && !slashedProtocol[result.protocol];
  43110. // if the url is a non-slashed url, then relative
  43111. // links like ../.. should be able
  43112. // to crawl up to the hostname, as well. This is strange.
  43113. // result.protocol has already been set by now.
  43114. // Later on, put the first path part into the host field.
  43115. if (psychotic) {
  43116. result.hostname = '';
  43117. result.port = null;
  43118. if (result.host) {
  43119. if (srcPath[0] === '') srcPath[0] = result.host;
  43120. else srcPath.unshift(result.host);
  43121. }
  43122. result.host = '';
  43123. if (relative.protocol) {
  43124. relative.hostname = null;
  43125. relative.port = null;
  43126. if (relative.host) {
  43127. if (relPath[0] === '') relPath[0] = relative.host;
  43128. else relPath.unshift(relative.host);
  43129. }
  43130. relative.host = null;
  43131. }
  43132. mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
  43133. }
  43134. if (isRelAbs) {
  43135. // it's absolute.
  43136. result.host = (relative.host || relative.host === '') ?
  43137. relative.host : result.host;
  43138. result.hostname = (relative.hostname || relative.hostname === '') ?
  43139. relative.hostname : result.hostname;
  43140. result.search = relative.search;
  43141. result.query = relative.query;
  43142. srcPath = relPath;
  43143. // fall through to the dot-handling below.
  43144. } else if (relPath.length) {
  43145. // it's relative
  43146. // throw away the existing file, and take the new path instead.
  43147. if (!srcPath) srcPath = [];
  43148. srcPath.pop();
  43149. srcPath = srcPath.concat(relPath);
  43150. result.search = relative.search;
  43151. result.query = relative.query;
  43152. } else if (!util.isNullOrUndefined(relative.search)) {
  43153. // just pull out the search.
  43154. // like href='?foo'.
  43155. // Put this after the other two cases because it simplifies the booleans
  43156. if (psychotic) {
  43157. result.hostname = result.host = srcPath.shift();
  43158. //occationaly the auth can get stuck only in host
  43159. //this especially happens in cases like
  43160. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  43161. var authInHost = result.host && result.host.indexOf('@') > 0 ?
  43162. result.host.split('@') : false;
  43163. if (authInHost) {
  43164. result.auth = authInHost.shift();
  43165. result.host = result.hostname = authInHost.shift();
  43166. }
  43167. }
  43168. result.search = relative.search;
  43169. result.query = relative.query;
  43170. //to support http.request
  43171. if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
  43172. result.path = (result.pathname ? result.pathname : '') +
  43173. (result.search ? result.search : '');
  43174. }
  43175. result.href = result.format();
  43176. return result;
  43177. }
  43178. if (!srcPath.length) {
  43179. // no path at all. easy.
  43180. // we've already handled the other stuff above.
  43181. result.pathname = null;
  43182. //to support http.request
  43183. if (result.search) {
  43184. result.path = '/' + result.search;
  43185. } else {
  43186. result.path = null;
  43187. }
  43188. result.href = result.format();
  43189. return result;
  43190. }
  43191. // if a url ENDs in . or .., then it must get a trailing slash.
  43192. // however, if it ends in anything else non-slashy,
  43193. // then it must NOT get a trailing slash.
  43194. var last = srcPath.slice(-1)[0];
  43195. var hasTrailingSlash = (
  43196. (result.host || relative.host || srcPath.length > 1) &&
  43197. (last === '.' || last === '..') || last === '');
  43198. // strip single dots, resolve double dots to parent dir
  43199. // if the path tries to go above the root, `up` ends up > 0
  43200. var up = 0;
  43201. for (var i = srcPath.length; i >= 0; i--) {
  43202. last = srcPath[i];
  43203. if (last === '.') {
  43204. srcPath.splice(i, 1);
  43205. } else if (last === '..') {
  43206. srcPath.splice(i, 1);
  43207. up++;
  43208. } else if (up) {
  43209. srcPath.splice(i, 1);
  43210. up--;
  43211. }
  43212. }
  43213. // if the path is allowed to go above the root, restore leading ..s
  43214. if (!mustEndAbs && !removeAllDots) {
  43215. for (; up--; up) {
  43216. srcPath.unshift('..');
  43217. }
  43218. }
  43219. if (mustEndAbs && srcPath[0] !== '' &&
  43220. (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
  43221. srcPath.unshift('');
  43222. }
  43223. if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
  43224. srcPath.push('');
  43225. }
  43226. var isAbsolute = srcPath[0] === '' ||
  43227. (srcPath[0] && srcPath[0].charAt(0) === '/');
  43228. // put the host back
  43229. if (psychotic) {
  43230. result.hostname = result.host = isAbsolute ? '' :
  43231. srcPath.length ? srcPath.shift() : '';
  43232. //occationaly the auth can get stuck only in host
  43233. //this especially happens in cases like
  43234. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  43235. var authInHost = result.host && result.host.indexOf('@') > 0 ?
  43236. result.host.split('@') : false;
  43237. if (authInHost) {
  43238. result.auth = authInHost.shift();
  43239. result.host = result.hostname = authInHost.shift();
  43240. }
  43241. }
  43242. mustEndAbs = mustEndAbs || (result.host && srcPath.length);
  43243. if (mustEndAbs && !isAbsolute) {
  43244. srcPath.unshift('');
  43245. }
  43246. if (!srcPath.length) {
  43247. result.pathname = null;
  43248. result.path = null;
  43249. } else {
  43250. result.pathname = srcPath.join('/');
  43251. }
  43252. //to support request.http
  43253. if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
  43254. result.path = (result.pathname ? result.pathname : '') +
  43255. (result.search ? result.search : '');
  43256. }
  43257. result.auth = relative.auth || result.auth;
  43258. result.slashes = result.slashes || relative.slashes;
  43259. result.href = result.format();
  43260. return result;
  43261. };
  43262. Url.prototype.parseHost = function() {
  43263. var host = this.host;
  43264. var port = portPattern.exec(host);
  43265. if (port) {
  43266. port = port[0];
  43267. if (port !== ':') {
  43268. this.port = port.substr(1);
  43269. }
  43270. host = host.substr(0, host.length - port.length);
  43271. }
  43272. if (host) this.hostname = host;
  43273. };
  43274. /***/ },
  43275. /* 227 */
  43276. /***/ function(module, exports, __webpack_require__) {
  43277. /* WEBPACK VAR INJECTION */(function(global) {
  43278. /**
  43279. * Module exports.
  43280. */
  43281. module.exports = deprecate;
  43282. /**
  43283. * Mark that a method should not be used.
  43284. * Returns a modified function which warns once by default.
  43285. *
  43286. * If `localStorage.noDeprecation = true` is set, then it is a no-op.
  43287. *
  43288. * If `localStorage.throwDeprecation = true` is set, then deprecated functions
  43289. * will throw an Error when invoked.
  43290. *
  43291. * If `localStorage.traceDeprecation = true` is set, then deprecated functions
  43292. * will invoke `console.trace()` instead of `console.error()`.
  43293. *
  43294. * @param {Function} fn - the function to deprecate
  43295. * @param {String} msg - the string to print to the console when `fn` is invoked
  43296. * @returns {Function} a new "deprecated" version of `fn`
  43297. * @api public
  43298. */
  43299. function deprecate (fn, msg) {
  43300. if (config('noDeprecation')) {
  43301. return fn;
  43302. }
  43303. var warned = false;
  43304. function deprecated() {
  43305. if (!warned) {
  43306. if (config('throwDeprecation')) {
  43307. throw new Error(msg);
  43308. } else if (config('traceDeprecation')) {
  43309. console.trace(msg);
  43310. } else {
  43311. console.warn(msg);
  43312. }
  43313. warned = true;
  43314. }
  43315. return fn.apply(this, arguments);
  43316. }
  43317. return deprecated;
  43318. }
  43319. /**
  43320. * Checks `localStorage` for boolean values for the given `name`.
  43321. *
  43322. * @param {String} name
  43323. * @returns {Boolean}
  43324. * @api private
  43325. */
  43326. function config (name) {
  43327. // accessing global.localStorage can trigger a DOMException in sandboxed iframes
  43328. try {
  43329. if (!global.localStorage) return false;
  43330. } catch (_) {
  43331. return false;
  43332. }
  43333. var val = global.localStorage[name];
  43334. if (null == val) return false;
  43335. return String(val).toLowerCase() === 'true';
  43336. }
  43337. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(13)))
  43338. /***/ },
  43339. /* 228 */
  43340. /***/ function(module, exports) {
  43341. // Returns a wrapper function that returns a wrapped callback
  43342. // The wrapper function should do some stuff, and return a
  43343. // presumably different callback function.
  43344. // This makes sure that own properties are retained, so that
  43345. // decorations and such are not lost along the way.
  43346. module.exports = wrappy
  43347. function wrappy (fn, cb) {
  43348. if (fn && cb) return wrappy(fn)(cb)
  43349. if (typeof fn !== 'function')
  43350. throw new TypeError('need wrapper function')
  43351. Object.keys(fn).forEach(function (k) {
  43352. wrapper[k] = fn[k]
  43353. })
  43354. return wrapper
  43355. function wrapper() {
  43356. var args = new Array(arguments.length)
  43357. for (var i = 0; i < args.length; i++) {
  43358. args[i] = arguments[i]
  43359. }
  43360. var ret = fn.apply(this, args)
  43361. var cb = args[args.length-1]
  43362. if (typeof ret === 'function' && ret !== cb) {
  43363. Object.keys(cb).forEach(function (k) {
  43364. ret[k] = cb[k]
  43365. })
  43366. }
  43367. return ret
  43368. }
  43369. }
  43370. /***/ },
  43371. /* 229 */
  43372. /***/ function(module, exports, __webpack_require__) {
  43373. "use strict";
  43374. /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
  43375. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
  43376. var multiaddr = __webpack_require__(524);
  43377. var loadCommands = __webpack_require__(278);
  43378. var getConfig = __webpack_require__(275);
  43379. var getRequestAPI = __webpack_require__(279);
  43380. function IpfsAPI(hostOrMultiaddr, port, opts) {
  43381. var config = getConfig();
  43382. try {
  43383. var maddr = multiaddr(hostOrMultiaddr).nodeAddress();
  43384. config.host = maddr.address;
  43385. config.port = maddr.port;
  43386. } catch (e) {
  43387. if (typeof hostOrMultiaddr === 'string') {
  43388. config.host = hostOrMultiaddr;
  43389. config.port = port && (typeof port === 'undefined' ? 'undefined' : _typeof(port)) !== 'object' ? port : config.port;
  43390. }
  43391. }
  43392. var lastIndex = arguments.length;
  43393. while (!opts && lastIndex-- > 0) {
  43394. opts = arguments[lastIndex];
  43395. if (opts) break;
  43396. }
  43397. Object.assign(config, opts);
  43398. // autoconfigure in browser
  43399. if (!config.host && typeof window !== 'undefined') {
  43400. var split = window.location.host.split(':');
  43401. config.host = split[0];
  43402. config.port = split[1];
  43403. }
  43404. var requestAPI = getRequestAPI(config);
  43405. var cmds = loadCommands(requestAPI);
  43406. cmds.send = requestAPI;
  43407. cmds.Buffer = Buffer;
  43408. return cmds;
  43409. }
  43410. exports = module.exports = IpfsAPI;
  43411. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  43412. /***/ },
  43413. /* 230 */
  43414. /***/ function(module, exports, __webpack_require__) {
  43415. "use strict";
  43416. /* WEBPACK VAR INJECTION */(function(global) {"use strict";
  43417. __webpack_require__(476);
  43418. __webpack_require__(553);
  43419. __webpack_require__(295);
  43420. /* eslint max-len: 0 */
  43421. if (global._babelPolyfill) {
  43422. throw new Error("only one instance of babel-polyfill is allowed");
  43423. }
  43424. global._babelPolyfill = true;
  43425. // Should be removed in the next major release:
  43426. var DEFINE_PROPERTY = "defineProperty";
  43427. function define(O, key, value) {
  43428. O[key] || Object[DEFINE_PROPERTY](O, key, {
  43429. writable: true,
  43430. configurable: true,
  43431. value: value
  43432. });
  43433. }
  43434. define(String.prototype, "padLeft", "".padStart);
  43435. define(String.prototype, "padRight", "".padEnd);
  43436. "pop,reverse,shift,keys,values,entries,indexOf,every,some,forEach,map,filter,find,findIndex,includes,join,slice,concat,push,splice,unshift,sort,lastIndexOf,reduce,reduceRight,copyWithin,fill".split(",").forEach(function (key) {
  43437. [][key] && define(Array, key, Function.call.bind([][key]));
  43438. });
  43439. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(13)))
  43440. /***/ },
  43441. /* 231 */
  43442. /***/ function(module, exports) {
  43443. module.exports = {
  43444. "modp1": {
  43445. "gen": "02",
  43446. "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"
  43447. },
  43448. "modp2": {
  43449. "gen": "02",
  43450. "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"
  43451. },
  43452. "modp5": {
  43453. "gen": "02",
  43454. "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"
  43455. },
  43456. "modp14": {
  43457. "gen": "02",
  43458. "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"
  43459. },
  43460. "modp15": {
  43461. "gen": "02",
  43462. "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"
  43463. },
  43464. "modp16": {
  43465. "gen": "02",
  43466. "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"
  43467. },
  43468. "modp17": {
  43469. "gen": "02",
  43470. "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"
  43471. },
  43472. "modp18": {
  43473. "gen": "02",
  43474. "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"
  43475. }
  43476. };
  43477. /***/ },
  43478. /* 232 */
  43479. /***/ function(module, exports) {
  43480. module.exports = {
  43481. "_args": [
  43482. [
  43483. "elliptic@^6.0.0",
  43484. "/Users/ground-control/code/js-ipfs-api/node_modules/browserify-sign"
  43485. ]
  43486. ],
  43487. "_from": "elliptic@>=6.0.0 <7.0.0",
  43488. "_id": "[email protected]",
  43489. "_inCache": true,
  43490. "_installable": true,
  43491. "_location": "/elliptic",
  43492. "_nodeVersion": "6.0.0",
  43493. "_npmOperationalInternal": {
  43494. "host": "packages-16-east.internal.npmjs.com",
  43495. "tmp": "tmp/elliptic-6.3.1.tgz_1465921413402_0.5202967382501811"
  43496. },
  43497. "_npmUser": {
  43498. "email": "[email protected]",
  43499. "name": "indutny"
  43500. },
  43501. "_npmVersion": "3.8.6",
  43502. "_phantomChildren": {},
  43503. "_requested": {
  43504. "name": "elliptic",
  43505. "raw": "elliptic@^6.0.0",
  43506. "rawSpec": "^6.0.0",
  43507. "scope": null,
  43508. "spec": ">=6.0.0 <7.0.0",
  43509. "type": "range"
  43510. },
  43511. "_requiredBy": [
  43512. "/browserify-sign",
  43513. "/create-ecdh"
  43514. ],
  43515. "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.3.1.tgz",
  43516. "_shasum": "17781f2109ab0ec686b146bdcff5d2e8c6aeceda",
  43517. "_shrinkwrap": null,
  43518. "_spec": "elliptic@^6.0.0",
  43519. "_where": "/Users/ground-control/code/js-ipfs-api/node_modules/browserify-sign",
  43520. "author": {
  43521. "email": "[email protected]",
  43522. "name": "Fedor Indutny"
  43523. },
  43524. "bugs": {
  43525. "url": "https://github.com/indutny/elliptic/issues"
  43526. },
  43527. "dependencies": {
  43528. "bn.js": "^4.4.0",
  43529. "brorand": "^1.0.1",
  43530. "hash.js": "^1.0.0",
  43531. "inherits": "^2.0.1"
  43532. },
  43533. "description": "EC cryptography",
  43534. "devDependencies": {
  43535. "brfs": "^1.4.3",
  43536. "coveralls": "^2.11.3",
  43537. "grunt": "^0.4.5",
  43538. "grunt-browserify": "^5.0.0",
  43539. "grunt-contrib-connect": "^1.0.0",
  43540. "grunt-contrib-copy": "^1.0.0",
  43541. "grunt-contrib-uglify": "^1.0.1",
  43542. "grunt-mocha-istanbul": "^3.0.1",
  43543. "grunt-saucelabs": "^8.6.2",
  43544. "istanbul": "^0.4.2",
  43545. "jscs": "^2.9.0",
  43546. "jshint": "^2.6.0",
  43547. "mocha": "^2.1.0"
  43548. },
  43549. "directories": {},
  43550. "dist": {
  43551. "shasum": "17781f2109ab0ec686b146bdcff5d2e8c6aeceda",
  43552. "tarball": "https://registry.npmjs.org/elliptic/-/elliptic-6.3.1.tgz"
  43553. },
  43554. "files": [
  43555. "lib"
  43556. ],
  43557. "gitHead": "c53f5cf3d832c0073eb4a4ed423a464cbce68f3e",
  43558. "homepage": "https://github.com/indutny/elliptic",
  43559. "keywords": [
  43560. "EC",
  43561. "Elliptic",
  43562. "curve",
  43563. "Cryptography"
  43564. ],
  43565. "license": "MIT",
  43566. "main": "lib/elliptic.js",
  43567. "maintainers": [
  43568. {
  43569. "email": "[email protected]",
  43570. "name": "indutny"
  43571. }
  43572. ],
  43573. "name": "elliptic",
  43574. "optionalDependencies": {},
  43575. "readme": "ERROR: No README data found!",
  43576. "repository": {
  43577. "type": "git",
  43578. "url": "git+ssh://[email protected]/indutny/elliptic.git"
  43579. },
  43580. "scripts": {
  43581. "jscs": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",
  43582. "jshint": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",
  43583. "lint": "npm run jscs && npm run jshint",
  43584. "test": "npm run lint && npm run unit",
  43585. "unit": "istanbul test _mocha --reporter=spec test/index.js",
  43586. "version": "grunt dist && git add dist/"
  43587. },
  43588. "version": "6.3.1"
  43589. };
  43590. /***/ },
  43591. /* 233 */
  43592. /***/ function(module, exports) {
  43593. module.exports = {
  43594. "2.16.840.1.101.3.4.1.1": "aes-128-ecb",
  43595. "2.16.840.1.101.3.4.1.2": "aes-128-cbc",
  43596. "2.16.840.1.101.3.4.1.3": "aes-128-ofb",
  43597. "2.16.840.1.101.3.4.1.4": "aes-128-cfb",
  43598. "2.16.840.1.101.3.4.1.21": "aes-192-ecb",
  43599. "2.16.840.1.101.3.4.1.22": "aes-192-cbc",
  43600. "2.16.840.1.101.3.4.1.23": "aes-192-ofb",
  43601. "2.16.840.1.101.3.4.1.24": "aes-192-cfb",
  43602. "2.16.840.1.101.3.4.1.41": "aes-256-ecb",
  43603. "2.16.840.1.101.3.4.1.42": "aes-256-cbc",
  43604. "2.16.840.1.101.3.4.1.43": "aes-256-ofb",
  43605. "2.16.840.1.101.3.4.1.44": "aes-256-cfb"
  43606. };
  43607. /***/ },
  43608. /* 234 */
  43609. /***/ function(module, exports) {
  43610. module.exports = {
  43611. "name": "ipfs-api",
  43612. "version": "6.0.2",
  43613. "description": "A client library for the IPFS API",
  43614. "main": "lib/index.js",
  43615. "jsnext:main": "src/index.js",
  43616. "dependencies": {
  43617. "async": "^2.0.0-rc.5",
  43618. "babel-runtime": "^6.6.1",
  43619. "bl": "^1.1.2",
  43620. "bs58": "^3.0.0",
  43621. "detect-node": "^2.0.3",
  43622. "flatmap": "0.0.3",
  43623. "glob": "^7.0.3",
  43624. "ipfs-merkle-dag": "^0.6.0",
  43625. "is-ipfs": "^0.2.0",
  43626. "isstream": "^0.1.2",
  43627. "multiaddr": "^2.0.0",
  43628. "multipart-stream": "^2.0.1",
  43629. "ndjson": "^1.4.3",
  43630. "promisify-es6": "^1.0.1",
  43631. "qs": "^6.1.0",
  43632. "wreck": "^7.0.2"
  43633. },
  43634. "engines": {
  43635. "node": ">=4.2.2"
  43636. },
  43637. "repository": {
  43638. "type": "git",
  43639. "url": "https://github.com/ipfs/js-ipfs-api"
  43640. },
  43641. "devDependencies": {
  43642. "aegir": "^3.2.0",
  43643. "chai": "^3.5.0",
  43644. "gulp": "^3.9.1",
  43645. "interface-ipfs-core": "^0.4.3",
  43646. "ipfsd-ctl": "^0.14.0",
  43647. "pre-commit": "^1.1.2",
  43648. "stream-equal": "^0.1.8",
  43649. "stream-http": "^2.2.0",
  43650. "streamifier": "^0.1.1"
  43651. },
  43652. "scripts": {
  43653. "test": "gulp test",
  43654. "test:node": "gulp test:node",
  43655. "test:browser": "gulp test:browser",
  43656. "lint": "aegir-lint",
  43657. "build": "gulp build",
  43658. "release": "gulp release",
  43659. "release-minor": "gulp release --type minor",
  43660. "release-major": "gulp release --type major",
  43661. "coverage": "gulp coverage",
  43662. "coverage-publish": "aegir-coverage publish"
  43663. },
  43664. "pre-commit": [
  43665. "lint",
  43666. "test"
  43667. ],
  43668. "keywords": [
  43669. "ipfs"
  43670. ],
  43671. "author": "Matt Bell <[email protected]>",
  43672. "contributors": [
  43673. "Alex Mingoia <[email protected]>",
  43674. "Connor Keenan <[email protected]>",
  43675. "David Braun <[email protected]>",
  43676. "David Dias <[email protected]>",
  43677. "Fil <[email protected]>",
  43678. "Francisco Baio Dias <[email protected]>",
  43679. "Gavin McDermott <[email protected]>",
  43680. "Harlan T Wood <[email protected]>",
  43681. "Harlan T Wood <[email protected]>",
  43682. "Holodisc <[email protected]>",
  43683. "Jason Carver <[email protected]>",
  43684. "Jeromy <[email protected]>",
  43685. "Juan Batiz-Benet <[email protected]>",
  43686. "Kristoffer Ström <[email protected]>",
  43687. "Matt Bell <[email protected]>",
  43688. "Mithgol <[email protected]>",
  43689. "Richard Littauer <[email protected]>",
  43690. "Stephen Whitmore <[email protected]>",
  43691. "Travis Person <[email protected]>",
  43692. "Victor Bjelkholm <[email protected]>",
  43693. "dignifiedquire <[email protected]>",
  43694. "ethers <[email protected]>",
  43695. "greenkeeperio-bot <[email protected]>",
  43696. "haad <[email protected]>",
  43697. "nginnever <[email protected]>",
  43698. "priecint <[email protected]>",
  43699. "samuli <[email protected]>"
  43700. ],
  43701. "license": "MIT",
  43702. "bugs": {
  43703. "url": "https://github.com/ipfs/js-ipfs-api/issues"
  43704. },
  43705. "homepage": "https://github.com/ipfs/js-ipfs-api"
  43706. };
  43707. /***/ },
  43708. /* 235 */
  43709. /***/ function(module, exports, __webpack_require__) {
  43710. var asn1 = __webpack_require__(77);
  43711. var inherits = __webpack_require__(2);
  43712. var api = exports;
  43713. api.define = function define(name, body) {
  43714. return new Entity(name, body);
  43715. };
  43716. function Entity(name, body) {
  43717. this.name = name;
  43718. this.body = body;
  43719. this.decoders = {};
  43720. this.encoders = {};
  43721. };
  43722. Entity.prototype._createNamed = function createNamed(base) {
  43723. var named;
  43724. try {
  43725. named = __webpack_require__(583).runInThisContext(
  43726. '(function ' + this.name + '(entity) {\n' +
  43727. ' this._initNamed(entity);\n' +
  43728. '})'
  43729. );
  43730. } catch (e) {
  43731. named = function (entity) {
  43732. this._initNamed(entity);
  43733. };
  43734. }
  43735. inherits(named, base);
  43736. named.prototype._initNamed = function initnamed(entity) {
  43737. base.call(this, entity);
  43738. };
  43739. return new named(this);
  43740. };
  43741. Entity.prototype._getDecoder = function _getDecoder(enc) {
  43742. enc = enc || 'der';
  43743. // Lazily create decoder
  43744. if (!this.decoders.hasOwnProperty(enc))
  43745. this.decoders[enc] = this._createNamed(asn1.decoders[enc]);
  43746. return this.decoders[enc];
  43747. };
  43748. Entity.prototype.decode = function decode(data, enc, options) {
  43749. return this._getDecoder(enc).decode(data, options);
  43750. };
  43751. Entity.prototype._getEncoder = function _getEncoder(enc) {
  43752. enc = enc || 'der';
  43753. // Lazily create encoder
  43754. if (!this.encoders.hasOwnProperty(enc))
  43755. this.encoders[enc] = this._createNamed(asn1.encoders[enc]);
  43756. return this.encoders[enc];
  43757. };
  43758. Entity.prototype.encode = function encode(data, enc, /* internal */ reporter) {
  43759. return this._getEncoder(enc).encode(data, reporter);
  43760. };
  43761. /***/ },
  43762. /* 236 */
  43763. /***/ function(module, exports, __webpack_require__) {
  43764. var Reporter = __webpack_require__(67).Reporter;
  43765. var EncoderBuffer = __webpack_require__(67).EncoderBuffer;
  43766. var DecoderBuffer = __webpack_require__(67).DecoderBuffer;
  43767. var assert = __webpack_require__(72);
  43768. // Supported tags
  43769. var tags = [
  43770. 'seq', 'seqof', 'set', 'setof', 'objid', 'bool',
  43771. 'gentime', 'utctime', 'null_', 'enum', 'int',
  43772. 'bitstr', 'bmpstr', 'charstr', 'genstr', 'graphstr', 'ia5str', 'iso646str',
  43773. 'numstr', 'octstr', 'printstr', 't61str', 'unistr', 'utf8str', 'videostr'
  43774. ];
  43775. // Public methods list
  43776. var methods = [
  43777. 'key', 'obj', 'use', 'optional', 'explicit', 'implicit', 'def', 'choice',
  43778. 'any', 'contains'
  43779. ].concat(tags);
  43780. // Overrided methods list
  43781. var overrided = [
  43782. '_peekTag', '_decodeTag', '_use',
  43783. '_decodeStr', '_decodeObjid', '_decodeTime',
  43784. '_decodeNull', '_decodeInt', '_decodeBool', '_decodeList',
  43785. '_encodeComposite', '_encodeStr', '_encodeObjid', '_encodeTime',
  43786. '_encodeNull', '_encodeInt', '_encodeBool'
  43787. ];
  43788. function Node(enc, parent) {
  43789. var state = {};
  43790. this._baseState = state;
  43791. state.enc = enc;
  43792. state.parent = parent || null;
  43793. state.children = null;
  43794. // State
  43795. state.tag = null;
  43796. state.args = null;
  43797. state.reverseArgs = null;
  43798. state.choice = null;
  43799. state.optional = false;
  43800. state.any = false;
  43801. state.obj = false;
  43802. state.use = null;
  43803. state.useDecoder = null;
  43804. state.key = null;
  43805. state['default'] = null;
  43806. state.explicit = null;
  43807. state.implicit = null;
  43808. state.contains = null;
  43809. // Should create new instance on each method
  43810. if (!state.parent) {
  43811. state.children = [];
  43812. this._wrap();
  43813. }
  43814. }
  43815. module.exports = Node;
  43816. var stateProps = [
  43817. 'enc', 'parent', 'children', 'tag', 'args', 'reverseArgs', 'choice',
  43818. 'optional', 'any', 'obj', 'use', 'alteredUse', 'key', 'default', 'explicit',
  43819. 'implicit'
  43820. ];
  43821. Node.prototype.clone = function clone() {
  43822. var state = this._baseState;
  43823. var cstate = {};
  43824. stateProps.forEach(function(prop) {
  43825. cstate[prop] = state[prop];
  43826. });
  43827. var res = new this.constructor(cstate.parent);
  43828. res._baseState = cstate;
  43829. return res;
  43830. };
  43831. Node.prototype._wrap = function wrap() {
  43832. var state = this._baseState;
  43833. methods.forEach(function(method) {
  43834. this[method] = function _wrappedMethod() {
  43835. var clone = new this.constructor(this);
  43836. state.children.push(clone);
  43837. return clone[method].apply(clone, arguments);
  43838. };
  43839. }, this);
  43840. };
  43841. Node.prototype._init = function init(body) {
  43842. var state = this._baseState;
  43843. assert(state.parent === null);
  43844. body.call(this);
  43845. // Filter children
  43846. state.children = state.children.filter(function(child) {
  43847. return child._baseState.parent === this;
  43848. }, this);
  43849. assert.equal(state.children.length, 1, 'Root node can have only one child');
  43850. };
  43851. Node.prototype._useArgs = function useArgs(args) {
  43852. var state = this._baseState;
  43853. // Filter children and args
  43854. var children = args.filter(function(arg) {
  43855. return arg instanceof this.constructor;
  43856. }, this);
  43857. args = args.filter(function(arg) {
  43858. return !(arg instanceof this.constructor);
  43859. }, this);
  43860. if (children.length !== 0) {
  43861. assert(state.children === null);
  43862. state.children = children;
  43863. // Replace parent to maintain backward link
  43864. children.forEach(function(child) {
  43865. child._baseState.parent = this;
  43866. }, this);
  43867. }
  43868. if (args.length !== 0) {
  43869. assert(state.args === null);
  43870. state.args = args;
  43871. state.reverseArgs = args.map(function(arg) {
  43872. if (typeof arg !== 'object' || arg.constructor !== Object)
  43873. return arg;
  43874. var res = {};
  43875. Object.keys(arg).forEach(function(key) {
  43876. if (key == (key | 0))
  43877. key |= 0;
  43878. var value = arg[key];
  43879. res[value] = key;
  43880. });
  43881. return res;
  43882. });
  43883. }
  43884. };
  43885. //
  43886. // Overrided methods
  43887. //
  43888. overrided.forEach(function(method) {
  43889. Node.prototype[method] = function _overrided() {
  43890. var state = this._baseState;
  43891. throw new Error(method + ' not implemented for encoding: ' + state.enc);
  43892. };
  43893. });
  43894. //
  43895. // Public methods
  43896. //
  43897. tags.forEach(function(tag) {
  43898. Node.prototype[tag] = function _tagMethod() {
  43899. var state = this._baseState;
  43900. var args = Array.prototype.slice.call(arguments);
  43901. assert(state.tag === null);
  43902. state.tag = tag;
  43903. this._useArgs(args);
  43904. return this;
  43905. };
  43906. });
  43907. Node.prototype.use = function use(item) {
  43908. var state = this._baseState;
  43909. assert(state.use === null);
  43910. state.use = item;
  43911. return this;
  43912. };
  43913. Node.prototype.optional = function optional() {
  43914. var state = this._baseState;
  43915. state.optional = true;
  43916. return this;
  43917. };
  43918. Node.prototype.def = function def(val) {
  43919. var state = this._baseState;
  43920. assert(state['default'] === null);
  43921. state['default'] = val;
  43922. state.optional = true;
  43923. return this;
  43924. };
  43925. Node.prototype.explicit = function explicit(num) {
  43926. var state = this._baseState;
  43927. assert(state.explicit === null && state.implicit === null);
  43928. state.explicit = num;
  43929. return this;
  43930. };
  43931. Node.prototype.implicit = function implicit(num) {
  43932. var state = this._baseState;
  43933. assert(state.explicit === null && state.implicit === null);
  43934. state.implicit = num;
  43935. return this;
  43936. };
  43937. Node.prototype.obj = function obj() {
  43938. var state = this._baseState;
  43939. var args = Array.prototype.slice.call(arguments);
  43940. state.obj = true;
  43941. if (args.length !== 0)
  43942. this._useArgs(args);
  43943. return this;
  43944. };
  43945. Node.prototype.key = function key(newKey) {
  43946. var state = this._baseState;
  43947. assert(state.key === null);
  43948. state.key = newKey;
  43949. return this;
  43950. };
  43951. Node.prototype.any = function any() {
  43952. var state = this._baseState;
  43953. state.any = true;
  43954. return this;
  43955. };
  43956. Node.prototype.choice = function choice(obj) {
  43957. var state = this._baseState;
  43958. assert(state.choice === null);
  43959. state.choice = obj;
  43960. this._useArgs(Object.keys(obj).map(function(key) {
  43961. return obj[key];
  43962. }));
  43963. return this;
  43964. };
  43965. Node.prototype.contains = function contains(item) {
  43966. var state = this._baseState;
  43967. assert(state.use === null);
  43968. state.contains = item;
  43969. return this;
  43970. };
  43971. //
  43972. // Decoding
  43973. //
  43974. Node.prototype._decode = function decode(input) {
  43975. var state = this._baseState;
  43976. // Decode root node
  43977. if (state.parent === null)
  43978. return input.wrapResult(state.children[0]._decode(input));
  43979. var result = state['default'];
  43980. var present = true;
  43981. var prevKey;
  43982. if (state.key !== null)
  43983. prevKey = input.enterKey(state.key);
  43984. // Check if tag is there
  43985. if (state.optional) {
  43986. var tag = null;
  43987. if (state.explicit !== null)
  43988. tag = state.explicit;
  43989. else if (state.implicit !== null)
  43990. tag = state.implicit;
  43991. else if (state.tag !== null)
  43992. tag = state.tag;
  43993. if (tag === null && !state.any) {
  43994. // Trial and Error
  43995. var save = input.save();
  43996. try {
  43997. if (state.choice === null)
  43998. this._decodeGeneric(state.tag, input);
  43999. else
  44000. this._decodeChoice(input);
  44001. present = true;
  44002. } catch (e) {
  44003. present = false;
  44004. }
  44005. input.restore(save);
  44006. } else {
  44007. present = this._peekTag(input, tag, state.any);
  44008. if (input.isError(present))
  44009. return present;
  44010. }
  44011. }
  44012. // Push object on stack
  44013. var prevObj;
  44014. if (state.obj && present)
  44015. prevObj = input.enterObject();
  44016. if (present) {
  44017. // Unwrap explicit values
  44018. if (state.explicit !== null) {
  44019. var explicit = this._decodeTag(input, state.explicit);
  44020. if (input.isError(explicit))
  44021. return explicit;
  44022. input = explicit;
  44023. }
  44024. // Unwrap implicit and normal values
  44025. if (state.use === null && state.choice === null) {
  44026. if (state.any)
  44027. var save = input.save();
  44028. var body = this._decodeTag(
  44029. input,
  44030. state.implicit !== null ? state.implicit : state.tag,
  44031. state.any
  44032. );
  44033. if (input.isError(body))
  44034. return body;
  44035. if (state.any)
  44036. result = input.raw(save);
  44037. else
  44038. input = body;
  44039. }
  44040. // Select proper method for tag
  44041. if (state.any)
  44042. result = result;
  44043. else if (state.choice === null)
  44044. result = this._decodeGeneric(state.tag, input);
  44045. else
  44046. result = this._decodeChoice(input);
  44047. if (input.isError(result))
  44048. return result;
  44049. // Decode children
  44050. if (!state.any && state.choice === null && state.children !== null) {
  44051. state.children.forEach(function decodeChildren(child) {
  44052. // NOTE: We are ignoring errors here, to let parser continue with other
  44053. // parts of encoded data
  44054. child._decode(input);
  44055. });
  44056. }
  44057. // Decode contained/encoded by schema, only in bit or octet strings
  44058. if (state.contains && (state.tag === 'octstr' || state.tag === 'bitstr')) {
  44059. var data = new DecoderBuffer(result);
  44060. result = this._getUse(state.contains, input._reporterState.obj)._decode(data);
  44061. }
  44062. }
  44063. // Pop object
  44064. if (state.obj && present)
  44065. result = input.leaveObject(prevObj);
  44066. // Set key
  44067. if (state.key !== null && (result !== null || present === true))
  44068. input.leaveKey(prevKey, state.key, result);
  44069. return result;
  44070. };
  44071. Node.prototype._decodeGeneric = function decodeGeneric(tag, input) {
  44072. var state = this._baseState;
  44073. if (tag === 'seq' || tag === 'set')
  44074. return null;
  44075. if (tag === 'seqof' || tag === 'setof')
  44076. return this._decodeList(input, tag, state.args[0]);
  44077. else if (/str$/.test(tag))
  44078. return this._decodeStr(input, tag);
  44079. else if (tag === 'objid' && state.args)
  44080. return this._decodeObjid(input, state.args[0], state.args[1]);
  44081. else if (tag === 'objid')
  44082. return this._decodeObjid(input, null, null);
  44083. else if (tag === 'gentime' || tag === 'utctime')
  44084. return this._decodeTime(input, tag);
  44085. else if (tag === 'null_')
  44086. return this._decodeNull(input);
  44087. else if (tag === 'bool')
  44088. return this._decodeBool(input);
  44089. else if (tag === 'int' || tag === 'enum')
  44090. return this._decodeInt(input, state.args && state.args[0]);
  44091. else if (state.use !== null)
  44092. return this._getUse(state.use, input._reporterState.obj)._decode(input);
  44093. else
  44094. return input.error('unknown tag: ' + tag);
  44095. };
  44096. Node.prototype._getUse = function _getUse(entity, obj) {
  44097. var state = this._baseState;
  44098. // Create altered use decoder if implicit is set
  44099. state.useDecoder = this._use(entity, obj);
  44100. assert(state.useDecoder._baseState.parent === null);
  44101. state.useDecoder = state.useDecoder._baseState.children[0];
  44102. if (state.implicit !== state.useDecoder._baseState.implicit) {
  44103. state.useDecoder = state.useDecoder.clone();
  44104. state.useDecoder._baseState.implicit = state.implicit;
  44105. }
  44106. return state.useDecoder;
  44107. };
  44108. Node.prototype._decodeChoice = function decodeChoice(input) {
  44109. var state = this._baseState;
  44110. var result = null;
  44111. var match = false;
  44112. Object.keys(state.choice).some(function(key) {
  44113. var save = input.save();
  44114. var node = state.choice[key];
  44115. try {
  44116. var value = node._decode(input);
  44117. if (input.isError(value))
  44118. return false;
  44119. result = { type: key, value: value };
  44120. match = true;
  44121. } catch (e) {
  44122. input.restore(save);
  44123. return false;
  44124. }
  44125. return true;
  44126. }, this);
  44127. if (!match)
  44128. return input.error('Choice not matched');
  44129. return result;
  44130. };
  44131. //
  44132. // Encoding
  44133. //
  44134. Node.prototype._createEncoderBuffer = function createEncoderBuffer(data) {
  44135. return new EncoderBuffer(data, this.reporter);
  44136. };
  44137. Node.prototype._encode = function encode(data, reporter, parent) {
  44138. var state = this._baseState;
  44139. if (state['default'] !== null && state['default'] === data)
  44140. return;
  44141. var result = this._encodeValue(data, reporter, parent);
  44142. if (result === undefined)
  44143. return;
  44144. if (this._skipDefault(result, reporter, parent))
  44145. return;
  44146. return result;
  44147. };
  44148. Node.prototype._encodeValue = function encode(data, reporter, parent) {
  44149. var state = this._baseState;
  44150. // Decode root node
  44151. if (state.parent === null)
  44152. return state.children[0]._encode(data, reporter || new Reporter());
  44153. var result = null;
  44154. // Set reporter to share it with a child class
  44155. this.reporter = reporter;
  44156. // Check if data is there
  44157. if (state.optional && data === undefined) {
  44158. if (state['default'] !== null)
  44159. data = state['default']
  44160. else
  44161. return;
  44162. }
  44163. // Encode children first
  44164. var content = null;
  44165. var primitive = false;
  44166. if (state.any) {
  44167. // Anything that was given is translated to buffer
  44168. result = this._createEncoderBuffer(data);
  44169. } else if (state.choice) {
  44170. result = this._encodeChoice(data, reporter);
  44171. } else if (state.contains) {
  44172. content = this._getUse(state.contains, parent)._encode(data, reporter);
  44173. primitive = true;
  44174. } else if (state.children) {
  44175. content = state.children.map(function(child) {
  44176. if (child._baseState.tag === 'null_')
  44177. return child._encode(null, reporter, data);
  44178. if (child._baseState.key === null)
  44179. return reporter.error('Child should have a key');
  44180. var prevKey = reporter.enterKey(child._baseState.key);
  44181. if (typeof data !== 'object')
  44182. return reporter.error('Child expected, but input is not object');
  44183. var res = child._encode(data[child._baseState.key], reporter, data);
  44184. reporter.leaveKey(prevKey);
  44185. return res;
  44186. }, this).filter(function(child) {
  44187. return child;
  44188. });
  44189. content = this._createEncoderBuffer(content);
  44190. } else {
  44191. if (state.tag === 'seqof' || state.tag === 'setof') {
  44192. // TODO(indutny): this should be thrown on DSL level
  44193. if (!(state.args && state.args.length === 1))
  44194. return reporter.error('Too many args for : ' + state.tag);
  44195. if (!Array.isArray(data))
  44196. return reporter.error('seqof/setof, but data is not Array');
  44197. var child = this.clone();
  44198. child._baseState.implicit = null;
  44199. content = this._createEncoderBuffer(data.map(function(item) {
  44200. var state = this._baseState;
  44201. return this._getUse(state.args[0], data)._encode(item, reporter);
  44202. }, child));
  44203. } else if (state.use !== null) {
  44204. result = this._getUse(state.use, parent)._encode(data, reporter);
  44205. } else {
  44206. content = this._encodePrimitive(state.tag, data);
  44207. primitive = true;
  44208. }
  44209. }
  44210. // Encode data itself
  44211. var result;
  44212. if (!state.any && state.choice === null) {
  44213. var tag = state.implicit !== null ? state.implicit : state.tag;
  44214. var cls = state.implicit === null ? 'universal' : 'context';
  44215. if (tag === null) {
  44216. if (state.use === null)
  44217. reporter.error('Tag could be ommited only for .use()');
  44218. } else {
  44219. if (state.use === null)
  44220. result = this._encodeComposite(tag, primitive, cls, content);
  44221. }
  44222. }
  44223. // Wrap in explicit
  44224. if (state.explicit !== null)
  44225. result = this._encodeComposite(state.explicit, false, 'context', result);
  44226. return result;
  44227. };
  44228. Node.prototype._encodeChoice = function encodeChoice(data, reporter) {
  44229. var state = this._baseState;
  44230. var node = state.choice[data.type];
  44231. if (!node) {
  44232. assert(
  44233. false,
  44234. data.type + ' not found in ' +
  44235. JSON.stringify(Object.keys(state.choice)));
  44236. }
  44237. return node._encode(data.value, reporter);
  44238. };
  44239. Node.prototype._encodePrimitive = function encodePrimitive(tag, data) {
  44240. var state = this._baseState;
  44241. if (/str$/.test(tag))
  44242. return this._encodeStr(data, tag);
  44243. else if (tag === 'objid' && state.args)
  44244. return this._encodeObjid(data, state.reverseArgs[0], state.args[1]);
  44245. else if (tag === 'objid')
  44246. return this._encodeObjid(data, null, null);
  44247. else if (tag === 'gentime' || tag === 'utctime')
  44248. return this._encodeTime(data, tag);
  44249. else if (tag === 'null_')
  44250. return this._encodeNull();
  44251. else if (tag === 'int' || tag === 'enum')
  44252. return this._encodeInt(data, state.args && state.reverseArgs[0]);
  44253. else if (tag === 'bool')
  44254. return this._encodeBool(data);
  44255. else
  44256. throw new Error('Unsupported tag: ' + tag);
  44257. };
  44258. Node.prototype._isNumstr = function isNumstr(str) {
  44259. return /^[0-9 ]*$/.test(str);
  44260. };
  44261. Node.prototype._isPrintstr = function isPrintstr(str) {
  44262. return /^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(str);
  44263. };
  44264. /***/ },
  44265. /* 237 */
  44266. /***/ function(module, exports, __webpack_require__) {
  44267. var inherits = __webpack_require__(2);
  44268. function Reporter(options) {
  44269. this._reporterState = {
  44270. obj: null,
  44271. path: [],
  44272. options: options || {},
  44273. errors: []
  44274. };
  44275. }
  44276. exports.Reporter = Reporter;
  44277. Reporter.prototype.isError = function isError(obj) {
  44278. return obj instanceof ReporterError;
  44279. };
  44280. Reporter.prototype.save = function save() {
  44281. var state = this._reporterState;
  44282. return { obj: state.obj, pathLen: state.path.length };
  44283. };
  44284. Reporter.prototype.restore = function restore(data) {
  44285. var state = this._reporterState;
  44286. state.obj = data.obj;
  44287. state.path = state.path.slice(0, data.pathLen);
  44288. };
  44289. Reporter.prototype.enterKey = function enterKey(key) {
  44290. return this._reporterState.path.push(key);
  44291. };
  44292. Reporter.prototype.leaveKey = function leaveKey(index, key, value) {
  44293. var state = this._reporterState;
  44294. state.path = state.path.slice(0, index - 1);
  44295. if (state.obj !== null)
  44296. state.obj[key] = value;
  44297. };
  44298. Reporter.prototype.enterObject = function enterObject() {
  44299. var state = this._reporterState;
  44300. var prev = state.obj;
  44301. state.obj = {};
  44302. return prev;
  44303. };
  44304. Reporter.prototype.leaveObject = function leaveObject(prev) {
  44305. var state = this._reporterState;
  44306. var now = state.obj;
  44307. state.obj = prev;
  44308. return now;
  44309. };
  44310. Reporter.prototype.error = function error(msg) {
  44311. var err;
  44312. var state = this._reporterState;
  44313. var inherited = msg instanceof ReporterError;
  44314. if (inherited) {
  44315. err = msg;
  44316. } else {
  44317. err = new ReporterError(state.path.map(function(elem) {
  44318. return '[' + JSON.stringify(elem) + ']';
  44319. }).join(''), msg.message || msg, msg.stack);
  44320. }
  44321. if (!state.options.partial)
  44322. throw err;
  44323. if (!inherited)
  44324. state.errors.push(err);
  44325. return err;
  44326. };
  44327. Reporter.prototype.wrapResult = function wrapResult(result) {
  44328. var state = this._reporterState;
  44329. if (!state.options.partial)
  44330. return result;
  44331. return {
  44332. result: this.isError(result) ? null : result,
  44333. errors: state.errors
  44334. };
  44335. };
  44336. function ReporterError(path, msg) {
  44337. this.path = path;
  44338. this.rethrow(msg);
  44339. };
  44340. inherits(ReporterError, Error);
  44341. ReporterError.prototype.rethrow = function rethrow(msg) {
  44342. this.message = msg + ' at: ' + (this.path || '(shallow)');
  44343. if (Error.captureStackTrace)
  44344. Error.captureStackTrace(this, ReporterError);
  44345. if (!this.stack) {
  44346. try {
  44347. // IE only adds stack when thrown
  44348. throw new Error(this.message);
  44349. } catch (e) {
  44350. this.stack = e.stack;
  44351. }
  44352. }
  44353. return this;
  44354. };
  44355. /***/ },
  44356. /* 238 */
  44357. /***/ function(module, exports, __webpack_require__) {
  44358. var constants = __webpack_require__(141);
  44359. exports.tagClass = {
  44360. 0: 'universal',
  44361. 1: 'application',
  44362. 2: 'context',
  44363. 3: 'private'
  44364. };
  44365. exports.tagClassByName = constants._reverse(exports.tagClass);
  44366. exports.tag = {
  44367. 0x00: 'end',
  44368. 0x01: 'bool',
  44369. 0x02: 'int',
  44370. 0x03: 'bitstr',
  44371. 0x04: 'octstr',
  44372. 0x05: 'null_',
  44373. 0x06: 'objid',
  44374. 0x07: 'objDesc',
  44375. 0x08: 'external',
  44376. 0x09: 'real',
  44377. 0x0a: 'enum',
  44378. 0x0b: 'embed',
  44379. 0x0c: 'utf8str',
  44380. 0x0d: 'relativeOid',
  44381. 0x10: 'seq',
  44382. 0x11: 'set',
  44383. 0x12: 'numstr',
  44384. 0x13: 'printstr',
  44385. 0x14: 't61str',
  44386. 0x15: 'videostr',
  44387. 0x16: 'ia5str',
  44388. 0x17: 'utctime',
  44389. 0x18: 'gentime',
  44390. 0x19: 'graphstr',
  44391. 0x1a: 'iso646str',
  44392. 0x1b: 'genstr',
  44393. 0x1c: 'unistr',
  44394. 0x1d: 'charstr',
  44395. 0x1e: 'bmpstr'
  44396. };
  44397. exports.tagByName = constants._reverse(exports.tag);
  44398. /***/ },
  44399. /* 239 */
  44400. /***/ function(module, exports, __webpack_require__) {
  44401. var decoders = exports;
  44402. decoders.der = __webpack_require__(142);
  44403. decoders.pem = __webpack_require__(240);
  44404. /***/ },
  44405. /* 240 */
  44406. /***/ function(module, exports, __webpack_require__) {
  44407. var inherits = __webpack_require__(2);
  44408. var Buffer = __webpack_require__(1).Buffer;
  44409. var DERDecoder = __webpack_require__(142);
  44410. function PEMDecoder(entity) {
  44411. DERDecoder.call(this, entity);
  44412. this.enc = 'pem';
  44413. };
  44414. inherits(PEMDecoder, DERDecoder);
  44415. module.exports = PEMDecoder;
  44416. PEMDecoder.prototype.decode = function decode(data, options) {
  44417. var lines = data.toString().split(/[\r\n]+/g);
  44418. var label = options.label.toUpperCase();
  44419. var re = /^-----(BEGIN|END) ([^-]+)-----$/;
  44420. var start = -1;
  44421. var end = -1;
  44422. for (var i = 0; i < lines.length; i++) {
  44423. var match = lines[i].match(re);
  44424. if (match === null)
  44425. continue;
  44426. if (match[2] !== label)
  44427. continue;
  44428. if (start === -1) {
  44429. if (match[1] !== 'BEGIN')
  44430. break;
  44431. start = i;
  44432. } else {
  44433. if (match[1] !== 'END')
  44434. break;
  44435. end = i;
  44436. break;
  44437. }
  44438. }
  44439. if (start === -1 || end === -1)
  44440. throw new Error('PEM section not found for: ' + label);
  44441. var base64 = lines.slice(start + 1, end).join('');
  44442. // Remove excessive symbols
  44443. base64.replace(/[^a-z0-9\+\/=]+/gi, '');
  44444. var input = new Buffer(base64, 'base64');
  44445. return DERDecoder.prototype.decode.call(this, input, options);
  44446. };
  44447. /***/ },
  44448. /* 241 */
  44449. /***/ function(module, exports, __webpack_require__) {
  44450. var encoders = exports;
  44451. encoders.der = __webpack_require__(143);
  44452. encoders.pem = __webpack_require__(242);
  44453. /***/ },
  44454. /* 242 */
  44455. /***/ function(module, exports, __webpack_require__) {
  44456. var inherits = __webpack_require__(2);
  44457. var DEREncoder = __webpack_require__(143);
  44458. function PEMEncoder(entity) {
  44459. DEREncoder.call(this, entity);
  44460. this.enc = 'pem';
  44461. };
  44462. inherits(PEMEncoder, DEREncoder);
  44463. module.exports = PEMEncoder;
  44464. PEMEncoder.prototype.encode = function encode(data, options) {
  44465. var buf = DEREncoder.prototype.encode.call(this, data);
  44466. var p = buf.toString('base64');
  44467. var out = [ '-----BEGIN ' + options.label + '-----' ];
  44468. for (var i = 0; i < p.length; i += 64)
  44469. out.push(p.slice(i, i + 64));
  44470. out.push('-----END ' + options.label + '-----');
  44471. return out.join('\n');
  44472. };
  44473. /***/ },
  44474. /* 243 */
  44475. /***/ function(module, exports, __webpack_require__) {
  44476. "use strict";
  44477. /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
  44478. // Declare internals
  44479. var internals = {};
  44480. exports.escapeJavaScript = function (input) {
  44481. if (!input) {
  44482. return '';
  44483. }
  44484. var escaped = '';
  44485. for (var i = 0; i < input.length; ++i) {
  44486. var charCode = input.charCodeAt(i);
  44487. if (internals.isSafe(charCode)) {
  44488. escaped += input[i];
  44489. } else {
  44490. escaped += internals.escapeJavaScriptChar(charCode);
  44491. }
  44492. }
  44493. return escaped;
  44494. };
  44495. exports.escapeHtml = function (input) {
  44496. if (!input) {
  44497. return '';
  44498. }
  44499. var escaped = '';
  44500. for (var i = 0; i < input.length; ++i) {
  44501. var charCode = input.charCodeAt(i);
  44502. if (internals.isSafe(charCode)) {
  44503. escaped += input[i];
  44504. } else {
  44505. escaped += internals.escapeHtmlChar(charCode);
  44506. }
  44507. }
  44508. return escaped;
  44509. };
  44510. internals.escapeJavaScriptChar = function (charCode) {
  44511. if (charCode >= 256) {
  44512. return '\\u' + internals.padLeft('' + charCode, 4);
  44513. }
  44514. var hexValue = new Buffer(String.fromCharCode(charCode), 'ascii').toString('hex');
  44515. return '\\x' + internals.padLeft(hexValue, 2);
  44516. };
  44517. internals.escapeHtmlChar = function (charCode) {
  44518. var namedEscape = internals.namedHtml[charCode];
  44519. if (typeof namedEscape !== 'undefined') {
  44520. return namedEscape;
  44521. }
  44522. if (charCode >= 256) {
  44523. return '&#' + charCode + ';';
  44524. }
  44525. var hexValue = new Buffer(String.fromCharCode(charCode), 'ascii').toString('hex');
  44526. return '&#x' + internals.padLeft(hexValue, 2) + ';';
  44527. };
  44528. internals.padLeft = function (str, len) {
  44529. while (str.length < len) {
  44530. str = '0' + str;
  44531. }
  44532. return str;
  44533. };
  44534. internals.isSafe = function (charCode) {
  44535. return typeof internals.safeCharCodes[charCode] !== 'undefined';
  44536. };
  44537. internals.namedHtml = {
  44538. '38': '&amp;',
  44539. '60': '&lt;',
  44540. '62': '&gt;',
  44541. '34': '&quot;',
  44542. '160': '&nbsp;',
  44543. '162': '&cent;',
  44544. '163': '&pound;',
  44545. '164': '&curren;',
  44546. '169': '&copy;',
  44547. '174': '&reg;'
  44548. };
  44549. internals.safeCharCodes = function () {
  44550. var safe = {};
  44551. for (var i = 32; i < 123; ++i) {
  44552. if (i >= 97 || // a-z
  44553. i >= 65 && i <= 90 || // A-Z
  44554. i >= 48 && i <= 57 || // 0-9
  44555. i === 32 || // space
  44556. i === 46 || // .
  44557. i === 44 || // ,
  44558. i === 45 || // -
  44559. i === 58 || // :
  44560. i === 95) {
  44561. // _
  44562. safe[i] = null;
  44563. }
  44564. }
  44565. return safe;
  44566. }();
  44567. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  44568. /***/ },
  44569. /* 244 */
  44570. /***/ function(module, exports, __webpack_require__) {
  44571. "use strict";
  44572. 'use strict';
  44573. var multihashing = __webpack_require__(205);
  44574. exports = module.exports;
  44575. // Hash is the global IPFS hash function. uses multihash SHA2_256, 256 bits
  44576. exports.hash = function (data) {
  44577. return multihashing(data, 'sha2-256');
  44578. };
  44579. /***/ },
  44580. /* 245 */
  44581. /***/ function(module, exports, __webpack_require__) {
  44582. "use strict";
  44583. 'use strict';
  44584. var _createClass = function () {
  44585. function defineProperties(target, props) {
  44586. for (var i = 0; i < props.length; i++) {
  44587. 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);
  44588. }
  44589. }return function (Constructor, protoProps, staticProps) {
  44590. if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;
  44591. };
  44592. }();
  44593. function _classCallCheck(instance, Constructor) {
  44594. if (!(instance instanceof Constructor)) {
  44595. throw new TypeError("Cannot call a class as a function");
  44596. }
  44597. }
  44598. var Block = __webpack_require__(147);
  44599. // Batch is to defer writes
  44600. module.exports = function () {
  44601. function Batch(ds, max) {
  44602. _classCallCheck(this, Batch);
  44603. if (!ds) {
  44604. throw Error('Invalid DAG Service');
  44605. }
  44606. this.dagService = ds;
  44607. this.blocks = [];
  44608. this.size = 0;
  44609. this.maxSize = max || 0;
  44610. }
  44611. _createClass(Batch, [{
  44612. key: 'add',
  44613. value: function add(node, cb) {
  44614. if (!node) {
  44615. return cb('Node is invalid');
  44616. }
  44617. var data = node.encoded();
  44618. if (!data) {
  44619. return cb('Node is unencoded');
  44620. }
  44621. this.size += data.length;
  44622. var block = new Block(data);
  44623. this.blocks.push(block);
  44624. if (this.size > this.maxSize) {
  44625. this.commit(cb, block.key);
  44626. } else {
  44627. cb(null, block.key);
  44628. }
  44629. }
  44630. }, {
  44631. key: 'commit',
  44632. value: function commit(cb, key) {
  44633. var _this = this;
  44634. this.dagService.blocks().addBlocks(this.blocks, function (err) {
  44635. if (err) {
  44636. return cb(err);
  44637. }
  44638. _this.blocks = [];
  44639. _this.size = 0;
  44640. cb(null, key);
  44641. });
  44642. }
  44643. }]);
  44644. return Batch;
  44645. }();
  44646. /***/ },
  44647. /* 246 */
  44648. /***/ function(module, exports, __webpack_require__) {
  44649. "use strict";
  44650. /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
  44651. var _createClass = function () {
  44652. function defineProperties(target, props) {
  44653. for (var i = 0; i < props.length; i++) {
  44654. 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);
  44655. }
  44656. }return function (Constructor, protoProps, staticProps) {
  44657. if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;
  44658. };
  44659. }();
  44660. function _classCallCheck(instance, Constructor) {
  44661. if (!(instance instanceof Constructor)) {
  44662. throw new TypeError("Cannot call a class as a function");
  44663. }
  44664. }
  44665. var Block = __webpack_require__(147);
  44666. var isIPFS = __webpack_require__(201);
  44667. var base58 = __webpack_require__(56);
  44668. var DAGNode = __webpack_require__(149);
  44669. module.exports = function () {
  44670. function DAGService(blockService) {
  44671. _classCallCheck(this, DAGService);
  44672. if (!blockService) {
  44673. throw new Error('DAGService requires a BlockService instance');
  44674. }
  44675. this.bs = blockService;
  44676. }
  44677. // add a DAGNode to the service, storing it on the block service
  44678. _createClass(DAGService, [{
  44679. key: 'add',
  44680. value: function add(node, callback) {
  44681. this.bs.addBlock(new Block(node.encoded()), callback);
  44682. }
  44683. // DEPRECATED - https://github.com/ipfs/go-ipfs/issues/2262
  44684. // this.addRecursive
  44685. // get retrieves a DAGNode, using the Block Service
  44686. }, {
  44687. key: 'get',
  44688. value: function get(multihash, callback) {
  44689. var isMhash = isIPFS.multihash(multihash);
  44690. var isPath = isIPFS.path(multihash);
  44691. if (!isMhash && !isPath) {
  44692. return callback(new Error('Invalid Key'));
  44693. }
  44694. if (isMhash) {
  44695. this.getWith(multihash, callback);
  44696. }
  44697. if (isPath) {
  44698. var ipfsKey = multihash.replace('/ipfs/', '');
  44699. this.getWith(ipfsKey, callback);
  44700. }
  44701. }
  44702. }, {
  44703. key: 'getWith',
  44704. value: function getWith(key, callback) {
  44705. var formatted = typeof key === 'string' ? new Buffer(base58.decode(key)) : key;
  44706. this.bs.getBlock(formatted, function (err, block) {
  44707. if (err) {
  44708. return callback(err);
  44709. }
  44710. var node = new DAGNode();
  44711. node.unMarshal(block.data);
  44712. return callback(null, node);
  44713. });
  44714. }
  44715. // getRecursive fetches a node and all of the nodes on its links recursively
  44716. // TODO add depth param
  44717. }, {
  44718. key: 'getRecursive',
  44719. value: function getRecursive(multihash, callback, linkStack, nodeStack) {
  44720. var _this = this;
  44721. this.get(multihash, function (err, node) {
  44722. if (err && nodeStack.length > 0) {
  44723. return callback(new Error('Could not complete the recursive get'), nodeStack);
  44724. }
  44725. if (err) {
  44726. return callback(err);
  44727. }
  44728. if (!linkStack) {
  44729. linkStack = [];
  44730. }
  44731. if (!nodeStack) {
  44732. nodeStack = [];
  44733. }
  44734. nodeStack.push(node);
  44735. var keys = node.links.map(function (link) {
  44736. return link.hash;
  44737. });
  44738. linkStack = linkStack.concat(keys);
  44739. var next = linkStack.pop();
  44740. if (next) {
  44741. _this.getRecursive(next, callback, linkStack, nodeStack);
  44742. } else {
  44743. var compare = function compare(hash) {
  44744. return function (node) {
  44745. node.multihash().equals(hash);
  44746. };
  44747. };
  44748. var link = void 0;
  44749. for (var k = 0; k < nodeStack.length; k++) {
  44750. var current = nodeStack[k];
  44751. for (var j = 0; j < current.links.length; j++) {
  44752. link = current.links[j];
  44753. var index = nodeStack.findIndex(compare(link.hash));
  44754. if (index !== -1) {
  44755. link.node = nodeStack[index];
  44756. }
  44757. }
  44758. }
  44759. return callback(null, nodeStack);
  44760. }
  44761. });
  44762. }
  44763. // remove deletes a node with given multihash from the blockService
  44764. }, {
  44765. key: 'remove',
  44766. value: function remove(multihash, cb) {
  44767. if (!multihash) {
  44768. return cb(new Error('Invalid multihash'));
  44769. }
  44770. this.bs.deleteBlock(multihash, cb);
  44771. }
  44772. // DEPRECATED - https://github.com/ipfs/go-ipfs/issues/2262
  44773. // this.removeRecursive = (key, callback) => { }
  44774. }]);
  44775. return DAGService;
  44776. }();
  44777. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  44778. /***/ },
  44779. /* 247 */
  44780. /***/ function(module, exports, __webpack_require__) {
  44781. "use strict";
  44782. 'use strict';
  44783. var Stringify = __webpack_require__(249);
  44784. var Parse = __webpack_require__(248);
  44785. module.exports = {
  44786. stringify: Stringify,
  44787. parse: Parse
  44788. };
  44789. /***/ },
  44790. /* 248 */
  44791. /***/ function(module, exports, __webpack_require__) {
  44792. "use strict";
  44793. 'use strict';
  44794. var Utils = __webpack_require__(151);
  44795. var defaults = {
  44796. delimiter: '&',
  44797. depth: 5,
  44798. arrayLimit: 20,
  44799. parameterLimit: 1000,
  44800. strictNullHandling: false,
  44801. plainObjects: false,
  44802. allowPrototypes: false,
  44803. allowDots: false,
  44804. decoder: Utils.decode
  44805. };
  44806. var parseValues = function parseValues(str, options) {
  44807. var obj = {};
  44808. var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit);
  44809. for (var i = 0; i < parts.length; ++i) {
  44810. var part = parts[i];
  44811. var pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1;
  44812. if (pos === -1) {
  44813. obj[options.decoder(part)] = '';
  44814. if (options.strictNullHandling) {
  44815. obj[options.decoder(part)] = null;
  44816. }
  44817. } else {
  44818. var key = options.decoder(part.slice(0, pos));
  44819. var val = options.decoder(part.slice(pos + 1));
  44820. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  44821. obj[key] = [].concat(obj[key]).concat(val);
  44822. } else {
  44823. obj[key] = val;
  44824. }
  44825. }
  44826. }
  44827. return obj;
  44828. };
  44829. var parseObject = function parseObject(chain, val, options) {
  44830. if (!chain.length) {
  44831. return val;
  44832. }
  44833. var root = chain.shift();
  44834. var obj;
  44835. if (root === '[]') {
  44836. obj = [];
  44837. obj = obj.concat(parseObject(chain, val, options));
  44838. } else {
  44839. obj = options.plainObjects ? Object.create(null) : {};
  44840. var cleanRoot = root[0] === '[' && root[root.length - 1] === ']' ? root.slice(1, root.length - 1) : root;
  44841. var index = parseInt(cleanRoot, 10);
  44842. if (!isNaN(index) && root !== cleanRoot && String(index) === cleanRoot && index >= 0 && options.parseArrays && index <= options.arrayLimit) {
  44843. obj = [];
  44844. obj[index] = parseObject(chain, val, options);
  44845. } else {
  44846. obj[cleanRoot] = parseObject(chain, val, options);
  44847. }
  44848. }
  44849. return obj;
  44850. };
  44851. var parseKeys = function parseKeys(givenKey, val, options) {
  44852. if (!givenKey) {
  44853. return;
  44854. }
  44855. // Transform dot notation to bracket notation
  44856. var key = options.allowDots ? givenKey.replace(/\.([^\.\[]+)/g, '[$1]') : givenKey;
  44857. // The regex chunks
  44858. var parent = /^([^\[\]]*)/;
  44859. var child = /(\[[^\[\]]*\])/g;
  44860. // Get the parent
  44861. var segment = parent.exec(key);
  44862. // Stash the parent if it exists
  44863. var keys = [];
  44864. if (segment[1]) {
  44865. // If we aren't using plain objects, optionally prefix keys
  44866. // that would overwrite object prototype properties
  44867. if (!options.plainObjects && Object.prototype.hasOwnProperty(segment[1])) {
  44868. if (!options.allowPrototypes) {
  44869. return;
  44870. }
  44871. }
  44872. keys.push(segment[1]);
  44873. }
  44874. // Loop through children appending to the array until we hit depth
  44875. var i = 0;
  44876. while ((segment = child.exec(key)) !== null && i < options.depth) {
  44877. i += 1;
  44878. if (!options.plainObjects && Object.prototype.hasOwnProperty(segment[1].replace(/\[|\]/g, ''))) {
  44879. if (!options.allowPrototypes) {
  44880. continue;
  44881. }
  44882. }
  44883. keys.push(segment[1]);
  44884. }
  44885. // If there's a remainder, just add whatever is left
  44886. if (segment) {
  44887. keys.push('[' + key.slice(segment.index) + ']');
  44888. }
  44889. return parseObject(keys, val, options);
  44890. };
  44891. module.exports = function (str, opts) {
  44892. var options = opts || {};
  44893. if (options.decoder !== null && options.decoder !== undefined && typeof options.decoder !== 'function') {
  44894. throw new TypeError('Decoder has to be a function.');
  44895. }
  44896. options.delimiter = typeof options.delimiter === 'string' || Utils.isRegExp(options.delimiter) ? options.delimiter : defaults.delimiter;
  44897. options.depth = typeof options.depth === 'number' ? options.depth : defaults.depth;
  44898. options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : defaults.arrayLimit;
  44899. options.parseArrays = options.parseArrays !== false;
  44900. options.decoder = typeof options.decoder === 'function' ? options.decoder : defaults.decoder;
  44901. options.allowDots = typeof options.allowDots === 'boolean' ? options.allowDots : defaults.allowDots;
  44902. options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : defaults.plainObjects;
  44903. options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : defaults.allowPrototypes;
  44904. options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : defaults.parameterLimit;
  44905. options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling;
  44906. if (str === '' || str === null || typeof str === 'undefined') {
  44907. return options.plainObjects ? Object.create(null) : {};
  44908. }
  44909. var tempObj = typeof str === 'string' ? parseValues(str, options) : str;
  44910. var obj = options.plainObjects ? Object.create(null) : {};
  44911. // Iterate over the keys and setup the new object
  44912. var keys = Object.keys(tempObj);
  44913. for (var i = 0; i < keys.length; ++i) {
  44914. var key = keys[i];
  44915. var newObj = parseKeys(key, tempObj[key], options);
  44916. obj = Utils.merge(obj, newObj, options);
  44917. }
  44918. return Utils.compact(obj);
  44919. };
  44920. /***/ },
  44921. /* 249 */
  44922. /***/ function(module, exports, __webpack_require__) {
  44923. "use strict";
  44924. 'use strict';
  44925. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
  44926. var Utils = __webpack_require__(151);
  44927. var arrayPrefixGenerators = {
  44928. brackets: function brackets(prefix) {
  44929. return prefix + '[]';
  44930. },
  44931. indices: function indices(prefix, key) {
  44932. return prefix + '[' + key + ']';
  44933. },
  44934. repeat: function repeat(prefix) {
  44935. return prefix;
  44936. }
  44937. };
  44938. var defaults = {
  44939. delimiter: '&',
  44940. strictNullHandling: false,
  44941. skipNulls: false,
  44942. encode: true,
  44943. encoder: Utils.encode
  44944. };
  44945. var stringify = function stringify(object, prefix, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots) {
  44946. var obj = object;
  44947. if (typeof filter === 'function') {
  44948. obj = filter(prefix, obj);
  44949. } else if (obj instanceof Date) {
  44950. obj = obj.toISOString();
  44951. } else if (obj === null) {
  44952. if (strictNullHandling) {
  44953. return encoder ? encoder(prefix) : prefix;
  44954. }
  44955. obj = '';
  44956. }
  44957. if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || Utils.isBuffer(obj)) {
  44958. if (encoder) {
  44959. return [encoder(prefix) + '=' + encoder(obj)];
  44960. }
  44961. return [prefix + '=' + String(obj)];
  44962. }
  44963. var values = [];
  44964. if (typeof obj === 'undefined') {
  44965. return values;
  44966. }
  44967. var objKeys;
  44968. if (Array.isArray(filter)) {
  44969. objKeys = filter;
  44970. } else {
  44971. var keys = Object.keys(obj);
  44972. objKeys = sort ? keys.sort(sort) : keys;
  44973. }
  44974. for (var i = 0; i < objKeys.length; ++i) {
  44975. var key = objKeys[i];
  44976. if (skipNulls && obj[key] === null) {
  44977. continue;
  44978. }
  44979. if (Array.isArray(obj)) {
  44980. values = values.concat(stringify(obj[key], generateArrayPrefix(prefix, key), generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots));
  44981. } else {
  44982. values = values.concat(stringify(obj[key], prefix + (allowDots ? '.' + key : '[' + key + ']'), generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots));
  44983. }
  44984. }
  44985. return values;
  44986. };
  44987. module.exports = function (object, opts) {
  44988. var obj = object;
  44989. var options = opts || {};
  44990. var delimiter = typeof options.delimiter === 'undefined' ? defaults.delimiter : options.delimiter;
  44991. var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling;
  44992. var skipNulls = typeof options.skipNulls === 'boolean' ? options.skipNulls : defaults.skipNulls;
  44993. var encode = typeof options.encode === 'boolean' ? options.encode : defaults.encode;
  44994. var encoder = encode ? typeof options.encoder === 'function' ? options.encoder : defaults.encoder : null;
  44995. var sort = typeof options.sort === 'function' ? options.sort : null;
  44996. var allowDots = typeof options.allowDots === 'undefined' ? false : options.allowDots;
  44997. var objKeys;
  44998. var filter;
  44999. if (options.encoder !== null && options.encoder !== undefined && typeof options.encoder !== 'function') {
  45000. throw new TypeError('Encoder has to be a function.');
  45001. }
  45002. if (typeof options.filter === 'function') {
  45003. filter = options.filter;
  45004. obj = filter('', obj);
  45005. } else if (Array.isArray(options.filter)) {
  45006. objKeys = filter = options.filter;
  45007. }
  45008. var keys = [];
  45009. if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object' || obj === null) {
  45010. return '';
  45011. }
  45012. var arrayFormat;
  45013. if (options.arrayFormat in arrayPrefixGenerators) {
  45014. arrayFormat = options.arrayFormat;
  45015. } else if ('indices' in options) {
  45016. arrayFormat = options.indices ? 'indices' : 'repeat';
  45017. } else {
  45018. arrayFormat = 'indices';
  45019. }
  45020. var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];
  45021. if (!objKeys) {
  45022. objKeys = Object.keys(obj);
  45023. }
  45024. if (sort) {
  45025. objKeys.sort(sort);
  45026. }
  45027. for (var i = 0; i < objKeys.length; ++i) {
  45028. var key = objKeys[i];
  45029. if (skipNulls && obj[key] === null) {
  45030. continue;
  45031. }
  45032. keys = keys.concat(stringify(obj[key], key, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots));
  45033. }
  45034. return keys.join(delimiter);
  45035. };
  45036. /***/ },
  45037. /* 250 */
  45038. /***/ function(module, exports, __webpack_require__) {
  45039. "use strict";
  45040. /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
  45041. // Load modules
  45042. var Boom = __webpack_require__(146);
  45043. var Hoek = __webpack_require__(68);
  45044. var Stream = __webpack_require__(9);
  45045. // Declare internals
  45046. var internals = {};
  45047. module.exports = internals.Recorder = function (options) {
  45048. Stream.Writable.call(this);
  45049. this.settings = options; // No need to clone since called internally with new object
  45050. this.buffers = [];
  45051. this.length = 0;
  45052. };
  45053. Hoek.inherits(internals.Recorder, Stream.Writable);
  45054. internals.Recorder.prototype._write = function (chunk, encoding, next) {
  45055. if (this.settings.maxBytes && this.length + chunk.length > this.settings.maxBytes) {
  45056. return this.emit('error', Boom.badRequest('Payload content length greater than maximum allowed: ' + this.settings.maxBytes));
  45057. }
  45058. this.length = this.length + chunk.length;
  45059. this.buffers.push(chunk);
  45060. next();
  45061. };
  45062. internals.Recorder.prototype.collect = function () {
  45063. var buffer = this.buffers.length === 0 ? new Buffer(0) : this.buffers.length === 1 ? this.buffers[0] : Buffer.concat(this.buffers, this.length);
  45064. return buffer;
  45065. };
  45066. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  45067. /***/ },
  45068. /* 251 */
  45069. /***/ function(module, exports, __webpack_require__) {
  45070. "use strict";
  45071. 'use strict';
  45072. // Load modules
  45073. var Hoek = __webpack_require__(68);
  45074. var Stream = __webpack_require__(9);
  45075. var Payload = __webpack_require__(153);
  45076. // Declare internals
  45077. var internals = {};
  45078. module.exports = internals.Tap = function () {
  45079. Stream.Transform.call(this);
  45080. this.buffers = [];
  45081. };
  45082. Hoek.inherits(internals.Tap, Stream.Transform);
  45083. internals.Tap.prototype._transform = function (chunk, encoding, next) {
  45084. this.buffers.push(chunk);
  45085. next(null, chunk);
  45086. };
  45087. internals.Tap.prototype.collect = function () {
  45088. return new Payload(this.buffers);
  45089. };
  45090. /***/ },
  45091. /* 252 */
  45092. /***/ function(module, exports, __webpack_require__) {
  45093. "use strict";
  45094. 'use strict';
  45095. var addToDagNodesTransform = __webpack_require__(100);
  45096. module.exports = function (send) {
  45097. return function add(path, opts, cb) {
  45098. if (typeof opts === 'function' && cb === undefined) {
  45099. cb = opts;
  45100. opts = {};
  45101. }
  45102. if (typeof path !== 'string') {
  45103. return cb(new Error('"path" must be a string'));
  45104. }
  45105. var sendWithTransform = send.withTransform(addToDagNodesTransform);
  45106. return sendWithTransform('add', null, opts, path, cb);
  45107. };
  45108. };
  45109. /***/ },
  45110. /* 253 */
  45111. /***/ function(module, exports, __webpack_require__) {
  45112. "use strict";
  45113. 'use strict';
  45114. var Wreck = __webpack_require__(152);
  45115. var addToDagNodesTransform = __webpack_require__(100);
  45116. module.exports = function (send) {
  45117. return function add(url, opts, cb) {
  45118. if (typeof opts === 'function' && cb === undefined) {
  45119. cb = opts;
  45120. opts = {};
  45121. }
  45122. if (typeof url !== 'string' || !url.startsWith('http')) {
  45123. return cb(new Error('"url" param must be an http(s) url'));
  45124. }
  45125. var sendWithTransform = send.withTransform(addToDagNodesTransform);
  45126. Wreck.request('GET', url, null, function (err, res) {
  45127. if (err) return cb(err);
  45128. sendWithTransform('add', null, opts, res, cb);
  45129. });
  45130. };
  45131. };
  45132. /***/ },
  45133. /* 254 */
  45134. /***/ function(module, exports, __webpack_require__) {
  45135. "use strict";
  45136. 'use strict';
  45137. var argCommand = __webpack_require__(18).argCommand;
  45138. module.exports = function (send) {
  45139. return {
  45140. wantlist: function wantlist(cb) {
  45141. return send('bitswap/wantlist', {}, null, null, cb);
  45142. },
  45143. stat: function stat(cb) {
  45144. return send('bitswap/stat', {}, null, null, cb);
  45145. },
  45146. unwant: argCommand(send, 'bitswap/unwant')
  45147. };
  45148. };
  45149. /***/ },
  45150. /* 255 */
  45151. /***/ function(module, exports, __webpack_require__) {
  45152. "use strict";
  45153. 'use strict';
  45154. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
  45155. var argCommand = __webpack_require__(18).argCommand;
  45156. module.exports = function (send) {
  45157. return {
  45158. get: argCommand(send, 'block/get'),
  45159. stat: argCommand(send, 'block/stat'),
  45160. put: function put(file, cb) {
  45161. if (Array.isArray(file)) {
  45162. var _ret = function () {
  45163. var err = new Error('block.put() only accepts 1 file');
  45164. if (typeof cb !== 'function' && typeof Promise !== 'undefined') {
  45165. return {
  45166. v: new Promise(function (resolve, reject) {
  45167. return reject(err);
  45168. })
  45169. };
  45170. }
  45171. return {
  45172. v: cb(err)
  45173. };
  45174. }();
  45175. if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
  45176. }
  45177. return send('block/put', null, null, file, cb);
  45178. }
  45179. };
  45180. };
  45181. /***/ },
  45182. /* 256 */
  45183. /***/ function(module, exports, __webpack_require__) {
  45184. "use strict";
  45185. 'use strict';
  45186. var command = __webpack_require__(18).command;
  45187. module.exports = function (send) {
  45188. return {
  45189. add: function add(arg, opts, cb) {
  45190. if (typeof opts === 'function' && cb === undefined) {
  45191. cb = opts;
  45192. opts = {};
  45193. }
  45194. return send('bootstrap/add', arg, opts, null, cb);
  45195. },
  45196. rm: function rm(arg, opts, cb) {
  45197. if (typeof opts === 'function' && cb === undefined) {
  45198. cb = opts;
  45199. opts = {};
  45200. }
  45201. return send('bootstrap/rm', arg, opts, null, cb);
  45202. },
  45203. list: command(send, 'bootstrap/list')
  45204. };
  45205. };
  45206. /***/ },
  45207. /* 257 */
  45208. /***/ function(module, exports, __webpack_require__) {
  45209. "use strict";
  45210. /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
  45211. var bs58 = __webpack_require__(56);
  45212. var isIPFS = __webpack_require__(201);
  45213. var promisify = __webpack_require__(78);
  45214. module.exports = function (send) {
  45215. var cat = promisify(function (multihash, callback) {
  45216. try {
  45217. multihash = cleanMultihash(multihash);
  45218. } catch (err) {
  45219. return callback(err);
  45220. }
  45221. send('cat', multihash, null, null, callback);
  45222. });
  45223. return cat;
  45224. };
  45225. function cleanMultihash(multihash) {
  45226. if (!isIPFS.multihash(multihash)) {
  45227. throw new Error('not valid multihash');
  45228. }
  45229. if (Buffer.isBuffer(multihash)) {
  45230. return bs58.encode(multihash);
  45231. }
  45232. return multihash;
  45233. }
  45234. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  45235. /***/ },
  45236. /* 258 */
  45237. /***/ function(module, exports, __webpack_require__) {
  45238. "use strict";
  45239. 'use strict';
  45240. var command = __webpack_require__(18).command;
  45241. module.exports = function (send) {
  45242. return command(send, 'commands');
  45243. };
  45244. /***/ },
  45245. /* 259 */
  45246. /***/ function(module, exports, __webpack_require__) {
  45247. "use strict";
  45248. 'use strict';
  45249. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
  45250. var argCommand = __webpack_require__(18).argCommand;
  45251. module.exports = function (send) {
  45252. return {
  45253. get: argCommand(send, 'config'),
  45254. set: function set(key, value, opts, cb) {
  45255. if (typeof opts === 'function') {
  45256. cb = opts;
  45257. opts = {};
  45258. }
  45259. if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') {
  45260. value = JSON.stringify(value);
  45261. opts = { json: true };
  45262. } else if (typeof value === 'boolean') {
  45263. value = value.toString();
  45264. opts = { bool: true };
  45265. }
  45266. return send('config', [key, value], opts, null, cb);
  45267. },
  45268. show: function show(cb) {
  45269. return send('config/show', null, null, null, true, cb);
  45270. },
  45271. replace: function replace(file, cb) {
  45272. return send('config/replace', null, null, file, cb);
  45273. }
  45274. };
  45275. };
  45276. /***/ },
  45277. /* 260 */
  45278. /***/ function(module, exports, __webpack_require__) {
  45279. "use strict";
  45280. 'use strict';
  45281. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
  45282. var argCommand = __webpack_require__(18).argCommand;
  45283. module.exports = function (send) {
  45284. return {
  45285. findprovs: argCommand(send, 'dht/findprovs'),
  45286. get: function get(key, opts, cb) {
  45287. if (typeof opts === 'function' && !cb) {
  45288. cb = opts;
  45289. opts = null;
  45290. }
  45291. var handleResult = function handleResult(done, err, res) {
  45292. if (err) return done(err);
  45293. if (!res) return done(new Error('empty response'));
  45294. if (res.length === 0) return done(new Error('no value returned for key'));
  45295. // Inconsistent return values in the browser vs node
  45296. if (Array.isArray(res)) {
  45297. res = res[0];
  45298. }
  45299. if (res.Type === 5) {
  45300. done(null, res.Extra);
  45301. } else {
  45302. var error = new Error('key was not found (type 6)');
  45303. done(error);
  45304. }
  45305. };
  45306. if (typeof cb !== 'function' && typeof Promise !== 'undefined') {
  45307. var _ret = function () {
  45308. var done = function done(err, res) {
  45309. if (err) throw err;
  45310. return res;
  45311. };
  45312. return {
  45313. v: send('dht/get', key, opts).then(function (res) {
  45314. return handleResult(done, null, res);
  45315. }, function (err) {
  45316. return handleResult(done, err);
  45317. })
  45318. };
  45319. }();
  45320. if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
  45321. }
  45322. return send('dht/get', key, opts, null, handleResult.bind(null, cb));
  45323. },
  45324. put: function put(key, value, opts, cb) {
  45325. if (typeof opts === 'function' && !cb) {
  45326. cb = opts;
  45327. opts = null;
  45328. }
  45329. return send('dht/put', [key, value], opts, null, cb);
  45330. }
  45331. };
  45332. };
  45333. /***/ },
  45334. /* 261 */
  45335. /***/ function(module, exports, __webpack_require__) {
  45336. "use strict";
  45337. 'use strict';
  45338. var command = __webpack_require__(18).command;
  45339. module.exports = function (send) {
  45340. return {
  45341. net: command(send, 'diag/net'),
  45342. sys: command(send, 'diag/sys'),
  45343. cmds: command(send, 'diag/sys')
  45344. };
  45345. };
  45346. /***/ },
  45347. /* 262 */
  45348. /***/ function(module, exports, __webpack_require__) {
  45349. "use strict";
  45350. 'use strict';
  45351. var argCommand = __webpack_require__(18).argCommand;
  45352. module.exports = function (send) {
  45353. return {
  45354. cp: argCommand(send, 'files/cp'),
  45355. ls: argCommand(send, 'files/ls'),
  45356. mkdir: argCommand(send, 'files/mkdir'),
  45357. stat: argCommand(send, 'files/stat'),
  45358. rm: function rm(path, opts, cb) {
  45359. if (typeof opts === 'function' && cb === undefined) {
  45360. cb = opts;
  45361. opts = {};
  45362. }
  45363. return send('files/rm', path, opts, null, cb);
  45364. },
  45365. read: argCommand(send, 'files/read'),
  45366. write: function write(pathDst, files, opts, cb) {
  45367. if (typeof opts === 'function' && cb === undefined) {
  45368. cb = opts;
  45369. opts = {};
  45370. }
  45371. return send('files/write', pathDst, opts, files, cb);
  45372. },
  45373. mv: argCommand(send, 'files/mv')
  45374. };
  45375. };
  45376. /***/ },
  45377. /* 263 */
  45378. /***/ function(module, exports) {
  45379. "use strict";
  45380. 'use strict';
  45381. module.exports = function (send) {
  45382. return function id(idParam, cb) {
  45383. if (typeof idParam === 'function') {
  45384. cb = idParam;
  45385. idParam = null;
  45386. }
  45387. return send('id', idParam, null, null, cb);
  45388. };
  45389. };
  45390. /***/ },
  45391. /* 264 */
  45392. /***/ function(module, exports, __webpack_require__) {
  45393. "use strict";
  45394. 'use strict';
  45395. var ndjson = __webpack_require__(206);
  45396. module.exports = function (send) {
  45397. return {
  45398. tail: function tail(cb) {
  45399. if (typeof cb !== 'function' && typeof Promise !== 'undefined') {
  45400. return send('log/tail', null, {}, null, false).then(function (res) {
  45401. return res.pipe(ndjson.parse());
  45402. });
  45403. }
  45404. return send('log/tail', null, {}, null, false, function (err, res) {
  45405. if (err) return cb(err);
  45406. cb(null, res.pipe(ndjson.parse()));
  45407. });
  45408. }
  45409. };
  45410. };
  45411. /***/ },
  45412. /* 265 */
  45413. /***/ function(module, exports, __webpack_require__) {
  45414. "use strict";
  45415. 'use strict';
  45416. var argCommand = __webpack_require__(18).argCommand;
  45417. module.exports = function (send) {
  45418. return argCommand(send, 'ls');
  45419. };
  45420. /***/ },
  45421. /* 266 */
  45422. /***/ function(module, exports) {
  45423. "use strict";
  45424. 'use strict';
  45425. module.exports = function (send) {
  45426. return function mount(ipfs, ipns, cb) {
  45427. if (typeof ipfs === 'function') {
  45428. cb = ipfs;
  45429. ipfs = null;
  45430. } else if (typeof ipns === 'function') {
  45431. cb = ipns;
  45432. ipns = null;
  45433. }
  45434. var opts = {};
  45435. if (ipfs) opts.f = ipfs;
  45436. if (ipns) opts.n = ipns;
  45437. return send('mount', null, opts, null, cb);
  45438. };
  45439. };
  45440. /***/ },
  45441. /* 267 */
  45442. /***/ function(module, exports, __webpack_require__) {
  45443. "use strict";
  45444. 'use strict';
  45445. var argCommand = __webpack_require__(18).argCommand;
  45446. module.exports = function (send) {
  45447. return {
  45448. publish: argCommand(send, 'name/publish'),
  45449. resolve: argCommand(send, 'name/resolve')
  45450. };
  45451. };
  45452. /***/ },
  45453. /* 268 */
  45454. /***/ function(module, exports, __webpack_require__) {
  45455. "use strict";
  45456. /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
  45457. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
  45458. var DAGNode = __webpack_require__(99).DAGNode;
  45459. var DAGLink = __webpack_require__(99).DAGLink;
  45460. var promisify = __webpack_require__(78);
  45461. var bs58 = __webpack_require__(56);
  45462. var bl = __webpack_require__(155);
  45463. module.exports = function (send) {
  45464. var api = {
  45465. get: promisify(function (multihash, options, callback) {
  45466. if (typeof options === 'function') {
  45467. callback = options;
  45468. options = {};
  45469. }
  45470. if (!options) {
  45471. options = {};
  45472. }
  45473. try {
  45474. multihash = cleanMultihash(multihash, options);
  45475. } catch (err) {
  45476. return callback(err);
  45477. }
  45478. send('object/get', multihash, null, null, function (err, result) {
  45479. if (err) {
  45480. return callback(err);
  45481. }
  45482. var node = new DAGNode(result.Data, result.Links.map(function (l) {
  45483. return new DAGLink(l.Name, l.Size, new Buffer(bs58.decode(l.Hash)));
  45484. }));
  45485. callback(null, node);
  45486. });
  45487. }),
  45488. put: promisify(function (obj, options, callback) {
  45489. if (typeof options === 'function') {
  45490. callback = options;
  45491. options = {};
  45492. }
  45493. if (!options) {
  45494. options = {};
  45495. }
  45496. var tmpObj = {
  45497. Data: null,
  45498. Links: []
  45499. };
  45500. if (Buffer.isBuffer(obj)) {
  45501. if (!options.enc) {
  45502. tmpObj = { Data: obj.toString(), Links: [] };
  45503. }
  45504. } else if (obj.multihash) {
  45505. tmpObj = {
  45506. Data: obj.data.toString(),
  45507. Links: obj.links.map(function (l) {
  45508. return l.toJSON();
  45509. })
  45510. };
  45511. } else if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object') {
  45512. tmpObj.Data = obj.Data.toString();
  45513. } else {
  45514. return callback(new Error('obj not recognized'));
  45515. }
  45516. var buf = void 0;
  45517. if (Buffer.isBuffer(obj) && options.enc) {
  45518. buf = obj;
  45519. } else {
  45520. buf = new Buffer(JSON.stringify(tmpObj));
  45521. }
  45522. var enc = options.enc || 'json';
  45523. send('object/put', null, { inputenc: enc }, buf, function (err, result) {
  45524. if (err) {
  45525. return callback(err);
  45526. }
  45527. if (Buffer.isBuffer(obj)) {
  45528. if (!options.enc) {
  45529. obj = { Data: obj, Links: [] };
  45530. } else if (options.enc === 'json') {
  45531. obj = JSON.parse(obj.toString());
  45532. }
  45533. }
  45534. var node = void 0;
  45535. if (obj.multihash) {
  45536. node = obj;
  45537. } else if (options.enc === 'protobuf') {
  45538. node = new DAGNode();
  45539. node.unMarshal(obj);
  45540. } else {
  45541. node = new DAGNode(obj.Data, obj.Links);
  45542. }
  45543. if (node.toJSON().Hash !== result.Hash) {
  45544. return callback(new Error('Stored object was different from constructed object'));
  45545. }
  45546. callback(null, node);
  45547. });
  45548. }),
  45549. data: promisify(function (multihash, options, callback) {
  45550. if (typeof options === 'function') {
  45551. callback = options;
  45552. options = {};
  45553. }
  45554. if (!options) {
  45555. options = {};
  45556. }
  45557. try {
  45558. multihash = cleanMultihash(multihash, options);
  45559. } catch (err) {
  45560. return callback(err);
  45561. }
  45562. send('object/data', multihash, null, null, function (err, result) {
  45563. if (err) {
  45564. return callback(err);
  45565. }
  45566. if (typeof result.pipe === 'function') {
  45567. result.pipe(bl(callback));
  45568. } else {
  45569. callback(null, result);
  45570. }
  45571. });
  45572. }),
  45573. links: promisify(function (multihash, options, callback) {
  45574. if (typeof options === 'function') {
  45575. callback = options;
  45576. options = {};
  45577. }
  45578. if (!options) {
  45579. options = {};
  45580. }
  45581. try {
  45582. multihash = cleanMultihash(multihash, options);
  45583. } catch (err) {
  45584. return callback(err);
  45585. }
  45586. send('object/links', multihash, null, null, function (err, result) {
  45587. if (err) {
  45588. return callback(err);
  45589. }
  45590. var links = [];
  45591. if (result.Links) {
  45592. links = result.Links.map(function (l) {
  45593. return new DAGLink(l.Name, l.Size, new Buffer(bs58.decode(l.Hash)));
  45594. });
  45595. }
  45596. callback(null, links);
  45597. });
  45598. }),
  45599. stat: promisify(function (multihash, options, callback) {
  45600. if (typeof options === 'function') {
  45601. callback = options;
  45602. options = {};
  45603. }
  45604. if (!options) {
  45605. options = {};
  45606. }
  45607. try {
  45608. multihash = cleanMultihash(multihash, options);
  45609. } catch (err) {
  45610. return callback(err);
  45611. }
  45612. send('object/stat', multihash, null, null, callback);
  45613. }),
  45614. new: promisify(function (callback) {
  45615. send('object/new', null, null, null, function (err, result) {
  45616. if (err) {
  45617. return callback(err);
  45618. }
  45619. var node = new DAGNode();
  45620. if (node.toJSON().Hash !== result.Hash) {
  45621. return callback(new Error('Stored object was different from constructed object'));
  45622. }
  45623. callback(null, node);
  45624. });
  45625. }),
  45626. patch: {
  45627. addLink: promisify(function (multihash, dLink, options, callback) {
  45628. if (typeof options === 'function') {
  45629. callback = options;
  45630. options = {};
  45631. }
  45632. if (!options) {
  45633. options = {};
  45634. }
  45635. try {
  45636. multihash = cleanMultihash(multihash, options);
  45637. } catch (err) {
  45638. return callback(err);
  45639. }
  45640. send('object/patch/add-link', [multihash, dLink.name, bs58.encode(dLink.hash).toString()], null, null, function (err, result) {
  45641. if (err) {
  45642. return callback(err);
  45643. }
  45644. api.get(result.Hash, { enc: 'base58' }, callback);
  45645. });
  45646. }),
  45647. rmLink: promisify(function (multihash, dLink, options, callback) {
  45648. if (typeof options === 'function') {
  45649. callback = options;
  45650. options = {};
  45651. }
  45652. if (!options) {
  45653. options = {};
  45654. }
  45655. try {
  45656. multihash = cleanMultihash(multihash, options);
  45657. } catch (err) {
  45658. return callback(err);
  45659. }
  45660. send('object/patch/rm-link', [multihash, dLink.name], null, null, function (err, result) {
  45661. if (err) {
  45662. return callback(err);
  45663. }
  45664. api.get(result.Hash, { enc: 'base58' }, callback);
  45665. });
  45666. }),
  45667. setData: promisify(function (multihash, data, options, callback) {
  45668. if (typeof options === 'function') {
  45669. callback = options;
  45670. options = {};
  45671. }
  45672. if (!options) {
  45673. options = {};
  45674. }
  45675. try {
  45676. multihash = cleanMultihash(multihash, options);
  45677. } catch (err) {
  45678. return callback(err);
  45679. }
  45680. send('object/patch/set-data', [multihash], null, data, function (err, result) {
  45681. if (err) {
  45682. return callback(err);
  45683. }
  45684. api.get(result.Hash, { enc: 'base58' }, callback);
  45685. });
  45686. }),
  45687. appendData: promisify(function (multihash, data, options, callback) {
  45688. if (typeof options === 'function') {
  45689. callback = options;
  45690. options = {};
  45691. }
  45692. if (!options) {
  45693. options = {};
  45694. }
  45695. try {
  45696. multihash = cleanMultihash(multihash, options);
  45697. } catch (err) {
  45698. return callback(err);
  45699. }
  45700. send('object/patch/append-data', [multihash], null, data, function (err, result) {
  45701. if (err) {
  45702. return callback(err);
  45703. }
  45704. api.get(result.Hash, { enc: 'base58' }, callback);
  45705. });
  45706. })
  45707. }
  45708. };
  45709. return api;
  45710. };
  45711. function cleanMultihash(multihash, options) {
  45712. if (Buffer.isBuffer(multihash)) {
  45713. if (options.enc) {
  45714. switch (options.enc) {
  45715. case 'base58':
  45716. {
  45717. multihash = multihash.toString();
  45718. break;
  45719. }
  45720. default:
  45721. throw new Error('invalid multihash');
  45722. }
  45723. } else {
  45724. multihash = bs58.encode(multihash).toString();
  45725. }
  45726. } else if (typeof multihash === 'string') {
  45727. if (options.enc) {
  45728. // For the future, when we support more than one enc
  45729. // switch (options.enc) {
  45730. // case 'base58': // It is good
  45731. // }
  45732. } else {
  45733. throw new Error('not valid multihash');
  45734. }
  45735. } else if (!multihash) {
  45736. throw new Error('missing valid multihash');
  45737. }
  45738. return multihash;
  45739. }
  45740. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  45741. /***/ },
  45742. /* 269 */
  45743. /***/ function(module, exports) {
  45744. "use strict";
  45745. 'use strict';
  45746. module.exports = function (send) {
  45747. return {
  45748. add: function add(hash, opts, cb) {
  45749. if (typeof opts === 'function') {
  45750. cb = opts;
  45751. opts = null;
  45752. }
  45753. return send('pin/add', hash, opts, null, cb);
  45754. },
  45755. remove: function remove(hash, opts, cb) {
  45756. if (typeof opts === 'function') {
  45757. cb = opts;
  45758. opts = null;
  45759. }
  45760. return send('pin/rm', hash, opts, null, cb);
  45761. },
  45762. list: function list(type, cb) {
  45763. if (typeof type === 'function') {
  45764. cb = type;
  45765. type = null;
  45766. }
  45767. var opts = null;
  45768. var hash = null;
  45769. if (typeof type === 'string') {
  45770. opts = { type: type };
  45771. } else if (type && type.hash) {
  45772. hash = type.hash;
  45773. type.hash = null;
  45774. opts = type;
  45775. }
  45776. return send('pin/ls', hash, opts, null, cb);
  45777. }
  45778. };
  45779. };
  45780. /***/ },
  45781. /* 270 */
  45782. /***/ function(module, exports) {
  45783. "use strict";
  45784. 'use strict';
  45785. module.exports = function (send) {
  45786. return function ping(id, cb) {
  45787. if (typeof cb !== 'function' && typeof Promise !== 'undefined') {
  45788. return send('ping', id, { n: 1 }, null).then(function (res) {
  45789. return res[1];
  45790. });
  45791. }
  45792. return send('ping', id, { n: 1 }, null, function (err, res) {
  45793. if (err) return cb(err, null);
  45794. cb(null, res[1]);
  45795. });
  45796. };
  45797. };
  45798. /***/ },
  45799. /* 271 */
  45800. /***/ function(module, exports, __webpack_require__) {
  45801. "use strict";
  45802. 'use strict';
  45803. var cmds = __webpack_require__(18);
  45804. module.exports = function (send) {
  45805. var refs = cmds.argCommand(send, 'refs');
  45806. refs.local = cmds.command(send, 'refs/local');
  45807. return refs;
  45808. };
  45809. /***/ },
  45810. /* 272 */
  45811. /***/ function(module, exports, __webpack_require__) {
  45812. "use strict";
  45813. 'use strict';
  45814. var cmds = __webpack_require__(18);
  45815. module.exports = function (send) {
  45816. return {
  45817. peers: cmds.command(send, 'swarm/peers'),
  45818. connect: cmds.argCommand(send, 'swarm/connect'),
  45819. disconnect: cmds.argCommand(send, 'swarm/disconnect'),
  45820. addrs: cmds.command(send, 'swarm/addrs'),
  45821. localAddrs: cmds.command(send, 'swarm/addrs/local')
  45822. };
  45823. };
  45824. /***/ },
  45825. /* 273 */
  45826. /***/ function(module, exports, __webpack_require__) {
  45827. "use strict";
  45828. 'use strict';
  45829. var command = __webpack_require__(18).command;
  45830. module.exports = function (send) {
  45831. return {
  45832. apply: command(send, 'update'),
  45833. check: command(send, 'update/check'),
  45834. log: command(send, 'update/log')
  45835. };
  45836. };
  45837. /***/ },
  45838. /* 274 */
  45839. /***/ function(module, exports, __webpack_require__) {
  45840. "use strict";
  45841. 'use strict';
  45842. var command = __webpack_require__(18).command;
  45843. module.exports = function (send) {
  45844. return command(send, 'version');
  45845. };
  45846. /***/ },
  45847. /* 275 */
  45848. /***/ function(module, exports, __webpack_require__) {
  45849. "use strict";
  45850. 'use strict';
  45851. var pkg = __webpack_require__(234);
  45852. exports = module.exports = function () {
  45853. return {
  45854. 'api-path': '/api/v0/',
  45855. 'user-agent': '/node-' + pkg.name + '/' + pkg.version + '/',
  45856. host: 'localhost',
  45857. port: '5001',
  45858. protocol: 'http'
  45859. };
  45860. };
  45861. /***/ },
  45862. /* 276 */
  45863. /***/ function(module, exports, __webpack_require__) {
  45864. "use strict";
  45865. 'use strict';
  45866. var DAGNode = __webpack_require__(99).DAGNode;
  45867. var bl = __webpack_require__(155);
  45868. var async = __webpack_require__(145);
  45869. module.exports = function (send, hash, cb) {
  45870. // Retrieve the object and its data in parallel, then produce a DAGNode
  45871. // instance using this information.
  45872. async.parallel([function get(done) {
  45873. send('object/get', hash, null, null, done);
  45874. }, function data(done) {
  45875. // WORKAROUND: request the object's data separately, since raw bits in JSON
  45876. // are interpreted as UTF-8 and corrupt the data.
  45877. // See https://github.com/ipfs/go-ipfs/issues/1582 for more details.
  45878. send('object/data', hash, null, null, done);
  45879. }], function done(err, res) {
  45880. if (err) {
  45881. return cb(err);
  45882. }
  45883. var object = res[0];
  45884. var stream = res[1];
  45885. stream.pipe(bl(function (err, data) {
  45886. if (err) {
  45887. return cb(err);
  45888. }
  45889. cb(err, new DAGNode(data, object.Links));
  45890. }));
  45891. });
  45892. };
  45893. /***/ },
  45894. /* 277 */
  45895. /***/ function(module, exports, __webpack_require__) {
  45896. "use strict";
  45897. 'use strict';
  45898. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
  45899. var isNode = __webpack_require__(196);
  45900. var Multipart = __webpack_require__(526);
  45901. var flatmap = __webpack_require__(500);
  45902. function headers(file) {
  45903. var name = file.path || '';
  45904. var header = {
  45905. 'Content-Disposition': 'file; filename="' + name + '"'
  45906. };
  45907. if (file.dir || !file.content) {
  45908. header['Content-Type'] = 'application/x-directory';
  45909. } else if (file.symlink) {
  45910. header['Content-Type'] = 'application/symlink';
  45911. } else {
  45912. header['Content-Type'] = 'application/octet-stream';
  45913. }
  45914. return header;
  45915. }
  45916. function strip(name, base) {
  45917. var smallBase = base.split('/').slice(0, -1).join('/') + '/';
  45918. return name.replace(smallBase, '');
  45919. }
  45920. function loadPaths(opts, file) {
  45921. var path = __webpack_require__(43);
  45922. var glob = __webpack_require__(200);
  45923. var followSymlinks = opts.followSymlinks != null ? opts.followSymlinks : true;
  45924. file = path.resolve(file);
  45925. var stats = fs.statSync(file);
  45926. if (stats.isDirectory() && !opts.recursive) {
  45927. throw new Error('Can only add directories using --recursive');
  45928. }
  45929. if (stats.isDirectory() && opts.recursive) {
  45930. var _ret = function () {
  45931. var mg = new glob.sync.GlobSync(file + '/**/*', {
  45932. follow: followSymlinks
  45933. });
  45934. return {
  45935. v: mg.found.map(function (name) {
  45936. // symlinks
  45937. if (mg.symlinks[name] === true) {
  45938. return {
  45939. path: strip(name, file),
  45940. symlink: true,
  45941. dir: false,
  45942. content: fs.readlinkSync(name)
  45943. };
  45944. }
  45945. // files
  45946. if (mg.cache[name] === 'FILE') {
  45947. return {
  45948. path: strip(name, file),
  45949. symlink: false,
  45950. dir: false,
  45951. content: fs.createReadStream(name)
  45952. };
  45953. }
  45954. // directories
  45955. if (mg.cache[name] === 'DIR' || mg.cache[name] instanceof Array) {
  45956. return {
  45957. path: strip(name, file),
  45958. symlink: false,
  45959. dir: true
  45960. };
  45961. }
  45962. // files inside symlinks and others
  45963. return;
  45964. })
  45965. // filter out null files
  45966. .filter(Boolean)
  45967. };
  45968. }();
  45969. if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
  45970. }
  45971. return {
  45972. path: file,
  45973. content: fs.createReadStream(file)
  45974. };
  45975. }
  45976. function getFilesStream(files, opts) {
  45977. if (!files) return null;
  45978. var mp = new Multipart();
  45979. flatmap(files, function (file) {
  45980. if (typeof file === 'string') {
  45981. if (!isNode) {
  45982. throw new Error('Can not add paths in node');
  45983. }
  45984. return loadPaths(opts, file);
  45985. }
  45986. if (file.path && !file.content) {
  45987. file.dir = true;
  45988. return file;
  45989. }
  45990. if (file.path && (file.content || file.dir)) {
  45991. return file;
  45992. }
  45993. return {
  45994. path: '',
  45995. symlink: false,
  45996. dir: false,
  45997. content: file
  45998. };
  45999. }).forEach(function (file) {
  46000. mp.addPart({
  46001. headers: headers(file),
  46002. body: file.content
  46003. });
  46004. });
  46005. return mp;
  46006. }
  46007. exports = module.exports = getFilesStream;
  46008. /***/ },
  46009. /* 278 */
  46010. /***/ function(module, exports, __webpack_require__) {
  46011. "use strict";
  46012. 'use strict';
  46013. function requireCommands() {
  46014. var cmds = {
  46015. add: __webpack_require__(101), // add alias
  46016. createAddStream: __webpack_require__(154), // add stream alias
  46017. bitswap: __webpack_require__(254),
  46018. block: __webpack_require__(255),
  46019. bootstrap: __webpack_require__(256),
  46020. cat: __webpack_require__(257),
  46021. commands: __webpack_require__(258),
  46022. config: __webpack_require__(259),
  46023. dht: __webpack_require__(260),
  46024. diag: __webpack_require__(261),
  46025. id: __webpack_require__(263),
  46026. log: __webpack_require__(264),
  46027. ls: __webpack_require__(265),
  46028. mount: __webpack_require__(266),
  46029. name: __webpack_require__(267),
  46030. object: __webpack_require__(268),
  46031. pin: __webpack_require__(269),
  46032. ping: __webpack_require__(270),
  46033. refs: __webpack_require__(271),
  46034. swarm: __webpack_require__(272),
  46035. update: __webpack_require__(273),
  46036. version: __webpack_require__(274)
  46037. };
  46038. // TODO: crowding the 'files' namespace temporarily for interface-ipfs-core
  46039. // compatibility, until 'files vs mfs' naming decision is resolved.
  46040. cmds.files = function (send) {
  46041. var files = __webpack_require__(262)(send);
  46042. files.add = __webpack_require__(101)(send);
  46043. files.createAddStream = __webpack_require__(154)(send);
  46044. return files;
  46045. };
  46046. cmds.util = function (send) {
  46047. var util = {
  46048. addFiles: __webpack_require__(252)(send),
  46049. addUrl: __webpack_require__(253)(send)
  46050. };
  46051. return util;
  46052. };
  46053. return cmds;
  46054. }
  46055. function loadCommands(send) {
  46056. var files = requireCommands();
  46057. var cmds = {};
  46058. Object.keys(files).forEach(function (file) {
  46059. cmds[file] = files[file](send);
  46060. });
  46061. return cmds;
  46062. }
  46063. module.exports = loadCommands;
  46064. /***/ },
  46065. /* 279 */
  46066. /***/ function(module, exports, __webpack_require__) {
  46067. "use strict";
  46068. 'use strict';
  46069. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
  46070. var Wreck = __webpack_require__(152);
  46071. var Qs = __webpack_require__(247);
  46072. var ndjson = __webpack_require__(206);
  46073. var getFilesStream = __webpack_require__(277);
  46074. var isNode = __webpack_require__(196);
  46075. // -- Internal
  46076. function parseChunkedJson(res, cb) {
  46077. var parsed = [];
  46078. res.pipe(ndjson.parse()).on('data', parsed.push.bind(parsed)).on('end', function () {
  46079. return cb(null, parsed);
  46080. });
  46081. }
  46082. function onRes(buffer, cb) {
  46083. return function (err, res) {
  46084. if (err) {
  46085. return cb(err);
  46086. }
  46087. var stream = Boolean(res.headers['x-stream-output']);
  46088. var chunkedObjects = Boolean(res.headers['x-chunked-output']);
  46089. var isJson = res.headers['content-type'] && res.headers['content-type'].indexOf('application/json') === 0;
  46090. if (res.statusCode >= 400 || !res.statusCode) {
  46091. var _ret = function () {
  46092. var error = new Error('Server responded with ' + res.statusCode);
  46093. return {
  46094. v: Wreck.read(res, { json: true }, function (err, payload) {
  46095. if (err) {
  46096. return cb(err);
  46097. }
  46098. if (payload) {
  46099. error.code = payload.Code;
  46100. error.message = payload.Message || payload.toString();
  46101. }
  46102. cb(error);
  46103. })
  46104. };
  46105. }();
  46106. if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
  46107. }
  46108. if (stream && !buffer) return cb(null, res);
  46109. if (chunkedObjects) {
  46110. if (isJson) return parseChunkedJson(res, cb);
  46111. return Wreck.read(res, null, cb);
  46112. }
  46113. Wreck.read(res, { json: isJson }, cb);
  46114. };
  46115. }
  46116. function requestAPI(config, path, args, qs, files, buffer, cb) {
  46117. qs = qs || {};
  46118. if (Array.isArray(path)) path = path.join('/');
  46119. if (args && !Array.isArray(args)) args = [args];
  46120. if (args) qs.arg = args;
  46121. if (files && !Array.isArray(files)) files = [files];
  46122. if (qs.r) {
  46123. qs.recursive = qs.r;
  46124. // From IPFS 0.4.0, it throws an error when both r and recursive are passed
  46125. delete qs.r;
  46126. }
  46127. if (!isNode && qs.recursive && path === 'add') {
  46128. return cb(new Error('Recursive uploads are not supported in the browser'));
  46129. }
  46130. qs['stream-channels'] = true;
  46131. var stream = void 0;
  46132. if (files) {
  46133. stream = getFilesStream(files, qs);
  46134. }
  46135. // this option is only used internally, not passed to daemon
  46136. delete qs.followSymlinks;
  46137. var port = config.port ? ':' + config.port : '';
  46138. var opts = {
  46139. method: files ? 'POST' : 'GET',
  46140. uri: config.protocol + '://' + config.host + port + config['api-path'] + path + '?' + Qs.stringify(qs, { arrayFormat: 'repeat' }),
  46141. headers: {}
  46142. };
  46143. if (isNode) {
  46144. // Browsers do not allow you to modify the user agent
  46145. opts.headers['User-Agent'] = config['user-agent'];
  46146. }
  46147. if (files) {
  46148. if (!stream.boundary) {
  46149. return cb(new Error('No boundary in multipart stream'));
  46150. }
  46151. opts.headers['Content-Type'] = 'multipart/form-data; boundary=' + stream.boundary;
  46152. opts.downstreamRes = stream;
  46153. opts.payload = stream;
  46154. }
  46155. return Wreck.request(opts.method, opts.uri, opts, onRes(buffer, cb));
  46156. }
  46157. // -- Interface
  46158. exports = module.exports = function getRequestAPI(config) {
  46159. var send = function send(path, args, qs, files, buffer, cb) {
  46160. if (typeof buffer === 'function') {
  46161. cb = buffer;
  46162. buffer = false;
  46163. }
  46164. if (typeof cb !== 'function' && typeof Promise !== 'undefined') {
  46165. return new Promise(function (resolve, reject) {
  46166. requestAPI(config, path, args, qs, files, buffer, function (err, res) {
  46167. if (err) return reject(err);
  46168. resolve(res);
  46169. });
  46170. });
  46171. }
  46172. return requestAPI(config, path, args, qs, files, buffer, cb);
  46173. };
  46174. // Wraps the 'send' function such that an asynchronous transform may be
  46175. // applied to its result before passing it on to either its callback or
  46176. // promise.
  46177. send.withTransform = function (transform) {
  46178. return function (path, args, qs, files, buffer, cb) {
  46179. if (typeof buffer === 'function') {
  46180. cb = buffer;
  46181. buffer = false;
  46182. }
  46183. var p = send(path, args, qs, files, buffer, wrap(cb));
  46184. if (p instanceof Promise) {
  46185. return p.then(function (res) {
  46186. return new Promise(function (resolve, reject) {
  46187. transform(null, res, send, function (err, res) {
  46188. if (err) {
  46189. reject(err);
  46190. } else {
  46191. resolve(res);
  46192. }
  46193. });
  46194. });
  46195. });
  46196. } else {
  46197. return p;
  46198. }
  46199. function wrap(done) {
  46200. if (done) {
  46201. return function (err, res) {
  46202. transform(err, res, send, done);
  46203. };
  46204. }
  46205. }
  46206. };
  46207. };
  46208. return send;
  46209. };
  46210. /***/ },
  46211. /* 280 */
  46212. /***/ function(module, exports) {
  46213. module.exports = balanced;
  46214. function balanced(a, b, str) {
  46215. if (a instanceof RegExp) a = maybeMatch(a, str);
  46216. if (b instanceof RegExp) b = maybeMatch(b, str);
  46217. var r = range(a, b, str);
  46218. return r && {
  46219. start: r[0],
  46220. end: r[1],
  46221. pre: str.slice(0, r[0]),
  46222. body: str.slice(r[0] + a.length, r[1]),
  46223. post: str.slice(r[1] + b.length)
  46224. };
  46225. }
  46226. function maybeMatch(reg, str) {
  46227. var m = str.match(reg);
  46228. return m ? m[0] : null;
  46229. }
  46230. balanced.range = range;
  46231. function range(a, b, str) {
  46232. var begs, beg, left, right, result;
  46233. var ai = str.indexOf(a);
  46234. var bi = str.indexOf(b, ai + 1);
  46235. var i = ai;
  46236. if (ai >= 0 && bi > 0) {
  46237. begs = [];
  46238. left = str.length;
  46239. while (i < str.length && i >= 0 && ! result) {
  46240. if (i == ai) {
  46241. begs.push(i);
  46242. ai = str.indexOf(a, i + 1);
  46243. } else if (begs.length == 1) {
  46244. result = [ begs.pop(), bi ];
  46245. } else {
  46246. beg = begs.pop();
  46247. if (beg < left) {
  46248. left = beg;
  46249. right = bi;
  46250. }
  46251. bi = str.indexOf(b, i + 1);
  46252. }
  46253. i = ai < bi && ai >= 0 ? ai : bi;
  46254. }
  46255. if (begs.length) {
  46256. result = [ left, right ];
  46257. }
  46258. }
  46259. return result;
  46260. }
  46261. /***/ },
  46262. /* 281 */
  46263. /***/ function(module, exports) {
  46264. // base-x encoding
  46265. // Forked from https://github.com/cryptocoinjs/bs58
  46266. // Originally written by Mike Hearn for BitcoinJ
  46267. // Copyright (c) 2011 Google Inc
  46268. // Ported to JavaScript by Stefan Thomas
  46269. // Merged Buffer refactorings from base58-native by Stephen Pair
  46270. // Copyright (c) 2013 BitPay Inc
  46271. module.exports = function base (ALPHABET) {
  46272. var ALPHABET_MAP = {}
  46273. var BASE = ALPHABET.length
  46274. var LEADER = ALPHABET.charAt(0)
  46275. // pre-compute lookup table
  46276. for (var i = 0; i < ALPHABET.length; i++) {
  46277. ALPHABET_MAP[ALPHABET.charAt(i)] = i
  46278. }
  46279. function encode (source) {
  46280. if (source.length === 0) return ''
  46281. var digits = [0]
  46282. for (var i = 0; i < source.length; ++i) {
  46283. for (var j = 0, carry = source[i]; j < digits.length; ++j) {
  46284. carry += digits[j] << 8
  46285. digits[j] = carry % BASE
  46286. carry = (carry / BASE) | 0
  46287. }
  46288. while (carry > 0) {
  46289. digits.push(carry % BASE)
  46290. carry = (carry / BASE) | 0
  46291. }
  46292. }
  46293. // deal with leading zeros
  46294. for (var k = 0; source[k] === 0 && k < source.length - 1; ++k) {
  46295. digits.push(0)
  46296. }
  46297. // convert digits to a string
  46298. for (var ii = 0, jj = digits.length - 1; ii <= jj; ++ii, --jj) {
  46299. var tmp = ALPHABET[digits[ii]]
  46300. digits[ii] = ALPHABET[digits[jj]]
  46301. digits[jj] = tmp
  46302. }
  46303. return digits.join('')
  46304. }
  46305. function decode (string) {
  46306. if (string.length === 0) return []
  46307. var bytes = [0]
  46308. for (var i = 0; i < string.length; i++) {
  46309. var value = ALPHABET_MAP[string[i]]
  46310. if (value === undefined) throw new Error('Non-base' + BASE + ' character')
  46311. for (var j = 0, carry = value; j < bytes.length; ++j) {
  46312. carry += bytes[j] * BASE
  46313. bytes[j] = carry & 0xff
  46314. carry >>= 8
  46315. }
  46316. while (carry > 0) {
  46317. bytes.push(carry & 0xff)
  46318. carry >>= 8
  46319. }
  46320. }
  46321. // deal with leading zeros
  46322. for (var k = 0; string[k] === LEADER && k < string.length - 1; ++k) {
  46323. bytes.push(0)
  46324. }
  46325. return bytes.reverse()
  46326. }
  46327. return {
  46328. encode: encode,
  46329. decode: decode
  46330. }
  46331. }
  46332. /***/ },
  46333. /* 282 */
  46334. /***/ function(module, exports) {
  46335. "use strict";
  46336. 'use strict'
  46337. exports.toByteArray = toByteArray
  46338. exports.fromByteArray = fromByteArray
  46339. var lookup = []
  46340. var revLookup = []
  46341. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  46342. function init () {
  46343. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  46344. for (var i = 0, len = code.length; i < len; ++i) {
  46345. lookup[i] = code[i]
  46346. revLookup[code.charCodeAt(i)] = i
  46347. }
  46348. revLookup['-'.charCodeAt(0)] = 62
  46349. revLookup['_'.charCodeAt(0)] = 63
  46350. }
  46351. init()
  46352. function toByteArray (b64) {
  46353. var i, j, l, tmp, placeHolders, arr
  46354. var len = b64.length
  46355. if (len % 4 > 0) {
  46356. throw new Error('Invalid string. Length must be a multiple of 4')
  46357. }
  46358. // the number of equal signs (place holders)
  46359. // if there are two placeholders, than the two characters before it
  46360. // represent one byte
  46361. // if there is only one, then the three characters before it represent 2 bytes
  46362. // this is just a cheap hack to not do indexOf twice
  46363. placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
  46364. // base64 is 4/3 + up to two characters of the original data
  46365. arr = new Arr(len * 3 / 4 - placeHolders)
  46366. // if there are placeholders, only get up to the last complete 4 chars
  46367. l = placeHolders > 0 ? len - 4 : len
  46368. var L = 0
  46369. for (i = 0, j = 0; i < l; i += 4, j += 3) {
  46370. tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
  46371. arr[L++] = (tmp >> 16) & 0xFF
  46372. arr[L++] = (tmp >> 8) & 0xFF
  46373. arr[L++] = tmp & 0xFF
  46374. }
  46375. if (placeHolders === 2) {
  46376. tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)
  46377. arr[L++] = tmp & 0xFF
  46378. } else if (placeHolders === 1) {
  46379. tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)
  46380. arr[L++] = (tmp >> 8) & 0xFF
  46381. arr[L++] = tmp & 0xFF
  46382. }
  46383. return arr
  46384. }
  46385. function tripletToBase64 (num) {
  46386. return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
  46387. }
  46388. function encodeChunk (uint8, start, end) {
  46389. var tmp
  46390. var output = []
  46391. for (var i = start; i < end; i += 3) {
  46392. tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
  46393. output.push(tripletToBase64(tmp))
  46394. }
  46395. return output.join('')
  46396. }
  46397. function fromByteArray (uint8) {
  46398. var tmp
  46399. var len = uint8.length
  46400. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  46401. var output = ''
  46402. var parts = []
  46403. var maxChunkLength = 16383 // must be multiple of 3
  46404. // go through the array every three bytes, we'll deal with trailing stuff later
  46405. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  46406. parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
  46407. }
  46408. // pad the end with zeros, but make sure to not forget the extra bytes
  46409. if (extraBytes === 1) {
  46410. tmp = uint8[len - 1]
  46411. output += lookup[tmp >> 2]
  46412. output += lookup[(tmp << 4) & 0x3F]
  46413. output += '=='
  46414. } else if (extraBytes === 2) {
  46415. tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
  46416. output += lookup[tmp >> 10]
  46417. output += lookup[(tmp >> 4) & 0x3F]
  46418. output += lookup[(tmp << 2) & 0x3F]
  46419. output += '='
  46420. }
  46421. parts.push(output)
  46422. return parts.join('')
  46423. }
  46424. /***/ },
  46425. /* 283 */
  46426. /***/ function(module, exports, __webpack_require__) {
  46427. var concatMap = __webpack_require__(294);
  46428. var balanced = __webpack_require__(280);
  46429. module.exports = expandTop;
  46430. var escSlash = '\0SLASH'+Math.random()+'\0';
  46431. var escOpen = '\0OPEN'+Math.random()+'\0';
  46432. var escClose = '\0CLOSE'+Math.random()+'\0';
  46433. var escComma = '\0COMMA'+Math.random()+'\0';
  46434. var escPeriod = '\0PERIOD'+Math.random()+'\0';
  46435. function numeric(str) {
  46436. return parseInt(str, 10) == str
  46437. ? parseInt(str, 10)
  46438. : str.charCodeAt(0);
  46439. }
  46440. function escapeBraces(str) {
  46441. return str.split('\\\\').join(escSlash)
  46442. .split('\\{').join(escOpen)
  46443. .split('\\}').join(escClose)
  46444. .split('\\,').join(escComma)
  46445. .split('\\.').join(escPeriod);
  46446. }
  46447. function unescapeBraces(str) {
  46448. return str.split(escSlash).join('\\')
  46449. .split(escOpen).join('{')
  46450. .split(escClose).join('}')
  46451. .split(escComma).join(',')
  46452. .split(escPeriod).join('.');
  46453. }
  46454. // Basically just str.split(","), but handling cases
  46455. // where we have nested braced sections, which should be
  46456. // treated as individual members, like {a,{b,c},d}
  46457. function parseCommaParts(str) {
  46458. if (!str)
  46459. return [''];
  46460. var parts = [];
  46461. var m = balanced('{', '}', str);
  46462. if (!m)
  46463. return str.split(',');
  46464. var pre = m.pre;
  46465. var body = m.body;
  46466. var post = m.post;
  46467. var p = pre.split(',');
  46468. p[p.length-1] += '{' + body + '}';
  46469. var postParts = parseCommaParts(post);
  46470. if (post.length) {
  46471. p[p.length-1] += postParts.shift();
  46472. p.push.apply(p, postParts);
  46473. }
  46474. parts.push.apply(parts, p);
  46475. return parts;
  46476. }
  46477. function expandTop(str) {
  46478. if (!str)
  46479. return [];
  46480. return expand(escapeBraces(str), true).map(unescapeBraces);
  46481. }
  46482. function identity(e) {
  46483. return e;
  46484. }
  46485. function embrace(str) {
  46486. return '{' + str + '}';
  46487. }
  46488. function isPadded(el) {
  46489. return /^-?0\d/.test(el);
  46490. }
  46491. function lte(i, y) {
  46492. return i <= y;
  46493. }
  46494. function gte(i, y) {
  46495. return i >= y;
  46496. }
  46497. function expand(str, isTop) {
  46498. var expansions = [];
  46499. var m = balanced('{', '}', str);
  46500. if (!m || /\$$/.test(m.pre)) return [str];
  46501. var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
  46502. var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
  46503. var isSequence = isNumericSequence || isAlphaSequence;
  46504. var isOptions = /^(.*,)+(.+)?$/.test(m.body);
  46505. if (!isSequence && !isOptions) {
  46506. // {a},b}
  46507. if (m.post.match(/,.*\}/)) {
  46508. str = m.pre + '{' + m.body + escClose + m.post;
  46509. return expand(str);
  46510. }
  46511. return [str];
  46512. }
  46513. var n;
  46514. if (isSequence) {
  46515. n = m.body.split(/\.\./);
  46516. } else {
  46517. n = parseCommaParts(m.body);
  46518. if (n.length === 1) {
  46519. // x{{a,b}}y ==> x{a}y x{b}y
  46520. n = expand(n[0], false).map(embrace);
  46521. if (n.length === 1) {
  46522. var post = m.post.length
  46523. ? expand(m.post, false)
  46524. : [''];
  46525. return post.map(function(p) {
  46526. return m.pre + n[0] + p;
  46527. });
  46528. }
  46529. }
  46530. }
  46531. // at this point, n is the parts, and we know it's not a comma set
  46532. // with a single entry.
  46533. // no need to expand pre, since it is guaranteed to be free of brace-sets
  46534. var pre = m.pre;
  46535. var post = m.post.length
  46536. ? expand(m.post, false)
  46537. : [''];
  46538. var N;
  46539. if (isSequence) {
  46540. var x = numeric(n[0]);
  46541. var y = numeric(n[1]);
  46542. var width = Math.max(n[0].length, n[1].length)
  46543. var incr = n.length == 3
  46544. ? Math.abs(numeric(n[2]))
  46545. : 1;
  46546. var test = lte;
  46547. var reverse = y < x;
  46548. if (reverse) {
  46549. incr *= -1;
  46550. test = gte;
  46551. }
  46552. var pad = n.some(isPadded);
  46553. N = [];
  46554. for (var i = x; test(i, y); i += incr) {
  46555. var c;
  46556. if (isAlphaSequence) {
  46557. c = String.fromCharCode(i);
  46558. if (c === '\\')
  46559. c = '';
  46560. } else {
  46561. c = String(i);
  46562. if (pad) {
  46563. var need = width - c.length;
  46564. if (need > 0) {
  46565. var z = new Array(need + 1).join('0');
  46566. if (i < 0)
  46567. c = '-' + z + c.slice(1);
  46568. else
  46569. c = z + c;
  46570. }
  46571. }
  46572. }
  46573. N.push(c);
  46574. }
  46575. } else {
  46576. N = concatMap(n, function(el) { return expand(el, false) });
  46577. }
  46578. for (var j = 0; j < N.length; j++) {
  46579. for (var k = 0; k < post.length; k++) {
  46580. var expansion = pre + N[j] + post[k];
  46581. if (!isTop || isSequence || expansion)
  46582. expansions.push(expansion);
  46583. }
  46584. }
  46585. return expansions;
  46586. }
  46587. /***/ },
  46588. /* 284 */
  46589. /***/ function(module, exports, __webpack_require__) {
  46590. /* WEBPACK VAR INJECTION */(function(Buffer) {var aes = __webpack_require__(79)
  46591. var Transform = __webpack_require__(57)
  46592. var inherits = __webpack_require__(2)
  46593. var modes = __webpack_require__(80)
  46594. var StreamCipher = __webpack_require__(164)
  46595. var AuthCipher = __webpack_require__(157)
  46596. var ebtk = __webpack_require__(95)
  46597. inherits(Decipher, Transform)
  46598. function Decipher (mode, key, iv) {
  46599. if (!(this instanceof Decipher)) {
  46600. return new Decipher(mode, key, iv)
  46601. }
  46602. Transform.call(this)
  46603. this._cache = new Splitter()
  46604. this._last = void 0
  46605. this._cipher = new aes.AES(key)
  46606. this._prev = new Buffer(iv.length)
  46607. iv.copy(this._prev)
  46608. this._mode = mode
  46609. this._autopadding = true
  46610. }
  46611. Decipher.prototype._update = function (data) {
  46612. this._cache.add(data)
  46613. var chunk
  46614. var thing
  46615. var out = []
  46616. while ((chunk = this._cache.get(this._autopadding))) {
  46617. thing = this._mode.decrypt(this, chunk)
  46618. out.push(thing)
  46619. }
  46620. return Buffer.concat(out)
  46621. }
  46622. Decipher.prototype._final = function () {
  46623. var chunk = this._cache.flush()
  46624. if (this._autopadding) {
  46625. return unpad(this._mode.decrypt(this, chunk))
  46626. } else if (chunk) {
  46627. throw new Error('data not multiple of block length')
  46628. }
  46629. }
  46630. Decipher.prototype.setAutoPadding = function (setTo) {
  46631. this._autopadding = !!setTo
  46632. return this
  46633. }
  46634. function Splitter () {
  46635. if (!(this instanceof Splitter)) {
  46636. return new Splitter()
  46637. }
  46638. this.cache = new Buffer('')
  46639. }
  46640. Splitter.prototype.add = function (data) {
  46641. this.cache = Buffer.concat([this.cache, data])
  46642. }
  46643. Splitter.prototype.get = function (autoPadding) {
  46644. var out
  46645. if (autoPadding) {
  46646. if (this.cache.length > 16) {
  46647. out = this.cache.slice(0, 16)
  46648. this.cache = this.cache.slice(16)
  46649. return out
  46650. }
  46651. } else {
  46652. if (this.cache.length >= 16) {
  46653. out = this.cache.slice(0, 16)
  46654. this.cache = this.cache.slice(16)
  46655. return out
  46656. }
  46657. }
  46658. return null
  46659. }
  46660. Splitter.prototype.flush = function () {
  46661. if (this.cache.length) {
  46662. return this.cache
  46663. }
  46664. }
  46665. function unpad (last) {
  46666. var padded = last[15]
  46667. var i = -1
  46668. while (++i < padded) {
  46669. if (last[(i + (16 - padded))] !== padded) {
  46670. throw new Error('unable to decrypt data')
  46671. }
  46672. }
  46673. if (padded === 16) {
  46674. return
  46675. }
  46676. return last.slice(0, 16 - padded)
  46677. }
  46678. var modelist = {
  46679. ECB: __webpack_require__(162),
  46680. CBC: __webpack_require__(158),
  46681. CFB: __webpack_require__(159),
  46682. CFB8: __webpack_require__(161),
  46683. CFB1: __webpack_require__(160),
  46684. OFB: __webpack_require__(163),
  46685. CTR: __webpack_require__(81),
  46686. GCM: __webpack_require__(81)
  46687. }
  46688. function createDecipheriv (suite, password, iv) {
  46689. var config = modes[suite.toLowerCase()]
  46690. if (!config) {
  46691. throw new TypeError('invalid suite type')
  46692. }
  46693. if (typeof iv === 'string') {
  46694. iv = new Buffer(iv)
  46695. }
  46696. if (typeof password === 'string') {
  46697. password = new Buffer(password)
  46698. }
  46699. if (password.length !== config.key / 8) {
  46700. throw new TypeError('invalid key length ' + password.length)
  46701. }
  46702. if (iv.length !== config.iv) {
  46703. throw new TypeError('invalid iv length ' + iv.length)
  46704. }
  46705. if (config.type === 'stream') {
  46706. return new StreamCipher(modelist[config.mode], password, iv, true)
  46707. } else if (config.type === 'auth') {
  46708. return new AuthCipher(modelist[config.mode], password, iv, true)
  46709. }
  46710. return new Decipher(modelist[config.mode], password, iv)
  46711. }
  46712. function createDecipher (suite, password) {
  46713. var config = modes[suite.toLowerCase()]
  46714. if (!config) {
  46715. throw new TypeError('invalid suite type')
  46716. }
  46717. var keys = ebtk(password, false, config.key, config.iv)
  46718. return createDecipheriv(suite, keys.key, keys.iv)
  46719. }
  46720. exports.createDecipher = createDecipher
  46721. exports.createDecipheriv = createDecipheriv
  46722. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  46723. /***/ },
  46724. /* 285 */
  46725. /***/ function(module, exports, __webpack_require__) {
  46726. /* WEBPACK VAR INJECTION */(function(Buffer) {var aes = __webpack_require__(79)
  46727. var Transform = __webpack_require__(57)
  46728. var inherits = __webpack_require__(2)
  46729. var modes = __webpack_require__(80)
  46730. var ebtk = __webpack_require__(95)
  46731. var StreamCipher = __webpack_require__(164)
  46732. var AuthCipher = __webpack_require__(157)
  46733. inherits(Cipher, Transform)
  46734. function Cipher (mode, key, iv) {
  46735. if (!(this instanceof Cipher)) {
  46736. return new Cipher(mode, key, iv)
  46737. }
  46738. Transform.call(this)
  46739. this._cache = new Splitter()
  46740. this._cipher = new aes.AES(key)
  46741. this._prev = new Buffer(iv.length)
  46742. iv.copy(this._prev)
  46743. this._mode = mode
  46744. this._autopadding = true
  46745. }
  46746. Cipher.prototype._update = function (data) {
  46747. this._cache.add(data)
  46748. var chunk
  46749. var thing
  46750. var out = []
  46751. while ((chunk = this._cache.get())) {
  46752. thing = this._mode.encrypt(this, chunk)
  46753. out.push(thing)
  46754. }
  46755. return Buffer.concat(out)
  46756. }
  46757. Cipher.prototype._final = function () {
  46758. var chunk = this._cache.flush()
  46759. if (this._autopadding) {
  46760. chunk = this._mode.encrypt(this, chunk)
  46761. this._cipher.scrub()
  46762. return chunk
  46763. } else if (chunk.toString('hex') !== '10101010101010101010101010101010') {
  46764. this._cipher.scrub()
  46765. throw new Error('data not multiple of block length')
  46766. }
  46767. }
  46768. Cipher.prototype.setAutoPadding = function (setTo) {
  46769. this._autopadding = !!setTo
  46770. return this
  46771. }
  46772. function Splitter () {
  46773. if (!(this instanceof Splitter)) {
  46774. return new Splitter()
  46775. }
  46776. this.cache = new Buffer('')
  46777. }
  46778. Splitter.prototype.add = function (data) {
  46779. this.cache = Buffer.concat([this.cache, data])
  46780. }
  46781. Splitter.prototype.get = function () {
  46782. if (this.cache.length > 15) {
  46783. var out = this.cache.slice(0, 16)
  46784. this.cache = this.cache.slice(16)
  46785. return out
  46786. }
  46787. return null
  46788. }
  46789. Splitter.prototype.flush = function () {
  46790. var len = 16 - this.cache.length
  46791. var padBuff = new Buffer(len)
  46792. var i = -1
  46793. while (++i < len) {
  46794. padBuff.writeUInt8(len, i)
  46795. }
  46796. var out = Buffer.concat([this.cache, padBuff])
  46797. return out
  46798. }
  46799. var modelist = {
  46800. ECB: __webpack_require__(162),
  46801. CBC: __webpack_require__(158),
  46802. CFB: __webpack_require__(159),
  46803. CFB8: __webpack_require__(161),
  46804. CFB1: __webpack_require__(160),
  46805. OFB: __webpack_require__(163),
  46806. CTR: __webpack_require__(81),
  46807. GCM: __webpack_require__(81)
  46808. }
  46809. function createCipheriv (suite, password, iv) {
  46810. var config = modes[suite.toLowerCase()]
  46811. if (!config) {
  46812. throw new TypeError('invalid suite type')
  46813. }
  46814. if (typeof iv === 'string') {
  46815. iv = new Buffer(iv)
  46816. }
  46817. if (typeof password === 'string') {
  46818. password = new Buffer(password)
  46819. }
  46820. if (password.length !== config.key / 8) {
  46821. throw new TypeError('invalid key length ' + password.length)
  46822. }
  46823. if (iv.length !== config.iv) {
  46824. throw new TypeError('invalid iv length ' + iv.length)
  46825. }
  46826. if (config.type === 'stream') {
  46827. return new StreamCipher(modelist[config.mode], password, iv)
  46828. } else if (config.type === 'auth') {
  46829. return new AuthCipher(modelist[config.mode], password, iv)
  46830. }
  46831. return new Cipher(modelist[config.mode], password, iv)
  46832. }
  46833. function createCipher (suite, password) {
  46834. var config = modes[suite.toLowerCase()]
  46835. if (!config) {
  46836. throw new TypeError('invalid suite type')
  46837. }
  46838. var keys = ebtk(password, false, config.key, config.iv)
  46839. return createCipheriv(suite, keys.key, keys.iv)
  46840. }
  46841. exports.createCipheriv = createCipheriv
  46842. exports.createCipher = createCipher
  46843. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  46844. /***/ },
  46845. /* 286 */
  46846. /***/ function(module, exports, __webpack_require__) {
  46847. /* WEBPACK VAR INJECTION */(function(Buffer) {var zeros = new Buffer(16)
  46848. zeros.fill(0)
  46849. module.exports = GHASH
  46850. function GHASH (key) {
  46851. this.h = key
  46852. this.state = new Buffer(16)
  46853. this.state.fill(0)
  46854. this.cache = new Buffer('')
  46855. }
  46856. // from http://bitwiseshiftleft.github.io/sjcl/doc/symbols/src/core_gcm.js.html
  46857. // by Juho Vähä-Herttua
  46858. GHASH.prototype.ghash = function (block) {
  46859. var i = -1
  46860. while (++i < block.length) {
  46861. this.state[i] ^= block[i]
  46862. }
  46863. this._multiply()
  46864. }
  46865. GHASH.prototype._multiply = function () {
  46866. var Vi = toArray(this.h)
  46867. var Zi = [0, 0, 0, 0]
  46868. var j, xi, lsb_Vi
  46869. var i = -1
  46870. while (++i < 128) {
  46871. xi = (this.state[~~(i / 8)] & (1 << (7 - i % 8))) !== 0
  46872. if (xi) {
  46873. // Z_i+1 = Z_i ^ V_i
  46874. Zi = xor(Zi, Vi)
  46875. }
  46876. // Store the value of LSB(V_i)
  46877. lsb_Vi = (Vi[3] & 1) !== 0
  46878. // V_i+1 = V_i >> 1
  46879. for (j = 3; j > 0; j--) {
  46880. Vi[j] = (Vi[j] >>> 1) | ((Vi[j - 1] & 1) << 31)
  46881. }
  46882. Vi[0] = Vi[0] >>> 1
  46883. // If LSB(V_i) is 1, V_i+1 = (V_i >> 1) ^ R
  46884. if (lsb_Vi) {
  46885. Vi[0] = Vi[0] ^ (0xe1 << 24)
  46886. }
  46887. }
  46888. this.state = fromArray(Zi)
  46889. }
  46890. GHASH.prototype.update = function (buf) {
  46891. this.cache = Buffer.concat([this.cache, buf])
  46892. var chunk
  46893. while (this.cache.length >= 16) {
  46894. chunk = this.cache.slice(0, 16)
  46895. this.cache = this.cache.slice(16)
  46896. this.ghash(chunk)
  46897. }
  46898. }
  46899. GHASH.prototype.final = function (abl, bl) {
  46900. if (this.cache.length) {
  46901. this.ghash(Buffer.concat([this.cache, zeros], 16))
  46902. }
  46903. this.ghash(fromArray([
  46904. 0, abl,
  46905. 0, bl
  46906. ]))
  46907. return this.state
  46908. }
  46909. function toArray (buf) {
  46910. return [
  46911. buf.readUInt32BE(0),
  46912. buf.readUInt32BE(4),
  46913. buf.readUInt32BE(8),
  46914. buf.readUInt32BE(12)
  46915. ]
  46916. }
  46917. function fromArray (out) {
  46918. out = out.map(fixup_uint32)
  46919. var buf = new Buffer(16)
  46920. buf.writeUInt32BE(out[0], 0)
  46921. buf.writeUInt32BE(out[1], 4)
  46922. buf.writeUInt32BE(out[2], 8)
  46923. buf.writeUInt32BE(out[3], 12)
  46924. return buf
  46925. }
  46926. var uint_max = Math.pow(2, 32)
  46927. function fixup_uint32 (x) {
  46928. var ret, x_pos
  46929. ret = x > uint_max || x < 0 ? (x_pos = Math.abs(x) % uint_max, x < 0 ? uint_max - x_pos : x_pos) : x
  46930. return ret
  46931. }
  46932. function xor (a, b) {
  46933. return [
  46934. a[0] ^ b[0],
  46935. a[1] ^ b[1],
  46936. a[2] ^ b[2],
  46937. a[3] ^ b[3]
  46938. ]
  46939. }
  46940. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  46941. /***/ },
  46942. /* 287 */
  46943. /***/ function(module, exports, __webpack_require__) {
  46944. var ebtk = __webpack_require__(95)
  46945. var aes = __webpack_require__(102)
  46946. var DES = __webpack_require__(288)
  46947. var desModes = __webpack_require__(289)
  46948. var aesModes = __webpack_require__(80)
  46949. function createCipher (suite, password) {
  46950. var keyLen, ivLen
  46951. suite = suite.toLowerCase()
  46952. if (aesModes[suite]) {
  46953. keyLen = aesModes[suite].key
  46954. ivLen = aesModes[suite].iv
  46955. } else if (desModes[suite]) {
  46956. keyLen = desModes[suite].key * 8
  46957. ivLen = desModes[suite].iv
  46958. } else {
  46959. throw new TypeError('invalid suite type')
  46960. }
  46961. var keys = ebtk(password, false, keyLen, ivLen)
  46962. return createCipheriv(suite, keys.key, keys.iv)
  46963. }
  46964. function createDecipher (suite, password) {
  46965. var keyLen, ivLen
  46966. suite = suite.toLowerCase()
  46967. if (aesModes[suite]) {
  46968. keyLen = aesModes[suite].key
  46969. ivLen = aesModes[suite].iv
  46970. } else if (desModes[suite]) {
  46971. keyLen = desModes[suite].key * 8
  46972. ivLen = desModes[suite].iv
  46973. } else {
  46974. throw new TypeError('invalid suite type')
  46975. }
  46976. var keys = ebtk(password, false, keyLen, ivLen)
  46977. return createDecipheriv(suite, keys.key, keys.iv)
  46978. }
  46979. function createCipheriv (suite, key, iv) {
  46980. suite = suite.toLowerCase()
  46981. if (aesModes[suite]) {
  46982. return aes.createCipheriv(suite, key, iv)
  46983. } else if (desModes[suite]) {
  46984. return new DES({
  46985. key: key,
  46986. iv: iv,
  46987. mode: suite
  46988. })
  46989. } else {
  46990. throw new TypeError('invalid suite type')
  46991. }
  46992. }
  46993. function createDecipheriv (suite, key, iv) {
  46994. suite = suite.toLowerCase()
  46995. if (aesModes[suite]) {
  46996. return aes.createDecipheriv(suite, key, iv)
  46997. } else if (desModes[suite]) {
  46998. return new DES({
  46999. key: key,
  47000. iv: iv,
  47001. mode: suite,
  47002. decrypt: true
  47003. })
  47004. } else {
  47005. throw new TypeError('invalid suite type')
  47006. }
  47007. }
  47008. exports.createCipher = exports.Cipher = createCipher
  47009. exports.createCipheriv = exports.Cipheriv = createCipheriv
  47010. exports.createDecipher = exports.Decipher = createDecipher
  47011. exports.createDecipheriv = exports.Decipheriv = createDecipheriv
  47012. function getCiphers () {
  47013. return Object.keys(desModes).concat(aes.getCiphers())
  47014. }
  47015. exports.listCiphers = exports.getCiphers = getCiphers
  47016. /***/ },
  47017. /* 288 */
  47018. /***/ function(module, exports, __webpack_require__) {
  47019. /* WEBPACK VAR INJECTION */(function(Buffer) {var CipherBase = __webpack_require__(57)
  47020. var des = __webpack_require__(132)
  47021. var inherits = __webpack_require__(2)
  47022. var modes = {
  47023. 'des-ede3-cbc': des.CBC.instantiate(des.EDE),
  47024. 'des-ede3': des.EDE,
  47025. 'des-ede-cbc': des.CBC.instantiate(des.EDE),
  47026. 'des-ede': des.EDE,
  47027. 'des-cbc': des.CBC.instantiate(des.DES),
  47028. 'des-ecb': des.DES
  47029. }
  47030. modes.des = modes['des-cbc']
  47031. modes.des3 = modes['des-ede3-cbc']
  47032. module.exports = DES
  47033. inherits(DES, CipherBase)
  47034. function DES (opts) {
  47035. CipherBase.call(this)
  47036. var modeName = opts.mode.toLowerCase()
  47037. var mode = modes[modeName]
  47038. var type
  47039. if (opts.decrypt) {
  47040. type = 'decrypt'
  47041. } else {
  47042. type = 'encrypt'
  47043. }
  47044. var key = opts.key
  47045. if (modeName === 'des-ede' || modeName === 'des-ede-cbc') {
  47046. key = Buffer.concat([key, key.slice(0, 8)])
  47047. }
  47048. var iv = opts.iv
  47049. this._des = mode.create({
  47050. key: key,
  47051. iv: iv,
  47052. type: type
  47053. })
  47054. }
  47055. DES.prototype._update = function (data) {
  47056. return new Buffer(this._des.update(data))
  47057. }
  47058. DES.prototype._final = function () {
  47059. return new Buffer(this._des.final())
  47060. }
  47061. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  47062. /***/ },
  47063. /* 289 */
  47064. /***/ function(module, exports) {
  47065. exports['des-ecb'] = {
  47066. key: 8,
  47067. iv: 0
  47068. }
  47069. exports['des-cbc'] = exports.des = {
  47070. key: 8,
  47071. iv: 8
  47072. }
  47073. exports['des-ede3-cbc'] = exports.des3 = {
  47074. key: 24,
  47075. iv: 8
  47076. }
  47077. exports['des-ede3'] = {
  47078. key: 24,
  47079. iv: 0
  47080. }
  47081. exports['des-ede-cbc'] = {
  47082. key: 16,
  47083. iv: 8
  47084. }
  47085. exports['des-ede'] = {
  47086. key: 16,
  47087. iv: 0
  47088. }
  47089. /***/ },
  47090. /* 290 */
  47091. /***/ function(module, exports, __webpack_require__) {
  47092. /* WEBPACK VAR INJECTION */(function(Buffer) {var _algos = __webpack_require__(165)
  47093. var createHash = __webpack_require__(63)
  47094. var inherits = __webpack_require__(2)
  47095. var sign = __webpack_require__(291)
  47096. var stream = __webpack_require__(9)
  47097. var verify = __webpack_require__(292)
  47098. var algos = {}
  47099. Object.keys(_algos).forEach(function (key) {
  47100. algos[key] = algos[key.toLowerCase()] = _algos[key]
  47101. })
  47102. function Sign (algorithm) {
  47103. stream.Writable.call(this)
  47104. var data = algos[algorithm]
  47105. if (!data) {
  47106. throw new Error('Unknown message digest')
  47107. }
  47108. this._hashType = data.hash
  47109. this._hash = createHash(data.hash)
  47110. this._tag = data.id
  47111. this._signType = data.sign
  47112. }
  47113. inherits(Sign, stream.Writable)
  47114. Sign.prototype._write = function _write (data, _, done) {
  47115. this._hash.update(data)
  47116. done()
  47117. }
  47118. Sign.prototype.update = function update (data, enc) {
  47119. if (typeof data === 'string') {
  47120. data = new Buffer(data, enc)
  47121. }
  47122. this._hash.update(data)
  47123. return this
  47124. }
  47125. Sign.prototype.sign = function signMethod (key, enc) {
  47126. this.end()
  47127. var hash = this._hash.digest()
  47128. var sig = sign(Buffer.concat([this._tag, hash]), key, this._hashType, this._signType)
  47129. return enc ? sig.toString(enc) : sig
  47130. }
  47131. function Verify (algorithm) {
  47132. stream.Writable.call(this)
  47133. var data = algos[algorithm]
  47134. if (!data) {
  47135. throw new Error('Unknown message digest')
  47136. }
  47137. this._hash = createHash(data.hash)
  47138. this._tag = data.id
  47139. this._signType = data.sign
  47140. }
  47141. inherits(Verify, stream.Writable)
  47142. Verify.prototype._write = function _write (data, _, done) {
  47143. this._hash.update(data)
  47144. done()
  47145. }
  47146. Verify.prototype.update = function update (data, enc) {
  47147. if (typeof data === 'string') {
  47148. data = new Buffer(data, enc)
  47149. }
  47150. this._hash.update(data)
  47151. return this
  47152. }
  47153. Verify.prototype.verify = function verifyMethod (key, sig, enc) {
  47154. if (typeof sig === 'string') {
  47155. sig = new Buffer(sig, enc)
  47156. }
  47157. this.end()
  47158. var hash = this._hash.digest()
  47159. return verify(sig, Buffer.concat([this._tag, hash]), key, this._signType)
  47160. }
  47161. function createSign (algorithm) {
  47162. return new Sign(algorithm)
  47163. }
  47164. function createVerify (algorithm) {
  47165. return new Verify(algorithm)
  47166. }
  47167. module.exports = {
  47168. Sign: createSign,
  47169. Verify: createVerify,
  47170. createSign: createSign,
  47171. createVerify: createVerify
  47172. }
  47173. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  47174. /***/ },
  47175. /* 291 */
  47176. /***/ function(module, exports, __webpack_require__) {
  47177. /* WEBPACK VAR INJECTION */(function(Buffer) {// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js
  47178. var createHmac = __webpack_require__(130)
  47179. var crt = __webpack_require__(103)
  47180. var curves = __webpack_require__(166)
  47181. var elliptic = __webpack_require__(20)
  47182. var parseKeys = __webpack_require__(97)
  47183. var BN = __webpack_require__(12)
  47184. var EC = elliptic.ec
  47185. function sign (hash, key, hashType, signType) {
  47186. var priv = parseKeys(key)
  47187. if (priv.curve) {
  47188. if (signType !== 'ecdsa') throw new Error('wrong private key type')
  47189. return ecSign(hash, priv)
  47190. } else if (priv.type === 'dsa') {
  47191. if (signType !== 'dsa') {
  47192. throw new Error('wrong private key type')
  47193. }
  47194. return dsaSign(hash, priv, hashType)
  47195. } else {
  47196. if (signType !== 'rsa') throw new Error('wrong private key type')
  47197. }
  47198. var len = priv.modulus.byteLength()
  47199. var pad = [ 0, 1 ]
  47200. while (hash.length + pad.length + 1 < len) {
  47201. pad.push(0xff)
  47202. }
  47203. pad.push(0x00)
  47204. var i = -1
  47205. while (++i < hash.length) {
  47206. pad.push(hash[i])
  47207. }
  47208. var out = crt(pad, priv)
  47209. return out
  47210. }
  47211. function ecSign (hash, priv) {
  47212. var curveId = curves[priv.curve.join('.')]
  47213. if (!curveId) throw new Error('unknown curve ' + priv.curve.join('.'))
  47214. var curve = new EC(curveId)
  47215. var key = curve.genKeyPair()
  47216. key._importPrivate(priv.privateKey)
  47217. var out = key.sign(hash)
  47218. return new Buffer(out.toDER())
  47219. }
  47220. function dsaSign (hash, priv, algo) {
  47221. var x = priv.params.priv_key
  47222. var p = priv.params.p
  47223. var q = priv.params.q
  47224. var g = priv.params.g
  47225. var r = new BN(0)
  47226. var k
  47227. var H = bits2int(hash, q).mod(q)
  47228. var s = false
  47229. var kv = getKey(x, q, hash, algo)
  47230. while (s === false) {
  47231. k = makeKey(q, kv, algo)
  47232. r = makeR(g, k, p, q)
  47233. s = k.invm(q).imul(H.add(x.mul(r))).mod(q)
  47234. if (!s.cmpn(0)) {
  47235. s = false
  47236. r = new BN(0)
  47237. }
  47238. }
  47239. return toDER(r, s)
  47240. }
  47241. function toDER (r, s) {
  47242. r = r.toArray()
  47243. s = s.toArray()
  47244. // Pad values
  47245. if (r[0] & 0x80) {
  47246. r = [ 0 ].concat(r)
  47247. }
  47248. // Pad values
  47249. if (s[0] & 0x80) {
  47250. s = [0].concat(s)
  47251. }
  47252. var total = r.length + s.length + 4
  47253. var res = [ 0x30, total, 0x02, r.length ]
  47254. res = res.concat(r, [ 0x02, s.length ], s)
  47255. return new Buffer(res)
  47256. }
  47257. function getKey (x, q, hash, algo) {
  47258. x = new Buffer(x.toArray())
  47259. if (x.length < q.byteLength()) {
  47260. var zeros = new Buffer(q.byteLength() - x.length)
  47261. zeros.fill(0)
  47262. x = Buffer.concat([zeros, x])
  47263. }
  47264. var hlen = hash.length
  47265. var hbits = bits2octets(hash, q)
  47266. var v = new Buffer(hlen)
  47267. v.fill(1)
  47268. var k = new Buffer(hlen)
  47269. k.fill(0)
  47270. k = createHmac(algo, k)
  47271. .update(v)
  47272. .update(new Buffer([0]))
  47273. .update(x)
  47274. .update(hbits)
  47275. .digest()
  47276. v = createHmac(algo, k)
  47277. .update(v)
  47278. .digest()
  47279. k = createHmac(algo, k)
  47280. .update(v)
  47281. .update(new Buffer([1]))
  47282. .update(x)
  47283. .update(hbits)
  47284. .digest()
  47285. v = createHmac(algo, k)
  47286. .update(v)
  47287. .digest()
  47288. return {
  47289. k: k,
  47290. v: v
  47291. }
  47292. }
  47293. function bits2int (obits, q) {
  47294. var bits = new BN(obits)
  47295. var shift = (obits.length << 3) - q.bitLength()
  47296. if (shift > 0) {
  47297. bits.ishrn(shift)
  47298. }
  47299. return bits
  47300. }
  47301. function bits2octets (bits, q) {
  47302. bits = bits2int(bits, q)
  47303. bits = bits.mod(q)
  47304. var out = new Buffer(bits.toArray())
  47305. if (out.length < q.byteLength()) {
  47306. var zeros = new Buffer(q.byteLength() - out.length)
  47307. zeros.fill(0)
  47308. out = Buffer.concat([zeros, out])
  47309. }
  47310. return out
  47311. }
  47312. function makeKey (q, kv, algo) {
  47313. var t, k
  47314. do {
  47315. t = new Buffer('')
  47316. while (t.length * 8 < q.bitLength()) {
  47317. kv.v = createHmac(algo, kv.k)
  47318. .update(kv.v)
  47319. .digest()
  47320. t = Buffer.concat([t, kv.v])
  47321. }
  47322. k = bits2int(t, q)
  47323. kv.k = createHmac(algo, kv.k)
  47324. .update(kv.v)
  47325. .update(new Buffer([0]))
  47326. .digest()
  47327. kv.v = createHmac(algo, kv.k)
  47328. .update(kv.v)
  47329. .digest()
  47330. } while (k.cmp(q) !== -1)
  47331. return k
  47332. }
  47333. function makeR (g, k, p, q) {
  47334. return g.toRed(BN.mont(p)).redPow(k).fromRed().mod(q)
  47335. }
  47336. module.exports = sign
  47337. module.exports.getKey = getKey
  47338. module.exports.makeKey = makeKey
  47339. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  47340. /***/ },
  47341. /* 292 */
  47342. /***/ function(module, exports, __webpack_require__) {
  47343. /* WEBPACK VAR INJECTION */(function(Buffer) {// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js
  47344. var curves = __webpack_require__(166)
  47345. var elliptic = __webpack_require__(20)
  47346. var parseKeys = __webpack_require__(97)
  47347. var BN = __webpack_require__(12)
  47348. var EC = elliptic.ec
  47349. function verify (sig, hash, key, signType) {
  47350. var pub = parseKeys(key)
  47351. if (pub.type === 'ec') {
  47352. if (signType !== 'ecdsa') {
  47353. throw new Error('wrong public key type')
  47354. }
  47355. return ecVerify(sig, hash, pub)
  47356. } else if (pub.type === 'dsa') {
  47357. if (signType !== 'dsa') {
  47358. throw new Error('wrong public key type')
  47359. }
  47360. return dsaVerify(sig, hash, pub)
  47361. } else {
  47362. if (signType !== 'rsa') {
  47363. throw new Error('wrong public key type')
  47364. }
  47365. }
  47366. var len = pub.modulus.byteLength()
  47367. var pad = [ 1 ]
  47368. var padNum = 0
  47369. while (hash.length + pad.length + 2 < len) {
  47370. pad.push(0xff)
  47371. padNum++
  47372. }
  47373. pad.push(0x00)
  47374. var i = -1
  47375. while (++i < hash.length) {
  47376. pad.push(hash[i])
  47377. }
  47378. pad = new Buffer(pad)
  47379. var red = BN.mont(pub.modulus)
  47380. sig = new BN(sig).toRed(red)
  47381. sig = sig.redPow(new BN(pub.publicExponent))
  47382. sig = new Buffer(sig.fromRed().toArray())
  47383. var out = 0
  47384. if (padNum < 8) {
  47385. out = 1
  47386. }
  47387. len = Math.min(sig.length, pad.length)
  47388. if (sig.length !== pad.length) {
  47389. out = 1
  47390. }
  47391. i = -1
  47392. while (++i < len) {
  47393. out |= (sig[i] ^ pad[i])
  47394. }
  47395. return out === 0
  47396. }
  47397. function ecVerify (sig, hash, pub) {
  47398. var curveId = curves[pub.data.algorithm.curve.join('.')]
  47399. if (!curveId) throw new Error('unknown curve ' + pub.data.algorithm.curve.join('.'))
  47400. var curve = new EC(curveId)
  47401. var pubkey = pub.data.subjectPrivateKey.data
  47402. return curve.verify(hash, sig, pubkey)
  47403. }
  47404. function dsaVerify (sig, hash, pub) {
  47405. var p = pub.data.p
  47406. var q = pub.data.q
  47407. var g = pub.data.g
  47408. var y = pub.data.pub_key
  47409. var unpacked = parseKeys.signature.decode(sig, 'der')
  47410. var s = unpacked.s
  47411. var r = unpacked.r
  47412. checkValue(s, q)
  47413. checkValue(r, q)
  47414. var montp = BN.mont(p)
  47415. var w = s.invm(q)
  47416. var v = g.toRed(montp)
  47417. .redPow(new BN(hash).mul(w).mod(q))
  47418. .fromRed()
  47419. .mul(
  47420. y.toRed(montp)
  47421. .redPow(r.mul(w).mod(q))
  47422. .fromRed()
  47423. ).mod(p).mod(q)
  47424. return !v.cmp(r)
  47425. }
  47426. function checkValue (b, q) {
  47427. if (b.cmpn(0) <= 0) {
  47428. throw new Error('invalid sig')
  47429. }
  47430. if (b.cmp(q) >= q) {
  47431. throw new Error('invalid sig')
  47432. }
  47433. }
  47434. module.exports = verify
  47435. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  47436. /***/ },
  47437. /* 293 */
  47438. /***/ function(module, exports) {
  47439. module.exports = {
  47440. "100": "Continue",
  47441. "101": "Switching Protocols",
  47442. "102": "Processing",
  47443. "200": "OK",
  47444. "201": "Created",
  47445. "202": "Accepted",
  47446. "203": "Non-Authoritative Information",
  47447. "204": "No Content",
  47448. "205": "Reset Content",
  47449. "206": "Partial Content",
  47450. "207": "Multi-Status",
  47451. "208": "Already Reported",
  47452. "226": "IM Used",
  47453. "300": "Multiple Choices",
  47454. "301": "Moved Permanently",
  47455. "302": "Found",
  47456. "303": "See Other",
  47457. "304": "Not Modified",
  47458. "305": "Use Proxy",
  47459. "307": "Temporary Redirect",
  47460. "308": "Permanent Redirect",
  47461. "400": "Bad Request",
  47462. "401": "Unauthorized",
  47463. "402": "Payment Required",
  47464. "403": "Forbidden",
  47465. "404": "Not Found",
  47466. "405": "Method Not Allowed",
  47467. "406": "Not Acceptable",
  47468. "407": "Proxy Authentication Required",
  47469. "408": "Request Timeout",
  47470. "409": "Conflict",
  47471. "410": "Gone",
  47472. "411": "Length Required",
  47473. "412": "Precondition Failed",
  47474. "413": "Payload Too Large",
  47475. "414": "URI Too Long",
  47476. "415": "Unsupported Media Type",
  47477. "416": "Range Not Satisfiable",
  47478. "417": "Expectation Failed",
  47479. "418": "I'm a teapot",
  47480. "421": "Misdirected Request",
  47481. "422": "Unprocessable Entity",
  47482. "423": "Locked",
  47483. "424": "Failed Dependency",
  47484. "425": "Unordered Collection",
  47485. "426": "Upgrade Required",
  47486. "428": "Precondition Required",
  47487. "429": "Too Many Requests",
  47488. "431": "Request Header Fields Too Large",
  47489. "500": "Internal Server Error",
  47490. "501": "Not Implemented",
  47491. "502": "Bad Gateway",
  47492. "503": "Service Unavailable",
  47493. "504": "Gateway Timeout",
  47494. "505": "HTTP Version Not Supported",
  47495. "506": "Variant Also Negotiates",
  47496. "507": "Insufficient Storage",
  47497. "508": "Loop Detected",
  47498. "509": "Bandwidth Limit Exceeded",
  47499. "510": "Not Extended",
  47500. "511": "Network Authentication Required"
  47501. }
  47502. /***/ },
  47503. /* 294 */
  47504. /***/ function(module, exports) {
  47505. module.exports = function (xs, fn) {
  47506. var res = [];
  47507. for (var i = 0; i < xs.length; i++) {
  47508. var x = fn(xs[i], i);
  47509. if (isArray(x)) res.push.apply(res, x);
  47510. else res.push(x);
  47511. }
  47512. return res;
  47513. };
  47514. var isArray = Array.isArray || function (xs) {
  47515. return Object.prototype.toString.call(xs) === '[object Array]';
  47516. };
  47517. /***/ },
  47518. /* 295 */
  47519. /***/ function(module, exports, __webpack_require__) {
  47520. __webpack_require__(305);
  47521. module.exports = __webpack_require__(32).RegExp.escape;
  47522. /***/ },
  47523. /* 296 */
  47524. /***/ function(module, exports, __webpack_require__) {
  47525. var isObject = __webpack_require__(7)
  47526. , isArray = __webpack_require__(112)
  47527. , SPECIES = __webpack_require__(8)('species');
  47528. module.exports = function(original){
  47529. var C;
  47530. if(isArray(original)){
  47531. C = original.constructor;
  47532. // cross-realm fallback
  47533. if(typeof C == 'function' && (C === Array || isArray(C.prototype)))C = undefined;
  47534. if(isObject(C)){
  47535. C = C[SPECIES];
  47536. if(C === null)C = undefined;
  47537. }
  47538. } return C === undefined ? Array : C;
  47539. };
  47540. /***/ },
  47541. /* 297 */
  47542. /***/ function(module, exports, __webpack_require__) {
  47543. // 9.4.2.3 ArraySpeciesCreate(originalArray, length)
  47544. var speciesConstructor = __webpack_require__(296);
  47545. module.exports = function(original, length){
  47546. return new (speciesConstructor(original))(length);
  47547. };
  47548. /***/ },
  47549. /* 298 */
  47550. /***/ function(module, exports, __webpack_require__) {
  47551. "use strict";
  47552. 'use strict';
  47553. var anObject = __webpack_require__(3)
  47554. , toPrimitive = __webpack_require__(34)
  47555. , NUMBER = 'number';
  47556. module.exports = function(hint){
  47557. if(hint !== 'string' && hint !== NUMBER && hint !== 'default')throw TypeError('Incorrect hint');
  47558. return toPrimitive(anObject(this), hint != NUMBER);
  47559. };
  47560. /***/ },
  47561. /* 299 */
  47562. /***/ function(module, exports, __webpack_require__) {
  47563. // all enumerable object keys, includes symbols
  47564. var getKeys = __webpack_require__(49)
  47565. , gOPS = __webpack_require__(90)
  47566. , pIE = __webpack_require__(71);
  47567. module.exports = function(it){
  47568. var result = getKeys(it)
  47569. , getSymbols = gOPS.f;
  47570. if(getSymbols){
  47571. var symbols = getSymbols(it)
  47572. , isEnum = pIE.f
  47573. , i = 0
  47574. , key;
  47575. while(symbols.length > i)if(isEnum.call(it, key = symbols[i++]))result.push(key);
  47576. } return result;
  47577. };
  47578. /***/ },
  47579. /* 300 */
  47580. /***/ function(module, exports, __webpack_require__) {
  47581. var getKeys = __webpack_require__(49)
  47582. , toIObject = __webpack_require__(24);
  47583. module.exports = function(object, el){
  47584. var O = toIObject(object)
  47585. , keys = getKeys(O)
  47586. , length = keys.length
  47587. , index = 0
  47588. , key;
  47589. while(length > index)if(O[key = keys[index++]] === el)return key;
  47590. };
  47591. /***/ },
  47592. /* 301 */
  47593. /***/ function(module, exports, __webpack_require__) {
  47594. "use strict";
  47595. 'use strict';
  47596. var path = __webpack_require__(302)
  47597. , invoke = __webpack_require__(86)
  47598. , aFunction = __webpack_require__(21);
  47599. module.exports = function(/* ...pargs */){
  47600. var fn = aFunction(this)
  47601. , length = arguments.length
  47602. , pargs = Array(length)
  47603. , i = 0
  47604. , _ = path._
  47605. , holder = false;
  47606. while(length > i)if((pargs[i] = arguments[i++]) === _)holder = true;
  47607. return function(/* ...args */){
  47608. var that = this
  47609. , aLen = arguments.length
  47610. , j = 0, k = 0, args;
  47611. if(!holder && !aLen)return invoke(fn, pargs, that);
  47612. args = pargs.slice();
  47613. if(holder)for(;length > j; j++)if(args[j] === _)args[j] = arguments[k++];
  47614. while(aLen > k)args.push(arguments[k++]);
  47615. return invoke(fn, args, that);
  47616. };
  47617. };
  47618. /***/ },
  47619. /* 302 */
  47620. /***/ function(module, exports, __webpack_require__) {
  47621. module.exports = __webpack_require__(5);
  47622. /***/ },
  47623. /* 303 */
  47624. /***/ function(module, exports) {
  47625. module.exports = function(regExp, replace){
  47626. var replacer = replace === Object(replace) ? function(part){
  47627. return replace[part];
  47628. } : replace;
  47629. return function(it){
  47630. return String(it).replace(regExp, replacer);
  47631. };
  47632. };
  47633. /***/ },
  47634. /* 304 */
  47635. /***/ function(module, exports, __webpack_require__) {
  47636. var classof = __webpack_require__(59)
  47637. , ITERATOR = __webpack_require__(8)('iterator')
  47638. , Iterators = __webpack_require__(45);
  47639. module.exports = __webpack_require__(32).isIterable = function(it){
  47640. var O = Object(it);
  47641. return O[ITERATOR] !== undefined
  47642. || '@@iterator' in O
  47643. || Iterators.hasOwnProperty(classof(O));
  47644. };
  47645. /***/ },
  47646. /* 305 */
  47647. /***/ function(module, exports, __webpack_require__) {
  47648. // https://github.com/benjamingr/RexExp.escape
  47649. var $export = __webpack_require__(0)
  47650. , $re = __webpack_require__(303)(/[\\^$*+?.()|[\]{}]/g, '\\$&');
  47651. $export($export.S, 'RegExp', {escape: function escape(it){ return $re(it); }});
  47652. /***/ },
  47653. /* 306 */
  47654. /***/ function(module, exports, __webpack_require__) {
  47655. // 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length)
  47656. var $export = __webpack_require__(0);
  47657. $export($export.P, 'Array', {copyWithin: __webpack_require__(169)});
  47658. __webpack_require__(58)('copyWithin');
  47659. /***/ },
  47660. /* 307 */
  47661. /***/ function(module, exports, __webpack_require__) {
  47662. "use strict";
  47663. 'use strict';
  47664. var $export = __webpack_require__(0)
  47665. , $every = __webpack_require__(31)(4);
  47666. $export($export.P + $export.F * !__webpack_require__(29)([].every, true), 'Array', {
  47667. // 22.1.3.5 / 15.4.4.16 Array.prototype.every(callbackfn [, thisArg])
  47668. every: function every(callbackfn /* , thisArg */){
  47669. return $every(this, callbackfn, arguments[1]);
  47670. }
  47671. });
  47672. /***/ },
  47673. /* 308 */
  47674. /***/ function(module, exports, __webpack_require__) {
  47675. // 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length)
  47676. var $export = __webpack_require__(0);
  47677. $export($export.P, 'Array', {fill: __webpack_require__(104)});
  47678. __webpack_require__(58)('fill');
  47679. /***/ },
  47680. /* 309 */
  47681. /***/ function(module, exports, __webpack_require__) {
  47682. "use strict";
  47683. 'use strict';
  47684. var $export = __webpack_require__(0)
  47685. , $filter = __webpack_require__(31)(2);
  47686. $export($export.P + $export.F * !__webpack_require__(29)([].filter, true), 'Array', {
  47687. // 22.1.3.7 / 15.4.4.20 Array.prototype.filter(callbackfn [, thisArg])
  47688. filter: function filter(callbackfn /* , thisArg */){
  47689. return $filter(this, callbackfn, arguments[1]);
  47690. }
  47691. });
  47692. /***/ },
  47693. /* 310 */
  47694. /***/ function(module, exports, __webpack_require__) {
  47695. "use strict";
  47696. 'use strict';
  47697. // 22.1.3.9 Array.prototype.findIndex(predicate, thisArg = undefined)
  47698. var $export = __webpack_require__(0)
  47699. , $find = __webpack_require__(31)(6)
  47700. , KEY = 'findIndex'
  47701. , forced = true;
  47702. // Shouldn't skip holes
  47703. if(KEY in [])Array(1)[KEY](function(){ forced = false; });
  47704. $export($export.P + $export.F * forced, 'Array', {
  47705. findIndex: function findIndex(callbackfn/*, that = undefined */){
  47706. return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  47707. }
  47708. });
  47709. __webpack_require__(58)(KEY);
  47710. /***/ },
  47711. /* 311 */
  47712. /***/ function(module, exports, __webpack_require__) {
  47713. "use strict";
  47714. 'use strict';
  47715. // 22.1.3.8 Array.prototype.find(predicate, thisArg = undefined)
  47716. var $export = __webpack_require__(0)
  47717. , $find = __webpack_require__(31)(5)
  47718. , KEY = 'find'
  47719. , forced = true;
  47720. // Shouldn't skip holes
  47721. if(KEY in [])Array(1)[KEY](function(){ forced = false; });
  47722. $export($export.P + $export.F * forced, 'Array', {
  47723. find: function find(callbackfn/*, that = undefined */){
  47724. return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  47725. }
  47726. });
  47727. __webpack_require__(58)(KEY);
  47728. /***/ },
  47729. /* 312 */
  47730. /***/ function(module, exports, __webpack_require__) {
  47731. "use strict";
  47732. 'use strict';
  47733. var $export = __webpack_require__(0)
  47734. , $forEach = __webpack_require__(31)(0)
  47735. , STRICT = __webpack_require__(29)([].forEach, true);
  47736. $export($export.P + $export.F * !STRICT, 'Array', {
  47737. // 22.1.3.10 / 15.4.4.18 Array.prototype.forEach(callbackfn [, thisArg])
  47738. forEach: function forEach(callbackfn /* , thisArg */){
  47739. return $forEach(this, callbackfn, arguments[1]);
  47740. }
  47741. });
  47742. /***/ },
  47743. /* 313 */
  47744. /***/ function(module, exports, __webpack_require__) {
  47745. "use strict";
  47746. 'use strict';
  47747. var ctx = __webpack_require__(35)
  47748. , $export = __webpack_require__(0)
  47749. , toObject = __webpack_require__(16)
  47750. , call = __webpack_require__(177)
  47751. , isArrayIter = __webpack_require__(111)
  47752. , toLength = __webpack_require__(15)
  47753. , createProperty = __webpack_require__(105)
  47754. , getIterFn = __webpack_require__(128);
  47755. $export($export.S + $export.F * !__webpack_require__(88)(function(iter){ Array.from(iter); }), 'Array', {
  47756. // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)
  47757. from: function from(arrayLike/*, mapfn = undefined, thisArg = undefined*/){
  47758. var O = toObject(arrayLike)
  47759. , C = typeof this == 'function' ? this : Array
  47760. , aLen = arguments.length
  47761. , mapfn = aLen > 1 ? arguments[1] : undefined
  47762. , mapping = mapfn !== undefined
  47763. , index = 0
  47764. , iterFn = getIterFn(O)
  47765. , length, result, step, iterator;
  47766. if(mapping)mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);
  47767. // if object isn't iterable or it's array with default iterator - use simple case
  47768. if(iterFn != undefined && !(C == Array && isArrayIter(iterFn))){
  47769. for(iterator = iterFn.call(O), result = new C; !(step = iterator.next()).done; index++){
  47770. createProperty(result, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value);
  47771. }
  47772. } else {
  47773. length = toLength(O.length);
  47774. for(result = new C(length); length > index; index++){
  47775. createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);
  47776. }
  47777. }
  47778. result.length = index;
  47779. return result;
  47780. }
  47781. });
  47782. /***/ },
  47783. /* 314 */
  47784. /***/ function(module, exports, __webpack_require__) {
  47785. "use strict";
  47786. 'use strict';
  47787. var $export = __webpack_require__(0)
  47788. , $indexOf = __webpack_require__(82)(false)
  47789. , $native = [].indexOf
  47790. , NEGATIVE_ZERO = !!$native && 1 / [1].indexOf(1, -0) < 0;
  47791. $export($export.P + $export.F * (NEGATIVE_ZERO || !__webpack_require__(29)($native)), 'Array', {
  47792. // 22.1.3.11 / 15.4.4.14 Array.prototype.indexOf(searchElement [, fromIndex])
  47793. indexOf: function indexOf(searchElement /*, fromIndex = 0 */){
  47794. return NEGATIVE_ZERO
  47795. // convert -0 to +0
  47796. ? $native.apply(this, arguments) || 0
  47797. : $indexOf(this, searchElement, arguments[1]);
  47798. }
  47799. });
  47800. /***/ },
  47801. /* 315 */
  47802. /***/ function(module, exports, __webpack_require__) {
  47803. // 22.1.2.2 / 15.4.3.2 Array.isArray(arg)
  47804. var $export = __webpack_require__(0);
  47805. $export($export.S, 'Array', {isArray: __webpack_require__(112)});
  47806. /***/ },
  47807. /* 316 */
  47808. /***/ function(module, exports, __webpack_require__) {
  47809. "use strict";
  47810. 'use strict';
  47811. // 22.1.3.13 Array.prototype.join(separator)
  47812. var $export = __webpack_require__(0)
  47813. , toIObject = __webpack_require__(24)
  47814. , arrayJoin = [].join;
  47815. // fallback for not array-like strings
  47816. $export($export.P + $export.F * (__webpack_require__(70) != Object || !__webpack_require__(29)(arrayJoin)), 'Array', {
  47817. join: function join(separator){
  47818. return arrayJoin.call(toIObject(this), separator === undefined ? ',' : separator);
  47819. }
  47820. });
  47821. /***/ },
  47822. /* 317 */
  47823. /***/ function(module, exports, __webpack_require__) {
  47824. "use strict";
  47825. 'use strict';
  47826. var $export = __webpack_require__(0)
  47827. , toIObject = __webpack_require__(24)
  47828. , toInteger = __webpack_require__(42)
  47829. , toLength = __webpack_require__(15)
  47830. , $native = [].lastIndexOf
  47831. , NEGATIVE_ZERO = !!$native && 1 / [1].lastIndexOf(1, -0) < 0;
  47832. $export($export.P + $export.F * (NEGATIVE_ZERO || !__webpack_require__(29)($native)), 'Array', {
  47833. // 22.1.3.14 / 15.4.4.15 Array.prototype.lastIndexOf(searchElement [, fromIndex])
  47834. lastIndexOf: function lastIndexOf(searchElement /*, fromIndex = @[*-1] */){
  47835. // convert -0 to +0
  47836. if(NEGATIVE_ZERO)return $native.apply(this, arguments) || 0;
  47837. var O = toIObject(this)
  47838. , length = toLength(O.length)
  47839. , index = length - 1;
  47840. if(arguments.length > 1)index = Math.min(index, toInteger(arguments[1]));
  47841. if(index < 0)index = length + index;
  47842. for(;index >= 0; index--)if(index in O)if(O[index] === searchElement)return index || 0;
  47843. return -1;
  47844. }
  47845. });
  47846. /***/ },
  47847. /* 318 */
  47848. /***/ function(module, exports, __webpack_require__) {
  47849. "use strict";
  47850. 'use strict';
  47851. var $export = __webpack_require__(0)
  47852. , $map = __webpack_require__(31)(1);
  47853. $export($export.P + $export.F * !__webpack_require__(29)([].map, true), 'Array', {
  47854. // 22.1.3.15 / 15.4.4.19 Array.prototype.map(callbackfn [, thisArg])
  47855. map: function map(callbackfn /* , thisArg */){
  47856. return $map(this, callbackfn, arguments[1]);
  47857. }
  47858. });
  47859. /***/ },
  47860. /* 319 */
  47861. /***/ function(module, exports, __webpack_require__) {
  47862. "use strict";
  47863. 'use strict';
  47864. var $export = __webpack_require__(0)
  47865. , createProperty = __webpack_require__(105);
  47866. // WebKit Array.of isn't generic
  47867. $export($export.S + $export.F * __webpack_require__(6)(function(){
  47868. function F(){}
  47869. return !(Array.of.call(F) instanceof F);
  47870. }), 'Array', {
  47871. // 22.1.2.3 Array.of( ...items)
  47872. of: function of(/* ...args */){
  47873. var index = 0
  47874. , aLen = arguments.length
  47875. , result = new (typeof this == 'function' ? this : Array)(aLen);
  47876. while(aLen > index)createProperty(result, index, arguments[index++]);
  47877. result.length = aLen;
  47878. return result;
  47879. }
  47880. });
  47881. /***/ },
  47882. /* 320 */
  47883. /***/ function(module, exports, __webpack_require__) {
  47884. "use strict";
  47885. 'use strict';
  47886. var $export = __webpack_require__(0)
  47887. , $reduce = __webpack_require__(171);
  47888. $export($export.P + $export.F * !__webpack_require__(29)([].reduceRight, true), 'Array', {
  47889. // 22.1.3.19 / 15.4.4.22 Array.prototype.reduceRight(callbackfn [, initialValue])
  47890. reduceRight: function reduceRight(callbackfn /* , initialValue */){
  47891. return $reduce(this, callbackfn, arguments.length, arguments[1], true);
  47892. }
  47893. });
  47894. /***/ },
  47895. /* 321 */
  47896. /***/ function(module, exports, __webpack_require__) {
  47897. "use strict";
  47898. 'use strict';
  47899. var $export = __webpack_require__(0)
  47900. , $reduce = __webpack_require__(171);
  47901. $export($export.P + $export.F * !__webpack_require__(29)([].reduce, true), 'Array', {
  47902. // 22.1.3.18 / 15.4.4.21 Array.prototype.reduce(callbackfn [, initialValue])
  47903. reduce: function reduce(callbackfn /* , initialValue */){
  47904. return $reduce(this, callbackfn, arguments.length, arguments[1], false);
  47905. }
  47906. });
  47907. /***/ },
  47908. /* 322 */
  47909. /***/ function(module, exports, __webpack_require__) {
  47910. "use strict";
  47911. 'use strict';
  47912. var $export = __webpack_require__(0)
  47913. , html = __webpack_require__(109)
  47914. , cof = __webpack_require__(27)
  47915. , toIndex = __webpack_require__(52)
  47916. , toLength = __webpack_require__(15)
  47917. , arraySlice = [].slice;
  47918. // fallback for not array-like ES3 strings and DOM objects
  47919. $export($export.P + $export.F * __webpack_require__(6)(function(){
  47920. if(html)arraySlice.call(html);
  47921. }), 'Array', {
  47922. slice: function slice(begin, end){
  47923. var len = toLength(this.length)
  47924. , klass = cof(this);
  47925. end = end === undefined ? len : end;
  47926. if(klass == 'Array')return arraySlice.call(this, begin, end);
  47927. var start = toIndex(begin, len)
  47928. , upTo = toIndex(end, len)
  47929. , size = toLength(upTo - start)
  47930. , cloned = Array(size)
  47931. , i = 0;
  47932. for(; i < size; i++)cloned[i] = klass == 'String'
  47933. ? this.charAt(start + i)
  47934. : this[start + i];
  47935. return cloned;
  47936. }
  47937. });
  47938. /***/ },
  47939. /* 323 */
  47940. /***/ function(module, exports, __webpack_require__) {
  47941. "use strict";
  47942. 'use strict';
  47943. var $export = __webpack_require__(0)
  47944. , $some = __webpack_require__(31)(3);
  47945. $export($export.P + $export.F * !__webpack_require__(29)([].some, true), 'Array', {
  47946. // 22.1.3.23 / 15.4.4.17 Array.prototype.some(callbackfn [, thisArg])
  47947. some: function some(callbackfn /* , thisArg */){
  47948. return $some(this, callbackfn, arguments[1]);
  47949. }
  47950. });
  47951. /***/ },
  47952. /* 324 */
  47953. /***/ function(module, exports, __webpack_require__) {
  47954. "use strict";
  47955. 'use strict';
  47956. var $export = __webpack_require__(0)
  47957. , aFunction = __webpack_require__(21)
  47958. , toObject = __webpack_require__(16)
  47959. , fails = __webpack_require__(6)
  47960. , $sort = [].sort
  47961. , test = [1, 2, 3];
  47962. $export($export.P + $export.F * (fails(function(){
  47963. // IE8-
  47964. test.sort(undefined);
  47965. }) || !fails(function(){
  47966. // V8 bug
  47967. test.sort(null);
  47968. // Old WebKit
  47969. }) || !__webpack_require__(29)($sort)), 'Array', {
  47970. // 22.1.3.25 Array.prototype.sort(comparefn)
  47971. sort: function sort(comparefn){
  47972. return comparefn === undefined
  47973. ? $sort.call(toObject(this))
  47974. : $sort.call(toObject(this), aFunction(comparefn));
  47975. }
  47976. });
  47977. /***/ },
  47978. /* 325 */
  47979. /***/ function(module, exports, __webpack_require__) {
  47980. __webpack_require__(51)('Array');
  47981. /***/ },
  47982. /* 326 */
  47983. /***/ function(module, exports, __webpack_require__) {
  47984. // 20.3.3.1 / 15.9.4.4 Date.now()
  47985. var $export = __webpack_require__(0);
  47986. $export($export.S, 'Date', {now: function(){ return new Date().getTime(); }});
  47987. /***/ },
  47988. /* 327 */
  47989. /***/ function(module, exports, __webpack_require__) {
  47990. "use strict";
  47991. 'use strict';
  47992. // 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString()
  47993. var $export = __webpack_require__(0)
  47994. , fails = __webpack_require__(6)
  47995. , getTime = Date.prototype.getTime;
  47996. var lz = function(num){
  47997. return num > 9 ? num : '0' + num;
  47998. };
  47999. // PhantomJS / old WebKit has a broken implementations
  48000. $export($export.P + $export.F * (fails(function(){
  48001. return new Date(-5e13 - 1).toISOString() != '0385-07-25T07:06:39.999Z';
  48002. }) || !fails(function(){
  48003. new Date(NaN).toISOString();
  48004. })), 'Date', {
  48005. toISOString: function toISOString(){
  48006. if(!isFinite(getTime.call(this)))throw RangeError('Invalid time value');
  48007. var d = this
  48008. , y = d.getUTCFullYear()
  48009. , m = d.getUTCMilliseconds()
  48010. , s = y < 0 ? '-' : y > 9999 ? '+' : '';
  48011. return s + ('00000' + Math.abs(y)).slice(s ? -6 : -4) +
  48012. '-' + lz(d.getUTCMonth() + 1) + '-' + lz(d.getUTCDate()) +
  48013. 'T' + lz(d.getUTCHours()) + ':' + lz(d.getUTCMinutes()) +
  48014. ':' + lz(d.getUTCSeconds()) + '.' + (m > 99 ? m : '0' + lz(m)) + 'Z';
  48015. }
  48016. });
  48017. /***/ },
  48018. /* 328 */
  48019. /***/ function(module, exports, __webpack_require__) {
  48020. "use strict";
  48021. 'use strict';
  48022. var $export = __webpack_require__(0)
  48023. , toObject = __webpack_require__(16)
  48024. , toPrimitive = __webpack_require__(34);
  48025. $export($export.P + $export.F * __webpack_require__(6)(function(){
  48026. return new Date(NaN).toJSON() !== null || Date.prototype.toJSON.call({toISOString: function(){ return 1; }}) !== 1;
  48027. }), 'Date', {
  48028. toJSON: function toJSON(key){
  48029. var O = toObject(this)
  48030. , pv = toPrimitive(O);
  48031. return typeof pv == 'number' && !isFinite(pv) ? null : O.toISOString();
  48032. }
  48033. });
  48034. /***/ },
  48035. /* 329 */
  48036. /***/ function(module, exports, __webpack_require__) {
  48037. var TO_PRIMITIVE = __webpack_require__(8)('toPrimitive')
  48038. , proto = Date.prototype;
  48039. if(!(TO_PRIMITIVE in proto))__webpack_require__(19)(proto, TO_PRIMITIVE, __webpack_require__(298));
  48040. /***/ },
  48041. /* 330 */
  48042. /***/ function(module, exports, __webpack_require__) {
  48043. var DateProto = Date.prototype
  48044. , INVALID_DATE = 'Invalid Date'
  48045. , TO_STRING = 'toString'
  48046. , $toString = DateProto[TO_STRING]
  48047. , getTime = DateProto.getTime;
  48048. if(new Date(NaN) + '' != INVALID_DATE){
  48049. __webpack_require__(22)(DateProto, TO_STRING, function toString(){
  48050. var value = getTime.call(this);
  48051. return value === value ? $toString.call(this) : INVALID_DATE;
  48052. });
  48053. }
  48054. /***/ },
  48055. /* 331 */
  48056. /***/ function(module, exports, __webpack_require__) {
  48057. // 19.2.3.2 / 15.3.4.5 Function.prototype.bind(thisArg, args...)
  48058. var $export = __webpack_require__(0);
  48059. $export($export.P, 'Function', {bind: __webpack_require__(172)});
  48060. /***/ },
  48061. /* 332 */
  48062. /***/ function(module, exports, __webpack_require__) {
  48063. "use strict";
  48064. 'use strict';
  48065. var isObject = __webpack_require__(7)
  48066. , getPrototypeOf = __webpack_require__(26)
  48067. , HAS_INSTANCE = __webpack_require__(8)('hasInstance')
  48068. , FunctionProto = Function.prototype;
  48069. // 19.2.3.6 Function.prototype[@@hasInstance](V)
  48070. if(!(HAS_INSTANCE in FunctionProto))__webpack_require__(11).f(FunctionProto, HAS_INSTANCE, {value: function(O){
  48071. if(typeof this != 'function' || !isObject(O))return false;
  48072. if(!isObject(this.prototype))return O instanceof this;
  48073. // for environment w/o native `@@hasInstance` logic enough `instanceof`, but add this:
  48074. while(O = getPrototypeOf(O))if(this.prototype === O)return true;
  48075. return false;
  48076. }});
  48077. /***/ },
  48078. /* 333 */
  48079. /***/ function(module, exports, __webpack_require__) {
  48080. var dP = __webpack_require__(11).f
  48081. , createDesc = __webpack_require__(41)
  48082. , has = __webpack_require__(17)
  48083. , FProto = Function.prototype
  48084. , nameRE = /^\s*function ([^ (]*)/
  48085. , NAME = 'name';
  48086. var isExtensible = Object.isExtensible || function(){
  48087. return true;
  48088. };
  48089. // 19.2.4.2 name
  48090. NAME in FProto || __webpack_require__(10) && dP(FProto, NAME, {
  48091. configurable: true,
  48092. get: function(){
  48093. try {
  48094. var that = this
  48095. , name = ('' + that).match(nameRE)[1];
  48096. has(that, NAME) || !isExtensible(that) || dP(that, NAME, createDesc(5, name));
  48097. return name;
  48098. } catch(e){
  48099. return '';
  48100. }
  48101. }
  48102. });
  48103. /***/ },
  48104. /* 334 */
  48105. /***/ function(module, exports, __webpack_require__) {
  48106. // 20.2.2.3 Math.acosh(x)
  48107. var $export = __webpack_require__(0)
  48108. , log1p = __webpack_require__(179)
  48109. , sqrt = Math.sqrt
  48110. , $acosh = Math.acosh;
  48111. $export($export.S + $export.F * !($acosh
  48112. // V8 bug: https://code.google.com/p/v8/issues/detail?id=3509
  48113. && Math.floor($acosh(Number.MAX_VALUE)) == 710
  48114. // Tor Browser bug: Math.acosh(Infinity) -> NaN
  48115. && $acosh(Infinity) == Infinity
  48116. ), 'Math', {
  48117. acosh: function acosh(x){
  48118. return (x = +x) < 1 ? NaN : x > 94906265.62425156
  48119. ? Math.log(x) + Math.LN2
  48120. : log1p(x - 1 + sqrt(x - 1) * sqrt(x + 1));
  48121. }
  48122. });
  48123. /***/ },
  48124. /* 335 */
  48125. /***/ function(module, exports, __webpack_require__) {
  48126. // 20.2.2.5 Math.asinh(x)
  48127. var $export = __webpack_require__(0)
  48128. , $asinh = Math.asinh;
  48129. function asinh(x){
  48130. return !isFinite(x = +x) || x == 0 ? x : x < 0 ? -asinh(-x) : Math.log(x + Math.sqrt(x * x + 1));
  48131. }
  48132. // Tor Browser bug: Math.asinh(0) -> -0
  48133. $export($export.S + $export.F * !($asinh && 1 / $asinh(0) > 0), 'Math', {asinh: asinh});
  48134. /***/ },
  48135. /* 336 */
  48136. /***/ function(module, exports, __webpack_require__) {
  48137. // 20.2.2.7 Math.atanh(x)
  48138. var $export = __webpack_require__(0)
  48139. , $atanh = Math.atanh;
  48140. // Tor Browser bug: Math.atanh(-0) -> 0
  48141. $export($export.S + $export.F * !($atanh && 1 / $atanh(-0) < 0), 'Math', {
  48142. atanh: function atanh(x){
  48143. return (x = +x) == 0 ? x : Math.log((1 + x) / (1 - x)) / 2;
  48144. }
  48145. });
  48146. /***/ },
  48147. /* 337 */
  48148. /***/ function(module, exports, __webpack_require__) {
  48149. // 20.2.2.9 Math.cbrt(x)
  48150. var $export = __webpack_require__(0)
  48151. , sign = __webpack_require__(117);
  48152. $export($export.S, 'Math', {
  48153. cbrt: function cbrt(x){
  48154. return sign(x = +x) * Math.pow(Math.abs(x), 1 / 3);
  48155. }
  48156. });
  48157. /***/ },
  48158. /* 338 */
  48159. /***/ function(module, exports, __webpack_require__) {
  48160. // 20.2.2.11 Math.clz32(x)
  48161. var $export = __webpack_require__(0);
  48162. $export($export.S, 'Math', {
  48163. clz32: function clz32(x){
  48164. return (x >>>= 0) ? 31 - Math.floor(Math.log(x + 0.5) * Math.LOG2E) : 32;
  48165. }
  48166. });
  48167. /***/ },
  48168. /* 339 */
  48169. /***/ function(module, exports, __webpack_require__) {
  48170. // 20.2.2.12 Math.cosh(x)
  48171. var $export = __webpack_require__(0)
  48172. , exp = Math.exp;
  48173. $export($export.S, 'Math', {
  48174. cosh: function cosh(x){
  48175. return (exp(x = +x) + exp(-x)) / 2;
  48176. }
  48177. });
  48178. /***/ },
  48179. /* 340 */
  48180. /***/ function(module, exports, __webpack_require__) {
  48181. // 20.2.2.14 Math.expm1(x)
  48182. var $export = __webpack_require__(0)
  48183. , $expm1 = __webpack_require__(116);
  48184. $export($export.S + $export.F * ($expm1 != Math.expm1), 'Math', {expm1: $expm1});
  48185. /***/ },
  48186. /* 341 */
  48187. /***/ function(module, exports, __webpack_require__) {
  48188. // 20.2.2.16 Math.fround(x)
  48189. var $export = __webpack_require__(0)
  48190. , sign = __webpack_require__(117)
  48191. , pow = Math.pow
  48192. , EPSILON = pow(2, -52)
  48193. , EPSILON32 = pow(2, -23)
  48194. , MAX32 = pow(2, 127) * (2 - EPSILON32)
  48195. , MIN32 = pow(2, -126);
  48196. var roundTiesToEven = function(n){
  48197. return n + 1 / EPSILON - 1 / EPSILON;
  48198. };
  48199. $export($export.S, 'Math', {
  48200. fround: function fround(x){
  48201. var $abs = Math.abs(x)
  48202. , $sign = sign(x)
  48203. , a, result;
  48204. if($abs < MIN32)return $sign * roundTiesToEven($abs / MIN32 / EPSILON32) * MIN32 * EPSILON32;
  48205. a = (1 + EPSILON32 / EPSILON) * $abs;
  48206. result = a - (a - $abs);
  48207. if(result > MAX32 || result != result)return $sign * Infinity;
  48208. return $sign * result;
  48209. }
  48210. });
  48211. /***/ },
  48212. /* 342 */
  48213. /***/ function(module, exports, __webpack_require__) {
  48214. // 20.2.2.17 Math.hypot([value1[, value2[, … ]]])
  48215. var $export = __webpack_require__(0)
  48216. , abs = Math.abs;
  48217. $export($export.S, 'Math', {
  48218. hypot: function hypot(value1, value2){ // eslint-disable-line no-unused-vars
  48219. var sum = 0
  48220. , i = 0
  48221. , aLen = arguments.length
  48222. , larg = 0
  48223. , arg, div;
  48224. while(i < aLen){
  48225. arg = abs(arguments[i++]);
  48226. if(larg < arg){
  48227. div = larg / arg;
  48228. sum = sum * div * div + 1;
  48229. larg = arg;
  48230. } else if(arg > 0){
  48231. div = arg / larg;
  48232. sum += div * div;
  48233. } else sum += arg;
  48234. }
  48235. return larg === Infinity ? Infinity : larg * Math.sqrt(sum);
  48236. }
  48237. });
  48238. /***/ },
  48239. /* 343 */
  48240. /***/ function(module, exports, __webpack_require__) {
  48241. // 20.2.2.18 Math.imul(x, y)
  48242. var $export = __webpack_require__(0)
  48243. , $imul = Math.imul;
  48244. // some WebKit versions fails with big numbers, some has wrong arity
  48245. $export($export.S + $export.F * __webpack_require__(6)(function(){
  48246. return $imul(0xffffffff, 5) != -5 || $imul.length != 2;
  48247. }), 'Math', {
  48248. imul: function imul(x, y){
  48249. var UINT16 = 0xffff
  48250. , xn = +x
  48251. , yn = +y
  48252. , xl = UINT16 & xn
  48253. , yl = UINT16 & yn;
  48254. return 0 | xl * yl + ((UINT16 & xn >>> 16) * yl + xl * (UINT16 & yn >>> 16) << 16 >>> 0);
  48255. }
  48256. });
  48257. /***/ },
  48258. /* 344 */
  48259. /***/ function(module, exports, __webpack_require__) {
  48260. // 20.2.2.21 Math.log10(x)
  48261. var $export = __webpack_require__(0);
  48262. $export($export.S, 'Math', {
  48263. log10: function log10(x){
  48264. return Math.log(x) / Math.LN10;
  48265. }
  48266. });
  48267. /***/ },
  48268. /* 345 */
  48269. /***/ function(module, exports, __webpack_require__) {
  48270. // 20.2.2.20 Math.log1p(x)
  48271. var $export = __webpack_require__(0);
  48272. $export($export.S, 'Math', {log1p: __webpack_require__(179)});
  48273. /***/ },
  48274. /* 346 */
  48275. /***/ function(module, exports, __webpack_require__) {
  48276. // 20.2.2.22 Math.log2(x)
  48277. var $export = __webpack_require__(0);
  48278. $export($export.S, 'Math', {
  48279. log2: function log2(x){
  48280. return Math.log(x) / Math.LN2;
  48281. }
  48282. });
  48283. /***/ },
  48284. /* 347 */
  48285. /***/ function(module, exports, __webpack_require__) {
  48286. // 20.2.2.28 Math.sign(x)
  48287. var $export = __webpack_require__(0);
  48288. $export($export.S, 'Math', {sign: __webpack_require__(117)});
  48289. /***/ },
  48290. /* 348 */
  48291. /***/ function(module, exports, __webpack_require__) {
  48292. // 20.2.2.30 Math.sinh(x)
  48293. var $export = __webpack_require__(0)
  48294. , expm1 = __webpack_require__(116)
  48295. , exp = Math.exp;
  48296. // V8 near Chromium 38 has a problem with very small numbers
  48297. $export($export.S + $export.F * __webpack_require__(6)(function(){
  48298. return !Math.sinh(-2e-17) != -2e-17;
  48299. }), 'Math', {
  48300. sinh: function sinh(x){
  48301. return Math.abs(x = +x) < 1
  48302. ? (expm1(x) - expm1(-x)) / 2
  48303. : (exp(x - 1) - exp(-x - 1)) * (Math.E / 2);
  48304. }
  48305. });
  48306. /***/ },
  48307. /* 349 */
  48308. /***/ function(module, exports, __webpack_require__) {
  48309. // 20.2.2.33 Math.tanh(x)
  48310. var $export = __webpack_require__(0)
  48311. , expm1 = __webpack_require__(116)
  48312. , exp = Math.exp;
  48313. $export($export.S, 'Math', {
  48314. tanh: function tanh(x){
  48315. var a = expm1(x = +x)
  48316. , b = expm1(-x);
  48317. return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (exp(x) + exp(-x));
  48318. }
  48319. });
  48320. /***/ },
  48321. /* 350 */
  48322. /***/ function(module, exports, __webpack_require__) {
  48323. // 20.2.2.34 Math.trunc(x)
  48324. var $export = __webpack_require__(0);
  48325. $export($export.S, 'Math', {
  48326. trunc: function trunc(it){
  48327. return (it > 0 ? Math.floor : Math.ceil)(it);
  48328. }
  48329. });
  48330. /***/ },
  48331. /* 351 */
  48332. /***/ function(module, exports, __webpack_require__) {
  48333. "use strict";
  48334. 'use strict';
  48335. var global = __webpack_require__(5)
  48336. , has = __webpack_require__(17)
  48337. , cof = __webpack_require__(27)
  48338. , inheritIfRequired = __webpack_require__(110)
  48339. , toPrimitive = __webpack_require__(34)
  48340. , fails = __webpack_require__(6)
  48341. , gOPN = __webpack_require__(48).f
  48342. , gOPD = __webpack_require__(25).f
  48343. , dP = __webpack_require__(11).f
  48344. , $trim = __webpack_require__(62).trim
  48345. , NUMBER = 'Number'
  48346. , $Number = global[NUMBER]
  48347. , Base = $Number
  48348. , proto = $Number.prototype
  48349. // Opera ~12 has broken Object#toString
  48350. , BROKEN_COF = cof(__webpack_require__(47)(proto)) == NUMBER
  48351. , TRIM = 'trim' in String.prototype;
  48352. // 7.1.3 ToNumber(argument)
  48353. var toNumber = function(argument){
  48354. var it = toPrimitive(argument, false);
  48355. if(typeof it == 'string' && it.length > 2){
  48356. it = TRIM ? it.trim() : $trim(it, 3);
  48357. var first = it.charCodeAt(0)
  48358. , third, radix, maxCode;
  48359. if(first === 43 || first === 45){
  48360. third = it.charCodeAt(2);
  48361. if(third === 88 || third === 120)return NaN; // Number('+0x1') should be NaN, old V8 fix
  48362. } else if(first === 48){
  48363. switch(it.charCodeAt(1)){
  48364. case 66 : case 98 : radix = 2; maxCode = 49; break; // fast equal /^0b[01]+$/i
  48365. case 79 : case 111 : radix = 8; maxCode = 55; break; // fast equal /^0o[0-7]+$/i
  48366. default : return +it;
  48367. }
  48368. for(var digits = it.slice(2), i = 0, l = digits.length, code; i < l; i++){
  48369. code = digits.charCodeAt(i);
  48370. // parseInt parses a string to a first unavailable symbol
  48371. // but ToNumber should return NaN if a string contains unavailable symbols
  48372. if(code < 48 || code > maxCode)return NaN;
  48373. } return parseInt(digits, radix);
  48374. }
  48375. } return +it;
  48376. };
  48377. if(!$Number(' 0o1') || !$Number('0b1') || $Number('+0x1')){
  48378. $Number = function Number(value){
  48379. var it = arguments.length < 1 ? 0 : value
  48380. , that = this;
  48381. return that instanceof $Number
  48382. // check on 1..constructor(foo) case
  48383. && (BROKEN_COF ? fails(function(){ proto.valueOf.call(that); }) : cof(that) != NUMBER)
  48384. ? inheritIfRequired(new Base(toNumber(it)), that, $Number) : toNumber(it);
  48385. };
  48386. for(var keys = __webpack_require__(10) ? gOPN(Base) : (
  48387. // ES3:
  48388. 'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' +
  48389. // ES6 (in case, if modules with ES6 Number statics required before):
  48390. 'EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,' +
  48391. 'MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger'
  48392. ).split(','), j = 0, key; keys.length > j; j++){
  48393. if(has(Base, key = keys[j]) && !has($Number, key)){
  48394. dP($Number, key, gOPD(Base, key));
  48395. }
  48396. }
  48397. $Number.prototype = proto;
  48398. proto.constructor = $Number;
  48399. __webpack_require__(22)(global, NUMBER, $Number);
  48400. }
  48401. /***/ },
  48402. /* 352 */
  48403. /***/ function(module, exports, __webpack_require__) {
  48404. // 20.1.2.1 Number.EPSILON
  48405. var $export = __webpack_require__(0);
  48406. $export($export.S, 'Number', {EPSILON: Math.pow(2, -52)});
  48407. /***/ },
  48408. /* 353 */
  48409. /***/ function(module, exports, __webpack_require__) {
  48410. // 20.1.2.2 Number.isFinite(number)
  48411. var $export = __webpack_require__(0)
  48412. , _isFinite = __webpack_require__(5).isFinite;
  48413. $export($export.S, 'Number', {
  48414. isFinite: function isFinite(it){
  48415. return typeof it == 'number' && _isFinite(it);
  48416. }
  48417. });
  48418. /***/ },
  48419. /* 354 */
  48420. /***/ function(module, exports, __webpack_require__) {
  48421. // 20.1.2.3 Number.isInteger(number)
  48422. var $export = __webpack_require__(0);
  48423. $export($export.S, 'Number', {isInteger: __webpack_require__(113)});
  48424. /***/ },
  48425. /* 355 */
  48426. /***/ function(module, exports, __webpack_require__) {
  48427. // 20.1.2.4 Number.isNaN(number)
  48428. var $export = __webpack_require__(0);
  48429. $export($export.S, 'Number', {
  48430. isNaN: function isNaN(number){
  48431. return number != number;
  48432. }
  48433. });
  48434. /***/ },
  48435. /* 356 */
  48436. /***/ function(module, exports, __webpack_require__) {
  48437. // 20.1.2.5 Number.isSafeInteger(number)
  48438. var $export = __webpack_require__(0)
  48439. , isInteger = __webpack_require__(113)
  48440. , abs = Math.abs;
  48441. $export($export.S, 'Number', {
  48442. isSafeInteger: function isSafeInteger(number){
  48443. return isInteger(number) && abs(number) <= 0x1fffffffffffff;
  48444. }
  48445. });
  48446. /***/ },
  48447. /* 357 */
  48448. /***/ function(module, exports, __webpack_require__) {
  48449. // 20.1.2.6 Number.MAX_SAFE_INTEGER
  48450. var $export = __webpack_require__(0);
  48451. $export($export.S, 'Number', {MAX_SAFE_INTEGER: 0x1fffffffffffff});
  48452. /***/ },
  48453. /* 358 */
  48454. /***/ function(module, exports, __webpack_require__) {
  48455. // 20.1.2.10 Number.MIN_SAFE_INTEGER
  48456. var $export = __webpack_require__(0);
  48457. $export($export.S, 'Number', {MIN_SAFE_INTEGER: -0x1fffffffffffff});
  48458. /***/ },
  48459. /* 359 */
  48460. /***/ function(module, exports, __webpack_require__) {
  48461. var $export = __webpack_require__(0)
  48462. , $parseFloat = __webpack_require__(186);
  48463. // 20.1.2.12 Number.parseFloat(string)
  48464. $export($export.S + $export.F * (Number.parseFloat != $parseFloat), 'Number', {parseFloat: $parseFloat});
  48465. /***/ },
  48466. /* 360 */
  48467. /***/ function(module, exports, __webpack_require__) {
  48468. var $export = __webpack_require__(0)
  48469. , $parseInt = __webpack_require__(187);
  48470. // 20.1.2.13 Number.parseInt(string, radix)
  48471. $export($export.S + $export.F * (Number.parseInt != $parseInt), 'Number', {parseInt: $parseInt});
  48472. /***/ },
  48473. /* 361 */
  48474. /***/ function(module, exports, __webpack_require__) {
  48475. "use strict";
  48476. 'use strict';
  48477. var $export = __webpack_require__(0)
  48478. , anInstance = __webpack_require__(39)
  48479. , toInteger = __webpack_require__(42)
  48480. , aNumberValue = __webpack_require__(168)
  48481. , repeat = __webpack_require__(123)
  48482. , $toFixed = 1..toFixed
  48483. , floor = Math.floor
  48484. , data = [0, 0, 0, 0, 0, 0]
  48485. , ERROR = 'Number.toFixed: incorrect invocation!'
  48486. , ZERO = '0';
  48487. var multiply = function(n, c){
  48488. var i = -1
  48489. , c2 = c;
  48490. while(++i < 6){
  48491. c2 += n * data[i];
  48492. data[i] = c2 % 1e7;
  48493. c2 = floor(c2 / 1e7);
  48494. }
  48495. };
  48496. var divide = function(n){
  48497. var i = 6
  48498. , c = 0;
  48499. while(--i >= 0){
  48500. c += data[i];
  48501. data[i] = floor(c / n);
  48502. c = (c % n) * 1e7;
  48503. }
  48504. };
  48505. var numToString = function(){
  48506. var i = 6
  48507. , s = '';
  48508. while(--i >= 0){
  48509. if(s !== '' || i === 0 || data[i] !== 0){
  48510. var t = String(data[i]);
  48511. s = s === '' ? t : s + repeat.call(ZERO, 7 - t.length) + t;
  48512. }
  48513. } return s;
  48514. };
  48515. var pow = function(x, n, acc){
  48516. return n === 0 ? acc : n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc);
  48517. };
  48518. var log = function(x){
  48519. var n = 0
  48520. , x2 = x;
  48521. while(x2 >= 4096){
  48522. n += 12;
  48523. x2 /= 4096;
  48524. }
  48525. while(x2 >= 2){
  48526. n += 1;
  48527. x2 /= 2;
  48528. } return n;
  48529. };
  48530. $export($export.P + $export.F * (!!$toFixed && (
  48531. 0.00008.toFixed(3) !== '0.000' ||
  48532. 0.9.toFixed(0) !== '1' ||
  48533. 1.255.toFixed(2) !== '1.25' ||
  48534. 1000000000000000128..toFixed(0) !== '1000000000000000128'
  48535. ) || !__webpack_require__(6)(function(){
  48536. // V8 ~ Android 4.3-
  48537. $toFixed.call({});
  48538. })), 'Number', {
  48539. toFixed: function toFixed(fractionDigits){
  48540. var x = aNumberValue(this, ERROR)
  48541. , f = toInteger(fractionDigits)
  48542. , s = ''
  48543. , m = ZERO
  48544. , e, z, j, k;
  48545. if(f < 0 || f > 20)throw RangeError(ERROR);
  48546. if(x != x)return 'NaN';
  48547. if(x <= -1e21 || x >= 1e21)return String(x);
  48548. if(x < 0){
  48549. s = '-';
  48550. x = -x;
  48551. }
  48552. if(x > 1e-21){
  48553. e = log(x * pow(2, 69, 1)) - 69;
  48554. z = e < 0 ? x * pow(2, -e, 1) : x / pow(2, e, 1);
  48555. z *= 0x10000000000000;
  48556. e = 52 - e;
  48557. if(e > 0){
  48558. multiply(0, z);
  48559. j = f;
  48560. while(j >= 7){
  48561. multiply(1e7, 0);
  48562. j -= 7;
  48563. }
  48564. multiply(pow(10, j, 1), 0);
  48565. j = e - 1;
  48566. while(j >= 23){
  48567. divide(1 << 23);
  48568. j -= 23;
  48569. }
  48570. divide(1 << j);
  48571. multiply(1, 1);
  48572. divide(2);
  48573. m = numToString();
  48574. } else {
  48575. multiply(0, z);
  48576. multiply(1 << -e, 0);
  48577. m = numToString() + repeat.call(ZERO, f);
  48578. }
  48579. }
  48580. if(f > 0){
  48581. k = m.length;
  48582. m = s + (k <= f ? '0.' + repeat.call(ZERO, f - k) + m : m.slice(0, k - f) + '.' + m.slice(k - f));
  48583. } else {
  48584. m = s + m;
  48585. } return m;
  48586. }
  48587. });
  48588. /***/ },
  48589. /* 362 */
  48590. /***/ function(module, exports, __webpack_require__) {
  48591. "use strict";
  48592. 'use strict';
  48593. var $export = __webpack_require__(0)
  48594. , $fails = __webpack_require__(6)
  48595. , aNumberValue = __webpack_require__(168)
  48596. , $toPrecision = 1..toPrecision;
  48597. $export($export.P + $export.F * ($fails(function(){
  48598. // IE7-
  48599. return $toPrecision.call(1, undefined) !== '1';
  48600. }) || !$fails(function(){
  48601. // V8 ~ Android 4.3-
  48602. $toPrecision.call({});
  48603. })), 'Number', {
  48604. toPrecision: function toPrecision(precision){
  48605. var that = aNumberValue(this, 'Number#toPrecision: incorrect invocation!');
  48606. return precision === undefined ? $toPrecision.call(that) : $toPrecision.call(that, precision);
  48607. }
  48608. });
  48609. /***/ },
  48610. /* 363 */
  48611. /***/ function(module, exports, __webpack_require__) {
  48612. // 19.1.3.1 Object.assign(target, source)
  48613. var $export = __webpack_require__(0);
  48614. $export($export.S + $export.F, 'Object', {assign: __webpack_require__(180)});
  48615. /***/ },
  48616. /* 364 */
  48617. /***/ function(module, exports, __webpack_require__) {
  48618. var $export = __webpack_require__(0)
  48619. // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
  48620. $export($export.S, 'Object', {create: __webpack_require__(47)});
  48621. /***/ },
  48622. /* 365 */
  48623. /***/ function(module, exports, __webpack_require__) {
  48624. var $export = __webpack_require__(0);
  48625. // 19.1.2.3 / 15.2.3.7 Object.defineProperties(O, Properties)
  48626. $export($export.S + $export.F * !__webpack_require__(10), 'Object', {defineProperties: __webpack_require__(181)});
  48627. /***/ },
  48628. /* 366 */
  48629. /***/ function(module, exports, __webpack_require__) {
  48630. var $export = __webpack_require__(0);
  48631. // 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes)
  48632. $export($export.S + $export.F * !__webpack_require__(10), 'Object', {defineProperty: __webpack_require__(11).f});
  48633. /***/ },
  48634. /* 367 */
  48635. /***/ function(module, exports, __webpack_require__) {
  48636. // 19.1.2.5 Object.freeze(O)
  48637. var isObject = __webpack_require__(7)
  48638. , meta = __webpack_require__(40).onFreeze;
  48639. __webpack_require__(33)('freeze', function($freeze){
  48640. return function freeze(it){
  48641. return $freeze && isObject(it) ? $freeze(meta(it)) : it;
  48642. };
  48643. });
  48644. /***/ },
  48645. /* 368 */
  48646. /***/ function(module, exports, __webpack_require__) {
  48647. // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
  48648. var toIObject = __webpack_require__(24)
  48649. , $getOwnPropertyDescriptor = __webpack_require__(25).f;
  48650. __webpack_require__(33)('getOwnPropertyDescriptor', function(){
  48651. return function getOwnPropertyDescriptor(it, key){
  48652. return $getOwnPropertyDescriptor(toIObject(it), key);
  48653. };
  48654. });
  48655. /***/ },
  48656. /* 369 */
  48657. /***/ function(module, exports, __webpack_require__) {
  48658. // 19.1.2.7 Object.getOwnPropertyNames(O)
  48659. __webpack_require__(33)('getOwnPropertyNames', function(){
  48660. return __webpack_require__(182).f;
  48661. });
  48662. /***/ },
  48663. /* 370 */
  48664. /***/ function(module, exports, __webpack_require__) {
  48665. // 19.1.2.9 Object.getPrototypeOf(O)
  48666. var toObject = __webpack_require__(16)
  48667. , $getPrototypeOf = __webpack_require__(26);
  48668. __webpack_require__(33)('getPrototypeOf', function(){
  48669. return function getPrototypeOf(it){
  48670. return $getPrototypeOf(toObject(it));
  48671. };
  48672. });
  48673. /***/ },
  48674. /* 371 */
  48675. /***/ function(module, exports, __webpack_require__) {
  48676. // 19.1.2.11 Object.isExtensible(O)
  48677. var isObject = __webpack_require__(7);
  48678. __webpack_require__(33)('isExtensible', function($isExtensible){
  48679. return function isExtensible(it){
  48680. return isObject(it) ? $isExtensible ? $isExtensible(it) : true : false;
  48681. };
  48682. });
  48683. /***/ },
  48684. /* 372 */
  48685. /***/ function(module, exports, __webpack_require__) {
  48686. // 19.1.2.12 Object.isFrozen(O)
  48687. var isObject = __webpack_require__(7);
  48688. __webpack_require__(33)('isFrozen', function($isFrozen){
  48689. return function isFrozen(it){
  48690. return isObject(it) ? $isFrozen ? $isFrozen(it) : false : true;
  48691. };
  48692. });
  48693. /***/ },
  48694. /* 373 */
  48695. /***/ function(module, exports, __webpack_require__) {
  48696. // 19.1.2.13 Object.isSealed(O)
  48697. var isObject = __webpack_require__(7);
  48698. __webpack_require__(33)('isSealed', function($isSealed){
  48699. return function isSealed(it){
  48700. return isObject(it) ? $isSealed ? $isSealed(it) : false : true;
  48701. };
  48702. });
  48703. /***/ },
  48704. /* 374 */
  48705. /***/ function(module, exports, __webpack_require__) {
  48706. // 19.1.3.10 Object.is(value1, value2)
  48707. var $export = __webpack_require__(0);
  48708. $export($export.S, 'Object', {is: __webpack_require__(188)});
  48709. /***/ },
  48710. /* 375 */
  48711. /***/ function(module, exports, __webpack_require__) {
  48712. // 19.1.2.14 Object.keys(O)
  48713. var toObject = __webpack_require__(16)
  48714. , $keys = __webpack_require__(49);
  48715. __webpack_require__(33)('keys', function(){
  48716. return function keys(it){
  48717. return $keys(toObject(it));
  48718. };
  48719. });
  48720. /***/ },
  48721. /* 376 */
  48722. /***/ function(module, exports, __webpack_require__) {
  48723. // 19.1.2.15 Object.preventExtensions(O)
  48724. var isObject = __webpack_require__(7)
  48725. , meta = __webpack_require__(40).onFreeze;
  48726. __webpack_require__(33)('preventExtensions', function($preventExtensions){
  48727. return function preventExtensions(it){
  48728. return $preventExtensions && isObject(it) ? $preventExtensions(meta(it)) : it;
  48729. };
  48730. });
  48731. /***/ },
  48732. /* 377 */
  48733. /***/ function(module, exports, __webpack_require__) {
  48734. // 19.1.2.17 Object.seal(O)
  48735. var isObject = __webpack_require__(7)
  48736. , meta = __webpack_require__(40).onFreeze;
  48737. __webpack_require__(33)('seal', function($seal){
  48738. return function seal(it){
  48739. return $seal && isObject(it) ? $seal(meta(it)) : it;
  48740. };
  48741. });
  48742. /***/ },
  48743. /* 378 */
  48744. /***/ function(module, exports, __webpack_require__) {
  48745. // 19.1.3.19 Object.setPrototypeOf(O, proto)
  48746. var $export = __webpack_require__(0);
  48747. $export($export.S, 'Object', {setPrototypeOf: __webpack_require__(91).set});
  48748. /***/ },
  48749. /* 379 */
  48750. /***/ function(module, exports, __webpack_require__) {
  48751. "use strict";
  48752. 'use strict';
  48753. // 19.1.3.6 Object.prototype.toString()
  48754. var classof = __webpack_require__(59)
  48755. , test = {};
  48756. test[__webpack_require__(8)('toStringTag')] = 'z';
  48757. if(test + '' != '[object z]'){
  48758. __webpack_require__(22)(Object.prototype, 'toString', function toString(){
  48759. return '[object ' + classof(this) + ']';
  48760. }, true);
  48761. }
  48762. /***/ },
  48763. /* 380 */
  48764. /***/ function(module, exports, __webpack_require__) {
  48765. var $export = __webpack_require__(0)
  48766. , $parseFloat = __webpack_require__(186);
  48767. // 18.2.4 parseFloat(string)
  48768. $export($export.G + $export.F * (parseFloat != $parseFloat), {parseFloat: $parseFloat});
  48769. /***/ },
  48770. /* 381 */
  48771. /***/ function(module, exports, __webpack_require__) {
  48772. var $export = __webpack_require__(0)
  48773. , $parseInt = __webpack_require__(187);
  48774. // 18.2.5 parseInt(string, radix)
  48775. $export($export.G + $export.F * (parseInt != $parseInt), {parseInt: $parseInt});
  48776. /***/ },
  48777. /* 382 */
  48778. /***/ function(module, exports, __webpack_require__) {
  48779. "use strict";
  48780. 'use strict';
  48781. var LIBRARY = __webpack_require__(46)
  48782. , global = __webpack_require__(5)
  48783. , ctx = __webpack_require__(35)
  48784. , classof = __webpack_require__(59)
  48785. , $export = __webpack_require__(0)
  48786. , isObject = __webpack_require__(7)
  48787. , anObject = __webpack_require__(3)
  48788. , aFunction = __webpack_require__(21)
  48789. , anInstance = __webpack_require__(39)
  48790. , forOf = __webpack_require__(60)
  48791. , setProto = __webpack_require__(91).set
  48792. , speciesConstructor = __webpack_require__(120)
  48793. , task = __webpack_require__(125).set
  48794. , microtask = __webpack_require__(118)()
  48795. , PROMISE = 'Promise'
  48796. , TypeError = global.TypeError
  48797. , process = global.process
  48798. , $Promise = global[PROMISE]
  48799. , process = global.process
  48800. , isNode = classof(process) == 'process'
  48801. , empty = function(){ /* empty */ }
  48802. , Internal, GenericPromiseCapability, Wrapper;
  48803. var USE_NATIVE = !!function(){
  48804. try {
  48805. // correct subclassing with @@species support
  48806. var promise = $Promise.resolve(1)
  48807. , FakePromise = (promise.constructor = {})[__webpack_require__(8)('species')] = function(exec){ exec(empty, empty); };
  48808. // unhandled rejections tracking support, NodeJS Promise without it fails @@species test
  48809. return (isNode || typeof PromiseRejectionEvent == 'function') && promise.then(empty) instanceof FakePromise;
  48810. } catch(e){ /* empty */ }
  48811. }();
  48812. // helpers
  48813. var sameConstructor = function(a, b){
  48814. // with library wrapper special case
  48815. return a === b || a === $Promise && b === Wrapper;
  48816. };
  48817. var isThenable = function(it){
  48818. var then;
  48819. return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
  48820. };
  48821. var newPromiseCapability = function(C){
  48822. return sameConstructor($Promise, C)
  48823. ? new PromiseCapability(C)
  48824. : new GenericPromiseCapability(C);
  48825. };
  48826. var PromiseCapability = GenericPromiseCapability = function(C){
  48827. var resolve, reject;
  48828. this.promise = new C(function($$resolve, $$reject){
  48829. if(resolve !== undefined || reject !== undefined)throw TypeError('Bad Promise constructor');
  48830. resolve = $$resolve;
  48831. reject = $$reject;
  48832. });
  48833. this.resolve = aFunction(resolve);
  48834. this.reject = aFunction(reject);
  48835. };
  48836. var perform = function(exec){
  48837. try {
  48838. exec();
  48839. } catch(e){
  48840. return {error: e};
  48841. }
  48842. };
  48843. var notify = function(promise, isReject){
  48844. if(promise._n)return;
  48845. promise._n = true;
  48846. var chain = promise._c;
  48847. microtask(function(){
  48848. var value = promise._v
  48849. , ok = promise._s == 1
  48850. , i = 0;
  48851. var run = function(reaction){
  48852. var handler = ok ? reaction.ok : reaction.fail
  48853. , resolve = reaction.resolve
  48854. , reject = reaction.reject
  48855. , domain = reaction.domain
  48856. , result, then;
  48857. try {
  48858. if(handler){
  48859. if(!ok){
  48860. if(promise._h == 2)onHandleUnhandled(promise);
  48861. promise._h = 1;
  48862. }
  48863. if(handler === true)result = value;
  48864. else {
  48865. if(domain)domain.enter();
  48866. result = handler(value);
  48867. if(domain)domain.exit();
  48868. }
  48869. if(result === reaction.promise){
  48870. reject(TypeError('Promise-chain cycle'));
  48871. } else if(then = isThenable(result)){
  48872. then.call(result, resolve, reject);
  48873. } else resolve(result);
  48874. } else reject(value);
  48875. } catch(e){
  48876. reject(e);
  48877. }
  48878. };
  48879. while(chain.length > i)run(chain[i++]); // variable length - can't use forEach
  48880. promise._c = [];
  48881. promise._n = false;
  48882. if(isReject && !promise._h)onUnhandled(promise);
  48883. });
  48884. };
  48885. var onUnhandled = function(promise){
  48886. task.call(global, function(){
  48887. var value = promise._v
  48888. , abrupt, handler, console;
  48889. if(isUnhandled(promise)){
  48890. abrupt = perform(function(){
  48891. if(isNode){
  48892. process.emit('unhandledRejection', value, promise);
  48893. } else if(handler = global.onunhandledrejection){
  48894. handler({promise: promise, reason: value});
  48895. } else if((console = global.console) && console.error){
  48896. console.error('Unhandled promise rejection', value);
  48897. }
  48898. });
  48899. // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
  48900. promise._h = isNode || isUnhandled(promise) ? 2 : 1;
  48901. } promise._a = undefined;
  48902. if(abrupt)throw abrupt.error;
  48903. });
  48904. };
  48905. var isUnhandled = function(promise){
  48906. if(promise._h == 1)return false;
  48907. var chain = promise._a || promise._c
  48908. , i = 0
  48909. , reaction;
  48910. while(chain.length > i){
  48911. reaction = chain[i++];
  48912. if(reaction.fail || !isUnhandled(reaction.promise))return false;
  48913. } return true;
  48914. };
  48915. var onHandleUnhandled = function(promise){
  48916. task.call(global, function(){
  48917. var handler;
  48918. if(isNode){
  48919. process.emit('rejectionHandled', promise);
  48920. } else if(handler = global.onrejectionhandled){
  48921. handler({promise: promise, reason: promise._v});
  48922. }
  48923. });
  48924. };
  48925. var $reject = function(value){
  48926. var promise = this;
  48927. if(promise._d)return;
  48928. promise._d = true;
  48929. promise = promise._w || promise; // unwrap
  48930. promise._v = value;
  48931. promise._s = 2;
  48932. if(!promise._a)promise._a = promise._c.slice();
  48933. notify(promise, true);
  48934. };
  48935. var $resolve = function(value){
  48936. var promise = this
  48937. , then;
  48938. if(promise._d)return;
  48939. promise._d = true;
  48940. promise = promise._w || promise; // unwrap
  48941. try {
  48942. if(promise === value)throw TypeError("Promise can't be resolved itself");
  48943. if(then = isThenable(value)){
  48944. microtask(function(){
  48945. var wrapper = {_w: promise, _d: false}; // wrap
  48946. try {
  48947. then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));
  48948. } catch(e){
  48949. $reject.call(wrapper, e);
  48950. }
  48951. });
  48952. } else {
  48953. promise._v = value;
  48954. promise._s = 1;
  48955. notify(promise, false);
  48956. }
  48957. } catch(e){
  48958. $reject.call({_w: promise, _d: false}, e); // wrap
  48959. }
  48960. };
  48961. // constructor polyfill
  48962. if(!USE_NATIVE){
  48963. // 25.4.3.1 Promise(executor)
  48964. $Promise = function Promise(executor){
  48965. anInstance(this, $Promise, PROMISE, '_h');
  48966. aFunction(executor);
  48967. Internal.call(this);
  48968. try {
  48969. executor(ctx($resolve, this, 1), ctx($reject, this, 1));
  48970. } catch(err){
  48971. $reject.call(this, err);
  48972. }
  48973. };
  48974. Internal = function Promise(executor){
  48975. this._c = []; // <- awaiting reactions
  48976. this._a = undefined; // <- checked in isUnhandled reactions
  48977. this._s = 0; // <- state
  48978. this._d = false; // <- done
  48979. this._v = undefined; // <- value
  48980. this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled
  48981. this._n = false; // <- notify
  48982. };
  48983. Internal.prototype = __webpack_require__(50)($Promise.prototype, {
  48984. // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)
  48985. then: function then(onFulfilled, onRejected){
  48986. var reaction = newPromiseCapability(speciesConstructor(this, $Promise));
  48987. reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
  48988. reaction.fail = typeof onRejected == 'function' && onRejected;
  48989. reaction.domain = isNode ? process.domain : undefined;
  48990. this._c.push(reaction);
  48991. if(this._a)this._a.push(reaction);
  48992. if(this._s)notify(this, false);
  48993. return reaction.promise;
  48994. },
  48995. // 25.4.5.1 Promise.prototype.catch(onRejected)
  48996. 'catch': function(onRejected){
  48997. return this.then(undefined, onRejected);
  48998. }
  48999. });
  49000. PromiseCapability = function(){
  49001. var promise = new Internal;
  49002. this.promise = promise;
  49003. this.resolve = ctx($resolve, promise, 1);
  49004. this.reject = ctx($reject, promise, 1);
  49005. };
  49006. }
  49007. $export($export.G + $export.W + $export.F * !USE_NATIVE, {Promise: $Promise});
  49008. __webpack_require__(61)($Promise, PROMISE);
  49009. __webpack_require__(51)(PROMISE);
  49010. Wrapper = __webpack_require__(32)[PROMISE];
  49011. // statics
  49012. $export($export.S + $export.F * !USE_NATIVE, PROMISE, {
  49013. // 25.4.4.5 Promise.reject(r)
  49014. reject: function reject(r){
  49015. var capability = newPromiseCapability(this)
  49016. , $$reject = capability.reject;
  49017. $$reject(r);
  49018. return capability.promise;
  49019. }
  49020. });
  49021. $export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, {
  49022. // 25.4.4.6 Promise.resolve(x)
  49023. resolve: function resolve(x){
  49024. // instanceof instead of internal slot check because we should fix it without replacement native Promise core
  49025. if(x instanceof $Promise && sameConstructor(x.constructor, this))return x;
  49026. var capability = newPromiseCapability(this)
  49027. , $$resolve = capability.resolve;
  49028. $$resolve(x);
  49029. return capability.promise;
  49030. }
  49031. });
  49032. $export($export.S + $export.F * !(USE_NATIVE && __webpack_require__(88)(function(iter){
  49033. $Promise.all(iter)['catch'](empty);
  49034. })), PROMISE, {
  49035. // 25.4.4.1 Promise.all(iterable)
  49036. all: function all(iterable){
  49037. var C = this
  49038. , capability = newPromiseCapability(C)
  49039. , resolve = capability.resolve
  49040. , reject = capability.reject;
  49041. var abrupt = perform(function(){
  49042. var values = []
  49043. , index = 0
  49044. , remaining = 1;
  49045. forOf(iterable, false, function(promise){
  49046. var $index = index++
  49047. , alreadyCalled = false;
  49048. values.push(undefined);
  49049. remaining++;
  49050. C.resolve(promise).then(function(value){
  49051. if(alreadyCalled)return;
  49052. alreadyCalled = true;
  49053. values[$index] = value;
  49054. --remaining || resolve(values);
  49055. }, reject);
  49056. });
  49057. --remaining || resolve(values);
  49058. });
  49059. if(abrupt)reject(abrupt.error);
  49060. return capability.promise;
  49061. },
  49062. // 25.4.4.4 Promise.race(iterable)
  49063. race: function race(iterable){
  49064. var C = this
  49065. , capability = newPromiseCapability(C)
  49066. , reject = capability.reject;
  49067. var abrupt = perform(function(){
  49068. forOf(iterable, false, function(promise){
  49069. C.resolve(promise).then(capability.resolve, reject);
  49070. });
  49071. });
  49072. if(abrupt)reject(abrupt.error);
  49073. return capability.promise;
  49074. }
  49075. });
  49076. /***/ },
  49077. /* 383 */
  49078. /***/ function(module, exports, __webpack_require__) {
  49079. // 26.1.1 Reflect.apply(target, thisArgument, argumentsList)
  49080. var $export = __webpack_require__(0)
  49081. , aFunction = __webpack_require__(21)
  49082. , anObject = __webpack_require__(3)
  49083. , _apply = Function.apply;
  49084. $export($export.S, 'Reflect', {
  49085. apply: function apply(target, thisArgument, argumentsList){
  49086. return _apply.call(aFunction(target), thisArgument, anObject(argumentsList));
  49087. }
  49088. });
  49089. /***/ },
  49090. /* 384 */
  49091. /***/ function(module, exports, __webpack_require__) {
  49092. // 26.1.2 Reflect.construct(target, argumentsList [, newTarget])
  49093. var $export = __webpack_require__(0)
  49094. , create = __webpack_require__(47)
  49095. , aFunction = __webpack_require__(21)
  49096. , anObject = __webpack_require__(3)
  49097. , isObject = __webpack_require__(7)
  49098. , bind = __webpack_require__(172);
  49099. // MS Edge supports only 2 arguments
  49100. // FF Nightly sets third argument as `new.target`, but does not create `this` from it
  49101. $export($export.S + $export.F * __webpack_require__(6)(function(){
  49102. function F(){}
  49103. return !(Reflect.construct(function(){}, [], F) instanceof F);
  49104. }), 'Reflect', {
  49105. construct: function construct(Target, args /*, newTarget*/){
  49106. aFunction(Target);
  49107. anObject(args);
  49108. var newTarget = arguments.length < 3 ? Target : aFunction(arguments[2]);
  49109. if(Target == newTarget){
  49110. // w/o altered newTarget, optimization for 0-4 arguments
  49111. switch(args.length){
  49112. case 0: return new Target;
  49113. case 1: return new Target(args[0]);
  49114. case 2: return new Target(args[0], args[1]);
  49115. case 3: return new Target(args[0], args[1], args[2]);
  49116. case 4: return new Target(args[0], args[1], args[2], args[3]);
  49117. }
  49118. // w/o altered newTarget, lot of arguments case
  49119. var $args = [null];
  49120. $args.push.apply($args, args);
  49121. return new (bind.apply(Target, $args));
  49122. }
  49123. // with altered newTarget, not support built-in constructors
  49124. var proto = newTarget.prototype
  49125. , instance = create(isObject(proto) ? proto : Object.prototype)
  49126. , result = Function.apply.call(Target, instance, args);
  49127. return isObject(result) ? result : instance;
  49128. }
  49129. });
  49130. /***/ },
  49131. /* 385 */
  49132. /***/ function(module, exports, __webpack_require__) {
  49133. // 26.1.3 Reflect.defineProperty(target, propertyKey, attributes)
  49134. var dP = __webpack_require__(11)
  49135. , $export = __webpack_require__(0)
  49136. , anObject = __webpack_require__(3)
  49137. , toPrimitive = __webpack_require__(34);
  49138. // MS Edge has broken Reflect.defineProperty - throwing instead of returning false
  49139. $export($export.S + $export.F * __webpack_require__(6)(function(){
  49140. Reflect.defineProperty(dP.f({}, 1, {value: 1}), 1, {value: 2});
  49141. }), 'Reflect', {
  49142. defineProperty: function defineProperty(target, propertyKey, attributes){
  49143. anObject(target);
  49144. propertyKey = toPrimitive(propertyKey, true);
  49145. anObject(attributes);
  49146. try {
  49147. dP.f(target, propertyKey, attributes);
  49148. return true;
  49149. } catch(e){
  49150. return false;
  49151. }
  49152. }
  49153. });
  49154. /***/ },
  49155. /* 386 */
  49156. /***/ function(module, exports, __webpack_require__) {
  49157. // 26.1.4 Reflect.deleteProperty(target, propertyKey)
  49158. var $export = __webpack_require__(0)
  49159. , gOPD = __webpack_require__(25).f
  49160. , anObject = __webpack_require__(3);
  49161. $export($export.S, 'Reflect', {
  49162. deleteProperty: function deleteProperty(target, propertyKey){
  49163. var desc = gOPD(anObject(target), propertyKey);
  49164. return desc && !desc.configurable ? false : delete target[propertyKey];
  49165. }
  49166. });
  49167. /***/ },
  49168. /* 387 */
  49169. /***/ function(module, exports, __webpack_require__) {
  49170. "use strict";
  49171. 'use strict';
  49172. // 26.1.5 Reflect.enumerate(target)
  49173. var $export = __webpack_require__(0)
  49174. , anObject = __webpack_require__(3);
  49175. var Enumerate = function(iterated){
  49176. this._t = anObject(iterated); // target
  49177. this._i = 0; // next index
  49178. var keys = this._k = [] // keys
  49179. , key;
  49180. for(key in iterated)keys.push(key);
  49181. };
  49182. __webpack_require__(114)(Enumerate, 'Object', function(){
  49183. var that = this
  49184. , keys = that._k
  49185. , key;
  49186. do {
  49187. if(that._i >= keys.length)return {value: undefined, done: true};
  49188. } while(!((key = keys[that._i++]) in that._t));
  49189. return {value: key, done: false};
  49190. });
  49191. $export($export.S, 'Reflect', {
  49192. enumerate: function enumerate(target){
  49193. return new Enumerate(target);
  49194. }
  49195. });
  49196. /***/ },
  49197. /* 388 */
  49198. /***/ function(module, exports, __webpack_require__) {
  49199. // 26.1.7 Reflect.getOwnPropertyDescriptor(target, propertyKey)
  49200. var gOPD = __webpack_require__(25)
  49201. , $export = __webpack_require__(0)
  49202. , anObject = __webpack_require__(3);
  49203. $export($export.S, 'Reflect', {
  49204. getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, propertyKey){
  49205. return gOPD.f(anObject(target), propertyKey);
  49206. }
  49207. });
  49208. /***/ },
  49209. /* 389 */
  49210. /***/ function(module, exports, __webpack_require__) {
  49211. // 26.1.8 Reflect.getPrototypeOf(target)
  49212. var $export = __webpack_require__(0)
  49213. , getProto = __webpack_require__(26)
  49214. , anObject = __webpack_require__(3);
  49215. $export($export.S, 'Reflect', {
  49216. getPrototypeOf: function getPrototypeOf(target){
  49217. return getProto(anObject(target));
  49218. }
  49219. });
  49220. /***/ },
  49221. /* 390 */
  49222. /***/ function(module, exports, __webpack_require__) {
  49223. // 26.1.6 Reflect.get(target, propertyKey [, receiver])
  49224. var gOPD = __webpack_require__(25)
  49225. , getPrototypeOf = __webpack_require__(26)
  49226. , has = __webpack_require__(17)
  49227. , $export = __webpack_require__(0)
  49228. , isObject = __webpack_require__(7)
  49229. , anObject = __webpack_require__(3);
  49230. function get(target, propertyKey/*, receiver*/){
  49231. var receiver = arguments.length < 3 ? target : arguments[2]
  49232. , desc, proto;
  49233. if(anObject(target) === receiver)return target[propertyKey];
  49234. if(desc = gOPD.f(target, propertyKey))return has(desc, 'value')
  49235. ? desc.value
  49236. : desc.get !== undefined
  49237. ? desc.get.call(receiver)
  49238. : undefined;
  49239. if(isObject(proto = getPrototypeOf(target)))return get(proto, propertyKey, receiver);
  49240. }
  49241. $export($export.S, 'Reflect', {get: get});
  49242. /***/ },
  49243. /* 391 */
  49244. /***/ function(module, exports, __webpack_require__) {
  49245. // 26.1.9 Reflect.has(target, propertyKey)
  49246. var $export = __webpack_require__(0);
  49247. $export($export.S, 'Reflect', {
  49248. has: function has(target, propertyKey){
  49249. return propertyKey in target;
  49250. }
  49251. });
  49252. /***/ },
  49253. /* 392 */
  49254. /***/ function(module, exports, __webpack_require__) {
  49255. // 26.1.10 Reflect.isExtensible(target)
  49256. var $export = __webpack_require__(0)
  49257. , anObject = __webpack_require__(3)
  49258. , $isExtensible = Object.isExtensible;
  49259. $export($export.S, 'Reflect', {
  49260. isExtensible: function isExtensible(target){
  49261. anObject(target);
  49262. return $isExtensible ? $isExtensible(target) : true;
  49263. }
  49264. });
  49265. /***/ },
  49266. /* 393 */
  49267. /***/ function(module, exports, __webpack_require__) {
  49268. // 26.1.11 Reflect.ownKeys(target)
  49269. var $export = __webpack_require__(0);
  49270. $export($export.S, 'Reflect', {ownKeys: __webpack_require__(185)});
  49271. /***/ },
  49272. /* 394 */
  49273. /***/ function(module, exports, __webpack_require__) {
  49274. // 26.1.12 Reflect.preventExtensions(target)
  49275. var $export = __webpack_require__(0)
  49276. , anObject = __webpack_require__(3)
  49277. , $preventExtensions = Object.preventExtensions;
  49278. $export($export.S, 'Reflect', {
  49279. preventExtensions: function preventExtensions(target){
  49280. anObject(target);
  49281. try {
  49282. if($preventExtensions)$preventExtensions(target);
  49283. return true;
  49284. } catch(e){
  49285. return false;
  49286. }
  49287. }
  49288. });
  49289. /***/ },
  49290. /* 395 */
  49291. /***/ function(module, exports, __webpack_require__) {
  49292. // 26.1.14 Reflect.setPrototypeOf(target, proto)
  49293. var $export = __webpack_require__(0)
  49294. , setProto = __webpack_require__(91);
  49295. if(setProto)$export($export.S, 'Reflect', {
  49296. setPrototypeOf: function setPrototypeOf(target, proto){
  49297. setProto.check(target, proto);
  49298. try {
  49299. setProto.set(target, proto);
  49300. return true;
  49301. } catch(e){
  49302. return false;
  49303. }
  49304. }
  49305. });
  49306. /***/ },
  49307. /* 396 */
  49308. /***/ function(module, exports, __webpack_require__) {
  49309. // 26.1.13 Reflect.set(target, propertyKey, V [, receiver])
  49310. var dP = __webpack_require__(11)
  49311. , gOPD = __webpack_require__(25)
  49312. , getPrototypeOf = __webpack_require__(26)
  49313. , has = __webpack_require__(17)
  49314. , $export = __webpack_require__(0)
  49315. , createDesc = __webpack_require__(41)
  49316. , anObject = __webpack_require__(3)
  49317. , isObject = __webpack_require__(7);
  49318. function set(target, propertyKey, V/*, receiver*/){
  49319. var receiver = arguments.length < 4 ? target : arguments[3]
  49320. , ownDesc = gOPD.f(anObject(target), propertyKey)
  49321. , existingDescriptor, proto;
  49322. if(!ownDesc){
  49323. if(isObject(proto = getPrototypeOf(target))){
  49324. return set(proto, propertyKey, V, receiver);
  49325. }
  49326. ownDesc = createDesc(0);
  49327. }
  49328. if(has(ownDesc, 'value')){
  49329. if(ownDesc.writable === false || !isObject(receiver))return false;
  49330. existingDescriptor = gOPD.f(receiver, propertyKey) || createDesc(0);
  49331. existingDescriptor.value = V;
  49332. dP.f(receiver, propertyKey, existingDescriptor);
  49333. return true;
  49334. }
  49335. return ownDesc.set === undefined ? false : (ownDesc.set.call(receiver, V), true);
  49336. }
  49337. $export($export.S, 'Reflect', {set: set});
  49338. /***/ },
  49339. /* 397 */
  49340. /***/ function(module, exports, __webpack_require__) {
  49341. var global = __webpack_require__(5)
  49342. , inheritIfRequired = __webpack_require__(110)
  49343. , dP = __webpack_require__(11).f
  49344. , gOPN = __webpack_require__(48).f
  49345. , isRegExp = __webpack_require__(87)
  49346. , $flags = __webpack_require__(85)
  49347. , $RegExp = global.RegExp
  49348. , Base = $RegExp
  49349. , proto = $RegExp.prototype
  49350. , re1 = /a/g
  49351. , re2 = /a/g
  49352. // "new" creates a new object, old webkit buggy here
  49353. , CORRECT_NEW = new $RegExp(re1) !== re1;
  49354. if(__webpack_require__(10) && (!CORRECT_NEW || __webpack_require__(6)(function(){
  49355. re2[__webpack_require__(8)('match')] = false;
  49356. // RegExp constructor can alter flags and IsRegExp works correct with @@match
  49357. return $RegExp(re1) != re1 || $RegExp(re2) == re2 || $RegExp(re1, 'i') != '/a/i';
  49358. }))){
  49359. $RegExp = function RegExp(p, f){
  49360. var tiRE = this instanceof $RegExp
  49361. , piRE = isRegExp(p)
  49362. , fiU = f === undefined;
  49363. return !tiRE && piRE && p.constructor === $RegExp && fiU ? p
  49364. : inheritIfRequired(CORRECT_NEW
  49365. ? new Base(piRE && !fiU ? p.source : p, f)
  49366. : Base((piRE = p instanceof $RegExp) ? p.source : p, piRE && fiU ? $flags.call(p) : f)
  49367. , tiRE ? this : proto, $RegExp);
  49368. };
  49369. var proxy = function(key){
  49370. key in $RegExp || dP($RegExp, key, {
  49371. configurable: true,
  49372. get: function(){ return Base[key]; },
  49373. set: function(it){ Base[key] = it; }
  49374. });
  49375. };
  49376. for(var keys = gOPN(Base), i = 0; keys.length > i; )proxy(keys[i++]);
  49377. proto.constructor = $RegExp;
  49378. $RegExp.prototype = proto;
  49379. __webpack_require__(22)(global, 'RegExp', $RegExp);
  49380. }
  49381. __webpack_require__(51)('RegExp');
  49382. /***/ },
  49383. /* 398 */
  49384. /***/ function(module, exports, __webpack_require__) {
  49385. // @@match logic
  49386. __webpack_require__(84)('match', 1, function(defined, MATCH, $match){
  49387. // 21.1.3.11 String.prototype.match(regexp)
  49388. return [function match(regexp){
  49389. 'use strict';
  49390. var O = defined(this)
  49391. , fn = regexp == undefined ? undefined : regexp[MATCH];
  49392. return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[MATCH](String(O));
  49393. }, $match];
  49394. });
  49395. /***/ },
  49396. /* 399 */
  49397. /***/ function(module, exports, __webpack_require__) {
  49398. // @@replace logic
  49399. __webpack_require__(84)('replace', 2, function(defined, REPLACE, $replace){
  49400. // 21.1.3.14 String.prototype.replace(searchValue, replaceValue)
  49401. return [function replace(searchValue, replaceValue){
  49402. 'use strict';
  49403. var O = defined(this)
  49404. , fn = searchValue == undefined ? undefined : searchValue[REPLACE];
  49405. return fn !== undefined
  49406. ? fn.call(searchValue, O, replaceValue)
  49407. : $replace.call(String(O), searchValue, replaceValue);
  49408. }, $replace];
  49409. });
  49410. /***/ },
  49411. /* 400 */
  49412. /***/ function(module, exports, __webpack_require__) {
  49413. // @@search logic
  49414. __webpack_require__(84)('search', 1, function(defined, SEARCH, $search){
  49415. // 21.1.3.15 String.prototype.search(regexp)
  49416. return [function search(regexp){
  49417. 'use strict';
  49418. var O = defined(this)
  49419. , fn = regexp == undefined ? undefined : regexp[SEARCH];
  49420. return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[SEARCH](String(O));
  49421. }, $search];
  49422. });
  49423. /***/ },
  49424. /* 401 */
  49425. /***/ function(module, exports, __webpack_require__) {
  49426. // @@split logic
  49427. __webpack_require__(84)('split', 2, function(defined, SPLIT, $split){
  49428. 'use strict';
  49429. var isRegExp = __webpack_require__(87)
  49430. , _split = $split
  49431. , $push = [].push
  49432. , $SPLIT = 'split'
  49433. , LENGTH = 'length'
  49434. , LAST_INDEX = 'lastIndex';
  49435. if(
  49436. 'abbc'[$SPLIT](/(b)*/)[1] == 'c' ||
  49437. 'test'[$SPLIT](/(?:)/, -1)[LENGTH] != 4 ||
  49438. 'ab'[$SPLIT](/(?:ab)*/)[LENGTH] != 2 ||
  49439. '.'[$SPLIT](/(.?)(.?)/)[LENGTH] != 4 ||
  49440. '.'[$SPLIT](/()()/)[LENGTH] > 1 ||
  49441. ''[$SPLIT](/.?/)[LENGTH]
  49442. ){
  49443. var NPCG = /()??/.exec('')[1] === undefined; // nonparticipating capturing group
  49444. // based on es5-shim implementation, need to rework it
  49445. $split = function(separator, limit){
  49446. var string = String(this);
  49447. if(separator === undefined && limit === 0)return [];
  49448. // If `separator` is not a regex, use native split
  49449. if(!isRegExp(separator))return _split.call(string, separator, limit);
  49450. var output = [];
  49451. var flags = (separator.ignoreCase ? 'i' : '') +
  49452. (separator.multiline ? 'm' : '') +
  49453. (separator.unicode ? 'u' : '') +
  49454. (separator.sticky ? 'y' : '');
  49455. var lastLastIndex = 0;
  49456. var splitLimit = limit === undefined ? 4294967295 : limit >>> 0;
  49457. // Make `global` and avoid `lastIndex` issues by working with a copy
  49458. var separatorCopy = new RegExp(separator.source, flags + 'g');
  49459. var separator2, match, lastIndex, lastLength, i;
  49460. // Doesn't need flags gy, but they don't hurt
  49461. if(!NPCG)separator2 = new RegExp('^' + separatorCopy.source + '$(?!\\s)', flags);
  49462. while(match = separatorCopy.exec(string)){
  49463. // `separatorCopy.lastIndex` is not reliable cross-browser
  49464. lastIndex = match.index + match[0][LENGTH];
  49465. if(lastIndex > lastLastIndex){
  49466. output.push(string.slice(lastLastIndex, match.index));
  49467. // Fix browsers whose `exec` methods don't consistently return `undefined` for NPCG
  49468. if(!NPCG && match[LENGTH] > 1)match[0].replace(separator2, function(){
  49469. for(i = 1; i < arguments[LENGTH] - 2; i++)if(arguments[i] === undefined)match[i] = undefined;
  49470. });
  49471. if(match[LENGTH] > 1 && match.index < string[LENGTH])$push.apply(output, match.slice(1));
  49472. lastLength = match[0][LENGTH];
  49473. lastLastIndex = lastIndex;
  49474. if(output[LENGTH] >= splitLimit)break;
  49475. }
  49476. if(separatorCopy[LAST_INDEX] === match.index)separatorCopy[LAST_INDEX]++; // Avoid an infinite loop
  49477. }
  49478. if(lastLastIndex === string[LENGTH]){
  49479. if(lastLength || !separatorCopy.test(''))output.push('');
  49480. } else output.push(string.slice(lastLastIndex));
  49481. return output[LENGTH] > splitLimit ? output.slice(0, splitLimit) : output;
  49482. };
  49483. // Chakra, V8
  49484. } else if('0'[$SPLIT](undefined, 0)[LENGTH]){
  49485. $split = function(separator, limit){
  49486. return separator === undefined && limit === 0 ? [] : _split.call(this, separator, limit);
  49487. };
  49488. }
  49489. // 21.1.3.17 String.prototype.split(separator, limit)
  49490. return [function split(separator, limit){
  49491. var O = defined(this)
  49492. , fn = separator == undefined ? undefined : separator[SPLIT];
  49493. return fn !== undefined ? fn.call(separator, O, limit) : $split.call(String(O), separator, limit);
  49494. }, $split];
  49495. });
  49496. /***/ },
  49497. /* 402 */
  49498. /***/ function(module, exports, __webpack_require__) {
  49499. "use strict";
  49500. 'use strict';
  49501. __webpack_require__(192);
  49502. var anObject = __webpack_require__(3)
  49503. , $flags = __webpack_require__(85)
  49504. , DESCRIPTORS = __webpack_require__(10)
  49505. , TO_STRING = 'toString'
  49506. , $toString = /./[TO_STRING];
  49507. var define = function(fn){
  49508. __webpack_require__(22)(RegExp.prototype, TO_STRING, fn, true);
  49509. };
  49510. // 21.2.5.14 RegExp.prototype.toString()
  49511. if(__webpack_require__(6)(function(){ return $toString.call({source: 'a', flags: 'b'}) != '/a/b'; })){
  49512. define(function toString(){
  49513. var R = anObject(this);
  49514. return '/'.concat(R.source, '/',
  49515. 'flags' in R ? R.flags : !DESCRIPTORS && R instanceof RegExp ? $flags.call(R) : undefined);
  49516. });
  49517. // FF44- RegExp#toString has a wrong name
  49518. } else if($toString.name != TO_STRING){
  49519. define(function toString(){
  49520. return $toString.call(this);
  49521. });
  49522. }
  49523. /***/ },
  49524. /* 403 */
  49525. /***/ function(module, exports, __webpack_require__) {
  49526. "use strict";
  49527. 'use strict';
  49528. // B.2.3.2 String.prototype.anchor(name)
  49529. __webpack_require__(23)('anchor', function(createHTML){
  49530. return function anchor(name){
  49531. return createHTML(this, 'a', 'name', name);
  49532. }
  49533. });
  49534. /***/ },
  49535. /* 404 */
  49536. /***/ function(module, exports, __webpack_require__) {
  49537. "use strict";
  49538. 'use strict';
  49539. // B.2.3.3 String.prototype.big()
  49540. __webpack_require__(23)('big', function(createHTML){
  49541. return function big(){
  49542. return createHTML(this, 'big', '', '');
  49543. }
  49544. });
  49545. /***/ },
  49546. /* 405 */
  49547. /***/ function(module, exports, __webpack_require__) {
  49548. "use strict";
  49549. 'use strict';
  49550. // B.2.3.4 String.prototype.blink()
  49551. __webpack_require__(23)('blink', function(createHTML){
  49552. return function blink(){
  49553. return createHTML(this, 'blink', '', '');
  49554. }
  49555. });
  49556. /***/ },
  49557. /* 406 */
  49558. /***/ function(module, exports, __webpack_require__) {
  49559. "use strict";
  49560. 'use strict';
  49561. // B.2.3.5 String.prototype.bold()
  49562. __webpack_require__(23)('bold', function(createHTML){
  49563. return function bold(){
  49564. return createHTML(this, 'b', '', '');
  49565. }
  49566. });
  49567. /***/ },
  49568. /* 407 */
  49569. /***/ function(module, exports, __webpack_require__) {
  49570. "use strict";
  49571. 'use strict';
  49572. var $export = __webpack_require__(0)
  49573. , $at = __webpack_require__(121)(false);
  49574. $export($export.P, 'String', {
  49575. // 21.1.3.3 String.prototype.codePointAt(pos)
  49576. codePointAt: function codePointAt(pos){
  49577. return $at(this, pos);
  49578. }
  49579. });
  49580. /***/ },
  49581. /* 408 */
  49582. /***/ function(module, exports, __webpack_require__) {
  49583. "use strict";
  49584. // 21.1.3.6 String.prototype.endsWith(searchString [, endPosition])
  49585. 'use strict';
  49586. var $export = __webpack_require__(0)
  49587. , toLength = __webpack_require__(15)
  49588. , context = __webpack_require__(122)
  49589. , ENDS_WITH = 'endsWith'
  49590. , $endsWith = ''[ENDS_WITH];
  49591. $export($export.P + $export.F * __webpack_require__(108)(ENDS_WITH), 'String', {
  49592. endsWith: function endsWith(searchString /*, endPosition = @length */){
  49593. var that = context(this, searchString, ENDS_WITH)
  49594. , endPosition = arguments.length > 1 ? arguments[1] : undefined
  49595. , len = toLength(that.length)
  49596. , end = endPosition === undefined ? len : Math.min(toLength(endPosition), len)
  49597. , search = String(searchString);
  49598. return $endsWith
  49599. ? $endsWith.call(that, search, end)
  49600. : that.slice(end - search.length, end) === search;
  49601. }
  49602. });
  49603. /***/ },
  49604. /* 409 */
  49605. /***/ function(module, exports, __webpack_require__) {
  49606. "use strict";
  49607. 'use strict';
  49608. // B.2.3.6 String.prototype.fixed()
  49609. __webpack_require__(23)('fixed', function(createHTML){
  49610. return function fixed(){
  49611. return createHTML(this, 'tt', '', '');
  49612. }
  49613. });
  49614. /***/ },
  49615. /* 410 */
  49616. /***/ function(module, exports, __webpack_require__) {
  49617. "use strict";
  49618. 'use strict';
  49619. // B.2.3.7 String.prototype.fontcolor(color)
  49620. __webpack_require__(23)('fontcolor', function(createHTML){
  49621. return function fontcolor(color){
  49622. return createHTML(this, 'font', 'color', color);
  49623. }
  49624. });
  49625. /***/ },
  49626. /* 411 */
  49627. /***/ function(module, exports, __webpack_require__) {
  49628. "use strict";
  49629. 'use strict';
  49630. // B.2.3.8 String.prototype.fontsize(size)
  49631. __webpack_require__(23)('fontsize', function(createHTML){
  49632. return function fontsize(size){
  49633. return createHTML(this, 'font', 'size', size);
  49634. }
  49635. });
  49636. /***/ },
  49637. /* 412 */
  49638. /***/ function(module, exports, __webpack_require__) {
  49639. var $export = __webpack_require__(0)
  49640. , toIndex = __webpack_require__(52)
  49641. , fromCharCode = String.fromCharCode
  49642. , $fromCodePoint = String.fromCodePoint;
  49643. // length should be 1, old FF problem
  49644. $export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', {
  49645. // 21.1.2.2 String.fromCodePoint(...codePoints)
  49646. fromCodePoint: function fromCodePoint(x){ // eslint-disable-line no-unused-vars
  49647. var res = []
  49648. , aLen = arguments.length
  49649. , i = 0
  49650. , code;
  49651. while(aLen > i){
  49652. code = +arguments[i++];
  49653. if(toIndex(code, 0x10ffff) !== code)throw RangeError(code + ' is not a valid code point');
  49654. res.push(code < 0x10000
  49655. ? fromCharCode(code)
  49656. : fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00)
  49657. );
  49658. } return res.join('');
  49659. }
  49660. });
  49661. /***/ },
  49662. /* 413 */
  49663. /***/ function(module, exports, __webpack_require__) {
  49664. "use strict";
  49665. // 21.1.3.7 String.prototype.includes(searchString, position = 0)
  49666. 'use strict';
  49667. var $export = __webpack_require__(0)
  49668. , context = __webpack_require__(122)
  49669. , INCLUDES = 'includes';
  49670. $export($export.P + $export.F * __webpack_require__(108)(INCLUDES), 'String', {
  49671. includes: function includes(searchString /*, position = 0 */){
  49672. return !!~context(this, searchString, INCLUDES)
  49673. .indexOf(searchString, arguments.length > 1 ? arguments[1] : undefined);
  49674. }
  49675. });
  49676. /***/ },
  49677. /* 414 */
  49678. /***/ function(module, exports, __webpack_require__) {
  49679. "use strict";
  49680. 'use strict';
  49681. // B.2.3.9 String.prototype.italics()
  49682. __webpack_require__(23)('italics', function(createHTML){
  49683. return function italics(){
  49684. return createHTML(this, 'i', '', '');
  49685. }
  49686. });
  49687. /***/ },
  49688. /* 415 */
  49689. /***/ function(module, exports, __webpack_require__) {
  49690. "use strict";
  49691. 'use strict';
  49692. var $at = __webpack_require__(121)(true);
  49693. // 21.1.3.27 String.prototype[@@iterator]()
  49694. __webpack_require__(115)(String, 'String', function(iterated){
  49695. this._t = String(iterated); // target
  49696. this._i = 0; // next index
  49697. // 21.1.5.2.1 %StringIteratorPrototype%.next()
  49698. }, function(){
  49699. var O = this._t
  49700. , index = this._i
  49701. , point;
  49702. if(index >= O.length)return {value: undefined, done: true};
  49703. point = $at(O, index);
  49704. this._i += point.length;
  49705. return {value: point, done: false};
  49706. });
  49707. /***/ },
  49708. /* 416 */
  49709. /***/ function(module, exports, __webpack_require__) {
  49710. "use strict";
  49711. 'use strict';
  49712. // B.2.3.10 String.prototype.link(url)
  49713. __webpack_require__(23)('link', function(createHTML){
  49714. return function link(url){
  49715. return createHTML(this, 'a', 'href', url);
  49716. }
  49717. });
  49718. /***/ },
  49719. /* 417 */
  49720. /***/ function(module, exports, __webpack_require__) {
  49721. var $export = __webpack_require__(0)
  49722. , toIObject = __webpack_require__(24)
  49723. , toLength = __webpack_require__(15);
  49724. $export($export.S, 'String', {
  49725. // 21.1.2.4 String.raw(callSite, ...substitutions)
  49726. raw: function raw(callSite){
  49727. var tpl = toIObject(callSite.raw)
  49728. , len = toLength(tpl.length)
  49729. , aLen = arguments.length
  49730. , res = []
  49731. , i = 0;
  49732. while(len > i){
  49733. res.push(String(tpl[i++]));
  49734. if(i < aLen)res.push(String(arguments[i]));
  49735. } return res.join('');
  49736. }
  49737. });
  49738. /***/ },
  49739. /* 418 */
  49740. /***/ function(module, exports, __webpack_require__) {
  49741. var $export = __webpack_require__(0);
  49742. $export($export.P, 'String', {
  49743. // 21.1.3.13 String.prototype.repeat(count)
  49744. repeat: __webpack_require__(123)
  49745. });
  49746. /***/ },
  49747. /* 419 */
  49748. /***/ function(module, exports, __webpack_require__) {
  49749. "use strict";
  49750. 'use strict';
  49751. // B.2.3.11 String.prototype.small()
  49752. __webpack_require__(23)('small', function(createHTML){
  49753. return function small(){
  49754. return createHTML(this, 'small', '', '');
  49755. }
  49756. });
  49757. /***/ },
  49758. /* 420 */
  49759. /***/ function(module, exports, __webpack_require__) {
  49760. "use strict";
  49761. // 21.1.3.18 String.prototype.startsWith(searchString [, position ])
  49762. 'use strict';
  49763. var $export = __webpack_require__(0)
  49764. , toLength = __webpack_require__(15)
  49765. , context = __webpack_require__(122)
  49766. , STARTS_WITH = 'startsWith'
  49767. , $startsWith = ''[STARTS_WITH];
  49768. $export($export.P + $export.F * __webpack_require__(108)(STARTS_WITH), 'String', {
  49769. startsWith: function startsWith(searchString /*, position = 0 */){
  49770. var that = context(this, searchString, STARTS_WITH)
  49771. , index = toLength(Math.min(arguments.length > 1 ? arguments[1] : undefined, that.length))
  49772. , search = String(searchString);
  49773. return $startsWith
  49774. ? $startsWith.call(that, search, index)
  49775. : that.slice(index, index + search.length) === search;
  49776. }
  49777. });
  49778. /***/ },
  49779. /* 421 */
  49780. /***/ function(module, exports, __webpack_require__) {
  49781. "use strict";
  49782. 'use strict';
  49783. // B.2.3.12 String.prototype.strike()
  49784. __webpack_require__(23)('strike', function(createHTML){
  49785. return function strike(){
  49786. return createHTML(this, 'strike', '', '');
  49787. }
  49788. });
  49789. /***/ },
  49790. /* 422 */
  49791. /***/ function(module, exports, __webpack_require__) {
  49792. "use strict";
  49793. 'use strict';
  49794. // B.2.3.13 String.prototype.sub()
  49795. __webpack_require__(23)('sub', function(createHTML){
  49796. return function sub(){
  49797. return createHTML(this, 'sub', '', '');
  49798. }
  49799. });
  49800. /***/ },
  49801. /* 423 */
  49802. /***/ function(module, exports, __webpack_require__) {
  49803. "use strict";
  49804. 'use strict';
  49805. // B.2.3.14 String.prototype.sup()
  49806. __webpack_require__(23)('sup', function(createHTML){
  49807. return function sup(){
  49808. return createHTML(this, 'sup', '', '');
  49809. }
  49810. });
  49811. /***/ },
  49812. /* 424 */
  49813. /***/ function(module, exports, __webpack_require__) {
  49814. "use strict";
  49815. 'use strict';
  49816. // 21.1.3.25 String.prototype.trim()
  49817. __webpack_require__(62)('trim', function($trim){
  49818. return function trim(){
  49819. return $trim(this, 3);
  49820. };
  49821. });
  49822. /***/ },
  49823. /* 425 */
  49824. /***/ function(module, exports, __webpack_require__) {
  49825. "use strict";
  49826. 'use strict';
  49827. // ECMAScript 6 symbols shim
  49828. var global = __webpack_require__(5)
  49829. , has = __webpack_require__(17)
  49830. , DESCRIPTORS = __webpack_require__(10)
  49831. , $export = __webpack_require__(0)
  49832. , redefine = __webpack_require__(22)
  49833. , META = __webpack_require__(40).KEY
  49834. , $fails = __webpack_require__(6)
  49835. , shared = __webpack_require__(92)
  49836. , setToStringTag = __webpack_require__(61)
  49837. , uid = __webpack_require__(53)
  49838. , wks = __webpack_require__(8)
  49839. , wksExt = __webpack_require__(190)
  49840. , wksDefine = __webpack_require__(127)
  49841. , keyOf = __webpack_require__(300)
  49842. , enumKeys = __webpack_require__(299)
  49843. , isArray = __webpack_require__(112)
  49844. , anObject = __webpack_require__(3)
  49845. , toIObject = __webpack_require__(24)
  49846. , toPrimitive = __webpack_require__(34)
  49847. , createDesc = __webpack_require__(41)
  49848. , _create = __webpack_require__(47)
  49849. , gOPNExt = __webpack_require__(182)
  49850. , $GOPD = __webpack_require__(25)
  49851. , $DP = __webpack_require__(11)
  49852. , $keys = __webpack_require__(49)
  49853. , gOPD = $GOPD.f
  49854. , dP = $DP.f
  49855. , gOPN = gOPNExt.f
  49856. , $Symbol = global.Symbol
  49857. , $JSON = global.JSON
  49858. , _stringify = $JSON && $JSON.stringify
  49859. , PROTOTYPE = 'prototype'
  49860. , HIDDEN = wks('_hidden')
  49861. , TO_PRIMITIVE = wks('toPrimitive')
  49862. , isEnum = {}.propertyIsEnumerable
  49863. , SymbolRegistry = shared('symbol-registry')
  49864. , AllSymbols = shared('symbols')
  49865. , OPSymbols = shared('op-symbols')
  49866. , ObjectProto = Object[PROTOTYPE]
  49867. , USE_NATIVE = typeof $Symbol == 'function'
  49868. , QObject = global.QObject;
  49869. // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
  49870. var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
  49871. // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
  49872. var setSymbolDesc = DESCRIPTORS && $fails(function(){
  49873. return _create(dP({}, 'a', {
  49874. get: function(){ return dP(this, 'a', {value: 7}).a; }
  49875. })).a != 7;
  49876. }) ? function(it, key, D){
  49877. var protoDesc = gOPD(ObjectProto, key);
  49878. if(protoDesc)delete ObjectProto[key];
  49879. dP(it, key, D);
  49880. if(protoDesc && it !== ObjectProto)dP(ObjectProto, key, protoDesc);
  49881. } : dP;
  49882. var wrap = function(tag){
  49883. var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]);
  49884. sym._k = tag;
  49885. return sym;
  49886. };
  49887. var isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function(it){
  49888. return typeof it == 'symbol';
  49889. } : function(it){
  49890. return it instanceof $Symbol;
  49891. };
  49892. var $defineProperty = function defineProperty(it, key, D){
  49893. if(it === ObjectProto)$defineProperty(OPSymbols, key, D);
  49894. anObject(it);
  49895. key = toPrimitive(key, true);
  49896. anObject(D);
  49897. if(has(AllSymbols, key)){
  49898. if(!D.enumerable){
  49899. if(!has(it, HIDDEN))dP(it, HIDDEN, createDesc(1, {}));
  49900. it[HIDDEN][key] = true;
  49901. } else {
  49902. if(has(it, HIDDEN) && it[HIDDEN][key])it[HIDDEN][key] = false;
  49903. D = _create(D, {enumerable: createDesc(0, false)});
  49904. } return setSymbolDesc(it, key, D);
  49905. } return dP(it, key, D);
  49906. };
  49907. var $defineProperties = function defineProperties(it, P){
  49908. anObject(it);
  49909. var keys = enumKeys(P = toIObject(P))
  49910. , i = 0
  49911. , l = keys.length
  49912. , key;
  49913. while(l > i)$defineProperty(it, key = keys[i++], P[key]);
  49914. return it;
  49915. };
  49916. var $create = function create(it, P){
  49917. return P === undefined ? _create(it) : $defineProperties(_create(it), P);
  49918. };
  49919. var $propertyIsEnumerable = function propertyIsEnumerable(key){
  49920. var E = isEnum.call(this, key = toPrimitive(key, true));
  49921. if(this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key))return false;
  49922. return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true;
  49923. };
  49924. var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key){
  49925. it = toIObject(it);
  49926. key = toPrimitive(key, true);
  49927. if(it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key))return;
  49928. var D = gOPD(it, key);
  49929. if(D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key]))D.enumerable = true;
  49930. return D;
  49931. };
  49932. var $getOwnPropertyNames = function getOwnPropertyNames(it){
  49933. var names = gOPN(toIObject(it))
  49934. , result = []
  49935. , i = 0
  49936. , key;
  49937. while(names.length > i){
  49938. if(!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META)result.push(key);
  49939. } return result;
  49940. };
  49941. var $getOwnPropertySymbols = function getOwnPropertySymbols(it){
  49942. var IS_OP = it === ObjectProto
  49943. , names = gOPN(IS_OP ? OPSymbols : toIObject(it))
  49944. , result = []
  49945. , i = 0
  49946. , key;
  49947. while(names.length > i){
  49948. if(has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true))result.push(AllSymbols[key]);
  49949. } return result;
  49950. };
  49951. // 19.4.1.1 Symbol([description])
  49952. if(!USE_NATIVE){
  49953. $Symbol = function Symbol(){
  49954. if(this instanceof $Symbol)throw TypeError('Symbol is not a constructor!');
  49955. var tag = uid(arguments.length > 0 ? arguments[0] : undefined);
  49956. var $set = function(value){
  49957. if(this === ObjectProto)$set.call(OPSymbols, value);
  49958. if(has(this, HIDDEN) && has(this[HIDDEN], tag))this[HIDDEN][tag] = false;
  49959. setSymbolDesc(this, tag, createDesc(1, value));
  49960. };
  49961. if(DESCRIPTORS && setter)setSymbolDesc(ObjectProto, tag, {configurable: true, set: $set});
  49962. return wrap(tag);
  49963. };
  49964. redefine($Symbol[PROTOTYPE], 'toString', function toString(){
  49965. return this._k;
  49966. });
  49967. $GOPD.f = $getOwnPropertyDescriptor;
  49968. $DP.f = $defineProperty;
  49969. __webpack_require__(48).f = gOPNExt.f = $getOwnPropertyNames;
  49970. __webpack_require__(71).f = $propertyIsEnumerable;
  49971. __webpack_require__(90).f = $getOwnPropertySymbols;
  49972. if(DESCRIPTORS && !__webpack_require__(46)){
  49973. redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true);
  49974. }
  49975. wksExt.f = function(name){
  49976. return wrap(wks(name));
  49977. }
  49978. }
  49979. $export($export.G + $export.W + $export.F * !USE_NATIVE, {Symbol: $Symbol});
  49980. for(var symbols = (
  49981. // 19.4.2.2, 19.4.2.3, 19.4.2.4, 19.4.2.6, 19.4.2.8, 19.4.2.9, 19.4.2.10, 19.4.2.11, 19.4.2.12, 19.4.2.13, 19.4.2.14
  49982. 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'
  49983. ).split(','), i = 0; symbols.length > i; )wks(symbols[i++]);
  49984. for(var symbols = $keys(wks.store), i = 0; symbols.length > i; )wksDefine(symbols[i++]);
  49985. $export($export.S + $export.F * !USE_NATIVE, 'Symbol', {
  49986. // 19.4.2.1 Symbol.for(key)
  49987. 'for': function(key){
  49988. return has(SymbolRegistry, key += '')
  49989. ? SymbolRegistry[key]
  49990. : SymbolRegistry[key] = $Symbol(key);
  49991. },
  49992. // 19.4.2.5 Symbol.keyFor(sym)
  49993. keyFor: function keyFor(key){
  49994. if(isSymbol(key))return keyOf(SymbolRegistry, key);
  49995. throw TypeError(key + ' is not a symbol!');
  49996. },
  49997. useSetter: function(){ setter = true; },
  49998. useSimple: function(){ setter = false; }
  49999. });
  50000. $export($export.S + $export.F * !USE_NATIVE, 'Object', {
  50001. // 19.1.2.2 Object.create(O [, Properties])
  50002. create: $create,
  50003. // 19.1.2.4 Object.defineProperty(O, P, Attributes)
  50004. defineProperty: $defineProperty,
  50005. // 19.1.2.3 Object.defineProperties(O, Properties)
  50006. defineProperties: $defineProperties,
  50007. // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
  50008. getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
  50009. // 19.1.2.7 Object.getOwnPropertyNames(O)
  50010. getOwnPropertyNames: $getOwnPropertyNames,
  50011. // 19.1.2.8 Object.getOwnPropertySymbols(O)
  50012. getOwnPropertySymbols: $getOwnPropertySymbols
  50013. });
  50014. // 24.3.2 JSON.stringify(value [, replacer [, space]])
  50015. $JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function(){
  50016. var S = $Symbol();
  50017. // MS Edge converts symbol values to JSON as {}
  50018. // WebKit converts symbol values to JSON as null
  50019. // V8 throws on boxed symbols
  50020. return _stringify([S]) != '[null]' || _stringify({a: S}) != '{}' || _stringify(Object(S)) != '{}';
  50021. })), 'JSON', {
  50022. stringify: function stringify(it){
  50023. if(it === undefined || isSymbol(it))return; // IE8 returns string on undefined
  50024. var args = [it]
  50025. , i = 1
  50026. , replacer, $replacer;
  50027. while(arguments.length > i)args.push(arguments[i++]);
  50028. replacer = args[1];
  50029. if(typeof replacer == 'function')$replacer = replacer;
  50030. if($replacer || !isArray(replacer))replacer = function(key, value){
  50031. if($replacer)value = $replacer.call(this, key, value);
  50032. if(!isSymbol(value))return value;
  50033. };
  50034. args[1] = replacer;
  50035. return _stringify.apply($JSON, args);
  50036. }
  50037. });
  50038. // 19.4.3.4 Symbol.prototype[@@toPrimitive](hint)
  50039. $Symbol[PROTOTYPE][TO_PRIMITIVE] || __webpack_require__(19)($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
  50040. // 19.4.3.5 Symbol.prototype[@@toStringTag]
  50041. setToStringTag($Symbol, 'Symbol');
  50042. // 20.2.1.9 Math[@@toStringTag]
  50043. setToStringTag(Math, 'Math', true);
  50044. // 24.3.3 JSON[@@toStringTag]
  50045. setToStringTag(global.JSON, 'JSON', true);
  50046. /***/ },
  50047. /* 426 */
  50048. /***/ function(module, exports, __webpack_require__) {
  50049. "use strict";
  50050. 'use strict';
  50051. var $export = __webpack_require__(0)
  50052. , $typed = __webpack_require__(93)
  50053. , buffer = __webpack_require__(126)
  50054. , anObject = __webpack_require__(3)
  50055. , toIndex = __webpack_require__(52)
  50056. , toLength = __webpack_require__(15)
  50057. , isObject = __webpack_require__(7)
  50058. , TYPED_ARRAY = __webpack_require__(8)('typed_array')
  50059. , ArrayBuffer = __webpack_require__(5).ArrayBuffer
  50060. , speciesConstructor = __webpack_require__(120)
  50061. , $ArrayBuffer = buffer.ArrayBuffer
  50062. , $DataView = buffer.DataView
  50063. , $isView = $typed.ABV && ArrayBuffer.isView
  50064. , $slice = $ArrayBuffer.prototype.slice
  50065. , VIEW = $typed.VIEW
  50066. , ARRAY_BUFFER = 'ArrayBuffer';
  50067. $export($export.G + $export.W + $export.F * (ArrayBuffer !== $ArrayBuffer), {ArrayBuffer: $ArrayBuffer});
  50068. $export($export.S + $export.F * !$typed.CONSTR, ARRAY_BUFFER, {
  50069. // 24.1.3.1 ArrayBuffer.isView(arg)
  50070. isView: function isView(it){
  50071. return $isView && $isView(it) || isObject(it) && VIEW in it;
  50072. }
  50073. });
  50074. $export($export.P + $export.U + $export.F * __webpack_require__(6)(function(){
  50075. return !new $ArrayBuffer(2).slice(1, undefined).byteLength;
  50076. }), ARRAY_BUFFER, {
  50077. // 24.1.4.3 ArrayBuffer.prototype.slice(start, end)
  50078. slice: function slice(start, end){
  50079. if($slice !== undefined && end === undefined)return $slice.call(anObject(this), start); // FF fix
  50080. var len = anObject(this).byteLength
  50081. , first = toIndex(start, len)
  50082. , final = toIndex(end === undefined ? len : end, len)
  50083. , result = new (speciesConstructor(this, $ArrayBuffer))(toLength(final - first))
  50084. , viewS = new $DataView(this)
  50085. , viewT = new $DataView(result)
  50086. , index = 0;
  50087. while(first < final){
  50088. viewT.setUint8(index++, viewS.getUint8(first++));
  50089. } return result;
  50090. }
  50091. });
  50092. __webpack_require__(51)(ARRAY_BUFFER);
  50093. /***/ },
  50094. /* 427 */
  50095. /***/ function(module, exports, __webpack_require__) {
  50096. var $export = __webpack_require__(0);
  50097. $export($export.G + $export.W + $export.F * !__webpack_require__(93).ABV, {
  50098. DataView: __webpack_require__(126).DataView
  50099. });
  50100. /***/ },
  50101. /* 428 */
  50102. /***/ function(module, exports, __webpack_require__) {
  50103. __webpack_require__(37)('Float32', 4, function(init){
  50104. return function Float32Array(data, byteOffset, length){
  50105. return init(this, data, byteOffset, length);
  50106. };
  50107. });
  50108. /***/ },
  50109. /* 429 */
  50110. /***/ function(module, exports, __webpack_require__) {
  50111. __webpack_require__(37)('Float64', 8, function(init){
  50112. return function Float64Array(data, byteOffset, length){
  50113. return init(this, data, byteOffset, length);
  50114. };
  50115. });
  50116. /***/ },
  50117. /* 430 */
  50118. /***/ function(module, exports, __webpack_require__) {
  50119. __webpack_require__(37)('Int16', 2, function(init){
  50120. return function Int16Array(data, byteOffset, length){
  50121. return init(this, data, byteOffset, length);
  50122. };
  50123. });
  50124. /***/ },
  50125. /* 431 */
  50126. /***/ function(module, exports, __webpack_require__) {
  50127. __webpack_require__(37)('Int32', 4, function(init){
  50128. return function Int32Array(data, byteOffset, length){
  50129. return init(this, data, byteOffset, length);
  50130. };
  50131. });
  50132. /***/ },
  50133. /* 432 */
  50134. /***/ function(module, exports, __webpack_require__) {
  50135. __webpack_require__(37)('Int8', 1, function(init){
  50136. return function Int8Array(data, byteOffset, length){
  50137. return init(this, data, byteOffset, length);
  50138. };
  50139. });
  50140. /***/ },
  50141. /* 433 */
  50142. /***/ function(module, exports, __webpack_require__) {
  50143. __webpack_require__(37)('Uint16', 2, function(init){
  50144. return function Uint16Array(data, byteOffset, length){
  50145. return init(this, data, byteOffset, length);
  50146. };
  50147. });
  50148. /***/ },
  50149. /* 434 */
  50150. /***/ function(module, exports, __webpack_require__) {
  50151. __webpack_require__(37)('Uint32', 4, function(init){
  50152. return function Uint32Array(data, byteOffset, length){
  50153. return init(this, data, byteOffset, length);
  50154. };
  50155. });
  50156. /***/ },
  50157. /* 435 */
  50158. /***/ function(module, exports, __webpack_require__) {
  50159. __webpack_require__(37)('Uint8', 1, function(init){
  50160. return function Uint8Array(data, byteOffset, length){
  50161. return init(this, data, byteOffset, length);
  50162. };
  50163. });
  50164. /***/ },
  50165. /* 436 */
  50166. /***/ function(module, exports, __webpack_require__) {
  50167. __webpack_require__(37)('Uint8', 1, function(init){
  50168. return function Uint8ClampedArray(data, byteOffset, length){
  50169. return init(this, data, byteOffset, length);
  50170. };
  50171. }, true);
  50172. /***/ },
  50173. /* 437 */
  50174. /***/ function(module, exports, __webpack_require__) {
  50175. "use strict";
  50176. 'use strict';
  50177. var weak = __webpack_require__(175);
  50178. // 23.4 WeakSet Objects
  50179. __webpack_require__(83)('WeakSet', function(get){
  50180. return function WeakSet(){ return get(this, arguments.length > 0 ? arguments[0] : undefined); };
  50181. }, {
  50182. // 23.4.3.1 WeakSet.prototype.add(value)
  50183. add: function add(value){
  50184. return weak.def(this, value, true);
  50185. }
  50186. }, weak, false, true);
  50187. /***/ },
  50188. /* 438 */
  50189. /***/ function(module, exports, __webpack_require__) {
  50190. "use strict";
  50191. 'use strict';
  50192. // https://github.com/tc39/Array.prototype.includes
  50193. var $export = __webpack_require__(0)
  50194. , $includes = __webpack_require__(82)(true);
  50195. $export($export.P, 'Array', {
  50196. includes: function includes(el /*, fromIndex = 0 */){
  50197. return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
  50198. }
  50199. });
  50200. __webpack_require__(58)('includes');
  50201. /***/ },
  50202. /* 439 */
  50203. /***/ function(module, exports, __webpack_require__) {
  50204. // https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-09/sept-25.md#510-globalasap-for-enqueuing-a-microtask
  50205. var $export = __webpack_require__(0)
  50206. , microtask = __webpack_require__(118)()
  50207. , process = __webpack_require__(5).process
  50208. , isNode = __webpack_require__(27)(process) == 'process';
  50209. $export($export.G, {
  50210. asap: function asap(fn){
  50211. var domain = isNode && process.domain;
  50212. microtask(domain ? domain.bind(fn) : fn);
  50213. }
  50214. });
  50215. /***/ },
  50216. /* 440 */
  50217. /***/ function(module, exports, __webpack_require__) {
  50218. // https://github.com/ljharb/proposal-is-error
  50219. var $export = __webpack_require__(0)
  50220. , cof = __webpack_require__(27);
  50221. $export($export.S, 'Error', {
  50222. isError: function isError(it){
  50223. return cof(it) === 'Error';
  50224. }
  50225. });
  50226. /***/ },
  50227. /* 441 */
  50228. /***/ function(module, exports, __webpack_require__) {
  50229. // https://github.com/DavidBruant/Map-Set.prototype.toJSON
  50230. var $export = __webpack_require__(0);
  50231. $export($export.P + $export.R, 'Map', {toJSON: __webpack_require__(174)('Map')});
  50232. /***/ },
  50233. /* 442 */
  50234. /***/ function(module, exports, __webpack_require__) {
  50235. // https://gist.github.com/BrendanEich/4294d5c212a6d2254703
  50236. var $export = __webpack_require__(0);
  50237. $export($export.S, 'Math', {
  50238. iaddh: function iaddh(x0, x1, y0, y1){
  50239. var $x0 = x0 >>> 0
  50240. , $x1 = x1 >>> 0
  50241. , $y0 = y0 >>> 0;
  50242. return $x1 + (y1 >>> 0) + (($x0 & $y0 | ($x0 | $y0) & ~($x0 + $y0 >>> 0)) >>> 31) | 0;
  50243. }
  50244. });
  50245. /***/ },
  50246. /* 443 */
  50247. /***/ function(module, exports, __webpack_require__) {
  50248. // https://gist.github.com/BrendanEich/4294d5c212a6d2254703
  50249. var $export = __webpack_require__(0);
  50250. $export($export.S, 'Math', {
  50251. imulh: function imulh(u, v){
  50252. var UINT16 = 0xffff
  50253. , $u = +u
  50254. , $v = +v
  50255. , u0 = $u & UINT16
  50256. , v0 = $v & UINT16
  50257. , u1 = $u >> 16
  50258. , v1 = $v >> 16
  50259. , t = (u1 * v0 >>> 0) + (u0 * v0 >>> 16);
  50260. return u1 * v1 + (t >> 16) + ((u0 * v1 >>> 0) + (t & UINT16) >> 16);
  50261. }
  50262. });
  50263. /***/ },
  50264. /* 444 */
  50265. /***/ function(module, exports, __webpack_require__) {
  50266. // https://gist.github.com/BrendanEich/4294d5c212a6d2254703
  50267. var $export = __webpack_require__(0);
  50268. $export($export.S, 'Math', {
  50269. isubh: function isubh(x0, x1, y0, y1){
  50270. var $x0 = x0 >>> 0
  50271. , $x1 = x1 >>> 0
  50272. , $y0 = y0 >>> 0;
  50273. return $x1 - (y1 >>> 0) - ((~$x0 & $y0 | ~($x0 ^ $y0) & $x0 - $y0 >>> 0) >>> 31) | 0;
  50274. }
  50275. });
  50276. /***/ },
  50277. /* 445 */
  50278. /***/ function(module, exports, __webpack_require__) {
  50279. // https://gist.github.com/BrendanEich/4294d5c212a6d2254703
  50280. var $export = __webpack_require__(0);
  50281. $export($export.S, 'Math', {
  50282. umulh: function umulh(u, v){
  50283. var UINT16 = 0xffff
  50284. , $u = +u
  50285. , $v = +v
  50286. , u0 = $u & UINT16
  50287. , v0 = $v & UINT16
  50288. , u1 = $u >>> 16
  50289. , v1 = $v >>> 16
  50290. , t = (u1 * v0 >>> 0) + (u0 * v0 >>> 16);
  50291. return u1 * v1 + (t >>> 16) + ((u0 * v1 >>> 0) + (t & UINT16) >>> 16);
  50292. }
  50293. });
  50294. /***/ },
  50295. /* 446 */
  50296. /***/ function(module, exports, __webpack_require__) {
  50297. "use strict";
  50298. 'use strict';
  50299. var $export = __webpack_require__(0)
  50300. , toObject = __webpack_require__(16)
  50301. , aFunction = __webpack_require__(21)
  50302. , $defineProperty = __webpack_require__(11);
  50303. // B.2.2.2 Object.prototype.__defineGetter__(P, getter)
  50304. __webpack_require__(10) && $export($export.P + __webpack_require__(89), 'Object', {
  50305. __defineGetter__: function __defineGetter__(P, getter){
  50306. $defineProperty.f(toObject(this), P, {get: aFunction(getter), enumerable: true, configurable: true});
  50307. }
  50308. });
  50309. /***/ },
  50310. /* 447 */
  50311. /***/ function(module, exports, __webpack_require__) {
  50312. "use strict";
  50313. 'use strict';
  50314. var $export = __webpack_require__(0)
  50315. , toObject = __webpack_require__(16)
  50316. , aFunction = __webpack_require__(21)
  50317. , $defineProperty = __webpack_require__(11);
  50318. // B.2.2.3 Object.prototype.__defineSetter__(P, setter)
  50319. __webpack_require__(10) && $export($export.P + __webpack_require__(89), 'Object', {
  50320. __defineSetter__: function __defineSetter__(P, setter){
  50321. $defineProperty.f(toObject(this), P, {set: aFunction(setter), enumerable: true, configurable: true});
  50322. }
  50323. });
  50324. /***/ },
  50325. /* 448 */
  50326. /***/ function(module, exports, __webpack_require__) {
  50327. // https://github.com/tc39/proposal-object-values-entries
  50328. var $export = __webpack_require__(0)
  50329. , $entries = __webpack_require__(184)(true);
  50330. $export($export.S, 'Object', {
  50331. entries: function entries(it){
  50332. return $entries(it);
  50333. }
  50334. });
  50335. /***/ },
  50336. /* 449 */
  50337. /***/ function(module, exports, __webpack_require__) {
  50338. // https://github.com/tc39/proposal-object-getownpropertydescriptors
  50339. var $export = __webpack_require__(0)
  50340. , ownKeys = __webpack_require__(185)
  50341. , toIObject = __webpack_require__(24)
  50342. , gOPD = __webpack_require__(25)
  50343. , createProperty = __webpack_require__(105);
  50344. $export($export.S, 'Object', {
  50345. getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object){
  50346. var O = toIObject(object)
  50347. , getDesc = gOPD.f
  50348. , keys = ownKeys(O)
  50349. , result = {}
  50350. , i = 0
  50351. , key, D;
  50352. while(keys.length > i)createProperty(result, key = keys[i++], getDesc(O, key));
  50353. return result;
  50354. }
  50355. });
  50356. /***/ },
  50357. /* 450 */
  50358. /***/ function(module, exports, __webpack_require__) {
  50359. "use strict";
  50360. 'use strict';
  50361. var $export = __webpack_require__(0)
  50362. , toObject = __webpack_require__(16)
  50363. , toPrimitive = __webpack_require__(34)
  50364. , getPrototypeOf = __webpack_require__(26)
  50365. , getOwnPropertyDescriptor = __webpack_require__(25).f;
  50366. // B.2.2.4 Object.prototype.__lookupGetter__(P)
  50367. __webpack_require__(10) && $export($export.P + __webpack_require__(89), 'Object', {
  50368. __lookupGetter__: function __lookupGetter__(P){
  50369. var O = toObject(this)
  50370. , K = toPrimitive(P, true)
  50371. , D;
  50372. do {
  50373. if(D = getOwnPropertyDescriptor(O, K))return D.get;
  50374. } while(O = getPrototypeOf(O));
  50375. }
  50376. });
  50377. /***/ },
  50378. /* 451 */
  50379. /***/ function(module, exports, __webpack_require__) {
  50380. "use strict";
  50381. 'use strict';
  50382. var $export = __webpack_require__(0)
  50383. , toObject = __webpack_require__(16)
  50384. , toPrimitive = __webpack_require__(34)
  50385. , getPrototypeOf = __webpack_require__(26)
  50386. , getOwnPropertyDescriptor = __webpack_require__(25).f;
  50387. // B.2.2.5 Object.prototype.__lookupSetter__(P)
  50388. __webpack_require__(10) && $export($export.P + __webpack_require__(89), 'Object', {
  50389. __lookupSetter__: function __lookupSetter__(P){
  50390. var O = toObject(this)
  50391. , K = toPrimitive(P, true)
  50392. , D;
  50393. do {
  50394. if(D = getOwnPropertyDescriptor(O, K))return D.set;
  50395. } while(O = getPrototypeOf(O));
  50396. }
  50397. });
  50398. /***/ },
  50399. /* 452 */
  50400. /***/ function(module, exports, __webpack_require__) {
  50401. // https://github.com/tc39/proposal-object-values-entries
  50402. var $export = __webpack_require__(0)
  50403. , $values = __webpack_require__(184)(false);
  50404. $export($export.S, 'Object', {
  50405. values: function values(it){
  50406. return $values(it);
  50407. }
  50408. });
  50409. /***/ },
  50410. /* 453 */
  50411. /***/ function(module, exports, __webpack_require__) {
  50412. "use strict";
  50413. 'use strict';
  50414. // https://github.com/zenparsing/es-observable
  50415. var $export = __webpack_require__(0)
  50416. , global = __webpack_require__(5)
  50417. , core = __webpack_require__(32)
  50418. , microtask = __webpack_require__(118)()
  50419. , OBSERVABLE = __webpack_require__(8)('observable')
  50420. , aFunction = __webpack_require__(21)
  50421. , anObject = __webpack_require__(3)
  50422. , anInstance = __webpack_require__(39)
  50423. , redefineAll = __webpack_require__(50)
  50424. , hide = __webpack_require__(19)
  50425. , forOf = __webpack_require__(60)
  50426. , RETURN = forOf.RETURN;
  50427. var getMethod = function(fn){
  50428. return fn == null ? undefined : aFunction(fn);
  50429. };
  50430. var cleanupSubscription = function(subscription){
  50431. var cleanup = subscription._c;
  50432. if(cleanup){
  50433. subscription._c = undefined;
  50434. cleanup();
  50435. }
  50436. };
  50437. var subscriptionClosed = function(subscription){
  50438. return subscription._o === undefined;
  50439. };
  50440. var closeSubscription = function(subscription){
  50441. if(!subscriptionClosed(subscription)){
  50442. subscription._o = undefined;
  50443. cleanupSubscription(subscription);
  50444. }
  50445. };
  50446. var Subscription = function(observer, subscriber){
  50447. anObject(observer);
  50448. this._c = undefined;
  50449. this._o = observer;
  50450. observer = new SubscriptionObserver(this);
  50451. try {
  50452. var cleanup = subscriber(observer)
  50453. , subscription = cleanup;
  50454. if(cleanup != null){
  50455. if(typeof cleanup.unsubscribe === 'function')cleanup = function(){ subscription.unsubscribe(); };
  50456. else aFunction(cleanup);
  50457. this._c = cleanup;
  50458. }
  50459. } catch(e){
  50460. observer.error(e);
  50461. return;
  50462. } if(subscriptionClosed(this))cleanupSubscription(this);
  50463. };
  50464. Subscription.prototype = redefineAll({}, {
  50465. unsubscribe: function unsubscribe(){ closeSubscription(this); }
  50466. });
  50467. var SubscriptionObserver = function(subscription){
  50468. this._s = subscription;
  50469. };
  50470. SubscriptionObserver.prototype = redefineAll({}, {
  50471. next: function next(value){
  50472. var subscription = this._s;
  50473. if(!subscriptionClosed(subscription)){
  50474. var observer = subscription._o;
  50475. try {
  50476. var m = getMethod(observer.next);
  50477. if(m)return m.call(observer, value);
  50478. } catch(e){
  50479. try {
  50480. closeSubscription(subscription);
  50481. } finally {
  50482. throw e;
  50483. }
  50484. }
  50485. }
  50486. },
  50487. error: function error(value){
  50488. var subscription = this._s;
  50489. if(subscriptionClosed(subscription))throw value;
  50490. var observer = subscription._o;
  50491. subscription._o = undefined;
  50492. try {
  50493. var m = getMethod(observer.error);
  50494. if(!m)throw value;
  50495. value = m.call(observer, value);
  50496. } catch(e){
  50497. try {
  50498. cleanupSubscription(subscription);
  50499. } finally {
  50500. throw e;
  50501. }
  50502. } cleanupSubscription(subscription);
  50503. return value;
  50504. },
  50505. complete: function complete(value){
  50506. var subscription = this._s;
  50507. if(!subscriptionClosed(subscription)){
  50508. var observer = subscription._o;
  50509. subscription._o = undefined;
  50510. try {
  50511. var m = getMethod(observer.complete);
  50512. value = m ? m.call(observer, value) : undefined;
  50513. } catch(e){
  50514. try {
  50515. cleanupSubscription(subscription);
  50516. } finally {
  50517. throw e;
  50518. }
  50519. } cleanupSubscription(subscription);
  50520. return value;
  50521. }
  50522. }
  50523. });
  50524. var $Observable = function Observable(subscriber){
  50525. anInstance(this, $Observable, 'Observable', '_f')._f = aFunction(subscriber);
  50526. };
  50527. redefineAll($Observable.prototype, {
  50528. subscribe: function subscribe(observer){
  50529. return new Subscription(observer, this._f);
  50530. },
  50531. forEach: function forEach(fn){
  50532. var that = this;
  50533. return new (core.Promise || global.Promise)(function(resolve, reject){
  50534. aFunction(fn);
  50535. var subscription = that.subscribe({
  50536. next : function(value){
  50537. try {
  50538. return fn(value);
  50539. } catch(e){
  50540. reject(e);
  50541. subscription.unsubscribe();
  50542. }
  50543. },
  50544. error: reject,
  50545. complete: resolve
  50546. });
  50547. });
  50548. }
  50549. });
  50550. redefineAll($Observable, {
  50551. from: function from(x){
  50552. var C = typeof this === 'function' ? this : $Observable;
  50553. var method = getMethod(anObject(x)[OBSERVABLE]);
  50554. if(method){
  50555. var observable = anObject(method.call(x));
  50556. return observable.constructor === C ? observable : new C(function(observer){
  50557. return observable.subscribe(observer);
  50558. });
  50559. }
  50560. return new C(function(observer){
  50561. var done = false;
  50562. microtask(function(){
  50563. if(!done){
  50564. try {
  50565. if(forOf(x, false, function(it){
  50566. observer.next(it);
  50567. if(done)return RETURN;
  50568. }) === RETURN)return;
  50569. } catch(e){
  50570. if(done)throw e;
  50571. observer.error(e);
  50572. return;
  50573. } observer.complete();
  50574. }
  50575. });
  50576. return function(){ done = true; };
  50577. });
  50578. },
  50579. of: function of(){
  50580. for(var i = 0, l = arguments.length, items = Array(l); i < l;)items[i] = arguments[i++];
  50581. return new (typeof this === 'function' ? this : $Observable)(function(observer){
  50582. var done = false;
  50583. microtask(function(){
  50584. if(!done){
  50585. for(var i = 0; i < items.length; ++i){
  50586. observer.next(items[i]);
  50587. if(done)return;
  50588. } observer.complete();
  50589. }
  50590. });
  50591. return function(){ done = true; };
  50592. });
  50593. }
  50594. });
  50595. hide($Observable.prototype, OBSERVABLE, function(){ return this; });
  50596. $export($export.G, {Observable: $Observable});
  50597. __webpack_require__(51)('Observable');
  50598. /***/ },
  50599. /* 454 */
  50600. /***/ function(module, exports, __webpack_require__) {
  50601. var metadata = __webpack_require__(36)
  50602. , anObject = __webpack_require__(3)
  50603. , toMetaKey = metadata.key
  50604. , ordinaryDefineOwnMetadata = metadata.set;
  50605. metadata.exp({defineMetadata: function defineMetadata(metadataKey, metadataValue, target, targetKey){
  50606. ordinaryDefineOwnMetadata(metadataKey, metadataValue, anObject(target), toMetaKey(targetKey));
  50607. }});
  50608. /***/ },
  50609. /* 455 */
  50610. /***/ function(module, exports, __webpack_require__) {
  50611. var metadata = __webpack_require__(36)
  50612. , anObject = __webpack_require__(3)
  50613. , toMetaKey = metadata.key
  50614. , getOrCreateMetadataMap = metadata.map
  50615. , store = metadata.store;
  50616. metadata.exp({deleteMetadata: function deleteMetadata(metadataKey, target /*, targetKey */){
  50617. var targetKey = arguments.length < 3 ? undefined : toMetaKey(arguments[2])
  50618. , metadataMap = getOrCreateMetadataMap(anObject(target), targetKey, false);
  50619. if(metadataMap === undefined || !metadataMap['delete'](metadataKey))return false;
  50620. if(metadataMap.size)return true;
  50621. var targetMetadata = store.get(target);
  50622. targetMetadata['delete'](targetKey);
  50623. return !!targetMetadata.size || store['delete'](target);
  50624. }});
  50625. /***/ },
  50626. /* 456 */
  50627. /***/ function(module, exports, __webpack_require__) {
  50628. var Set = __webpack_require__(193)
  50629. , from = __webpack_require__(170)
  50630. , metadata = __webpack_require__(36)
  50631. , anObject = __webpack_require__(3)
  50632. , getPrototypeOf = __webpack_require__(26)
  50633. , ordinaryOwnMetadataKeys = metadata.keys
  50634. , toMetaKey = metadata.key;
  50635. var ordinaryMetadataKeys = function(O, P){
  50636. var oKeys = ordinaryOwnMetadataKeys(O, P)
  50637. , parent = getPrototypeOf(O);
  50638. if(parent === null)return oKeys;
  50639. var pKeys = ordinaryMetadataKeys(parent, P);
  50640. return pKeys.length ? oKeys.length ? from(new Set(oKeys.concat(pKeys))) : pKeys : oKeys;
  50641. };
  50642. metadata.exp({getMetadataKeys: function getMetadataKeys(target /*, targetKey */){
  50643. return ordinaryMetadataKeys(anObject(target), arguments.length < 2 ? undefined : toMetaKey(arguments[1]));
  50644. }});
  50645. /***/ },
  50646. /* 457 */
  50647. /***/ function(module, exports, __webpack_require__) {
  50648. var metadata = __webpack_require__(36)
  50649. , anObject = __webpack_require__(3)
  50650. , getPrototypeOf = __webpack_require__(26)
  50651. , ordinaryHasOwnMetadata = metadata.has
  50652. , ordinaryGetOwnMetadata = metadata.get
  50653. , toMetaKey = metadata.key;
  50654. var ordinaryGetMetadata = function(MetadataKey, O, P){
  50655. var hasOwn = ordinaryHasOwnMetadata(MetadataKey, O, P);
  50656. if(hasOwn)return ordinaryGetOwnMetadata(MetadataKey, O, P);
  50657. var parent = getPrototypeOf(O);
  50658. return parent !== null ? ordinaryGetMetadata(MetadataKey, parent, P) : undefined;
  50659. };
  50660. metadata.exp({getMetadata: function getMetadata(metadataKey, target /*, targetKey */){
  50661. return ordinaryGetMetadata(metadataKey, anObject(target), arguments.length < 3 ? undefined : toMetaKey(arguments[2]));
  50662. }});
  50663. /***/ },
  50664. /* 458 */
  50665. /***/ function(module, exports, __webpack_require__) {
  50666. var metadata = __webpack_require__(36)
  50667. , anObject = __webpack_require__(3)
  50668. , ordinaryOwnMetadataKeys = metadata.keys
  50669. , toMetaKey = metadata.key;
  50670. metadata.exp({getOwnMetadataKeys: function getOwnMetadataKeys(target /*, targetKey */){
  50671. return ordinaryOwnMetadataKeys(anObject(target), arguments.length < 2 ? undefined : toMetaKey(arguments[1]));
  50672. }});
  50673. /***/ },
  50674. /* 459 */
  50675. /***/ function(module, exports, __webpack_require__) {
  50676. var metadata = __webpack_require__(36)
  50677. , anObject = __webpack_require__(3)
  50678. , ordinaryGetOwnMetadata = metadata.get
  50679. , toMetaKey = metadata.key;
  50680. metadata.exp({getOwnMetadata: function getOwnMetadata(metadataKey, target /*, targetKey */){
  50681. return ordinaryGetOwnMetadata(metadataKey, anObject(target)
  50682. , arguments.length < 3 ? undefined : toMetaKey(arguments[2]));
  50683. }});
  50684. /***/ },
  50685. /* 460 */
  50686. /***/ function(module, exports, __webpack_require__) {
  50687. var metadata = __webpack_require__(36)
  50688. , anObject = __webpack_require__(3)
  50689. , getPrototypeOf = __webpack_require__(26)
  50690. , ordinaryHasOwnMetadata = metadata.has
  50691. , toMetaKey = metadata.key;
  50692. var ordinaryHasMetadata = function(MetadataKey, O, P){
  50693. var hasOwn = ordinaryHasOwnMetadata(MetadataKey, O, P);
  50694. if(hasOwn)return true;
  50695. var parent = getPrototypeOf(O);
  50696. return parent !== null ? ordinaryHasMetadata(MetadataKey, parent, P) : false;
  50697. };
  50698. metadata.exp({hasMetadata: function hasMetadata(metadataKey, target /*, targetKey */){
  50699. return ordinaryHasMetadata(metadataKey, anObject(target), arguments.length < 3 ? undefined : toMetaKey(arguments[2]));
  50700. }});
  50701. /***/ },
  50702. /* 461 */
  50703. /***/ function(module, exports, __webpack_require__) {
  50704. var metadata = __webpack_require__(36)
  50705. , anObject = __webpack_require__(3)
  50706. , ordinaryHasOwnMetadata = metadata.has
  50707. , toMetaKey = metadata.key;
  50708. metadata.exp({hasOwnMetadata: function hasOwnMetadata(metadataKey, target /*, targetKey */){
  50709. return ordinaryHasOwnMetadata(metadataKey, anObject(target)
  50710. , arguments.length < 3 ? undefined : toMetaKey(arguments[2]));
  50711. }});
  50712. /***/ },
  50713. /* 462 */
  50714. /***/ function(module, exports, __webpack_require__) {
  50715. var metadata = __webpack_require__(36)
  50716. , anObject = __webpack_require__(3)
  50717. , aFunction = __webpack_require__(21)
  50718. , toMetaKey = metadata.key
  50719. , ordinaryDefineOwnMetadata = metadata.set;
  50720. metadata.exp({metadata: function metadata(metadataKey, metadataValue){
  50721. return function decorator(target, targetKey){
  50722. ordinaryDefineOwnMetadata(
  50723. metadataKey, metadataValue,
  50724. (targetKey !== undefined ? anObject : aFunction)(target),
  50725. toMetaKey(targetKey)
  50726. );
  50727. };
  50728. }});
  50729. /***/ },
  50730. /* 463 */
  50731. /***/ function(module, exports, __webpack_require__) {
  50732. // https://github.com/DavidBruant/Map-Set.prototype.toJSON
  50733. var $export = __webpack_require__(0);
  50734. $export($export.P + $export.R, 'Set', {toJSON: __webpack_require__(174)('Set')});
  50735. /***/ },
  50736. /* 464 */
  50737. /***/ function(module, exports, __webpack_require__) {
  50738. "use strict";
  50739. 'use strict';
  50740. // https://github.com/mathiasbynens/String.prototype.at
  50741. var $export = __webpack_require__(0)
  50742. , $at = __webpack_require__(121)(true);
  50743. $export($export.P, 'String', {
  50744. at: function at(pos){
  50745. return $at(this, pos);
  50746. }
  50747. });
  50748. /***/ },
  50749. /* 465 */
  50750. /***/ function(module, exports, __webpack_require__) {
  50751. "use strict";
  50752. 'use strict';
  50753. // https://tc39.github.io/String.prototype.matchAll/
  50754. var $export = __webpack_require__(0)
  50755. , defined = __webpack_require__(28)
  50756. , toLength = __webpack_require__(15)
  50757. , isRegExp = __webpack_require__(87)
  50758. , getFlags = __webpack_require__(85)
  50759. , RegExpProto = RegExp.prototype;
  50760. var $RegExpStringIterator = function(regexp, string){
  50761. this._r = regexp;
  50762. this._s = string;
  50763. };
  50764. __webpack_require__(114)($RegExpStringIterator, 'RegExp String', function next(){
  50765. var match = this._r.exec(this._s);
  50766. return {value: match, done: match === null};
  50767. });
  50768. $export($export.P, 'String', {
  50769. matchAll: function matchAll(regexp){
  50770. defined(this);
  50771. if(!isRegExp(regexp))throw TypeError(regexp + ' is not a regexp!');
  50772. var S = String(this)
  50773. , flags = 'flags' in RegExpProto ? String(regexp.flags) : getFlags.call(regexp)
  50774. , rx = new RegExp(regexp.source, ~flags.indexOf('g') ? flags : 'g' + flags);
  50775. rx.lastIndex = toLength(regexp.lastIndex);
  50776. return new $RegExpStringIterator(rx, S);
  50777. }
  50778. });
  50779. /***/ },
  50780. /* 466 */
  50781. /***/ function(module, exports, __webpack_require__) {
  50782. "use strict";
  50783. 'use strict';
  50784. // https://github.com/tc39/proposal-string-pad-start-end
  50785. var $export = __webpack_require__(0)
  50786. , $pad = __webpack_require__(189);
  50787. $export($export.P, 'String', {
  50788. padEnd: function padEnd(maxLength /*, fillString = ' ' */){
  50789. return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, false);
  50790. }
  50791. });
  50792. /***/ },
  50793. /* 467 */
  50794. /***/ function(module, exports, __webpack_require__) {
  50795. "use strict";
  50796. 'use strict';
  50797. // https://github.com/tc39/proposal-string-pad-start-end
  50798. var $export = __webpack_require__(0)
  50799. , $pad = __webpack_require__(189);
  50800. $export($export.P, 'String', {
  50801. padStart: function padStart(maxLength /*, fillString = ' ' */){
  50802. return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, true);
  50803. }
  50804. });
  50805. /***/ },
  50806. /* 468 */
  50807. /***/ function(module, exports, __webpack_require__) {
  50808. "use strict";
  50809. 'use strict';
  50810. // https://github.com/sebmarkbage/ecmascript-string-left-right-trim
  50811. __webpack_require__(62)('trimLeft', function($trim){
  50812. return function trimLeft(){
  50813. return $trim(this, 1);
  50814. };
  50815. }, 'trimStart');
  50816. /***/ },
  50817. /* 469 */
  50818. /***/ function(module, exports, __webpack_require__) {
  50819. "use strict";
  50820. 'use strict';
  50821. // https://github.com/sebmarkbage/ecmascript-string-left-right-trim
  50822. __webpack_require__(62)('trimRight', function($trim){
  50823. return function trimRight(){
  50824. return $trim(this, 2);
  50825. };
  50826. }, 'trimEnd');
  50827. /***/ },
  50828. /* 470 */
  50829. /***/ function(module, exports, __webpack_require__) {
  50830. __webpack_require__(127)('asyncIterator');
  50831. /***/ },
  50832. /* 471 */
  50833. /***/ function(module, exports, __webpack_require__) {
  50834. __webpack_require__(127)('observable');
  50835. /***/ },
  50836. /* 472 */
  50837. /***/ function(module, exports, __webpack_require__) {
  50838. // https://github.com/ljharb/proposal-global
  50839. var $export = __webpack_require__(0);
  50840. $export($export.S, 'System', {global: __webpack_require__(5)});
  50841. /***/ },
  50842. /* 473 */
  50843. /***/ function(module, exports, __webpack_require__) {
  50844. var $iterators = __webpack_require__(129)
  50845. , redefine = __webpack_require__(22)
  50846. , global = __webpack_require__(5)
  50847. , hide = __webpack_require__(19)
  50848. , Iterators = __webpack_require__(45)
  50849. , wks = __webpack_require__(8)
  50850. , ITERATOR = wks('iterator')
  50851. , TO_STRING_TAG = wks('toStringTag')
  50852. , ArrayValues = Iterators.Array;
  50853. for(var collections = ['NodeList', 'DOMTokenList', 'MediaList', 'StyleSheetList', 'CSSRuleList'], i = 0; i < 5; i++){
  50854. var NAME = collections[i]
  50855. , Collection = global[NAME]
  50856. , proto = Collection && Collection.prototype
  50857. , key;
  50858. if(proto){
  50859. if(!proto[ITERATOR])hide(proto, ITERATOR, ArrayValues);
  50860. if(!proto[TO_STRING_TAG])hide(proto, TO_STRING_TAG, NAME);
  50861. Iterators[NAME] = ArrayValues;
  50862. for(key in $iterators)if(!proto[key])redefine(proto, key, $iterators[key], true);
  50863. }
  50864. }
  50865. /***/ },
  50866. /* 474 */
  50867. /***/ function(module, exports, __webpack_require__) {
  50868. var $export = __webpack_require__(0)
  50869. , $task = __webpack_require__(125);
  50870. $export($export.G + $export.B, {
  50871. setImmediate: $task.set,
  50872. clearImmediate: $task.clear
  50873. });
  50874. /***/ },
  50875. /* 475 */
  50876. /***/ function(module, exports, __webpack_require__) {
  50877. // ie9- setTimeout & setInterval additional parameters fix
  50878. var global = __webpack_require__(5)
  50879. , $export = __webpack_require__(0)
  50880. , invoke = __webpack_require__(86)
  50881. , partial = __webpack_require__(301)
  50882. , navigator = global.navigator
  50883. , MSIE = !!navigator && /MSIE .\./.test(navigator.userAgent); // <- dirty ie9- check
  50884. var wrap = function(set){
  50885. return MSIE ? function(fn, time /*, ...args */){
  50886. return set(invoke(
  50887. partial,
  50888. [].slice.call(arguments, 2),
  50889. typeof fn == 'function' ? fn : Function(fn)
  50890. ), time);
  50891. } : set;
  50892. };
  50893. $export($export.G + $export.B + $export.F * MSIE, {
  50894. setTimeout: wrap(global.setTimeout),
  50895. setInterval: wrap(global.setInterval)
  50896. });
  50897. /***/ },
  50898. /* 476 */
  50899. /***/ function(module, exports, __webpack_require__) {
  50900. __webpack_require__(425);
  50901. __webpack_require__(364);
  50902. __webpack_require__(366);
  50903. __webpack_require__(365);
  50904. __webpack_require__(368);
  50905. __webpack_require__(370);
  50906. __webpack_require__(375);
  50907. __webpack_require__(369);
  50908. __webpack_require__(367);
  50909. __webpack_require__(377);
  50910. __webpack_require__(376);
  50911. __webpack_require__(372);
  50912. __webpack_require__(373);
  50913. __webpack_require__(371);
  50914. __webpack_require__(363);
  50915. __webpack_require__(374);
  50916. __webpack_require__(378);
  50917. __webpack_require__(379);
  50918. __webpack_require__(331);
  50919. __webpack_require__(333);
  50920. __webpack_require__(332);
  50921. __webpack_require__(381);
  50922. __webpack_require__(380);
  50923. __webpack_require__(351);
  50924. __webpack_require__(361);
  50925. __webpack_require__(362);
  50926. __webpack_require__(352);
  50927. __webpack_require__(353);
  50928. __webpack_require__(354);
  50929. __webpack_require__(355);
  50930. __webpack_require__(356);
  50931. __webpack_require__(357);
  50932. __webpack_require__(358);
  50933. __webpack_require__(359);
  50934. __webpack_require__(360);
  50935. __webpack_require__(334);
  50936. __webpack_require__(335);
  50937. __webpack_require__(336);
  50938. __webpack_require__(337);
  50939. __webpack_require__(338);
  50940. __webpack_require__(339);
  50941. __webpack_require__(340);
  50942. __webpack_require__(341);
  50943. __webpack_require__(342);
  50944. __webpack_require__(343);
  50945. __webpack_require__(344);
  50946. __webpack_require__(345);
  50947. __webpack_require__(346);
  50948. __webpack_require__(347);
  50949. __webpack_require__(348);
  50950. __webpack_require__(349);
  50951. __webpack_require__(350);
  50952. __webpack_require__(412);
  50953. __webpack_require__(417);
  50954. __webpack_require__(424);
  50955. __webpack_require__(415);
  50956. __webpack_require__(407);
  50957. __webpack_require__(408);
  50958. __webpack_require__(413);
  50959. __webpack_require__(418);
  50960. __webpack_require__(420);
  50961. __webpack_require__(403);
  50962. __webpack_require__(404);
  50963. __webpack_require__(405);
  50964. __webpack_require__(406);
  50965. __webpack_require__(409);
  50966. __webpack_require__(410);
  50967. __webpack_require__(411);
  50968. __webpack_require__(414);
  50969. __webpack_require__(416);
  50970. __webpack_require__(419);
  50971. __webpack_require__(421);
  50972. __webpack_require__(422);
  50973. __webpack_require__(423);
  50974. __webpack_require__(326);
  50975. __webpack_require__(328);
  50976. __webpack_require__(327);
  50977. __webpack_require__(330);
  50978. __webpack_require__(329);
  50979. __webpack_require__(315);
  50980. __webpack_require__(313);
  50981. __webpack_require__(319);
  50982. __webpack_require__(316);
  50983. __webpack_require__(322);
  50984. __webpack_require__(324);
  50985. __webpack_require__(312);
  50986. __webpack_require__(318);
  50987. __webpack_require__(309);
  50988. __webpack_require__(323);
  50989. __webpack_require__(307);
  50990. __webpack_require__(321);
  50991. __webpack_require__(320);
  50992. __webpack_require__(314);
  50993. __webpack_require__(317);
  50994. __webpack_require__(306);
  50995. __webpack_require__(308);
  50996. __webpack_require__(311);
  50997. __webpack_require__(310);
  50998. __webpack_require__(325);
  50999. __webpack_require__(129);
  51000. __webpack_require__(397);
  51001. __webpack_require__(402);
  51002. __webpack_require__(192);
  51003. __webpack_require__(398);
  51004. __webpack_require__(399);
  51005. __webpack_require__(400);
  51006. __webpack_require__(401);
  51007. __webpack_require__(382);
  51008. __webpack_require__(191);
  51009. __webpack_require__(193);
  51010. __webpack_require__(194);
  51011. __webpack_require__(437);
  51012. __webpack_require__(426);
  51013. __webpack_require__(427);
  51014. __webpack_require__(432);
  51015. __webpack_require__(435);
  51016. __webpack_require__(436);
  51017. __webpack_require__(430);
  51018. __webpack_require__(433);
  51019. __webpack_require__(431);
  51020. __webpack_require__(434);
  51021. __webpack_require__(428);
  51022. __webpack_require__(429);
  51023. __webpack_require__(383);
  51024. __webpack_require__(384);
  51025. __webpack_require__(385);
  51026. __webpack_require__(386);
  51027. __webpack_require__(387);
  51028. __webpack_require__(390);
  51029. __webpack_require__(388);
  51030. __webpack_require__(389);
  51031. __webpack_require__(391);
  51032. __webpack_require__(392);
  51033. __webpack_require__(393);
  51034. __webpack_require__(394);
  51035. __webpack_require__(396);
  51036. __webpack_require__(395);
  51037. __webpack_require__(438);
  51038. __webpack_require__(464);
  51039. __webpack_require__(467);
  51040. __webpack_require__(466);
  51041. __webpack_require__(468);
  51042. __webpack_require__(469);
  51043. __webpack_require__(465);
  51044. __webpack_require__(470);
  51045. __webpack_require__(471);
  51046. __webpack_require__(449);
  51047. __webpack_require__(452);
  51048. __webpack_require__(448);
  51049. __webpack_require__(446);
  51050. __webpack_require__(447);
  51051. __webpack_require__(450);
  51052. __webpack_require__(451);
  51053. __webpack_require__(441);
  51054. __webpack_require__(463);
  51055. __webpack_require__(472);
  51056. __webpack_require__(440);
  51057. __webpack_require__(442);
  51058. __webpack_require__(444);
  51059. __webpack_require__(443);
  51060. __webpack_require__(445);
  51061. __webpack_require__(454);
  51062. __webpack_require__(455);
  51063. __webpack_require__(457);
  51064. __webpack_require__(456);
  51065. __webpack_require__(459);
  51066. __webpack_require__(458);
  51067. __webpack_require__(460);
  51068. __webpack_require__(461);
  51069. __webpack_require__(462);
  51070. __webpack_require__(439);
  51071. __webpack_require__(453);
  51072. __webpack_require__(475);
  51073. __webpack_require__(474);
  51074. __webpack_require__(473);
  51075. module.exports = __webpack_require__(32);
  51076. /***/ },
  51077. /* 477 */
  51078. /***/ function(module, exports, __webpack_require__) {
  51079. /* WEBPACK VAR INJECTION */(function(Buffer) {var elliptic = __webpack_require__(20);
  51080. var BN = __webpack_require__(12);
  51081. module.exports = function createECDH(curve) {
  51082. return new ECDH(curve);
  51083. };
  51084. var aliases = {
  51085. secp256k1: {
  51086. name: 'secp256k1',
  51087. byteLength: 32
  51088. },
  51089. secp224r1: {
  51090. name: 'p224',
  51091. byteLength: 28
  51092. },
  51093. prime256v1: {
  51094. name: 'p256',
  51095. byteLength: 32
  51096. },
  51097. prime192v1: {
  51098. name: 'p192',
  51099. byteLength: 24
  51100. },
  51101. ed25519: {
  51102. name: 'ed25519',
  51103. byteLength: 32
  51104. },
  51105. secp384r1: {
  51106. name: 'p384',
  51107. byteLength: 48
  51108. },
  51109. secp521r1: {
  51110. name: 'p521',
  51111. byteLength: 66
  51112. }
  51113. };
  51114. aliases.p224 = aliases.secp224r1;
  51115. aliases.p256 = aliases.secp256r1 = aliases.prime256v1;
  51116. aliases.p192 = aliases.secp192r1 = aliases.prime192v1;
  51117. aliases.p384 = aliases.secp384r1;
  51118. aliases.p521 = aliases.secp521r1;
  51119. function ECDH(curve) {
  51120. this.curveType = aliases[curve];
  51121. if (!this.curveType ) {
  51122. this.curveType = {
  51123. name: curve
  51124. };
  51125. }
  51126. this.curve = new elliptic.ec(this.curveType.name);
  51127. this.keys = void 0;
  51128. }
  51129. ECDH.prototype.generateKeys = function (enc, format) {
  51130. this.keys = this.curve.genKeyPair();
  51131. return this.getPublicKey(enc, format);
  51132. };
  51133. ECDH.prototype.computeSecret = function (other, inenc, enc) {
  51134. inenc = inenc || 'utf8';
  51135. if (!Buffer.isBuffer(other)) {
  51136. other = new Buffer(other, inenc);
  51137. }
  51138. var otherPub = this.curve.keyFromPublic(other).getPublic();
  51139. var out = otherPub.mul(this.keys.getPrivate()).getX();
  51140. return formatReturnValue(out, enc, this.curveType.byteLength);
  51141. };
  51142. ECDH.prototype.getPublicKey = function (enc, format) {
  51143. var key = this.keys.getPublic(format === 'compressed', true);
  51144. if (format === 'hybrid') {
  51145. if (key[key.length - 1] % 2) {
  51146. key[0] = 7;
  51147. } else {
  51148. key [0] = 6;
  51149. }
  51150. }
  51151. return formatReturnValue(key, enc);
  51152. };
  51153. ECDH.prototype.getPrivateKey = function (enc) {
  51154. return formatReturnValue(this.keys.getPrivate(), enc);
  51155. };
  51156. ECDH.prototype.setPublicKey = function (pub, enc) {
  51157. enc = enc || 'utf8';
  51158. if (!Buffer.isBuffer(pub)) {
  51159. pub = new Buffer(pub, enc);
  51160. }
  51161. this.keys._importPublic(pub);
  51162. return this;
  51163. };
  51164. ECDH.prototype.setPrivateKey = function (priv, enc) {
  51165. enc = enc || 'utf8';
  51166. if (!Buffer.isBuffer(priv)) {
  51167. priv = new Buffer(priv, enc);
  51168. }
  51169. var _priv = new BN(priv);
  51170. _priv = _priv.toString(16);
  51171. this.keys._importPrivate(_priv);
  51172. return this;
  51173. };
  51174. function formatReturnValue(bn, enc, len) {
  51175. if (!Array.isArray(bn)) {
  51176. bn = bn.toArray();
  51177. }
  51178. var buf = new Buffer(bn);
  51179. if (len && buf.length < len) {
  51180. var zeros = new Buffer(len - buf.length);
  51181. zeros.fill(0);
  51182. buf = Buffer.concat([zeros, buf]);
  51183. }
  51184. if (!enc) {
  51185. return buf;
  51186. } else {
  51187. return buf.toString(enc);
  51188. }
  51189. }
  51190. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  51191. /***/ },
  51192. /* 478 */
  51193. /***/ function(module, exports, __webpack_require__) {
  51194. "use strict";
  51195. /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
  51196. var intSize = 4;
  51197. var zeroBuffer = new Buffer(intSize); zeroBuffer.fill(0);
  51198. var chrsz = 8;
  51199. function toArray(buf, bigEndian) {
  51200. if ((buf.length % intSize) !== 0) {
  51201. var len = buf.length + (intSize - (buf.length % intSize));
  51202. buf = Buffer.concat([buf, zeroBuffer], len);
  51203. }
  51204. var arr = [];
  51205. var fn = bigEndian ? buf.readInt32BE : buf.readInt32LE;
  51206. for (var i = 0; i < buf.length; i += intSize) {
  51207. arr.push(fn.call(buf, i));
  51208. }
  51209. return arr;
  51210. }
  51211. function toBuffer(arr, size, bigEndian) {
  51212. var buf = new Buffer(size);
  51213. var fn = bigEndian ? buf.writeInt32BE : buf.writeInt32LE;
  51214. for (var i = 0; i < arr.length; i++) {
  51215. fn.call(buf, arr[i], i * 4, true);
  51216. }
  51217. return buf;
  51218. }
  51219. function hash(buf, fn, hashSize, bigEndian) {
  51220. if (!Buffer.isBuffer(buf)) buf = new Buffer(buf);
  51221. var arr = fn(toArray(buf, bigEndian), buf.length * chrsz);
  51222. return toBuffer(arr, hashSize, bigEndian);
  51223. }
  51224. exports.hash = hash;
  51225. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  51226. /***/ },
  51227. /* 479 */
  51228. /***/ function(module, exports, __webpack_require__) {
  51229. "use strict";
  51230. 'use strict';
  51231. var assert = __webpack_require__(72);
  51232. var inherits = __webpack_require__(2);
  51233. var proto = {};
  51234. function CBCState(iv) {
  51235. assert.equal(iv.length, 8, 'Invalid IV length');
  51236. this.iv = new Array(8);
  51237. for (var i = 0; i < this.iv.length; i++)
  51238. this.iv[i] = iv[i];
  51239. }
  51240. function instantiate(Base) {
  51241. function CBC(options) {
  51242. Base.call(this, options);
  51243. this._cbcInit();
  51244. }
  51245. inherits(CBC, Base);
  51246. var keys = Object.keys(proto);
  51247. for (var i = 0; i < keys.length; i++) {
  51248. var key = keys[i];
  51249. CBC.prototype[key] = proto[key];
  51250. }
  51251. CBC.create = function create(options) {
  51252. return new CBC(options);
  51253. };
  51254. return CBC;
  51255. }
  51256. exports.instantiate = instantiate;
  51257. proto._cbcInit = function _cbcInit() {
  51258. var state = new CBCState(this.options.iv);
  51259. this._cbcState = state;
  51260. };
  51261. proto._update = function _update(inp, inOff, out, outOff) {
  51262. var state = this._cbcState;
  51263. var superProto = this.constructor.super_.prototype;
  51264. var iv = state.iv;
  51265. if (this.type === 'encrypt') {
  51266. for (var i = 0; i < this.blockSize; i++)
  51267. iv[i] ^= inp[inOff + i];
  51268. superProto._update.call(this, iv, 0, out, outOff);
  51269. for (var i = 0; i < this.blockSize; i++)
  51270. iv[i] = out[outOff + i];
  51271. } else {
  51272. superProto._update.call(this, inp, inOff, out, outOff);
  51273. for (var i = 0; i < this.blockSize; i++)
  51274. out[outOff + i] ^= iv[i];
  51275. for (var i = 0; i < this.blockSize; i++)
  51276. iv[i] = inp[inOff + i];
  51277. }
  51278. };
  51279. /***/ },
  51280. /* 480 */
  51281. /***/ function(module, exports, __webpack_require__) {
  51282. "use strict";
  51283. 'use strict';
  51284. var assert = __webpack_require__(72);
  51285. function Cipher(options) {
  51286. this.options = options;
  51287. this.type = this.options.type;
  51288. this.blockSize = 8;
  51289. this._init();
  51290. this.buffer = new Array(this.blockSize);
  51291. this.bufferOff = 0;
  51292. }
  51293. module.exports = Cipher;
  51294. Cipher.prototype._init = function _init() {
  51295. // Might be overrided
  51296. };
  51297. Cipher.prototype.update = function update(data) {
  51298. if (data.length === 0)
  51299. return [];
  51300. if (this.type === 'decrypt')
  51301. return this._updateDecrypt(data);
  51302. else
  51303. return this._updateEncrypt(data);
  51304. };
  51305. Cipher.prototype._buffer = function _buffer(data, off) {
  51306. // Append data to buffer
  51307. var min = Math.min(this.buffer.length - this.bufferOff, data.length - off);
  51308. for (var i = 0; i < min; i++)
  51309. this.buffer[this.bufferOff + i] = data[off + i];
  51310. this.bufferOff += min;
  51311. // Shift next
  51312. return min;
  51313. };
  51314. Cipher.prototype._flushBuffer = function _flushBuffer(out, off) {
  51315. this._update(this.buffer, 0, out, off);
  51316. this.bufferOff = 0;
  51317. return this.blockSize;
  51318. };
  51319. Cipher.prototype._updateEncrypt = function _updateEncrypt(data) {
  51320. var inputOff = 0;
  51321. var outputOff = 0;
  51322. var count = ((this.bufferOff + data.length) / this.blockSize) | 0;
  51323. var out = new Array(count * this.blockSize);
  51324. if (this.bufferOff !== 0) {
  51325. inputOff += this._buffer(data, inputOff);
  51326. if (this.bufferOff === this.buffer.length)
  51327. outputOff += this._flushBuffer(out, outputOff);
  51328. }
  51329. // Write blocks
  51330. var max = data.length - ((data.length - inputOff) % this.blockSize);
  51331. for (; inputOff < max; inputOff += this.blockSize) {
  51332. this._update(data, inputOff, out, outputOff);
  51333. outputOff += this.blockSize;
  51334. }
  51335. // Queue rest
  51336. for (; inputOff < data.length; inputOff++, this.bufferOff++)
  51337. this.buffer[this.bufferOff] = data[inputOff];
  51338. return out;
  51339. };
  51340. Cipher.prototype._updateDecrypt = function _updateDecrypt(data) {
  51341. var inputOff = 0;
  51342. var outputOff = 0;
  51343. var count = Math.ceil((this.bufferOff + data.length) / this.blockSize) - 1;
  51344. var out = new Array(count * this.blockSize);
  51345. // TODO(indutny): optimize it, this is far from optimal
  51346. for (; count > 0; count--) {
  51347. inputOff += this._buffer(data, inputOff);
  51348. outputOff += this._flushBuffer(out, outputOff);
  51349. }
  51350. // Buffer rest of the input
  51351. inputOff += this._buffer(data, inputOff);
  51352. return out;
  51353. };
  51354. Cipher.prototype.final = function final(buffer) {
  51355. var first;
  51356. if (buffer)
  51357. first = this.update(buffer);
  51358. var last;
  51359. if (this.type === 'encrypt')
  51360. last = this._finalEncrypt();
  51361. else
  51362. last = this._finalDecrypt();
  51363. if (first)
  51364. return first.concat(last);
  51365. else
  51366. return last;
  51367. };
  51368. Cipher.prototype._pad = function _pad(buffer, off) {
  51369. if (off === 0)
  51370. return false;
  51371. while (off < buffer.length)
  51372. buffer[off++] = 0;
  51373. return true;
  51374. };
  51375. Cipher.prototype._finalEncrypt = function _finalEncrypt() {
  51376. if (!this._pad(this.buffer, this.bufferOff))
  51377. return [];
  51378. var out = new Array(this.blockSize);
  51379. this._update(this.buffer, 0, out, 0);
  51380. return out;
  51381. };
  51382. Cipher.prototype._unpad = function _unpad(buffer) {
  51383. return buffer;
  51384. };
  51385. Cipher.prototype._finalDecrypt = function _finalDecrypt() {
  51386. assert.equal(this.bufferOff, this.blockSize, 'Not enough data to decrypt');
  51387. var out = new Array(this.blockSize);
  51388. this._flushBuffer(out, 0);
  51389. return this._unpad(out);
  51390. };
  51391. /***/ },
  51392. /* 481 */
  51393. /***/ function(module, exports, __webpack_require__) {
  51394. "use strict";
  51395. 'use strict';
  51396. var assert = __webpack_require__(72);
  51397. var inherits = __webpack_require__(2);
  51398. var des = __webpack_require__(132);
  51399. var utils = des.utils;
  51400. var Cipher = des.Cipher;
  51401. function DESState() {
  51402. this.tmp = new Array(2);
  51403. this.keys = null;
  51404. }
  51405. function DES(options) {
  51406. Cipher.call(this, options);
  51407. var state = new DESState();
  51408. this._desState = state;
  51409. this.deriveKeys(state, options.key);
  51410. }
  51411. inherits(DES, Cipher);
  51412. module.exports = DES;
  51413. DES.create = function create(options) {
  51414. return new DES(options);
  51415. };
  51416. var shiftTable = [
  51417. 1, 1, 2, 2, 2, 2, 2, 2,
  51418. 1, 2, 2, 2, 2, 2, 2, 1
  51419. ];
  51420. DES.prototype.deriveKeys = function deriveKeys(state, key) {
  51421. state.keys = new Array(16 * 2);
  51422. assert.equal(key.length, this.blockSize, 'Invalid key length');
  51423. var kL = utils.readUInt32BE(key, 0);
  51424. var kR = utils.readUInt32BE(key, 4);
  51425. utils.pc1(kL, kR, state.tmp, 0);
  51426. kL = state.tmp[0];
  51427. kR = state.tmp[1];
  51428. for (var i = 0; i < state.keys.length; i += 2) {
  51429. var shift = shiftTable[i >>> 1];
  51430. kL = utils.r28shl(kL, shift);
  51431. kR = utils.r28shl(kR, shift);
  51432. utils.pc2(kL, kR, state.keys, i);
  51433. }
  51434. };
  51435. DES.prototype._update = function _update(inp, inOff, out, outOff) {
  51436. var state = this._desState;
  51437. var l = utils.readUInt32BE(inp, inOff);
  51438. var r = utils.readUInt32BE(inp, inOff + 4);
  51439. // Initial Permutation
  51440. utils.ip(l, r, state.tmp, 0);
  51441. l = state.tmp[0];
  51442. r = state.tmp[1];
  51443. if (this.type === 'encrypt')
  51444. this._encrypt(state, l, r, state.tmp, 0);
  51445. else
  51446. this._decrypt(state, l, r, state.tmp, 0);
  51447. l = state.tmp[0];
  51448. r = state.tmp[1];
  51449. utils.writeUInt32BE(out, l, outOff);
  51450. utils.writeUInt32BE(out, r, outOff + 4);
  51451. };
  51452. DES.prototype._pad = function _pad(buffer, off) {
  51453. var value = buffer.length - off;
  51454. for (var i = off; i < buffer.length; i++)
  51455. buffer[i] = value;
  51456. return true;
  51457. };
  51458. DES.prototype._unpad = function _unpad(buffer) {
  51459. var pad = buffer[buffer.length - 1];
  51460. for (var i = buffer.length - pad; i < buffer.length; i++)
  51461. assert.equal(buffer[i], pad);
  51462. return buffer.slice(0, buffer.length - pad);
  51463. };
  51464. DES.prototype._encrypt = function _encrypt(state, lStart, rStart, out, off) {
  51465. var l = lStart;
  51466. var r = rStart;
  51467. // Apply f() x16 times
  51468. for (var i = 0; i < state.keys.length; i += 2) {
  51469. var keyL = state.keys[i];
  51470. var keyR = state.keys[i + 1];
  51471. // f(r, k)
  51472. utils.expand(r, state.tmp, 0);
  51473. keyL ^= state.tmp[0];
  51474. keyR ^= state.tmp[1];
  51475. var s = utils.substitute(keyL, keyR);
  51476. var f = utils.permute(s);
  51477. var t = r;
  51478. r = (l ^ f) >>> 0;
  51479. l = t;
  51480. }
  51481. // Reverse Initial Permutation
  51482. utils.rip(r, l, out, off);
  51483. };
  51484. DES.prototype._decrypt = function _decrypt(state, lStart, rStart, out, off) {
  51485. var l = rStart;
  51486. var r = lStart;
  51487. // Apply f() x16 times
  51488. for (var i = state.keys.length - 2; i >= 0; i -= 2) {
  51489. var keyL = state.keys[i];
  51490. var keyR = state.keys[i + 1];
  51491. // f(r, k)
  51492. utils.expand(l, state.tmp, 0);
  51493. keyL ^= state.tmp[0];
  51494. keyR ^= state.tmp[1];
  51495. var s = utils.substitute(keyL, keyR);
  51496. var f = utils.permute(s);
  51497. var t = l;
  51498. l = (r ^ f) >>> 0;
  51499. r = t;
  51500. }
  51501. // Reverse Initial Permutation
  51502. utils.rip(l, r, out, off);
  51503. };
  51504. /***/ },
  51505. /* 482 */
  51506. /***/ function(module, exports, __webpack_require__) {
  51507. "use strict";
  51508. 'use strict';
  51509. var assert = __webpack_require__(72);
  51510. var inherits = __webpack_require__(2);
  51511. var des = __webpack_require__(132);
  51512. var Cipher = des.Cipher;
  51513. var DES = des.DES;
  51514. function EDEState(type, key) {
  51515. assert.equal(key.length, 24, 'Invalid key length');
  51516. var k1 = key.slice(0, 8);
  51517. var k2 = key.slice(8, 16);
  51518. var k3 = key.slice(16, 24);
  51519. if (type === 'encrypt') {
  51520. this.ciphers = [
  51521. DES.create({ type: 'encrypt', key: k1 }),
  51522. DES.create({ type: 'decrypt', key: k2 }),
  51523. DES.create({ type: 'encrypt', key: k3 })
  51524. ];
  51525. } else {
  51526. this.ciphers = [
  51527. DES.create({ type: 'decrypt', key: k3 }),
  51528. DES.create({ type: 'encrypt', key: k2 }),
  51529. DES.create({ type: 'decrypt', key: k1 })
  51530. ];
  51531. }
  51532. }
  51533. function EDE(options) {
  51534. Cipher.call(this, options);
  51535. var state = new EDEState(this.type, this.options.key);
  51536. this._edeState = state;
  51537. }
  51538. inherits(EDE, Cipher);
  51539. module.exports = EDE;
  51540. EDE.create = function create(options) {
  51541. return new EDE(options);
  51542. };
  51543. EDE.prototype._update = function _update(inp, inOff, out, outOff) {
  51544. var state = this._edeState;
  51545. state.ciphers[0]._update(inp, inOff, out, outOff);
  51546. state.ciphers[1]._update(out, outOff, out, outOff);
  51547. state.ciphers[2]._update(out, outOff, out, outOff);
  51548. };
  51549. EDE.prototype._pad = DES.prototype._pad;
  51550. EDE.prototype._unpad = DES.prototype._unpad;
  51551. /***/ },
  51552. /* 483 */
  51553. /***/ function(module, exports) {
  51554. "use strict";
  51555. 'use strict';
  51556. exports.readUInt32BE = function readUInt32BE(bytes, off) {
  51557. var res = (bytes[0 + off] << 24) |
  51558. (bytes[1 + off] << 16) |
  51559. (bytes[2 + off] << 8) |
  51560. bytes[3 + off];
  51561. return res >>> 0;
  51562. };
  51563. exports.writeUInt32BE = function writeUInt32BE(bytes, value, off) {
  51564. bytes[0 + off] = value >>> 24;
  51565. bytes[1 + off] = (value >>> 16) & 0xff;
  51566. bytes[2 + off] = (value >>> 8) & 0xff;
  51567. bytes[3 + off] = value & 0xff;
  51568. };
  51569. exports.ip = function ip(inL, inR, out, off) {
  51570. var outL = 0;
  51571. var outR = 0;
  51572. for (var i = 6; i >= 0; i -= 2) {
  51573. for (var j = 0; j <= 24; j += 8) {
  51574. outL <<= 1;
  51575. outL |= (inR >>> (j + i)) & 1;
  51576. }
  51577. for (var j = 0; j <= 24; j += 8) {
  51578. outL <<= 1;
  51579. outL |= (inL >>> (j + i)) & 1;
  51580. }
  51581. }
  51582. for (var i = 6; i >= 0; i -= 2) {
  51583. for (var j = 1; j <= 25; j += 8) {
  51584. outR <<= 1;
  51585. outR |= (inR >>> (j + i)) & 1;
  51586. }
  51587. for (var j = 1; j <= 25; j += 8) {
  51588. outR <<= 1;
  51589. outR |= (inL >>> (j + i)) & 1;
  51590. }
  51591. }
  51592. out[off + 0] = outL >>> 0;
  51593. out[off + 1] = outR >>> 0;
  51594. };
  51595. exports.rip = function rip(inL, inR, out, off) {
  51596. var outL = 0;
  51597. var outR = 0;
  51598. for (var i = 0; i < 4; i++) {
  51599. for (var j = 24; j >= 0; j -= 8) {
  51600. outL <<= 1;
  51601. outL |= (inR >>> (j + i)) & 1;
  51602. outL <<= 1;
  51603. outL |= (inL >>> (j + i)) & 1;
  51604. }
  51605. }
  51606. for (var i = 4; i < 8; i++) {
  51607. for (var j = 24; j >= 0; j -= 8) {
  51608. outR <<= 1;
  51609. outR |= (inR >>> (j + i)) & 1;
  51610. outR <<= 1;
  51611. outR |= (inL >>> (j + i)) & 1;
  51612. }
  51613. }
  51614. out[off + 0] = outL >>> 0;
  51615. out[off + 1] = outR >>> 0;
  51616. };
  51617. exports.pc1 = function pc1(inL, inR, out, off) {
  51618. var outL = 0;
  51619. var outR = 0;
  51620. // 7, 15, 23, 31, 39, 47, 55, 63
  51621. // 6, 14, 22, 30, 39, 47, 55, 63
  51622. // 5, 13, 21, 29, 39, 47, 55, 63
  51623. // 4, 12, 20, 28
  51624. for (var i = 7; i >= 5; i--) {
  51625. for (var j = 0; j <= 24; j += 8) {
  51626. outL <<= 1;
  51627. outL |= (inR >> (j + i)) & 1;
  51628. }
  51629. for (var j = 0; j <= 24; j += 8) {
  51630. outL <<= 1;
  51631. outL |= (inL >> (j + i)) & 1;
  51632. }
  51633. }
  51634. for (var j = 0; j <= 24; j += 8) {
  51635. outL <<= 1;
  51636. outL |= (inR >> (j + i)) & 1;
  51637. }
  51638. // 1, 9, 17, 25, 33, 41, 49, 57
  51639. // 2, 10, 18, 26, 34, 42, 50, 58
  51640. // 3, 11, 19, 27, 35, 43, 51, 59
  51641. // 36, 44, 52, 60
  51642. for (var i = 1; i <= 3; i++) {
  51643. for (var j = 0; j <= 24; j += 8) {
  51644. outR <<= 1;
  51645. outR |= (inR >> (j + i)) & 1;
  51646. }
  51647. for (var j = 0; j <= 24; j += 8) {
  51648. outR <<= 1;
  51649. outR |= (inL >> (j + i)) & 1;
  51650. }
  51651. }
  51652. for (var j = 0; j <= 24; j += 8) {
  51653. outR <<= 1;
  51654. outR |= (inL >> (j + i)) & 1;
  51655. }
  51656. out[off + 0] = outL >>> 0;
  51657. out[off + 1] = outR >>> 0;
  51658. };
  51659. exports.r28shl = function r28shl(num, shift) {
  51660. return ((num << shift) & 0xfffffff) | (num >>> (28 - shift));
  51661. };
  51662. var pc2table = [
  51663. // inL => outL
  51664. 14, 11, 17, 4, 27, 23, 25, 0,
  51665. 13, 22, 7, 18, 5, 9, 16, 24,
  51666. 2, 20, 12, 21, 1, 8, 15, 26,
  51667. // inR => outR
  51668. 15, 4, 25, 19, 9, 1, 26, 16,
  51669. 5, 11, 23, 8, 12, 7, 17, 0,
  51670. 22, 3, 10, 14, 6, 20, 27, 24
  51671. ];
  51672. exports.pc2 = function pc2(inL, inR, out, off) {
  51673. var outL = 0;
  51674. var outR = 0;
  51675. var len = pc2table.length >>> 1;
  51676. for (var i = 0; i < len; i++) {
  51677. outL <<= 1;
  51678. outL |= (inL >>> pc2table[i]) & 0x1;
  51679. }
  51680. for (var i = len; i < pc2table.length; i++) {
  51681. outR <<= 1;
  51682. outR |= (inR >>> pc2table[i]) & 0x1;
  51683. }
  51684. out[off + 0] = outL >>> 0;
  51685. out[off + 1] = outR >>> 0;
  51686. };
  51687. exports.expand = function expand(r, out, off) {
  51688. var outL = 0;
  51689. var outR = 0;
  51690. outL = ((r & 1) << 5) | (r >>> 27);
  51691. for (var i = 23; i >= 15; i -= 4) {
  51692. outL <<= 6;
  51693. outL |= (r >>> i) & 0x3f;
  51694. }
  51695. for (var i = 11; i >= 3; i -= 4) {
  51696. outR |= (r >>> i) & 0x3f;
  51697. outR <<= 6;
  51698. }
  51699. outR |= ((r & 0x1f) << 1) | (r >>> 31);
  51700. out[off + 0] = outL >>> 0;
  51701. out[off + 1] = outR >>> 0;
  51702. };
  51703. var sTable = [
  51704. 14, 0, 4, 15, 13, 7, 1, 4, 2, 14, 15, 2, 11, 13, 8, 1,
  51705. 3, 10, 10, 6, 6, 12, 12, 11, 5, 9, 9, 5, 0, 3, 7, 8,
  51706. 4, 15, 1, 12, 14, 8, 8, 2, 13, 4, 6, 9, 2, 1, 11, 7,
  51707. 15, 5, 12, 11, 9, 3, 7, 14, 3, 10, 10, 0, 5, 6, 0, 13,
  51708. 15, 3, 1, 13, 8, 4, 14, 7, 6, 15, 11, 2, 3, 8, 4, 14,
  51709. 9, 12, 7, 0, 2, 1, 13, 10, 12, 6, 0, 9, 5, 11, 10, 5,
  51710. 0, 13, 14, 8, 7, 10, 11, 1, 10, 3, 4, 15, 13, 4, 1, 2,
  51711. 5, 11, 8, 6, 12, 7, 6, 12, 9, 0, 3, 5, 2, 14, 15, 9,
  51712. 10, 13, 0, 7, 9, 0, 14, 9, 6, 3, 3, 4, 15, 6, 5, 10,
  51713. 1, 2, 13, 8, 12, 5, 7, 14, 11, 12, 4, 11, 2, 15, 8, 1,
  51714. 13, 1, 6, 10, 4, 13, 9, 0, 8, 6, 15, 9, 3, 8, 0, 7,
  51715. 11, 4, 1, 15, 2, 14, 12, 3, 5, 11, 10, 5, 14, 2, 7, 12,
  51716. 7, 13, 13, 8, 14, 11, 3, 5, 0, 6, 6, 15, 9, 0, 10, 3,
  51717. 1, 4, 2, 7, 8, 2, 5, 12, 11, 1, 12, 10, 4, 14, 15, 9,
  51718. 10, 3, 6, 15, 9, 0, 0, 6, 12, 10, 11, 1, 7, 13, 13, 8,
  51719. 15, 9, 1, 4, 3, 5, 14, 11, 5, 12, 2, 7, 8, 2, 4, 14,
  51720. 2, 14, 12, 11, 4, 2, 1, 12, 7, 4, 10, 7, 11, 13, 6, 1,
  51721. 8, 5, 5, 0, 3, 15, 15, 10, 13, 3, 0, 9, 14, 8, 9, 6,
  51722. 4, 11, 2, 8, 1, 12, 11, 7, 10, 1, 13, 14, 7, 2, 8, 13,
  51723. 15, 6, 9, 15, 12, 0, 5, 9, 6, 10, 3, 4, 0, 5, 14, 3,
  51724. 12, 10, 1, 15, 10, 4, 15, 2, 9, 7, 2, 12, 6, 9, 8, 5,
  51725. 0, 6, 13, 1, 3, 13, 4, 14, 14, 0, 7, 11, 5, 3, 11, 8,
  51726. 9, 4, 14, 3, 15, 2, 5, 12, 2, 9, 8, 5, 12, 15, 3, 10,
  51727. 7, 11, 0, 14, 4, 1, 10, 7, 1, 6, 13, 0, 11, 8, 6, 13,
  51728. 4, 13, 11, 0, 2, 11, 14, 7, 15, 4, 0, 9, 8, 1, 13, 10,
  51729. 3, 14, 12, 3, 9, 5, 7, 12, 5, 2, 10, 15, 6, 8, 1, 6,
  51730. 1, 6, 4, 11, 11, 13, 13, 8, 12, 1, 3, 4, 7, 10, 14, 7,
  51731. 10, 9, 15, 5, 6, 0, 8, 15, 0, 14, 5, 2, 9, 3, 2, 12,
  51732. 13, 1, 2, 15, 8, 13, 4, 8, 6, 10, 15, 3, 11, 7, 1, 4,
  51733. 10, 12, 9, 5, 3, 6, 14, 11, 5, 0, 0, 14, 12, 9, 7, 2,
  51734. 7, 2, 11, 1, 4, 14, 1, 7, 9, 4, 12, 10, 14, 8, 2, 13,
  51735. 0, 15, 6, 12, 10, 9, 13, 0, 15, 3, 3, 5, 5, 6, 8, 11
  51736. ];
  51737. exports.substitute = function substitute(inL, inR) {
  51738. var out = 0;
  51739. for (var i = 0; i < 4; i++) {
  51740. var b = (inL >>> (18 - i * 6)) & 0x3f;
  51741. var sb = sTable[i * 0x40 + b];
  51742. out <<= 4;
  51743. out |= sb;
  51744. }
  51745. for (var i = 0; i < 4; i++) {
  51746. var b = (inR >>> (18 - i * 6)) & 0x3f;
  51747. var sb = sTable[4 * 0x40 + i * 0x40 + b];
  51748. out <<= 4;
  51749. out |= sb;
  51750. }
  51751. return out >>> 0;
  51752. };
  51753. var permuteTable = [
  51754. 16, 25, 12, 11, 3, 20, 4, 15, 31, 17, 9, 6, 27, 14, 1, 22,
  51755. 30, 24, 8, 18, 0, 5, 29, 23, 13, 19, 2, 26, 10, 21, 28, 7
  51756. ];
  51757. exports.permute = function permute(num) {
  51758. var out = 0;
  51759. for (var i = 0; i < permuteTable.length; i++) {
  51760. out <<= 1;
  51761. out |= (num >>> permuteTable[i]) & 0x1;
  51762. }
  51763. return out >>> 0;
  51764. };
  51765. exports.padSplit = function padSplit(num, size, group) {
  51766. var str = num.toString(2);
  51767. while (str.length < size)
  51768. str = '0' + str;
  51769. var out = [];
  51770. for (var i = 0; i < size; i += group)
  51771. out.push(str.slice(i, i + group));
  51772. return out.join(' ');
  51773. };
  51774. /***/ },
  51775. /* 484 */
  51776. /***/ function(module, exports, __webpack_require__) {
  51777. /* WEBPACK VAR INJECTION */(function(Buffer) {var generatePrime = __webpack_require__(197)
  51778. var primes = __webpack_require__(231)
  51779. var DH = __webpack_require__(485)
  51780. function getDiffieHellman (mod) {
  51781. var prime = new Buffer(primes[mod].prime, 'hex')
  51782. var gen = new Buffer(primes[mod].gen, 'hex')
  51783. return new DH(prime, gen)
  51784. }
  51785. var ENCODINGS = {
  51786. 'binary': true, 'hex': true, 'base64': true
  51787. }
  51788. function createDiffieHellman (prime, enc, generator, genc) {
  51789. if (Buffer.isBuffer(enc) || ENCODINGS[enc] === undefined) {
  51790. return createDiffieHellman(prime, 'binary', enc, generator)
  51791. }
  51792. enc = enc || 'binary'
  51793. genc = genc || 'binary'
  51794. generator = generator || new Buffer([2])
  51795. if (!Buffer.isBuffer(generator)) {
  51796. generator = new Buffer(generator, genc)
  51797. }
  51798. if (typeof prime === 'number') {
  51799. return new DH(generatePrime(prime, generator), generator, true)
  51800. }
  51801. if (!Buffer.isBuffer(prime)) {
  51802. prime = new Buffer(prime, enc)
  51803. }
  51804. return new DH(prime, generator, true)
  51805. }
  51806. exports.DiffieHellmanGroup = exports.createDiffieHellmanGroup = exports.getDiffieHellman = getDiffieHellman
  51807. exports.createDiffieHellman = exports.DiffieHellman = createDiffieHellman
  51808. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  51809. /***/ },
  51810. /* 485 */
  51811. /***/ function(module, exports, __webpack_require__) {
  51812. /* WEBPACK VAR INJECTION */(function(Buffer) {var BN = __webpack_require__(12);
  51813. var MillerRabin = __webpack_require__(204);
  51814. var millerRabin = new MillerRabin();
  51815. var TWENTYFOUR = new BN(24);
  51816. var ELEVEN = new BN(11);
  51817. var TEN = new BN(10);
  51818. var THREE = new BN(3);
  51819. var SEVEN = new BN(7);
  51820. var primes = __webpack_require__(197);
  51821. var randomBytes = __webpack_require__(73);
  51822. module.exports = DH;
  51823. function setPublicKey(pub, enc) {
  51824. enc = enc || 'utf8';
  51825. if (!Buffer.isBuffer(pub)) {
  51826. pub = new Buffer(pub, enc);
  51827. }
  51828. this._pub = new BN(pub);
  51829. return this;
  51830. }
  51831. function setPrivateKey(priv, enc) {
  51832. enc = enc || 'utf8';
  51833. if (!Buffer.isBuffer(priv)) {
  51834. priv = new Buffer(priv, enc);
  51835. }
  51836. this._priv = new BN(priv);
  51837. return this;
  51838. }
  51839. var primeCache = {};
  51840. function checkPrime(prime, generator) {
  51841. var gen = generator.toString('hex');
  51842. var hex = [gen, prime.toString(16)].join('_');
  51843. if (hex in primeCache) {
  51844. return primeCache[hex];
  51845. }
  51846. var error = 0;
  51847. if (prime.isEven() ||
  51848. !primes.simpleSieve ||
  51849. !primes.fermatTest(prime) ||
  51850. !millerRabin.test(prime)) {
  51851. //not a prime so +1
  51852. error += 1;
  51853. if (gen === '02' || gen === '05') {
  51854. // we'd be able to check the generator
  51855. // it would fail so +8
  51856. error += 8;
  51857. } else {
  51858. //we wouldn't be able to test the generator
  51859. // so +4
  51860. error += 4;
  51861. }
  51862. primeCache[hex] = error;
  51863. return error;
  51864. }
  51865. if (!millerRabin.test(prime.shrn(1))) {
  51866. //not a safe prime
  51867. error += 2;
  51868. }
  51869. var rem;
  51870. switch (gen) {
  51871. case '02':
  51872. if (prime.mod(TWENTYFOUR).cmp(ELEVEN)) {
  51873. // unsuidable generator
  51874. error += 8;
  51875. }
  51876. break;
  51877. case '05':
  51878. rem = prime.mod(TEN);
  51879. if (rem.cmp(THREE) && rem.cmp(SEVEN)) {
  51880. // prime mod 10 needs to equal 3 or 7
  51881. error += 8;
  51882. }
  51883. break;
  51884. default:
  51885. error += 4;
  51886. }
  51887. primeCache[hex] = error;
  51888. return error;
  51889. }
  51890. function DH(prime, generator, malleable) {
  51891. this.setGenerator(generator);
  51892. this.__prime = new BN(prime);
  51893. this._prime = BN.mont(this.__prime);
  51894. this._primeLen = prime.length;
  51895. this._pub = undefined;
  51896. this._priv = undefined;
  51897. this._primeCode = undefined;
  51898. if (malleable) {
  51899. this.setPublicKey = setPublicKey;
  51900. this.setPrivateKey = setPrivateKey;
  51901. } else {
  51902. this._primeCode = 8;
  51903. }
  51904. }
  51905. Object.defineProperty(DH.prototype, 'verifyError', {
  51906. enumerable: true,
  51907. get: function () {
  51908. if (typeof this._primeCode !== 'number') {
  51909. this._primeCode = checkPrime(this.__prime, this.__gen);
  51910. }
  51911. return this._primeCode;
  51912. }
  51913. });
  51914. DH.prototype.generateKeys = function () {
  51915. if (!this._priv) {
  51916. this._priv = new BN(randomBytes(this._primeLen));
  51917. }
  51918. this._pub = this._gen.toRed(this._prime).redPow(this._priv).fromRed();
  51919. return this.getPublicKey();
  51920. };
  51921. DH.prototype.computeSecret = function (other) {
  51922. other = new BN(other);
  51923. other = other.toRed(this._prime);
  51924. var secret = other.redPow(this._priv).fromRed();
  51925. var out = new Buffer(secret.toArray());
  51926. var prime = this.getPrime();
  51927. if (out.length < prime.length) {
  51928. var front = new Buffer(prime.length - out.length);
  51929. front.fill(0);
  51930. out = Buffer.concat([front, out]);
  51931. }
  51932. return out;
  51933. };
  51934. DH.prototype.getPublicKey = function getPublicKey(enc) {
  51935. return formatReturnValue(this._pub, enc);
  51936. };
  51937. DH.prototype.getPrivateKey = function getPrivateKey(enc) {
  51938. return formatReturnValue(this._priv, enc);
  51939. };
  51940. DH.prototype.getPrime = function (enc) {
  51941. return formatReturnValue(this.__prime, enc);
  51942. };
  51943. DH.prototype.getGenerator = function (enc) {
  51944. return formatReturnValue(this._gen, enc);
  51945. };
  51946. DH.prototype.setGenerator = function (gen, enc) {
  51947. enc = enc || 'utf8';
  51948. if (!Buffer.isBuffer(gen)) {
  51949. gen = new Buffer(gen, enc);
  51950. }
  51951. this.__gen = gen;
  51952. this._gen = new BN(gen);
  51953. return this;
  51954. };
  51955. function formatReturnValue(bn, enc) {
  51956. var buf = new Buffer(bn.toArray());
  51957. if (!enc) {
  51958. return buf;
  51959. } else {
  51960. return buf.toString(enc);
  51961. }
  51962. }
  51963. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  51964. /***/ },
  51965. /* 486 */
  51966. /***/ function(module, exports, __webpack_require__) {
  51967. "use strict";
  51968. 'use strict';
  51969. var BN = __webpack_require__(12);
  51970. var elliptic = __webpack_require__(20);
  51971. var utils = elliptic.utils;
  51972. var getNAF = utils.getNAF;
  51973. var getJSF = utils.getJSF;
  51974. var assert = utils.assert;
  51975. function BaseCurve(type, conf) {
  51976. this.type = type;
  51977. this.p = new BN(conf.p, 16);
  51978. // Use Montgomery, when there is no fast reduction for the prime
  51979. this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p);
  51980. // Useful for many curves
  51981. this.zero = new BN(0).toRed(this.red);
  51982. this.one = new BN(1).toRed(this.red);
  51983. this.two = new BN(2).toRed(this.red);
  51984. // Curve configuration, optional
  51985. this.n = conf.n && new BN(conf.n, 16);
  51986. this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed);
  51987. // Temporary arrays
  51988. this._wnafT1 = new Array(4);
  51989. this._wnafT2 = new Array(4);
  51990. this._wnafT3 = new Array(4);
  51991. this._wnafT4 = new Array(4);
  51992. // Generalized Greg Maxwell's trick
  51993. var adjustCount = this.n && this.p.div(this.n);
  51994. if (!adjustCount || adjustCount.cmpn(100) > 0) {
  51995. this.redN = null;
  51996. } else {
  51997. this._maxwellTrick = true;
  51998. this.redN = this.n.toRed(this.red);
  51999. }
  52000. }
  52001. module.exports = BaseCurve;
  52002. BaseCurve.prototype.point = function point() {
  52003. throw new Error('Not implemented');
  52004. };
  52005. BaseCurve.prototype.validate = function validate() {
  52006. throw new Error('Not implemented');
  52007. };
  52008. BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) {
  52009. assert(p.precomputed);
  52010. var doubles = p._getDoubles();
  52011. var naf = getNAF(k, 1);
  52012. var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1);
  52013. I /= 3;
  52014. // Translate into more windowed form
  52015. var repr = [];
  52016. for (var j = 0; j < naf.length; j += doubles.step) {
  52017. var nafW = 0;
  52018. for (var k = j + doubles.step - 1; k >= j; k--)
  52019. nafW = (nafW << 1) + naf[k];
  52020. repr.push(nafW);
  52021. }
  52022. var a = this.jpoint(null, null, null);
  52023. var b = this.jpoint(null, null, null);
  52024. for (var i = I; i > 0; i--) {
  52025. for (var j = 0; j < repr.length; j++) {
  52026. var nafW = repr[j];
  52027. if (nafW === i)
  52028. b = b.mixedAdd(doubles.points[j]);
  52029. else if (nafW === -i)
  52030. b = b.mixedAdd(doubles.points[j].neg());
  52031. }
  52032. a = a.add(b);
  52033. }
  52034. return a.toP();
  52035. };
  52036. BaseCurve.prototype._wnafMul = function _wnafMul(p, k) {
  52037. var w = 4;
  52038. // Precompute window
  52039. var nafPoints = p._getNAFPoints(w);
  52040. w = nafPoints.wnd;
  52041. var wnd = nafPoints.points;
  52042. // Get NAF form
  52043. var naf = getNAF(k, w);
  52044. // Add `this`*(N+1) for every w-NAF index
  52045. var acc = this.jpoint(null, null, null);
  52046. for (var i = naf.length - 1; i >= 0; i--) {
  52047. // Count zeroes
  52048. for (var k = 0; i >= 0 && naf[i] === 0; i--)
  52049. k++;
  52050. if (i >= 0)
  52051. k++;
  52052. acc = acc.dblp(k);
  52053. if (i < 0)
  52054. break;
  52055. var z = naf[i];
  52056. assert(z !== 0);
  52057. if (p.type === 'affine') {
  52058. // J +- P
  52059. if (z > 0)
  52060. acc = acc.mixedAdd(wnd[(z - 1) >> 1]);
  52061. else
  52062. acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg());
  52063. } else {
  52064. // J +- J
  52065. if (z > 0)
  52066. acc = acc.add(wnd[(z - 1) >> 1]);
  52067. else
  52068. acc = acc.add(wnd[(-z - 1) >> 1].neg());
  52069. }
  52070. }
  52071. return p.type === 'affine' ? acc.toP() : acc;
  52072. };
  52073. BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW,
  52074. points,
  52075. coeffs,
  52076. len,
  52077. jacobianResult) {
  52078. var wndWidth = this._wnafT1;
  52079. var wnd = this._wnafT2;
  52080. var naf = this._wnafT3;
  52081. // Fill all arrays
  52082. var max = 0;
  52083. for (var i = 0; i < len; i++) {
  52084. var p = points[i];
  52085. var nafPoints = p._getNAFPoints(defW);
  52086. wndWidth[i] = nafPoints.wnd;
  52087. wnd[i] = nafPoints.points;
  52088. }
  52089. // Comb small window NAFs
  52090. for (var i = len - 1; i >= 1; i -= 2) {
  52091. var a = i - 1;
  52092. var b = i;
  52093. if (wndWidth[a] !== 1 || wndWidth[b] !== 1) {
  52094. naf[a] = getNAF(coeffs[a], wndWidth[a]);
  52095. naf[b] = getNAF(coeffs[b], wndWidth[b]);
  52096. max = Math.max(naf[a].length, max);
  52097. max = Math.max(naf[b].length, max);
  52098. continue;
  52099. }
  52100. var comb = [
  52101. points[a], /* 1 */
  52102. null, /* 3 */
  52103. null, /* 5 */
  52104. points[b] /* 7 */
  52105. ];
  52106. // Try to avoid Projective points, if possible
  52107. if (points[a].y.cmp(points[b].y) === 0) {
  52108. comb[1] = points[a].add(points[b]);
  52109. comb[2] = points[a].toJ().mixedAdd(points[b].neg());
  52110. } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) {
  52111. comb[1] = points[a].toJ().mixedAdd(points[b]);
  52112. comb[2] = points[a].add(points[b].neg());
  52113. } else {
  52114. comb[1] = points[a].toJ().mixedAdd(points[b]);
  52115. comb[2] = points[a].toJ().mixedAdd(points[b].neg());
  52116. }
  52117. var index = [
  52118. -3, /* -1 -1 */
  52119. -1, /* -1 0 */
  52120. -5, /* -1 1 */
  52121. -7, /* 0 -1 */
  52122. 0, /* 0 0 */
  52123. 7, /* 0 1 */
  52124. 5, /* 1 -1 */
  52125. 1, /* 1 0 */
  52126. 3 /* 1 1 */
  52127. ];
  52128. var jsf = getJSF(coeffs[a], coeffs[b]);
  52129. max = Math.max(jsf[0].length, max);
  52130. naf[a] = new Array(max);
  52131. naf[b] = new Array(max);
  52132. for (var j = 0; j < max; j++) {
  52133. var ja = jsf[0][j] | 0;
  52134. var jb = jsf[1][j] | 0;
  52135. naf[a][j] = index[(ja + 1) * 3 + (jb + 1)];
  52136. naf[b][j] = 0;
  52137. wnd[a] = comb;
  52138. }
  52139. }
  52140. var acc = this.jpoint(null, null, null);
  52141. var tmp = this._wnafT4;
  52142. for (var i = max; i >= 0; i--) {
  52143. var k = 0;
  52144. while (i >= 0) {
  52145. var zero = true;
  52146. for (var j = 0; j < len; j++) {
  52147. tmp[j] = naf[j][i] | 0;
  52148. if (tmp[j] !== 0)
  52149. zero = false;
  52150. }
  52151. if (!zero)
  52152. break;
  52153. k++;
  52154. i--;
  52155. }
  52156. if (i >= 0)
  52157. k++;
  52158. acc = acc.dblp(k);
  52159. if (i < 0)
  52160. break;
  52161. for (var j = 0; j < len; j++) {
  52162. var z = tmp[j];
  52163. var p;
  52164. if (z === 0)
  52165. continue;
  52166. else if (z > 0)
  52167. p = wnd[j][(z - 1) >> 1];
  52168. else if (z < 0)
  52169. p = wnd[j][(-z - 1) >> 1].neg();
  52170. if (p.type === 'affine')
  52171. acc = acc.mixedAdd(p);
  52172. else
  52173. acc = acc.add(p);
  52174. }
  52175. }
  52176. // Zeroify references
  52177. for (var i = 0; i < len; i++)
  52178. wnd[i] = null;
  52179. if (jacobianResult)
  52180. return acc;
  52181. else
  52182. return acc.toP();
  52183. };
  52184. function BasePoint(curve, type) {
  52185. this.curve = curve;
  52186. this.type = type;
  52187. this.precomputed = null;
  52188. }
  52189. BaseCurve.BasePoint = BasePoint;
  52190. BasePoint.prototype.eq = function eq(/*other*/) {
  52191. throw new Error('Not implemented');
  52192. };
  52193. BasePoint.prototype.validate = function validate() {
  52194. return this.curve.validate(this);
  52195. };
  52196. BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
  52197. bytes = utils.toArray(bytes, enc);
  52198. var len = this.p.byteLength();
  52199. // uncompressed, hybrid-odd, hybrid-even
  52200. if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) &&
  52201. bytes.length - 1 === 2 * len) {
  52202. if (bytes[0] === 0x06)
  52203. assert(bytes[bytes.length - 1] % 2 === 0);
  52204. else if (bytes[0] === 0x07)
  52205. assert(bytes[bytes.length - 1] % 2 === 1);
  52206. var res = this.point(bytes.slice(1, 1 + len),
  52207. bytes.slice(1 + len, 1 + 2 * len));
  52208. return res;
  52209. } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) &&
  52210. bytes.length - 1 === len) {
  52211. return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03);
  52212. }
  52213. throw new Error('Unknown point format');
  52214. };
  52215. BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) {
  52216. return this.encode(enc, true);
  52217. };
  52218. BasePoint.prototype._encode = function _encode(compact) {
  52219. var len = this.curve.p.byteLength();
  52220. var x = this.getX().toArray('be', len);
  52221. if (compact)
  52222. return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x);
  52223. return [ 0x04 ].concat(x, this.getY().toArray('be', len)) ;
  52224. };
  52225. BasePoint.prototype.encode = function encode(enc, compact) {
  52226. return utils.encode(this._encode(compact), enc);
  52227. };
  52228. BasePoint.prototype.precompute = function precompute(power) {
  52229. if (this.precomputed)
  52230. return this;
  52231. var precomputed = {
  52232. doubles: null,
  52233. naf: null,
  52234. beta: null
  52235. };
  52236. precomputed.naf = this._getNAFPoints(8);
  52237. precomputed.doubles = this._getDoubles(4, power);
  52238. precomputed.beta = this._getBeta();
  52239. this.precomputed = precomputed;
  52240. return this;
  52241. };
  52242. BasePoint.prototype._hasDoubles = function _hasDoubles(k) {
  52243. if (!this.precomputed)
  52244. return false;
  52245. var doubles = this.precomputed.doubles;
  52246. if (!doubles)
  52247. return false;
  52248. return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step);
  52249. };
  52250. BasePoint.prototype._getDoubles = function _getDoubles(step, power) {
  52251. if (this.precomputed && this.precomputed.doubles)
  52252. return this.precomputed.doubles;
  52253. var doubles = [ this ];
  52254. var acc = this;
  52255. for (var i = 0; i < power; i += step) {
  52256. for (var j = 0; j < step; j++)
  52257. acc = acc.dbl();
  52258. doubles.push(acc);
  52259. }
  52260. return {
  52261. step: step,
  52262. points: doubles
  52263. };
  52264. };
  52265. BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) {
  52266. if (this.precomputed && this.precomputed.naf)
  52267. return this.precomputed.naf;
  52268. var res = [ this ];
  52269. var max = (1 << wnd) - 1;
  52270. var dbl = max === 1 ? null : this.dbl();
  52271. for (var i = 1; i < max; i++)
  52272. res[i] = res[i - 1].add(dbl);
  52273. return {
  52274. wnd: wnd,
  52275. points: res
  52276. };
  52277. };
  52278. BasePoint.prototype._getBeta = function _getBeta() {
  52279. return null;
  52280. };
  52281. BasePoint.prototype.dblp = function dblp(k) {
  52282. var r = this;
  52283. for (var i = 0; i < k; i++)
  52284. r = r.dbl();
  52285. return r;
  52286. };
  52287. /***/ },
  52288. /* 487 */
  52289. /***/ function(module, exports, __webpack_require__) {
  52290. "use strict";
  52291. 'use strict';
  52292. var curve = __webpack_require__(94);
  52293. var elliptic = __webpack_require__(20);
  52294. var BN = __webpack_require__(12);
  52295. var inherits = __webpack_require__(2);
  52296. var Base = curve.base;
  52297. var assert = elliptic.utils.assert;
  52298. function EdwardsCurve(conf) {
  52299. // NOTE: Important as we are creating point in Base.call()
  52300. this.twisted = (conf.a | 0) !== 1;
  52301. this.mOneA = this.twisted && (conf.a | 0) === -1;
  52302. this.extended = this.mOneA;
  52303. Base.call(this, 'edwards', conf);
  52304. this.a = new BN(conf.a, 16).umod(this.red.m);
  52305. this.a = this.a.toRed(this.red);
  52306. this.c = new BN(conf.c, 16).toRed(this.red);
  52307. this.c2 = this.c.redSqr();
  52308. this.d = new BN(conf.d, 16).toRed(this.red);
  52309. this.dd = this.d.redAdd(this.d);
  52310. assert(!this.twisted || this.c.fromRed().cmpn(1) === 0);
  52311. this.oneC = (conf.c | 0) === 1;
  52312. }
  52313. inherits(EdwardsCurve, Base);
  52314. module.exports = EdwardsCurve;
  52315. EdwardsCurve.prototype._mulA = function _mulA(num) {
  52316. if (this.mOneA)
  52317. return num.redNeg();
  52318. else
  52319. return this.a.redMul(num);
  52320. };
  52321. EdwardsCurve.prototype._mulC = function _mulC(num) {
  52322. if (this.oneC)
  52323. return num;
  52324. else
  52325. return this.c.redMul(num);
  52326. };
  52327. // Just for compatibility with Short curve
  52328. EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) {
  52329. return this.point(x, y, z, t);
  52330. };
  52331. EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) {
  52332. x = new BN(x, 16);
  52333. if (!x.red)
  52334. x = x.toRed(this.red);
  52335. var x2 = x.redSqr();
  52336. var rhs = this.c2.redSub(this.a.redMul(x2));
  52337. var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2));
  52338. var y2 = rhs.redMul(lhs.redInvm());
  52339. var y = y2.redSqrt();
  52340. if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
  52341. throw new Error('invalid point');
  52342. var isOdd = y.fromRed().isOdd();
  52343. if (odd && !isOdd || !odd && isOdd)
  52344. y = y.redNeg();
  52345. return this.point(x, y);
  52346. };
  52347. EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) {
  52348. y = new BN(y, 16);
  52349. if (!y.red)
  52350. y = y.toRed(this.red);
  52351. // x^2 = (y^2 - 1) / (d y^2 + 1)
  52352. var y2 = y.redSqr();
  52353. var lhs = y2.redSub(this.one);
  52354. var rhs = y2.redMul(this.d).redAdd(this.one);
  52355. var x2 = lhs.redMul(rhs.redInvm());
  52356. if (x2.cmp(this.zero) === 0) {
  52357. if (odd)
  52358. throw new Error('invalid point');
  52359. else
  52360. return this.point(this.zero, y);
  52361. }
  52362. var x = x2.redSqrt();
  52363. if (x.redSqr().redSub(x2).cmp(this.zero) !== 0)
  52364. throw new Error('invalid point');
  52365. if (x.isOdd() !== odd)
  52366. x = x.redNeg();
  52367. return this.point(x, y);
  52368. };
  52369. EdwardsCurve.prototype.validate = function validate(point) {
  52370. if (point.isInfinity())
  52371. return true;
  52372. // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2)
  52373. point.normalize();
  52374. var x2 = point.x.redSqr();
  52375. var y2 = point.y.redSqr();
  52376. var lhs = x2.redMul(this.a).redAdd(y2);
  52377. var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2)));
  52378. return lhs.cmp(rhs) === 0;
  52379. };
  52380. function Point(curve, x, y, z, t) {
  52381. Base.BasePoint.call(this, curve, 'projective');
  52382. if (x === null && y === null && z === null) {
  52383. this.x = this.curve.zero;
  52384. this.y = this.curve.one;
  52385. this.z = this.curve.one;
  52386. this.t = this.curve.zero;
  52387. this.zOne = true;
  52388. } else {
  52389. this.x = new BN(x, 16);
  52390. this.y = new BN(y, 16);
  52391. this.z = z ? new BN(z, 16) : this.curve.one;
  52392. this.t = t && new BN(t, 16);
  52393. if (!this.x.red)
  52394. this.x = this.x.toRed(this.curve.red);
  52395. if (!this.y.red)
  52396. this.y = this.y.toRed(this.curve.red);
  52397. if (!this.z.red)
  52398. this.z = this.z.toRed(this.curve.red);
  52399. if (this.t && !this.t.red)
  52400. this.t = this.t.toRed(this.curve.red);
  52401. this.zOne = this.z === this.curve.one;
  52402. // Use extended coordinates
  52403. if (this.curve.extended && !this.t) {
  52404. this.t = this.x.redMul(this.y);
  52405. if (!this.zOne)
  52406. this.t = this.t.redMul(this.z.redInvm());
  52407. }
  52408. }
  52409. }
  52410. inherits(Point, Base.BasePoint);
  52411. EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
  52412. return Point.fromJSON(this, obj);
  52413. };
  52414. EdwardsCurve.prototype.point = function point(x, y, z, t) {
  52415. return new Point(this, x, y, z, t);
  52416. };
  52417. Point.fromJSON = function fromJSON(curve, obj) {
  52418. return new Point(curve, obj[0], obj[1], obj[2]);
  52419. };
  52420. Point.prototype.inspect = function inspect() {
  52421. if (this.isInfinity())
  52422. return '<EC Point Infinity>';
  52423. return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
  52424. ' y: ' + this.y.fromRed().toString(16, 2) +
  52425. ' z: ' + this.z.fromRed().toString(16, 2) + '>';
  52426. };
  52427. Point.prototype.isInfinity = function isInfinity() {
  52428. // XXX This code assumes that zero is always zero in red
  52429. return this.x.cmpn(0) === 0 &&
  52430. this.y.cmp(this.z) === 0;
  52431. };
  52432. Point.prototype._extDbl = function _extDbl() {
  52433. // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
  52434. // #doubling-dbl-2008-hwcd
  52435. // 4M + 4S
  52436. // A = X1^2
  52437. var a = this.x.redSqr();
  52438. // B = Y1^2
  52439. var b = this.y.redSqr();
  52440. // C = 2 * Z1^2
  52441. var c = this.z.redSqr();
  52442. c = c.redIAdd(c);
  52443. // D = a * A
  52444. var d = this.curve._mulA(a);
  52445. // E = (X1 + Y1)^2 - A - B
  52446. var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b);
  52447. // G = D + B
  52448. var g = d.redAdd(b);
  52449. // F = G - C
  52450. var f = g.redSub(c);
  52451. // H = D - B
  52452. var h = d.redSub(b);
  52453. // X3 = E * F
  52454. var nx = e.redMul(f);
  52455. // Y3 = G * H
  52456. var ny = g.redMul(h);
  52457. // T3 = E * H
  52458. var nt = e.redMul(h);
  52459. // Z3 = F * G
  52460. var nz = f.redMul(g);
  52461. return this.curve.point(nx, ny, nz, nt);
  52462. };
  52463. Point.prototype._projDbl = function _projDbl() {
  52464. // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
  52465. // #doubling-dbl-2008-bbjlp
  52466. // #doubling-dbl-2007-bl
  52467. // and others
  52468. // Generally 3M + 4S or 2M + 4S
  52469. // B = (X1 + Y1)^2
  52470. var b = this.x.redAdd(this.y).redSqr();
  52471. // C = X1^2
  52472. var c = this.x.redSqr();
  52473. // D = Y1^2
  52474. var d = this.y.redSqr();
  52475. var nx;
  52476. var ny;
  52477. var nz;
  52478. if (this.curve.twisted) {
  52479. // E = a * C
  52480. var e = this.curve._mulA(c);
  52481. // F = E + D
  52482. var f = e.redAdd(d);
  52483. if (this.zOne) {
  52484. // X3 = (B - C - D) * (F - 2)
  52485. nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two));
  52486. // Y3 = F * (E - D)
  52487. ny = f.redMul(e.redSub(d));
  52488. // Z3 = F^2 - 2 * F
  52489. nz = f.redSqr().redSub(f).redSub(f);
  52490. } else {
  52491. // H = Z1^2
  52492. var h = this.z.redSqr();
  52493. // J = F - 2 * H
  52494. var j = f.redSub(h).redISub(h);
  52495. // X3 = (B-C-D)*J
  52496. nx = b.redSub(c).redISub(d).redMul(j);
  52497. // Y3 = F * (E - D)
  52498. ny = f.redMul(e.redSub(d));
  52499. // Z3 = F * J
  52500. nz = f.redMul(j);
  52501. }
  52502. } else {
  52503. // E = C + D
  52504. var e = c.redAdd(d);
  52505. // H = (c * Z1)^2
  52506. var h = this.curve._mulC(this.c.redMul(this.z)).redSqr();
  52507. // J = E - 2 * H
  52508. var j = e.redSub(h).redSub(h);
  52509. // X3 = c * (B - E) * J
  52510. nx = this.curve._mulC(b.redISub(e)).redMul(j);
  52511. // Y3 = c * E * (C - D)
  52512. ny = this.curve._mulC(e).redMul(c.redISub(d));
  52513. // Z3 = E * J
  52514. nz = e.redMul(j);
  52515. }
  52516. return this.curve.point(nx, ny, nz);
  52517. };
  52518. Point.prototype.dbl = function dbl() {
  52519. if (this.isInfinity())
  52520. return this;
  52521. // Double in extended coordinates
  52522. if (this.curve.extended)
  52523. return this._extDbl();
  52524. else
  52525. return this._projDbl();
  52526. };
  52527. Point.prototype._extAdd = function _extAdd(p) {
  52528. // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
  52529. // #addition-add-2008-hwcd-3
  52530. // 8M
  52531. // A = (Y1 - X1) * (Y2 - X2)
  52532. var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x));
  52533. // B = (Y1 + X1) * (Y2 + X2)
  52534. var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x));
  52535. // C = T1 * k * T2
  52536. var c = this.t.redMul(this.curve.dd).redMul(p.t);
  52537. // D = Z1 * 2 * Z2
  52538. var d = this.z.redMul(p.z.redAdd(p.z));
  52539. // E = B - A
  52540. var e = b.redSub(a);
  52541. // F = D - C
  52542. var f = d.redSub(c);
  52543. // G = D + C
  52544. var g = d.redAdd(c);
  52545. // H = B + A
  52546. var h = b.redAdd(a);
  52547. // X3 = E * F
  52548. var nx = e.redMul(f);
  52549. // Y3 = G * H
  52550. var ny = g.redMul(h);
  52551. // T3 = E * H
  52552. var nt = e.redMul(h);
  52553. // Z3 = F * G
  52554. var nz = f.redMul(g);
  52555. return this.curve.point(nx, ny, nz, nt);
  52556. };
  52557. Point.prototype._projAdd = function _projAdd(p) {
  52558. // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
  52559. // #addition-add-2008-bbjlp
  52560. // #addition-add-2007-bl
  52561. // 10M + 1S
  52562. // A = Z1 * Z2
  52563. var a = this.z.redMul(p.z);
  52564. // B = A^2
  52565. var b = a.redSqr();
  52566. // C = X1 * X2
  52567. var c = this.x.redMul(p.x);
  52568. // D = Y1 * Y2
  52569. var d = this.y.redMul(p.y);
  52570. // E = d * C * D
  52571. var e = this.curve.d.redMul(c).redMul(d);
  52572. // F = B - E
  52573. var f = b.redSub(e);
  52574. // G = B + E
  52575. var g = b.redAdd(e);
  52576. // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D)
  52577. var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d);
  52578. var nx = a.redMul(f).redMul(tmp);
  52579. var ny;
  52580. var nz;
  52581. if (this.curve.twisted) {
  52582. // Y3 = A * G * (D - a * C)
  52583. ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c)));
  52584. // Z3 = F * G
  52585. nz = f.redMul(g);
  52586. } else {
  52587. // Y3 = A * G * (D - C)
  52588. ny = a.redMul(g).redMul(d.redSub(c));
  52589. // Z3 = c * F * G
  52590. nz = this.curve._mulC(f).redMul(g);
  52591. }
  52592. return this.curve.point(nx, ny, nz);
  52593. };
  52594. Point.prototype.add = function add(p) {
  52595. if (this.isInfinity())
  52596. return p;
  52597. if (p.isInfinity())
  52598. return this;
  52599. if (this.curve.extended)
  52600. return this._extAdd(p);
  52601. else
  52602. return this._projAdd(p);
  52603. };
  52604. Point.prototype.mul = function mul(k) {
  52605. if (this._hasDoubles(k))
  52606. return this.curve._fixedNafMul(this, k);
  52607. else
  52608. return this.curve._wnafMul(this, k);
  52609. };
  52610. Point.prototype.mulAdd = function mulAdd(k1, p, k2) {
  52611. return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false);
  52612. };
  52613. Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) {
  52614. return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true);
  52615. };
  52616. Point.prototype.normalize = function normalize() {
  52617. if (this.zOne)
  52618. return this;
  52619. // Normalize coordinates
  52620. var zi = this.z.redInvm();
  52621. this.x = this.x.redMul(zi);
  52622. this.y = this.y.redMul(zi);
  52623. if (this.t)
  52624. this.t = this.t.redMul(zi);
  52625. this.z = this.curve.one;
  52626. this.zOne = true;
  52627. return this;
  52628. };
  52629. Point.prototype.neg = function neg() {
  52630. return this.curve.point(this.x.redNeg(),
  52631. this.y,
  52632. this.z,
  52633. this.t && this.t.redNeg());
  52634. };
  52635. Point.prototype.getX = function getX() {
  52636. this.normalize();
  52637. return this.x.fromRed();
  52638. };
  52639. Point.prototype.getY = function getY() {
  52640. this.normalize();
  52641. return this.y.fromRed();
  52642. };
  52643. Point.prototype.eq = function eq(other) {
  52644. return this === other ||
  52645. this.getX().cmp(other.getX()) === 0 &&
  52646. this.getY().cmp(other.getY()) === 0;
  52647. };
  52648. Point.prototype.eqXToP = function eqXToP(x) {
  52649. var rx = x.toRed(this.curve.red).redMul(this.z);
  52650. if (this.x.cmp(rx) === 0)
  52651. return true;
  52652. var xc = x.clone();
  52653. var t = this.curve.redN.redMul(this.z);
  52654. for (;;) {
  52655. xc.iadd(this.curve.n);
  52656. if (xc.cmp(this.curve.p) >= 0)
  52657. return false;
  52658. rx.redIAdd(t);
  52659. if (this.x.cmp(rx) === 0)
  52660. return true;
  52661. }
  52662. return false;
  52663. };
  52664. // Compatibility with BaseCurve
  52665. Point.prototype.toP = Point.prototype.normalize;
  52666. Point.prototype.mixedAdd = Point.prototype.add;
  52667. /***/ },
  52668. /* 488 */
  52669. /***/ function(module, exports, __webpack_require__) {
  52670. "use strict";
  52671. 'use strict';
  52672. var curve = __webpack_require__(94);
  52673. var BN = __webpack_require__(12);
  52674. var inherits = __webpack_require__(2);
  52675. var Base = curve.base;
  52676. var elliptic = __webpack_require__(20);
  52677. var utils = elliptic.utils;
  52678. function MontCurve(conf) {
  52679. Base.call(this, 'mont', conf);
  52680. this.a = new BN(conf.a, 16).toRed(this.red);
  52681. this.b = new BN(conf.b, 16).toRed(this.red);
  52682. this.i4 = new BN(4).toRed(this.red).redInvm();
  52683. this.two = new BN(2).toRed(this.red);
  52684. this.a24 = this.i4.redMul(this.a.redAdd(this.two));
  52685. }
  52686. inherits(MontCurve, Base);
  52687. module.exports = MontCurve;
  52688. MontCurve.prototype.validate = function validate(point) {
  52689. var x = point.normalize().x;
  52690. var x2 = x.redSqr();
  52691. var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x);
  52692. var y = rhs.redSqrt();
  52693. return y.redSqr().cmp(rhs) === 0;
  52694. };
  52695. function Point(curve, x, z) {
  52696. Base.BasePoint.call(this, curve, 'projective');
  52697. if (x === null && z === null) {
  52698. this.x = this.curve.one;
  52699. this.z = this.curve.zero;
  52700. } else {
  52701. this.x = new BN(x, 16);
  52702. this.z = new BN(z, 16);
  52703. if (!this.x.red)
  52704. this.x = this.x.toRed(this.curve.red);
  52705. if (!this.z.red)
  52706. this.z = this.z.toRed(this.curve.red);
  52707. }
  52708. }
  52709. inherits(Point, Base.BasePoint);
  52710. MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
  52711. return this.point(utils.toArray(bytes, enc), 1);
  52712. };
  52713. MontCurve.prototype.point = function point(x, z) {
  52714. return new Point(this, x, z);
  52715. };
  52716. MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
  52717. return Point.fromJSON(this, obj);
  52718. };
  52719. Point.prototype.precompute = function precompute() {
  52720. // No-op
  52721. };
  52722. Point.prototype._encode = function _encode() {
  52723. return this.getX().toArray('be', this.curve.p.byteLength());
  52724. };
  52725. Point.fromJSON = function fromJSON(curve, obj) {
  52726. return new Point(curve, obj[0], obj[1] || curve.one);
  52727. };
  52728. Point.prototype.inspect = function inspect() {
  52729. if (this.isInfinity())
  52730. return '<EC Point Infinity>';
  52731. return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
  52732. ' z: ' + this.z.fromRed().toString(16, 2) + '>';
  52733. };
  52734. Point.prototype.isInfinity = function isInfinity() {
  52735. // XXX This code assumes that zero is always zero in red
  52736. return this.z.cmpn(0) === 0;
  52737. };
  52738. Point.prototype.dbl = function dbl() {
  52739. // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3
  52740. // 2M + 2S + 4A
  52741. // A = X1 + Z1
  52742. var a = this.x.redAdd(this.z);
  52743. // AA = A^2
  52744. var aa = a.redSqr();
  52745. // B = X1 - Z1
  52746. var b = this.x.redSub(this.z);
  52747. // BB = B^2
  52748. var bb = b.redSqr();
  52749. // C = AA - BB
  52750. var c = aa.redSub(bb);
  52751. // X3 = AA * BB
  52752. var nx = aa.redMul(bb);
  52753. // Z3 = C * (BB + A24 * C)
  52754. var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c)));
  52755. return this.curve.point(nx, nz);
  52756. };
  52757. Point.prototype.add = function add() {
  52758. throw new Error('Not supported on Montgomery curve');
  52759. };
  52760. Point.prototype.diffAdd = function diffAdd(p, diff) {
  52761. // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3
  52762. // 4M + 2S + 6A
  52763. // A = X2 + Z2
  52764. var a = this.x.redAdd(this.z);
  52765. // B = X2 - Z2
  52766. var b = this.x.redSub(this.z);
  52767. // C = X3 + Z3
  52768. var c = p.x.redAdd(p.z);
  52769. // D = X3 - Z3
  52770. var d = p.x.redSub(p.z);
  52771. // DA = D * A
  52772. var da = d.redMul(a);
  52773. // CB = C * B
  52774. var cb = c.redMul(b);
  52775. // X5 = Z1 * (DA + CB)^2
  52776. var nx = diff.z.redMul(da.redAdd(cb).redSqr());
  52777. // Z5 = X1 * (DA - CB)^2
  52778. var nz = diff.x.redMul(da.redISub(cb).redSqr());
  52779. return this.curve.point(nx, nz);
  52780. };
  52781. Point.prototype.mul = function mul(k) {
  52782. var t = k.clone();
  52783. var a = this; // (N / 2) * Q + Q
  52784. var b = this.curve.point(null, null); // (N / 2) * Q
  52785. var c = this; // Q
  52786. for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1))
  52787. bits.push(t.andln(1));
  52788. for (var i = bits.length - 1; i >= 0; i--) {
  52789. if (bits[i] === 0) {
  52790. // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q
  52791. a = a.diffAdd(b, c);
  52792. // N * Q = 2 * ((N / 2) * Q + Q))
  52793. b = b.dbl();
  52794. } else {
  52795. // N * Q = ((N / 2) * Q + Q) + ((N / 2) * Q)
  52796. b = a.diffAdd(b, c);
  52797. // N * Q + Q = 2 * ((N / 2) * Q + Q)
  52798. a = a.dbl();
  52799. }
  52800. }
  52801. return b;
  52802. };
  52803. Point.prototype.mulAdd = function mulAdd() {
  52804. throw new Error('Not supported on Montgomery curve');
  52805. };
  52806. Point.prototype.jumlAdd = function jumlAdd() {
  52807. throw new Error('Not supported on Montgomery curve');
  52808. };
  52809. Point.prototype.eq = function eq(other) {
  52810. return this.getX().cmp(other.getX()) === 0;
  52811. };
  52812. Point.prototype.normalize = function normalize() {
  52813. this.x = this.x.redMul(this.z.redInvm());
  52814. this.z = this.curve.one;
  52815. return this;
  52816. };
  52817. Point.prototype.getX = function getX() {
  52818. // Normalize coordinates
  52819. this.normalize();
  52820. return this.x.fromRed();
  52821. };
  52822. /***/ },
  52823. /* 489 */
  52824. /***/ function(module, exports, __webpack_require__) {
  52825. "use strict";
  52826. 'use strict';
  52827. var curve = __webpack_require__(94);
  52828. var elliptic = __webpack_require__(20);
  52829. var BN = __webpack_require__(12);
  52830. var inherits = __webpack_require__(2);
  52831. var Base = curve.base;
  52832. var assert = elliptic.utils.assert;
  52833. function ShortCurve(conf) {
  52834. Base.call(this, 'short', conf);
  52835. this.a = new BN(conf.a, 16).toRed(this.red);
  52836. this.b = new BN(conf.b, 16).toRed(this.red);
  52837. this.tinv = this.two.redInvm();
  52838. this.zeroA = this.a.fromRed().cmpn(0) === 0;
  52839. this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0;
  52840. // If the curve is endomorphic, precalculate beta and lambda
  52841. this.endo = this._getEndomorphism(conf);
  52842. this._endoWnafT1 = new Array(4);
  52843. this._endoWnafT2 = new Array(4);
  52844. }
  52845. inherits(ShortCurve, Base);
  52846. module.exports = ShortCurve;
  52847. ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) {
  52848. // No efficient endomorphism
  52849. if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)
  52850. return;
  52851. // Compute beta and lambda, that lambda * P = (beta * Px; Py)
  52852. var beta;
  52853. var lambda;
  52854. if (conf.beta) {
  52855. beta = new BN(conf.beta, 16).toRed(this.red);
  52856. } else {
  52857. var betas = this._getEndoRoots(this.p);
  52858. // Choose the smallest beta
  52859. beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1];
  52860. beta = beta.toRed(this.red);
  52861. }
  52862. if (conf.lambda) {
  52863. lambda = new BN(conf.lambda, 16);
  52864. } else {
  52865. // Choose the lambda that is matching selected beta
  52866. var lambdas = this._getEndoRoots(this.n);
  52867. if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) {
  52868. lambda = lambdas[0];
  52869. } else {
  52870. lambda = lambdas[1];
  52871. assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0);
  52872. }
  52873. }
  52874. // Get basis vectors, used for balanced length-two representation
  52875. var basis;
  52876. if (conf.basis) {
  52877. basis = conf.basis.map(function(vec) {
  52878. return {
  52879. a: new BN(vec.a, 16),
  52880. b: new BN(vec.b, 16)
  52881. };
  52882. });
  52883. } else {
  52884. basis = this._getEndoBasis(lambda);
  52885. }
  52886. return {
  52887. beta: beta,
  52888. lambda: lambda,
  52889. basis: basis
  52890. };
  52891. };
  52892. ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) {
  52893. // Find roots of for x^2 + x + 1 in F
  52894. // Root = (-1 +- Sqrt(-3)) / 2
  52895. //
  52896. var red = num === this.p ? this.red : BN.mont(num);
  52897. var tinv = new BN(2).toRed(red).redInvm();
  52898. var ntinv = tinv.redNeg();
  52899. var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv);
  52900. var l1 = ntinv.redAdd(s).fromRed();
  52901. var l2 = ntinv.redSub(s).fromRed();
  52902. return [ l1, l2 ];
  52903. };
  52904. ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) {
  52905. // aprxSqrt >= sqrt(this.n)
  52906. var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2));
  52907. // 3.74
  52908. // Run EGCD, until r(L + 1) < aprxSqrt
  52909. var u = lambda;
  52910. var v = this.n.clone();
  52911. var x1 = new BN(1);
  52912. var y1 = new BN(0);
  52913. var x2 = new BN(0);
  52914. var y2 = new BN(1);
  52915. // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n)
  52916. var a0;
  52917. var b0;
  52918. // First vector
  52919. var a1;
  52920. var b1;
  52921. // Second vector
  52922. var a2;
  52923. var b2;
  52924. var prevR;
  52925. var i = 0;
  52926. var r;
  52927. var x;
  52928. while (u.cmpn(0) !== 0) {
  52929. var q = v.div(u);
  52930. r = v.sub(q.mul(u));
  52931. x = x2.sub(q.mul(x1));
  52932. var y = y2.sub(q.mul(y1));
  52933. if (!a1 && r.cmp(aprxSqrt) < 0) {
  52934. a0 = prevR.neg();
  52935. b0 = x1;
  52936. a1 = r.neg();
  52937. b1 = x;
  52938. } else if (a1 && ++i === 2) {
  52939. break;
  52940. }
  52941. prevR = r;
  52942. v = u;
  52943. u = r;
  52944. x2 = x1;
  52945. x1 = x;
  52946. y2 = y1;
  52947. y1 = y;
  52948. }
  52949. a2 = r.neg();
  52950. b2 = x;
  52951. var len1 = a1.sqr().add(b1.sqr());
  52952. var len2 = a2.sqr().add(b2.sqr());
  52953. if (len2.cmp(len1) >= 0) {
  52954. a2 = a0;
  52955. b2 = b0;
  52956. }
  52957. // Normalize signs
  52958. if (a1.negative) {
  52959. a1 = a1.neg();
  52960. b1 = b1.neg();
  52961. }
  52962. if (a2.negative) {
  52963. a2 = a2.neg();
  52964. b2 = b2.neg();
  52965. }
  52966. return [
  52967. { a: a1, b: b1 },
  52968. { a: a2, b: b2 }
  52969. ];
  52970. };
  52971. ShortCurve.prototype._endoSplit = function _endoSplit(k) {
  52972. var basis = this.endo.basis;
  52973. var v1 = basis[0];
  52974. var v2 = basis[1];
  52975. var c1 = v2.b.mul(k).divRound(this.n);
  52976. var c2 = v1.b.neg().mul(k).divRound(this.n);
  52977. var p1 = c1.mul(v1.a);
  52978. var p2 = c2.mul(v2.a);
  52979. var q1 = c1.mul(v1.b);
  52980. var q2 = c2.mul(v2.b);
  52981. // Calculate answer
  52982. var k1 = k.sub(p1).sub(p2);
  52983. var k2 = q1.add(q2).neg();
  52984. return { k1: k1, k2: k2 };
  52985. };
  52986. ShortCurve.prototype.pointFromX = function pointFromX(x, odd) {
  52987. x = new BN(x, 16);
  52988. if (!x.red)
  52989. x = x.toRed(this.red);
  52990. var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b);
  52991. var y = y2.redSqrt();
  52992. if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
  52993. throw new Error('invalid point');
  52994. // XXX Is there any way to tell if the number is odd without converting it
  52995. // to non-red form?
  52996. var isOdd = y.fromRed().isOdd();
  52997. if (odd && !isOdd || !odd && isOdd)
  52998. y = y.redNeg();
  52999. return this.point(x, y);
  53000. };
  53001. ShortCurve.prototype.validate = function validate(point) {
  53002. if (point.inf)
  53003. return true;
  53004. var x = point.x;
  53005. var y = point.y;
  53006. var ax = this.a.redMul(x);
  53007. var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b);
  53008. return y.redSqr().redISub(rhs).cmpn(0) === 0;
  53009. };
  53010. ShortCurve.prototype._endoWnafMulAdd =
  53011. function _endoWnafMulAdd(points, coeffs, jacobianResult) {
  53012. var npoints = this._endoWnafT1;
  53013. var ncoeffs = this._endoWnafT2;
  53014. for (var i = 0; i < points.length; i++) {
  53015. var split = this._endoSplit(coeffs[i]);
  53016. var p = points[i];
  53017. var beta = p._getBeta();
  53018. if (split.k1.negative) {
  53019. split.k1.ineg();
  53020. p = p.neg(true);
  53021. }
  53022. if (split.k2.negative) {
  53023. split.k2.ineg();
  53024. beta = beta.neg(true);
  53025. }
  53026. npoints[i * 2] = p;
  53027. npoints[i * 2 + 1] = beta;
  53028. ncoeffs[i * 2] = split.k1;
  53029. ncoeffs[i * 2 + 1] = split.k2;
  53030. }
  53031. var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult);
  53032. // Clean-up references to points and coefficients
  53033. for (var j = 0; j < i * 2; j++) {
  53034. npoints[j] = null;
  53035. ncoeffs[j] = null;
  53036. }
  53037. return res;
  53038. };
  53039. function Point(curve, x, y, isRed) {
  53040. Base.BasePoint.call(this, curve, 'affine');
  53041. if (x === null && y === null) {
  53042. this.x = null;
  53043. this.y = null;
  53044. this.inf = true;
  53045. } else {
  53046. this.x = new BN(x, 16);
  53047. this.y = new BN(y, 16);
  53048. // Force redgomery representation when loading from JSON
  53049. if (isRed) {
  53050. this.x.forceRed(this.curve.red);
  53051. this.y.forceRed(this.curve.red);
  53052. }
  53053. if (!this.x.red)
  53054. this.x = this.x.toRed(this.curve.red);
  53055. if (!this.y.red)
  53056. this.y = this.y.toRed(this.curve.red);
  53057. this.inf = false;
  53058. }
  53059. }
  53060. inherits(Point, Base.BasePoint);
  53061. ShortCurve.prototype.point = function point(x, y, isRed) {
  53062. return new Point(this, x, y, isRed);
  53063. };
  53064. ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) {
  53065. return Point.fromJSON(this, obj, red);
  53066. };
  53067. Point.prototype._getBeta = function _getBeta() {
  53068. if (!this.curve.endo)
  53069. return;
  53070. var pre = this.precomputed;
  53071. if (pre && pre.beta)
  53072. return pre.beta;
  53073. var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y);
  53074. if (pre) {
  53075. var curve = this.curve;
  53076. var endoMul = function(p) {
  53077. return curve.point(p.x.redMul(curve.endo.beta), p.y);
  53078. };
  53079. pre.beta = beta;
  53080. beta.precomputed = {
  53081. beta: null,
  53082. naf: pre.naf && {
  53083. wnd: pre.naf.wnd,
  53084. points: pre.naf.points.map(endoMul)
  53085. },
  53086. doubles: pre.doubles && {
  53087. step: pre.doubles.step,
  53088. points: pre.doubles.points.map(endoMul)
  53089. }
  53090. };
  53091. }
  53092. return beta;
  53093. };
  53094. Point.prototype.toJSON = function toJSON() {
  53095. if (!this.precomputed)
  53096. return [ this.x, this.y ];
  53097. return [ this.x, this.y, this.precomputed && {
  53098. doubles: this.precomputed.doubles && {
  53099. step: this.precomputed.doubles.step,
  53100. points: this.precomputed.doubles.points.slice(1)
  53101. },
  53102. naf: this.precomputed.naf && {
  53103. wnd: this.precomputed.naf.wnd,
  53104. points: this.precomputed.naf.points.slice(1)
  53105. }
  53106. } ];
  53107. };
  53108. Point.fromJSON = function fromJSON(curve, obj, red) {
  53109. if (typeof obj === 'string')
  53110. obj = JSON.parse(obj);
  53111. var res = curve.point(obj[0], obj[1], red);
  53112. if (!obj[2])
  53113. return res;
  53114. function obj2point(obj) {
  53115. return curve.point(obj[0], obj[1], red);
  53116. }
  53117. var pre = obj[2];
  53118. res.precomputed = {
  53119. beta: null,
  53120. doubles: pre.doubles && {
  53121. step: pre.doubles.step,
  53122. points: [ res ].concat(pre.doubles.points.map(obj2point))
  53123. },
  53124. naf: pre.naf && {
  53125. wnd: pre.naf.wnd,
  53126. points: [ res ].concat(pre.naf.points.map(obj2point))
  53127. }
  53128. };
  53129. return res;
  53130. };
  53131. Point.prototype.inspect = function inspect() {
  53132. if (this.isInfinity())
  53133. return '<EC Point Infinity>';
  53134. return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
  53135. ' y: ' + this.y.fromRed().toString(16, 2) + '>';
  53136. };
  53137. Point.prototype.isInfinity = function isInfinity() {
  53138. return this.inf;
  53139. };
  53140. Point.prototype.add = function add(p) {
  53141. // O + P = P
  53142. if (this.inf)
  53143. return p;
  53144. // P + O = P
  53145. if (p.inf)
  53146. return this;
  53147. // P + P = 2P
  53148. if (this.eq(p))
  53149. return this.dbl();
  53150. // P + (-P) = O
  53151. if (this.neg().eq(p))
  53152. return this.curve.point(null, null);
  53153. // P + Q = O
  53154. if (this.x.cmp(p.x) === 0)
  53155. return this.curve.point(null, null);
  53156. var c = this.y.redSub(p.y);
  53157. if (c.cmpn(0) !== 0)
  53158. c = c.redMul(this.x.redSub(p.x).redInvm());
  53159. var nx = c.redSqr().redISub(this.x).redISub(p.x);
  53160. var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
  53161. return this.curve.point(nx, ny);
  53162. };
  53163. Point.prototype.dbl = function dbl() {
  53164. if (this.inf)
  53165. return this;
  53166. // 2P = O
  53167. var ys1 = this.y.redAdd(this.y);
  53168. if (ys1.cmpn(0) === 0)
  53169. return this.curve.point(null, null);
  53170. var a = this.curve.a;
  53171. var x2 = this.x.redSqr();
  53172. var dyinv = ys1.redInvm();
  53173. var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv);
  53174. var nx = c.redSqr().redISub(this.x.redAdd(this.x));
  53175. var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
  53176. return this.curve.point(nx, ny);
  53177. };
  53178. Point.prototype.getX = function getX() {
  53179. return this.x.fromRed();
  53180. };
  53181. Point.prototype.getY = function getY() {
  53182. return this.y.fromRed();
  53183. };
  53184. Point.prototype.mul = function mul(k) {
  53185. k = new BN(k, 16);
  53186. if (this._hasDoubles(k))
  53187. return this.curve._fixedNafMul(this, k);
  53188. else if (this.curve.endo)
  53189. return this.curve._endoWnafMulAdd([ this ], [ k ]);
  53190. else
  53191. return this.curve._wnafMul(this, k);
  53192. };
  53193. Point.prototype.mulAdd = function mulAdd(k1, p2, k2) {
  53194. var points = [ this, p2 ];
  53195. var coeffs = [ k1, k2 ];
  53196. if (this.curve.endo)
  53197. return this.curve._endoWnafMulAdd(points, coeffs);
  53198. else
  53199. return this.curve._wnafMulAdd(1, points, coeffs, 2);
  53200. };
  53201. Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) {
  53202. var points = [ this, p2 ];
  53203. var coeffs = [ k1, k2 ];
  53204. if (this.curve.endo)
  53205. return this.curve._endoWnafMulAdd(points, coeffs, true);
  53206. else
  53207. return this.curve._wnafMulAdd(1, points, coeffs, 2, true);
  53208. };
  53209. Point.prototype.eq = function eq(p) {
  53210. return this === p ||
  53211. this.inf === p.inf &&
  53212. (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0);
  53213. };
  53214. Point.prototype.neg = function neg(_precompute) {
  53215. if (this.inf)
  53216. return this;
  53217. var res = this.curve.point(this.x, this.y.redNeg());
  53218. if (_precompute && this.precomputed) {
  53219. var pre = this.precomputed;
  53220. var negate = function(p) {
  53221. return p.neg();
  53222. };
  53223. res.precomputed = {
  53224. naf: pre.naf && {
  53225. wnd: pre.naf.wnd,
  53226. points: pre.naf.points.map(negate)
  53227. },
  53228. doubles: pre.doubles && {
  53229. step: pre.doubles.step,
  53230. points: pre.doubles.points.map(negate)
  53231. }
  53232. };
  53233. }
  53234. return res;
  53235. };
  53236. Point.prototype.toJ = function toJ() {
  53237. if (this.inf)
  53238. return this.curve.jpoint(null, null, null);
  53239. var res = this.curve.jpoint(this.x, this.y, this.curve.one);
  53240. return res;
  53241. };
  53242. function JPoint(curve, x, y, z) {
  53243. Base.BasePoint.call(this, curve, 'jacobian');
  53244. if (x === null && y === null && z === null) {
  53245. this.x = this.curve.one;
  53246. this.y = this.curve.one;
  53247. this.z = new BN(0);
  53248. } else {
  53249. this.x = new BN(x, 16);
  53250. this.y = new BN(y, 16);
  53251. this.z = new BN(z, 16);
  53252. }
  53253. if (!this.x.red)
  53254. this.x = this.x.toRed(this.curve.red);
  53255. if (!this.y.red)
  53256. this.y = this.y.toRed(this.curve.red);
  53257. if (!this.z.red)
  53258. this.z = this.z.toRed(this.curve.red);
  53259. this.zOne = this.z === this.curve.one;
  53260. }
  53261. inherits(JPoint, Base.BasePoint);
  53262. ShortCurve.prototype.jpoint = function jpoint(x, y, z) {
  53263. return new JPoint(this, x, y, z);
  53264. };
  53265. JPoint.prototype.toP = function toP() {
  53266. if (this.isInfinity())
  53267. return this.curve.point(null, null);
  53268. var zinv = this.z.redInvm();
  53269. var zinv2 = zinv.redSqr();
  53270. var ax = this.x.redMul(zinv2);
  53271. var ay = this.y.redMul(zinv2).redMul(zinv);
  53272. return this.curve.point(ax, ay);
  53273. };
  53274. JPoint.prototype.neg = function neg() {
  53275. return this.curve.jpoint(this.x, this.y.redNeg(), this.z);
  53276. };
  53277. JPoint.prototype.add = function add(p) {
  53278. // O + P = P
  53279. if (this.isInfinity())
  53280. return p;
  53281. // P + O = P
  53282. if (p.isInfinity())
  53283. return this;
  53284. // 12M + 4S + 7A
  53285. var pz2 = p.z.redSqr();
  53286. var z2 = this.z.redSqr();
  53287. var u1 = this.x.redMul(pz2);
  53288. var u2 = p.x.redMul(z2);
  53289. var s1 = this.y.redMul(pz2.redMul(p.z));
  53290. var s2 = p.y.redMul(z2.redMul(this.z));
  53291. var h = u1.redSub(u2);
  53292. var r = s1.redSub(s2);
  53293. if (h.cmpn(0) === 0) {
  53294. if (r.cmpn(0) !== 0)
  53295. return this.curve.jpoint(null, null, null);
  53296. else
  53297. return this.dbl();
  53298. }
  53299. var h2 = h.redSqr();
  53300. var h3 = h2.redMul(h);
  53301. var v = u1.redMul(h2);
  53302. var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
  53303. var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
  53304. var nz = this.z.redMul(p.z).redMul(h);
  53305. return this.curve.jpoint(nx, ny, nz);
  53306. };
  53307. JPoint.prototype.mixedAdd = function mixedAdd(p) {
  53308. // O + P = P
  53309. if (this.isInfinity())
  53310. return p.toJ();
  53311. // P + O = P
  53312. if (p.isInfinity())
  53313. return this;
  53314. // 8M + 3S + 7A
  53315. var z2 = this.z.redSqr();
  53316. var u1 = this.x;
  53317. var u2 = p.x.redMul(z2);
  53318. var s1 = this.y;
  53319. var s2 = p.y.redMul(z2).redMul(this.z);
  53320. var h = u1.redSub(u2);
  53321. var r = s1.redSub(s2);
  53322. if (h.cmpn(0) === 0) {
  53323. if (r.cmpn(0) !== 0)
  53324. return this.curve.jpoint(null, null, null);
  53325. else
  53326. return this.dbl();
  53327. }
  53328. var h2 = h.redSqr();
  53329. var h3 = h2.redMul(h);
  53330. var v = u1.redMul(h2);
  53331. var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
  53332. var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
  53333. var nz = this.z.redMul(h);
  53334. return this.curve.jpoint(nx, ny, nz);
  53335. };
  53336. JPoint.prototype.dblp = function dblp(pow) {
  53337. if (pow === 0)
  53338. return this;
  53339. if (this.isInfinity())
  53340. return this;
  53341. if (!pow)
  53342. return this.dbl();
  53343. if (this.curve.zeroA || this.curve.threeA) {
  53344. var r = this;
  53345. for (var i = 0; i < pow; i++)
  53346. r = r.dbl();
  53347. return r;
  53348. }
  53349. // 1M + 2S + 1A + N * (4S + 5M + 8A)
  53350. // N = 1 => 6M + 6S + 9A
  53351. var a = this.curve.a;
  53352. var tinv = this.curve.tinv;
  53353. var jx = this.x;
  53354. var jy = this.y;
  53355. var jz = this.z;
  53356. var jz4 = jz.redSqr().redSqr();
  53357. // Reuse results
  53358. var jyd = jy.redAdd(jy);
  53359. for (var i = 0; i < pow; i++) {
  53360. var jx2 = jx.redSqr();
  53361. var jyd2 = jyd.redSqr();
  53362. var jyd4 = jyd2.redSqr();
  53363. var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
  53364. var t1 = jx.redMul(jyd2);
  53365. var nx = c.redSqr().redISub(t1.redAdd(t1));
  53366. var t2 = t1.redISub(nx);
  53367. var dny = c.redMul(t2);
  53368. dny = dny.redIAdd(dny).redISub(jyd4);
  53369. var nz = jyd.redMul(jz);
  53370. if (i + 1 < pow)
  53371. jz4 = jz4.redMul(jyd4);
  53372. jx = nx;
  53373. jz = nz;
  53374. jyd = dny;
  53375. }
  53376. return this.curve.jpoint(jx, jyd.redMul(tinv), jz);
  53377. };
  53378. JPoint.prototype.dbl = function dbl() {
  53379. if (this.isInfinity())
  53380. return this;
  53381. if (this.curve.zeroA)
  53382. return this._zeroDbl();
  53383. else if (this.curve.threeA)
  53384. return this._threeDbl();
  53385. else
  53386. return this._dbl();
  53387. };
  53388. JPoint.prototype._zeroDbl = function _zeroDbl() {
  53389. var nx;
  53390. var ny;
  53391. var nz;
  53392. // Z = 1
  53393. if (this.zOne) {
  53394. // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
  53395. // #doubling-mdbl-2007-bl
  53396. // 1M + 5S + 14A
  53397. // XX = X1^2
  53398. var xx = this.x.redSqr();
  53399. // YY = Y1^2
  53400. var yy = this.y.redSqr();
  53401. // YYYY = YY^2
  53402. var yyyy = yy.redSqr();
  53403. // S = 2 * ((X1 + YY)^2 - XX - YYYY)
  53404. var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
  53405. s = s.redIAdd(s);
  53406. // M = 3 * XX + a; a = 0
  53407. var m = xx.redAdd(xx).redIAdd(xx);
  53408. // T = M ^ 2 - 2*S
  53409. var t = m.redSqr().redISub(s).redISub(s);
  53410. // 8 * YYYY
  53411. var yyyy8 = yyyy.redIAdd(yyyy);
  53412. yyyy8 = yyyy8.redIAdd(yyyy8);
  53413. yyyy8 = yyyy8.redIAdd(yyyy8);
  53414. // X3 = T
  53415. nx = t;
  53416. // Y3 = M * (S - T) - 8 * YYYY
  53417. ny = m.redMul(s.redISub(t)).redISub(yyyy8);
  53418. // Z3 = 2*Y1
  53419. nz = this.y.redAdd(this.y);
  53420. } else {
  53421. // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
  53422. // #doubling-dbl-2009-l
  53423. // 2M + 5S + 13A
  53424. // A = X1^2
  53425. var a = this.x.redSqr();
  53426. // B = Y1^2
  53427. var b = this.y.redSqr();
  53428. // C = B^2
  53429. var c = b.redSqr();
  53430. // D = 2 * ((X1 + B)^2 - A - C)
  53431. var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c);
  53432. d = d.redIAdd(d);
  53433. // E = 3 * A
  53434. var e = a.redAdd(a).redIAdd(a);
  53435. // F = E^2
  53436. var f = e.redSqr();
  53437. // 8 * C
  53438. var c8 = c.redIAdd(c);
  53439. c8 = c8.redIAdd(c8);
  53440. c8 = c8.redIAdd(c8);
  53441. // X3 = F - 2 * D
  53442. nx = f.redISub(d).redISub(d);
  53443. // Y3 = E * (D - X3) - 8 * C
  53444. ny = e.redMul(d.redISub(nx)).redISub(c8);
  53445. // Z3 = 2 * Y1 * Z1
  53446. nz = this.y.redMul(this.z);
  53447. nz = nz.redIAdd(nz);
  53448. }
  53449. return this.curve.jpoint(nx, ny, nz);
  53450. };
  53451. JPoint.prototype._threeDbl = function _threeDbl() {
  53452. var nx;
  53453. var ny;
  53454. var nz;
  53455. // Z = 1
  53456. if (this.zOne) {
  53457. // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html
  53458. // #doubling-mdbl-2007-bl
  53459. // 1M + 5S + 15A
  53460. // XX = X1^2
  53461. var xx = this.x.redSqr();
  53462. // YY = Y1^2
  53463. var yy = this.y.redSqr();
  53464. // YYYY = YY^2
  53465. var yyyy = yy.redSqr();
  53466. // S = 2 * ((X1 + YY)^2 - XX - YYYY)
  53467. var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
  53468. s = s.redIAdd(s);
  53469. // M = 3 * XX + a
  53470. var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a);
  53471. // T = M^2 - 2 * S
  53472. var t = m.redSqr().redISub(s).redISub(s);
  53473. // X3 = T
  53474. nx = t;
  53475. // Y3 = M * (S - T) - 8 * YYYY
  53476. var yyyy8 = yyyy.redIAdd(yyyy);
  53477. yyyy8 = yyyy8.redIAdd(yyyy8);
  53478. yyyy8 = yyyy8.redIAdd(yyyy8);
  53479. ny = m.redMul(s.redISub(t)).redISub(yyyy8);
  53480. // Z3 = 2 * Y1
  53481. nz = this.y.redAdd(this.y);
  53482. } else {
  53483. // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b
  53484. // 3M + 5S
  53485. // delta = Z1^2
  53486. var delta = this.z.redSqr();
  53487. // gamma = Y1^2
  53488. var gamma = this.y.redSqr();
  53489. // beta = X1 * gamma
  53490. var beta = this.x.redMul(gamma);
  53491. // alpha = 3 * (X1 - delta) * (X1 + delta)
  53492. var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta));
  53493. alpha = alpha.redAdd(alpha).redIAdd(alpha);
  53494. // X3 = alpha^2 - 8 * beta
  53495. var beta4 = beta.redIAdd(beta);
  53496. beta4 = beta4.redIAdd(beta4);
  53497. var beta8 = beta4.redAdd(beta4);
  53498. nx = alpha.redSqr().redISub(beta8);
  53499. // Z3 = (Y1 + Z1)^2 - gamma - delta
  53500. nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta);
  53501. // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2
  53502. var ggamma8 = gamma.redSqr();
  53503. ggamma8 = ggamma8.redIAdd(ggamma8);
  53504. ggamma8 = ggamma8.redIAdd(ggamma8);
  53505. ggamma8 = ggamma8.redIAdd(ggamma8);
  53506. ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8);
  53507. }
  53508. return this.curve.jpoint(nx, ny, nz);
  53509. };
  53510. JPoint.prototype._dbl = function _dbl() {
  53511. var a = this.curve.a;
  53512. // 4M + 6S + 10A
  53513. var jx = this.x;
  53514. var jy = this.y;
  53515. var jz = this.z;
  53516. var jz4 = jz.redSqr().redSqr();
  53517. var jx2 = jx.redSqr();
  53518. var jy2 = jy.redSqr();
  53519. var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
  53520. var jxd4 = jx.redAdd(jx);
  53521. jxd4 = jxd4.redIAdd(jxd4);
  53522. var t1 = jxd4.redMul(jy2);
  53523. var nx = c.redSqr().redISub(t1.redAdd(t1));
  53524. var t2 = t1.redISub(nx);
  53525. var jyd8 = jy2.redSqr();
  53526. jyd8 = jyd8.redIAdd(jyd8);
  53527. jyd8 = jyd8.redIAdd(jyd8);
  53528. jyd8 = jyd8.redIAdd(jyd8);
  53529. var ny = c.redMul(t2).redISub(jyd8);
  53530. var nz = jy.redAdd(jy).redMul(jz);
  53531. return this.curve.jpoint(nx, ny, nz);
  53532. };
  53533. JPoint.prototype.trpl = function trpl() {
  53534. if (!this.curve.zeroA)
  53535. return this.dbl().add(this);
  53536. // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl
  53537. // 5M + 10S + ...
  53538. // XX = X1^2
  53539. var xx = this.x.redSqr();
  53540. // YY = Y1^2
  53541. var yy = this.y.redSqr();
  53542. // ZZ = Z1^2
  53543. var zz = this.z.redSqr();
  53544. // YYYY = YY^2
  53545. var yyyy = yy.redSqr();
  53546. // M = 3 * XX + a * ZZ2; a = 0
  53547. var m = xx.redAdd(xx).redIAdd(xx);
  53548. // MM = M^2
  53549. var mm = m.redSqr();
  53550. // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM
  53551. var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
  53552. e = e.redIAdd(e);
  53553. e = e.redAdd(e).redIAdd(e);
  53554. e = e.redISub(mm);
  53555. // EE = E^2
  53556. var ee = e.redSqr();
  53557. // T = 16*YYYY
  53558. var t = yyyy.redIAdd(yyyy);
  53559. t = t.redIAdd(t);
  53560. t = t.redIAdd(t);
  53561. t = t.redIAdd(t);
  53562. // U = (M + E)^2 - MM - EE - T
  53563. var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t);
  53564. // X3 = 4 * (X1 * EE - 4 * YY * U)
  53565. var yyu4 = yy.redMul(u);
  53566. yyu4 = yyu4.redIAdd(yyu4);
  53567. yyu4 = yyu4.redIAdd(yyu4);
  53568. var nx = this.x.redMul(ee).redISub(yyu4);
  53569. nx = nx.redIAdd(nx);
  53570. nx = nx.redIAdd(nx);
  53571. // Y3 = 8 * Y1 * (U * (T - U) - E * EE)
  53572. var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee)));
  53573. ny = ny.redIAdd(ny);
  53574. ny = ny.redIAdd(ny);
  53575. ny = ny.redIAdd(ny);
  53576. // Z3 = (Z1 + E)^2 - ZZ - EE
  53577. var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee);
  53578. return this.curve.jpoint(nx, ny, nz);
  53579. };
  53580. JPoint.prototype.mul = function mul(k, kbase) {
  53581. k = new BN(k, kbase);
  53582. return this.curve._wnafMul(this, k);
  53583. };
  53584. JPoint.prototype.eq = function eq(p) {
  53585. if (p.type === 'affine')
  53586. return this.eq(p.toJ());
  53587. if (this === p)
  53588. return true;
  53589. // x1 * z2^2 == x2 * z1^2
  53590. var z2 = this.z.redSqr();
  53591. var pz2 = p.z.redSqr();
  53592. if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0)
  53593. return false;
  53594. // y1 * z2^3 == y2 * z1^3
  53595. var z3 = z2.redMul(this.z);
  53596. var pz3 = pz2.redMul(p.z);
  53597. return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0;
  53598. };
  53599. JPoint.prototype.eqXToP = function eqXToP(x) {
  53600. var zs = this.z.redSqr();
  53601. var rx = x.toRed(this.curve.red).redMul(zs);
  53602. if (this.x.cmp(rx) === 0)
  53603. return true;
  53604. var xc = x.clone();
  53605. var t = this.curve.redN.redMul(zs);
  53606. for (;;) {
  53607. xc.iadd(this.curve.n);
  53608. if (xc.cmp(this.curve.p) >= 0)
  53609. return false;
  53610. rx.redIAdd(t);
  53611. if (this.x.cmp(rx) === 0)
  53612. return true;
  53613. }
  53614. return false;
  53615. };
  53616. JPoint.prototype.inspect = function inspect() {
  53617. if (this.isInfinity())
  53618. return '<EC JPoint Infinity>';
  53619. return '<EC JPoint x: ' + this.x.toString(16, 2) +
  53620. ' y: ' + this.y.toString(16, 2) +
  53621. ' z: ' + this.z.toString(16, 2) + '>';
  53622. };
  53623. JPoint.prototype.isInfinity = function isInfinity() {
  53624. // XXX This code assumes that zero is always zero in red
  53625. return this.z.cmpn(0) === 0;
  53626. };
  53627. /***/ },
  53628. /* 490 */
  53629. /***/ function(module, exports, __webpack_require__) {
  53630. "use strict";
  53631. 'use strict';
  53632. var curves = exports;
  53633. var hash = __webpack_require__(54);
  53634. var elliptic = __webpack_require__(20);
  53635. var assert = elliptic.utils.assert;
  53636. function PresetCurve(options) {
  53637. if (options.type === 'short')
  53638. this.curve = new elliptic.curve.short(options);
  53639. else if (options.type === 'edwards')
  53640. this.curve = new elliptic.curve.edwards(options);
  53641. else
  53642. this.curve = new elliptic.curve.mont(options);
  53643. this.g = this.curve.g;
  53644. this.n = this.curve.n;
  53645. this.hash = options.hash;
  53646. assert(this.g.validate(), 'Invalid curve');
  53647. assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O');
  53648. }
  53649. curves.PresetCurve = PresetCurve;
  53650. function defineCurve(name, options) {
  53651. Object.defineProperty(curves, name, {
  53652. configurable: true,
  53653. enumerable: true,
  53654. get: function() {
  53655. var curve = new PresetCurve(options);
  53656. Object.defineProperty(curves, name, {
  53657. configurable: true,
  53658. enumerable: true,
  53659. value: curve
  53660. });
  53661. return curve;
  53662. }
  53663. });
  53664. }
  53665. defineCurve('p192', {
  53666. type: 'short',
  53667. prime: 'p192',
  53668. p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff',
  53669. a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc',
  53670. b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1',
  53671. n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831',
  53672. hash: hash.sha256,
  53673. gRed: false,
  53674. g: [
  53675. '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012',
  53676. '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811'
  53677. ]
  53678. });
  53679. defineCurve('p224', {
  53680. type: 'short',
  53681. prime: 'p224',
  53682. p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001',
  53683. a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe',
  53684. b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4',
  53685. n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d',
  53686. hash: hash.sha256,
  53687. gRed: false,
  53688. g: [
  53689. 'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21',
  53690. 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34'
  53691. ]
  53692. });
  53693. defineCurve('p256', {
  53694. type: 'short',
  53695. prime: null,
  53696. p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff',
  53697. a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc',
  53698. b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b',
  53699. n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551',
  53700. hash: hash.sha256,
  53701. gRed: false,
  53702. g: [
  53703. '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296',
  53704. '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5'
  53705. ]
  53706. });
  53707. defineCurve('p384', {
  53708. type: 'short',
  53709. prime: null,
  53710. p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  53711. 'fffffffe ffffffff 00000000 00000000 ffffffff',
  53712. a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  53713. 'fffffffe ffffffff 00000000 00000000 fffffffc',
  53714. b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' +
  53715. '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef',
  53716. n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' +
  53717. 'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973',
  53718. hash: hash.sha384,
  53719. gRed: false,
  53720. g: [
  53721. 'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' +
  53722. '5502f25d bf55296c 3a545e38 72760ab7',
  53723. '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' +
  53724. '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f'
  53725. ]
  53726. });
  53727. defineCurve('p521', {
  53728. type: 'short',
  53729. prime: null,
  53730. p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  53731. 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  53732. 'ffffffff ffffffff ffffffff ffffffff ffffffff',
  53733. a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  53734. 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  53735. 'ffffffff ffffffff ffffffff ffffffff fffffffc',
  53736. b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' +
  53737. '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' +
  53738. '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00',
  53739. n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  53740. 'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' +
  53741. 'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409',
  53742. hash: hash.sha512,
  53743. gRed: false,
  53744. g: [
  53745. '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' +
  53746. '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' +
  53747. 'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66',
  53748. '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' +
  53749. '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' +
  53750. '3fad0761 353c7086 a272c240 88be9476 9fd16650'
  53751. ]
  53752. });
  53753. defineCurve('curve25519', {
  53754. type: 'mont',
  53755. prime: 'p25519',
  53756. p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
  53757. a: '76d06',
  53758. b: '0',
  53759. n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
  53760. hash: hash.sha256,
  53761. gRed: false,
  53762. g: [
  53763. '9'
  53764. ]
  53765. });
  53766. defineCurve('ed25519', {
  53767. type: 'edwards',
  53768. prime: 'p25519',
  53769. p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
  53770. a: '-1',
  53771. c: '1',
  53772. // -121665 * (121666^(-1)) (mod P)
  53773. d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3',
  53774. n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
  53775. hash: hash.sha256,
  53776. gRed: false,
  53777. g: [
  53778. '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a',
  53779. // 4/5
  53780. '6666666666666666666666666666666666666666666666666666666666666658'
  53781. ]
  53782. });
  53783. var pre;
  53784. try {
  53785. pre = __webpack_require__(498);
  53786. } catch (e) {
  53787. pre = undefined;
  53788. }
  53789. defineCurve('secp256k1', {
  53790. type: 'short',
  53791. prime: 'k256',
  53792. p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f',
  53793. a: '0',
  53794. b: '7',
  53795. n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141',
  53796. h: '1',
  53797. hash: hash.sha256,
  53798. // Precomputed endomorphism
  53799. beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee',
  53800. lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72',
  53801. basis: [
  53802. {
  53803. a: '3086d221a7d46bcde86c90e49284eb15',
  53804. b: '-e4437ed6010e88286f547fa90abfe4c3'
  53805. },
  53806. {
  53807. a: '114ca50f7a8e2f3f657c1108d9d44cfd8',
  53808. b: '3086d221a7d46bcde86c90e49284eb15'
  53809. }
  53810. ],
  53811. gRed: false,
  53812. g: [
  53813. '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
  53814. '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8',
  53815. pre
  53816. ]
  53817. });
  53818. /***/ },
  53819. /* 491 */
  53820. /***/ function(module, exports, __webpack_require__) {
  53821. "use strict";
  53822. 'use strict';
  53823. var BN = __webpack_require__(12);
  53824. var elliptic = __webpack_require__(20);
  53825. var utils = elliptic.utils;
  53826. var assert = utils.assert;
  53827. var KeyPair = __webpack_require__(492);
  53828. var Signature = __webpack_require__(493);
  53829. function EC(options) {
  53830. if (!(this instanceof EC))
  53831. return new EC(options);
  53832. // Shortcut `elliptic.ec(curve-name)`
  53833. if (typeof options === 'string') {
  53834. assert(elliptic.curves.hasOwnProperty(options), 'Unknown curve ' + options);
  53835. options = elliptic.curves[options];
  53836. }
  53837. // Shortcut for `elliptic.ec(elliptic.curves.curveName)`
  53838. if (options instanceof elliptic.curves.PresetCurve)
  53839. options = { curve: options };
  53840. this.curve = options.curve.curve;
  53841. this.n = this.curve.n;
  53842. this.nh = this.n.ushrn(1);
  53843. this.g = this.curve.g;
  53844. // Point on curve
  53845. this.g = options.curve.g;
  53846. this.g.precompute(options.curve.n.bitLength() + 1);
  53847. // Hash for function for DRBG
  53848. this.hash = options.hash || options.curve.hash;
  53849. }
  53850. module.exports = EC;
  53851. EC.prototype.keyPair = function keyPair(options) {
  53852. return new KeyPair(this, options);
  53853. };
  53854. EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) {
  53855. return KeyPair.fromPrivate(this, priv, enc);
  53856. };
  53857. EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) {
  53858. return KeyPair.fromPublic(this, pub, enc);
  53859. };
  53860. EC.prototype.genKeyPair = function genKeyPair(options) {
  53861. if (!options)
  53862. options = {};
  53863. // Instantiate Hmac_DRBG
  53864. var drbg = new elliptic.hmacDRBG({
  53865. hash: this.hash,
  53866. pers: options.pers,
  53867. entropy: options.entropy || elliptic.rand(this.hash.hmacStrength),
  53868. nonce: this.n.toArray()
  53869. });
  53870. var bytes = this.n.byteLength();
  53871. var ns2 = this.n.sub(new BN(2));
  53872. do {
  53873. var priv = new BN(drbg.generate(bytes));
  53874. if (priv.cmp(ns2) > 0)
  53875. continue;
  53876. priv.iaddn(1);
  53877. return this.keyFromPrivate(priv);
  53878. } while (true);
  53879. };
  53880. EC.prototype._truncateToN = function truncateToN(msg, truncOnly) {
  53881. var delta = msg.byteLength() * 8 - this.n.bitLength();
  53882. if (delta > 0)
  53883. msg = msg.ushrn(delta);
  53884. if (!truncOnly && msg.cmp(this.n) >= 0)
  53885. return msg.sub(this.n);
  53886. else
  53887. return msg;
  53888. };
  53889. EC.prototype.sign = function sign(msg, key, enc, options) {
  53890. if (typeof enc === 'object') {
  53891. options = enc;
  53892. enc = null;
  53893. }
  53894. if (!options)
  53895. options = {};
  53896. key = this.keyFromPrivate(key, enc);
  53897. msg = this._truncateToN(new BN(msg, 16));
  53898. // Zero-extend key to provide enough entropy
  53899. var bytes = this.n.byteLength();
  53900. var bkey = key.getPrivate().toArray('be', bytes);
  53901. // Zero-extend nonce to have the same byte size as N
  53902. var nonce = msg.toArray('be', bytes);
  53903. // Instantiate Hmac_DRBG
  53904. var drbg = new elliptic.hmacDRBG({
  53905. hash: this.hash,
  53906. entropy: bkey,
  53907. nonce: nonce,
  53908. pers: options.pers,
  53909. persEnc: options.persEnc
  53910. });
  53911. // Number of bytes to generate
  53912. var ns1 = this.n.sub(new BN(1));
  53913. for (var iter = 0; true; iter++) {
  53914. var k = options.k ?
  53915. options.k(iter) :
  53916. new BN(drbg.generate(this.n.byteLength()));
  53917. k = this._truncateToN(k, true);
  53918. if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0)
  53919. continue;
  53920. var kp = this.g.mul(k);
  53921. if (kp.isInfinity())
  53922. continue;
  53923. var kpX = kp.getX();
  53924. var r = kpX.umod(this.n);
  53925. if (r.cmpn(0) === 0)
  53926. continue;
  53927. var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg));
  53928. s = s.umod(this.n);
  53929. if (s.cmpn(0) === 0)
  53930. continue;
  53931. var recoveryParam = (kp.getY().isOdd() ? 1 : 0) |
  53932. (kpX.cmp(r) !== 0 ? 2 : 0);
  53933. // Use complement of `s`, if it is > `n / 2`
  53934. if (options.canonical && s.cmp(this.nh) > 0) {
  53935. s = this.n.sub(s);
  53936. recoveryParam ^= 1;
  53937. }
  53938. return new Signature({ r: r, s: s, recoveryParam: recoveryParam });
  53939. }
  53940. };
  53941. EC.prototype.verify = function verify(msg, signature, key, enc) {
  53942. msg = this._truncateToN(new BN(msg, 16));
  53943. key = this.keyFromPublic(key, enc);
  53944. signature = new Signature(signature, 'hex');
  53945. // Perform primitive values validation
  53946. var r = signature.r;
  53947. var s = signature.s;
  53948. if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0)
  53949. return false;
  53950. if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0)
  53951. return false;
  53952. // Validate signature
  53953. var sinv = s.invm(this.n);
  53954. var u1 = sinv.mul(msg).umod(this.n);
  53955. var u2 = sinv.mul(r).umod(this.n);
  53956. if (!this.curve._maxwellTrick) {
  53957. var p = this.g.mulAdd(u1, key.getPublic(), u2);
  53958. if (p.isInfinity())
  53959. return false;
  53960. return p.getX().umod(this.n).cmp(r) === 0;
  53961. }
  53962. // NOTE: Greg Maxwell's trick, inspired by:
  53963. // https://git.io/vad3K
  53964. var p = this.g.jmulAdd(u1, key.getPublic(), u2);
  53965. if (p.isInfinity())
  53966. return false;
  53967. // Compare `p.x` of Jacobian point with `r`,
  53968. // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the
  53969. // inverse of `p.z^2`
  53970. return p.eqXToP(r);
  53971. };
  53972. EC.prototype.recoverPubKey = function(msg, signature, j, enc) {
  53973. assert((3 & j) === j, 'The recovery param is more than two bits');
  53974. signature = new Signature(signature, enc);
  53975. var n = this.n;
  53976. var e = new BN(msg);
  53977. var r = signature.r;
  53978. var s = signature.s;
  53979. // A set LSB signifies that the y-coordinate is odd
  53980. var isYOdd = j & 1;
  53981. var isSecondKey = j >> 1;
  53982. if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey)
  53983. throw new Error('Unable to find sencond key candinate');
  53984. // 1.1. Let x = r + jn.
  53985. if (isSecondKey)
  53986. r = this.curve.pointFromX(r.add(this.curve.n), isYOdd);
  53987. else
  53988. r = this.curve.pointFromX(r, isYOdd);
  53989. var eNeg = n.sub(e);
  53990. // 1.6.1 Compute Q = r^-1 (sR - eG)
  53991. // Q = r^-1 (sR + -eG)
  53992. var rInv = signature.r.invm(n);
  53993. return this.g.mulAdd(eNeg, r, s).mul(rInv);
  53994. };
  53995. EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) {
  53996. signature = new Signature(signature, enc);
  53997. if (signature.recoveryParam !== null)
  53998. return signature.recoveryParam;
  53999. for (var i = 0; i < 4; i++) {
  54000. var Qprime;
  54001. try {
  54002. Qprime = this.recoverPubKey(e, signature, i);
  54003. } catch (e) {
  54004. continue;
  54005. }
  54006. if (Qprime.eq(Q))
  54007. return i;
  54008. }
  54009. throw new Error('Unable to find valid recovery factor');
  54010. };
  54011. /***/ },
  54012. /* 492 */
  54013. /***/ function(module, exports, __webpack_require__) {
  54014. "use strict";
  54015. 'use strict';
  54016. var BN = __webpack_require__(12);
  54017. function KeyPair(ec, options) {
  54018. this.ec = ec;
  54019. this.priv = null;
  54020. this.pub = null;
  54021. // KeyPair(ec, { priv: ..., pub: ... })
  54022. if (options.priv)
  54023. this._importPrivate(options.priv, options.privEnc);
  54024. if (options.pub)
  54025. this._importPublic(options.pub, options.pubEnc);
  54026. }
  54027. module.exports = KeyPair;
  54028. KeyPair.fromPublic = function fromPublic(ec, pub, enc) {
  54029. if (pub instanceof KeyPair)
  54030. return pub;
  54031. return new KeyPair(ec, {
  54032. pub: pub,
  54033. pubEnc: enc
  54034. });
  54035. };
  54036. KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) {
  54037. if (priv instanceof KeyPair)
  54038. return priv;
  54039. return new KeyPair(ec, {
  54040. priv: priv,
  54041. privEnc: enc
  54042. });
  54043. };
  54044. KeyPair.prototype.validate = function validate() {
  54045. var pub = this.getPublic();
  54046. if (pub.isInfinity())
  54047. return { result: false, reason: 'Invalid public key' };
  54048. if (!pub.validate())
  54049. return { result: false, reason: 'Public key is not a point' };
  54050. if (!pub.mul(this.ec.curve.n).isInfinity())
  54051. return { result: false, reason: 'Public key * N != O' };
  54052. return { result: true, reason: null };
  54053. };
  54054. KeyPair.prototype.getPublic = function getPublic(compact, enc) {
  54055. // compact is optional argument
  54056. if (typeof compact === 'string') {
  54057. enc = compact;
  54058. compact = null;
  54059. }
  54060. if (!this.pub)
  54061. this.pub = this.ec.g.mul(this.priv);
  54062. if (!enc)
  54063. return this.pub;
  54064. return this.pub.encode(enc, compact);
  54065. };
  54066. KeyPair.prototype.getPrivate = function getPrivate(enc) {
  54067. if (enc === 'hex')
  54068. return this.priv.toString(16, 2);
  54069. else
  54070. return this.priv;
  54071. };
  54072. KeyPair.prototype._importPrivate = function _importPrivate(key, enc) {
  54073. this.priv = new BN(key, enc || 16);
  54074. // Ensure that the priv won't be bigger than n, otherwise we may fail
  54075. // in fixed multiplication method
  54076. this.priv = this.priv.umod(this.ec.curve.n);
  54077. };
  54078. KeyPair.prototype._importPublic = function _importPublic(key, enc) {
  54079. if (key.x || key.y) {
  54080. this.pub = this.ec.curve.point(key.x, key.y);
  54081. return;
  54082. }
  54083. this.pub = this.ec.curve.decodePoint(key, enc);
  54084. };
  54085. // ECDH
  54086. KeyPair.prototype.derive = function derive(pub) {
  54087. return pub.mul(this.priv).getX();
  54088. };
  54089. // ECDSA
  54090. KeyPair.prototype.sign = function sign(msg, enc, options) {
  54091. return this.ec.sign(msg, this, enc, options);
  54092. };
  54093. KeyPair.prototype.verify = function verify(msg, signature) {
  54094. return this.ec.verify(msg, signature, this);
  54095. };
  54096. KeyPair.prototype.inspect = function inspect() {
  54097. return '<Key priv: ' + (this.priv && this.priv.toString(16, 2)) +
  54098. ' pub: ' + (this.pub && this.pub.inspect()) + ' >';
  54099. };
  54100. /***/ },
  54101. /* 493 */
  54102. /***/ function(module, exports, __webpack_require__) {
  54103. "use strict";
  54104. 'use strict';
  54105. var BN = __webpack_require__(12);
  54106. var elliptic = __webpack_require__(20);
  54107. var utils = elliptic.utils;
  54108. var assert = utils.assert;
  54109. function Signature(options, enc) {
  54110. if (options instanceof Signature)
  54111. return options;
  54112. if (this._importDER(options, enc))
  54113. return;
  54114. assert(options.r && options.s, 'Signature without r or s');
  54115. this.r = new BN(options.r, 16);
  54116. this.s = new BN(options.s, 16);
  54117. if (options.recoveryParam === undefined)
  54118. this.recoveryParam = null;
  54119. else
  54120. this.recoveryParam = options.recoveryParam;
  54121. }
  54122. module.exports = Signature;
  54123. function Position() {
  54124. this.place = 0;
  54125. }
  54126. function getLength(buf, p) {
  54127. var initial = buf[p.place++];
  54128. if (!(initial & 0x80)) {
  54129. return initial;
  54130. }
  54131. var octetLen = initial & 0xf;
  54132. var val = 0;
  54133. for (var i = 0, off = p.place; i < octetLen; i++, off++) {
  54134. val <<= 8;
  54135. val |= buf[off];
  54136. }
  54137. p.place = off;
  54138. return val;
  54139. }
  54140. function rmPadding(buf) {
  54141. var i = 0;
  54142. var len = buf.length - 1;
  54143. while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) {
  54144. i++;
  54145. }
  54146. if (i === 0) {
  54147. return buf;
  54148. }
  54149. return buf.slice(i);
  54150. }
  54151. Signature.prototype._importDER = function _importDER(data, enc) {
  54152. data = utils.toArray(data, enc);
  54153. var p = new Position();
  54154. if (data[p.place++] !== 0x30) {
  54155. return false;
  54156. }
  54157. var len = getLength(data, p);
  54158. if ((len + p.place) !== data.length) {
  54159. return false;
  54160. }
  54161. if (data[p.place++] !== 0x02) {
  54162. return false;
  54163. }
  54164. var rlen = getLength(data, p);
  54165. var r = data.slice(p.place, rlen + p.place);
  54166. p.place += rlen;
  54167. if (data[p.place++] !== 0x02) {
  54168. return false;
  54169. }
  54170. var slen = getLength(data, p);
  54171. if (data.length !== slen + p.place) {
  54172. return false;
  54173. }
  54174. var s = data.slice(p.place, slen + p.place);
  54175. if (r[0] === 0 && (r[1] & 0x80)) {
  54176. r = r.slice(1);
  54177. }
  54178. if (s[0] === 0 && (s[1] & 0x80)) {
  54179. s = s.slice(1);
  54180. }
  54181. this.r = new BN(r);
  54182. this.s = new BN(s);
  54183. this.recoveryParam = null;
  54184. return true;
  54185. };
  54186. function constructLength(arr, len) {
  54187. if (len < 0x80) {
  54188. arr.push(len);
  54189. return;
  54190. }
  54191. var octets = 1 + (Math.log(len) / Math.LN2 >>> 3);
  54192. arr.push(octets | 0x80);
  54193. while (--octets) {
  54194. arr.push((len >>> (octets << 3)) & 0xff);
  54195. }
  54196. arr.push(len);
  54197. }
  54198. Signature.prototype.toDER = function toDER(enc) {
  54199. var r = this.r.toArray();
  54200. var s = this.s.toArray();
  54201. // Pad values
  54202. if (r[0] & 0x80)
  54203. r = [ 0 ].concat(r);
  54204. // Pad values
  54205. if (s[0] & 0x80)
  54206. s = [ 0 ].concat(s);
  54207. r = rmPadding(r);
  54208. s = rmPadding(s);
  54209. while (!s[0] && !(s[1] & 0x80)) {
  54210. s = s.slice(1);
  54211. }
  54212. var arr = [ 0x02 ];
  54213. constructLength(arr, r.length);
  54214. arr = arr.concat(r);
  54215. arr.push(0x02);
  54216. constructLength(arr, s.length);
  54217. var backHalf = arr.concat(s);
  54218. var res = [ 0x30 ];
  54219. constructLength(res, backHalf.length);
  54220. res = res.concat(backHalf);
  54221. return utils.encode(res, enc);
  54222. };
  54223. /***/ },
  54224. /* 494 */
  54225. /***/ function(module, exports, __webpack_require__) {
  54226. "use strict";
  54227. 'use strict';
  54228. var hash = __webpack_require__(54);
  54229. var elliptic = __webpack_require__(20);
  54230. var utils = elliptic.utils;
  54231. var assert = utils.assert;
  54232. var parseBytes = utils.parseBytes;
  54233. var KeyPair = __webpack_require__(495);
  54234. var Signature = __webpack_require__(496);
  54235. function EDDSA(curve) {
  54236. assert(curve === 'ed25519', 'only tested with ed25519 so far');
  54237. if (!(this instanceof EDDSA))
  54238. return new EDDSA(curve);
  54239. var curve = elliptic.curves[curve].curve;
  54240. this.curve = curve;
  54241. this.g = curve.g;
  54242. this.g.precompute(curve.n.bitLength() + 1);
  54243. this.pointClass = curve.point().constructor;
  54244. this.encodingLength = Math.ceil(curve.n.bitLength() / 8);
  54245. this.hash = hash.sha512;
  54246. }
  54247. module.exports = EDDSA;
  54248. /**
  54249. * @param {Array|String} message - message bytes
  54250. * @param {Array|String|KeyPair} secret - secret bytes or a keypair
  54251. * @returns {Signature} - signature
  54252. */
  54253. EDDSA.prototype.sign = function sign(message, secret) {
  54254. message = parseBytes(message);
  54255. var key = this.keyFromSecret(secret);
  54256. var r = this.hashInt(key.messagePrefix(), message);
  54257. var R = this.g.mul(r);
  54258. var Rencoded = this.encodePoint(R);
  54259. var s_ = this.hashInt(Rencoded, key.pubBytes(), message)
  54260. .mul(key.priv());
  54261. var S = r.add(s_).umod(this.curve.n);
  54262. return this.makeSignature({ R: R, S: S, Rencoded: Rencoded });
  54263. };
  54264. /**
  54265. * @param {Array} message - message bytes
  54266. * @param {Array|String|Signature} sig - sig bytes
  54267. * @param {Array|String|Point|KeyPair} pub - public key
  54268. * @returns {Boolean} - true if public key matches sig of message
  54269. */
  54270. EDDSA.prototype.verify = function verify(message, sig, pub) {
  54271. message = parseBytes(message);
  54272. sig = this.makeSignature(sig);
  54273. var key = this.keyFromPublic(pub);
  54274. var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message);
  54275. var SG = this.g.mul(sig.S());
  54276. var RplusAh = sig.R().add(key.pub().mul(h));
  54277. return RplusAh.eq(SG);
  54278. };
  54279. EDDSA.prototype.hashInt = function hashInt() {
  54280. var hash = this.hash();
  54281. for (var i = 0; i < arguments.length; i++)
  54282. hash.update(arguments[i]);
  54283. return utils.intFromLE(hash.digest()).umod(this.curve.n);
  54284. };
  54285. EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) {
  54286. return KeyPair.fromPublic(this, pub);
  54287. };
  54288. EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) {
  54289. return KeyPair.fromSecret(this, secret);
  54290. };
  54291. EDDSA.prototype.makeSignature = function makeSignature(sig) {
  54292. if (sig instanceof Signature)
  54293. return sig;
  54294. return new Signature(this, sig);
  54295. };
  54296. /**
  54297. * * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2
  54298. *
  54299. * EDDSA defines methods for encoding and decoding points and integers. These are
  54300. * helper convenience methods, that pass along to utility functions implied
  54301. * parameters.
  54302. *
  54303. */
  54304. EDDSA.prototype.encodePoint = function encodePoint(point) {
  54305. var enc = point.getY().toArray('le', this.encodingLength);
  54306. enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0;
  54307. return enc;
  54308. };
  54309. EDDSA.prototype.decodePoint = function decodePoint(bytes) {
  54310. bytes = utils.parseBytes(bytes);
  54311. var lastIx = bytes.length - 1;
  54312. var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80);
  54313. var xIsOdd = (bytes[lastIx] & 0x80) !== 0;
  54314. var y = utils.intFromLE(normed);
  54315. return this.curve.pointFromY(y, xIsOdd);
  54316. };
  54317. EDDSA.prototype.encodeInt = function encodeInt(num) {
  54318. return num.toArray('le', this.encodingLength);
  54319. };
  54320. EDDSA.prototype.decodeInt = function decodeInt(bytes) {
  54321. return utils.intFromLE(bytes);
  54322. };
  54323. EDDSA.prototype.isPoint = function isPoint(val) {
  54324. return val instanceof this.pointClass;
  54325. };
  54326. /***/ },
  54327. /* 495 */
  54328. /***/ function(module, exports, __webpack_require__) {
  54329. "use strict";
  54330. 'use strict';
  54331. var elliptic = __webpack_require__(20);
  54332. var utils = elliptic.utils;
  54333. var assert = utils.assert;
  54334. var parseBytes = utils.parseBytes;
  54335. var cachedProperty = utils.cachedProperty;
  54336. /**
  54337. * @param {EDDSA} eddsa - instance
  54338. * @param {Object} params - public/private key parameters
  54339. *
  54340. * @param {Array<Byte>} [params.secret] - secret seed bytes
  54341. * @param {Point} [params.pub] - public key point (aka `A` in eddsa terms)
  54342. * @param {Array<Byte>} [params.pub] - public key point encoded as bytes
  54343. *
  54344. */
  54345. function KeyPair(eddsa, params) {
  54346. this.eddsa = eddsa;
  54347. this._secret = parseBytes(params.secret);
  54348. if (eddsa.isPoint(params.pub))
  54349. this._pub = params.pub;
  54350. else
  54351. this._pubBytes = parseBytes(params.pub);
  54352. }
  54353. KeyPair.fromPublic = function fromPublic(eddsa, pub) {
  54354. if (pub instanceof KeyPair)
  54355. return pub;
  54356. return new KeyPair(eddsa, { pub: pub });
  54357. };
  54358. KeyPair.fromSecret = function fromSecret(eddsa, secret) {
  54359. if (secret instanceof KeyPair)
  54360. return secret;
  54361. return new KeyPair(eddsa, { secret: secret });
  54362. };
  54363. KeyPair.prototype.secret = function secret() {
  54364. return this._secret;
  54365. };
  54366. cachedProperty(KeyPair, 'pubBytes', function pubBytes() {
  54367. return this.eddsa.encodePoint(this.pub());
  54368. });
  54369. cachedProperty(KeyPair, 'pub', function pub() {
  54370. if (this._pubBytes)
  54371. return this.eddsa.decodePoint(this._pubBytes);
  54372. return this.eddsa.g.mul(this.priv());
  54373. });
  54374. cachedProperty(KeyPair, 'privBytes', function privBytes() {
  54375. var eddsa = this.eddsa;
  54376. var hash = this.hash();
  54377. var lastIx = eddsa.encodingLength - 1;
  54378. var a = hash.slice(0, eddsa.encodingLength);
  54379. a[0] &= 248;
  54380. a[lastIx] &= 127;
  54381. a[lastIx] |= 64;
  54382. return a;
  54383. });
  54384. cachedProperty(KeyPair, 'priv', function priv() {
  54385. return this.eddsa.decodeInt(this.privBytes());
  54386. });
  54387. cachedProperty(KeyPair, 'hash', function hash() {
  54388. return this.eddsa.hash().update(this.secret()).digest();
  54389. });
  54390. cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() {
  54391. return this.hash().slice(this.eddsa.encodingLength);
  54392. });
  54393. KeyPair.prototype.sign = function sign(message) {
  54394. assert(this._secret, 'KeyPair can only verify');
  54395. return this.eddsa.sign(message, this);
  54396. };
  54397. KeyPair.prototype.verify = function verify(message, sig) {
  54398. return this.eddsa.verify(message, sig, this);
  54399. };
  54400. KeyPair.prototype.getSecret = function getSecret(enc) {
  54401. assert(this._secret, 'KeyPair is public only');
  54402. return utils.encode(this.secret(), enc);
  54403. };
  54404. KeyPair.prototype.getPublic = function getPublic(enc) {
  54405. return utils.encode(this.pubBytes(), enc);
  54406. };
  54407. module.exports = KeyPair;
  54408. /***/ },
  54409. /* 496 */
  54410. /***/ function(module, exports, __webpack_require__) {
  54411. "use strict";
  54412. 'use strict';
  54413. var BN = __webpack_require__(12);
  54414. var elliptic = __webpack_require__(20);
  54415. var utils = elliptic.utils;
  54416. var assert = utils.assert;
  54417. var cachedProperty = utils.cachedProperty;
  54418. var parseBytes = utils.parseBytes;
  54419. /**
  54420. * @param {EDDSA} eddsa - eddsa instance
  54421. * @param {Array<Bytes>|Object} sig -
  54422. * @param {Array<Bytes>|Point} [sig.R] - R point as Point or bytes
  54423. * @param {Array<Bytes>|bn} [sig.S] - S scalar as bn or bytes
  54424. * @param {Array<Bytes>} [sig.Rencoded] - R point encoded
  54425. * @param {Array<Bytes>} [sig.Sencoded] - S scalar encoded
  54426. */
  54427. function Signature(eddsa, sig) {
  54428. this.eddsa = eddsa;
  54429. if (typeof sig !== 'object')
  54430. sig = parseBytes(sig);
  54431. if (Array.isArray(sig)) {
  54432. sig = {
  54433. R: sig.slice(0, eddsa.encodingLength),
  54434. S: sig.slice(eddsa.encodingLength)
  54435. };
  54436. }
  54437. assert(sig.R && sig.S, 'Signature without R or S');
  54438. if (eddsa.isPoint(sig.R))
  54439. this._R = sig.R;
  54440. if (sig.S instanceof BN)
  54441. this._S = sig.S;
  54442. this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded;
  54443. this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded;
  54444. }
  54445. cachedProperty(Signature, 'S', function S() {
  54446. return this.eddsa.decodeInt(this.Sencoded());
  54447. });
  54448. cachedProperty(Signature, 'R', function R() {
  54449. return this.eddsa.decodePoint(this.Rencoded());
  54450. });
  54451. cachedProperty(Signature, 'Rencoded', function Rencoded() {
  54452. return this.eddsa.encodePoint(this.R());
  54453. });
  54454. cachedProperty(Signature, 'Sencoded', function Sencoded() {
  54455. return this.eddsa.encodeInt(this.S());
  54456. });
  54457. Signature.prototype.toBytes = function toBytes() {
  54458. return this.Rencoded().concat(this.Sencoded());
  54459. };
  54460. Signature.prototype.toHex = function toHex() {
  54461. return utils.encode(this.toBytes(), 'hex').toUpperCase();
  54462. };
  54463. module.exports = Signature;
  54464. /***/ },
  54465. /* 497 */
  54466. /***/ function(module, exports, __webpack_require__) {
  54467. "use strict";
  54468. 'use strict';
  54469. var hash = __webpack_require__(54);
  54470. var elliptic = __webpack_require__(20);
  54471. var utils = elliptic.utils;
  54472. var assert = utils.assert;
  54473. function HmacDRBG(options) {
  54474. if (!(this instanceof HmacDRBG))
  54475. return new HmacDRBG(options);
  54476. this.hash = options.hash;
  54477. this.predResist = !!options.predResist;
  54478. this.outLen = this.hash.outSize;
  54479. this.minEntropy = options.minEntropy || this.hash.hmacStrength;
  54480. this.reseed = null;
  54481. this.reseedInterval = null;
  54482. this.K = null;
  54483. this.V = null;
  54484. var entropy = utils.toArray(options.entropy, options.entropyEnc);
  54485. var nonce = utils.toArray(options.nonce, options.nonceEnc);
  54486. var pers = utils.toArray(options.pers, options.persEnc);
  54487. assert(entropy.length >= (this.minEntropy / 8),
  54488. 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
  54489. this._init(entropy, nonce, pers);
  54490. }
  54491. module.exports = HmacDRBG;
  54492. HmacDRBG.prototype._init = function init(entropy, nonce, pers) {
  54493. var seed = entropy.concat(nonce).concat(pers);
  54494. this.K = new Array(this.outLen / 8);
  54495. this.V = new Array(this.outLen / 8);
  54496. for (var i = 0; i < this.V.length; i++) {
  54497. this.K[i] = 0x00;
  54498. this.V[i] = 0x01;
  54499. }
  54500. this._update(seed);
  54501. this.reseed = 1;
  54502. this.reseedInterval = 0x1000000000000; // 2^48
  54503. };
  54504. HmacDRBG.prototype._hmac = function hmac() {
  54505. return new hash.hmac(this.hash, this.K);
  54506. };
  54507. HmacDRBG.prototype._update = function update(seed) {
  54508. var kmac = this._hmac()
  54509. .update(this.V)
  54510. .update([ 0x00 ]);
  54511. if (seed)
  54512. kmac = kmac.update(seed);
  54513. this.K = kmac.digest();
  54514. this.V = this._hmac().update(this.V).digest();
  54515. if (!seed)
  54516. return;
  54517. this.K = this._hmac()
  54518. .update(this.V)
  54519. .update([ 0x01 ])
  54520. .update(seed)
  54521. .digest();
  54522. this.V = this._hmac().update(this.V).digest();
  54523. };
  54524. HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc) {
  54525. // Optional entropy enc
  54526. if (typeof entropyEnc !== 'string') {
  54527. addEnc = add;
  54528. add = entropyEnc;
  54529. entropyEnc = null;
  54530. }
  54531. entropy = utils.toBuffer(entropy, entropyEnc);
  54532. add = utils.toBuffer(add, addEnc);
  54533. assert(entropy.length >= (this.minEntropy / 8),
  54534. 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
  54535. this._update(entropy.concat(add || []));
  54536. this.reseed = 1;
  54537. };
  54538. HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) {
  54539. if (this.reseed > this.reseedInterval)
  54540. throw new Error('Reseed is required');
  54541. // Optional encoding
  54542. if (typeof enc !== 'string') {
  54543. addEnc = add;
  54544. add = enc;
  54545. enc = null;
  54546. }
  54547. // Optional additional data
  54548. if (add) {
  54549. add = utils.toArray(add, addEnc);
  54550. this._update(add);
  54551. }
  54552. var temp = [];
  54553. while (temp.length < len) {
  54554. this.V = this._hmac().update(this.V).digest();
  54555. temp = temp.concat(this.V);
  54556. }
  54557. var res = temp.slice(0, len);
  54558. this._update(add);
  54559. this.reseed++;
  54560. return utils.encode(res, enc);
  54561. };
  54562. /***/ },
  54563. /* 498 */
  54564. /***/ function(module, exports) {
  54565. module.exports = {
  54566. doubles: {
  54567. step: 4,
  54568. points: [
  54569. [
  54570. 'e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a',
  54571. 'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821'
  54572. ],
  54573. [
  54574. '8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508',
  54575. '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf'
  54576. ],
  54577. [
  54578. '175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739',
  54579. 'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695'
  54580. ],
  54581. [
  54582. '363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640',
  54583. '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9'
  54584. ],
  54585. [
  54586. '8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c',
  54587. '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36'
  54588. ],
  54589. [
  54590. '723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda',
  54591. '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f'
  54592. ],
  54593. [
  54594. 'eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa',
  54595. '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999'
  54596. ],
  54597. [
  54598. '100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0',
  54599. 'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09'
  54600. ],
  54601. [
  54602. 'e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d',
  54603. '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d'
  54604. ],
  54605. [
  54606. 'feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d',
  54607. 'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088'
  54608. ],
  54609. [
  54610. 'da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1',
  54611. '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d'
  54612. ],
  54613. [
  54614. '53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0',
  54615. '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8'
  54616. ],
  54617. [
  54618. '8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047',
  54619. '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a'
  54620. ],
  54621. [
  54622. '385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862',
  54623. '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453'
  54624. ],
  54625. [
  54626. '6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7',
  54627. '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160'
  54628. ],
  54629. [
  54630. '3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd',
  54631. '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0'
  54632. ],
  54633. [
  54634. '85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83',
  54635. '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6'
  54636. ],
  54637. [
  54638. '948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a',
  54639. '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589'
  54640. ],
  54641. [
  54642. '6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8',
  54643. 'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17'
  54644. ],
  54645. [
  54646. 'e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d',
  54647. '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda'
  54648. ],
  54649. [
  54650. 'e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725',
  54651. '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd'
  54652. ],
  54653. [
  54654. '213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754',
  54655. '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2'
  54656. ],
  54657. [
  54658. '4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c',
  54659. '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6'
  54660. ],
  54661. [
  54662. 'fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6',
  54663. '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f'
  54664. ],
  54665. [
  54666. '76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39',
  54667. 'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01'
  54668. ],
  54669. [
  54670. 'c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891',
  54671. '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3'
  54672. ],
  54673. [
  54674. 'd895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b',
  54675. 'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f'
  54676. ],
  54677. [
  54678. 'b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03',
  54679. '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7'
  54680. ],
  54681. [
  54682. 'e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d',
  54683. 'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78'
  54684. ],
  54685. [
  54686. 'a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070',
  54687. '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1'
  54688. ],
  54689. [
  54690. '90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4',
  54691. 'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150'
  54692. ],
  54693. [
  54694. '8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da',
  54695. '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82'
  54696. ],
  54697. [
  54698. 'e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11',
  54699. '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc'
  54700. ],
  54701. [
  54702. '8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e',
  54703. 'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b'
  54704. ],
  54705. [
  54706. 'e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41',
  54707. '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51'
  54708. ],
  54709. [
  54710. 'b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef',
  54711. '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45'
  54712. ],
  54713. [
  54714. 'd68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8',
  54715. 'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120'
  54716. ],
  54717. [
  54718. '324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d',
  54719. '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84'
  54720. ],
  54721. [
  54722. '4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96',
  54723. '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d'
  54724. ],
  54725. [
  54726. '9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd',
  54727. 'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d'
  54728. ],
  54729. [
  54730. '6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5',
  54731. '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8'
  54732. ],
  54733. [
  54734. 'a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266',
  54735. '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8'
  54736. ],
  54737. [
  54738. '7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71',
  54739. '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac'
  54740. ],
  54741. [
  54742. '928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac',
  54743. 'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f'
  54744. ],
  54745. [
  54746. '85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751',
  54747. '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962'
  54748. ],
  54749. [
  54750. 'ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e',
  54751. '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907'
  54752. ],
  54753. [
  54754. '827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241',
  54755. 'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec'
  54756. ],
  54757. [
  54758. 'eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3',
  54759. 'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d'
  54760. ],
  54761. [
  54762. 'e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f',
  54763. '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414'
  54764. ],
  54765. [
  54766. '1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19',
  54767. 'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd'
  54768. ],
  54769. [
  54770. '146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be',
  54771. 'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0'
  54772. ],
  54773. [
  54774. 'fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9',
  54775. '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811'
  54776. ],
  54777. [
  54778. 'da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2',
  54779. '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1'
  54780. ],
  54781. [
  54782. 'a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13',
  54783. '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c'
  54784. ],
  54785. [
  54786. '174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c',
  54787. 'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73'
  54788. ],
  54789. [
  54790. '959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba',
  54791. '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd'
  54792. ],
  54793. [
  54794. 'd2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151',
  54795. 'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405'
  54796. ],
  54797. [
  54798. '64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073',
  54799. 'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589'
  54800. ],
  54801. [
  54802. '8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458',
  54803. '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e'
  54804. ],
  54805. [
  54806. '13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b',
  54807. '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27'
  54808. ],
  54809. [
  54810. 'bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366',
  54811. 'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1'
  54812. ],
  54813. [
  54814. '8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa',
  54815. '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482'
  54816. ],
  54817. [
  54818. '8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0',
  54819. '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945'
  54820. ],
  54821. [
  54822. 'dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787',
  54823. '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573'
  54824. ],
  54825. [
  54826. 'f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e',
  54827. 'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82'
  54828. ]
  54829. ]
  54830. },
  54831. naf: {
  54832. wnd: 7,
  54833. points: [
  54834. [
  54835. 'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9',
  54836. '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672'
  54837. ],
  54838. [
  54839. '2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4',
  54840. 'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6'
  54841. ],
  54842. [
  54843. '5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc',
  54844. '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da'
  54845. ],
  54846. [
  54847. 'acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe',
  54848. 'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37'
  54849. ],
  54850. [
  54851. '774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb',
  54852. 'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b'
  54853. ],
  54854. [
  54855. 'f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8',
  54856. 'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81'
  54857. ],
  54858. [
  54859. 'd7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e',
  54860. '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58'
  54861. ],
  54862. [
  54863. 'defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34',
  54864. '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77'
  54865. ],
  54866. [
  54867. '2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c',
  54868. '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a'
  54869. ],
  54870. [
  54871. '352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5',
  54872. '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c'
  54873. ],
  54874. [
  54875. '2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f',
  54876. '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67'
  54877. ],
  54878. [
  54879. '9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714',
  54880. '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402'
  54881. ],
  54882. [
  54883. 'daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729',
  54884. 'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55'
  54885. ],
  54886. [
  54887. 'c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db',
  54888. '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482'
  54889. ],
  54890. [
  54891. '6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4',
  54892. 'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82'
  54893. ],
  54894. [
  54895. '1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5',
  54896. 'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396'
  54897. ],
  54898. [
  54899. '605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479',
  54900. '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49'
  54901. ],
  54902. [
  54903. '62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d',
  54904. '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf'
  54905. ],
  54906. [
  54907. '80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f',
  54908. '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a'
  54909. ],
  54910. [
  54911. '7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb',
  54912. 'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7'
  54913. ],
  54914. [
  54915. 'd528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9',
  54916. 'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933'
  54917. ],
  54918. [
  54919. '49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963',
  54920. '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a'
  54921. ],
  54922. [
  54923. '77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74',
  54924. '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6'
  54925. ],
  54926. [
  54927. 'f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530',
  54928. 'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37'
  54929. ],
  54930. [
  54931. '463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b',
  54932. '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e'
  54933. ],
  54934. [
  54935. 'f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247',
  54936. 'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6'
  54937. ],
  54938. [
  54939. 'caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1',
  54940. 'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476'
  54941. ],
  54942. [
  54943. '2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120',
  54944. '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40'
  54945. ],
  54946. [
  54947. '7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435',
  54948. '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61'
  54949. ],
  54950. [
  54951. '754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18',
  54952. '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683'
  54953. ],
  54954. [
  54955. 'e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8',
  54956. '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5'
  54957. ],
  54958. [
  54959. '186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb',
  54960. '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b'
  54961. ],
  54962. [
  54963. 'df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f',
  54964. '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417'
  54965. ],
  54966. [
  54967. '5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143',
  54968. 'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868'
  54969. ],
  54970. [
  54971. '290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba',
  54972. 'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a'
  54973. ],
  54974. [
  54975. 'af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45',
  54976. 'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6'
  54977. ],
  54978. [
  54979. '766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a',
  54980. '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996'
  54981. ],
  54982. [
  54983. '59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e',
  54984. 'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e'
  54985. ],
  54986. [
  54987. 'f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8',
  54988. 'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d'
  54989. ],
  54990. [
  54991. '7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c',
  54992. '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2'
  54993. ],
  54994. [
  54995. '948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519',
  54996. 'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e'
  54997. ],
  54998. [
  54999. '7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab',
  55000. '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437'
  55001. ],
  55002. [
  55003. '3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca',
  55004. 'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311'
  55005. ],
  55006. [
  55007. 'd3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf',
  55008. '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4'
  55009. ],
  55010. [
  55011. '1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610',
  55012. '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575'
  55013. ],
  55014. [
  55015. '733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4',
  55016. 'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d'
  55017. ],
  55018. [
  55019. '15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c',
  55020. 'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d'
  55021. ],
  55022. [
  55023. 'a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940',
  55024. 'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629'
  55025. ],
  55026. [
  55027. 'e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980',
  55028. 'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06'
  55029. ],
  55030. [
  55031. '311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3',
  55032. '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374'
  55033. ],
  55034. [
  55035. '34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf',
  55036. '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee'
  55037. ],
  55038. [
  55039. 'f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63',
  55040. '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1'
  55041. ],
  55042. [
  55043. 'd7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448',
  55044. 'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b'
  55045. ],
  55046. [
  55047. '32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf',
  55048. '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661'
  55049. ],
  55050. [
  55051. '7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5',
  55052. '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6'
  55053. ],
  55054. [
  55055. 'ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6',
  55056. '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e'
  55057. ],
  55058. [
  55059. '16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5',
  55060. '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d'
  55061. ],
  55062. [
  55063. 'eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99',
  55064. 'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc'
  55065. ],
  55066. [
  55067. '78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51',
  55068. 'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4'
  55069. ],
  55070. [
  55071. '494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5',
  55072. '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c'
  55073. ],
  55074. [
  55075. 'a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5',
  55076. '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b'
  55077. ],
  55078. [
  55079. 'c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997',
  55080. '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913'
  55081. ],
  55082. [
  55083. '841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881',
  55084. '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154'
  55085. ],
  55086. [
  55087. '5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5',
  55088. '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865'
  55089. ],
  55090. [
  55091. '36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66',
  55092. 'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc'
  55093. ],
  55094. [
  55095. '336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726',
  55096. 'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224'
  55097. ],
  55098. [
  55099. '8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede',
  55100. '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e'
  55101. ],
  55102. [
  55103. '1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94',
  55104. '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6'
  55105. ],
  55106. [
  55107. '85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31',
  55108. '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511'
  55109. ],
  55110. [
  55111. '29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51',
  55112. 'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b'
  55113. ],
  55114. [
  55115. 'a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252',
  55116. 'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2'
  55117. ],
  55118. [
  55119. '4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5',
  55120. 'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c'
  55121. ],
  55122. [
  55123. 'd24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b',
  55124. '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3'
  55125. ],
  55126. [
  55127. 'ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4',
  55128. '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d'
  55129. ],
  55130. [
  55131. 'af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f',
  55132. '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700'
  55133. ],
  55134. [
  55135. 'e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889',
  55136. '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4'
  55137. ],
  55138. [
  55139. '591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246',
  55140. 'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196'
  55141. ],
  55142. [
  55143. '11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984',
  55144. '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4'
  55145. ],
  55146. [
  55147. '3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a',
  55148. 'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257'
  55149. ],
  55150. [
  55151. 'cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030',
  55152. 'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13'
  55153. ],
  55154. [
  55155. 'c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197',
  55156. '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096'
  55157. ],
  55158. [
  55159. 'c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593',
  55160. 'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38'
  55161. ],
  55162. [
  55163. 'a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef',
  55164. '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f'
  55165. ],
  55166. [
  55167. '347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38',
  55168. '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448'
  55169. ],
  55170. [
  55171. 'da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a',
  55172. '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a'
  55173. ],
  55174. [
  55175. 'c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111',
  55176. '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4'
  55177. ],
  55178. [
  55179. '4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502',
  55180. '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437'
  55181. ],
  55182. [
  55183. '3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea',
  55184. 'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7'
  55185. ],
  55186. [
  55187. 'cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26',
  55188. '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d'
  55189. ],
  55190. [
  55191. 'b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986',
  55192. '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a'
  55193. ],
  55194. [
  55195. 'd4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e',
  55196. '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54'
  55197. ],
  55198. [
  55199. '48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4',
  55200. '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77'
  55201. ],
  55202. [
  55203. 'dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda',
  55204. 'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517'
  55205. ],
  55206. [
  55207. '6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859',
  55208. 'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10'
  55209. ],
  55210. [
  55211. 'e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f',
  55212. 'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125'
  55213. ],
  55214. [
  55215. 'eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c',
  55216. '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e'
  55217. ],
  55218. [
  55219. '13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942',
  55220. 'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1'
  55221. ],
  55222. [
  55223. 'ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a',
  55224. '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2'
  55225. ],
  55226. [
  55227. 'b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80',
  55228. '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423'
  55229. ],
  55230. [
  55231. 'ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d',
  55232. '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8'
  55233. ],
  55234. [
  55235. '8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1',
  55236. 'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758'
  55237. ],
  55238. [
  55239. '52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63',
  55240. 'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375'
  55241. ],
  55242. [
  55243. 'e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352',
  55244. '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d'
  55245. ],
  55246. [
  55247. '7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193',
  55248. 'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec'
  55249. ],
  55250. [
  55251. '5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00',
  55252. '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0'
  55253. ],
  55254. [
  55255. '32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58',
  55256. 'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c'
  55257. ],
  55258. [
  55259. 'e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7',
  55260. 'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4'
  55261. ],
  55262. [
  55263. '8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8',
  55264. 'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f'
  55265. ],
  55266. [
  55267. '4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e',
  55268. '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649'
  55269. ],
  55270. [
  55271. '3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d',
  55272. 'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826'
  55273. ],
  55274. [
  55275. '674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b',
  55276. '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5'
  55277. ],
  55278. [
  55279. 'd32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f',
  55280. 'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87'
  55281. ],
  55282. [
  55283. '30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6',
  55284. '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b'
  55285. ],
  55286. [
  55287. 'be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297',
  55288. '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc'
  55289. ],
  55290. [
  55291. '93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a',
  55292. '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c'
  55293. ],
  55294. [
  55295. 'b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c',
  55296. 'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f'
  55297. ],
  55298. [
  55299. 'd5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52',
  55300. '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a'
  55301. ],
  55302. [
  55303. 'd3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb',
  55304. 'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46'
  55305. ],
  55306. [
  55307. '463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065',
  55308. 'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f'
  55309. ],
  55310. [
  55311. '7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917',
  55312. '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03'
  55313. ],
  55314. [
  55315. '74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9',
  55316. 'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08'
  55317. ],
  55318. [
  55319. '30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3',
  55320. '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8'
  55321. ],
  55322. [
  55323. '9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57',
  55324. '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373'
  55325. ],
  55326. [
  55327. '176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66',
  55328. 'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3'
  55329. ],
  55330. [
  55331. '75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8',
  55332. '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8'
  55333. ],
  55334. [
  55335. '809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721',
  55336. '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1'
  55337. ],
  55338. [
  55339. '1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180',
  55340. '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9'
  55341. ]
  55342. ]
  55343. }
  55344. };
  55345. /***/ },
  55346. /* 499 */
  55347. /***/ function(module, exports, __webpack_require__) {
  55348. "use strict";
  55349. 'use strict';
  55350. var utils = exports;
  55351. var BN = __webpack_require__(12);
  55352. utils.assert = function assert(val, msg) {
  55353. if (!val)
  55354. throw new Error(msg || 'Assertion failed');
  55355. };
  55356. function toArray(msg, enc) {
  55357. if (Array.isArray(msg))
  55358. return msg.slice();
  55359. if (!msg)
  55360. return [];
  55361. var res = [];
  55362. if (typeof msg !== 'string') {
  55363. for (var i = 0; i < msg.length; i++)
  55364. res[i] = msg[i] | 0;
  55365. return res;
  55366. }
  55367. if (!enc) {
  55368. for (var i = 0; i < msg.length; i++) {
  55369. var c = msg.charCodeAt(i);
  55370. var hi = c >> 8;
  55371. var lo = c & 0xff;
  55372. if (hi)
  55373. res.push(hi, lo);
  55374. else
  55375. res.push(lo);
  55376. }
  55377. } else if (enc === 'hex') {
  55378. msg = msg.replace(/[^a-z0-9]+/ig, '');
  55379. if (msg.length % 2 !== 0)
  55380. msg = '0' + msg;
  55381. for (var i = 0; i < msg.length; i += 2)
  55382. res.push(parseInt(msg[i] + msg[i + 1], 16));
  55383. }
  55384. return res;
  55385. }
  55386. utils.toArray = toArray;
  55387. function zero2(word) {
  55388. if (word.length === 1)
  55389. return '0' + word;
  55390. else
  55391. return word;
  55392. }
  55393. utils.zero2 = zero2;
  55394. function toHex(msg) {
  55395. var res = '';
  55396. for (var i = 0; i < msg.length; i++)
  55397. res += zero2(msg[i].toString(16));
  55398. return res;
  55399. }
  55400. utils.toHex = toHex;
  55401. utils.encode = function encode(arr, enc) {
  55402. if (enc === 'hex')
  55403. return toHex(arr);
  55404. else
  55405. return arr;
  55406. };
  55407. // Represent num in a w-NAF form
  55408. function getNAF(num, w) {
  55409. var naf = [];
  55410. var ws = 1 << (w + 1);
  55411. var k = num.clone();
  55412. while (k.cmpn(1) >= 0) {
  55413. var z;
  55414. if (k.isOdd()) {
  55415. var mod = k.andln(ws - 1);
  55416. if (mod > (ws >> 1) - 1)
  55417. z = (ws >> 1) - mod;
  55418. else
  55419. z = mod;
  55420. k.isubn(z);
  55421. } else {
  55422. z = 0;
  55423. }
  55424. naf.push(z);
  55425. // Optimization, shift by word if possible
  55426. var shift = (k.cmpn(0) !== 0 && k.andln(ws - 1) === 0) ? (w + 1) : 1;
  55427. for (var i = 1; i < shift; i++)
  55428. naf.push(0);
  55429. k.iushrn(shift);
  55430. }
  55431. return naf;
  55432. }
  55433. utils.getNAF = getNAF;
  55434. // Represent k1, k2 in a Joint Sparse Form
  55435. function getJSF(k1, k2) {
  55436. var jsf = [
  55437. [],
  55438. []
  55439. ];
  55440. k1 = k1.clone();
  55441. k2 = k2.clone();
  55442. var d1 = 0;
  55443. var d2 = 0;
  55444. while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) {
  55445. // First phase
  55446. var m14 = (k1.andln(3) + d1) & 3;
  55447. var m24 = (k2.andln(3) + d2) & 3;
  55448. if (m14 === 3)
  55449. m14 = -1;
  55450. if (m24 === 3)
  55451. m24 = -1;
  55452. var u1;
  55453. if ((m14 & 1) === 0) {
  55454. u1 = 0;
  55455. } else {
  55456. var m8 = (k1.andln(7) + d1) & 7;
  55457. if ((m8 === 3 || m8 === 5) && m24 === 2)
  55458. u1 = -m14;
  55459. else
  55460. u1 = m14;
  55461. }
  55462. jsf[0].push(u1);
  55463. var u2;
  55464. if ((m24 & 1) === 0) {
  55465. u2 = 0;
  55466. } else {
  55467. var m8 = (k2.andln(7) + d2) & 7;
  55468. if ((m8 === 3 || m8 === 5) && m14 === 2)
  55469. u2 = -m24;
  55470. else
  55471. u2 = m24;
  55472. }
  55473. jsf[1].push(u2);
  55474. // Second phase
  55475. if (2 * d1 === u1 + 1)
  55476. d1 = 1 - d1;
  55477. if (2 * d2 === u2 + 1)
  55478. d2 = 1 - d2;
  55479. k1.iushrn(1);
  55480. k2.iushrn(1);
  55481. }
  55482. return jsf;
  55483. }
  55484. utils.getJSF = getJSF;
  55485. function cachedProperty(obj, name, computer) {
  55486. var key = '_' + name;
  55487. obj.prototype[name] = function cachedProperty() {
  55488. return this[key] !== undefined ? this[key] :
  55489. this[key] = computer.call(this);
  55490. };
  55491. }
  55492. utils.cachedProperty = cachedProperty;
  55493. function parseBytes(bytes) {
  55494. return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') :
  55495. bytes;
  55496. }
  55497. utils.parseBytes = parseBytes;
  55498. function intFromLE(bytes) {
  55499. return new BN(bytes, 'hex', 'le');
  55500. }
  55501. utils.intFromLE = intFromLE;
  55502. /***/ },
  55503. /* 500 */
  55504. /***/ function(module, exports) {
  55505. "use strict";
  55506. "use strict";
  55507. module.exports = function(arr, iter, context) {
  55508. var results = [];
  55509. if (!Array.isArray(arr)) return results;
  55510. arr.forEach(function(value, index, list) {
  55511. var res = iter.call(context, value, index, list);
  55512. if (Array.isArray(res)) {
  55513. results.push.apply(results, res);
  55514. } else if (res != null) {
  55515. results.push(res);
  55516. }
  55517. });
  55518. return results;
  55519. };
  55520. /***/ },
  55521. /* 501 */
  55522. /***/ function(module, exports, __webpack_require__) {
  55523. /* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors.
  55524. //
  55525. // Permission is hereby granted, free of charge, to any person obtaining a
  55526. // copy of this software and associated documentation files (the
  55527. // "Software"), to deal in the Software without restriction, including
  55528. // without limitation the rights to use, copy, modify, merge, publish,
  55529. // distribute, sublicense, and/or sell copies of the Software, and to permit
  55530. // persons to whom the Software is furnished to do so, subject to the
  55531. // following conditions:
  55532. //
  55533. // The above copyright notice and this permission notice shall be included
  55534. // in all copies or substantial portions of the Software.
  55535. //
  55536. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  55537. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  55538. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  55539. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  55540. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  55541. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  55542. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  55543. var pathModule = __webpack_require__(43);
  55544. var isWindows = process.platform === 'win32';
  55545. // JavaScript implementation of realpath, ported from node pre-v6
  55546. var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
  55547. function rethrow() {
  55548. // Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and
  55549. // is fairly slow to generate.
  55550. var callback;
  55551. if (DEBUG) {
  55552. var backtrace = new Error;
  55553. callback = debugCallback;
  55554. } else
  55555. callback = missingCallback;
  55556. return callback;
  55557. function debugCallback(err) {
  55558. if (err) {
  55559. backtrace.message = err.message;
  55560. err = backtrace;
  55561. missingCallback(err);
  55562. }
  55563. }
  55564. function missingCallback(err) {
  55565. if (err) {
  55566. if (process.throwDeprecation)
  55567. throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs
  55568. else if (!process.noDeprecation) {
  55569. var msg = 'fs: missing callback ' + (err.stack || err.message);
  55570. if (process.traceDeprecation)
  55571. console.trace(msg);
  55572. else
  55573. console.error(msg);
  55574. }
  55575. }
  55576. }
  55577. }
  55578. function maybeCallback(cb) {
  55579. return typeof cb === 'function' ? cb : rethrow();
  55580. }
  55581. var normalize = pathModule.normalize;
  55582. // Regexp that finds the next partion of a (partial) path
  55583. // result is [base_with_slash, base], e.g. ['somedir/', 'somedir']
  55584. if (isWindows) {
  55585. var nextPartRe = /(.*?)(?:[\/\\]+|$)/g;
  55586. } else {
  55587. var nextPartRe = /(.*?)(?:[\/]+|$)/g;
  55588. }
  55589. // Regex to find the device root, including trailing slash. E.g. 'c:\\'.
  55590. if (isWindows) {
  55591. var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;
  55592. } else {
  55593. var splitRootRe = /^[\/]*/;
  55594. }
  55595. exports.realpathSync = function realpathSync(p, cache) {
  55596. // make p is absolute
  55597. p = pathModule.resolve(p);
  55598. if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
  55599. return cache[p];
  55600. }
  55601. var original = p,
  55602. seenLinks = {},
  55603. knownHard = {};
  55604. // current character position in p
  55605. var pos;
  55606. // the partial path so far, including a trailing slash if any
  55607. var current;
  55608. // the partial path without a trailing slash (except when pointing at a root)
  55609. var base;
  55610. // the partial path scanned in the previous round, with slash
  55611. var previous;
  55612. start();
  55613. function start() {
  55614. // Skip over roots
  55615. var m = splitRootRe.exec(p);
  55616. pos = m[0].length;
  55617. current = m[0];
  55618. base = m[0];
  55619. previous = '';
  55620. // On windows, check that the root exists. On unix there is no need.
  55621. if (isWindows && !knownHard[base]) {
  55622. fs.lstatSync(base);
  55623. knownHard[base] = true;
  55624. }
  55625. }
  55626. // walk down the path, swapping out linked pathparts for their real
  55627. // values
  55628. // NB: p.length changes.
  55629. while (pos < p.length) {
  55630. // find the next part
  55631. nextPartRe.lastIndex = pos;
  55632. var result = nextPartRe.exec(p);
  55633. previous = current;
  55634. current += result[0];
  55635. base = previous + result[1];
  55636. pos = nextPartRe.lastIndex;
  55637. // continue if not a symlink
  55638. if (knownHard[base] || (cache && cache[base] === base)) {
  55639. continue;
  55640. }
  55641. var resolvedLink;
  55642. if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
  55643. // some known symbolic link. no need to stat again.
  55644. resolvedLink = cache[base];
  55645. } else {
  55646. var stat = fs.lstatSync(base);
  55647. if (!stat.isSymbolicLink()) {
  55648. knownHard[base] = true;
  55649. if (cache) cache[base] = base;
  55650. continue;
  55651. }
  55652. // read the link if it wasn't read before
  55653. // dev/ino always return 0 on windows, so skip the check.
  55654. var linkTarget = null;
  55655. if (!isWindows) {
  55656. var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
  55657. if (seenLinks.hasOwnProperty(id)) {
  55658. linkTarget = seenLinks[id];
  55659. }
  55660. }
  55661. if (linkTarget === null) {
  55662. fs.statSync(base);
  55663. linkTarget = fs.readlinkSync(base);
  55664. }
  55665. resolvedLink = pathModule.resolve(previous, linkTarget);
  55666. // track this, if given a cache.
  55667. if (cache) cache[base] = resolvedLink;
  55668. if (!isWindows) seenLinks[id] = linkTarget;
  55669. }
  55670. // resolve the link, then start over
  55671. p = pathModule.resolve(resolvedLink, p.slice(pos));
  55672. start();
  55673. }
  55674. if (cache) cache[original] = p;
  55675. return p;
  55676. };
  55677. exports.realpath = function realpath(p, cache, cb) {
  55678. if (typeof cb !== 'function') {
  55679. cb = maybeCallback(cache);
  55680. cache = null;
  55681. }
  55682. // make p is absolute
  55683. p = pathModule.resolve(p);
  55684. if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
  55685. return process.nextTick(cb.bind(null, null, cache[p]));
  55686. }
  55687. var original = p,
  55688. seenLinks = {},
  55689. knownHard = {};
  55690. // current character position in p
  55691. var pos;
  55692. // the partial path so far, including a trailing slash if any
  55693. var current;
  55694. // the partial path without a trailing slash (except when pointing at a root)
  55695. var base;
  55696. // the partial path scanned in the previous round, with slash
  55697. var previous;
  55698. start();
  55699. function start() {
  55700. // Skip over roots
  55701. var m = splitRootRe.exec(p);
  55702. pos = m[0].length;
  55703. current = m[0];
  55704. base = m[0];
  55705. previous = '';
  55706. // On windows, check that the root exists. On unix there is no need.
  55707. if (isWindows && !knownHard[base]) {
  55708. fs.lstat(base, function(err) {
  55709. if (err) return cb(err);
  55710. knownHard[base] = true;
  55711. LOOP();
  55712. });
  55713. } else {
  55714. process.nextTick(LOOP);
  55715. }
  55716. }
  55717. // walk down the path, swapping out linked pathparts for their real
  55718. // values
  55719. function LOOP() {
  55720. // stop if scanned past end of path
  55721. if (pos >= p.length) {
  55722. if (cache) cache[original] = p;
  55723. return cb(null, p);
  55724. }
  55725. // find the next part
  55726. nextPartRe.lastIndex = pos;
  55727. var result = nextPartRe.exec(p);
  55728. previous = current;
  55729. current += result[0];
  55730. base = previous + result[1];
  55731. pos = nextPartRe.lastIndex;
  55732. // continue if not a symlink
  55733. if (knownHard[base] || (cache && cache[base] === base)) {
  55734. return process.nextTick(LOOP);
  55735. }
  55736. if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
  55737. // known symbolic link. no need to stat again.
  55738. return gotResolvedLink(cache[base]);
  55739. }
  55740. return fs.lstat(base, gotStat);
  55741. }
  55742. function gotStat(err, stat) {
  55743. if (err) return cb(err);
  55744. // if not a symlink, skip to the next path part
  55745. if (!stat.isSymbolicLink()) {
  55746. knownHard[base] = true;
  55747. if (cache) cache[base] = base;
  55748. return process.nextTick(LOOP);
  55749. }
  55750. // stat & read the link if not read before
  55751. // call gotTarget as soon as the link target is known
  55752. // dev/ino always return 0 on windows, so skip the check.
  55753. if (!isWindows) {
  55754. var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
  55755. if (seenLinks.hasOwnProperty(id)) {
  55756. return gotTarget(null, seenLinks[id], base);
  55757. }
  55758. }
  55759. fs.stat(base, function(err) {
  55760. if (err) return cb(err);
  55761. fs.readlink(base, function(err, target) {
  55762. if (!isWindows) seenLinks[id] = target;
  55763. gotTarget(err, target);
  55764. });
  55765. });
  55766. }
  55767. function gotTarget(err, target, base) {
  55768. if (err) return cb(err);
  55769. var resolvedLink = pathModule.resolve(previous, target);
  55770. if (cache) cache[base] = resolvedLink;
  55771. gotResolvedLink(resolvedLink);
  55772. }
  55773. function gotResolvedLink(resolvedLink) {
  55774. // resolve the link, then start over
  55775. p = pathModule.resolve(resolvedLink, p.slice(pos));
  55776. start();
  55777. }
  55778. };
  55779. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  55780. /***/ },
  55781. /* 502 */
  55782. /***/ function(module, exports, __webpack_require__) {
  55783. var util = __webpack_require__(44)
  55784. var INDENT_START = /[\{\[]/
  55785. var INDENT_END = /[\}\]]/
  55786. module.exports = function() {
  55787. var lines = []
  55788. var indent = 0
  55789. var push = function(str) {
  55790. var spaces = ''
  55791. while (spaces.length < indent*2) spaces += ' '
  55792. lines.push(spaces+str)
  55793. }
  55794. var line = function(fmt) {
  55795. if (!fmt) return line
  55796. if (INDENT_END.test(fmt.trim()[0]) && INDENT_START.test(fmt[fmt.length-1])) {
  55797. indent--
  55798. push(util.format.apply(util, arguments))
  55799. indent++
  55800. return line
  55801. }
  55802. if (INDENT_START.test(fmt[fmt.length-1])) {
  55803. push(util.format.apply(util, arguments))
  55804. indent++
  55805. return line
  55806. }
  55807. if (INDENT_END.test(fmt.trim()[0])) {
  55808. indent--
  55809. push(util.format.apply(util, arguments))
  55810. return line
  55811. }
  55812. push(util.format.apply(util, arguments))
  55813. return line
  55814. }
  55815. line.toString = function() {
  55816. return lines.join('\n')
  55817. }
  55818. line.toFunction = function(scope) {
  55819. var src = 'return ('+line.toString()+')'
  55820. var keys = Object.keys(scope || {}).map(function(key) {
  55821. return key
  55822. })
  55823. var vals = keys.map(function(key) {
  55824. return scope[key]
  55825. })
  55826. return Function.apply(null, keys.concat(src)).apply(null, vals)
  55827. }
  55828. if (arguments.length) line.apply(null, arguments)
  55829. return line
  55830. }
  55831. /***/ },
  55832. /* 503 */
  55833. /***/ function(module, exports, __webpack_require__) {
  55834. var isProperty = __webpack_require__(515)
  55835. var gen = function(obj, prop) {
  55836. return isProperty(prop) ? obj+'.'+prop : obj+'['+JSON.stringify(prop)+']'
  55837. }
  55838. gen.valid = isProperty
  55839. gen.property = function (prop) {
  55840. return isProperty(prop) ? prop : JSON.stringify(prop)
  55841. }
  55842. module.exports = gen
  55843. /***/ },
  55844. /* 504 */
  55845. /***/ function(module, exports, __webpack_require__) {
  55846. /* WEBPACK VAR INJECTION */(function(process) {module.exports = globSync
  55847. globSync.GlobSync = GlobSync
  55848. var rp = __webpack_require__(198)
  55849. var minimatch = __webpack_require__(135)
  55850. var Minimatch = minimatch.Minimatch
  55851. var Glob = __webpack_require__(200).Glob
  55852. var util = __webpack_require__(44)
  55853. var path = __webpack_require__(43)
  55854. var assert = __webpack_require__(144)
  55855. var isAbsolute = __webpack_require__(137)
  55856. var common = __webpack_require__(199)
  55857. var alphasort = common.alphasort
  55858. var alphasorti = common.alphasorti
  55859. var setopts = common.setopts
  55860. var ownProp = common.ownProp
  55861. var childrenIgnored = common.childrenIgnored
  55862. function globSync (pattern, options) {
  55863. if (typeof options === 'function' || arguments.length === 3)
  55864. throw new TypeError('callback provided to sync glob\n'+
  55865. 'See: https://github.com/isaacs/node-glob/issues/167')
  55866. return new GlobSync(pattern, options).found
  55867. }
  55868. function GlobSync (pattern, options) {
  55869. if (!pattern)
  55870. throw new Error('must provide pattern')
  55871. if (typeof options === 'function' || arguments.length === 3)
  55872. throw new TypeError('callback provided to sync glob\n'+
  55873. 'See: https://github.com/isaacs/node-glob/issues/167')
  55874. if (!(this instanceof GlobSync))
  55875. return new GlobSync(pattern, options)
  55876. setopts(this, pattern, options)
  55877. if (this.noprocess)
  55878. return this
  55879. var n = this.minimatch.set.length
  55880. this.matches = new Array(n)
  55881. for (var i = 0; i < n; i ++) {
  55882. this._process(this.minimatch.set[i], i, false)
  55883. }
  55884. this._finish()
  55885. }
  55886. GlobSync.prototype._finish = function () {
  55887. assert(this instanceof GlobSync)
  55888. if (this.realpath) {
  55889. var self = this
  55890. this.matches.forEach(function (matchset, index) {
  55891. var set = self.matches[index] = Object.create(null)
  55892. for (var p in matchset) {
  55893. try {
  55894. p = self._makeAbs(p)
  55895. var real = rp.realpathSync(p, self.realpathCache)
  55896. set[real] = true
  55897. } catch (er) {
  55898. if (er.syscall === 'stat')
  55899. set[self._makeAbs(p)] = true
  55900. else
  55901. throw er
  55902. }
  55903. }
  55904. })
  55905. }
  55906. common.finish(this)
  55907. }
  55908. GlobSync.prototype._process = function (pattern, index, inGlobStar) {
  55909. assert(this instanceof GlobSync)
  55910. // Get the first [n] parts of pattern that are all strings.
  55911. var n = 0
  55912. while (typeof pattern[n] === 'string') {
  55913. n ++
  55914. }
  55915. // now n is the index of the first one that is *not* a string.
  55916. // See if there's anything else
  55917. var prefix
  55918. switch (n) {
  55919. // if not, then this is rather simple
  55920. case pattern.length:
  55921. this._processSimple(pattern.join('/'), index)
  55922. return
  55923. case 0:
  55924. // pattern *starts* with some non-trivial item.
  55925. // going to readdir(cwd), but not include the prefix in matches.
  55926. prefix = null
  55927. break
  55928. default:
  55929. // pattern has some string bits in the front.
  55930. // whatever it starts with, whether that's 'absolute' like /foo/bar,
  55931. // or 'relative' like '../baz'
  55932. prefix = pattern.slice(0, n).join('/')
  55933. break
  55934. }
  55935. var remain = pattern.slice(n)
  55936. // get the list of entries.
  55937. var read
  55938. if (prefix === null)
  55939. read = '.'
  55940. else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) {
  55941. if (!prefix || !isAbsolute(prefix))
  55942. prefix = '/' + prefix
  55943. read = prefix
  55944. } else
  55945. read = prefix
  55946. var abs = this._makeAbs(read)
  55947. //if ignored, skip processing
  55948. if (childrenIgnored(this, read))
  55949. return
  55950. var isGlobStar = remain[0] === minimatch.GLOBSTAR
  55951. if (isGlobStar)
  55952. this._processGlobStar(prefix, read, abs, remain, index, inGlobStar)
  55953. else
  55954. this._processReaddir(prefix, read, abs, remain, index, inGlobStar)
  55955. }
  55956. GlobSync.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar) {
  55957. var entries = this._readdir(abs, inGlobStar)
  55958. // if the abs isn't a dir, then nothing can match!
  55959. if (!entries)
  55960. return
  55961. // It will only match dot entries if it starts with a dot, or if
  55962. // dot is set. Stuff like @(.foo|.bar) isn't allowed.
  55963. var pn = remain[0]
  55964. var negate = !!this.minimatch.negate
  55965. var rawGlob = pn._glob
  55966. var dotOk = this.dot || rawGlob.charAt(0) === '.'
  55967. var matchedEntries = []
  55968. for (var i = 0; i < entries.length; i++) {
  55969. var e = entries[i]
  55970. if (e.charAt(0) !== '.' || dotOk) {
  55971. var m
  55972. if (negate && !prefix) {
  55973. m = !e.match(pn)
  55974. } else {
  55975. m = e.match(pn)
  55976. }
  55977. if (m)
  55978. matchedEntries.push(e)
  55979. }
  55980. }
  55981. var len = matchedEntries.length
  55982. // If there are no matched entries, then nothing matches.
  55983. if (len === 0)
  55984. return
  55985. // if this is the last remaining pattern bit, then no need for
  55986. // an additional stat *unless* the user has specified mark or
  55987. // stat explicitly. We know they exist, since readdir returned
  55988. // them.
  55989. if (remain.length === 1 && !this.mark && !this.stat) {
  55990. if (!this.matches[index])
  55991. this.matches[index] = Object.create(null)
  55992. for (var i = 0; i < len; i ++) {
  55993. var e = matchedEntries[i]
  55994. if (prefix) {
  55995. if (prefix.slice(-1) !== '/')
  55996. e = prefix + '/' + e
  55997. else
  55998. e = prefix + e
  55999. }
  56000. if (e.charAt(0) === '/' && !this.nomount) {
  56001. e = path.join(this.root, e)
  56002. }
  56003. this.matches[index][e] = true
  56004. }
  56005. // This was the last one, and no stats were needed
  56006. return
  56007. }
  56008. // now test all matched entries as stand-ins for that part
  56009. // of the pattern.
  56010. remain.shift()
  56011. for (var i = 0; i < len; i ++) {
  56012. var e = matchedEntries[i]
  56013. var newPattern
  56014. if (prefix)
  56015. newPattern = [prefix, e]
  56016. else
  56017. newPattern = [e]
  56018. this._process(newPattern.concat(remain), index, inGlobStar)
  56019. }
  56020. }
  56021. GlobSync.prototype._emitMatch = function (index, e) {
  56022. var abs = this._makeAbs(e)
  56023. if (this.mark)
  56024. e = this._mark(e)
  56025. if (this.matches[index][e])
  56026. return
  56027. if (this.nodir) {
  56028. var c = this.cache[this._makeAbs(e)]
  56029. if (c === 'DIR' || Array.isArray(c))
  56030. return
  56031. }
  56032. this.matches[index][e] = true
  56033. if (this.stat)
  56034. this._stat(e)
  56035. }
  56036. GlobSync.prototype._readdirInGlobStar = function (abs) {
  56037. // follow all symlinked directories forever
  56038. // just proceed as if this is a non-globstar situation
  56039. if (this.follow)
  56040. return this._readdir(abs, false)
  56041. var entries
  56042. var lstat
  56043. var stat
  56044. try {
  56045. lstat = fs.lstatSync(abs)
  56046. } catch (er) {
  56047. // lstat failed, doesn't exist
  56048. return null
  56049. }
  56050. var isSym = lstat.isSymbolicLink()
  56051. this.symlinks[abs] = isSym
  56052. // If it's not a symlink or a dir, then it's definitely a regular file.
  56053. // don't bother doing a readdir in that case.
  56054. if (!isSym && !lstat.isDirectory())
  56055. this.cache[abs] = 'FILE'
  56056. else
  56057. entries = this._readdir(abs, false)
  56058. return entries
  56059. }
  56060. GlobSync.prototype._readdir = function (abs, inGlobStar) {
  56061. var entries
  56062. if (inGlobStar && !ownProp(this.symlinks, abs))
  56063. return this._readdirInGlobStar(abs)
  56064. if (ownProp(this.cache, abs)) {
  56065. var c = this.cache[abs]
  56066. if (!c || c === 'FILE')
  56067. return null
  56068. if (Array.isArray(c))
  56069. return c
  56070. }
  56071. try {
  56072. return this._readdirEntries(abs, fs.readdirSync(abs))
  56073. } catch (er) {
  56074. this._readdirError(abs, er)
  56075. return null
  56076. }
  56077. }
  56078. GlobSync.prototype._readdirEntries = function (abs, entries) {
  56079. // if we haven't asked to stat everything, then just
  56080. // assume that everything in there exists, so we can avoid
  56081. // having to stat it a second time.
  56082. if (!this.mark && !this.stat) {
  56083. for (var i = 0; i < entries.length; i ++) {
  56084. var e = entries[i]
  56085. if (abs === '/')
  56086. e = abs + e
  56087. else
  56088. e = abs + '/' + e
  56089. this.cache[e] = true
  56090. }
  56091. }
  56092. this.cache[abs] = entries
  56093. // mark and cache dir-ness
  56094. return entries
  56095. }
  56096. GlobSync.prototype._readdirError = function (f, er) {
  56097. // handle errors, and cache the information
  56098. switch (er.code) {
  56099. case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205
  56100. case 'ENOTDIR': // totally normal. means it *does* exist.
  56101. var abs = this._makeAbs(f)
  56102. this.cache[abs] = 'FILE'
  56103. if (abs === this.cwdAbs) {
  56104. var error = new Error(er.code + ' invalid cwd ' + this.cwd)
  56105. error.path = this.cwd
  56106. error.code = er.code
  56107. throw error
  56108. }
  56109. break
  56110. case 'ENOENT': // not terribly unusual
  56111. case 'ELOOP':
  56112. case 'ENAMETOOLONG':
  56113. case 'UNKNOWN':
  56114. this.cache[this._makeAbs(f)] = false
  56115. break
  56116. default: // some unusual error. Treat as failure.
  56117. this.cache[this._makeAbs(f)] = false
  56118. if (this.strict)
  56119. throw er
  56120. if (!this.silent)
  56121. console.error('glob error', er)
  56122. break
  56123. }
  56124. }
  56125. GlobSync.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar) {
  56126. var entries = this._readdir(abs, inGlobStar)
  56127. // no entries means not a dir, so it can never have matches
  56128. // foo.txt/** doesn't match foo.txt
  56129. if (!entries)
  56130. return
  56131. // test without the globstar, and with every child both below
  56132. // and replacing the globstar.
  56133. var remainWithoutGlobStar = remain.slice(1)
  56134. var gspref = prefix ? [ prefix ] : []
  56135. var noGlobStar = gspref.concat(remainWithoutGlobStar)
  56136. // the noGlobStar pattern exits the inGlobStar state
  56137. this._process(noGlobStar, index, false)
  56138. var len = entries.length
  56139. var isSym = this.symlinks[abs]
  56140. // If it's a symlink, and we're in a globstar, then stop
  56141. if (isSym && inGlobStar)
  56142. return
  56143. for (var i = 0; i < len; i++) {
  56144. var e = entries[i]
  56145. if (e.charAt(0) === '.' && !this.dot)
  56146. continue
  56147. // these two cases enter the inGlobStar state
  56148. var instead = gspref.concat(entries[i], remainWithoutGlobStar)
  56149. this._process(instead, index, true)
  56150. var below = gspref.concat(entries[i], remain)
  56151. this._process(below, index, true)
  56152. }
  56153. }
  56154. GlobSync.prototype._processSimple = function (prefix, index) {
  56155. // XXX review this. Shouldn't it be doing the mounting etc
  56156. // before doing stat? kinda weird?
  56157. var exists = this._stat(prefix)
  56158. if (!this.matches[index])
  56159. this.matches[index] = Object.create(null)
  56160. // If it doesn't exist, then just mark the lack of results
  56161. if (!exists)
  56162. return
  56163. if (prefix && isAbsolute(prefix) && !this.nomount) {
  56164. var trail = /[\/\\]$/.test(prefix)
  56165. if (prefix.charAt(0) === '/') {
  56166. prefix = path.join(this.root, prefix)
  56167. } else {
  56168. prefix = path.resolve(this.root, prefix)
  56169. if (trail)
  56170. prefix += '/'
  56171. }
  56172. }
  56173. if (process.platform === 'win32')
  56174. prefix = prefix.replace(/\\/g, '/')
  56175. // Mark this as a match
  56176. this.matches[index][prefix] = true
  56177. }
  56178. // Returns either 'DIR', 'FILE', or false
  56179. GlobSync.prototype._stat = function (f) {
  56180. var abs = this._makeAbs(f)
  56181. var needDir = f.slice(-1) === '/'
  56182. if (f.length > this.maxLength)
  56183. return false
  56184. if (!this.stat && ownProp(this.cache, abs)) {
  56185. var c = this.cache[abs]
  56186. if (Array.isArray(c))
  56187. c = 'DIR'
  56188. // It exists, but maybe not how we need it
  56189. if (!needDir || c === 'DIR')
  56190. return c
  56191. if (needDir && c === 'FILE')
  56192. return false
  56193. // otherwise we have to stat, because maybe c=true
  56194. // if we know it exists, but not what it is.
  56195. }
  56196. var exists
  56197. var stat = this.statCache[abs]
  56198. if (!stat) {
  56199. var lstat
  56200. try {
  56201. lstat = fs.lstatSync(abs)
  56202. } catch (er) {
  56203. return false
  56204. }
  56205. if (lstat.isSymbolicLink()) {
  56206. try {
  56207. stat = fs.statSync(abs)
  56208. } catch (er) {
  56209. stat = lstat
  56210. }
  56211. } else {
  56212. stat = lstat
  56213. }
  56214. }
  56215. this.statCache[abs] = stat
  56216. var c = stat.isDirectory() ? 'DIR' : 'FILE'
  56217. this.cache[abs] = this.cache[abs] || c
  56218. if (needDir && c !== 'DIR')
  56219. return false
  56220. return c
  56221. }
  56222. GlobSync.prototype._mark = function (p) {
  56223. return common.mark(this, p)
  56224. }
  56225. GlobSync.prototype._makeAbs = function (f) {
  56226. return common.makeAbs(this, f)
  56227. }
  56228. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  56229. /***/ },
  56230. /* 505 */
  56231. /***/ function(module, exports, __webpack_require__) {
  56232. var hash = __webpack_require__(54);
  56233. var utils = hash.utils;
  56234. var assert = utils.assert;
  56235. function BlockHash() {
  56236. this.pending = null;
  56237. this.pendingTotal = 0;
  56238. this.blockSize = this.constructor.blockSize;
  56239. this.outSize = this.constructor.outSize;
  56240. this.hmacStrength = this.constructor.hmacStrength;
  56241. this.padLength = this.constructor.padLength / 8;
  56242. this.endian = 'big';
  56243. this._delta8 = this.blockSize / 8;
  56244. this._delta32 = this.blockSize / 32;
  56245. }
  56246. exports.BlockHash = BlockHash;
  56247. BlockHash.prototype.update = function update(msg, enc) {
  56248. // Convert message to array, pad it, and join into 32bit blocks
  56249. msg = utils.toArray(msg, enc);
  56250. if (!this.pending)
  56251. this.pending = msg;
  56252. else
  56253. this.pending = this.pending.concat(msg);
  56254. this.pendingTotal += msg.length;
  56255. // Enough data, try updating
  56256. if (this.pending.length >= this._delta8) {
  56257. msg = this.pending;
  56258. // Process pending data in blocks
  56259. var r = msg.length % this._delta8;
  56260. this.pending = msg.slice(msg.length - r, msg.length);
  56261. if (this.pending.length === 0)
  56262. this.pending = null;
  56263. msg = utils.join32(msg, 0, msg.length - r, this.endian);
  56264. for (var i = 0; i < msg.length; i += this._delta32)
  56265. this._update(msg, i, i + this._delta32);
  56266. }
  56267. return this;
  56268. };
  56269. BlockHash.prototype.digest = function digest(enc) {
  56270. this.update(this._pad());
  56271. assert(this.pending === null);
  56272. return this._digest(enc);
  56273. };
  56274. BlockHash.prototype._pad = function pad() {
  56275. var len = this.pendingTotal;
  56276. var bytes = this._delta8;
  56277. var k = bytes - ((len + this.padLength) % bytes);
  56278. var res = new Array(k + this.padLength);
  56279. res[0] = 0x80;
  56280. for (var i = 1; i < k; i++)
  56281. res[i] = 0;
  56282. // Append length
  56283. len <<= 3;
  56284. if (this.endian === 'big') {
  56285. for (var t = 8; t < this.padLength; t++)
  56286. res[i++] = 0;
  56287. res[i++] = 0;
  56288. res[i++] = 0;
  56289. res[i++] = 0;
  56290. res[i++] = 0;
  56291. res[i++] = (len >>> 24) & 0xff;
  56292. res[i++] = (len >>> 16) & 0xff;
  56293. res[i++] = (len >>> 8) & 0xff;
  56294. res[i++] = len & 0xff;
  56295. } else {
  56296. res[i++] = len & 0xff;
  56297. res[i++] = (len >>> 8) & 0xff;
  56298. res[i++] = (len >>> 16) & 0xff;
  56299. res[i++] = (len >>> 24) & 0xff;
  56300. res[i++] = 0;
  56301. res[i++] = 0;
  56302. res[i++] = 0;
  56303. res[i++] = 0;
  56304. for (var t = 8; t < this.padLength; t++)
  56305. res[i++] = 0;
  56306. }
  56307. return res;
  56308. };
  56309. /***/ },
  56310. /* 506 */
  56311. /***/ function(module, exports, __webpack_require__) {
  56312. var hmac = exports;
  56313. var hash = __webpack_require__(54);
  56314. var utils = hash.utils;
  56315. var assert = utils.assert;
  56316. function Hmac(hash, key, enc) {
  56317. if (!(this instanceof Hmac))
  56318. return new Hmac(hash, key, enc);
  56319. this.Hash = hash;
  56320. this.blockSize = hash.blockSize / 8;
  56321. this.outSize = hash.outSize / 8;
  56322. this.inner = null;
  56323. this.outer = null;
  56324. this._init(utils.toArray(key, enc));
  56325. }
  56326. module.exports = Hmac;
  56327. Hmac.prototype._init = function init(key) {
  56328. // Shorten key, if needed
  56329. if (key.length > this.blockSize)
  56330. key = new this.Hash().update(key).digest();
  56331. assert(key.length <= this.blockSize);
  56332. // Add padding to key
  56333. for (var i = key.length; i < this.blockSize; i++)
  56334. key.push(0);
  56335. for (var i = 0; i < key.length; i++)
  56336. key[i] ^= 0x36;
  56337. this.inner = new this.Hash().update(key);
  56338. // 0x36 ^ 0x5c = 0x6a
  56339. for (var i = 0; i < key.length; i++)
  56340. key[i] ^= 0x6a;
  56341. this.outer = new this.Hash().update(key);
  56342. };
  56343. Hmac.prototype.update = function update(msg, enc) {
  56344. this.inner.update(msg, enc);
  56345. return this;
  56346. };
  56347. Hmac.prototype.digest = function digest(enc) {
  56348. this.outer.update(this.inner.digest());
  56349. return this.outer.digest(enc);
  56350. };
  56351. /***/ },
  56352. /* 507 */
  56353. /***/ function(module, exports, __webpack_require__) {
  56354. var hash = __webpack_require__(54);
  56355. var utils = hash.utils;
  56356. var rotl32 = utils.rotl32;
  56357. var sum32 = utils.sum32;
  56358. var sum32_3 = utils.sum32_3;
  56359. var sum32_4 = utils.sum32_4;
  56360. var BlockHash = hash.common.BlockHash;
  56361. function RIPEMD160() {
  56362. if (!(this instanceof RIPEMD160))
  56363. return new RIPEMD160();
  56364. BlockHash.call(this);
  56365. this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ];
  56366. this.endian = 'little';
  56367. }
  56368. utils.inherits(RIPEMD160, BlockHash);
  56369. exports.ripemd160 = RIPEMD160;
  56370. RIPEMD160.blockSize = 512;
  56371. RIPEMD160.outSize = 160;
  56372. RIPEMD160.hmacStrength = 192;
  56373. RIPEMD160.padLength = 64;
  56374. RIPEMD160.prototype._update = function update(msg, start) {
  56375. var A = this.h[0];
  56376. var B = this.h[1];
  56377. var C = this.h[2];
  56378. var D = this.h[3];
  56379. var E = this.h[4];
  56380. var Ah = A;
  56381. var Bh = B;
  56382. var Ch = C;
  56383. var Dh = D;
  56384. var Eh = E;
  56385. for (var j = 0; j < 80; j++) {
  56386. var T = sum32(
  56387. rotl32(
  56388. sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)),
  56389. s[j]),
  56390. E);
  56391. A = E;
  56392. E = D;
  56393. D = rotl32(C, 10);
  56394. C = B;
  56395. B = T;
  56396. T = sum32(
  56397. rotl32(
  56398. sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)),
  56399. sh[j]),
  56400. Eh);
  56401. Ah = Eh;
  56402. Eh = Dh;
  56403. Dh = rotl32(Ch, 10);
  56404. Ch = Bh;
  56405. Bh = T;
  56406. }
  56407. T = sum32_3(this.h[1], C, Dh);
  56408. this.h[1] = sum32_3(this.h[2], D, Eh);
  56409. this.h[2] = sum32_3(this.h[3], E, Ah);
  56410. this.h[3] = sum32_3(this.h[4], A, Bh);
  56411. this.h[4] = sum32_3(this.h[0], B, Ch);
  56412. this.h[0] = T;
  56413. };
  56414. RIPEMD160.prototype._digest = function digest(enc) {
  56415. if (enc === 'hex')
  56416. return utils.toHex32(this.h, 'little');
  56417. else
  56418. return utils.split32(this.h, 'little');
  56419. };
  56420. function f(j, x, y, z) {
  56421. if (j <= 15)
  56422. return x ^ y ^ z;
  56423. else if (j <= 31)
  56424. return (x & y) | ((~x) & z);
  56425. else if (j <= 47)
  56426. return (x | (~y)) ^ z;
  56427. else if (j <= 63)
  56428. return (x & z) | (y & (~z));
  56429. else
  56430. return x ^ (y | (~z));
  56431. }
  56432. function K(j) {
  56433. if (j <= 15)
  56434. return 0x00000000;
  56435. else if (j <= 31)
  56436. return 0x5a827999;
  56437. else if (j <= 47)
  56438. return 0x6ed9eba1;
  56439. else if (j <= 63)
  56440. return 0x8f1bbcdc;
  56441. else
  56442. return 0xa953fd4e;
  56443. }
  56444. function Kh(j) {
  56445. if (j <= 15)
  56446. return 0x50a28be6;
  56447. else if (j <= 31)
  56448. return 0x5c4dd124;
  56449. else if (j <= 47)
  56450. return 0x6d703ef3;
  56451. else if (j <= 63)
  56452. return 0x7a6d76e9;
  56453. else
  56454. return 0x00000000;
  56455. }
  56456. var r = [
  56457. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
  56458. 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
  56459. 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
  56460. 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
  56461. 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
  56462. ];
  56463. var rh = [
  56464. 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
  56465. 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
  56466. 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
  56467. 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
  56468. 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
  56469. ];
  56470. var s = [
  56471. 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
  56472. 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
  56473. 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
  56474. 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
  56475. 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
  56476. ];
  56477. var sh = [
  56478. 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
  56479. 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
  56480. 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
  56481. 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
  56482. 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
  56483. ];
  56484. /***/ },
  56485. /* 508 */
  56486. /***/ function(module, exports, __webpack_require__) {
  56487. var hash = __webpack_require__(54);
  56488. var utils = hash.utils;
  56489. var assert = utils.assert;
  56490. var rotr32 = utils.rotr32;
  56491. var rotl32 = utils.rotl32;
  56492. var sum32 = utils.sum32;
  56493. var sum32_4 = utils.sum32_4;
  56494. var sum32_5 = utils.sum32_5;
  56495. var rotr64_hi = utils.rotr64_hi;
  56496. var rotr64_lo = utils.rotr64_lo;
  56497. var shr64_hi = utils.shr64_hi;
  56498. var shr64_lo = utils.shr64_lo;
  56499. var sum64 = utils.sum64;
  56500. var sum64_hi = utils.sum64_hi;
  56501. var sum64_lo = utils.sum64_lo;
  56502. var sum64_4_hi = utils.sum64_4_hi;
  56503. var sum64_4_lo = utils.sum64_4_lo;
  56504. var sum64_5_hi = utils.sum64_5_hi;
  56505. var sum64_5_lo = utils.sum64_5_lo;
  56506. var BlockHash = hash.common.BlockHash;
  56507. var sha256_K = [
  56508. 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
  56509. 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
  56510. 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
  56511. 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
  56512. 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
  56513. 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
  56514. 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
  56515. 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
  56516. 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
  56517. 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
  56518. 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
  56519. 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
  56520. 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
  56521. 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
  56522. 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
  56523. 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
  56524. ];
  56525. var sha512_K = [
  56526. 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
  56527. 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
  56528. 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
  56529. 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
  56530. 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
  56531. 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
  56532. 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
  56533. 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
  56534. 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
  56535. 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
  56536. 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
  56537. 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
  56538. 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
  56539. 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
  56540. 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
  56541. 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
  56542. 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
  56543. 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
  56544. 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
  56545. 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
  56546. 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
  56547. 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
  56548. 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
  56549. 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
  56550. 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
  56551. 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
  56552. 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
  56553. 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
  56554. 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
  56555. 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
  56556. 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
  56557. 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
  56558. 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
  56559. 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
  56560. 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
  56561. 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
  56562. 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
  56563. 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
  56564. 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
  56565. 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
  56566. ];
  56567. var sha1_K = [
  56568. 0x5A827999, 0x6ED9EBA1,
  56569. 0x8F1BBCDC, 0xCA62C1D6
  56570. ];
  56571. function SHA256() {
  56572. if (!(this instanceof SHA256))
  56573. return new SHA256();
  56574. BlockHash.call(this);
  56575. this.h = [ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
  56576. 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 ];
  56577. this.k = sha256_K;
  56578. this.W = new Array(64);
  56579. }
  56580. utils.inherits(SHA256, BlockHash);
  56581. exports.sha256 = SHA256;
  56582. SHA256.blockSize = 512;
  56583. SHA256.outSize = 256;
  56584. SHA256.hmacStrength = 192;
  56585. SHA256.padLength = 64;
  56586. SHA256.prototype._update = function _update(msg, start) {
  56587. var W = this.W;
  56588. for (var i = 0; i < 16; i++)
  56589. W[i] = msg[start + i];
  56590. for (; i < W.length; i++)
  56591. W[i] = sum32_4(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]);
  56592. var a = this.h[0];
  56593. var b = this.h[1];
  56594. var c = this.h[2];
  56595. var d = this.h[3];
  56596. var e = this.h[4];
  56597. var f = this.h[5];
  56598. var g = this.h[6];
  56599. var h = this.h[7];
  56600. assert(this.k.length === W.length);
  56601. for (var i = 0; i < W.length; i++) {
  56602. var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]);
  56603. var T2 = sum32(s0_256(a), maj32(a, b, c));
  56604. h = g;
  56605. g = f;
  56606. f = e;
  56607. e = sum32(d, T1);
  56608. d = c;
  56609. c = b;
  56610. b = a;
  56611. a = sum32(T1, T2);
  56612. }
  56613. this.h[0] = sum32(this.h[0], a);
  56614. this.h[1] = sum32(this.h[1], b);
  56615. this.h[2] = sum32(this.h[2], c);
  56616. this.h[3] = sum32(this.h[3], d);
  56617. this.h[4] = sum32(this.h[4], e);
  56618. this.h[5] = sum32(this.h[5], f);
  56619. this.h[6] = sum32(this.h[6], g);
  56620. this.h[7] = sum32(this.h[7], h);
  56621. };
  56622. SHA256.prototype._digest = function digest(enc) {
  56623. if (enc === 'hex')
  56624. return utils.toHex32(this.h, 'big');
  56625. else
  56626. return utils.split32(this.h, 'big');
  56627. };
  56628. function SHA224() {
  56629. if (!(this instanceof SHA224))
  56630. return new SHA224();
  56631. SHA256.call(this);
  56632. this.h = [ 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
  56633. 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ];
  56634. }
  56635. utils.inherits(SHA224, SHA256);
  56636. exports.sha224 = SHA224;
  56637. SHA224.blockSize = 512;
  56638. SHA224.outSize = 224;
  56639. SHA224.hmacStrength = 192;
  56640. SHA224.padLength = 64;
  56641. SHA224.prototype._digest = function digest(enc) {
  56642. // Just truncate output
  56643. if (enc === 'hex')
  56644. return utils.toHex32(this.h.slice(0, 7), 'big');
  56645. else
  56646. return utils.split32(this.h.slice(0, 7), 'big');
  56647. };
  56648. function SHA512() {
  56649. if (!(this instanceof SHA512))
  56650. return new SHA512();
  56651. BlockHash.call(this);
  56652. this.h = [ 0x6a09e667, 0xf3bcc908,
  56653. 0xbb67ae85, 0x84caa73b,
  56654. 0x3c6ef372, 0xfe94f82b,
  56655. 0xa54ff53a, 0x5f1d36f1,
  56656. 0x510e527f, 0xade682d1,
  56657. 0x9b05688c, 0x2b3e6c1f,
  56658. 0x1f83d9ab, 0xfb41bd6b,
  56659. 0x5be0cd19, 0x137e2179 ];
  56660. this.k = sha512_K;
  56661. this.W = new Array(160);
  56662. }
  56663. utils.inherits(SHA512, BlockHash);
  56664. exports.sha512 = SHA512;
  56665. SHA512.blockSize = 1024;
  56666. SHA512.outSize = 512;
  56667. SHA512.hmacStrength = 192;
  56668. SHA512.padLength = 128;
  56669. SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) {
  56670. var W = this.W;
  56671. // 32 x 32bit words
  56672. for (var i = 0; i < 32; i++)
  56673. W[i] = msg[start + i];
  56674. for (; i < W.length; i += 2) {
  56675. var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 2
  56676. var c0_lo = g1_512_lo(W[i - 4], W[i - 3]);
  56677. var c1_hi = W[i - 14]; // i - 7
  56678. var c1_lo = W[i - 13];
  56679. var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 15
  56680. var c2_lo = g0_512_lo(W[i - 30], W[i - 29]);
  56681. var c3_hi = W[i - 32]; // i - 16
  56682. var c3_lo = W[i - 31];
  56683. W[i] = sum64_4_hi(c0_hi, c0_lo,
  56684. c1_hi, c1_lo,
  56685. c2_hi, c2_lo,
  56686. c3_hi, c3_lo);
  56687. W[i + 1] = sum64_4_lo(c0_hi, c0_lo,
  56688. c1_hi, c1_lo,
  56689. c2_hi, c2_lo,
  56690. c3_hi, c3_lo);
  56691. }
  56692. };
  56693. SHA512.prototype._update = function _update(msg, start) {
  56694. this._prepareBlock(msg, start);
  56695. var W = this.W;
  56696. var ah = this.h[0];
  56697. var al = this.h[1];
  56698. var bh = this.h[2];
  56699. var bl = this.h[3];
  56700. var ch = this.h[4];
  56701. var cl = this.h[5];
  56702. var dh = this.h[6];
  56703. var dl = this.h[7];
  56704. var eh = this.h[8];
  56705. var el = this.h[9];
  56706. var fh = this.h[10];
  56707. var fl = this.h[11];
  56708. var gh = this.h[12];
  56709. var gl = this.h[13];
  56710. var hh = this.h[14];
  56711. var hl = this.h[15];
  56712. assert(this.k.length === W.length);
  56713. for (var i = 0; i < W.length; i += 2) {
  56714. var c0_hi = hh;
  56715. var c0_lo = hl;
  56716. var c1_hi = s1_512_hi(eh, el);
  56717. var c1_lo = s1_512_lo(eh, el);
  56718. var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl);
  56719. var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl);
  56720. var c3_hi = this.k[i];
  56721. var c3_lo = this.k[i + 1];
  56722. var c4_hi = W[i];
  56723. var c4_lo = W[i + 1];
  56724. var T1_hi = sum64_5_hi(c0_hi, c0_lo,
  56725. c1_hi, c1_lo,
  56726. c2_hi, c2_lo,
  56727. c3_hi, c3_lo,
  56728. c4_hi, c4_lo);
  56729. var T1_lo = sum64_5_lo(c0_hi, c0_lo,
  56730. c1_hi, c1_lo,
  56731. c2_hi, c2_lo,
  56732. c3_hi, c3_lo,
  56733. c4_hi, c4_lo);
  56734. var c0_hi = s0_512_hi(ah, al);
  56735. var c0_lo = s0_512_lo(ah, al);
  56736. var c1_hi = maj64_hi(ah, al, bh, bl, ch, cl);
  56737. var c1_lo = maj64_lo(ah, al, bh, bl, ch, cl);
  56738. var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo);
  56739. var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo);
  56740. hh = gh;
  56741. hl = gl;
  56742. gh = fh;
  56743. gl = fl;
  56744. fh = eh;
  56745. fl = el;
  56746. eh = sum64_hi(dh, dl, T1_hi, T1_lo);
  56747. el = sum64_lo(dl, dl, T1_hi, T1_lo);
  56748. dh = ch;
  56749. dl = cl;
  56750. ch = bh;
  56751. cl = bl;
  56752. bh = ah;
  56753. bl = al;
  56754. ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo);
  56755. al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo);
  56756. }
  56757. sum64(this.h, 0, ah, al);
  56758. sum64(this.h, 2, bh, bl);
  56759. sum64(this.h, 4, ch, cl);
  56760. sum64(this.h, 6, dh, dl);
  56761. sum64(this.h, 8, eh, el);
  56762. sum64(this.h, 10, fh, fl);
  56763. sum64(this.h, 12, gh, gl);
  56764. sum64(this.h, 14, hh, hl);
  56765. };
  56766. SHA512.prototype._digest = function digest(enc) {
  56767. if (enc === 'hex')
  56768. return utils.toHex32(this.h, 'big');
  56769. else
  56770. return utils.split32(this.h, 'big');
  56771. };
  56772. function SHA384() {
  56773. if (!(this instanceof SHA384))
  56774. return new SHA384();
  56775. SHA512.call(this);
  56776. this.h = [ 0xcbbb9d5d, 0xc1059ed8,
  56777. 0x629a292a, 0x367cd507,
  56778. 0x9159015a, 0x3070dd17,
  56779. 0x152fecd8, 0xf70e5939,
  56780. 0x67332667, 0xffc00b31,
  56781. 0x8eb44a87, 0x68581511,
  56782. 0xdb0c2e0d, 0x64f98fa7,
  56783. 0x47b5481d, 0xbefa4fa4 ];
  56784. }
  56785. utils.inherits(SHA384, SHA512);
  56786. exports.sha384 = SHA384;
  56787. SHA384.blockSize = 1024;
  56788. SHA384.outSize = 384;
  56789. SHA384.hmacStrength = 192;
  56790. SHA384.padLength = 128;
  56791. SHA384.prototype._digest = function digest(enc) {
  56792. if (enc === 'hex')
  56793. return utils.toHex32(this.h.slice(0, 12), 'big');
  56794. else
  56795. return utils.split32(this.h.slice(0, 12), 'big');
  56796. };
  56797. function SHA1() {
  56798. if (!(this instanceof SHA1))
  56799. return new SHA1();
  56800. BlockHash.call(this);
  56801. this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe,
  56802. 0x10325476, 0xc3d2e1f0 ];
  56803. this.W = new Array(80);
  56804. }
  56805. utils.inherits(SHA1, BlockHash);
  56806. exports.sha1 = SHA1;
  56807. SHA1.blockSize = 512;
  56808. SHA1.outSize = 160;
  56809. SHA1.hmacStrength = 80;
  56810. SHA1.padLength = 64;
  56811. SHA1.prototype._update = function _update(msg, start) {
  56812. var W = this.W;
  56813. for (var i = 0; i < 16; i++)
  56814. W[i] = msg[start + i];
  56815. for(; i < W.length; i++)
  56816. W[i] = rotl32(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);
  56817. var a = this.h[0];
  56818. var b = this.h[1];
  56819. var c = this.h[2];
  56820. var d = this.h[3];
  56821. var e = this.h[4];
  56822. for (var i = 0; i < W.length; i++) {
  56823. var s = ~~(i / 20);
  56824. var t = sum32_5(rotl32(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]);
  56825. e = d;
  56826. d = c;
  56827. c = rotl32(b, 30);
  56828. b = a;
  56829. a = t;
  56830. }
  56831. this.h[0] = sum32(this.h[0], a);
  56832. this.h[1] = sum32(this.h[1], b);
  56833. this.h[2] = sum32(this.h[2], c);
  56834. this.h[3] = sum32(this.h[3], d);
  56835. this.h[4] = sum32(this.h[4], e);
  56836. };
  56837. SHA1.prototype._digest = function digest(enc) {
  56838. if (enc === 'hex')
  56839. return utils.toHex32(this.h, 'big');
  56840. else
  56841. return utils.split32(this.h, 'big');
  56842. };
  56843. function ch32(x, y, z) {
  56844. return (x & y) ^ ((~x) & z);
  56845. }
  56846. function maj32(x, y, z) {
  56847. return (x & y) ^ (x & z) ^ (y & z);
  56848. }
  56849. function p32(x, y, z) {
  56850. return x ^ y ^ z;
  56851. }
  56852. function s0_256(x) {
  56853. return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
  56854. }
  56855. function s1_256(x) {
  56856. return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);
  56857. }
  56858. function g0_256(x) {
  56859. return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3);
  56860. }
  56861. function g1_256(x) {
  56862. return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10);
  56863. }
  56864. function ft_1(s, x, y, z) {
  56865. if (s === 0)
  56866. return ch32(x, y, z);
  56867. if (s === 1 || s === 3)
  56868. return p32(x, y, z);
  56869. if (s === 2)
  56870. return maj32(x, y, z);
  56871. }
  56872. function ch64_hi(xh, xl, yh, yl, zh, zl) {
  56873. var r = (xh & yh) ^ ((~xh) & zh);
  56874. if (r < 0)
  56875. r += 0x100000000;
  56876. return r;
  56877. }
  56878. function ch64_lo(xh, xl, yh, yl, zh, zl) {
  56879. var r = (xl & yl) ^ ((~xl) & zl);
  56880. if (r < 0)
  56881. r += 0x100000000;
  56882. return r;
  56883. }
  56884. function maj64_hi(xh, xl, yh, yl, zh, zl) {
  56885. var r = (xh & yh) ^ (xh & zh) ^ (yh & zh);
  56886. if (r < 0)
  56887. r += 0x100000000;
  56888. return r;
  56889. }
  56890. function maj64_lo(xh, xl, yh, yl, zh, zl) {
  56891. var r = (xl & yl) ^ (xl & zl) ^ (yl & zl);
  56892. if (r < 0)
  56893. r += 0x100000000;
  56894. return r;
  56895. }
  56896. function s0_512_hi(xh, xl) {
  56897. var c0_hi = rotr64_hi(xh, xl, 28);
  56898. var c1_hi = rotr64_hi(xl, xh, 2); // 34
  56899. var c2_hi = rotr64_hi(xl, xh, 7); // 39
  56900. var r = c0_hi ^ c1_hi ^ c2_hi;
  56901. if (r < 0)
  56902. r += 0x100000000;
  56903. return r;
  56904. }
  56905. function s0_512_lo(xh, xl) {
  56906. var c0_lo = rotr64_lo(xh, xl, 28);
  56907. var c1_lo = rotr64_lo(xl, xh, 2); // 34
  56908. var c2_lo = rotr64_lo(xl, xh, 7); // 39
  56909. var r = c0_lo ^ c1_lo ^ c2_lo;
  56910. if (r < 0)
  56911. r += 0x100000000;
  56912. return r;
  56913. }
  56914. function s1_512_hi(xh, xl) {
  56915. var c0_hi = rotr64_hi(xh, xl, 14);
  56916. var c1_hi = rotr64_hi(xh, xl, 18);
  56917. var c2_hi = rotr64_hi(xl, xh, 9); // 41
  56918. var r = c0_hi ^ c1_hi ^ c2_hi;
  56919. if (r < 0)
  56920. r += 0x100000000;
  56921. return r;
  56922. }
  56923. function s1_512_lo(xh, xl) {
  56924. var c0_lo = rotr64_lo(xh, xl, 14);
  56925. var c1_lo = rotr64_lo(xh, xl, 18);
  56926. var c2_lo = rotr64_lo(xl, xh, 9); // 41
  56927. var r = c0_lo ^ c1_lo ^ c2_lo;
  56928. if (r < 0)
  56929. r += 0x100000000;
  56930. return r;
  56931. }
  56932. function g0_512_hi(xh, xl) {
  56933. var c0_hi = rotr64_hi(xh, xl, 1);
  56934. var c1_hi = rotr64_hi(xh, xl, 8);
  56935. var c2_hi = shr64_hi(xh, xl, 7);
  56936. var r = c0_hi ^ c1_hi ^ c2_hi;
  56937. if (r < 0)
  56938. r += 0x100000000;
  56939. return r;
  56940. }
  56941. function g0_512_lo(xh, xl) {
  56942. var c0_lo = rotr64_lo(xh, xl, 1);
  56943. var c1_lo = rotr64_lo(xh, xl, 8);
  56944. var c2_lo = shr64_lo(xh, xl, 7);
  56945. var r = c0_lo ^ c1_lo ^ c2_lo;
  56946. if (r < 0)
  56947. r += 0x100000000;
  56948. return r;
  56949. }
  56950. function g1_512_hi(xh, xl) {
  56951. var c0_hi = rotr64_hi(xh, xl, 19);
  56952. var c1_hi = rotr64_hi(xl, xh, 29); // 61
  56953. var c2_hi = shr64_hi(xh, xl, 6);
  56954. var r = c0_hi ^ c1_hi ^ c2_hi;
  56955. if (r < 0)
  56956. r += 0x100000000;
  56957. return r;
  56958. }
  56959. function g1_512_lo(xh, xl) {
  56960. var c0_lo = rotr64_lo(xh, xl, 19);
  56961. var c1_lo = rotr64_lo(xl, xh, 29); // 61
  56962. var c2_lo = shr64_lo(xh, xl, 6);
  56963. var r = c0_lo ^ c1_lo ^ c2_lo;
  56964. if (r < 0)
  56965. r += 0x100000000;
  56966. return r;
  56967. }
  56968. /***/ },
  56969. /* 509 */
  56970. /***/ function(module, exports, __webpack_require__) {
  56971. var utils = exports;
  56972. var inherits = __webpack_require__(2);
  56973. function toArray(msg, enc) {
  56974. if (Array.isArray(msg))
  56975. return msg.slice();
  56976. if (!msg)
  56977. return [];
  56978. var res = [];
  56979. if (typeof msg === 'string') {
  56980. if (!enc) {
  56981. for (var i = 0; i < msg.length; i++) {
  56982. var c = msg.charCodeAt(i);
  56983. var hi = c >> 8;
  56984. var lo = c & 0xff;
  56985. if (hi)
  56986. res.push(hi, lo);
  56987. else
  56988. res.push(lo);
  56989. }
  56990. } else if (enc === 'hex') {
  56991. msg = msg.replace(/[^a-z0-9]+/ig, '');
  56992. if (msg.length % 2 !== 0)
  56993. msg = '0' + msg;
  56994. for (var i = 0; i < msg.length; i += 2)
  56995. res.push(parseInt(msg[i] + msg[i + 1], 16));
  56996. }
  56997. } else {
  56998. for (var i = 0; i < msg.length; i++)
  56999. res[i] = msg[i] | 0;
  57000. }
  57001. return res;
  57002. }
  57003. utils.toArray = toArray;
  57004. function toHex(msg) {
  57005. var res = '';
  57006. for (var i = 0; i < msg.length; i++)
  57007. res += zero2(msg[i].toString(16));
  57008. return res;
  57009. }
  57010. utils.toHex = toHex;
  57011. function htonl(w) {
  57012. var res = (w >>> 24) |
  57013. ((w >>> 8) & 0xff00) |
  57014. ((w << 8) & 0xff0000) |
  57015. ((w & 0xff) << 24);
  57016. return res >>> 0;
  57017. }
  57018. utils.htonl = htonl;
  57019. function toHex32(msg, endian) {
  57020. var res = '';
  57021. for (var i = 0; i < msg.length; i++) {
  57022. var w = msg[i];
  57023. if (endian === 'little')
  57024. w = htonl(w);
  57025. res += zero8(w.toString(16));
  57026. }
  57027. return res;
  57028. }
  57029. utils.toHex32 = toHex32;
  57030. function zero2(word) {
  57031. if (word.length === 1)
  57032. return '0' + word;
  57033. else
  57034. return word;
  57035. }
  57036. utils.zero2 = zero2;
  57037. function zero8(word) {
  57038. if (word.length === 7)
  57039. return '0' + word;
  57040. else if (word.length === 6)
  57041. return '00' + word;
  57042. else if (word.length === 5)
  57043. return '000' + word;
  57044. else if (word.length === 4)
  57045. return '0000' + word;
  57046. else if (word.length === 3)
  57047. return '00000' + word;
  57048. else if (word.length === 2)
  57049. return '000000' + word;
  57050. else if (word.length === 1)
  57051. return '0000000' + word;
  57052. else
  57053. return word;
  57054. }
  57055. utils.zero8 = zero8;
  57056. function join32(msg, start, end, endian) {
  57057. var len = end - start;
  57058. assert(len % 4 === 0);
  57059. var res = new Array(len / 4);
  57060. for (var i = 0, k = start; i < res.length; i++, k += 4) {
  57061. var w;
  57062. if (endian === 'big')
  57063. w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];
  57064. else
  57065. w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];
  57066. res[i] = w >>> 0;
  57067. }
  57068. return res;
  57069. }
  57070. utils.join32 = join32;
  57071. function split32(msg, endian) {
  57072. var res = new Array(msg.length * 4);
  57073. for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
  57074. var m = msg[i];
  57075. if (endian === 'big') {
  57076. res[k] = m >>> 24;
  57077. res[k + 1] = (m >>> 16) & 0xff;
  57078. res[k + 2] = (m >>> 8) & 0xff;
  57079. res[k + 3] = m & 0xff;
  57080. } else {
  57081. res[k + 3] = m >>> 24;
  57082. res[k + 2] = (m >>> 16) & 0xff;
  57083. res[k + 1] = (m >>> 8) & 0xff;
  57084. res[k] = m & 0xff;
  57085. }
  57086. }
  57087. return res;
  57088. }
  57089. utils.split32 = split32;
  57090. function rotr32(w, b) {
  57091. return (w >>> b) | (w << (32 - b));
  57092. }
  57093. utils.rotr32 = rotr32;
  57094. function rotl32(w, b) {
  57095. return (w << b) | (w >>> (32 - b));
  57096. }
  57097. utils.rotl32 = rotl32;
  57098. function sum32(a, b) {
  57099. return (a + b) >>> 0;
  57100. }
  57101. utils.sum32 = sum32;
  57102. function sum32_3(a, b, c) {
  57103. return (a + b + c) >>> 0;
  57104. }
  57105. utils.sum32_3 = sum32_3;
  57106. function sum32_4(a, b, c, d) {
  57107. return (a + b + c + d) >>> 0;
  57108. }
  57109. utils.sum32_4 = sum32_4;
  57110. function sum32_5(a, b, c, d, e) {
  57111. return (a + b + c + d + e) >>> 0;
  57112. }
  57113. utils.sum32_5 = sum32_5;
  57114. function assert(cond, msg) {
  57115. if (!cond)
  57116. throw new Error(msg || 'Assertion failed');
  57117. }
  57118. utils.assert = assert;
  57119. utils.inherits = inherits;
  57120. function sum64(buf, pos, ah, al) {
  57121. var bh = buf[pos];
  57122. var bl = buf[pos + 1];
  57123. var lo = (al + bl) >>> 0;
  57124. var hi = (lo < al ? 1 : 0) + ah + bh;
  57125. buf[pos] = hi >>> 0;
  57126. buf[pos + 1] = lo;
  57127. }
  57128. exports.sum64 = sum64;
  57129. function sum64_hi(ah, al, bh, bl) {
  57130. var lo = (al + bl) >>> 0;
  57131. var hi = (lo < al ? 1 : 0) + ah + bh;
  57132. return hi >>> 0;
  57133. };
  57134. exports.sum64_hi = sum64_hi;
  57135. function sum64_lo(ah, al, bh, bl) {
  57136. var lo = al + bl;
  57137. return lo >>> 0;
  57138. };
  57139. exports.sum64_lo = sum64_lo;
  57140. function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) {
  57141. var carry = 0;
  57142. var lo = al;
  57143. lo = (lo + bl) >>> 0;
  57144. carry += lo < al ? 1 : 0;
  57145. lo = (lo + cl) >>> 0;
  57146. carry += lo < cl ? 1 : 0;
  57147. lo = (lo + dl) >>> 0;
  57148. carry += lo < dl ? 1 : 0;
  57149. var hi = ah + bh + ch + dh + carry;
  57150. return hi >>> 0;
  57151. };
  57152. exports.sum64_4_hi = sum64_4_hi;
  57153. function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) {
  57154. var lo = al + bl + cl + dl;
  57155. return lo >>> 0;
  57156. };
  57157. exports.sum64_4_lo = sum64_4_lo;
  57158. function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
  57159. var carry = 0;
  57160. var lo = al;
  57161. lo = (lo + bl) >>> 0;
  57162. carry += lo < al ? 1 : 0;
  57163. lo = (lo + cl) >>> 0;
  57164. carry += lo < cl ? 1 : 0;
  57165. lo = (lo + dl) >>> 0;
  57166. carry += lo < dl ? 1 : 0;
  57167. lo = (lo + el) >>> 0;
  57168. carry += lo < el ? 1 : 0;
  57169. var hi = ah + bh + ch + dh + eh + carry;
  57170. return hi >>> 0;
  57171. };
  57172. exports.sum64_5_hi = sum64_5_hi;
  57173. function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
  57174. var lo = al + bl + cl + dl + el;
  57175. return lo >>> 0;
  57176. };
  57177. exports.sum64_5_lo = sum64_5_lo;
  57178. function rotr64_hi(ah, al, num) {
  57179. var r = (al << (32 - num)) | (ah >>> num);
  57180. return r >>> 0;
  57181. };
  57182. exports.rotr64_hi = rotr64_hi;
  57183. function rotr64_lo(ah, al, num) {
  57184. var r = (ah << (32 - num)) | (al >>> num);
  57185. return r >>> 0;
  57186. };
  57187. exports.rotr64_lo = rotr64_lo;
  57188. function shr64_hi(ah, al, num) {
  57189. return ah >>> num;
  57190. };
  57191. exports.shr64_hi = shr64_hi;
  57192. function shr64_lo(ah, al, num) {
  57193. var r = (ah << (32 - num)) | (al >>> num);
  57194. return r >>> 0;
  57195. };
  57196. exports.shr64_lo = shr64_lo;
  57197. /***/ },
  57198. /* 510 */
  57199. /***/ function(module, exports, __webpack_require__) {
  57200. var http = __webpack_require__(220);
  57201. var https = module.exports;
  57202. for (var key in http) {
  57203. if (http.hasOwnProperty(key)) https[key] = http[key];
  57204. };
  57205. https.request = function (params, cb) {
  57206. if (!params) params = {};
  57207. params.scheme = 'https';
  57208. params.protocol = 'https:';
  57209. return http.request.call(this, params, cb);
  57210. }
  57211. /***/ },
  57212. /* 511 */
  57213. /***/ function(module, exports) {
  57214. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  57215. var e, m
  57216. var eLen = nBytes * 8 - mLen - 1
  57217. var eMax = (1 << eLen) - 1
  57218. var eBias = eMax >> 1
  57219. var nBits = -7
  57220. var i = isLE ? (nBytes - 1) : 0
  57221. var d = isLE ? -1 : 1
  57222. var s = buffer[offset + i]
  57223. i += d
  57224. e = s & ((1 << (-nBits)) - 1)
  57225. s >>= (-nBits)
  57226. nBits += eLen
  57227. for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  57228. m = e & ((1 << (-nBits)) - 1)
  57229. e >>= (-nBits)
  57230. nBits += mLen
  57231. for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  57232. if (e === 0) {
  57233. e = 1 - eBias
  57234. } else if (e === eMax) {
  57235. return m ? NaN : ((s ? -1 : 1) * Infinity)
  57236. } else {
  57237. m = m + Math.pow(2, mLen)
  57238. e = e - eBias
  57239. }
  57240. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  57241. }
  57242. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  57243. var e, m, c
  57244. var eLen = nBytes * 8 - mLen - 1
  57245. var eMax = (1 << eLen) - 1
  57246. var eBias = eMax >> 1
  57247. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  57248. var i = isLE ? 0 : (nBytes - 1)
  57249. var d = isLE ? 1 : -1
  57250. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  57251. value = Math.abs(value)
  57252. if (isNaN(value) || value === Infinity) {
  57253. m = isNaN(value) ? 1 : 0
  57254. e = eMax
  57255. } else {
  57256. e = Math.floor(Math.log(value) / Math.LN2)
  57257. if (value * (c = Math.pow(2, -e)) < 1) {
  57258. e--
  57259. c *= 2
  57260. }
  57261. if (e + eBias >= 1) {
  57262. value += rt / c
  57263. } else {
  57264. value += rt * Math.pow(2, 1 - eBias)
  57265. }
  57266. if (value * c >= 2) {
  57267. e++
  57268. c /= 2
  57269. }
  57270. if (e + eBias >= eMax) {
  57271. m = 0
  57272. e = eMax
  57273. } else if (e + eBias >= 1) {
  57274. m = (value * c - 1) * Math.pow(2, mLen)
  57275. e = e + eBias
  57276. } else {
  57277. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  57278. e = 0
  57279. }
  57280. }
  57281. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  57282. e = (e << mLen) | m
  57283. eLen += mLen
  57284. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  57285. buffer[offset + i - d] |= s * 128
  57286. }
  57287. /***/ },
  57288. /* 512 */
  57289. /***/ function(module, exports) {
  57290. var indexOf = [].indexOf;
  57291. module.exports = function(arr, obj){
  57292. if (indexOf) return arr.indexOf(obj);
  57293. for (var i = 0; i < arr.length; ++i) {
  57294. if (arr[i] === obj) return i;
  57295. }
  57296. return -1;
  57297. };
  57298. /***/ },
  57299. /* 513 */
  57300. /***/ function(module, exports, __webpack_require__) {
  57301. /* WEBPACK VAR INJECTION */(function(process) {var wrappy = __webpack_require__(228)
  57302. var reqs = Object.create(null)
  57303. var once = __webpack_require__(208)
  57304. module.exports = wrappy(inflight)
  57305. function inflight (key, cb) {
  57306. if (reqs[key]) {
  57307. reqs[key].push(cb)
  57308. return null
  57309. } else {
  57310. reqs[key] = [cb]
  57311. return makeres(key)
  57312. }
  57313. }
  57314. function makeres (key) {
  57315. return once(function RES () {
  57316. var cbs = reqs[key]
  57317. var len = cbs.length
  57318. var args = slice(arguments)
  57319. for (var i = 0; i < len; i++) {
  57320. cbs[i].apply(null, args)
  57321. }
  57322. if (cbs.length > len) {
  57323. // added more in the interim.
  57324. // de-zalgo, just in case, but don't call again.
  57325. cbs.splice(0, len)
  57326. process.nextTick(function () {
  57327. RES.apply(null, args)
  57328. })
  57329. } else {
  57330. delete reqs[key]
  57331. }
  57332. })
  57333. }
  57334. function slice (args) {
  57335. var length = args.length
  57336. var array = []
  57337. for (var i = 0; i < length; i++) array[i] = args[i]
  57338. return array
  57339. }
  57340. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  57341. /***/ },
  57342. /* 514 */
  57343. /***/ function(module, exports, __webpack_require__) {
  57344. "use strict";
  57345. 'use strict';
  57346. var ip = exports;
  57347. var Buffer = __webpack_require__(1).Buffer;
  57348. var os = __webpack_require__(209);
  57349. ip.toBuffer = function(ip, buff, offset) {
  57350. offset = ~~offset;
  57351. var result;
  57352. if (this.isV4Format(ip)) {
  57353. result = buff || new Buffer(offset + 4);
  57354. ip.split(/\./g).map(function(byte) {
  57355. result[offset++] = parseInt(byte, 10) & 0xff;
  57356. });
  57357. } else if (this.isV6Format(ip)) {
  57358. var sections = ip.split(':', 8);
  57359. var i;
  57360. for (i = 0; i < sections.length; i++) {
  57361. var isv4 = this.isV4Format(sections[i]);
  57362. var v4Buffer;
  57363. if (isv4) {
  57364. v4Buffer = this.toBuffer(sections[i]);
  57365. sections[i] = v4Buffer.slice(0, 2).toString('hex');
  57366. }
  57367. if (v4Buffer && ++i < 8) {
  57368. sections.splice(i, 0, v4Buffer.slice(2, 4).toString('hex'));
  57369. }
  57370. }
  57371. if (sections[0] === '') {
  57372. while (sections.length < 8) sections.unshift('0');
  57373. } else if (sections[sections.length - 1] === '') {
  57374. while (sections.length < 8) sections.push('0');
  57375. } else if (sections.length < 8) {
  57376. for (i = 0; i < sections.length && sections[i] !== ''; i++);
  57377. var argv = [ i, 1 ];
  57378. for (i = 9 - sections.length; i > 0; i--) {
  57379. argv.push('0');
  57380. }
  57381. sections.splice.apply(sections, argv);
  57382. }
  57383. result = buff || new Buffer(offset + 16);
  57384. for (i = 0; i < sections.length; i++) {
  57385. var word = parseInt(sections[i], 16);
  57386. result[offset++] = (word >> 8) & 0xff;
  57387. result[offset++] = word & 0xff;
  57388. }
  57389. }
  57390. if (!result) {
  57391. throw Error('Invalid ip address: ' + ip);
  57392. }
  57393. return result;
  57394. };
  57395. ip.toString = function(buff, offset, length) {
  57396. offset = ~~offset;
  57397. length = length || (buff.length - offset);
  57398. var result = [];
  57399. if (length === 4) {
  57400. // IPv4
  57401. for (var i = 0; i < length; i++) {
  57402. result.push(buff[offset + i]);
  57403. }
  57404. result = result.join('.');
  57405. } else if (length === 16) {
  57406. // IPv6
  57407. for (var i = 0; i < length; i += 2) {
  57408. result.push(buff.readUInt16BE(offset + i).toString(16));
  57409. }
  57410. result = result.join(':');
  57411. result = result.replace(/(^|:)0(:0)*:0(:|$)/, '$1::$3');
  57412. result = result.replace(/:{3,4}/, '::');
  57413. }
  57414. return result;
  57415. };
  57416. var ipv4Regex = /^(\d{1,3}\.){3,3}\d{1,3}$/;
  57417. var ipv6Regex =
  57418. /^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i;
  57419. ip.isV4Format = function(ip) {
  57420. return ipv4Regex.test(ip);
  57421. };
  57422. ip.isV6Format = function(ip) {
  57423. return ipv6Regex.test(ip);
  57424. };
  57425. function _normalizeFamily(family) {
  57426. return family ? family.toLowerCase() : 'ipv4';
  57427. }
  57428. ip.fromPrefixLen = function(prefixlen, family) {
  57429. if (prefixlen > 32) {
  57430. family = 'ipv6';
  57431. } else {
  57432. family = _normalizeFamily(family);
  57433. }
  57434. var len = 4;
  57435. if (family === 'ipv6') {
  57436. len = 16;
  57437. }
  57438. var buff = new Buffer(len);
  57439. for (var i = 0, n = buff.length; i < n; ++i) {
  57440. var bits = 8;
  57441. if (prefixlen < 8) {
  57442. bits = prefixlen;
  57443. }
  57444. prefixlen -= bits;
  57445. buff[i] = ~(0xff >> bits);
  57446. }
  57447. return ip.toString(buff);
  57448. };
  57449. ip.mask = function(addr, mask) {
  57450. addr = ip.toBuffer(addr);
  57451. mask = ip.toBuffer(mask);
  57452. var result = new Buffer(Math.max(addr.length, mask.length));
  57453. // Same protocol - do bitwise and
  57454. if (addr.length === mask.length) {
  57455. for (var i = 0; i < addr.length; i++) {
  57456. result[i] = addr[i] & mask[i];
  57457. }
  57458. } else if (mask.length === 4) {
  57459. // IPv6 address and IPv4 mask
  57460. // (Mask low bits)
  57461. for (var i = 0; i < mask.length; i++) {
  57462. result[i] = addr[addr.length - 4 + i] & mask[i];
  57463. }
  57464. } else {
  57465. // IPv6 mask and IPv4 addr
  57466. for (var i = 0; i < result.length - 6; i++) {
  57467. result[i] = 0;
  57468. }
  57469. // ::ffff:ipv4
  57470. result[10] = 0xff;
  57471. result[11] = 0xff;
  57472. for (var i = 0; i < addr.length; i++) {
  57473. result[i + 12] = addr[i] & mask[i + 12];
  57474. }
  57475. }
  57476. return ip.toString(result);
  57477. };
  57478. ip.cidr = function(cidrString) {
  57479. var cidrParts = cidrString.split('/');
  57480. var addr = cidrParts[0];
  57481. if (cidrParts.length !== 2)
  57482. throw new Error('invalid CIDR subnet: ' + addr);
  57483. var mask = ip.fromPrefixLen(parseInt(cidrParts[1], 10));
  57484. return ip.mask(addr, mask);
  57485. };
  57486. ip.subnet = function(addr, mask) {
  57487. var networkAddress = ip.toLong(ip.mask(addr, mask));
  57488. // Calculate the mask's length.
  57489. var maskBuffer = ip.toBuffer(mask);
  57490. var maskLength = 0;
  57491. for (var i = 0; i < maskBuffer.length; i++) {
  57492. if (maskBuffer[i] === 0xff) {
  57493. maskLength += 8;
  57494. } else {
  57495. var octet = maskBuffer[i] & 0xff;
  57496. while (octet) {
  57497. octet = (octet << 1) & 0xff;
  57498. maskLength++;
  57499. }
  57500. }
  57501. }
  57502. var numberOfAddresses = Math.pow(2, 32 - maskLength);
  57503. return {
  57504. networkAddress: ip.fromLong(networkAddress),
  57505. firstAddress: numberOfAddresses <= 2 ?
  57506. ip.fromLong(networkAddress) :
  57507. ip.fromLong(networkAddress + 1),
  57508. lastAddress: numberOfAddresses <= 2 ?
  57509. ip.fromLong(networkAddress + numberOfAddresses - 1) :
  57510. ip.fromLong(networkAddress + numberOfAddresses - 2),
  57511. broadcastAddress: ip.fromLong(networkAddress + numberOfAddresses - 1),
  57512. subnetMask: mask,
  57513. subnetMaskLength: maskLength,
  57514. numHosts: numberOfAddresses <= 2 ?
  57515. numberOfAddresses : numberOfAddresses - 2,
  57516. length: numberOfAddresses,
  57517. contains: function(other) {
  57518. return networkAddress === ip.toLong(ip.mask(other, mask));
  57519. }
  57520. };
  57521. };
  57522. ip.cidrSubnet = function(cidrString) {
  57523. var cidrParts = cidrString.split('/');
  57524. var addr = cidrParts[0];
  57525. if (cidrParts.length !== 2)
  57526. throw new Error('invalid CIDR subnet: ' + addr);
  57527. var mask = ip.fromPrefixLen(parseInt(cidrParts[1], 10));
  57528. return ip.subnet(addr, mask);
  57529. };
  57530. ip.not = function(addr) {
  57531. var buff = ip.toBuffer(addr);
  57532. for (var i = 0; i < buff.length; i++) {
  57533. buff[i] = 0xff ^ buff[i];
  57534. }
  57535. return ip.toString(buff);
  57536. };
  57537. ip.or = function(a, b) {
  57538. a = ip.toBuffer(a);
  57539. b = ip.toBuffer(b);
  57540. // same protocol
  57541. if (a.length === b.length) {
  57542. for (var i = 0; i < a.length; ++i) {
  57543. a[i] |= b[i];
  57544. }
  57545. return ip.toString(a);
  57546. // mixed protocols
  57547. } else {
  57548. var buff = a;
  57549. var other = b;
  57550. if (b.length > a.length) {
  57551. buff = b;
  57552. other = a;
  57553. }
  57554. var offset = buff.length - other.length;
  57555. for (var i = offset; i < buff.length; ++i) {
  57556. buff[i] |= other[i - offset];
  57557. }
  57558. return ip.toString(buff);
  57559. }
  57560. };
  57561. ip.isEqual = function(a, b) {
  57562. a = ip.toBuffer(a);
  57563. b = ip.toBuffer(b);
  57564. // Same protocol
  57565. if (a.length === b.length) {
  57566. for (var i = 0; i < a.length; i++) {
  57567. if (a[i] !== b[i]) return false;
  57568. }
  57569. return true;
  57570. }
  57571. // Swap
  57572. if (b.length === 4) {
  57573. var t = b;
  57574. b = a;
  57575. a = t;
  57576. }
  57577. // a - IPv4, b - IPv6
  57578. for (var i = 0; i < 10; i++) {
  57579. if (b[i] !== 0) return false;
  57580. }
  57581. var word = b.readUInt16BE(10);
  57582. if (word !== 0 && word !== 0xffff) return false;
  57583. for (var i = 0; i < 4; i++) {
  57584. if (a[i] !== b[i + 12]) return false;
  57585. }
  57586. return true;
  57587. };
  57588. ip.isPrivate = function(addr) {
  57589. return /^(::f{4}:)?10\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i
  57590. .test(addr) ||
  57591. /^(::f{4}:)?192\.168\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) ||
  57592. /^(::f{4}:)?172\.(1[6-9]|2\d|30|31)\.([0-9]{1,3})\.([0-9]{1,3})$/i
  57593. .test(addr) ||
  57594. /^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) ||
  57595. /^(::f{4}:)?169\.254\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) ||
  57596. /^f[cd][0-9a-f]{2}:/i.test(addr) ||
  57597. /^fe80:/i.test(addr) ||
  57598. /^::1$/.test(addr) ||
  57599. /^::$/.test(addr);
  57600. };
  57601. ip.isPublic = function(addr) {
  57602. return !ip.isPrivate(addr);
  57603. };
  57604. ip.isLoopback = function(addr) {
  57605. return /^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/
  57606. .test(addr) ||
  57607. /^fe80::1$/.test(addr) ||
  57608. /^::1$/.test(addr) ||
  57609. /^::$/.test(addr);
  57610. };
  57611. ip.loopback = function(family) {
  57612. //
  57613. // Default to `ipv4`
  57614. //
  57615. family = _normalizeFamily(family);
  57616. if (family !== 'ipv4' && family !== 'ipv6') {
  57617. throw new Error('family must be ipv4 or ipv6');
  57618. }
  57619. return family === 'ipv4' ? '127.0.0.1' : 'fe80::1';
  57620. };
  57621. //
  57622. // ### function address (name, family)
  57623. // #### @name {string|'public'|'private'} **Optional** Name or security
  57624. // of the network interface.
  57625. // #### @family {ipv4|ipv6} **Optional** IP family of the address (defaults
  57626. // to ipv4).
  57627. //
  57628. // Returns the address for the network interface on the current system with
  57629. // the specified `name`:
  57630. // * String: First `family` address of the interface.
  57631. // If not found see `undefined`.
  57632. // * 'public': the first public ip address of family.
  57633. // * 'private': the first private ip address of family.
  57634. // * undefined: First address with `ipv4` or loopback address `127.0.0.1`.
  57635. //
  57636. ip.address = function(name, family) {
  57637. var interfaces = os.networkInterfaces();
  57638. var all;
  57639. //
  57640. // Default to `ipv4`
  57641. //
  57642. family = _normalizeFamily(family);
  57643. //
  57644. // If a specific network interface has been named,
  57645. // return the address.
  57646. //
  57647. if (name && name !== 'private' && name !== 'public') {
  57648. var res = interfaces[name].filter(function(details) {
  57649. var itemFamily = details.family.toLowerCase();
  57650. return itemFamily === family;
  57651. });
  57652. if (res.length === 0)
  57653. return undefined;
  57654. return res[0].address;
  57655. }
  57656. var all = Object.keys(interfaces).map(function (nic) {
  57657. //
  57658. // Note: name will only be `public` or `private`
  57659. // when this is called.
  57660. //
  57661. var addresses = interfaces[nic].filter(function (details) {
  57662. details.family = details.family.toLowerCase();
  57663. if (details.family !== family || ip.isLoopback(details.address)) {
  57664. return false;
  57665. } else if (!name) {
  57666. return true;
  57667. }
  57668. return name === 'public' ? ip.isPrivate(details.address) :
  57669. ip.isPublic(details.address);
  57670. });
  57671. return addresses.length ? addresses[0].address : undefined;
  57672. }).filter(Boolean);
  57673. return !all.length ? ip.loopback(family) : all[0];
  57674. };
  57675. ip.toLong = function(ip) {
  57676. var ipl = 0;
  57677. ip.split('.').forEach(function(octet) {
  57678. ipl <<= 8;
  57679. ipl += parseInt(octet);
  57680. });
  57681. return(ipl >>> 0);
  57682. };
  57683. ip.fromLong = function(ipl) {
  57684. return ((ipl >>> 24) + '.' +
  57685. (ipl >> 16 & 255) + '.' +
  57686. (ipl >> 8 & 255) + '.' +
  57687. (ipl & 255) );
  57688. };
  57689. /***/ },
  57690. /* 515 */
  57691. /***/ function(module, exports) {
  57692. "use strict";
  57693. "use strict"
  57694. function isProperty(str) {
  57695. return /^[$A-Z\_a-z\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc][$A-Z\_a-z\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc0-9\u0300-\u036f\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08e4-\u08fe\u0900-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d02\u0d03\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19b0-\u19c0\u19c8\u19c9\u19d0-\u19d9\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf2-\u1cf4\u1dc0-\u1de6\u1dfc-\u1dff\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua880\ua881\ua8b4-\ua8c4\ua8d0-\ua8d9\ua8e0-\ua8f1\ua900-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f]*$/.test(str)
  57696. }
  57697. module.exports = isProperty
  57698. /***/ },
  57699. /* 516 */
  57700. /***/ function(module, exports) {
  57701. "use strict";
  57702. 'use strict';
  57703. var isStream = module.exports = function (stream) {
  57704. return stream !== null && typeof stream === 'object' && typeof stream.pipe === 'function';
  57705. };
  57706. isStream.writable = function (stream) {
  57707. return isStream(stream) && stream.writable !== false && typeof stream._write === 'function' && typeof stream._writableState === 'object';
  57708. };
  57709. isStream.readable = function (stream) {
  57710. return isStream(stream) && stream.readable !== false && typeof stream._read === 'function' && typeof stream._readableState === 'object';
  57711. };
  57712. isStream.duplex = function (stream) {
  57713. return isStream.writable(stream) && isStream.readable(stream);
  57714. };
  57715. isStream.transform = function (stream) {
  57716. return isStream.duplex(stream) && typeof stream._transform === 'function' && typeof stream._transformState === 'object';
  57717. };
  57718. /***/ },
  57719. /* 517 */
  57720. /***/ function(module, exports, __webpack_require__) {
  57721. var stream = __webpack_require__(9)
  57722. function isStream (obj) {
  57723. return obj instanceof stream.Stream
  57724. }
  57725. function isReadable (obj) {
  57726. return isStream(obj) && typeof obj._read == 'function' && typeof obj._readableState == 'object'
  57727. }
  57728. function isWritable (obj) {
  57729. return isStream(obj) && typeof obj._write == 'function' && typeof obj._writableState == 'object'
  57730. }
  57731. function isDuplex (obj) {
  57732. return isReadable(obj) && isWritable(obj)
  57733. }
  57734. module.exports = isStream
  57735. module.exports.isReadable = isReadable
  57736. module.exports.isWritable = isWritable
  57737. module.exports.isDuplex = isDuplex
  57738. /***/ },
  57739. /* 518 */
  57740. /***/ function(module, exports, __webpack_require__) {
  57741. /**
  57742. * lodash 4.0.1 (Custom Build) <https://lodash.com/>
  57743. * Build: `lodash modularize exports="npm" -o ./`
  57744. * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
  57745. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  57746. * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  57747. * Available under MIT license <https://lodash.com/license>
  57748. */
  57749. var baseEach = __webpack_require__(202);
  57750. /**
  57751. * The base implementation of `_.filter` without support for iteratee shorthands.
  57752. *
  57753. * @private
  57754. * @param {Array|Object} collection The collection to iterate over.
  57755. * @param {Function} predicate The function invoked per iteration.
  57756. * @returns {Array} Returns the new filtered array.
  57757. */
  57758. function baseFilter(collection, predicate) {
  57759. var result = [];
  57760. baseEach(collection, function(value, index, collection) {
  57761. if (predicate(value, index, collection)) {
  57762. result.push(value);
  57763. }
  57764. });
  57765. return result;
  57766. }
  57767. module.exports = baseFilter;
  57768. /***/ },
  57769. /* 519 */
  57770. /***/ function(module, exports, __webpack_require__) {
  57771. /* WEBPACK VAR INJECTION */(function(module, global) {/**
  57772. * lodash (Custom Build) <https://lodash.com/>
  57773. * Build: `lodash modularize exports="npm" -o ./`
  57774. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  57775. * Released under MIT license <https://lodash.com/license>
  57776. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  57777. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  57778. */
  57779. /** Used as references for various `Number` constants. */
  57780. var INFINITY = 1 / 0;
  57781. /** `Object#toString` result references. */
  57782. var symbolTag = '[object Symbol]';
  57783. /** Used to determine if values are of the language type `Object`. */
  57784. var objectTypes = {
  57785. 'function': true,
  57786. 'object': true
  57787. };
  57788. /** Detect free variable `exports`. */
  57789. var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType)
  57790. ? exports
  57791. : undefined;
  57792. /** Detect free variable `module`. */
  57793. var freeModule = (objectTypes[typeof module] && module && !module.nodeType)
  57794. ? module
  57795. : undefined;
  57796. /** Detect free variable `global` from Node.js. */
  57797. var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global);
  57798. /** Detect free variable `self`. */
  57799. var freeSelf = checkGlobal(objectTypes[typeof self] && self);
  57800. /** Detect free variable `window`. */
  57801. var freeWindow = checkGlobal(objectTypes[typeof window] && window);
  57802. /** Detect `this` as the global object. */
  57803. var thisGlobal = checkGlobal(objectTypes[typeof this] && this);
  57804. /**
  57805. * Used as a reference to the global object.
  57806. *
  57807. * The `this` value is used if it's the global object to avoid Greasemonkey's
  57808. * restricted `window` object, otherwise the `window` object is used.
  57809. */
  57810. var root = freeGlobal ||
  57811. ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) ||
  57812. freeSelf || thisGlobal || Function('return this')();
  57813. /**
  57814. * Checks if `value` is a global object.
  57815. *
  57816. * @private
  57817. * @param {*} value The value to check.
  57818. * @returns {null|Object} Returns `value` if it's a global object, else `null`.
  57819. */
  57820. function checkGlobal(value) {
  57821. return (value && value.Object === Object) ? value : null;
  57822. }
  57823. /** Used for built-in method references. */
  57824. var objectProto = Object.prototype;
  57825. /**
  57826. * Used to resolve the
  57827. * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  57828. * of values.
  57829. */
  57830. var objectToString = objectProto.toString;
  57831. /** Built-in value references. */
  57832. var Symbol = root.Symbol;
  57833. /** Used to convert symbols to primitives and strings. */
  57834. var symbolProto = Symbol ? Symbol.prototype : undefined,
  57835. symbolToString = symbolProto ? symbolProto.toString : undefined;
  57836. /**
  57837. * The base implementation of `_.toString` which doesn't convert nullish
  57838. * values to empty strings.
  57839. *
  57840. * @private
  57841. * @param {*} value The value to process.
  57842. * @returns {string} Returns the string.
  57843. */
  57844. function baseToString(value) {
  57845. // Exit early for strings to avoid a performance hit in some environments.
  57846. if (typeof value == 'string') {
  57847. return value;
  57848. }
  57849. if (isSymbol(value)) {
  57850. return symbolToString ? symbolToString.call(value) : '';
  57851. }
  57852. var result = (value + '');
  57853. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  57854. }
  57855. /**
  57856. * Checks if `value` is object-like. A value is object-like if it's not `null`
  57857. * and has a `typeof` result of "object".
  57858. *
  57859. * @static
  57860. * @memberOf _
  57861. * @since 4.0.0
  57862. * @category Lang
  57863. * @param {*} value The value to check.
  57864. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  57865. * @example
  57866. *
  57867. * _.isObjectLike({});
  57868. * // => true
  57869. *
  57870. * _.isObjectLike([1, 2, 3]);
  57871. * // => true
  57872. *
  57873. * _.isObjectLike(_.noop);
  57874. * // => false
  57875. *
  57876. * _.isObjectLike(null);
  57877. * // => false
  57878. */
  57879. function isObjectLike(value) {
  57880. return !!value && typeof value == 'object';
  57881. }
  57882. /**
  57883. * Checks if `value` is classified as a `Symbol` primitive or object.
  57884. *
  57885. * @static
  57886. * @memberOf _
  57887. * @since 4.0.0
  57888. * @category Lang
  57889. * @param {*} value The value to check.
  57890. * @returns {boolean} Returns `true` if `value` is correctly classified,
  57891. * else `false`.
  57892. * @example
  57893. *
  57894. * _.isSymbol(Symbol.iterator);
  57895. * // => true
  57896. *
  57897. * _.isSymbol('abc');
  57898. * // => false
  57899. */
  57900. function isSymbol(value) {
  57901. return typeof value == 'symbol' ||
  57902. (isObjectLike(value) && objectToString.call(value) == symbolTag);
  57903. }
  57904. module.exports = baseToString;
  57905. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(76)(module), __webpack_require__(13)))
  57906. /***/ },
  57907. /* 520 */
  57908. /***/ function(module, exports, __webpack_require__) {
  57909. /* WEBPACK VAR INJECTION */(function(module, global) {/**
  57910. * lodash (Custom Build) <https://lodash.com/>
  57911. * Build: `lodash modularize exports="npm" -o ./`
  57912. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  57913. * Released under MIT license <https://lodash.com/license>
  57914. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  57915. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  57916. */
  57917. var baseToString = __webpack_require__(519);
  57918. /** Used as the `TypeError` message for "Functions" methods. */
  57919. var FUNC_ERROR_TEXT = 'Expected a function';
  57920. /** Used to stand-in for `undefined` hash values. */
  57921. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  57922. /** `Object#toString` result references. */
  57923. var funcTag = '[object Function]',
  57924. genTag = '[object GeneratorFunction]';
  57925. /** Used to match property names within property paths. */
  57926. var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]/g;
  57927. /**
  57928. * Used to match `RegExp`
  57929. * [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns).
  57930. */
  57931. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  57932. /** Used to match backslashes in property paths. */
  57933. var reEscapeChar = /\\(\\)?/g;
  57934. /** Used to detect host constructors (Safari). */
  57935. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  57936. /** Used to determine if values are of the language type `Object`. */
  57937. var objectTypes = {
  57938. 'function': true,
  57939. 'object': true
  57940. };
  57941. /** Detect free variable `exports`. */
  57942. var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType)
  57943. ? exports
  57944. : undefined;
  57945. /** Detect free variable `module`. */
  57946. var freeModule = (objectTypes[typeof module] && module && !module.nodeType)
  57947. ? module
  57948. : undefined;
  57949. /** Detect free variable `global` from Node.js. */
  57950. var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global);
  57951. /** Detect free variable `self`. */
  57952. var freeSelf = checkGlobal(objectTypes[typeof self] && self);
  57953. /** Detect free variable `window`. */
  57954. var freeWindow = checkGlobal(objectTypes[typeof window] && window);
  57955. /** Detect `this` as the global object. */
  57956. var thisGlobal = checkGlobal(objectTypes[typeof this] && this);
  57957. /**
  57958. * Used as a reference to the global object.
  57959. *
  57960. * The `this` value is used if it's the global object to avoid Greasemonkey's
  57961. * restricted `window` object, otherwise the `window` object is used.
  57962. */
  57963. var root = freeGlobal ||
  57964. ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) ||
  57965. freeSelf || thisGlobal || Function('return this')();
  57966. /**
  57967. * Checks if `value` is a global object.
  57968. *
  57969. * @private
  57970. * @param {*} value The value to check.
  57971. * @returns {null|Object} Returns `value` if it's a global object, else `null`.
  57972. */
  57973. function checkGlobal(value) {
  57974. return (value && value.Object === Object) ? value : null;
  57975. }
  57976. /**
  57977. * Checks if `value` is a host object in IE < 9.
  57978. *
  57979. * @private
  57980. * @param {*} value The value to check.
  57981. * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
  57982. */
  57983. function isHostObject(value) {
  57984. // Many host objects are `Object` objects that can coerce to strings
  57985. // despite having improperly defined `toString` methods.
  57986. var result = false;
  57987. if (value != null && typeof value.toString != 'function') {
  57988. try {
  57989. result = !!(value + '');
  57990. } catch (e) {}
  57991. }
  57992. return result;
  57993. }
  57994. /** Used for built-in method references. */
  57995. var arrayProto = Array.prototype,
  57996. objectProto = Object.prototype;
  57997. /** Used to resolve the decompiled source of functions. */
  57998. var funcToString = Function.prototype.toString;
  57999. /** Used to check objects for own properties. */
  58000. var hasOwnProperty = objectProto.hasOwnProperty;
  58001. /**
  58002. * Used to resolve the
  58003. * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  58004. * of values.
  58005. */
  58006. var objectToString = objectProto.toString;
  58007. /** Used to detect if a method is native. */
  58008. var reIsNative = RegExp('^' +
  58009. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  58010. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  58011. );
  58012. /** Built-in value references. */
  58013. var splice = arrayProto.splice;
  58014. /* Built-in method references that are verified to be native. */
  58015. var Map = getNative(root, 'Map'),
  58016. nativeCreate = getNative(Object, 'create');
  58017. /**
  58018. * Creates a hash object.
  58019. *
  58020. * @private
  58021. * @constructor
  58022. * @param {Array} [entries] The key-value pairs to cache.
  58023. */
  58024. function Hash(entries) {
  58025. var index = -1,
  58026. length = entries ? entries.length : 0;
  58027. this.clear();
  58028. while (++index < length) {
  58029. var entry = entries[index];
  58030. this.set(entry[0], entry[1]);
  58031. }
  58032. }
  58033. /**
  58034. * Removes all key-value entries from the hash.
  58035. *
  58036. * @private
  58037. * @name clear
  58038. * @memberOf Hash
  58039. */
  58040. function hashClear() {
  58041. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  58042. }
  58043. /**
  58044. * Removes `key` and its value from the hash.
  58045. *
  58046. * @private
  58047. * @name delete
  58048. * @memberOf Hash
  58049. * @param {Object} hash The hash to modify.
  58050. * @param {string} key The key of the value to remove.
  58051. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  58052. */
  58053. function hashDelete(key) {
  58054. return this.has(key) && delete this.__data__[key];
  58055. }
  58056. /**
  58057. * Gets the hash value for `key`.
  58058. *
  58059. * @private
  58060. * @name get
  58061. * @memberOf Hash
  58062. * @param {string} key The key of the value to get.
  58063. * @returns {*} Returns the entry value.
  58064. */
  58065. function hashGet(key) {
  58066. var data = this.__data__;
  58067. if (nativeCreate) {
  58068. var result = data[key];
  58069. return result === HASH_UNDEFINED ? undefined : result;
  58070. }
  58071. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  58072. }
  58073. /**
  58074. * Checks if a hash value for `key` exists.
  58075. *
  58076. * @private
  58077. * @name has
  58078. * @memberOf Hash
  58079. * @param {string} key The key of the entry to check.
  58080. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  58081. */
  58082. function hashHas(key) {
  58083. var data = this.__data__;
  58084. return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
  58085. }
  58086. /**
  58087. * Sets the hash `key` to `value`.
  58088. *
  58089. * @private
  58090. * @name set
  58091. * @memberOf Hash
  58092. * @param {string} key The key of the value to set.
  58093. * @param {*} value The value to set.
  58094. * @returns {Object} Returns the hash instance.
  58095. */
  58096. function hashSet(key, value) {
  58097. var data = this.__data__;
  58098. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  58099. return this;
  58100. }
  58101. // Add methods to `Hash`.
  58102. Hash.prototype.clear = hashClear;
  58103. Hash.prototype['delete'] = hashDelete;
  58104. Hash.prototype.get = hashGet;
  58105. Hash.prototype.has = hashHas;
  58106. Hash.prototype.set = hashSet;
  58107. /**
  58108. * Creates an list cache object.
  58109. *
  58110. * @private
  58111. * @constructor
  58112. * @param {Array} [entries] The key-value pairs to cache.
  58113. */
  58114. function ListCache(entries) {
  58115. var index = -1,
  58116. length = entries ? entries.length : 0;
  58117. this.clear();
  58118. while (++index < length) {
  58119. var entry = entries[index];
  58120. this.set(entry[0], entry[1]);
  58121. }
  58122. }
  58123. /**
  58124. * Removes all key-value entries from the list cache.
  58125. *
  58126. * @private
  58127. * @name clear
  58128. * @memberOf ListCache
  58129. */
  58130. function listCacheClear() {
  58131. this.__data__ = [];
  58132. }
  58133. /**
  58134. * Removes `key` and its value from the list cache.
  58135. *
  58136. * @private
  58137. * @name delete
  58138. * @memberOf ListCache
  58139. * @param {string} key The key of the value to remove.
  58140. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  58141. */
  58142. function listCacheDelete(key) {
  58143. var data = this.__data__,
  58144. index = assocIndexOf(data, key);
  58145. if (index < 0) {
  58146. return false;
  58147. }
  58148. var lastIndex = data.length - 1;
  58149. if (index == lastIndex) {
  58150. data.pop();
  58151. } else {
  58152. splice.call(data, index, 1);
  58153. }
  58154. return true;
  58155. }
  58156. /**
  58157. * Gets the list cache value for `key`.
  58158. *
  58159. * @private
  58160. * @name get
  58161. * @memberOf ListCache
  58162. * @param {string} key The key of the value to get.
  58163. * @returns {*} Returns the entry value.
  58164. */
  58165. function listCacheGet(key) {
  58166. var data = this.__data__,
  58167. index = assocIndexOf(data, key);
  58168. return index < 0 ? undefined : data[index][1];
  58169. }
  58170. /**
  58171. * Checks if a list cache value for `key` exists.
  58172. *
  58173. * @private
  58174. * @name has
  58175. * @memberOf ListCache
  58176. * @param {string} key The key of the entry to check.
  58177. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  58178. */
  58179. function listCacheHas(key) {
  58180. return assocIndexOf(this.__data__, key) > -1;
  58181. }
  58182. /**
  58183. * Sets the list cache `key` to `value`.
  58184. *
  58185. * @private
  58186. * @name set
  58187. * @memberOf ListCache
  58188. * @param {string} key The key of the value to set.
  58189. * @param {*} value The value to set.
  58190. * @returns {Object} Returns the list cache instance.
  58191. */
  58192. function listCacheSet(key, value) {
  58193. var data = this.__data__,
  58194. index = assocIndexOf(data, key);
  58195. if (index < 0) {
  58196. data.push([key, value]);
  58197. } else {
  58198. data[index][1] = value;
  58199. }
  58200. return this;
  58201. }
  58202. // Add methods to `ListCache`.
  58203. ListCache.prototype.clear = listCacheClear;
  58204. ListCache.prototype['delete'] = listCacheDelete;
  58205. ListCache.prototype.get = listCacheGet;
  58206. ListCache.prototype.has = listCacheHas;
  58207. ListCache.prototype.set = listCacheSet;
  58208. /**
  58209. * Creates a map cache object to store key-value pairs.
  58210. *
  58211. * @private
  58212. * @constructor
  58213. * @param {Array} [entries] The key-value pairs to cache.
  58214. */
  58215. function MapCache(entries) {
  58216. var index = -1,
  58217. length = entries ? entries.length : 0;
  58218. this.clear();
  58219. while (++index < length) {
  58220. var entry = entries[index];
  58221. this.set(entry[0], entry[1]);
  58222. }
  58223. }
  58224. /**
  58225. * Removes all key-value entries from the map.
  58226. *
  58227. * @private
  58228. * @name clear
  58229. * @memberOf MapCache
  58230. */
  58231. function mapCacheClear() {
  58232. this.__data__ = {
  58233. 'hash': new Hash,
  58234. 'map': new (Map || ListCache),
  58235. 'string': new Hash
  58236. };
  58237. }
  58238. /**
  58239. * Removes `key` and its value from the map.
  58240. *
  58241. * @private
  58242. * @name delete
  58243. * @memberOf MapCache
  58244. * @param {string} key The key of the value to remove.
  58245. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  58246. */
  58247. function mapCacheDelete(key) {
  58248. return getMapData(this, key)['delete'](key);
  58249. }
  58250. /**
  58251. * Gets the map value for `key`.
  58252. *
  58253. * @private
  58254. * @name get
  58255. * @memberOf MapCache
  58256. * @param {string} key The key of the value to get.
  58257. * @returns {*} Returns the entry value.
  58258. */
  58259. function mapCacheGet(key) {
  58260. return getMapData(this, key).get(key);
  58261. }
  58262. /**
  58263. * Checks if a map value for `key` exists.
  58264. *
  58265. * @private
  58266. * @name has
  58267. * @memberOf MapCache
  58268. * @param {string} key The key of the entry to check.
  58269. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  58270. */
  58271. function mapCacheHas(key) {
  58272. return getMapData(this, key).has(key);
  58273. }
  58274. /**
  58275. * Sets the map `key` to `value`.
  58276. *
  58277. * @private
  58278. * @name set
  58279. * @memberOf MapCache
  58280. * @param {string} key The key of the value to set.
  58281. * @param {*} value The value to set.
  58282. * @returns {Object} Returns the map cache instance.
  58283. */
  58284. function mapCacheSet(key, value) {
  58285. getMapData(this, key).set(key, value);
  58286. return this;
  58287. }
  58288. // Add methods to `MapCache`.
  58289. MapCache.prototype.clear = mapCacheClear;
  58290. MapCache.prototype['delete'] = mapCacheDelete;
  58291. MapCache.prototype.get = mapCacheGet;
  58292. MapCache.prototype.has = mapCacheHas;
  58293. MapCache.prototype.set = mapCacheSet;
  58294. /**
  58295. * Gets the index at which the `key` is found in `array` of key-value pairs.
  58296. *
  58297. * @private
  58298. * @param {Array} array The array to search.
  58299. * @param {*} key The key to search for.
  58300. * @returns {number} Returns the index of the matched value, else `-1`.
  58301. */
  58302. function assocIndexOf(array, key) {
  58303. var length = array.length;
  58304. while (length--) {
  58305. if (eq(array[length][0], key)) {
  58306. return length;
  58307. }
  58308. }
  58309. return -1;
  58310. }
  58311. /**
  58312. * Gets the data for `map`.
  58313. *
  58314. * @private
  58315. * @param {Object} map The map to query.
  58316. * @param {string} key The reference key.
  58317. * @returns {*} Returns the map data.
  58318. */
  58319. function getMapData(map, key) {
  58320. var data = map.__data__;
  58321. return isKeyable(key)
  58322. ? data[typeof key == 'string' ? 'string' : 'hash']
  58323. : data.map;
  58324. }
  58325. /**
  58326. * Gets the native function at `key` of `object`.
  58327. *
  58328. * @private
  58329. * @param {Object} object The object to query.
  58330. * @param {string} key The key of the method to get.
  58331. * @returns {*} Returns the function if it's native, else `undefined`.
  58332. */
  58333. function getNative(object, key) {
  58334. var value = object[key];
  58335. return isNative(value) ? value : undefined;
  58336. }
  58337. /**
  58338. * Checks if `value` is suitable for use as unique object key.
  58339. *
  58340. * @private
  58341. * @param {*} value The value to check.
  58342. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  58343. */
  58344. function isKeyable(value) {
  58345. var type = typeof value;
  58346. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  58347. ? (value !== '__proto__')
  58348. : (value === null);
  58349. }
  58350. /**
  58351. * Converts `string` to a property path array.
  58352. *
  58353. * @private
  58354. * @param {string} string The string to convert.
  58355. * @returns {Array} Returns the property path array.
  58356. */
  58357. var stringToPath = memoize(function(string) {
  58358. var result = [];
  58359. toString(string).replace(rePropName, function(match, number, quote, string) {
  58360. result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
  58361. });
  58362. return result;
  58363. });
  58364. /**
  58365. * Converts `func` to its source code.
  58366. *
  58367. * @private
  58368. * @param {Function} func The function to process.
  58369. * @returns {string} Returns the source code.
  58370. */
  58371. function toSource(func) {
  58372. if (func != null) {
  58373. try {
  58374. return funcToString.call(func);
  58375. } catch (e) {}
  58376. try {
  58377. return (func + '');
  58378. } catch (e) {}
  58379. }
  58380. return '';
  58381. }
  58382. /**
  58383. * Creates a function that memoizes the result of `func`. If `resolver` is
  58384. * provided, it determines the cache key for storing the result based on the
  58385. * arguments provided to the memoized function. By default, the first argument
  58386. * provided to the memoized function is used as the map cache key. The `func`
  58387. * is invoked with the `this` binding of the memoized function.
  58388. *
  58389. * **Note:** The cache is exposed as the `cache` property on the memoized
  58390. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  58391. * constructor with one whose instances implement the
  58392. * [`Map`](http://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-map-prototype-object)
  58393. * method interface of `delete`, `get`, `has`, and `set`.
  58394. *
  58395. * @static
  58396. * @memberOf _
  58397. * @since 0.1.0
  58398. * @category Function
  58399. * @param {Function} func The function to have its output memoized.
  58400. * @param {Function} [resolver] The function to resolve the cache key.
  58401. * @returns {Function} Returns the new memoized function.
  58402. * @example
  58403. *
  58404. * var object = { 'a': 1, 'b': 2 };
  58405. * var other = { 'c': 3, 'd': 4 };
  58406. *
  58407. * var values = _.memoize(_.values);
  58408. * values(object);
  58409. * // => [1, 2]
  58410. *
  58411. * values(other);
  58412. * // => [3, 4]
  58413. *
  58414. * object.a = 2;
  58415. * values(object);
  58416. * // => [1, 2]
  58417. *
  58418. * // Modify the result cache.
  58419. * values.cache.set(object, ['a', 'b']);
  58420. * values(object);
  58421. * // => ['a', 'b']
  58422. *
  58423. * // Replace `_.memoize.Cache`.
  58424. * _.memoize.Cache = WeakMap;
  58425. */
  58426. function memoize(func, resolver) {
  58427. if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
  58428. throw new TypeError(FUNC_ERROR_TEXT);
  58429. }
  58430. var memoized = function() {
  58431. var args = arguments,
  58432. key = resolver ? resolver.apply(this, args) : args[0],
  58433. cache = memoized.cache;
  58434. if (cache.has(key)) {
  58435. return cache.get(key);
  58436. }
  58437. var result = func.apply(this, args);
  58438. memoized.cache = cache.set(key, result);
  58439. return result;
  58440. };
  58441. memoized.cache = new (memoize.Cache || MapCache);
  58442. return memoized;
  58443. }
  58444. // Assign cache to `_.memoize`.
  58445. memoize.Cache = MapCache;
  58446. /**
  58447. * Performs a
  58448. * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
  58449. * comparison between two values to determine if they are equivalent.
  58450. *
  58451. * @static
  58452. * @memberOf _
  58453. * @since 4.0.0
  58454. * @category Lang
  58455. * @param {*} value The value to compare.
  58456. * @param {*} other The other value to compare.
  58457. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  58458. * @example
  58459. *
  58460. * var object = { 'user': 'fred' };
  58461. * var other = { 'user': 'fred' };
  58462. *
  58463. * _.eq(object, object);
  58464. * // => true
  58465. *
  58466. * _.eq(object, other);
  58467. * // => false
  58468. *
  58469. * _.eq('a', 'a');
  58470. * // => true
  58471. *
  58472. * _.eq('a', Object('a'));
  58473. * // => false
  58474. *
  58475. * _.eq(NaN, NaN);
  58476. * // => true
  58477. */
  58478. function eq(value, other) {
  58479. return value === other || (value !== value && other !== other);
  58480. }
  58481. /**
  58482. * Checks if `value` is classified as a `Function` object.
  58483. *
  58484. * @static
  58485. * @memberOf _
  58486. * @since 0.1.0
  58487. * @category Lang
  58488. * @param {*} value The value to check.
  58489. * @returns {boolean} Returns `true` if `value` is correctly classified,
  58490. * else `false`.
  58491. * @example
  58492. *
  58493. * _.isFunction(_);
  58494. * // => true
  58495. *
  58496. * _.isFunction(/abc/);
  58497. * // => false
  58498. */
  58499. function isFunction(value) {
  58500. // The use of `Object#toString` avoids issues with the `typeof` operator
  58501. // in Safari 8 which returns 'object' for typed array and weak map constructors,
  58502. // and PhantomJS 1.9 which returns 'function' for `NodeList` instances.
  58503. var tag = isObject(value) ? objectToString.call(value) : '';
  58504. return tag == funcTag || tag == genTag;
  58505. }
  58506. /**
  58507. * Checks if `value` is the
  58508. * [language type](http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types)
  58509. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  58510. *
  58511. * @static
  58512. * @memberOf _
  58513. * @since 0.1.0
  58514. * @category Lang
  58515. * @param {*} value The value to check.
  58516. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  58517. * @example
  58518. *
  58519. * _.isObject({});
  58520. * // => true
  58521. *
  58522. * _.isObject([1, 2, 3]);
  58523. * // => true
  58524. *
  58525. * _.isObject(_.noop);
  58526. * // => true
  58527. *
  58528. * _.isObject(null);
  58529. * // => false
  58530. */
  58531. function isObject(value) {
  58532. var type = typeof value;
  58533. return !!value && (type == 'object' || type == 'function');
  58534. }
  58535. /**
  58536. * Checks if `value` is a native function.
  58537. *
  58538. * @static
  58539. * @memberOf _
  58540. * @since 3.0.0
  58541. * @category Lang
  58542. * @param {*} value The value to check.
  58543. * @returns {boolean} Returns `true` if `value` is a native function,
  58544. * else `false`.
  58545. * @example
  58546. *
  58547. * _.isNative(Array.prototype.push);
  58548. * // => true
  58549. *
  58550. * _.isNative(_);
  58551. * // => false
  58552. */
  58553. function isNative(value) {
  58554. if (!isObject(value)) {
  58555. return false;
  58556. }
  58557. var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
  58558. return pattern.test(toSource(value));
  58559. }
  58560. /**
  58561. * Converts `value` to a string. An empty string is returned for `null`
  58562. * and `undefined` values. The sign of `-0` is preserved.
  58563. *
  58564. * @static
  58565. * @memberOf _
  58566. * @since 4.0.0
  58567. * @category Lang
  58568. * @param {*} value The value to process.
  58569. * @returns {string} Returns the string.
  58570. * @example
  58571. *
  58572. * _.toString(null);
  58573. * // => ''
  58574. *
  58575. * _.toString(-0);
  58576. * // => '-0'
  58577. *
  58578. * _.toString([1, 2, 3]);
  58579. * // => '1,2,3'
  58580. */
  58581. function toString(value) {
  58582. return value == null ? '' : baseToString(value);
  58583. }
  58584. module.exports = stringToPath;
  58585. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(76)(module), __webpack_require__(13)))
  58586. /***/ },
  58587. /* 521 */
  58588. /***/ function(module, exports, __webpack_require__) {
  58589. /**
  58590. * lodash (Custom Build) <https://lodash.com/>
  58591. * Build: `lodash modularize exports="npm" -o ./`
  58592. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  58593. * Released under MIT license <https://lodash.com/license>
  58594. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  58595. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  58596. */
  58597. var baseFilter = __webpack_require__(518),
  58598. baseIteratee = __webpack_require__(203);
  58599. /**
  58600. * A specialized version of `_.filter` for arrays without support for
  58601. * iteratee shorthands.
  58602. *
  58603. * @private
  58604. * @param {Array} array The array to iterate over.
  58605. * @param {Function} predicate The function invoked per iteration.
  58606. * @returns {Array} Returns the new filtered array.
  58607. */
  58608. function arrayFilter(array, predicate) {
  58609. var index = -1,
  58610. length = array.length,
  58611. resIndex = 0,
  58612. result = [];
  58613. while (++index < length) {
  58614. var value = array[index];
  58615. if (predicate(value, index, array)) {
  58616. result[resIndex++] = value;
  58617. }
  58618. }
  58619. return result;
  58620. }
  58621. /**
  58622. * Iterates over elements of `collection`, returning an array of all elements
  58623. * `predicate` returns truthy for. The predicate is invoked with three
  58624. * arguments: (value, index|key, collection).
  58625. *
  58626. * @static
  58627. * @memberOf _
  58628. * @since 0.1.0
  58629. * @category Collection
  58630. * @param {Array|Object} collection The collection to iterate over.
  58631. * @param {Array|Function|Object|string} [predicate=_.identity]
  58632. * The function invoked per iteration.
  58633. * @returns {Array} Returns the new filtered array.
  58634. * @see _.reject
  58635. * @example
  58636. *
  58637. * var users = [
  58638. * { 'user': 'barney', 'age': 36, 'active': true },
  58639. * { 'user': 'fred', 'age': 40, 'active': false }
  58640. * ];
  58641. *
  58642. * _.filter(users, function(o) { return !o.active; });
  58643. * // => objects for ['fred']
  58644. *
  58645. * // The `_.matches` iteratee shorthand.
  58646. * _.filter(users, { 'age': 36, 'active': true });
  58647. * // => objects for ['barney']
  58648. *
  58649. * // The `_.matchesProperty` iteratee shorthand.
  58650. * _.filter(users, ['active', false]);
  58651. * // => objects for ['fred']
  58652. *
  58653. * // The `_.property` iteratee shorthand.
  58654. * _.filter(users, 'active');
  58655. * // => objects for ['barney']
  58656. */
  58657. function filter(collection, predicate) {
  58658. var func = isArray(collection) ? arrayFilter : baseFilter;
  58659. return func(collection, baseIteratee(predicate, 3));
  58660. }
  58661. /**
  58662. * Checks if `value` is classified as an `Array` object.
  58663. *
  58664. * @static
  58665. * @memberOf _
  58666. * @since 0.1.0
  58667. * @type {Function}
  58668. * @category Lang
  58669. * @param {*} value The value to check.
  58670. * @returns {boolean} Returns `true` if `value` is correctly classified,
  58671. * else `false`.
  58672. * @example
  58673. *
  58674. * _.isArray([1, 2, 3]);
  58675. * // => true
  58676. *
  58677. * _.isArray(document.body.children);
  58678. * // => false
  58679. *
  58680. * _.isArray('abc');
  58681. * // => false
  58682. *
  58683. * _.isArray(_.noop);
  58684. * // => false
  58685. */
  58686. var isArray = Array.isArray;
  58687. module.exports = filter;
  58688. /***/ },
  58689. /* 522 */
  58690. /***/ function(module, exports, __webpack_require__) {
  58691. "use strict";
  58692. /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
  58693. var map = __webpack_require__(134);
  58694. var filter = __webpack_require__(521);
  58695. var convert = __webpack_require__(523);
  58696. var protocols = __webpack_require__(136);
  58697. var varint = __webpack_require__(75);
  58698. // export codec
  58699. module.exports = {
  58700. stringToStringTuples: stringToStringTuples,
  58701. stringTuplesToString: stringTuplesToString,
  58702. tuplesToStringTuples: tuplesToStringTuples,
  58703. stringTuplesToTuples: stringTuplesToTuples,
  58704. bufferToTuples: bufferToTuples,
  58705. tuplesToBuffer: tuplesToBuffer,
  58706. bufferToString: bufferToString,
  58707. stringToBuffer: stringToBuffer,
  58708. fromString: fromString,
  58709. fromBuffer: fromBuffer,
  58710. validateBuffer: validateBuffer,
  58711. isValidBuffer: isValidBuffer,
  58712. cleanPath: cleanPath,
  58713. ParseError: ParseError,
  58714. protoFromTuple: protoFromTuple,
  58715. sizeForAddr: sizeForAddr
  58716. };
  58717. // string -> [[str name, str addr]... ]
  58718. function stringToStringTuples(str) {
  58719. var tuples = [];
  58720. var parts = str.split('/').slice(1); // skip first empty elem
  58721. if (parts.length === 1 && parts[0] === '') {
  58722. return [];
  58723. }
  58724. for (var p = 0; p < parts.length; p++) {
  58725. var part = parts[p];
  58726. var proto = protocols(part);
  58727. if (proto.size === 0) {
  58728. tuples.push([part]);
  58729. continue;
  58730. }
  58731. p++; // advance addr part
  58732. if (p >= parts.length) {
  58733. throw ParseError('invalid address: ' + str);
  58734. }
  58735. tuples.push([part, parts[p]]);
  58736. }
  58737. return tuples;
  58738. }
  58739. // [[str name, str addr]... ] -> string
  58740. function stringTuplesToString(tuples) {
  58741. var parts = [];
  58742. map(tuples, function (tup) {
  58743. var proto = protoFromTuple(tup);
  58744. parts.push(proto.name);
  58745. if (tup.length > 1) {
  58746. parts.push(tup[1]);
  58747. }
  58748. });
  58749. return '/' + parts.join('/');
  58750. }
  58751. // [[str name, str addr]... ] -> [[int code, Buffer]... ]
  58752. function stringTuplesToTuples(tuples) {
  58753. return map(tuples, function (tup) {
  58754. if (!Array.isArray(tup)) {
  58755. tup = [tup];
  58756. }
  58757. var proto = protoFromTuple(tup);
  58758. if (tup.length > 1) {
  58759. return [proto.code, convert.toBuffer(proto.code, tup[1])];
  58760. }
  58761. return [proto.code];
  58762. });
  58763. }
  58764. // [[int code, Buffer]... ] -> [[str name, str addr]... ]
  58765. function tuplesToStringTuples(tuples) {
  58766. return map(tuples, function (tup) {
  58767. var proto = protoFromTuple(tup);
  58768. if (tup.length > 1) {
  58769. return [proto.code, convert.toString(proto.code, tup[1])];
  58770. }
  58771. return [proto.code];
  58772. });
  58773. }
  58774. // [[int code, Buffer ]... ] -> Buffer
  58775. function tuplesToBuffer(tuples) {
  58776. return fromBuffer(Buffer.concat(map(tuples, function (tup) {
  58777. var proto = protoFromTuple(tup);
  58778. var buf = new Buffer(varint.encode(proto.code));
  58779. if (tup.length > 1) {
  58780. buf = Buffer.concat([buf, tup[1]]); // add address buffer
  58781. }
  58782. return buf;
  58783. })));
  58784. }
  58785. function sizeForAddr(p, addr) {
  58786. if (p.size > 0) {
  58787. return p.size / 8;
  58788. } else if (p.size === 0) {
  58789. return 0;
  58790. } else {
  58791. var size = varint.decode(addr);
  58792. return size + varint.decode.bytes;
  58793. }
  58794. }
  58795. // Buffer -> [[int code, Buffer ]... ]
  58796. function bufferToTuples(buf) {
  58797. var tuples = [];
  58798. var i = 0;
  58799. while (i < buf.length) {
  58800. var code = varint.decode(buf, i);
  58801. var n = varint.decode.bytes;
  58802. var p = protocols(code);
  58803. var size = sizeForAddr(p, buf.slice(i + n));
  58804. if (size === 0) {
  58805. tuples.push([code]);
  58806. i += n;
  58807. continue;
  58808. }
  58809. var addr = buf.slice(i + n, i + n + size);
  58810. i += size + n;
  58811. if (i > buf.length) {
  58812. // did not end _exactly_ at buffer.length
  58813. throw ParseError('Invalid address buffer: ' + buf.toString('hex'));
  58814. }
  58815. // ok, tuple seems good.
  58816. tuples.push([code, addr]);
  58817. }
  58818. return tuples;
  58819. }
  58820. // Buffer -> String
  58821. function bufferToString(buf) {
  58822. var a = bufferToTuples(buf);
  58823. var b = tuplesToStringTuples(a);
  58824. return stringTuplesToString(b);
  58825. }
  58826. // String -> Buffer
  58827. function stringToBuffer(str) {
  58828. str = cleanPath(str);
  58829. var a = stringToStringTuples(str);
  58830. var b = stringTuplesToTuples(a);
  58831. return tuplesToBuffer(b);
  58832. }
  58833. // String -> Buffer
  58834. function fromString(str) {
  58835. return stringToBuffer(str);
  58836. }
  58837. // Buffer -> Buffer
  58838. function fromBuffer(buf) {
  58839. var err = validateBuffer(buf);
  58840. if (err) throw err;
  58841. return new Buffer(buf); // copy
  58842. }
  58843. function validateBuffer(buf) {
  58844. try {
  58845. bufferToTuples(buf); // try to parse. will throw if breaks
  58846. } catch (err) {
  58847. return err;
  58848. }
  58849. }
  58850. function isValidBuffer(buf) {
  58851. return validateBuffer(buf) === undefined;
  58852. }
  58853. function cleanPath(str) {
  58854. return '/' + filter(str.trim().split('/')).join('/');
  58855. }
  58856. function ParseError(str) {
  58857. return new Error('Error parsing address: ' + str);
  58858. }
  58859. function protoFromTuple(tup) {
  58860. var proto = protocols(tup[0]);
  58861. return proto;
  58862. }
  58863. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  58864. /***/ },
  58865. /* 523 */
  58866. /***/ function(module, exports, __webpack_require__) {
  58867. "use strict";
  58868. /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
  58869. var ip = __webpack_require__(514);
  58870. var protocols = __webpack_require__(136);
  58871. var bs58 = __webpack_require__(56);
  58872. var varint = __webpack_require__(75);
  58873. module.exports = Convert;
  58874. // converts (serializes) addresses
  58875. function Convert(proto, a) {
  58876. if (a instanceof Buffer) {
  58877. return Convert.toString(proto, a);
  58878. } else {
  58879. return Convert.toBuffer(proto, a);
  58880. }
  58881. }
  58882. Convert.toString = function convertToString(proto, buf) {
  58883. proto = protocols(proto);
  58884. switch (proto.code) {
  58885. case 4: // ipv4
  58886. case 41:
  58887. // ipv6
  58888. return ip.toString(buf);
  58889. case 6: // tcp
  58890. case 17: // udp
  58891. case 33: // dccp
  58892. case 132:
  58893. // sctp
  58894. return buf2port(buf);
  58895. case 421:
  58896. // ipfs
  58897. return buf2mh(buf);
  58898. default:
  58899. return buf.toString('hex'); // no clue. convert to hex
  58900. }
  58901. };
  58902. Convert.toBuffer = function convertToBuffer(proto, str) {
  58903. proto = protocols(proto);
  58904. switch (proto.code) {
  58905. case 4: // ipv4
  58906. case 41:
  58907. // ipv6
  58908. return ip.toBuffer(str);
  58909. case 6: // tcp
  58910. case 17: // udp
  58911. case 33: // dccp
  58912. case 132:
  58913. // sctp
  58914. return port2buf(parseInt(str, 10));
  58915. case 421:
  58916. // ipfs
  58917. return mh2buf(str);
  58918. default:
  58919. return new Buffer(str, 'hex'); // no clue. convert from hex
  58920. }
  58921. };
  58922. function port2buf(port) {
  58923. var buf = new Buffer(2);
  58924. buf.writeUInt16BE(port, 0);
  58925. return buf;
  58926. }
  58927. function buf2port(buf) {
  58928. return buf.readUInt16BE(0);
  58929. }
  58930. function mh2buf(hash) {
  58931. // the address is a varint prefixed multihash string representation
  58932. var mh = new Buffer(bs58.decode(hash));
  58933. var size = new Buffer(varint.encode(mh.length));
  58934. return Buffer.concat([size, mh]);
  58935. }
  58936. function buf2mh(buf) {
  58937. var size = varint.decode(buf);
  58938. var address = buf.slice(varint.decode.bytes);
  58939. if (address.length !== size) {
  58940. throw new Error('inconsistent lengths');
  58941. }
  58942. return bs58.encode(address);
  58943. }
  58944. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  58945. /***/ },
  58946. /* 524 */
  58947. /***/ function(module, exports, __webpack_require__) {
  58948. "use strict";
  58949. /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict';
  58950. var map = __webpack_require__(134);
  58951. var extend = __webpack_require__(98);
  58952. var codec = __webpack_require__(522);
  58953. var protocols = __webpack_require__(136);
  58954. var NotImplemented = new Error('Sorry, Not Implemented Yet.');
  58955. var varint = __webpack_require__(75);
  58956. exports = module.exports = Multiaddr;
  58957. function Multiaddr(addr) {
  58958. if (!(this instanceof Multiaddr)) {
  58959. return new Multiaddr(addr);
  58960. }
  58961. // defaults
  58962. if (!addr) {
  58963. addr = '';
  58964. }
  58965. if (addr instanceof Buffer) {
  58966. this.buffer = codec.fromBuffer(addr);
  58967. } else if (typeof addr === 'string' || addr instanceof String) {
  58968. this.buffer = codec.fromString(addr);
  58969. } else if (addr.buffer && addr.protos && addr.protoCodes) {
  58970. // Multiaddr
  58971. this.buffer = codec.fromBuffer(addr.buffer); // validate + copy buffer
  58972. } else {
  58973. throw new Error('addr must be a string, Buffer, or another Multiaddr');
  58974. }
  58975. }
  58976. // get the multiaddr protocols
  58977. Multiaddr.prototype.toString = function toString() {
  58978. return codec.bufferToString(this.buffer);
  58979. };
  58980. // get the multiaddr as a convinent options object to be dropped in net.createConnection
  58981. Multiaddr.prototype.toOptions = function toOptions() {
  58982. var opts = {};
  58983. var parsed = this.toString().split('/');
  58984. opts.family = parsed[1] === 'ip4' ? 'ipv4' : 'ipv6';
  58985. opts.host = parsed[2];
  58986. opts.port = parsed[4];
  58987. return opts;
  58988. };
  58989. // get the multiaddr protocols
  58990. Multiaddr.prototype.inspect = function inspect() {
  58991. return '<Multiaddr ' + this.buffer.toString('hex') + ' - ' + codec.bufferToString(this.buffer) + '>';
  58992. };
  58993. // get the multiaddr protocols
  58994. Multiaddr.prototype.protos = function protos() {
  58995. return map(this.protoCodes(), function (code) {
  58996. return extend(protocols(code));
  58997. // copy to prevent users from modifying the internal objs.
  58998. });
  58999. };
  59000. // get the multiaddr protocol codes
  59001. Multiaddr.prototype.protoCodes = function protoCodes() {
  59002. var codes = [];
  59003. var buf = this.buffer;
  59004. var i = 0;
  59005. while (i < buf.length) {
  59006. var code = varint.decode(buf, i);
  59007. var n = varint.decode.bytes;
  59008. var p = protocols(code);
  59009. var size = codec.sizeForAddr(p, buf.slice(i + n));
  59010. i += size + n;
  59011. codes.push(code);
  59012. }
  59013. return codes;
  59014. };
  59015. // get the multiaddr protocol string names
  59016. Multiaddr.prototype.protoNames = function protoNames() {
  59017. return map(this.protos(), function (proto) {
  59018. return proto.name;
  59019. });
  59020. };
  59021. // Returns a tuple of parts:
  59022. Multiaddr.prototype.tuples = function tuples() {
  59023. return codec.bufferToTuples(this.buffer);
  59024. };
  59025. // Returns a tuple of string parts:
  59026. Multiaddr.prototype.stringTuples = function stringTuples() {
  59027. var t = codec.bufferToTuples(this.buffer);
  59028. return codec.tuplesToStringTuples(t);
  59029. };
  59030. Multiaddr.prototype.encapsulate = function encapsulate(addr) {
  59031. addr = Multiaddr(addr);
  59032. return Multiaddr(this.toString() + addr.toString());
  59033. };
  59034. Multiaddr.prototype.decapsulate = function decapsulate(addr) {
  59035. addr = addr.toString();
  59036. var s = this.toString();
  59037. var i = s.lastIndexOf(addr);
  59038. if (i < 0) {
  59039. throw new Error('Address ' + this + ' does not contain subaddress: ' + addr);
  59040. }
  59041. return Multiaddr(s.slice(0, i));
  59042. };
  59043. Multiaddr.prototype.equals = function equals(addr) {
  59044. return this.buffer.equals(addr.buffer);
  59045. };
  59046. // get a node friendly address object
  59047. Multiaddr.prototype.nodeAddress = function nodeAddress() {
  59048. if (!this.isThinWaistAddress()) {
  59049. throw new Error('Multiaddr must be "thin waist" address for nodeAddress.');
  59050. }
  59051. var codes = this.protoCodes();
  59052. var parts = this.toString().split('/').slice(1);
  59053. return {
  59054. family: codes[0] === 41 ? 'IPv6' : 'IPv4',
  59055. address: parts[1], // ip addr
  59056. port: parts[3] // tcp or udp port
  59057. };
  59058. };
  59059. // from a node friendly address object
  59060. Multiaddr.fromNodeAddress = function fromNodeAddress(addr, transport) {
  59061. if (!addr) throw new Error('requires node address object');
  59062. if (!transport) throw new Error('requires transport protocol');
  59063. var ip = addr.family === 'IPv6' ? 'ip6' : 'ip4';
  59064. return Multiaddr('/' + [ip, addr.address, transport, addr.port].join('/'));
  59065. };
  59066. // returns whether this address is a standard combination:
  59067. // /{IPv4, IPv6}/{TCP, UDP}
  59068. Multiaddr.prototype.isThinWaistAddress = function isThinWaistAddress(addr) {
  59069. var protos = (addr || this).protos();
  59070. if (protos.length !== 2) {
  59071. return false;
  59072. }
  59073. if (protos[0].code !== 4 && protos[0].code !== 41) {
  59074. return false;
  59075. }
  59076. if (protos[1].code !== 6 && protos[1].code !== 17) {
  59077. return false;
  59078. }
  59079. return true;
  59080. };
  59081. // parses the "stupid string" format:
  59082. // <proto><IPv>://<IP Addr>[:<proto port>]
  59083. // udp4://1.2.3.4:5678
  59084. Multiaddr.prototype.fromStupidString = function fromStupidString(str) {
  59085. throw NotImplemented;
  59086. };
  59087. // patch this in
  59088. Multiaddr.protocols = protocols;
  59089. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  59090. /***/ },
  59091. /* 525 */
  59092. /***/ function(module, exports) {
  59093. "use strict";
  59094. 'use strict';
  59095. exports.names = {
  59096. sha1: 0x11,
  59097. 'sha2-256': 0x12,
  59098. 'sha2-512': 0x13,
  59099. sha3: 0x14,
  59100. blake2b: 0x40,
  59101. blake2s: 0x41
  59102. };
  59103. exports.codes = {
  59104. 0x11: 'sha1',
  59105. 0x12: 'sha2-256',
  59106. 0x13: 'sha2-512',
  59107. 0x14: 'sha3',
  59108. 0x40: 'blake2b',
  59109. 0x41: 'blake2s'
  59110. };
  59111. exports.defaultLengths = {
  59112. 0x11: 20,
  59113. 0x12: 32,
  59114. 0x13: 64,
  59115. 0x14: 64,
  59116. 0x40: 64,
  59117. 0x41: 32
  59118. };
  59119. /***/ },
  59120. /* 526 */
  59121. /***/ function(module, exports, __webpack_require__) {
  59122. var Sandwich = __webpack_require__(555).SandwichStream
  59123. var stream = __webpack_require__(9)
  59124. var inherits = __webpack_require__(2)
  59125. var isStream = __webpack_require__(516)
  59126. var CRNL = '\r\n'
  59127. module.exports = Multipart
  59128. /**
  59129. * Multipart request constructor.
  59130. * @constructor
  59131. * @param {object} [opts]
  59132. * @param {string} [opts.boundary] - The boundary to be used. If omitted one is generated.
  59133. * @returns {function} Returns the multipart stream.
  59134. */
  59135. function Multipart(boundary) {
  59136. if(!this instanceof Multipart) {
  59137. return new Multipart(boundary)
  59138. }
  59139. this.boundary = boundary || Math.random().toString(36).slice(2)
  59140. Sandwich.call(this, {
  59141. head: '--' + this.boundary + CRNL,
  59142. tail: CRNL + '--' + this.boundary + '--',
  59143. separator: CRNL + '--' + this.boundary + CRNL
  59144. })
  59145. this._add = this.add
  59146. this.add = this.addPart
  59147. }
  59148. inherits(Multipart, Sandwich)
  59149. /**
  59150. * Adds a new part to the request.
  59151. * @param {object} [part={}]
  59152. * @param {object} [part.headers={}]
  59153. * @param {string|buffer|stream} [part.body=\r\n]
  59154. * @returns {function} Returns the multipart stream.
  59155. */
  59156. Multipart.prototype.addPart = function(part) {
  59157. part = part || {}
  59158. var partStream = new stream.PassThrough()
  59159. if(part.headers) {
  59160. for(var key in part.headers) {
  59161. var header = part.headers[key]
  59162. partStream.write(key + ': ' + header + CRNL)
  59163. }
  59164. }
  59165. partStream.write(CRNL)
  59166. if(isStream(part.body)) {
  59167. part.body.pipe(partStream)
  59168. } else {
  59169. partStream.end(part.body)
  59170. }
  59171. this._add(partStream)
  59172. }
  59173. /***/ },
  59174. /* 527 */
  59175. /***/ function(module, exports) {
  59176. module.exports = Array.isArray || function (arr) {
  59177. return Object.prototype.toString.call(arr) == '[object Array]';
  59178. };
  59179. /***/ },
  59180. /* 528 */
  59181. /***/ function(module, exports, __webpack_require__) {
  59182. /* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors.
  59183. //
  59184. // Permission is hereby granted, free of charge, to any person obtaining a
  59185. // copy of this software and associated documentation files (the
  59186. // "Software"), to deal in the Software without restriction, including
  59187. // without limitation the rights to use, copy, modify, merge, publish,
  59188. // distribute, sublicense, and/or sell copies of the Software, and to permit
  59189. // persons to whom the Software is furnished to do so, subject to the
  59190. // following conditions:
  59191. //
  59192. // The above copyright notice and this permission notice shall be included
  59193. // in all copies or substantial portions of the Software.
  59194. //
  59195. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  59196. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  59197. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  59198. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  59199. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  59200. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  59201. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  59202. module.exports = Readable;
  59203. /*<replacement>*/
  59204. var isArray = __webpack_require__(527);
  59205. /*</replacement>*/
  59206. /*<replacement>*/
  59207. var Buffer = __webpack_require__(1).Buffer;
  59208. /*</replacement>*/
  59209. Readable.ReadableState = ReadableState;
  59210. var EE = __webpack_require__(30).EventEmitter;
  59211. /*<replacement>*/
  59212. if (!EE.listenerCount) EE.listenerCount = function(emitter, type) {
  59213. return emitter.listeners(type).length;
  59214. };
  59215. /*</replacement>*/
  59216. var Stream = __webpack_require__(9);
  59217. /*<replacement>*/
  59218. var util = __webpack_require__(14);
  59219. util.inherits = __webpack_require__(2);
  59220. /*</replacement>*/
  59221. var StringDecoder;
  59222. util.inherits(Readable, Stream);
  59223. function ReadableState(options, stream) {
  59224. options = options || {};
  59225. // the point at which it stops calling _read() to fill the buffer
  59226. // Note: 0 is a valid value, means "don't call _read preemptively ever"
  59227. var hwm = options.highWaterMark;
  59228. this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024;
  59229. // cast to ints.
  59230. this.highWaterMark = ~~this.highWaterMark;
  59231. this.buffer = [];
  59232. this.length = 0;
  59233. this.pipes = null;
  59234. this.pipesCount = 0;
  59235. this.flowing = false;
  59236. this.ended = false;
  59237. this.endEmitted = false;
  59238. this.reading = false;
  59239. // In streams that never have any data, and do push(null) right away,
  59240. // the consumer can miss the 'end' event if they do some I/O before
  59241. // consuming the stream. So, we don't emit('end') until some reading
  59242. // happens.
  59243. this.calledRead = false;
  59244. // a flag to be able to tell if the onwrite cb is called immediately,
  59245. // or on a later tick. We set this to true at first, becuase any
  59246. // actions that shouldn't happen until "later" should generally also
  59247. // not happen before the first write call.
  59248. this.sync = true;
  59249. // whenever we return null, then we set a flag to say
  59250. // that we're awaiting a 'readable' event emission.
  59251. this.needReadable = false;
  59252. this.emittedReadable = false;
  59253. this.readableListening = false;
  59254. // object stream flag. Used to make read(n) ignore n and to
  59255. // make all the buffer merging and length checks go away
  59256. this.objectMode = !!options.objectMode;
  59257. // Crypto is kind of old and crusty. Historically, its default string
  59258. // encoding is 'binary' so we have to make this configurable.
  59259. // Everything else in the universe uses 'utf8', though.
  59260. this.defaultEncoding = options.defaultEncoding || 'utf8';
  59261. // when piping, we only care about 'readable' events that happen
  59262. // after read()ing all the bytes and not getting any pushback.
  59263. this.ranOut = false;
  59264. // the number of writers that are awaiting a drain event in .pipe()s
  59265. this.awaitDrain = 0;
  59266. // if true, a maybeReadMore has been scheduled
  59267. this.readingMore = false;
  59268. this.decoder = null;
  59269. this.encoding = null;
  59270. if (options.encoding) {
  59271. if (!StringDecoder)
  59272. StringDecoder = __webpack_require__(38).StringDecoder;
  59273. this.decoder = new StringDecoder(options.encoding);
  59274. this.encoding = options.encoding;
  59275. }
  59276. }
  59277. function Readable(options) {
  59278. if (!(this instanceof Readable))
  59279. return new Readable(options);
  59280. this._readableState = new ReadableState(options, this);
  59281. // legacy
  59282. this.readable = true;
  59283. Stream.call(this);
  59284. }
  59285. // Manually shove something into the read() buffer.
  59286. // This returns true if the highWaterMark has not been hit yet,
  59287. // similar to how Writable.write() returns true if you should
  59288. // write() some more.
  59289. Readable.prototype.push = function(chunk, encoding) {
  59290. var state = this._readableState;
  59291. if (typeof chunk === 'string' && !state.objectMode) {
  59292. encoding = encoding || state.defaultEncoding;
  59293. if (encoding !== state.encoding) {
  59294. chunk = new Buffer(chunk, encoding);
  59295. encoding = '';
  59296. }
  59297. }
  59298. return readableAddChunk(this, state, chunk, encoding, false);
  59299. };
  59300. // Unshift should *always* be something directly out of read()
  59301. Readable.prototype.unshift = function(chunk) {
  59302. var state = this._readableState;
  59303. return readableAddChunk(this, state, chunk, '', true);
  59304. };
  59305. function readableAddChunk(stream, state, chunk, encoding, addToFront) {
  59306. var er = chunkInvalid(state, chunk);
  59307. if (er) {
  59308. stream.emit('error', er);
  59309. } else if (chunk === null || chunk === undefined) {
  59310. state.reading = false;
  59311. if (!state.ended)
  59312. onEofChunk(stream, state);
  59313. } else if (state.objectMode || chunk && chunk.length > 0) {
  59314. if (state.ended && !addToFront) {
  59315. var e = new Error('stream.push() after EOF');
  59316. stream.emit('error', e);
  59317. } else if (state.endEmitted && addToFront) {
  59318. var e = new Error('stream.unshift() after end event');
  59319. stream.emit('error', e);
  59320. } else {
  59321. if (state.decoder && !addToFront && !encoding)
  59322. chunk = state.decoder.write(chunk);
  59323. // update the buffer info.
  59324. state.length += state.objectMode ? 1 : chunk.length;
  59325. if (addToFront) {
  59326. state.buffer.unshift(chunk);
  59327. } else {
  59328. state.reading = false;
  59329. state.buffer.push(chunk);
  59330. }
  59331. if (state.needReadable)
  59332. emitReadable(stream);
  59333. maybeReadMore(stream, state);
  59334. }
  59335. } else if (!addToFront) {
  59336. state.reading = false;
  59337. }
  59338. return needMoreData(state);
  59339. }
  59340. // if it's past the high water mark, we can push in some more.
  59341. // Also, if we have no data yet, we can stand some
  59342. // more bytes. This is to work around cases where hwm=0,
  59343. // such as the repl. Also, if the push() triggered a
  59344. // readable event, and the user called read(largeNumber) such that
  59345. // needReadable was set, then we ought to push more, so that another
  59346. // 'readable' event will be triggered.
  59347. function needMoreData(state) {
  59348. return !state.ended &&
  59349. (state.needReadable ||
  59350. state.length < state.highWaterMark ||
  59351. state.length === 0);
  59352. }
  59353. // backwards compatibility.
  59354. Readable.prototype.setEncoding = function(enc) {
  59355. if (!StringDecoder)
  59356. StringDecoder = __webpack_require__(38).StringDecoder;
  59357. this._readableState.decoder = new StringDecoder(enc);
  59358. this._readableState.encoding = enc;
  59359. };
  59360. // Don't raise the hwm > 128MB
  59361. var MAX_HWM = 0x800000;
  59362. function roundUpToNextPowerOf2(n) {
  59363. if (n >= MAX_HWM) {
  59364. n = MAX_HWM;
  59365. } else {
  59366. // Get the next highest power of 2
  59367. n--;
  59368. for (var p = 1; p < 32; p <<= 1) n |= n >> p;
  59369. n++;
  59370. }
  59371. return n;
  59372. }
  59373. function howMuchToRead(n, state) {
  59374. if (state.length === 0 && state.ended)
  59375. return 0;
  59376. if (state.objectMode)
  59377. return n === 0 ? 0 : 1;
  59378. if (n === null || isNaN(n)) {
  59379. // only flow one buffer at a time
  59380. if (state.flowing && state.buffer.length)
  59381. return state.buffer[0].length;
  59382. else
  59383. return state.length;
  59384. }
  59385. if (n <= 0)
  59386. return 0;
  59387. // If we're asking for more than the target buffer level,
  59388. // then raise the water mark. Bump up to the next highest
  59389. // power of 2, to prevent increasing it excessively in tiny
  59390. // amounts.
  59391. if (n > state.highWaterMark)
  59392. state.highWaterMark = roundUpToNextPowerOf2(n);
  59393. // don't have that much. return null, unless we've ended.
  59394. if (n > state.length) {
  59395. if (!state.ended) {
  59396. state.needReadable = true;
  59397. return 0;
  59398. } else
  59399. return state.length;
  59400. }
  59401. return n;
  59402. }
  59403. // you can override either this method, or the async _read(n) below.
  59404. Readable.prototype.read = function(n) {
  59405. var state = this._readableState;
  59406. state.calledRead = true;
  59407. var nOrig = n;
  59408. var ret;
  59409. if (typeof n !== 'number' || n > 0)
  59410. state.emittedReadable = false;
  59411. // if we're doing read(0) to trigger a readable event, but we
  59412. // already have a bunch of data in the buffer, then just trigger
  59413. // the 'readable' event and move on.
  59414. if (n === 0 &&
  59415. state.needReadable &&
  59416. (state.length >= state.highWaterMark || state.ended)) {
  59417. emitReadable(this);
  59418. return null;
  59419. }
  59420. n = howMuchToRead(n, state);
  59421. // if we've ended, and we're now clear, then finish it up.
  59422. if (n === 0 && state.ended) {
  59423. ret = null;
  59424. // In cases where the decoder did not receive enough data
  59425. // to produce a full chunk, then immediately received an
  59426. // EOF, state.buffer will contain [<Buffer >, <Buffer 00 ...>].
  59427. // howMuchToRead will see this and coerce the amount to
  59428. // read to zero (because it's looking at the length of the
  59429. // first <Buffer > in state.buffer), and we'll end up here.
  59430. //
  59431. // This can only happen via state.decoder -- no other venue
  59432. // exists for pushing a zero-length chunk into state.buffer
  59433. // and triggering this behavior. In this case, we return our
  59434. // remaining data and end the stream, if appropriate.
  59435. if (state.length > 0 && state.decoder) {
  59436. ret = fromList(n, state);
  59437. state.length -= ret.length;
  59438. }
  59439. if (state.length === 0)
  59440. endReadable(this);
  59441. return ret;
  59442. }
  59443. // All the actual chunk generation logic needs to be
  59444. // *below* the call to _read. The reason is that in certain
  59445. // synthetic stream cases, such as passthrough streams, _read
  59446. // may be a completely synchronous operation which may change
  59447. // the state of the read buffer, providing enough data when
  59448. // before there was *not* enough.
  59449. //
  59450. // So, the steps are:
  59451. // 1. Figure out what the state of things will be after we do
  59452. // a read from the buffer.
  59453. //
  59454. // 2. If that resulting state will trigger a _read, then call _read.
  59455. // Note that this may be asynchronous, or synchronous. Yes, it is
  59456. // deeply ugly to write APIs this way, but that still doesn't mean
  59457. // that the Readable class should behave improperly, as streams are
  59458. // designed to be sync/async agnostic.
  59459. // Take note if the _read call is sync or async (ie, if the read call
  59460. // has returned yet), so that we know whether or not it's safe to emit
  59461. // 'readable' etc.
  59462. //
  59463. // 3. Actually pull the requested chunks out of the buffer and return.
  59464. // if we need a readable event, then we need to do some reading.
  59465. var doRead = state.needReadable;
  59466. // if we currently have less than the highWaterMark, then also read some
  59467. if (state.length - n <= state.highWaterMark)
  59468. doRead = true;
  59469. // however, if we've ended, then there's no point, and if we're already
  59470. // reading, then it's unnecessary.
  59471. if (state.ended || state.reading)
  59472. doRead = false;
  59473. if (doRead) {
  59474. state.reading = true;
  59475. state.sync = true;
  59476. // if the length is currently zero, then we *need* a readable event.
  59477. if (state.length === 0)
  59478. state.needReadable = true;
  59479. // call internal read method
  59480. this._read(state.highWaterMark);
  59481. state.sync = false;
  59482. }
  59483. // If _read called its callback synchronously, then `reading`
  59484. // will be false, and we need to re-evaluate how much data we
  59485. // can return to the user.
  59486. if (doRead && !state.reading)
  59487. n = howMuchToRead(nOrig, state);
  59488. if (n > 0)
  59489. ret = fromList(n, state);
  59490. else
  59491. ret = null;
  59492. if (ret === null) {
  59493. state.needReadable = true;
  59494. n = 0;
  59495. }
  59496. state.length -= n;
  59497. // If we have nothing in the buffer, then we want to know
  59498. // as soon as we *do* get something into the buffer.
  59499. if (state.length === 0 && !state.ended)
  59500. state.needReadable = true;
  59501. // If we happened to read() exactly the remaining amount in the
  59502. // buffer, and the EOF has been seen at this point, then make sure
  59503. // that we emit 'end' on the very next tick.
  59504. if (state.ended && !state.endEmitted && state.length === 0)
  59505. endReadable(this);
  59506. return ret;
  59507. };
  59508. function chunkInvalid(state, chunk) {
  59509. var er = null;
  59510. if (!Buffer.isBuffer(chunk) &&
  59511. 'string' !== typeof chunk &&
  59512. chunk !== null &&
  59513. chunk !== undefined &&
  59514. !state.objectMode) {
  59515. er = new TypeError('Invalid non-string/buffer chunk');
  59516. }
  59517. return er;
  59518. }
  59519. function onEofChunk(stream, state) {
  59520. if (state.decoder && !state.ended) {
  59521. var chunk = state.decoder.end();
  59522. if (chunk && chunk.length) {
  59523. state.buffer.push(chunk);
  59524. state.length += state.objectMode ? 1 : chunk.length;
  59525. }
  59526. }
  59527. state.ended = true;
  59528. // if we've ended and we have some data left, then emit
  59529. // 'readable' now to make sure it gets picked up.
  59530. if (state.length > 0)
  59531. emitReadable(stream);
  59532. else
  59533. endReadable(stream);
  59534. }
  59535. // Don't emit readable right away in sync mode, because this can trigger
  59536. // another read() call => stack overflow. This way, it might trigger
  59537. // a nextTick recursion warning, but that's not so bad.
  59538. function emitReadable(stream) {
  59539. var state = stream._readableState;
  59540. state.needReadable = false;
  59541. if (state.emittedReadable)
  59542. return;
  59543. state.emittedReadable = true;
  59544. if (state.sync)
  59545. process.nextTick(function() {
  59546. emitReadable_(stream);
  59547. });
  59548. else
  59549. emitReadable_(stream);
  59550. }
  59551. function emitReadable_(stream) {
  59552. stream.emit('readable');
  59553. }
  59554. // at this point, the user has presumably seen the 'readable' event,
  59555. // and called read() to consume some data. that may have triggered
  59556. // in turn another _read(n) call, in which case reading = true if
  59557. // it's in progress.
  59558. // However, if we're not ended, or reading, and the length < hwm,
  59559. // then go ahead and try to read some more preemptively.
  59560. function maybeReadMore(stream, state) {
  59561. if (!state.readingMore) {
  59562. state.readingMore = true;
  59563. process.nextTick(function() {
  59564. maybeReadMore_(stream, state);
  59565. });
  59566. }
  59567. }
  59568. function maybeReadMore_(stream, state) {
  59569. var len = state.length;
  59570. while (!state.reading && !state.flowing && !state.ended &&
  59571. state.length < state.highWaterMark) {
  59572. stream.read(0);
  59573. if (len === state.length)
  59574. // didn't get any data, stop spinning.
  59575. break;
  59576. else
  59577. len = state.length;
  59578. }
  59579. state.readingMore = false;
  59580. }
  59581. // abstract method. to be overridden in specific implementation classes.
  59582. // call cb(er, data) where data is <= n in length.
  59583. // for virtual (non-string, non-buffer) streams, "length" is somewhat
  59584. // arbitrary, and perhaps not very meaningful.
  59585. Readable.prototype._read = function(n) {
  59586. this.emit('error', new Error('not implemented'));
  59587. };
  59588. Readable.prototype.pipe = function(dest, pipeOpts) {
  59589. var src = this;
  59590. var state = this._readableState;
  59591. switch (state.pipesCount) {
  59592. case 0:
  59593. state.pipes = dest;
  59594. break;
  59595. case 1:
  59596. state.pipes = [state.pipes, dest];
  59597. break;
  59598. default:
  59599. state.pipes.push(dest);
  59600. break;
  59601. }
  59602. state.pipesCount += 1;
  59603. var doEnd = (!pipeOpts || pipeOpts.end !== false) &&
  59604. dest !== process.stdout &&
  59605. dest !== process.stderr;
  59606. var endFn = doEnd ? onend : cleanup;
  59607. if (state.endEmitted)
  59608. process.nextTick(endFn);
  59609. else
  59610. src.once('end', endFn);
  59611. dest.on('unpipe', onunpipe);
  59612. function onunpipe(readable) {
  59613. if (readable !== src) return;
  59614. cleanup();
  59615. }
  59616. function onend() {
  59617. dest.end();
  59618. }
  59619. // when the dest drains, it reduces the awaitDrain counter
  59620. // on the source. This would be more elegant with a .once()
  59621. // handler in flow(), but adding and removing repeatedly is
  59622. // too slow.
  59623. var ondrain = pipeOnDrain(src);
  59624. dest.on('drain', ondrain);
  59625. function cleanup() {
  59626. // cleanup event handlers once the pipe is broken
  59627. dest.removeListener('close', onclose);
  59628. dest.removeListener('finish', onfinish);
  59629. dest.removeListener('drain', ondrain);
  59630. dest.removeListener('error', onerror);
  59631. dest.removeListener('unpipe', onunpipe);
  59632. src.removeListener('end', onend);
  59633. src.removeListener('end', cleanup);
  59634. // if the reader is waiting for a drain event from this
  59635. // specific writer, then it would cause it to never start
  59636. // flowing again.
  59637. // So, if this is awaiting a drain, then we just call it now.
  59638. // If we don't know, then assume that we are waiting for one.
  59639. if (!dest._writableState || dest._writableState.needDrain)
  59640. ondrain();
  59641. }
  59642. // if the dest has an error, then stop piping into it.
  59643. // however, don't suppress the throwing behavior for this.
  59644. function onerror(er) {
  59645. unpipe();
  59646. dest.removeListener('error', onerror);
  59647. if (EE.listenerCount(dest, 'error') === 0)
  59648. dest.emit('error', er);
  59649. }
  59650. // This is a brutally ugly hack to make sure that our error handler
  59651. // is attached before any userland ones. NEVER DO THIS.
  59652. if (!dest._events || !dest._events.error)
  59653. dest.on('error', onerror);
  59654. else if (isArray(dest._events.error))
  59655. dest._events.error.unshift(onerror);
  59656. else
  59657. dest._events.error = [onerror, dest._events.error];
  59658. // Both close and finish should trigger unpipe, but only once.
  59659. function onclose() {
  59660. dest.removeListener('finish', onfinish);
  59661. unpipe();
  59662. }
  59663. dest.once('close', onclose);
  59664. function onfinish() {
  59665. dest.removeListener('close', onclose);
  59666. unpipe();
  59667. }
  59668. dest.once('finish', onfinish);
  59669. function unpipe() {
  59670. src.unpipe(dest);
  59671. }
  59672. // tell the dest that it's being piped to
  59673. dest.emit('pipe', src);
  59674. // start the flow if it hasn't been started already.
  59675. if (!state.flowing) {
  59676. // the handler that waits for readable events after all
  59677. // the data gets sucked out in flow.
  59678. // This would be easier to follow with a .once() handler
  59679. // in flow(), but that is too slow.
  59680. this.on('readable', pipeOnReadable);
  59681. state.flowing = true;
  59682. process.nextTick(function() {
  59683. flow(src);
  59684. });
  59685. }
  59686. return dest;
  59687. };
  59688. function pipeOnDrain(src) {
  59689. return function() {
  59690. var dest = this;
  59691. var state = src._readableState;
  59692. state.awaitDrain--;
  59693. if (state.awaitDrain === 0)
  59694. flow(src);
  59695. };
  59696. }
  59697. function flow(src) {
  59698. var state = src._readableState;
  59699. var chunk;
  59700. state.awaitDrain = 0;
  59701. function write(dest, i, list) {
  59702. var written = dest.write(chunk);
  59703. if (false === written) {
  59704. state.awaitDrain++;
  59705. }
  59706. }
  59707. while (state.pipesCount && null !== (chunk = src.read())) {
  59708. if (state.pipesCount === 1)
  59709. write(state.pipes, 0, null);
  59710. else
  59711. forEach(state.pipes, write);
  59712. src.emit('data', chunk);
  59713. // if anyone needs a drain, then we have to wait for that.
  59714. if (state.awaitDrain > 0)
  59715. return;
  59716. }
  59717. // if every destination was unpiped, either before entering this
  59718. // function, or in the while loop, then stop flowing.
  59719. //
  59720. // NB: This is a pretty rare edge case.
  59721. if (state.pipesCount === 0) {
  59722. state.flowing = false;
  59723. // if there were data event listeners added, then switch to old mode.
  59724. if (EE.listenerCount(src, 'data') > 0)
  59725. emitDataEvents(src);
  59726. return;
  59727. }
  59728. // at this point, no one needed a drain, so we just ran out of data
  59729. // on the next readable event, start it over again.
  59730. state.ranOut = true;
  59731. }
  59732. function pipeOnReadable() {
  59733. if (this._readableState.ranOut) {
  59734. this._readableState.ranOut = false;
  59735. flow(this);
  59736. }
  59737. }
  59738. Readable.prototype.unpipe = function(dest) {
  59739. var state = this._readableState;
  59740. // if we're not piping anywhere, then do nothing.
  59741. if (state.pipesCount === 0)
  59742. return this;
  59743. // just one destination. most common case.
  59744. if (state.pipesCount === 1) {
  59745. // passed in one, but it's not the right one.
  59746. if (dest && dest !== state.pipes)
  59747. return this;
  59748. if (!dest)
  59749. dest = state.pipes;
  59750. // got a match.
  59751. state.pipes = null;
  59752. state.pipesCount = 0;
  59753. this.removeListener('readable', pipeOnReadable);
  59754. state.flowing = false;
  59755. if (dest)
  59756. dest.emit('unpipe', this);
  59757. return this;
  59758. }
  59759. // slow case. multiple pipe destinations.
  59760. if (!dest) {
  59761. // remove all.
  59762. var dests = state.pipes;
  59763. var len = state.pipesCount;
  59764. state.pipes = null;
  59765. state.pipesCount = 0;
  59766. this.removeListener('readable', pipeOnReadable);
  59767. state.flowing = false;
  59768. for (var i = 0; i < len; i++)
  59769. dests[i].emit('unpipe', this);
  59770. return this;
  59771. }
  59772. // try to find the right one.
  59773. var i = indexOf(state.pipes, dest);
  59774. if (i === -1)
  59775. return this;
  59776. state.pipes.splice(i, 1);
  59777. state.pipesCount -= 1;
  59778. if (state.pipesCount === 1)
  59779. state.pipes = state.pipes[0];
  59780. dest.emit('unpipe', this);
  59781. return this;
  59782. };
  59783. // set up data events if they are asked for
  59784. // Ensure readable listeners eventually get something
  59785. Readable.prototype.on = function(ev, fn) {
  59786. var res = Stream.prototype.on.call(this, ev, fn);
  59787. if (ev === 'data' && !this._readableState.flowing)
  59788. emitDataEvents(this);
  59789. if (ev === 'readable' && this.readable) {
  59790. var state = this._readableState;
  59791. if (!state.readableListening) {
  59792. state.readableListening = true;
  59793. state.emittedReadable = false;
  59794. state.needReadable = true;
  59795. if (!state.reading) {
  59796. this.read(0);
  59797. } else if (state.length) {
  59798. emitReadable(this, state);
  59799. }
  59800. }
  59801. }
  59802. return res;
  59803. };
  59804. Readable.prototype.addListener = Readable.prototype.on;
  59805. // pause() and resume() are remnants of the legacy readable stream API
  59806. // If the user uses them, then switch into old mode.
  59807. Readable.prototype.resume = function() {
  59808. emitDataEvents(this);
  59809. this.read(0);
  59810. this.emit('resume');
  59811. };
  59812. Readable.prototype.pause = function() {
  59813. emitDataEvents(this, true);
  59814. this.emit('pause');
  59815. };
  59816. function emitDataEvents(stream, startPaused) {
  59817. var state = stream._readableState;
  59818. if (state.flowing) {
  59819. // https://github.com/isaacs/readable-stream/issues/16
  59820. throw new Error('Cannot switch to old mode now.');
  59821. }
  59822. var paused = startPaused || false;
  59823. var readable = false;
  59824. // convert to an old-style stream.
  59825. stream.readable = true;
  59826. stream.pipe = Stream.prototype.pipe;
  59827. stream.on = stream.addListener = Stream.prototype.on;
  59828. stream.on('readable', function() {
  59829. readable = true;
  59830. var c;
  59831. while (!paused && (null !== (c = stream.read())))
  59832. stream.emit('data', c);
  59833. if (c === null) {
  59834. readable = false;
  59835. stream._readableState.needReadable = true;
  59836. }
  59837. });
  59838. stream.pause = function() {
  59839. paused = true;
  59840. this.emit('pause');
  59841. };
  59842. stream.resume = function() {
  59843. paused = false;
  59844. if (readable)
  59845. process.nextTick(function() {
  59846. stream.emit('readable');
  59847. });
  59848. else
  59849. this.read(0);
  59850. this.emit('resume');
  59851. };
  59852. // now make it start, just in case it hadn't already.
  59853. stream.emit('readable');
  59854. }
  59855. // wrap an old-style stream as the async data source.
  59856. // This is *not* part of the readable stream interface.
  59857. // It is an ugly unfortunate mess of history.
  59858. Readable.prototype.wrap = function(stream) {
  59859. var state = this._readableState;
  59860. var paused = false;
  59861. var self = this;
  59862. stream.on('end', function() {
  59863. if (state.decoder && !state.ended) {
  59864. var chunk = state.decoder.end();
  59865. if (chunk && chunk.length)
  59866. self.push(chunk);
  59867. }
  59868. self.push(null);
  59869. });
  59870. stream.on('data', function(chunk) {
  59871. if (state.decoder)
  59872. chunk = state.decoder.write(chunk);
  59873. // don't skip over falsy values in objectMode
  59874. //if (state.objectMode && util.isNullOrUndefined(chunk))
  59875. if (state.objectMode && (chunk === null || chunk === undefined))
  59876. return;
  59877. else if (!state.objectMode && (!chunk || !chunk.length))
  59878. return;
  59879. var ret = self.push(chunk);
  59880. if (!ret) {
  59881. paused = true;
  59882. stream.pause();
  59883. }
  59884. });
  59885. // proxy all the other methods.
  59886. // important when wrapping filters and duplexes.
  59887. for (var i in stream) {
  59888. if (typeof stream[i] === 'function' &&
  59889. typeof this[i] === 'undefined') {
  59890. this[i] = function(method) { return function() {
  59891. return stream[method].apply(stream, arguments);
  59892. }}(i);
  59893. }
  59894. }
  59895. // proxy certain important events.
  59896. var events = ['error', 'close', 'destroy', 'pause', 'resume'];
  59897. forEach(events, function(ev) {
  59898. stream.on(ev, self.emit.bind(self, ev));
  59899. });
  59900. // when we try to consume some more bytes, simply unpause the
  59901. // underlying stream.
  59902. self._read = function(n) {
  59903. if (paused) {
  59904. paused = false;
  59905. stream.resume();
  59906. }
  59907. };
  59908. return self;
  59909. };
  59910. // exposed for testing purposes only.
  59911. Readable._fromList = fromList;
  59912. // Pluck off n bytes from an array of buffers.
  59913. // Length is the combined lengths of all the buffers in the list.
  59914. function fromList(n, state) {
  59915. var list = state.buffer;
  59916. var length = state.length;
  59917. var stringMode = !!state.decoder;
  59918. var objectMode = !!state.objectMode;
  59919. var ret;
  59920. // nothing in the list, definitely empty.
  59921. if (list.length === 0)
  59922. return null;
  59923. if (length === 0)
  59924. ret = null;
  59925. else if (objectMode)
  59926. ret = list.shift();
  59927. else if (!n || n >= length) {
  59928. // read it all, truncate the array.
  59929. if (stringMode)
  59930. ret = list.join('');
  59931. else
  59932. ret = Buffer.concat(list, length);
  59933. list.length = 0;
  59934. } else {
  59935. // read just some of it.
  59936. if (n < list[0].length) {
  59937. // just take a part of the first list item.
  59938. // slice is the same for buffers and strings.
  59939. var buf = list[0];
  59940. ret = buf.slice(0, n);
  59941. list[0] = buf.slice(n);
  59942. } else if (n === list[0].length) {
  59943. // first list is a perfect match
  59944. ret = list.shift();
  59945. } else {
  59946. // complex case.
  59947. // we have enough to cover it, but it spans past the first buffer.
  59948. if (stringMode)
  59949. ret = '';
  59950. else
  59951. ret = new Buffer(n);
  59952. var c = 0;
  59953. for (var i = 0, l = list.length; i < l && c < n; i++) {
  59954. var buf = list[0];
  59955. var cpy = Math.min(n - c, buf.length);
  59956. if (stringMode)
  59957. ret += buf.slice(0, cpy);
  59958. else
  59959. buf.copy(ret, c, 0, cpy);
  59960. if (cpy < buf.length)
  59961. list[0] = buf.slice(cpy);
  59962. else
  59963. list.shift();
  59964. c += cpy;
  59965. }
  59966. }
  59967. }
  59968. return ret;
  59969. }
  59970. function endReadable(stream) {
  59971. var state = stream._readableState;
  59972. // If we get here before consuming all the bytes, then that is a
  59973. // bug in node. Should never happen.
  59974. if (state.length > 0)
  59975. throw new Error('endReadable called on non-empty stream');
  59976. if (!state.endEmitted && state.calledRead) {
  59977. state.ended = true;
  59978. process.nextTick(function() {
  59979. // Check that we didn't get one last unshift.
  59980. if (!state.endEmitted && state.length === 0) {
  59981. state.endEmitted = true;
  59982. stream.readable = false;
  59983. stream.emit('end');
  59984. }
  59985. });
  59986. }
  59987. }
  59988. function forEach (xs, f) {
  59989. for (var i = 0, l = xs.length; i < l; i++) {
  59990. f(xs[i], i);
  59991. }
  59992. }
  59993. function indexOf (xs, x) {
  59994. for (var i = 0, l = xs.length; i < l; i++) {
  59995. if (xs[i] === x) return i;
  59996. }
  59997. return -1;
  59998. }
  59999. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  60000. /***/ },
  60001. /* 529 */
  60002. /***/ function(module, exports, __webpack_require__) {
  60003. // Copyright Joyent, Inc. and other Node contributors.
  60004. //
  60005. // Permission is hereby granted, free of charge, to any person obtaining a
  60006. // copy of this software and associated documentation files (the
  60007. // "Software"), to deal in the Software without restriction, including
  60008. // without limitation the rights to use, copy, modify, merge, publish,
  60009. // distribute, sublicense, and/or sell copies of the Software, and to permit
  60010. // persons to whom the Software is furnished to do so, subject to the
  60011. // following conditions:
  60012. //
  60013. // The above copyright notice and this permission notice shall be included
  60014. // in all copies or substantial portions of the Software.
  60015. //
  60016. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  60017. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  60018. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  60019. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  60020. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  60021. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  60022. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  60023. // a transform stream is a readable/writable stream where you do
  60024. // something with the data. Sometimes it's called a "filter",
  60025. // but that's not a great name for it, since that implies a thing where
  60026. // some bits pass through, and others are simply ignored. (That would
  60027. // be a valid example of a transform, of course.)
  60028. //
  60029. // While the output is causally related to the input, it's not a
  60030. // necessarily symmetric or synchronous transformation. For example,
  60031. // a zlib stream might take multiple plain-text writes(), and then
  60032. // emit a single compressed chunk some time in the future.
  60033. //
  60034. // Here's how this works:
  60035. //
  60036. // The Transform stream has all the aspects of the readable and writable
  60037. // stream classes. When you write(chunk), that calls _write(chunk,cb)
  60038. // internally, and returns false if there's a lot of pending writes
  60039. // buffered up. When you call read(), that calls _read(n) until
  60040. // there's enough pending readable data buffered up.
  60041. //
  60042. // In a transform stream, the written data is placed in a buffer. When
  60043. // _read(n) is called, it transforms the queued up data, calling the
  60044. // buffered _write cb's as it consumes chunks. If consuming a single
  60045. // written chunk would result in multiple output chunks, then the first
  60046. // outputted bit calls the readcb, and subsequent chunks just go into
  60047. // the read buffer, and will cause it to emit 'readable' if necessary.
  60048. //
  60049. // This way, back-pressure is actually determined by the reading side,
  60050. // since _read has to be called to start processing a new chunk. However,
  60051. // a pathological inflate type of transform can cause excessive buffering
  60052. // here. For example, imagine a stream where every byte of input is
  60053. // interpreted as an integer from 0-255, and then results in that many
  60054. // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
  60055. // 1kb of data being output. In this case, you could write a very small
  60056. // amount of input, and end up with a very large amount of output. In
  60057. // such a pathological inflating mechanism, there'd be no way to tell
  60058. // the system to stop doing the transform. A single 4MB write could
  60059. // cause the system to run out of memory.
  60060. //
  60061. // However, even in such a pathological case, only a single written chunk
  60062. // would be consumed, and then the rest would wait (un-transformed) until
  60063. // the results of the previous transformed chunk were consumed.
  60064. module.exports = Transform;
  60065. var Duplex = __webpack_require__(207);
  60066. /*<replacement>*/
  60067. var util = __webpack_require__(14);
  60068. util.inherits = __webpack_require__(2);
  60069. /*</replacement>*/
  60070. util.inherits(Transform, Duplex);
  60071. function TransformState(options, stream) {
  60072. this.afterTransform = function(er, data) {
  60073. return afterTransform(stream, er, data);
  60074. };
  60075. this.needTransform = false;
  60076. this.transforming = false;
  60077. this.writecb = null;
  60078. this.writechunk = null;
  60079. }
  60080. function afterTransform(stream, er, data) {
  60081. var ts = stream._transformState;
  60082. ts.transforming = false;
  60083. var cb = ts.writecb;
  60084. if (!cb)
  60085. return stream.emit('error', new Error('no writecb in Transform class'));
  60086. ts.writechunk = null;
  60087. ts.writecb = null;
  60088. if (data !== null && data !== undefined)
  60089. stream.push(data);
  60090. if (cb)
  60091. cb(er);
  60092. var rs = stream._readableState;
  60093. rs.reading = false;
  60094. if (rs.needReadable || rs.length < rs.highWaterMark) {
  60095. stream._read(rs.highWaterMark);
  60096. }
  60097. }
  60098. function Transform(options) {
  60099. if (!(this instanceof Transform))
  60100. return new Transform(options);
  60101. Duplex.call(this, options);
  60102. var ts = this._transformState = new TransformState(options, this);
  60103. // when the writable side finishes, then flush out anything remaining.
  60104. var stream = this;
  60105. // start out asking for a readable event once data is transformed.
  60106. this._readableState.needReadable = true;
  60107. // we have implemented the _read method, and done the other things
  60108. // that Readable wants before the first _read call, so unset the
  60109. // sync guard flag.
  60110. this._readableState.sync = false;
  60111. this.once('finish', function() {
  60112. if ('function' === typeof this._flush)
  60113. this._flush(function(er) {
  60114. done(stream, er);
  60115. });
  60116. else
  60117. done(stream);
  60118. });
  60119. }
  60120. Transform.prototype.push = function(chunk, encoding) {
  60121. this._transformState.needTransform = false;
  60122. return Duplex.prototype.push.call(this, chunk, encoding);
  60123. };
  60124. // This is the part where you do stuff!
  60125. // override this function in implementation classes.
  60126. // 'chunk' is an input chunk.
  60127. //
  60128. // Call `push(newChunk)` to pass along transformed output
  60129. // to the readable side. You may call 'push' zero or more times.
  60130. //
  60131. // Call `cb(err)` when you are done with this chunk. If you pass
  60132. // an error, then that'll put the hurt on the whole operation. If you
  60133. // never call cb(), then you'll never get another chunk.
  60134. Transform.prototype._transform = function(chunk, encoding, cb) {
  60135. throw new Error('not implemented');
  60136. };
  60137. Transform.prototype._write = function(chunk, encoding, cb) {
  60138. var ts = this._transformState;
  60139. ts.writecb = cb;
  60140. ts.writechunk = chunk;
  60141. ts.writeencoding = encoding;
  60142. if (!ts.transforming) {
  60143. var rs = this._readableState;
  60144. if (ts.needTransform ||
  60145. rs.needReadable ||
  60146. rs.length < rs.highWaterMark)
  60147. this._read(rs.highWaterMark);
  60148. }
  60149. };
  60150. // Doesn't matter what the args are here.
  60151. // _transform does all the work.
  60152. // That we got here means that the readable side wants more data.
  60153. Transform.prototype._read = function(n) {
  60154. var ts = this._transformState;
  60155. if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
  60156. ts.transforming = true;
  60157. this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
  60158. } else {
  60159. // mark that we need a transform, so that any data that comes in
  60160. // will get processed, now that we've asked for it.
  60161. ts.needTransform = true;
  60162. }
  60163. };
  60164. function done(stream, er) {
  60165. if (er)
  60166. return stream.emit('error', er);
  60167. // if there's nothing in the write buffer, then that means
  60168. // that nothing more will ever be provided
  60169. var ws = stream._writableState;
  60170. var rs = stream._readableState;
  60171. var ts = stream._transformState;
  60172. if (ws.length)
  60173. throw new Error('calling transform done when ws.length != 0');
  60174. if (ts.transforming)
  60175. throw new Error('calling transform done when still transforming');
  60176. return stream.push(null);
  60177. }
  60178. /***/ },
  60179. /* 530 */
  60180. /***/ function(module, exports, __webpack_require__) {
  60181. /* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors.
  60182. //
  60183. // Permission is hereby granted, free of charge, to any person obtaining a
  60184. // copy of this software and associated documentation files (the
  60185. // "Software"), to deal in the Software without restriction, including
  60186. // without limitation the rights to use, copy, modify, merge, publish,
  60187. // distribute, sublicense, and/or sell copies of the Software, and to permit
  60188. // persons to whom the Software is furnished to do so, subject to the
  60189. // following conditions:
  60190. //
  60191. // The above copyright notice and this permission notice shall be included
  60192. // in all copies or substantial portions of the Software.
  60193. //
  60194. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  60195. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  60196. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  60197. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  60198. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  60199. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  60200. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  60201. // A bit simpler than readable streams.
  60202. // Implement an async ._write(chunk, cb), and it'll handle all
  60203. // the drain event emission and buffering.
  60204. module.exports = Writable;
  60205. /*<replacement>*/
  60206. var Buffer = __webpack_require__(1).Buffer;
  60207. /*</replacement>*/
  60208. Writable.WritableState = WritableState;
  60209. /*<replacement>*/
  60210. var util = __webpack_require__(14);
  60211. util.inherits = __webpack_require__(2);
  60212. /*</replacement>*/
  60213. var Stream = __webpack_require__(9);
  60214. util.inherits(Writable, Stream);
  60215. function WriteReq(chunk, encoding, cb) {
  60216. this.chunk = chunk;
  60217. this.encoding = encoding;
  60218. this.callback = cb;
  60219. }
  60220. function WritableState(options, stream) {
  60221. options = options || {};
  60222. // the point at which write() starts returning false
  60223. // Note: 0 is a valid value, means that we always return false if
  60224. // the entire buffer is not flushed immediately on write()
  60225. var hwm = options.highWaterMark;
  60226. this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024;
  60227. // object stream flag to indicate whether or not this stream
  60228. // contains buffers or objects.
  60229. this.objectMode = !!options.objectMode;
  60230. // cast to ints.
  60231. this.highWaterMark = ~~this.highWaterMark;
  60232. this.needDrain = false;
  60233. // at the start of calling end()
  60234. this.ending = false;
  60235. // when end() has been called, and returned
  60236. this.ended = false;
  60237. // when 'finish' is emitted
  60238. this.finished = false;
  60239. // should we decode strings into buffers before passing to _write?
  60240. // this is here so that some node-core streams can optimize string
  60241. // handling at a lower level.
  60242. var noDecode = options.decodeStrings === false;
  60243. this.decodeStrings = !noDecode;
  60244. // Crypto is kind of old and crusty. Historically, its default string
  60245. // encoding is 'binary' so we have to make this configurable.
  60246. // Everything else in the universe uses 'utf8', though.
  60247. this.defaultEncoding = options.defaultEncoding || 'utf8';
  60248. // not an actual buffer we keep track of, but a measurement
  60249. // of how much we're waiting to get pushed to some underlying
  60250. // socket or file.
  60251. this.length = 0;
  60252. // a flag to see when we're in the middle of a write.
  60253. this.writing = false;
  60254. // a flag to be able to tell if the onwrite cb is called immediately,
  60255. // or on a later tick. We set this to true at first, becuase any
  60256. // actions that shouldn't happen until "later" should generally also
  60257. // not happen before the first write call.
  60258. this.sync = true;
  60259. // a flag to know if we're processing previously buffered items, which
  60260. // may call the _write() callback in the same tick, so that we don't
  60261. // end up in an overlapped onwrite situation.
  60262. this.bufferProcessing = false;
  60263. // the callback that's passed to _write(chunk,cb)
  60264. this.onwrite = function(er) {
  60265. onwrite(stream, er);
  60266. };
  60267. // the callback that the user supplies to write(chunk,encoding,cb)
  60268. this.writecb = null;
  60269. // the amount that is being written when _write is called.
  60270. this.writelen = 0;
  60271. this.buffer = [];
  60272. // True if the error was already emitted and should not be thrown again
  60273. this.errorEmitted = false;
  60274. }
  60275. function Writable(options) {
  60276. var Duplex = __webpack_require__(207);
  60277. // Writable ctor is applied to Duplexes, though they're not
  60278. // instanceof Writable, they're instanceof Readable.
  60279. if (!(this instanceof Writable) && !(this instanceof Duplex))
  60280. return new Writable(options);
  60281. this._writableState = new WritableState(options, this);
  60282. // legacy.
  60283. this.writable = true;
  60284. Stream.call(this);
  60285. }
  60286. // Otherwise people can pipe Writable streams, which is just wrong.
  60287. Writable.prototype.pipe = function() {
  60288. this.emit('error', new Error('Cannot pipe. Not readable.'));
  60289. };
  60290. function writeAfterEnd(stream, state, cb) {
  60291. var er = new Error('write after end');
  60292. // TODO: defer error events consistently everywhere, not just the cb
  60293. stream.emit('error', er);
  60294. process.nextTick(function() {
  60295. cb(er);
  60296. });
  60297. }
  60298. // If we get something that is not a buffer, string, null, or undefined,
  60299. // and we're not in objectMode, then that's an error.
  60300. // Otherwise stream chunks are all considered to be of length=1, and the
  60301. // watermarks determine how many objects to keep in the buffer, rather than
  60302. // how many bytes or characters.
  60303. function validChunk(stream, state, chunk, cb) {
  60304. var valid = true;
  60305. if (!Buffer.isBuffer(chunk) &&
  60306. 'string' !== typeof chunk &&
  60307. chunk !== null &&
  60308. chunk !== undefined &&
  60309. !state.objectMode) {
  60310. var er = new TypeError('Invalid non-string/buffer chunk');
  60311. stream.emit('error', er);
  60312. process.nextTick(function() {
  60313. cb(er);
  60314. });
  60315. valid = false;
  60316. }
  60317. return valid;
  60318. }
  60319. Writable.prototype.write = function(chunk, encoding, cb) {
  60320. var state = this._writableState;
  60321. var ret = false;
  60322. if (typeof encoding === 'function') {
  60323. cb = encoding;
  60324. encoding = null;
  60325. }
  60326. if (Buffer.isBuffer(chunk))
  60327. encoding = 'buffer';
  60328. else if (!encoding)
  60329. encoding = state.defaultEncoding;
  60330. if (typeof cb !== 'function')
  60331. cb = function() {};
  60332. if (state.ended)
  60333. writeAfterEnd(this, state, cb);
  60334. else if (validChunk(this, state, chunk, cb))
  60335. ret = writeOrBuffer(this, state, chunk, encoding, cb);
  60336. return ret;
  60337. };
  60338. function decodeChunk(state, chunk, encoding) {
  60339. if (!state.objectMode &&
  60340. state.decodeStrings !== false &&
  60341. typeof chunk === 'string') {
  60342. chunk = new Buffer(chunk, encoding);
  60343. }
  60344. return chunk;
  60345. }
  60346. // if we're already writing something, then just put this
  60347. // in the queue, and wait our turn. Otherwise, call _write
  60348. // If we return false, then we need a drain event, so set that flag.
  60349. function writeOrBuffer(stream, state, chunk, encoding, cb) {
  60350. chunk = decodeChunk(state, chunk, encoding);
  60351. if (Buffer.isBuffer(chunk))
  60352. encoding = 'buffer';
  60353. var len = state.objectMode ? 1 : chunk.length;
  60354. state.length += len;
  60355. var ret = state.length < state.highWaterMark;
  60356. // we must ensure that previous needDrain will not be reset to false.
  60357. if (!ret)
  60358. state.needDrain = true;
  60359. if (state.writing)
  60360. state.buffer.push(new WriteReq(chunk, encoding, cb));
  60361. else
  60362. doWrite(stream, state, len, chunk, encoding, cb);
  60363. return ret;
  60364. }
  60365. function doWrite(stream, state, len, chunk, encoding, cb) {
  60366. state.writelen = len;
  60367. state.writecb = cb;
  60368. state.writing = true;
  60369. state.sync = true;
  60370. stream._write(chunk, encoding, state.onwrite);
  60371. state.sync = false;
  60372. }
  60373. function onwriteError(stream, state, sync, er, cb) {
  60374. if (sync)
  60375. process.nextTick(function() {
  60376. cb(er);
  60377. });
  60378. else
  60379. cb(er);
  60380. stream._writableState.errorEmitted = true;
  60381. stream.emit('error', er);
  60382. }
  60383. function onwriteStateUpdate(state) {
  60384. state.writing = false;
  60385. state.writecb = null;
  60386. state.length -= state.writelen;
  60387. state.writelen = 0;
  60388. }
  60389. function onwrite(stream, er) {
  60390. var state = stream._writableState;
  60391. var sync = state.sync;
  60392. var cb = state.writecb;
  60393. onwriteStateUpdate(state);
  60394. if (er)
  60395. onwriteError(stream, state, sync, er, cb);
  60396. else {
  60397. // Check if we're actually ready to finish, but don't emit yet
  60398. var finished = needFinish(stream, state);
  60399. if (!finished && !state.bufferProcessing && state.buffer.length)
  60400. clearBuffer(stream, state);
  60401. if (sync) {
  60402. process.nextTick(function() {
  60403. afterWrite(stream, state, finished, cb);
  60404. });
  60405. } else {
  60406. afterWrite(stream, state, finished, cb);
  60407. }
  60408. }
  60409. }
  60410. function afterWrite(stream, state, finished, cb) {
  60411. if (!finished)
  60412. onwriteDrain(stream, state);
  60413. cb();
  60414. if (finished)
  60415. finishMaybe(stream, state);
  60416. }
  60417. // Must force callback to be called on nextTick, so that we don't
  60418. // emit 'drain' before the write() consumer gets the 'false' return
  60419. // value, and has a chance to attach a 'drain' listener.
  60420. function onwriteDrain(stream, state) {
  60421. if (state.length === 0 && state.needDrain) {
  60422. state.needDrain = false;
  60423. stream.emit('drain');
  60424. }
  60425. }
  60426. // if there's something in the buffer waiting, then process it
  60427. function clearBuffer(stream, state) {
  60428. state.bufferProcessing = true;
  60429. for (var c = 0; c < state.buffer.length; c++) {
  60430. var entry = state.buffer[c];
  60431. var chunk = entry.chunk;
  60432. var encoding = entry.encoding;
  60433. var cb = entry.callback;
  60434. var len = state.objectMode ? 1 : chunk.length;
  60435. doWrite(stream, state, len, chunk, encoding, cb);
  60436. // if we didn't call the onwrite immediately, then
  60437. // it means that we need to wait until it does.
  60438. // also, that means that the chunk and cb are currently
  60439. // being processed, so move the buffer counter past them.
  60440. if (state.writing) {
  60441. c++;
  60442. break;
  60443. }
  60444. }
  60445. state.bufferProcessing = false;
  60446. if (c < state.buffer.length)
  60447. state.buffer = state.buffer.slice(c);
  60448. else
  60449. state.buffer.length = 0;
  60450. }
  60451. Writable.prototype._write = function(chunk, encoding, cb) {
  60452. cb(new Error('not implemented'));
  60453. };
  60454. Writable.prototype.end = function(chunk, encoding, cb) {
  60455. var state = this._writableState;
  60456. if (typeof chunk === 'function') {
  60457. cb = chunk;
  60458. chunk = null;
  60459. encoding = null;
  60460. } else if (typeof encoding === 'function') {
  60461. cb = encoding;
  60462. encoding = null;
  60463. }
  60464. if (typeof chunk !== 'undefined' && chunk !== null)
  60465. this.write(chunk, encoding);
  60466. // ignore unnecessary end() calls.
  60467. if (!state.ending && !state.finished)
  60468. endWritable(this, state, cb);
  60469. };
  60470. function needFinish(stream, state) {
  60471. return (state.ending &&
  60472. state.length === 0 &&
  60473. !state.finished &&
  60474. !state.writing);
  60475. }
  60476. function finishMaybe(stream, state) {
  60477. var need = needFinish(stream, state);
  60478. if (need) {
  60479. state.finished = true;
  60480. stream.emit('finish');
  60481. }
  60482. return need;
  60483. }
  60484. function endWritable(stream, state, cb) {
  60485. state.ending = true;
  60486. finishMaybe(stream, state);
  60487. if (cb) {
  60488. if (state.finished)
  60489. process.nextTick(cb);
  60490. else
  60491. stream.once('finish', cb);
  60492. }
  60493. state.ended = true;
  60494. }
  60495. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  60496. /***/ },
  60497. /* 531 */
  60498. /***/ function(module, exports, __webpack_require__) {
  60499. module.exports = __webpack_require__(529)
  60500. /***/ },
  60501. /* 532 */
  60502. /***/ function(module, exports, __webpack_require__) {
  60503. /* WEBPACK VAR INJECTION */(function(process) {var Transform = __webpack_require__(531)
  60504. , inherits = __webpack_require__(44).inherits
  60505. , xtend = __webpack_require__(98)
  60506. function DestroyableTransform(opts) {
  60507. Transform.call(this, opts)
  60508. this._destroyed = false
  60509. }
  60510. inherits(DestroyableTransform, Transform)
  60511. DestroyableTransform.prototype.destroy = function(err) {
  60512. if (this._destroyed) return
  60513. this._destroyed = true
  60514. var self = this
  60515. process.nextTick(function() {
  60516. if (err)
  60517. self.emit('error', err)
  60518. self.emit('close')
  60519. })
  60520. }
  60521. // a noop _transform function
  60522. function noop (chunk, enc, callback) {
  60523. callback(null, chunk)
  60524. }
  60525. // create a new export function, used by both the main export and
  60526. // the .ctor export, contains common logic for dealing with arguments
  60527. function through2 (construct) {
  60528. return function (options, transform, flush) {
  60529. if (typeof options == 'function') {
  60530. flush = transform
  60531. transform = options
  60532. options = {}
  60533. }
  60534. if (typeof transform != 'function')
  60535. transform = noop
  60536. if (typeof flush != 'function')
  60537. flush = null
  60538. return construct(options, transform, flush)
  60539. }
  60540. }
  60541. // main export, just make me a transform stream!
  60542. module.exports = through2(function (options, transform, flush) {
  60543. var t2 = new DestroyableTransform(options)
  60544. t2._transform = transform
  60545. if (flush)
  60546. t2._flush = flush
  60547. return t2
  60548. })
  60549. // make me a reusable prototype that I can `new`, or implicitly `new`
  60550. // with a constructor call
  60551. module.exports.ctor = through2(function (options, transform, flush) {
  60552. function Through2 (override) {
  60553. if (!(this instanceof Through2))
  60554. return new Through2(override)
  60555. this.options = xtend(options, override)
  60556. DestroyableTransform.call(this, this.options)
  60557. }
  60558. inherits(Through2, DestroyableTransform)
  60559. Through2.prototype._transform = transform
  60560. if (flush)
  60561. Through2.prototype._flush = flush
  60562. return Through2
  60563. })
  60564. module.exports.obj = through2(function (options, transform, flush) {
  60565. var t2 = new DestroyableTransform(xtend({ objectMode: true, highWaterMark: 16 }, options))
  60566. t2._transform = transform
  60567. if (flush)
  60568. t2._flush = flush
  60569. return t2
  60570. })
  60571. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  60572. /***/ },
  60573. /* 533 */
  60574. /***/ function(module, exports, __webpack_require__) {
  60575. // from https://github.com/indutny/self-signed/blob/gh-pages/lib/asn1.js
  60576. // Fedor, you are amazing.
  60577. var asn1 = __webpack_require__(77)
  60578. var RSAPrivateKey = asn1.define('RSAPrivateKey', function () {
  60579. this.seq().obj(
  60580. this.key('version').int(),
  60581. this.key('modulus').int(),
  60582. this.key('publicExponent').int(),
  60583. this.key('privateExponent').int(),
  60584. this.key('prime1').int(),
  60585. this.key('prime2').int(),
  60586. this.key('exponent1').int(),
  60587. this.key('exponent2').int(),
  60588. this.key('coefficient').int()
  60589. )
  60590. })
  60591. exports.RSAPrivateKey = RSAPrivateKey
  60592. var RSAPublicKey = asn1.define('RSAPublicKey', function () {
  60593. this.seq().obj(
  60594. this.key('modulus').int(),
  60595. this.key('publicExponent').int()
  60596. )
  60597. })
  60598. exports.RSAPublicKey = RSAPublicKey
  60599. var PublicKey = asn1.define('SubjectPublicKeyInfo', function () {
  60600. this.seq().obj(
  60601. this.key('algorithm').use(AlgorithmIdentifier),
  60602. this.key('subjectPublicKey').bitstr()
  60603. )
  60604. })
  60605. exports.PublicKey = PublicKey
  60606. var AlgorithmIdentifier = asn1.define('AlgorithmIdentifier', function () {
  60607. this.seq().obj(
  60608. this.key('algorithm').objid(),
  60609. this.key('none').null_().optional(),
  60610. this.key('curve').objid().optional(),
  60611. this.key('params').seq().obj(
  60612. this.key('p').int(),
  60613. this.key('q').int(),
  60614. this.key('g').int()
  60615. ).optional()
  60616. )
  60617. })
  60618. var PrivateKeyInfo = asn1.define('PrivateKeyInfo', function () {
  60619. this.seq().obj(
  60620. this.key('version').int(),
  60621. this.key('algorithm').use(AlgorithmIdentifier),
  60622. this.key('subjectPrivateKey').octstr()
  60623. )
  60624. })
  60625. exports.PrivateKey = PrivateKeyInfo
  60626. var EncryptedPrivateKeyInfo = asn1.define('EncryptedPrivateKeyInfo', function () {
  60627. this.seq().obj(
  60628. this.key('algorithm').seq().obj(
  60629. this.key('id').objid(),
  60630. this.key('decrypt').seq().obj(
  60631. this.key('kde').seq().obj(
  60632. this.key('id').objid(),
  60633. this.key('kdeparams').seq().obj(
  60634. this.key('salt').octstr(),
  60635. this.key('iters').int()
  60636. )
  60637. ),
  60638. this.key('cipher').seq().obj(
  60639. this.key('algo').objid(),
  60640. this.key('iv').octstr()
  60641. )
  60642. )
  60643. ),
  60644. this.key('subjectPrivateKey').octstr()
  60645. )
  60646. })
  60647. exports.EncryptedPrivateKey = EncryptedPrivateKeyInfo
  60648. var DSAPrivateKey = asn1.define('DSAPrivateKey', function () {
  60649. this.seq().obj(
  60650. this.key('version').int(),
  60651. this.key('p').int(),
  60652. this.key('q').int(),
  60653. this.key('g').int(),
  60654. this.key('pub_key').int(),
  60655. this.key('priv_key').int()
  60656. )
  60657. })
  60658. exports.DSAPrivateKey = DSAPrivateKey
  60659. exports.DSAparam = asn1.define('DSAparam', function () {
  60660. this.int()
  60661. })
  60662. var ECPrivateKey = asn1.define('ECPrivateKey', function () {
  60663. this.seq().obj(
  60664. this.key('version').int(),
  60665. this.key('privateKey').octstr(),
  60666. this.key('parameters').optional().explicit(0).use(ECParameters),
  60667. this.key('publicKey').optional().explicit(1).bitstr()
  60668. )
  60669. })
  60670. exports.ECPrivateKey = ECPrivateKey
  60671. var ECParameters = asn1.define('ECParameters', function () {
  60672. this.choice({
  60673. namedCurve: this.objid()
  60674. })
  60675. })
  60676. exports.signature = asn1.define('signature', function () {
  60677. this.seq().obj(
  60678. this.key('r').int(),
  60679. this.key('s').int()
  60680. )
  60681. })
  60682. /***/ },
  60683. /* 534 */
  60684. /***/ function(module, exports, __webpack_require__) {
  60685. /* WEBPACK VAR INJECTION */(function(Buffer) {// adapted from https://github.com/apatil/pemstrip
  60686. var findProc = /Proc-Type: 4,ENCRYPTED\r?\nDEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)\r?\n\r?\n([0-9A-z\n\r\+\/\=]+)\r?\n/m
  60687. var startRegex = /^-----BEGIN (.*) KEY-----\r?\n/m
  60688. var fullRegex = /^-----BEGIN (.*) KEY-----\r?\n([0-9A-z\n\r\+\/\=]+)\r?\n-----END \1 KEY-----$/m
  60689. var evp = __webpack_require__(95)
  60690. var ciphers = __webpack_require__(102)
  60691. module.exports = function (okey, password) {
  60692. var key = okey.toString()
  60693. var match = key.match(findProc)
  60694. var decrypted
  60695. if (!match) {
  60696. var match2 = key.match(fullRegex)
  60697. decrypted = new Buffer(match2[2].replace(/\r?\n/g, ''), 'base64')
  60698. } else {
  60699. var suite = 'aes' + match[1]
  60700. var iv = new Buffer(match[2], 'hex')
  60701. var cipherText = new Buffer(match[3].replace(/\r?\n/g, ''), 'base64')
  60702. var cipherKey = evp(password, iv.slice(0, 8), parseInt(match[1], 10)).key
  60703. var out = []
  60704. var cipher = ciphers.createDecipheriv(suite, cipherKey, iv)
  60705. out.push(cipher.update(cipherText))
  60706. out.push(cipher.final())
  60707. decrypted = Buffer.concat(out)
  60708. }
  60709. var tag = key.match(startRegex)[1] + ' KEY'
  60710. return {
  60711. tag: tag,
  60712. data: decrypted
  60713. }
  60714. }
  60715. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  60716. /***/ },
  60717. /* 535 */
  60718. /***/ function(module, exports, __webpack_require__) {
  60719. var parse = __webpack_require__(536)
  60720. var stringify = __webpack_require__(537)
  60721. module.exports = parse
  60722. module.exports.parse = parse
  60723. module.exports.stringify = stringify
  60724. /***/ },
  60725. /* 536 */
  60726. /***/ function(module, exports, __webpack_require__) {
  60727. var tokenize = __webpack_require__(538)
  60728. var MAX_RANGE = 0x1FFFFFFF
  60729. var onfieldoptions = function (tokens) {
  60730. var opts = {}
  60731. while (tokens.length) {
  60732. switch (tokens[0]) {
  60733. case '[':
  60734. case ',':
  60735. tokens.shift()
  60736. var name = tokens.shift()
  60737. if (name === '(') { // handling [(A) = B]
  60738. name = tokens.shift()
  60739. tokens.shift() // remove the end of bracket
  60740. }
  60741. if (tokens[0] !== '=') throw new Error('Unexpected token in field options: ' + tokens[0])
  60742. tokens.shift()
  60743. if (tokens[0] === ']') throw new Error('Unexpected ] in field option')
  60744. opts[name] = tokens.shift()
  60745. break
  60746. case ']':
  60747. tokens.shift()
  60748. return opts
  60749. default:
  60750. throw new Error('Unexpected token in field options: ' + tokens[0])
  60751. }
  60752. }
  60753. throw new Error('No closing tag for field options')
  60754. }
  60755. var onfield = function (tokens) {
  60756. var field = {
  60757. name: null,
  60758. type: null,
  60759. tag: 0,
  60760. map: null,
  60761. oneof: null,
  60762. required: false,
  60763. repeated: false,
  60764. options: {}
  60765. }
  60766. while (tokens.length) {
  60767. switch (tokens[0]) {
  60768. case '=':
  60769. tokens.shift()
  60770. field.tag = Number(tokens.shift())
  60771. break
  60772. case 'map':
  60773. field.type = 'map'
  60774. field.map = {from: null, to: null}
  60775. tokens.shift()
  60776. if (tokens[0] !== '<') throw new Error('Unexpected token in map type: ' + tokens[0])
  60777. tokens.shift()
  60778. field.map.from = tokens.shift()
  60779. if (tokens[0] !== ',') throw new Error('Unexpected token in map type: ' + tokens[0])
  60780. tokens.shift()
  60781. field.map.to = tokens.shift()
  60782. if (tokens[0] !== '>') throw new Error('Unexpected token in map type: ' + tokens[0])
  60783. tokens.shift()
  60784. field.name = tokens.shift()
  60785. break
  60786. case 'repeated':
  60787. case 'required':
  60788. case 'optional':
  60789. var t = tokens.shift()
  60790. field.required = t === 'required'
  60791. field.repeated = t === 'repeated'
  60792. field.type = tokens.shift()
  60793. field.name = tokens.shift()
  60794. break
  60795. case '[':
  60796. field.options = onfieldoptions(tokens)
  60797. break
  60798. case ';':
  60799. tokens.shift()
  60800. return field
  60801. default:
  60802. throw new Error('Unexpected token in message field: ' + tokens[0])
  60803. }
  60804. }
  60805. throw new Error('No ; found for message field')
  60806. }
  60807. var onmessagebody = function (tokens) {
  60808. var body = {
  60809. enums: [],
  60810. messages: [],
  60811. fields: [],
  60812. extensions: null
  60813. }
  60814. while (tokens.length) {
  60815. switch (tokens[0]) {
  60816. case 'map':
  60817. case 'repeated':
  60818. case 'optional':
  60819. case 'required':
  60820. body.fields.push(onfield(tokens))
  60821. break
  60822. case 'enum':
  60823. body.enums.push(onenum(tokens))
  60824. break
  60825. case 'message':
  60826. body.messages.push(onmessage(tokens))
  60827. break
  60828. case 'extensions':
  60829. body.extensions = onextensions(tokens)
  60830. break
  60831. case 'oneof':
  60832. tokens.shift()
  60833. var name = tokens.shift()
  60834. if (tokens[0] !== '{') throw new Error('Unexpected token in oneof: ' + tokens[0])
  60835. tokens.shift()
  60836. while (tokens[0] !== '}') {
  60837. tokens.unshift('optional')
  60838. var field = onfield(tokens)
  60839. field.oneof = name
  60840. body.fields.push(field)
  60841. }
  60842. tokens.shift()
  60843. break
  60844. case ';':
  60845. tokens.shift()
  60846. break
  60847. default:
  60848. // proto3 does not require the use of optional/required, assumed as optional
  60849. // "singular: a well-formed message can have zero or one of this field (but not more than one)."
  60850. // https://developers.google.com/protocol-buffers/docs/proto3#specifying-field-rules
  60851. tokens.unshift('optional')
  60852. body.fields.push(onfield(tokens))
  60853. }
  60854. }
  60855. return body
  60856. }
  60857. var onextend = function (tokens) {
  60858. var out = {
  60859. name: tokens[1],
  60860. message: onmessage(tokens)
  60861. }
  60862. return out
  60863. }
  60864. var onextensions = function (tokens) {
  60865. tokens.shift()
  60866. var from = Number(tokens.shift())
  60867. if (isNaN(from)) throw new Error('Invalid from in extensions definition')
  60868. if (tokens.shift() !== 'to') throw new Error("Expected keyword 'to' in extensions definition")
  60869. var to = tokens.shift()
  60870. if (to === 'max') to = MAX_RANGE
  60871. to = Number(to)
  60872. if (isNaN(to)) throw new Error('Invalid to in extensions definition')
  60873. if (tokens.shift() !== ';') throw new Error('Missing ; in extensions definition')
  60874. return {from: from, to: to}
  60875. }
  60876. var onmessage = function (tokens) {
  60877. tokens.shift()
  60878. var lvl = 1
  60879. var body = []
  60880. var msg = {
  60881. name: tokens.shift(),
  60882. enums: [],
  60883. messages: [],
  60884. fields: []
  60885. }
  60886. if (tokens[0] !== '{') throw new Error('Expected { but found ' + tokens[0])
  60887. tokens.shift()
  60888. while (tokens.length) {
  60889. if (tokens[0] === '{') lvl++
  60890. else if (tokens[0] === '}') lvl--
  60891. if (!lvl) {
  60892. tokens.shift()
  60893. body = onmessagebody(body)
  60894. msg.enums = body.enums
  60895. msg.messages = body.messages
  60896. msg.fields = body.fields
  60897. msg.extensions = body.extensions
  60898. return msg
  60899. }
  60900. body.push(tokens.shift())
  60901. }
  60902. if (lvl) throw new Error('No closing tag for message')
  60903. }
  60904. var onpackagename = function (tokens) {
  60905. tokens.shift()
  60906. var name = tokens.shift()
  60907. if (tokens[0] !== ';') throw new Error('Expected ; but found ' + tokens[0])
  60908. tokens.shift()
  60909. return name
  60910. }
  60911. var onsyntaxversion = function (tokens) {
  60912. tokens.shift()
  60913. if (tokens[0] !== '=') throw new Error('Expected = but found ' + tokens[0])
  60914. tokens.shift()
  60915. var version = tokens.shift()
  60916. switch (version) {
  60917. case '"proto2"':
  60918. version = 2
  60919. break
  60920. case '"proto3"':
  60921. version = 3
  60922. break
  60923. default:
  60924. throw new Error('Expected protobuf syntax version but found ' + version)
  60925. }
  60926. if (tokens[0] !== ';') throw new Error('Expected ; but found ' + tokens[0])
  60927. tokens.shift()
  60928. return version
  60929. }
  60930. var onenumvalue = function (tokens) {
  60931. if (tokens.length < 4) throw new Error('Invalid enum value: ' + tokens.slice(0, 3).join(' '))
  60932. if (tokens[1] !== '=') throw new Error('Expected = but found ' + tokens[1])
  60933. if (tokens[3] !== ';') throw new Error('Expected ; but found ' + tokens[1])
  60934. var name = tokens.shift()
  60935. tokens.shift()
  60936. var value = Number(tokens.shift())
  60937. tokens.shift()
  60938. return {
  60939. name: name,
  60940. value: value
  60941. }
  60942. }
  60943. var onenum = function (tokens) {
  60944. tokens.shift()
  60945. var e = {
  60946. name: tokens.shift(),
  60947. values: {}
  60948. }
  60949. if (tokens[0] !== '{') throw new Error('Expected { but found ' + tokens[0])
  60950. tokens.shift()
  60951. while (tokens.length) {
  60952. if (tokens[0] === '}') {
  60953. tokens.shift()
  60954. // there goes optional semicolon after the enclosing "}"
  60955. if (tokens[0] === ';') tokens.shift()
  60956. return e
  60957. }
  60958. if (tokens[0] === 'option') {
  60959. // just skip "option allow_alias = true;"
  60960. while (tokens.shift() !== ';') {
  60961. // do nothing
  60962. }
  60963. }
  60964. var val = onenumvalue(tokens)
  60965. e.values[val.name] = val.value
  60966. }
  60967. throw new Error('No closing tag for enum')
  60968. }
  60969. var onoption = function (tokens) {
  60970. var name = null
  60971. var value = null
  60972. var parse = function (value) {
  60973. if (value === 'true') return true
  60974. if (value === 'false') return false
  60975. return value.replace(/^"+|"+$/gm, '')
  60976. }
  60977. while (tokens.length) {
  60978. if (tokens[0] === ';') {
  60979. tokens.shift()
  60980. return {name: name, value: value}
  60981. }
  60982. switch (tokens[0]) {
  60983. case 'option':
  60984. tokens.shift()
  60985. var hasBracket = tokens[0] === '('
  60986. if (hasBracket) tokens.shift()
  60987. name = tokens.shift()
  60988. if (hasBracket) {
  60989. if (tokens[0] !== ')') throw new Error('Expected ) but found ' + tokens[0])
  60990. tokens.shift()
  60991. }
  60992. break
  60993. case '=':
  60994. tokens.shift()
  60995. if (name === null) throw new Error('Expected key for option with value: ' + tokens[0])
  60996. value = parse(tokens.shift())
  60997. if (name === 'optimize_for' && !/^(SPEED|CODE_SIZE|LITE_RUNTIME)$/.test(value)) {
  60998. throw new Error('Unexpected value for option optimize_for: ' + value)
  60999. } else if (value === '{') {
  61000. // option foo = {bar: baz}
  61001. value = onoptionMap(tokens)
  61002. }
  61003. break
  61004. default:
  61005. throw new Error('Unexpected token in option: ' + tokens[0])
  61006. }
  61007. }
  61008. }
  61009. var onoptionMap = function (tokens) {
  61010. var parse = function (value) {
  61011. if (value === 'true') return true
  61012. if (value === 'false') return false
  61013. return value.replace(/^"+|"+$/gm, '')
  61014. }
  61015. var map = {}
  61016. while (tokens.length) {
  61017. if (tokens[0] === '}') {
  61018. tokens.shift()
  61019. return map
  61020. }
  61021. var hasBracket = tokens[0] === '('
  61022. if (hasBracket) tokens.shift()
  61023. var key = tokens.shift()
  61024. if (hasBracket) {
  61025. if (tokens[0] !== ')') throw new Error('Expected ) but found ' + tokens[0])
  61026. tokens.shift()
  61027. }
  61028. var value = null
  61029. switch (tokens[0]) {
  61030. case ':':
  61031. if (map[key] !== undefined) throw new Error('Duplicate option map key ' + key)
  61032. tokens.shift()
  61033. value = parse(tokens.shift())
  61034. if (value === '{') {
  61035. // option foo = {bar: baz}
  61036. value = onoptionMap(tokens)
  61037. }
  61038. map[key] = value
  61039. break
  61040. case '{':
  61041. tokens.shift()
  61042. value = onoptionMap(tokens)
  61043. if (map[key] === undefined) map[key] = []
  61044. if (!Array.isArray(map[key])) throw new Error('Duplicate option map key ' + key)
  61045. map[key].push(value)
  61046. break
  61047. default:
  61048. throw new Error('Unexpected token in option map: ' + tokens[0])
  61049. }
  61050. }
  61051. throw new Error('No closing tag for option map')
  61052. }
  61053. var onimport = function (tokens) {
  61054. tokens.shift()
  61055. var file = tokens.shift().replace(/^"+|"+$/gm, '')
  61056. if (tokens[0] !== ';') throw new Error('Unexpected token: ' + tokens[0] + '. Expected ";"')
  61057. tokens.shift()
  61058. return file
  61059. }
  61060. var onservice = function (tokens) {
  61061. tokens.shift()
  61062. var service = {
  61063. name: tokens.shift(),
  61064. methods: [],
  61065. options: {}
  61066. }
  61067. if (tokens[0] !== '{') throw new Error('Expected { but found ' + tokens[0])
  61068. tokens.shift()
  61069. while (tokens.length) {
  61070. if (tokens[0] === '}') {
  61071. tokens.shift()
  61072. // there goes optional semicolon after the enclosing "}"
  61073. if (tokens[0] === ';') tokens.shift()
  61074. return service
  61075. }
  61076. switch (tokens[0]) {
  61077. case 'option':
  61078. var opt = onoption(tokens)
  61079. if (service.options[opt.name] !== undefined) throw new Error('Duplicate option ' + opt.name)
  61080. service.options[opt.name] = opt.value
  61081. break
  61082. case 'rpc':
  61083. service.methods.push(onrpc(tokens))
  61084. break
  61085. default:
  61086. throw new Error('Unexpected token in service: ' + tokens[0])
  61087. }
  61088. }
  61089. throw new Error('No closing tag for service')
  61090. }
  61091. var onrpc = function (tokens) {
  61092. tokens.shift()
  61093. var rpc = {
  61094. name: tokens.shift(),
  61095. input_type: null,
  61096. output_type: null,
  61097. client_streaming: false,
  61098. server_streaming: false,
  61099. options: {}
  61100. }
  61101. if (tokens[0] !== '(') throw new Error('Expected ( but found ' + tokens[0])
  61102. tokens.shift()
  61103. if (tokens[0] === 'stream') {
  61104. tokens.shift()
  61105. rpc.client_streaming = true
  61106. }
  61107. rpc.input_type = tokens.shift()
  61108. if (tokens[0] !== ')') throw new Error('Expected ) but found ' + tokens[0])
  61109. tokens.shift()
  61110. if (tokens[0] !== 'returns') throw new Error('Expected returns but found ' + tokens[0])
  61111. tokens.shift()
  61112. if (tokens[0] !== '(') throw new Error('Expected ( but found ' + tokens[0])
  61113. tokens.shift()
  61114. if (tokens[0] === 'stream') {
  61115. tokens.shift()
  61116. rpc.server_streaming = true
  61117. }
  61118. rpc.output_type = tokens.shift()
  61119. if (tokens[0] !== ')') throw new Error('Expected ) but found ' + tokens[0])
  61120. tokens.shift()
  61121. if (tokens[0] === ';') {
  61122. tokens.shift()
  61123. return rpc
  61124. }
  61125. if (tokens[0] !== '{') throw new Error('Expected { but found ' + tokens[0])
  61126. tokens.shift()
  61127. while (tokens.length) {
  61128. if (tokens[0] === '}') {
  61129. tokens.shift()
  61130. // there goes optional semicolon after the enclosing "}"
  61131. if (tokens[0] === ';') tokens.shift()
  61132. return rpc
  61133. }
  61134. if (tokens[0] === 'option') {
  61135. var opt = onoption(tokens)
  61136. if (rpc.options[opt.name] !== undefined) throw new Error('Duplicate option ' + opt.name)
  61137. rpc.options[opt.name] = opt.value
  61138. } else {
  61139. throw new Error('Unexpected token in rpc options: ' + tokens[0])
  61140. }
  61141. }
  61142. throw new Error('No closing tag for rpc')
  61143. }
  61144. var parse = function (buf) {
  61145. var tokens = tokenize(buf.toString())
  61146. // check for isolated strings in tokens by looking for opening quote
  61147. for (var i = 0; i < tokens.length; i++) {
  61148. if (/^(\"|\')([^\'\"]*)$/.test(tokens[i])) {
  61149. var j
  61150. if (tokens[i].length === 1) {
  61151. j = i + 1
  61152. } else {
  61153. j = i
  61154. }
  61155. // look ahead for the closing quote and collapse all
  61156. // in-between tokens into a single token
  61157. for (j; j < tokens.length; j++) {
  61158. if (/^([^\'\"]*)(\"|\')$/.test(tokens[j])) {
  61159. tokens = tokens.slice(0, i).concat(tokens.slice(i, j + 1).join('')).concat(tokens.slice(j + 1))
  61160. break
  61161. }
  61162. }
  61163. }
  61164. }
  61165. var schema = {
  61166. syntax: 3,
  61167. package: null,
  61168. imports: [],
  61169. enums: [],
  61170. messages: [],
  61171. options: {},
  61172. extends: []
  61173. }
  61174. var firstline = true
  61175. while (tokens.length) {
  61176. switch (tokens[0]) {
  61177. case 'package':
  61178. schema.package = onpackagename(tokens)
  61179. break
  61180. case 'syntax':
  61181. if (!firstline) throw new Error('Protobuf syntax version should be first thing in file')
  61182. schema.syntax = onsyntaxversion(tokens)
  61183. break
  61184. case 'message':
  61185. schema.messages.push(onmessage(tokens))
  61186. break
  61187. case 'enum':
  61188. schema.enums.push(onenum(tokens))
  61189. break
  61190. case 'option':
  61191. var opt = onoption(tokens)
  61192. if (schema.options[opt.name]) throw new Error('Duplicate option ' + opt.name)
  61193. schema.options[opt.name] = opt.value
  61194. break
  61195. case 'import':
  61196. schema.imports.push(onimport(tokens))
  61197. break
  61198. case 'extend':
  61199. schema.extends.push(onextend(tokens))
  61200. break
  61201. case 'service':
  61202. if (!schema.services) schema.services = []
  61203. schema.services.push(onservice(tokens))
  61204. break
  61205. default:
  61206. throw new Error('Unexpected token: ' + tokens[0])
  61207. }
  61208. firstline = false
  61209. }
  61210. // now iterate over messages and propagate extends
  61211. schema.extends.forEach(function (ext) {
  61212. schema.messages.forEach(function (msg) {
  61213. if (msg.name === ext.name) {
  61214. ext.message.fields.forEach(function (field) {
  61215. if (!msg.extensions || field.tag < msg.extensions.from || field.tag > msg.extensions.to) {
  61216. throw new Error(msg.name + ' does not declare ' + field.tag + ' as an extension number')
  61217. }
  61218. msg.fields.push(field)
  61219. })
  61220. }
  61221. })
  61222. })
  61223. return schema
  61224. }
  61225. module.exports = parse
  61226. /***/ },
  61227. /* 537 */
  61228. /***/ function(module, exports) {
  61229. var onfield = function (f, result) {
  61230. var prefix = f.repeated ? 'repeated' : f.required ? 'required' : 'optional'
  61231. if (f.type === 'map') prefix = 'map<' + f.map.from + ',' + f.map.to + '>'
  61232. if (f.oneof) prefix = ''
  61233. var opts = Object.keys(f.options || {}).map(function (key) {
  61234. return key + ' = ' + f.options[key]
  61235. }).join(',')
  61236. if (opts) opts = ' [' + opts + ']'
  61237. result.push((prefix ? prefix + ' ' : '') + (f.map === 'map' ? '' : f.type + ' ') + f.name + ' = ' + f.tag + opts + ';')
  61238. return result
  61239. }
  61240. var onmessage = function (m, result) {
  61241. result.push('message ' + m.name + ' {')
  61242. if (!m.enums) m.enums = []
  61243. m.enums.forEach(function (e) {
  61244. result.push(onenum(e, []))
  61245. })
  61246. if (!m.messages) m.messages = []
  61247. m.messages.forEach(function (m) {
  61248. result.push(onmessage(m, []))
  61249. })
  61250. var oneofs = {}
  61251. if (!m.fields) m.fields = []
  61252. m.fields.forEach(function (f) {
  61253. if (f.oneof) {
  61254. if (!oneofs[f.oneof]) oneofs[f.oneof] = []
  61255. oneofs[f.oneof].push(onfield(f, []))
  61256. } else {
  61257. result.push(onfield(f, []))
  61258. }
  61259. })
  61260. Object.keys(oneofs).forEach(function (n) {
  61261. oneofs[n].unshift('oneof ' + n + ' {')
  61262. oneofs[n].push('}')
  61263. result.push(oneofs[n])
  61264. })
  61265. result.push('}', '')
  61266. return result
  61267. }
  61268. var onenum = function (e, result) {
  61269. result.push('enum ' + e.name + ' {')
  61270. var vals = Object.keys(e.values).map(function (key) {
  61271. return key + ' = ' + e.values[key] + ';'
  61272. })
  61273. result.push(vals)
  61274. result.push('}', '')
  61275. return result
  61276. }
  61277. var onoption = function (o, result) {
  61278. var keys = Object.keys(o)
  61279. keys.forEach(function (option) {
  61280. var v = o[option]
  61281. if (~option.indexOf('.')) option = '(' + option + ')'
  61282. var type = typeof v
  61283. if (type === 'object') {
  61284. v = onoptionMap(v, [])
  61285. if (v.length) result.push('option ' + option + ' = {', v, '};')
  61286. } else {
  61287. if (type === 'string' && option !== 'optimize_for') v = '"' + v + '"'
  61288. result.push('option ' + option + ' = ' + v + ';')
  61289. }
  61290. })
  61291. if (keys.length > 0) {
  61292. result.push('')
  61293. }
  61294. return result
  61295. }
  61296. var onoptionMap = function (o, result) {
  61297. var keys = Object.keys(o)
  61298. keys.forEach(function (k) {
  61299. var v = o[k]
  61300. var type = typeof v
  61301. if (type === 'object') {
  61302. if (Array.isArray(v)) {
  61303. v.forEach(function (v) {
  61304. v = onoptionMap(v, [])
  61305. if (v.length) result.push(k + ' {', v, '}')
  61306. })
  61307. } else {
  61308. v = onoptionMap(v, [])
  61309. if (v.length) result.push(k + ' {', v, '}')
  61310. }
  61311. } else {
  61312. if (type === 'string') v = '"' + v + '"'
  61313. result.push(k + ': ' + v)
  61314. }
  61315. })
  61316. return result
  61317. }
  61318. var onservices = function (s, result) {
  61319. result.push('service ' + s.name + ' {')
  61320. if (!s.options) s.options = {}
  61321. onoption(s.options, result)
  61322. if (!s.methods) s.methods = []
  61323. s.methods.forEach(function (m) {
  61324. result.push(onrpc(m, []))
  61325. })
  61326. result.push('}', '')
  61327. return result
  61328. }
  61329. var onrpc = function (rpc, result) {
  61330. var def = 'rpc ' + rpc.name + '('
  61331. if (rpc.client_streaming) def += 'stream '
  61332. def += rpc.input_type + ') returns ('
  61333. if (rpc.server_streaming) def += 'stream '
  61334. def += rpc.output_type + ')'
  61335. if (!rpc.options) rpc.options = {}
  61336. var options = onoption(rpc.options, [])
  61337. if (options.length > 1) {
  61338. result.push(def + ' {', options.slice(0, -1), '}')
  61339. } else {
  61340. result.push(def + ';')
  61341. }
  61342. return result
  61343. }
  61344. var indent = function (lvl) {
  61345. return function (line) {
  61346. if (Array.isArray(line)) return line.map(indent(lvl + ' ')).join('\n')
  61347. return lvl + line
  61348. }
  61349. }
  61350. module.exports = function (schema) {
  61351. var result = []
  61352. result.push('syntax = "proto' + schema.syntax + '";', '')
  61353. if (schema.package) result.push('package ' + schema.package + ';', '')
  61354. if (!schema.options) schema.options = {}
  61355. onoption(schema.options, result)
  61356. if (!schema.enums) schema.enums = []
  61357. schema.enums.forEach(function (e) {
  61358. onenum(e, result)
  61359. })
  61360. if (!schema.messages) schema.messages = []
  61361. schema.messages.forEach(function (m) {
  61362. onmessage(m, result)
  61363. })
  61364. if (schema.services) {
  61365. schema.services.forEach(function (s) {
  61366. onservices(s, result)
  61367. })
  61368. }
  61369. return result.map(indent('')).join('\n')
  61370. }
  61371. /***/ },
  61372. /* 538 */
  61373. /***/ function(module, exports) {
  61374. module.exports = function (sch) {
  61375. var noComments = function (line) {
  61376. var i = line.indexOf('//')
  61377. return i > -1 ? line.slice(0, i) : line
  61378. }
  61379. var noMultilineComments = function () {
  61380. var inside = false
  61381. return function (token) {
  61382. if (token === '/*') {
  61383. inside = true
  61384. return false
  61385. }
  61386. if (token === '*/') {
  61387. inside = false
  61388. return false
  61389. }
  61390. return !inside
  61391. }
  61392. }
  61393. var trim = function (line) {
  61394. return line.trim()
  61395. }
  61396. return sch
  61397. .replace(/([;,{}\(\)=\:\[\]<>]|\/\*|\*\/)/g, ' $1 ')
  61398. .split(/\n/)
  61399. .map(trim)
  61400. .filter(Boolean)
  61401. .map(noComments)
  61402. .map(trim)
  61403. .filter(Boolean)
  61404. .join('\n')
  61405. .split(/\s+|\n+/gm)
  61406. .filter(noMultilineComments())
  61407. }
  61408. /***/ },
  61409. /* 539 */
  61410. /***/ function(module, exports, __webpack_require__) {
  61411. /* WEBPACK VAR INJECTION */(function(Buffer) {/* eslint-disable no-spaced-func */
  61412. /* eslint-disable no-unexpected-multiline */
  61413. var encodings = __webpack_require__(540)
  61414. var varint = __webpack_require__(75)
  61415. var genobj = __webpack_require__(503)
  61416. var genfun = __webpack_require__(502)
  61417. var skip = function (type, buffer, offset) {
  61418. switch (type) {
  61419. case 0:
  61420. varint.decode(buffer, offset)
  61421. return offset + varint.decode.bytes
  61422. case 1:
  61423. return offset + 8
  61424. case 2:
  61425. var len = varint.decode(buffer, offset)
  61426. return offset + varint.decode.bytes + len
  61427. case 3:
  61428. case 4:
  61429. throw new Error('Groups are not supported')
  61430. case 5:
  61431. return offset + 4
  61432. }
  61433. throw new Error('Unknown wire type: ' + type)
  61434. }
  61435. var defined = function (val) {
  61436. return val !== null && val !== undefined && (typeof val !== 'number' || !isNaN(val))
  61437. }
  61438. var isString = function (def) {
  61439. try {
  61440. return !!def && typeof JSON.parse(def) === 'string'
  61441. } catch (err) {
  61442. return false
  61443. }
  61444. }
  61445. var defaultValue = function (f, def) {
  61446. if (f.map) return '{}'
  61447. if (f.repeated) return '[]'
  61448. switch (f.type) {
  61449. case 'string':
  61450. return isString(def) ? def : '""'
  61451. case 'bool':
  61452. if (def === 'true') return 'true'
  61453. return 'false'
  61454. case 'float':
  61455. case 'double':
  61456. case 'sfixed32':
  61457. case 'fixed32':
  61458. case 'varint':
  61459. case 'enum':
  61460. case 'uint64':
  61461. case 'uint32':
  61462. case 'int64':
  61463. case 'int32':
  61464. case 'sint64':
  61465. case 'sint32':
  61466. return '' + Number(def || 0)
  61467. default:
  61468. return 'null'
  61469. }
  61470. }
  61471. module.exports = function (schema, extraEncodings) {
  61472. var messages = {}
  61473. var enums = {}
  61474. var cache = {}
  61475. var visit = function (schema, prefix) {
  61476. if (schema.enums) {
  61477. schema.enums.forEach(function (e) {
  61478. e.id = prefix + (prefix ? '.' : '') + e.name
  61479. enums[e.id] = e
  61480. visit(e, e.id)
  61481. })
  61482. }
  61483. if (schema.messages) {
  61484. schema.messages.forEach(function (m) {
  61485. m.id = prefix + (prefix ? '.' : '') + m.name
  61486. messages[m.id] = m
  61487. m.fields.forEach(function (f) {
  61488. if (!f.map) return
  61489. var name = 'Map_' + f.map.from + '_' + f.map.to
  61490. var map = {
  61491. name: name,
  61492. enums: [],
  61493. messages: [],
  61494. fields: [{
  61495. name: 'key',
  61496. type: f.map.from,
  61497. tag: 1,
  61498. repeated: false,
  61499. required: true
  61500. }, {
  61501. name: 'value',
  61502. type: f.map.to,
  61503. tag: 2,
  61504. repeated: false,
  61505. required: false
  61506. }],
  61507. extensions: null,
  61508. id: prefix + (prefix ? '.' : '') + name
  61509. }
  61510. if (!messages[map.id]) {
  61511. messages[map.id] = map
  61512. schema.messages.push(map)
  61513. }
  61514. f.type = name
  61515. f.repeated = true
  61516. })
  61517. visit(m, m.id)
  61518. })
  61519. }
  61520. }
  61521. visit(schema, '')
  61522. var compileEnum = function (e) {
  61523. var conditions = Object.keys(e.values)
  61524. .map(function (k) {
  61525. return 'val !== ' + parseInt(e.values[k], 10)
  61526. })
  61527. .join(' && ')
  61528. if (!conditions) conditions = 'true'
  61529. var encode = genfun()
  61530. ('function encode (val, buf, offset) {')
  61531. ('if (%s) throw new Error("Invalid enum value: "+val)', conditions)
  61532. ('varint.encode(val, buf, offset)')
  61533. ('encode.bytes = varint.encode.bytes')
  61534. ('return buf')
  61535. ('}')
  61536. .toFunction({
  61537. varint: varint
  61538. })
  61539. var decode = genfun()
  61540. ('function decode (buf, offset) {')
  61541. ('var val = varint.decode(buf, offset)')
  61542. ('if (%s) throw new Error("Invalid enum value: "+val)', conditions)
  61543. ('decode.bytes = varint.decode.bytes')
  61544. ('return val')
  61545. ('}')
  61546. .toFunction({
  61547. varint: varint
  61548. })
  61549. return encodings.make(0, encode, decode, varint.encodingLength)
  61550. }
  61551. var compileMessage = function (m, exports) {
  61552. m.messages.forEach(function (nested) {
  61553. exports[nested.name] = resolve(nested.name, m.id)
  61554. })
  61555. m.enums.forEach(function (val) {
  61556. exports[val.name] = val.values
  61557. })
  61558. exports.type = 2
  61559. exports.message = true
  61560. exports.name = m.name
  61561. var oneofs = {}
  61562. m.fields.forEach(function (f) {
  61563. if (!f.oneof) return
  61564. if (!oneofs[f.oneof]) oneofs[f.oneof] = []
  61565. oneofs[f.oneof].push(f.name)
  61566. })
  61567. var enc = m.fields.map(function (f) {
  61568. return resolve(f.type, m.id)
  61569. })
  61570. var forEach = function (fn) {
  61571. for (var i = 0; i < enc.length; i++) fn(enc[i], m.fields[i], genobj('obj', m.fields[i].name), i)
  61572. }
  61573. // compile encodingLength
  61574. var encodingLength = genfun()
  61575. ('function encodingLength (obj) {')
  61576. ('var length = 0')
  61577. Object.keys(oneofs).forEach(function (name) {
  61578. var msg = JSON.stringify('only one of the properties defined in oneof ' + name + ' can be set')
  61579. var cnt = oneofs[name]
  61580. .map(function (prop) {
  61581. return '+defined(' + genobj('obj', prop) + ')'
  61582. })
  61583. .join(' + ')
  61584. encodingLength('if ((%s) > 1) throw new Error(%s)', cnt, msg)
  61585. })
  61586. forEach(function (e, f, val, i) {
  61587. var packed = f.repeated && f.options && f.options.packed && f.options.packed !== 'false'
  61588. var hl = varint.encodingLength(f.tag << 3 | e.type)
  61589. if (f.required) encodingLength('if (!defined(%s)) throw new Error(%s)', val, JSON.stringify(f.name + ' is required'))
  61590. else encodingLength('if (defined(%s)) {', val)
  61591. if (f.map) {
  61592. encodingLength()
  61593. ('var tmp = Object.keys(%s)', val)
  61594. ('for (var i = 0; i < tmp.length; i++) {')
  61595. ('tmp[i] = {key: tmp[i], value: %s[tmp[i]]}', val)
  61596. ('}')
  61597. val = 'tmp'
  61598. }
  61599. if (packed) {
  61600. encodingLength()
  61601. ('var packedLen = 0')
  61602. ('for (var i = 0; i < %s.length; i++) {', val)
  61603. ('if (!defined(%s)) continue', val + '[i]')
  61604. ('var len = enc[%d].encodingLength(%s)', i, val + '[i]')
  61605. ('packedLen += len')
  61606. if (e.message) encodingLength('packedLen += varint.encodingLength(len)')
  61607. encodingLength('}')
  61608. ('if (packedLen) {')
  61609. ('length += %d + packedLen + varint.encodingLength(packedLen)', hl)
  61610. ('}')
  61611. } else {
  61612. if (f.repeated) {
  61613. encodingLength('for (var i = 0; i < %s.length; i++) {', val)
  61614. val += '[i]'
  61615. encodingLength('if (!defined(%s)) continue', val)
  61616. }
  61617. encodingLength('var len = enc[%d].encodingLength(%s)', i, val)
  61618. if (e.message) encodingLength('length += varint.encodingLength(len)')
  61619. encodingLength('length += %d + len', hl)
  61620. if (f.repeated) encodingLength('}')
  61621. }
  61622. if (!f.required) encodingLength('}')
  61623. })
  61624. encodingLength()
  61625. ('return length')
  61626. ('}')
  61627. encodingLength = encodingLength.toFunction({
  61628. defined: defined,
  61629. varint: varint,
  61630. enc: enc
  61631. })
  61632. // compile encode
  61633. var encode = genfun()
  61634. ('function encode (obj, buf, offset) {')
  61635. ('if (!offset) offset = 0')
  61636. ('if (!buf) buf = new Buffer(encodingLength(obj))')
  61637. ('var oldOffset = offset')
  61638. Object.keys(oneofs).forEach(function (name) {
  61639. var msg = JSON.stringify('only one of the properties defined in oneof ' + name + ' can be set')
  61640. var cnt = oneofs[name]
  61641. .map(function (prop) {
  61642. return '+defined(' + genobj('obj', prop) + ')'
  61643. })
  61644. .join(' + ')
  61645. encode('if ((%s) > 1) throw new Error(%s)', cnt, msg)
  61646. })
  61647. forEach(function (e, f, val, i) {
  61648. if (f.required) encode('if (!defined(%s)) throw new Error(%s)', val, JSON.stringify(f.name + ' is required'))
  61649. else encode('if (defined(%s)) {', val)
  61650. var packed = f.repeated && f.options && f.options.packed && f.options.packed !== 'false'
  61651. var p = varint.encode(f.tag << 3 | 2)
  61652. var h = varint.encode(f.tag << 3 | e.type)
  61653. var j
  61654. if (f.map) {
  61655. encode()
  61656. ('var tmp = Object.keys(%s)', val)
  61657. ('for (var i = 0; i < tmp.length; i++) {')
  61658. ('tmp[i] = {key: tmp[i], value: %s[tmp[i]]}', val)
  61659. ('}')
  61660. val = 'tmp'
  61661. }
  61662. if (packed) {
  61663. encode()
  61664. ('var packedLen = 0')
  61665. ('for (var i = 0; i < %s.length; i++) {', val)
  61666. ('if (!defined(%s)) continue', val + '[i]')
  61667. ('packedLen += enc[%d].encodingLength(%s)', i, val + '[i]')
  61668. ('}')
  61669. encode('if (packedLen) {')
  61670. for (j = 0; j < h.length; j++) encode('buf[offset++] = %d', p[j])
  61671. encode('varint.encode(packedLen, buf, offset)')
  61672. encode('offset += varint.encode.bytes')
  61673. encode('}')
  61674. }
  61675. if (f.repeated) {
  61676. encode('for (var i = 0; i < %s.length; i++) {', val)
  61677. val += '[i]'
  61678. encode('if (!defined(%s)) continue', val)
  61679. }
  61680. if (!packed) for (j = 0; j < h.length; j++) encode('buf[offset++] = %d', h[j])
  61681. if (e.message) {
  61682. encode('varint.encode(enc[%d].encodingLength(%s), buf, offset)', i, val)
  61683. encode('offset += varint.encode.bytes')
  61684. }
  61685. encode('enc[%d].encode(%s, buf, offset)', i, val)
  61686. encode('offset += enc[%d].encode.bytes', i)
  61687. if (f.repeated) encode('}')
  61688. if (!f.required) encode('}')
  61689. })
  61690. encode()
  61691. ('encode.bytes = offset - oldOffset')
  61692. ('return buf')
  61693. ('}')
  61694. encode = encode.toFunction({
  61695. encodingLength: encodingLength,
  61696. defined: defined,
  61697. varint: varint,
  61698. enc: enc,
  61699. Buffer: Buffer
  61700. })
  61701. // compile decode
  61702. var invalid = m.fields
  61703. .map(function (f, i) {
  61704. return f.required && '!found' + i
  61705. })
  61706. .filter(function (f) {
  61707. return f
  61708. })
  61709. .join(' || ')
  61710. var decode = genfun()
  61711. var objectKeys = []
  61712. forEach(function (e, f) {
  61713. var def = f.options && f.options.default
  61714. var resolved = resolve(f.type, m.id, false)
  61715. var vals = resolved && resolved.values
  61716. if (vals) { // is enum
  61717. if (f.repeated) {
  61718. objectKeys.push(genobj.property(f.name) + ': []')
  61719. } else {
  61720. def = (def && def in vals) ? vals[def] : vals[Object.keys(vals)[0]]
  61721. objectKeys.push(genobj.property(f.name) + ': ' + parseInt(def || 0, 10))
  61722. }
  61723. return
  61724. }
  61725. if (!f.oneof) {
  61726. objectKeys.push(genobj.property(f.name) + ': ' + defaultValue(f, def))
  61727. }
  61728. })
  61729. decode()
  61730. ('function decode (buf, offset, end) {')
  61731. ('if (!offset) offset = 0')
  61732. ('if (!end) end = buf.length')
  61733. ('if (!(end <= buf.length && offset <= buf.length)) throw new Error("Decoded message is not valid")')
  61734. ('var oldOffset = offset')
  61735. ('var obj = {')
  61736. objectKeys.forEach(function (prop, i) {
  61737. decode(prop + (i === objectKeys.length - 1 ? '' : ','))
  61738. })
  61739. decode('}')
  61740. forEach(function (e, f, val, i) {
  61741. if (f.required) decode('var found%d = false', i)
  61742. })
  61743. decode('while (true) {')
  61744. ('if (end <= offset) {')
  61745. (invalid && 'if (%s) throw new Error("Decoded message is not valid")', invalid)
  61746. ('decode.bytes = offset - oldOffset')
  61747. ('return obj')
  61748. ('}')
  61749. ('var prefix = varint.decode(buf, offset)')
  61750. ('offset += varint.decode.bytes')
  61751. ('var tag = prefix >> 3')
  61752. ('switch (tag) {')
  61753. forEach(function (e, f, val, i) {
  61754. var packed = f.repeated && f.options && f.options.packed && f.options.packed !== 'false'
  61755. decode('case %d:', f.tag)
  61756. if (f.oneof) {
  61757. m.fields.forEach(function (otherField) {
  61758. if (otherField.oneof === f.oneof && f.name !== otherField.name) {
  61759. decode('delete %s', genobj('obj', otherField.name))
  61760. }
  61761. })
  61762. }
  61763. if (packed) {
  61764. decode()
  61765. ('var packedEnd = varint.decode(buf, offset)')
  61766. ('offset += varint.decode.bytes')
  61767. ('packedEnd += offset')
  61768. ('while (offset < packedEnd) {')
  61769. }
  61770. if (e.message) {
  61771. decode('var len = varint.decode(buf, offset)')
  61772. decode('offset += varint.decode.bytes')
  61773. if (f.map) {
  61774. decode('var tmp = enc[%d].decode(buf, offset, offset + len)', i)
  61775. decode('%s[tmp.key] = tmp.value', val)
  61776. } else if (f.repeated) {
  61777. decode('%s.push(enc[%d].decode(buf, offset, offset + len))', val, i)
  61778. } else {
  61779. decode('%s = enc[%d].decode(buf, offset, offset + len)', val, i)
  61780. }
  61781. } else {
  61782. if (f.repeated) {
  61783. decode('%s.push(enc[%d].decode(buf, offset))', val, i)
  61784. } else {
  61785. decode('%s = enc[%d].decode(buf, offset)', val, i)
  61786. }
  61787. }
  61788. decode('offset += enc[%d].decode.bytes', i)
  61789. if (packed) decode('}')
  61790. if (f.required) decode('found%d = true', i)
  61791. decode('break')
  61792. })
  61793. decode()
  61794. ('default:')
  61795. ('offset = skip(prefix & 7, buf, offset)')
  61796. ('}')
  61797. ('}')
  61798. ('}')
  61799. decode = decode.toFunction({
  61800. varint: varint,
  61801. skip: skip,
  61802. enc: enc
  61803. })
  61804. // end of compilation - return all the things
  61805. encode.bytes = decode.bytes = 0
  61806. exports.buffer = true
  61807. exports.encode = encode
  61808. exports.decode = decode
  61809. exports.encodingLength = encodingLength
  61810. return exports
  61811. }
  61812. var resolve = function (name, from, compile) {
  61813. if (extraEncodings && extraEncodings[name]) return extraEncodings[name]
  61814. if (encodings[name]) return encodings[name]
  61815. var m = (from ? from + '.' + name : name).split('.')
  61816. .map(function (part, i, list) {
  61817. return list.slice(0, i).concat(name).join('.')
  61818. })
  61819. .reverse()
  61820. .reduce(function (result, id) {
  61821. return result || messages[id] || enums[id]
  61822. }, null)
  61823. if (compile === false) return m
  61824. if (!m) throw new Error('Could not resolve ' + name)
  61825. if (m.values) return compileEnum(m)
  61826. return cache[m.id] || compileMessage(m, cache[m.id] = {})
  61827. }
  61828. return (schema.enums || []).concat((schema.messages || []).map(function (message) {
  61829. return resolve(message.id)
  61830. }))
  61831. }
  61832. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  61833. /***/ },
  61834. /* 540 */
  61835. /***/ function(module, exports, __webpack_require__) {
  61836. /* WEBPACK VAR INJECTION */(function(Buffer) {var varint = __webpack_require__(75)
  61837. var svarint = __webpack_require__(561)
  61838. var encoder = function (type, encode, decode, encodingLength) {
  61839. encode.bytes = decode.bytes = 0
  61840. return {
  61841. type: type,
  61842. encode: encode,
  61843. decode: decode,
  61844. encodingLength: encodingLength
  61845. }
  61846. }
  61847. exports.make = encoder
  61848. exports.bytes = (function (tag) {
  61849. var bufferLength = function (val) {
  61850. return Buffer.isBuffer(val) ? val.length : Buffer.byteLength(val)
  61851. }
  61852. var encodingLength = function (val) {
  61853. var len = bufferLength(val)
  61854. return varint.encodingLength(len) + len
  61855. }
  61856. var encode = function (val, buffer, offset) {
  61857. var oldOffset = offset
  61858. var len = bufferLength(val)
  61859. varint.encode(len, buffer, offset)
  61860. offset += varint.encode.bytes
  61861. if (Buffer.isBuffer(val)) val.copy(buffer, offset)
  61862. else buffer.write(val, offset, len)
  61863. offset += len
  61864. encode.bytes = offset - oldOffset
  61865. return buffer
  61866. }
  61867. var decode = function (buffer, offset) {
  61868. var oldOffset = offset
  61869. var len = varint.decode(buffer, offset)
  61870. offset += varint.decode.bytes
  61871. var val = buffer.slice(offset, offset + len)
  61872. offset += val.length
  61873. decode.bytes = offset - oldOffset
  61874. return val
  61875. }
  61876. return encoder(2, encode, decode, encodingLength)
  61877. })()
  61878. exports.string = (function () {
  61879. var encodingLength = function (val) {
  61880. var len = Buffer.byteLength(val)
  61881. return varint.encodingLength(len) + len
  61882. }
  61883. var encode = function (val, buffer, offset) {
  61884. var oldOffset = offset
  61885. var len = Buffer.byteLength(val)
  61886. varint.encode(len, buffer, offset, 'utf-8')
  61887. offset += varint.encode.bytes
  61888. buffer.write(val, offset, len)
  61889. offset += len
  61890. encode.bytes = offset - oldOffset
  61891. return buffer
  61892. }
  61893. var decode = function (buffer, offset) {
  61894. var oldOffset = offset
  61895. var len = varint.decode(buffer, offset)
  61896. offset += varint.decode.bytes
  61897. var val = buffer.toString('utf-8', offset, offset + len)
  61898. offset += len
  61899. decode.bytes = offset - oldOffset
  61900. return val
  61901. }
  61902. return encoder(2, encode, decode, encodingLength)
  61903. })()
  61904. exports.bool = (function () {
  61905. var encodingLength = function (val) {
  61906. return 1
  61907. }
  61908. var encode = function (val, buffer, offset) {
  61909. buffer[offset] = val ? 1 : 0
  61910. encode.bytes = 1
  61911. return buffer
  61912. }
  61913. var decode = function (buffer, offset) {
  61914. var bool = buffer[offset] > 0
  61915. decode.bytes = 1
  61916. return bool
  61917. }
  61918. return encoder(0, encode, decode, encodingLength)
  61919. })()
  61920. exports.int32 = (function () {
  61921. var decode = function (buffer, offset) {
  61922. var val = varint.decode(buffer, offset)
  61923. decode.bytes = varint.decode.bytes
  61924. return val > 2147483647 ? val - 4294967296 : val
  61925. }
  61926. var encode = function (val, buffer, offset) {
  61927. varint.encode(val < 0 ? val + 4294967296 : val, buffer, offset)
  61928. encode.bytes = varint.encode.bytes
  61929. return buffer
  61930. }
  61931. var encodingLength = function (val) {
  61932. return varint.encodingLength(val < 0 ? val + 4294967296 : val)
  61933. }
  61934. return encoder(0, varint.encode, decode, encodingLength)
  61935. })()
  61936. exports.int64 = (function () {
  61937. var decode = function (buffer, offset) {
  61938. var val = varint.decode(buffer, offset)
  61939. if (val >= Math.pow(2, 63)) {
  61940. var limit = 9
  61941. while (buffer[offset + limit - 1] === 0xff) limit--
  61942. limit = limit || 9
  61943. var subset = new Buffer(limit)
  61944. buffer.copy(subset, 0, offset, offset + limit)
  61945. subset[limit - 1] = subset[limit - 1] & 0x7f
  61946. val = -1 * varint.decode(subset, 0)
  61947. decode.bytes = 10
  61948. } else {
  61949. decode.bytes = varint.decode.bytes
  61950. }
  61951. return val
  61952. }
  61953. var encode = function (val, buffer, offset) {
  61954. if (val < 0) {
  61955. var last = offset + 9
  61956. varint.encode(val * -1, buffer, offset)
  61957. offset += varint.encode.bytes - 1
  61958. buffer[offset] = buffer[offset] | 0x80
  61959. while (offset < last - 1) {
  61960. offset++
  61961. buffer[offset] = 0xff
  61962. }
  61963. buffer[last] = 0x01
  61964. encode.bytes = 10
  61965. } else {
  61966. varint.encode(val, buffer, offset)
  61967. encode.bytes = varint.encode.bytes
  61968. }
  61969. return buffer
  61970. }
  61971. var encodingLength = function (val) {
  61972. return val < 0 ? 10 : varint.encodingLength(val)
  61973. }
  61974. return encoder(0, encode, decode, encodingLength)
  61975. })()
  61976. exports.sint32 =
  61977. exports.sint64 = (function () {
  61978. return encoder(0, svarint.encode, svarint.decode, svarint.encodingLength)
  61979. })()
  61980. exports.uint32 =
  61981. exports.uint64 =
  61982. exports.enum =
  61983. exports.varint = (function () {
  61984. return encoder(0, varint.encode, varint.decode, varint.encodingLength)
  61985. })()
  61986. // we cannot represent these in javascript so we just use buffers
  61987. exports.fixed64 =
  61988. exports.sfixed64 = (function () {
  61989. var encodingLength = function (val) {
  61990. return 8
  61991. }
  61992. var encode = function (val, buffer, offset) {
  61993. val.copy(buffer, offset)
  61994. encode.bytes = 8
  61995. return buffer
  61996. }
  61997. var decode = function (buffer, offset) {
  61998. var val = buffer.slice(offset, offset + 8)
  61999. decode.bytes = 8
  62000. return val
  62001. }
  62002. return encoder(1, encode, decode, encodingLength)
  62003. })()
  62004. exports.double = (function () {
  62005. var encodingLength = function (val) {
  62006. return 8
  62007. }
  62008. var encode = function (val, buffer, offset) {
  62009. buffer.writeDoubleLE(val, offset)
  62010. encode.bytes = 8
  62011. return buffer
  62012. }
  62013. var decode = function (buffer, offset) {
  62014. var val = buffer.readDoubleLE(offset)
  62015. decode.bytes = 8
  62016. return val
  62017. }
  62018. return encoder(1, encode, decode, encodingLength)
  62019. })()
  62020. exports.fixed32 = (function () {
  62021. var encodingLength = function (val) {
  62022. return 4
  62023. }
  62024. var encode = function (val, buffer, offset) {
  62025. buffer.writeUInt32LE(val, offset)
  62026. encode.bytes = 4
  62027. return buffer
  62028. }
  62029. var decode = function (buffer, offset) {
  62030. var val = buffer.readUInt32LE(offset)
  62031. decode.bytes = 4
  62032. return val
  62033. }
  62034. return encoder(5, encode, decode, encodingLength)
  62035. })()
  62036. exports.sfixed32 = (function () {
  62037. var encodingLength = function (val) {
  62038. return 4
  62039. }
  62040. var encode = function (val, buffer, offset) {
  62041. buffer.writeInt32LE(val, offset)
  62042. encode.bytes = 4
  62043. return buffer
  62044. }
  62045. var decode = function (buffer, offset) {
  62046. var val = buffer.readInt32LE(offset)
  62047. decode.bytes = 4
  62048. return val
  62049. }
  62050. return encoder(5, encode, decode, encodingLength)
  62051. })()
  62052. exports.float = (function () {
  62053. var encodingLength = function (val) {
  62054. return 4
  62055. }
  62056. var encode = function (val, buffer, offset) {
  62057. buffer.writeFloatLE(val, offset)
  62058. encode.bytes = 4
  62059. return buffer
  62060. }
  62061. var decode = function (buffer, offset) {
  62062. var val = buffer.readFloatLE(offset)
  62063. decode.bytes = 4
  62064. return val
  62065. }
  62066. return encoder(5, encode, decode, encodingLength)
  62067. })()
  62068. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  62069. /***/ },
  62070. /* 541 */
  62071. /***/ function(module, exports, __webpack_require__) {
  62072. /* WEBPACK VAR INJECTION */(function(Buffer) {var schema = __webpack_require__(535)
  62073. var compile = __webpack_require__(539)
  62074. module.exports = function (proto, opts) {
  62075. if (!opts) opts = {}
  62076. if (!proto) throw new Error('Pass in a .proto string or a protobuf-schema parsed object')
  62077. var sch = (typeof proto === 'object' && !Buffer.isBuffer(proto)) ? proto : schema.parse(proto)
  62078. // to not make toString,toJSON enumarable we make a fire-and-forget prototype
  62079. var Messages = function () {
  62080. var self = this
  62081. compile(sch, opts.encodings || {}).forEach(function (m) {
  62082. self[m.name] = m.values || m
  62083. })
  62084. }
  62085. Messages.prototype.toString = function () {
  62086. return schema.stringify(sch)
  62087. }
  62088. Messages.prototype.toJSON = function () {
  62089. return sch
  62090. }
  62091. return new Messages()
  62092. }
  62093. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  62094. /***/ },
  62095. /* 542 */
  62096. /***/ function(module, exports, __webpack_require__) {
  62097. exports.publicEncrypt = __webpack_require__(544);
  62098. exports.privateDecrypt = __webpack_require__(543);
  62099. exports.privateEncrypt = function privateEncrypt(key, buf) {
  62100. return exports.publicEncrypt(key, buf, true);
  62101. };
  62102. exports.publicDecrypt = function publicDecrypt(key, buf) {
  62103. return exports.privateDecrypt(key, buf, true);
  62104. };
  62105. /***/ },
  62106. /* 543 */
  62107. /***/ function(module, exports, __webpack_require__) {
  62108. /* WEBPACK VAR INJECTION */(function(Buffer) {var parseKeys = __webpack_require__(97);
  62109. var mgf = __webpack_require__(211);
  62110. var xor = __webpack_require__(213);
  62111. var bn = __webpack_require__(12);
  62112. var crt = __webpack_require__(103);
  62113. var createHash = __webpack_require__(63);
  62114. var withPublic = __webpack_require__(212);
  62115. module.exports = function privateDecrypt(private_key, enc, reverse) {
  62116. var padding;
  62117. if (private_key.padding) {
  62118. padding = private_key.padding;
  62119. } else if (reverse) {
  62120. padding = 1;
  62121. } else {
  62122. padding = 4;
  62123. }
  62124. var key = parseKeys(private_key);
  62125. var k = key.modulus.byteLength();
  62126. if (enc.length > k || new bn(enc).cmp(key.modulus) >= 0) {
  62127. throw new Error('decryption error');
  62128. }
  62129. var msg;
  62130. if (reverse) {
  62131. msg = withPublic(new bn(enc), key);
  62132. } else {
  62133. msg = crt(enc, key);
  62134. }
  62135. var zBuffer = new Buffer(k - msg.length);
  62136. zBuffer.fill(0);
  62137. msg = Buffer.concat([zBuffer, msg], k);
  62138. if (padding === 4) {
  62139. return oaep(key, msg);
  62140. } else if (padding === 1) {
  62141. return pkcs1(key, msg, reverse);
  62142. } else if (padding === 3) {
  62143. return msg;
  62144. } else {
  62145. throw new Error('unknown padding');
  62146. }
  62147. };
  62148. function oaep(key, msg){
  62149. var n = key.modulus;
  62150. var k = key.modulus.byteLength();
  62151. var mLen = msg.length;
  62152. var iHash = createHash('sha1').update(new Buffer('')).digest();
  62153. var hLen = iHash.length;
  62154. var hLen2 = 2 * hLen;
  62155. if (msg[0] !== 0) {
  62156. throw new Error('decryption error');
  62157. }
  62158. var maskedSeed = msg.slice(1, hLen + 1);
  62159. var maskedDb = msg.slice(hLen + 1);
  62160. var seed = xor(maskedSeed, mgf(maskedDb, hLen));
  62161. var db = xor(maskedDb, mgf(seed, k - hLen - 1));
  62162. if (compare(iHash, db.slice(0, hLen))) {
  62163. throw new Error('decryption error');
  62164. }
  62165. var i = hLen;
  62166. while (db[i] === 0) {
  62167. i++;
  62168. }
  62169. if (db[i++] !== 1) {
  62170. throw new Error('decryption error');
  62171. }
  62172. return db.slice(i);
  62173. }
  62174. function pkcs1(key, msg, reverse){
  62175. var p1 = msg.slice(0, 2);
  62176. var i = 2;
  62177. var status = 0;
  62178. while (msg[i++] !== 0) {
  62179. if (i >= msg.length) {
  62180. status++;
  62181. break;
  62182. }
  62183. }
  62184. var ps = msg.slice(2, i - 1);
  62185. var p2 = msg.slice(i - 1, i);
  62186. if ((p1.toString('hex') !== '0002' && !reverse) || (p1.toString('hex') !== '0001' && reverse)){
  62187. status++;
  62188. }
  62189. if (ps.length < 8) {
  62190. status++;
  62191. }
  62192. if (status) {
  62193. throw new Error('decryption error');
  62194. }
  62195. return msg.slice(i);
  62196. }
  62197. function compare(a, b){
  62198. a = new Buffer(a);
  62199. b = new Buffer(b);
  62200. var dif = 0;
  62201. var len = a.length;
  62202. if (a.length !== b.length) {
  62203. dif++;
  62204. len = Math.min(a.length, b.length);
  62205. }
  62206. var i = -1;
  62207. while (++i < len) {
  62208. dif += (a[i] ^ b[i]);
  62209. }
  62210. return dif;
  62211. }
  62212. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  62213. /***/ },
  62214. /* 544 */
  62215. /***/ function(module, exports, __webpack_require__) {
  62216. /* WEBPACK VAR INJECTION */(function(Buffer) {var parseKeys = __webpack_require__(97);
  62217. var randomBytes = __webpack_require__(73);
  62218. var createHash = __webpack_require__(63);
  62219. var mgf = __webpack_require__(211);
  62220. var xor = __webpack_require__(213);
  62221. var bn = __webpack_require__(12);
  62222. var withPublic = __webpack_require__(212);
  62223. var crt = __webpack_require__(103);
  62224. var constants = {
  62225. RSA_PKCS1_OAEP_PADDING: 4,
  62226. RSA_PKCS1_PADDIN: 1,
  62227. RSA_NO_PADDING: 3
  62228. };
  62229. module.exports = function publicEncrypt(public_key, msg, reverse) {
  62230. var padding;
  62231. if (public_key.padding) {
  62232. padding = public_key.padding;
  62233. } else if (reverse) {
  62234. padding = 1;
  62235. } else {
  62236. padding = 4;
  62237. }
  62238. var key = parseKeys(public_key);
  62239. var paddedMsg;
  62240. if (padding === 4) {
  62241. paddedMsg = oaep(key, msg);
  62242. } else if (padding === 1) {
  62243. paddedMsg = pkcs1(key, msg, reverse);
  62244. } else if (padding === 3) {
  62245. paddedMsg = new bn(msg);
  62246. if (paddedMsg.cmp(key.modulus) >= 0) {
  62247. throw new Error('data too long for modulus');
  62248. }
  62249. } else {
  62250. throw new Error('unknown padding');
  62251. }
  62252. if (reverse) {
  62253. return crt(paddedMsg, key);
  62254. } else {
  62255. return withPublic(paddedMsg, key);
  62256. }
  62257. };
  62258. function oaep(key, msg){
  62259. var k = key.modulus.byteLength();
  62260. var mLen = msg.length;
  62261. var iHash = createHash('sha1').update(new Buffer('')).digest();
  62262. var hLen = iHash.length;
  62263. var hLen2 = 2 * hLen;
  62264. if (mLen > k - hLen2 - 2) {
  62265. throw new Error('message too long');
  62266. }
  62267. var ps = new Buffer(k - mLen - hLen2 - 2);
  62268. ps.fill(0);
  62269. var dblen = k - hLen - 1;
  62270. var seed = randomBytes(hLen);
  62271. var maskedDb = xor(Buffer.concat([iHash, ps, new Buffer([1]), msg], dblen), mgf(seed, dblen));
  62272. var maskedSeed = xor(seed, mgf(maskedDb, hLen));
  62273. return new bn(Buffer.concat([new Buffer([0]), maskedSeed, maskedDb], k));
  62274. }
  62275. function pkcs1(key, msg, reverse){
  62276. var mLen = msg.length;
  62277. var k = key.modulus.byteLength();
  62278. if (mLen > k - 11) {
  62279. throw new Error('message too long');
  62280. }
  62281. var ps;
  62282. if (reverse) {
  62283. ps = new Buffer(k - mLen - 3);
  62284. ps.fill(0xff);
  62285. } else {
  62286. ps = nonZero(k - mLen - 3);
  62287. }
  62288. return new bn(Buffer.concat([new Buffer([0, reverse?1:2]), ps, new Buffer([0]), msg], k));
  62289. }
  62290. function nonZero(len, crypto) {
  62291. var out = new Buffer(len);
  62292. var i = 0;
  62293. var cache = randomBytes(len*2);
  62294. var cur = 0;
  62295. var num;
  62296. while (i < len) {
  62297. if (cur === cache.length) {
  62298. cache = randomBytes(len*2);
  62299. cur = 0;
  62300. }
  62301. num = cache[cur++];
  62302. if (num) {
  62303. out[i++] = num;
  62304. }
  62305. }
  62306. return out;
  62307. }
  62308. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  62309. /***/ },
  62310. /* 545 */
  62311. /***/ function(module, exports, __webpack_require__) {
  62312. /* WEBPACK VAR INJECTION */(function(module, global) {var __WEBPACK_AMD_DEFINE_RESULT__;/*! https://mths.be/punycode v1.4.1 by @mathias */
  62313. ;(function(root) {
  62314. /** Detect free variables */
  62315. var freeExports = typeof exports == 'object' && exports &&
  62316. !exports.nodeType && exports;
  62317. var freeModule = typeof module == 'object' && module &&
  62318. !module.nodeType && module;
  62319. var freeGlobal = typeof global == 'object' && global;
  62320. if (
  62321. freeGlobal.global === freeGlobal ||
  62322. freeGlobal.window === freeGlobal ||
  62323. freeGlobal.self === freeGlobal
  62324. ) {
  62325. root = freeGlobal;
  62326. }
  62327. /**
  62328. * The `punycode` object.
  62329. * @name punycode
  62330. * @type Object
  62331. */
  62332. var punycode,
  62333. /** Highest positive signed 32-bit float value */
  62334. maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1
  62335. /** Bootstring parameters */
  62336. base = 36,
  62337. tMin = 1,
  62338. tMax = 26,
  62339. skew = 38,
  62340. damp = 700,
  62341. initialBias = 72,
  62342. initialN = 128, // 0x80
  62343. delimiter = '-', // '\x2D'
  62344. /** Regular expressions */
  62345. regexPunycode = /^xn--/,
  62346. regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars
  62347. regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators
  62348. /** Error messages */
  62349. errors = {
  62350. 'overflow': 'Overflow: input needs wider integers to process',
  62351. 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
  62352. 'invalid-input': 'Invalid input'
  62353. },
  62354. /** Convenience shortcuts */
  62355. baseMinusTMin = base - tMin,
  62356. floor = Math.floor,
  62357. stringFromCharCode = String.fromCharCode,
  62358. /** Temporary variable */
  62359. key;
  62360. /*--------------------------------------------------------------------------*/
  62361. /**
  62362. * A generic error utility function.
  62363. * @private
  62364. * @param {String} type The error type.
  62365. * @returns {Error} Throws a `RangeError` with the applicable error message.
  62366. */
  62367. function error(type) {
  62368. throw new RangeError(errors[type]);
  62369. }
  62370. /**
  62371. * A generic `Array#map` utility function.
  62372. * @private
  62373. * @param {Array} array The array to iterate over.
  62374. * @param {Function} callback The function that gets called for every array
  62375. * item.
  62376. * @returns {Array} A new array of values returned by the callback function.
  62377. */
  62378. function map(array, fn) {
  62379. var length = array.length;
  62380. var result = [];
  62381. while (length--) {
  62382. result[length] = fn(array[length]);
  62383. }
  62384. return result;
  62385. }
  62386. /**
  62387. * A simple `Array#map`-like wrapper to work with domain name strings or email
  62388. * addresses.
  62389. * @private
  62390. * @param {String} domain The domain name or email address.
  62391. * @param {Function} callback The function that gets called for every
  62392. * character.
  62393. * @returns {Array} A new string of characters returned by the callback
  62394. * function.
  62395. */
  62396. function mapDomain(string, fn) {
  62397. var parts = string.split('@');
  62398. var result = '';
  62399. if (parts.length > 1) {
  62400. // In email addresses, only the domain name should be punycoded. Leave
  62401. // the local part (i.e. everything up to `@`) intact.
  62402. result = parts[0] + '@';
  62403. string = parts[1];
  62404. }
  62405. // Avoid `split(regex)` for IE8 compatibility. See #17.
  62406. string = string.replace(regexSeparators, '\x2E');
  62407. var labels = string.split('.');
  62408. var encoded = map(labels, fn).join('.');
  62409. return result + encoded;
  62410. }
  62411. /**
  62412. * Creates an array containing the numeric code points of each Unicode
  62413. * character in the string. While JavaScript uses UCS-2 internally,
  62414. * this function will convert a pair of surrogate halves (each of which
  62415. * UCS-2 exposes as separate characters) into a single code point,
  62416. * matching UTF-16.
  62417. * @see `punycode.ucs2.encode`
  62418. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  62419. * @memberOf punycode.ucs2
  62420. * @name decode
  62421. * @param {String} string The Unicode input string (UCS-2).
  62422. * @returns {Array} The new array of code points.
  62423. */
  62424. function ucs2decode(string) {
  62425. var output = [],
  62426. counter = 0,
  62427. length = string.length,
  62428. value,
  62429. extra;
  62430. while (counter < length) {
  62431. value = string.charCodeAt(counter++);
  62432. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  62433. // high surrogate, and there is a next character
  62434. extra = string.charCodeAt(counter++);
  62435. if ((extra & 0xFC00) == 0xDC00) { // low surrogate
  62436. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  62437. } else {
  62438. // unmatched surrogate; only append this code unit, in case the next
  62439. // code unit is the high surrogate of a surrogate pair
  62440. output.push(value);
  62441. counter--;
  62442. }
  62443. } else {
  62444. output.push(value);
  62445. }
  62446. }
  62447. return output;
  62448. }
  62449. /**
  62450. * Creates a string based on an array of numeric code points.
  62451. * @see `punycode.ucs2.decode`
  62452. * @memberOf punycode.ucs2
  62453. * @name encode
  62454. * @param {Array} codePoints The array of numeric code points.
  62455. * @returns {String} The new Unicode string (UCS-2).
  62456. */
  62457. function ucs2encode(array) {
  62458. return map(array, function(value) {
  62459. var output = '';
  62460. if (value > 0xFFFF) {
  62461. value -= 0x10000;
  62462. output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
  62463. value = 0xDC00 | value & 0x3FF;
  62464. }
  62465. output += stringFromCharCode(value);
  62466. return output;
  62467. }).join('');
  62468. }
  62469. /**
  62470. * Converts a basic code point into a digit/integer.
  62471. * @see `digitToBasic()`
  62472. * @private
  62473. * @param {Number} codePoint The basic numeric code point value.
  62474. * @returns {Number} The numeric value of a basic code point (for use in
  62475. * representing integers) in the range `0` to `base - 1`, or `base` if
  62476. * the code point does not represent a value.
  62477. */
  62478. function basicToDigit(codePoint) {
  62479. if (codePoint - 48 < 10) {
  62480. return codePoint - 22;
  62481. }
  62482. if (codePoint - 65 < 26) {
  62483. return codePoint - 65;
  62484. }
  62485. if (codePoint - 97 < 26) {
  62486. return codePoint - 97;
  62487. }
  62488. return base;
  62489. }
  62490. /**
  62491. * Converts a digit/integer into a basic code point.
  62492. * @see `basicToDigit()`
  62493. * @private
  62494. * @param {Number} digit The numeric value of a basic code point.
  62495. * @returns {Number} The basic code point whose value (when used for
  62496. * representing integers) is `digit`, which needs to be in the range
  62497. * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
  62498. * used; else, the lowercase form is used. The behavior is undefined
  62499. * if `flag` is non-zero and `digit` has no uppercase form.
  62500. */
  62501. function digitToBasic(digit, flag) {
  62502. // 0..25 map to ASCII a..z or A..Z
  62503. // 26..35 map to ASCII 0..9
  62504. return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
  62505. }
  62506. /**
  62507. * Bias adaptation function as per section 3.4 of RFC 3492.
  62508. * https://tools.ietf.org/html/rfc3492#section-3.4
  62509. * @private
  62510. */
  62511. function adapt(delta, numPoints, firstTime) {
  62512. var k = 0;
  62513. delta = firstTime ? floor(delta / damp) : delta >> 1;
  62514. delta += floor(delta / numPoints);
  62515. for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
  62516. delta = floor(delta / baseMinusTMin);
  62517. }
  62518. return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
  62519. }
  62520. /**
  62521. * Converts a Punycode string of ASCII-only symbols to a string of Unicode
  62522. * symbols.
  62523. * @memberOf punycode
  62524. * @param {String} input The Punycode string of ASCII-only symbols.
  62525. * @returns {String} The resulting string of Unicode symbols.
  62526. */
  62527. function decode(input) {
  62528. // Don't use UCS-2
  62529. var output = [],
  62530. inputLength = input.length,
  62531. out,
  62532. i = 0,
  62533. n = initialN,
  62534. bias = initialBias,
  62535. basic,
  62536. j,
  62537. index,
  62538. oldi,
  62539. w,
  62540. k,
  62541. digit,
  62542. t,
  62543. /** Cached calculation results */
  62544. baseMinusT;
  62545. // Handle the basic code points: let `basic` be the number of input code
  62546. // points before the last delimiter, or `0` if there is none, then copy
  62547. // the first basic code points to the output.
  62548. basic = input.lastIndexOf(delimiter);
  62549. if (basic < 0) {
  62550. basic = 0;
  62551. }
  62552. for (j = 0; j < basic; ++j) {
  62553. // if it's not a basic code point
  62554. if (input.charCodeAt(j) >= 0x80) {
  62555. error('not-basic');
  62556. }
  62557. output.push(input.charCodeAt(j));
  62558. }
  62559. // Main decoding loop: start just after the last delimiter if any basic code
  62560. // points were copied; start at the beginning otherwise.
  62561. for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
  62562. // `index` is the index of the next character to be consumed.
  62563. // Decode a generalized variable-length integer into `delta`,
  62564. // which gets added to `i`. The overflow checking is easier
  62565. // if we increase `i` as we go, then subtract off its starting
  62566. // value at the end to obtain `delta`.
  62567. for (oldi = i, w = 1, k = base; /* no condition */; k += base) {
  62568. if (index >= inputLength) {
  62569. error('invalid-input');
  62570. }
  62571. digit = basicToDigit(input.charCodeAt(index++));
  62572. if (digit >= base || digit > floor((maxInt - i) / w)) {
  62573. error('overflow');
  62574. }
  62575. i += digit * w;
  62576. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  62577. if (digit < t) {
  62578. break;
  62579. }
  62580. baseMinusT = base - t;
  62581. if (w > floor(maxInt / baseMinusT)) {
  62582. error('overflow');
  62583. }
  62584. w *= baseMinusT;
  62585. }
  62586. out = output.length + 1;
  62587. bias = adapt(i - oldi, out, oldi == 0);
  62588. // `i` was supposed to wrap around from `out` to `0`,
  62589. // incrementing `n` each time, so we'll fix that now:
  62590. if (floor(i / out) > maxInt - n) {
  62591. error('overflow');
  62592. }
  62593. n += floor(i / out);
  62594. i %= out;
  62595. // Insert `n` at position `i` of the output
  62596. output.splice(i++, 0, n);
  62597. }
  62598. return ucs2encode(output);
  62599. }
  62600. /**
  62601. * Converts a string of Unicode symbols (e.g. a domain name label) to a
  62602. * Punycode string of ASCII-only symbols.
  62603. * @memberOf punycode
  62604. * @param {String} input The string of Unicode symbols.
  62605. * @returns {String} The resulting Punycode string of ASCII-only symbols.
  62606. */
  62607. function encode(input) {
  62608. var n,
  62609. delta,
  62610. handledCPCount,
  62611. basicLength,
  62612. bias,
  62613. j,
  62614. m,
  62615. q,
  62616. k,
  62617. t,
  62618. currentValue,
  62619. output = [],
  62620. /** `inputLength` will hold the number of code points in `input`. */
  62621. inputLength,
  62622. /** Cached calculation results */
  62623. handledCPCountPlusOne,
  62624. baseMinusT,
  62625. qMinusT;
  62626. // Convert the input in UCS-2 to Unicode
  62627. input = ucs2decode(input);
  62628. // Cache the length
  62629. inputLength = input.length;
  62630. // Initialize the state
  62631. n = initialN;
  62632. delta = 0;
  62633. bias = initialBias;
  62634. // Handle the basic code points
  62635. for (j = 0; j < inputLength; ++j) {
  62636. currentValue = input[j];
  62637. if (currentValue < 0x80) {
  62638. output.push(stringFromCharCode(currentValue));
  62639. }
  62640. }
  62641. handledCPCount = basicLength = output.length;
  62642. // `handledCPCount` is the number of code points that have been handled;
  62643. // `basicLength` is the number of basic code points.
  62644. // Finish the basic string - if it is not empty - with a delimiter
  62645. if (basicLength) {
  62646. output.push(delimiter);
  62647. }
  62648. // Main encoding loop:
  62649. while (handledCPCount < inputLength) {
  62650. // All non-basic code points < n have been handled already. Find the next
  62651. // larger one:
  62652. for (m = maxInt, j = 0; j < inputLength; ++j) {
  62653. currentValue = input[j];
  62654. if (currentValue >= n && currentValue < m) {
  62655. m = currentValue;
  62656. }
  62657. }
  62658. // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
  62659. // but guard against overflow
  62660. handledCPCountPlusOne = handledCPCount + 1;
  62661. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  62662. error('overflow');
  62663. }
  62664. delta += (m - n) * handledCPCountPlusOne;
  62665. n = m;
  62666. for (j = 0; j < inputLength; ++j) {
  62667. currentValue = input[j];
  62668. if (currentValue < n && ++delta > maxInt) {
  62669. error('overflow');
  62670. }
  62671. if (currentValue == n) {
  62672. // Represent delta as a generalized variable-length integer
  62673. for (q = delta, k = base; /* no condition */; k += base) {
  62674. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  62675. if (q < t) {
  62676. break;
  62677. }
  62678. qMinusT = q - t;
  62679. baseMinusT = base - t;
  62680. output.push(
  62681. stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
  62682. );
  62683. q = floor(qMinusT / baseMinusT);
  62684. }
  62685. output.push(stringFromCharCode(digitToBasic(q, 0)));
  62686. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  62687. delta = 0;
  62688. ++handledCPCount;
  62689. }
  62690. }
  62691. ++delta;
  62692. ++n;
  62693. }
  62694. return output.join('');
  62695. }
  62696. /**
  62697. * Converts a Punycode string representing a domain name or an email address
  62698. * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
  62699. * it doesn't matter if you call it on a string that has already been
  62700. * converted to Unicode.
  62701. * @memberOf punycode
  62702. * @param {String} input The Punycoded domain name or email address to
  62703. * convert to Unicode.
  62704. * @returns {String} The Unicode representation of the given Punycode
  62705. * string.
  62706. */
  62707. function toUnicode(input) {
  62708. return mapDomain(input, function(string) {
  62709. return regexPunycode.test(string)
  62710. ? decode(string.slice(4).toLowerCase())
  62711. : string;
  62712. });
  62713. }
  62714. /**
  62715. * Converts a Unicode string representing a domain name or an email address to
  62716. * Punycode. Only the non-ASCII parts of the domain name will be converted,
  62717. * i.e. it doesn't matter if you call it with a domain that's already in
  62718. * ASCII.
  62719. * @memberOf punycode
  62720. * @param {String} input The domain name or email address to convert, as a
  62721. * Unicode string.
  62722. * @returns {String} The Punycode representation of the given domain name or
  62723. * email address.
  62724. */
  62725. function toASCII(input) {
  62726. return mapDomain(input, function(string) {
  62727. return regexNonASCII.test(string)
  62728. ? 'xn--' + encode(string)
  62729. : string;
  62730. });
  62731. }
  62732. /*--------------------------------------------------------------------------*/
  62733. /** Define the public API */
  62734. punycode = {
  62735. /**
  62736. * A string representing the current Punycode.js version number.
  62737. * @memberOf punycode
  62738. * @type String
  62739. */
  62740. 'version': '1.4.1',
  62741. /**
  62742. * An object of methods to convert from JavaScript's internal character
  62743. * representation (UCS-2) to Unicode code points, and back.
  62744. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  62745. * @memberOf punycode
  62746. * @type Object
  62747. */
  62748. 'ucs2': {
  62749. 'decode': ucs2decode,
  62750. 'encode': ucs2encode
  62751. },
  62752. 'decode': decode,
  62753. 'encode': encode,
  62754. 'toASCII': toASCII,
  62755. 'toUnicode': toUnicode
  62756. };
  62757. /** Expose `punycode` */
  62758. // Some AMD build optimizers, like r.js, check for specific condition patterns
  62759. // like the following:
  62760. if (
  62761. true
  62762. ) {
  62763. !(__WEBPACK_AMD_DEFINE_RESULT__ = function() {
  62764. return punycode;
  62765. }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  62766. } else if (freeExports && freeModule) {
  62767. if (module.exports == freeExports) {
  62768. // in Node.js, io.js, or RingoJS v0.8.0+
  62769. freeModule.exports = punycode;
  62770. } else {
  62771. // in Narwhal or RingoJS v0.7.0-
  62772. for (key in punycode) {
  62773. punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
  62774. }
  62775. }
  62776. } else {
  62777. // in Rhino or a web browser
  62778. root.punycode = punycode;
  62779. }
  62780. }(this));
  62781. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(76)(module), __webpack_require__(13)))
  62782. /***/ },
  62783. /* 546 */
  62784. /***/ function(module, exports) {
  62785. "use strict";
  62786. // Copyright Joyent, Inc. and other Node contributors.
  62787. //
  62788. // Permission is hereby granted, free of charge, to any person obtaining a
  62789. // copy of this software and associated documentation files (the
  62790. // "Software"), to deal in the Software without restriction, including
  62791. // without limitation the rights to use, copy, modify, merge, publish,
  62792. // distribute, sublicense, and/or sell copies of the Software, and to permit
  62793. // persons to whom the Software is furnished to do so, subject to the
  62794. // following conditions:
  62795. //
  62796. // The above copyright notice and this permission notice shall be included
  62797. // in all copies or substantial portions of the Software.
  62798. //
  62799. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  62800. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  62801. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  62802. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  62803. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  62804. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  62805. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  62806. 'use strict';
  62807. // If obj.hasOwnProperty has been overridden, then calling
  62808. // obj.hasOwnProperty(prop) will break.
  62809. // See: https://github.com/joyent/node/issues/1707
  62810. function hasOwnProperty(obj, prop) {
  62811. return Object.prototype.hasOwnProperty.call(obj, prop);
  62812. }
  62813. module.exports = function(qs, sep, eq, options) {
  62814. sep = sep || '&';
  62815. eq = eq || '=';
  62816. var obj = {};
  62817. if (typeof qs !== 'string' || qs.length === 0) {
  62818. return obj;
  62819. }
  62820. var regexp = /\+/g;
  62821. qs = qs.split(sep);
  62822. var maxKeys = 1000;
  62823. if (options && typeof options.maxKeys === 'number') {
  62824. maxKeys = options.maxKeys;
  62825. }
  62826. var len = qs.length;
  62827. // maxKeys <= 0 means that we should not limit keys count
  62828. if (maxKeys > 0 && len > maxKeys) {
  62829. len = maxKeys;
  62830. }
  62831. for (var i = 0; i < len; ++i) {
  62832. var x = qs[i].replace(regexp, '%20'),
  62833. idx = x.indexOf(eq),
  62834. kstr, vstr, k, v;
  62835. if (idx >= 0) {
  62836. kstr = x.substr(0, idx);
  62837. vstr = x.substr(idx + 1);
  62838. } else {
  62839. kstr = x;
  62840. vstr = '';
  62841. }
  62842. k = decodeURIComponent(kstr);
  62843. v = decodeURIComponent(vstr);
  62844. if (!hasOwnProperty(obj, k)) {
  62845. obj[k] = v;
  62846. } else if (isArray(obj[k])) {
  62847. obj[k].push(v);
  62848. } else {
  62849. obj[k] = [obj[k], v];
  62850. }
  62851. }
  62852. return obj;
  62853. };
  62854. var isArray = Array.isArray || function (xs) {
  62855. return Object.prototype.toString.call(xs) === '[object Array]';
  62856. };
  62857. /***/ },
  62858. /* 547 */
  62859. /***/ function(module, exports) {
  62860. "use strict";
  62861. // Copyright Joyent, Inc. and other Node contributors.
  62862. //
  62863. // Permission is hereby granted, free of charge, to any person obtaining a
  62864. // copy of this software and associated documentation files (the
  62865. // "Software"), to deal in the Software without restriction, including
  62866. // without limitation the rights to use, copy, modify, merge, publish,
  62867. // distribute, sublicense, and/or sell copies of the Software, and to permit
  62868. // persons to whom the Software is furnished to do so, subject to the
  62869. // following conditions:
  62870. //
  62871. // The above copyright notice and this permission notice shall be included
  62872. // in all copies or substantial portions of the Software.
  62873. //
  62874. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  62875. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  62876. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  62877. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  62878. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  62879. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  62880. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  62881. 'use strict';
  62882. var stringifyPrimitive = function(v) {
  62883. switch (typeof v) {
  62884. case 'string':
  62885. return v;
  62886. case 'boolean':
  62887. return v ? 'true' : 'false';
  62888. case 'number':
  62889. return isFinite(v) ? v : '';
  62890. default:
  62891. return '';
  62892. }
  62893. };
  62894. module.exports = function(obj, sep, eq, name) {
  62895. sep = sep || '&';
  62896. eq = eq || '=';
  62897. if (obj === null) {
  62898. obj = undefined;
  62899. }
  62900. if (typeof obj === 'object') {
  62901. return map(objectKeys(obj), function(k) {
  62902. var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
  62903. if (isArray(obj[k])) {
  62904. return map(obj[k], function(v) {
  62905. return ks + encodeURIComponent(stringifyPrimitive(v));
  62906. }).join(sep);
  62907. } else {
  62908. return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
  62909. }
  62910. }).join(sep);
  62911. }
  62912. if (!name) return '';
  62913. return encodeURIComponent(stringifyPrimitive(name)) + eq +
  62914. encodeURIComponent(stringifyPrimitive(obj));
  62915. };
  62916. var isArray = Array.isArray || function (xs) {
  62917. return Object.prototype.toString.call(xs) === '[object Array]';
  62918. };
  62919. function map (xs, f) {
  62920. if (xs.map) return xs.map(f);
  62921. var res = [];
  62922. for (var i = 0; i < xs.length; i++) {
  62923. res.push(f(xs[i], i));
  62924. }
  62925. return res;
  62926. }
  62927. var objectKeys = Object.keys || function (obj) {
  62928. var res = [];
  62929. for (var key in obj) {
  62930. if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
  62931. }
  62932. return res;
  62933. };
  62934. /***/ },
  62935. /* 548 */
  62936. /***/ function(module, exports, __webpack_require__) {
  62937. "use strict";
  62938. 'use strict';
  62939. exports.decode = exports.parse = __webpack_require__(546);
  62940. exports.encode = exports.stringify = __webpack_require__(547);
  62941. /***/ },
  62942. /* 549 */
  62943. /***/ function(module, exports, __webpack_require__) {
  62944. module.exports = __webpack_require__(215)
  62945. /***/ },
  62946. /* 550 */
  62947. /***/ function(module, exports, __webpack_require__) {
  62948. var Stream = (function (){
  62949. try {
  62950. return __webpack_require__(9); // hack to fix a circular dependency issue when used with browserify
  62951. } catch(_){}
  62952. }());
  62953. exports = module.exports = __webpack_require__(216);
  62954. exports.Stream = Stream || exports;
  62955. exports.Readable = exports;
  62956. exports.Writable = __webpack_require__(139);
  62957. exports.Duplex = __webpack_require__(55);
  62958. exports.Transform = __webpack_require__(138);
  62959. exports.PassThrough = __webpack_require__(215);
  62960. /***/ },
  62961. /* 551 */
  62962. /***/ function(module, exports, __webpack_require__) {
  62963. module.exports = __webpack_require__(138)
  62964. /***/ },
  62965. /* 552 */
  62966. /***/ function(module, exports, __webpack_require__) {
  62967. module.exports = __webpack_require__(139)
  62968. /***/ },
  62969. /* 553 */
  62970. /***/ function(module, exports, __webpack_require__) {
  62971. /* WEBPACK VAR INJECTION */(function(global, process) {/**
  62972. * Copyright (c) 2014, Facebook, Inc.
  62973. * All rights reserved.
  62974. *
  62975. * This source code is licensed under the BSD-style license found in the
  62976. * https://raw.github.com/facebook/regenerator/master/LICENSE file. An
  62977. * additional grant of patent rights can be found in the PATENTS file in
  62978. * the same directory.
  62979. */
  62980. !(function(global) {
  62981. "use strict";
  62982. var hasOwn = Object.prototype.hasOwnProperty;
  62983. var undefined; // More compressible than void 0.
  62984. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  62985. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  62986. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  62987. var inModule = typeof module === "object";
  62988. var runtime = global.regeneratorRuntime;
  62989. if (runtime) {
  62990. if (inModule) {
  62991. // If regeneratorRuntime is defined globally and we're in a module,
  62992. // make the exports object identical to regeneratorRuntime.
  62993. module.exports = runtime;
  62994. }
  62995. // Don't bother evaluating the rest of this file if the runtime was
  62996. // already defined globally.
  62997. return;
  62998. }
  62999. // Define the runtime globally (as expected by generated code) as either
  63000. // module.exports (if we're in a module) or a new, empty object.
  63001. runtime = global.regeneratorRuntime = inModule ? module.exports : {};
  63002. function wrap(innerFn, outerFn, self, tryLocsList) {
  63003. // If outerFn provided, then outerFn.prototype instanceof Generator.
  63004. var generator = Object.create((outerFn || Generator).prototype);
  63005. var context = new Context(tryLocsList || []);
  63006. // The ._invoke method unifies the implementations of the .next,
  63007. // .throw, and .return methods.
  63008. generator._invoke = makeInvokeMethod(innerFn, self, context);
  63009. return generator;
  63010. }
  63011. runtime.wrap = wrap;
  63012. // Try/catch helper to minimize deoptimizations. Returns a completion
  63013. // record like context.tryEntries[i].completion. This interface could
  63014. // have been (and was previously) designed to take a closure to be
  63015. // invoked without arguments, but in all the cases we care about we
  63016. // already have an existing method we want to call, so there's no need
  63017. // to create a new function object. We can even get away with assuming
  63018. // the method takes exactly one argument, since that happens to be true
  63019. // in every case, so we don't have to touch the arguments object. The
  63020. // only additional allocation required is the completion record, which
  63021. // has a stable shape and so hopefully should be cheap to allocate.
  63022. function tryCatch(fn, obj, arg) {
  63023. try {
  63024. return { type: "normal", arg: fn.call(obj, arg) };
  63025. } catch (err) {
  63026. return { type: "throw", arg: err };
  63027. }
  63028. }
  63029. var GenStateSuspendedStart = "suspendedStart";
  63030. var GenStateSuspendedYield = "suspendedYield";
  63031. var GenStateExecuting = "executing";
  63032. var GenStateCompleted = "completed";
  63033. // Returning this object from the innerFn has the same effect as
  63034. // breaking out of the dispatch switch statement.
  63035. var ContinueSentinel = {};
  63036. // Dummy constructor functions that we use as the .constructor and
  63037. // .constructor.prototype properties for functions that return Generator
  63038. // objects. For full spec compliance, you may wish to configure your
  63039. // minifier not to mangle the names of these two functions.
  63040. function Generator() {}
  63041. function GeneratorFunction() {}
  63042. function GeneratorFunctionPrototype() {}
  63043. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype;
  63044. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  63045. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  63046. GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction";
  63047. // Helper for defining the .next, .throw, and .return methods of the
  63048. // Iterator interface in terms of a single ._invoke method.
  63049. function defineIteratorMethods(prototype) {
  63050. ["next", "throw", "return"].forEach(function(method) {
  63051. prototype[method] = function(arg) {
  63052. return this._invoke(method, arg);
  63053. };
  63054. });
  63055. }
  63056. runtime.isGeneratorFunction = function(genFun) {
  63057. var ctor = typeof genFun === "function" && genFun.constructor;
  63058. return ctor
  63059. ? ctor === GeneratorFunction ||
  63060. // For the native GeneratorFunction constructor, the best we can
  63061. // do is to check its .name property.
  63062. (ctor.displayName || ctor.name) === "GeneratorFunction"
  63063. : false;
  63064. };
  63065. runtime.mark = function(genFun) {
  63066. if (Object.setPrototypeOf) {
  63067. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  63068. } else {
  63069. genFun.__proto__ = GeneratorFunctionPrototype;
  63070. if (!(toStringTagSymbol in genFun)) {
  63071. genFun[toStringTagSymbol] = "GeneratorFunction";
  63072. }
  63073. }
  63074. genFun.prototype = Object.create(Gp);
  63075. return genFun;
  63076. };
  63077. // Within the body of any async function, `await x` is transformed to
  63078. // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
  63079. // `value instanceof AwaitArgument` to determine if the yielded value is
  63080. // meant to be awaited. Some may consider the name of this method too
  63081. // cutesy, but they are curmudgeons.
  63082. runtime.awrap = function(arg) {
  63083. return new AwaitArgument(arg);
  63084. };
  63085. function AwaitArgument(arg) {
  63086. this.arg = arg;
  63087. }
  63088. function AsyncIterator(generator) {
  63089. function invoke(method, arg, resolve, reject) {
  63090. var record = tryCatch(generator[method], generator, arg);
  63091. if (record.type === "throw") {
  63092. reject(record.arg);
  63093. } else {
  63094. var result = record.arg;
  63095. var value = result.value;
  63096. if (value instanceof AwaitArgument) {
  63097. return Promise.resolve(value.arg).then(function(value) {
  63098. invoke("next", value, resolve, reject);
  63099. }, function(err) {
  63100. invoke("throw", err, resolve, reject);
  63101. });
  63102. }
  63103. return Promise.resolve(value).then(function(unwrapped) {
  63104. // When a yielded Promise is resolved, its final value becomes
  63105. // the .value of the Promise<{value,done}> result for the
  63106. // current iteration. If the Promise is rejected, however, the
  63107. // result for this iteration will be rejected with the same
  63108. // reason. Note that rejections of yielded Promises are not
  63109. // thrown back into the generator function, as is the case
  63110. // when an awaited Promise is rejected. This difference in
  63111. // behavior between yield and await is important, because it
  63112. // allows the consumer to decide what to do with the yielded
  63113. // rejection (swallow it and continue, manually .throw it back
  63114. // into the generator, abandon iteration, whatever). With
  63115. // await, by contrast, there is no opportunity to examine the
  63116. // rejection reason outside the generator function, so the
  63117. // only option is to throw it from the await expression, and
  63118. // let the generator function handle the exception.
  63119. result.value = unwrapped;
  63120. resolve(result);
  63121. }, reject);
  63122. }
  63123. }
  63124. if (typeof process === "object" && process.domain) {
  63125. invoke = process.domain.bind(invoke);
  63126. }
  63127. var previousPromise;
  63128. function enqueue(method, arg) {
  63129. function callInvokeWithMethodAndArg() {
  63130. return new Promise(function(resolve, reject) {
  63131. invoke(method, arg, resolve, reject);
  63132. });
  63133. }
  63134. return previousPromise =
  63135. // If enqueue has been called before, then we want to wait until
  63136. // all previous Promises have been resolved before calling invoke,
  63137. // so that results are always delivered in the correct order. If
  63138. // enqueue has not been called before, then it is important to
  63139. // call invoke immediately, without waiting on a callback to fire,
  63140. // so that the async generator function has the opportunity to do
  63141. // any necessary setup in a predictable way. This predictability
  63142. // is why the Promise constructor synchronously invokes its
  63143. // executor callback, and why async functions synchronously
  63144. // execute code before the first await. Since we implement simple
  63145. // async functions in terms of async generators, it is especially
  63146. // important to get this right, even though it requires care.
  63147. previousPromise ? previousPromise.then(
  63148. callInvokeWithMethodAndArg,
  63149. // Avoid propagating failures to Promises returned by later
  63150. // invocations of the iterator.
  63151. callInvokeWithMethodAndArg
  63152. ) : callInvokeWithMethodAndArg();
  63153. }
  63154. // Define the unified helper method that is used to implement .next,
  63155. // .throw, and .return (see defineIteratorMethods).
  63156. this._invoke = enqueue;
  63157. }
  63158. defineIteratorMethods(AsyncIterator.prototype);
  63159. // Note that simple async functions are implemented on top of
  63160. // AsyncIterator objects; they just return a Promise for the value of
  63161. // the final result produced by the iterator.
  63162. runtime.async = function(innerFn, outerFn, self, tryLocsList) {
  63163. var iter = new AsyncIterator(
  63164. wrap(innerFn, outerFn, self, tryLocsList)
  63165. );
  63166. return runtime.isGeneratorFunction(outerFn)
  63167. ? iter // If outerFn is a generator, return the full iterator.
  63168. : iter.next().then(function(result) {
  63169. return result.done ? result.value : iter.next();
  63170. });
  63171. };
  63172. function makeInvokeMethod(innerFn, self, context) {
  63173. var state = GenStateSuspendedStart;
  63174. return function invoke(method, arg) {
  63175. if (state === GenStateExecuting) {
  63176. throw new Error("Generator is already running");
  63177. }
  63178. if (state === GenStateCompleted) {
  63179. if (method === "throw") {
  63180. throw arg;
  63181. }
  63182. // Be forgiving, per 25.3.3.3.3 of the spec:
  63183. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
  63184. return doneResult();
  63185. }
  63186. while (true) {
  63187. var delegate = context.delegate;
  63188. if (delegate) {
  63189. if (method === "return" ||
  63190. (method === "throw" && delegate.iterator[method] === undefined)) {
  63191. // A return or throw (when the delegate iterator has no throw
  63192. // method) always terminates the yield* loop.
  63193. context.delegate = null;
  63194. // If the delegate iterator has a return method, give it a
  63195. // chance to clean up.
  63196. var returnMethod = delegate.iterator["return"];
  63197. if (returnMethod) {
  63198. var record = tryCatch(returnMethod, delegate.iterator, arg);
  63199. if (record.type === "throw") {
  63200. // If the return method threw an exception, let that
  63201. // exception prevail over the original return or throw.
  63202. method = "throw";
  63203. arg = record.arg;
  63204. continue;
  63205. }
  63206. }
  63207. if (method === "return") {
  63208. // Continue with the outer return, now that the delegate
  63209. // iterator has been terminated.
  63210. continue;
  63211. }
  63212. }
  63213. var record = tryCatch(
  63214. delegate.iterator[method],
  63215. delegate.iterator,
  63216. arg
  63217. );
  63218. if (record.type === "throw") {
  63219. context.delegate = null;
  63220. // Like returning generator.throw(uncaught), but without the
  63221. // overhead of an extra function call.
  63222. method = "throw";
  63223. arg = record.arg;
  63224. continue;
  63225. }
  63226. // Delegate generator ran and handled its own exceptions so
  63227. // regardless of what the method was, we continue as if it is
  63228. // "next" with an undefined arg.
  63229. method = "next";
  63230. arg = undefined;
  63231. var info = record.arg;
  63232. if (info.done) {
  63233. context[delegate.resultName] = info.value;
  63234. context.next = delegate.nextLoc;
  63235. } else {
  63236. state = GenStateSuspendedYield;
  63237. return info;
  63238. }
  63239. context.delegate = null;
  63240. }
  63241. if (method === "next") {
  63242. // Setting context._sent for legacy support of Babel's
  63243. // function.sent implementation.
  63244. context.sent = context._sent = arg;
  63245. } else if (method === "throw") {
  63246. if (state === GenStateSuspendedStart) {
  63247. state = GenStateCompleted;
  63248. throw arg;
  63249. }
  63250. if (context.dispatchException(arg)) {
  63251. // If the dispatched exception was caught by a catch block,
  63252. // then let that catch block handle the exception normally.
  63253. method = "next";
  63254. arg = undefined;
  63255. }
  63256. } else if (method === "return") {
  63257. context.abrupt("return", arg);
  63258. }
  63259. state = GenStateExecuting;
  63260. var record = tryCatch(innerFn, self, context);
  63261. if (record.type === "normal") {
  63262. // If an exception is thrown from innerFn, we leave state ===
  63263. // GenStateExecuting and loop back for another invocation.
  63264. state = context.done
  63265. ? GenStateCompleted
  63266. : GenStateSuspendedYield;
  63267. var info = {
  63268. value: record.arg,
  63269. done: context.done
  63270. };
  63271. if (record.arg === ContinueSentinel) {
  63272. if (context.delegate && method === "next") {
  63273. // Deliberately forget the last sent value so that we don't
  63274. // accidentally pass it on to the delegate.
  63275. arg = undefined;
  63276. }
  63277. } else {
  63278. return info;
  63279. }
  63280. } else if (record.type === "throw") {
  63281. state = GenStateCompleted;
  63282. // Dispatch the exception by looping back around to the
  63283. // context.dispatchException(arg) call above.
  63284. method = "throw";
  63285. arg = record.arg;
  63286. }
  63287. }
  63288. };
  63289. }
  63290. // Define Generator.prototype.{next,throw,return} in terms of the
  63291. // unified ._invoke helper method.
  63292. defineIteratorMethods(Gp);
  63293. Gp[iteratorSymbol] = function() {
  63294. return this;
  63295. };
  63296. Gp[toStringTagSymbol] = "Generator";
  63297. Gp.toString = function() {
  63298. return "[object Generator]";
  63299. };
  63300. function pushTryEntry(locs) {
  63301. var entry = { tryLoc: locs[0] };
  63302. if (1 in locs) {
  63303. entry.catchLoc = locs[1];
  63304. }
  63305. if (2 in locs) {
  63306. entry.finallyLoc = locs[2];
  63307. entry.afterLoc = locs[3];
  63308. }
  63309. this.tryEntries.push(entry);
  63310. }
  63311. function resetTryEntry(entry) {
  63312. var record = entry.completion || {};
  63313. record.type = "normal";
  63314. delete record.arg;
  63315. entry.completion = record;
  63316. }
  63317. function Context(tryLocsList) {
  63318. // The root entry object (effectively a try statement without a catch
  63319. // or a finally block) gives us a place to store values thrown from
  63320. // locations where there is no enclosing try statement.
  63321. this.tryEntries = [{ tryLoc: "root" }];
  63322. tryLocsList.forEach(pushTryEntry, this);
  63323. this.reset(true);
  63324. }
  63325. runtime.keys = function(object) {
  63326. var keys = [];
  63327. for (var key in object) {
  63328. keys.push(key);
  63329. }
  63330. keys.reverse();
  63331. // Rather than returning an object with a next method, we keep
  63332. // things simple and return the next function itself.
  63333. return function next() {
  63334. while (keys.length) {
  63335. var key = keys.pop();
  63336. if (key in object) {
  63337. next.value = key;
  63338. next.done = false;
  63339. return next;
  63340. }
  63341. }
  63342. // To avoid creating an additional object, we just hang the .value
  63343. // and .done properties off the next function object itself. This
  63344. // also ensures that the minifier will not anonymize the function.
  63345. next.done = true;
  63346. return next;
  63347. };
  63348. };
  63349. function values(iterable) {
  63350. if (iterable) {
  63351. var iteratorMethod = iterable[iteratorSymbol];
  63352. if (iteratorMethod) {
  63353. return iteratorMethod.call(iterable);
  63354. }
  63355. if (typeof iterable.next === "function") {
  63356. return iterable;
  63357. }
  63358. if (!isNaN(iterable.length)) {
  63359. var i = -1, next = function next() {
  63360. while (++i < iterable.length) {
  63361. if (hasOwn.call(iterable, i)) {
  63362. next.value = iterable[i];
  63363. next.done = false;
  63364. return next;
  63365. }
  63366. }
  63367. next.value = undefined;
  63368. next.done = true;
  63369. return next;
  63370. };
  63371. return next.next = next;
  63372. }
  63373. }
  63374. // Return an iterator with no values.
  63375. return { next: doneResult };
  63376. }
  63377. runtime.values = values;
  63378. function doneResult() {
  63379. return { value: undefined, done: true };
  63380. }
  63381. Context.prototype = {
  63382. constructor: Context,
  63383. reset: function(skipTempReset) {
  63384. this.prev = 0;
  63385. this.next = 0;
  63386. // Resetting context._sent for legacy support of Babel's
  63387. // function.sent implementation.
  63388. this.sent = this._sent = undefined;
  63389. this.done = false;
  63390. this.delegate = null;
  63391. this.tryEntries.forEach(resetTryEntry);
  63392. if (!skipTempReset) {
  63393. for (var name in this) {
  63394. // Not sure about the optimal order of these conditions:
  63395. if (name.charAt(0) === "t" &&
  63396. hasOwn.call(this, name) &&
  63397. !isNaN(+name.slice(1))) {
  63398. this[name] = undefined;
  63399. }
  63400. }
  63401. }
  63402. },
  63403. stop: function() {
  63404. this.done = true;
  63405. var rootEntry = this.tryEntries[0];
  63406. var rootRecord = rootEntry.completion;
  63407. if (rootRecord.type === "throw") {
  63408. throw rootRecord.arg;
  63409. }
  63410. return this.rval;
  63411. },
  63412. dispatchException: function(exception) {
  63413. if (this.done) {
  63414. throw exception;
  63415. }
  63416. var context = this;
  63417. function handle(loc, caught) {
  63418. record.type = "throw";
  63419. record.arg = exception;
  63420. context.next = loc;
  63421. return !!caught;
  63422. }
  63423. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  63424. var entry = this.tryEntries[i];
  63425. var record = entry.completion;
  63426. if (entry.tryLoc === "root") {
  63427. // Exception thrown outside of any try block that could handle
  63428. // it, so set the completion value of the entire function to
  63429. // throw the exception.
  63430. return handle("end");
  63431. }
  63432. if (entry.tryLoc <= this.prev) {
  63433. var hasCatch = hasOwn.call(entry, "catchLoc");
  63434. var hasFinally = hasOwn.call(entry, "finallyLoc");
  63435. if (hasCatch && hasFinally) {
  63436. if (this.prev < entry.catchLoc) {
  63437. return handle(entry.catchLoc, true);
  63438. } else if (this.prev < entry.finallyLoc) {
  63439. return handle(entry.finallyLoc);
  63440. }
  63441. } else if (hasCatch) {
  63442. if (this.prev < entry.catchLoc) {
  63443. return handle(entry.catchLoc, true);
  63444. }
  63445. } else if (hasFinally) {
  63446. if (this.prev < entry.finallyLoc) {
  63447. return handle(entry.finallyLoc);
  63448. }
  63449. } else {
  63450. throw new Error("try statement without catch or finally");
  63451. }
  63452. }
  63453. }
  63454. },
  63455. abrupt: function(type, arg) {
  63456. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  63457. var entry = this.tryEntries[i];
  63458. if (entry.tryLoc <= this.prev &&
  63459. hasOwn.call(entry, "finallyLoc") &&
  63460. this.prev < entry.finallyLoc) {
  63461. var finallyEntry = entry;
  63462. break;
  63463. }
  63464. }
  63465. if (finallyEntry &&
  63466. (type === "break" ||
  63467. type === "continue") &&
  63468. finallyEntry.tryLoc <= arg &&
  63469. arg <= finallyEntry.finallyLoc) {
  63470. // Ignore the finally entry if control is not jumping to a
  63471. // location outside the try/catch block.
  63472. finallyEntry = null;
  63473. }
  63474. var record = finallyEntry ? finallyEntry.completion : {};
  63475. record.type = type;
  63476. record.arg = arg;
  63477. if (finallyEntry) {
  63478. this.next = finallyEntry.finallyLoc;
  63479. } else {
  63480. this.complete(record);
  63481. }
  63482. return ContinueSentinel;
  63483. },
  63484. complete: function(record, afterLoc) {
  63485. if (record.type === "throw") {
  63486. throw record.arg;
  63487. }
  63488. if (record.type === "break" ||
  63489. record.type === "continue") {
  63490. this.next = record.arg;
  63491. } else if (record.type === "return") {
  63492. this.rval = record.arg;
  63493. this.next = "end";
  63494. } else if (record.type === "normal" && afterLoc) {
  63495. this.next = afterLoc;
  63496. }
  63497. },
  63498. finish: function(finallyLoc) {
  63499. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  63500. var entry = this.tryEntries[i];
  63501. if (entry.finallyLoc === finallyLoc) {
  63502. this.complete(entry.completion, entry.afterLoc);
  63503. resetTryEntry(entry);
  63504. return ContinueSentinel;
  63505. }
  63506. }
  63507. },
  63508. "catch": function(tryLoc) {
  63509. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  63510. var entry = this.tryEntries[i];
  63511. if (entry.tryLoc === tryLoc) {
  63512. var record = entry.completion;
  63513. if (record.type === "throw") {
  63514. var thrown = record.arg;
  63515. resetTryEntry(entry);
  63516. }
  63517. return thrown;
  63518. }
  63519. }
  63520. // The context.catch method must only be called with a location
  63521. // argument that corresponds to a known catch block.
  63522. throw new Error("illegal catch attempt");
  63523. },
  63524. delegateYield: function(iterable, resultName, nextLoc) {
  63525. this.delegate = {
  63526. iterator: values(iterable),
  63527. resultName: resultName,
  63528. nextLoc: nextLoc
  63529. };
  63530. return ContinueSentinel;
  63531. }
  63532. };
  63533. })(
  63534. // Among the various tricks for obtaining a reference to the global
  63535. // object, this seems to be the most reliable technique that does not
  63536. // use indirect eval (which violates Content Security Policy).
  63537. typeof global === "object" ? global :
  63538. typeof window === "object" ? window :
  63539. typeof self === "object" ? self : this
  63540. );
  63541. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(13), __webpack_require__(4)))
  63542. /***/ },
  63543. /* 554 */
  63544. /***/ function(module, exports, __webpack_require__) {
  63545. /* WEBPACK VAR INJECTION */(function(Buffer) {/*
  63546. CryptoJS v3.1.2
  63547. code.google.com/p/crypto-js
  63548. (c) 2009-2013 by Jeff Mott. All rights reserved.
  63549. code.google.com/p/crypto-js/wiki/License
  63550. */
  63551. /** @preserve
  63552. (c) 2012 by Cédric Mesnil. All rights reserved.
  63553. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
  63554. - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  63555. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  63556. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  63557. */
  63558. // constants table
  63559. var zl = [
  63560. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
  63561. 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
  63562. 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
  63563. 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
  63564. 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
  63565. ]
  63566. var zr = [
  63567. 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
  63568. 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
  63569. 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
  63570. 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
  63571. 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
  63572. ]
  63573. var sl = [
  63574. 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
  63575. 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
  63576. 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
  63577. 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
  63578. 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
  63579. ]
  63580. var sr = [
  63581. 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
  63582. 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
  63583. 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
  63584. 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
  63585. 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
  63586. ]
  63587. var hl = [0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]
  63588. var hr = [0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]
  63589. function bytesToWords (bytes) {
  63590. var words = []
  63591. for (var i = 0, b = 0; i < bytes.length; i++, b += 8) {
  63592. words[b >>> 5] |= bytes[i] << (24 - b % 32)
  63593. }
  63594. return words
  63595. }
  63596. function wordsToBytes (words) {
  63597. var bytes = []
  63598. for (var b = 0; b < words.length * 32; b += 8) {
  63599. bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF)
  63600. }
  63601. return bytes
  63602. }
  63603. function processBlock (H, M, offset) {
  63604. // swap endian
  63605. for (var i = 0; i < 16; i++) {
  63606. var offset_i = offset + i
  63607. var M_offset_i = M[offset_i]
  63608. // Swap
  63609. M[offset_i] = (
  63610. (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
  63611. (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
  63612. )
  63613. }
  63614. // Working variables
  63615. var al, bl, cl, dl, el
  63616. var ar, br, cr, dr, er
  63617. ar = al = H[0]
  63618. br = bl = H[1]
  63619. cr = cl = H[2]
  63620. dr = dl = H[3]
  63621. er = el = H[4]
  63622. // computation
  63623. var t
  63624. for (i = 0; i < 80; i += 1) {
  63625. t = (al + M[offset + zl[i]]) | 0
  63626. if (i < 16) {
  63627. t += f1(bl, cl, dl) + hl[0]
  63628. } else if (i < 32) {
  63629. t += f2(bl, cl, dl) + hl[1]
  63630. } else if (i < 48) {
  63631. t += f3(bl, cl, dl) + hl[2]
  63632. } else if (i < 64) {
  63633. t += f4(bl, cl, dl) + hl[3]
  63634. } else {// if (i<80) {
  63635. t += f5(bl, cl, dl) + hl[4]
  63636. }
  63637. t = t | 0
  63638. t = rotl(t, sl[i])
  63639. t = (t + el) | 0
  63640. al = el
  63641. el = dl
  63642. dl = rotl(cl, 10)
  63643. cl = bl
  63644. bl = t
  63645. t = (ar + M[offset + zr[i]]) | 0
  63646. if (i < 16) {
  63647. t += f5(br, cr, dr) + hr[0]
  63648. } else if (i < 32) {
  63649. t += f4(br, cr, dr) + hr[1]
  63650. } else if (i < 48) {
  63651. t += f3(br, cr, dr) + hr[2]
  63652. } else if (i < 64) {
  63653. t += f2(br, cr, dr) + hr[3]
  63654. } else {// if (i<80) {
  63655. t += f1(br, cr, dr) + hr[4]
  63656. }
  63657. t = t | 0
  63658. t = rotl(t, sr[i])
  63659. t = (t + er) | 0
  63660. ar = er
  63661. er = dr
  63662. dr = rotl(cr, 10)
  63663. cr = br
  63664. br = t
  63665. }
  63666. // intermediate hash value
  63667. t = (H[1] + cl + dr) | 0
  63668. H[1] = (H[2] + dl + er) | 0
  63669. H[2] = (H[3] + el + ar) | 0
  63670. H[3] = (H[4] + al + br) | 0
  63671. H[4] = (H[0] + bl + cr) | 0
  63672. H[0] = t
  63673. }
  63674. function f1 (x, y, z) {
  63675. return ((x) ^ (y) ^ (z))
  63676. }
  63677. function f2 (x, y, z) {
  63678. return (((x) & (y)) | ((~x) & (z)))
  63679. }
  63680. function f3 (x, y, z) {
  63681. return (((x) | (~(y))) ^ (z))
  63682. }
  63683. function f4 (x, y, z) {
  63684. return (((x) & (z)) | ((y) & (~(z))))
  63685. }
  63686. function f5 (x, y, z) {
  63687. return ((x) ^ ((y) | (~(z))))
  63688. }
  63689. function rotl (x, n) {
  63690. return (x << n) | (x >>> (32 - n))
  63691. }
  63692. function ripemd160 (message) {
  63693. var H = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]
  63694. if (typeof message === 'string') {
  63695. message = new Buffer(message, 'utf8')
  63696. }
  63697. var m = bytesToWords(message)
  63698. var nBitsLeft = message.length * 8
  63699. var nBitsTotal = message.length * 8
  63700. // Add padding
  63701. m[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32)
  63702. m[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
  63703. (((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) |
  63704. (((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00)
  63705. )
  63706. for (var i = 0; i < m.length; i += 16) {
  63707. processBlock(H, m, i)
  63708. }
  63709. // swap endian
  63710. for (i = 0; i < 5; i++) {
  63711. // shortcut
  63712. var H_i = H[i]
  63713. // Swap
  63714. H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
  63715. (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00)
  63716. }
  63717. var digestbytes = wordsToBytes(H)
  63718. return new Buffer(digestbytes)
  63719. }
  63720. module.exports = ripemd160
  63721. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  63722. /***/ },
  63723. /* 555 */
  63724. /***/ function(module, exports, __webpack_require__) {
  63725. var Readable = __webpack_require__(9).Readable;
  63726. var PassThrough = __webpack_require__(9).PassThrough;
  63727. function SandwichStream(options) {
  63728. Readable.call(this, options);
  63729. options = options || {};
  63730. this._streamsActive = false;
  63731. this._streamsAdded = false;
  63732. this._streams = [];
  63733. this._currentStream = undefined;
  63734. this._errorsEmitted = false;
  63735. if (options.head) {
  63736. this._head = options.head;
  63737. }
  63738. if (options.tail) {
  63739. this._tail = options.tail;
  63740. }
  63741. if (options.separator) {
  63742. this._separator = options.separator;
  63743. }
  63744. }
  63745. SandwichStream.prototype = Object.create(Readable.prototype, {
  63746. constructor: SandwichStream
  63747. });
  63748. SandwichStream.prototype._read = function () {
  63749. if (!this._streamsActive) {
  63750. this._streamsActive = true;
  63751. this._pushHead();
  63752. this._streamNextStream();
  63753. }
  63754. };
  63755. SandwichStream.prototype.add = function (newStream) {
  63756. if (!this._streamsActive) {
  63757. this._streamsAdded = true;
  63758. this._streams.push(newStream);
  63759. newStream.on('error', this._substreamOnError.bind(this));
  63760. }
  63761. else {
  63762. throw new Error('SandwichStream error adding new stream while streaming');
  63763. }
  63764. };
  63765. SandwichStream.prototype._substreamOnError = function (error) {
  63766. this._errorsEmitted = true;
  63767. this.emit('error', error);
  63768. };
  63769. SandwichStream.prototype._pushHead = function () {
  63770. if (this._head) {
  63771. this.push(this._head);
  63772. }
  63773. };
  63774. SandwichStream.prototype._streamNextStream = function () {
  63775. if (this._nextStream()) {
  63776. this._bindCurrentStreamEvents();
  63777. }
  63778. else {
  63779. this._pushTail();
  63780. this.push(null);
  63781. }
  63782. };
  63783. SandwichStream.prototype._nextStream = function () {
  63784. this._currentStream = this._streams.shift();
  63785. return this._currentStream !== undefined;
  63786. };
  63787. SandwichStream.prototype._bindCurrentStreamEvents = function () {
  63788. this._currentStream.on('readable', this._currentStreamOnReadable.bind(this));
  63789. this._currentStream.on('end', this._currentStreamOnEnd.bind(this));
  63790. };
  63791. SandwichStream.prototype._currentStreamOnReadable = function () {
  63792. this.push(this._currentStream.read() || '');
  63793. };
  63794. SandwichStream.prototype._currentStreamOnEnd = function () {
  63795. this._pushSeparator();
  63796. this._streamNextStream();
  63797. };
  63798. SandwichStream.prototype._pushSeparator = function () {
  63799. if (this._streams.length > 0 && this._separator) {
  63800. this.push(this._separator);
  63801. }
  63802. };
  63803. SandwichStream.prototype._pushTail = function () {
  63804. if (this._tail) {
  63805. this.push(this._tail);
  63806. }
  63807. };
  63808. function sandwichStream(options) {
  63809. var stream = new SandwichStream(options);
  63810. return stream;
  63811. }
  63812. sandwichStream.SandwichStream = SandwichStream;
  63813. module.exports = sandwichStream;
  63814. /***/ },
  63815. /* 556 */
  63816. /***/ function(module, exports, __webpack_require__) {
  63817. var exports = module.exports = function SHA (algorithm) {
  63818. algorithm = algorithm.toLowerCase()
  63819. var Algorithm = exports[algorithm]
  63820. if (!Algorithm) throw new Error(algorithm + ' is not supported (we accept pull requests)')
  63821. return new Algorithm()
  63822. }
  63823. exports.sha = __webpack_require__(557)
  63824. exports.sha1 = __webpack_require__(558)
  63825. exports.sha224 = __webpack_require__(559)
  63826. exports.sha256 = __webpack_require__(217)
  63827. exports.sha384 = __webpack_require__(560)
  63828. exports.sha512 = __webpack_require__(218)
  63829. /***/ },
  63830. /* 557 */
  63831. /***/ function(module, exports, __webpack_require__) {
  63832. /* WEBPACK VAR INJECTION */(function(Buffer) {/*
  63833. * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined
  63834. * in FIPS PUB 180-1
  63835. * This source code is derived from sha1.js of the same repository.
  63836. * The difference between SHA-0 and SHA-1 is just a bitwise rotate left
  63837. * operation was added.
  63838. */
  63839. var inherits = __webpack_require__(2)
  63840. var Hash = __webpack_require__(65)
  63841. var K = [
  63842. 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
  63843. ]
  63844. var W = new Array(80)
  63845. function Sha () {
  63846. this.init()
  63847. this._w = W
  63848. Hash.call(this, 64, 56)
  63849. }
  63850. inherits(Sha, Hash)
  63851. Sha.prototype.init = function () {
  63852. this._a = 0x67452301
  63853. this._b = 0xefcdab89
  63854. this._c = 0x98badcfe
  63855. this._d = 0x10325476
  63856. this._e = 0xc3d2e1f0
  63857. return this
  63858. }
  63859. function rotl5 (num) {
  63860. return (num << 5) | (num >>> 27)
  63861. }
  63862. function rotl30 (num) {
  63863. return (num << 30) | (num >>> 2)
  63864. }
  63865. function ft (s, b, c, d) {
  63866. if (s === 0) return (b & c) | ((~b) & d)
  63867. if (s === 2) return (b & c) | (b & d) | (c & d)
  63868. return b ^ c ^ d
  63869. }
  63870. Sha.prototype._update = function (M) {
  63871. var W = this._w
  63872. var a = this._a | 0
  63873. var b = this._b | 0
  63874. var c = this._c | 0
  63875. var d = this._d | 0
  63876. var e = this._e | 0
  63877. for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
  63878. for (; i < 80; ++i) W[i] = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]
  63879. for (var j = 0; j < 80; ++j) {
  63880. var s = ~~(j / 20)
  63881. var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0
  63882. e = d
  63883. d = c
  63884. c = rotl30(b)
  63885. b = a
  63886. a = t
  63887. }
  63888. this._a = (a + this._a) | 0
  63889. this._b = (b + this._b) | 0
  63890. this._c = (c + this._c) | 0
  63891. this._d = (d + this._d) | 0
  63892. this._e = (e + this._e) | 0
  63893. }
  63894. Sha.prototype._hash = function () {
  63895. var H = new Buffer(20)
  63896. H.writeInt32BE(this._a | 0, 0)
  63897. H.writeInt32BE(this._b | 0, 4)
  63898. H.writeInt32BE(this._c | 0, 8)
  63899. H.writeInt32BE(this._d | 0, 12)
  63900. H.writeInt32BE(this._e | 0, 16)
  63901. return H
  63902. }
  63903. module.exports = Sha
  63904. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  63905. /***/ },
  63906. /* 558 */
  63907. /***/ function(module, exports, __webpack_require__) {
  63908. /* WEBPACK VAR INJECTION */(function(Buffer) {/*
  63909. * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
  63910. * in FIPS PUB 180-1
  63911. * Version 2.1a Copyright Paul Johnston 2000 - 2002.
  63912. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  63913. * Distributed under the BSD License
  63914. * See http://pajhome.org.uk/crypt/md5 for details.
  63915. */
  63916. var inherits = __webpack_require__(2)
  63917. var Hash = __webpack_require__(65)
  63918. var K = [
  63919. 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
  63920. ]
  63921. var W = new Array(80)
  63922. function Sha1 () {
  63923. this.init()
  63924. this._w = W
  63925. Hash.call(this, 64, 56)
  63926. }
  63927. inherits(Sha1, Hash)
  63928. Sha1.prototype.init = function () {
  63929. this._a = 0x67452301
  63930. this._b = 0xefcdab89
  63931. this._c = 0x98badcfe
  63932. this._d = 0x10325476
  63933. this._e = 0xc3d2e1f0
  63934. return this
  63935. }
  63936. function rotl1 (num) {
  63937. return (num << 1) | (num >>> 31)
  63938. }
  63939. function rotl5 (num) {
  63940. return (num << 5) | (num >>> 27)
  63941. }
  63942. function rotl30 (num) {
  63943. return (num << 30) | (num >>> 2)
  63944. }
  63945. function ft (s, b, c, d) {
  63946. if (s === 0) return (b & c) | ((~b) & d)
  63947. if (s === 2) return (b & c) | (b & d) | (c & d)
  63948. return b ^ c ^ d
  63949. }
  63950. Sha1.prototype._update = function (M) {
  63951. var W = this._w
  63952. var a = this._a | 0
  63953. var b = this._b | 0
  63954. var c = this._c | 0
  63955. var d = this._d | 0
  63956. var e = this._e | 0
  63957. for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
  63958. for (; i < 80; ++i) W[i] = rotl1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16])
  63959. for (var j = 0; j < 80; ++j) {
  63960. var s = ~~(j / 20)
  63961. var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0
  63962. e = d
  63963. d = c
  63964. c = rotl30(b)
  63965. b = a
  63966. a = t
  63967. }
  63968. this._a = (a + this._a) | 0
  63969. this._b = (b + this._b) | 0
  63970. this._c = (c + this._c) | 0
  63971. this._d = (d + this._d) | 0
  63972. this._e = (e + this._e) | 0
  63973. }
  63974. Sha1.prototype._hash = function () {
  63975. var H = new Buffer(20)
  63976. H.writeInt32BE(this._a | 0, 0)
  63977. H.writeInt32BE(this._b | 0, 4)
  63978. H.writeInt32BE(this._c | 0, 8)
  63979. H.writeInt32BE(this._d | 0, 12)
  63980. H.writeInt32BE(this._e | 0, 16)
  63981. return H
  63982. }
  63983. module.exports = Sha1
  63984. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  63985. /***/ },
  63986. /* 559 */
  63987. /***/ function(module, exports, __webpack_require__) {
  63988. /* WEBPACK VAR INJECTION */(function(Buffer) {/**
  63989. * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
  63990. * in FIPS 180-2
  63991. * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
  63992. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  63993. *
  63994. */
  63995. var inherits = __webpack_require__(2)
  63996. var Sha256 = __webpack_require__(217)
  63997. var Hash = __webpack_require__(65)
  63998. var W = new Array(64)
  63999. function Sha224 () {
  64000. this.init()
  64001. this._w = W // new Array(64)
  64002. Hash.call(this, 64, 56)
  64003. }
  64004. inherits(Sha224, Sha256)
  64005. Sha224.prototype.init = function () {
  64006. this._a = 0xc1059ed8
  64007. this._b = 0x367cd507
  64008. this._c = 0x3070dd17
  64009. this._d = 0xf70e5939
  64010. this._e = 0xffc00b31
  64011. this._f = 0x68581511
  64012. this._g = 0x64f98fa7
  64013. this._h = 0xbefa4fa4
  64014. return this
  64015. }
  64016. Sha224.prototype._hash = function () {
  64017. var H = new Buffer(28)
  64018. H.writeInt32BE(this._a, 0)
  64019. H.writeInt32BE(this._b, 4)
  64020. H.writeInt32BE(this._c, 8)
  64021. H.writeInt32BE(this._d, 12)
  64022. H.writeInt32BE(this._e, 16)
  64023. H.writeInt32BE(this._f, 20)
  64024. H.writeInt32BE(this._g, 24)
  64025. return H
  64026. }
  64027. module.exports = Sha224
  64028. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  64029. /***/ },
  64030. /* 560 */
  64031. /***/ function(module, exports, __webpack_require__) {
  64032. /* WEBPACK VAR INJECTION */(function(Buffer) {var inherits = __webpack_require__(2)
  64033. var SHA512 = __webpack_require__(218)
  64034. var Hash = __webpack_require__(65)
  64035. var W = new Array(160)
  64036. function Sha384 () {
  64037. this.init()
  64038. this._w = W
  64039. Hash.call(this, 128, 112)
  64040. }
  64041. inherits(Sha384, SHA512)
  64042. Sha384.prototype.init = function () {
  64043. this._ah = 0xcbbb9d5d
  64044. this._bh = 0x629a292a
  64045. this._ch = 0x9159015a
  64046. this._dh = 0x152fecd8
  64047. this._eh = 0x67332667
  64048. this._fh = 0x8eb44a87
  64049. this._gh = 0xdb0c2e0d
  64050. this._hh = 0x47b5481d
  64051. this._al = 0xc1059ed8
  64052. this._bl = 0x367cd507
  64053. this._cl = 0x3070dd17
  64054. this._dl = 0xf70e5939
  64055. this._el = 0xffc00b31
  64056. this._fl = 0x68581511
  64057. this._gl = 0x64f98fa7
  64058. this._hl = 0xbefa4fa4
  64059. return this
  64060. }
  64061. Sha384.prototype._hash = function () {
  64062. var H = new Buffer(48)
  64063. function writeInt64BE (h, l, offset) {
  64064. H.writeInt32BE(h, offset)
  64065. H.writeInt32BE(l, offset + 4)
  64066. }
  64067. writeInt64BE(this._ah, this._al, 0)
  64068. writeInt64BE(this._bh, this._bl, 8)
  64069. writeInt64BE(this._ch, this._cl, 16)
  64070. writeInt64BE(this._dh, this._dl, 24)
  64071. writeInt64BE(this._eh, this._el, 32)
  64072. writeInt64BE(this._fh, this._fl, 40)
  64073. return H
  64074. }
  64075. module.exports = Sha384
  64076. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer))
  64077. /***/ },
  64078. /* 561 */
  64079. /***/ function(module, exports, __webpack_require__) {
  64080. var varint = __webpack_require__(564)
  64081. exports.encode = function encode (v, b, o) {
  64082. v = v >= 0 ? v*2 : v*-2 - 1
  64083. var r = varint.encode(v, b, o)
  64084. encode.bytes = varint.encode.bytes
  64085. return r
  64086. }
  64087. exports.decode = function decode (b, o) {
  64088. var v = varint.decode(b, o)
  64089. decode.bytes = varint.decode.bytes
  64090. return v & 1 ? (v+1) / -2 : v / 2
  64091. }
  64092. exports.encodingLength = function (v) {
  64093. return varint.encodingLength(v >= 0 ? v*2 : v*-2 - 1)
  64094. }
  64095. /***/ },
  64096. /* 562 */
  64097. /***/ function(module, exports) {
  64098. module.exports = read
  64099. var MSB = 0x80
  64100. , REST = 0x7F
  64101. function read(buf, offset) {
  64102. var res = 0
  64103. , offset = offset || 0
  64104. , shift = 0
  64105. , counter = offset
  64106. , b
  64107. , l = buf.length
  64108. do {
  64109. if(counter >= l) {
  64110. read.bytesRead = 0
  64111. return undefined
  64112. }
  64113. b = buf[counter++]
  64114. res += shift < 28
  64115. ? (b & REST) << shift
  64116. : (b & REST) * Math.pow(2, shift)
  64117. shift += 7
  64118. } while (b >= MSB)
  64119. read.bytes = counter - offset
  64120. return res
  64121. }
  64122. /***/ },
  64123. /* 563 */
  64124. /***/ function(module, exports) {
  64125. module.exports = encode
  64126. var MSB = 0x80
  64127. , REST = 0x7F
  64128. , MSBALL = ~REST
  64129. , INT = Math.pow(2, 31)
  64130. function encode(num, out, offset) {
  64131. out = out || []
  64132. offset = offset || 0
  64133. var oldOffset = offset
  64134. while(num >= INT) {
  64135. out[offset++] = (num & 0xFF) | MSB
  64136. num /= 128
  64137. }
  64138. while(num & MSBALL) {
  64139. out[offset++] = (num & 0xFF) | MSB
  64140. num >>>= 7
  64141. }
  64142. out[offset] = num | 0
  64143. encode.bytes = offset - oldOffset + 1
  64144. return out
  64145. }
  64146. /***/ },
  64147. /* 564 */
  64148. /***/ function(module, exports, __webpack_require__) {
  64149. module.exports = {
  64150. encode: __webpack_require__(563)
  64151. , decode: __webpack_require__(562)
  64152. , encodingLength: __webpack_require__(565)
  64153. }
  64154. /***/ },
  64155. /* 565 */
  64156. /***/ function(module, exports) {
  64157. var N1 = Math.pow(2, 7)
  64158. var N2 = Math.pow(2, 14)
  64159. var N3 = Math.pow(2, 21)
  64160. var N4 = Math.pow(2, 28)
  64161. var N5 = Math.pow(2, 35)
  64162. var N6 = Math.pow(2, 42)
  64163. var N7 = Math.pow(2, 49)
  64164. module.exports = function (value) {
  64165. return (
  64166. value < N1 ? 1
  64167. : value < N2 ? 2
  64168. : value < N3 ? 3
  64169. : value < N4 ? 4
  64170. : value < N5 ? 5
  64171. : value < N6 ? 6
  64172. : value < N7 ? 7
  64173. : 8
  64174. )
  64175. }
  64176. /***/ },
  64177. /* 566 */
  64178. /***/ function(module, exports, __webpack_require__) {
  64179. "use strict";
  64180. /*
  64181. Copyright (c) 2014, Matteo Collina <[email protected]>
  64182. Permission to use, copy, modify, and/or distribute this software for any
  64183. purpose with or without fee is hereby granted, provided that the above
  64184. copyright notice and this permission notice appear in all copies.
  64185. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  64186. WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  64187. MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  64188. ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  64189. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  64190. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
  64191. IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  64192. */
  64193. 'use strict';
  64194. var through = __webpack_require__(572)
  64195. function transform(chunk, enc, cb) {
  64196. var list = chunk.toString('utf8').split(this.matcher)
  64197. , remaining = list.pop()
  64198. , i
  64199. if (list.length >= 1) {
  64200. push(this, this.mapper((this._last + list.shift())))
  64201. } else {
  64202. remaining = this._last + remaining
  64203. }
  64204. for (i = 0; i < list.length; i++) {
  64205. push(this, this.mapper(list[i]))
  64206. }
  64207. this._last = remaining
  64208. cb()
  64209. }
  64210. function flush(cb) {
  64211. if (this._last)
  64212. push(this, this.mapper(this._last))
  64213. cb()
  64214. }
  64215. function push(self, val) {
  64216. if (val !== undefined)
  64217. self.push(val)
  64218. }
  64219. function noop(incoming) {
  64220. return incoming
  64221. }
  64222. function split(matcher, mapper, options) {
  64223. if (typeof matcher === 'object' && !(matcher instanceof RegExp)) {
  64224. options = matcher
  64225. matcher = null
  64226. }
  64227. if (typeof matcher === 'function') {
  64228. mapper = matcher
  64229. matcher = null
  64230. }
  64231. options = options || {}
  64232. var stream = through(options, transform, flush)
  64233. // this stream is in objectMode only in the readable part
  64234. stream._readableState.objectMode = true;
  64235. stream._last = ''
  64236. stream.matcher = matcher || /\r?\n/
  64237. stream.mapper = mapper || noop
  64238. return stream
  64239. }
  64240. module.exports = split
  64241. /***/ },
  64242. /* 567 */
  64243. /***/ function(module, exports) {
  64244. module.exports = Array.isArray || function (arr) {
  64245. return Object.prototype.toString.call(arr) == '[object Array]';
  64246. };
  64247. /***/ },
  64248. /* 568 */
  64249. /***/ function(module, exports, __webpack_require__) {
  64250. /* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors.
  64251. //
  64252. // Permission is hereby granted, free of charge, to any person obtaining a
  64253. // copy of this software and associated documentation files (the
  64254. // "Software"), to deal in the Software without restriction, including
  64255. // without limitation the rights to use, copy, modify, merge, publish,
  64256. // distribute, sublicense, and/or sell copies of the Software, and to permit
  64257. // persons to whom the Software is furnished to do so, subject to the
  64258. // following conditions:
  64259. //
  64260. // The above copyright notice and this permission notice shall be included
  64261. // in all copies or substantial portions of the Software.
  64262. //
  64263. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  64264. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  64265. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  64266. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  64267. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  64268. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  64269. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  64270. module.exports = Readable;
  64271. /*<replacement>*/
  64272. var isArray = __webpack_require__(567);
  64273. /*</replacement>*/
  64274. /*<replacement>*/
  64275. var Buffer = __webpack_require__(1).Buffer;
  64276. /*</replacement>*/
  64277. Readable.ReadableState = ReadableState;
  64278. var EE = __webpack_require__(30).EventEmitter;
  64279. /*<replacement>*/
  64280. if (!EE.listenerCount) EE.listenerCount = function(emitter, type) {
  64281. return emitter.listeners(type).length;
  64282. };
  64283. /*</replacement>*/
  64284. var Stream = __webpack_require__(9);
  64285. /*<replacement>*/
  64286. var util = __webpack_require__(14);
  64287. util.inherits = __webpack_require__(2);
  64288. /*</replacement>*/
  64289. var StringDecoder;
  64290. util.inherits(Readable, Stream);
  64291. function ReadableState(options, stream) {
  64292. options = options || {};
  64293. // the point at which it stops calling _read() to fill the buffer
  64294. // Note: 0 is a valid value, means "don't call _read preemptively ever"
  64295. var hwm = options.highWaterMark;
  64296. this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024;
  64297. // cast to ints.
  64298. this.highWaterMark = ~~this.highWaterMark;
  64299. this.buffer = [];
  64300. this.length = 0;
  64301. this.pipes = null;
  64302. this.pipesCount = 0;
  64303. this.flowing = false;
  64304. this.ended = false;
  64305. this.endEmitted = false;
  64306. this.reading = false;
  64307. // In streams that never have any data, and do push(null) right away,
  64308. // the consumer can miss the 'end' event if they do some I/O before
  64309. // consuming the stream. So, we don't emit('end') until some reading
  64310. // happens.
  64311. this.calledRead = false;
  64312. // a flag to be able to tell if the onwrite cb is called immediately,
  64313. // or on a later tick. We set this to true at first, becuase any
  64314. // actions that shouldn't happen until "later" should generally also
  64315. // not happen before the first write call.
  64316. this.sync = true;
  64317. // whenever we return null, then we set a flag to say
  64318. // that we're awaiting a 'readable' event emission.
  64319. this.needReadable = false;
  64320. this.emittedReadable = false;
  64321. this.readableListening = false;
  64322. // object stream flag. Used to make read(n) ignore n and to
  64323. // make all the buffer merging and length checks go away
  64324. this.objectMode = !!options.objectMode;
  64325. // Crypto is kind of old and crusty. Historically, its default string
  64326. // encoding is 'binary' so we have to make this configurable.
  64327. // Everything else in the universe uses 'utf8', though.
  64328. this.defaultEncoding = options.defaultEncoding || 'utf8';
  64329. // when piping, we only care about 'readable' events that happen
  64330. // after read()ing all the bytes and not getting any pushback.
  64331. this.ranOut = false;
  64332. // the number of writers that are awaiting a drain event in .pipe()s
  64333. this.awaitDrain = 0;
  64334. // if true, a maybeReadMore has been scheduled
  64335. this.readingMore = false;
  64336. this.decoder = null;
  64337. this.encoding = null;
  64338. if (options.encoding) {
  64339. if (!StringDecoder)
  64340. StringDecoder = __webpack_require__(38).StringDecoder;
  64341. this.decoder = new StringDecoder(options.encoding);
  64342. this.encoding = options.encoding;
  64343. }
  64344. }
  64345. function Readable(options) {
  64346. if (!(this instanceof Readable))
  64347. return new Readable(options);
  64348. this._readableState = new ReadableState(options, this);
  64349. // legacy
  64350. this.readable = true;
  64351. Stream.call(this);
  64352. }
  64353. // Manually shove something into the read() buffer.
  64354. // This returns true if the highWaterMark has not been hit yet,
  64355. // similar to how Writable.write() returns true if you should
  64356. // write() some more.
  64357. Readable.prototype.push = function(chunk, encoding) {
  64358. var state = this._readableState;
  64359. if (typeof chunk === 'string' && !state.objectMode) {
  64360. encoding = encoding || state.defaultEncoding;
  64361. if (encoding !== state.encoding) {
  64362. chunk = new Buffer(chunk, encoding);
  64363. encoding = '';
  64364. }
  64365. }
  64366. return readableAddChunk(this, state, chunk, encoding, false);
  64367. };
  64368. // Unshift should *always* be something directly out of read()
  64369. Readable.prototype.unshift = function(chunk) {
  64370. var state = this._readableState;
  64371. return readableAddChunk(this, state, chunk, '', true);
  64372. };
  64373. function readableAddChunk(stream, state, chunk, encoding, addToFront) {
  64374. var er = chunkInvalid(state, chunk);
  64375. if (er) {
  64376. stream.emit('error', er);
  64377. } else if (chunk === null || chunk === undefined) {
  64378. state.reading = false;
  64379. if (!state.ended)
  64380. onEofChunk(stream, state);
  64381. } else if (state.objectMode || chunk && chunk.length > 0) {
  64382. if (state.ended && !addToFront) {
  64383. var e = new Error('stream.push() after EOF');
  64384. stream.emit('error', e);
  64385. } else if (state.endEmitted && addToFront) {
  64386. var e = new Error('stream.unshift() after end event');
  64387. stream.emit('error', e);
  64388. } else {
  64389. if (state.decoder && !addToFront && !encoding)
  64390. chunk = state.decoder.write(chunk);
  64391. // update the buffer info.
  64392. state.length += state.objectMode ? 1 : chunk.length;
  64393. if (addToFront) {
  64394. state.buffer.unshift(chunk);
  64395. } else {
  64396. state.reading = false;
  64397. state.buffer.push(chunk);
  64398. }
  64399. if (state.needReadable)
  64400. emitReadable(stream);
  64401. maybeReadMore(stream, state);
  64402. }
  64403. } else if (!addToFront) {
  64404. state.reading = false;
  64405. }
  64406. return needMoreData(state);
  64407. }
  64408. // if it's past the high water mark, we can push in some more.
  64409. // Also, if we have no data yet, we can stand some
  64410. // more bytes. This is to work around cases where hwm=0,
  64411. // such as the repl. Also, if the push() triggered a
  64412. // readable event, and the user called read(largeNumber) such that
  64413. // needReadable was set, then we ought to push more, so that another
  64414. // 'readable' event will be triggered.
  64415. function needMoreData(state) {
  64416. return !state.ended &&
  64417. (state.needReadable ||
  64418. state.length < state.highWaterMark ||
  64419. state.length === 0);
  64420. }
  64421. // backwards compatibility.
  64422. Readable.prototype.setEncoding = function(enc) {
  64423. if (!StringDecoder)
  64424. StringDecoder = __webpack_require__(38).StringDecoder;
  64425. this._readableState.decoder = new StringDecoder(enc);
  64426. this._readableState.encoding = enc;
  64427. };
  64428. // Don't raise the hwm > 128MB
  64429. var MAX_HWM = 0x800000;
  64430. function roundUpToNextPowerOf2(n) {
  64431. if (n >= MAX_HWM) {
  64432. n = MAX_HWM;
  64433. } else {
  64434. // Get the next highest power of 2
  64435. n--;
  64436. for (var p = 1; p < 32; p <<= 1) n |= n >> p;
  64437. n++;
  64438. }
  64439. return n;
  64440. }
  64441. function howMuchToRead(n, state) {
  64442. if (state.length === 0 && state.ended)
  64443. return 0;
  64444. if (state.objectMode)
  64445. return n === 0 ? 0 : 1;
  64446. if (n === null || isNaN(n)) {
  64447. // only flow one buffer at a time
  64448. if (state.flowing && state.buffer.length)
  64449. return state.buffer[0].length;
  64450. else
  64451. return state.length;
  64452. }
  64453. if (n <= 0)
  64454. return 0;
  64455. // If we're asking for more than the target buffer level,
  64456. // then raise the water mark. Bump up to the next highest
  64457. // power of 2, to prevent increasing it excessively in tiny
  64458. // amounts.
  64459. if (n > state.highWaterMark)
  64460. state.highWaterMark = roundUpToNextPowerOf2(n);
  64461. // don't have that much. return null, unless we've ended.
  64462. if (n > state.length) {
  64463. if (!state.ended) {
  64464. state.needReadable = true;
  64465. return 0;
  64466. } else
  64467. return state.length;
  64468. }
  64469. return n;
  64470. }
  64471. // you can override either this method, or the async _read(n) below.
  64472. Readable.prototype.read = function(n) {
  64473. var state = this._readableState;
  64474. state.calledRead = true;
  64475. var nOrig = n;
  64476. var ret;
  64477. if (typeof n !== 'number' || n > 0)
  64478. state.emittedReadable = false;
  64479. // if we're doing read(0) to trigger a readable event, but we
  64480. // already have a bunch of data in the buffer, then just trigger
  64481. // the 'readable' event and move on.
  64482. if (n === 0 &&
  64483. state.needReadable &&
  64484. (state.length >= state.highWaterMark || state.ended)) {
  64485. emitReadable(this);
  64486. return null;
  64487. }
  64488. n = howMuchToRead(n, state);
  64489. // if we've ended, and we're now clear, then finish it up.
  64490. if (n === 0 && state.ended) {
  64491. ret = null;
  64492. // In cases where the decoder did not receive enough data
  64493. // to produce a full chunk, then immediately received an
  64494. // EOF, state.buffer will contain [<Buffer >, <Buffer 00 ...>].
  64495. // howMuchToRead will see this and coerce the amount to
  64496. // read to zero (because it's looking at the length of the
  64497. // first <Buffer > in state.buffer), and we'll end up here.
  64498. //
  64499. // This can only happen via state.decoder -- no other venue
  64500. // exists for pushing a zero-length chunk into state.buffer
  64501. // and triggering this behavior. In this case, we return our
  64502. // remaining data and end the stream, if appropriate.
  64503. if (state.length > 0 && state.decoder) {
  64504. ret = fromList(n, state);
  64505. state.length -= ret.length;
  64506. }
  64507. if (state.length === 0)
  64508. endReadable(this);
  64509. return ret;
  64510. }
  64511. // All the actual chunk generation logic needs to be
  64512. // *below* the call to _read. The reason is that in certain
  64513. // synthetic stream cases, such as passthrough streams, _read
  64514. // may be a completely synchronous operation which may change
  64515. // the state of the read buffer, providing enough data when
  64516. // before there was *not* enough.
  64517. //
  64518. // So, the steps are:
  64519. // 1. Figure out what the state of things will be after we do
  64520. // a read from the buffer.
  64521. //
  64522. // 2. If that resulting state will trigger a _read, then call _read.
  64523. // Note that this may be asynchronous, or synchronous. Yes, it is
  64524. // deeply ugly to write APIs this way, but that still doesn't mean
  64525. // that the Readable class should behave improperly, as streams are
  64526. // designed to be sync/async agnostic.
  64527. // Take note if the _read call is sync or async (ie, if the read call
  64528. // has returned yet), so that we know whether or not it's safe to emit
  64529. // 'readable' etc.
  64530. //
  64531. // 3. Actually pull the requested chunks out of the buffer and return.
  64532. // if we need a readable event, then we need to do some reading.
  64533. var doRead = state.needReadable;
  64534. // if we currently have less than the highWaterMark, then also read some
  64535. if (state.length - n <= state.highWaterMark)
  64536. doRead = true;
  64537. // however, if we've ended, then there's no point, and if we're already
  64538. // reading, then it's unnecessary.
  64539. if (state.ended || state.reading)
  64540. doRead = false;
  64541. if (doRead) {
  64542. state.reading = true;
  64543. state.sync = true;
  64544. // if the length is currently zero, then we *need* a readable event.
  64545. if (state.length === 0)
  64546. state.needReadable = true;
  64547. // call internal read method
  64548. this._read(state.highWaterMark);
  64549. state.sync = false;
  64550. }
  64551. // If _read called its callback synchronously, then `reading`
  64552. // will be false, and we need to re-evaluate how much data we
  64553. // can return to the user.
  64554. if (doRead && !state.reading)
  64555. n = howMuchToRead(nOrig, state);
  64556. if (n > 0)
  64557. ret = fromList(n, state);
  64558. else
  64559. ret = null;
  64560. if (ret === null) {
  64561. state.needReadable = true;
  64562. n = 0;
  64563. }
  64564. state.length -= n;
  64565. // If we have nothing in the buffer, then we want to know
  64566. // as soon as we *do* get something into the buffer.
  64567. if (state.length === 0 && !state.ended)
  64568. state.needReadable = true;
  64569. // If we happened to read() exactly the remaining amount in the
  64570. // buffer, and the EOF has been seen at this point, then make sure
  64571. // that we emit 'end' on the very next tick.
  64572. if (state.ended && !state.endEmitted && state.length === 0)
  64573. endReadable(this);
  64574. return ret;
  64575. };
  64576. function chunkInvalid(state, chunk) {
  64577. var er = null;
  64578. if (!Buffer.isBuffer(chunk) &&
  64579. 'string' !== typeof chunk &&
  64580. chunk !== null &&
  64581. chunk !== undefined &&
  64582. !state.objectMode) {
  64583. er = new TypeError('Invalid non-string/buffer chunk');
  64584. }
  64585. return er;
  64586. }
  64587. function onEofChunk(stream, state) {
  64588. if (state.decoder && !state.ended) {
  64589. var chunk = state.decoder.end();
  64590. if (chunk && chunk.length) {
  64591. state.buffer.push(chunk);
  64592. state.length += state.objectMode ? 1 : chunk.length;
  64593. }
  64594. }
  64595. state.ended = true;
  64596. // if we've ended and we have some data left, then emit
  64597. // 'readable' now to make sure it gets picked up.
  64598. if (state.length > 0)
  64599. emitReadable(stream);
  64600. else
  64601. endReadable(stream);
  64602. }
  64603. // Don't emit readable right away in sync mode, because this can trigger
  64604. // another read() call => stack overflow. This way, it might trigger
  64605. // a nextTick recursion warning, but that's not so bad.
  64606. function emitReadable(stream) {
  64607. var state = stream._readableState;
  64608. state.needReadable = false;
  64609. if (state.emittedReadable)
  64610. return;
  64611. state.emittedReadable = true;
  64612. if (state.sync)
  64613. process.nextTick(function() {
  64614. emitReadable_(stream);
  64615. });
  64616. else
  64617. emitReadable_(stream);
  64618. }
  64619. function emitReadable_(stream) {
  64620. stream.emit('readable');
  64621. }
  64622. // at this point, the user has presumably seen the 'readable' event,
  64623. // and called read() to consume some data. that may have triggered
  64624. // in turn another _read(n) call, in which case reading = true if
  64625. // it's in progress.
  64626. // However, if we're not ended, or reading, and the length < hwm,
  64627. // then go ahead and try to read some more preemptively.
  64628. function maybeReadMore(stream, state) {
  64629. if (!state.readingMore) {
  64630. state.readingMore = true;
  64631. process.nextTick(function() {
  64632. maybeReadMore_(stream, state);
  64633. });
  64634. }
  64635. }
  64636. function maybeReadMore_(stream, state) {
  64637. var len = state.length;
  64638. while (!state.reading && !state.flowing && !state.ended &&
  64639. state.length < state.highWaterMark) {
  64640. stream.read(0);
  64641. if (len === state.length)
  64642. // didn't get any data, stop spinning.
  64643. break;
  64644. else
  64645. len = state.length;
  64646. }
  64647. state.readingMore = false;
  64648. }
  64649. // abstract method. to be overridden in specific implementation classes.
  64650. // call cb(er, data) where data is <= n in length.
  64651. // for virtual (non-string, non-buffer) streams, "length" is somewhat
  64652. // arbitrary, and perhaps not very meaningful.
  64653. Readable.prototype._read = function(n) {
  64654. this.emit('error', new Error('not implemented'));
  64655. };
  64656. Readable.prototype.pipe = function(dest, pipeOpts) {
  64657. var src = this;
  64658. var state = this._readableState;
  64659. switch (state.pipesCount) {
  64660. case 0:
  64661. state.pipes = dest;
  64662. break;
  64663. case 1:
  64664. state.pipes = [state.pipes, dest];
  64665. break;
  64666. default:
  64667. state.pipes.push(dest);
  64668. break;
  64669. }
  64670. state.pipesCount += 1;
  64671. var doEnd = (!pipeOpts || pipeOpts.end !== false) &&
  64672. dest !== process.stdout &&
  64673. dest !== process.stderr;
  64674. var endFn = doEnd ? onend : cleanup;
  64675. if (state.endEmitted)
  64676. process.nextTick(endFn);
  64677. else
  64678. src.once('end', endFn);
  64679. dest.on('unpipe', onunpipe);
  64680. function onunpipe(readable) {
  64681. if (readable !== src) return;
  64682. cleanup();
  64683. }
  64684. function onend() {
  64685. dest.end();
  64686. }
  64687. // when the dest drains, it reduces the awaitDrain counter
  64688. // on the source. This would be more elegant with a .once()
  64689. // handler in flow(), but adding and removing repeatedly is
  64690. // too slow.
  64691. var ondrain = pipeOnDrain(src);
  64692. dest.on('drain', ondrain);
  64693. function cleanup() {
  64694. // cleanup event handlers once the pipe is broken
  64695. dest.removeListener('close', onclose);
  64696. dest.removeListener('finish', onfinish);
  64697. dest.removeListener('drain', ondrain);
  64698. dest.removeListener('error', onerror);
  64699. dest.removeListener('unpipe', onunpipe);
  64700. src.removeListener('end', onend);
  64701. src.removeListener('end', cleanup);
  64702. // if the reader is waiting for a drain event from this
  64703. // specific writer, then it would cause it to never start
  64704. // flowing again.
  64705. // So, if this is awaiting a drain, then we just call it now.
  64706. // If we don't know, then assume that we are waiting for one.
  64707. if (!dest._writableState || dest._writableState.needDrain)
  64708. ondrain();
  64709. }
  64710. // if the dest has an error, then stop piping into it.
  64711. // however, don't suppress the throwing behavior for this.
  64712. function onerror(er) {
  64713. unpipe();
  64714. dest.removeListener('error', onerror);
  64715. if (EE.listenerCount(dest, 'error') === 0)
  64716. dest.emit('error', er);
  64717. }
  64718. // This is a brutally ugly hack to make sure that our error handler
  64719. // is attached before any userland ones. NEVER DO THIS.
  64720. if (!dest._events || !dest._events.error)
  64721. dest.on('error', onerror);
  64722. else if (isArray(dest._events.error))
  64723. dest._events.error.unshift(onerror);
  64724. else
  64725. dest._events.error = [onerror, dest._events.error];
  64726. // Both close and finish should trigger unpipe, but only once.
  64727. function onclose() {
  64728. dest.removeListener('finish', onfinish);
  64729. unpipe();
  64730. }
  64731. dest.once('close', onclose);
  64732. function onfinish() {
  64733. dest.removeListener('close', onclose);
  64734. unpipe();
  64735. }
  64736. dest.once('finish', onfinish);
  64737. function unpipe() {
  64738. src.unpipe(dest);
  64739. }
  64740. // tell the dest that it's being piped to
  64741. dest.emit('pipe', src);
  64742. // start the flow if it hasn't been started already.
  64743. if (!state.flowing) {
  64744. // the handler that waits for readable events after all
  64745. // the data gets sucked out in flow.
  64746. // This would be easier to follow with a .once() handler
  64747. // in flow(), but that is too slow.
  64748. this.on('readable', pipeOnReadable);
  64749. state.flowing = true;
  64750. process.nextTick(function() {
  64751. flow(src);
  64752. });
  64753. }
  64754. return dest;
  64755. };
  64756. function pipeOnDrain(src) {
  64757. return function() {
  64758. var dest = this;
  64759. var state = src._readableState;
  64760. state.awaitDrain--;
  64761. if (state.awaitDrain === 0)
  64762. flow(src);
  64763. };
  64764. }
  64765. function flow(src) {
  64766. var state = src._readableState;
  64767. var chunk;
  64768. state.awaitDrain = 0;
  64769. function write(dest, i, list) {
  64770. var written = dest.write(chunk);
  64771. if (false === written) {
  64772. state.awaitDrain++;
  64773. }
  64774. }
  64775. while (state.pipesCount && null !== (chunk = src.read())) {
  64776. if (state.pipesCount === 1)
  64777. write(state.pipes, 0, null);
  64778. else
  64779. forEach(state.pipes, write);
  64780. src.emit('data', chunk);
  64781. // if anyone needs a drain, then we have to wait for that.
  64782. if (state.awaitDrain > 0)
  64783. return;
  64784. }
  64785. // if every destination was unpiped, either before entering this
  64786. // function, or in the while loop, then stop flowing.
  64787. //
  64788. // NB: This is a pretty rare edge case.
  64789. if (state.pipesCount === 0) {
  64790. state.flowing = false;
  64791. // if there were data event listeners added, then switch to old mode.
  64792. if (EE.listenerCount(src, 'data') > 0)
  64793. emitDataEvents(src);
  64794. return;
  64795. }
  64796. // at this point, no one needed a drain, so we just ran out of data
  64797. // on the next readable event, start it over again.
  64798. state.ranOut = true;
  64799. }
  64800. function pipeOnReadable() {
  64801. if (this._readableState.ranOut) {
  64802. this._readableState.ranOut = false;
  64803. flow(this);
  64804. }
  64805. }
  64806. Readable.prototype.unpipe = function(dest) {
  64807. var state = this._readableState;
  64808. // if we're not piping anywhere, then do nothing.
  64809. if (state.pipesCount === 0)
  64810. return this;
  64811. // just one destination. most common case.
  64812. if (state.pipesCount === 1) {
  64813. // passed in one, but it's not the right one.
  64814. if (dest && dest !== state.pipes)
  64815. return this;
  64816. if (!dest)
  64817. dest = state.pipes;
  64818. // got a match.
  64819. state.pipes = null;
  64820. state.pipesCount = 0;
  64821. this.removeListener('readable', pipeOnReadable);
  64822. state.flowing = false;
  64823. if (dest)
  64824. dest.emit('unpipe', this);
  64825. return this;
  64826. }
  64827. // slow case. multiple pipe destinations.
  64828. if (!dest) {
  64829. // remove all.
  64830. var dests = state.pipes;
  64831. var len = state.pipesCount;
  64832. state.pipes = null;
  64833. state.pipesCount = 0;
  64834. this.removeListener('readable', pipeOnReadable);
  64835. state.flowing = false;
  64836. for (var i = 0; i < len; i++)
  64837. dests[i].emit('unpipe', this);
  64838. return this;
  64839. }
  64840. // try to find the right one.
  64841. var i = indexOf(state.pipes, dest);
  64842. if (i === -1)
  64843. return this;
  64844. state.pipes.splice(i, 1);
  64845. state.pipesCount -= 1;
  64846. if (state.pipesCount === 1)
  64847. state.pipes = state.pipes[0];
  64848. dest.emit('unpipe', this);
  64849. return this;
  64850. };
  64851. // set up data events if they are asked for
  64852. // Ensure readable listeners eventually get something
  64853. Readable.prototype.on = function(ev, fn) {
  64854. var res = Stream.prototype.on.call(this, ev, fn);
  64855. if (ev === 'data' && !this._readableState.flowing)
  64856. emitDataEvents(this);
  64857. if (ev === 'readable' && this.readable) {
  64858. var state = this._readableState;
  64859. if (!state.readableListening) {
  64860. state.readableListening = true;
  64861. state.emittedReadable = false;
  64862. state.needReadable = true;
  64863. if (!state.reading) {
  64864. this.read(0);
  64865. } else if (state.length) {
  64866. emitReadable(this, state);
  64867. }
  64868. }
  64869. }
  64870. return res;
  64871. };
  64872. Readable.prototype.addListener = Readable.prototype.on;
  64873. // pause() and resume() are remnants of the legacy readable stream API
  64874. // If the user uses them, then switch into old mode.
  64875. Readable.prototype.resume = function() {
  64876. emitDataEvents(this);
  64877. this.read(0);
  64878. this.emit('resume');
  64879. };
  64880. Readable.prototype.pause = function() {
  64881. emitDataEvents(this, true);
  64882. this.emit('pause');
  64883. };
  64884. function emitDataEvents(stream, startPaused) {
  64885. var state = stream._readableState;
  64886. if (state.flowing) {
  64887. // https://github.com/isaacs/readable-stream/issues/16
  64888. throw new Error('Cannot switch to old mode now.');
  64889. }
  64890. var paused = startPaused || false;
  64891. var readable = false;
  64892. // convert to an old-style stream.
  64893. stream.readable = true;
  64894. stream.pipe = Stream.prototype.pipe;
  64895. stream.on = stream.addListener = Stream.prototype.on;
  64896. stream.on('readable', function() {
  64897. readable = true;
  64898. var c;
  64899. while (!paused && (null !== (c = stream.read())))
  64900. stream.emit('data', c);
  64901. if (c === null) {
  64902. readable = false;
  64903. stream._readableState.needReadable = true;
  64904. }
  64905. });
  64906. stream.pause = function() {
  64907. paused = true;
  64908. this.emit('pause');
  64909. };
  64910. stream.resume = function() {
  64911. paused = false;
  64912. if (readable)
  64913. process.nextTick(function() {
  64914. stream.emit('readable');
  64915. });
  64916. else
  64917. this.read(0);
  64918. this.emit('resume');
  64919. };
  64920. // now make it start, just in case it hadn't already.
  64921. stream.emit('readable');
  64922. }
  64923. // wrap an old-style stream as the async data source.
  64924. // This is *not* part of the readable stream interface.
  64925. // It is an ugly unfortunate mess of history.
  64926. Readable.prototype.wrap = function(stream) {
  64927. var state = this._readableState;
  64928. var paused = false;
  64929. var self = this;
  64930. stream.on('end', function() {
  64931. if (state.decoder && !state.ended) {
  64932. var chunk = state.decoder.end();
  64933. if (chunk && chunk.length)
  64934. self.push(chunk);
  64935. }
  64936. self.push(null);
  64937. });
  64938. stream.on('data', function(chunk) {
  64939. if (state.decoder)
  64940. chunk = state.decoder.write(chunk);
  64941. // don't skip over falsy values in objectMode
  64942. //if (state.objectMode && util.isNullOrUndefined(chunk))
  64943. if (state.objectMode && (chunk === null || chunk === undefined))
  64944. return;
  64945. else if (!state.objectMode && (!chunk || !chunk.length))
  64946. return;
  64947. var ret = self.push(chunk);
  64948. if (!ret) {
  64949. paused = true;
  64950. stream.pause();
  64951. }
  64952. });
  64953. // proxy all the other methods.
  64954. // important when wrapping filters and duplexes.
  64955. for (var i in stream) {
  64956. if (typeof stream[i] === 'function' &&
  64957. typeof this[i] === 'undefined') {
  64958. this[i] = function(method) { return function() {
  64959. return stream[method].apply(stream, arguments);
  64960. }}(i);
  64961. }
  64962. }
  64963. // proxy certain important events.
  64964. var events = ['error', 'close', 'destroy', 'pause', 'resume'];
  64965. forEach(events, function(ev) {
  64966. stream.on(ev, self.emit.bind(self, ev));
  64967. });
  64968. // when we try to consume some more bytes, simply unpause the
  64969. // underlying stream.
  64970. self._read = function(n) {
  64971. if (paused) {
  64972. paused = false;
  64973. stream.resume();
  64974. }
  64975. };
  64976. return self;
  64977. };
  64978. // exposed for testing purposes only.
  64979. Readable._fromList = fromList;
  64980. // Pluck off n bytes from an array of buffers.
  64981. // Length is the combined lengths of all the buffers in the list.
  64982. function fromList(n, state) {
  64983. var list = state.buffer;
  64984. var length = state.length;
  64985. var stringMode = !!state.decoder;
  64986. var objectMode = !!state.objectMode;
  64987. var ret;
  64988. // nothing in the list, definitely empty.
  64989. if (list.length === 0)
  64990. return null;
  64991. if (length === 0)
  64992. ret = null;
  64993. else if (objectMode)
  64994. ret = list.shift();
  64995. else if (!n || n >= length) {
  64996. // read it all, truncate the array.
  64997. if (stringMode)
  64998. ret = list.join('');
  64999. else
  65000. ret = Buffer.concat(list, length);
  65001. list.length = 0;
  65002. } else {
  65003. // read just some of it.
  65004. if (n < list[0].length) {
  65005. // just take a part of the first list item.
  65006. // slice is the same for buffers and strings.
  65007. var buf = list[0];
  65008. ret = buf.slice(0, n);
  65009. list[0] = buf.slice(n);
  65010. } else if (n === list[0].length) {
  65011. // first list is a perfect match
  65012. ret = list.shift();
  65013. } else {
  65014. // complex case.
  65015. // we have enough to cover it, but it spans past the first buffer.
  65016. if (stringMode)
  65017. ret = '';
  65018. else
  65019. ret = new Buffer(n);
  65020. var c = 0;
  65021. for (var i = 0, l = list.length; i < l && c < n; i++) {
  65022. var buf = list[0];
  65023. var cpy = Math.min(n - c, buf.length);
  65024. if (stringMode)
  65025. ret += buf.slice(0, cpy);
  65026. else
  65027. buf.copy(ret, c, 0, cpy);
  65028. if (cpy < buf.length)
  65029. list[0] = buf.slice(cpy);
  65030. else
  65031. list.shift();
  65032. c += cpy;
  65033. }
  65034. }
  65035. }
  65036. return ret;
  65037. }
  65038. function endReadable(stream) {
  65039. var state = stream._readableState;
  65040. // If we get here before consuming all the bytes, then that is a
  65041. // bug in node. Should never happen.
  65042. if (state.length > 0)
  65043. throw new Error('endReadable called on non-empty stream');
  65044. if (!state.endEmitted && state.calledRead) {
  65045. state.ended = true;
  65046. process.nextTick(function() {
  65047. // Check that we didn't get one last unshift.
  65048. if (!state.endEmitted && state.length === 0) {
  65049. state.endEmitted = true;
  65050. stream.readable = false;
  65051. stream.emit('end');
  65052. }
  65053. });
  65054. }
  65055. }
  65056. function forEach (xs, f) {
  65057. for (var i = 0, l = xs.length; i < l; i++) {
  65058. f(xs[i], i);
  65059. }
  65060. }
  65061. function indexOf (xs, x) {
  65062. for (var i = 0, l = xs.length; i < l; i++) {
  65063. if (xs[i] === x) return i;
  65064. }
  65065. return -1;
  65066. }
  65067. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  65068. /***/ },
  65069. /* 569 */
  65070. /***/ function(module, exports, __webpack_require__) {
  65071. // Copyright Joyent, Inc. and other Node contributors.
  65072. //
  65073. // Permission is hereby granted, free of charge, to any person obtaining a
  65074. // copy of this software and associated documentation files (the
  65075. // "Software"), to deal in the Software without restriction, including
  65076. // without limitation the rights to use, copy, modify, merge, publish,
  65077. // distribute, sublicense, and/or sell copies of the Software, and to permit
  65078. // persons to whom the Software is furnished to do so, subject to the
  65079. // following conditions:
  65080. //
  65081. // The above copyright notice and this permission notice shall be included
  65082. // in all copies or substantial portions of the Software.
  65083. //
  65084. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  65085. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  65086. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  65087. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  65088. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  65089. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  65090. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  65091. // a transform stream is a readable/writable stream where you do
  65092. // something with the data. Sometimes it's called a "filter",
  65093. // but that's not a great name for it, since that implies a thing where
  65094. // some bits pass through, and others are simply ignored. (That would
  65095. // be a valid example of a transform, of course.)
  65096. //
  65097. // While the output is causally related to the input, it's not a
  65098. // necessarily symmetric or synchronous transformation. For example,
  65099. // a zlib stream might take multiple plain-text writes(), and then
  65100. // emit a single compressed chunk some time in the future.
  65101. //
  65102. // Here's how this works:
  65103. //
  65104. // The Transform stream has all the aspects of the readable and writable
  65105. // stream classes. When you write(chunk), that calls _write(chunk,cb)
  65106. // internally, and returns false if there's a lot of pending writes
  65107. // buffered up. When you call read(), that calls _read(n) until
  65108. // there's enough pending readable data buffered up.
  65109. //
  65110. // In a transform stream, the written data is placed in a buffer. When
  65111. // _read(n) is called, it transforms the queued up data, calling the
  65112. // buffered _write cb's as it consumes chunks. If consuming a single
  65113. // written chunk would result in multiple output chunks, then the first
  65114. // outputted bit calls the readcb, and subsequent chunks just go into
  65115. // the read buffer, and will cause it to emit 'readable' if necessary.
  65116. //
  65117. // This way, back-pressure is actually determined by the reading side,
  65118. // since _read has to be called to start processing a new chunk. However,
  65119. // a pathological inflate type of transform can cause excessive buffering
  65120. // here. For example, imagine a stream where every byte of input is
  65121. // interpreted as an integer from 0-255, and then results in that many
  65122. // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
  65123. // 1kb of data being output. In this case, you could write a very small
  65124. // amount of input, and end up with a very large amount of output. In
  65125. // such a pathological inflating mechanism, there'd be no way to tell
  65126. // the system to stop doing the transform. A single 4MB write could
  65127. // cause the system to run out of memory.
  65128. //
  65129. // However, even in such a pathological case, only a single written chunk
  65130. // would be consumed, and then the rest would wait (un-transformed) until
  65131. // the results of the previous transformed chunk were consumed.
  65132. module.exports = Transform;
  65133. var Duplex = __webpack_require__(219);
  65134. /*<replacement>*/
  65135. var util = __webpack_require__(14);
  65136. util.inherits = __webpack_require__(2);
  65137. /*</replacement>*/
  65138. util.inherits(Transform, Duplex);
  65139. function TransformState(options, stream) {
  65140. this.afterTransform = function(er, data) {
  65141. return afterTransform(stream, er, data);
  65142. };
  65143. this.needTransform = false;
  65144. this.transforming = false;
  65145. this.writecb = null;
  65146. this.writechunk = null;
  65147. }
  65148. function afterTransform(stream, er, data) {
  65149. var ts = stream._transformState;
  65150. ts.transforming = false;
  65151. var cb = ts.writecb;
  65152. if (!cb)
  65153. return stream.emit('error', new Error('no writecb in Transform class'));
  65154. ts.writechunk = null;
  65155. ts.writecb = null;
  65156. if (data !== null && data !== undefined)
  65157. stream.push(data);
  65158. if (cb)
  65159. cb(er);
  65160. var rs = stream._readableState;
  65161. rs.reading = false;
  65162. if (rs.needReadable || rs.length < rs.highWaterMark) {
  65163. stream._read(rs.highWaterMark);
  65164. }
  65165. }
  65166. function Transform(options) {
  65167. if (!(this instanceof Transform))
  65168. return new Transform(options);
  65169. Duplex.call(this, options);
  65170. var ts = this._transformState = new TransformState(options, this);
  65171. // when the writable side finishes, then flush out anything remaining.
  65172. var stream = this;
  65173. // start out asking for a readable event once data is transformed.
  65174. this._readableState.needReadable = true;
  65175. // we have implemented the _read method, and done the other things
  65176. // that Readable wants before the first _read call, so unset the
  65177. // sync guard flag.
  65178. this._readableState.sync = false;
  65179. this.once('finish', function() {
  65180. if ('function' === typeof this._flush)
  65181. this._flush(function(er) {
  65182. done(stream, er);
  65183. });
  65184. else
  65185. done(stream);
  65186. });
  65187. }
  65188. Transform.prototype.push = function(chunk, encoding) {
  65189. this._transformState.needTransform = false;
  65190. return Duplex.prototype.push.call(this, chunk, encoding);
  65191. };
  65192. // This is the part where you do stuff!
  65193. // override this function in implementation classes.
  65194. // 'chunk' is an input chunk.
  65195. //
  65196. // Call `push(newChunk)` to pass along transformed output
  65197. // to the readable side. You may call 'push' zero or more times.
  65198. //
  65199. // Call `cb(err)` when you are done with this chunk. If you pass
  65200. // an error, then that'll put the hurt on the whole operation. If you
  65201. // never call cb(), then you'll never get another chunk.
  65202. Transform.prototype._transform = function(chunk, encoding, cb) {
  65203. throw new Error('not implemented');
  65204. };
  65205. Transform.prototype._write = function(chunk, encoding, cb) {
  65206. var ts = this._transformState;
  65207. ts.writecb = cb;
  65208. ts.writechunk = chunk;
  65209. ts.writeencoding = encoding;
  65210. if (!ts.transforming) {
  65211. var rs = this._readableState;
  65212. if (ts.needTransform ||
  65213. rs.needReadable ||
  65214. rs.length < rs.highWaterMark)
  65215. this._read(rs.highWaterMark);
  65216. }
  65217. };
  65218. // Doesn't matter what the args are here.
  65219. // _transform does all the work.
  65220. // That we got here means that the readable side wants more data.
  65221. Transform.prototype._read = function(n) {
  65222. var ts = this._transformState;
  65223. if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
  65224. ts.transforming = true;
  65225. this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
  65226. } else {
  65227. // mark that we need a transform, so that any data that comes in
  65228. // will get processed, now that we've asked for it.
  65229. ts.needTransform = true;
  65230. }
  65231. };
  65232. function done(stream, er) {
  65233. if (er)
  65234. return stream.emit('error', er);
  65235. // if there's nothing in the write buffer, then that means
  65236. // that nothing more will ever be provided
  65237. var ws = stream._writableState;
  65238. var rs = stream._readableState;
  65239. var ts = stream._transformState;
  65240. if (ws.length)
  65241. throw new Error('calling transform done when ws.length != 0');
  65242. if (ts.transforming)
  65243. throw new Error('calling transform done when still transforming');
  65244. return stream.push(null);
  65245. }
  65246. /***/ },
  65247. /* 570 */
  65248. /***/ function(module, exports, __webpack_require__) {
  65249. /* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors.
  65250. //
  65251. // Permission is hereby granted, free of charge, to any person obtaining a
  65252. // copy of this software and associated documentation files (the
  65253. // "Software"), to deal in the Software without restriction, including
  65254. // without limitation the rights to use, copy, modify, merge, publish,
  65255. // distribute, sublicense, and/or sell copies of the Software, and to permit
  65256. // persons to whom the Software is furnished to do so, subject to the
  65257. // following conditions:
  65258. //
  65259. // The above copyright notice and this permission notice shall be included
  65260. // in all copies or substantial portions of the Software.
  65261. //
  65262. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  65263. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  65264. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  65265. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  65266. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  65267. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  65268. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  65269. // A bit simpler than readable streams.
  65270. // Implement an async ._write(chunk, cb), and it'll handle all
  65271. // the drain event emission and buffering.
  65272. module.exports = Writable;
  65273. /*<replacement>*/
  65274. var Buffer = __webpack_require__(1).Buffer;
  65275. /*</replacement>*/
  65276. Writable.WritableState = WritableState;
  65277. /*<replacement>*/
  65278. var util = __webpack_require__(14);
  65279. util.inherits = __webpack_require__(2);
  65280. /*</replacement>*/
  65281. var Stream = __webpack_require__(9);
  65282. util.inherits(Writable, Stream);
  65283. function WriteReq(chunk, encoding, cb) {
  65284. this.chunk = chunk;
  65285. this.encoding = encoding;
  65286. this.callback = cb;
  65287. }
  65288. function WritableState(options, stream) {
  65289. options = options || {};
  65290. // the point at which write() starts returning false
  65291. // Note: 0 is a valid value, means that we always return false if
  65292. // the entire buffer is not flushed immediately on write()
  65293. var hwm = options.highWaterMark;
  65294. this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024;
  65295. // object stream flag to indicate whether or not this stream
  65296. // contains buffers or objects.
  65297. this.objectMode = !!options.objectMode;
  65298. // cast to ints.
  65299. this.highWaterMark = ~~this.highWaterMark;
  65300. this.needDrain = false;
  65301. // at the start of calling end()
  65302. this.ending = false;
  65303. // when end() has been called, and returned
  65304. this.ended = false;
  65305. // when 'finish' is emitted
  65306. this.finished = false;
  65307. // should we decode strings into buffers before passing to _write?
  65308. // this is here so that some node-core streams can optimize string
  65309. // handling at a lower level.
  65310. var noDecode = options.decodeStrings === false;
  65311. this.decodeStrings = !noDecode;
  65312. // Crypto is kind of old and crusty. Historically, its default string
  65313. // encoding is 'binary' so we have to make this configurable.
  65314. // Everything else in the universe uses 'utf8', though.
  65315. this.defaultEncoding = options.defaultEncoding || 'utf8';
  65316. // not an actual buffer we keep track of, but a measurement
  65317. // of how much we're waiting to get pushed to some underlying
  65318. // socket or file.
  65319. this.length = 0;
  65320. // a flag to see when we're in the middle of a write.
  65321. this.writing = false;
  65322. // a flag to be able to tell if the onwrite cb is called immediately,
  65323. // or on a later tick. We set this to true at first, becuase any
  65324. // actions that shouldn't happen until "later" should generally also
  65325. // not happen before the first write call.
  65326. this.sync = true;
  65327. // a flag to know if we're processing previously buffered items, which
  65328. // may call the _write() callback in the same tick, so that we don't
  65329. // end up in an overlapped onwrite situation.
  65330. this.bufferProcessing = false;
  65331. // the callback that's passed to _write(chunk,cb)
  65332. this.onwrite = function(er) {
  65333. onwrite(stream, er);
  65334. };
  65335. // the callback that the user supplies to write(chunk,encoding,cb)
  65336. this.writecb = null;
  65337. // the amount that is being written when _write is called.
  65338. this.writelen = 0;
  65339. this.buffer = [];
  65340. // True if the error was already emitted and should not be thrown again
  65341. this.errorEmitted = false;
  65342. }
  65343. function Writable(options) {
  65344. var Duplex = __webpack_require__(219);
  65345. // Writable ctor is applied to Duplexes, though they're not
  65346. // instanceof Writable, they're instanceof Readable.
  65347. if (!(this instanceof Writable) && !(this instanceof Duplex))
  65348. return new Writable(options);
  65349. this._writableState = new WritableState(options, this);
  65350. // legacy.
  65351. this.writable = true;
  65352. Stream.call(this);
  65353. }
  65354. // Otherwise people can pipe Writable streams, which is just wrong.
  65355. Writable.prototype.pipe = function() {
  65356. this.emit('error', new Error('Cannot pipe. Not readable.'));
  65357. };
  65358. function writeAfterEnd(stream, state, cb) {
  65359. var er = new Error('write after end');
  65360. // TODO: defer error events consistently everywhere, not just the cb
  65361. stream.emit('error', er);
  65362. process.nextTick(function() {
  65363. cb(er);
  65364. });
  65365. }
  65366. // If we get something that is not a buffer, string, null, or undefined,
  65367. // and we're not in objectMode, then that's an error.
  65368. // Otherwise stream chunks are all considered to be of length=1, and the
  65369. // watermarks determine how many objects to keep in the buffer, rather than
  65370. // how many bytes or characters.
  65371. function validChunk(stream, state, chunk, cb) {
  65372. var valid = true;
  65373. if (!Buffer.isBuffer(chunk) &&
  65374. 'string' !== typeof chunk &&
  65375. chunk !== null &&
  65376. chunk !== undefined &&
  65377. !state.objectMode) {
  65378. var er = new TypeError('Invalid non-string/buffer chunk');
  65379. stream.emit('error', er);
  65380. process.nextTick(function() {
  65381. cb(er);
  65382. });
  65383. valid = false;
  65384. }
  65385. return valid;
  65386. }
  65387. Writable.prototype.write = function(chunk, encoding, cb) {
  65388. var state = this._writableState;
  65389. var ret = false;
  65390. if (typeof encoding === 'function') {
  65391. cb = encoding;
  65392. encoding = null;
  65393. }
  65394. if (Buffer.isBuffer(chunk))
  65395. encoding = 'buffer';
  65396. else if (!encoding)
  65397. encoding = state.defaultEncoding;
  65398. if (typeof cb !== 'function')
  65399. cb = function() {};
  65400. if (state.ended)
  65401. writeAfterEnd(this, state, cb);
  65402. else if (validChunk(this, state, chunk, cb))
  65403. ret = writeOrBuffer(this, state, chunk, encoding, cb);
  65404. return ret;
  65405. };
  65406. function decodeChunk(state, chunk, encoding) {
  65407. if (!state.objectMode &&
  65408. state.decodeStrings !== false &&
  65409. typeof chunk === 'string') {
  65410. chunk = new Buffer(chunk, encoding);
  65411. }
  65412. return chunk;
  65413. }
  65414. // if we're already writing something, then just put this
  65415. // in the queue, and wait our turn. Otherwise, call _write
  65416. // If we return false, then we need a drain event, so set that flag.
  65417. function writeOrBuffer(stream, state, chunk, encoding, cb) {
  65418. chunk = decodeChunk(state, chunk, encoding);
  65419. if (Buffer.isBuffer(chunk))
  65420. encoding = 'buffer';
  65421. var len = state.objectMode ? 1 : chunk.length;
  65422. state.length += len;
  65423. var ret = state.length < state.highWaterMark;
  65424. // we must ensure that previous needDrain will not be reset to false.
  65425. if (!ret)
  65426. state.needDrain = true;
  65427. if (state.writing)
  65428. state.buffer.push(new WriteReq(chunk, encoding, cb));
  65429. else
  65430. doWrite(stream, state, len, chunk, encoding, cb);
  65431. return ret;
  65432. }
  65433. function doWrite(stream, state, len, chunk, encoding, cb) {
  65434. state.writelen = len;
  65435. state.writecb = cb;
  65436. state.writing = true;
  65437. state.sync = true;
  65438. stream._write(chunk, encoding, state.onwrite);
  65439. state.sync = false;
  65440. }
  65441. function onwriteError(stream, state, sync, er, cb) {
  65442. if (sync)
  65443. process.nextTick(function() {
  65444. cb(er);
  65445. });
  65446. else
  65447. cb(er);
  65448. stream._writableState.errorEmitted = true;
  65449. stream.emit('error', er);
  65450. }
  65451. function onwriteStateUpdate(state) {
  65452. state.writing = false;
  65453. state.writecb = null;
  65454. state.length -= state.writelen;
  65455. state.writelen = 0;
  65456. }
  65457. function onwrite(stream, er) {
  65458. var state = stream._writableState;
  65459. var sync = state.sync;
  65460. var cb = state.writecb;
  65461. onwriteStateUpdate(state);
  65462. if (er)
  65463. onwriteError(stream, state, sync, er, cb);
  65464. else {
  65465. // Check if we're actually ready to finish, but don't emit yet
  65466. var finished = needFinish(stream, state);
  65467. if (!finished && !state.bufferProcessing && state.buffer.length)
  65468. clearBuffer(stream, state);
  65469. if (sync) {
  65470. process.nextTick(function() {
  65471. afterWrite(stream, state, finished, cb);
  65472. });
  65473. } else {
  65474. afterWrite(stream, state, finished, cb);
  65475. }
  65476. }
  65477. }
  65478. function afterWrite(stream, state, finished, cb) {
  65479. if (!finished)
  65480. onwriteDrain(stream, state);
  65481. cb();
  65482. if (finished)
  65483. finishMaybe(stream, state);
  65484. }
  65485. // Must force callback to be called on nextTick, so that we don't
  65486. // emit 'drain' before the write() consumer gets the 'false' return
  65487. // value, and has a chance to attach a 'drain' listener.
  65488. function onwriteDrain(stream, state) {
  65489. if (state.length === 0 && state.needDrain) {
  65490. state.needDrain = false;
  65491. stream.emit('drain');
  65492. }
  65493. }
  65494. // if there's something in the buffer waiting, then process it
  65495. function clearBuffer(stream, state) {
  65496. state.bufferProcessing = true;
  65497. for (var c = 0; c < state.buffer.length; c++) {
  65498. var entry = state.buffer[c];
  65499. var chunk = entry.chunk;
  65500. var encoding = entry.encoding;
  65501. var cb = entry.callback;
  65502. var len = state.objectMode ? 1 : chunk.length;
  65503. doWrite(stream, state, len, chunk, encoding, cb);
  65504. // if we didn't call the onwrite immediately, then
  65505. // it means that we need to wait until it does.
  65506. // also, that means that the chunk and cb are currently
  65507. // being processed, so move the buffer counter past them.
  65508. if (state.writing) {
  65509. c++;
  65510. break;
  65511. }
  65512. }
  65513. state.bufferProcessing = false;
  65514. if (c < state.buffer.length)
  65515. state.buffer = state.buffer.slice(c);
  65516. else
  65517. state.buffer.length = 0;
  65518. }
  65519. Writable.prototype._write = function(chunk, encoding, cb) {
  65520. cb(new Error('not implemented'));
  65521. };
  65522. Writable.prototype.end = function(chunk, encoding, cb) {
  65523. var state = this._writableState;
  65524. if (typeof chunk === 'function') {
  65525. cb = chunk;
  65526. chunk = null;
  65527. encoding = null;
  65528. } else if (typeof encoding === 'function') {
  65529. cb = encoding;
  65530. encoding = null;
  65531. }
  65532. if (typeof chunk !== 'undefined' && chunk !== null)
  65533. this.write(chunk, encoding);
  65534. // ignore unnecessary end() calls.
  65535. if (!state.ending && !state.finished)
  65536. endWritable(this, state, cb);
  65537. };
  65538. function needFinish(stream, state) {
  65539. return (state.ending &&
  65540. state.length === 0 &&
  65541. !state.finished &&
  65542. !state.writing);
  65543. }
  65544. function finishMaybe(stream, state) {
  65545. var need = needFinish(stream, state);
  65546. if (need) {
  65547. state.finished = true;
  65548. stream.emit('finish');
  65549. }
  65550. return need;
  65551. }
  65552. function endWritable(stream, state, cb) {
  65553. state.ending = true;
  65554. finishMaybe(stream, state);
  65555. if (cb) {
  65556. if (state.finished)
  65557. process.nextTick(cb);
  65558. else
  65559. stream.once('finish', cb);
  65560. }
  65561. state.ended = true;
  65562. }
  65563. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  65564. /***/ },
  65565. /* 571 */
  65566. /***/ function(module, exports, __webpack_require__) {
  65567. module.exports = __webpack_require__(569)
  65568. /***/ },
  65569. /* 572 */
  65570. /***/ function(module, exports, __webpack_require__) {
  65571. /* WEBPACK VAR INJECTION */(function(process) {var Transform = __webpack_require__(571)
  65572. , inherits = __webpack_require__(44).inherits
  65573. , xtend = __webpack_require__(98)
  65574. function DestroyableTransform(opts) {
  65575. Transform.call(this, opts)
  65576. this._destroyed = false
  65577. }
  65578. inherits(DestroyableTransform, Transform)
  65579. DestroyableTransform.prototype.destroy = function(err) {
  65580. if (this._destroyed) return
  65581. this._destroyed = true
  65582. var self = this
  65583. process.nextTick(function() {
  65584. if (err)
  65585. self.emit('error', err)
  65586. self.emit('close')
  65587. })
  65588. }
  65589. // a noop _transform function
  65590. function noop (chunk, enc, callback) {
  65591. callback(null, chunk)
  65592. }
  65593. // create a new export function, used by both the main export and
  65594. // the .ctor export, contains common logic for dealing with arguments
  65595. function through2 (construct) {
  65596. return function (options, transform, flush) {
  65597. if (typeof options == 'function') {
  65598. flush = transform
  65599. transform = options
  65600. options = {}
  65601. }
  65602. if (typeof transform != 'function')
  65603. transform = noop
  65604. if (typeof flush != 'function')
  65605. flush = null
  65606. return construct(options, transform, flush)
  65607. }
  65608. }
  65609. // main export, just make me a transform stream!
  65610. module.exports = through2(function (options, transform, flush) {
  65611. var t2 = new DestroyableTransform(options)
  65612. t2._transform = transform
  65613. if (flush)
  65614. t2._flush = flush
  65615. return t2
  65616. })
  65617. // make me a reusable prototype that I can `new`, or implicitly `new`
  65618. // with a constructor call
  65619. module.exports.ctor = through2(function (options, transform, flush) {
  65620. function Through2 (override) {
  65621. if (!(this instanceof Through2))
  65622. return new Through2(override)
  65623. this.options = xtend(options, override)
  65624. DestroyableTransform.call(this, this.options)
  65625. }
  65626. inherits(Through2, DestroyableTransform)
  65627. Through2.prototype._transform = transform
  65628. if (flush)
  65629. Through2.prototype._flush = flush
  65630. return Through2
  65631. })
  65632. module.exports.obj = through2(function (options, transform, flush) {
  65633. var t2 = new DestroyableTransform(xtend({ objectMode: true, highWaterMark: 16 }, options))
  65634. t2._transform = transform
  65635. if (flush)
  65636. t2._flush = flush
  65637. return t2
  65638. })
  65639. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  65640. /***/ },
  65641. /* 573 */
  65642. /***/ function(module, exports, __webpack_require__) {
  65643. //! stable.js 0.1.5, https://github.com/Two-Screen/stable
  65644. //! © 2014 Angry Bytes and contributors. MIT licensed.
  65645. (function() {
  65646. // A stable array sort, because `Array#sort()` is not guaranteed stable.
  65647. // This is an implementation of merge sort, without recursion.
  65648. var stable = function(arr, comp) {
  65649. return exec(arr.slice(), comp);
  65650. };
  65651. stable.inplace = function(arr, comp) {
  65652. var result = exec(arr, comp);
  65653. // This simply copies back if the result isn't in the original array,
  65654. // which happens on an odd number of passes.
  65655. if (result !== arr) {
  65656. pass(result, null, arr.length, arr);
  65657. }
  65658. return arr;
  65659. };
  65660. // Execute the sort using the input array and a second buffer as work space.
  65661. // Returns one of those two, containing the final result.
  65662. function exec(arr, comp) {
  65663. if (typeof(comp) !== 'function') {
  65664. comp = function(a, b) {
  65665. return String(a).localeCompare(b);
  65666. };
  65667. }
  65668. // Short-circuit when there's nothing to sort.
  65669. var len = arr.length;
  65670. if (len <= 1) {
  65671. return arr;
  65672. }
  65673. // Rather than dividing input, simply iterate chunks of 1, 2, 4, 8, etc.
  65674. // Chunks are the size of the left or right hand in merge sort.
  65675. // Stop when the left-hand covers all of the array.
  65676. var buffer = new Array(len);
  65677. for (var chk = 1; chk < len; chk *= 2) {
  65678. pass(arr, comp, chk, buffer);
  65679. var tmp = arr;
  65680. arr = buffer;
  65681. buffer = tmp;
  65682. }
  65683. return arr;
  65684. }
  65685. // Run a single pass with the given chunk size.
  65686. var pass = function(arr, comp, chk, result) {
  65687. var len = arr.length;
  65688. var i = 0;
  65689. // Step size / double chunk size.
  65690. var dbl = chk * 2;
  65691. // Bounds of the left and right chunks.
  65692. var l, r, e;
  65693. // Iterators over the left and right chunk.
  65694. var li, ri;
  65695. // Iterate over pairs of chunks.
  65696. for (l = 0; l < len; l += dbl) {
  65697. r = l + chk;
  65698. e = r + chk;
  65699. if (r > len) r = len;
  65700. if (e > len) e = len;
  65701. // Iterate both chunks in parallel.
  65702. li = l;
  65703. ri = r;
  65704. while (true) {
  65705. // Compare the chunks.
  65706. if (li < r && ri < e) {
  65707. // This works for a regular `sort()` compatible comparator,
  65708. // but also for a simple comparator like: `a > b`
  65709. if (comp(arr[li], arr[ri]) <= 0) {
  65710. result[i++] = arr[li++];
  65711. }
  65712. else {
  65713. result[i++] = arr[ri++];
  65714. }
  65715. }
  65716. // Nothing to compare, just flush what's left.
  65717. else if (li < r) {
  65718. result[i++] = arr[li++];
  65719. }
  65720. else if (ri < e) {
  65721. result[i++] = arr[ri++];
  65722. }
  65723. // Both iterators are at the chunk ends.
  65724. else {
  65725. break;
  65726. }
  65727. }
  65728. }
  65729. };
  65730. // Export using CommonJS or to the window.
  65731. if (true) {
  65732. module.exports = stable;
  65733. }
  65734. else {
  65735. window.stable = stable;
  65736. }
  65737. })();
  65738. /***/ },
  65739. /* 574 */
  65740. /***/ function(module, exports, __webpack_require__) {
  65741. /* WEBPACK VAR INJECTION */(function(Buffer, global, process) {var capability = __webpack_require__(221)
  65742. var inherits = __webpack_require__(2)
  65743. var response = __webpack_require__(575)
  65744. var stream = __webpack_require__(225)
  65745. var toArrayBuffer = __webpack_require__(577)
  65746. var IncomingMessage = response.IncomingMessage
  65747. var rStates = response.readyStates
  65748. function decideMode (preferBinary) {
  65749. if (capability.fetch) {
  65750. return 'fetch'
  65751. } else if (capability.mozchunkedarraybuffer) {
  65752. return 'moz-chunked-arraybuffer'
  65753. } else if (capability.msstream) {
  65754. return 'ms-stream'
  65755. } else if (capability.arraybuffer && preferBinary) {
  65756. return 'arraybuffer'
  65757. } else if (capability.vbArray && preferBinary) {
  65758. return 'text:vbarray'
  65759. } else {
  65760. return 'text'
  65761. }
  65762. }
  65763. var ClientRequest = module.exports = function (opts) {
  65764. var self = this
  65765. stream.Writable.call(self)
  65766. self._opts = opts
  65767. self._body = []
  65768. self._headers = {}
  65769. if (opts.auth)
  65770. self.setHeader('Authorization', 'Basic ' + new Buffer(opts.auth).toString('base64'))
  65771. Object.keys(opts.headers).forEach(function (name) {
  65772. self.setHeader(name, opts.headers[name])
  65773. })
  65774. var preferBinary
  65775. if (opts.mode === 'prefer-streaming') {
  65776. // If streaming is a high priority but binary compatibility and
  65777. // the accuracy of the 'content-type' header aren't
  65778. preferBinary = false
  65779. } else if (opts.mode === 'allow-wrong-content-type') {
  65780. // If streaming is more important than preserving the 'content-type' header
  65781. preferBinary = !capability.overrideMimeType
  65782. } else if (!opts.mode || opts.mode === 'default' || opts.mode === 'prefer-fast') {
  65783. // Use binary if text streaming may corrupt data or the content-type header, or for speed
  65784. preferBinary = true
  65785. } else {
  65786. throw new Error('Invalid value for opts.mode')
  65787. }
  65788. self._mode = decideMode(preferBinary)
  65789. self.on('finish', function () {
  65790. self._onFinish()
  65791. })
  65792. }
  65793. inherits(ClientRequest, stream.Writable)
  65794. ClientRequest.prototype.setHeader = function (name, value) {
  65795. var self = this
  65796. var lowerName = name.toLowerCase()
  65797. // This check is not necessary, but it prevents warnings from browsers about setting unsafe
  65798. // headers. To be honest I'm not entirely sure hiding these warnings is a good thing, but
  65799. // http-browserify did it, so I will too.
  65800. if (unsafeHeaders.indexOf(lowerName) !== -1)
  65801. return
  65802. self._headers[lowerName] = {
  65803. name: name,
  65804. value: value
  65805. }
  65806. }
  65807. ClientRequest.prototype.getHeader = function (name) {
  65808. var self = this
  65809. return self._headers[name.toLowerCase()].value
  65810. }
  65811. ClientRequest.prototype.removeHeader = function (name) {
  65812. var self = this
  65813. delete self._headers[name.toLowerCase()]
  65814. }
  65815. ClientRequest.prototype._onFinish = function () {
  65816. var self = this
  65817. if (self._destroyed)
  65818. return
  65819. var opts = self._opts
  65820. var headersObj = self._headers
  65821. var body
  65822. if (opts.method === 'POST' || opts.method === 'PUT' || opts.method === 'PATCH') {
  65823. if (capability.blobConstructor) {
  65824. body = new global.Blob(self._body.map(function (buffer) {
  65825. return toArrayBuffer(buffer)
  65826. }), {
  65827. type: (headersObj['content-type'] || {}).value || ''
  65828. })
  65829. } else {
  65830. // get utf8 string
  65831. body = Buffer.concat(self._body).toString()
  65832. }
  65833. }
  65834. if (self._mode === 'fetch') {
  65835. var headers = Object.keys(headersObj).map(function (name) {
  65836. return [headersObj[name].name, headersObj[name].value]
  65837. })
  65838. global.fetch(self._opts.url, {
  65839. method: self._opts.method,
  65840. headers: headers,
  65841. body: body,
  65842. mode: 'cors',
  65843. credentials: opts.withCredentials ? 'include' : 'same-origin'
  65844. }).then(function (response) {
  65845. self._fetchResponse = response
  65846. self._connect()
  65847. }, function (reason) {
  65848. self.emit('error', reason)
  65849. })
  65850. } else {
  65851. var xhr = self._xhr = new global.XMLHttpRequest()
  65852. try {
  65853. xhr.open(self._opts.method, self._opts.url, true)
  65854. } catch (err) {
  65855. process.nextTick(function () {
  65856. self.emit('error', err)
  65857. })
  65858. return
  65859. }
  65860. // Can't set responseType on really old browsers
  65861. if ('responseType' in xhr)
  65862. xhr.responseType = self._mode.split(':')[0]
  65863. if ('withCredentials' in xhr)
  65864. xhr.withCredentials = !!opts.withCredentials
  65865. if (self._mode === 'text' && 'overrideMimeType' in xhr)
  65866. xhr.overrideMimeType('text/plain; charset=x-user-defined')
  65867. Object.keys(headersObj).forEach(function (name) {
  65868. xhr.setRequestHeader(headersObj[name].name, headersObj[name].value)
  65869. })
  65870. self._response = null
  65871. xhr.onreadystatechange = function () {
  65872. switch (xhr.readyState) {
  65873. case rStates.LOADING:
  65874. case rStates.DONE:
  65875. self._onXHRProgress()
  65876. break
  65877. }
  65878. }
  65879. // Necessary for streaming in Firefox, since xhr.response is ONLY defined
  65880. // in onprogress, not in onreadystatechange with xhr.readyState = 3
  65881. if (self._mode === 'moz-chunked-arraybuffer') {
  65882. xhr.onprogress = function () {
  65883. self._onXHRProgress()
  65884. }
  65885. }
  65886. xhr.onerror = function () {
  65887. if (self._destroyed)
  65888. return
  65889. self.emit('error', new Error('XHR error'))
  65890. }
  65891. try {
  65892. xhr.send(body)
  65893. } catch (err) {
  65894. process.nextTick(function () {
  65895. self.emit('error', err)
  65896. })
  65897. return
  65898. }
  65899. }
  65900. }
  65901. /**
  65902. * Checks if xhr.status is readable and non-zero, indicating no error.
  65903. * Even though the spec says it should be available in readyState 3,
  65904. * accessing it throws an exception in IE8
  65905. */
  65906. function statusValid (xhr) {
  65907. try {
  65908. var status = xhr.status
  65909. return (status !== null && status !== 0)
  65910. } catch (e) {
  65911. return false
  65912. }
  65913. }
  65914. ClientRequest.prototype._onXHRProgress = function () {
  65915. var self = this
  65916. if (!statusValid(self._xhr) || self._destroyed)
  65917. return
  65918. if (!self._response)
  65919. self._connect()
  65920. self._response._onXHRProgress()
  65921. }
  65922. ClientRequest.prototype._connect = function () {
  65923. var self = this
  65924. if (self._destroyed)
  65925. return
  65926. self._response = new IncomingMessage(self._xhr, self._fetchResponse, self._mode)
  65927. self.emit('response', self._response)
  65928. }
  65929. ClientRequest.prototype._write = function (chunk, encoding, cb) {
  65930. var self = this
  65931. self._body.push(chunk)
  65932. cb()
  65933. }
  65934. ClientRequest.prototype.abort = ClientRequest.prototype.destroy = function () {
  65935. var self = this
  65936. self._destroyed = true
  65937. if (self._response)
  65938. self._response._destroyed = true
  65939. if (self._xhr)
  65940. self._xhr.abort()
  65941. // Currently, there isn't a way to truly abort a fetch.
  65942. // If you like bikeshedding, see https://github.com/whatwg/fetch/issues/27
  65943. }
  65944. ClientRequest.prototype.end = function (data, encoding, cb) {
  65945. var self = this
  65946. if (typeof data === 'function') {
  65947. cb = data
  65948. data = undefined
  65949. }
  65950. stream.Writable.prototype.end.call(self, data, encoding, cb)
  65951. }
  65952. ClientRequest.prototype.flushHeaders = function () {}
  65953. ClientRequest.prototype.setTimeout = function () {}
  65954. ClientRequest.prototype.setNoDelay = function () {}
  65955. ClientRequest.prototype.setSocketKeepAlive = function () {}
  65956. // Taken from http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader%28%29-method
  65957. var unsafeHeaders = [
  65958. 'accept-charset',
  65959. 'accept-encoding',
  65960. 'access-control-request-headers',
  65961. 'access-control-request-method',
  65962. 'connection',
  65963. 'content-length',
  65964. 'cookie',
  65965. 'cookie2',
  65966. 'date',
  65967. 'dnt',
  65968. 'expect',
  65969. 'host',
  65970. 'keep-alive',
  65971. 'origin',
  65972. 'referer',
  65973. 'te',
  65974. 'trailer',
  65975. 'transfer-encoding',
  65976. 'upgrade',
  65977. 'user-agent',
  65978. 'via'
  65979. ]
  65980. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1).Buffer, __webpack_require__(13), __webpack_require__(4)))
  65981. /***/ },
  65982. /* 575 */
  65983. /***/ function(module, exports, __webpack_require__) {
  65984. /* WEBPACK VAR INJECTION */(function(process, Buffer, global) {var capability = __webpack_require__(221)
  65985. var inherits = __webpack_require__(2)
  65986. var stream = __webpack_require__(225)
  65987. var rStates = exports.readyStates = {
  65988. UNSENT: 0,
  65989. OPENED: 1,
  65990. HEADERS_RECEIVED: 2,
  65991. LOADING: 3,
  65992. DONE: 4
  65993. }
  65994. var IncomingMessage = exports.IncomingMessage = function (xhr, response, mode) {
  65995. var self = this
  65996. stream.Readable.call(self)
  65997. self._mode = mode
  65998. self.headers = {}
  65999. self.rawHeaders = []
  66000. self.trailers = {}
  66001. self.rawTrailers = []
  66002. // Fake the 'close' event, but only once 'end' fires
  66003. self.on('end', function () {
  66004. // The nextTick is necessary to prevent the 'request' module from causing an infinite loop
  66005. process.nextTick(function () {
  66006. self.emit('close')
  66007. })
  66008. })
  66009. if (mode === 'fetch') {
  66010. self._fetchResponse = response
  66011. self.url = response.url
  66012. self.statusCode = response.status
  66013. self.statusMessage = response.statusText
  66014. // backwards compatible version of for (<item> of <iterable>):
  66015. // for (var <item>,_i,_it = <iterable>[Symbol.iterator](); <item> = (_i = _it.next()).value,!_i.done;)
  66016. for (var header, _i, _it = response.headers[Symbol.iterator](); header = (_i = _it.next()).value, !_i.done;) {
  66017. self.headers[header[0].toLowerCase()] = header[1]
  66018. self.rawHeaders.push(header[0], header[1])
  66019. }
  66020. // TODO: this doesn't respect backpressure. Once WritableStream is available, this can be fixed
  66021. var reader = response.body.getReader()
  66022. function read () {
  66023. reader.read().then(function (result) {
  66024. if (self._destroyed)
  66025. return
  66026. if (result.done) {
  66027. self.push(null)
  66028. return
  66029. }
  66030. self.push(new Buffer(result.value))
  66031. read()
  66032. })
  66033. }
  66034. read()
  66035. } else {
  66036. self._xhr = xhr
  66037. self._pos = 0
  66038. self.url = xhr.responseURL
  66039. self.statusCode = xhr.status
  66040. self.statusMessage = xhr.statusText
  66041. var headers = xhr.getAllResponseHeaders().split(/\r?\n/)
  66042. headers.forEach(function (header) {
  66043. var matches = header.match(/^([^:]+):\s*(.*)/)
  66044. if (matches) {
  66045. var key = matches[1].toLowerCase()
  66046. if (key === 'set-cookie') {
  66047. if (self.headers[key] === undefined) {
  66048. self.headers[key] = []
  66049. }
  66050. self.headers[key].push(matches[2])
  66051. } else if (self.headers[key] !== undefined) {
  66052. self.headers[key] += ', ' + matches[2]
  66053. } else {
  66054. self.headers[key] = matches[2]
  66055. }
  66056. self.rawHeaders.push(matches[1], matches[2])
  66057. }
  66058. })
  66059. self._charset = 'x-user-defined'
  66060. if (!capability.overrideMimeType) {
  66061. var mimeType = self.rawHeaders['mime-type']
  66062. if (mimeType) {
  66063. var charsetMatch = mimeType.match(/;\s*charset=([^;])(;|$)/)
  66064. if (charsetMatch) {
  66065. self._charset = charsetMatch[1].toLowerCase()
  66066. }
  66067. }
  66068. if (!self._charset)
  66069. self._charset = 'utf-8' // best guess
  66070. }
  66071. }
  66072. }
  66073. inherits(IncomingMessage, stream.Readable)
  66074. IncomingMessage.prototype._read = function () {}
  66075. IncomingMessage.prototype._onXHRProgress = function () {
  66076. var self = this
  66077. var xhr = self._xhr
  66078. var response = null
  66079. switch (self._mode) {
  66080. case 'text:vbarray': // For IE9
  66081. if (xhr.readyState !== rStates.DONE)
  66082. break
  66083. try {
  66084. // This fails in IE8
  66085. response = new global.VBArray(xhr.responseBody).toArray()
  66086. } catch (e) {}
  66087. if (response !== null) {
  66088. self.push(new Buffer(response))
  66089. break
  66090. }
  66091. // Falls through in IE8
  66092. case 'text':
  66093. try { // This will fail when readyState = 3 in IE9. Switch mode and wait for readyState = 4
  66094. response = xhr.responseText
  66095. } catch (e) {
  66096. self._mode = 'text:vbarray'
  66097. break
  66098. }
  66099. if (response.length > self._pos) {
  66100. var newData = response.substr(self._pos)
  66101. if (self._charset === 'x-user-defined') {
  66102. var buffer = new Buffer(newData.length)
  66103. for (var i = 0; i < newData.length; i++)
  66104. buffer[i] = newData.charCodeAt(i) & 0xff
  66105. self.push(buffer)
  66106. } else {
  66107. self.push(newData, self._charset)
  66108. }
  66109. self._pos = response.length
  66110. }
  66111. break
  66112. case 'arraybuffer':
  66113. if (xhr.readyState !== rStates.DONE)
  66114. break
  66115. response = xhr.response
  66116. self.push(new Buffer(new Uint8Array(response)))
  66117. break
  66118. case 'moz-chunked-arraybuffer': // take whole
  66119. response = xhr.response
  66120. if (xhr.readyState !== rStates.LOADING || !response)
  66121. break
  66122. self.push(new Buffer(new Uint8Array(response)))
  66123. break
  66124. case 'ms-stream':
  66125. response = xhr.response
  66126. if (xhr.readyState !== rStates.LOADING)
  66127. break
  66128. var reader = new global.MSStreamReader()
  66129. reader.onprogress = function () {
  66130. if (reader.result.byteLength > self._pos) {
  66131. self.push(new Buffer(new Uint8Array(reader.result.slice(self._pos))))
  66132. self._pos = reader.result.byteLength
  66133. }
  66134. }
  66135. reader.onload = function () {
  66136. self.push(null)
  66137. }
  66138. // reader.onerror = ??? // TODO: this
  66139. reader.readAsArrayBuffer(response)
  66140. break
  66141. }
  66142. // The ms-stream case handles end separately in reader.onload()
  66143. if (self._xhr.readyState === rStates.DONE && self._mode !== 'ms-stream') {
  66144. self.push(null)
  66145. }
  66146. }
  66147. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4), __webpack_require__(1).Buffer, __webpack_require__(13)))
  66148. /***/ },
  66149. /* 576 */
  66150. /***/ function(module, exports, __webpack_require__) {
  66151. "use strict";
  66152. // a passthrough stream.
  66153. // basically just the most minimal sort of Transform stream.
  66154. // Every written chunk gets output as-is.
  66155. 'use strict';
  66156. module.exports = PassThrough;
  66157. var Transform = __webpack_require__(223);
  66158. /*<replacement>*/
  66159. var util = __webpack_require__(14);
  66160. util.inherits = __webpack_require__(2);
  66161. /*</replacement>*/
  66162. util.inherits(PassThrough, Transform);
  66163. function PassThrough(options) {
  66164. if (!(this instanceof PassThrough)) return new PassThrough(options);
  66165. Transform.call(this, options);
  66166. }
  66167. PassThrough.prototype._transform = function (chunk, encoding, cb) {
  66168. cb(null, chunk);
  66169. };
  66170. /***/ },
  66171. /* 577 */
  66172. /***/ function(module, exports, __webpack_require__) {
  66173. var Buffer = __webpack_require__(1).Buffer
  66174. module.exports = function (buf) {
  66175. // If the buffer is backed by a Uint8Array, a faster version will work
  66176. if (buf instanceof Uint8Array) {
  66177. // If the buffer isn't a subarray, return the underlying ArrayBuffer
  66178. if (buf.byteOffset === 0 && buf.byteLength === buf.buffer.byteLength) {
  66179. return buf.buffer
  66180. } else if (typeof buf.buffer.slice === 'function') {
  66181. // Otherwise we need to get a proper copy
  66182. return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength)
  66183. }
  66184. }
  66185. if (Buffer.isBuffer(buf)) {
  66186. // This is the slow version that will work with any Buffer
  66187. // implementation (even in old browsers)
  66188. var arrayCopy = new Uint8Array(buf.length)
  66189. var len = buf.length
  66190. for (var i = 0; i < len; i++) {
  66191. arrayCopy[i] = buf[i]
  66192. }
  66193. return arrayCopy.buffer
  66194. } else {
  66195. throw new Error('Argument must be a Buffer')
  66196. }
  66197. }
  66198. /***/ },
  66199. /* 578 */
  66200. /***/ function(module, exports) {
  66201. "use strict";
  66202. 'use strict';
  66203. module.exports = {
  66204. isString: function(arg) {
  66205. return typeof(arg) === 'string';
  66206. },
  66207. isObject: function(arg) {
  66208. return typeof(arg) === 'object' && arg !== null;
  66209. },
  66210. isNull: function(arg) {
  66211. return arg === null;
  66212. },
  66213. isNullOrUndefined: function(arg) {
  66214. return arg == null;
  66215. }
  66216. };
  66217. /***/ },
  66218. /* 579 */
  66219. /***/ function(module, exports) {
  66220. module.exports = function isBuffer(arg) {
  66221. return arg && typeof arg === 'object'
  66222. && typeof arg.copy === 'function'
  66223. && typeof arg.fill === 'function'
  66224. && typeof arg.readUInt8 === 'function';
  66225. }
  66226. /***/ },
  66227. /* 580 */
  66228. /***/ function(module, exports) {
  66229. module.exports = read
  66230. var MSB = 0x80
  66231. , REST = 0x7F
  66232. function read(buf, offset) {
  66233. var res = 0
  66234. , offset = offset || 0
  66235. , shift = 0
  66236. , counter = offset
  66237. , b
  66238. , l = buf.length
  66239. do {
  66240. if(counter >= l) {
  66241. read.bytes = 0
  66242. read.bytesRead = 0 // DEPRECATED
  66243. return undefined
  66244. }
  66245. b = buf[counter++]
  66246. res += shift < 28
  66247. ? (b & REST) << shift
  66248. : (b & REST) * Math.pow(2, shift)
  66249. shift += 7
  66250. } while (b >= MSB)
  66251. read.bytes = counter - offset
  66252. return res
  66253. }
  66254. /***/ },
  66255. /* 581 */
  66256. /***/ function(module, exports) {
  66257. module.exports = encode
  66258. var MSB = 0x80
  66259. , REST = 0x7F
  66260. , MSBALL = ~REST
  66261. , INT = Math.pow(2, 31)
  66262. function encode(num, out, offset) {
  66263. out = out || []
  66264. offset = offset || 0
  66265. var oldOffset = offset
  66266. while(num >= INT) {
  66267. out[offset++] = (num & 0xFF) | MSB
  66268. num /= 128
  66269. }
  66270. while(num & MSBALL) {
  66271. out[offset++] = (num & 0xFF) | MSB
  66272. num >>>= 7
  66273. }
  66274. out[offset] = num | 0
  66275. encode.bytes = offset - oldOffset + 1
  66276. return out
  66277. }
  66278. /***/ },
  66279. /* 582 */
  66280. /***/ function(module, exports) {
  66281. var N1 = Math.pow(2, 7)
  66282. var N2 = Math.pow(2, 14)
  66283. var N3 = Math.pow(2, 21)
  66284. var N4 = Math.pow(2, 28)
  66285. var N5 = Math.pow(2, 35)
  66286. var N6 = Math.pow(2, 42)
  66287. var N7 = Math.pow(2, 49)
  66288. var N8 = Math.pow(2, 56)
  66289. var N9 = Math.pow(2, 63)
  66290. module.exports = function (value) {
  66291. return (
  66292. value < N1 ? 1
  66293. : value < N2 ? 2
  66294. : value < N3 ? 3
  66295. : value < N4 ? 4
  66296. : value < N5 ? 5
  66297. : value < N6 ? 6
  66298. : value < N7 ? 7
  66299. : value < N8 ? 8
  66300. : value < N9 ? 9
  66301. : 10
  66302. )
  66303. }
  66304. /***/ },
  66305. /* 583 */
  66306. /***/ function(module, exports, __webpack_require__) {
  66307. var indexOf = __webpack_require__(512);
  66308. var Object_keys = function (obj) {
  66309. if (Object.keys) return Object.keys(obj)
  66310. else {
  66311. var res = [];
  66312. for (var key in obj) res.push(key)
  66313. return res;
  66314. }
  66315. };
  66316. var forEach = function (xs, fn) {
  66317. if (xs.forEach) return xs.forEach(fn)
  66318. else for (var i = 0; i < xs.length; i++) {
  66319. fn(xs[i], i, xs);
  66320. }
  66321. };
  66322. var defineProp = (function() {
  66323. try {
  66324. Object.defineProperty({}, '_', {});
  66325. return function(obj, name, value) {
  66326. Object.defineProperty(obj, name, {
  66327. writable: true,
  66328. enumerable: false,
  66329. configurable: true,
  66330. value: value
  66331. })
  66332. };
  66333. } catch(e) {
  66334. return function(obj, name, value) {
  66335. obj[name] = value;
  66336. };
  66337. }
  66338. }());
  66339. var globals = ['Array', 'Boolean', 'Date', 'Error', 'EvalError', 'Function',
  66340. 'Infinity', 'JSON', 'Math', 'NaN', 'Number', 'Object', 'RangeError',
  66341. 'ReferenceError', 'RegExp', 'String', 'SyntaxError', 'TypeError', 'URIError',
  66342. 'decodeURI', 'decodeURIComponent', 'encodeURI', 'encodeURIComponent', 'escape',
  66343. 'eval', 'isFinite', 'isNaN', 'parseFloat', 'parseInt', 'undefined', 'unescape'];
  66344. function Context() {}
  66345. Context.prototype = {};
  66346. var Script = exports.Script = function NodeScript (code) {
  66347. if (!(this instanceof Script)) return new Script(code);
  66348. this.code = code;
  66349. };
  66350. Script.prototype.runInContext = function (context) {
  66351. if (!(context instanceof Context)) {
  66352. throw new TypeError("needs a 'context' argument.");
  66353. }
  66354. var iframe = document.createElement('iframe');
  66355. if (!iframe.style) iframe.style = {};
  66356. iframe.style.display = 'none';
  66357. document.body.appendChild(iframe);
  66358. var win = iframe.contentWindow;
  66359. var wEval = win.eval, wExecScript = win.execScript;
  66360. if (!wEval && wExecScript) {
  66361. // win.eval() magically appears when this is called in IE:
  66362. wExecScript.call(win, 'null');
  66363. wEval = win.eval;
  66364. }
  66365. forEach(Object_keys(context), function (key) {
  66366. win[key] = context[key];
  66367. });
  66368. forEach(globals, function (key) {
  66369. if (context[key]) {
  66370. win[key] = context[key];
  66371. }
  66372. });
  66373. var winKeys = Object_keys(win);
  66374. var res = wEval.call(win, this.code);
  66375. forEach(Object_keys(win), function (key) {
  66376. // Avoid copying circular objects like `top` and `window` by only
  66377. // updating existing context properties or new properties in the `win`
  66378. // that was only introduced after the eval.
  66379. if (key in context || indexOf(winKeys, key) === -1) {
  66380. context[key] = win[key];
  66381. }
  66382. });
  66383. forEach(globals, function (key) {
  66384. if (!(key in context)) {
  66385. defineProp(context, key, win[key]);
  66386. }
  66387. });
  66388. document.body.removeChild(iframe);
  66389. return res;
  66390. };
  66391. Script.prototype.runInThisContext = function () {
  66392. return eval(this.code); // maybe...
  66393. };
  66394. Script.prototype.runInNewContext = function (context) {
  66395. var ctx = Script.createContext(context);
  66396. var res = this.runInContext(ctx);
  66397. forEach(Object_keys(ctx), function (key) {
  66398. context[key] = ctx[key];
  66399. });
  66400. return res;
  66401. };
  66402. forEach(Object_keys(Script.prototype), function (name) {
  66403. exports[name] = Script[name] = function (code) {
  66404. var s = Script(code);
  66405. return s[name].apply(s, [].slice.call(arguments, 1));
  66406. };
  66407. });
  66408. exports.createScript = function (code) {
  66409. return exports.Script(code);
  66410. };
  66411. exports.createContext = Script.createContext = function (context) {
  66412. var copy = new Context();
  66413. if(typeof context === 'object') {
  66414. forEach(Object_keys(context), function (key) {
  66415. copy[key] = context[key];
  66416. });
  66417. }
  66418. return copy;
  66419. };
  66420. /***/ },
  66421. /* 584 */
  66422. /***/ function(module, exports, __webpack_require__) {
  66423. /* WEBPACK VAR INJECTION */(function(global) {var isNode = !global.window
  66424. if (isNode) {
  66425. module.exports = __webpack_require__(587)
  66426. } else {
  66427. module.exports = __webpack_require__(131)
  66428. }
  66429. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(13)))
  66430. /***/ },
  66431. /* 585 */
  66432. /***/ function(module, exports) {
  66433. /* (ignored) */
  66434. /***/ },
  66435. /* 586 */
  66436. /***/ function(module, exports) {
  66437. /* (ignored) */
  66438. /***/ },
  66439. /* 587 */
  66440. /***/ function(module, exports) {
  66441. /* (ignored) */
  66442. /***/ },
  66443. /* 588 */
  66444. /***/ function(module, exports, __webpack_require__) {
  66445. __webpack_require__(230);
  66446. module.exports = __webpack_require__(229);
  66447. /***/ }
  66448. /******/ ]);
  66449. //# sourceMappingURL=index.js.map
  66450. var EmbarkJS =
  66451. /******/ (function(modules) { // webpackBootstrap
  66452. /******/ // The module cache
  66453. /******/ var installedModules = {};
  66454. /******/ // The require function
  66455. /******/ function __webpack_require__(moduleId) {
  66456. /******/ // Check if module is in cache
  66457. /******/ if(installedModules[moduleId])
  66458. /******/ return installedModules[moduleId].exports;
  66459. /******/ // Create a new module (and put it into the cache)
  66460. /******/ var module = installedModules[moduleId] = {
  66461. /******/ exports: {},
  66462. /******/ id: moduleId,
  66463. /******/ loaded: false
  66464. /******/ };
  66465. /******/ // Execute the module function
  66466. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  66467. /******/ // Flag the module as loaded
  66468. /******/ module.loaded = true;
  66469. /******/ // Return the exports of the module
  66470. /******/ return module.exports;
  66471. /******/ }
  66472. /******/ // expose the modules object (__webpack_modules__)
  66473. /******/ __webpack_require__.m = modules;
  66474. /******/ // expose the module cache
  66475. /******/ __webpack_require__.c = installedModules;
  66476. /******/ // __webpack_public_path__
  66477. /******/ __webpack_require__.p = "";
  66478. /******/ // Load entry module and return exports
  66479. /******/ return __webpack_require__(0);
  66480. /******/ })
  66481. /************************************************************************/
  66482. /******/ ([
  66483. /* 0 */
  66484. /***/ function(module, exports) {
  66485. /*jshint esversion: 6 */
  66486. //var Ipfs = require('./ipfs.js');
  66487. var EmbarkJS = {
  66488. };
  66489. EmbarkJS.Contract = function(options) {
  66490. var self = this;
  66491. var i, abiElement;
  66492. this.abi = options.abi;
  66493. this.address = options.address;
  66494. this.code = '0x' + options.code;
  66495. this.web3 = options.web3 || web3;
  66496. var ContractClass = this.web3.eth.contract(this.abi);
  66497. this.eventList = [];
  66498. if (this.abi) {
  66499. for (i = 0; i < this.abi.length; i++) {
  66500. abiElement = this.abi[i];
  66501. if (abiElement.type === 'event') {
  66502. this.eventList.push(abiElement.name);
  66503. }
  66504. }
  66505. }
  66506. var messageEvents = function() {
  66507. this.cb = function() {};
  66508. };
  66509. messageEvents.prototype.then = function(cb) {
  66510. this.cb = cb;
  66511. };
  66512. messageEvents.prototype.error = function(err) {
  66513. return err;
  66514. };
  66515. this._originalContractObject = ContractClass.at(this.address);
  66516. this._methods = Object.getOwnPropertyNames(this._originalContractObject).filter(function (p) {
  66517. // TODO: check for forbidden properties
  66518. if (self.eventList.indexOf(p) >= 0) {
  66519. self[p] = function() {
  66520. var promise = new messageEvents();
  66521. var args = Array.prototype.slice.call(arguments);
  66522. args.push(function(err, result) {
  66523. if (err) {
  66524. promise.error(err);
  66525. } else {
  66526. promise.cb(result);
  66527. }
  66528. });
  66529. self._originalContractObject[p].apply(self._originalContractObject[p], args);
  66530. return promise;
  66531. };
  66532. return true;
  66533. } else if (typeof self._originalContractObject[p] === 'function') {
  66534. self[p] = function(_args) {
  66535. var args = Array.prototype.slice.call(arguments);
  66536. var fn = self._originalContractObject[p];
  66537. var props = self.abi.find((x) => x.name == p);
  66538. var promise = new Promise(function(resolve, reject) {
  66539. args.push(function(err, transaction) {
  66540. promise.tx = transaction;
  66541. if (err) {
  66542. return reject(err);
  66543. }
  66544. var getConfirmation = function() {
  66545. self.web3.eth.getTransactionReceipt(transaction, function(err, receipt) {
  66546. if (err) {
  66547. return reject(err);
  66548. }
  66549. if (receipt !== null) {
  66550. return resolve(receipt);
  66551. }
  66552. setTimeout(getConfirmation, 1000);
  66553. });
  66554. };
  66555. if (typeof(transaction) !== "string" || props.constant) {
  66556. resolve(transaction);
  66557. } else {
  66558. getConfirmation();
  66559. }
  66560. });
  66561. fn.apply(fn, args);
  66562. });
  66563. return promise;
  66564. };
  66565. return true;
  66566. }
  66567. return false;
  66568. });
  66569. };
  66570. EmbarkJS.Contract.prototype.deploy = function(args, _options) {
  66571. var self = this;
  66572. var contractParams;
  66573. var options = _options || {};
  66574. contractParams = args || [];
  66575. contractParams.push({
  66576. from: this.web3.eth.accounts[0],
  66577. data: this.code,
  66578. gas: options.gas || 800000
  66579. });
  66580. var contractObject = this.web3.eth.contract(this.abi);
  66581. var promise = new Promise(function(resolve, reject) {
  66582. contractParams.push(function(err, transaction) {
  66583. if (err) {
  66584. reject(err);
  66585. } else if (transaction.address !== undefined) {
  66586. resolve(new EmbarkJS.Contract({abi: self.abi, code: self.code, address: transaction.address}));
  66587. }
  66588. });
  66589. // returns promise
  66590. // deploys contract
  66591. // wraps it around EmbarkJS.Contract
  66592. contractObject["new"].apply(contractObject, contractParams);
  66593. });
  66594. return promise;
  66595. };
  66596. EmbarkJS.IPFS = 'ipfs';
  66597. EmbarkJS.Storage = {
  66598. };
  66599. EmbarkJS.Storage.setProvider = function(provider, options) {
  66600. if (provider === 'ipfs') {
  66601. this.currentStorage = EmbarkJS.Storage.IPFS;
  66602. if (options === undefined) {
  66603. this.ipfsConnection = IpfsApi('localhost', '5001');
  66604. } else {
  66605. this.ipfsConnection = IpfsApi(options.server, options.port);
  66606. }
  66607. } else {
  66608. throw Error('unknown provider');
  66609. }
  66610. };
  66611. EmbarkJS.Storage.saveText = function(text) {
  66612. var self = this;
  66613. if (!this.ipfsConnection) {
  66614. this.setProvider('ipfs');
  66615. }
  66616. var promise = new Promise(function(resolve, reject) {
  66617. self.ipfsConnection.add((new self.ipfsConnection.Buffer(text)), function(err, result) {
  66618. if (err) {
  66619. reject(err);
  66620. } else {
  66621. resolve(result[0].path);
  66622. }
  66623. });
  66624. });
  66625. return promise;
  66626. };
  66627. EmbarkJS.Storage.uploadFile = function(inputSelector) {
  66628. var self = this;
  66629. var file = inputSelector[0].files[0];
  66630. if (file === undefined) {
  66631. throw new Error('no file found');
  66632. }
  66633. if (!this.ipfsConnection) {
  66634. this.setProvider('ipfs');
  66635. }
  66636. var promise = new Promise(function(resolve, reject) {
  66637. var reader = new FileReader();
  66638. reader.onloadend = function() {
  66639. var fileContent = reader.result;
  66640. var buffer = self.ipfsConnection.Buffer.from(fileContent);
  66641. self.ipfsConnection.add(buffer, function(err, result) {
  66642. if (err) {
  66643. reject(err);
  66644. } else {
  66645. resolve(result[0].path);
  66646. }
  66647. });
  66648. };
  66649. reader.readAsArrayBuffer(file);
  66650. });
  66651. return promise;
  66652. };
  66653. EmbarkJS.Storage.get = function(hash) {
  66654. var self = this;
  66655. // TODO: detect type, then convert if needed
  66656. //var ipfsHash = web3.toAscii(hash);
  66657. if (!this.ipfsConnection) {
  66658. this.setProvider('ipfs');
  66659. }
  66660. var promise = new Promise(function(resolve, reject) {
  66661. self.ipfsConnection.object.get([hash]).then(function(node) {
  66662. resolve(node.data);
  66663. });
  66664. });
  66665. return promise;
  66666. };
  66667. EmbarkJS.Storage.getUrl = function(hash) {
  66668. //var ipfsHash = web3.toAscii(hash);
  66669. return 'http://localhost:8080/ipfs/' + hash;
  66670. };
  66671. EmbarkJS.Messages = {
  66672. };
  66673. EmbarkJS.Messages.setProvider = function(provider, options) {
  66674. var self = this;
  66675. var ipfs;
  66676. if (provider === 'whisper') {
  66677. this.currentMessages = EmbarkJS.Messages.Whisper;
  66678. if (typeof variable === 'undefined') {
  66679. if (options === undefined) {
  66680. web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
  66681. } else {
  66682. web3 = new Web3(new Web3.providers.HttpProvider("http://" + options.server + ':' + options.port));
  66683. }
  66684. }
  66685. web3.version.getWhisper(function(err, res) {
  66686. if (err) {
  66687. console.log("whisper not available");
  66688. } else {
  66689. self.currentMessages.identity = web3.shh.newIdentity();
  66690. }
  66691. });
  66692. } else if (provider === 'orbit') {
  66693. this.currentMessages = EmbarkJS.Messages.Orbit;
  66694. if (options === undefined) {
  66695. ipfs = HaadIpfsApi('localhost', '5001');
  66696. } else {
  66697. ipfs = HaadIpfsApi(options.server, options.port);
  66698. }
  66699. this.currentMessages.orbit = new Orbit(ipfs);
  66700. this.currentMessages.orbit.connect(web3.eth.accounts[0]);
  66701. } else {
  66702. throw Error('unknown provider');
  66703. }
  66704. };
  66705. EmbarkJS.Messages.sendMessage = function(options) {
  66706. return this.currentMessages.sendMessage(options);
  66707. };
  66708. EmbarkJS.Messages.listenTo = function(options) {
  66709. return this.currentMessages.listenTo(options);
  66710. };
  66711. EmbarkJS.Messages.Whisper = {
  66712. };
  66713. EmbarkJS.Messages.Whisper.sendMessage = function(options) {
  66714. var topics = options.topic || options.topics;
  66715. var data = options.data || options.payload;
  66716. var identity = options.identity || this.identity || web3.shh.newIdentity();
  66717. var ttl = options.ttl || 100;
  66718. var priority = options.priority || 1000;
  66719. var _topics;
  66720. if (topics === undefined) {
  66721. throw new Error("missing option: topic");
  66722. }
  66723. if (data === undefined) {
  66724. throw new Error("missing option: data");
  66725. }
  66726. // do fromAscii to each topics unless it's already a string
  66727. if (typeof topics === 'string') {
  66728. _topics = [web3.fromAscii(topics)];
  66729. } else {
  66730. // TODO: replace with es6 + babel;
  66731. for (var i = 0; i < topics.length; i++) {
  66732. _topics.push(web3.fromAscii(topics[i]));
  66733. }
  66734. }
  66735. topics = _topics;
  66736. var payload = JSON.stringify(data);
  66737. var message = {
  66738. from: identity,
  66739. topics: topics,
  66740. payload: web3.fromAscii(payload),
  66741. ttl: ttl,
  66742. priority: priority
  66743. };
  66744. return web3.shh.post(message, function() {});
  66745. };
  66746. EmbarkJS.Messages.Whisper.listenTo = function(options) {
  66747. var topics = options.topic || options.topics;
  66748. var _topics = [];
  66749. if (typeof topics === 'string') {
  66750. _topics = [topics];
  66751. } else {
  66752. // TODO: replace with es6 + babel;
  66753. for (var i = 0; i < topics.length; i++) {
  66754. _topics.push(topics[i]);
  66755. }
  66756. }
  66757. topics = _topics;
  66758. var filterOptions = {
  66759. topics: topics
  66760. };
  66761. var messageEvents = function() {
  66762. this.cb = function() {};
  66763. };
  66764. messageEvents.prototype.then = function(cb) {
  66765. this.cb = cb;
  66766. };
  66767. messageEvents.prototype.error = function(err) {
  66768. return err;
  66769. };
  66770. messageEvents.prototype.stop = function() {
  66771. this.filter.stopWatching();
  66772. };
  66773. var promise = new messageEvents();
  66774. var filter = web3.shh.filter(filterOptions, function(err, result) {
  66775. var payload = JSON.parse(web3.toAscii(result.payload));
  66776. var data;
  66777. if (err) {
  66778. promise.error(err);
  66779. } else {
  66780. data = {
  66781. topic: topics,
  66782. data: payload,
  66783. from: result.from,
  66784. time: (new Date(result.sent * 1000))
  66785. };
  66786. promise.cb(payload, data, result);
  66787. }
  66788. });
  66789. promise.filter = filter;
  66790. return promise;
  66791. };
  66792. EmbarkJS.Messages.Orbit = {
  66793. };
  66794. EmbarkJS.Messages.Orbit.sendMessage = function(options) {
  66795. var topics = options.topic || options.topics;
  66796. var data = options.data || options.payload;
  66797. if (topics === undefined) {
  66798. throw new Error("missing option: topic");
  66799. }
  66800. if (data === undefined) {
  66801. throw new Error("missing option: data");
  66802. }
  66803. if (typeof topics === 'string') {
  66804. topics = topics;
  66805. } else {
  66806. // TODO: better to just send to different channels instead
  66807. topics = topics.join(',');
  66808. }
  66809. this.orbit.join(topics);
  66810. var payload = JSON.stringify(data);
  66811. this.orbit.send(topics, data);
  66812. };
  66813. EmbarkJS.Messages.Orbit.listenTo = function(options) {
  66814. var self = this;
  66815. var topics = options.topic || options.topics;
  66816. if (typeof topics === 'string') {
  66817. topics = topics;
  66818. } else {
  66819. topics = topics.join(',');
  66820. }
  66821. this.orbit.join(topics);
  66822. var messageEvents = function() {
  66823. this.cb = function() {};
  66824. };
  66825. messageEvents.prototype.then = function(cb) {
  66826. this.cb = cb;
  66827. };
  66828. messageEvents.prototype.error = function(err) {
  66829. return err;
  66830. };
  66831. var promise = new messageEvents();
  66832. this.orbit.events.on('message', (channel, message) => {
  66833. // TODO: looks like sometimes it's receving messages from all topics
  66834. if (topics !== channel) return;
  66835. self.orbit.getPost(message.payload.value, true).then((post) => {
  66836. var data = {
  66837. topic: channel,
  66838. data: post.content,
  66839. from: post.meta.from.name,
  66840. time: (new Date(post.meta.ts))
  66841. };
  66842. promise.cb(post.content, data, post);
  66843. });
  66844. });
  66845. return promise;
  66846. };
  66847. module.exports = EmbarkJS;
  66848. /***/ }
  66849. /******/ ]);
  66850. if (typeof web3 !== 'undefined' && typeof Web3 !== 'undefined') {
  66851. web3 = new Web3(web3.currentProvider);
  66852. } else if (typeof Web3 !== 'undefined') {
  66853. web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
  66854. }
  66855. web3.eth.defaultAccount = web3.eth.accounts[0];
  66856. Move = new EmbarkJS.Contract({abi: [], address: '0xe609402b206bc80516cff106b2bc5ab530a0f886', code: '6060604052346000575b60358060166000396000f30060606040525b60005600a165627a7a72305820dc0fd30165702693e33a6777c52dcccacc439e55f147652d92a061e21edf7b000029', gasEstimates: {"creation":[58,10600],"external":{},"internal":{}}});
  66857. Padomima = new EmbarkJS.Contract({abi: [{"constant":true,"inputs":[],"name":"getMapRotation","outputs":[{"name":"","type":"uint8"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"getMyMatch","outputs":[{"name":"hash","type":"bytes32"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"amInMatch","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"getMyMap","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"getMyStake","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"claimEmptyMatch","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"getMyOpponent","outputs":[{"name":"hash","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"hash","type":"bytes32"}],"name":"joinMatch","outputs":[],"payable":true,"type":"function"},{"constant":false,"inputs":[],"name":"createMatch","outputs":[],"payable":true,"type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"changeOwner","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"hash","type":"bytes32"},{"name":"sig","type":"bytes"}],"name":"sig_verify","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"inputs":[],"payable":false,"type":"constructor"}], address: '0xaba7e3659fd63a70a680170e60ba5cdd16e4f87b', code: '606060405260008054600160a060020a03191633600160a060020a031617905534610000575b5b5b6107ab806100366000396000f300606060405236156100935763ffffffff60e060020a60003504166323802e69811461009857806325b2bbd1146100bb5780633d71901f146100da5780634207a2f5146100fb5780635499dca51461011a57806363487567146101395780638032de4b146101485780639ff6944214610171578063a0cc641a1461017e578063a6f9dae114610188578063b840efb8146101a3575b610000565b34610000576100a5610213565b6040805160ff9092168252519081900360200190f35b34610000576100c8610271565b60408051918252519081900360200190f35b34610000576100e76102a4565b604080519115158252519081900360200190f35b34610000576100c86102c3565b60408051918252519081900360200190f35b34610000576100c8610327565b60408051918252519081900360200190f35b346100005761014661036a565b005b3461000057610155610485565b60408051600160a060020a039092168252519081900360200190f35b6101466004356104f8565b005b6101466105c7565b005b3461000057610146600160a060020a03600435166106b6565b005b346100005760408051602060046024803582810135601f810185900485028601850190965285855261015595833595939460449493929092019181908401838280828437509496506106ed95505050505050565b60408051600160a060020a039092168252519081900360200190f35b6000600061021f6102a4565b151561022a57610000565b50600160a060020a0333811660008181526001602081815260408084205484526002909152909120908101549092161415610268576001915061026d565b600091505b5090565b600061027b6102a4565b151561028657610000565b50600160a060020a0333166000908152600160205260409020545b90565b600160a060020a03331660009081526001602052604090205415155b90565b600160a060020a03338116600090815260016020818152604080842054845260029091529182902080549181015483516c0100000000000000000000000093861684028152941691909102601484015290519182900360280190912090815b505090565b60006103316102a4565b151561033c57610000565b50600160a060020a033316600090815260016020908152604080832054835260029182905290912001545b90565b600160a060020a033316600090815260016020526040812054151561038e57610000565b50600160a060020a03338116600081815260016020908152604080832054808452600290925290912054909216146103c557610000565b600081815260026020526040902060010154600160a060020a0316156103ea57610000565b6000818152600260208190526040808320909101549051600160a060020a0333169282156108fc02929190818181858888f19350505050151561042c57610000565b600160a060020a033316600090815260016020818152604080842084905584845260029182905283208054600160a060020a031990811682559281018054909316909255810191909155600301805460ff191690555b50565b600060006104916102a4565b151561049c57610000565b50600160a060020a03338116600081815260016020818152604080842054845260029091529091209081015490921614156104e3578054600160a060020a0316915061026d565b6001810154600160a060020a031691505b5090565b6000818152600260208190526040909120015434101561051757610000565b600160a060020a0333166000908152600160205260409020541561053a57610000565b600081815260026020526040902060010154600160a060020a03161561055f57610000565b60008181526002602052604090205433600160a060020a039081169116141561058757610000565b600081815260026020908152604080832060019081018054600160a060020a03191633600160a060020a0316908117909155845290915290208190555b50565b600066b1a2bc2ec500003410156105dd57610000565b600160a060020a0333166000908152600160205260409020541561060057610000565b50604080516c01000000000000000000000000600160a060020a033381169182028352835192839003601401832060008381526001602081815287832084905560808701885294865284860182815234878901908152606088018481528585526002978890529890932096518754908616600160a060020a0319918216178855905191870180549290951691161790925590519183019190915591516003909101805491151560ff199092169190911790555b50565b60005433600160a060020a03908116911614156104825760008054600160a060020a031916600160a060020a0383161790555b5b50565b6020810151604082015160608301516000929190831a601b60ff8216101561071357601b015b60408051600081815260208083018452918301819052825189815260ff85168184015280840187905260608101869052925160019360808082019493601f19840193928390039091019190866161da5a03f1156100005750506020604051035193505b505050929150505600a165627a7a72305820c4e94f8e8e257e033bbf5a5d28ca1e244b098d8816959290dd2e850abcea64c90029', gasEstimates: {"creation":[20561,392600],"external":{"amInMatch()":402,"changeOwner(address)":20643,"claimEmptyMatch()":null,"createMatch()":101235,"getMapRotation()":759,"getMyMap()":754,"getMyMatch()":583,"getMyOpponent()":1005,"getMyStake()":780,"joinMatch(bytes32)":41279,"sig_verify(bytes32,bytes)":null},"internal":{}}});
  66858. EmbarkJS.Storage.setProvider('ipfs', {server: 'localhost', port: '5001'});
  66859. EmbarkJS.Messages.setProvider('whisper');
  66860. /*! jQuery v1.11.3 | (c) 2005, 2015 jQuery Foundation, Inc. | jquery.org/license */
  66861. !function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l="1.11.3",m=function(a,b){return new m.fn.init(a,b)},n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,o=/^-ms-/,p=/-([\da-z])/gi,q=function(a,b){return b.toUpperCase()};m.fn=m.prototype={jquery:l,constructor:m,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=m.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return m.each(this,a,b)},map:function(a){return this.pushStack(m.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},m.extend=m.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||m.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(m.isPlainObject(c)||(b=m.isArray(c)))?(b?(b=!1,f=a&&m.isArray(a)?a:[]):f=a&&m.isPlainObject(a)?a:{},g[d]=m.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},m.extend({expando:"jQuery"+(l+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===m.type(a)},isArray:Array.isArray||function(a){return"array"===m.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return!m.isArray(a)&&a-parseFloat(a)+1>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==m.type(a)||a.nodeType||m.isWindow(a))return!1;try{if(a.constructor&&!j.call(a,"constructor")&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(k.ownLast)for(b in a)return j.call(a,b);for(b in a);return void 0===b||j.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(b){b&&m.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(o,"ms-").replace(p,q)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=r(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(n,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(r(Object(a))?m.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(g)return g.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=r(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(f=a[b],b=a,a=f),m.isFunction(a)?(c=d.call(arguments,2),e=function(){return a.apply(b||this,c.concat(d.call(arguments)))},e.guid=a.guid=a.guid||m.guid++,e):void 0},now:function(){return+new Date},support:k}),m.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function r(a){var b="length"in a&&a.length,c=m.type(a);return"function"===c||m.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var s=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ha(),z=ha(),A=ha(),B=function(a,b){return a===b&&(l=!0),0},C=1<<31,D={}.hasOwnProperty,E=[],F=E.pop,G=E.push,H=E.push,I=E.slice,J=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},K="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",L="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",N=M.replace("w","w#"),O="\\["+L+"*("+M+")(?:"+L+"*([*^$|!~]?=)"+L+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+N+"))|)"+L+"*\\]",P=":("+M+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+O+")*)|.*)\\)|)",Q=new RegExp(L+"+","g"),R=new RegExp("^"+L+"+|((?:^|[^\\\\])(?:\\\\.)*)"+L+"+$","g"),S=new RegExp("^"+L+"*,"+L+"*"),T=new RegExp("^"+L+"*([>+~]|"+L+")"+L+"*"),U=new RegExp("="+L+"*([^\\]'\"]*?)"+L+"*\\]","g"),V=new RegExp(P),W=new RegExp("^"+N+"$"),X={ID:new RegExp("^#("+M+")"),CLASS:new RegExp("^\\.("+M+")"),TAG:new RegExp("^("+M.replace("w","w*")+")"),ATTR:new RegExp("^"+O),PSEUDO:new RegExp("^"+P),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+L+"*(even|odd|(([+-]|)(\\d*)n|)"+L+"*(?:([+-]|)"+L+"*(\\d+)|))"+L+"*\\)|)","i"),bool:new RegExp("^(?:"+K+")$","i"),needsContext:new RegExp("^"+L+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+L+"*((?:-\\d)?\\d*)"+L+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,aa=/[+~]/,ba=/'|\\/g,ca=new RegExp("\\\\([\\da-f]{1,6}"+L+"?|("+L+")|.)","ig"),da=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},ea=function(){m()};try{H.apply(E=I.call(v.childNodes),v.childNodes),E[v.childNodes.length].nodeType}catch(fa){H={apply:E.length?function(a,b){G.apply(a,I.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function ga(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],k=b.nodeType,"string"!=typeof a||!a||1!==k&&9!==k&&11!==k)return d;if(!e&&p){if(11!==k&&(f=_.exec(a)))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return H.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName)return H.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=1!==k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(ba,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+ra(o[l]);w=aa.test(a)&&pa(b.parentNode)||b,x=o.join(",")}if(x)try{return H.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function ha(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function ia(a){return a[u]=!0,a}function ja(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function ka(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function la(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||C)-(~a.sourceIndex||C);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function ma(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function na(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function oa(a){return ia(function(b){return b=+b,ia(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function pa(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}c=ga.support={},f=ga.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=ga.setDocument=function(a){var b,e,g=a?a.ownerDocument||a:v;return g!==n&&9===g.nodeType&&g.documentElement?(n=g,o=g.documentElement,e=g.defaultView,e&&e!==e.top&&(e.addEventListener?e.addEventListener("unload",ea,!1):e.attachEvent&&e.attachEvent("onunload",ea)),p=!f(g),c.attributes=ja(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ja(function(a){return a.appendChild(g.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(g.getElementsByClassName),c.getById=ja(function(a){return o.appendChild(a).id=u,!g.getElementsByName||!g.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(ca,da);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(ca,da);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):c.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(g.querySelectorAll))&&(ja(function(a){o.appendChild(a).innerHTML="<a id='"+u+"'></a><select id='"+u+"-\f]' msallowcapture=''><option selected=''></option></select>",a.querySelectorAll("[msallowcapture^='']").length&&q.push("[*^$]="+L+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+L+"*(?:value|"+K+")"),a.querySelectorAll("[id~="+u+"-]").length||q.push("~="),a.querySelectorAll(":checked").length||q.push(":checked"),a.querySelectorAll("a#"+u+"+*").length||q.push(".#.+[+~]")}),ja(function(a){var b=g.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+L+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ja(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",P)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===g||a.ownerDocument===v&&t(v,a)?-1:b===g||b.ownerDocument===v&&t(v,b)?1:k?J(k,a)-J(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,h=[a],i=[b];if(!e||!f)return a===g?-1:b===g?1:e?-1:f?1:k?J(k,a)-J(k,b):0;if(e===f)return la(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?la(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},g):n},ga.matches=function(a,b){return ga(a,null,null,b)},ga.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return ga(b,n,null,[a]).length>0},ga.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},ga.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&D.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},ga.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},ga.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=ga.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=ga.selectors={cacheLength:50,createPseudo:ia,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(ca,da),a[3]=(a[3]||a[4]||a[5]||"").replace(ca,da),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||ga.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&ga.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(ca,da).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+L+")"+a+"("+L+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=ga.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e.replace(Q," ")+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||ga.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ia(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=J(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ia(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?ia(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ia(function(a){return function(b){return ga(a,b).length>0}}),contains:ia(function(a){return a=a.replace(ca,da),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ia(function(a){return W.test(a||"")||ga.error("unsupported lang: "+a),a=a.replace(ca,da).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:oa(function(){return[0]}),last:oa(function(a,b){return[b-1]}),eq:oa(function(a,b,c){return[0>c?c+b:c]}),even:oa(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:oa(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:oa(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:oa(function(a,b,c){for(var d=0>c?c+b:c;++d<b;)a.push(d);return a})}},d.pseudos.nth=d.pseudos.eq;for(b in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})d.pseudos[b]=ma(b);for(b in{submit:!0,reset:!0})d.pseudos[b]=na(b);function qa(){}qa.prototype=d.filters=d.pseudos,d.setFilters=new qa,g=ga.tokenize=function(a,b){var c,e,f,g,h,i,j,k=z[a+" "];if(k)return b?0:k.slice(0);h=a,i=[],j=d.preFilter;while(h){(!c||(e=S.exec(h)))&&(e&&(h=h.slice(e[0].length)||h),i.push(f=[])),c=!1,(e=T.exec(h))&&(c=e.shift(),f.push({value:c,type:e[0].replace(R," ")}),h=h.slice(c.length));for(g in d.filter)!(e=X[g].exec(h))||j[g]&&!(e=j[g](e))||(c=e.shift(),f.push({value:c,type:g,matches:e}),h=h.slice(c.length));if(!c)break}return b?h.length:h?ga.error(a):z(a,i).slice(0)};function ra(a){for(var b=0,c=a.length,d="";c>b;b++)d+=a[b].value;return d}function sa(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function ta(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function ua(a,b,c){for(var d=0,e=b.length;e>d;d++)ga(a,b[d],c);return c}function va(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function wa(a,b,c,d,e,f){return d&&!d[u]&&(d=wa(d)),e&&!e[u]&&(e=wa(e,f)),ia(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||ua(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:va(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=va(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?J(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=va(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):H.apply(g,r)})}function xa(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=sa(function(a){return a===b},h,!0),l=sa(function(a){return J(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];f>i;i++)if(c=d.relative[a[i].type])m=[sa(ta(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return wa(i>1&&ta(m),i>1&&ra(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&xa(a.slice(i,e)),f>e&&xa(a=a.slice(e)),f>e&&ra(a))}m.push(c)}return ta(m)}function ya(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=F.call(i));s=va(s)}H.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&ga.uniqueSort(i)}return k&&(w=v,j=t),r};return c?ia(f):f}return h=ga.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=xa(b[c]),f[u]?d.push(f):e.push(f);f=A(a,ya(e,d)),f.selector=a}return f},i=ga.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(ca,da),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(ca,da),aa.test(j[0].type)&&pa(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&ra(j),!a)return H.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,aa.test(a)&&pa(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ja(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ja(function(a){return a.innerHTML="<a href='#'></a>","#"===a.firstChild.getAttribute("href")})||ka("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ja(function(a){return a.innerHTML="<input/>",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||ka("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ja(function(a){return null==a.getAttribute("disabled")})||ka(K,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),ga}(a);m.find=s,m.expr=s.selectors,m.expr[":"]=m.expr.pseudos,m.unique=s.uniqueSort,m.text=s.getText,m.isXMLDoc=s.isXML,m.contains=s.contains;var t=m.expr.match.needsContext,u=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,v=/^.[^:#\[\.,]*$/;function w(a,b,c){if(m.isFunction(b))return m.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return m.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(v.test(b))return m.filter(b,a,c);b=m.filter(b,a)}return m.grep(a,function(a){return m.inArray(a,b)>=0!==c})}m.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?m.find.matchesSelector(d,a)?[d]:[]:m.find.matches(a,m.grep(b,function(a){return 1===a.nodeType}))},m.fn.extend({find:function(a){var b,c=[],d=this,e=d.length;if("string"!=typeof a)return this.pushStack(m(a).filter(function(){for(b=0;e>b;b++)if(m.contains(d[b],this))return!0}));for(b=0;e>b;b++)m.find(a,d[b],c);return c=this.pushStack(e>1?m.unique(c):c),c.selector=this.selector?this.selector+" "+a:a,c},filter:function(a){return this.pushStack(w(this,a||[],!1))},not:function(a){return this.pushStack(w(this,a||[],!0))},is:function(a){return!!w(this,"string"==typeof a&&t.test(a)?m(a):a||[],!1).length}});var x,y=a.document,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=m.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a.charAt(0)&&">"===a.charAt(a.length-1)&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||x).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof m?b[0]:b,m.merge(this,m.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:y,!0)),u.test(c[1])&&m.isPlainObject(b))for(c in b)m.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}if(d=y.getElementById(c[2]),d&&d.parentNode){if(d.id!==c[2])return x.find(a);this.length=1,this[0]=d}return this.context=y,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):m.isFunction(a)?"undefined"!=typeof x.ready?x.ready(a):a(m):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),m.makeArray(a,this))};A.prototype=m.fn,x=m(y);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};m.extend({dir:function(a,b,c){var d=[],e=a[b];while(e&&9!==e.nodeType&&(void 0===c||1!==e.nodeType||!m(e).is(c)))1===e.nodeType&&d.push(e),e=e[b];return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),m.fn.extend({has:function(a){var b,c=m(a,this),d=c.length;return this.filter(function(){for(b=0;d>b;b++)if(m.contains(this,c[b]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=t.test(a)||"string"!=typeof a?m(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&m.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?m.unique(f):f)},index:function(a){return a?"string"==typeof a?m.inArray(this[0],m(a)):m.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(m.unique(m.merge(this.get(),m(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){do a=a[b];while(a&&1!==a.nodeType);return a}m.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return m.dir(a,"parentNode")},parentsUntil:function(a,b,c){return m.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return m.dir(a,"nextSibling")},prevAll:function(a){return m.dir(a,"previousSibling")},nextUntil:function(a,b,c){return m.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return m.dir(a,"previousSibling",c)},siblings:function(a){return m.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return m.sibling(a.firstChild)},contents:function(a){return m.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:m.merge([],a.childNodes)}},function(a,b){m.fn[a]=function(c,d){var e=m.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=m.filter(d,e)),this.length>1&&(C[a]||(e=m.unique(e)),B.test(a)&&(e=e.reverse())),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return m.each(a.match(E)||[],function(a,c){b[c]=!0}),b}m.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):m.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(c=a.memory&&l,d=!0,f=g||0,g=0,e=h.length,b=!0;h&&e>f;f++)if(h[f].apply(l[0],l[1])===!1&&a.stopOnFalse){c=!1;break}b=!1,h&&(i?i.length&&j(i.shift()):c?h=[]:k.disable())},k={add:function(){if(h){var d=h.length;!function f(b){m.each(b,function(b,c){var d=m.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&f(c)})}(arguments),b?e=h.length:c&&(g=d,j(c))}return this},remove:function(){return h&&m.each(arguments,function(a,c){var d;while((d=m.inArray(c,h,d))>-1)h.splice(d,1),b&&(e>=d&&e--,f>=d&&f--)}),this},has:function(a){return a?m.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],e=0,this},disable:function(){return h=i=c=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,c||k.disable(),this},locked:function(){return!i},fireWith:function(a,c){return!h||d&&!i||(c=c||[],c=[a,c.slice?c.slice():c],b?i.push(c):j(c)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!d}};return k},m.extend({Deferred:function(a){var b=[["resolve","done",m.Callbacks("once memory"),"resolved"],["reject","fail",m.Callbacks("once memory"),"rejected"],["notify","progress",m.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return m.Deferred(function(c){m.each(b,function(b,f){var g=m.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&m.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?m.extend(a,d):d}},e={};return d.pipe=d.then,m.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&m.isFunction(a.promise)?e:0,g=1===f?a:m.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&m.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;m.fn.ready=function(a){return m.ready.promise().done(a),this},m.extend({isReady:!1,readyWait:1,holdReady:function(a){a?m.readyWait++:m.ready(!0)},ready:function(a){if(a===!0?!--m.readyWait:!m.isReady){if(!y.body)return setTimeout(m.ready);m.isReady=!0,a!==!0&&--m.readyWait>0||(H.resolveWith(y,[m]),m.fn.triggerHandler&&(m(y).triggerHandler("ready"),m(y).off("ready")))}}});function I(){y.addEventListener?(y.removeEventListener("DOMContentLoaded",J,!1),a.removeEventListener("load",J,!1)):(y.detachEvent("onreadystatechange",J),a.detachEvent("onload",J))}function J(){(y.addEventListener||"load"===event.type||"complete"===y.readyState)&&(I(),m.ready())}m.ready.promise=function(b){if(!H)if(H=m.Deferred(),"complete"===y.readyState)setTimeout(m.ready);else if(y.addEventListener)y.addEventListener("DOMContentLoaded",J,!1),a.addEventListener("load",J,!1);else{y.attachEvent("onreadystatechange",J),a.attachEvent("onload",J);var c=!1;try{c=null==a.frameElement&&y.documentElement}catch(d){}c&&c.doScroll&&!function e(){if(!m.isReady){try{c.doScroll("left")}catch(a){return setTimeout(e,50)}I(),m.ready()}}()}return H.promise(b)};var K="undefined",L;for(L in m(k))break;k.ownLast="0"!==L,k.inlineBlockNeedsLayout=!1,m(function(){var a,b,c,d;c=y.getElementsByTagName("body")[0],c&&c.style&&(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),typeof b.style.zoom!==K&&(b.style.cssText="display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1",k.inlineBlockNeedsLayout=a=3===b.offsetWidth,a&&(c.style.zoom=1)),c.removeChild(d))}),function(){var a=y.createElement("div");if(null==k.deleteExpando){k.deleteExpando=!0;try{delete a.test}catch(b){k.deleteExpando=!1}}a=null}(),m.acceptData=function(a){var b=m.noData[(a.nodeName+" ").toLowerCase()],c=+a.nodeType||1;return 1!==c&&9!==c?!1:!b||b!==!0&&a.getAttribute("classid")===b};var M=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,N=/([A-Z])/g;function O(a,b,c){if(void 0===c&&1===a.nodeType){var d="data-"+b.replace(N,"-$1").toLowerCase();if(c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:M.test(c)?m.parseJSON(c):c}catch(e){}m.data(a,b,c)}else c=void 0}return c}function P(a){var b;for(b in a)if(("data"!==b||!m.isEmptyObject(a[b]))&&"toJSON"!==b)return!1;
  66862. return!0}function Q(a,b,d,e){if(m.acceptData(a)){var f,g,h=m.expando,i=a.nodeType,j=i?m.cache:a,k=i?a[h]:a[h]&&h;if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||m.guid++:h),j[k]||(j[k]=i?{}:{toJSON:m.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=m.extend(j[k],b):j[k].data=m.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[m.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[m.camelCase(b)])):f=g,f}}function R(a,b,c){if(m.acceptData(a)){var d,e,f=a.nodeType,g=f?m.cache:a,h=f?a[m.expando]:m.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){m.isArray(b)?b=b.concat(m.map(b,m.camelCase)):b in d?b=[b]:(b=m.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!P(d):!m.isEmptyObject(d))return}(c||(delete g[h].data,P(g[h])))&&(f?m.cleanData([a],!0):k.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}m.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?m.cache[a[m.expando]]:a[m.expando],!!a&&!P(a)},data:function(a,b,c){return Q(a,b,c)},removeData:function(a,b){return R(a,b)},_data:function(a,b,c){return Q(a,b,c,!0)},_removeData:function(a,b){return R(a,b,!0)}}),m.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=m.data(f),1===f.nodeType&&!m._data(f,"parsedAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=m.camelCase(d.slice(5)),O(f,d,e[d])));m._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){m.data(this,a)}):arguments.length>1?this.each(function(){m.data(this,a,b)}):f?O(f,a,m.data(f,a)):void 0},removeData:function(a){return this.each(function(){m.removeData(this,a)})}}),m.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=m._data(a,b),c&&(!d||m.isArray(c)?d=m._data(a,b,m.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=m.queue(a,b),d=c.length,e=c.shift(),f=m._queueHooks(a,b),g=function(){m.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return m._data(a,c)||m._data(a,c,{empty:m.Callbacks("once memory").add(function(){m._removeData(a,b+"queue"),m._removeData(a,c)})})}}),m.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?m.queue(this[0],a):void 0===b?this:this.each(function(){var c=m.queue(this,a,b);m._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&m.dequeue(this,a)})},dequeue:function(a){return this.each(function(){m.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=m.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=m._data(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var S=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=["Top","Right","Bottom","Left"],U=function(a,b){return a=b||a,"none"===m.css(a,"display")||!m.contains(a.ownerDocument,a)},V=m.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===m.type(c)){e=!0;for(h in c)m.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,m.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(m(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},W=/^(?:checkbox|radio)$/i;!function(){var a=y.createElement("input"),b=y.createElement("div"),c=y.createDocumentFragment();if(b.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",k.leadingWhitespace=3===b.firstChild.nodeType,k.tbody=!b.getElementsByTagName("tbody").length,k.htmlSerialize=!!b.getElementsByTagName("link").length,k.html5Clone="<:nav></:nav>"!==y.createElement("nav").cloneNode(!0).outerHTML,a.type="checkbox",a.checked=!0,c.appendChild(a),k.appendChecked=a.checked,b.innerHTML="<textarea>x</textarea>",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue,c.appendChild(b),b.innerHTML="<input type='radio' checked='checked' name='t'/>",k.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,k.noCloneEvent=!0,b.attachEvent&&(b.attachEvent("onclick",function(){k.noCloneEvent=!1}),b.cloneNode(!0).click()),null==k.deleteExpando){k.deleteExpando=!0;try{delete b.test}catch(d){k.deleteExpando=!1}}}(),function(){var b,c,d=y.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(k[b+"Bubbles"]=c in a)||(d.setAttribute(c,"t"),k[b+"Bubbles"]=d.attributes[c].expando===!1);d=null}();var X=/^(?:input|select|textarea)$/i,Y=/^key/,Z=/^(?:mouse|pointer|contextmenu)|click/,$=/^(?:focusinfocus|focusoutblur)$/,_=/^([^.]*)(?:\.(.+)|)$/;function aa(){return!0}function ba(){return!1}function ca(){try{return y.activeElement}catch(a){}}m.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m._data(a);if(r){c.handler&&(i=c,c=i.handler,e=i.selector),c.guid||(c.guid=m.guid++),(g=r.events)||(g=r.events={}),(k=r.handle)||(k=r.handle=function(a){return typeof m===K||a&&m.event.triggered===a.type?void 0:m.event.dispatch.apply(k.elem,arguments)},k.elem=a),b=(b||"").match(E)||[""],h=b.length;while(h--)f=_.exec(b[h])||[],o=q=f[1],p=(f[2]||"").split(".").sort(),o&&(j=m.event.special[o]||{},o=(e?j.delegateType:j.bindType)||o,j=m.event.special[o]||{},l=m.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&m.expr.match.needsContext.test(e),namespace:p.join(".")},i),(n=g[o])||(n=g[o]=[],n.delegateCount=0,j.setup&&j.setup.call(a,d,p,k)!==!1||(a.addEventListener?a.addEventListener(o,k,!1):a.attachEvent&&a.attachEvent("on"+o,k))),j.add&&(j.add.call(a,l),l.handler.guid||(l.handler.guid=c.guid)),e?n.splice(n.delegateCount++,0,l):n.push(l),m.event.global[o]=!0);a=null}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m.hasData(a)&&m._data(a);if(r&&(k=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=_.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=m.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,n=k[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),i=f=n.length;while(f--)g=n[f],!e&&q!==g.origType||c&&c.guid!==g.guid||h&&!h.test(g.namespace)||d&&d!==g.selector&&("**"!==d||!g.selector)||(n.splice(f,1),g.selector&&n.delegateCount--,l.remove&&l.remove.call(a,g));i&&!n.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||m.removeEvent(a,o,r.handle),delete k[o])}else for(o in k)m.event.remove(a,o+b[j],c,d,!0);m.isEmptyObject(k)&&(delete r.handle,m._removeData(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,l,n,o=[d||y],p=j.call(b,"type")?b.type:b,q=j.call(b,"namespace")?b.namespace.split("."):[];if(h=l=d=d||y,3!==d.nodeType&&8!==d.nodeType&&!$.test(p+m.event.triggered)&&(p.indexOf(".")>=0&&(q=p.split("."),p=q.shift(),q.sort()),g=p.indexOf(":")<0&&"on"+p,b=b[m.expando]?b:new m.Event(p,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=q.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:m.makeArray(c,[b]),k=m.event.special[p]||{},e||!k.trigger||k.trigger.apply(d,c)!==!1)){if(!e&&!k.noBubble&&!m.isWindow(d)){for(i=k.delegateType||p,$.test(i+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),l=h;l===(d.ownerDocument||y)&&o.push(l.defaultView||l.parentWindow||a)}n=0;while((h=o[n++])&&!b.isPropagationStopped())b.type=n>1?i:k.bindType||p,f=(m._data(h,"events")||{})[b.type]&&m._data(h,"handle"),f&&f.apply(h,c),f=g&&h[g],f&&f.apply&&m.acceptData(h)&&(b.result=f.apply(h,c),b.result===!1&&b.preventDefault());if(b.type=p,!e&&!b.isDefaultPrevented()&&(!k._default||k._default.apply(o.pop(),c)===!1)&&m.acceptData(d)&&g&&d[p]&&!m.isWindow(d)){l=d[g],l&&(d[g]=null),m.event.triggered=p;try{d[p]()}catch(r){}m.event.triggered=void 0,l&&(d[g]=l)}return b.result}},dispatch:function(a){a=m.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(m._data(this,"events")||{})[a.type]||[],k=m.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=m.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,g=0;while((e=f.handlers[g++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(e.namespace))&&(a.handleObj=e,a.data=e.data,c=((m.event.special[e.origType]||{}).handle||e.handler).apply(f.elem,i),void 0!==c&&(a.result=c)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!=this;i=i.parentNode||this)if(1===i.nodeType&&(i.disabled!==!0||"click"!==a.type)){for(e=[],f=0;h>f;f++)d=b[f],c=d.selector+" ",void 0===e[c]&&(e[c]=d.needsContext?m(c,this).index(i)>=0:m.find(c,this,null,[i]).length),e[c]&&e.push(d);e.length&&g.push({elem:i,handlers:e})}return h<b.length&&g.push({elem:this,handlers:b.slice(h)}),g},fix:function(a){if(a[m.expando])return a;var b,c,d,e=a.type,f=a,g=this.fixHooks[e];g||(this.fixHooks[e]=g=Z.test(e)?this.mouseHooks:Y.test(e)?this.keyHooks:{}),d=g.props?this.props.concat(g.props):this.props,a=new m.Event(f),b=d.length;while(b--)c=d[b],a[c]=f[c];return a.target||(a.target=f.srcElement||y),3===a.target.nodeType&&(a.target=a.target.parentNode),a.metaKey=!!a.metaKey,g.filter?g.filter(a,f):a},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(a,b){return null==a.which&&(a.which=null!=b.charCode?b.charCode:b.keyCode),a}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(a,b){var c,d,e,f=b.button,g=b.fromElement;return null==a.pageX&&null!=b.clientX&&(d=a.target.ownerDocument||y,e=d.documentElement,c=d.body,a.pageX=b.clientX+(e&&e.scrollLeft||c&&c.scrollLeft||0)-(e&&e.clientLeft||c&&c.clientLeft||0),a.pageY=b.clientY+(e&&e.scrollTop||c&&c.scrollTop||0)-(e&&e.clientTop||c&&c.clientTop||0)),!a.relatedTarget&&g&&(a.relatedTarget=g===a.target?b.toElement:g),a.which||void 0===f||(a.which=1&f?1:2&f?3:4&f?2:0),a}},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==ca()&&this.focus)try{return this.focus(),!1}catch(a){}},delegateType:"focusin"},blur:{trigger:function(){return this===ca()&&this.blur?(this.blur(),!1):void 0},delegateType:"focusout"},click:{trigger:function(){return m.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):void 0},_default:function(a){return m.nodeName(a.target,"a")}},beforeunload:{postDispatch:function(a){void 0!==a.result&&a.originalEvent&&(a.originalEvent.returnValue=a.result)}}},simulate:function(a,b,c,d){var e=m.extend(new m.Event,c,{type:a,isSimulated:!0,originalEvent:{}});d?m.event.trigger(e,null,b):m.event.dispatch.call(b,e),e.isDefaultPrevented()&&c.preventDefault()}},m.removeEvent=y.removeEventListener?function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)}:function(a,b,c){var d="on"+b;a.detachEvent&&(typeof a[d]===K&&(a[d]=null),a.detachEvent(d,c))},m.Event=function(a,b){return this instanceof m.Event?(a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||void 0===a.defaultPrevented&&a.returnValue===!1?aa:ba):this.type=a,b&&m.extend(this,b),this.timeStamp=a&&a.timeStamp||m.now(),void(this[m.expando]=!0)):new m.Event(a,b)},m.Event.prototype={isDefaultPrevented:ba,isPropagationStopped:ba,isImmediatePropagationStopped:ba,preventDefault:function(){var a=this.originalEvent;this.isDefaultPrevented=aa,a&&(a.preventDefault?a.preventDefault():a.returnValue=!1)},stopPropagation:function(){var a=this.originalEvent;this.isPropagationStopped=aa,a&&(a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0)},stopImmediatePropagation:function(){var a=this.originalEvent;this.isImmediatePropagationStopped=aa,a&&a.stopImmediatePropagation&&a.stopImmediatePropagation(),this.stopPropagation()}},m.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(a,b){m.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c,d=this,e=a.relatedTarget,f=a.handleObj;return(!e||e!==d&&!m.contains(d,e))&&(a.type=f.origType,c=f.handler.apply(this,arguments),a.type=b),c}}}),k.submitBubbles||(m.event.special.submit={setup:function(){return m.nodeName(this,"form")?!1:void m.event.add(this,"click._submit keypress._submit",function(a){var b=a.target,c=m.nodeName(b,"input")||m.nodeName(b,"button")?b.form:void 0;c&&!m._data(c,"submitBubbles")&&(m.event.add(c,"submit._submit",function(a){a._submit_bubble=!0}),m._data(c,"submitBubbles",!0))})},postDispatch:function(a){a._submit_bubble&&(delete a._submit_bubble,this.parentNode&&!a.isTrigger&&m.event.simulate("submit",this.parentNode,a,!0))},teardown:function(){return m.nodeName(this,"form")?!1:void m.event.remove(this,"._submit")}}),k.changeBubbles||(m.event.special.change={setup:function(){return X.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(m.event.add(this,"propertychange._change",function(a){"checked"===a.originalEvent.propertyName&&(this._just_changed=!0)}),m.event.add(this,"click._change",function(a){this._just_changed&&!a.isTrigger&&(this._just_changed=!1),m.event.simulate("change",this,a,!0)})),!1):void m.event.add(this,"beforeactivate._change",function(a){var b=a.target;X.test(b.nodeName)&&!m._data(b,"changeBubbles")&&(m.event.add(b,"change._change",function(a){!this.parentNode||a.isSimulated||a.isTrigger||m.event.simulate("change",this.parentNode,a,!0)}),m._data(b,"changeBubbles",!0))})},handle:function(a){var b=a.target;return this!==b||a.isSimulated||a.isTrigger||"radio"!==b.type&&"checkbox"!==b.type?a.handleObj.handler.apply(this,arguments):void 0},teardown:function(){return m.event.remove(this,"._change"),!X.test(this.nodeName)}}),k.focusinBubbles||m.each({focus:"focusin",blur:"focusout"},function(a,b){var c=function(a){m.event.simulate(b,a.target,m.event.fix(a),!0)};m.event.special[b]={setup:function(){var d=this.ownerDocument||this,e=m._data(d,b);e||d.addEventListener(a,c,!0),m._data(d,b,(e||0)+1)},teardown:function(){var d=this.ownerDocument||this,e=m._data(d,b)-1;e?m._data(d,b,e):(d.removeEventListener(a,c,!0),m._removeData(d,b))}}}),m.fn.extend({on:function(a,b,c,d,e){var f,g;if("object"==typeof a){"string"!=typeof b&&(c=c||b,b=void 0);for(f in a)this.on(f,b,c,a[f],e);return this}if(null==c&&null==d?(d=b,c=b=void 0):null==d&&("string"==typeof b?(d=c,c=void 0):(d=c,c=b,b=void 0)),d===!1)d=ba;else if(!d)return this;return 1===e&&(g=d,d=function(a){return m().off(a),g.apply(this,arguments)},d.guid=g.guid||(g.guid=m.guid++)),this.each(function(){m.event.add(this,a,d,c,b)})},one:function(a,b,c,d){return this.on(a,b,c,d,1)},off:function(a,b,c){var d,e;if(a&&a.preventDefault&&a.handleObj)return d=a.handleObj,m(a.delegateTarget).off(d.namespace?d.origType+"."+d.namespace:d.origType,d.selector,d.handler),this;if("object"==typeof a){for(e in a)this.off(e,b,a[e]);return this}return(b===!1||"function"==typeof b)&&(c=b,b=void 0),c===!1&&(c=ba),this.each(function(){m.event.remove(this,a,c,b)})},trigger:function(a,b){return this.each(function(){m.event.trigger(a,b,this)})},triggerHandler:function(a,b){var c=this[0];return c?m.event.trigger(a,b,c,!0):void 0}});function da(a){var b=ea.split("|"),c=a.createDocumentFragment();if(c.createElement)while(b.length)c.createElement(b.pop());return c}var ea="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",fa=/ jQuery\d+="(?:null|\d+)"/g,ga=new RegExp("<(?:"+ea+")[\\s/>]","i"),ha=/^\s+/,ia=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,ja=/<([\w:]+)/,ka=/<tbody/i,la=/<|&#?\w+;/,ma=/<(?:script|style|link)/i,na=/checked\s*(?:[^=]|=\s*.checked.)/i,oa=/^$|\/(?:java|ecma)script/i,pa=/^true\/(.*)/,qa=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,ra={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],area:[1,"<map>","</map>"],param:[1,"<object>","</object>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:k.htmlSerialize?[0,"",""]:[1,"X<div>","</div>"]},sa=da(y),ta=sa.appendChild(y.createElement("div"));ra.optgroup=ra.option,ra.tbody=ra.tfoot=ra.colgroup=ra.caption=ra.thead,ra.th=ra.td;function ua(a,b){var c,d,e=0,f=typeof a.getElementsByTagName!==K?a.getElementsByTagName(b||"*"):typeof a.querySelectorAll!==K?a.querySelectorAll(b||"*"):void 0;if(!f)for(f=[],c=a.childNodes||a;null!=(d=c[e]);e++)!b||m.nodeName(d,b)?f.push(d):m.merge(f,ua(d,b));return void 0===b||b&&m.nodeName(a,b)?m.merge([a],f):f}function va(a){W.test(a.type)&&(a.defaultChecked=a.checked)}function wa(a,b){return m.nodeName(a,"table")&&m.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function xa(a){return a.type=(null!==m.find.attr(a,"type"))+"/"+a.type,a}function ya(a){var b=pa.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function za(a,b){for(var c,d=0;null!=(c=a[d]);d++)m._data(c,"globalEval",!b||m._data(b[d],"globalEval"))}function Aa(a,b){if(1===b.nodeType&&m.hasData(a)){var c,d,e,f=m._data(a),g=m._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;e>d;d++)m.event.add(b,c,h[c][d])}g.data&&(g.data=m.extend({},g.data))}}function Ba(a,b){var c,d,e;if(1===b.nodeType){if(c=b.nodeName.toLowerCase(),!k.noCloneEvent&&b[m.expando]){e=m._data(b);for(d in e.events)m.removeEvent(b,d,e.handle);b.removeAttribute(m.expando)}"script"===c&&b.text!==a.text?(xa(b).text=a.text,ya(b)):"object"===c?(b.parentNode&&(b.outerHTML=a.outerHTML),k.html5Clone&&a.innerHTML&&!m.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):"input"===c&&W.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):"option"===c?b.defaultSelected=b.selected=a.defaultSelected:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}}m.extend({clone:function(a,b,c){var d,e,f,g,h,i=m.contains(a.ownerDocument,a);if(k.html5Clone||m.isXMLDoc(a)||!ga.test("<"+a.nodeName+">")?f=a.cloneNode(!0):(ta.innerHTML=a.outerHTML,ta.removeChild(f=ta.firstChild)),!(k.noCloneEvent&&k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||m.isXMLDoc(a)))for(d=ua(f),h=ua(a),g=0;null!=(e=h[g]);++g)d[g]&&Ba(e,d[g]);if(b)if(c)for(h=h||ua(a),d=d||ua(f),g=0;null!=(e=h[g]);g++)Aa(e,d[g]);else Aa(a,f);return d=ua(f,"script"),d.length>0&&za(d,!i&&ua(a,"script")),d=h=e=null,f},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,l,n=a.length,o=da(b),p=[],q=0;n>q;q++)if(f=a[q],f||0===f)if("object"===m.type(f))m.merge(p,f.nodeType?[f]:f);else if(la.test(f)){h=h||o.appendChild(b.createElement("div")),i=(ja.exec(f)||["",""])[1].toLowerCase(),l=ra[i]||ra._default,h.innerHTML=l[1]+f.replace(ia,"<$1></$2>")+l[2],e=l[0];while(e--)h=h.lastChild;if(!k.leadingWhitespace&&ha.test(f)&&p.push(b.createTextNode(ha.exec(f)[0])),!k.tbody){f="table"!==i||ka.test(f)?"<table>"!==l[1]||ka.test(f)?0:h:h.firstChild,e=f&&f.childNodes.length;while(e--)m.nodeName(j=f.childNodes[e],"tbody")&&!j.childNodes.length&&f.removeChild(j)}m.merge(p,h.childNodes),h.textContent="";while(h.firstChild)h.removeChild(h.firstChild);h=o.lastChild}else p.push(b.createTextNode(f));h&&o.removeChild(h),k.appendChecked||m.grep(ua(p,"input"),va),q=0;while(f=p[q++])if((!d||-1===m.inArray(f,d))&&(g=m.contains(f.ownerDocument,f),h=ua(o.appendChild(f),"script"),g&&za(h),c)){e=0;while(f=h[e++])oa.test(f.type||"")&&c.push(f)}return h=null,o},cleanData:function(a,b){for(var d,e,f,g,h=0,i=m.expando,j=m.cache,l=k.deleteExpando,n=m.event.special;null!=(d=a[h]);h++)if((b||m.acceptData(d))&&(f=d[i],g=f&&j[f])){if(g.events)for(e in g.events)n[e]?m.event.remove(d,e):m.removeEvent(d,e,g.handle);j[f]&&(delete j[f],l?delete d[i]:typeof d.removeAttribute!==K?d.removeAttribute(i):d[i]=null,c.push(f))}}}),m.fn.extend({text:function(a){return V(this,function(a){return void 0===a?m.text(this):this.empty().append((this[0]&&this[0].ownerDocument||y).createTextNode(a))},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wa(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wa(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?m.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||m.cleanData(ua(c)),c.parentNode&&(b&&m.contains(c.ownerDocument,c)&&za(ua(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++){1===a.nodeType&&m.cleanData(ua(a,!1));while(a.firstChild)a.removeChild(a.firstChild);a.options&&m.nodeName(a,"select")&&(a.options.length=0)}return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return m.clone(this,a,b)})},html:function(a){return V(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a)return 1===b.nodeType?b.innerHTML.replace(fa,""):void 0;if(!("string"!=typeof a||ma.test(a)||!k.htmlSerialize&&ga.test(a)||!k.leadingWhitespace&&ha.test(a)||ra[(ja.exec(a)||["",""])[1].toLowerCase()])){a=a.replace(ia,"<$1></$2>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(m.cleanData(ua(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,m.cleanData(ua(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,n=this,o=l-1,p=a[0],q=m.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&na.test(p))return this.each(function(c){var d=n.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(i=m.buildFragment(a,this[0].ownerDocument,!1,this),c=i.firstChild,1===i.childNodes.length&&(i=c),c)){for(g=m.map(ua(i,"script"),xa),f=g.length;l>j;j++)d=i,j!==o&&(d=m.clone(d,!0,!0),f&&m.merge(g,ua(d,"script"))),b.call(this[j],d,j);if(f)for(h=g[g.length-1].ownerDocument,m.map(g,ya),j=0;f>j;j++)d=g[j],oa.test(d.type||"")&&!m._data(d,"globalEval")&&m.contains(h,d)&&(d.src?m._evalUrl&&m._evalUrl(d.src):m.globalEval((d.text||d.textContent||d.innerHTML||"").replace(qa,"")));i=c=null}return this}}),m.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){m.fn[a]=function(a){for(var c,d=0,e=[],g=m(a),h=g.length-1;h>=d;d++)c=d===h?this:this.clone(!0),m(g[d])[b](c),f.apply(e,c.get());return this.pushStack(e)}});var Ca,Da={};function Ea(b,c){var d,e=m(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:m.css(e[0],"display");return e.detach(),f}function Fa(a){var b=y,c=Da[a];return c||(c=Ea(a,b),"none"!==c&&c||(Ca=(Ca||m("<iframe frameborder='0' width='0' height='0'/>")).appendTo(b.documentElement),b=(Ca[0].contentWindow||Ca[0].contentDocument).document,b.write(),b.close(),c=Ea(a,b),Ca.detach()),Da[a]=c),c}!function(){var a;k.shrinkWrapBlocks=function(){if(null!=a)return a;a=!1;var b,c,d;return c=y.getElementsByTagName("body")[0],c&&c.style?(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),typeof b.style.zoom!==K&&(b.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:1px;width:1px;zoom:1",b.appendChild(y.createElement("div")).style.width="5px",a=3!==b.offsetWidth),c.removeChild(d),a):void 0}}();var Ga=/^margin/,Ha=new RegExp("^("+S+")(?!px)[a-z%]+$","i"),Ia,Ja,Ka=/^(top|right|bottom|left)$/;a.getComputedStyle?(Ia=function(b){return b.ownerDocument.defaultView.opener?b.ownerDocument.defaultView.getComputedStyle(b,null):a.getComputedStyle(b,null)},Ja=function(a,b,c){var d,e,f,g,h=a.style;return c=c||Ia(a),g=c?c.getPropertyValue(b)||c[b]:void 0,c&&(""!==g||m.contains(a.ownerDocument,a)||(g=m.style(a,b)),Ha.test(g)&&Ga.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=g,g=c.width,h.width=d,h.minWidth=e,h.maxWidth=f)),void 0===g?g:g+""}):y.documentElement.currentStyle&&(Ia=function(a){return a.currentStyle},Ja=function(a,b,c){var d,e,f,g,h=a.style;return c=c||Ia(a),g=c?c[b]:void 0,null==g&&h&&h[b]&&(g=h[b]),Ha.test(g)&&!Ka.test(b)&&(d=h.left,e=a.runtimeStyle,f=e&&e.left,f&&(e.left=a.currentStyle.left),h.left="fontSize"===b?"1em":g,g=h.pixelLeft+"px",h.left=d,f&&(e.left=f)),void 0===g?g:g+""||"auto"});function La(a,b){return{get:function(){var c=a();if(null!=c)return c?void delete this.get:(this.get=b).apply(this,arguments)}}}!function(){var b,c,d,e,f,g,h;if(b=y.createElement("div"),b.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",d=b.getElementsByTagName("a")[0],c=d&&d.style){c.cssText="float:left;opacity:.5",k.opacity="0.5"===c.opacity,k.cssFloat=!!c.cssFloat,b.style.backgroundClip="content-box",b.cloneNode(!0).style.backgroundClip="",k.clearCloneStyle="content-box"===b.style.backgroundClip,k.boxSizing=""===c.boxSizing||""===c.MozBoxSizing||""===c.WebkitBoxSizing,m.extend(k,{reliableHiddenOffsets:function(){return null==g&&i(),g},boxSizingReliable:function(){return null==f&&i(),f},pixelPosition:function(){return null==e&&i(),e},reliableMarginRight:function(){return null==h&&i(),h}});function i(){var b,c,d,i;c=y.getElementsByTagName("body")[0],c&&c.style&&(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),b.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:block;margin-top:1%;top:1%;border:1px;padding:1px;width:4px;position:absolute",e=f=!1,h=!0,a.getComputedStyle&&(e="1%"!==(a.getComputedStyle(b,null)||{}).top,f="4px"===(a.getComputedStyle(b,null)||{width:"4px"}).width,i=b.appendChild(y.createElement("div")),i.style.cssText=b.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:0",i.style.marginRight=i.style.width="0",b.style.width="1px",h=!parseFloat((a.getComputedStyle(i,null)||{}).marginRight),b.removeChild(i)),b.innerHTML="<table><tr><td></td><td>t</td></tr></table>",i=b.getElementsByTagName("td"),i[0].style.cssText="margin:0;border:0;padding:0;display:none",g=0===i[0].offsetHeight,g&&(i[0].style.display="",i[1].style.display="none",g=0===i[0].offsetHeight),c.removeChild(d))}}}(),m.swap=function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e};var Ma=/alpha\([^)]*\)/i,Na=/opacity\s*=\s*([^)]*)/,Oa=/^(none|table(?!-c[ea]).+)/,Pa=new RegExp("^("+S+")(.*)$","i"),Qa=new RegExp("^([+-])=("+S+")","i"),Ra={position:"absolute",visibility:"hidden",display:"block"},Sa={letterSpacing:"0",fontWeight:"400"},Ta=["Webkit","O","Moz","ms"];function Ua(a,b){if(b in a)return b;var c=b.charAt(0).toUpperCase()+b.slice(1),d=b,e=Ta.length;while(e--)if(b=Ta[e]+c,b in a)return b;return d}function Va(a,b){for(var c,d,e,f=[],g=0,h=a.length;h>g;g++)d=a[g],d.style&&(f[g]=m._data(d,"olddisplay"),c=d.style.display,b?(f[g]||"none"!==c||(d.style.display=""),""===d.style.display&&U(d)&&(f[g]=m._data(d,"olddisplay",Fa(d.nodeName)))):(e=U(d),(c&&"none"!==c||!e)&&m._data(d,"olddisplay",e?c:m.css(d,"display"))));for(g=0;h>g;g++)d=a[g],d.style&&(b&&"none"!==d.style.display&&""!==d.style.display||(d.style.display=b?f[g]||"":"none"));return a}function Wa(a,b,c){var d=Pa.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function Xa(a,b,c,d,e){for(var f=c===(d?"border":"content")?4:"width"===b?1:0,g=0;4>f;f+=2)"margin"===c&&(g+=m.css(a,c+T[f],!0,e)),d?("content"===c&&(g-=m.css(a,"padding"+T[f],!0,e)),"margin"!==c&&(g-=m.css(a,"border"+T[f]+"Width",!0,e))):(g+=m.css(a,"padding"+T[f],!0,e),"padding"!==c&&(g+=m.css(a,"border"+T[f]+"Width",!0,e)));return g}function Ya(a,b,c){var d=!0,e="width"===b?a.offsetWidth:a.offsetHeight,f=Ia(a),g=k.boxSizing&&"border-box"===m.css(a,"boxSizing",!1,f);if(0>=e||null==e){if(e=Ja(a,b,f),(0>e||null==e)&&(e=a.style[b]),Ha.test(e))return e;d=g&&(k.boxSizingReliable()||e===a.style[b]),e=parseFloat(e)||0}return e+Xa(a,b,c||(g?"border":"content"),d,f)+"px"}m.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=Ja(a,"opacity");return""===c?"1":c}}}},cssNumber:{columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":k.cssFloat?"cssFloat":"styleFloat"},style:function(a,b,c,d){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var e,f,g,h=m.camelCase(b),i=a.style;if(b=m.cssProps[h]||(m.cssProps[h]=Ua(i,h)),g=m.cssHooks[b]||m.cssHooks[h],void 0===c)return g&&"get"in g&&void 0!==(e=g.get(a,!1,d))?e:i[b];if(f=typeof c,"string"===f&&(e=Qa.exec(c))&&(c=(e[1]+1)*e[2]+parseFloat(m.css(a,b)),f="number"),null!=c&&c===c&&("number"!==f||m.cssNumber[h]||(c+="px"),k.clearCloneStyle||""!==c||0!==b.indexOf("background")||(i[b]="inherit"),!(g&&"set"in g&&void 0===(c=g.set(a,c,d)))))try{i[b]=c}catch(j){}}},css:function(a,b,c,d){var e,f,g,h=m.camelCase(b);return b=m.cssProps[h]||(m.cssProps[h]=Ua(a.style,h)),g=m.cssHooks[b]||m.cssHooks[h],g&&"get"in g&&(f=g.get(a,!0,c)),void 0===f&&(f=Ja(a,b,d)),"normal"===f&&b in Sa&&(f=Sa[b]),""===c||c?(e=parseFloat(f),c===!0||m.isNumeric(e)?e||0:f):f}}),m.each(["height","width"],function(a,b){m.cssHooks[b]={get:function(a,c,d){return c?Oa.test(m.css(a,"display"))&&0===a.offsetWidth?m.swap(a,Ra,function(){return Ya(a,b,d)}):Ya(a,b,d):void 0},set:function(a,c,d){var e=d&&Ia(a);return Wa(a,c,d?Xa(a,b,d,k.boxSizing&&"border-box"===m.css(a,"boxSizing",!1,e),e):0)}}}),k.opacity||(m.cssHooks.opacity={get:function(a,b){return Na.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=m.isNumeric(b)?"alpha(opacity="+100*b+")":"",f=d&&d.filter||c.filter||"";c.zoom=1,(b>=1||""===b)&&""===m.trim(f.replace(Ma,""))&&c.removeAttribute&&(c.removeAttribute("filter"),""===b||d&&!d.filter)||(c.filter=Ma.test(f)?f.replace(Ma,e):f+" "+e)}}),m.cssHooks.marginRight=La(k.reliableMarginRight,function(a,b){return b?m.swap(a,{display:"inline-block"},Ja,[a,"marginRight"]):void 0}),m.each({margin:"",padding:"",border:"Width"},function(a,b){m.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];4>d;d++)e[a+T[d]+b]=f[d]||f[d-2]||f[0];return e}},Ga.test(a)||(m.cssHooks[a+b].set=Wa)}),m.fn.extend({css:function(a,b){return V(this,function(a,b,c){var d,e,f={},g=0;if(m.isArray(b)){for(d=Ia(a),e=b.length;e>g;g++)f[b[g]]=m.css(a,b[g],!1,d);return f}return void 0!==c?m.style(a,b,c):m.css(a,b)},a,b,arguments.length>1)},show:function(){return Va(this,!0)},hide:function(){return Va(this)},toggle:function(a){return"boolean"==typeof a?a?this.show():this.hide():this.each(function(){U(this)?m(this).show():m(this).hide()})}});function Za(a,b,c,d,e){
  66863. return new Za.prototype.init(a,b,c,d,e)}m.Tween=Za,Za.prototype={constructor:Za,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(m.cssNumber[c]?"":"px")},cur:function(){var a=Za.propHooks[this.prop];return a&&a.get?a.get(this):Za.propHooks._default.get(this)},run:function(a){var b,c=Za.propHooks[this.prop];return this.options.duration?this.pos=b=m.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):this.pos=b=a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Za.propHooks._default.set(this),this}},Za.prototype.init.prototype=Za.prototype,Za.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=m.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){m.fx.step[a.prop]?m.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[m.cssProps[a.prop]]||m.cssHooks[a.prop])?m.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Za.propHooks.scrollTop=Za.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},m.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},m.fx=Za.prototype.init,m.fx.step={};var $a,_a,ab=/^(?:toggle|show|hide)$/,bb=new RegExp("^(?:([+-])=|)("+S+")([a-z%]*)$","i"),cb=/queueHooks$/,db=[ib],eb={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=bb.exec(b),f=e&&e[3]||(m.cssNumber[a]?"":"px"),g=(m.cssNumber[a]||"px"!==f&&+d)&&bb.exec(m.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,m.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function fb(){return setTimeout(function(){$a=void 0}),$a=m.now()}function gb(a,b){var c,d={height:a},e=0;for(b=b?1:0;4>e;e+=2-b)c=T[e],d["margin"+c]=d["padding"+c]=a;return b&&(d.opacity=d.width=a),d}function hb(a,b,c){for(var d,e=(eb[b]||[]).concat(eb["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function ib(a,b,c){var d,e,f,g,h,i,j,l,n=this,o={},p=a.style,q=a.nodeType&&U(a),r=m._data(a,"fxshow");c.queue||(h=m._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,n.always(function(){n.always(function(){h.unqueued--,m.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[p.overflow,p.overflowX,p.overflowY],j=m.css(a,"display"),l="none"===j?m._data(a,"olddisplay")||Fa(a.nodeName):j,"inline"===l&&"none"===m.css(a,"float")&&(k.inlineBlockNeedsLayout&&"inline"!==Fa(a.nodeName)?p.zoom=1:p.display="inline-block")),c.overflow&&(p.overflow="hidden",k.shrinkWrapBlocks()||n.always(function(){p.overflow=c.overflow[0],p.overflowX=c.overflow[1],p.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],ab.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(q?"hide":"show")){if("show"!==e||!r||void 0===r[d])continue;q=!0}o[d]=r&&r[d]||m.style(a,d)}else j=void 0;if(m.isEmptyObject(o))"inline"===("none"===j?Fa(a.nodeName):j)&&(p.display=j);else{r?"hidden"in r&&(q=r.hidden):r=m._data(a,"fxshow",{}),f&&(r.hidden=!q),q?m(a).show():n.done(function(){m(a).hide()}),n.done(function(){var b;m._removeData(a,"fxshow");for(b in o)m.style(a,b,o[b])});for(d in o)g=hb(q?r[d]:0,d,n),d in r||(r[d]=g.start,q&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function jb(a,b){var c,d,e,f,g;for(c in a)if(d=m.camelCase(c),e=b[d],f=a[c],m.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=m.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function kb(a,b,c){var d,e,f=0,g=db.length,h=m.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=$a||fb(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:m.extend({},b),opts:m.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:$a||fb(),duration:c.duration,tweens:[],createTween:function(b,c){var d=m.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(jb(k,j.opts.specialEasing);g>f;f++)if(d=db[f].call(j,a,k,j.opts))return d;return m.map(k,hb,j),m.isFunction(j.opts.start)&&j.opts.start.call(a,j),m.fx.timer(m.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}m.Animation=m.extend(kb,{tweener:function(a,b){m.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;e>d;d++)c=a[d],eb[c]=eb[c]||[],eb[c].unshift(b)},prefilter:function(a,b){b?db.unshift(a):db.push(a)}}),m.speed=function(a,b,c){var d=a&&"object"==typeof a?m.extend({},a):{complete:c||!c&&b||m.isFunction(a)&&a,duration:a,easing:c&&b||b&&!m.isFunction(b)&&b};return d.duration=m.fx.off?0:"number"==typeof d.duration?d.duration:d.duration in m.fx.speeds?m.fx.speeds[d.duration]:m.fx.speeds._default,(null==d.queue||d.queue===!0)&&(d.queue="fx"),d.old=d.complete,d.complete=function(){m.isFunction(d.old)&&d.old.call(this),d.queue&&m.dequeue(this,d.queue)},d},m.fn.extend({fadeTo:function(a,b,c,d){return this.filter(U).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=m.isEmptyObject(a),f=m.speed(b,c,d),g=function(){var b=kb(this,m.extend({},a),f);(e||m._data(this,"finish"))&&b.stop(!0)};return g.finish=g,e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,b,c){var d=function(a){var b=a.stop;delete a.stop,b(c)};return"string"!=typeof a&&(c=b,b=a,a=void 0),b&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,e=null!=a&&a+"queueHooks",f=m.timers,g=m._data(this);if(e)g[e]&&g[e].stop&&d(g[e]);else for(e in g)g[e]&&g[e].stop&&cb.test(e)&&d(g[e]);for(e=f.length;e--;)f[e].elem!==this||null!=a&&f[e].queue!==a||(f[e].anim.stop(c),b=!1,f.splice(e,1));(b||!c)&&m.dequeue(this,a)})},finish:function(a){return a!==!1&&(a=a||"fx"),this.each(function(){var b,c=m._data(this),d=c[a+"queue"],e=c[a+"queueHooks"],f=m.timers,g=d?d.length:0;for(c.finish=!0,m.queue(this,a,[]),e&&e.stop&&e.stop.call(this,!0),b=f.length;b--;)f[b].elem===this&&f[b].queue===a&&(f[b].anim.stop(!0),f.splice(b,1));for(b=0;g>b;b++)d[b]&&d[b].finish&&d[b].finish.call(this);delete c.finish})}}),m.each(["toggle","show","hide"],function(a,b){var c=m.fn[b];m.fn[b]=function(a,d,e){return null==a||"boolean"==typeof a?c.apply(this,arguments):this.animate(gb(b,!0),a,d,e)}}),m.each({slideDown:gb("show"),slideUp:gb("hide"),slideToggle:gb("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){m.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),m.timers=[],m.fx.tick=function(){var a,b=m.timers,c=0;for($a=m.now();c<b.length;c++)a=b[c],a()||b[c]!==a||b.splice(c--,1);b.length||m.fx.stop(),$a=void 0},m.fx.timer=function(a){m.timers.push(a),a()?m.fx.start():m.timers.pop()},m.fx.interval=13,m.fx.start=function(){_a||(_a=setInterval(m.fx.tick,m.fx.interval))},m.fx.stop=function(){clearInterval(_a),_a=null},m.fx.speeds={slow:600,fast:200,_default:400},m.fn.delay=function(a,b){return a=m.fx?m.fx.speeds[a]||a:a,b=b||"fx",this.queue(b,function(b,c){var d=setTimeout(b,a);c.stop=function(){clearTimeout(d)}})},function(){var a,b,c,d,e;b=y.createElement("div"),b.setAttribute("className","t"),b.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",d=b.getElementsByTagName("a")[0],c=y.createElement("select"),e=c.appendChild(y.createElement("option")),a=b.getElementsByTagName("input")[0],d.style.cssText="top:1px",k.getSetAttribute="t"!==b.className,k.style=/top/.test(d.getAttribute("style")),k.hrefNormalized="/a"===d.getAttribute("href"),k.checkOn=!!a.value,k.optSelected=e.selected,k.enctype=!!y.createElement("form").enctype,c.disabled=!0,k.optDisabled=!e.disabled,a=y.createElement("input"),a.setAttribute("value",""),k.input=""===a.getAttribute("value"),a.value="t",a.setAttribute("type","radio"),k.radioValue="t"===a.value}();var lb=/\r/g;m.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=m.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,m(this).val()):a,null==e?e="":"number"==typeof e?e+="":m.isArray(e)&&(e=m.map(e,function(a){return null==a?"":a+""})),b=m.valHooks[this.type]||m.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=m.valHooks[e.type]||m.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(lb,""):null==c?"":c)}}}),m.extend({valHooks:{option:{get:function(a){var b=m.find.attr(a,"value");return null!=b?b:m.trim(m.text(a))}},select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type||0>e,g=f?null:[],h=f?e+1:d.length,i=0>e?h:f?e:0;h>i;i++)if(c=d[i],!(!c.selected&&i!==e||(k.optDisabled?c.disabled:null!==c.getAttribute("disabled"))||c.parentNode.disabled&&m.nodeName(c.parentNode,"optgroup"))){if(b=m(c).val(),f)return b;g.push(b)}return g},set:function(a,b){var c,d,e=a.options,f=m.makeArray(b),g=e.length;while(g--)if(d=e[g],m.inArray(m.valHooks.option.get(d),f)>=0)try{d.selected=c=!0}catch(h){d.scrollHeight}else d.selected=!1;return c||(a.selectedIndex=-1),e}}}}),m.each(["radio","checkbox"],function(){m.valHooks[this]={set:function(a,b){return m.isArray(b)?a.checked=m.inArray(m(a).val(),b)>=0:void 0}},k.checkOn||(m.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})});var mb,nb,ob=m.expr.attrHandle,pb=/^(?:checked|selected)$/i,qb=k.getSetAttribute,rb=k.input;m.fn.extend({attr:function(a,b){return V(this,m.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){m.removeAttr(this,a)})}}),m.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(a&&3!==f&&8!==f&&2!==f)return typeof a.getAttribute===K?m.prop(a,b,c):(1===f&&m.isXMLDoc(a)||(b=b.toLowerCase(),d=m.attrHooks[b]||(m.expr.match.bool.test(b)?nb:mb)),void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=m.find.attr(a,b),null==e?void 0:e):null!==c?d&&"set"in d&&void 0!==(e=d.set(a,c,b))?e:(a.setAttribute(b,c+""),c):void m.removeAttr(a,b))},removeAttr:function(a,b){var c,d,e=0,f=b&&b.match(E);if(f&&1===a.nodeType)while(c=f[e++])d=m.propFix[c]||c,m.expr.match.bool.test(c)?rb&&qb||!pb.test(c)?a[d]=!1:a[m.camelCase("default-"+c)]=a[d]=!1:m.attr(a,c,""),a.removeAttribute(qb?c:d)},attrHooks:{type:{set:function(a,b){if(!k.radioValue&&"radio"===b&&m.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}}}),nb={set:function(a,b,c){return b===!1?m.removeAttr(a,c):rb&&qb||!pb.test(c)?a.setAttribute(!qb&&m.propFix[c]||c,c):a[m.camelCase("default-"+c)]=a[c]=!0,c}},m.each(m.expr.match.bool.source.match(/\w+/g),function(a,b){var c=ob[b]||m.find.attr;ob[b]=rb&&qb||!pb.test(b)?function(a,b,d){var e,f;return d||(f=ob[b],ob[b]=e,e=null!=c(a,b,d)?b.toLowerCase():null,ob[b]=f),e}:function(a,b,c){return c?void 0:a[m.camelCase("default-"+b)]?b.toLowerCase():null}}),rb&&qb||(m.attrHooks.value={set:function(a,b,c){return m.nodeName(a,"input")?void(a.defaultValue=b):mb&&mb.set(a,b,c)}}),qb||(mb={set:function(a,b,c){var d=a.getAttributeNode(c);return d||a.setAttributeNode(d=a.ownerDocument.createAttribute(c)),d.value=b+="","value"===c||b===a.getAttribute(c)?b:void 0}},ob.id=ob.name=ob.coords=function(a,b,c){var d;return c?void 0:(d=a.getAttributeNode(b))&&""!==d.value?d.value:null},m.valHooks.button={get:function(a,b){var c=a.getAttributeNode(b);return c&&c.specified?c.value:void 0},set:mb.set},m.attrHooks.contenteditable={set:function(a,b,c){mb.set(a,""===b?!1:b,c)}},m.each(["width","height"],function(a,b){m.attrHooks[b]={set:function(a,c){return""===c?(a.setAttribute(b,"auto"),c):void 0}}})),k.style||(m.attrHooks.style={get:function(a){return a.style.cssText||void 0},set:function(a,b){return a.style.cssText=b+""}});var sb=/^(?:input|select|textarea|button|object)$/i,tb=/^(?:a|area)$/i;m.fn.extend({prop:function(a,b){return V(this,m.prop,a,b,arguments.length>1)},removeProp:function(a){return a=m.propFix[a]||a,this.each(function(){try{this[a]=void 0,delete this[a]}catch(b){}})}}),m.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(a,b,c){var d,e,f,g=a.nodeType;if(a&&3!==g&&8!==g&&2!==g)return f=1!==g||!m.isXMLDoc(a),f&&(b=m.propFix[b]||b,e=m.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){var b=m.find.attr(a,"tabindex");return b?parseInt(b,10):sb.test(a.nodeName)||tb.test(a.nodeName)&&a.href?0:-1}}}}),k.hrefNormalized||m.each(["href","src"],function(a,b){m.propHooks[b]={get:function(a){return a.getAttribute(b,4)}}}),k.optSelected||(m.propHooks.selected={get:function(a){var b=a.parentNode;return b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex),null}}),m.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){m.propFix[this.toLowerCase()]=this}),k.enctype||(m.propFix.enctype="encoding");var ub=/[\t\r\n\f]/g;m.fn.extend({addClass:function(a){var b,c,d,e,f,g,h=0,i=this.length,j="string"==typeof a&&a;if(m.isFunction(a))return this.each(function(b){m(this).addClass(a.call(this,b,this.className))});if(j)for(b=(a||"").match(E)||[];i>h;h++)if(c=this[h],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ub," "):" ")){f=0;while(e=b[f++])d.indexOf(" "+e+" ")<0&&(d+=e+" ");g=m.trim(d),c.className!==g&&(c.className=g)}return this},removeClass:function(a){var b,c,d,e,f,g,h=0,i=this.length,j=0===arguments.length||"string"==typeof a&&a;if(m.isFunction(a))return this.each(function(b){m(this).removeClass(a.call(this,b,this.className))});if(j)for(b=(a||"").match(E)||[];i>h;h++)if(c=this[h],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ub," "):"")){f=0;while(e=b[f++])while(d.indexOf(" "+e+" ")>=0)d=d.replace(" "+e+" "," ");g=a?m.trim(d):"",c.className!==g&&(c.className=g)}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):this.each(m.isFunction(a)?function(c){m(this).toggleClass(a.call(this,c,this.className,b),b)}:function(){if("string"===c){var b,d=0,e=m(this),f=a.match(E)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else(c===K||"boolean"===c)&&(this.className&&m._data(this,"__className__",this.className),this.className=this.className||a===!1?"":m._data(this,"__className__")||"")})},hasClass:function(a){for(var b=" "+a+" ",c=0,d=this.length;d>c;c++)if(1===this[c].nodeType&&(" "+this[c].className+" ").replace(ub," ").indexOf(b)>=0)return!0;return!1}}),m.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){m.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),m.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return 1===arguments.length?this.off(a,"**"):this.off(b,a||"**",c)}});var vb=m.now(),wb=/\?/,xb=/(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;m.parseJSON=function(b){if(a.JSON&&a.JSON.parse)return a.JSON.parse(b+"");var c,d=null,e=m.trim(b+"");return e&&!m.trim(e.replace(xb,function(a,b,e,f){return c&&b&&(d=0),0===d?a:(c=e||b,d+=!f-!e,"")}))?Function("return "+e)():m.error("Invalid JSON: "+b)},m.parseXML=function(b){var c,d;if(!b||"string"!=typeof b)return null;try{a.DOMParser?(d=new DOMParser,c=d.parseFromString(b,"text/xml")):(c=new ActiveXObject("Microsoft.XMLDOM"),c.async="false",c.loadXML(b))}catch(e){c=void 0}return c&&c.documentElement&&!c.getElementsByTagName("parsererror").length||m.error("Invalid XML: "+b),c};var yb,zb,Ab=/#.*$/,Bb=/([?&])_=[^&]*/,Cb=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Db=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Eb=/^(?:GET|HEAD)$/,Fb=/^\/\//,Gb=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,Hb={},Ib={},Jb="*/".concat("*");try{zb=location.href}catch(Kb){zb=y.createElement("a"),zb.href="",zb=zb.href}yb=Gb.exec(zb.toLowerCase())||[];function Lb(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(E)||[];if(m.isFunction(c))while(d=f[e++])"+"===d.charAt(0)?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function Mb(a,b,c,d){var e={},f=a===Ib;function g(h){var i;return e[h]=!0,m.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function Nb(a,b){var c,d,e=m.ajaxSettings.flatOptions||{};for(d in b)void 0!==b[d]&&((e[d]?a:c||(c={}))[d]=b[d]);return c&&m.extend(!0,a,c),a}function Ob(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===e&&(e=a.mimeType||b.getResponseHeader("Content-Type"));if(e)for(g in h)if(h[g]&&h[g].test(e)){i.unshift(g);break}if(i[0]in c)f=i[0];else{for(g in c){if(!i[0]||a.converters[g+" "+i[0]]){f=g;break}d||(d=g)}f=f||d}return f?(f!==i[0]&&i.unshift(f),c[f]):void 0}function Pb(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}m.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:zb,type:"GET",isLocal:Db.test(yb[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Jb,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":m.parseJSON,"text xml":m.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?Nb(Nb(a,m.ajaxSettings),b):Nb(m.ajaxSettings,a)},ajaxPrefilter:Lb(Hb),ajaxTransport:Lb(Ib),ajax:function(a,b){"object"==typeof a&&(b=a,a=void 0),b=b||{};var c,d,e,f,g,h,i,j,k=m.ajaxSetup({},b),l=k.context||k,n=k.context&&(l.nodeType||l.jquery)?m(l):m.event,o=m.Deferred(),p=m.Callbacks("once memory"),q=k.statusCode||{},r={},s={},t=0,u="canceled",v={readyState:0,getResponseHeader:function(a){var b;if(2===t){if(!j){j={};while(b=Cb.exec(f))j[b[1].toLowerCase()]=b[2]}b=j[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return 2===t?f:null},setRequestHeader:function(a,b){var c=a.toLowerCase();return t||(a=s[c]=s[c]||a,r[a]=b),this},overrideMimeType:function(a){return t||(k.mimeType=a),this},statusCode:function(a){var b;if(a)if(2>t)for(b in a)q[b]=[q[b],a[b]];else v.always(a[v.status]);return this},abort:function(a){var b=a||u;return i&&i.abort(b),x(0,b),this}};if(o.promise(v).complete=p.add,v.success=v.done,v.error=v.fail,k.url=((a||k.url||zb)+"").replace(Ab,"").replace(Fb,yb[1]+"//"),k.type=b.method||b.type||k.method||k.type,k.dataTypes=m.trim(k.dataType||"*").toLowerCase().match(E)||[""],null==k.crossDomain&&(c=Gb.exec(k.url.toLowerCase()),k.crossDomain=!(!c||c[1]===yb[1]&&c[2]===yb[2]&&(c[3]||("http:"===c[1]?"80":"443"))===(yb[3]||("http:"===yb[1]?"80":"443")))),k.data&&k.processData&&"string"!=typeof k.data&&(k.data=m.param(k.data,k.traditional)),Mb(Hb,k,b,v),2===t)return v;h=m.event&&k.global,h&&0===m.active++&&m.event.trigger("ajaxStart"),k.type=k.type.toUpperCase(),k.hasContent=!Eb.test(k.type),e=k.url,k.hasContent||(k.data&&(e=k.url+=(wb.test(e)?"&":"?")+k.data,delete k.data),k.cache===!1&&(k.url=Bb.test(e)?e.replace(Bb,"$1_="+vb++):e+(wb.test(e)?"&":"?")+"_="+vb++)),k.ifModified&&(m.lastModified[e]&&v.setRequestHeader("If-Modified-Since",m.lastModified[e]),m.etag[e]&&v.setRequestHeader("If-None-Match",m.etag[e])),(k.data&&k.hasContent&&k.contentType!==!1||b.contentType)&&v.setRequestHeader("Content-Type",k.contentType),v.setRequestHeader("Accept",k.dataTypes[0]&&k.accepts[k.dataTypes[0]]?k.accepts[k.dataTypes[0]]+("*"!==k.dataTypes[0]?", "+Jb+"; q=0.01":""):k.accepts["*"]);for(d in k.headers)v.setRequestHeader(d,k.headers[d]);if(k.beforeSend&&(k.beforeSend.call(l,v,k)===!1||2===t))return v.abort();u="abort";for(d in{success:1,error:1,complete:1})v[d](k[d]);if(i=Mb(Ib,k,b,v)){v.readyState=1,h&&n.trigger("ajaxSend",[v,k]),k.async&&k.timeout>0&&(g=setTimeout(function(){v.abort("timeout")},k.timeout));try{t=1,i.send(r,x)}catch(w){if(!(2>t))throw w;x(-1,w)}}else x(-1,"No Transport");function x(a,b,c,d){var j,r,s,u,w,x=b;2!==t&&(t=2,g&&clearTimeout(g),i=void 0,f=d||"",v.readyState=a>0?4:0,j=a>=200&&300>a||304===a,c&&(u=Ob(k,v,c)),u=Pb(k,u,v,j),j?(k.ifModified&&(w=v.getResponseHeader("Last-Modified"),w&&(m.lastModified[e]=w),w=v.getResponseHeader("etag"),w&&(m.etag[e]=w)),204===a||"HEAD"===k.type?x="nocontent":304===a?x="notmodified":(x=u.state,r=u.data,s=u.error,j=!s)):(s=x,(a||!x)&&(x="error",0>a&&(a=0))),v.status=a,v.statusText=(b||x)+"",j?o.resolveWith(l,[r,x,v]):o.rejectWith(l,[v,x,s]),v.statusCode(q),q=void 0,h&&n.trigger(j?"ajaxSuccess":"ajaxError",[v,k,j?r:s]),p.fireWith(l,[v,x]),h&&(n.trigger("ajaxComplete",[v,k]),--m.active||m.event.trigger("ajaxStop")))}return v},getJSON:function(a,b,c){return m.get(a,b,c,"json")},getScript:function(a,b){return m.get(a,void 0,b,"script")}}),m.each(["get","post"],function(a,b){m[b]=function(a,c,d,e){return m.isFunction(c)&&(e=e||d,d=c,c=void 0),m.ajax({url:a,type:b,dataType:e,data:c,success:d})}}),m._evalUrl=function(a){return m.ajax({url:a,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})},m.fn.extend({wrapAll:function(a){if(m.isFunction(a))return this.each(function(b){m(this).wrapAll(a.call(this,b))});if(this[0]){var b=m(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&1===a.firstChild.nodeType)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){return this.each(m.isFunction(a)?function(b){m(this).wrapInner(a.call(this,b))}:function(){var b=m(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=m.isFunction(a);return this.each(function(c){m(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){m.nodeName(this,"body")||m(this).replaceWith(this.childNodes)}).end()}}),m.expr.filters.hidden=function(a){return a.offsetWidth<=0&&a.offsetHeight<=0||!k.reliableHiddenOffsets()&&"none"===(a.style&&a.style.display||m.css(a,"display"))},m.expr.filters.visible=function(a){return!m.expr.filters.hidden(a)};var Qb=/%20/g,Rb=/\[\]$/,Sb=/\r?\n/g,Tb=/^(?:submit|button|image|reset|file)$/i,Ub=/^(?:input|select|textarea|keygen)/i;function Vb(a,b,c,d){var e;if(m.isArray(b))m.each(b,function(b,e){c||Rb.test(a)?d(a,e):Vb(a+"["+("object"==typeof e?b:"")+"]",e,c,d)});else if(c||"object"!==m.type(b))d(a,b);else for(e in b)Vb(a+"["+e+"]",b[e],c,d)}m.param=function(a,b){var c,d=[],e=function(a,b){b=m.isFunction(b)?b():null==b?"":b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};if(void 0===b&&(b=m.ajaxSettings&&m.ajaxSettings.traditional),m.isArray(a)||a.jquery&&!m.isPlainObject(a))m.each(a,function(){e(this.name,this.value)});else for(c in a)Vb(c,a[c],b,e);return d.join("&").replace(Qb,"+")},m.fn.extend({serialize:function(){return m.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=m.prop(this,"elements");return a?m.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!m(this).is(":disabled")&&Ub.test(this.nodeName)&&!Tb.test(a)&&(this.checked||!W.test(a))}).map(function(a,b){var c=m(this).val();return null==c?null:m.isArray(c)?m.map(c,function(a){return{name:b.name,value:a.replace(Sb,"\r\n")}}):{name:b.name,value:c.replace(Sb,"\r\n")}}).get()}}),m.ajaxSettings.xhr=void 0!==a.ActiveXObject?function(){return!this.isLocal&&/^(get|post|head|put|delete|options)$/i.test(this.type)&&Zb()||$b()}:Zb;var Wb=0,Xb={},Yb=m.ajaxSettings.xhr();a.attachEvent&&a.attachEvent("onunload",function(){for(var a in Xb)Xb[a](void 0,!0)}),k.cors=!!Yb&&"withCredentials"in Yb,Yb=k.ajax=!!Yb,Yb&&m.ajaxTransport(function(a){if(!a.crossDomain||k.cors){var b;return{send:function(c,d){var e,f=a.xhr(),g=++Wb;if(f.open(a.type,a.url,a.async,a.username,a.password),a.xhrFields)for(e in a.xhrFields)f[e]=a.xhrFields[e];a.mimeType&&f.overrideMimeType&&f.overrideMimeType(a.mimeType),a.crossDomain||c["X-Requested-With"]||(c["X-Requested-With"]="XMLHttpRequest");for(e in c)void 0!==c[e]&&f.setRequestHeader(e,c[e]+"");f.send(a.hasContent&&a.data||null),b=function(c,e){var h,i,j;if(b&&(e||4===f.readyState))if(delete Xb[g],b=void 0,f.onreadystatechange=m.noop,e)4!==f.readyState&&f.abort();else{j={},h=f.status,"string"==typeof f.responseText&&(j.text=f.responseText);try{i=f.statusText}catch(k){i=""}h||!a.isLocal||a.crossDomain?1223===h&&(h=204):h=j.text?200:404}j&&d(h,i,j,f.getAllResponseHeaders())},a.async?4===f.readyState?setTimeout(b):f.onreadystatechange=Xb[g]=b:b()},abort:function(){b&&b(void 0,!0)}}}});function Zb(){try{return new a.XMLHttpRequest}catch(b){}}function $b(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}m.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(a){return m.globalEval(a),a}}}),m.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),m.ajaxTransport("script",function(a){if(a.crossDomain){var b,c=y.head||m("head")[0]||y.documentElement;return{send:function(d,e){b=y.createElement("script"),b.async=!0,a.scriptCharset&&(b.charset=a.scriptCharset),b.src=a.url,b.onload=b.onreadystatechange=function(a,c){(c||!b.readyState||/loaded|complete/.test(b.readyState))&&(b.onload=b.onreadystatechange=null,b.parentNode&&b.parentNode.removeChild(b),b=null,c||e(200,"success"))},c.insertBefore(b,c.firstChild)},abort:function(){b&&b.onload(void 0,!0)}}}});var _b=[],ac=/(=)\?(?=&|$)|\?\?/;m.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=_b.pop()||m.expando+"_"+vb++;return this[a]=!0,a}}),m.ajaxPrefilter("json jsonp",function(b,c,d){var e,f,g,h=b.jsonp!==!1&&(ac.test(b.url)?"url":"string"==typeof b.data&&!(b.contentType||"").indexOf("application/x-www-form-urlencoded")&&ac.test(b.data)&&"data");return h||"jsonp"===b.dataTypes[0]?(e=b.jsonpCallback=m.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,h?b[h]=b[h].replace(ac,"$1"+e):b.jsonp!==!1&&(b.url+=(wb.test(b.url)?"&":"?")+b.jsonp+"="+e),b.converters["script json"]=function(){return g||m.error(e+" was not called"),g[0]},b.dataTypes[0]="json",f=a[e],a[e]=function(){g=arguments},d.always(function(){a[e]=f,b[e]&&(b.jsonpCallback=c.jsonpCallback,_b.push(e)),g&&m.isFunction(f)&&f(g[0]),g=f=void 0}),"script"):void 0}),m.parseHTML=function(a,b,c){if(!a||"string"!=typeof a)return null;"boolean"==typeof b&&(c=b,b=!1),b=b||y;var d=u.exec(a),e=!c&&[];return d?[b.createElement(d[1])]:(d=m.buildFragment([a],b,e),e&&e.length&&m(e).remove(),m.merge([],d.childNodes))};var bc=m.fn.load;m.fn.load=function(a,b,c){if("string"!=typeof a&&bc)return bc.apply(this,arguments);var d,e,f,g=this,h=a.indexOf(" ");return h>=0&&(d=m.trim(a.slice(h,a.length)),a=a.slice(0,h)),m.isFunction(b)?(c=b,b=void 0):b&&"object"==typeof b&&(f="POST"),g.length>0&&m.ajax({url:a,type:f,dataType:"html",data:b}).done(function(a){e=arguments,g.html(d?m("<div>").append(m.parseHTML(a)).find(d):a)}).complete(c&&function(a,b){g.each(c,e||[a.responseText,b,a])}),this},m.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){m.fn[b]=function(a){return this.on(b,a)}}),m.expr.filters.animated=function(a){return m.grep(m.timers,function(b){return a===b.elem}).length};var cc=a.document.documentElement;function dc(a){return m.isWindow(a)?a:9===a.nodeType?a.defaultView||a.parentWindow:!1}m.offset={setOffset:function(a,b,c){var d,e,f,g,h,i,j,k=m.css(a,"position"),l=m(a),n={};"static"===k&&(a.style.position="relative"),h=l.offset(),f=m.css(a,"top"),i=m.css(a,"left"),j=("absolute"===k||"fixed"===k)&&m.inArray("auto",[f,i])>-1,j?(d=l.position(),g=d.top,e=d.left):(g=parseFloat(f)||0,e=parseFloat(i)||0),m.isFunction(b)&&(b=b.call(a,c,h)),null!=b.top&&(n.top=b.top-h.top+g),null!=b.left&&(n.left=b.left-h.left+e),"using"in b?b.using.call(a,n):l.css(n)}},m.fn.extend({offset:function(a){if(arguments.length)return void 0===a?this:this.each(function(b){m.offset.setOffset(this,a,b)});var b,c,d={top:0,left:0},e=this[0],f=e&&e.ownerDocument;if(f)return b=f.documentElement,m.contains(b,e)?(typeof e.getBoundingClientRect!==K&&(d=e.getBoundingClientRect()),c=dc(f),{top:d.top+(c.pageYOffset||b.scrollTop)-(b.clientTop||0),left:d.left+(c.pageXOffset||b.scrollLeft)-(b.clientLeft||0)}):d},position:function(){if(this[0]){var a,b,c={top:0,left:0},d=this[0];return"fixed"===m.css(d,"position")?b=d.getBoundingClientRect():(a=this.offsetParent(),b=this.offset(),m.nodeName(a[0],"html")||(c=a.offset()),c.top+=m.css(a[0],"borderTopWidth",!0),c.left+=m.css(a[0],"borderLeftWidth",!0)),{top:b.top-c.top-m.css(d,"marginTop",!0),left:b.left-c.left-m.css(d,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||cc;while(a&&!m.nodeName(a,"html")&&"static"===m.css(a,"position"))a=a.offsetParent;return a||cc})}}),m.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,b){var c=/Y/.test(b);m.fn[a]=function(d){return V(this,function(a,d,e){var f=dc(a);return void 0===e?f?b in f?f[b]:f.document.documentElement[d]:a[d]:void(f?f.scrollTo(c?m(f).scrollLeft():e,c?e:m(f).scrollTop()):a[d]=e)},a,d,arguments.length,null)}}),m.each(["top","left"],function(a,b){m.cssHooks[b]=La(k.pixelPosition,function(a,c){return c?(c=Ja(a,b),Ha.test(c)?m(a).position()[b]+"px":c):void 0})}),m.each({Height:"height",Width:"width"},function(a,b){m.each({padding:"inner"+a,content:b,"":"outer"+a},function(c,d){m.fn[d]=function(d,e){var f=arguments.length&&(c||"boolean"!=typeof d),g=c||(d===!0||e===!0?"margin":"border");return V(this,function(b,c,d){var e;return m.isWindow(b)?b.document.documentElement["client"+a]:9===b.nodeType?(e=b.documentElement,Math.max(b.body["scroll"+a],e["scroll"+a],b.body["offset"+a],e["offset"+a],e["client"+a])):void 0===d?m.css(b,c,g):m.style(b,c,d,g)},b,f?d:void 0,f,null)}})}),m.fn.size=function(){return this.length},m.fn.andSelf=m.fn.addBack,"function"==typeof define&&define.amd&&define("jquery",[],function(){return m});var ec=a.jQuery,fc=a.$;return m.noConflict=function(b){return a.$===m&&(a.$=fc),b&&a.jQuery===m&&(a.jQuery=ec),m},typeof b===K&&(a.jQuery=a.$=m),m});
  66864. /*!
  66865. * Bootstrap v3.3.6 (http://getbootstrap.com)
  66866. * Copyright 2011-2015 Twitter, Inc.
  66867. * Licensed under the MIT license
  66868. */
  66869. if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");+function(a){"use strict";var b=a.fn.jquery.split(" ")[0].split(".");if(b[0]<2&&b[1]<9||1==b[0]&&9==b[1]&&b[2]<1||b[0]>2)throw new Error("Bootstrap's JavaScript requires jQuery version 1.9.1 or higher, but lower than version 3")}(jQuery),+function(a){"use strict";function b(){var a=document.createElement("bootstrap"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var c in b)if(void 0!==a.style[c])return{end:b[c]};return!1}a.fn.emulateTransitionEnd=function(b){var c=!1,d=this;a(this).one("bsTransitionEnd",function(){c=!0});var e=function(){c||a(d).trigger(a.support.transition.end)};return setTimeout(e,b),this},a(function(){a.support.transition=b(),a.support.transition&&(a.event.special.bsTransitionEnd={bindType:a.support.transition.end,delegateType:a.support.transition.end,handle:function(b){return a(b.target).is(this)?b.handleObj.handler.apply(this,arguments):void 0}})})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var c=a(this),e=c.data("bs.alert");e||c.data("bs.alert",e=new d(this)),"string"==typeof b&&e[b].call(c)})}var c='[data-dismiss="alert"]',d=function(b){a(b).on("click",c,this.close)};d.VERSION="3.3.6",d.TRANSITION_DURATION=150,d.prototype.close=function(b){function c(){g.detach().trigger("closed.bs.alert").remove()}var e=a(this),f=e.attr("data-target");f||(f=e.attr("href"),f=f&&f.replace(/.*(?=#[^\s]*$)/,""));var g=a(f);b&&b.preventDefault(),g.length||(g=e.closest(".alert")),g.trigger(b=a.Event("close.bs.alert")),b.isDefaultPrevented()||(g.removeClass("in"),a.support.transition&&g.hasClass("fade")?g.one("bsTransitionEnd",c).emulateTransitionEnd(d.TRANSITION_DURATION):c())};var e=a.fn.alert;a.fn.alert=b,a.fn.alert.Constructor=d,a.fn.alert.noConflict=function(){return a.fn.alert=e,this},a(document).on("click.bs.alert.data-api",c,d.prototype.close)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.button"),f="object"==typeof b&&b;e||d.data("bs.button",e=new c(this,f)),"toggle"==b?e.toggle():b&&e.setState(b)})}var c=function(b,d){this.$element=a(b),this.options=a.extend({},c.DEFAULTS,d),this.isLoading=!1};c.VERSION="3.3.6",c.DEFAULTS={loadingText:"loading..."},c.prototype.setState=function(b){var c="disabled",d=this.$element,e=d.is("input")?"val":"html",f=d.data();b+="Text",null==f.resetText&&d.data("resetText",d[e]()),setTimeout(a.proxy(function(){d[e](null==f[b]?this.options[b]:f[b]),"loadingText"==b?(this.isLoading=!0,d.addClass(c).attr(c,c)):this.isLoading&&(this.isLoading=!1,d.removeClass(c).removeAttr(c))},this),0)},c.prototype.toggle=function(){var a=!0,b=this.$element.closest('[data-toggle="buttons"]');if(b.length){var c=this.$element.find("input");"radio"==c.prop("type")?(c.prop("checked")&&(a=!1),b.find(".active").removeClass("active"),this.$element.addClass("active")):"checkbox"==c.prop("type")&&(c.prop("checked")!==this.$element.hasClass("active")&&(a=!1),this.$element.toggleClass("active")),c.prop("checked",this.$element.hasClass("active")),a&&c.trigger("change")}else this.$element.attr("aria-pressed",!this.$element.hasClass("active")),this.$element.toggleClass("active")};var d=a.fn.button;a.fn.button=b,a.fn.button.Constructor=c,a.fn.button.noConflict=function(){return a.fn.button=d,this},a(document).on("click.bs.button.data-api",'[data-toggle^="button"]',function(c){var d=a(c.target);d.hasClass("btn")||(d=d.closest(".btn")),b.call(d,"toggle"),a(c.target).is('input[type="radio"]')||a(c.target).is('input[type="checkbox"]')||c.preventDefault()}).on("focus.bs.button.data-api blur.bs.button.data-api",'[data-toggle^="button"]',function(b){a(b.target).closest(".btn").toggleClass("focus",/^focus(in)?$/.test(b.type))})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.carousel"),f=a.extend({},c.DEFAULTS,d.data(),"object"==typeof b&&b),g="string"==typeof b?b:f.slide;e||d.data("bs.carousel",e=new c(this,f)),"number"==typeof b?e.to(b):g?e[g]():f.interval&&e.pause().cycle()})}var c=function(b,c){this.$element=a(b),this.$indicators=this.$element.find(".carousel-indicators"),this.options=c,this.paused=null,this.sliding=null,this.interval=null,this.$active=null,this.$items=null,this.options.keyboard&&this.$element.on("keydown.bs.carousel",a.proxy(this.keydown,this)),"hover"==this.options.pause&&!("ontouchstart"in document.documentElement)&&this.$element.on("mouseenter.bs.carousel",a.proxy(this.pause,this)).on("mouseleave.bs.carousel",a.proxy(this.cycle,this))};c.VERSION="3.3.6",c.TRANSITION_DURATION=600,c.DEFAULTS={interval:5e3,pause:"hover",wrap:!0,keyboard:!0},c.prototype.keydown=function(a){if(!/input|textarea/i.test(a.target.tagName)){switch(a.which){case 37:this.prev();break;case 39:this.next();break;default:return}a.preventDefault()}},c.prototype.cycle=function(b){return b||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(a.proxy(this.next,this),this.options.interval)),this},c.prototype.getItemIndex=function(a){return this.$items=a.parent().children(".item"),this.$items.index(a||this.$active)},c.prototype.getItemForDirection=function(a,b){var c=this.getItemIndex(b),d="prev"==a&&0===c||"next"==a&&c==this.$items.length-1;if(d&&!this.options.wrap)return b;var e="prev"==a?-1:1,f=(c+e)%this.$items.length;return this.$items.eq(f)},c.prototype.to=function(a){var b=this,c=this.getItemIndex(this.$active=this.$element.find(".item.active"));return a>this.$items.length-1||0>a?void 0:this.sliding?this.$element.one("slid.bs.carousel",function(){b.to(a)}):c==a?this.pause().cycle():this.slide(a>c?"next":"prev",this.$items.eq(a))},c.prototype.pause=function(b){return b||(this.paused=!0),this.$element.find(".next, .prev").length&&a.support.transition&&(this.$element.trigger(a.support.transition.end),this.cycle(!0)),this.interval=clearInterval(this.interval),this},c.prototype.next=function(){return this.sliding?void 0:this.slide("next")},c.prototype.prev=function(){return this.sliding?void 0:this.slide("prev")},c.prototype.slide=function(b,d){var e=this.$element.find(".item.active"),f=d||this.getItemForDirection(b,e),g=this.interval,h="next"==b?"left":"right",i=this;if(f.hasClass("active"))return this.sliding=!1;var j=f[0],k=a.Event("slide.bs.carousel",{relatedTarget:j,direction:h});if(this.$element.trigger(k),!k.isDefaultPrevented()){if(this.sliding=!0,g&&this.pause(),this.$indicators.length){this.$indicators.find(".active").removeClass("active");var l=a(this.$indicators.children()[this.getItemIndex(f)]);l&&l.addClass("active")}var m=a.Event("slid.bs.carousel",{relatedTarget:j,direction:h});return a.support.transition&&this.$element.hasClass("slide")?(f.addClass(b),f[0].offsetWidth,e.addClass(h),f.addClass(h),e.one("bsTransitionEnd",function(){f.removeClass([b,h].join(" ")).addClass("active"),e.removeClass(["active",h].join(" ")),i.sliding=!1,setTimeout(function(){i.$element.trigger(m)},0)}).emulateTransitionEnd(c.TRANSITION_DURATION)):(e.removeClass("active"),f.addClass("active"),this.sliding=!1,this.$element.trigger(m)),g&&this.cycle(),this}};var d=a.fn.carousel;a.fn.carousel=b,a.fn.carousel.Constructor=c,a.fn.carousel.noConflict=function(){return a.fn.carousel=d,this};var e=function(c){var d,e=a(this),f=a(e.attr("data-target")||(d=e.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,""));if(f.hasClass("carousel")){var g=a.extend({},f.data(),e.data()),h=e.attr("data-slide-to");h&&(g.interval=!1),b.call(f,g),h&&f.data("bs.carousel").to(h),c.preventDefault()}};a(document).on("click.bs.carousel.data-api","[data-slide]",e).on("click.bs.carousel.data-api","[data-slide-to]",e),a(window).on("load",function(){a('[data-ride="carousel"]').each(function(){var c=a(this);b.call(c,c.data())})})}(jQuery),+function(a){"use strict";function b(b){var c,d=b.attr("data-target")||(c=b.attr("href"))&&c.replace(/.*(?=#[^\s]+$)/,"");return a(d)}function c(b){return this.each(function(){var c=a(this),e=c.data("bs.collapse"),f=a.extend({},d.DEFAULTS,c.data(),"object"==typeof b&&b);!e&&f.toggle&&/show|hide/.test(b)&&(f.toggle=!1),e||c.data("bs.collapse",e=new d(this,f)),"string"==typeof b&&e[b]()})}var d=function(b,c){this.$element=a(b),this.options=a.extend({},d.DEFAULTS,c),this.$trigger=a('[data-toggle="collapse"][href="#'+b.id+'"],[data-toggle="collapse"][data-target="#'+b.id+'"]'),this.transitioning=null,this.options.parent?this.$parent=this.getParent():this.addAriaAndCollapsedClass(this.$element,this.$trigger),this.options.toggle&&this.toggle()};d.VERSION="3.3.6",d.TRANSITION_DURATION=350,d.DEFAULTS={toggle:!0},d.prototype.dimension=function(){var a=this.$element.hasClass("width");return a?"width":"height"},d.prototype.show=function(){if(!this.transitioning&&!this.$element.hasClass("in")){var b,e=this.$parent&&this.$parent.children(".panel").children(".in, .collapsing");if(!(e&&e.length&&(b=e.data("bs.collapse"),b&&b.transitioning))){var f=a.Event("show.bs.collapse");if(this.$element.trigger(f),!f.isDefaultPrevented()){e&&e.length&&(c.call(e,"hide"),b||e.data("bs.collapse",null));var g=this.dimension();this.$element.removeClass("collapse").addClass("collapsing")[g](0).attr("aria-expanded",!0),this.$trigger.removeClass("collapsed").attr("aria-expanded",!0),this.transitioning=1;var h=function(){this.$element.removeClass("collapsing").addClass("collapse in")[g](""),this.transitioning=0,this.$element.trigger("shown.bs.collapse")};if(!a.support.transition)return h.call(this);var i=a.camelCase(["scroll",g].join("-"));this.$element.one("bsTransitionEnd",a.proxy(h,this)).emulateTransitionEnd(d.TRANSITION_DURATION)[g](this.$element[0][i])}}}},d.prototype.hide=function(){if(!this.transitioning&&this.$element.hasClass("in")){var b=a.Event("hide.bs.collapse");if(this.$element.trigger(b),!b.isDefaultPrevented()){var c=this.dimension();this.$element[c](this.$element[c]())[0].offsetHeight,this.$element.addClass("collapsing").removeClass("collapse in").attr("aria-expanded",!1),this.$trigger.addClass("collapsed").attr("aria-expanded",!1),this.transitioning=1;var e=function(){this.transitioning=0,this.$element.removeClass("collapsing").addClass("collapse").trigger("hidden.bs.collapse")};return a.support.transition?void this.$element[c](0).one("bsTransitionEnd",a.proxy(e,this)).emulateTransitionEnd(d.TRANSITION_DURATION):e.call(this)}}},d.prototype.toggle=function(){this[this.$element.hasClass("in")?"hide":"show"]()},d.prototype.getParent=function(){return a(this.options.parent).find('[data-toggle="collapse"][data-parent="'+this.options.parent+'"]').each(a.proxy(function(c,d){var e=a(d);this.addAriaAndCollapsedClass(b(e),e)},this)).end()},d.prototype.addAriaAndCollapsedClass=function(a,b){var c=a.hasClass("in");a.attr("aria-expanded",c),b.toggleClass("collapsed",!c).attr("aria-expanded",c)};var e=a.fn.collapse;a.fn.collapse=c,a.fn.collapse.Constructor=d,a.fn.collapse.noConflict=function(){return a.fn.collapse=e,this},a(document).on("click.bs.collapse.data-api",'[data-toggle="collapse"]',function(d){var e=a(this);e.attr("data-target")||d.preventDefault();var f=b(e),g=f.data("bs.collapse"),h=g?"toggle":e.data();c.call(f,h)})}(jQuery),+function(a){"use strict";function b(b){var c=b.attr("data-target");c||(c=b.attr("href"),c=c&&/#[A-Za-z]/.test(c)&&c.replace(/.*(?=#[^\s]*$)/,""));var d=c&&a(c);return d&&d.length?d:b.parent()}function c(c){c&&3===c.which||(a(e).remove(),a(f).each(function(){var d=a(this),e=b(d),f={relatedTarget:this};e.hasClass("open")&&(c&&"click"==c.type&&/input|textarea/i.test(c.target.tagName)&&a.contains(e[0],c.target)||(e.trigger(c=a.Event("hide.bs.dropdown",f)),c.isDefaultPrevented()||(d.attr("aria-expanded","false"),e.removeClass("open").trigger(a.Event("hidden.bs.dropdown",f)))))}))}function d(b){return this.each(function(){var c=a(this),d=c.data("bs.dropdown");d||c.data("bs.dropdown",d=new g(this)),"string"==typeof b&&d[b].call(c)})}var e=".dropdown-backdrop",f='[data-toggle="dropdown"]',g=function(b){a(b).on("click.bs.dropdown",this.toggle)};g.VERSION="3.3.6",g.prototype.toggle=function(d){var e=a(this);if(!e.is(".disabled, :disabled")){var f=b(e),g=f.hasClass("open");if(c(),!g){"ontouchstart"in document.documentElement&&!f.closest(".navbar-nav").length&&a(document.createElement("div")).addClass("dropdown-backdrop").insertAfter(a(this)).on("click",c);var h={relatedTarget:this};if(f.trigger(d=a.Event("show.bs.dropdown",h)),d.isDefaultPrevented())return;e.trigger("focus").attr("aria-expanded","true"),f.toggleClass("open").trigger(a.Event("shown.bs.dropdown",h))}return!1}},g.prototype.keydown=function(c){if(/(38|40|27|32)/.test(c.which)&&!/input|textarea/i.test(c.target.tagName)){var d=a(this);if(c.preventDefault(),c.stopPropagation(),!d.is(".disabled, :disabled")){var e=b(d),g=e.hasClass("open");if(!g&&27!=c.which||g&&27==c.which)return 27==c.which&&e.find(f).trigger("focus"),d.trigger("click");var h=" li:not(.disabled):visible a",i=e.find(".dropdown-menu"+h);if(i.length){var j=i.index(c.target);38==c.which&&j>0&&j--,40==c.which&&j<i.length-1&&j++,~j||(j=0),i.eq(j).trigger("focus")}}}};var h=a.fn.dropdown;a.fn.dropdown=d,a.fn.dropdown.Constructor=g,a.fn.dropdown.noConflict=function(){return a.fn.dropdown=h,this},a(document).on("click.bs.dropdown.data-api",c).on("click.bs.dropdown.data-api",".dropdown form",function(a){a.stopPropagation()}).on("click.bs.dropdown.data-api",f,g.prototype.toggle).on("keydown.bs.dropdown.data-api",f,g.prototype.keydown).on("keydown.bs.dropdown.data-api",".dropdown-menu",g.prototype.keydown)}(jQuery),+function(a){"use strict";function b(b,d){return this.each(function(){var e=a(this),f=e.data("bs.modal"),g=a.extend({},c.DEFAULTS,e.data(),"object"==typeof b&&b);f||e.data("bs.modal",f=new c(this,g)),"string"==typeof b?f[b](d):g.show&&f.show(d)})}var c=function(b,c){this.options=c,this.$body=a(document.body),this.$element=a(b),this.$dialog=this.$element.find(".modal-dialog"),this.$backdrop=null,this.isShown=null,this.originalBodyPad=null,this.scrollbarWidth=0,this.ignoreBackdropClick=!1,this.options.remote&&this.$element.find(".modal-content").load(this.options.remote,a.proxy(function(){this.$element.trigger("loaded.bs.modal")},this))};c.VERSION="3.3.6",c.TRANSITION_DURATION=300,c.BACKDROP_TRANSITION_DURATION=150,c.DEFAULTS={backdrop:!0,keyboard:!0,show:!0},c.prototype.toggle=function(a){return this.isShown?this.hide():this.show(a)},c.prototype.show=function(b){var d=this,e=a.Event("show.bs.modal",{relatedTarget:b});this.$element.trigger(e),this.isShown||e.isDefaultPrevented()||(this.isShown=!0,this.checkScrollbar(),this.setScrollbar(),this.$body.addClass("modal-open"),this.escape(),this.resize(),this.$element.on("click.dismiss.bs.modal",'[data-dismiss="modal"]',a.proxy(this.hide,this)),this.$dialog.on("mousedown.dismiss.bs.modal",function(){d.$element.one("mouseup.dismiss.bs.modal",function(b){a(b.target).is(d.$element)&&(d.ignoreBackdropClick=!0)})}),this.backdrop(function(){var e=a.support.transition&&d.$element.hasClass("fade");d.$element.parent().length||d.$element.appendTo(d.$body),d.$element.show().scrollTop(0),d.adjustDialog(),e&&d.$element[0].offsetWidth,d.$element.addClass("in"),d.enforceFocus();var f=a.Event("shown.bs.modal",{relatedTarget:b});e?d.$dialog.one("bsTransitionEnd",function(){d.$element.trigger("focus").trigger(f)}).emulateTransitionEnd(c.TRANSITION_DURATION):d.$element.trigger("focus").trigger(f)}))},c.prototype.hide=function(b){b&&b.preventDefault(),b=a.Event("hide.bs.modal"),this.$element.trigger(b),this.isShown&&!b.isDefaultPrevented()&&(this.isShown=!1,this.escape(),this.resize(),a(document).off("focusin.bs.modal"),this.$element.removeClass("in").off("click.dismiss.bs.modal").off("mouseup.dismiss.bs.modal"),this.$dialog.off("mousedown.dismiss.bs.modal"),a.support.transition&&this.$element.hasClass("fade")?this.$element.one("bsTransitionEnd",a.proxy(this.hideModal,this)).emulateTransitionEnd(c.TRANSITION_DURATION):this.hideModal())},c.prototype.enforceFocus=function(){a(document).off("focusin.bs.modal").on("focusin.bs.modal",a.proxy(function(a){this.$element[0]===a.target||this.$element.has(a.target).length||this.$element.trigger("focus")},this))},c.prototype.escape=function(){this.isShown&&this.options.keyboard?this.$element.on("keydown.dismiss.bs.modal",a.proxy(function(a){27==a.which&&this.hide()},this)):this.isShown||this.$element.off("keydown.dismiss.bs.modal")},c.prototype.resize=function(){this.isShown?a(window).on("resize.bs.modal",a.proxy(this.handleUpdate,this)):a(window).off("resize.bs.modal")},c.prototype.hideModal=function(){var a=this;this.$element.hide(),this.backdrop(function(){a.$body.removeClass("modal-open"),a.resetAdjustments(),a.resetScrollbar(),a.$element.trigger("hidden.bs.modal")})},c.prototype.removeBackdrop=function(){this.$backdrop&&this.$backdrop.remove(),this.$backdrop=null},c.prototype.backdrop=function(b){var d=this,e=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var f=a.support.transition&&e;if(this.$backdrop=a(document.createElement("div")).addClass("modal-backdrop "+e).appendTo(this.$body),this.$element.on("click.dismiss.bs.modal",a.proxy(function(a){return this.ignoreBackdropClick?void(this.ignoreBackdropClick=!1):void(a.target===a.currentTarget&&("static"==this.options.backdrop?this.$element[0].focus():this.hide()))},this)),f&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in"),!b)return;f?this.$backdrop.one("bsTransitionEnd",b).emulateTransitionEnd(c.BACKDROP_TRANSITION_DURATION):b()}else if(!this.isShown&&this.$backdrop){this.$backdrop.removeClass("in");var g=function(){d.removeBackdrop(),b&&b()};a.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one("bsTransitionEnd",g).emulateTransitionEnd(c.BACKDROP_TRANSITION_DURATION):g()}else b&&b()},c.prototype.handleUpdate=function(){this.adjustDialog()},c.prototype.adjustDialog=function(){var a=this.$element[0].scrollHeight>document.documentElement.clientHeight;this.$element.css({paddingLeft:!this.bodyIsOverflowing&&a?this.scrollbarWidth:"",paddingRight:this.bodyIsOverflowing&&!a?this.scrollbarWidth:""})},c.prototype.resetAdjustments=function(){this.$element.css({paddingLeft:"",paddingRight:""})},c.prototype.checkScrollbar=function(){var a=window.innerWidth;if(!a){var b=document.documentElement.getBoundingClientRect();a=b.right-Math.abs(b.left)}this.bodyIsOverflowing=document.body.clientWidth<a,this.scrollbarWidth=this.measureScrollbar()},c.prototype.setScrollbar=function(){var a=parseInt(this.$body.css("padding-right")||0,10);this.originalBodyPad=document.body.style.paddingRight||"",this.bodyIsOverflowing&&this.$body.css("padding-right",a+this.scrollbarWidth)},c.prototype.resetScrollbar=function(){this.$body.css("padding-right",this.originalBodyPad)},c.prototype.measureScrollbar=function(){var a=document.createElement("div");a.className="modal-scrollbar-measure",this.$body.append(a);var b=a.offsetWidth-a.clientWidth;return this.$body[0].removeChild(a),b};var d=a.fn.modal;a.fn.modal=b,a.fn.modal.Constructor=c,a.fn.modal.noConflict=function(){return a.fn.modal=d,this},a(document).on("click.bs.modal.data-api",'[data-toggle="modal"]',function(c){var d=a(this),e=d.attr("href"),f=a(d.attr("data-target")||e&&e.replace(/.*(?=#[^\s]+$)/,"")),g=f.data("bs.modal")?"toggle":a.extend({remote:!/#/.test(e)&&e},f.data(),d.data());d.is("a")&&c.preventDefault(),f.one("show.bs.modal",function(a){a.isDefaultPrevented()||f.one("hidden.bs.modal",function(){d.is(":visible")&&d.trigger("focus")})}),b.call(f,g,this)})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.tooltip"),f="object"==typeof b&&b;(e||!/destroy|hide/.test(b))&&(e||d.data("bs.tooltip",e=new c(this,f)),"string"==typeof b&&e[b]())})}var c=function(a,b){this.type=null,this.options=null,this.enabled=null,this.timeout=null,this.hoverState=null,this.$element=null,this.inState=null,this.init("tooltip",a,b)};c.VERSION="3.3.6",c.TRANSITION_DURATION=150,c.DEFAULTS={animation:!0,placement:"top",selector:!1,template:'<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',trigger:"hover focus",title:"",delay:0,html:!1,container:!1,viewport:{selector:"body",padding:0}},c.prototype.init=function(b,c,d){if(this.enabled=!0,this.type=b,this.$element=a(c),this.options=this.getOptions(d),this.$viewport=this.options.viewport&&a(a.isFunction(this.options.viewport)?this.options.viewport.call(this,this.$element):this.options.viewport.selector||this.options.viewport),this.inState={click:!1,hover:!1,focus:!1},this.$element[0]instanceof document.constructor&&!this.options.selector)throw new Error("`selector` option must be specified when initializing "+this.type+" on the window.document object!");for(var e=this.options.trigger.split(" "),f=e.length;f--;){var g=e[f];if("click"==g)this.$element.on("click."+this.type,this.options.selector,a.proxy(this.toggle,this));else if("manual"!=g){var h="hover"==g?"mouseenter":"focusin",i="hover"==g?"mouseleave":"focusout";this.$element.on(h+"."+this.type,this.options.selector,a.proxy(this.enter,this)),this.$element.on(i+"."+this.type,this.options.selector,a.proxy(this.leave,this))}}this.options.selector?this._options=a.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.getOptions=function(b){return b=a.extend({},this.getDefaults(),this.$element.data(),b),b.delay&&"number"==typeof b.delay&&(b.delay={show:b.delay,hide:b.delay}),b},c.prototype.getDelegateOptions=function(){var b={},c=this.getDefaults();return this._options&&a.each(this._options,function(a,d){c[a]!=d&&(b[a]=d)}),b},c.prototype.enter=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);return c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),b instanceof a.Event&&(c.inState["focusin"==b.type?"focus":"hover"]=!0),c.tip().hasClass("in")||"in"==c.hoverState?void(c.hoverState="in"):(clearTimeout(c.timeout),c.hoverState="in",c.options.delay&&c.options.delay.show?void(c.timeout=setTimeout(function(){"in"==c.hoverState&&c.show()},c.options.delay.show)):c.show())},c.prototype.isInStateTrue=function(){for(var a in this.inState)if(this.inState[a])return!0;return!1},c.prototype.leave=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);return c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),b instanceof a.Event&&(c.inState["focusout"==b.type?"focus":"hover"]=!1),c.isInStateTrue()?void 0:(clearTimeout(c.timeout),c.hoverState="out",c.options.delay&&c.options.delay.hide?void(c.timeout=setTimeout(function(){"out"==c.hoverState&&c.hide()},c.options.delay.hide)):c.hide())},c.prototype.show=function(){var b=a.Event("show.bs."+this.type);if(this.hasContent()&&this.enabled){this.$element.trigger(b);var d=a.contains(this.$element[0].ownerDocument.documentElement,this.$element[0]);if(b.isDefaultPrevented()||!d)return;var e=this,f=this.tip(),g=this.getUID(this.type);this.setContent(),f.attr("id",g),this.$element.attr("aria-describedby",g),this.options.animation&&f.addClass("fade");var h="function"==typeof this.options.placement?this.options.placement.call(this,f[0],this.$element[0]):this.options.placement,i=/\s?auto?\s?/i,j=i.test(h);j&&(h=h.replace(i,"")||"top"),f.detach().css({top:0,left:0,display:"block"}).addClass(h).data("bs."+this.type,this),this.options.container?f.appendTo(this.options.container):f.insertAfter(this.$element),this.$element.trigger("inserted.bs."+this.type);var k=this.getPosition(),l=f[0].offsetWidth,m=f[0].offsetHeight;if(j){var n=h,o=this.getPosition(this.$viewport);h="bottom"==h&&k.bottom+m>o.bottom?"top":"top"==h&&k.top-m<o.top?"bottom":"right"==h&&k.right+l>o.width?"left":"left"==h&&k.left-l<o.left?"right":h,f.removeClass(n).addClass(h)}var p=this.getCalculatedOffset(h,k,l,m);this.applyPlacement(p,h);var q=function(){var a=e.hoverState;e.$element.trigger("shown.bs."+e.type),e.hoverState=null,"out"==a&&e.leave(e)};a.support.transition&&this.$tip.hasClass("fade")?f.one("bsTransitionEnd",q).emulateTransitionEnd(c.TRANSITION_DURATION):q()}},c.prototype.applyPlacement=function(b,c){var d=this.tip(),e=d[0].offsetWidth,f=d[0].offsetHeight,g=parseInt(d.css("margin-top"),10),h=parseInt(d.css("margin-left"),10);isNaN(g)&&(g=0),isNaN(h)&&(h=0),b.top+=g,b.left+=h,a.offset.setOffset(d[0],a.extend({using:function(a){d.css({top:Math.round(a.top),left:Math.round(a.left)})}},b),0),d.addClass("in");var i=d[0].offsetWidth,j=d[0].offsetHeight;"top"==c&&j!=f&&(b.top=b.top+f-j);var k=this.getViewportAdjustedDelta(c,b,i,j);k.left?b.left+=k.left:b.top+=k.top;var l=/top|bottom/.test(c),m=l?2*k.left-e+i:2*k.top-f+j,n=l?"offsetWidth":"offsetHeight";d.offset(b),this.replaceArrow(m,d[0][n],l)},c.prototype.replaceArrow=function(a,b,c){this.arrow().css(c?"left":"top",50*(1-a/b)+"%").css(c?"top":"left","")},c.prototype.setContent=function(){var a=this.tip(),b=this.getTitle();a.find(".tooltip-inner")[this.options.html?"html":"text"](b),a.removeClass("fade in top bottom left right")},c.prototype.hide=function(b){function d(){"in"!=e.hoverState&&f.detach(),e.$element.removeAttr("aria-describedby").trigger("hidden.bs."+e.type),b&&b()}var e=this,f=a(this.$tip),g=a.Event("hide.bs."+this.type);return this.$element.trigger(g),g.isDefaultPrevented()?void 0:(f.removeClass("in"),a.support.transition&&f.hasClass("fade")?f.one("bsTransitionEnd",d).emulateTransitionEnd(c.TRANSITION_DURATION):d(),this.hoverState=null,this)},c.prototype.fixTitle=function(){var a=this.$element;(a.attr("title")||"string"!=typeof a.attr("data-original-title"))&&a.attr("data-original-title",a.attr("title")||"").attr("title","")},c.prototype.hasContent=function(){return this.getTitle()},c.prototype.getPosition=function(b){b=b||this.$element;var c=b[0],d="BODY"==c.tagName,e=c.getBoundingClientRect();null==e.width&&(e=a.extend({},e,{width:e.right-e.left,height:e.bottom-e.top}));var f=d?{top:0,left:0}:b.offset(),g={scroll:d?document.documentElement.scrollTop||document.body.scrollTop:b.scrollTop()},h=d?{width:a(window).width(),height:a(window).height()}:null;return a.extend({},e,g,h,f)},c.prototype.getCalculatedOffset=function(a,b,c,d){return"bottom"==a?{top:b.top+b.height,left:b.left+b.width/2-c/2}:"top"==a?{top:b.top-d,left:b.left+b.width/2-c/2}:"left"==a?{top:b.top+b.height/2-d/2,left:b.left-c}:{top:b.top+b.height/2-d/2,left:b.left+b.width}},c.prototype.getViewportAdjustedDelta=function(a,b,c,d){var e={top:0,left:0};if(!this.$viewport)return e;var f=this.options.viewport&&this.options.viewport.padding||0,g=this.getPosition(this.$viewport);if(/right|left/.test(a)){var h=b.top-f-g.scroll,i=b.top+f-g.scroll+d;h<g.top?e.top=g.top-h:i>g.top+g.height&&(e.top=g.top+g.height-i)}else{var j=b.left-f,k=b.left+f+c;j<g.left?e.left=g.left-j:k>g.right&&(e.left=g.left+g.width-k)}return e},c.prototype.getTitle=function(){var a,b=this.$element,c=this.options;return a=b.attr("data-original-title")||("function"==typeof c.title?c.title.call(b[0]):c.title)},c.prototype.getUID=function(a){do a+=~~(1e6*Math.random());while(document.getElementById(a));return a},c.prototype.tip=function(){if(!this.$tip&&(this.$tip=a(this.options.template),1!=this.$tip.length))throw new Error(this.type+" `template` option must consist of exactly 1 top-level element!");return this.$tip},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},c.prototype.enable=function(){this.enabled=!0},c.prototype.disable=function(){this.enabled=!1},c.prototype.toggleEnabled=function(){this.enabled=!this.enabled},c.prototype.toggle=function(b){var c=this;b&&(c=a(b.currentTarget).data("bs."+this.type),c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c))),b?(c.inState.click=!c.inState.click,c.isInStateTrue()?c.enter(c):c.leave(c)):c.tip().hasClass("in")?c.leave(c):c.enter(c)},c.prototype.destroy=function(){var a=this;clearTimeout(this.timeout),this.hide(function(){a.$element.off("."+a.type).removeData("bs."+a.type),a.$tip&&a.$tip.detach(),a.$tip=null,a.$arrow=null,a.$viewport=null})};var d=a.fn.tooltip;a.fn.tooltip=b,a.fn.tooltip.Constructor=c,a.fn.tooltip.noConflict=function(){return a.fn.tooltip=d,this}}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.popover"),f="object"==typeof b&&b;(e||!/destroy|hide/.test(b))&&(e||d.data("bs.popover",e=new c(this,f)),"string"==typeof b&&e[b]())})}var c=function(a,b){this.init("popover",a,b)};if(!a.fn.tooltip)throw new Error("Popover requires tooltip.js");c.VERSION="3.3.6",c.DEFAULTS=a.extend({},a.fn.tooltip.Constructor.DEFAULTS,{placement:"right",trigger:"click",content:"",template:'<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'}),c.prototype=a.extend({},a.fn.tooltip.Constructor.prototype),c.prototype.constructor=c,c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.setContent=function(){var a=this.tip(),b=this.getTitle(),c=this.getContent();a.find(".popover-title")[this.options.html?"html":"text"](b),a.find(".popover-content").children().detach().end()[this.options.html?"string"==typeof c?"html":"append":"text"](c),a.removeClass("fade top bottom left right in"),a.find(".popover-title").html()||a.find(".popover-title").hide()},c.prototype.hasContent=function(){return this.getTitle()||this.getContent()},c.prototype.getContent=function(){var a=this.$element,b=this.options;return a.attr("data-content")||("function"==typeof b.content?b.content.call(a[0]):b.content)},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")};var d=a.fn.popover;a.fn.popover=b,a.fn.popover.Constructor=c,a.fn.popover.noConflict=function(){return a.fn.popover=d,this}}(jQuery),+function(a){"use strict";function b(c,d){this.$body=a(document.body),this.$scrollElement=a(a(c).is(document.body)?window:c),this.options=a.extend({},b.DEFAULTS,d),this.selector=(this.options.target||"")+" .nav li > a",this.offsets=[],this.targets=[],this.activeTarget=null,this.scrollHeight=0,this.$scrollElement.on("scroll.bs.scrollspy",a.proxy(this.process,this)),this.refresh(),this.process()}function c(c){return this.each(function(){var d=a(this),e=d.data("bs.scrollspy"),f="object"==typeof c&&c;e||d.data("bs.scrollspy",e=new b(this,f)),"string"==typeof c&&e[c]()})}b.VERSION="3.3.6",b.DEFAULTS={offset:10},b.prototype.getScrollHeight=function(){return this.$scrollElement[0].scrollHeight||Math.max(this.$body[0].scrollHeight,document.documentElement.scrollHeight)},b.prototype.refresh=function(){var b=this,c="offset",d=0;this.offsets=[],this.targets=[],this.scrollHeight=this.getScrollHeight(),a.isWindow(this.$scrollElement[0])||(c="position",d=this.$scrollElement.scrollTop()),this.$body.find(this.selector).map(function(){var b=a(this),e=b.data("target")||b.attr("href"),f=/^#./.test(e)&&a(e);return f&&f.length&&f.is(":visible")&&[[f[c]().top+d,e]]||null}).sort(function(a,b){return a[0]-b[0]}).each(function(){b.offsets.push(this[0]),b.targets.push(this[1])})},b.prototype.process=function(){var a,b=this.$scrollElement.scrollTop()+this.options.offset,c=this.getScrollHeight(),d=this.options.offset+c-this.$scrollElement.height(),e=this.offsets,f=this.targets,g=this.activeTarget;if(this.scrollHeight!=c&&this.refresh(),b>=d)return g!=(a=f[f.length-1])&&this.activate(a);if(g&&b<e[0])return this.activeTarget=null,this.clear();for(a=e.length;a--;)g!=f[a]&&b>=e[a]&&(void 0===e[a+1]||b<e[a+1])&&this.activate(f[a])},b.prototype.activate=function(b){this.activeTarget=b,this.clear();var c=this.selector+'[data-target="'+b+'"],'+this.selector+'[href="'+b+'"]',d=a(c).parents("li").addClass("active");
  66870. d.parent(".dropdown-menu").length&&(d=d.closest("li.dropdown").addClass("active")),d.trigger("activate.bs.scrollspy")},b.prototype.clear=function(){a(this.selector).parentsUntil(this.options.target,".active").removeClass("active")};var d=a.fn.scrollspy;a.fn.scrollspy=c,a.fn.scrollspy.Constructor=b,a.fn.scrollspy.noConflict=function(){return a.fn.scrollspy=d,this},a(window).on("load.bs.scrollspy.data-api",function(){a('[data-spy="scroll"]').each(function(){var b=a(this);c.call(b,b.data())})})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.tab");e||d.data("bs.tab",e=new c(this)),"string"==typeof b&&e[b]()})}var c=function(b){this.element=a(b)};c.VERSION="3.3.6",c.TRANSITION_DURATION=150,c.prototype.show=function(){var b=this.element,c=b.closest("ul:not(.dropdown-menu)"),d=b.data("target");if(d||(d=b.attr("href"),d=d&&d.replace(/.*(?=#[^\s]*$)/,"")),!b.parent("li").hasClass("active")){var e=c.find(".active:last a"),f=a.Event("hide.bs.tab",{relatedTarget:b[0]}),g=a.Event("show.bs.tab",{relatedTarget:e[0]});if(e.trigger(f),b.trigger(g),!g.isDefaultPrevented()&&!f.isDefaultPrevented()){var h=a(d);this.activate(b.closest("li"),c),this.activate(h,h.parent(),function(){e.trigger({type:"hidden.bs.tab",relatedTarget:b[0]}),b.trigger({type:"shown.bs.tab",relatedTarget:e[0]})})}}},c.prototype.activate=function(b,d,e){function f(){g.removeClass("active").find("> .dropdown-menu > .active").removeClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!1),b.addClass("active").find('[data-toggle="tab"]').attr("aria-expanded",!0),h?(b[0].offsetWidth,b.addClass("in")):b.removeClass("fade"),b.parent(".dropdown-menu").length&&b.closest("li.dropdown").addClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!0),e&&e()}var g=d.find("> .active"),h=e&&a.support.transition&&(g.length&&g.hasClass("fade")||!!d.find("> .fade").length);g.length&&h?g.one("bsTransitionEnd",f).emulateTransitionEnd(c.TRANSITION_DURATION):f(),g.removeClass("in")};var d=a.fn.tab;a.fn.tab=b,a.fn.tab.Constructor=c,a.fn.tab.noConflict=function(){return a.fn.tab=d,this};var e=function(c){c.preventDefault(),b.call(a(this),"show")};a(document).on("click.bs.tab.data-api",'[data-toggle="tab"]',e).on("click.bs.tab.data-api",'[data-toggle="pill"]',e)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.affix"),f="object"==typeof b&&b;e||d.data("bs.affix",e=new c(this,f)),"string"==typeof b&&e[b]()})}var c=function(b,d){this.options=a.extend({},c.DEFAULTS,d),this.$target=a(this.options.target).on("scroll.bs.affix.data-api",a.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",a.proxy(this.checkPositionWithEventLoop,this)),this.$element=a(b),this.affixed=null,this.unpin=null,this.pinnedOffset=null,this.checkPosition()};c.VERSION="3.3.6",c.RESET="affix affix-top affix-bottom",c.DEFAULTS={offset:0,target:window},c.prototype.getState=function(a,b,c,d){var e=this.$target.scrollTop(),f=this.$element.offset(),g=this.$target.height();if(null!=c&&"top"==this.affixed)return c>e?"top":!1;if("bottom"==this.affixed)return null!=c?e+this.unpin<=f.top?!1:"bottom":a-d>=e+g?!1:"bottom";var h=null==this.affixed,i=h?e:f.top,j=h?g:b;return null!=c&&c>=e?"top":null!=d&&i+j>=a-d?"bottom":!1},c.prototype.getPinnedOffset=function(){if(this.pinnedOffset)return this.pinnedOffset;this.$element.removeClass(c.RESET).addClass("affix");var a=this.$target.scrollTop(),b=this.$element.offset();return this.pinnedOffset=b.top-a},c.prototype.checkPositionWithEventLoop=function(){setTimeout(a.proxy(this.checkPosition,this),1)},c.prototype.checkPosition=function(){if(this.$element.is(":visible")){var b=this.$element.height(),d=this.options.offset,e=d.top,f=d.bottom,g=Math.max(a(document).height(),a(document.body).height());"object"!=typeof d&&(f=e=d),"function"==typeof e&&(e=d.top(this.$element)),"function"==typeof f&&(f=d.bottom(this.$element));var h=this.getState(g,b,e,f);if(this.affixed!=h){null!=this.unpin&&this.$element.css("top","");var i="affix"+(h?"-"+h:""),j=a.Event(i+".bs.affix");if(this.$element.trigger(j),j.isDefaultPrevented())return;this.affixed=h,this.unpin="bottom"==h?this.getPinnedOffset():null,this.$element.removeClass(c.RESET).addClass(i).trigger(i.replace("affix","affixed")+".bs.affix")}"bottom"==h&&this.$element.offset({top:g-b-f})}};var d=a.fn.affix;a.fn.affix=b,a.fn.affix.Constructor=c,a.fn.affix.noConflict=function(){return a.fn.affix=d,this},a(window).on("load",function(){a('[data-spy="affix"]').each(function(){var c=a(this),d=c.data();d.offset=d.offset||{},null!=d.offsetBottom&&(d.offset.bottom=d.offsetBottom),null!=d.offsetTop&&(d.offset.top=d.offsetTop),b.call(c,d)})})}(jQuery);
  66871. // When document is ready initialize app
  66872. $(document).ready(function() {
  66873. var filter = web3.eth.filter('latest');
  66874. filter.watch(function(err, res){
  66875. if(!err){
  66876. updateUI();
  66877. }
  66878. else{
  66879. console.error("!!!!!!Error Happened!");
  66880. filter.stopWatching();
  66881. }
  66882. });
  66883. /// INIT Whisper
  66884. web3.Lib.initWhisper()
  66885. .then(function(w){
  66886. web3.Whisper = w;
  66887. });
  66888. createUI();
  66889. updateUI();
  66890. });
  66891. ///////////////////
  66892. /// UI ////////////
  66893. ///////////////////
  66894. var matchhash;
  66895. var maphash;
  66896. var opAccount;
  66897. var selectBox;
  66898. function createUI(){
  66899. selectBox = document.getElementById("accselector");
  66900. for (var i = 0; i<web3.eth.accounts.length; i++){
  66901. var opt = document.createElement('option');
  66902. opt.value = i;
  66903. opt.innerHTML = web3.eth.accounts[i];
  66904. selectBox.appendChild(opt);
  66905. }
  66906. selectBox.onchange = function(){
  66907. web3.eth.defaultAccount = web3.eth.accounts[selectBox.value];
  66908. updateUI(selectBox.value);
  66909. }
  66910. $("#showMapBtn").click(function(){
  66911. updateMapTable(web3.Game.getMapArray());
  66912. });
  66913. $("#createMatchBtn").click(function(){
  66914. var stake = $("#stakeTxt").val();
  66915. createMatch(stake);
  66916. });
  66917. $("#joinMatchBtn").click(function(){
  66918. var stake = parseInt($("#stakeTxt").val());
  66919. var matchhash = $("#matchhashTxt").val();
  66920. joinMatch(stake, matchhash);
  66921. });
  66922. $("#startGameBtn").click(function(){
  66923. startGame();
  66924. });
  66925. $("#sendSelectMoveBtn").click(function(){
  66926. sendSelectMove();
  66927. });
  66928. $("#sendBetMoveBtn").click(function(){
  66929. sendBetMove();
  66930. });
  66931. $("#sendCallMoveBtn").click(function(){
  66932. sendCallMove();
  66933. });
  66934. $("#sendFoldMoveBtn").click(function(){
  66935. sendFoldMove();
  66936. });
  66937. $("#sendProofMoveBtn").click(function(){
  66938. sendProofMove();
  66939. });
  66940. }
  66941. function updateUI(accindex){
  66942. updateForAccount();
  66943. }
  66944. function updateGameUI(state){
  66945. $("#mycoins").html(state.coins[web3.eth.defaultAccount]);
  66946. $("#opcoins").html(state.coins[web3.eth.opponentAccount]);
  66947. $("#pot").html(state.pot);
  66948. $("#round").html(state.round);
  66949. $("#mybets").html(state.bets[web3.eth.defaultAccount]);
  66950. $("#opbets").html(state.bets[web3.eth.opponentAccount]);
  66951. var sums = web3.Game.findSums();
  66952. $("#mysum").html(sums[web3.eth.defaultAccount]);
  66953. $("#opsum").html(sums[web3.eth.opponentAccount]);
  66954. updateMapTable(web3.Game.getMapArray(), state);
  66955. // console.log("Selected for me: ");
  66956. // console.log(state.selected[web3.eth.defaultAccount]);
  66957. // console.log("Selected for opponent: ");
  66958. // console.log(state.selected[web3.eth.opponentAccount]);
  66959. }
  66960. function updateForAccount(){
  66961. var ethaddr = web3.eth.defaultAccount;
  66962. $("#ethaddr").html(ethaddr);
  66963. var ethbal = web3.eth.getBalance(ethaddr);
  66964. $("#ethbal").html(web3.fromWei(ethbal, "ether").toNumber());
  66965. var blockNumber = web3.eth.blockNumber;
  66966. $("#block").html("#"+blockNumber);
  66967. dbname = web3.db.DBNAME = "CUSTOMDBFOR"+web3.eth.defaultAccount;
  66968. Padomima.amInMatch().then(function(res){
  66969. $("#inmatch").html(res? "Yes": "No");
  66970. if(res){
  66971. Padomima.getMyMatch().then(function(res){
  66972. matchhash = res;
  66973. $("#matchhash").html(res);
  66974. });
  66975. Padomima.getMyStake().then(function(res){
  66976. res = web3.fromWei(res);
  66977. $("#stakeTxt").val(res);
  66978. });
  66979. Padomima.getMyMap().then(function(res){
  66980. maphash = res;
  66981. $("#maphash").html(res);
  66982. });
  66983. Padomima.getMyOpponent().then(function(res){
  66984. opAccount = res;
  66985. web3.eth.opponentAccount = res;
  66986. $("#opponentHash").html(res);
  66987. });
  66988. }
  66989. });
  66990. }
  66991. function updateMapTable(map,state){
  66992. if(typeof state == "undefined"){
  66993. state = {
  66994. selected:{
  66995. [web3.eth.defaultAccount]:[0,0,0,0,0,0],
  66996. [web3.eth.opponentAccount]:[0,0,0,0,0,0]
  66997. }
  66998. };
  66999. }
  67000. state = web3.Game.applyStateRotation(state);
  67001. var mapTable = $("#mapTable")[0];
  67002. if(mapTable.hasChildNodes())
  67003. mapTable.removeChild(mapTable.children[0]);
  67004. var tbody = document.createElement("tbody");
  67005. for(var i=0;i<6;i++){
  67006. var tr = document.createElement("tr");
  67007. if(state.selected[web3.eth.defaultAccount][i]){
  67008. $(tr).addClass("green");
  67009. }
  67010. for (var j = 0; j < 6; j++) {
  67011. var td = document.createElement("td");
  67012. td.innerHTML = map[i][j];
  67013. if(web3.Game.haveSelected(j)){
  67014. $(td).addClass("green");
  67015. }
  67016. if(state.selected[web3.eth.opponentAccount][j]){
  67017. $(td).addClass("red");
  67018. }
  67019. if(web3.Game.isMyNumber(i,j)){
  67020. $(td).addClass("my-number");
  67021. }
  67022. if(web3.Game.isOpponentNumber(i,j)){
  67023. $(td).addClass("op-number");
  67024. }
  67025. tr.appendChild(td);
  67026. }
  67027. tbody.appendChild(tr);
  67028. }
  67029. mapTable.appendChild(tbody);
  67030. }
  67031. /////////////////////
  67032. //// CALCULATIONS ///
  67033. /////////////////////
  67034. // function hashToNumbers(hash){
  67035. // var nums = [];
  67036. // hash = hash.substr(2);
  67037. // for(var i=0;i<32;i++){
  67038. // var b = hash.substr(2*i, 2*i+2);
  67039. // nums.push(web3.toDecimal('0x'+b));
  67040. // }
  67041. // return nums;
  67042. // }
  67043. // /////////////////////
  67044. // function calculateMapArray(){
  67045. // console.log("Calculating map array for map hash: " + maphash);
  67046. // var first32Hash = maphash,
  67047. // second32Hash = web3.sha3(first32Hash),
  67048. // third32Hash = web3.sha3(second32Hash);
  67049. // // Make hash to numbers
  67050. // var numbers = hashToNumbers(first32Hash)
  67051. // .concat(hashToNumbers(second32Hash))
  67052. // .concat(hashToNumbers(third32Hash));
  67053. // // init mapArray
  67054. // var maparray = [];
  67055. // for(var i=0;i<6;i++){
  67056. // maparray.push([]);
  67057. // for(var j=0;j<6;j++){
  67058. // maparray[i][j] = i*6 + j + 1;
  67059. // }
  67060. // }
  67061. // ///
  67062. // /// helper local swapPosition
  67063. // function swapPositions(a,b){
  67064. // a = a % 36
  67065. // ai = a % 6;
  67066. // aj = parseInt(a / 6);
  67067. // b = b % 36
  67068. // bi = b % 6;
  67069. // bj = parseInt(b / 6);
  67070. // var temp = maparray[ai][aj];
  67071. // maparray[ai][aj] = maparray[bi][bj];
  67072. // maparray[bi][bj] = temp;
  67073. // }
  67074. // ///
  67075. // for(var i=0;i<numbers.length;i++){
  67076. // swapPositions(i, numbers[i]);
  67077. // }
  67078. // ////////////////////////////////
  67079. // console.log(maparray);
  67080. // ////////////////////////////////
  67081. // return maparray;
  67082. // }
  67083. ///////////////////// CUSTOM NET ////
  67084. function createMatch(stake){
  67085. var createMatchData = Padomima.createMatch({value: web3.toWei(stake, 'ether'), gas: 2255200});
  67086. console.log(createMatchData);
  67087. return createMatchData;
  67088. //return web3.eth.sendTransaction({
  67089. // 'from': web3.eth.defaultAccount,
  67090. // 'contractAddress': Padomima.address,
  67091. // 'to': Padomima.address,
  67092. // 'value':web3.toWei(stake, 'ether'),
  67093. // 'data': createMatchData,
  67094. // 'gas': 4000000
  67095. // });
  67096. }
  67097. function joinMatch(stake, h){
  67098. var joinMatchData = Padomima.joinMatch(h , {value: web3.toWei(stake, 'ether'), gas: 2255200});
  67099. console.log(joinMatchData);
  67100. return web3.eth.sendTransaction({
  67101. 'from': web3.eth.defaultAccount,
  67102. 'contractAddress': Padomima.address,
  67103. 'to': Padomima.address,
  67104. 'value':web3.toWei(stake, 'ether'),
  67105. 'data': joinMatchData,
  67106. 'gas': 4000000
  67107. });
  67108. }
  67109. function getMatch(){
  67110. Padomima.getMyMatch().then(function(res){
  67111. console.log("MY Match Hash: " );
  67112. console.log(res);
  67113. });
  67114. }
  67115. function getMap(){
  67116. Padomima.getMyMap().then(function(res){
  67117. console.log("MY Map Hash: " );
  67118. console.log(res);
  67119. });
  67120. }
  67121. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  67122. ///////////////////////////////////////////////////////////////////
  67123. /////////// START GAME PHASE ///////////////////////////////////
  67124. ///////////////////////////////////////////////////////////////////
  67125. var dbname = web3.db.DBNAME = "CUSTOMDBFOR"+web3.eth.defaultAccount;
  67126. function getDB(key){
  67127. return web3.db.getString(dbname,key);
  67128. }
  67129. function getDBJSON(key){
  67130. return JSON.parse(web3.db.getString(dbname,key));
  67131. }
  67132. function saveDBJSON(d){
  67133. return;
  67134. if(!web3.db.getString(dbname,"currentIndex"))
  67135. web3.db.putString(dbname,"currentIndex","0");
  67136. var cid = getDB("currentIndex");
  67137. web3.db.putString(dbname, "Index" + cid, JSON.stringify(d));
  67138. web3.db.putString(dbname, "currentIndex", ""+(parseInt(cid)+1) );
  67139. }
  67140. function saveDB(key, data){
  67141. web3.db.putString(dbname, key, data);
  67142. }
  67143. function saveACK(data){
  67144. // save ACK and mark it on UI
  67145. saveDBJSON({
  67146. who : web3.eth.defaultAccount,
  67147. ack : data,
  67148. opponent: opAccount
  67149. });
  67150. // update Current Game State to the next one because we have all the SIGNED information needed until here!
  67151. return;
  67152. }
  67153. function saveOpponentMove(data){
  67154. // save move and mark it on UI
  67155. saveDBJSON({
  67156. who : opAccount,
  67157. ack : data
  67158. });
  67159. return;
  67160. }
  67161. function moveRecieved(data){
  67162. console.log("Recieved Data from Game Channel:");
  67163. console.log(data);
  67164. if(web3.Game.performMove(data))
  67165. return data;
  67166. //web3.Game.communicateState();
  67167. return false;
  67168. }
  67169. function stateHandler(){
  67170. console.log("State changed!");
  67171. console.log(web3.Game.getState());
  67172. updateGameUI(web3.Game.getState());
  67173. }
  67174. function roundHandler(){
  67175. console.log("Round changed!");
  67176. updateGameUI(web3.Game.getState());
  67177. }
  67178. function startGame() {
  67179. // body...
  67180. $("#GameUI").removeClass("hidden");
  67181. // Establish whisper connection //
  67182. // web3.Lib.initWhisper(maphash.substr(2))
  67183. // .then(function(w){
  67184. // w.setFunction(moveRecieved);
  67185. // web3.GWhisper = w;
  67186. // });
  67187. web3.NetLib.init();
  67188. web3.NetLib.setChannel(maphash.substr(2));
  67189. web3.NetLib.setSolo(web3.eth.opponentAccount);
  67190. //web3.NetLib.addInterceptor(web3.Game.getStateInterceptor());
  67191. web3.NetLib.setSoloInterceptor();
  67192. web3.NetLib.setProofInterceptor();
  67193. web3.NetLib.addInterceptor(moveRecieved);
  67194. web3.NetLib.startListening();
  67195. web3.Game.init(maphash);
  67196. web3.Game.setOnStateChange(stateHandler);
  67197. web3.Game.setOnRoundChange(roundHandler);
  67198. Padomima.getMapRotation().then(function(res){
  67199. web3.Game.setMapRotation(res);
  67200. updateMapTable(web3.Game.getMapArray());
  67201. web3.Game.loadFromDB();
  67202. updateGameUI(web3.Game.getState());
  67203. });
  67204. }
  67205. function sendSelectMove(){
  67206. var mycol = parseInt($("#columnForMe").val())-1;
  67207. var opcol = parseInt($("#columnForOp").val())-1;
  67208. var move = web3.Game.createSelectMove(mycol,opcol);
  67209. web3.Game.performMove(move.move);
  67210. web3.NetLib.sendPacketWaitForVerification(move.move);
  67211. web3.Game.saveProof(move.proof.data.selectIndex % 4, move.proof);
  67212. // var move = web3.sha3(''+mycolR).substr(2) + "+" + web3.sha3(''+opcolR).substr(2);
  67213. // var moveSignature = web3.Lib.signData(web3.eth.defaultAccount, move);
  67214. // console.log("Move Signature : ");
  67215. // console.log(moveSignature);
  67216. // console.log("Verifying locally...");
  67217. // var ver = web3.Lib.verifySignature(web3.eth.defaultAccount, moveSignature);
  67218. // console.log(ver);
  67219. // Send through Whisper
  67220. //web3.GWhisper.send({ who: web3.eth.defaultAccount, signature : moveSignature })
  67221. }
  67222. function sendBetMove(){
  67223. var am = parseInt($("#amount").val());
  67224. var move = web3.Game.createBetMove(am);
  67225. if(web3.Game.performMove(move))
  67226. web3.NetLib.sendPacketWaitForVerification(move);
  67227. }
  67228. function sendCallMove(){
  67229. var move = web3.Game.createCallMove();
  67230. if(web3.Game.performMove(move))
  67231. web3.NetLib.sendPacketWaitForVerification(move);
  67232. }
  67233. function sendFoldMove(){
  67234. var move = web3.Game.createFoldMove();
  67235. if(web3.Game.performMove(move))
  67236. web3.NetLib.sendPacketWaitForVerification(move);
  67237. }
  67238. function sendProofMove(){
  67239. var proofnum = parseInt($("#proofCol").val());
  67240. var move = web3.Game.getProofMove(proofnum);
  67241. if(web3.Game.performMove(move))
  67242. web3.NetLib.sendPacketWaitForVerification(move);
  67243. }
  67244. /////////////////////////////////////////////////////////////////////////////
  67245. /////////////// GAME HELPERS /////////////////////////////////////////
  67246. ///////////////////////////////////////////////////////////////////////
  67247. function findRandomBigNumber(num){
  67248. var randomNumber = Math.floor(10000000000 + Math.random() * 90000000000);
  67249. while(randomNumber % 6 != num){
  67250. randomNumber++;
  67251. }
  67252. // console.log("Random Big Number for : " + num);
  67253. // console.log(randomNumber);
  67254. return randomNumber;
  67255. }
  67256. function printMoveStack(){
  67257. console.log("---- Move Stack --------");
  67258. var cid = getDB("currentIndex");
  67259. for( var i = 0; i < cid; i ++ ){
  67260. console.log(getDBJSON("Index" + i));
  67261. }
  67262. console.log("------------------------");
  67263. }
  67264. (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
  67265. web3.Utils = require("./index.js");
  67266. },{"./index.js":2}],2:[function(require,module,exports){
  67267. (function (Buffer){
  67268. const createKeccakHash = require('keccak')
  67269. const secp256k1 = require('secp256k1')
  67270. const assert = require('assert')
  67271. const rlp = require('rlp')
  67272. const BN = require('bn.js')
  67273. const createHash = require('create-hash')
  67274. Object.assign(exports, require('ethjs-util'))
  67275. /**
  67276. * the max integer that this VM can handle (a ```BN```)
  67277. * @var {BN} MAX_INTEGER
  67278. */
  67279. exports.MAX_INTEGER = new BN('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16)
  67280. /**
  67281. * 2^256 (a ```BN```)
  67282. * @var {BN} TWO_POW256
  67283. */
  67284. exports.TWO_POW256 = new BN('10000000000000000000000000000000000000000000000000000000000000000', 16)
  67285. /**
  67286. * SHA3-256 hash of null (a ```String```)
  67287. * @var {String} SHA3_NULL_S
  67288. */
  67289. exports.SHA3_NULL_S = 'c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'
  67290. /**
  67291. * SHA3-256 hash of null (a ```Buffer```)
  67292. * @var {Buffer} SHA3_NULL
  67293. */
  67294. exports.SHA3_NULL = Buffer.from(exports.SHA3_NULL_S, 'hex')
  67295. /**
  67296. * SHA3-256 of an RLP of an empty array (a ```String```)
  67297. * @var {String} SHA3_RLP_ARRAY_S
  67298. */
  67299. exports.SHA3_RLP_ARRAY_S = '1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347'
  67300. /**
  67301. * SHA3-256 of an RLP of an empty array (a ```Buffer```)
  67302. * @var {Buffer} SHA3_RLP_ARRAY
  67303. */
  67304. exports.SHA3_RLP_ARRAY = Buffer.from(exports.SHA3_RLP_ARRAY_S, 'hex')
  67305. /**
  67306. * SHA3-256 hash of the RLP of null (a ```String```)
  67307. * @var {String} SHA3_RLP_S
  67308. */
  67309. exports.SHA3_RLP_S = '56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'
  67310. /**
  67311. * SHA3-256 hash of the RLP of null (a ```Buffer```)
  67312. * @var {Buffer} SHA3_RLP
  67313. */
  67314. exports.SHA3_RLP = Buffer.from(exports.SHA3_RLP_S, 'hex')
  67315. /**
  67316. * [`BN`](https://github.com/indutny/bn.js)
  67317. * @var {Function}
  67318. */
  67319. exports.BN = BN
  67320. /**
  67321. * [`rlp`](https://github.com/ethereumjs/rlp)
  67322. * @var {Function}
  67323. */
  67324. exports.rlp = rlp
  67325. /**
  67326. * [`secp256k1`](https://github.com/cryptocoinjs/secp256k1-node/)
  67327. * @var {Object}
  67328. */
  67329. exports.secp256k1 = secp256k1
  67330. /**
  67331. * Returns a buffer filled with 0s
  67332. * @method zeros
  67333. * @param {Number} bytes the number of bytes the buffer should be
  67334. * @return {Buffer}
  67335. */
  67336. exports.zeros = function (bytes) {
  67337. return Buffer.allocUnsafe(bytes).fill(0)
  67338. }
  67339. /**
  67340. * Left Pads an `Array` or `Buffer` with leading zeros till it has `length` bytes.
  67341. * Or it truncates the beginning if it exceeds.
  67342. * @method lsetLength
  67343. * @param {Buffer|Array} msg the value to pad
  67344. * @param {Number} length the number of bytes the output should be
  67345. * @param {Boolean} [right=false] whether to start padding form the left or right
  67346. * @return {Buffer|Array}
  67347. */
  67348. exports.setLengthLeft = exports.setLength = function (msg, length, right) {
  67349. var buf = exports.zeros(length)
  67350. msg = exports.toBuffer(msg)
  67351. if (right) {
  67352. if (msg.length < length) {
  67353. msg.copy(buf)
  67354. return buf
  67355. }
  67356. return msg.slice(0, length)
  67357. } else {
  67358. if (msg.length < length) {
  67359. msg.copy(buf, length - msg.length)
  67360. return buf
  67361. }
  67362. return msg.slice(-length)
  67363. }
  67364. }
  67365. /**
  67366. * Right Pads an `Array` or `Buffer` with leading zeros till it has `length` bytes.
  67367. * Or it truncates the beginning if it exceeds.
  67368. * @param {Buffer|Array} msg the value to pad
  67369. * @param {Number} length the number of bytes the output should be
  67370. * @return {Buffer|Array}
  67371. */
  67372. exports.setLengthRight = function (msg, length) {
  67373. return exports.setLength(msg, length, true)
  67374. }
  67375. /**
  67376. * Trims leading zeros from a `Buffer` or an `Array`
  67377. * @param {Buffer|Array|String} a
  67378. * @return {Buffer|Array|String}
  67379. */
  67380. exports.unpad = exports.stripZeros = function (a) {
  67381. a = exports.stripHexPrefix(a)
  67382. var first = a[0]
  67383. while (a.length > 0 && first.toString() === '0') {
  67384. a = a.slice(1)
  67385. first = a[0]
  67386. }
  67387. return a
  67388. }
  67389. /**
  67390. * Attempts to turn a value into a `Buffer`. As input it supports `Buffer`, `String`, `Number`, null/undefined, `BN` and other objects with a `toArray()` method.
  67391. * @param {*} v the value
  67392. */
  67393. exports.toBuffer = function (v) {
  67394. if (!Buffer.isBuffer(v)) {
  67395. if (Array.isArray(v)) {
  67396. v = Buffer.from(v)
  67397. } else if (typeof v === 'string') {
  67398. if (exports.isHexPrefixed(v)) {
  67399. v = Buffer.from(exports.padToEven(exports.stripHexPrefix(v)), 'hex')
  67400. } else {
  67401. v = Buffer.from(v)
  67402. }
  67403. } else if (typeof v === 'number') {
  67404. v = exports.intToBuffer(v)
  67405. } else if (v === null || v === undefined) {
  67406. v = Buffer.allocUnsafe(0)
  67407. } else if (v.toArray) {
  67408. // converts a BN to a Buffer
  67409. v = Buffer.from(v.toArray())
  67410. } else {
  67411. throw new Error('invalid type')
  67412. }
  67413. }
  67414. return v
  67415. }
  67416. /**
  67417. * Converts a `Buffer` to a `Number`
  67418. * @param {Buffer} buf
  67419. * @return {Number}
  67420. * @throws If the input number exceeds 53 bits.
  67421. */
  67422. exports.bufferToInt = function (buf) {
  67423. return new BN(exports.toBuffer(buf)).toNumber()
  67424. }
  67425. /**
  67426. * Converts a `Buffer` into a hex `String`
  67427. * @param {Buffer} buf
  67428. * @return {String}
  67429. */
  67430. exports.bufferToHex = function (buf) {
  67431. buf = exports.toBuffer(buf)
  67432. return '0x' + buf.toString('hex')
  67433. }
  67434. /**
  67435. * Interprets a `Buffer` as a signed integer and returns a `BN`. Assumes 256-bit numbers.
  67436. * @param {Buffer} num
  67437. * @return {BN}
  67438. */
  67439. exports.fromSigned = function (num) {
  67440. return new BN(num).fromTwos(256)
  67441. }
  67442. /**
  67443. * Converts a `BN` to an unsigned integer and returns it as a `Buffer`. Assumes 256-bit numbers.
  67444. * @param {BN} num
  67445. * @return {Buffer}
  67446. */
  67447. exports.toUnsigned = function (num) {
  67448. return Buffer.from(num.toTwos(256).toArray())
  67449. }
  67450. /**
  67451. * Creates SHA-3 hash of the input
  67452. * @param {Buffer|Array|String|Number} a the input data
  67453. * @param {Number} [bits=256] the SHA width
  67454. * @return {Buffer}
  67455. */
  67456. exports.sha3 = function (a, bits) {
  67457. a = exports.toBuffer(a)
  67458. if (!bits) bits = 256
  67459. return createKeccakHash('keccak' + bits).update(a).digest()
  67460. }
  67461. /**
  67462. * Creates SHA256 hash of the input
  67463. * @param {Buffer|Array|String|Number} a the input data
  67464. * @return {Buffer}
  67465. */
  67466. exports.sha256 = function (a) {
  67467. a = exports.toBuffer(a)
  67468. return createHash('sha256').update(a).digest()
  67469. }
  67470. /**
  67471. * Creates RIPEMD160 hash of the input
  67472. * @param {Buffer|Array|String|Number} a the input data
  67473. * @param {Boolean} padded whether it should be padded to 256 bits or not
  67474. * @return {Buffer}
  67475. */
  67476. exports.ripemd160 = function (a, padded) {
  67477. a = exports.toBuffer(a)
  67478. var hash = createHash('rmd160').update(a).digest()
  67479. if (padded === true) {
  67480. return exports.setLength(hash, 32)
  67481. } else {
  67482. return hash
  67483. }
  67484. }
  67485. /**
  67486. * Creates SHA-3 hash of the RLP encoded version of the input
  67487. * @param {Buffer|Array|String|Number} a the input data
  67488. * @return {Buffer}
  67489. */
  67490. exports.rlphash = function (a) {
  67491. return exports.sha3(rlp.encode(a))
  67492. }
  67493. /**
  67494. * Checks if the private key satisfies the rules of the curve secp256k1.
  67495. * @param {Buffer} privateKey
  67496. * @return {Boolean}
  67497. */
  67498. exports.isValidPrivate = function (privateKey) {
  67499. return secp256k1.privateKeyVerify(privateKey)
  67500. }
  67501. /**
  67502. * Checks if the public key satisfies the rules of the curve secp256k1
  67503. * and the requirements of Ethereum.
  67504. * @param {Buffer} publicKey The two points of an uncompressed key, unless sanitize is enabled
  67505. * @param {Boolean} [sanitize=false] Accept public keys in other formats
  67506. * @return {Boolean}
  67507. */
  67508. exports.isValidPublic = function (publicKey, sanitize) {
  67509. if (publicKey.length === 64) {
  67510. // Convert to SEC1 for secp256k1
  67511. return secp256k1.publicKeyVerify(Buffer.concat([ Buffer.from([4]), publicKey ]))
  67512. }
  67513. if (!sanitize) {
  67514. return false
  67515. }
  67516. return secp256k1.publicKeyVerify(publicKey)
  67517. }
  67518. /**
  67519. * Returns the ethereum address of a given public key.
  67520. * Accepts "Ethereum public keys" and SEC1 encoded keys.
  67521. * @param {Buffer} pubKey The two points of an uncompressed key, unless sanitize is enabled
  67522. * @param {Boolean} [sanitize=false] Accept public keys in other formats
  67523. * @return {Buffer}
  67524. */
  67525. exports.pubToAddress = exports.publicToAddress = function (pubKey, sanitize) {
  67526. pubKey = exports.toBuffer(pubKey)
  67527. if (sanitize && (pubKey.length !== 64)) {
  67528. pubKey = secp256k1.publicKeyConvert(pubKey, false).slice(1)
  67529. }
  67530. assert(pubKey.length === 64)
  67531. // Only take the lower 160bits of the hash
  67532. return exports.sha3(pubKey).slice(-20)
  67533. }
  67534. /**
  67535. * Returns the ethereum public key of a given private key
  67536. * @param {Buffer} privateKey A private key must be 256 bits wide
  67537. * @return {Buffer}
  67538. */
  67539. var privateToPublic = exports.privateToPublic = function (privateKey) {
  67540. privateKey = exports.toBuffer(privateKey)
  67541. // skip the type flag and use the X, Y points
  67542. return secp256k1.publicKeyCreate(privateKey, false).slice(1)
  67543. }
  67544. /**
  67545. * Converts a public key to the Ethereum format.
  67546. * @param {Buffer} publicKey
  67547. * @return {Buffer}
  67548. */
  67549. exports.importPublic = function (publicKey) {
  67550. publicKey = exports.toBuffer(publicKey)
  67551. if (publicKey.length !== 64) {
  67552. publicKey = secp256k1.publicKeyConvert(publicKey, false).slice(1)
  67553. }
  67554. return publicKey
  67555. }
  67556. /**
  67557. * ECDSA sign
  67558. * @param {Buffer} msgHash
  67559. * @param {Buffer} privateKey
  67560. * @return {Object}
  67561. */
  67562. exports.ecsign = function (msgHash, privateKey) {
  67563. var sig = secp256k1.sign(msgHash, privateKey)
  67564. var ret = {}
  67565. ret.r = sig.signature.slice(0, 32)
  67566. ret.s = sig.signature.slice(32, 64)
  67567. ret.v = sig.recovery + 27
  67568. return ret
  67569. }
  67570. /**
  67571. * Returns the keccak-256 hash of `message`, prefixed with the header used by the `eth_sign` RPC call.
  67572. * The output of this function can be fed into `ecsign` to produce the same signature as the `eth_sign`
  67573. * call for a given `message`, or fed to `ecrecover` along with a signature to recover the public key
  67574. * used to produce the signature.
  67575. * @param message
  67576. * @returns {Buffer} hash
  67577. */
  67578. exports.hashPersonalMessage = function (message) {
  67579. var prefix = exports.toBuffer('\u0019Ethereum Signed Message:\n' + message.length.toString())
  67580. return exports.sha3(Buffer.concat([prefix, message]))
  67581. }
  67582. /**
  67583. * ECDSA public key recovery from signature
  67584. * @param {Buffer} msgHash
  67585. * @param {Number} v
  67586. * @param {Buffer} r
  67587. * @param {Buffer} s
  67588. * @return {Buffer} publicKey
  67589. */
  67590. exports.ecrecover = function (msgHash, v, r, s) {
  67591. var signature = Buffer.concat([exports.setLength(r, 32), exports.setLength(s, 32)], 64)
  67592. var recovery = v - 27
  67593. if (recovery !== 0 && recovery !== 1) {
  67594. throw new Error('Invalid signature v value')
  67595. }
  67596. var senderPubKey = secp256k1.recover(msgHash, signature, recovery)
  67597. return secp256k1.publicKeyConvert(senderPubKey, false).slice(1)
  67598. }
  67599. /**
  67600. * Convert signature parameters into the format of `eth_sign` RPC method
  67601. * @param {Number} v
  67602. * @param {Buffer} r
  67603. * @param {Buffer} s
  67604. * @return {String} sig
  67605. */
  67606. exports.toRpcSig = function (v, r, s) {
  67607. // NOTE: with potential introduction of chainId this might need to be updated
  67608. if (v !== 27 && v !== 28) {
  67609. throw new Error('Invalid recovery id')
  67610. }
  67611. // geth (and the RPC eth_sign method) uses the 65 byte format used by Bitcoin
  67612. // FIXME: this might change in the future - https://github.com/ethereum/go-ethereum/issues/2053
  67613. return exports.bufferToHex(Buffer.concat([
  67614. exports.setLengthLeft(r, 32),
  67615. exports.setLengthLeft(s, 32),
  67616. exports.toBuffer(v - 27)
  67617. ]))
  67618. }
  67619. /**
  67620. * Convert signature format of the `eth_sign` RPC method to signature parameters
  67621. * NOTE: all because of a bug in geth: https://github.com/ethereum/go-ethereum/issues/2053
  67622. * @param {String} sig
  67623. * @return {Object}
  67624. */
  67625. exports.fromRpcSig = function (sig) {
  67626. sig = exports.toBuffer(sig)
  67627. // NOTE: with potential introduction of chainId this might need to be updated
  67628. if (sig.length !== 65) {
  67629. throw new Error('Invalid signature length')
  67630. }
  67631. var v = sig[64]
  67632. // support both versions of `eth_sign` responses
  67633. if (v < 27) {
  67634. v += 27
  67635. }
  67636. return {
  67637. v: v,
  67638. r: sig.slice(0, 32),
  67639. s: sig.slice(32, 64)
  67640. }
  67641. }
  67642. /**
  67643. * Returns the ethereum address of a given private key
  67644. * @param {Buffer} privateKey A private key must be 256 bits wide
  67645. * @return {Buffer}
  67646. */
  67647. exports.privateToAddress = function (privateKey) {
  67648. return exports.publicToAddress(privateToPublic(privateKey))
  67649. }
  67650. /**
  67651. * Checks if the address is a valid. Accepts checksummed addresses too
  67652. * @param {String} address
  67653. * @return {Boolean}
  67654. */
  67655. exports.isValidAddress = function (address) {
  67656. return /^0x[0-9a-fA-F]{40}$/i.test(address)
  67657. }
  67658. /**
  67659. * Returns a checksummed address
  67660. * @param {String} address
  67661. * @return {String}
  67662. */
  67663. exports.toChecksumAddress = function (address) {
  67664. address = exports.stripHexPrefix(address).toLowerCase()
  67665. var hash = exports.sha3(address).toString('hex')
  67666. var ret = '0x'
  67667. for (var i = 0; i < address.length; i++) {
  67668. if (parseInt(hash[i], 16) >= 8) {
  67669. ret += address[i].toUpperCase()
  67670. } else {
  67671. ret += address[i]
  67672. }
  67673. }
  67674. return ret
  67675. }
  67676. /**
  67677. * Checks if the address is a valid checksummed address
  67678. * @param {Buffer} address
  67679. * @return {Boolean}
  67680. */
  67681. exports.isValidChecksumAddress = function (address) {
  67682. return exports.isValidAddress(address) && (exports.toChecksumAddress(address) === address)
  67683. }
  67684. /**
  67685. * Generates an address of a newly created contract
  67686. * @param {Buffer} from the address which is creating this new address
  67687. * @param {Buffer} nonce the nonce of the from account
  67688. * @return {Buffer}
  67689. */
  67690. exports.generateAddress = function (from, nonce) {
  67691. from = exports.toBuffer(from)
  67692. nonce = new BN(nonce)
  67693. if (nonce.isZero()) {
  67694. // in RLP we want to encode null in the case of zero nonce
  67695. // read the RLP documentation for an answer if you dare
  67696. nonce = null
  67697. } else {
  67698. nonce = Buffer.from(nonce.toArray())
  67699. }
  67700. // Only take the lower 160bits of the hash
  67701. return exports.rlphash([from, nonce]).slice(-20)
  67702. }
  67703. /**
  67704. * Returns true if the supplied address belongs to a precompiled account
  67705. * @param {Buffer|String} address
  67706. * @return {Boolean}
  67707. */
  67708. exports.isPrecompiled = function (address) {
  67709. var a = exports.unpad(address)
  67710. return a.length === 1 && a[0] > 0 && a[0] < 5
  67711. }
  67712. /**
  67713. * Adds "0x" to a given `String` if it does not already start with "0x"
  67714. * @param {String} str
  67715. * @return {String}
  67716. */
  67717. exports.addHexPrefix = function (str) {
  67718. if (typeof str !== 'string') {
  67719. return str
  67720. }
  67721. return exports.isHexPrefixed(str) ? str : '0x' + str
  67722. }
  67723. /**
  67724. * Validate ECDSA signature
  67725. * @method isValidSignature
  67726. * @param {Buffer} v
  67727. * @param {Buffer} r
  67728. * @param {Buffer} s
  67729. * @param {Boolean} [homestead=true]
  67730. * @return {Boolean}
  67731. */
  67732. exports.isValidSignature = function (v, r, s, homestead) {
  67733. const SECP256K1_N_DIV_2 = new BN('7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0', 16)
  67734. const SECP256K1_N = new BN('fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141', 16)
  67735. if (r.length !== 32 || s.length !== 32) {
  67736. return false
  67737. }
  67738. if (v !== 27 && v !== 28) {
  67739. return false
  67740. }
  67741. r = new BN(r)
  67742. s = new BN(s)
  67743. if (r.isZero() || r.gt(SECP256K1_N) || s.isZero() || s.gt(SECP256K1_N)) {
  67744. return false
  67745. }
  67746. if ((homestead === false) && (new BN(s).cmp(SECP256K1_N_DIV_2) === 1)) {
  67747. return false
  67748. }
  67749. return true
  67750. }
  67751. /**
  67752. * Converts a `Buffer` or `Array` to JSON
  67753. * @param {Buffer|Array} ba
  67754. * @return {Array|String|null}
  67755. */
  67756. exports.baToJSON = function (ba) {
  67757. if (Buffer.isBuffer(ba)) {
  67758. return '0x' + ba.toString('hex')
  67759. } else if (ba instanceof Array) {
  67760. var array = []
  67761. for (var i = 0; i < ba.length; i++) {
  67762. array.push(exports.baToJSON(ba[i]))
  67763. }
  67764. return array
  67765. }
  67766. }
  67767. /**
  67768. * Defines properties on a `Object`. It make the assumption that underlying data is binary.
  67769. * @param {Object} self the `Object` to define properties on
  67770. * @param {Array} fields an array fields to define. Fields can contain:
  67771. * * `name` - the name of the properties
  67772. * * `length` - the number of bytes the field can have
  67773. * * `allowLess` - if the field can be less than the length
  67774. * * `allowEmpty`
  67775. * @param {*} data data to be validated against the definitions
  67776. */
  67777. exports.defineProperties = function (self, fields, data) {
  67778. self.raw = []
  67779. self._fields = []
  67780. // attach the `toJSON`
  67781. self.toJSON = function (label) {
  67782. if (label) {
  67783. var obj = {}
  67784. self._fields.forEach(function (field) {
  67785. obj[field] = '0x' + self[field].toString('hex')
  67786. })
  67787. return obj
  67788. }
  67789. return exports.baToJSON(this.raw)
  67790. }
  67791. self.serialize = function serialize () {
  67792. return rlp.encode(self.raw)
  67793. }
  67794. fields.forEach(function (field, i) {
  67795. self._fields.push(field.name)
  67796. function getter () {
  67797. return self.raw[i]
  67798. }
  67799. function setter (v) {
  67800. v = exports.toBuffer(v)
  67801. if (v.toString('hex') === '00' && !field.allowZero) {
  67802. v = Buffer.allocUnsafe(0)
  67803. }
  67804. if (field.allowLess && field.length) {
  67805. v = exports.stripZeros(v)
  67806. assert(field.length >= v.length, 'The field ' + field.name + ' must not have more ' + field.length + ' bytes')
  67807. } else if (!(field.allowZero && v.length === 0) && field.length) {
  67808. assert(field.length === v.length, 'The field ' + field.name + ' must have byte length of ' + field.length)
  67809. }
  67810. self.raw[i] = v
  67811. }
  67812. Object.defineProperty(self, field.name, {
  67813. enumerable: true,
  67814. configurable: true,
  67815. get: getter,
  67816. set: setter
  67817. })
  67818. if (field.default) {
  67819. self[field.name] = field.default
  67820. }
  67821. // attach alias
  67822. if (field.alias) {
  67823. Object.defineProperty(self, field.alias, {
  67824. enumerable: false,
  67825. configurable: true,
  67826. set: setter,
  67827. get: getter
  67828. })
  67829. }
  67830. })
  67831. // if the constuctor is passed data
  67832. if (data) {
  67833. if (typeof data === 'string') {
  67834. data = Buffer.from(exports.stripHexPrefix(data), 'hex')
  67835. }
  67836. if (Buffer.isBuffer(data)) {
  67837. data = rlp.decode(data)
  67838. }
  67839. if (Array.isArray(data)) {
  67840. if (data.length > self._fields.length) {
  67841. throw (new Error('wrong number of fields in data'))
  67842. }
  67843. // make sure all the items are buffers
  67844. data.forEach(function (d, i) {
  67845. self[self._fields[i]] = exports.toBuffer(d)
  67846. })
  67847. } else if (typeof data === 'object') {
  67848. const keys = Object.keys(data)
  67849. fields.forEach(function (field) {
  67850. if (keys.indexOf(field.name) !== -1) self[field.name] = data[field.name]
  67851. if (keys.indexOf(field.alias) !== -1) self[field.alias] = data[field.alias]
  67852. })
  67853. } else {
  67854. throw new Error('invalid data')
  67855. }
  67856. }
  67857. }
  67858. }).call(this,require("buffer").Buffer)
  67859. },{"assert":61,"bn.js":4,"buffer":65,"create-hash":7,"ethjs-util":26,"keccak":36,"rlp":45,"secp256k1":46}],3:[function(require,module,exports){
  67860. (function (Buffer){
  67861. // Reference https://github.com/bitcoin/bips/blob/master/bip-0066.mediawiki
  67862. // Format: 0x30 [total-length] 0x02 [R-length] [R] 0x02 [S-length] [S]
  67863. // NOTE: SIGHASH byte ignored AND restricted, truncate before use
  67864. function check (buffer) {
  67865. if (buffer.length < 8) return false
  67866. if (buffer.length > 72) return false
  67867. if (buffer[0] !== 0x30) return false
  67868. if (buffer[1] !== buffer.length - 2) return false
  67869. if (buffer[2] !== 0x02) return false
  67870. var lenR = buffer[3]
  67871. if (lenR === 0) return false
  67872. if (5 + lenR >= buffer.length) return false
  67873. if (buffer[4 + lenR] !== 0x02) return false
  67874. var lenS = buffer[5 + lenR]
  67875. if (lenS === 0) return false
  67876. if ((6 + lenR + lenS) !== buffer.length) return false
  67877. if (buffer[4] & 0x80) return false
  67878. if (lenR > 1 && (buffer[4] === 0x00) && !(buffer[5] & 0x80)) return false
  67879. if (buffer[lenR + 6] & 0x80) return false
  67880. if (lenS > 1 && (buffer[lenR + 6] === 0x00) && !(buffer[lenR + 7] & 0x80)) return false
  67881. return true
  67882. }
  67883. function decode (buffer) {
  67884. if (buffer.length < 8) throw new Error('DER sequence length is too short')
  67885. if (buffer.length > 72) throw new Error('DER sequence length is too long')
  67886. if (buffer[0] !== 0x30) throw new Error('Expected DER sequence')
  67887. if (buffer[1] !== buffer.length - 2) throw new Error('DER sequence length is invalid')
  67888. if (buffer[2] !== 0x02) throw new Error('Expected DER integer')
  67889. var lenR = buffer[3]
  67890. if (lenR === 0) throw new Error('R length is zero')
  67891. if (5 + lenR >= buffer.length) throw new Error('R length is too long')
  67892. if (buffer[4 + lenR] !== 0x02) throw new Error('Expected DER integer (2)')
  67893. var lenS = buffer[5 + lenR]
  67894. if (lenS === 0) throw new Error('S length is zero')
  67895. if ((6 + lenR + lenS) !== buffer.length) throw new Error('S length is invalid')
  67896. if (buffer[4] & 0x80) throw new Error('R value is negative')
  67897. if (lenR > 1 && (buffer[4] === 0x00) && !(buffer[5] & 0x80)) throw new Error('R value excessively padded')
  67898. if (buffer[lenR + 6] & 0x80) throw new Error('S value is negative')
  67899. if (lenS > 1 && (buffer[lenR + 6] === 0x00) && !(buffer[lenR + 7] & 0x80)) throw new Error('S value excessively padded')
  67900. // non-BIP66 - extract R, S values
  67901. return {
  67902. r: buffer.slice(4, 4 + lenR),
  67903. s: buffer.slice(6 + lenR)
  67904. }
  67905. }
  67906. /*
  67907. * Expects r and s to be positive DER integers.
  67908. *
  67909. * The DER format uses the most significant bit as a sign bit (& 0x80).
  67910. * If the significant bit is set AND the integer is positive, a 0x00 is prepended.
  67911. *
  67912. * Examples:
  67913. *
  67914. * 0 => 0x00
  67915. * 1 => 0x01
  67916. * -1 => 0xff
  67917. * 127 => 0x7f
  67918. * -127 => 0x81
  67919. * 128 => 0x0080
  67920. * -128 => 0x80
  67921. * 255 => 0x00ff
  67922. * -255 => 0xff01
  67923. * 16300 => 0x3fac
  67924. * -16300 => 0xc054
  67925. * 62300 => 0x00f35c
  67926. * -62300 => 0xff0ca4
  67927. */
  67928. function encode (r, s) {
  67929. var lenR = r.length
  67930. var lenS = s.length
  67931. if (lenR === 0) throw new Error('R length is zero')
  67932. if (lenS === 0) throw new Error('S length is zero')
  67933. if (lenR > 33) throw new Error('R length is too long')
  67934. if (lenS > 33) throw new Error('S length is too long')
  67935. if (r[0] & 0x80) throw new Error('R value is negative')
  67936. if (s[0] & 0x80) throw new Error('S value is negative')
  67937. if (lenR > 1 && (r[0] === 0x00) && !(r[1] & 0x80)) throw new Error('R value excessively padded')
  67938. if (lenS > 1 && (s[0] === 0x00) && !(s[1] & 0x80)) throw new Error('S value excessively padded')
  67939. var signature = new Buffer(6 + lenR + lenS)
  67940. // 0x30 [total-length] 0x02 [R-length] [R] 0x02 [S-length] [S]
  67941. signature[0] = 0x30
  67942. signature[1] = signature.length - 2
  67943. signature[2] = 0x02
  67944. signature[3] = r.length
  67945. r.copy(signature, 4)
  67946. signature[4 + lenR] = 0x02
  67947. signature[5 + lenR] = s.length
  67948. s.copy(signature, 6 + lenR)
  67949. return signature
  67950. }
  67951. module.exports = {
  67952. check: check,
  67953. decode: decode,
  67954. encode: encode
  67955. }
  67956. }).call(this,require("buffer").Buffer)
  67957. },{"buffer":65}],4:[function(require,module,exports){
  67958. (function (module, exports) {
  67959. 'use strict';
  67960. // Utils
  67961. function assert (val, msg) {
  67962. if (!val) throw new Error(msg || 'Assertion failed');
  67963. }
  67964. // Could use `inherits` module, but don't want to move from single file
  67965. // architecture yet.
  67966. function inherits (ctor, superCtor) {
  67967. ctor.super_ = superCtor;
  67968. var TempCtor = function () {};
  67969. TempCtor.prototype = superCtor.prototype;
  67970. ctor.prototype = new TempCtor();
  67971. ctor.prototype.constructor = ctor;
  67972. }
  67973. // BN
  67974. function BN (number, base, endian) {
  67975. if (BN.isBN(number)) {
  67976. return number;
  67977. }
  67978. this.negative = 0;
  67979. this.words = null;
  67980. this.length = 0;
  67981. // Reduction context
  67982. this.red = null;
  67983. if (number !== null) {
  67984. if (base === 'le' || base === 'be') {
  67985. endian = base;
  67986. base = 10;
  67987. }
  67988. this._init(number || 0, base || 10, endian || 'be');
  67989. }
  67990. }
  67991. if (typeof module === 'object') {
  67992. module.exports = BN;
  67993. } else {
  67994. exports.BN = BN;
  67995. }
  67996. BN.BN = BN;
  67997. BN.wordSize = 26;
  67998. var Buffer;
  67999. try {
  68000. Buffer = require('buf' + 'fer').Buffer;
  68001. } catch (e) {
  68002. }
  68003. BN.isBN = function isBN (num) {
  68004. if (num instanceof BN) {
  68005. return true;
  68006. }
  68007. return num !== null && typeof num === 'object' &&
  68008. num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);
  68009. };
  68010. BN.max = function max (left, right) {
  68011. if (left.cmp(right) > 0) return left;
  68012. return right;
  68013. };
  68014. BN.min = function min (left, right) {
  68015. if (left.cmp(right) < 0) return left;
  68016. return right;
  68017. };
  68018. BN.prototype._init = function init (number, base, endian) {
  68019. if (typeof number === 'number') {
  68020. return this._initNumber(number, base, endian);
  68021. }
  68022. if (typeof number === 'object') {
  68023. return this._initArray(number, base, endian);
  68024. }
  68025. if (base === 'hex') {
  68026. base = 16;
  68027. }
  68028. assert(base === (base | 0) && base >= 2 && base <= 36);
  68029. number = number.toString().replace(/\s+/g, '');
  68030. var start = 0;
  68031. if (number[0] === '-') {
  68032. start++;
  68033. }
  68034. if (base === 16) {
  68035. this._parseHex(number, start);
  68036. } else {
  68037. this._parseBase(number, base, start);
  68038. }
  68039. if (number[0] === '-') {
  68040. this.negative = 1;
  68041. }
  68042. this.strip();
  68043. if (endian !== 'le') return;
  68044. this._initArray(this.toArray(), base, endian);
  68045. };
  68046. BN.prototype._initNumber = function _initNumber (number, base, endian) {
  68047. if (number < 0) {
  68048. this.negative = 1;
  68049. number = -number;
  68050. }
  68051. if (number < 0x4000000) {
  68052. this.words = [ number & 0x3ffffff ];
  68053. this.length = 1;
  68054. } else if (number < 0x10000000000000) {
  68055. this.words = [
  68056. number & 0x3ffffff,
  68057. (number / 0x4000000) & 0x3ffffff
  68058. ];
  68059. this.length = 2;
  68060. } else {
  68061. assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)
  68062. this.words = [
  68063. number & 0x3ffffff,
  68064. (number / 0x4000000) & 0x3ffffff,
  68065. 1
  68066. ];
  68067. this.length = 3;
  68068. }
  68069. if (endian !== 'le') return;
  68070. // Reverse the bytes
  68071. this._initArray(this.toArray(), base, endian);
  68072. };
  68073. BN.prototype._initArray = function _initArray (number, base, endian) {
  68074. // Perhaps a Uint8Array
  68075. assert(typeof number.length === 'number');
  68076. if (number.length <= 0) {
  68077. this.words = [ 0 ];
  68078. this.length = 1;
  68079. return this;
  68080. }
  68081. this.length = Math.ceil(number.length / 3);
  68082. this.words = new Array(this.length);
  68083. for (var i = 0; i < this.length; i++) {
  68084. this.words[i] = 0;
  68085. }
  68086. var j, w;
  68087. var off = 0;
  68088. if (endian === 'be') {
  68089. for (i = number.length - 1, j = 0; i >= 0; i -= 3) {
  68090. w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);
  68091. this.words[j] |= (w << off) & 0x3ffffff;
  68092. this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
  68093. off += 24;
  68094. if (off >= 26) {
  68095. off -= 26;
  68096. j++;
  68097. }
  68098. }
  68099. } else if (endian === 'le') {
  68100. for (i = 0, j = 0; i < number.length; i += 3) {
  68101. w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);
  68102. this.words[j] |= (w << off) & 0x3ffffff;
  68103. this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;
  68104. off += 24;
  68105. if (off >= 26) {
  68106. off -= 26;
  68107. j++;
  68108. }
  68109. }
  68110. }
  68111. return this.strip();
  68112. };
  68113. function parseHex (str, start, end) {
  68114. var r = 0;
  68115. var len = Math.min(str.length, end);
  68116. for (var i = start; i < len; i++) {
  68117. var c = str.charCodeAt(i) - 48;
  68118. r <<= 4;
  68119. // 'a' - 'f'
  68120. if (c >= 49 && c <= 54) {
  68121. r |= c - 49 + 0xa;
  68122. // 'A' - 'F'
  68123. } else if (c >= 17 && c <= 22) {
  68124. r |= c - 17 + 0xa;
  68125. // '0' - '9'
  68126. } else {
  68127. r |= c & 0xf;
  68128. }
  68129. }
  68130. return r;
  68131. }
  68132. BN.prototype._parseHex = function _parseHex (number, start) {
  68133. // Create possibly bigger array to ensure that it fits the number
  68134. this.length = Math.ceil((number.length - start) / 6);
  68135. this.words = new Array(this.length);
  68136. for (var i = 0; i < this.length; i++) {
  68137. this.words[i] = 0;
  68138. }
  68139. var j, w;
  68140. // Scan 24-bit chunks and add them to the number
  68141. var off = 0;
  68142. for (i = number.length - 6, j = 0; i >= start; i -= 6) {
  68143. w = parseHex(number, i, i + 6);
  68144. this.words[j] |= (w << off) & 0x3ffffff;
  68145. // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb
  68146. this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;
  68147. off += 24;
  68148. if (off >= 26) {
  68149. off -= 26;
  68150. j++;
  68151. }
  68152. }
  68153. if (i + 6 !== start) {
  68154. w = parseHex(number, start, i + 6);
  68155. this.words[j] |= (w << off) & 0x3ffffff;
  68156. this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;
  68157. }
  68158. this.strip();
  68159. };
  68160. function parseBase (str, start, end, mul) {
  68161. var r = 0;
  68162. var len = Math.min(str.length, end);
  68163. for (var i = start; i < len; i++) {
  68164. var c = str.charCodeAt(i) - 48;
  68165. r *= mul;
  68166. // 'a'
  68167. if (c >= 49) {
  68168. r += c - 49 + 0xa;
  68169. // 'A'
  68170. } else if (c >= 17) {
  68171. r += c - 17 + 0xa;
  68172. // '0' - '9'
  68173. } else {
  68174. r += c;
  68175. }
  68176. }
  68177. return r;
  68178. }
  68179. BN.prototype._parseBase = function _parseBase (number, base, start) {
  68180. // Initialize as zero
  68181. this.words = [ 0 ];
  68182. this.length = 1;
  68183. // Find length of limb in base
  68184. for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {
  68185. limbLen++;
  68186. }
  68187. limbLen--;
  68188. limbPow = (limbPow / base) | 0;
  68189. var total = number.length - start;
  68190. var mod = total % limbLen;
  68191. var end = Math.min(total, total - mod) + start;
  68192. var word = 0;
  68193. for (var i = start; i < end; i += limbLen) {
  68194. word = parseBase(number, i, i + limbLen, base);
  68195. this.imuln(limbPow);
  68196. if (this.words[0] + word < 0x4000000) {
  68197. this.words[0] += word;
  68198. } else {
  68199. this._iaddn(word);
  68200. }
  68201. }
  68202. if (mod !== 0) {
  68203. var pow = 1;
  68204. word = parseBase(number, i, number.length, base);
  68205. for (i = 0; i < mod; i++) {
  68206. pow *= base;
  68207. }
  68208. this.imuln(pow);
  68209. if (this.words[0] + word < 0x4000000) {
  68210. this.words[0] += word;
  68211. } else {
  68212. this._iaddn(word);
  68213. }
  68214. }
  68215. };
  68216. BN.prototype.copy = function copy (dest) {
  68217. dest.words = new Array(this.length);
  68218. for (var i = 0; i < this.length; i++) {
  68219. dest.words[i] = this.words[i];
  68220. }
  68221. dest.length = this.length;
  68222. dest.negative = this.negative;
  68223. dest.red = this.red;
  68224. };
  68225. BN.prototype.clone = function clone () {
  68226. var r = new BN(null);
  68227. this.copy(r);
  68228. return r;
  68229. };
  68230. BN.prototype._expand = function _expand (size) {
  68231. while (this.length < size) {
  68232. this.words[this.length++] = 0;
  68233. }
  68234. return this;
  68235. };
  68236. // Remove leading `0` from `this`
  68237. BN.prototype.strip = function strip () {
  68238. while (this.length > 1 && this.words[this.length - 1] === 0) {
  68239. this.length--;
  68240. }
  68241. return this._normSign();
  68242. };
  68243. BN.prototype._normSign = function _normSign () {
  68244. // -0 = 0
  68245. if (this.length === 1 && this.words[0] === 0) {
  68246. this.negative = 0;
  68247. }
  68248. return this;
  68249. };
  68250. BN.prototype.inspect = function inspect () {
  68251. return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';
  68252. };
  68253. /*
  68254. var zeros = [];
  68255. var groupSizes = [];
  68256. var groupBases = [];
  68257. var s = '';
  68258. var i = -1;
  68259. while (++i < BN.wordSize) {
  68260. zeros[i] = s;
  68261. s += '0';
  68262. }
  68263. groupSizes[0] = 0;
  68264. groupSizes[1] = 0;
  68265. groupBases[0] = 0;
  68266. groupBases[1] = 0;
  68267. var base = 2 - 1;
  68268. while (++base < 36 + 1) {
  68269. var groupSize = 0;
  68270. var groupBase = 1;
  68271. while (groupBase < (1 << BN.wordSize) / base) {
  68272. groupBase *= base;
  68273. groupSize += 1;
  68274. }
  68275. groupSizes[base] = groupSize;
  68276. groupBases[base] = groupBase;
  68277. }
  68278. */
  68279. var zeros = [
  68280. '',
  68281. '0',
  68282. '00',
  68283. '000',
  68284. '0000',
  68285. '00000',
  68286. '000000',
  68287. '0000000',
  68288. '00000000',
  68289. '000000000',
  68290. '0000000000',
  68291. '00000000000',
  68292. '000000000000',
  68293. '0000000000000',
  68294. '00000000000000',
  68295. '000000000000000',
  68296. '0000000000000000',
  68297. '00000000000000000',
  68298. '000000000000000000',
  68299. '0000000000000000000',
  68300. '00000000000000000000',
  68301. '000000000000000000000',
  68302. '0000000000000000000000',
  68303. '00000000000000000000000',
  68304. '000000000000000000000000',
  68305. '0000000000000000000000000'
  68306. ];
  68307. var groupSizes = [
  68308. 0, 0,
  68309. 25, 16, 12, 11, 10, 9, 8,
  68310. 8, 7, 7, 7, 7, 6, 6,
  68311. 6, 6, 6, 6, 6, 5, 5,
  68312. 5, 5, 5, 5, 5, 5, 5,
  68313. 5, 5, 5, 5, 5, 5, 5
  68314. ];
  68315. var groupBases = [
  68316. 0, 0,
  68317. 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,
  68318. 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,
  68319. 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,
  68320. 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,
  68321. 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176
  68322. ];
  68323. BN.prototype.toString = function toString (base, padding) {
  68324. base = base || 10;
  68325. padding = padding | 0 || 1;
  68326. var out;
  68327. if (base === 16 || base === 'hex') {
  68328. out = '';
  68329. var off = 0;
  68330. var carry = 0;
  68331. for (var i = 0; i < this.length; i++) {
  68332. var w = this.words[i];
  68333. var word = (((w << off) | carry) & 0xffffff).toString(16);
  68334. carry = (w >>> (24 - off)) & 0xffffff;
  68335. if (carry !== 0 || i !== this.length - 1) {
  68336. out = zeros[6 - word.length] + word + out;
  68337. } else {
  68338. out = word + out;
  68339. }
  68340. off += 2;
  68341. if (off >= 26) {
  68342. off -= 26;
  68343. i--;
  68344. }
  68345. }
  68346. if (carry !== 0) {
  68347. out = carry.toString(16) + out;
  68348. }
  68349. while (out.length % padding !== 0) {
  68350. out = '0' + out;
  68351. }
  68352. if (this.negative !== 0) {
  68353. out = '-' + out;
  68354. }
  68355. return out;
  68356. }
  68357. if (base === (base | 0) && base >= 2 && base <= 36) {
  68358. // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));
  68359. var groupSize = groupSizes[base];
  68360. // var groupBase = Math.pow(base, groupSize);
  68361. var groupBase = groupBases[base];
  68362. out = '';
  68363. var c = this.clone();
  68364. c.negative = 0;
  68365. while (!c.isZero()) {
  68366. var r = c.modn(groupBase).toString(base);
  68367. c = c.idivn(groupBase);
  68368. if (!c.isZero()) {
  68369. out = zeros[groupSize - r.length] + r + out;
  68370. } else {
  68371. out = r + out;
  68372. }
  68373. }
  68374. if (this.isZero()) {
  68375. out = '0' + out;
  68376. }
  68377. while (out.length % padding !== 0) {
  68378. out = '0' + out;
  68379. }
  68380. if (this.negative !== 0) {
  68381. out = '-' + out;
  68382. }
  68383. return out;
  68384. }
  68385. assert(false, 'Base should be between 2 and 36');
  68386. };
  68387. BN.prototype.toNumber = function toNumber () {
  68388. var ret = this.words[0];
  68389. if (this.length === 2) {
  68390. ret += this.words[1] * 0x4000000;
  68391. } else if (this.length === 3 && this.words[2] === 0x01) {
  68392. // NOTE: at this stage it is known that the top bit is set
  68393. ret += 0x10000000000000 + (this.words[1] * 0x4000000);
  68394. } else if (this.length > 2) {
  68395. assert(false, 'Number can only safely store up to 53 bits');
  68396. }
  68397. return (this.negative !== 0) ? -ret : ret;
  68398. };
  68399. BN.prototype.toJSON = function toJSON () {
  68400. return this.toString(16);
  68401. };
  68402. BN.prototype.toBuffer = function toBuffer (endian, length) {
  68403. assert(typeof Buffer !== 'undefined');
  68404. return this.toArrayLike(Buffer, endian, length);
  68405. };
  68406. BN.prototype.toArray = function toArray (endian, length) {
  68407. return this.toArrayLike(Array, endian, length);
  68408. };
  68409. BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {
  68410. var byteLength = this.byteLength();
  68411. var reqLength = length || Math.max(1, byteLength);
  68412. assert(byteLength <= reqLength, 'byte array longer than desired length');
  68413. assert(reqLength > 0, 'Requested array length <= 0');
  68414. this.strip();
  68415. var littleEndian = endian === 'le';
  68416. var res = new ArrayType(reqLength);
  68417. var b, i;
  68418. var q = this.clone();
  68419. if (!littleEndian) {
  68420. // Assume big-endian
  68421. for (i = 0; i < reqLength - byteLength; i++) {
  68422. res[i] = 0;
  68423. }
  68424. for (i = 0; !q.isZero(); i++) {
  68425. b = q.andln(0xff);
  68426. q.iushrn(8);
  68427. res[reqLength - i - 1] = b;
  68428. }
  68429. } else {
  68430. for (i = 0; !q.isZero(); i++) {
  68431. b = q.andln(0xff);
  68432. q.iushrn(8);
  68433. res[i] = b;
  68434. }
  68435. for (; i < reqLength; i++) {
  68436. res[i] = 0;
  68437. }
  68438. }
  68439. return res;
  68440. };
  68441. if (Math.clz32) {
  68442. BN.prototype._countBits = function _countBits (w) {
  68443. return 32 - Math.clz32(w);
  68444. };
  68445. } else {
  68446. BN.prototype._countBits = function _countBits (w) {
  68447. var t = w;
  68448. var r = 0;
  68449. if (t >= 0x1000) {
  68450. r += 13;
  68451. t >>>= 13;
  68452. }
  68453. if (t >= 0x40) {
  68454. r += 7;
  68455. t >>>= 7;
  68456. }
  68457. if (t >= 0x8) {
  68458. r += 4;
  68459. t >>>= 4;
  68460. }
  68461. if (t >= 0x02) {
  68462. r += 2;
  68463. t >>>= 2;
  68464. }
  68465. return r + t;
  68466. };
  68467. }
  68468. BN.prototype._zeroBits = function _zeroBits (w) {
  68469. // Short-cut
  68470. if (w === 0) return 26;
  68471. var t = w;
  68472. var r = 0;
  68473. if ((t & 0x1fff) === 0) {
  68474. r += 13;
  68475. t >>>= 13;
  68476. }
  68477. if ((t & 0x7f) === 0) {
  68478. r += 7;
  68479. t >>>= 7;
  68480. }
  68481. if ((t & 0xf) === 0) {
  68482. r += 4;
  68483. t >>>= 4;
  68484. }
  68485. if ((t & 0x3) === 0) {
  68486. r += 2;
  68487. t >>>= 2;
  68488. }
  68489. if ((t & 0x1) === 0) {
  68490. r++;
  68491. }
  68492. return r;
  68493. };
  68494. // Return number of used bits in a BN
  68495. BN.prototype.bitLength = function bitLength () {
  68496. var w = this.words[this.length - 1];
  68497. var hi = this._countBits(w);
  68498. return (this.length - 1) * 26 + hi;
  68499. };
  68500. function toBitArray (num) {
  68501. var w = new Array(num.bitLength());
  68502. for (var bit = 0; bit < w.length; bit++) {
  68503. var off = (bit / 26) | 0;
  68504. var wbit = bit % 26;
  68505. w[bit] = (num.words[off] & (1 << wbit)) >>> wbit;
  68506. }
  68507. return w;
  68508. }
  68509. // Number of trailing zero bits
  68510. BN.prototype.zeroBits = function zeroBits () {
  68511. if (this.isZero()) return 0;
  68512. var r = 0;
  68513. for (var i = 0; i < this.length; i++) {
  68514. var b = this._zeroBits(this.words[i]);
  68515. r += b;
  68516. if (b !== 26) break;
  68517. }
  68518. return r;
  68519. };
  68520. BN.prototype.byteLength = function byteLength () {
  68521. return Math.ceil(this.bitLength() / 8);
  68522. };
  68523. BN.prototype.toTwos = function toTwos (width) {
  68524. if (this.negative !== 0) {
  68525. return this.abs().inotn(width).iaddn(1);
  68526. }
  68527. return this.clone();
  68528. };
  68529. BN.prototype.fromTwos = function fromTwos (width) {
  68530. if (this.testn(width - 1)) {
  68531. return this.notn(width).iaddn(1).ineg();
  68532. }
  68533. return this.clone();
  68534. };
  68535. BN.prototype.isNeg = function isNeg () {
  68536. return this.negative !== 0;
  68537. };
  68538. // Return negative clone of `this`
  68539. BN.prototype.neg = function neg () {
  68540. return this.clone().ineg();
  68541. };
  68542. BN.prototype.ineg = function ineg () {
  68543. if (!this.isZero()) {
  68544. this.negative ^= 1;
  68545. }
  68546. return this;
  68547. };
  68548. // Or `num` with `this` in-place
  68549. BN.prototype.iuor = function iuor (num) {
  68550. while (this.length < num.length) {
  68551. this.words[this.length++] = 0;
  68552. }
  68553. for (var i = 0; i < num.length; i++) {
  68554. this.words[i] = this.words[i] | num.words[i];
  68555. }
  68556. return this.strip();
  68557. };
  68558. BN.prototype.ior = function ior (num) {
  68559. assert((this.negative | num.negative) === 0);
  68560. return this.iuor(num);
  68561. };
  68562. // Or `num` with `this`
  68563. BN.prototype.or = function or (num) {
  68564. if (this.length > num.length) return this.clone().ior(num);
  68565. return num.clone().ior(this);
  68566. };
  68567. BN.prototype.uor = function uor (num) {
  68568. if (this.length > num.length) return this.clone().iuor(num);
  68569. return num.clone().iuor(this);
  68570. };
  68571. // And `num` with `this` in-place
  68572. BN.prototype.iuand = function iuand (num) {
  68573. // b = min-length(num, this)
  68574. var b;
  68575. if (this.length > num.length) {
  68576. b = num;
  68577. } else {
  68578. b = this;
  68579. }
  68580. for (var i = 0; i < b.length; i++) {
  68581. this.words[i] = this.words[i] & num.words[i];
  68582. }
  68583. this.length = b.length;
  68584. return this.strip();
  68585. };
  68586. BN.prototype.iand = function iand (num) {
  68587. assert((this.negative | num.negative) === 0);
  68588. return this.iuand(num);
  68589. };
  68590. // And `num` with `this`
  68591. BN.prototype.and = function and (num) {
  68592. if (this.length > num.length) return this.clone().iand(num);
  68593. return num.clone().iand(this);
  68594. };
  68595. BN.prototype.uand = function uand (num) {
  68596. if (this.length > num.length) return this.clone().iuand(num);
  68597. return num.clone().iuand(this);
  68598. };
  68599. // Xor `num` with `this` in-place
  68600. BN.prototype.iuxor = function iuxor (num) {
  68601. // a.length > b.length
  68602. var a;
  68603. var b;
  68604. if (this.length > num.length) {
  68605. a = this;
  68606. b = num;
  68607. } else {
  68608. a = num;
  68609. b = this;
  68610. }
  68611. for (var i = 0; i < b.length; i++) {
  68612. this.words[i] = a.words[i] ^ b.words[i];
  68613. }
  68614. if (this !== a) {
  68615. for (; i < a.length; i++) {
  68616. this.words[i] = a.words[i];
  68617. }
  68618. }
  68619. this.length = a.length;
  68620. return this.strip();
  68621. };
  68622. BN.prototype.ixor = function ixor (num) {
  68623. assert((this.negative | num.negative) === 0);
  68624. return this.iuxor(num);
  68625. };
  68626. // Xor `num` with `this`
  68627. BN.prototype.xor = function xor (num) {
  68628. if (this.length > num.length) return this.clone().ixor(num);
  68629. return num.clone().ixor(this);
  68630. };
  68631. BN.prototype.uxor = function uxor (num) {
  68632. if (this.length > num.length) return this.clone().iuxor(num);
  68633. return num.clone().iuxor(this);
  68634. };
  68635. // Not ``this`` with ``width`` bitwidth
  68636. BN.prototype.inotn = function inotn (width) {
  68637. assert(typeof width === 'number' && width >= 0);
  68638. var bytesNeeded = Math.ceil(width / 26) | 0;
  68639. var bitsLeft = width % 26;
  68640. // Extend the buffer with leading zeroes
  68641. this._expand(bytesNeeded);
  68642. if (bitsLeft > 0) {
  68643. bytesNeeded--;
  68644. }
  68645. // Handle complete words
  68646. for (var i = 0; i < bytesNeeded; i++) {
  68647. this.words[i] = ~this.words[i] & 0x3ffffff;
  68648. }
  68649. // Handle the residue
  68650. if (bitsLeft > 0) {
  68651. this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));
  68652. }
  68653. // And remove leading zeroes
  68654. return this.strip();
  68655. };
  68656. BN.prototype.notn = function notn (width) {
  68657. return this.clone().inotn(width);
  68658. };
  68659. // Set `bit` of `this`
  68660. BN.prototype.setn = function setn (bit, val) {
  68661. assert(typeof bit === 'number' && bit >= 0);
  68662. var off = (bit / 26) | 0;
  68663. var wbit = bit % 26;
  68664. this._expand(off + 1);
  68665. if (val) {
  68666. this.words[off] = this.words[off] | (1 << wbit);
  68667. } else {
  68668. this.words[off] = this.words[off] & ~(1 << wbit);
  68669. }
  68670. return this.strip();
  68671. };
  68672. // Add `num` to `this` in-place
  68673. BN.prototype.iadd = function iadd (num) {
  68674. var r;
  68675. // negative + positive
  68676. if (this.negative !== 0 && num.negative === 0) {
  68677. this.negative = 0;
  68678. r = this.isub(num);
  68679. this.negative ^= 1;
  68680. return this._normSign();
  68681. // positive + negative
  68682. } else if (this.negative === 0 && num.negative !== 0) {
  68683. num.negative = 0;
  68684. r = this.isub(num);
  68685. num.negative = 1;
  68686. return r._normSign();
  68687. }
  68688. // a.length > b.length
  68689. var a, b;
  68690. if (this.length > num.length) {
  68691. a = this;
  68692. b = num;
  68693. } else {
  68694. a = num;
  68695. b = this;
  68696. }
  68697. var carry = 0;
  68698. for (var i = 0; i < b.length; i++) {
  68699. r = (a.words[i] | 0) + (b.words[i] | 0) + carry;
  68700. this.words[i] = r & 0x3ffffff;
  68701. carry = r >>> 26;
  68702. }
  68703. for (; carry !== 0 && i < a.length; i++) {
  68704. r = (a.words[i] | 0) + carry;
  68705. this.words[i] = r & 0x3ffffff;
  68706. carry = r >>> 26;
  68707. }
  68708. this.length = a.length;
  68709. if (carry !== 0) {
  68710. this.words[this.length] = carry;
  68711. this.length++;
  68712. // Copy the rest of the words
  68713. } else if (a !== this) {
  68714. for (; i < a.length; i++) {
  68715. this.words[i] = a.words[i];
  68716. }
  68717. }
  68718. return this;
  68719. };
  68720. // Add `num` to `this`
  68721. BN.prototype.add = function add (num) {
  68722. var res;
  68723. if (num.negative !== 0 && this.negative === 0) {
  68724. num.negative = 0;
  68725. res = this.sub(num);
  68726. num.negative ^= 1;
  68727. return res;
  68728. } else if (num.negative === 0 && this.negative !== 0) {
  68729. this.negative = 0;
  68730. res = num.sub(this);
  68731. this.negative = 1;
  68732. return res;
  68733. }
  68734. if (this.length > num.length) return this.clone().iadd(num);
  68735. return num.clone().iadd(this);
  68736. };
  68737. // Subtract `num` from `this` in-place
  68738. BN.prototype.isub = function isub (num) {
  68739. // this - (-num) = this + num
  68740. if (num.negative !== 0) {
  68741. num.negative = 0;
  68742. var r = this.iadd(num);
  68743. num.negative = 1;
  68744. return r._normSign();
  68745. // -this - num = -(this + num)
  68746. } else if (this.negative !== 0) {
  68747. this.negative = 0;
  68748. this.iadd(num);
  68749. this.negative = 1;
  68750. return this._normSign();
  68751. }
  68752. // At this point both numbers are positive
  68753. var cmp = this.cmp(num);
  68754. // Optimization - zeroify
  68755. if (cmp === 0) {
  68756. this.negative = 0;
  68757. this.length = 1;
  68758. this.words[0] = 0;
  68759. return this;
  68760. }
  68761. // a > b
  68762. var a, b;
  68763. if (cmp > 0) {
  68764. a = this;
  68765. b = num;
  68766. } else {
  68767. a = num;
  68768. b = this;
  68769. }
  68770. var carry = 0;
  68771. for (var i = 0; i < b.length; i++) {
  68772. r = (a.words[i] | 0) - (b.words[i] | 0) + carry;
  68773. carry = r >> 26;
  68774. this.words[i] = r & 0x3ffffff;
  68775. }
  68776. for (; carry !== 0 && i < a.length; i++) {
  68777. r = (a.words[i] | 0) + carry;
  68778. carry = r >> 26;
  68779. this.words[i] = r & 0x3ffffff;
  68780. }
  68781. // Copy rest of the words
  68782. if (carry === 0 && i < a.length && a !== this) {
  68783. for (; i < a.length; i++) {
  68784. this.words[i] = a.words[i];
  68785. }
  68786. }
  68787. this.length = Math.max(this.length, i);
  68788. if (a !== this) {
  68789. this.negative = 1;
  68790. }
  68791. return this.strip();
  68792. };
  68793. // Subtract `num` from `this`
  68794. BN.prototype.sub = function sub (num) {
  68795. return this.clone().isub(num);
  68796. };
  68797. function smallMulTo (self, num, out) {
  68798. out.negative = num.negative ^ self.negative;
  68799. var len = (self.length + num.length) | 0;
  68800. out.length = len;
  68801. len = (len - 1) | 0;
  68802. // Peel one iteration (compiler can't do it, because of code complexity)
  68803. var a = self.words[0] | 0;
  68804. var b = num.words[0] | 0;
  68805. var r = a * b;
  68806. var lo = r & 0x3ffffff;
  68807. var carry = (r / 0x4000000) | 0;
  68808. out.words[0] = lo;
  68809. for (var k = 1; k < len; k++) {
  68810. // Sum all words with the same `i + j = k` and accumulate `ncarry`,
  68811. // note that ncarry could be >= 0x3ffffff
  68812. var ncarry = carry >>> 26;
  68813. var rword = carry & 0x3ffffff;
  68814. var maxJ = Math.min(k, num.length - 1);
  68815. for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
  68816. var i = (k - j) | 0;
  68817. a = self.words[i] | 0;
  68818. b = num.words[j] | 0;
  68819. r = a * b + rword;
  68820. ncarry += (r / 0x4000000) | 0;
  68821. rword = r & 0x3ffffff;
  68822. }
  68823. out.words[k] = rword | 0;
  68824. carry = ncarry | 0;
  68825. }
  68826. if (carry !== 0) {
  68827. out.words[k] = carry | 0;
  68828. } else {
  68829. out.length--;
  68830. }
  68831. return out.strip();
  68832. }
  68833. // TODO(indutny): it may be reasonable to omit it for users who don't need
  68834. // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit
  68835. // multiplication (like elliptic secp256k1).
  68836. var comb10MulTo = function comb10MulTo (self, num, out) {
  68837. var a = self.words;
  68838. var b = num.words;
  68839. var o = out.words;
  68840. var c = 0;
  68841. var lo;
  68842. var mid;
  68843. var hi;
  68844. var a0 = a[0] | 0;
  68845. var al0 = a0 & 0x1fff;
  68846. var ah0 = a0 >>> 13;
  68847. var a1 = a[1] | 0;
  68848. var al1 = a1 & 0x1fff;
  68849. var ah1 = a1 >>> 13;
  68850. var a2 = a[2] | 0;
  68851. var al2 = a2 & 0x1fff;
  68852. var ah2 = a2 >>> 13;
  68853. var a3 = a[3] | 0;
  68854. var al3 = a3 & 0x1fff;
  68855. var ah3 = a3 >>> 13;
  68856. var a4 = a[4] | 0;
  68857. var al4 = a4 & 0x1fff;
  68858. var ah4 = a4 >>> 13;
  68859. var a5 = a[5] | 0;
  68860. var al5 = a5 & 0x1fff;
  68861. var ah5 = a5 >>> 13;
  68862. var a6 = a[6] | 0;
  68863. var al6 = a6 & 0x1fff;
  68864. var ah6 = a6 >>> 13;
  68865. var a7 = a[7] | 0;
  68866. var al7 = a7 & 0x1fff;
  68867. var ah7 = a7 >>> 13;
  68868. var a8 = a[8] | 0;
  68869. var al8 = a8 & 0x1fff;
  68870. var ah8 = a8 >>> 13;
  68871. var a9 = a[9] | 0;
  68872. var al9 = a9 & 0x1fff;
  68873. var ah9 = a9 >>> 13;
  68874. var b0 = b[0] | 0;
  68875. var bl0 = b0 & 0x1fff;
  68876. var bh0 = b0 >>> 13;
  68877. var b1 = b[1] | 0;
  68878. var bl1 = b1 & 0x1fff;
  68879. var bh1 = b1 >>> 13;
  68880. var b2 = b[2] | 0;
  68881. var bl2 = b2 & 0x1fff;
  68882. var bh2 = b2 >>> 13;
  68883. var b3 = b[3] | 0;
  68884. var bl3 = b3 & 0x1fff;
  68885. var bh3 = b3 >>> 13;
  68886. var b4 = b[4] | 0;
  68887. var bl4 = b4 & 0x1fff;
  68888. var bh4 = b4 >>> 13;
  68889. var b5 = b[5] | 0;
  68890. var bl5 = b5 & 0x1fff;
  68891. var bh5 = b5 >>> 13;
  68892. var b6 = b[6] | 0;
  68893. var bl6 = b6 & 0x1fff;
  68894. var bh6 = b6 >>> 13;
  68895. var b7 = b[7] | 0;
  68896. var bl7 = b7 & 0x1fff;
  68897. var bh7 = b7 >>> 13;
  68898. var b8 = b[8] | 0;
  68899. var bl8 = b8 & 0x1fff;
  68900. var bh8 = b8 >>> 13;
  68901. var b9 = b[9] | 0;
  68902. var bl9 = b9 & 0x1fff;
  68903. var bh9 = b9 >>> 13;
  68904. out.negative = self.negative ^ num.negative;
  68905. out.length = 19;
  68906. /* k = 0 */
  68907. lo = Math.imul(al0, bl0);
  68908. mid = Math.imul(al0, bh0);
  68909. mid = (mid + Math.imul(ah0, bl0)) | 0;
  68910. hi = Math.imul(ah0, bh0);
  68911. var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  68912. c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;
  68913. w0 &= 0x3ffffff;
  68914. /* k = 1 */
  68915. lo = Math.imul(al1, bl0);
  68916. mid = Math.imul(al1, bh0);
  68917. mid = (mid + Math.imul(ah1, bl0)) | 0;
  68918. hi = Math.imul(ah1, bh0);
  68919. lo = (lo + Math.imul(al0, bl1)) | 0;
  68920. mid = (mid + Math.imul(al0, bh1)) | 0;
  68921. mid = (mid + Math.imul(ah0, bl1)) | 0;
  68922. hi = (hi + Math.imul(ah0, bh1)) | 0;
  68923. var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  68924. c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;
  68925. w1 &= 0x3ffffff;
  68926. /* k = 2 */
  68927. lo = Math.imul(al2, bl0);
  68928. mid = Math.imul(al2, bh0);
  68929. mid = (mid + Math.imul(ah2, bl0)) | 0;
  68930. hi = Math.imul(ah2, bh0);
  68931. lo = (lo + Math.imul(al1, bl1)) | 0;
  68932. mid = (mid + Math.imul(al1, bh1)) | 0;
  68933. mid = (mid + Math.imul(ah1, bl1)) | 0;
  68934. hi = (hi + Math.imul(ah1, bh1)) | 0;
  68935. lo = (lo + Math.imul(al0, bl2)) | 0;
  68936. mid = (mid + Math.imul(al0, bh2)) | 0;
  68937. mid = (mid + Math.imul(ah0, bl2)) | 0;
  68938. hi = (hi + Math.imul(ah0, bh2)) | 0;
  68939. var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  68940. c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;
  68941. w2 &= 0x3ffffff;
  68942. /* k = 3 */
  68943. lo = Math.imul(al3, bl0);
  68944. mid = Math.imul(al3, bh0);
  68945. mid = (mid + Math.imul(ah3, bl0)) | 0;
  68946. hi = Math.imul(ah3, bh0);
  68947. lo = (lo + Math.imul(al2, bl1)) | 0;
  68948. mid = (mid + Math.imul(al2, bh1)) | 0;
  68949. mid = (mid + Math.imul(ah2, bl1)) | 0;
  68950. hi = (hi + Math.imul(ah2, bh1)) | 0;
  68951. lo = (lo + Math.imul(al1, bl2)) | 0;
  68952. mid = (mid + Math.imul(al1, bh2)) | 0;
  68953. mid = (mid + Math.imul(ah1, bl2)) | 0;
  68954. hi = (hi + Math.imul(ah1, bh2)) | 0;
  68955. lo = (lo + Math.imul(al0, bl3)) | 0;
  68956. mid = (mid + Math.imul(al0, bh3)) | 0;
  68957. mid = (mid + Math.imul(ah0, bl3)) | 0;
  68958. hi = (hi + Math.imul(ah0, bh3)) | 0;
  68959. var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  68960. c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;
  68961. w3 &= 0x3ffffff;
  68962. /* k = 4 */
  68963. lo = Math.imul(al4, bl0);
  68964. mid = Math.imul(al4, bh0);
  68965. mid = (mid + Math.imul(ah4, bl0)) | 0;
  68966. hi = Math.imul(ah4, bh0);
  68967. lo = (lo + Math.imul(al3, bl1)) | 0;
  68968. mid = (mid + Math.imul(al3, bh1)) | 0;
  68969. mid = (mid + Math.imul(ah3, bl1)) | 0;
  68970. hi = (hi + Math.imul(ah3, bh1)) | 0;
  68971. lo = (lo + Math.imul(al2, bl2)) | 0;
  68972. mid = (mid + Math.imul(al2, bh2)) | 0;
  68973. mid = (mid + Math.imul(ah2, bl2)) | 0;
  68974. hi = (hi + Math.imul(ah2, bh2)) | 0;
  68975. lo = (lo + Math.imul(al1, bl3)) | 0;
  68976. mid = (mid + Math.imul(al1, bh3)) | 0;
  68977. mid = (mid + Math.imul(ah1, bl3)) | 0;
  68978. hi = (hi + Math.imul(ah1, bh3)) | 0;
  68979. lo = (lo + Math.imul(al0, bl4)) | 0;
  68980. mid = (mid + Math.imul(al0, bh4)) | 0;
  68981. mid = (mid + Math.imul(ah0, bl4)) | 0;
  68982. hi = (hi + Math.imul(ah0, bh4)) | 0;
  68983. var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  68984. c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;
  68985. w4 &= 0x3ffffff;
  68986. /* k = 5 */
  68987. lo = Math.imul(al5, bl0);
  68988. mid = Math.imul(al5, bh0);
  68989. mid = (mid + Math.imul(ah5, bl0)) | 0;
  68990. hi = Math.imul(ah5, bh0);
  68991. lo = (lo + Math.imul(al4, bl1)) | 0;
  68992. mid = (mid + Math.imul(al4, bh1)) | 0;
  68993. mid = (mid + Math.imul(ah4, bl1)) | 0;
  68994. hi = (hi + Math.imul(ah4, bh1)) | 0;
  68995. lo = (lo + Math.imul(al3, bl2)) | 0;
  68996. mid = (mid + Math.imul(al3, bh2)) | 0;
  68997. mid = (mid + Math.imul(ah3, bl2)) | 0;
  68998. hi = (hi + Math.imul(ah3, bh2)) | 0;
  68999. lo = (lo + Math.imul(al2, bl3)) | 0;
  69000. mid = (mid + Math.imul(al2, bh3)) | 0;
  69001. mid = (mid + Math.imul(ah2, bl3)) | 0;
  69002. hi = (hi + Math.imul(ah2, bh3)) | 0;
  69003. lo = (lo + Math.imul(al1, bl4)) | 0;
  69004. mid = (mid + Math.imul(al1, bh4)) | 0;
  69005. mid = (mid + Math.imul(ah1, bl4)) | 0;
  69006. hi = (hi + Math.imul(ah1, bh4)) | 0;
  69007. lo = (lo + Math.imul(al0, bl5)) | 0;
  69008. mid = (mid + Math.imul(al0, bh5)) | 0;
  69009. mid = (mid + Math.imul(ah0, bl5)) | 0;
  69010. hi = (hi + Math.imul(ah0, bh5)) | 0;
  69011. var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  69012. c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;
  69013. w5 &= 0x3ffffff;
  69014. /* k = 6 */
  69015. lo = Math.imul(al6, bl0);
  69016. mid = Math.imul(al6, bh0);
  69017. mid = (mid + Math.imul(ah6, bl0)) | 0;
  69018. hi = Math.imul(ah6, bh0);
  69019. lo = (lo + Math.imul(al5, bl1)) | 0;
  69020. mid = (mid + Math.imul(al5, bh1)) | 0;
  69021. mid = (mid + Math.imul(ah5, bl1)) | 0;
  69022. hi = (hi + Math.imul(ah5, bh1)) | 0;
  69023. lo = (lo + Math.imul(al4, bl2)) | 0;
  69024. mid = (mid + Math.imul(al4, bh2)) | 0;
  69025. mid = (mid + Math.imul(ah4, bl2)) | 0;
  69026. hi = (hi + Math.imul(ah4, bh2)) | 0;
  69027. lo = (lo + Math.imul(al3, bl3)) | 0;
  69028. mid = (mid + Math.imul(al3, bh3)) | 0;
  69029. mid = (mid + Math.imul(ah3, bl3)) | 0;
  69030. hi = (hi + Math.imul(ah3, bh3)) | 0;
  69031. lo = (lo + Math.imul(al2, bl4)) | 0;
  69032. mid = (mid + Math.imul(al2, bh4)) | 0;
  69033. mid = (mid + Math.imul(ah2, bl4)) | 0;
  69034. hi = (hi + Math.imul(ah2, bh4)) | 0;
  69035. lo = (lo + Math.imul(al1, bl5)) | 0;
  69036. mid = (mid + Math.imul(al1, bh5)) | 0;
  69037. mid = (mid + Math.imul(ah1, bl5)) | 0;
  69038. hi = (hi + Math.imul(ah1, bh5)) | 0;
  69039. lo = (lo + Math.imul(al0, bl6)) | 0;
  69040. mid = (mid + Math.imul(al0, bh6)) | 0;
  69041. mid = (mid + Math.imul(ah0, bl6)) | 0;
  69042. hi = (hi + Math.imul(ah0, bh6)) | 0;
  69043. var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  69044. c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;
  69045. w6 &= 0x3ffffff;
  69046. /* k = 7 */
  69047. lo = Math.imul(al7, bl0);
  69048. mid = Math.imul(al7, bh0);
  69049. mid = (mid + Math.imul(ah7, bl0)) | 0;
  69050. hi = Math.imul(ah7, bh0);
  69051. lo = (lo + Math.imul(al6, bl1)) | 0;
  69052. mid = (mid + Math.imul(al6, bh1)) | 0;
  69053. mid = (mid + Math.imul(ah6, bl1)) | 0;
  69054. hi = (hi + Math.imul(ah6, bh1)) | 0;
  69055. lo = (lo + Math.imul(al5, bl2)) | 0;
  69056. mid = (mid + Math.imul(al5, bh2)) | 0;
  69057. mid = (mid + Math.imul(ah5, bl2)) | 0;
  69058. hi = (hi + Math.imul(ah5, bh2)) | 0;
  69059. lo = (lo + Math.imul(al4, bl3)) | 0;
  69060. mid = (mid + Math.imul(al4, bh3)) | 0;
  69061. mid = (mid + Math.imul(ah4, bl3)) | 0;
  69062. hi = (hi + Math.imul(ah4, bh3)) | 0;
  69063. lo = (lo + Math.imul(al3, bl4)) | 0;
  69064. mid = (mid + Math.imul(al3, bh4)) | 0;
  69065. mid = (mid + Math.imul(ah3, bl4)) | 0;
  69066. hi = (hi + Math.imul(ah3, bh4)) | 0;
  69067. lo = (lo + Math.imul(al2, bl5)) | 0;
  69068. mid = (mid + Math.imul(al2, bh5)) | 0;
  69069. mid = (mid + Math.imul(ah2, bl5)) | 0;
  69070. hi = (hi + Math.imul(ah2, bh5)) | 0;
  69071. lo = (lo + Math.imul(al1, bl6)) | 0;
  69072. mid = (mid + Math.imul(al1, bh6)) | 0;
  69073. mid = (mid + Math.imul(ah1, bl6)) | 0;
  69074. hi = (hi + Math.imul(ah1, bh6)) | 0;
  69075. lo = (lo + Math.imul(al0, bl7)) | 0;
  69076. mid = (mid + Math.imul(al0, bh7)) | 0;
  69077. mid = (mid + Math.imul(ah0, bl7)) | 0;
  69078. hi = (hi + Math.imul(ah0, bh7)) | 0;
  69079. var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  69080. c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;
  69081. w7 &= 0x3ffffff;
  69082. /* k = 8 */
  69083. lo = Math.imul(al8, bl0);
  69084. mid = Math.imul(al8, bh0);
  69085. mid = (mid + Math.imul(ah8, bl0)) | 0;
  69086. hi = Math.imul(ah8, bh0);
  69087. lo = (lo + Math.imul(al7, bl1)) | 0;
  69088. mid = (mid + Math.imul(al7, bh1)) | 0;
  69089. mid = (mid + Math.imul(ah7, bl1)) | 0;
  69090. hi = (hi + Math.imul(ah7, bh1)) | 0;
  69091. lo = (lo + Math.imul(al6, bl2)) | 0;
  69092. mid = (mid + Math.imul(al6, bh2)) | 0;
  69093. mid = (mid + Math.imul(ah6, bl2)) | 0;
  69094. hi = (hi + Math.imul(ah6, bh2)) | 0;
  69095. lo = (lo + Math.imul(al5, bl3)) | 0;
  69096. mid = (mid + Math.imul(al5, bh3)) | 0;
  69097. mid = (mid + Math.imul(ah5, bl3)) | 0;
  69098. hi = (hi + Math.imul(ah5, bh3)) | 0;
  69099. lo = (lo + Math.imul(al4, bl4)) | 0;
  69100. mid = (mid + Math.imul(al4, bh4)) | 0;
  69101. mid = (mid + Math.imul(ah4, bl4)) | 0;
  69102. hi = (hi + Math.imul(ah4, bh4)) | 0;
  69103. lo = (lo + Math.imul(al3, bl5)) | 0;
  69104. mid = (mid + Math.imul(al3, bh5)) | 0;
  69105. mid = (mid + Math.imul(ah3, bl5)) | 0;
  69106. hi = (hi + Math.imul(ah3, bh5)) | 0;
  69107. lo = (lo + Math.imul(al2, bl6)) | 0;
  69108. mid = (mid + Math.imul(al2, bh6)) | 0;
  69109. mid = (mid + Math.imul(ah2, bl6)) | 0;
  69110. hi = (hi + Math.imul(ah2, bh6)) | 0;
  69111. lo = (lo + Math.imul(al1, bl7)) | 0;
  69112. mid = (mid + Math.imul(al1, bh7)) | 0;
  69113. mid = (mid + Math.imul(ah1, bl7)) | 0;
  69114. hi = (hi + Math.imul(ah1, bh7)) | 0;
  69115. lo = (lo + Math.imul(al0, bl8)) | 0;
  69116. mid = (mid + Math.imul(al0, bh8)) | 0;
  69117. mid = (mid + Math.imul(ah0, bl8)) | 0;
  69118. hi = (hi + Math.imul(ah0, bh8)) | 0;
  69119. var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  69120. c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;
  69121. w8 &= 0x3ffffff;
  69122. /* k = 9 */
  69123. lo = Math.imul(al9, bl0);
  69124. mid = Math.imul(al9, bh0);
  69125. mid = (mid + Math.imul(ah9, bl0)) | 0;
  69126. hi = Math.imul(ah9, bh0);
  69127. lo = (lo + Math.imul(al8, bl1)) | 0;
  69128. mid = (mid + Math.imul(al8, bh1)) | 0;
  69129. mid = (mid + Math.imul(ah8, bl1)) | 0;
  69130. hi = (hi + Math.imul(ah8, bh1)) | 0;
  69131. lo = (lo + Math.imul(al7, bl2)) | 0;
  69132. mid = (mid + Math.imul(al7, bh2)) | 0;
  69133. mid = (mid + Math.imul(ah7, bl2)) | 0;
  69134. hi = (hi + Math.imul(ah7, bh2)) | 0;
  69135. lo = (lo + Math.imul(al6, bl3)) | 0;
  69136. mid = (mid + Math.imul(al6, bh3)) | 0;
  69137. mid = (mid + Math.imul(ah6, bl3)) | 0;
  69138. hi = (hi + Math.imul(ah6, bh3)) | 0;
  69139. lo = (lo + Math.imul(al5, bl4)) | 0;
  69140. mid = (mid + Math.imul(al5, bh4)) | 0;
  69141. mid = (mid + Math.imul(ah5, bl4)) | 0;
  69142. hi = (hi + Math.imul(ah5, bh4)) | 0;
  69143. lo = (lo + Math.imul(al4, bl5)) | 0;
  69144. mid = (mid + Math.imul(al4, bh5)) | 0;
  69145. mid = (mid + Math.imul(ah4, bl5)) | 0;
  69146. hi = (hi + Math.imul(ah4, bh5)) | 0;
  69147. lo = (lo + Math.imul(al3, bl6)) | 0;
  69148. mid = (mid + Math.imul(al3, bh6)) | 0;
  69149. mid = (mid + Math.imul(ah3, bl6)) | 0;
  69150. hi = (hi + Math.imul(ah3, bh6)) | 0;
  69151. lo = (lo + Math.imul(al2, bl7)) | 0;
  69152. mid = (mid + Math.imul(al2, bh7)) | 0;
  69153. mid = (mid + Math.imul(ah2, bl7)) | 0;
  69154. hi = (hi + Math.imul(ah2, bh7)) | 0;
  69155. lo = (lo + Math.imul(al1, bl8)) | 0;
  69156. mid = (mid + Math.imul(al1, bh8)) | 0;
  69157. mid = (mid + Math.imul(ah1, bl8)) | 0;
  69158. hi = (hi + Math.imul(ah1, bh8)) | 0;
  69159. lo = (lo + Math.imul(al0, bl9)) | 0;
  69160. mid = (mid + Math.imul(al0, bh9)) | 0;
  69161. mid = (mid + Math.imul(ah0, bl9)) | 0;
  69162. hi = (hi + Math.imul(ah0, bh9)) | 0;
  69163. var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  69164. c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;
  69165. w9 &= 0x3ffffff;
  69166. /* k = 10 */
  69167. lo = Math.imul(al9, bl1);
  69168. mid = Math.imul(al9, bh1);
  69169. mid = (mid + Math.imul(ah9, bl1)) | 0;
  69170. hi = Math.imul(ah9, bh1);
  69171. lo = (lo + Math.imul(al8, bl2)) | 0;
  69172. mid = (mid + Math.imul(al8, bh2)) | 0;
  69173. mid = (mid + Math.imul(ah8, bl2)) | 0;
  69174. hi = (hi + Math.imul(ah8, bh2)) | 0;
  69175. lo = (lo + Math.imul(al7, bl3)) | 0;
  69176. mid = (mid + Math.imul(al7, bh3)) | 0;
  69177. mid = (mid + Math.imul(ah7, bl3)) | 0;
  69178. hi = (hi + Math.imul(ah7, bh3)) | 0;
  69179. lo = (lo + Math.imul(al6, bl4)) | 0;
  69180. mid = (mid + Math.imul(al6, bh4)) | 0;
  69181. mid = (mid + Math.imul(ah6, bl4)) | 0;
  69182. hi = (hi + Math.imul(ah6, bh4)) | 0;
  69183. lo = (lo + Math.imul(al5, bl5)) | 0;
  69184. mid = (mid + Math.imul(al5, bh5)) | 0;
  69185. mid = (mid + Math.imul(ah5, bl5)) | 0;
  69186. hi = (hi + Math.imul(ah5, bh5)) | 0;
  69187. lo = (lo + Math.imul(al4, bl6)) | 0;
  69188. mid = (mid + Math.imul(al4, bh6)) | 0;
  69189. mid = (mid + Math.imul(ah4, bl6)) | 0;
  69190. hi = (hi + Math.imul(ah4, bh6)) | 0;
  69191. lo = (lo + Math.imul(al3, bl7)) | 0;
  69192. mid = (mid + Math.imul(al3, bh7)) | 0;
  69193. mid = (mid + Math.imul(ah3, bl7)) | 0;
  69194. hi = (hi + Math.imul(ah3, bh7)) | 0;
  69195. lo = (lo + Math.imul(al2, bl8)) | 0;
  69196. mid = (mid + Math.imul(al2, bh8)) | 0;
  69197. mid = (mid + Math.imul(ah2, bl8)) | 0;
  69198. hi = (hi + Math.imul(ah2, bh8)) | 0;
  69199. lo = (lo + Math.imul(al1, bl9)) | 0;
  69200. mid = (mid + Math.imul(al1, bh9)) | 0;
  69201. mid = (mid + Math.imul(ah1, bl9)) | 0;
  69202. hi = (hi + Math.imul(ah1, bh9)) | 0;
  69203. var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  69204. c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;
  69205. w10 &= 0x3ffffff;
  69206. /* k = 11 */
  69207. lo = Math.imul(al9, bl2);
  69208. mid = Math.imul(al9, bh2);
  69209. mid = (mid + Math.imul(ah9, bl2)) | 0;
  69210. hi = Math.imul(ah9, bh2);
  69211. lo = (lo + Math.imul(al8, bl3)) | 0;
  69212. mid = (mid + Math.imul(al8, bh3)) | 0;
  69213. mid = (mid + Math.imul(ah8, bl3)) | 0;
  69214. hi = (hi + Math.imul(ah8, bh3)) | 0;
  69215. lo = (lo + Math.imul(al7, bl4)) | 0;
  69216. mid = (mid + Math.imul(al7, bh4)) | 0;
  69217. mid = (mid + Math.imul(ah7, bl4)) | 0;
  69218. hi = (hi + Math.imul(ah7, bh4)) | 0;
  69219. lo = (lo + Math.imul(al6, bl5)) | 0;
  69220. mid = (mid + Math.imul(al6, bh5)) | 0;
  69221. mid = (mid + Math.imul(ah6, bl5)) | 0;
  69222. hi = (hi + Math.imul(ah6, bh5)) | 0;
  69223. lo = (lo + Math.imul(al5, bl6)) | 0;
  69224. mid = (mid + Math.imul(al5, bh6)) | 0;
  69225. mid = (mid + Math.imul(ah5, bl6)) | 0;
  69226. hi = (hi + Math.imul(ah5, bh6)) | 0;
  69227. lo = (lo + Math.imul(al4, bl7)) | 0;
  69228. mid = (mid + Math.imul(al4, bh7)) | 0;
  69229. mid = (mid + Math.imul(ah4, bl7)) | 0;
  69230. hi = (hi + Math.imul(ah4, bh7)) | 0;
  69231. lo = (lo + Math.imul(al3, bl8)) | 0;
  69232. mid = (mid + Math.imul(al3, bh8)) | 0;
  69233. mid = (mid + Math.imul(ah3, bl8)) | 0;
  69234. hi = (hi + Math.imul(ah3, bh8)) | 0;
  69235. lo = (lo + Math.imul(al2, bl9)) | 0;
  69236. mid = (mid + Math.imul(al2, bh9)) | 0;
  69237. mid = (mid + Math.imul(ah2, bl9)) | 0;
  69238. hi = (hi + Math.imul(ah2, bh9)) | 0;
  69239. var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  69240. c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;
  69241. w11 &= 0x3ffffff;
  69242. /* k = 12 */
  69243. lo = Math.imul(al9, bl3);
  69244. mid = Math.imul(al9, bh3);
  69245. mid = (mid + Math.imul(ah9, bl3)) | 0;
  69246. hi = Math.imul(ah9, bh3);
  69247. lo = (lo + Math.imul(al8, bl4)) | 0;
  69248. mid = (mid + Math.imul(al8, bh4)) | 0;
  69249. mid = (mid + Math.imul(ah8, bl4)) | 0;
  69250. hi = (hi + Math.imul(ah8, bh4)) | 0;
  69251. lo = (lo + Math.imul(al7, bl5)) | 0;
  69252. mid = (mid + Math.imul(al7, bh5)) | 0;
  69253. mid = (mid + Math.imul(ah7, bl5)) | 0;
  69254. hi = (hi + Math.imul(ah7, bh5)) | 0;
  69255. lo = (lo + Math.imul(al6, bl6)) | 0;
  69256. mid = (mid + Math.imul(al6, bh6)) | 0;
  69257. mid = (mid + Math.imul(ah6, bl6)) | 0;
  69258. hi = (hi + Math.imul(ah6, bh6)) | 0;
  69259. lo = (lo + Math.imul(al5, bl7)) | 0;
  69260. mid = (mid + Math.imul(al5, bh7)) | 0;
  69261. mid = (mid + Math.imul(ah5, bl7)) | 0;
  69262. hi = (hi + Math.imul(ah5, bh7)) | 0;
  69263. lo = (lo + Math.imul(al4, bl8)) | 0;
  69264. mid = (mid + Math.imul(al4, bh8)) | 0;
  69265. mid = (mid + Math.imul(ah4, bl8)) | 0;
  69266. hi = (hi + Math.imul(ah4, bh8)) | 0;
  69267. lo = (lo + Math.imul(al3, bl9)) | 0;
  69268. mid = (mid + Math.imul(al3, bh9)) | 0;
  69269. mid = (mid + Math.imul(ah3, bl9)) | 0;
  69270. hi = (hi + Math.imul(ah3, bh9)) | 0;
  69271. var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  69272. c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;
  69273. w12 &= 0x3ffffff;
  69274. /* k = 13 */
  69275. lo = Math.imul(al9, bl4);
  69276. mid = Math.imul(al9, bh4);
  69277. mid = (mid + Math.imul(ah9, bl4)) | 0;
  69278. hi = Math.imul(ah9, bh4);
  69279. lo = (lo + Math.imul(al8, bl5)) | 0;
  69280. mid = (mid + Math.imul(al8, bh5)) | 0;
  69281. mid = (mid + Math.imul(ah8, bl5)) | 0;
  69282. hi = (hi + Math.imul(ah8, bh5)) | 0;
  69283. lo = (lo + Math.imul(al7, bl6)) | 0;
  69284. mid = (mid + Math.imul(al7, bh6)) | 0;
  69285. mid = (mid + Math.imul(ah7, bl6)) | 0;
  69286. hi = (hi + Math.imul(ah7, bh6)) | 0;
  69287. lo = (lo + Math.imul(al6, bl7)) | 0;
  69288. mid = (mid + Math.imul(al6, bh7)) | 0;
  69289. mid = (mid + Math.imul(ah6, bl7)) | 0;
  69290. hi = (hi + Math.imul(ah6, bh7)) | 0;
  69291. lo = (lo + Math.imul(al5, bl8)) | 0;
  69292. mid = (mid + Math.imul(al5, bh8)) | 0;
  69293. mid = (mid + Math.imul(ah5, bl8)) | 0;
  69294. hi = (hi + Math.imul(ah5, bh8)) | 0;
  69295. lo = (lo + Math.imul(al4, bl9)) | 0;
  69296. mid = (mid + Math.imul(al4, bh9)) | 0;
  69297. mid = (mid + Math.imul(ah4, bl9)) | 0;
  69298. hi = (hi + Math.imul(ah4, bh9)) | 0;
  69299. var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  69300. c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;
  69301. w13 &= 0x3ffffff;
  69302. /* k = 14 */
  69303. lo = Math.imul(al9, bl5);
  69304. mid = Math.imul(al9, bh5);
  69305. mid = (mid + Math.imul(ah9, bl5)) | 0;
  69306. hi = Math.imul(ah9, bh5);
  69307. lo = (lo + Math.imul(al8, bl6)) | 0;
  69308. mid = (mid + Math.imul(al8, bh6)) | 0;
  69309. mid = (mid + Math.imul(ah8, bl6)) | 0;
  69310. hi = (hi + Math.imul(ah8, bh6)) | 0;
  69311. lo = (lo + Math.imul(al7, bl7)) | 0;
  69312. mid = (mid + Math.imul(al7, bh7)) | 0;
  69313. mid = (mid + Math.imul(ah7, bl7)) | 0;
  69314. hi = (hi + Math.imul(ah7, bh7)) | 0;
  69315. lo = (lo + Math.imul(al6, bl8)) | 0;
  69316. mid = (mid + Math.imul(al6, bh8)) | 0;
  69317. mid = (mid + Math.imul(ah6, bl8)) | 0;
  69318. hi = (hi + Math.imul(ah6, bh8)) | 0;
  69319. lo = (lo + Math.imul(al5, bl9)) | 0;
  69320. mid = (mid + Math.imul(al5, bh9)) | 0;
  69321. mid = (mid + Math.imul(ah5, bl9)) | 0;
  69322. hi = (hi + Math.imul(ah5, bh9)) | 0;
  69323. var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  69324. c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;
  69325. w14 &= 0x3ffffff;
  69326. /* k = 15 */
  69327. lo = Math.imul(al9, bl6);
  69328. mid = Math.imul(al9, bh6);
  69329. mid = (mid + Math.imul(ah9, bl6)) | 0;
  69330. hi = Math.imul(ah9, bh6);
  69331. lo = (lo + Math.imul(al8, bl7)) | 0;
  69332. mid = (mid + Math.imul(al8, bh7)) | 0;
  69333. mid = (mid + Math.imul(ah8, bl7)) | 0;
  69334. hi = (hi + Math.imul(ah8, bh7)) | 0;
  69335. lo = (lo + Math.imul(al7, bl8)) | 0;
  69336. mid = (mid + Math.imul(al7, bh8)) | 0;
  69337. mid = (mid + Math.imul(ah7, bl8)) | 0;
  69338. hi = (hi + Math.imul(ah7, bh8)) | 0;
  69339. lo = (lo + Math.imul(al6, bl9)) | 0;
  69340. mid = (mid + Math.imul(al6, bh9)) | 0;
  69341. mid = (mid + Math.imul(ah6, bl9)) | 0;
  69342. hi = (hi + Math.imul(ah6, bh9)) | 0;
  69343. var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  69344. c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;
  69345. w15 &= 0x3ffffff;
  69346. /* k = 16 */
  69347. lo = Math.imul(al9, bl7);
  69348. mid = Math.imul(al9, bh7);
  69349. mid = (mid + Math.imul(ah9, bl7)) | 0;
  69350. hi = Math.imul(ah9, bh7);
  69351. lo = (lo + Math.imul(al8, bl8)) | 0;
  69352. mid = (mid + Math.imul(al8, bh8)) | 0;
  69353. mid = (mid + Math.imul(ah8, bl8)) | 0;
  69354. hi = (hi + Math.imul(ah8, bh8)) | 0;
  69355. lo = (lo + Math.imul(al7, bl9)) | 0;
  69356. mid = (mid + Math.imul(al7, bh9)) | 0;
  69357. mid = (mid + Math.imul(ah7, bl9)) | 0;
  69358. hi = (hi + Math.imul(ah7, bh9)) | 0;
  69359. var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  69360. c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;
  69361. w16 &= 0x3ffffff;
  69362. /* k = 17 */
  69363. lo = Math.imul(al9, bl8);
  69364. mid = Math.imul(al9, bh8);
  69365. mid = (mid + Math.imul(ah9, bl8)) | 0;
  69366. hi = Math.imul(ah9, bh8);
  69367. lo = (lo + Math.imul(al8, bl9)) | 0;
  69368. mid = (mid + Math.imul(al8, bh9)) | 0;
  69369. mid = (mid + Math.imul(ah8, bl9)) | 0;
  69370. hi = (hi + Math.imul(ah8, bh9)) | 0;
  69371. var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  69372. c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;
  69373. w17 &= 0x3ffffff;
  69374. /* k = 18 */
  69375. lo = Math.imul(al9, bl9);
  69376. mid = Math.imul(al9, bh9);
  69377. mid = (mid + Math.imul(ah9, bl9)) | 0;
  69378. hi = Math.imul(ah9, bh9);
  69379. var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;
  69380. c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;
  69381. w18 &= 0x3ffffff;
  69382. o[0] = w0;
  69383. o[1] = w1;
  69384. o[2] = w2;
  69385. o[3] = w3;
  69386. o[4] = w4;
  69387. o[5] = w5;
  69388. o[6] = w6;
  69389. o[7] = w7;
  69390. o[8] = w8;
  69391. o[9] = w9;
  69392. o[10] = w10;
  69393. o[11] = w11;
  69394. o[12] = w12;
  69395. o[13] = w13;
  69396. o[14] = w14;
  69397. o[15] = w15;
  69398. o[16] = w16;
  69399. o[17] = w17;
  69400. o[18] = w18;
  69401. if (c !== 0) {
  69402. o[19] = c;
  69403. out.length++;
  69404. }
  69405. return out;
  69406. };
  69407. // Polyfill comb
  69408. if (!Math.imul) {
  69409. comb10MulTo = smallMulTo;
  69410. }
  69411. function bigMulTo (self, num, out) {
  69412. out.negative = num.negative ^ self.negative;
  69413. out.length = self.length + num.length;
  69414. var carry = 0;
  69415. var hncarry = 0;
  69416. for (var k = 0; k < out.length - 1; k++) {
  69417. // Sum all words with the same `i + j = k` and accumulate `ncarry`,
  69418. // note that ncarry could be >= 0x3ffffff
  69419. var ncarry = hncarry;
  69420. hncarry = 0;
  69421. var rword = carry & 0x3ffffff;
  69422. var maxJ = Math.min(k, num.length - 1);
  69423. for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {
  69424. var i = k - j;
  69425. var a = self.words[i] | 0;
  69426. var b = num.words[j] | 0;
  69427. var r = a * b;
  69428. var lo = r & 0x3ffffff;
  69429. ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;
  69430. lo = (lo + rword) | 0;
  69431. rword = lo & 0x3ffffff;
  69432. ncarry = (ncarry + (lo >>> 26)) | 0;
  69433. hncarry += ncarry >>> 26;
  69434. ncarry &= 0x3ffffff;
  69435. }
  69436. out.words[k] = rword;
  69437. carry = ncarry;
  69438. ncarry = hncarry;
  69439. }
  69440. if (carry !== 0) {
  69441. out.words[k] = carry;
  69442. } else {
  69443. out.length--;
  69444. }
  69445. return out.strip();
  69446. }
  69447. function jumboMulTo (self, num, out) {
  69448. var fftm = new FFTM();
  69449. return fftm.mulp(self, num, out);
  69450. }
  69451. BN.prototype.mulTo = function mulTo (num, out) {
  69452. var res;
  69453. var len = this.length + num.length;
  69454. if (this.length === 10 && num.length === 10) {
  69455. res = comb10MulTo(this, num, out);
  69456. } else if (len < 63) {
  69457. res = smallMulTo(this, num, out);
  69458. } else if (len < 1024) {
  69459. res = bigMulTo(this, num, out);
  69460. } else {
  69461. res = jumboMulTo(this, num, out);
  69462. }
  69463. return res;
  69464. };
  69465. // Cooley-Tukey algorithm for FFT
  69466. // slightly revisited to rely on looping instead of recursion
  69467. function FFTM (x, y) {
  69468. this.x = x;
  69469. this.y = y;
  69470. }
  69471. FFTM.prototype.makeRBT = function makeRBT (N) {
  69472. var t = new Array(N);
  69473. var l = BN.prototype._countBits(N) - 1;
  69474. for (var i = 0; i < N; i++) {
  69475. t[i] = this.revBin(i, l, N);
  69476. }
  69477. return t;
  69478. };
  69479. // Returns binary-reversed representation of `x`
  69480. FFTM.prototype.revBin = function revBin (x, l, N) {
  69481. if (x === 0 || x === N - 1) return x;
  69482. var rb = 0;
  69483. for (var i = 0; i < l; i++) {
  69484. rb |= (x & 1) << (l - i - 1);
  69485. x >>= 1;
  69486. }
  69487. return rb;
  69488. };
  69489. // Performs "tweedling" phase, therefore 'emulating'
  69490. // behaviour of the recursive algorithm
  69491. FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {
  69492. for (var i = 0; i < N; i++) {
  69493. rtws[i] = rws[rbt[i]];
  69494. itws[i] = iws[rbt[i]];
  69495. }
  69496. };
  69497. FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {
  69498. this.permute(rbt, rws, iws, rtws, itws, N);
  69499. for (var s = 1; s < N; s <<= 1) {
  69500. var l = s << 1;
  69501. var rtwdf = Math.cos(2 * Math.PI / l);
  69502. var itwdf = Math.sin(2 * Math.PI / l);
  69503. for (var p = 0; p < N; p += l) {
  69504. var rtwdf_ = rtwdf;
  69505. var itwdf_ = itwdf;
  69506. for (var j = 0; j < s; j++) {
  69507. var re = rtws[p + j];
  69508. var ie = itws[p + j];
  69509. var ro = rtws[p + j + s];
  69510. var io = itws[p + j + s];
  69511. var rx = rtwdf_ * ro - itwdf_ * io;
  69512. io = rtwdf_ * io + itwdf_ * ro;
  69513. ro = rx;
  69514. rtws[p + j] = re + ro;
  69515. itws[p + j] = ie + io;
  69516. rtws[p + j + s] = re - ro;
  69517. itws[p + j + s] = ie - io;
  69518. /* jshint maxdepth : false */
  69519. if (j !== l) {
  69520. rx = rtwdf * rtwdf_ - itwdf * itwdf_;
  69521. itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
  69522. rtwdf_ = rx;
  69523. }
  69524. }
  69525. }
  69526. }
  69527. };
  69528. FFTM.prototype.guessLen13b = function guessLen13b (n, m) {
  69529. var N = Math.max(m, n) | 1;
  69530. var odd = N & 1;
  69531. var i = 0;
  69532. for (N = N / 2 | 0; N; N = N >>> 1) {
  69533. i++;
  69534. }
  69535. return 1 << i + 1 + odd;
  69536. };
  69537. FFTM.prototype.conjugate = function conjugate (rws, iws, N) {
  69538. if (N <= 1) return;
  69539. for (var i = 0; i < N / 2; i++) {
  69540. var t = rws[i];
  69541. rws[i] = rws[N - i - 1];
  69542. rws[N - i - 1] = t;
  69543. t = iws[i];
  69544. iws[i] = -iws[N - i - 1];
  69545. iws[N - i - 1] = -t;
  69546. }
  69547. };
  69548. FFTM.prototype.normalize13b = function normalize13b (ws, N) {
  69549. var carry = 0;
  69550. for (var i = 0; i < N / 2; i++) {
  69551. var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +
  69552. Math.round(ws[2 * i] / N) +
  69553. carry;
  69554. ws[i] = w & 0x3ffffff;
  69555. if (w < 0x4000000) {
  69556. carry = 0;
  69557. } else {
  69558. carry = w / 0x4000000 | 0;
  69559. }
  69560. }
  69561. return ws;
  69562. };
  69563. FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {
  69564. var carry = 0;
  69565. for (var i = 0; i < len; i++) {
  69566. carry = carry + (ws[i] | 0);
  69567. rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;
  69568. rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;
  69569. }
  69570. // Pad with zeroes
  69571. for (i = 2 * len; i < N; ++i) {
  69572. rws[i] = 0;
  69573. }
  69574. assert(carry === 0);
  69575. assert((carry & ~0x1fff) === 0);
  69576. };
  69577. FFTM.prototype.stub = function stub (N) {
  69578. var ph = new Array(N);
  69579. for (var i = 0; i < N; i++) {
  69580. ph[i] = 0;
  69581. }
  69582. return ph;
  69583. };
  69584. FFTM.prototype.mulp = function mulp (x, y, out) {
  69585. var N = 2 * this.guessLen13b(x.length, y.length);
  69586. var rbt = this.makeRBT(N);
  69587. var _ = this.stub(N);
  69588. var rws = new Array(N);
  69589. var rwst = new Array(N);
  69590. var iwst = new Array(N);
  69591. var nrws = new Array(N);
  69592. var nrwst = new Array(N);
  69593. var niwst = new Array(N);
  69594. var rmws = out.words;
  69595. rmws.length = N;
  69596. this.convert13b(x.words, x.length, rws, N);
  69597. this.convert13b(y.words, y.length, nrws, N);
  69598. this.transform(rws, _, rwst, iwst, N, rbt);
  69599. this.transform(nrws, _, nrwst, niwst, N, rbt);
  69600. for (var i = 0; i < N; i++) {
  69601. var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];
  69602. iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];
  69603. rwst[i] = rx;
  69604. }
  69605. this.conjugate(rwst, iwst, N);
  69606. this.transform(rwst, iwst, rmws, _, N, rbt);
  69607. this.conjugate(rmws, _, N);
  69608. this.normalize13b(rmws, N);
  69609. out.negative = x.negative ^ y.negative;
  69610. out.length = x.length + y.length;
  69611. return out.strip();
  69612. };
  69613. // Multiply `this` by `num`
  69614. BN.prototype.mul = function mul (num) {
  69615. var out = new BN(null);
  69616. out.words = new Array(this.length + num.length);
  69617. return this.mulTo(num, out);
  69618. };
  69619. // Multiply employing FFT
  69620. BN.prototype.mulf = function mulf (num) {
  69621. var out = new BN(null);
  69622. out.words = new Array(this.length + num.length);
  69623. return jumboMulTo(this, num, out);
  69624. };
  69625. // In-place Multiplication
  69626. BN.prototype.imul = function imul (num) {
  69627. return this.clone().mulTo(num, this);
  69628. };
  69629. BN.prototype.imuln = function imuln (num) {
  69630. assert(typeof num === 'number');
  69631. assert(num < 0x4000000);
  69632. // Carry
  69633. var carry = 0;
  69634. for (var i = 0; i < this.length; i++) {
  69635. var w = (this.words[i] | 0) * num;
  69636. var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);
  69637. carry >>= 26;
  69638. carry += (w / 0x4000000) | 0;
  69639. // NOTE: lo is 27bit maximum
  69640. carry += lo >>> 26;
  69641. this.words[i] = lo & 0x3ffffff;
  69642. }
  69643. if (carry !== 0) {
  69644. this.words[i] = carry;
  69645. this.length++;
  69646. }
  69647. return this;
  69648. };
  69649. BN.prototype.muln = function muln (num) {
  69650. return this.clone().imuln(num);
  69651. };
  69652. // `this` * `this`
  69653. BN.prototype.sqr = function sqr () {
  69654. return this.mul(this);
  69655. };
  69656. // `this` * `this` in-place
  69657. BN.prototype.isqr = function isqr () {
  69658. return this.imul(this.clone());
  69659. };
  69660. // Math.pow(`this`, `num`)
  69661. BN.prototype.pow = function pow (num) {
  69662. var w = toBitArray(num);
  69663. if (w.length === 0) return new BN(1);
  69664. // Skip leading zeroes
  69665. var res = this;
  69666. for (var i = 0; i < w.length; i++, res = res.sqr()) {
  69667. if (w[i] !== 0) break;
  69668. }
  69669. if (++i < w.length) {
  69670. for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {
  69671. if (w[i] === 0) continue;
  69672. res = res.mul(q);
  69673. }
  69674. }
  69675. return res;
  69676. };
  69677. // Shift-left in-place
  69678. BN.prototype.iushln = function iushln (bits) {
  69679. assert(typeof bits === 'number' && bits >= 0);
  69680. var r = bits % 26;
  69681. var s = (bits - r) / 26;
  69682. var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);
  69683. var i;
  69684. if (r !== 0) {
  69685. var carry = 0;
  69686. for (i = 0; i < this.length; i++) {
  69687. var newCarry = this.words[i] & carryMask;
  69688. var c = ((this.words[i] | 0) - newCarry) << r;
  69689. this.words[i] = c | carry;
  69690. carry = newCarry >>> (26 - r);
  69691. }
  69692. if (carry) {
  69693. this.words[i] = carry;
  69694. this.length++;
  69695. }
  69696. }
  69697. if (s !== 0) {
  69698. for (i = this.length - 1; i >= 0; i--) {
  69699. this.words[i + s] = this.words[i];
  69700. }
  69701. for (i = 0; i < s; i++) {
  69702. this.words[i] = 0;
  69703. }
  69704. this.length += s;
  69705. }
  69706. return this.strip();
  69707. };
  69708. BN.prototype.ishln = function ishln (bits) {
  69709. // TODO(indutny): implement me
  69710. assert(this.negative === 0);
  69711. return this.iushln(bits);
  69712. };
  69713. // Shift-right in-place
  69714. // NOTE: `hint` is a lowest bit before trailing zeroes
  69715. // NOTE: if `extended` is present - it will be filled with destroyed bits
  69716. BN.prototype.iushrn = function iushrn (bits, hint, extended) {
  69717. assert(typeof bits === 'number' && bits >= 0);
  69718. var h;
  69719. if (hint) {
  69720. h = (hint - (hint % 26)) / 26;
  69721. } else {
  69722. h = 0;
  69723. }
  69724. var r = bits % 26;
  69725. var s = Math.min((bits - r) / 26, this.length);
  69726. var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
  69727. var maskedWords = extended;
  69728. h -= s;
  69729. h = Math.max(0, h);
  69730. // Extended mode, copy masked part
  69731. if (maskedWords) {
  69732. for (var i = 0; i < s; i++) {
  69733. maskedWords.words[i] = this.words[i];
  69734. }
  69735. maskedWords.length = s;
  69736. }
  69737. if (s === 0) {
  69738. // No-op, we should not move anything at all
  69739. } else if (this.length > s) {
  69740. this.length -= s;
  69741. for (i = 0; i < this.length; i++) {
  69742. this.words[i] = this.words[i + s];
  69743. }
  69744. } else {
  69745. this.words[0] = 0;
  69746. this.length = 1;
  69747. }
  69748. var carry = 0;
  69749. for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {
  69750. var word = this.words[i] | 0;
  69751. this.words[i] = (carry << (26 - r)) | (word >>> r);
  69752. carry = word & mask;
  69753. }
  69754. // Push carried bits as a mask
  69755. if (maskedWords && carry !== 0) {
  69756. maskedWords.words[maskedWords.length++] = carry;
  69757. }
  69758. if (this.length === 0) {
  69759. this.words[0] = 0;
  69760. this.length = 1;
  69761. }
  69762. return this.strip();
  69763. };
  69764. BN.prototype.ishrn = function ishrn (bits, hint, extended) {
  69765. // TODO(indutny): implement me
  69766. assert(this.negative === 0);
  69767. return this.iushrn(bits, hint, extended);
  69768. };
  69769. // Shift-left
  69770. BN.prototype.shln = function shln (bits) {
  69771. return this.clone().ishln(bits);
  69772. };
  69773. BN.prototype.ushln = function ushln (bits) {
  69774. return this.clone().iushln(bits);
  69775. };
  69776. // Shift-right
  69777. BN.prototype.shrn = function shrn (bits) {
  69778. return this.clone().ishrn(bits);
  69779. };
  69780. BN.prototype.ushrn = function ushrn (bits) {
  69781. return this.clone().iushrn(bits);
  69782. };
  69783. // Test if n bit is set
  69784. BN.prototype.testn = function testn (bit) {
  69785. assert(typeof bit === 'number' && bit >= 0);
  69786. var r = bit % 26;
  69787. var s = (bit - r) / 26;
  69788. var q = 1 << r;
  69789. // Fast case: bit is much higher than all existing words
  69790. if (this.length <= s) return false;
  69791. // Check bit and return
  69792. var w = this.words[s];
  69793. return !!(w & q);
  69794. };
  69795. // Return only lowers bits of number (in-place)
  69796. BN.prototype.imaskn = function imaskn (bits) {
  69797. assert(typeof bits === 'number' && bits >= 0);
  69798. var r = bits % 26;
  69799. var s = (bits - r) / 26;
  69800. assert(this.negative === 0, 'imaskn works only with positive numbers');
  69801. if (this.length <= s) {
  69802. return this;
  69803. }
  69804. if (r !== 0) {
  69805. s++;
  69806. }
  69807. this.length = Math.min(s, this.length);
  69808. if (r !== 0) {
  69809. var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);
  69810. this.words[this.length - 1] &= mask;
  69811. }
  69812. return this.strip();
  69813. };
  69814. // Return only lowers bits of number
  69815. BN.prototype.maskn = function maskn (bits) {
  69816. return this.clone().imaskn(bits);
  69817. };
  69818. // Add plain number `num` to `this`
  69819. BN.prototype.iaddn = function iaddn (num) {
  69820. assert(typeof num === 'number');
  69821. assert(num < 0x4000000);
  69822. if (num < 0) return this.isubn(-num);
  69823. // Possible sign change
  69824. if (this.negative !== 0) {
  69825. if (this.length === 1 && (this.words[0] | 0) < num) {
  69826. this.words[0] = num - (this.words[0] | 0);
  69827. this.negative = 0;
  69828. return this;
  69829. }
  69830. this.negative = 0;
  69831. this.isubn(num);
  69832. this.negative = 1;
  69833. return this;
  69834. }
  69835. // Add without checks
  69836. return this._iaddn(num);
  69837. };
  69838. BN.prototype._iaddn = function _iaddn (num) {
  69839. this.words[0] += num;
  69840. // Carry
  69841. for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {
  69842. this.words[i] -= 0x4000000;
  69843. if (i === this.length - 1) {
  69844. this.words[i + 1] = 1;
  69845. } else {
  69846. this.words[i + 1]++;
  69847. }
  69848. }
  69849. this.length = Math.max(this.length, i + 1);
  69850. return this;
  69851. };
  69852. // Subtract plain number `num` from `this`
  69853. BN.prototype.isubn = function isubn (num) {
  69854. assert(typeof num === 'number');
  69855. assert(num < 0x4000000);
  69856. if (num < 0) return this.iaddn(-num);
  69857. if (this.negative !== 0) {
  69858. this.negative = 0;
  69859. this.iaddn(num);
  69860. this.negative = 1;
  69861. return this;
  69862. }
  69863. this.words[0] -= num;
  69864. if (this.length === 1 && this.words[0] < 0) {
  69865. this.words[0] = -this.words[0];
  69866. this.negative = 1;
  69867. } else {
  69868. // Carry
  69869. for (var i = 0; i < this.length && this.words[i] < 0; i++) {
  69870. this.words[i] += 0x4000000;
  69871. this.words[i + 1] -= 1;
  69872. }
  69873. }
  69874. return this.strip();
  69875. };
  69876. BN.prototype.addn = function addn (num) {
  69877. return this.clone().iaddn(num);
  69878. };
  69879. BN.prototype.subn = function subn (num) {
  69880. return this.clone().isubn(num);
  69881. };
  69882. BN.prototype.iabs = function iabs () {
  69883. this.negative = 0;
  69884. return this;
  69885. };
  69886. BN.prototype.abs = function abs () {
  69887. return this.clone().iabs();
  69888. };
  69889. BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {
  69890. var len = num.length + shift;
  69891. var i;
  69892. this._expand(len);
  69893. var w;
  69894. var carry = 0;
  69895. for (i = 0; i < num.length; i++) {
  69896. w = (this.words[i + shift] | 0) + carry;
  69897. var right = (num.words[i] | 0) * mul;
  69898. w -= right & 0x3ffffff;
  69899. carry = (w >> 26) - ((right / 0x4000000) | 0);
  69900. this.words[i + shift] = w & 0x3ffffff;
  69901. }
  69902. for (; i < this.length - shift; i++) {
  69903. w = (this.words[i + shift] | 0) + carry;
  69904. carry = w >> 26;
  69905. this.words[i + shift] = w & 0x3ffffff;
  69906. }
  69907. if (carry === 0) return this.strip();
  69908. // Subtraction overflow
  69909. assert(carry === -1);
  69910. carry = 0;
  69911. for (i = 0; i < this.length; i++) {
  69912. w = -(this.words[i] | 0) + carry;
  69913. carry = w >> 26;
  69914. this.words[i] = w & 0x3ffffff;
  69915. }
  69916. this.negative = 1;
  69917. return this.strip();
  69918. };
  69919. BN.prototype._wordDiv = function _wordDiv (num, mode) {
  69920. var shift = this.length - num.length;
  69921. var a = this.clone();
  69922. var b = num;
  69923. // Normalize
  69924. var bhi = b.words[b.length - 1] | 0;
  69925. var bhiBits = this._countBits(bhi);
  69926. shift = 26 - bhiBits;
  69927. if (shift !== 0) {
  69928. b = b.ushln(shift);
  69929. a.iushln(shift);
  69930. bhi = b.words[b.length - 1] | 0;
  69931. }
  69932. // Initialize quotient
  69933. var m = a.length - b.length;
  69934. var q;
  69935. if (mode !== 'mod') {
  69936. q = new BN(null);
  69937. q.length = m + 1;
  69938. q.words = new Array(q.length);
  69939. for (var i = 0; i < q.length; i++) {
  69940. q.words[i] = 0;
  69941. }
  69942. }
  69943. var diff = a.clone()._ishlnsubmul(b, 1, m);
  69944. if (diff.negative === 0) {
  69945. a = diff;
  69946. if (q) {
  69947. q.words[m] = 1;
  69948. }
  69949. }
  69950. for (var j = m - 1; j >= 0; j--) {
  69951. var qj = (a.words[b.length + j] | 0) * 0x4000000 +
  69952. (a.words[b.length + j - 1] | 0);
  69953. // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
  69954. // (0x7ffffff)
  69955. qj = Math.min((qj / bhi) | 0, 0x3ffffff);
  69956. a._ishlnsubmul(b, qj, j);
  69957. while (a.negative !== 0) {
  69958. qj--;
  69959. a.negative = 0;
  69960. a._ishlnsubmul(b, 1, j);
  69961. if (!a.isZero()) {
  69962. a.negative ^= 1;
  69963. }
  69964. }
  69965. if (q) {
  69966. q.words[j] = qj;
  69967. }
  69968. }
  69969. if (q) {
  69970. q.strip();
  69971. }
  69972. a.strip();
  69973. // Denormalize
  69974. if (mode !== 'div' && shift !== 0) {
  69975. a.iushrn(shift);
  69976. }
  69977. return {
  69978. div: q || null,
  69979. mod: a
  69980. };
  69981. };
  69982. // NOTE: 1) `mode` can be set to `mod` to request mod only,
  69983. // to `div` to request div only, or be absent to
  69984. // request both div & mod
  69985. // 2) `positive` is true if unsigned mod is requested
  69986. BN.prototype.divmod = function divmod (num, mode, positive) {
  69987. assert(!num.isZero());
  69988. if (this.isZero()) {
  69989. return {
  69990. div: new BN(0),
  69991. mod: new BN(0)
  69992. };
  69993. }
  69994. var div, mod, res;
  69995. if (this.negative !== 0 && num.negative === 0) {
  69996. res = this.neg().divmod(num, mode);
  69997. if (mode !== 'mod') {
  69998. div = res.div.neg();
  69999. }
  70000. if (mode !== 'div') {
  70001. mod = res.mod.neg();
  70002. if (positive && mod.negative !== 0) {
  70003. mod.iadd(num);
  70004. }
  70005. }
  70006. return {
  70007. div: div,
  70008. mod: mod
  70009. };
  70010. }
  70011. if (this.negative === 0 && num.negative !== 0) {
  70012. res = this.divmod(num.neg(), mode);
  70013. if (mode !== 'mod') {
  70014. div = res.div.neg();
  70015. }
  70016. return {
  70017. div: div,
  70018. mod: res.mod
  70019. };
  70020. }
  70021. if ((this.negative & num.negative) !== 0) {
  70022. res = this.neg().divmod(num.neg(), mode);
  70023. if (mode !== 'div') {
  70024. mod = res.mod.neg();
  70025. if (positive && mod.negative !== 0) {
  70026. mod.isub(num);
  70027. }
  70028. }
  70029. return {
  70030. div: res.div,
  70031. mod: mod
  70032. };
  70033. }
  70034. // Both numbers are positive at this point
  70035. // Strip both numbers to approximate shift value
  70036. if (num.length > this.length || this.cmp(num) < 0) {
  70037. return {
  70038. div: new BN(0),
  70039. mod: this
  70040. };
  70041. }
  70042. // Very short reduction
  70043. if (num.length === 1) {
  70044. if (mode === 'div') {
  70045. return {
  70046. div: this.divn(num.words[0]),
  70047. mod: null
  70048. };
  70049. }
  70050. if (mode === 'mod') {
  70051. return {
  70052. div: null,
  70053. mod: new BN(this.modn(num.words[0]))
  70054. };
  70055. }
  70056. return {
  70057. div: this.divn(num.words[0]),
  70058. mod: new BN(this.modn(num.words[0]))
  70059. };
  70060. }
  70061. return this._wordDiv(num, mode);
  70062. };
  70063. // Find `this` / `num`
  70064. BN.prototype.div = function div (num) {
  70065. return this.divmod(num, 'div', false).div;
  70066. };
  70067. // Find `this` % `num`
  70068. BN.prototype.mod = function mod (num) {
  70069. return this.divmod(num, 'mod', false).mod;
  70070. };
  70071. BN.prototype.umod = function umod (num) {
  70072. return this.divmod(num, 'mod', true).mod;
  70073. };
  70074. // Find Round(`this` / `num`)
  70075. BN.prototype.divRound = function divRound (num) {
  70076. var dm = this.divmod(num);
  70077. // Fast case - exact division
  70078. if (dm.mod.isZero()) return dm.div;
  70079. var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
  70080. var half = num.ushrn(1);
  70081. var r2 = num.andln(1);
  70082. var cmp = mod.cmp(half);
  70083. // Round down
  70084. if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;
  70085. // Round up
  70086. return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
  70087. };
  70088. BN.prototype.modn = function modn (num) {
  70089. assert(num <= 0x3ffffff);
  70090. var p = (1 << 26) % num;
  70091. var acc = 0;
  70092. for (var i = this.length - 1; i >= 0; i--) {
  70093. acc = (p * acc + (this.words[i] | 0)) % num;
  70094. }
  70095. return acc;
  70096. };
  70097. // In-place division by number
  70098. BN.prototype.idivn = function idivn (num) {
  70099. assert(num <= 0x3ffffff);
  70100. var carry = 0;
  70101. for (var i = this.length - 1; i >= 0; i--) {
  70102. var w = (this.words[i] | 0) + carry * 0x4000000;
  70103. this.words[i] = (w / num) | 0;
  70104. carry = w % num;
  70105. }
  70106. return this.strip();
  70107. };
  70108. BN.prototype.divn = function divn (num) {
  70109. return this.clone().idivn(num);
  70110. };
  70111. BN.prototype.egcd = function egcd (p) {
  70112. assert(p.negative === 0);
  70113. assert(!p.isZero());
  70114. var x = this;
  70115. var y = p.clone();
  70116. if (x.negative !== 0) {
  70117. x = x.umod(p);
  70118. } else {
  70119. x = x.clone();
  70120. }
  70121. // A * x + B * y = x
  70122. var A = new BN(1);
  70123. var B = new BN(0);
  70124. // C * x + D * y = y
  70125. var C = new BN(0);
  70126. var D = new BN(1);
  70127. var g = 0;
  70128. while (x.isEven() && y.isEven()) {
  70129. x.iushrn(1);
  70130. y.iushrn(1);
  70131. ++g;
  70132. }
  70133. var yp = y.clone();
  70134. var xp = x.clone();
  70135. while (!x.isZero()) {
  70136. for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
  70137. if (i > 0) {
  70138. x.iushrn(i);
  70139. while (i-- > 0) {
  70140. if (A.isOdd() || B.isOdd()) {
  70141. A.iadd(yp);
  70142. B.isub(xp);
  70143. }
  70144. A.iushrn(1);
  70145. B.iushrn(1);
  70146. }
  70147. }
  70148. for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
  70149. if (j > 0) {
  70150. y.iushrn(j);
  70151. while (j-- > 0) {
  70152. if (C.isOdd() || D.isOdd()) {
  70153. C.iadd(yp);
  70154. D.isub(xp);
  70155. }
  70156. C.iushrn(1);
  70157. D.iushrn(1);
  70158. }
  70159. }
  70160. if (x.cmp(y) >= 0) {
  70161. x.isub(y);
  70162. A.isub(C);
  70163. B.isub(D);
  70164. } else {
  70165. y.isub(x);
  70166. C.isub(A);
  70167. D.isub(B);
  70168. }
  70169. }
  70170. return {
  70171. a: C,
  70172. b: D,
  70173. gcd: y.iushln(g)
  70174. };
  70175. };
  70176. // This is reduced incarnation of the binary EEA
  70177. // above, designated to invert members of the
  70178. // _prime_ fields F(p) at a maximal speed
  70179. BN.prototype._invmp = function _invmp (p) {
  70180. assert(p.negative === 0);
  70181. assert(!p.isZero());
  70182. var a = this;
  70183. var b = p.clone();
  70184. if (a.negative !== 0) {
  70185. a = a.umod(p);
  70186. } else {
  70187. a = a.clone();
  70188. }
  70189. var x1 = new BN(1);
  70190. var x2 = new BN(0);
  70191. var delta = b.clone();
  70192. while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {
  70193. for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);
  70194. if (i > 0) {
  70195. a.iushrn(i);
  70196. while (i-- > 0) {
  70197. if (x1.isOdd()) {
  70198. x1.iadd(delta);
  70199. }
  70200. x1.iushrn(1);
  70201. }
  70202. }
  70203. for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);
  70204. if (j > 0) {
  70205. b.iushrn(j);
  70206. while (j-- > 0) {
  70207. if (x2.isOdd()) {
  70208. x2.iadd(delta);
  70209. }
  70210. x2.iushrn(1);
  70211. }
  70212. }
  70213. if (a.cmp(b) >= 0) {
  70214. a.isub(b);
  70215. x1.isub(x2);
  70216. } else {
  70217. b.isub(a);
  70218. x2.isub(x1);
  70219. }
  70220. }
  70221. var res;
  70222. if (a.cmpn(1) === 0) {
  70223. res = x1;
  70224. } else {
  70225. res = x2;
  70226. }
  70227. if (res.cmpn(0) < 0) {
  70228. res.iadd(p);
  70229. }
  70230. return res;
  70231. };
  70232. BN.prototype.gcd = function gcd (num) {
  70233. if (this.isZero()) return num.abs();
  70234. if (num.isZero()) return this.abs();
  70235. var a = this.clone();
  70236. var b = num.clone();
  70237. a.negative = 0;
  70238. b.negative = 0;
  70239. // Remove common factor of two
  70240. for (var shift = 0; a.isEven() && b.isEven(); shift++) {
  70241. a.iushrn(1);
  70242. b.iushrn(1);
  70243. }
  70244. do {
  70245. while (a.isEven()) {
  70246. a.iushrn(1);
  70247. }
  70248. while (b.isEven()) {
  70249. b.iushrn(1);
  70250. }
  70251. var r = a.cmp(b);
  70252. if (r < 0) {
  70253. // Swap `a` and `b` to make `a` always bigger than `b`
  70254. var t = a;
  70255. a = b;
  70256. b = t;
  70257. } else if (r === 0 || b.cmpn(1) === 0) {
  70258. break;
  70259. }
  70260. a.isub(b);
  70261. } while (true);
  70262. return b.iushln(shift);
  70263. };
  70264. // Invert number in the field F(num)
  70265. BN.prototype.invm = function invm (num) {
  70266. return this.egcd(num).a.umod(num);
  70267. };
  70268. BN.prototype.isEven = function isEven () {
  70269. return (this.words[0] & 1) === 0;
  70270. };
  70271. BN.prototype.isOdd = function isOdd () {
  70272. return (this.words[0] & 1) === 1;
  70273. };
  70274. // And first word and num
  70275. BN.prototype.andln = function andln (num) {
  70276. return this.words[0] & num;
  70277. };
  70278. // Increment at the bit position in-line
  70279. BN.prototype.bincn = function bincn (bit) {
  70280. assert(typeof bit === 'number');
  70281. var r = bit % 26;
  70282. var s = (bit - r) / 26;
  70283. var q = 1 << r;
  70284. // Fast case: bit is much higher than all existing words
  70285. if (this.length <= s) {
  70286. this._expand(s + 1);
  70287. this.words[s] |= q;
  70288. return this;
  70289. }
  70290. // Add bit and propagate, if needed
  70291. var carry = q;
  70292. for (var i = s; carry !== 0 && i < this.length; i++) {
  70293. var w = this.words[i] | 0;
  70294. w += carry;
  70295. carry = w >>> 26;
  70296. w &= 0x3ffffff;
  70297. this.words[i] = w;
  70298. }
  70299. if (carry !== 0) {
  70300. this.words[i] = carry;
  70301. this.length++;
  70302. }
  70303. return this;
  70304. };
  70305. BN.prototype.isZero = function isZero () {
  70306. return this.length === 1 && this.words[0] === 0;
  70307. };
  70308. BN.prototype.cmpn = function cmpn (num) {
  70309. var negative = num < 0;
  70310. if (this.negative !== 0 && !negative) return -1;
  70311. if (this.negative === 0 && negative) return 1;
  70312. this.strip();
  70313. var res;
  70314. if (this.length > 1) {
  70315. res = 1;
  70316. } else {
  70317. if (negative) {
  70318. num = -num;
  70319. }
  70320. assert(num <= 0x3ffffff, 'Number is too big');
  70321. var w = this.words[0] | 0;
  70322. res = w === num ? 0 : w < num ? -1 : 1;
  70323. }
  70324. if (this.negative !== 0) return -res | 0;
  70325. return res;
  70326. };
  70327. // Compare two numbers and return:
  70328. // 1 - if `this` > `num`
  70329. // 0 - if `this` == `num`
  70330. // -1 - if `this` < `num`
  70331. BN.prototype.cmp = function cmp (num) {
  70332. if (this.negative !== 0 && num.negative === 0) return -1;
  70333. if (this.negative === 0 && num.negative !== 0) return 1;
  70334. var res = this.ucmp(num);
  70335. if (this.negative !== 0) return -res | 0;
  70336. return res;
  70337. };
  70338. // Unsigned comparison
  70339. BN.prototype.ucmp = function ucmp (num) {
  70340. // At this point both numbers have the same sign
  70341. if (this.length > num.length) return 1;
  70342. if (this.length < num.length) return -1;
  70343. var res = 0;
  70344. for (var i = this.length - 1; i >= 0; i--) {
  70345. var a = this.words[i] | 0;
  70346. var b = num.words[i] | 0;
  70347. if (a === b) continue;
  70348. if (a < b) {
  70349. res = -1;
  70350. } else if (a > b) {
  70351. res = 1;
  70352. }
  70353. break;
  70354. }
  70355. return res;
  70356. };
  70357. BN.prototype.gtn = function gtn (num) {
  70358. return this.cmpn(num) === 1;
  70359. };
  70360. BN.prototype.gt = function gt (num) {
  70361. return this.cmp(num) === 1;
  70362. };
  70363. BN.prototype.gten = function gten (num) {
  70364. return this.cmpn(num) >= 0;
  70365. };
  70366. BN.prototype.gte = function gte (num) {
  70367. return this.cmp(num) >= 0;
  70368. };
  70369. BN.prototype.ltn = function ltn (num) {
  70370. return this.cmpn(num) === -1;
  70371. };
  70372. BN.prototype.lt = function lt (num) {
  70373. return this.cmp(num) === -1;
  70374. };
  70375. BN.prototype.lten = function lten (num) {
  70376. return this.cmpn(num) <= 0;
  70377. };
  70378. BN.prototype.lte = function lte (num) {
  70379. return this.cmp(num) <= 0;
  70380. };
  70381. BN.prototype.eqn = function eqn (num) {
  70382. return this.cmpn(num) === 0;
  70383. };
  70384. BN.prototype.eq = function eq (num) {
  70385. return this.cmp(num) === 0;
  70386. };
  70387. //
  70388. // A reduce context, could be using montgomery or something better, depending
  70389. // on the `m` itself.
  70390. //
  70391. BN.red = function red (num) {
  70392. return new Red(num);
  70393. };
  70394. BN.prototype.toRed = function toRed (ctx) {
  70395. assert(!this.red, 'Already a number in reduction context');
  70396. assert(this.negative === 0, 'red works only with positives');
  70397. return ctx.convertTo(this)._forceRed(ctx);
  70398. };
  70399. BN.prototype.fromRed = function fromRed () {
  70400. assert(this.red, 'fromRed works only with numbers in reduction context');
  70401. return this.red.convertFrom(this);
  70402. };
  70403. BN.prototype._forceRed = function _forceRed (ctx) {
  70404. this.red = ctx;
  70405. return this;
  70406. };
  70407. BN.prototype.forceRed = function forceRed (ctx) {
  70408. assert(!this.red, 'Already a number in reduction context');
  70409. return this._forceRed(ctx);
  70410. };
  70411. BN.prototype.redAdd = function redAdd (num) {
  70412. assert(this.red, 'redAdd works only with red numbers');
  70413. return this.red.add(this, num);
  70414. };
  70415. BN.prototype.redIAdd = function redIAdd (num) {
  70416. assert(this.red, 'redIAdd works only with red numbers');
  70417. return this.red.iadd(this, num);
  70418. };
  70419. BN.prototype.redSub = function redSub (num) {
  70420. assert(this.red, 'redSub works only with red numbers');
  70421. return this.red.sub(this, num);
  70422. };
  70423. BN.prototype.redISub = function redISub (num) {
  70424. assert(this.red, 'redISub works only with red numbers');
  70425. return this.red.isub(this, num);
  70426. };
  70427. BN.prototype.redShl = function redShl (num) {
  70428. assert(this.red, 'redShl works only with red numbers');
  70429. return this.red.shl(this, num);
  70430. };
  70431. BN.prototype.redMul = function redMul (num) {
  70432. assert(this.red, 'redMul works only with red numbers');
  70433. this.red._verify2(this, num);
  70434. return this.red.mul(this, num);
  70435. };
  70436. BN.prototype.redIMul = function redIMul (num) {
  70437. assert(this.red, 'redMul works only with red numbers');
  70438. this.red._verify2(this, num);
  70439. return this.red.imul(this, num);
  70440. };
  70441. BN.prototype.redSqr = function redSqr () {
  70442. assert(this.red, 'redSqr works only with red numbers');
  70443. this.red._verify1(this);
  70444. return this.red.sqr(this);
  70445. };
  70446. BN.prototype.redISqr = function redISqr () {
  70447. assert(this.red, 'redISqr works only with red numbers');
  70448. this.red._verify1(this);
  70449. return this.red.isqr(this);
  70450. };
  70451. // Square root over p
  70452. BN.prototype.redSqrt = function redSqrt () {
  70453. assert(this.red, 'redSqrt works only with red numbers');
  70454. this.red._verify1(this);
  70455. return this.red.sqrt(this);
  70456. };
  70457. BN.prototype.redInvm = function redInvm () {
  70458. assert(this.red, 'redInvm works only with red numbers');
  70459. this.red._verify1(this);
  70460. return this.red.invm(this);
  70461. };
  70462. // Return negative clone of `this` % `red modulo`
  70463. BN.prototype.redNeg = function redNeg () {
  70464. assert(this.red, 'redNeg works only with red numbers');
  70465. this.red._verify1(this);
  70466. return this.red.neg(this);
  70467. };
  70468. BN.prototype.redPow = function redPow (num) {
  70469. assert(this.red && !num.red, 'redPow(normalNum)');
  70470. this.red._verify1(this);
  70471. return this.red.pow(this, num);
  70472. };
  70473. // Prime numbers with efficient reduction
  70474. var primes = {
  70475. k256: null,
  70476. p224: null,
  70477. p192: null,
  70478. p25519: null
  70479. };
  70480. // Pseudo-Mersenne prime
  70481. function MPrime (name, p) {
  70482. // P = 2 ^ N - K
  70483. this.name = name;
  70484. this.p = new BN(p, 16);
  70485. this.n = this.p.bitLength();
  70486. this.k = new BN(1).iushln(this.n).isub(this.p);
  70487. this.tmp = this._tmp();
  70488. }
  70489. MPrime.prototype._tmp = function _tmp () {
  70490. var tmp = new BN(null);
  70491. tmp.words = new Array(Math.ceil(this.n / 13));
  70492. return tmp;
  70493. };
  70494. MPrime.prototype.ireduce = function ireduce (num) {
  70495. // Assumes that `num` is less than `P^2`
  70496. // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)
  70497. var r = num;
  70498. var rlen;
  70499. do {
  70500. this.split(r, this.tmp);
  70501. r = this.imulK(r);
  70502. r = r.iadd(this.tmp);
  70503. rlen = r.bitLength();
  70504. } while (rlen > this.n);
  70505. var cmp = rlen < this.n ? -1 : r.ucmp(this.p);
  70506. if (cmp === 0) {
  70507. r.words[0] = 0;
  70508. r.length = 1;
  70509. } else if (cmp > 0) {
  70510. r.isub(this.p);
  70511. } else {
  70512. r.strip();
  70513. }
  70514. return r;
  70515. };
  70516. MPrime.prototype.split = function split (input, out) {
  70517. input.iushrn(this.n, 0, out);
  70518. };
  70519. MPrime.prototype.imulK = function imulK (num) {
  70520. return num.imul(this.k);
  70521. };
  70522. function K256 () {
  70523. MPrime.call(
  70524. this,
  70525. 'k256',
  70526. 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');
  70527. }
  70528. inherits(K256, MPrime);
  70529. K256.prototype.split = function split (input, output) {
  70530. // 256 = 9 * 26 + 22
  70531. var mask = 0x3fffff;
  70532. var outLen = Math.min(input.length, 9);
  70533. for (var i = 0; i < outLen; i++) {
  70534. output.words[i] = input.words[i];
  70535. }
  70536. output.length = outLen;
  70537. if (input.length <= 9) {
  70538. input.words[0] = 0;
  70539. input.length = 1;
  70540. return;
  70541. }
  70542. // Shift by 9 limbs
  70543. var prev = input.words[9];
  70544. output.words[output.length++] = prev & mask;
  70545. for (i = 10; i < input.length; i++) {
  70546. var next = input.words[i] | 0;
  70547. input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);
  70548. prev = next;
  70549. }
  70550. prev >>>= 22;
  70551. input.words[i - 10] = prev;
  70552. if (prev === 0 && input.length > 10) {
  70553. input.length -= 10;
  70554. } else {
  70555. input.length -= 9;
  70556. }
  70557. };
  70558. K256.prototype.imulK = function imulK (num) {
  70559. // K = 0x1000003d1 = [ 0x40, 0x3d1 ]
  70560. num.words[num.length] = 0;
  70561. num.words[num.length + 1] = 0;
  70562. num.length += 2;
  70563. // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
  70564. var lo = 0;
  70565. for (var i = 0; i < num.length; i++) {
  70566. var w = num.words[i] | 0;
  70567. lo += w * 0x3d1;
  70568. num.words[i] = lo & 0x3ffffff;
  70569. lo = w * 0x40 + ((lo / 0x4000000) | 0);
  70570. }
  70571. // Fast length reduction
  70572. if (num.words[num.length - 1] === 0) {
  70573. num.length--;
  70574. if (num.words[num.length - 1] === 0) {
  70575. num.length--;
  70576. }
  70577. }
  70578. return num;
  70579. };
  70580. function P224 () {
  70581. MPrime.call(
  70582. this,
  70583. 'p224',
  70584. 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');
  70585. }
  70586. inherits(P224, MPrime);
  70587. function P192 () {
  70588. MPrime.call(
  70589. this,
  70590. 'p192',
  70591. 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');
  70592. }
  70593. inherits(P192, MPrime);
  70594. function P25519 () {
  70595. // 2 ^ 255 - 19
  70596. MPrime.call(
  70597. this,
  70598. '25519',
  70599. '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');
  70600. }
  70601. inherits(P25519, MPrime);
  70602. P25519.prototype.imulK = function imulK (num) {
  70603. // K = 0x13
  70604. var carry = 0;
  70605. for (var i = 0; i < num.length; i++) {
  70606. var hi = (num.words[i] | 0) * 0x13 + carry;
  70607. var lo = hi & 0x3ffffff;
  70608. hi >>>= 26;
  70609. num.words[i] = lo;
  70610. carry = hi;
  70611. }
  70612. if (carry !== 0) {
  70613. num.words[num.length++] = carry;
  70614. }
  70615. return num;
  70616. };
  70617. // Exported mostly for testing purposes, use plain name instead
  70618. BN._prime = function prime (name) {
  70619. // Cached version of prime
  70620. if (primes[name]) return primes[name];
  70621. var prime;
  70622. if (name === 'k256') {
  70623. prime = new K256();
  70624. } else if (name === 'p224') {
  70625. prime = new P224();
  70626. } else if (name === 'p192') {
  70627. prime = new P192();
  70628. } else if (name === 'p25519') {
  70629. prime = new P25519();
  70630. } else {
  70631. throw new Error('Unknown prime ' + name);
  70632. }
  70633. primes[name] = prime;
  70634. return prime;
  70635. };
  70636. //
  70637. // Base reduction engine
  70638. //
  70639. function Red (m) {
  70640. if (typeof m === 'string') {
  70641. var prime = BN._prime(m);
  70642. this.m = prime.p;
  70643. this.prime = prime;
  70644. } else {
  70645. assert(m.gtn(1), 'modulus must be greater than 1');
  70646. this.m = m;
  70647. this.prime = null;
  70648. }
  70649. }
  70650. Red.prototype._verify1 = function _verify1 (a) {
  70651. assert(a.negative === 0, 'red works only with positives');
  70652. assert(a.red, 'red works only with red numbers');
  70653. };
  70654. Red.prototype._verify2 = function _verify2 (a, b) {
  70655. assert((a.negative | b.negative) === 0, 'red works only with positives');
  70656. assert(a.red && a.red === b.red,
  70657. 'red works only with red numbers');
  70658. };
  70659. Red.prototype.imod = function imod (a) {
  70660. if (this.prime) return this.prime.ireduce(a)._forceRed(this);
  70661. return a.umod(this.m)._forceRed(this);
  70662. };
  70663. Red.prototype.neg = function neg (a) {
  70664. if (a.isZero()) {
  70665. return a.clone();
  70666. }
  70667. return this.m.sub(a)._forceRed(this);
  70668. };
  70669. Red.prototype.add = function add (a, b) {
  70670. this._verify2(a, b);
  70671. var res = a.add(b);
  70672. if (res.cmp(this.m) >= 0) {
  70673. res.isub(this.m);
  70674. }
  70675. return res._forceRed(this);
  70676. };
  70677. Red.prototype.iadd = function iadd (a, b) {
  70678. this._verify2(a, b);
  70679. var res = a.iadd(b);
  70680. if (res.cmp(this.m) >= 0) {
  70681. res.isub(this.m);
  70682. }
  70683. return res;
  70684. };
  70685. Red.prototype.sub = function sub (a, b) {
  70686. this._verify2(a, b);
  70687. var res = a.sub(b);
  70688. if (res.cmpn(0) < 0) {
  70689. res.iadd(this.m);
  70690. }
  70691. return res._forceRed(this);
  70692. };
  70693. Red.prototype.isub = function isub (a, b) {
  70694. this._verify2(a, b);
  70695. var res = a.isub(b);
  70696. if (res.cmpn(0) < 0) {
  70697. res.iadd(this.m);
  70698. }
  70699. return res;
  70700. };
  70701. Red.prototype.shl = function shl (a, num) {
  70702. this._verify1(a);
  70703. return this.imod(a.ushln(num));
  70704. };
  70705. Red.prototype.imul = function imul (a, b) {
  70706. this._verify2(a, b);
  70707. return this.imod(a.imul(b));
  70708. };
  70709. Red.prototype.mul = function mul (a, b) {
  70710. this._verify2(a, b);
  70711. return this.imod(a.mul(b));
  70712. };
  70713. Red.prototype.isqr = function isqr (a) {
  70714. return this.imul(a, a.clone());
  70715. };
  70716. Red.prototype.sqr = function sqr (a) {
  70717. return this.mul(a, a);
  70718. };
  70719. Red.prototype.sqrt = function sqrt (a) {
  70720. if (a.isZero()) return a.clone();
  70721. var mod3 = this.m.andln(3);
  70722. assert(mod3 % 2 === 1);
  70723. // Fast case
  70724. if (mod3 === 3) {
  70725. var pow = this.m.add(new BN(1)).iushrn(2);
  70726. return this.pow(a, pow);
  70727. }
  70728. // Tonelli-Shanks algorithm (Totally unoptimized and slow)
  70729. //
  70730. // Find Q and S, that Q * 2 ^ S = (P - 1)
  70731. var q = this.m.subn(1);
  70732. var s = 0;
  70733. while (!q.isZero() && q.andln(1) === 0) {
  70734. s++;
  70735. q.iushrn(1);
  70736. }
  70737. assert(!q.isZero());
  70738. var one = new BN(1).toRed(this);
  70739. var nOne = one.redNeg();
  70740. // Find quadratic non-residue
  70741. // NOTE: Max is such because of generalized Riemann hypothesis.
  70742. var lpow = this.m.subn(1).iushrn(1);
  70743. var z = this.m.bitLength();
  70744. z = new BN(2 * z * z).toRed(this);
  70745. while (this.pow(z, lpow).cmp(nOne) !== 0) {
  70746. z.redIAdd(nOne);
  70747. }
  70748. var c = this.pow(z, q);
  70749. var r = this.pow(a, q.addn(1).iushrn(1));
  70750. var t = this.pow(a, q);
  70751. var m = s;
  70752. while (t.cmp(one) !== 0) {
  70753. var tmp = t;
  70754. for (var i = 0; tmp.cmp(one) !== 0; i++) {
  70755. tmp = tmp.redSqr();
  70756. }
  70757. assert(i < m);
  70758. var b = this.pow(c, new BN(1).iushln(m - i - 1));
  70759. r = r.redMul(b);
  70760. c = b.redSqr();
  70761. t = t.redMul(c);
  70762. m = i;
  70763. }
  70764. return r;
  70765. };
  70766. Red.prototype.invm = function invm (a) {
  70767. var inv = a._invmp(this.m);
  70768. if (inv.negative !== 0) {
  70769. inv.negative = 0;
  70770. return this.imod(inv).redNeg();
  70771. } else {
  70772. return this.imod(inv);
  70773. }
  70774. };
  70775. Red.prototype.pow = function pow (a, num) {
  70776. if (num.isZero()) return new BN(1);
  70777. if (num.cmpn(1) === 0) return a.clone();
  70778. var windowSize = 4;
  70779. var wnd = new Array(1 << windowSize);
  70780. wnd[0] = new BN(1).toRed(this);
  70781. wnd[1] = a;
  70782. for (var i = 2; i < wnd.length; i++) {
  70783. wnd[i] = this.mul(wnd[i - 1], a);
  70784. }
  70785. var res = wnd[0];
  70786. var current = 0;
  70787. var currentLen = 0;
  70788. var start = num.bitLength() % 26;
  70789. if (start === 0) {
  70790. start = 26;
  70791. }
  70792. for (i = num.length - 1; i >= 0; i--) {
  70793. var word = num.words[i];
  70794. for (var j = start - 1; j >= 0; j--) {
  70795. var bit = (word >> j) & 1;
  70796. if (res !== wnd[0]) {
  70797. res = this.sqr(res);
  70798. }
  70799. if (bit === 0 && current === 0) {
  70800. currentLen = 0;
  70801. continue;
  70802. }
  70803. current <<= 1;
  70804. current |= bit;
  70805. currentLen++;
  70806. if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;
  70807. res = this.mul(res, wnd[current]);
  70808. currentLen = 0;
  70809. current = 0;
  70810. }
  70811. start = 26;
  70812. }
  70813. return res;
  70814. };
  70815. Red.prototype.convertTo = function convertTo (num) {
  70816. var r = num.umod(this.m);
  70817. return r === num ? r.clone() : r;
  70818. };
  70819. Red.prototype.convertFrom = function convertFrom (num) {
  70820. var res = num.clone();
  70821. res.red = null;
  70822. return res;
  70823. };
  70824. //
  70825. // Montgomery method engine
  70826. //
  70827. BN.mont = function mont (num) {
  70828. return new Mont(num);
  70829. };
  70830. function Mont (m) {
  70831. Red.call(this, m);
  70832. this.shift = this.m.bitLength();
  70833. if (this.shift % 26 !== 0) {
  70834. this.shift += 26 - (this.shift % 26);
  70835. }
  70836. this.r = new BN(1).iushln(this.shift);
  70837. this.r2 = this.imod(this.r.sqr());
  70838. this.rinv = this.r._invmp(this.m);
  70839. this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);
  70840. this.minv = this.minv.umod(this.r);
  70841. this.minv = this.r.sub(this.minv);
  70842. }
  70843. inherits(Mont, Red);
  70844. Mont.prototype.convertTo = function convertTo (num) {
  70845. return this.imod(num.ushln(this.shift));
  70846. };
  70847. Mont.prototype.convertFrom = function convertFrom (num) {
  70848. var r = this.imod(num.mul(this.rinv));
  70849. r.red = null;
  70850. return r;
  70851. };
  70852. Mont.prototype.imul = function imul (a, b) {
  70853. if (a.isZero() || b.isZero()) {
  70854. a.words[0] = 0;
  70855. a.length = 1;
  70856. return a;
  70857. }
  70858. var t = a.imul(b);
  70859. var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
  70860. var u = t.isub(c).iushrn(this.shift);
  70861. var res = u;
  70862. if (u.cmp(this.m) >= 0) {
  70863. res = u.isub(this.m);
  70864. } else if (u.cmpn(0) < 0) {
  70865. res = u.iadd(this.m);
  70866. }
  70867. return res._forceRed(this);
  70868. };
  70869. Mont.prototype.mul = function mul (a, b) {
  70870. if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);
  70871. var t = a.mul(b);
  70872. var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);
  70873. var u = t.isub(c).iushrn(this.shift);
  70874. var res = u;
  70875. if (u.cmp(this.m) >= 0) {
  70876. res = u.isub(this.m);
  70877. } else if (u.cmpn(0) < 0) {
  70878. res = u.iadd(this.m);
  70879. }
  70880. return res._forceRed(this);
  70881. };
  70882. Mont.prototype.invm = function invm (a) {
  70883. // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R
  70884. var res = this.imod(a._invmp(this.m).mul(this.r2));
  70885. return res._forceRed(this);
  70886. };
  70887. })(typeof module === 'undefined' || module, this);
  70888. },{}],5:[function(require,module,exports){
  70889. var r;
  70890. module.exports = function rand(len) {
  70891. if (!r)
  70892. r = new Rand(null);
  70893. return r.generate(len);
  70894. };
  70895. function Rand(rand) {
  70896. this.rand = rand;
  70897. }
  70898. module.exports.Rand = Rand;
  70899. Rand.prototype.generate = function generate(len) {
  70900. return this._rand(len);
  70901. };
  70902. // Emulate crypto API using randy
  70903. Rand.prototype._rand = function _rand(n) {
  70904. if (this.rand.getBytes)
  70905. return this.rand.getBytes(n);
  70906. var res = new Uint8Array(n);
  70907. for (var i = 0; i < res.length; i++)
  70908. res[i] = this.rand.getByte();
  70909. return res;
  70910. };
  70911. if (typeof self === 'object') {
  70912. if (self.crypto && self.crypto.getRandomValues) {
  70913. // Modern browsers
  70914. Rand.prototype._rand = function _rand(n) {
  70915. var arr = new Uint8Array(n);
  70916. self.crypto.getRandomValues(arr);
  70917. return arr;
  70918. };
  70919. } else if (self.msCrypto && self.msCrypto.getRandomValues) {
  70920. // IE
  70921. Rand.prototype._rand = function _rand(n) {
  70922. var arr = new Uint8Array(n);
  70923. self.msCrypto.getRandomValues(arr);
  70924. return arr;
  70925. };
  70926. // Safari's WebWorkers do not have `crypto`
  70927. } else if (typeof window === 'object') {
  70928. // Old junk
  70929. Rand.prototype._rand = function() {
  70930. throw new Error('Not implemented yet');
  70931. };
  70932. }
  70933. } else {
  70934. // Node.js or Web worker with no crypto support
  70935. try {
  70936. var crypto = require('crypto');
  70937. if (typeof crypto.randomBytes !== 'function')
  70938. throw new Error('Not supported');
  70939. Rand.prototype._rand = function _rand(n) {
  70940. return crypto.randomBytes(n);
  70941. };
  70942. } catch (e) {
  70943. }
  70944. }
  70945. },{"crypto":63}],6:[function(require,module,exports){
  70946. (function (Buffer){
  70947. var Transform = require('stream').Transform
  70948. var inherits = require('inherits')
  70949. var StringDecoder = require('string_decoder').StringDecoder
  70950. module.exports = CipherBase
  70951. inherits(CipherBase, Transform)
  70952. function CipherBase (hashMode) {
  70953. Transform.call(this)
  70954. this.hashMode = typeof hashMode === 'string'
  70955. if (this.hashMode) {
  70956. this[hashMode] = this._finalOrDigest
  70957. } else {
  70958. this.final = this._finalOrDigest
  70959. }
  70960. this._decoder = null
  70961. this._encoding = null
  70962. }
  70963. CipherBase.prototype.update = function (data, inputEnc, outputEnc) {
  70964. if (typeof data === 'string') {
  70965. data = new Buffer(data, inputEnc)
  70966. }
  70967. var outData = this._update(data)
  70968. if (this.hashMode) {
  70969. return this
  70970. }
  70971. if (outputEnc) {
  70972. outData = this._toString(outData, outputEnc)
  70973. }
  70974. return outData
  70975. }
  70976. CipherBase.prototype.setAutoPadding = function () {}
  70977. CipherBase.prototype.getAuthTag = function () {
  70978. throw new Error('trying to get auth tag in unsupported state')
  70979. }
  70980. CipherBase.prototype.setAuthTag = function () {
  70981. throw new Error('trying to set auth tag in unsupported state')
  70982. }
  70983. CipherBase.prototype.setAAD = function () {
  70984. throw new Error('trying to set aad in unsupported state')
  70985. }
  70986. CipherBase.prototype._transform = function (data, _, next) {
  70987. var err
  70988. try {
  70989. if (this.hashMode) {
  70990. this._update(data)
  70991. } else {
  70992. this.push(this._update(data))
  70993. }
  70994. } catch (e) {
  70995. err = e
  70996. } finally {
  70997. next(err)
  70998. }
  70999. }
  71000. CipherBase.prototype._flush = function (done) {
  71001. var err
  71002. try {
  71003. this.push(this._final())
  71004. } catch (e) {
  71005. err = e
  71006. } finally {
  71007. done(err)
  71008. }
  71009. }
  71010. CipherBase.prototype._finalOrDigest = function (outputEnc) {
  71011. var outData = this._final() || new Buffer('')
  71012. if (outputEnc) {
  71013. outData = this._toString(outData, outputEnc, true)
  71014. }
  71015. return outData
  71016. }
  71017. CipherBase.prototype._toString = function (value, enc, fin) {
  71018. if (!this._decoder) {
  71019. this._decoder = new StringDecoder(enc)
  71020. this._encoding = enc
  71021. }
  71022. if (this._encoding !== enc) {
  71023. throw new Error('can\'t switch encodings')
  71024. }
  71025. var out = this._decoder.write(value)
  71026. if (fin) {
  71027. out += this._decoder.end()
  71028. }
  71029. return out
  71030. }
  71031. }).call(this,require("buffer").Buffer)
  71032. },{"buffer":65,"inherits":34,"stream":85,"string_decoder":86}],7:[function(require,module,exports){
  71033. (function (Buffer){
  71034. 'use strict';
  71035. var inherits = require('inherits')
  71036. var md5 = require('./md5')
  71037. var rmd160 = require('ripemd160')
  71038. var sha = require('sha.js')
  71039. var Base = require('cipher-base')
  71040. function HashNoConstructor(hash) {
  71041. Base.call(this, 'digest')
  71042. this._hash = hash
  71043. this.buffers = []
  71044. }
  71045. inherits(HashNoConstructor, Base)
  71046. HashNoConstructor.prototype._update = function (data) {
  71047. this.buffers.push(data)
  71048. }
  71049. HashNoConstructor.prototype._final = function () {
  71050. var buf = Buffer.concat(this.buffers)
  71051. var r = this._hash(buf)
  71052. this.buffers = null
  71053. return r
  71054. }
  71055. function Hash(hash) {
  71056. Base.call(this, 'digest')
  71057. this._hash = hash
  71058. }
  71059. inherits(Hash, Base)
  71060. Hash.prototype._update = function (data) {
  71061. this._hash.update(data)
  71062. }
  71063. Hash.prototype._final = function () {
  71064. return this._hash.digest()
  71065. }
  71066. module.exports = function createHash (alg) {
  71067. alg = alg.toLowerCase()
  71068. if ('md5' === alg) return new HashNoConstructor(md5)
  71069. if ('rmd160' === alg || 'ripemd160' === alg) return new HashNoConstructor(rmd160)
  71070. return new Hash(sha(alg))
  71071. }
  71072. }).call(this,require("buffer").Buffer)
  71073. },{"./md5":9,"buffer":65,"cipher-base":6,"inherits":34,"ripemd160":44,"sha.js":53}],8:[function(require,module,exports){
  71074. (function (Buffer){
  71075. 'use strict';
  71076. var intSize = 4;
  71077. var zeroBuffer = new Buffer(intSize); zeroBuffer.fill(0);
  71078. var chrsz = 8;
  71079. function toArray(buf, bigEndian) {
  71080. if ((buf.length % intSize) !== 0) {
  71081. var len = buf.length + (intSize - (buf.length % intSize));
  71082. buf = Buffer.concat([buf, zeroBuffer], len);
  71083. }
  71084. var arr = [];
  71085. var fn = bigEndian ? buf.readInt32BE : buf.readInt32LE;
  71086. for (var i = 0; i < buf.length; i += intSize) {
  71087. arr.push(fn.call(buf, i));
  71088. }
  71089. return arr;
  71090. }
  71091. function toBuffer(arr, size, bigEndian) {
  71092. var buf = new Buffer(size);
  71093. var fn = bigEndian ? buf.writeInt32BE : buf.writeInt32LE;
  71094. for (var i = 0; i < arr.length; i++) {
  71095. fn.call(buf, arr[i], i * 4, true);
  71096. }
  71097. return buf;
  71098. }
  71099. function hash(buf, fn, hashSize, bigEndian) {
  71100. if (!Buffer.isBuffer(buf)) buf = new Buffer(buf);
  71101. var arr = fn(toArray(buf, bigEndian), buf.length * chrsz);
  71102. return toBuffer(arr, hashSize, bigEndian);
  71103. }
  71104. exports.hash = hash;
  71105. }).call(this,require("buffer").Buffer)
  71106. },{"buffer":65}],9:[function(require,module,exports){
  71107. 'use strict';
  71108. /*
  71109. * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  71110. * Digest Algorithm, as defined in RFC 1321.
  71111. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
  71112. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  71113. * Distributed under the BSD License
  71114. * See http://pajhome.org.uk/crypt/md5 for more info.
  71115. */
  71116. var helpers = require('./helpers');
  71117. /*
  71118. * Calculate the MD5 of an array of little-endian words, and a bit length
  71119. */
  71120. function core_md5(x, len)
  71121. {
  71122. /* append padding */
  71123. x[len >> 5] |= 0x80 << ((len) % 32);
  71124. x[(((len + 64) >>> 9) << 4) + 14] = len;
  71125. var a = 1732584193;
  71126. var b = -271733879;
  71127. var c = -1732584194;
  71128. var d = 271733878;
  71129. for(var i = 0; i < x.length; i += 16)
  71130. {
  71131. var olda = a;
  71132. var oldb = b;
  71133. var oldc = c;
  71134. var oldd = d;
  71135. a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
  71136. d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
  71137. c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
  71138. b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
  71139. a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
  71140. d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
  71141. c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
  71142. b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
  71143. a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
  71144. d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
  71145. c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
  71146. b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
  71147. a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
  71148. d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
  71149. c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
  71150. b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
  71151. a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
  71152. d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
  71153. c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
  71154. b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
  71155. a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
  71156. d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
  71157. c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
  71158. b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
  71159. a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
  71160. d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
  71161. c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
  71162. b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
  71163. a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
  71164. d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
  71165. c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
  71166. b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
  71167. a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
  71168. d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
  71169. c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
  71170. b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
  71171. a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
  71172. d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
  71173. c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
  71174. b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
  71175. a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
  71176. d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
  71177. c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
  71178. b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
  71179. a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
  71180. d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
  71181. c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
  71182. b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
  71183. a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
  71184. d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
  71185. c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
  71186. b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
  71187. a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
  71188. d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
  71189. c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
  71190. b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
  71191. a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
  71192. d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
  71193. c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
  71194. b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
  71195. a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
  71196. d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
  71197. c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
  71198. b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
  71199. a = safe_add(a, olda);
  71200. b = safe_add(b, oldb);
  71201. c = safe_add(c, oldc);
  71202. d = safe_add(d, oldd);
  71203. }
  71204. return Array(a, b, c, d);
  71205. }
  71206. /*
  71207. * These functions implement the four basic operations the algorithm uses.
  71208. */
  71209. function md5_cmn(q, a, b, x, s, t)
  71210. {
  71211. return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
  71212. }
  71213. function md5_ff(a, b, c, d, x, s, t)
  71214. {
  71215. return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
  71216. }
  71217. function md5_gg(a, b, c, d, x, s, t)
  71218. {
  71219. return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
  71220. }
  71221. function md5_hh(a, b, c, d, x, s, t)
  71222. {
  71223. return md5_cmn(b ^ c ^ d, a, b, x, s, t);
  71224. }
  71225. function md5_ii(a, b, c, d, x, s, t)
  71226. {
  71227. return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
  71228. }
  71229. /*
  71230. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  71231. * to work around bugs in some JS interpreters.
  71232. */
  71233. function safe_add(x, y)
  71234. {
  71235. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  71236. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  71237. return (msw << 16) | (lsw & 0xFFFF);
  71238. }
  71239. /*
  71240. * Bitwise rotate a 32-bit number to the left.
  71241. */
  71242. function bit_rol(num, cnt)
  71243. {
  71244. return (num << cnt) | (num >>> (32 - cnt));
  71245. }
  71246. module.exports = function md5(buf) {
  71247. return helpers.hash(buf, core_md5, 16);
  71248. };
  71249. },{"./helpers":8}],10:[function(require,module,exports){
  71250. 'use strict';
  71251. var elliptic = exports;
  71252. elliptic.version = require('../package.json').version;
  71253. elliptic.utils = require('./elliptic/utils');
  71254. elliptic.rand = require('brorand');
  71255. elliptic.curve = require('./elliptic/curve');
  71256. elliptic.curves = require('./elliptic/curves');
  71257. // Protocols
  71258. elliptic.ec = require('./elliptic/ec');
  71259. elliptic.eddsa = require('./elliptic/eddsa');
  71260. },{"../package.json":25,"./elliptic/curve":13,"./elliptic/curves":16,"./elliptic/ec":17,"./elliptic/eddsa":20,"./elliptic/utils":24,"brorand":5}],11:[function(require,module,exports){
  71261. 'use strict';
  71262. var BN = require('bn.js');
  71263. var elliptic = require('../../elliptic');
  71264. var utils = elliptic.utils;
  71265. var getNAF = utils.getNAF;
  71266. var getJSF = utils.getJSF;
  71267. var assert = utils.assert;
  71268. function BaseCurve(type, conf) {
  71269. this.type = type;
  71270. this.p = new BN(conf.p, 16);
  71271. // Use Montgomery, when there is no fast reduction for the prime
  71272. this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p);
  71273. // Useful for many curves
  71274. this.zero = new BN(0).toRed(this.red);
  71275. this.one = new BN(1).toRed(this.red);
  71276. this.two = new BN(2).toRed(this.red);
  71277. // Curve configuration, optional
  71278. this.n = conf.n && new BN(conf.n, 16);
  71279. this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed);
  71280. // Temporary arrays
  71281. this._wnafT1 = new Array(4);
  71282. this._wnafT2 = new Array(4);
  71283. this._wnafT3 = new Array(4);
  71284. this._wnafT4 = new Array(4);
  71285. // Generalized Greg Maxwell's trick
  71286. var adjustCount = this.n && this.p.div(this.n);
  71287. if (!adjustCount || adjustCount.cmpn(100) > 0) {
  71288. this.redN = null;
  71289. } else {
  71290. this._maxwellTrick = true;
  71291. this.redN = this.n.toRed(this.red);
  71292. }
  71293. }
  71294. module.exports = BaseCurve;
  71295. BaseCurve.prototype.point = function point() {
  71296. throw new Error('Not implemented');
  71297. };
  71298. BaseCurve.prototype.validate = function validate() {
  71299. throw new Error('Not implemented');
  71300. };
  71301. BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) {
  71302. assert(p.precomputed);
  71303. var doubles = p._getDoubles();
  71304. var naf = getNAF(k, 1);
  71305. var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1);
  71306. I /= 3;
  71307. // Translate into more windowed form
  71308. var repr = [];
  71309. for (var j = 0; j < naf.length; j += doubles.step) {
  71310. var nafW = 0;
  71311. for (var k = j + doubles.step - 1; k >= j; k--)
  71312. nafW = (nafW << 1) + naf[k];
  71313. repr.push(nafW);
  71314. }
  71315. var a = this.jpoint(null, null, null);
  71316. var b = this.jpoint(null, null, null);
  71317. for (var i = I; i > 0; i--) {
  71318. for (var j = 0; j < repr.length; j++) {
  71319. var nafW = repr[j];
  71320. if (nafW === i)
  71321. b = b.mixedAdd(doubles.points[j]);
  71322. else if (nafW === -i)
  71323. b = b.mixedAdd(doubles.points[j].neg());
  71324. }
  71325. a = a.add(b);
  71326. }
  71327. return a.toP();
  71328. };
  71329. BaseCurve.prototype._wnafMul = function _wnafMul(p, k) {
  71330. var w = 4;
  71331. // Precompute window
  71332. var nafPoints = p._getNAFPoints(w);
  71333. w = nafPoints.wnd;
  71334. var wnd = nafPoints.points;
  71335. // Get NAF form
  71336. var naf = getNAF(k, w);
  71337. // Add `this`*(N+1) for every w-NAF index
  71338. var acc = this.jpoint(null, null, null);
  71339. for (var i = naf.length - 1; i >= 0; i--) {
  71340. // Count zeroes
  71341. for (var k = 0; i >= 0 && naf[i] === 0; i--)
  71342. k++;
  71343. if (i >= 0)
  71344. k++;
  71345. acc = acc.dblp(k);
  71346. if (i < 0)
  71347. break;
  71348. var z = naf[i];
  71349. assert(z !== 0);
  71350. if (p.type === 'affine') {
  71351. // J +- P
  71352. if (z > 0)
  71353. acc = acc.mixedAdd(wnd[(z - 1) >> 1]);
  71354. else
  71355. acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg());
  71356. } else {
  71357. // J +- J
  71358. if (z > 0)
  71359. acc = acc.add(wnd[(z - 1) >> 1]);
  71360. else
  71361. acc = acc.add(wnd[(-z - 1) >> 1].neg());
  71362. }
  71363. }
  71364. return p.type === 'affine' ? acc.toP() : acc;
  71365. };
  71366. BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW,
  71367. points,
  71368. coeffs,
  71369. len,
  71370. jacobianResult) {
  71371. var wndWidth = this._wnafT1;
  71372. var wnd = this._wnafT2;
  71373. var naf = this._wnafT3;
  71374. // Fill all arrays
  71375. var max = 0;
  71376. for (var i = 0; i < len; i++) {
  71377. var p = points[i];
  71378. var nafPoints = p._getNAFPoints(defW);
  71379. wndWidth[i] = nafPoints.wnd;
  71380. wnd[i] = nafPoints.points;
  71381. }
  71382. // Comb small window NAFs
  71383. for (var i = len - 1; i >= 1; i -= 2) {
  71384. var a = i - 1;
  71385. var b = i;
  71386. if (wndWidth[a] !== 1 || wndWidth[b] !== 1) {
  71387. naf[a] = getNAF(coeffs[a], wndWidth[a]);
  71388. naf[b] = getNAF(coeffs[b], wndWidth[b]);
  71389. max = Math.max(naf[a].length, max);
  71390. max = Math.max(naf[b].length, max);
  71391. continue;
  71392. }
  71393. var comb = [
  71394. points[a], /* 1 */
  71395. null, /* 3 */
  71396. null, /* 5 */
  71397. points[b] /* 7 */
  71398. ];
  71399. // Try to avoid Projective points, if possible
  71400. if (points[a].y.cmp(points[b].y) === 0) {
  71401. comb[1] = points[a].add(points[b]);
  71402. comb[2] = points[a].toJ().mixedAdd(points[b].neg());
  71403. } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) {
  71404. comb[1] = points[a].toJ().mixedAdd(points[b]);
  71405. comb[2] = points[a].add(points[b].neg());
  71406. } else {
  71407. comb[1] = points[a].toJ().mixedAdd(points[b]);
  71408. comb[2] = points[a].toJ().mixedAdd(points[b].neg());
  71409. }
  71410. var index = [
  71411. -3, /* -1 -1 */
  71412. -1, /* -1 0 */
  71413. -5, /* -1 1 */
  71414. -7, /* 0 -1 */
  71415. 0, /* 0 0 */
  71416. 7, /* 0 1 */
  71417. 5, /* 1 -1 */
  71418. 1, /* 1 0 */
  71419. 3 /* 1 1 */
  71420. ];
  71421. var jsf = getJSF(coeffs[a], coeffs[b]);
  71422. max = Math.max(jsf[0].length, max);
  71423. naf[a] = new Array(max);
  71424. naf[b] = new Array(max);
  71425. for (var j = 0; j < max; j++) {
  71426. var ja = jsf[0][j] | 0;
  71427. var jb = jsf[1][j] | 0;
  71428. naf[a][j] = index[(ja + 1) * 3 + (jb + 1)];
  71429. naf[b][j] = 0;
  71430. wnd[a] = comb;
  71431. }
  71432. }
  71433. var acc = this.jpoint(null, null, null);
  71434. var tmp = this._wnafT4;
  71435. for (var i = max; i >= 0; i--) {
  71436. var k = 0;
  71437. while (i >= 0) {
  71438. var zero = true;
  71439. for (var j = 0; j < len; j++) {
  71440. tmp[j] = naf[j][i] | 0;
  71441. if (tmp[j] !== 0)
  71442. zero = false;
  71443. }
  71444. if (!zero)
  71445. break;
  71446. k++;
  71447. i--;
  71448. }
  71449. if (i >= 0)
  71450. k++;
  71451. acc = acc.dblp(k);
  71452. if (i < 0)
  71453. break;
  71454. for (var j = 0; j < len; j++) {
  71455. var z = tmp[j];
  71456. var p;
  71457. if (z === 0)
  71458. continue;
  71459. else if (z > 0)
  71460. p = wnd[j][(z - 1) >> 1];
  71461. else if (z < 0)
  71462. p = wnd[j][(-z - 1) >> 1].neg();
  71463. if (p.type === 'affine')
  71464. acc = acc.mixedAdd(p);
  71465. else
  71466. acc = acc.add(p);
  71467. }
  71468. }
  71469. // Zeroify references
  71470. for (var i = 0; i < len; i++)
  71471. wnd[i] = null;
  71472. if (jacobianResult)
  71473. return acc;
  71474. else
  71475. return acc.toP();
  71476. };
  71477. function BasePoint(curve, type) {
  71478. this.curve = curve;
  71479. this.type = type;
  71480. this.precomputed = null;
  71481. }
  71482. BaseCurve.BasePoint = BasePoint;
  71483. BasePoint.prototype.eq = function eq(/*other*/) {
  71484. throw new Error('Not implemented');
  71485. };
  71486. BasePoint.prototype.validate = function validate() {
  71487. return this.curve.validate(this);
  71488. };
  71489. BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
  71490. bytes = utils.toArray(bytes, enc);
  71491. var len = this.p.byteLength();
  71492. // uncompressed, hybrid-odd, hybrid-even
  71493. if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) &&
  71494. bytes.length - 1 === 2 * len) {
  71495. if (bytes[0] === 0x06)
  71496. assert(bytes[bytes.length - 1] % 2 === 0);
  71497. else if (bytes[0] === 0x07)
  71498. assert(bytes[bytes.length - 1] % 2 === 1);
  71499. var res = this.point(bytes.slice(1, 1 + len),
  71500. bytes.slice(1 + len, 1 + 2 * len));
  71501. return res;
  71502. } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) &&
  71503. bytes.length - 1 === len) {
  71504. return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03);
  71505. }
  71506. throw new Error('Unknown point format');
  71507. };
  71508. BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) {
  71509. return this.encode(enc, true);
  71510. };
  71511. BasePoint.prototype._encode = function _encode(compact) {
  71512. var len = this.curve.p.byteLength();
  71513. var x = this.getX().toArray('be', len);
  71514. if (compact)
  71515. return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x);
  71516. return [ 0x04 ].concat(x, this.getY().toArray('be', len)) ;
  71517. };
  71518. BasePoint.prototype.encode = function encode(enc, compact) {
  71519. return utils.encode(this._encode(compact), enc);
  71520. };
  71521. BasePoint.prototype.precompute = function precompute(power) {
  71522. if (this.precomputed)
  71523. return this;
  71524. var precomputed = {
  71525. doubles: null,
  71526. naf: null,
  71527. beta: null
  71528. };
  71529. precomputed.naf = this._getNAFPoints(8);
  71530. precomputed.doubles = this._getDoubles(4, power);
  71531. precomputed.beta = this._getBeta();
  71532. this.precomputed = precomputed;
  71533. return this;
  71534. };
  71535. BasePoint.prototype._hasDoubles = function _hasDoubles(k) {
  71536. if (!this.precomputed)
  71537. return false;
  71538. var doubles = this.precomputed.doubles;
  71539. if (!doubles)
  71540. return false;
  71541. return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step);
  71542. };
  71543. BasePoint.prototype._getDoubles = function _getDoubles(step, power) {
  71544. if (this.precomputed && this.precomputed.doubles)
  71545. return this.precomputed.doubles;
  71546. var doubles = [ this ];
  71547. var acc = this;
  71548. for (var i = 0; i < power; i += step) {
  71549. for (var j = 0; j < step; j++)
  71550. acc = acc.dbl();
  71551. doubles.push(acc);
  71552. }
  71553. return {
  71554. step: step,
  71555. points: doubles
  71556. };
  71557. };
  71558. BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) {
  71559. if (this.precomputed && this.precomputed.naf)
  71560. return this.precomputed.naf;
  71561. var res = [ this ];
  71562. var max = (1 << wnd) - 1;
  71563. var dbl = max === 1 ? null : this.dbl();
  71564. for (var i = 1; i < max; i++)
  71565. res[i] = res[i - 1].add(dbl);
  71566. return {
  71567. wnd: wnd,
  71568. points: res
  71569. };
  71570. };
  71571. BasePoint.prototype._getBeta = function _getBeta() {
  71572. return null;
  71573. };
  71574. BasePoint.prototype.dblp = function dblp(k) {
  71575. var r = this;
  71576. for (var i = 0; i < k; i++)
  71577. r = r.dbl();
  71578. return r;
  71579. };
  71580. },{"../../elliptic":10,"bn.js":4}],12:[function(require,module,exports){
  71581. 'use strict';
  71582. var curve = require('../curve');
  71583. var elliptic = require('../../elliptic');
  71584. var BN = require('bn.js');
  71585. var inherits = require('inherits');
  71586. var Base = curve.base;
  71587. var assert = elliptic.utils.assert;
  71588. function EdwardsCurve(conf) {
  71589. // NOTE: Important as we are creating point in Base.call()
  71590. this.twisted = (conf.a | 0) !== 1;
  71591. this.mOneA = this.twisted && (conf.a | 0) === -1;
  71592. this.extended = this.mOneA;
  71593. Base.call(this, 'edwards', conf);
  71594. this.a = new BN(conf.a, 16).umod(this.red.m);
  71595. this.a = this.a.toRed(this.red);
  71596. this.c = new BN(conf.c, 16).toRed(this.red);
  71597. this.c2 = this.c.redSqr();
  71598. this.d = new BN(conf.d, 16).toRed(this.red);
  71599. this.dd = this.d.redAdd(this.d);
  71600. assert(!this.twisted || this.c.fromRed().cmpn(1) === 0);
  71601. this.oneC = (conf.c | 0) === 1;
  71602. }
  71603. inherits(EdwardsCurve, Base);
  71604. module.exports = EdwardsCurve;
  71605. EdwardsCurve.prototype._mulA = function _mulA(num) {
  71606. if (this.mOneA)
  71607. return num.redNeg();
  71608. else
  71609. return this.a.redMul(num);
  71610. };
  71611. EdwardsCurve.prototype._mulC = function _mulC(num) {
  71612. if (this.oneC)
  71613. return num;
  71614. else
  71615. return this.c.redMul(num);
  71616. };
  71617. // Just for compatibility with Short curve
  71618. EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) {
  71619. return this.point(x, y, z, t);
  71620. };
  71621. EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) {
  71622. x = new BN(x, 16);
  71623. if (!x.red)
  71624. x = x.toRed(this.red);
  71625. var x2 = x.redSqr();
  71626. var rhs = this.c2.redSub(this.a.redMul(x2));
  71627. var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2));
  71628. var y2 = rhs.redMul(lhs.redInvm());
  71629. var y = y2.redSqrt();
  71630. if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
  71631. throw new Error('invalid point');
  71632. var isOdd = y.fromRed().isOdd();
  71633. if (odd && !isOdd || !odd && isOdd)
  71634. y = y.redNeg();
  71635. return this.point(x, y);
  71636. };
  71637. EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) {
  71638. y = new BN(y, 16);
  71639. if (!y.red)
  71640. y = y.toRed(this.red);
  71641. // x^2 = (y^2 - 1) / (d y^2 + 1)
  71642. var y2 = y.redSqr();
  71643. var lhs = y2.redSub(this.one);
  71644. var rhs = y2.redMul(this.d).redAdd(this.one);
  71645. var x2 = lhs.redMul(rhs.redInvm());
  71646. if (x2.cmp(this.zero) === 0) {
  71647. if (odd)
  71648. throw new Error('invalid point');
  71649. else
  71650. return this.point(this.zero, y);
  71651. }
  71652. var x = x2.redSqrt();
  71653. if (x.redSqr().redSub(x2).cmp(this.zero) !== 0)
  71654. throw new Error('invalid point');
  71655. if (x.isOdd() !== odd)
  71656. x = x.redNeg();
  71657. return this.point(x, y);
  71658. };
  71659. EdwardsCurve.prototype.validate = function validate(point) {
  71660. if (point.isInfinity())
  71661. return true;
  71662. // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2)
  71663. point.normalize();
  71664. var x2 = point.x.redSqr();
  71665. var y2 = point.y.redSqr();
  71666. var lhs = x2.redMul(this.a).redAdd(y2);
  71667. var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2)));
  71668. return lhs.cmp(rhs) === 0;
  71669. };
  71670. function Point(curve, x, y, z, t) {
  71671. Base.BasePoint.call(this, curve, 'projective');
  71672. if (x === null && y === null && z === null) {
  71673. this.x = this.curve.zero;
  71674. this.y = this.curve.one;
  71675. this.z = this.curve.one;
  71676. this.t = this.curve.zero;
  71677. this.zOne = true;
  71678. } else {
  71679. this.x = new BN(x, 16);
  71680. this.y = new BN(y, 16);
  71681. this.z = z ? new BN(z, 16) : this.curve.one;
  71682. this.t = t && new BN(t, 16);
  71683. if (!this.x.red)
  71684. this.x = this.x.toRed(this.curve.red);
  71685. if (!this.y.red)
  71686. this.y = this.y.toRed(this.curve.red);
  71687. if (!this.z.red)
  71688. this.z = this.z.toRed(this.curve.red);
  71689. if (this.t && !this.t.red)
  71690. this.t = this.t.toRed(this.curve.red);
  71691. this.zOne = this.z === this.curve.one;
  71692. // Use extended coordinates
  71693. if (this.curve.extended && !this.t) {
  71694. this.t = this.x.redMul(this.y);
  71695. if (!this.zOne)
  71696. this.t = this.t.redMul(this.z.redInvm());
  71697. }
  71698. }
  71699. }
  71700. inherits(Point, Base.BasePoint);
  71701. EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
  71702. return Point.fromJSON(this, obj);
  71703. };
  71704. EdwardsCurve.prototype.point = function point(x, y, z, t) {
  71705. return new Point(this, x, y, z, t);
  71706. };
  71707. Point.fromJSON = function fromJSON(curve, obj) {
  71708. return new Point(curve, obj[0], obj[1], obj[2]);
  71709. };
  71710. Point.prototype.inspect = function inspect() {
  71711. if (this.isInfinity())
  71712. return '<EC Point Infinity>';
  71713. return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
  71714. ' y: ' + this.y.fromRed().toString(16, 2) +
  71715. ' z: ' + this.z.fromRed().toString(16, 2) + '>';
  71716. };
  71717. Point.prototype.isInfinity = function isInfinity() {
  71718. // XXX This code assumes that zero is always zero in red
  71719. return this.x.cmpn(0) === 0 &&
  71720. this.y.cmp(this.z) === 0;
  71721. };
  71722. Point.prototype._extDbl = function _extDbl() {
  71723. // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
  71724. // #doubling-dbl-2008-hwcd
  71725. // 4M + 4S
  71726. // A = X1^2
  71727. var a = this.x.redSqr();
  71728. // B = Y1^2
  71729. var b = this.y.redSqr();
  71730. // C = 2 * Z1^2
  71731. var c = this.z.redSqr();
  71732. c = c.redIAdd(c);
  71733. // D = a * A
  71734. var d = this.curve._mulA(a);
  71735. // E = (X1 + Y1)^2 - A - B
  71736. var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b);
  71737. // G = D + B
  71738. var g = d.redAdd(b);
  71739. // F = G - C
  71740. var f = g.redSub(c);
  71741. // H = D - B
  71742. var h = d.redSub(b);
  71743. // X3 = E * F
  71744. var nx = e.redMul(f);
  71745. // Y3 = G * H
  71746. var ny = g.redMul(h);
  71747. // T3 = E * H
  71748. var nt = e.redMul(h);
  71749. // Z3 = F * G
  71750. var nz = f.redMul(g);
  71751. return this.curve.point(nx, ny, nz, nt);
  71752. };
  71753. Point.prototype._projDbl = function _projDbl() {
  71754. // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
  71755. // #doubling-dbl-2008-bbjlp
  71756. // #doubling-dbl-2007-bl
  71757. // and others
  71758. // Generally 3M + 4S or 2M + 4S
  71759. // B = (X1 + Y1)^2
  71760. var b = this.x.redAdd(this.y).redSqr();
  71761. // C = X1^2
  71762. var c = this.x.redSqr();
  71763. // D = Y1^2
  71764. var d = this.y.redSqr();
  71765. var nx;
  71766. var ny;
  71767. var nz;
  71768. if (this.curve.twisted) {
  71769. // E = a * C
  71770. var e = this.curve._mulA(c);
  71771. // F = E + D
  71772. var f = e.redAdd(d);
  71773. if (this.zOne) {
  71774. // X3 = (B - C - D) * (F - 2)
  71775. nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two));
  71776. // Y3 = F * (E - D)
  71777. ny = f.redMul(e.redSub(d));
  71778. // Z3 = F^2 - 2 * F
  71779. nz = f.redSqr().redSub(f).redSub(f);
  71780. } else {
  71781. // H = Z1^2
  71782. var h = this.z.redSqr();
  71783. // J = F - 2 * H
  71784. var j = f.redSub(h).redISub(h);
  71785. // X3 = (B-C-D)*J
  71786. nx = b.redSub(c).redISub(d).redMul(j);
  71787. // Y3 = F * (E - D)
  71788. ny = f.redMul(e.redSub(d));
  71789. // Z3 = F * J
  71790. nz = f.redMul(j);
  71791. }
  71792. } else {
  71793. // E = C + D
  71794. var e = c.redAdd(d);
  71795. // H = (c * Z1)^2
  71796. var h = this.curve._mulC(this.c.redMul(this.z)).redSqr();
  71797. // J = E - 2 * H
  71798. var j = e.redSub(h).redSub(h);
  71799. // X3 = c * (B - E) * J
  71800. nx = this.curve._mulC(b.redISub(e)).redMul(j);
  71801. // Y3 = c * E * (C - D)
  71802. ny = this.curve._mulC(e).redMul(c.redISub(d));
  71803. // Z3 = E * J
  71804. nz = e.redMul(j);
  71805. }
  71806. return this.curve.point(nx, ny, nz);
  71807. };
  71808. Point.prototype.dbl = function dbl() {
  71809. if (this.isInfinity())
  71810. return this;
  71811. // Double in extended coordinates
  71812. if (this.curve.extended)
  71813. return this._extDbl();
  71814. else
  71815. return this._projDbl();
  71816. };
  71817. Point.prototype._extAdd = function _extAdd(p) {
  71818. // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html
  71819. // #addition-add-2008-hwcd-3
  71820. // 8M
  71821. // A = (Y1 - X1) * (Y2 - X2)
  71822. var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x));
  71823. // B = (Y1 + X1) * (Y2 + X2)
  71824. var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x));
  71825. // C = T1 * k * T2
  71826. var c = this.t.redMul(this.curve.dd).redMul(p.t);
  71827. // D = Z1 * 2 * Z2
  71828. var d = this.z.redMul(p.z.redAdd(p.z));
  71829. // E = B - A
  71830. var e = b.redSub(a);
  71831. // F = D - C
  71832. var f = d.redSub(c);
  71833. // G = D + C
  71834. var g = d.redAdd(c);
  71835. // H = B + A
  71836. var h = b.redAdd(a);
  71837. // X3 = E * F
  71838. var nx = e.redMul(f);
  71839. // Y3 = G * H
  71840. var ny = g.redMul(h);
  71841. // T3 = E * H
  71842. var nt = e.redMul(h);
  71843. // Z3 = F * G
  71844. var nz = f.redMul(g);
  71845. return this.curve.point(nx, ny, nz, nt);
  71846. };
  71847. Point.prototype._projAdd = function _projAdd(p) {
  71848. // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html
  71849. // #addition-add-2008-bbjlp
  71850. // #addition-add-2007-bl
  71851. // 10M + 1S
  71852. // A = Z1 * Z2
  71853. var a = this.z.redMul(p.z);
  71854. // B = A^2
  71855. var b = a.redSqr();
  71856. // C = X1 * X2
  71857. var c = this.x.redMul(p.x);
  71858. // D = Y1 * Y2
  71859. var d = this.y.redMul(p.y);
  71860. // E = d * C * D
  71861. var e = this.curve.d.redMul(c).redMul(d);
  71862. // F = B - E
  71863. var f = b.redSub(e);
  71864. // G = B + E
  71865. var g = b.redAdd(e);
  71866. // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D)
  71867. var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d);
  71868. var nx = a.redMul(f).redMul(tmp);
  71869. var ny;
  71870. var nz;
  71871. if (this.curve.twisted) {
  71872. // Y3 = A * G * (D - a * C)
  71873. ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c)));
  71874. // Z3 = F * G
  71875. nz = f.redMul(g);
  71876. } else {
  71877. // Y3 = A * G * (D - C)
  71878. ny = a.redMul(g).redMul(d.redSub(c));
  71879. // Z3 = c * F * G
  71880. nz = this.curve._mulC(f).redMul(g);
  71881. }
  71882. return this.curve.point(nx, ny, nz);
  71883. };
  71884. Point.prototype.add = function add(p) {
  71885. if (this.isInfinity())
  71886. return p;
  71887. if (p.isInfinity())
  71888. return this;
  71889. if (this.curve.extended)
  71890. return this._extAdd(p);
  71891. else
  71892. return this._projAdd(p);
  71893. };
  71894. Point.prototype.mul = function mul(k) {
  71895. if (this._hasDoubles(k))
  71896. return this.curve._fixedNafMul(this, k);
  71897. else
  71898. return this.curve._wnafMul(this, k);
  71899. };
  71900. Point.prototype.mulAdd = function mulAdd(k1, p, k2) {
  71901. return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false);
  71902. };
  71903. Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) {
  71904. return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true);
  71905. };
  71906. Point.prototype.normalize = function normalize() {
  71907. if (this.zOne)
  71908. return this;
  71909. // Normalize coordinates
  71910. var zi = this.z.redInvm();
  71911. this.x = this.x.redMul(zi);
  71912. this.y = this.y.redMul(zi);
  71913. if (this.t)
  71914. this.t = this.t.redMul(zi);
  71915. this.z = this.curve.one;
  71916. this.zOne = true;
  71917. return this;
  71918. };
  71919. Point.prototype.neg = function neg() {
  71920. return this.curve.point(this.x.redNeg(),
  71921. this.y,
  71922. this.z,
  71923. this.t && this.t.redNeg());
  71924. };
  71925. Point.prototype.getX = function getX() {
  71926. this.normalize();
  71927. return this.x.fromRed();
  71928. };
  71929. Point.prototype.getY = function getY() {
  71930. this.normalize();
  71931. return this.y.fromRed();
  71932. };
  71933. Point.prototype.eq = function eq(other) {
  71934. return this === other ||
  71935. this.getX().cmp(other.getX()) === 0 &&
  71936. this.getY().cmp(other.getY()) === 0;
  71937. };
  71938. Point.prototype.eqXToP = function eqXToP(x) {
  71939. var rx = x.toRed(this.curve.red).redMul(this.z);
  71940. if (this.x.cmp(rx) === 0)
  71941. return true;
  71942. var xc = x.clone();
  71943. var t = this.curve.redN.redMul(this.z);
  71944. for (;;) {
  71945. xc.iadd(this.curve.n);
  71946. if (xc.cmp(this.curve.p) >= 0)
  71947. return false;
  71948. rx.redIAdd(t);
  71949. if (this.x.cmp(rx) === 0)
  71950. return true;
  71951. }
  71952. return false;
  71953. };
  71954. // Compatibility with BaseCurve
  71955. Point.prototype.toP = Point.prototype.normalize;
  71956. Point.prototype.mixedAdd = Point.prototype.add;
  71957. },{"../../elliptic":10,"../curve":13,"bn.js":4,"inherits":34}],13:[function(require,module,exports){
  71958. 'use strict';
  71959. var curve = exports;
  71960. curve.base = require('./base');
  71961. curve.short = require('./short');
  71962. curve.mont = require('./mont');
  71963. curve.edwards = require('./edwards');
  71964. },{"./base":11,"./edwards":12,"./mont":14,"./short":15}],14:[function(require,module,exports){
  71965. 'use strict';
  71966. var curve = require('../curve');
  71967. var BN = require('bn.js');
  71968. var inherits = require('inherits');
  71969. var Base = curve.base;
  71970. var elliptic = require('../../elliptic');
  71971. var utils = elliptic.utils;
  71972. function MontCurve(conf) {
  71973. Base.call(this, 'mont', conf);
  71974. this.a = new BN(conf.a, 16).toRed(this.red);
  71975. this.b = new BN(conf.b, 16).toRed(this.red);
  71976. this.i4 = new BN(4).toRed(this.red).redInvm();
  71977. this.two = new BN(2).toRed(this.red);
  71978. this.a24 = this.i4.redMul(this.a.redAdd(this.two));
  71979. }
  71980. inherits(MontCurve, Base);
  71981. module.exports = MontCurve;
  71982. MontCurve.prototype.validate = function validate(point) {
  71983. var x = point.normalize().x;
  71984. var x2 = x.redSqr();
  71985. var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x);
  71986. var y = rhs.redSqrt();
  71987. return y.redSqr().cmp(rhs) === 0;
  71988. };
  71989. function Point(curve, x, z) {
  71990. Base.BasePoint.call(this, curve, 'projective');
  71991. if (x === null && z === null) {
  71992. this.x = this.curve.one;
  71993. this.z = this.curve.zero;
  71994. } else {
  71995. this.x = new BN(x, 16);
  71996. this.z = new BN(z, 16);
  71997. if (!this.x.red)
  71998. this.x = this.x.toRed(this.curve.red);
  71999. if (!this.z.red)
  72000. this.z = this.z.toRed(this.curve.red);
  72001. }
  72002. }
  72003. inherits(Point, Base.BasePoint);
  72004. MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
  72005. return this.point(utils.toArray(bytes, enc), 1);
  72006. };
  72007. MontCurve.prototype.point = function point(x, z) {
  72008. return new Point(this, x, z);
  72009. };
  72010. MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
  72011. return Point.fromJSON(this, obj);
  72012. };
  72013. Point.prototype.precompute = function precompute() {
  72014. // No-op
  72015. };
  72016. Point.prototype._encode = function _encode() {
  72017. return this.getX().toArray('be', this.curve.p.byteLength());
  72018. };
  72019. Point.fromJSON = function fromJSON(curve, obj) {
  72020. return new Point(curve, obj[0], obj[1] || curve.one);
  72021. };
  72022. Point.prototype.inspect = function inspect() {
  72023. if (this.isInfinity())
  72024. return '<EC Point Infinity>';
  72025. return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
  72026. ' z: ' + this.z.fromRed().toString(16, 2) + '>';
  72027. };
  72028. Point.prototype.isInfinity = function isInfinity() {
  72029. // XXX This code assumes that zero is always zero in red
  72030. return this.z.cmpn(0) === 0;
  72031. };
  72032. Point.prototype.dbl = function dbl() {
  72033. // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3
  72034. // 2M + 2S + 4A
  72035. // A = X1 + Z1
  72036. var a = this.x.redAdd(this.z);
  72037. // AA = A^2
  72038. var aa = a.redSqr();
  72039. // B = X1 - Z1
  72040. var b = this.x.redSub(this.z);
  72041. // BB = B^2
  72042. var bb = b.redSqr();
  72043. // C = AA - BB
  72044. var c = aa.redSub(bb);
  72045. // X3 = AA * BB
  72046. var nx = aa.redMul(bb);
  72047. // Z3 = C * (BB + A24 * C)
  72048. var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c)));
  72049. return this.curve.point(nx, nz);
  72050. };
  72051. Point.prototype.add = function add() {
  72052. throw new Error('Not supported on Montgomery curve');
  72053. };
  72054. Point.prototype.diffAdd = function diffAdd(p, diff) {
  72055. // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3
  72056. // 4M + 2S + 6A
  72057. // A = X2 + Z2
  72058. var a = this.x.redAdd(this.z);
  72059. // B = X2 - Z2
  72060. var b = this.x.redSub(this.z);
  72061. // C = X3 + Z3
  72062. var c = p.x.redAdd(p.z);
  72063. // D = X3 - Z3
  72064. var d = p.x.redSub(p.z);
  72065. // DA = D * A
  72066. var da = d.redMul(a);
  72067. // CB = C * B
  72068. var cb = c.redMul(b);
  72069. // X5 = Z1 * (DA + CB)^2
  72070. var nx = diff.z.redMul(da.redAdd(cb).redSqr());
  72071. // Z5 = X1 * (DA - CB)^2
  72072. var nz = diff.x.redMul(da.redISub(cb).redSqr());
  72073. return this.curve.point(nx, nz);
  72074. };
  72075. Point.prototype.mul = function mul(k) {
  72076. var t = k.clone();
  72077. var a = this; // (N / 2) * Q + Q
  72078. var b = this.curve.point(null, null); // (N / 2) * Q
  72079. var c = this; // Q
  72080. for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1))
  72081. bits.push(t.andln(1));
  72082. for (var i = bits.length - 1; i >= 0; i--) {
  72083. if (bits[i] === 0) {
  72084. // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q
  72085. a = a.diffAdd(b, c);
  72086. // N * Q = 2 * ((N / 2) * Q + Q))
  72087. b = b.dbl();
  72088. } else {
  72089. // N * Q = ((N / 2) * Q + Q) + ((N / 2) * Q)
  72090. b = a.diffAdd(b, c);
  72091. // N * Q + Q = 2 * ((N / 2) * Q + Q)
  72092. a = a.dbl();
  72093. }
  72094. }
  72095. return b;
  72096. };
  72097. Point.prototype.mulAdd = function mulAdd() {
  72098. throw new Error('Not supported on Montgomery curve');
  72099. };
  72100. Point.prototype.jumlAdd = function jumlAdd() {
  72101. throw new Error('Not supported on Montgomery curve');
  72102. };
  72103. Point.prototype.eq = function eq(other) {
  72104. return this.getX().cmp(other.getX()) === 0;
  72105. };
  72106. Point.prototype.normalize = function normalize() {
  72107. this.x = this.x.redMul(this.z.redInvm());
  72108. this.z = this.curve.one;
  72109. return this;
  72110. };
  72111. Point.prototype.getX = function getX() {
  72112. // Normalize coordinates
  72113. this.normalize();
  72114. return this.x.fromRed();
  72115. };
  72116. },{"../../elliptic":10,"../curve":13,"bn.js":4,"inherits":34}],15:[function(require,module,exports){
  72117. 'use strict';
  72118. var curve = require('../curve');
  72119. var elliptic = require('../../elliptic');
  72120. var BN = require('bn.js');
  72121. var inherits = require('inherits');
  72122. var Base = curve.base;
  72123. var assert = elliptic.utils.assert;
  72124. function ShortCurve(conf) {
  72125. Base.call(this, 'short', conf);
  72126. this.a = new BN(conf.a, 16).toRed(this.red);
  72127. this.b = new BN(conf.b, 16).toRed(this.red);
  72128. this.tinv = this.two.redInvm();
  72129. this.zeroA = this.a.fromRed().cmpn(0) === 0;
  72130. this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0;
  72131. // If the curve is endomorphic, precalculate beta and lambda
  72132. this.endo = this._getEndomorphism(conf);
  72133. this._endoWnafT1 = new Array(4);
  72134. this._endoWnafT2 = new Array(4);
  72135. }
  72136. inherits(ShortCurve, Base);
  72137. module.exports = ShortCurve;
  72138. ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) {
  72139. // No efficient endomorphism
  72140. if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)
  72141. return;
  72142. // Compute beta and lambda, that lambda * P = (beta * Px; Py)
  72143. var beta;
  72144. var lambda;
  72145. if (conf.beta) {
  72146. beta = new BN(conf.beta, 16).toRed(this.red);
  72147. } else {
  72148. var betas = this._getEndoRoots(this.p);
  72149. // Choose the smallest beta
  72150. beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1];
  72151. beta = beta.toRed(this.red);
  72152. }
  72153. if (conf.lambda) {
  72154. lambda = new BN(conf.lambda, 16);
  72155. } else {
  72156. // Choose the lambda that is matching selected beta
  72157. var lambdas = this._getEndoRoots(this.n);
  72158. if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) {
  72159. lambda = lambdas[0];
  72160. } else {
  72161. lambda = lambdas[1];
  72162. assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0);
  72163. }
  72164. }
  72165. // Get basis vectors, used for balanced length-two representation
  72166. var basis;
  72167. if (conf.basis) {
  72168. basis = conf.basis.map(function(vec) {
  72169. return {
  72170. a: new BN(vec.a, 16),
  72171. b: new BN(vec.b, 16)
  72172. };
  72173. });
  72174. } else {
  72175. basis = this._getEndoBasis(lambda);
  72176. }
  72177. return {
  72178. beta: beta,
  72179. lambda: lambda,
  72180. basis: basis
  72181. };
  72182. };
  72183. ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) {
  72184. // Find roots of for x^2 + x + 1 in F
  72185. // Root = (-1 +- Sqrt(-3)) / 2
  72186. //
  72187. var red = num === this.p ? this.red : BN.mont(num);
  72188. var tinv = new BN(2).toRed(red).redInvm();
  72189. var ntinv = tinv.redNeg();
  72190. var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv);
  72191. var l1 = ntinv.redAdd(s).fromRed();
  72192. var l2 = ntinv.redSub(s).fromRed();
  72193. return [ l1, l2 ];
  72194. };
  72195. ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) {
  72196. // aprxSqrt >= sqrt(this.n)
  72197. var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2));
  72198. // 3.74
  72199. // Run EGCD, until r(L + 1) < aprxSqrt
  72200. var u = lambda;
  72201. var v = this.n.clone();
  72202. var x1 = new BN(1);
  72203. var y1 = new BN(0);
  72204. var x2 = new BN(0);
  72205. var y2 = new BN(1);
  72206. // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n)
  72207. var a0;
  72208. var b0;
  72209. // First vector
  72210. var a1;
  72211. var b1;
  72212. // Second vector
  72213. var a2;
  72214. var b2;
  72215. var prevR;
  72216. var i = 0;
  72217. var r;
  72218. var x;
  72219. while (u.cmpn(0) !== 0) {
  72220. var q = v.div(u);
  72221. r = v.sub(q.mul(u));
  72222. x = x2.sub(q.mul(x1));
  72223. var y = y2.sub(q.mul(y1));
  72224. if (!a1 && r.cmp(aprxSqrt) < 0) {
  72225. a0 = prevR.neg();
  72226. b0 = x1;
  72227. a1 = r.neg();
  72228. b1 = x;
  72229. } else if (a1 && ++i === 2) {
  72230. break;
  72231. }
  72232. prevR = r;
  72233. v = u;
  72234. u = r;
  72235. x2 = x1;
  72236. x1 = x;
  72237. y2 = y1;
  72238. y1 = y;
  72239. }
  72240. a2 = r.neg();
  72241. b2 = x;
  72242. var len1 = a1.sqr().add(b1.sqr());
  72243. var len2 = a2.sqr().add(b2.sqr());
  72244. if (len2.cmp(len1) >= 0) {
  72245. a2 = a0;
  72246. b2 = b0;
  72247. }
  72248. // Normalize signs
  72249. if (a1.negative) {
  72250. a1 = a1.neg();
  72251. b1 = b1.neg();
  72252. }
  72253. if (a2.negative) {
  72254. a2 = a2.neg();
  72255. b2 = b2.neg();
  72256. }
  72257. return [
  72258. { a: a1, b: b1 },
  72259. { a: a2, b: b2 }
  72260. ];
  72261. };
  72262. ShortCurve.prototype._endoSplit = function _endoSplit(k) {
  72263. var basis = this.endo.basis;
  72264. var v1 = basis[0];
  72265. var v2 = basis[1];
  72266. var c1 = v2.b.mul(k).divRound(this.n);
  72267. var c2 = v1.b.neg().mul(k).divRound(this.n);
  72268. var p1 = c1.mul(v1.a);
  72269. var p2 = c2.mul(v2.a);
  72270. var q1 = c1.mul(v1.b);
  72271. var q2 = c2.mul(v2.b);
  72272. // Calculate answer
  72273. var k1 = k.sub(p1).sub(p2);
  72274. var k2 = q1.add(q2).neg();
  72275. return { k1: k1, k2: k2 };
  72276. };
  72277. ShortCurve.prototype.pointFromX = function pointFromX(x, odd) {
  72278. x = new BN(x, 16);
  72279. if (!x.red)
  72280. x = x.toRed(this.red);
  72281. var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b);
  72282. var y = y2.redSqrt();
  72283. if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
  72284. throw new Error('invalid point');
  72285. // XXX Is there any way to tell if the number is odd without converting it
  72286. // to non-red form?
  72287. var isOdd = y.fromRed().isOdd();
  72288. if (odd && !isOdd || !odd && isOdd)
  72289. y = y.redNeg();
  72290. return this.point(x, y);
  72291. };
  72292. ShortCurve.prototype.validate = function validate(point) {
  72293. if (point.inf)
  72294. return true;
  72295. var x = point.x;
  72296. var y = point.y;
  72297. var ax = this.a.redMul(x);
  72298. var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b);
  72299. return y.redSqr().redISub(rhs).cmpn(0) === 0;
  72300. };
  72301. ShortCurve.prototype._endoWnafMulAdd =
  72302. function _endoWnafMulAdd(points, coeffs, jacobianResult) {
  72303. var npoints = this._endoWnafT1;
  72304. var ncoeffs = this._endoWnafT2;
  72305. for (var i = 0; i < points.length; i++) {
  72306. var split = this._endoSplit(coeffs[i]);
  72307. var p = points[i];
  72308. var beta = p._getBeta();
  72309. if (split.k1.negative) {
  72310. split.k1.ineg();
  72311. p = p.neg(true);
  72312. }
  72313. if (split.k2.negative) {
  72314. split.k2.ineg();
  72315. beta = beta.neg(true);
  72316. }
  72317. npoints[i * 2] = p;
  72318. npoints[i * 2 + 1] = beta;
  72319. ncoeffs[i * 2] = split.k1;
  72320. ncoeffs[i * 2 + 1] = split.k2;
  72321. }
  72322. var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult);
  72323. // Clean-up references to points and coefficients
  72324. for (var j = 0; j < i * 2; j++) {
  72325. npoints[j] = null;
  72326. ncoeffs[j] = null;
  72327. }
  72328. return res;
  72329. };
  72330. function Point(curve, x, y, isRed) {
  72331. Base.BasePoint.call(this, curve, 'affine');
  72332. if (x === null && y === null) {
  72333. this.x = null;
  72334. this.y = null;
  72335. this.inf = true;
  72336. } else {
  72337. this.x = new BN(x, 16);
  72338. this.y = new BN(y, 16);
  72339. // Force redgomery representation when loading from JSON
  72340. if (isRed) {
  72341. this.x.forceRed(this.curve.red);
  72342. this.y.forceRed(this.curve.red);
  72343. }
  72344. if (!this.x.red)
  72345. this.x = this.x.toRed(this.curve.red);
  72346. if (!this.y.red)
  72347. this.y = this.y.toRed(this.curve.red);
  72348. this.inf = false;
  72349. }
  72350. }
  72351. inherits(Point, Base.BasePoint);
  72352. ShortCurve.prototype.point = function point(x, y, isRed) {
  72353. return new Point(this, x, y, isRed);
  72354. };
  72355. ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) {
  72356. return Point.fromJSON(this, obj, red);
  72357. };
  72358. Point.prototype._getBeta = function _getBeta() {
  72359. if (!this.curve.endo)
  72360. return;
  72361. var pre = this.precomputed;
  72362. if (pre && pre.beta)
  72363. return pre.beta;
  72364. var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y);
  72365. if (pre) {
  72366. var curve = this.curve;
  72367. var endoMul = function(p) {
  72368. return curve.point(p.x.redMul(curve.endo.beta), p.y);
  72369. };
  72370. pre.beta = beta;
  72371. beta.precomputed = {
  72372. beta: null,
  72373. naf: pre.naf && {
  72374. wnd: pre.naf.wnd,
  72375. points: pre.naf.points.map(endoMul)
  72376. },
  72377. doubles: pre.doubles && {
  72378. step: pre.doubles.step,
  72379. points: pre.doubles.points.map(endoMul)
  72380. }
  72381. };
  72382. }
  72383. return beta;
  72384. };
  72385. Point.prototype.toJSON = function toJSON() {
  72386. if (!this.precomputed)
  72387. return [ this.x, this.y ];
  72388. return [ this.x, this.y, this.precomputed && {
  72389. doubles: this.precomputed.doubles && {
  72390. step: this.precomputed.doubles.step,
  72391. points: this.precomputed.doubles.points.slice(1)
  72392. },
  72393. naf: this.precomputed.naf && {
  72394. wnd: this.precomputed.naf.wnd,
  72395. points: this.precomputed.naf.points.slice(1)
  72396. }
  72397. } ];
  72398. };
  72399. Point.fromJSON = function fromJSON(curve, obj, red) {
  72400. if (typeof obj === 'string')
  72401. obj = JSON.parse(obj);
  72402. var res = curve.point(obj[0], obj[1], red);
  72403. if (!obj[2])
  72404. return res;
  72405. function obj2point(obj) {
  72406. return curve.point(obj[0], obj[1], red);
  72407. }
  72408. var pre = obj[2];
  72409. res.precomputed = {
  72410. beta: null,
  72411. doubles: pre.doubles && {
  72412. step: pre.doubles.step,
  72413. points: [ res ].concat(pre.doubles.points.map(obj2point))
  72414. },
  72415. naf: pre.naf && {
  72416. wnd: pre.naf.wnd,
  72417. points: [ res ].concat(pre.naf.points.map(obj2point))
  72418. }
  72419. };
  72420. return res;
  72421. };
  72422. Point.prototype.inspect = function inspect() {
  72423. if (this.isInfinity())
  72424. return '<EC Point Infinity>';
  72425. return '<EC Point x: ' + this.x.fromRed().toString(16, 2) +
  72426. ' y: ' + this.y.fromRed().toString(16, 2) + '>';
  72427. };
  72428. Point.prototype.isInfinity = function isInfinity() {
  72429. return this.inf;
  72430. };
  72431. Point.prototype.add = function add(p) {
  72432. // O + P = P
  72433. if (this.inf)
  72434. return p;
  72435. // P + O = P
  72436. if (p.inf)
  72437. return this;
  72438. // P + P = 2P
  72439. if (this.eq(p))
  72440. return this.dbl();
  72441. // P + (-P) = O
  72442. if (this.neg().eq(p))
  72443. return this.curve.point(null, null);
  72444. // P + Q = O
  72445. if (this.x.cmp(p.x) === 0)
  72446. return this.curve.point(null, null);
  72447. var c = this.y.redSub(p.y);
  72448. if (c.cmpn(0) !== 0)
  72449. c = c.redMul(this.x.redSub(p.x).redInvm());
  72450. var nx = c.redSqr().redISub(this.x).redISub(p.x);
  72451. var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
  72452. return this.curve.point(nx, ny);
  72453. };
  72454. Point.prototype.dbl = function dbl() {
  72455. if (this.inf)
  72456. return this;
  72457. // 2P = O
  72458. var ys1 = this.y.redAdd(this.y);
  72459. if (ys1.cmpn(0) === 0)
  72460. return this.curve.point(null, null);
  72461. var a = this.curve.a;
  72462. var x2 = this.x.redSqr();
  72463. var dyinv = ys1.redInvm();
  72464. var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv);
  72465. var nx = c.redSqr().redISub(this.x.redAdd(this.x));
  72466. var ny = c.redMul(this.x.redSub(nx)).redISub(this.y);
  72467. return this.curve.point(nx, ny);
  72468. };
  72469. Point.prototype.getX = function getX() {
  72470. return this.x.fromRed();
  72471. };
  72472. Point.prototype.getY = function getY() {
  72473. return this.y.fromRed();
  72474. };
  72475. Point.prototype.mul = function mul(k) {
  72476. k = new BN(k, 16);
  72477. if (this._hasDoubles(k))
  72478. return this.curve._fixedNafMul(this, k);
  72479. else if (this.curve.endo)
  72480. return this.curve._endoWnafMulAdd([ this ], [ k ]);
  72481. else
  72482. return this.curve._wnafMul(this, k);
  72483. };
  72484. Point.prototype.mulAdd = function mulAdd(k1, p2, k2) {
  72485. var points = [ this, p2 ];
  72486. var coeffs = [ k1, k2 ];
  72487. if (this.curve.endo)
  72488. return this.curve._endoWnafMulAdd(points, coeffs);
  72489. else
  72490. return this.curve._wnafMulAdd(1, points, coeffs, 2);
  72491. };
  72492. Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) {
  72493. var points = [ this, p2 ];
  72494. var coeffs = [ k1, k2 ];
  72495. if (this.curve.endo)
  72496. return this.curve._endoWnafMulAdd(points, coeffs, true);
  72497. else
  72498. return this.curve._wnafMulAdd(1, points, coeffs, 2, true);
  72499. };
  72500. Point.prototype.eq = function eq(p) {
  72501. return this === p ||
  72502. this.inf === p.inf &&
  72503. (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0);
  72504. };
  72505. Point.prototype.neg = function neg(_precompute) {
  72506. if (this.inf)
  72507. return this;
  72508. var res = this.curve.point(this.x, this.y.redNeg());
  72509. if (_precompute && this.precomputed) {
  72510. var pre = this.precomputed;
  72511. var negate = function(p) {
  72512. return p.neg();
  72513. };
  72514. res.precomputed = {
  72515. naf: pre.naf && {
  72516. wnd: pre.naf.wnd,
  72517. points: pre.naf.points.map(negate)
  72518. },
  72519. doubles: pre.doubles && {
  72520. step: pre.doubles.step,
  72521. points: pre.doubles.points.map(negate)
  72522. }
  72523. };
  72524. }
  72525. return res;
  72526. };
  72527. Point.prototype.toJ = function toJ() {
  72528. if (this.inf)
  72529. return this.curve.jpoint(null, null, null);
  72530. var res = this.curve.jpoint(this.x, this.y, this.curve.one);
  72531. return res;
  72532. };
  72533. function JPoint(curve, x, y, z) {
  72534. Base.BasePoint.call(this, curve, 'jacobian');
  72535. if (x === null && y === null && z === null) {
  72536. this.x = this.curve.one;
  72537. this.y = this.curve.one;
  72538. this.z = new BN(0);
  72539. } else {
  72540. this.x = new BN(x, 16);
  72541. this.y = new BN(y, 16);
  72542. this.z = new BN(z, 16);
  72543. }
  72544. if (!this.x.red)
  72545. this.x = this.x.toRed(this.curve.red);
  72546. if (!this.y.red)
  72547. this.y = this.y.toRed(this.curve.red);
  72548. if (!this.z.red)
  72549. this.z = this.z.toRed(this.curve.red);
  72550. this.zOne = this.z === this.curve.one;
  72551. }
  72552. inherits(JPoint, Base.BasePoint);
  72553. ShortCurve.prototype.jpoint = function jpoint(x, y, z) {
  72554. return new JPoint(this, x, y, z);
  72555. };
  72556. JPoint.prototype.toP = function toP() {
  72557. if (this.isInfinity())
  72558. return this.curve.point(null, null);
  72559. var zinv = this.z.redInvm();
  72560. var zinv2 = zinv.redSqr();
  72561. var ax = this.x.redMul(zinv2);
  72562. var ay = this.y.redMul(zinv2).redMul(zinv);
  72563. return this.curve.point(ax, ay);
  72564. };
  72565. JPoint.prototype.neg = function neg() {
  72566. return this.curve.jpoint(this.x, this.y.redNeg(), this.z);
  72567. };
  72568. JPoint.prototype.add = function add(p) {
  72569. // O + P = P
  72570. if (this.isInfinity())
  72571. return p;
  72572. // P + O = P
  72573. if (p.isInfinity())
  72574. return this;
  72575. // 12M + 4S + 7A
  72576. var pz2 = p.z.redSqr();
  72577. var z2 = this.z.redSqr();
  72578. var u1 = this.x.redMul(pz2);
  72579. var u2 = p.x.redMul(z2);
  72580. var s1 = this.y.redMul(pz2.redMul(p.z));
  72581. var s2 = p.y.redMul(z2.redMul(this.z));
  72582. var h = u1.redSub(u2);
  72583. var r = s1.redSub(s2);
  72584. if (h.cmpn(0) === 0) {
  72585. if (r.cmpn(0) !== 0)
  72586. return this.curve.jpoint(null, null, null);
  72587. else
  72588. return this.dbl();
  72589. }
  72590. var h2 = h.redSqr();
  72591. var h3 = h2.redMul(h);
  72592. var v = u1.redMul(h2);
  72593. var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
  72594. var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
  72595. var nz = this.z.redMul(p.z).redMul(h);
  72596. return this.curve.jpoint(nx, ny, nz);
  72597. };
  72598. JPoint.prototype.mixedAdd = function mixedAdd(p) {
  72599. // O + P = P
  72600. if (this.isInfinity())
  72601. return p.toJ();
  72602. // P + O = P
  72603. if (p.isInfinity())
  72604. return this;
  72605. // 8M + 3S + 7A
  72606. var z2 = this.z.redSqr();
  72607. var u1 = this.x;
  72608. var u2 = p.x.redMul(z2);
  72609. var s1 = this.y;
  72610. var s2 = p.y.redMul(z2).redMul(this.z);
  72611. var h = u1.redSub(u2);
  72612. var r = s1.redSub(s2);
  72613. if (h.cmpn(0) === 0) {
  72614. if (r.cmpn(0) !== 0)
  72615. return this.curve.jpoint(null, null, null);
  72616. else
  72617. return this.dbl();
  72618. }
  72619. var h2 = h.redSqr();
  72620. var h3 = h2.redMul(h);
  72621. var v = u1.redMul(h2);
  72622. var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v);
  72623. var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3));
  72624. var nz = this.z.redMul(h);
  72625. return this.curve.jpoint(nx, ny, nz);
  72626. };
  72627. JPoint.prototype.dblp = function dblp(pow) {
  72628. if (pow === 0)
  72629. return this;
  72630. if (this.isInfinity())
  72631. return this;
  72632. if (!pow)
  72633. return this.dbl();
  72634. if (this.curve.zeroA || this.curve.threeA) {
  72635. var r = this;
  72636. for (var i = 0; i < pow; i++)
  72637. r = r.dbl();
  72638. return r;
  72639. }
  72640. // 1M + 2S + 1A + N * (4S + 5M + 8A)
  72641. // N = 1 => 6M + 6S + 9A
  72642. var a = this.curve.a;
  72643. var tinv = this.curve.tinv;
  72644. var jx = this.x;
  72645. var jy = this.y;
  72646. var jz = this.z;
  72647. var jz4 = jz.redSqr().redSqr();
  72648. // Reuse results
  72649. var jyd = jy.redAdd(jy);
  72650. for (var i = 0; i < pow; i++) {
  72651. var jx2 = jx.redSqr();
  72652. var jyd2 = jyd.redSqr();
  72653. var jyd4 = jyd2.redSqr();
  72654. var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
  72655. var t1 = jx.redMul(jyd2);
  72656. var nx = c.redSqr().redISub(t1.redAdd(t1));
  72657. var t2 = t1.redISub(nx);
  72658. var dny = c.redMul(t2);
  72659. dny = dny.redIAdd(dny).redISub(jyd4);
  72660. var nz = jyd.redMul(jz);
  72661. if (i + 1 < pow)
  72662. jz4 = jz4.redMul(jyd4);
  72663. jx = nx;
  72664. jz = nz;
  72665. jyd = dny;
  72666. }
  72667. return this.curve.jpoint(jx, jyd.redMul(tinv), jz);
  72668. };
  72669. JPoint.prototype.dbl = function dbl() {
  72670. if (this.isInfinity())
  72671. return this;
  72672. if (this.curve.zeroA)
  72673. return this._zeroDbl();
  72674. else if (this.curve.threeA)
  72675. return this._threeDbl();
  72676. else
  72677. return this._dbl();
  72678. };
  72679. JPoint.prototype._zeroDbl = function _zeroDbl() {
  72680. var nx;
  72681. var ny;
  72682. var nz;
  72683. // Z = 1
  72684. if (this.zOne) {
  72685. // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
  72686. // #doubling-mdbl-2007-bl
  72687. // 1M + 5S + 14A
  72688. // XX = X1^2
  72689. var xx = this.x.redSqr();
  72690. // YY = Y1^2
  72691. var yy = this.y.redSqr();
  72692. // YYYY = YY^2
  72693. var yyyy = yy.redSqr();
  72694. // S = 2 * ((X1 + YY)^2 - XX - YYYY)
  72695. var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
  72696. s = s.redIAdd(s);
  72697. // M = 3 * XX + a; a = 0
  72698. var m = xx.redAdd(xx).redIAdd(xx);
  72699. // T = M ^ 2 - 2*S
  72700. var t = m.redSqr().redISub(s).redISub(s);
  72701. // 8 * YYYY
  72702. var yyyy8 = yyyy.redIAdd(yyyy);
  72703. yyyy8 = yyyy8.redIAdd(yyyy8);
  72704. yyyy8 = yyyy8.redIAdd(yyyy8);
  72705. // X3 = T
  72706. nx = t;
  72707. // Y3 = M * (S - T) - 8 * YYYY
  72708. ny = m.redMul(s.redISub(t)).redISub(yyyy8);
  72709. // Z3 = 2*Y1
  72710. nz = this.y.redAdd(this.y);
  72711. } else {
  72712. // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html
  72713. // #doubling-dbl-2009-l
  72714. // 2M + 5S + 13A
  72715. // A = X1^2
  72716. var a = this.x.redSqr();
  72717. // B = Y1^2
  72718. var b = this.y.redSqr();
  72719. // C = B^2
  72720. var c = b.redSqr();
  72721. // D = 2 * ((X1 + B)^2 - A - C)
  72722. var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c);
  72723. d = d.redIAdd(d);
  72724. // E = 3 * A
  72725. var e = a.redAdd(a).redIAdd(a);
  72726. // F = E^2
  72727. var f = e.redSqr();
  72728. // 8 * C
  72729. var c8 = c.redIAdd(c);
  72730. c8 = c8.redIAdd(c8);
  72731. c8 = c8.redIAdd(c8);
  72732. // X3 = F - 2 * D
  72733. nx = f.redISub(d).redISub(d);
  72734. // Y3 = E * (D - X3) - 8 * C
  72735. ny = e.redMul(d.redISub(nx)).redISub(c8);
  72736. // Z3 = 2 * Y1 * Z1
  72737. nz = this.y.redMul(this.z);
  72738. nz = nz.redIAdd(nz);
  72739. }
  72740. return this.curve.jpoint(nx, ny, nz);
  72741. };
  72742. JPoint.prototype._threeDbl = function _threeDbl() {
  72743. var nx;
  72744. var ny;
  72745. var nz;
  72746. // Z = 1
  72747. if (this.zOne) {
  72748. // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html
  72749. // #doubling-mdbl-2007-bl
  72750. // 1M + 5S + 15A
  72751. // XX = X1^2
  72752. var xx = this.x.redSqr();
  72753. // YY = Y1^2
  72754. var yy = this.y.redSqr();
  72755. // YYYY = YY^2
  72756. var yyyy = yy.redSqr();
  72757. // S = 2 * ((X1 + YY)^2 - XX - YYYY)
  72758. var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
  72759. s = s.redIAdd(s);
  72760. // M = 3 * XX + a
  72761. var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a);
  72762. // T = M^2 - 2 * S
  72763. var t = m.redSqr().redISub(s).redISub(s);
  72764. // X3 = T
  72765. nx = t;
  72766. // Y3 = M * (S - T) - 8 * YYYY
  72767. var yyyy8 = yyyy.redIAdd(yyyy);
  72768. yyyy8 = yyyy8.redIAdd(yyyy8);
  72769. yyyy8 = yyyy8.redIAdd(yyyy8);
  72770. ny = m.redMul(s.redISub(t)).redISub(yyyy8);
  72771. // Z3 = 2 * Y1
  72772. nz = this.y.redAdd(this.y);
  72773. } else {
  72774. // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b
  72775. // 3M + 5S
  72776. // delta = Z1^2
  72777. var delta = this.z.redSqr();
  72778. // gamma = Y1^2
  72779. var gamma = this.y.redSqr();
  72780. // beta = X1 * gamma
  72781. var beta = this.x.redMul(gamma);
  72782. // alpha = 3 * (X1 - delta) * (X1 + delta)
  72783. var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta));
  72784. alpha = alpha.redAdd(alpha).redIAdd(alpha);
  72785. // X3 = alpha^2 - 8 * beta
  72786. var beta4 = beta.redIAdd(beta);
  72787. beta4 = beta4.redIAdd(beta4);
  72788. var beta8 = beta4.redAdd(beta4);
  72789. nx = alpha.redSqr().redISub(beta8);
  72790. // Z3 = (Y1 + Z1)^2 - gamma - delta
  72791. nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta);
  72792. // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2
  72793. var ggamma8 = gamma.redSqr();
  72794. ggamma8 = ggamma8.redIAdd(ggamma8);
  72795. ggamma8 = ggamma8.redIAdd(ggamma8);
  72796. ggamma8 = ggamma8.redIAdd(ggamma8);
  72797. ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8);
  72798. }
  72799. return this.curve.jpoint(nx, ny, nz);
  72800. };
  72801. JPoint.prototype._dbl = function _dbl() {
  72802. var a = this.curve.a;
  72803. // 4M + 6S + 10A
  72804. var jx = this.x;
  72805. var jy = this.y;
  72806. var jz = this.z;
  72807. var jz4 = jz.redSqr().redSqr();
  72808. var jx2 = jx.redSqr();
  72809. var jy2 = jy.redSqr();
  72810. var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4));
  72811. var jxd4 = jx.redAdd(jx);
  72812. jxd4 = jxd4.redIAdd(jxd4);
  72813. var t1 = jxd4.redMul(jy2);
  72814. var nx = c.redSqr().redISub(t1.redAdd(t1));
  72815. var t2 = t1.redISub(nx);
  72816. var jyd8 = jy2.redSqr();
  72817. jyd8 = jyd8.redIAdd(jyd8);
  72818. jyd8 = jyd8.redIAdd(jyd8);
  72819. jyd8 = jyd8.redIAdd(jyd8);
  72820. var ny = c.redMul(t2).redISub(jyd8);
  72821. var nz = jy.redAdd(jy).redMul(jz);
  72822. return this.curve.jpoint(nx, ny, nz);
  72823. };
  72824. JPoint.prototype.trpl = function trpl() {
  72825. if (!this.curve.zeroA)
  72826. return this.dbl().add(this);
  72827. // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl
  72828. // 5M + 10S + ...
  72829. // XX = X1^2
  72830. var xx = this.x.redSqr();
  72831. // YY = Y1^2
  72832. var yy = this.y.redSqr();
  72833. // ZZ = Z1^2
  72834. var zz = this.z.redSqr();
  72835. // YYYY = YY^2
  72836. var yyyy = yy.redSqr();
  72837. // M = 3 * XX + a * ZZ2; a = 0
  72838. var m = xx.redAdd(xx).redIAdd(xx);
  72839. // MM = M^2
  72840. var mm = m.redSqr();
  72841. // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM
  72842. var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy);
  72843. e = e.redIAdd(e);
  72844. e = e.redAdd(e).redIAdd(e);
  72845. e = e.redISub(mm);
  72846. // EE = E^2
  72847. var ee = e.redSqr();
  72848. // T = 16*YYYY
  72849. var t = yyyy.redIAdd(yyyy);
  72850. t = t.redIAdd(t);
  72851. t = t.redIAdd(t);
  72852. t = t.redIAdd(t);
  72853. // U = (M + E)^2 - MM - EE - T
  72854. var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t);
  72855. // X3 = 4 * (X1 * EE - 4 * YY * U)
  72856. var yyu4 = yy.redMul(u);
  72857. yyu4 = yyu4.redIAdd(yyu4);
  72858. yyu4 = yyu4.redIAdd(yyu4);
  72859. var nx = this.x.redMul(ee).redISub(yyu4);
  72860. nx = nx.redIAdd(nx);
  72861. nx = nx.redIAdd(nx);
  72862. // Y3 = 8 * Y1 * (U * (T - U) - E * EE)
  72863. var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee)));
  72864. ny = ny.redIAdd(ny);
  72865. ny = ny.redIAdd(ny);
  72866. ny = ny.redIAdd(ny);
  72867. // Z3 = (Z1 + E)^2 - ZZ - EE
  72868. var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee);
  72869. return this.curve.jpoint(nx, ny, nz);
  72870. };
  72871. JPoint.prototype.mul = function mul(k, kbase) {
  72872. k = new BN(k, kbase);
  72873. return this.curve._wnafMul(this, k);
  72874. };
  72875. JPoint.prototype.eq = function eq(p) {
  72876. if (p.type === 'affine')
  72877. return this.eq(p.toJ());
  72878. if (this === p)
  72879. return true;
  72880. // x1 * z2^2 == x2 * z1^2
  72881. var z2 = this.z.redSqr();
  72882. var pz2 = p.z.redSqr();
  72883. if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0)
  72884. return false;
  72885. // y1 * z2^3 == y2 * z1^3
  72886. var z3 = z2.redMul(this.z);
  72887. var pz3 = pz2.redMul(p.z);
  72888. return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0;
  72889. };
  72890. JPoint.prototype.eqXToP = function eqXToP(x) {
  72891. var zs = this.z.redSqr();
  72892. var rx = x.toRed(this.curve.red).redMul(zs);
  72893. if (this.x.cmp(rx) === 0)
  72894. return true;
  72895. var xc = x.clone();
  72896. var t = this.curve.redN.redMul(zs);
  72897. for (;;) {
  72898. xc.iadd(this.curve.n);
  72899. if (xc.cmp(this.curve.p) >= 0)
  72900. return false;
  72901. rx.redIAdd(t);
  72902. if (this.x.cmp(rx) === 0)
  72903. return true;
  72904. }
  72905. return false;
  72906. };
  72907. JPoint.prototype.inspect = function inspect() {
  72908. if (this.isInfinity())
  72909. return '<EC JPoint Infinity>';
  72910. return '<EC JPoint x: ' + this.x.toString(16, 2) +
  72911. ' y: ' + this.y.toString(16, 2) +
  72912. ' z: ' + this.z.toString(16, 2) + '>';
  72913. };
  72914. JPoint.prototype.isInfinity = function isInfinity() {
  72915. // XXX This code assumes that zero is always zero in red
  72916. return this.z.cmpn(0) === 0;
  72917. };
  72918. },{"../../elliptic":10,"../curve":13,"bn.js":4,"inherits":34}],16:[function(require,module,exports){
  72919. 'use strict';
  72920. var curves = exports;
  72921. var hash = require('hash.js');
  72922. var elliptic = require('../elliptic');
  72923. var assert = elliptic.utils.assert;
  72924. function PresetCurve(options) {
  72925. if (options.type === 'short')
  72926. this.curve = new elliptic.curve.short(options);
  72927. else if (options.type === 'edwards')
  72928. this.curve = new elliptic.curve.edwards(options);
  72929. else
  72930. this.curve = new elliptic.curve.mont(options);
  72931. this.g = this.curve.g;
  72932. this.n = this.curve.n;
  72933. this.hash = options.hash;
  72934. assert(this.g.validate(), 'Invalid curve');
  72935. assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O');
  72936. }
  72937. curves.PresetCurve = PresetCurve;
  72938. function defineCurve(name, options) {
  72939. Object.defineProperty(curves, name, {
  72940. configurable: true,
  72941. enumerable: true,
  72942. get: function() {
  72943. var curve = new PresetCurve(options);
  72944. Object.defineProperty(curves, name, {
  72945. configurable: true,
  72946. enumerable: true,
  72947. value: curve
  72948. });
  72949. return curve;
  72950. }
  72951. });
  72952. }
  72953. defineCurve('p192', {
  72954. type: 'short',
  72955. prime: 'p192',
  72956. p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff',
  72957. a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc',
  72958. b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1',
  72959. n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831',
  72960. hash: hash.sha256,
  72961. gRed: false,
  72962. g: [
  72963. '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012',
  72964. '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811'
  72965. ]
  72966. });
  72967. defineCurve('p224', {
  72968. type: 'short',
  72969. prime: 'p224',
  72970. p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001',
  72971. a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe',
  72972. b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4',
  72973. n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d',
  72974. hash: hash.sha256,
  72975. gRed: false,
  72976. g: [
  72977. 'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21',
  72978. 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34'
  72979. ]
  72980. });
  72981. defineCurve('p256', {
  72982. type: 'short',
  72983. prime: null,
  72984. p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff',
  72985. a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc',
  72986. b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b',
  72987. n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551',
  72988. hash: hash.sha256,
  72989. gRed: false,
  72990. g: [
  72991. '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296',
  72992. '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5'
  72993. ]
  72994. });
  72995. defineCurve('p384', {
  72996. type: 'short',
  72997. prime: null,
  72998. p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  72999. 'fffffffe ffffffff 00000000 00000000 ffffffff',
  73000. a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  73001. 'fffffffe ffffffff 00000000 00000000 fffffffc',
  73002. b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' +
  73003. '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef',
  73004. n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' +
  73005. 'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973',
  73006. hash: hash.sha384,
  73007. gRed: false,
  73008. g: [
  73009. 'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' +
  73010. '5502f25d bf55296c 3a545e38 72760ab7',
  73011. '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' +
  73012. '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f'
  73013. ]
  73014. });
  73015. defineCurve('p521', {
  73016. type: 'short',
  73017. prime: null,
  73018. p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  73019. 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  73020. 'ffffffff ffffffff ffffffff ffffffff ffffffff',
  73021. a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  73022. 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  73023. 'ffffffff ffffffff ffffffff ffffffff fffffffc',
  73024. b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' +
  73025. '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' +
  73026. '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00',
  73027. n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' +
  73028. 'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' +
  73029. 'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409',
  73030. hash: hash.sha512,
  73031. gRed: false,
  73032. g: [
  73033. '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' +
  73034. '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' +
  73035. 'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66',
  73036. '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' +
  73037. '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' +
  73038. '3fad0761 353c7086 a272c240 88be9476 9fd16650'
  73039. ]
  73040. });
  73041. defineCurve('curve25519', {
  73042. type: 'mont',
  73043. prime: 'p25519',
  73044. p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
  73045. a: '76d06',
  73046. b: '1',
  73047. n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
  73048. hash: hash.sha256,
  73049. gRed: false,
  73050. g: [
  73051. '9'
  73052. ]
  73053. });
  73054. defineCurve('ed25519', {
  73055. type: 'edwards',
  73056. prime: 'p25519',
  73057. p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',
  73058. a: '-1',
  73059. c: '1',
  73060. // -121665 * (121666^(-1)) (mod P)
  73061. d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3',
  73062. n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',
  73063. hash: hash.sha256,
  73064. gRed: false,
  73065. g: [
  73066. '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a',
  73067. // 4/5
  73068. '6666666666666666666666666666666666666666666666666666666666666658'
  73069. ]
  73070. });
  73071. var pre;
  73072. try {
  73073. pre = require('./precomputed/secp256k1');
  73074. } catch (e) {
  73075. pre = undefined;
  73076. }
  73077. defineCurve('secp256k1', {
  73078. type: 'short',
  73079. prime: 'k256',
  73080. p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f',
  73081. a: '0',
  73082. b: '7',
  73083. n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141',
  73084. h: '1',
  73085. hash: hash.sha256,
  73086. // Precomputed endomorphism
  73087. beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee',
  73088. lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72',
  73089. basis: [
  73090. {
  73091. a: '3086d221a7d46bcde86c90e49284eb15',
  73092. b: '-e4437ed6010e88286f547fa90abfe4c3'
  73093. },
  73094. {
  73095. a: '114ca50f7a8e2f3f657c1108d9d44cfd8',
  73096. b: '3086d221a7d46bcde86c90e49284eb15'
  73097. }
  73098. ],
  73099. gRed: false,
  73100. g: [
  73101. '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
  73102. '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8',
  73103. pre
  73104. ]
  73105. });
  73106. },{"../elliptic":10,"./precomputed/secp256k1":23,"hash.js":27}],17:[function(require,module,exports){
  73107. 'use strict';
  73108. var BN = require('bn.js');
  73109. var HmacDRBG = require('hmac-drbg');
  73110. var elliptic = require('../../elliptic');
  73111. var utils = elliptic.utils;
  73112. var assert = utils.assert;
  73113. var KeyPair = require('./key');
  73114. var Signature = require('./signature');
  73115. function EC(options) {
  73116. if (!(this instanceof EC))
  73117. return new EC(options);
  73118. // Shortcut `elliptic.ec(curve-name)`
  73119. if (typeof options === 'string') {
  73120. assert(elliptic.curves.hasOwnProperty(options), 'Unknown curve ' + options);
  73121. options = elliptic.curves[options];
  73122. }
  73123. // Shortcut for `elliptic.ec(elliptic.curves.curveName)`
  73124. if (options instanceof elliptic.curves.PresetCurve)
  73125. options = { curve: options };
  73126. this.curve = options.curve.curve;
  73127. this.n = this.curve.n;
  73128. this.nh = this.n.ushrn(1);
  73129. this.g = this.curve.g;
  73130. // Point on curve
  73131. this.g = options.curve.g;
  73132. this.g.precompute(options.curve.n.bitLength() + 1);
  73133. // Hash for function for DRBG
  73134. this.hash = options.hash || options.curve.hash;
  73135. }
  73136. module.exports = EC;
  73137. EC.prototype.keyPair = function keyPair(options) {
  73138. return new KeyPair(this, options);
  73139. };
  73140. EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) {
  73141. return KeyPair.fromPrivate(this, priv, enc);
  73142. };
  73143. EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) {
  73144. return KeyPair.fromPublic(this, pub, enc);
  73145. };
  73146. EC.prototype.genKeyPair = function genKeyPair(options) {
  73147. if (!options)
  73148. options = {};
  73149. // Instantiate Hmac_DRBG
  73150. var drbg = new HmacDRBG({
  73151. hash: this.hash,
  73152. pers: options.pers,
  73153. persEnc: options.persEnc || 'utf8',
  73154. entropy: options.entropy || elliptic.rand(this.hash.hmacStrength),
  73155. entropyEnc: options.entropy && options.entropyEnc || 'utf8',
  73156. nonce: this.n.toArray()
  73157. });
  73158. var bytes = this.n.byteLength();
  73159. var ns2 = this.n.sub(new BN(2));
  73160. do {
  73161. var priv = new BN(drbg.generate(bytes));
  73162. if (priv.cmp(ns2) > 0)
  73163. continue;
  73164. priv.iaddn(1);
  73165. return this.keyFromPrivate(priv);
  73166. } while (true);
  73167. };
  73168. EC.prototype._truncateToN = function truncateToN(msg, truncOnly) {
  73169. var delta = msg.byteLength() * 8 - this.n.bitLength();
  73170. if (delta > 0)
  73171. msg = msg.ushrn(delta);
  73172. if (!truncOnly && msg.cmp(this.n) >= 0)
  73173. return msg.sub(this.n);
  73174. else
  73175. return msg;
  73176. };
  73177. EC.prototype.sign = function sign(msg, key, enc, options) {
  73178. if (typeof enc === 'object') {
  73179. options = enc;
  73180. enc = null;
  73181. }
  73182. if (!options)
  73183. options = {};
  73184. key = this.keyFromPrivate(key, enc);
  73185. msg = this._truncateToN(new BN(msg, 16));
  73186. // Zero-extend key to provide enough entropy
  73187. var bytes = this.n.byteLength();
  73188. var bkey = key.getPrivate().toArray('be', bytes);
  73189. // Zero-extend nonce to have the same byte size as N
  73190. var nonce = msg.toArray('be', bytes);
  73191. // Instantiate Hmac_DRBG
  73192. var drbg = new HmacDRBG({
  73193. hash: this.hash,
  73194. entropy: bkey,
  73195. nonce: nonce,
  73196. pers: options.pers,
  73197. persEnc: options.persEnc || 'utf8'
  73198. });
  73199. // Number of bytes to generate
  73200. var ns1 = this.n.sub(new BN(1));
  73201. for (var iter = 0; true; iter++) {
  73202. var k = options.k ?
  73203. options.k(iter) :
  73204. new BN(drbg.generate(this.n.byteLength()));
  73205. k = this._truncateToN(k, true);
  73206. if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0)
  73207. continue;
  73208. var kp = this.g.mul(k);
  73209. if (kp.isInfinity())
  73210. continue;
  73211. var kpX = kp.getX();
  73212. var r = kpX.umod(this.n);
  73213. if (r.cmpn(0) === 0)
  73214. continue;
  73215. var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg));
  73216. s = s.umod(this.n);
  73217. if (s.cmpn(0) === 0)
  73218. continue;
  73219. var recoveryParam = (kp.getY().isOdd() ? 1 : 0) |
  73220. (kpX.cmp(r) !== 0 ? 2 : 0);
  73221. // Use complement of `s`, if it is > `n / 2`
  73222. if (options.canonical && s.cmp(this.nh) > 0) {
  73223. s = this.n.sub(s);
  73224. recoveryParam ^= 1;
  73225. }
  73226. return new Signature({ r: r, s: s, recoveryParam: recoveryParam });
  73227. }
  73228. };
  73229. EC.prototype.verify = function verify(msg, signature, key, enc) {
  73230. msg = this._truncateToN(new BN(msg, 16));
  73231. key = this.keyFromPublic(key, enc);
  73232. signature = new Signature(signature, 'hex');
  73233. // Perform primitive values validation
  73234. var r = signature.r;
  73235. var s = signature.s;
  73236. if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0)
  73237. return false;
  73238. if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0)
  73239. return false;
  73240. // Validate signature
  73241. var sinv = s.invm(this.n);
  73242. var u1 = sinv.mul(msg).umod(this.n);
  73243. var u2 = sinv.mul(r).umod(this.n);
  73244. if (!this.curve._maxwellTrick) {
  73245. var p = this.g.mulAdd(u1, key.getPublic(), u2);
  73246. if (p.isInfinity())
  73247. return false;
  73248. return p.getX().umod(this.n).cmp(r) === 0;
  73249. }
  73250. // NOTE: Greg Maxwell's trick, inspired by:
  73251. // https://git.io/vad3K
  73252. var p = this.g.jmulAdd(u1, key.getPublic(), u2);
  73253. if (p.isInfinity())
  73254. return false;
  73255. // Compare `p.x` of Jacobian point with `r`,
  73256. // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the
  73257. // inverse of `p.z^2`
  73258. return p.eqXToP(r);
  73259. };
  73260. EC.prototype.recoverPubKey = function(msg, signature, j, enc) {
  73261. assert((3 & j) === j, 'The recovery param is more than two bits');
  73262. signature = new Signature(signature, enc);
  73263. var n = this.n;
  73264. var e = new BN(msg);
  73265. var r = signature.r;
  73266. var s = signature.s;
  73267. // A set LSB signifies that the y-coordinate is odd
  73268. var isYOdd = j & 1;
  73269. var isSecondKey = j >> 1;
  73270. if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey)
  73271. throw new Error('Unable to find sencond key candinate');
  73272. // 1.1. Let x = r + jn.
  73273. if (isSecondKey)
  73274. r = this.curve.pointFromX(r.add(this.curve.n), isYOdd);
  73275. else
  73276. r = this.curve.pointFromX(r, isYOdd);
  73277. var rInv = signature.r.invm(n);
  73278. var s1 = n.sub(e).mul(rInv).umod(n);
  73279. var s2 = s.mul(rInv).umod(n);
  73280. // 1.6.1 Compute Q = r^-1 (sR - eG)
  73281. // Q = r^-1 (sR + -eG)
  73282. return this.g.mulAdd(s1, r, s2);
  73283. };
  73284. EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) {
  73285. signature = new Signature(signature, enc);
  73286. if (signature.recoveryParam !== null)
  73287. return signature.recoveryParam;
  73288. for (var i = 0; i < 4; i++) {
  73289. var Qprime;
  73290. try {
  73291. Qprime = this.recoverPubKey(e, signature, i);
  73292. } catch (e) {
  73293. continue;
  73294. }
  73295. if (Qprime.eq(Q))
  73296. return i;
  73297. }
  73298. throw new Error('Unable to find valid recovery factor');
  73299. };
  73300. },{"../../elliptic":10,"./key":18,"./signature":19,"bn.js":4,"hmac-drbg":33}],18:[function(require,module,exports){
  73301. 'use strict';
  73302. var BN = require('bn.js');
  73303. var elliptic = require('../../elliptic');
  73304. var utils = elliptic.utils;
  73305. var assert = utils.assert;
  73306. function KeyPair(ec, options) {
  73307. this.ec = ec;
  73308. this.priv = null;
  73309. this.pub = null;
  73310. // KeyPair(ec, { priv: ..., pub: ... })
  73311. if (options.priv)
  73312. this._importPrivate(options.priv, options.privEnc);
  73313. if (options.pub)
  73314. this._importPublic(options.pub, options.pubEnc);
  73315. }
  73316. module.exports = KeyPair;
  73317. KeyPair.fromPublic = function fromPublic(ec, pub, enc) {
  73318. if (pub instanceof KeyPair)
  73319. return pub;
  73320. return new KeyPair(ec, {
  73321. pub: pub,
  73322. pubEnc: enc
  73323. });
  73324. };
  73325. KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) {
  73326. if (priv instanceof KeyPair)
  73327. return priv;
  73328. return new KeyPair(ec, {
  73329. priv: priv,
  73330. privEnc: enc
  73331. });
  73332. };
  73333. KeyPair.prototype.validate = function validate() {
  73334. var pub = this.getPublic();
  73335. if (pub.isInfinity())
  73336. return { result: false, reason: 'Invalid public key' };
  73337. if (!pub.validate())
  73338. return { result: false, reason: 'Public key is not a point' };
  73339. if (!pub.mul(this.ec.curve.n).isInfinity())
  73340. return { result: false, reason: 'Public key * N != O' };
  73341. return { result: true, reason: null };
  73342. };
  73343. KeyPair.prototype.getPublic = function getPublic(compact, enc) {
  73344. // compact is optional argument
  73345. if (typeof compact === 'string') {
  73346. enc = compact;
  73347. compact = null;
  73348. }
  73349. if (!this.pub)
  73350. this.pub = this.ec.g.mul(this.priv);
  73351. if (!enc)
  73352. return this.pub;
  73353. return this.pub.encode(enc, compact);
  73354. };
  73355. KeyPair.prototype.getPrivate = function getPrivate(enc) {
  73356. if (enc === 'hex')
  73357. return this.priv.toString(16, 2);
  73358. else
  73359. return this.priv;
  73360. };
  73361. KeyPair.prototype._importPrivate = function _importPrivate(key, enc) {
  73362. this.priv = new BN(key, enc || 16);
  73363. // Ensure that the priv won't be bigger than n, otherwise we may fail
  73364. // in fixed multiplication method
  73365. this.priv = this.priv.umod(this.ec.curve.n);
  73366. };
  73367. KeyPair.prototype._importPublic = function _importPublic(key, enc) {
  73368. if (key.x || key.y) {
  73369. // Montgomery points only have an `x` coordinate.
  73370. // Weierstrass/Edwards points on the other hand have both `x` and
  73371. // `y` coordinates.
  73372. if (this.ec.curve.type === 'mont') {
  73373. assert(key.x, 'Need x coordinate');
  73374. } else if (this.ec.curve.type === 'short' ||
  73375. this.ec.curve.type === 'edwards') {
  73376. assert(key.x && key.y, 'Need both x and y coordinate');
  73377. }
  73378. this.pub = this.ec.curve.point(key.x, key.y);
  73379. return;
  73380. }
  73381. this.pub = this.ec.curve.decodePoint(key, enc);
  73382. };
  73383. // ECDH
  73384. KeyPair.prototype.derive = function derive(pub) {
  73385. return pub.mul(this.priv).getX();
  73386. };
  73387. // ECDSA
  73388. KeyPair.prototype.sign = function sign(msg, enc, options) {
  73389. return this.ec.sign(msg, this, enc, options);
  73390. };
  73391. KeyPair.prototype.verify = function verify(msg, signature) {
  73392. return this.ec.verify(msg, signature, this);
  73393. };
  73394. KeyPair.prototype.inspect = function inspect() {
  73395. return '<Key priv: ' + (this.priv && this.priv.toString(16, 2)) +
  73396. ' pub: ' + (this.pub && this.pub.inspect()) + ' >';
  73397. };
  73398. },{"../../elliptic":10,"bn.js":4}],19:[function(require,module,exports){
  73399. 'use strict';
  73400. var BN = require('bn.js');
  73401. var elliptic = require('../../elliptic');
  73402. var utils = elliptic.utils;
  73403. var assert = utils.assert;
  73404. function Signature(options, enc) {
  73405. if (options instanceof Signature)
  73406. return options;
  73407. if (this._importDER(options, enc))
  73408. return;
  73409. assert(options.r && options.s, 'Signature without r or s');
  73410. this.r = new BN(options.r, 16);
  73411. this.s = new BN(options.s, 16);
  73412. if (options.recoveryParam === undefined)
  73413. this.recoveryParam = null;
  73414. else
  73415. this.recoveryParam = options.recoveryParam;
  73416. }
  73417. module.exports = Signature;
  73418. function Position() {
  73419. this.place = 0;
  73420. }
  73421. function getLength(buf, p) {
  73422. var initial = buf[p.place++];
  73423. if (!(initial & 0x80)) {
  73424. return initial;
  73425. }
  73426. var octetLen = initial & 0xf;
  73427. var val = 0;
  73428. for (var i = 0, off = p.place; i < octetLen; i++, off++) {
  73429. val <<= 8;
  73430. val |= buf[off];
  73431. }
  73432. p.place = off;
  73433. return val;
  73434. }
  73435. function rmPadding(buf) {
  73436. var i = 0;
  73437. var len = buf.length - 1;
  73438. while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) {
  73439. i++;
  73440. }
  73441. if (i === 0) {
  73442. return buf;
  73443. }
  73444. return buf.slice(i);
  73445. }
  73446. Signature.prototype._importDER = function _importDER(data, enc) {
  73447. data = utils.toArray(data, enc);
  73448. var p = new Position();
  73449. if (data[p.place++] !== 0x30) {
  73450. return false;
  73451. }
  73452. var len = getLength(data, p);
  73453. if ((len + p.place) !== data.length) {
  73454. return false;
  73455. }
  73456. if (data[p.place++] !== 0x02) {
  73457. return false;
  73458. }
  73459. var rlen = getLength(data, p);
  73460. var r = data.slice(p.place, rlen + p.place);
  73461. p.place += rlen;
  73462. if (data[p.place++] !== 0x02) {
  73463. return false;
  73464. }
  73465. var slen = getLength(data, p);
  73466. if (data.length !== slen + p.place) {
  73467. return false;
  73468. }
  73469. var s = data.slice(p.place, slen + p.place);
  73470. if (r[0] === 0 && (r[1] & 0x80)) {
  73471. r = r.slice(1);
  73472. }
  73473. if (s[0] === 0 && (s[1] & 0x80)) {
  73474. s = s.slice(1);
  73475. }
  73476. this.r = new BN(r);
  73477. this.s = new BN(s);
  73478. this.recoveryParam = null;
  73479. return true;
  73480. };
  73481. function constructLength(arr, len) {
  73482. if (len < 0x80) {
  73483. arr.push(len);
  73484. return;
  73485. }
  73486. var octets = 1 + (Math.log(len) / Math.LN2 >>> 3);
  73487. arr.push(octets | 0x80);
  73488. while (--octets) {
  73489. arr.push((len >>> (octets << 3)) & 0xff);
  73490. }
  73491. arr.push(len);
  73492. }
  73493. Signature.prototype.toDER = function toDER(enc) {
  73494. var r = this.r.toArray();
  73495. var s = this.s.toArray();
  73496. // Pad values
  73497. if (r[0] & 0x80)
  73498. r = [ 0 ].concat(r);
  73499. // Pad values
  73500. if (s[0] & 0x80)
  73501. s = [ 0 ].concat(s);
  73502. r = rmPadding(r);
  73503. s = rmPadding(s);
  73504. while (!s[0] && !(s[1] & 0x80)) {
  73505. s = s.slice(1);
  73506. }
  73507. var arr = [ 0x02 ];
  73508. constructLength(arr, r.length);
  73509. arr = arr.concat(r);
  73510. arr.push(0x02);
  73511. constructLength(arr, s.length);
  73512. var backHalf = arr.concat(s);
  73513. var res = [ 0x30 ];
  73514. constructLength(res, backHalf.length);
  73515. res = res.concat(backHalf);
  73516. return utils.encode(res, enc);
  73517. };
  73518. },{"../../elliptic":10,"bn.js":4}],20:[function(require,module,exports){
  73519. 'use strict';
  73520. var hash = require('hash.js');
  73521. var elliptic = require('../../elliptic');
  73522. var utils = elliptic.utils;
  73523. var assert = utils.assert;
  73524. var parseBytes = utils.parseBytes;
  73525. var KeyPair = require('./key');
  73526. var Signature = require('./signature');
  73527. function EDDSA(curve) {
  73528. assert(curve === 'ed25519', 'only tested with ed25519 so far');
  73529. if (!(this instanceof EDDSA))
  73530. return new EDDSA(curve);
  73531. var curve = elliptic.curves[curve].curve;
  73532. this.curve = curve;
  73533. this.g = curve.g;
  73534. this.g.precompute(curve.n.bitLength() + 1);
  73535. this.pointClass = curve.point().constructor;
  73536. this.encodingLength = Math.ceil(curve.n.bitLength() / 8);
  73537. this.hash = hash.sha512;
  73538. }
  73539. module.exports = EDDSA;
  73540. /**
  73541. * @param {Array|String} message - message bytes
  73542. * @param {Array|String|KeyPair} secret - secret bytes or a keypair
  73543. * @returns {Signature} - signature
  73544. */
  73545. EDDSA.prototype.sign = function sign(message, secret) {
  73546. message = parseBytes(message);
  73547. var key = this.keyFromSecret(secret);
  73548. var r = this.hashInt(key.messagePrefix(), message);
  73549. var R = this.g.mul(r);
  73550. var Rencoded = this.encodePoint(R);
  73551. var s_ = this.hashInt(Rencoded, key.pubBytes(), message)
  73552. .mul(key.priv());
  73553. var S = r.add(s_).umod(this.curve.n);
  73554. return this.makeSignature({ R: R, S: S, Rencoded: Rencoded });
  73555. };
  73556. /**
  73557. * @param {Array} message - message bytes
  73558. * @param {Array|String|Signature} sig - sig bytes
  73559. * @param {Array|String|Point|KeyPair} pub - public key
  73560. * @returns {Boolean} - true if public key matches sig of message
  73561. */
  73562. EDDSA.prototype.verify = function verify(message, sig, pub) {
  73563. message = parseBytes(message);
  73564. sig = this.makeSignature(sig);
  73565. var key = this.keyFromPublic(pub);
  73566. var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message);
  73567. var SG = this.g.mul(sig.S());
  73568. var RplusAh = sig.R().add(key.pub().mul(h));
  73569. return RplusAh.eq(SG);
  73570. };
  73571. EDDSA.prototype.hashInt = function hashInt() {
  73572. var hash = this.hash();
  73573. for (var i = 0; i < arguments.length; i++)
  73574. hash.update(arguments[i]);
  73575. return utils.intFromLE(hash.digest()).umod(this.curve.n);
  73576. };
  73577. EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) {
  73578. return KeyPair.fromPublic(this, pub);
  73579. };
  73580. EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) {
  73581. return KeyPair.fromSecret(this, secret);
  73582. };
  73583. EDDSA.prototype.makeSignature = function makeSignature(sig) {
  73584. if (sig instanceof Signature)
  73585. return sig;
  73586. return new Signature(this, sig);
  73587. };
  73588. /**
  73589. * * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2
  73590. *
  73591. * EDDSA defines methods for encoding and decoding points and integers. These are
  73592. * helper convenience methods, that pass along to utility functions implied
  73593. * parameters.
  73594. *
  73595. */
  73596. EDDSA.prototype.encodePoint = function encodePoint(point) {
  73597. var enc = point.getY().toArray('le', this.encodingLength);
  73598. enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0;
  73599. return enc;
  73600. };
  73601. EDDSA.prototype.decodePoint = function decodePoint(bytes) {
  73602. bytes = utils.parseBytes(bytes);
  73603. var lastIx = bytes.length - 1;
  73604. var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80);
  73605. var xIsOdd = (bytes[lastIx] & 0x80) !== 0;
  73606. var y = utils.intFromLE(normed);
  73607. return this.curve.pointFromY(y, xIsOdd);
  73608. };
  73609. EDDSA.prototype.encodeInt = function encodeInt(num) {
  73610. return num.toArray('le', this.encodingLength);
  73611. };
  73612. EDDSA.prototype.decodeInt = function decodeInt(bytes) {
  73613. return utils.intFromLE(bytes);
  73614. };
  73615. EDDSA.prototype.isPoint = function isPoint(val) {
  73616. return val instanceof this.pointClass;
  73617. };
  73618. },{"../../elliptic":10,"./key":21,"./signature":22,"hash.js":27}],21:[function(require,module,exports){
  73619. 'use strict';
  73620. var elliptic = require('../../elliptic');
  73621. var utils = elliptic.utils;
  73622. var assert = utils.assert;
  73623. var parseBytes = utils.parseBytes;
  73624. var cachedProperty = utils.cachedProperty;
  73625. /**
  73626. * @param {EDDSA} eddsa - instance
  73627. * @param {Object} params - public/private key parameters
  73628. *
  73629. * @param {Array<Byte>} [params.secret] - secret seed bytes
  73630. * @param {Point} [params.pub] - public key point (aka `A` in eddsa terms)
  73631. * @param {Array<Byte>} [params.pub] - public key point encoded as bytes
  73632. *
  73633. */
  73634. function KeyPair(eddsa, params) {
  73635. this.eddsa = eddsa;
  73636. this._secret = parseBytes(params.secret);
  73637. if (eddsa.isPoint(params.pub))
  73638. this._pub = params.pub;
  73639. else
  73640. this._pubBytes = parseBytes(params.pub);
  73641. }
  73642. KeyPair.fromPublic = function fromPublic(eddsa, pub) {
  73643. if (pub instanceof KeyPair)
  73644. return pub;
  73645. return new KeyPair(eddsa, { pub: pub });
  73646. };
  73647. KeyPair.fromSecret = function fromSecret(eddsa, secret) {
  73648. if (secret instanceof KeyPair)
  73649. return secret;
  73650. return new KeyPair(eddsa, { secret: secret });
  73651. };
  73652. KeyPair.prototype.secret = function secret() {
  73653. return this._secret;
  73654. };
  73655. cachedProperty(KeyPair, 'pubBytes', function pubBytes() {
  73656. return this.eddsa.encodePoint(this.pub());
  73657. });
  73658. cachedProperty(KeyPair, 'pub', function pub() {
  73659. if (this._pubBytes)
  73660. return this.eddsa.decodePoint(this._pubBytes);
  73661. return this.eddsa.g.mul(this.priv());
  73662. });
  73663. cachedProperty(KeyPair, 'privBytes', function privBytes() {
  73664. var eddsa = this.eddsa;
  73665. var hash = this.hash();
  73666. var lastIx = eddsa.encodingLength - 1;
  73667. var a = hash.slice(0, eddsa.encodingLength);
  73668. a[0] &= 248;
  73669. a[lastIx] &= 127;
  73670. a[lastIx] |= 64;
  73671. return a;
  73672. });
  73673. cachedProperty(KeyPair, 'priv', function priv() {
  73674. return this.eddsa.decodeInt(this.privBytes());
  73675. });
  73676. cachedProperty(KeyPair, 'hash', function hash() {
  73677. return this.eddsa.hash().update(this.secret()).digest();
  73678. });
  73679. cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() {
  73680. return this.hash().slice(this.eddsa.encodingLength);
  73681. });
  73682. KeyPair.prototype.sign = function sign(message) {
  73683. assert(this._secret, 'KeyPair can only verify');
  73684. return this.eddsa.sign(message, this);
  73685. };
  73686. KeyPair.prototype.verify = function verify(message, sig) {
  73687. return this.eddsa.verify(message, sig, this);
  73688. };
  73689. KeyPair.prototype.getSecret = function getSecret(enc) {
  73690. assert(this._secret, 'KeyPair is public only');
  73691. return utils.encode(this.secret(), enc);
  73692. };
  73693. KeyPair.prototype.getPublic = function getPublic(enc) {
  73694. return utils.encode(this.pubBytes(), enc);
  73695. };
  73696. module.exports = KeyPair;
  73697. },{"../../elliptic":10}],22:[function(require,module,exports){
  73698. 'use strict';
  73699. var BN = require('bn.js');
  73700. var elliptic = require('../../elliptic');
  73701. var utils = elliptic.utils;
  73702. var assert = utils.assert;
  73703. var cachedProperty = utils.cachedProperty;
  73704. var parseBytes = utils.parseBytes;
  73705. /**
  73706. * @param {EDDSA} eddsa - eddsa instance
  73707. * @param {Array<Bytes>|Object} sig -
  73708. * @param {Array<Bytes>|Point} [sig.R] - R point as Point or bytes
  73709. * @param {Array<Bytes>|bn} [sig.S] - S scalar as bn or bytes
  73710. * @param {Array<Bytes>} [sig.Rencoded] - R point encoded
  73711. * @param {Array<Bytes>} [sig.Sencoded] - S scalar encoded
  73712. */
  73713. function Signature(eddsa, sig) {
  73714. this.eddsa = eddsa;
  73715. if (typeof sig !== 'object')
  73716. sig = parseBytes(sig);
  73717. if (Array.isArray(sig)) {
  73718. sig = {
  73719. R: sig.slice(0, eddsa.encodingLength),
  73720. S: sig.slice(eddsa.encodingLength)
  73721. };
  73722. }
  73723. assert(sig.R && sig.S, 'Signature without R or S');
  73724. if (eddsa.isPoint(sig.R))
  73725. this._R = sig.R;
  73726. if (sig.S instanceof BN)
  73727. this._S = sig.S;
  73728. this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded;
  73729. this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded;
  73730. }
  73731. cachedProperty(Signature, 'S', function S() {
  73732. return this.eddsa.decodeInt(this.Sencoded());
  73733. });
  73734. cachedProperty(Signature, 'R', function R() {
  73735. return this.eddsa.decodePoint(this.Rencoded());
  73736. });
  73737. cachedProperty(Signature, 'Rencoded', function Rencoded() {
  73738. return this.eddsa.encodePoint(this.R());
  73739. });
  73740. cachedProperty(Signature, 'Sencoded', function Sencoded() {
  73741. return this.eddsa.encodeInt(this.S());
  73742. });
  73743. Signature.prototype.toBytes = function toBytes() {
  73744. return this.Rencoded().concat(this.Sencoded());
  73745. };
  73746. Signature.prototype.toHex = function toHex() {
  73747. return utils.encode(this.toBytes(), 'hex').toUpperCase();
  73748. };
  73749. module.exports = Signature;
  73750. },{"../../elliptic":10,"bn.js":4}],23:[function(require,module,exports){
  73751. module.exports = {
  73752. doubles: {
  73753. step: 4,
  73754. points: [
  73755. [
  73756. 'e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a',
  73757. 'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821'
  73758. ],
  73759. [
  73760. '8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508',
  73761. '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf'
  73762. ],
  73763. [
  73764. '175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739',
  73765. 'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695'
  73766. ],
  73767. [
  73768. '363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640',
  73769. '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9'
  73770. ],
  73771. [
  73772. '8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c',
  73773. '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36'
  73774. ],
  73775. [
  73776. '723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda',
  73777. '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f'
  73778. ],
  73779. [
  73780. 'eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa',
  73781. '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999'
  73782. ],
  73783. [
  73784. '100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0',
  73785. 'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09'
  73786. ],
  73787. [
  73788. 'e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d',
  73789. '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d'
  73790. ],
  73791. [
  73792. 'feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d',
  73793. 'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088'
  73794. ],
  73795. [
  73796. 'da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1',
  73797. '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d'
  73798. ],
  73799. [
  73800. '53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0',
  73801. '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8'
  73802. ],
  73803. [
  73804. '8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047',
  73805. '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a'
  73806. ],
  73807. [
  73808. '385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862',
  73809. '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453'
  73810. ],
  73811. [
  73812. '6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7',
  73813. '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160'
  73814. ],
  73815. [
  73816. '3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd',
  73817. '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0'
  73818. ],
  73819. [
  73820. '85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83',
  73821. '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6'
  73822. ],
  73823. [
  73824. '948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a',
  73825. '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589'
  73826. ],
  73827. [
  73828. '6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8',
  73829. 'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17'
  73830. ],
  73831. [
  73832. 'e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d',
  73833. '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda'
  73834. ],
  73835. [
  73836. 'e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725',
  73837. '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd'
  73838. ],
  73839. [
  73840. '213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754',
  73841. '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2'
  73842. ],
  73843. [
  73844. '4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c',
  73845. '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6'
  73846. ],
  73847. [
  73848. 'fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6',
  73849. '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f'
  73850. ],
  73851. [
  73852. '76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39',
  73853. 'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01'
  73854. ],
  73855. [
  73856. 'c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891',
  73857. '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3'
  73858. ],
  73859. [
  73860. 'd895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b',
  73861. 'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f'
  73862. ],
  73863. [
  73864. 'b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03',
  73865. '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7'
  73866. ],
  73867. [
  73868. 'e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d',
  73869. 'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78'
  73870. ],
  73871. [
  73872. 'a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070',
  73873. '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1'
  73874. ],
  73875. [
  73876. '90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4',
  73877. 'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150'
  73878. ],
  73879. [
  73880. '8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da',
  73881. '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82'
  73882. ],
  73883. [
  73884. 'e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11',
  73885. '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc'
  73886. ],
  73887. [
  73888. '8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e',
  73889. 'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b'
  73890. ],
  73891. [
  73892. 'e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41',
  73893. '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51'
  73894. ],
  73895. [
  73896. 'b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef',
  73897. '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45'
  73898. ],
  73899. [
  73900. 'd68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8',
  73901. 'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120'
  73902. ],
  73903. [
  73904. '324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d',
  73905. '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84'
  73906. ],
  73907. [
  73908. '4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96',
  73909. '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d'
  73910. ],
  73911. [
  73912. '9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd',
  73913. 'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d'
  73914. ],
  73915. [
  73916. '6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5',
  73917. '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8'
  73918. ],
  73919. [
  73920. 'a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266',
  73921. '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8'
  73922. ],
  73923. [
  73924. '7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71',
  73925. '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac'
  73926. ],
  73927. [
  73928. '928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac',
  73929. 'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f'
  73930. ],
  73931. [
  73932. '85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751',
  73933. '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962'
  73934. ],
  73935. [
  73936. 'ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e',
  73937. '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907'
  73938. ],
  73939. [
  73940. '827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241',
  73941. 'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec'
  73942. ],
  73943. [
  73944. 'eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3',
  73945. 'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d'
  73946. ],
  73947. [
  73948. 'e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f',
  73949. '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414'
  73950. ],
  73951. [
  73952. '1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19',
  73953. 'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd'
  73954. ],
  73955. [
  73956. '146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be',
  73957. 'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0'
  73958. ],
  73959. [
  73960. 'fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9',
  73961. '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811'
  73962. ],
  73963. [
  73964. 'da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2',
  73965. '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1'
  73966. ],
  73967. [
  73968. 'a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13',
  73969. '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c'
  73970. ],
  73971. [
  73972. '174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c',
  73973. 'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73'
  73974. ],
  73975. [
  73976. '959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba',
  73977. '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd'
  73978. ],
  73979. [
  73980. 'd2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151',
  73981. 'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405'
  73982. ],
  73983. [
  73984. '64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073',
  73985. 'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589'
  73986. ],
  73987. [
  73988. '8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458',
  73989. '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e'
  73990. ],
  73991. [
  73992. '13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b',
  73993. '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27'
  73994. ],
  73995. [
  73996. 'bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366',
  73997. 'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1'
  73998. ],
  73999. [
  74000. '8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa',
  74001. '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482'
  74002. ],
  74003. [
  74004. '8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0',
  74005. '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945'
  74006. ],
  74007. [
  74008. 'dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787',
  74009. '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573'
  74010. ],
  74011. [
  74012. 'f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e',
  74013. 'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82'
  74014. ]
  74015. ]
  74016. },
  74017. naf: {
  74018. wnd: 7,
  74019. points: [
  74020. [
  74021. 'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9',
  74022. '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672'
  74023. ],
  74024. [
  74025. '2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4',
  74026. 'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6'
  74027. ],
  74028. [
  74029. '5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc',
  74030. '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da'
  74031. ],
  74032. [
  74033. 'acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe',
  74034. 'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37'
  74035. ],
  74036. [
  74037. '774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb',
  74038. 'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b'
  74039. ],
  74040. [
  74041. 'f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8',
  74042. 'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81'
  74043. ],
  74044. [
  74045. 'd7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e',
  74046. '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58'
  74047. ],
  74048. [
  74049. 'defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34',
  74050. '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77'
  74051. ],
  74052. [
  74053. '2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c',
  74054. '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a'
  74055. ],
  74056. [
  74057. '352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5',
  74058. '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c'
  74059. ],
  74060. [
  74061. '2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f',
  74062. '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67'
  74063. ],
  74064. [
  74065. '9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714',
  74066. '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402'
  74067. ],
  74068. [
  74069. 'daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729',
  74070. 'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55'
  74071. ],
  74072. [
  74073. 'c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db',
  74074. '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482'
  74075. ],
  74076. [
  74077. '6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4',
  74078. 'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82'
  74079. ],
  74080. [
  74081. '1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5',
  74082. 'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396'
  74083. ],
  74084. [
  74085. '605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479',
  74086. '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49'
  74087. ],
  74088. [
  74089. '62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d',
  74090. '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf'
  74091. ],
  74092. [
  74093. '80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f',
  74094. '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a'
  74095. ],
  74096. [
  74097. '7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb',
  74098. 'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7'
  74099. ],
  74100. [
  74101. 'd528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9',
  74102. 'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933'
  74103. ],
  74104. [
  74105. '49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963',
  74106. '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a'
  74107. ],
  74108. [
  74109. '77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74',
  74110. '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6'
  74111. ],
  74112. [
  74113. 'f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530',
  74114. 'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37'
  74115. ],
  74116. [
  74117. '463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b',
  74118. '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e'
  74119. ],
  74120. [
  74121. 'f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247',
  74122. 'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6'
  74123. ],
  74124. [
  74125. 'caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1',
  74126. 'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476'
  74127. ],
  74128. [
  74129. '2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120',
  74130. '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40'
  74131. ],
  74132. [
  74133. '7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435',
  74134. '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61'
  74135. ],
  74136. [
  74137. '754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18',
  74138. '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683'
  74139. ],
  74140. [
  74141. 'e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8',
  74142. '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5'
  74143. ],
  74144. [
  74145. '186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb',
  74146. '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b'
  74147. ],
  74148. [
  74149. 'df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f',
  74150. '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417'
  74151. ],
  74152. [
  74153. '5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143',
  74154. 'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868'
  74155. ],
  74156. [
  74157. '290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba',
  74158. 'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a'
  74159. ],
  74160. [
  74161. 'af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45',
  74162. 'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6'
  74163. ],
  74164. [
  74165. '766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a',
  74166. '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996'
  74167. ],
  74168. [
  74169. '59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e',
  74170. 'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e'
  74171. ],
  74172. [
  74173. 'f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8',
  74174. 'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d'
  74175. ],
  74176. [
  74177. '7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c',
  74178. '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2'
  74179. ],
  74180. [
  74181. '948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519',
  74182. 'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e'
  74183. ],
  74184. [
  74185. '7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab',
  74186. '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437'
  74187. ],
  74188. [
  74189. '3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca',
  74190. 'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311'
  74191. ],
  74192. [
  74193. 'd3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf',
  74194. '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4'
  74195. ],
  74196. [
  74197. '1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610',
  74198. '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575'
  74199. ],
  74200. [
  74201. '733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4',
  74202. 'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d'
  74203. ],
  74204. [
  74205. '15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c',
  74206. 'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d'
  74207. ],
  74208. [
  74209. 'a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940',
  74210. 'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629'
  74211. ],
  74212. [
  74213. 'e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980',
  74214. 'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06'
  74215. ],
  74216. [
  74217. '311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3',
  74218. '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374'
  74219. ],
  74220. [
  74221. '34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf',
  74222. '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee'
  74223. ],
  74224. [
  74225. 'f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63',
  74226. '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1'
  74227. ],
  74228. [
  74229. 'd7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448',
  74230. 'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b'
  74231. ],
  74232. [
  74233. '32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf',
  74234. '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661'
  74235. ],
  74236. [
  74237. '7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5',
  74238. '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6'
  74239. ],
  74240. [
  74241. 'ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6',
  74242. '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e'
  74243. ],
  74244. [
  74245. '16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5',
  74246. '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d'
  74247. ],
  74248. [
  74249. 'eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99',
  74250. 'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc'
  74251. ],
  74252. [
  74253. '78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51',
  74254. 'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4'
  74255. ],
  74256. [
  74257. '494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5',
  74258. '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c'
  74259. ],
  74260. [
  74261. 'a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5',
  74262. '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b'
  74263. ],
  74264. [
  74265. 'c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997',
  74266. '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913'
  74267. ],
  74268. [
  74269. '841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881',
  74270. '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154'
  74271. ],
  74272. [
  74273. '5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5',
  74274. '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865'
  74275. ],
  74276. [
  74277. '36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66',
  74278. 'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc'
  74279. ],
  74280. [
  74281. '336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726',
  74282. 'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224'
  74283. ],
  74284. [
  74285. '8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede',
  74286. '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e'
  74287. ],
  74288. [
  74289. '1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94',
  74290. '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6'
  74291. ],
  74292. [
  74293. '85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31',
  74294. '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511'
  74295. ],
  74296. [
  74297. '29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51',
  74298. 'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b'
  74299. ],
  74300. [
  74301. 'a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252',
  74302. 'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2'
  74303. ],
  74304. [
  74305. '4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5',
  74306. 'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c'
  74307. ],
  74308. [
  74309. 'd24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b',
  74310. '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3'
  74311. ],
  74312. [
  74313. 'ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4',
  74314. '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d'
  74315. ],
  74316. [
  74317. 'af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f',
  74318. '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700'
  74319. ],
  74320. [
  74321. 'e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889',
  74322. '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4'
  74323. ],
  74324. [
  74325. '591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246',
  74326. 'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196'
  74327. ],
  74328. [
  74329. '11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984',
  74330. '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4'
  74331. ],
  74332. [
  74333. '3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a',
  74334. 'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257'
  74335. ],
  74336. [
  74337. 'cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030',
  74338. 'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13'
  74339. ],
  74340. [
  74341. 'c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197',
  74342. '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096'
  74343. ],
  74344. [
  74345. 'c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593',
  74346. 'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38'
  74347. ],
  74348. [
  74349. 'a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef',
  74350. '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f'
  74351. ],
  74352. [
  74353. '347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38',
  74354. '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448'
  74355. ],
  74356. [
  74357. 'da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a',
  74358. '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a'
  74359. ],
  74360. [
  74361. 'c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111',
  74362. '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4'
  74363. ],
  74364. [
  74365. '4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502',
  74366. '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437'
  74367. ],
  74368. [
  74369. '3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea',
  74370. 'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7'
  74371. ],
  74372. [
  74373. 'cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26',
  74374. '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d'
  74375. ],
  74376. [
  74377. 'b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986',
  74378. '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a'
  74379. ],
  74380. [
  74381. 'd4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e',
  74382. '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54'
  74383. ],
  74384. [
  74385. '48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4',
  74386. '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77'
  74387. ],
  74388. [
  74389. 'dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda',
  74390. 'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517'
  74391. ],
  74392. [
  74393. '6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859',
  74394. 'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10'
  74395. ],
  74396. [
  74397. 'e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f',
  74398. 'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125'
  74399. ],
  74400. [
  74401. 'eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c',
  74402. '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e'
  74403. ],
  74404. [
  74405. '13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942',
  74406. 'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1'
  74407. ],
  74408. [
  74409. 'ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a',
  74410. '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2'
  74411. ],
  74412. [
  74413. 'b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80',
  74414. '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423'
  74415. ],
  74416. [
  74417. 'ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d',
  74418. '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8'
  74419. ],
  74420. [
  74421. '8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1',
  74422. 'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758'
  74423. ],
  74424. [
  74425. '52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63',
  74426. 'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375'
  74427. ],
  74428. [
  74429. 'e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352',
  74430. '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d'
  74431. ],
  74432. [
  74433. '7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193',
  74434. 'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec'
  74435. ],
  74436. [
  74437. '5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00',
  74438. '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0'
  74439. ],
  74440. [
  74441. '32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58',
  74442. 'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c'
  74443. ],
  74444. [
  74445. 'e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7',
  74446. 'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4'
  74447. ],
  74448. [
  74449. '8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8',
  74450. 'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f'
  74451. ],
  74452. [
  74453. '4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e',
  74454. '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649'
  74455. ],
  74456. [
  74457. '3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d',
  74458. 'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826'
  74459. ],
  74460. [
  74461. '674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b',
  74462. '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5'
  74463. ],
  74464. [
  74465. 'd32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f',
  74466. 'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87'
  74467. ],
  74468. [
  74469. '30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6',
  74470. '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b'
  74471. ],
  74472. [
  74473. 'be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297',
  74474. '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc'
  74475. ],
  74476. [
  74477. '93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a',
  74478. '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c'
  74479. ],
  74480. [
  74481. 'b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c',
  74482. 'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f'
  74483. ],
  74484. [
  74485. 'd5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52',
  74486. '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a'
  74487. ],
  74488. [
  74489. 'd3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb',
  74490. 'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46'
  74491. ],
  74492. [
  74493. '463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065',
  74494. 'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f'
  74495. ],
  74496. [
  74497. '7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917',
  74498. '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03'
  74499. ],
  74500. [
  74501. '74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9',
  74502. 'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08'
  74503. ],
  74504. [
  74505. '30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3',
  74506. '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8'
  74507. ],
  74508. [
  74509. '9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57',
  74510. '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373'
  74511. ],
  74512. [
  74513. '176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66',
  74514. 'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3'
  74515. ],
  74516. [
  74517. '75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8',
  74518. '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8'
  74519. ],
  74520. [
  74521. '809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721',
  74522. '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1'
  74523. ],
  74524. [
  74525. '1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180',
  74526. '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9'
  74527. ]
  74528. ]
  74529. }
  74530. };
  74531. },{}],24:[function(require,module,exports){
  74532. 'use strict';
  74533. var utils = exports;
  74534. var BN = require('bn.js');
  74535. var minAssert = require('minimalistic-assert');
  74536. var minUtils = require('minimalistic-crypto-utils');
  74537. utils.assert = minAssert;
  74538. utils.toArray = minUtils.toArray;
  74539. utils.zero2 = minUtils.zero2;
  74540. utils.toHex = minUtils.toHex;
  74541. utils.encode = minUtils.encode;
  74542. // Represent num in a w-NAF form
  74543. function getNAF(num, w) {
  74544. var naf = [];
  74545. var ws = 1 << (w + 1);
  74546. var k = num.clone();
  74547. while (k.cmpn(1) >= 0) {
  74548. var z;
  74549. if (k.isOdd()) {
  74550. var mod = k.andln(ws - 1);
  74551. if (mod > (ws >> 1) - 1)
  74552. z = (ws >> 1) - mod;
  74553. else
  74554. z = mod;
  74555. k.isubn(z);
  74556. } else {
  74557. z = 0;
  74558. }
  74559. naf.push(z);
  74560. // Optimization, shift by word if possible
  74561. var shift = (k.cmpn(0) !== 0 && k.andln(ws - 1) === 0) ? (w + 1) : 1;
  74562. for (var i = 1; i < shift; i++)
  74563. naf.push(0);
  74564. k.iushrn(shift);
  74565. }
  74566. return naf;
  74567. }
  74568. utils.getNAF = getNAF;
  74569. // Represent k1, k2 in a Joint Sparse Form
  74570. function getJSF(k1, k2) {
  74571. var jsf = [
  74572. [],
  74573. []
  74574. ];
  74575. k1 = k1.clone();
  74576. k2 = k2.clone();
  74577. var d1 = 0;
  74578. var d2 = 0;
  74579. while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) {
  74580. // First phase
  74581. var m14 = (k1.andln(3) + d1) & 3;
  74582. var m24 = (k2.andln(3) + d2) & 3;
  74583. if (m14 === 3)
  74584. m14 = -1;
  74585. if (m24 === 3)
  74586. m24 = -1;
  74587. var u1;
  74588. if ((m14 & 1) === 0) {
  74589. u1 = 0;
  74590. } else {
  74591. var m8 = (k1.andln(7) + d1) & 7;
  74592. if ((m8 === 3 || m8 === 5) && m24 === 2)
  74593. u1 = -m14;
  74594. else
  74595. u1 = m14;
  74596. }
  74597. jsf[0].push(u1);
  74598. var u2;
  74599. if ((m24 & 1) === 0) {
  74600. u2 = 0;
  74601. } else {
  74602. var m8 = (k2.andln(7) + d2) & 7;
  74603. if ((m8 === 3 || m8 === 5) && m14 === 2)
  74604. u2 = -m24;
  74605. else
  74606. u2 = m24;
  74607. }
  74608. jsf[1].push(u2);
  74609. // Second phase
  74610. if (2 * d1 === u1 + 1)
  74611. d1 = 1 - d1;
  74612. if (2 * d2 === u2 + 1)
  74613. d2 = 1 - d2;
  74614. k1.iushrn(1);
  74615. k2.iushrn(1);
  74616. }
  74617. return jsf;
  74618. }
  74619. utils.getJSF = getJSF;
  74620. function cachedProperty(obj, name, computer) {
  74621. var key = '_' + name;
  74622. obj.prototype[name] = function cachedProperty() {
  74623. return this[key] !== undefined ? this[key] :
  74624. this[key] = computer.call(this);
  74625. };
  74626. }
  74627. utils.cachedProperty = cachedProperty;
  74628. function parseBytes(bytes) {
  74629. return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') :
  74630. bytes;
  74631. }
  74632. utils.parseBytes = parseBytes;
  74633. function intFromLE(bytes) {
  74634. return new BN(bytes, 'hex', 'le');
  74635. }
  74636. utils.intFromLE = intFromLE;
  74637. },{"bn.js":4,"minimalistic-assert":42,"minimalistic-crypto-utils":43}],25:[function(require,module,exports){
  74638. module.exports={
  74639. "_args": [
  74640. [
  74641. {
  74642. "raw": "elliptic@^6.2.3",
  74643. "scope": null,
  74644. "escapedName": "elliptic",
  74645. "name": "elliptic",
  74646. "rawSpec": "^6.2.3",
  74647. "spec": ">=6.2.3 <7.0.0",
  74648. "type": "range"
  74649. },
  74650. "/home/ethvm/Desktop/Embark/eth-utils/ethereumjs-util/node_modules/secp256k1"
  74651. ]
  74652. ],
  74653. "_from": "elliptic@>=6.2.3 <7.0.0",
  74654. "_id": "[email protected]",
  74655. "_inCache": true,
  74656. "_location": "/elliptic",
  74657. "_nodeVersion": "7.0.0",
  74658. "_npmOperationalInternal": {
  74659. "host": "packages-18-east.internal.npmjs.com",
  74660. "tmp": "tmp/elliptic-6.4.0.tgz_1487798866428_0.30510620190761983"
  74661. },
  74662. "_npmUser": {
  74663. "name": "indutny",
  74664. "email": "[email protected]"
  74665. },
  74666. "_npmVersion": "3.10.8",
  74667. "_phantomChildren": {},
  74668. "_requested": {
  74669. "raw": "elliptic@^6.2.3",
  74670. "scope": null,
  74671. "escapedName": "elliptic",
  74672. "name": "elliptic",
  74673. "rawSpec": "^6.2.3",
  74674. "spec": ">=6.2.3 <7.0.0",
  74675. "type": "range"
  74676. },
  74677. "_requiredBy": [
  74678. "/browserify-sign",
  74679. "/create-ecdh",
  74680. "/secp256k1"
  74681. ],
  74682. "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz",
  74683. "_shasum": "cac9af8762c85836187003c8dfe193e5e2eae5df",
  74684. "_shrinkwrap": null,
  74685. "_spec": "elliptic@^6.2.3",
  74686. "_where": "/home/ethvm/Desktop/Embark/eth-utils/ethereumjs-util/node_modules/secp256k1",
  74687. "author": {
  74688. "name": "Fedor Indutny",
  74689. "email": "[email protected]"
  74690. },
  74691. "bugs": {
  74692. "url": "https://github.com/indutny/elliptic/issues"
  74693. },
  74694. "dependencies": {
  74695. "bn.js": "^4.4.0",
  74696. "brorand": "^1.0.1",
  74697. "hash.js": "^1.0.0",
  74698. "hmac-drbg": "^1.0.0",
  74699. "inherits": "^2.0.1",
  74700. "minimalistic-assert": "^1.0.0",
  74701. "minimalistic-crypto-utils": "^1.0.0"
  74702. },
  74703. "description": "EC cryptography",
  74704. "devDependencies": {
  74705. "brfs": "^1.4.3",
  74706. "coveralls": "^2.11.3",
  74707. "grunt": "^0.4.5",
  74708. "grunt-browserify": "^5.0.0",
  74709. "grunt-cli": "^1.2.0",
  74710. "grunt-contrib-connect": "^1.0.0",
  74711. "grunt-contrib-copy": "^1.0.0",
  74712. "grunt-contrib-uglify": "^1.0.1",
  74713. "grunt-mocha-istanbul": "^3.0.1",
  74714. "grunt-saucelabs": "^8.6.2",
  74715. "istanbul": "^0.4.2",
  74716. "jscs": "^2.9.0",
  74717. "jshint": "^2.6.0",
  74718. "mocha": "^2.1.0"
  74719. },
  74720. "directories": {},
  74721. "dist": {
  74722. "shasum": "cac9af8762c85836187003c8dfe193e5e2eae5df",
  74723. "tarball": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz"
  74724. },
  74725. "files": [
  74726. "lib"
  74727. ],
  74728. "gitHead": "6b0d2b76caae91471649c8e21f0b1d3ba0f96090",
  74729. "homepage": "https://github.com/indutny/elliptic",
  74730. "keywords": [
  74731. "EC",
  74732. "Elliptic",
  74733. "curve",
  74734. "Cryptography"
  74735. ],
  74736. "license": "MIT",
  74737. "main": "lib/elliptic.js",
  74738. "maintainers": [
  74739. {
  74740. "name": "indutny",
  74741. "email": "[email protected]"
  74742. }
  74743. ],
  74744. "name": "elliptic",
  74745. "optionalDependencies": {},
  74746. "readme": "ERROR: No README data found!",
  74747. "repository": {
  74748. "type": "git",
  74749. "url": "git+ssh://[email protected]/indutny/elliptic.git"
  74750. },
  74751. "scripts": {
  74752. "jscs": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",
  74753. "jshint": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",
  74754. "lint": "npm run jscs && npm run jshint",
  74755. "test": "npm run lint && npm run unit",
  74756. "unit": "istanbul test _mocha --reporter=spec test/index.js",
  74757. "version": "grunt dist && git add dist/"
  74758. },
  74759. "version": "6.4.0"
  74760. }
  74761. },{}],26:[function(require,module,exports){
  74762. (function (Buffer){
  74763. 'use strict';
  74764. var isHexPrefixed = require('is-hex-prefixed');
  74765. var stripHexPrefix = require('strip-hex-prefix');
  74766. /**
  74767. * Pads a `String` to have an even length
  74768. * @param {String} value
  74769. * @return {String} output
  74770. */
  74771. function padToEven(value) {
  74772. var a = value; // eslint-disable-line
  74773. if (typeof a !== 'string') {
  74774. throw new Error('[ethjs-util] while padding to even, value must be string, is currently ' + typeof a + ', while padToEven.');
  74775. }
  74776. if (a.length % 2) {
  74777. a = '0' + a;
  74778. }
  74779. return a;
  74780. }
  74781. /**
  74782. * Converts a `Number` into a hex `String`
  74783. * @param {Number} i
  74784. * @return {String}
  74785. */
  74786. function intToHex(i) {
  74787. var hex = i.toString(16); // eslint-disable-line
  74788. return '0x' + padToEven(hex);
  74789. }
  74790. /**
  74791. * Converts an `Number` to a `Buffer`
  74792. * @param {Number} i
  74793. * @return {Buffer}
  74794. */
  74795. function intToBuffer(i) {
  74796. var hex = intToHex(i);
  74797. return new Buffer(hex.slice(2), 'hex');
  74798. }
  74799. /**
  74800. * Get the binary size of a string
  74801. * @param {String} str
  74802. * @return {Number}
  74803. */
  74804. function getBinarySize(str) {
  74805. if (typeof str !== 'string') {
  74806. throw new Error('[ethjs-util] while getting binary size, method getBinarySize requires input \'str\' to be type String, got \'' + typeof str + '\'.');
  74807. }
  74808. return Buffer.byteLength(str, 'utf8');
  74809. }
  74810. /**
  74811. * Returns TRUE if the first specified array contains all elements
  74812. * from the second one. FALSE otherwise.
  74813. *
  74814. * @param {array} superset
  74815. * @param {array} subset
  74816. *
  74817. * @returns {boolean}
  74818. */
  74819. function arrayContainsArray(superset, subset, some) {
  74820. if (Array.isArray(superset) !== true) {
  74821. throw new Error('[ethjs-util] method arrayContainsArray requires input \'superset\' to be an array got type \'' + typeof superset + '\'');
  74822. }
  74823. if (Array.isArray(subset) !== true) {
  74824. throw new Error('[ethjs-util] method arrayContainsArray requires input \'subset\' to be an array got type \'' + typeof subset + '\'');
  74825. }
  74826. return subset[Boolean(some) && 'some' || 'every'](function (value) {
  74827. return superset.indexOf(value) >= 0;
  74828. });
  74829. }
  74830. /**
  74831. * Should be called to get utf8 from it's hex representation
  74832. *
  74833. * @method toUtf8
  74834. * @param {String} string in hex
  74835. * @returns {String} ascii string representation of hex value
  74836. */
  74837. function toUtf8(hex) {
  74838. var bufferValue = new Buffer(padToEven(stripHexPrefix(hex).replace(/^0+|0+$/g, '')), 'hex');
  74839. return bufferValue.toString('utf8');
  74840. }
  74841. /**
  74842. * Should be called to get ascii from it's hex representation
  74843. *
  74844. * @method toAscii
  74845. * @param {String} string in hex
  74846. * @returns {String} ascii string representation of hex value
  74847. */
  74848. function toAscii(hex) {
  74849. var str = ''; // eslint-disable-line
  74850. var i = 0,
  74851. l = hex.length; // eslint-disable-line
  74852. if (hex.substring(0, 2) === '0x') {
  74853. i = 2;
  74854. }
  74855. for (; i < l; i += 2) {
  74856. var code = parseInt(hex.substr(i, 2), 16);
  74857. str += String.fromCharCode(code);
  74858. }
  74859. return str;
  74860. }
  74861. /**
  74862. * Should be called to get hex representation (prefixed by 0x) of utf8 string
  74863. *
  74864. * @method fromUtf8
  74865. * @param {String} string
  74866. * @param {Number} optional padding
  74867. * @returns {String} hex representation of input string
  74868. */
  74869. function fromUtf8(stringValue) {
  74870. var str = new Buffer(stringValue, 'utf8');
  74871. return '0x' + padToEven(str.toString('hex')).replace(/^0+|0+$/g, '');
  74872. }
  74873. /**
  74874. * Should be called to get hex representation (prefixed by 0x) of ascii string
  74875. *
  74876. * @method fromAscii
  74877. * @param {String} string
  74878. * @param {Number} optional padding
  74879. * @returns {String} hex representation of input string
  74880. */
  74881. function fromAscii(stringValue) {
  74882. var hex = ''; // eslint-disable-line
  74883. for (var i = 0; i < stringValue.length; i++) {
  74884. // eslint-disable-line
  74885. var code = stringValue.charCodeAt(i);
  74886. var n = code.toString(16);
  74887. hex += n.length < 2 ? '0' + n : n;
  74888. }
  74889. return '0x' + hex;
  74890. }
  74891. /**
  74892. * getKeys([{a: 1, b: 2}, {a: 3, b: 4}], 'a') => [1, 3]
  74893. *
  74894. * @method getKeys get specific key from inner object array of objects
  74895. * @param {String} params
  74896. * @param {String} key
  74897. * @param {Boolean} allowEmpty
  74898. * @returns {Array} output just a simple array of output keys
  74899. */
  74900. function getKeys(params, key, allowEmpty) {
  74901. if (!Array.isArray(params)) {
  74902. throw new Error('[ethjs-util] method getKeys expecting type Array as \'params\' input, got \'' + typeof params + '\'');
  74903. }
  74904. if (typeof key !== 'string') {
  74905. throw new Error('[ethjs-util] method getKeys expecting type String for input \'key\' got \'' + typeof key + '\'.');
  74906. }
  74907. var result = []; // eslint-disable-line
  74908. for (var i = 0; i < params.length; i++) {
  74909. // eslint-disable-line
  74910. var value = params[i][key]; // eslint-disable-line
  74911. if (allowEmpty && !value) {
  74912. value = '';
  74913. } else if (typeof value !== 'string') {
  74914. throw new Error('invalid abi');
  74915. }
  74916. result.push(value);
  74917. }
  74918. return result;
  74919. }
  74920. /**
  74921. * Is the string a hex string.
  74922. *
  74923. * @method check if string is hex string of specific length
  74924. * @param {String} value
  74925. * @param {Number} length
  74926. * @returns {Boolean} output the string is a hex string
  74927. */
  74928. function isHexString(value, length) {
  74929. if (typeof value !== 'string' || !value.match(/^0x[0-9A-Fa-f]*$/)) {
  74930. return false;
  74931. }
  74932. if (length && value.length !== 2 + 2 * length) {
  74933. return false;
  74934. }
  74935. return true;
  74936. }
  74937. module.exports = {
  74938. arrayContainsArray: arrayContainsArray,
  74939. intToBuffer: intToBuffer,
  74940. getBinarySize: getBinarySize,
  74941. isHexPrefixed: isHexPrefixed,
  74942. stripHexPrefix: stripHexPrefix,
  74943. padToEven: padToEven,
  74944. intToHex: intToHex,
  74945. fromAscii: fromAscii,
  74946. fromUtf8: fromUtf8,
  74947. toAscii: toAscii,
  74948. toUtf8: toUtf8,
  74949. getKeys: getKeys,
  74950. isHexString: isHexString
  74951. };
  74952. }).call(this,require("buffer").Buffer)
  74953. },{"buffer":65,"is-hex-prefixed":35,"strip-hex-prefix":60}],27:[function(require,module,exports){
  74954. var hash = exports;
  74955. hash.utils = require('./hash/utils');
  74956. hash.common = require('./hash/common');
  74957. hash.sha = require('./hash/sha');
  74958. hash.ripemd = require('./hash/ripemd');
  74959. hash.hmac = require('./hash/hmac');
  74960. // Proxy hash functions to the main object
  74961. hash.sha1 = hash.sha.sha1;
  74962. hash.sha256 = hash.sha.sha256;
  74963. hash.sha224 = hash.sha.sha224;
  74964. hash.sha384 = hash.sha.sha384;
  74965. hash.sha512 = hash.sha.sha512;
  74966. hash.ripemd160 = hash.ripemd.ripemd160;
  74967. },{"./hash/common":28,"./hash/hmac":29,"./hash/ripemd":30,"./hash/sha":31,"./hash/utils":32}],28:[function(require,module,exports){
  74968. var hash = require('../hash');
  74969. var utils = hash.utils;
  74970. var assert = utils.assert;
  74971. function BlockHash() {
  74972. this.pending = null;
  74973. this.pendingTotal = 0;
  74974. this.blockSize = this.constructor.blockSize;
  74975. this.outSize = this.constructor.outSize;
  74976. this.hmacStrength = this.constructor.hmacStrength;
  74977. this.padLength = this.constructor.padLength / 8;
  74978. this.endian = 'big';
  74979. this._delta8 = this.blockSize / 8;
  74980. this._delta32 = this.blockSize / 32;
  74981. }
  74982. exports.BlockHash = BlockHash;
  74983. BlockHash.prototype.update = function update(msg, enc) {
  74984. // Convert message to array, pad it, and join into 32bit blocks
  74985. msg = utils.toArray(msg, enc);
  74986. if (!this.pending)
  74987. this.pending = msg;
  74988. else
  74989. this.pending = this.pending.concat(msg);
  74990. this.pendingTotal += msg.length;
  74991. // Enough data, try updating
  74992. if (this.pending.length >= this._delta8) {
  74993. msg = this.pending;
  74994. // Process pending data in blocks
  74995. var r = msg.length % this._delta8;
  74996. this.pending = msg.slice(msg.length - r, msg.length);
  74997. if (this.pending.length === 0)
  74998. this.pending = null;
  74999. msg = utils.join32(msg, 0, msg.length - r, this.endian);
  75000. for (var i = 0; i < msg.length; i += this._delta32)
  75001. this._update(msg, i, i + this._delta32);
  75002. }
  75003. return this;
  75004. };
  75005. BlockHash.prototype.digest = function digest(enc) {
  75006. this.update(this._pad());
  75007. assert(this.pending === null);
  75008. return this._digest(enc);
  75009. };
  75010. BlockHash.prototype._pad = function pad() {
  75011. var len = this.pendingTotal;
  75012. var bytes = this._delta8;
  75013. var k = bytes - ((len + this.padLength) % bytes);
  75014. var res = new Array(k + this.padLength);
  75015. res[0] = 0x80;
  75016. for (var i = 1; i < k; i++)
  75017. res[i] = 0;
  75018. // Append length
  75019. len <<= 3;
  75020. if (this.endian === 'big') {
  75021. for (var t = 8; t < this.padLength; t++)
  75022. res[i++] = 0;
  75023. res[i++] = 0;
  75024. res[i++] = 0;
  75025. res[i++] = 0;
  75026. res[i++] = 0;
  75027. res[i++] = (len >>> 24) & 0xff;
  75028. res[i++] = (len >>> 16) & 0xff;
  75029. res[i++] = (len >>> 8) & 0xff;
  75030. res[i++] = len & 0xff;
  75031. } else {
  75032. res[i++] = len & 0xff;
  75033. res[i++] = (len >>> 8) & 0xff;
  75034. res[i++] = (len >>> 16) & 0xff;
  75035. res[i++] = (len >>> 24) & 0xff;
  75036. res[i++] = 0;
  75037. res[i++] = 0;
  75038. res[i++] = 0;
  75039. res[i++] = 0;
  75040. for (var t = 8; t < this.padLength; t++)
  75041. res[i++] = 0;
  75042. }
  75043. return res;
  75044. };
  75045. },{"../hash":27}],29:[function(require,module,exports){
  75046. var hmac = exports;
  75047. var hash = require('../hash');
  75048. var utils = hash.utils;
  75049. var assert = utils.assert;
  75050. function Hmac(hash, key, enc) {
  75051. if (!(this instanceof Hmac))
  75052. return new Hmac(hash, key, enc);
  75053. this.Hash = hash;
  75054. this.blockSize = hash.blockSize / 8;
  75055. this.outSize = hash.outSize / 8;
  75056. this.inner = null;
  75057. this.outer = null;
  75058. this._init(utils.toArray(key, enc));
  75059. }
  75060. module.exports = Hmac;
  75061. Hmac.prototype._init = function init(key) {
  75062. // Shorten key, if needed
  75063. if (key.length > this.blockSize)
  75064. key = new this.Hash().update(key).digest();
  75065. assert(key.length <= this.blockSize);
  75066. // Add padding to key
  75067. for (var i = key.length; i < this.blockSize; i++)
  75068. key.push(0);
  75069. for (var i = 0; i < key.length; i++)
  75070. key[i] ^= 0x36;
  75071. this.inner = new this.Hash().update(key);
  75072. // 0x36 ^ 0x5c = 0x6a
  75073. for (var i = 0; i < key.length; i++)
  75074. key[i] ^= 0x6a;
  75075. this.outer = new this.Hash().update(key);
  75076. };
  75077. Hmac.prototype.update = function update(msg, enc) {
  75078. this.inner.update(msg, enc);
  75079. return this;
  75080. };
  75081. Hmac.prototype.digest = function digest(enc) {
  75082. this.outer.update(this.inner.digest());
  75083. return this.outer.digest(enc);
  75084. };
  75085. },{"../hash":27}],30:[function(require,module,exports){
  75086. var hash = require('../hash');
  75087. var utils = hash.utils;
  75088. var rotl32 = utils.rotl32;
  75089. var sum32 = utils.sum32;
  75090. var sum32_3 = utils.sum32_3;
  75091. var sum32_4 = utils.sum32_4;
  75092. var BlockHash = hash.common.BlockHash;
  75093. function RIPEMD160() {
  75094. if (!(this instanceof RIPEMD160))
  75095. return new RIPEMD160();
  75096. BlockHash.call(this);
  75097. this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ];
  75098. this.endian = 'little';
  75099. }
  75100. utils.inherits(RIPEMD160, BlockHash);
  75101. exports.ripemd160 = RIPEMD160;
  75102. RIPEMD160.blockSize = 512;
  75103. RIPEMD160.outSize = 160;
  75104. RIPEMD160.hmacStrength = 192;
  75105. RIPEMD160.padLength = 64;
  75106. RIPEMD160.prototype._update = function update(msg, start) {
  75107. var A = this.h[0];
  75108. var B = this.h[1];
  75109. var C = this.h[2];
  75110. var D = this.h[3];
  75111. var E = this.h[4];
  75112. var Ah = A;
  75113. var Bh = B;
  75114. var Ch = C;
  75115. var Dh = D;
  75116. var Eh = E;
  75117. for (var j = 0; j < 80; j++) {
  75118. var T = sum32(
  75119. rotl32(
  75120. sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)),
  75121. s[j]),
  75122. E);
  75123. A = E;
  75124. E = D;
  75125. D = rotl32(C, 10);
  75126. C = B;
  75127. B = T;
  75128. T = sum32(
  75129. rotl32(
  75130. sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)),
  75131. sh[j]),
  75132. Eh);
  75133. Ah = Eh;
  75134. Eh = Dh;
  75135. Dh = rotl32(Ch, 10);
  75136. Ch = Bh;
  75137. Bh = T;
  75138. }
  75139. T = sum32_3(this.h[1], C, Dh);
  75140. this.h[1] = sum32_3(this.h[2], D, Eh);
  75141. this.h[2] = sum32_3(this.h[3], E, Ah);
  75142. this.h[3] = sum32_3(this.h[4], A, Bh);
  75143. this.h[4] = sum32_3(this.h[0], B, Ch);
  75144. this.h[0] = T;
  75145. };
  75146. RIPEMD160.prototype._digest = function digest(enc) {
  75147. if (enc === 'hex')
  75148. return utils.toHex32(this.h, 'little');
  75149. else
  75150. return utils.split32(this.h, 'little');
  75151. };
  75152. function f(j, x, y, z) {
  75153. if (j <= 15)
  75154. return x ^ y ^ z;
  75155. else if (j <= 31)
  75156. return (x & y) | ((~x) & z);
  75157. else if (j <= 47)
  75158. return (x | (~y)) ^ z;
  75159. else if (j <= 63)
  75160. return (x & z) | (y & (~z));
  75161. else
  75162. return x ^ (y | (~z));
  75163. }
  75164. function K(j) {
  75165. if (j <= 15)
  75166. return 0x00000000;
  75167. else if (j <= 31)
  75168. return 0x5a827999;
  75169. else if (j <= 47)
  75170. return 0x6ed9eba1;
  75171. else if (j <= 63)
  75172. return 0x8f1bbcdc;
  75173. else
  75174. return 0xa953fd4e;
  75175. }
  75176. function Kh(j) {
  75177. if (j <= 15)
  75178. return 0x50a28be6;
  75179. else if (j <= 31)
  75180. return 0x5c4dd124;
  75181. else if (j <= 47)
  75182. return 0x6d703ef3;
  75183. else if (j <= 63)
  75184. return 0x7a6d76e9;
  75185. else
  75186. return 0x00000000;
  75187. }
  75188. var r = [
  75189. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
  75190. 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
  75191. 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
  75192. 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
  75193. 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
  75194. ];
  75195. var rh = [
  75196. 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
  75197. 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
  75198. 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
  75199. 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
  75200. 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
  75201. ];
  75202. var s = [
  75203. 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
  75204. 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
  75205. 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
  75206. 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
  75207. 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
  75208. ];
  75209. var sh = [
  75210. 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
  75211. 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
  75212. 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
  75213. 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
  75214. 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
  75215. ];
  75216. },{"../hash":27}],31:[function(require,module,exports){
  75217. var hash = require('../hash');
  75218. var utils = hash.utils;
  75219. var assert = utils.assert;
  75220. var rotr32 = utils.rotr32;
  75221. var rotl32 = utils.rotl32;
  75222. var sum32 = utils.sum32;
  75223. var sum32_4 = utils.sum32_4;
  75224. var sum32_5 = utils.sum32_5;
  75225. var rotr64_hi = utils.rotr64_hi;
  75226. var rotr64_lo = utils.rotr64_lo;
  75227. var shr64_hi = utils.shr64_hi;
  75228. var shr64_lo = utils.shr64_lo;
  75229. var sum64 = utils.sum64;
  75230. var sum64_hi = utils.sum64_hi;
  75231. var sum64_lo = utils.sum64_lo;
  75232. var sum64_4_hi = utils.sum64_4_hi;
  75233. var sum64_4_lo = utils.sum64_4_lo;
  75234. var sum64_5_hi = utils.sum64_5_hi;
  75235. var sum64_5_lo = utils.sum64_5_lo;
  75236. var BlockHash = hash.common.BlockHash;
  75237. var sha256_K = [
  75238. 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
  75239. 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
  75240. 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
  75241. 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
  75242. 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
  75243. 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
  75244. 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
  75245. 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
  75246. 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
  75247. 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
  75248. 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
  75249. 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
  75250. 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
  75251. 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
  75252. 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
  75253. 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
  75254. ];
  75255. var sha512_K = [
  75256. 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
  75257. 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
  75258. 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
  75259. 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
  75260. 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
  75261. 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
  75262. 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
  75263. 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
  75264. 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
  75265. 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
  75266. 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
  75267. 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
  75268. 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
  75269. 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
  75270. 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
  75271. 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
  75272. 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
  75273. 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
  75274. 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
  75275. 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
  75276. 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
  75277. 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
  75278. 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
  75279. 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
  75280. 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
  75281. 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
  75282. 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
  75283. 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
  75284. 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
  75285. 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
  75286. 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
  75287. 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
  75288. 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
  75289. 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
  75290. 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
  75291. 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
  75292. 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
  75293. 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
  75294. 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
  75295. 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
  75296. ];
  75297. var sha1_K = [
  75298. 0x5A827999, 0x6ED9EBA1,
  75299. 0x8F1BBCDC, 0xCA62C1D6
  75300. ];
  75301. function SHA256() {
  75302. if (!(this instanceof SHA256))
  75303. return new SHA256();
  75304. BlockHash.call(this);
  75305. this.h = [ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
  75306. 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 ];
  75307. this.k = sha256_K;
  75308. this.W = new Array(64);
  75309. }
  75310. utils.inherits(SHA256, BlockHash);
  75311. exports.sha256 = SHA256;
  75312. SHA256.blockSize = 512;
  75313. SHA256.outSize = 256;
  75314. SHA256.hmacStrength = 192;
  75315. SHA256.padLength = 64;
  75316. SHA256.prototype._update = function _update(msg, start) {
  75317. var W = this.W;
  75318. for (var i = 0; i < 16; i++)
  75319. W[i] = msg[start + i];
  75320. for (; i < W.length; i++)
  75321. W[i] = sum32_4(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]);
  75322. var a = this.h[0];
  75323. var b = this.h[1];
  75324. var c = this.h[2];
  75325. var d = this.h[3];
  75326. var e = this.h[4];
  75327. var f = this.h[5];
  75328. var g = this.h[6];
  75329. var h = this.h[7];
  75330. assert(this.k.length === W.length);
  75331. for (var i = 0; i < W.length; i++) {
  75332. var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]);
  75333. var T2 = sum32(s0_256(a), maj32(a, b, c));
  75334. h = g;
  75335. g = f;
  75336. f = e;
  75337. e = sum32(d, T1);
  75338. d = c;
  75339. c = b;
  75340. b = a;
  75341. a = sum32(T1, T2);
  75342. }
  75343. this.h[0] = sum32(this.h[0], a);
  75344. this.h[1] = sum32(this.h[1], b);
  75345. this.h[2] = sum32(this.h[2], c);
  75346. this.h[3] = sum32(this.h[3], d);
  75347. this.h[4] = sum32(this.h[4], e);
  75348. this.h[5] = sum32(this.h[5], f);
  75349. this.h[6] = sum32(this.h[6], g);
  75350. this.h[7] = sum32(this.h[7], h);
  75351. };
  75352. SHA256.prototype._digest = function digest(enc) {
  75353. if (enc === 'hex')
  75354. return utils.toHex32(this.h, 'big');
  75355. else
  75356. return utils.split32(this.h, 'big');
  75357. };
  75358. function SHA224() {
  75359. if (!(this instanceof SHA224))
  75360. return new SHA224();
  75361. SHA256.call(this);
  75362. this.h = [ 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
  75363. 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ];
  75364. }
  75365. utils.inherits(SHA224, SHA256);
  75366. exports.sha224 = SHA224;
  75367. SHA224.blockSize = 512;
  75368. SHA224.outSize = 224;
  75369. SHA224.hmacStrength = 192;
  75370. SHA224.padLength = 64;
  75371. SHA224.prototype._digest = function digest(enc) {
  75372. // Just truncate output
  75373. if (enc === 'hex')
  75374. return utils.toHex32(this.h.slice(0, 7), 'big');
  75375. else
  75376. return utils.split32(this.h.slice(0, 7), 'big');
  75377. };
  75378. function SHA512() {
  75379. if (!(this instanceof SHA512))
  75380. return new SHA512();
  75381. BlockHash.call(this);
  75382. this.h = [ 0x6a09e667, 0xf3bcc908,
  75383. 0xbb67ae85, 0x84caa73b,
  75384. 0x3c6ef372, 0xfe94f82b,
  75385. 0xa54ff53a, 0x5f1d36f1,
  75386. 0x510e527f, 0xade682d1,
  75387. 0x9b05688c, 0x2b3e6c1f,
  75388. 0x1f83d9ab, 0xfb41bd6b,
  75389. 0x5be0cd19, 0x137e2179 ];
  75390. this.k = sha512_K;
  75391. this.W = new Array(160);
  75392. }
  75393. utils.inherits(SHA512, BlockHash);
  75394. exports.sha512 = SHA512;
  75395. SHA512.blockSize = 1024;
  75396. SHA512.outSize = 512;
  75397. SHA512.hmacStrength = 192;
  75398. SHA512.padLength = 128;
  75399. SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) {
  75400. var W = this.W;
  75401. // 32 x 32bit words
  75402. for (var i = 0; i < 32; i++)
  75403. W[i] = msg[start + i];
  75404. for (; i < W.length; i += 2) {
  75405. var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 2
  75406. var c0_lo = g1_512_lo(W[i - 4], W[i - 3]);
  75407. var c1_hi = W[i - 14]; // i - 7
  75408. var c1_lo = W[i - 13];
  75409. var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 15
  75410. var c2_lo = g0_512_lo(W[i - 30], W[i - 29]);
  75411. var c3_hi = W[i - 32]; // i - 16
  75412. var c3_lo = W[i - 31];
  75413. W[i] = sum64_4_hi(c0_hi, c0_lo,
  75414. c1_hi, c1_lo,
  75415. c2_hi, c2_lo,
  75416. c3_hi, c3_lo);
  75417. W[i + 1] = sum64_4_lo(c0_hi, c0_lo,
  75418. c1_hi, c1_lo,
  75419. c2_hi, c2_lo,
  75420. c3_hi, c3_lo);
  75421. }
  75422. };
  75423. SHA512.prototype._update = function _update(msg, start) {
  75424. this._prepareBlock(msg, start);
  75425. var W = this.W;
  75426. var ah = this.h[0];
  75427. var al = this.h[1];
  75428. var bh = this.h[2];
  75429. var bl = this.h[3];
  75430. var ch = this.h[4];
  75431. var cl = this.h[5];
  75432. var dh = this.h[6];
  75433. var dl = this.h[7];
  75434. var eh = this.h[8];
  75435. var el = this.h[9];
  75436. var fh = this.h[10];
  75437. var fl = this.h[11];
  75438. var gh = this.h[12];
  75439. var gl = this.h[13];
  75440. var hh = this.h[14];
  75441. var hl = this.h[15];
  75442. assert(this.k.length === W.length);
  75443. for (var i = 0; i < W.length; i += 2) {
  75444. var c0_hi = hh;
  75445. var c0_lo = hl;
  75446. var c1_hi = s1_512_hi(eh, el);
  75447. var c1_lo = s1_512_lo(eh, el);
  75448. var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl);
  75449. var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl);
  75450. var c3_hi = this.k[i];
  75451. var c3_lo = this.k[i + 1];
  75452. var c4_hi = W[i];
  75453. var c4_lo = W[i + 1];
  75454. var T1_hi = sum64_5_hi(c0_hi, c0_lo,
  75455. c1_hi, c1_lo,
  75456. c2_hi, c2_lo,
  75457. c3_hi, c3_lo,
  75458. c4_hi, c4_lo);
  75459. var T1_lo = sum64_5_lo(c0_hi, c0_lo,
  75460. c1_hi, c1_lo,
  75461. c2_hi, c2_lo,
  75462. c3_hi, c3_lo,
  75463. c4_hi, c4_lo);
  75464. var c0_hi = s0_512_hi(ah, al);
  75465. var c0_lo = s0_512_lo(ah, al);
  75466. var c1_hi = maj64_hi(ah, al, bh, bl, ch, cl);
  75467. var c1_lo = maj64_lo(ah, al, bh, bl, ch, cl);
  75468. var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo);
  75469. var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo);
  75470. hh = gh;
  75471. hl = gl;
  75472. gh = fh;
  75473. gl = fl;
  75474. fh = eh;
  75475. fl = el;
  75476. eh = sum64_hi(dh, dl, T1_hi, T1_lo);
  75477. el = sum64_lo(dl, dl, T1_hi, T1_lo);
  75478. dh = ch;
  75479. dl = cl;
  75480. ch = bh;
  75481. cl = bl;
  75482. bh = ah;
  75483. bl = al;
  75484. ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo);
  75485. al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo);
  75486. }
  75487. sum64(this.h, 0, ah, al);
  75488. sum64(this.h, 2, bh, bl);
  75489. sum64(this.h, 4, ch, cl);
  75490. sum64(this.h, 6, dh, dl);
  75491. sum64(this.h, 8, eh, el);
  75492. sum64(this.h, 10, fh, fl);
  75493. sum64(this.h, 12, gh, gl);
  75494. sum64(this.h, 14, hh, hl);
  75495. };
  75496. SHA512.prototype._digest = function digest(enc) {
  75497. if (enc === 'hex')
  75498. return utils.toHex32(this.h, 'big');
  75499. else
  75500. return utils.split32(this.h, 'big');
  75501. };
  75502. function SHA384() {
  75503. if (!(this instanceof SHA384))
  75504. return new SHA384();
  75505. SHA512.call(this);
  75506. this.h = [ 0xcbbb9d5d, 0xc1059ed8,
  75507. 0x629a292a, 0x367cd507,
  75508. 0x9159015a, 0x3070dd17,
  75509. 0x152fecd8, 0xf70e5939,
  75510. 0x67332667, 0xffc00b31,
  75511. 0x8eb44a87, 0x68581511,
  75512. 0xdb0c2e0d, 0x64f98fa7,
  75513. 0x47b5481d, 0xbefa4fa4 ];
  75514. }
  75515. utils.inherits(SHA384, SHA512);
  75516. exports.sha384 = SHA384;
  75517. SHA384.blockSize = 1024;
  75518. SHA384.outSize = 384;
  75519. SHA384.hmacStrength = 192;
  75520. SHA384.padLength = 128;
  75521. SHA384.prototype._digest = function digest(enc) {
  75522. if (enc === 'hex')
  75523. return utils.toHex32(this.h.slice(0, 12), 'big');
  75524. else
  75525. return utils.split32(this.h.slice(0, 12), 'big');
  75526. };
  75527. function SHA1() {
  75528. if (!(this instanceof SHA1))
  75529. return new SHA1();
  75530. BlockHash.call(this);
  75531. this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe,
  75532. 0x10325476, 0xc3d2e1f0 ];
  75533. this.W = new Array(80);
  75534. }
  75535. utils.inherits(SHA1, BlockHash);
  75536. exports.sha1 = SHA1;
  75537. SHA1.blockSize = 512;
  75538. SHA1.outSize = 160;
  75539. SHA1.hmacStrength = 80;
  75540. SHA1.padLength = 64;
  75541. SHA1.prototype._update = function _update(msg, start) {
  75542. var W = this.W;
  75543. for (var i = 0; i < 16; i++)
  75544. W[i] = msg[start + i];
  75545. for(; i < W.length; i++)
  75546. W[i] = rotl32(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);
  75547. var a = this.h[0];
  75548. var b = this.h[1];
  75549. var c = this.h[2];
  75550. var d = this.h[3];
  75551. var e = this.h[4];
  75552. for (var i = 0; i < W.length; i++) {
  75553. var s = ~~(i / 20);
  75554. var t = sum32_5(rotl32(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]);
  75555. e = d;
  75556. d = c;
  75557. c = rotl32(b, 30);
  75558. b = a;
  75559. a = t;
  75560. }
  75561. this.h[0] = sum32(this.h[0], a);
  75562. this.h[1] = sum32(this.h[1], b);
  75563. this.h[2] = sum32(this.h[2], c);
  75564. this.h[3] = sum32(this.h[3], d);
  75565. this.h[4] = sum32(this.h[4], e);
  75566. };
  75567. SHA1.prototype._digest = function digest(enc) {
  75568. if (enc === 'hex')
  75569. return utils.toHex32(this.h, 'big');
  75570. else
  75571. return utils.split32(this.h, 'big');
  75572. };
  75573. function ch32(x, y, z) {
  75574. return (x & y) ^ ((~x) & z);
  75575. }
  75576. function maj32(x, y, z) {
  75577. return (x & y) ^ (x & z) ^ (y & z);
  75578. }
  75579. function p32(x, y, z) {
  75580. return x ^ y ^ z;
  75581. }
  75582. function s0_256(x) {
  75583. return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
  75584. }
  75585. function s1_256(x) {
  75586. return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);
  75587. }
  75588. function g0_256(x) {
  75589. return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3);
  75590. }
  75591. function g1_256(x) {
  75592. return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10);
  75593. }
  75594. function ft_1(s, x, y, z) {
  75595. if (s === 0)
  75596. return ch32(x, y, z);
  75597. if (s === 1 || s === 3)
  75598. return p32(x, y, z);
  75599. if (s === 2)
  75600. return maj32(x, y, z);
  75601. }
  75602. function ch64_hi(xh, xl, yh, yl, zh, zl) {
  75603. var r = (xh & yh) ^ ((~xh) & zh);
  75604. if (r < 0)
  75605. r += 0x100000000;
  75606. return r;
  75607. }
  75608. function ch64_lo(xh, xl, yh, yl, zh, zl) {
  75609. var r = (xl & yl) ^ ((~xl) & zl);
  75610. if (r < 0)
  75611. r += 0x100000000;
  75612. return r;
  75613. }
  75614. function maj64_hi(xh, xl, yh, yl, zh, zl) {
  75615. var r = (xh & yh) ^ (xh & zh) ^ (yh & zh);
  75616. if (r < 0)
  75617. r += 0x100000000;
  75618. return r;
  75619. }
  75620. function maj64_lo(xh, xl, yh, yl, zh, zl) {
  75621. var r = (xl & yl) ^ (xl & zl) ^ (yl & zl);
  75622. if (r < 0)
  75623. r += 0x100000000;
  75624. return r;
  75625. }
  75626. function s0_512_hi(xh, xl) {
  75627. var c0_hi = rotr64_hi(xh, xl, 28);
  75628. var c1_hi = rotr64_hi(xl, xh, 2); // 34
  75629. var c2_hi = rotr64_hi(xl, xh, 7); // 39
  75630. var r = c0_hi ^ c1_hi ^ c2_hi;
  75631. if (r < 0)
  75632. r += 0x100000000;
  75633. return r;
  75634. }
  75635. function s0_512_lo(xh, xl) {
  75636. var c0_lo = rotr64_lo(xh, xl, 28);
  75637. var c1_lo = rotr64_lo(xl, xh, 2); // 34
  75638. var c2_lo = rotr64_lo(xl, xh, 7); // 39
  75639. var r = c0_lo ^ c1_lo ^ c2_lo;
  75640. if (r < 0)
  75641. r += 0x100000000;
  75642. return r;
  75643. }
  75644. function s1_512_hi(xh, xl) {
  75645. var c0_hi = rotr64_hi(xh, xl, 14);
  75646. var c1_hi = rotr64_hi(xh, xl, 18);
  75647. var c2_hi = rotr64_hi(xl, xh, 9); // 41
  75648. var r = c0_hi ^ c1_hi ^ c2_hi;
  75649. if (r < 0)
  75650. r += 0x100000000;
  75651. return r;
  75652. }
  75653. function s1_512_lo(xh, xl) {
  75654. var c0_lo = rotr64_lo(xh, xl, 14);
  75655. var c1_lo = rotr64_lo(xh, xl, 18);
  75656. var c2_lo = rotr64_lo(xl, xh, 9); // 41
  75657. var r = c0_lo ^ c1_lo ^ c2_lo;
  75658. if (r < 0)
  75659. r += 0x100000000;
  75660. return r;
  75661. }
  75662. function g0_512_hi(xh, xl) {
  75663. var c0_hi = rotr64_hi(xh, xl, 1);
  75664. var c1_hi = rotr64_hi(xh, xl, 8);
  75665. var c2_hi = shr64_hi(xh, xl, 7);
  75666. var r = c0_hi ^ c1_hi ^ c2_hi;
  75667. if (r < 0)
  75668. r += 0x100000000;
  75669. return r;
  75670. }
  75671. function g0_512_lo(xh, xl) {
  75672. var c0_lo = rotr64_lo(xh, xl, 1);
  75673. var c1_lo = rotr64_lo(xh, xl, 8);
  75674. var c2_lo = shr64_lo(xh, xl, 7);
  75675. var r = c0_lo ^ c1_lo ^ c2_lo;
  75676. if (r < 0)
  75677. r += 0x100000000;
  75678. return r;
  75679. }
  75680. function g1_512_hi(xh, xl) {
  75681. var c0_hi = rotr64_hi(xh, xl, 19);
  75682. var c1_hi = rotr64_hi(xl, xh, 29); // 61
  75683. var c2_hi = shr64_hi(xh, xl, 6);
  75684. var r = c0_hi ^ c1_hi ^ c2_hi;
  75685. if (r < 0)
  75686. r += 0x100000000;
  75687. return r;
  75688. }
  75689. function g1_512_lo(xh, xl) {
  75690. var c0_lo = rotr64_lo(xh, xl, 19);
  75691. var c1_lo = rotr64_lo(xl, xh, 29); // 61
  75692. var c2_lo = shr64_lo(xh, xl, 6);
  75693. var r = c0_lo ^ c1_lo ^ c2_lo;
  75694. if (r < 0)
  75695. r += 0x100000000;
  75696. return r;
  75697. }
  75698. },{"../hash":27}],32:[function(require,module,exports){
  75699. var utils = exports;
  75700. var inherits = require('inherits');
  75701. function toArray(msg, enc) {
  75702. if (Array.isArray(msg))
  75703. return msg.slice();
  75704. if (!msg)
  75705. return [];
  75706. var res = [];
  75707. if (typeof msg === 'string') {
  75708. if (!enc) {
  75709. for (var i = 0; i < msg.length; i++) {
  75710. var c = msg.charCodeAt(i);
  75711. var hi = c >> 8;
  75712. var lo = c & 0xff;
  75713. if (hi)
  75714. res.push(hi, lo);
  75715. else
  75716. res.push(lo);
  75717. }
  75718. } else if (enc === 'hex') {
  75719. msg = msg.replace(/[^a-z0-9]+/ig, '');
  75720. if (msg.length % 2 !== 0)
  75721. msg = '0' + msg;
  75722. for (var i = 0; i < msg.length; i += 2)
  75723. res.push(parseInt(msg[i] + msg[i + 1], 16));
  75724. }
  75725. } else {
  75726. for (var i = 0; i < msg.length; i++)
  75727. res[i] = msg[i] | 0;
  75728. }
  75729. return res;
  75730. }
  75731. utils.toArray = toArray;
  75732. function toHex(msg) {
  75733. var res = '';
  75734. for (var i = 0; i < msg.length; i++)
  75735. res += zero2(msg[i].toString(16));
  75736. return res;
  75737. }
  75738. utils.toHex = toHex;
  75739. function htonl(w) {
  75740. var res = (w >>> 24) |
  75741. ((w >>> 8) & 0xff00) |
  75742. ((w << 8) & 0xff0000) |
  75743. ((w & 0xff) << 24);
  75744. return res >>> 0;
  75745. }
  75746. utils.htonl = htonl;
  75747. function toHex32(msg, endian) {
  75748. var res = '';
  75749. for (var i = 0; i < msg.length; i++) {
  75750. var w = msg[i];
  75751. if (endian === 'little')
  75752. w = htonl(w);
  75753. res += zero8(w.toString(16));
  75754. }
  75755. return res;
  75756. }
  75757. utils.toHex32 = toHex32;
  75758. function zero2(word) {
  75759. if (word.length === 1)
  75760. return '0' + word;
  75761. else
  75762. return word;
  75763. }
  75764. utils.zero2 = zero2;
  75765. function zero8(word) {
  75766. if (word.length === 7)
  75767. return '0' + word;
  75768. else if (word.length === 6)
  75769. return '00' + word;
  75770. else if (word.length === 5)
  75771. return '000' + word;
  75772. else if (word.length === 4)
  75773. return '0000' + word;
  75774. else if (word.length === 3)
  75775. return '00000' + word;
  75776. else if (word.length === 2)
  75777. return '000000' + word;
  75778. else if (word.length === 1)
  75779. return '0000000' + word;
  75780. else
  75781. return word;
  75782. }
  75783. utils.zero8 = zero8;
  75784. function join32(msg, start, end, endian) {
  75785. var len = end - start;
  75786. assert(len % 4 === 0);
  75787. var res = new Array(len / 4);
  75788. for (var i = 0, k = start; i < res.length; i++, k += 4) {
  75789. var w;
  75790. if (endian === 'big')
  75791. w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];
  75792. else
  75793. w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];
  75794. res[i] = w >>> 0;
  75795. }
  75796. return res;
  75797. }
  75798. utils.join32 = join32;
  75799. function split32(msg, endian) {
  75800. var res = new Array(msg.length * 4);
  75801. for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
  75802. var m = msg[i];
  75803. if (endian === 'big') {
  75804. res[k] = m >>> 24;
  75805. res[k + 1] = (m >>> 16) & 0xff;
  75806. res[k + 2] = (m >>> 8) & 0xff;
  75807. res[k + 3] = m & 0xff;
  75808. } else {
  75809. res[k + 3] = m >>> 24;
  75810. res[k + 2] = (m >>> 16) & 0xff;
  75811. res[k + 1] = (m >>> 8) & 0xff;
  75812. res[k] = m & 0xff;
  75813. }
  75814. }
  75815. return res;
  75816. }
  75817. utils.split32 = split32;
  75818. function rotr32(w, b) {
  75819. return (w >>> b) | (w << (32 - b));
  75820. }
  75821. utils.rotr32 = rotr32;
  75822. function rotl32(w, b) {
  75823. return (w << b) | (w >>> (32 - b));
  75824. }
  75825. utils.rotl32 = rotl32;
  75826. function sum32(a, b) {
  75827. return (a + b) >>> 0;
  75828. }
  75829. utils.sum32 = sum32;
  75830. function sum32_3(a, b, c) {
  75831. return (a + b + c) >>> 0;
  75832. }
  75833. utils.sum32_3 = sum32_3;
  75834. function sum32_4(a, b, c, d) {
  75835. return (a + b + c + d) >>> 0;
  75836. }
  75837. utils.sum32_4 = sum32_4;
  75838. function sum32_5(a, b, c, d, e) {
  75839. return (a + b + c + d + e) >>> 0;
  75840. }
  75841. utils.sum32_5 = sum32_5;
  75842. function assert(cond, msg) {
  75843. if (!cond)
  75844. throw new Error(msg || 'Assertion failed');
  75845. }
  75846. utils.assert = assert;
  75847. utils.inherits = inherits;
  75848. function sum64(buf, pos, ah, al) {
  75849. var bh = buf[pos];
  75850. var bl = buf[pos + 1];
  75851. var lo = (al + bl) >>> 0;
  75852. var hi = (lo < al ? 1 : 0) + ah + bh;
  75853. buf[pos] = hi >>> 0;
  75854. buf[pos + 1] = lo;
  75855. }
  75856. exports.sum64 = sum64;
  75857. function sum64_hi(ah, al, bh, bl) {
  75858. var lo = (al + bl) >>> 0;
  75859. var hi = (lo < al ? 1 : 0) + ah + bh;
  75860. return hi >>> 0;
  75861. };
  75862. exports.sum64_hi = sum64_hi;
  75863. function sum64_lo(ah, al, bh, bl) {
  75864. var lo = al + bl;
  75865. return lo >>> 0;
  75866. };
  75867. exports.sum64_lo = sum64_lo;
  75868. function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) {
  75869. var carry = 0;
  75870. var lo = al;
  75871. lo = (lo + bl) >>> 0;
  75872. carry += lo < al ? 1 : 0;
  75873. lo = (lo + cl) >>> 0;
  75874. carry += lo < cl ? 1 : 0;
  75875. lo = (lo + dl) >>> 0;
  75876. carry += lo < dl ? 1 : 0;
  75877. var hi = ah + bh + ch + dh + carry;
  75878. return hi >>> 0;
  75879. };
  75880. exports.sum64_4_hi = sum64_4_hi;
  75881. function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) {
  75882. var lo = al + bl + cl + dl;
  75883. return lo >>> 0;
  75884. };
  75885. exports.sum64_4_lo = sum64_4_lo;
  75886. function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
  75887. var carry = 0;
  75888. var lo = al;
  75889. lo = (lo + bl) >>> 0;
  75890. carry += lo < al ? 1 : 0;
  75891. lo = (lo + cl) >>> 0;
  75892. carry += lo < cl ? 1 : 0;
  75893. lo = (lo + dl) >>> 0;
  75894. carry += lo < dl ? 1 : 0;
  75895. lo = (lo + el) >>> 0;
  75896. carry += lo < el ? 1 : 0;
  75897. var hi = ah + bh + ch + dh + eh + carry;
  75898. return hi >>> 0;
  75899. };
  75900. exports.sum64_5_hi = sum64_5_hi;
  75901. function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
  75902. var lo = al + bl + cl + dl + el;
  75903. return lo >>> 0;
  75904. };
  75905. exports.sum64_5_lo = sum64_5_lo;
  75906. function rotr64_hi(ah, al, num) {
  75907. var r = (al << (32 - num)) | (ah >>> num);
  75908. return r >>> 0;
  75909. };
  75910. exports.rotr64_hi = rotr64_hi;
  75911. function rotr64_lo(ah, al, num) {
  75912. var r = (ah << (32 - num)) | (al >>> num);
  75913. return r >>> 0;
  75914. };
  75915. exports.rotr64_lo = rotr64_lo;
  75916. function shr64_hi(ah, al, num) {
  75917. return ah >>> num;
  75918. };
  75919. exports.shr64_hi = shr64_hi;
  75920. function shr64_lo(ah, al, num) {
  75921. var r = (ah << (32 - num)) | (al >>> num);
  75922. return r >>> 0;
  75923. };
  75924. exports.shr64_lo = shr64_lo;
  75925. },{"inherits":34}],33:[function(require,module,exports){
  75926. 'use strict';
  75927. var hash = require('hash.js');
  75928. var utils = require('minimalistic-crypto-utils');
  75929. var assert = require('minimalistic-assert');
  75930. function HmacDRBG(options) {
  75931. if (!(this instanceof HmacDRBG))
  75932. return new HmacDRBG(options);
  75933. this.hash = options.hash;
  75934. this.predResist = !!options.predResist;
  75935. this.outLen = this.hash.outSize;
  75936. this.minEntropy = options.minEntropy || this.hash.hmacStrength;
  75937. this.reseed = null;
  75938. this.reseedInterval = null;
  75939. this.K = null;
  75940. this.V = null;
  75941. var entropy = utils.toArray(options.entropy, options.entropyEnc || 'hex');
  75942. var nonce = utils.toArray(options.nonce, options.nonceEnc || 'hex');
  75943. var pers = utils.toArray(options.pers, options.persEnc || 'hex');
  75944. assert(entropy.length >= (this.minEntropy / 8),
  75945. 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
  75946. this._init(entropy, nonce, pers);
  75947. }
  75948. module.exports = HmacDRBG;
  75949. HmacDRBG.prototype._init = function init(entropy, nonce, pers) {
  75950. var seed = entropy.concat(nonce).concat(pers);
  75951. this.K = new Array(this.outLen / 8);
  75952. this.V = new Array(this.outLen / 8);
  75953. for (var i = 0; i < this.V.length; i++) {
  75954. this.K[i] = 0x00;
  75955. this.V[i] = 0x01;
  75956. }
  75957. this._update(seed);
  75958. this.reseed = 1;
  75959. this.reseedInterval = 0x1000000000000; // 2^48
  75960. };
  75961. HmacDRBG.prototype._hmac = function hmac() {
  75962. return new hash.hmac(this.hash, this.K);
  75963. };
  75964. HmacDRBG.prototype._update = function update(seed) {
  75965. var kmac = this._hmac()
  75966. .update(this.V)
  75967. .update([ 0x00 ]);
  75968. if (seed)
  75969. kmac = kmac.update(seed);
  75970. this.K = kmac.digest();
  75971. this.V = this._hmac().update(this.V).digest();
  75972. if (!seed)
  75973. return;
  75974. this.K = this._hmac()
  75975. .update(this.V)
  75976. .update([ 0x01 ])
  75977. .update(seed)
  75978. .digest();
  75979. this.V = this._hmac().update(this.V).digest();
  75980. };
  75981. HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc) {
  75982. // Optional entropy enc
  75983. if (typeof entropyEnc !== 'string') {
  75984. addEnc = add;
  75985. add = entropyEnc;
  75986. entropyEnc = null;
  75987. }
  75988. entropy = utils.toArray(entropy, entropyEnc);
  75989. add = utils.toArray(add, addEnc);
  75990. assert(entropy.length >= (this.minEntropy / 8),
  75991. 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits');
  75992. this._update(entropy.concat(add || []));
  75993. this.reseed = 1;
  75994. };
  75995. HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) {
  75996. if (this.reseed > this.reseedInterval)
  75997. throw new Error('Reseed is required');
  75998. // Optional encoding
  75999. if (typeof enc !== 'string') {
  76000. addEnc = add;
  76001. add = enc;
  76002. enc = null;
  76003. }
  76004. // Optional additional data
  76005. if (add) {
  76006. add = utils.toArray(add, addEnc || 'hex');
  76007. this._update(add);
  76008. }
  76009. var temp = [];
  76010. while (temp.length < len) {
  76011. this.V = this._hmac().update(this.V).digest();
  76012. temp = temp.concat(this.V);
  76013. }
  76014. var res = temp.slice(0, len);
  76015. this._update(add);
  76016. this.reseed++;
  76017. return utils.encode(res, enc);
  76018. };
  76019. },{"hash.js":27,"minimalistic-assert":42,"minimalistic-crypto-utils":43}],34:[function(require,module,exports){
  76020. if (typeof Object.create === 'function') {
  76021. // implementation from standard node.js 'util' module
  76022. module.exports = function inherits(ctor, superCtor) {
  76023. ctor.super_ = superCtor
  76024. ctor.prototype = Object.create(superCtor.prototype, {
  76025. constructor: {
  76026. value: ctor,
  76027. enumerable: false,
  76028. writable: true,
  76029. configurable: true
  76030. }
  76031. });
  76032. };
  76033. } else {
  76034. // old school shim for old browsers
  76035. module.exports = function inherits(ctor, superCtor) {
  76036. ctor.super_ = superCtor
  76037. var TempCtor = function () {}
  76038. TempCtor.prototype = superCtor.prototype
  76039. ctor.prototype = new TempCtor()
  76040. ctor.prototype.constructor = ctor
  76041. }
  76042. }
  76043. },{}],35:[function(require,module,exports){
  76044. /**
  76045. * Returns a `Boolean` on whether or not the a `String` starts with '0x'
  76046. * @param {String} str the string input value
  76047. * @return {Boolean} a boolean if it is or is not hex prefixed
  76048. * @throws if the str input is not a string
  76049. */
  76050. module.exports = function isHexPrefixed(str) {
  76051. if (typeof str !== 'string') {
  76052. throw new Error("[is-hex-prefixed] value must be type 'string', is currently type " + (typeof str) + ", while checking isHexPrefixed.");
  76053. }
  76054. return str.slice(0, 2) === '0x';
  76055. }
  76056. },{}],36:[function(require,module,exports){
  76057. 'use strict'
  76058. module.exports = require('./lib/api')(require('./lib/keccak'))
  76059. },{"./lib/api":37,"./lib/keccak":41}],37:[function(require,module,exports){
  76060. 'use strict'
  76061. var createKeccak = require('./keccak')
  76062. var createShake = require('./shake')
  76063. module.exports = function (KeccakState) {
  76064. var Keccak = createKeccak(KeccakState)
  76065. var Shake = createShake(KeccakState)
  76066. return function (algorithm, options) {
  76067. var hash = typeof algorithm === 'string' ? algorithm.toLowerCase() : algorithm
  76068. switch (hash) {
  76069. case 'keccak224': return new Keccak(1152, 448, null, 224, options)
  76070. case 'keccak256': return new Keccak(1088, 512, null, 256, options)
  76071. case 'keccak384': return new Keccak(832, 768, null, 384, options)
  76072. case 'keccak512': return new Keccak(576, 1024, null, 512, options)
  76073. case 'sha3-224': return new Keccak(1152, 448, 0x06, 224, options)
  76074. case 'sha3-256': return new Keccak(1088, 512, 0x06, 256, options)
  76075. case 'sha3-384': return new Keccak(832, 768, 0x06, 384, options)
  76076. case 'sha3-512': return new Keccak(576, 1024, 0x06, 512, options)
  76077. case 'shake128': return new Shake(1344, 256, 0x1f, options)
  76078. case 'shake256': return new Shake(1088, 512, 0x1f, options)
  76079. default: throw new Error('Invald algorithm: ' + algorithm)
  76080. }
  76081. }
  76082. }
  76083. },{"./keccak":38,"./shake":39}],38:[function(require,module,exports){
  76084. (function (Buffer){
  76085. 'use strict'
  76086. var Transform = require('stream').Transform
  76087. var inherits = require('inherits')
  76088. module.exports = function (KeccakState) {
  76089. function Keccak (rate, capacity, delimitedSuffix, hashBitLength, options) {
  76090. Transform.call(this, options)
  76091. this._rate = rate
  76092. this._capacity = capacity
  76093. this._delimitedSuffix = delimitedSuffix
  76094. this._hashBitLength = hashBitLength
  76095. this._options = options
  76096. this._state = new KeccakState()
  76097. this._state.initialize(rate, capacity)
  76098. this._finalized = false
  76099. }
  76100. inherits(Keccak, Transform)
  76101. Keccak.prototype._transform = function (chunk, encoding, callback) {
  76102. var error = null
  76103. try {
  76104. this.update(chunk, encoding)
  76105. } catch (err) {
  76106. error = err
  76107. }
  76108. callback(error)
  76109. }
  76110. Keccak.prototype._flush = function (callback) {
  76111. var error = null
  76112. try {
  76113. this.push(this.digest())
  76114. } catch (err) {
  76115. error = err
  76116. }
  76117. callback(error)
  76118. }
  76119. Keccak.prototype.update = function (data, encoding) {
  76120. if (!Buffer.isBuffer(data) && typeof data !== 'string') throw new TypeError('Data must be a string or a buffer')
  76121. if (this._finalized) throw new Error('Digest already called')
  76122. if (!Buffer.isBuffer(data)) data = new Buffer(data, encoding)
  76123. this._state.absorb(data)
  76124. return this
  76125. }
  76126. Keccak.prototype.digest = function (encoding) {
  76127. if (this._finalized) throw new Error('Digest already called')
  76128. this._finalized = true
  76129. if (this._delimitedSuffix) this._state.absorbLastFewBits(this._delimitedSuffix)
  76130. var digest = this._state.squeeze(this._hashBitLength / 8)
  76131. if (encoding !== undefined) digest = digest.toString(encoding)
  76132. this._resetState()
  76133. return digest
  76134. }
  76135. // remove result from memory
  76136. Keccak.prototype._resetState = function () {
  76137. this._state.initialize(this._rate, this._capacity)
  76138. return this
  76139. }
  76140. // because sometimes we need hash right now and little later
  76141. Keccak.prototype._clone = function () {
  76142. var clone = new Keccak(this._rate, this._capacity, this._delimitedSuffix, this._hashBitLength, this._options)
  76143. this._state.copy(clone._state)
  76144. clone._finalized = this._finalized
  76145. return clone
  76146. }
  76147. return Keccak
  76148. }
  76149. }).call(this,require("buffer").Buffer)
  76150. },{"buffer":65,"inherits":34,"stream":85}],39:[function(require,module,exports){
  76151. (function (Buffer){
  76152. 'use strict'
  76153. var Transform = require('stream').Transform
  76154. var inherits = require('inherits')
  76155. module.exports = function (KeccakState) {
  76156. function Shake (rate, capacity, delimitedSuffix, options) {
  76157. Transform.call(this, options)
  76158. this._rate = rate
  76159. this._capacity = capacity
  76160. this._delimitedSuffix = delimitedSuffix
  76161. this._options = options
  76162. this._state = new KeccakState()
  76163. this._state.initialize(rate, capacity)
  76164. this._finalized = false
  76165. }
  76166. inherits(Shake, Transform)
  76167. Shake.prototype._transform = function (chunk, encoding, callback) {
  76168. var error = null
  76169. try {
  76170. this.update(chunk, encoding)
  76171. } catch (err) {
  76172. error = err
  76173. }
  76174. callback(error)
  76175. }
  76176. Shake.prototype._flush = function () {}
  76177. Shake.prototype._read = function (size) {
  76178. this.push(this.squeeze(size))
  76179. }
  76180. Shake.prototype.update = function (data, encoding) {
  76181. if (!Buffer.isBuffer(data) && typeof data !== 'string') throw new TypeError('Data must be a string or a buffer')
  76182. if (this._finalized) throw new Error('Squeeze already called')
  76183. if (!Buffer.isBuffer(data)) data = new Buffer(data, encoding)
  76184. this._state.absorb(data)
  76185. return this
  76186. }
  76187. Shake.prototype.squeeze = function (dataByteLength, encoding) {
  76188. if (!this._finalized) {
  76189. this._finalized = true
  76190. this._state.absorbLastFewBits(this._delimitedSuffix)
  76191. }
  76192. var data = this._state.squeeze(dataByteLength)
  76193. if (encoding !== undefined) data = data.toString(encoding)
  76194. return data
  76195. }
  76196. Shake.prototype._resetState = function () {
  76197. this._state.initialize(this._rate, this._capacity)
  76198. return this
  76199. }
  76200. Shake.prototype._clone = function () {
  76201. var clone = new Shake(this._rate, this._capacity, this._delimitedSuffix, this._options)
  76202. this._state.copy(clone._state)
  76203. clone._finalized = this._finalized
  76204. return clone
  76205. }
  76206. return Shake
  76207. }
  76208. }).call(this,require("buffer").Buffer)
  76209. },{"buffer":65,"inherits":34,"stream":85}],40:[function(require,module,exports){
  76210. 'use strict'
  76211. var P1600_ROUND_CONSTANTS = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649, 0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0, 2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, 2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648, 2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648]
  76212. exports.p1600 = function (s) {
  76213. for (var round = 0; round < 24; ++round) {
  76214. // theta
  76215. var lo0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40]
  76216. var hi0 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41]
  76217. var lo1 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42]
  76218. var hi1 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43]
  76219. var lo2 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44]
  76220. var hi2 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45]
  76221. var lo3 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46]
  76222. var hi3 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47]
  76223. var lo4 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48]
  76224. var hi4 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49]
  76225. var lo = lo4 ^ (lo1 << 1 | hi1 >>> 31)
  76226. var hi = hi4 ^ (hi1 << 1 | lo1 >>> 31)
  76227. var t1slo0 = s[0] ^ lo
  76228. var t1shi0 = s[1] ^ hi
  76229. var t1slo5 = s[10] ^ lo
  76230. var t1shi5 = s[11] ^ hi
  76231. var t1slo10 = s[20] ^ lo
  76232. var t1shi10 = s[21] ^ hi
  76233. var t1slo15 = s[30] ^ lo
  76234. var t1shi15 = s[31] ^ hi
  76235. var t1slo20 = s[40] ^ lo
  76236. var t1shi20 = s[41] ^ hi
  76237. lo = lo0 ^ (lo2 << 1 | hi2 >>> 31)
  76238. hi = hi0 ^ (hi2 << 1 | lo2 >>> 31)
  76239. var t1slo1 = s[2] ^ lo
  76240. var t1shi1 = s[3] ^ hi
  76241. var t1slo6 = s[12] ^ lo
  76242. var t1shi6 = s[13] ^ hi
  76243. var t1slo11 = s[22] ^ lo
  76244. var t1shi11 = s[23] ^ hi
  76245. var t1slo16 = s[32] ^ lo
  76246. var t1shi16 = s[33] ^ hi
  76247. var t1slo21 = s[42] ^ lo
  76248. var t1shi21 = s[43] ^ hi
  76249. lo = lo1 ^ (lo3 << 1 | hi3 >>> 31)
  76250. hi = hi1 ^ (hi3 << 1 | lo3 >>> 31)
  76251. var t1slo2 = s[4] ^ lo
  76252. var t1shi2 = s[5] ^ hi
  76253. var t1slo7 = s[14] ^ lo
  76254. var t1shi7 = s[15] ^ hi
  76255. var t1slo12 = s[24] ^ lo
  76256. var t1shi12 = s[25] ^ hi
  76257. var t1slo17 = s[34] ^ lo
  76258. var t1shi17 = s[35] ^ hi
  76259. var t1slo22 = s[44] ^ lo
  76260. var t1shi22 = s[45] ^ hi
  76261. lo = lo2 ^ (lo4 << 1 | hi4 >>> 31)
  76262. hi = hi2 ^ (hi4 << 1 | lo4 >>> 31)
  76263. var t1slo3 = s[6] ^ lo
  76264. var t1shi3 = s[7] ^ hi
  76265. var t1slo8 = s[16] ^ lo
  76266. var t1shi8 = s[17] ^ hi
  76267. var t1slo13 = s[26] ^ lo
  76268. var t1shi13 = s[27] ^ hi
  76269. var t1slo18 = s[36] ^ lo
  76270. var t1shi18 = s[37] ^ hi
  76271. var t1slo23 = s[46] ^ lo
  76272. var t1shi23 = s[47] ^ hi
  76273. lo = lo3 ^ (lo0 << 1 | hi0 >>> 31)
  76274. hi = hi3 ^ (hi0 << 1 | lo0 >>> 31)
  76275. var t1slo4 = s[8] ^ lo
  76276. var t1shi4 = s[9] ^ hi
  76277. var t1slo9 = s[18] ^ lo
  76278. var t1shi9 = s[19] ^ hi
  76279. var t1slo14 = s[28] ^ lo
  76280. var t1shi14 = s[29] ^ hi
  76281. var t1slo19 = s[38] ^ lo
  76282. var t1shi19 = s[39] ^ hi
  76283. var t1slo24 = s[48] ^ lo
  76284. var t1shi24 = s[49] ^ hi
  76285. // rho & pi
  76286. var t2slo0 = t1slo0
  76287. var t2shi0 = t1shi0
  76288. var t2slo16 = (t1shi5 << 4 | t1slo5 >>> 28)
  76289. var t2shi16 = (t1slo5 << 4 | t1shi5 >>> 28)
  76290. var t2slo7 = (t1slo10 << 3 | t1shi10 >>> 29)
  76291. var t2shi7 = (t1shi10 << 3 | t1slo10 >>> 29)
  76292. var t2slo23 = (t1shi15 << 9 | t1slo15 >>> 23)
  76293. var t2shi23 = (t1slo15 << 9 | t1shi15 >>> 23)
  76294. var t2slo14 = (t1slo20 << 18 | t1shi20 >>> 14)
  76295. var t2shi14 = (t1shi20 << 18 | t1slo20 >>> 14)
  76296. var t2slo10 = (t1slo1 << 1 | t1shi1 >>> 31)
  76297. var t2shi10 = (t1shi1 << 1 | t1slo1 >>> 31)
  76298. var t2slo1 = (t1shi6 << 12 | t1slo6 >>> 20)
  76299. var t2shi1 = (t1slo6 << 12 | t1shi6 >>> 20)
  76300. var t2slo17 = (t1slo11 << 10 | t1shi11 >>> 22)
  76301. var t2shi17 = (t1shi11 << 10 | t1slo11 >>> 22)
  76302. var t2slo8 = (t1shi16 << 13 | t1slo16 >>> 19)
  76303. var t2shi8 = (t1slo16 << 13 | t1shi16 >>> 19)
  76304. var t2slo24 = (t1slo21 << 2 | t1shi21 >>> 30)
  76305. var t2shi24 = (t1shi21 << 2 | t1slo21 >>> 30)
  76306. var t2slo20 = (t1shi2 << 30 | t1slo2 >>> 2)
  76307. var t2shi20 = (t1slo2 << 30 | t1shi2 >>> 2)
  76308. var t2slo11 = (t1slo7 << 6 | t1shi7 >>> 26)
  76309. var t2shi11 = (t1shi7 << 6 | t1slo7 >>> 26)
  76310. var t2slo2 = (t1shi12 << 11 | t1slo12 >>> 21)
  76311. var t2shi2 = (t1slo12 << 11 | t1shi12 >>> 21)
  76312. var t2slo18 = (t1slo17 << 15 | t1shi17 >>> 17)
  76313. var t2shi18 = (t1shi17 << 15 | t1slo17 >>> 17)
  76314. var t2slo9 = (t1shi22 << 29 | t1slo22 >>> 3)
  76315. var t2shi9 = (t1slo22 << 29 | t1shi22 >>> 3)
  76316. var t2slo5 = (t1slo3 << 28 | t1shi3 >>> 4)
  76317. var t2shi5 = (t1shi3 << 28 | t1slo3 >>> 4)
  76318. var t2slo21 = (t1shi8 << 23 | t1slo8 >>> 9)
  76319. var t2shi21 = (t1slo8 << 23 | t1shi8 >>> 9)
  76320. var t2slo12 = (t1slo13 << 25 | t1shi13 >>> 7)
  76321. var t2shi12 = (t1shi13 << 25 | t1slo13 >>> 7)
  76322. var t2slo3 = (t1slo18 << 21 | t1shi18 >>> 11)
  76323. var t2shi3 = (t1shi18 << 21 | t1slo18 >>> 11)
  76324. var t2slo19 = (t1shi23 << 24 | t1slo23 >>> 8)
  76325. var t2shi19 = (t1slo23 << 24 | t1shi23 >>> 8)
  76326. var t2slo15 = (t1slo4 << 27 | t1shi4 >>> 5)
  76327. var t2shi15 = (t1shi4 << 27 | t1slo4 >>> 5)
  76328. var t2slo6 = (t1slo9 << 20 | t1shi9 >>> 12)
  76329. var t2shi6 = (t1shi9 << 20 | t1slo9 >>> 12)
  76330. var t2slo22 = (t1shi14 << 7 | t1slo14 >>> 25)
  76331. var t2shi22 = (t1slo14 << 7 | t1shi14 >>> 25)
  76332. var t2slo13 = (t1slo19 << 8 | t1shi19 >>> 24)
  76333. var t2shi13 = (t1shi19 << 8 | t1slo19 >>> 24)
  76334. var t2slo4 = (t1slo24 << 14 | t1shi24 >>> 18)
  76335. var t2shi4 = (t1shi24 << 14 | t1slo24 >>> 18)
  76336. // chi
  76337. s[0] = t2slo0 ^ (~t2slo1 & t2slo2)
  76338. s[1] = t2shi0 ^ (~t2shi1 & t2shi2)
  76339. s[10] = t2slo5 ^ (~t2slo6 & t2slo7)
  76340. s[11] = t2shi5 ^ (~t2shi6 & t2shi7)
  76341. s[20] = t2slo10 ^ (~t2slo11 & t2slo12)
  76342. s[21] = t2shi10 ^ (~t2shi11 & t2shi12)
  76343. s[30] = t2slo15 ^ (~t2slo16 & t2slo17)
  76344. s[31] = t2shi15 ^ (~t2shi16 & t2shi17)
  76345. s[40] = t2slo20 ^ (~t2slo21 & t2slo22)
  76346. s[41] = t2shi20 ^ (~t2shi21 & t2shi22)
  76347. s[2] = t2slo1 ^ (~t2slo2 & t2slo3)
  76348. s[3] = t2shi1 ^ (~t2shi2 & t2shi3)
  76349. s[12] = t2slo6 ^ (~t2slo7 & t2slo8)
  76350. s[13] = t2shi6 ^ (~t2shi7 & t2shi8)
  76351. s[22] = t2slo11 ^ (~t2slo12 & t2slo13)
  76352. s[23] = t2shi11 ^ (~t2shi12 & t2shi13)
  76353. s[32] = t2slo16 ^ (~t2slo17 & t2slo18)
  76354. s[33] = t2shi16 ^ (~t2shi17 & t2shi18)
  76355. s[42] = t2slo21 ^ (~t2slo22 & t2slo23)
  76356. s[43] = t2shi21 ^ (~t2shi22 & t2shi23)
  76357. s[4] = t2slo2 ^ (~t2slo3 & t2slo4)
  76358. s[5] = t2shi2 ^ (~t2shi3 & t2shi4)
  76359. s[14] = t2slo7 ^ (~t2slo8 & t2slo9)
  76360. s[15] = t2shi7 ^ (~t2shi8 & t2shi9)
  76361. s[24] = t2slo12 ^ (~t2slo13 & t2slo14)
  76362. s[25] = t2shi12 ^ (~t2shi13 & t2shi14)
  76363. s[34] = t2slo17 ^ (~t2slo18 & t2slo19)
  76364. s[35] = t2shi17 ^ (~t2shi18 & t2shi19)
  76365. s[44] = t2slo22 ^ (~t2slo23 & t2slo24)
  76366. s[45] = t2shi22 ^ (~t2shi23 & t2shi24)
  76367. s[6] = t2slo3 ^ (~t2slo4 & t2slo0)
  76368. s[7] = t2shi3 ^ (~t2shi4 & t2shi0)
  76369. s[16] = t2slo8 ^ (~t2slo9 & t2slo5)
  76370. s[17] = t2shi8 ^ (~t2shi9 & t2shi5)
  76371. s[26] = t2slo13 ^ (~t2slo14 & t2slo10)
  76372. s[27] = t2shi13 ^ (~t2shi14 & t2shi10)
  76373. s[36] = t2slo18 ^ (~t2slo19 & t2slo15)
  76374. s[37] = t2shi18 ^ (~t2shi19 & t2shi15)
  76375. s[46] = t2slo23 ^ (~t2slo24 & t2slo20)
  76376. s[47] = t2shi23 ^ (~t2shi24 & t2shi20)
  76377. s[8] = t2slo4 ^ (~t2slo0 & t2slo1)
  76378. s[9] = t2shi4 ^ (~t2shi0 & t2shi1)
  76379. s[18] = t2slo9 ^ (~t2slo5 & t2slo6)
  76380. s[19] = t2shi9 ^ (~t2shi5 & t2shi6)
  76381. s[28] = t2slo14 ^ (~t2slo10 & t2slo11)
  76382. s[29] = t2shi14 ^ (~t2shi10 & t2shi11)
  76383. s[38] = t2slo19 ^ (~t2slo15 & t2slo16)
  76384. s[39] = t2shi19 ^ (~t2shi15 & t2shi16)
  76385. s[48] = t2slo24 ^ (~t2slo20 & t2slo21)
  76386. s[49] = t2shi24 ^ (~t2shi20 & t2shi21)
  76387. // iota
  76388. s[0] ^= P1600_ROUND_CONSTANTS[round * 2]
  76389. s[1] ^= P1600_ROUND_CONSTANTS[round * 2 + 1]
  76390. }
  76391. }
  76392. },{}],41:[function(require,module,exports){
  76393. (function (Buffer){
  76394. 'use strict'
  76395. var keccakState = require('./keccak-state-unroll')
  76396. function Keccak () {
  76397. // much faster than `new Array(50)`
  76398. this.state = [
  76399. 0, 0, 0, 0, 0,
  76400. 0, 0, 0, 0, 0,
  76401. 0, 0, 0, 0, 0,
  76402. 0, 0, 0, 0, 0,
  76403. 0, 0, 0, 0, 0
  76404. ]
  76405. this.blockSize = null
  76406. this.count = 0
  76407. this.squeezing = false
  76408. }
  76409. Keccak.prototype.initialize = function (rate, capacity) {
  76410. for (var i = 0; i < 50; ++i) this.state[i] = 0
  76411. this.blockSize = rate / 8
  76412. this.count = 0
  76413. this.squeezing = false
  76414. }
  76415. Keccak.prototype.absorb = function (data) {
  76416. for (var i = 0; i < data.length; ++i) {
  76417. this.state[~~(this.count / 4)] ^= data[i] << (8 * (this.count % 4))
  76418. this.count += 1
  76419. if (this.count === this.blockSize) {
  76420. keccakState.p1600(this.state)
  76421. this.count = 0
  76422. }
  76423. }
  76424. }
  76425. Keccak.prototype.absorbLastFewBits = function (bits) {
  76426. this.state[~~(this.count / 4)] ^= bits << (8 * (this.count % 4))
  76427. if ((bits & 0x80) !== 0 && this.count === (this.blockSize - 1)) keccakState.p1600(this.state)
  76428. this.state[~~((this.blockSize - 1) / 4)] ^= 0x80 << (8 * ((this.blockSize - 1) % 4))
  76429. keccakState.p1600(this.state)
  76430. this.count = 0
  76431. this.squeezing = true
  76432. }
  76433. Keccak.prototype.squeeze = function (length) {
  76434. if (!this.squeezing) this.absorbLastFewBits(0x01)
  76435. var output = new Buffer(length)
  76436. for (var i = 0; i < length; ++i) {
  76437. output[i] = (this.state[~~(this.count / 4)] >>> (8 * (this.count % 4))) & 0xff
  76438. this.count += 1
  76439. if (this.count === this.blockSize) {
  76440. keccakState.p1600(this.state)
  76441. this.count = 0
  76442. }
  76443. }
  76444. return output
  76445. }
  76446. Keccak.prototype.copy = function (dest) {
  76447. for (var i = 0; i < 50; ++i) dest.state[i] = this.state[i]
  76448. dest.blockSize = this.blockSize
  76449. dest.count = this.count
  76450. dest.squeezing = this.squeezing
  76451. }
  76452. module.exports = Keccak
  76453. }).call(this,require("buffer").Buffer)
  76454. },{"./keccak-state-unroll":40,"buffer":65}],42:[function(require,module,exports){
  76455. module.exports = assert;
  76456. function assert(val, msg) {
  76457. if (!val)
  76458. throw new Error(msg || 'Assertion failed');
  76459. }
  76460. assert.equal = function assertEqual(l, r, msg) {
  76461. if (l != r)
  76462. throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
  76463. };
  76464. },{}],43:[function(require,module,exports){
  76465. 'use strict';
  76466. var utils = exports;
  76467. function toArray(msg, enc) {
  76468. if (Array.isArray(msg))
  76469. return msg.slice();
  76470. if (!msg)
  76471. return [];
  76472. var res = [];
  76473. if (typeof msg !== 'string') {
  76474. for (var i = 0; i < msg.length; i++)
  76475. res[i] = msg[i] | 0;
  76476. return res;
  76477. }
  76478. if (enc === 'hex') {
  76479. msg = msg.replace(/[^a-z0-9]+/ig, '');
  76480. if (msg.length % 2 !== 0)
  76481. msg = '0' + msg;
  76482. for (var i = 0; i < msg.length; i += 2)
  76483. res.push(parseInt(msg[i] + msg[i + 1], 16));
  76484. } else {
  76485. for (var i = 0; i < msg.length; i++) {
  76486. var c = msg.charCodeAt(i);
  76487. var hi = c >> 8;
  76488. var lo = c & 0xff;
  76489. if (hi)
  76490. res.push(hi, lo);
  76491. else
  76492. res.push(lo);
  76493. }
  76494. }
  76495. return res;
  76496. }
  76497. utils.toArray = toArray;
  76498. function zero2(word) {
  76499. if (word.length === 1)
  76500. return '0' + word;
  76501. else
  76502. return word;
  76503. }
  76504. utils.zero2 = zero2;
  76505. function toHex(msg) {
  76506. var res = '';
  76507. for (var i = 0; i < msg.length; i++)
  76508. res += zero2(msg[i].toString(16));
  76509. return res;
  76510. }
  76511. utils.toHex = toHex;
  76512. utils.encode = function encode(arr, enc) {
  76513. if (enc === 'hex')
  76514. return toHex(arr);
  76515. else
  76516. return arr;
  76517. };
  76518. },{}],44:[function(require,module,exports){
  76519. (function (Buffer){
  76520. /*
  76521. CryptoJS v3.1.2
  76522. code.google.com/p/crypto-js
  76523. (c) 2009-2013 by Jeff Mott. All rights reserved.
  76524. code.google.com/p/crypto-js/wiki/License
  76525. */
  76526. /** @preserve
  76527. (c) 2012 by Cédric Mesnil. All rights reserved.
  76528. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
  76529. - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  76530. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  76531. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  76532. */
  76533. // constants table
  76534. var zl = [
  76535. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
  76536. 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
  76537. 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
  76538. 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
  76539. 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
  76540. ]
  76541. var zr = [
  76542. 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
  76543. 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
  76544. 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
  76545. 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
  76546. 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
  76547. ]
  76548. var sl = [
  76549. 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
  76550. 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
  76551. 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
  76552. 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
  76553. 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
  76554. ]
  76555. var sr = [
  76556. 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
  76557. 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
  76558. 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
  76559. 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
  76560. 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
  76561. ]
  76562. var hl = [0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]
  76563. var hr = [0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]
  76564. function bytesToWords (bytes) {
  76565. var words = []
  76566. for (var i = 0, b = 0; i < bytes.length; i++, b += 8) {
  76567. words[b >>> 5] |= bytes[i] << (24 - b % 32)
  76568. }
  76569. return words
  76570. }
  76571. function wordsToBytes (words) {
  76572. var bytes = []
  76573. for (var b = 0; b < words.length * 32; b += 8) {
  76574. bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF)
  76575. }
  76576. return bytes
  76577. }
  76578. function processBlock (H, M, offset) {
  76579. // swap endian
  76580. for (var i = 0; i < 16; i++) {
  76581. var offset_i = offset + i
  76582. var M_offset_i = M[offset_i]
  76583. // Swap
  76584. M[offset_i] = (
  76585. (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
  76586. (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
  76587. )
  76588. }
  76589. // Working variables
  76590. var al, bl, cl, dl, el
  76591. var ar, br, cr, dr, er
  76592. ar = al = H[0]
  76593. br = bl = H[1]
  76594. cr = cl = H[2]
  76595. dr = dl = H[3]
  76596. er = el = H[4]
  76597. // computation
  76598. var t
  76599. for (i = 0; i < 80; i += 1) {
  76600. t = (al + M[offset + zl[i]]) | 0
  76601. if (i < 16) {
  76602. t += f1(bl, cl, dl) + hl[0]
  76603. } else if (i < 32) {
  76604. t += f2(bl, cl, dl) + hl[1]
  76605. } else if (i < 48) {
  76606. t += f3(bl, cl, dl) + hl[2]
  76607. } else if (i < 64) {
  76608. t += f4(bl, cl, dl) + hl[3]
  76609. } else {// if (i<80) {
  76610. t += f5(bl, cl, dl) + hl[4]
  76611. }
  76612. t = t | 0
  76613. t = rotl(t, sl[i])
  76614. t = (t + el) | 0
  76615. al = el
  76616. el = dl
  76617. dl = rotl(cl, 10)
  76618. cl = bl
  76619. bl = t
  76620. t = (ar + M[offset + zr[i]]) | 0
  76621. if (i < 16) {
  76622. t += f5(br, cr, dr) + hr[0]
  76623. } else if (i < 32) {
  76624. t += f4(br, cr, dr) + hr[1]
  76625. } else if (i < 48) {
  76626. t += f3(br, cr, dr) + hr[2]
  76627. } else if (i < 64) {
  76628. t += f2(br, cr, dr) + hr[3]
  76629. } else {// if (i<80) {
  76630. t += f1(br, cr, dr) + hr[4]
  76631. }
  76632. t = t | 0
  76633. t = rotl(t, sr[i])
  76634. t = (t + er) | 0
  76635. ar = er
  76636. er = dr
  76637. dr = rotl(cr, 10)
  76638. cr = br
  76639. br = t
  76640. }
  76641. // intermediate hash value
  76642. t = (H[1] + cl + dr) | 0
  76643. H[1] = (H[2] + dl + er) | 0
  76644. H[2] = (H[3] + el + ar) | 0
  76645. H[3] = (H[4] + al + br) | 0
  76646. H[4] = (H[0] + bl + cr) | 0
  76647. H[0] = t
  76648. }
  76649. function f1 (x, y, z) {
  76650. return ((x) ^ (y) ^ (z))
  76651. }
  76652. function f2 (x, y, z) {
  76653. return (((x) & (y)) | ((~x) & (z)))
  76654. }
  76655. function f3 (x, y, z) {
  76656. return (((x) | (~(y))) ^ (z))
  76657. }
  76658. function f4 (x, y, z) {
  76659. return (((x) & (z)) | ((y) & (~(z))))
  76660. }
  76661. function f5 (x, y, z) {
  76662. return ((x) ^ ((y) | (~(z))))
  76663. }
  76664. function rotl (x, n) {
  76665. return (x << n) | (x >>> (32 - n))
  76666. }
  76667. function ripemd160 (message) {
  76668. var H = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]
  76669. if (typeof message === 'string') {
  76670. message = new Buffer(message, 'utf8')
  76671. }
  76672. var m = bytesToWords(message)
  76673. var nBitsLeft = message.length * 8
  76674. var nBitsTotal = message.length * 8
  76675. // Add padding
  76676. m[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32)
  76677. m[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
  76678. (((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) |
  76679. (((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00)
  76680. )
  76681. for (var i = 0; i < m.length; i += 16) {
  76682. processBlock(H, m, i)
  76683. }
  76684. // swap endian
  76685. for (i = 0; i < 5; i++) {
  76686. // shortcut
  76687. var H_i = H[i]
  76688. // Swap
  76689. H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
  76690. (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00)
  76691. }
  76692. var digestbytes = wordsToBytes(H)
  76693. return new Buffer(digestbytes)
  76694. }
  76695. module.exports = ripemd160
  76696. }).call(this,require("buffer").Buffer)
  76697. },{"buffer":65}],45:[function(require,module,exports){
  76698. (function (Buffer){
  76699. const assert = require('assert')
  76700. /**
  76701. * RLP Encoding based on: https://github.com/ethereum/wiki/wiki/%5BEnglish%5D-RLP
  76702. * This function takes in a data, convert it to buffer if not, and a length for recursion
  76703. *
  76704. * @param {Buffer,String,Integer,Array} data - will be converted to buffer
  76705. * @returns {Buffer} - returns buffer of encoded data
  76706. **/
  76707. exports.encode = function (input) {
  76708. if (input instanceof Array) {
  76709. var output = []
  76710. for (var i = 0; i < input.length; i++) {
  76711. output.push(exports.encode(input[i]))
  76712. }
  76713. var buf = Buffer.concat(output)
  76714. return Buffer.concat([encodeLength(buf.length, 192), buf])
  76715. } else {
  76716. input = toBuffer(input)
  76717. if (input.length === 1 && input[0] < 128) {
  76718. return input
  76719. } else {
  76720. return Buffer.concat([encodeLength(input.length, 128), input])
  76721. }
  76722. }
  76723. }
  76724. function safeParseInt (v, base) {
  76725. if (v.slice(0, 2) === '00') {
  76726. throw (new Error('invalid RLP: extra zeros'))
  76727. }
  76728. return parseInt(v, base)
  76729. }
  76730. function encodeLength (len, offset) {
  76731. if (len < 56) {
  76732. return new Buffer([len + offset])
  76733. } else {
  76734. var hexLength = intToHex(len)
  76735. var lLength = hexLength.length / 2
  76736. var firstByte = intToHex(offset + 55 + lLength)
  76737. return new Buffer(firstByte + hexLength, 'hex')
  76738. }
  76739. }
  76740. /**
  76741. * RLP Decoding based on: {@link https://github.com/ethereum/wiki/wiki/%5BEnglish%5D-RLP|RLP}
  76742. * @param {Buffer,String,Integer,Array} data - will be converted to buffer
  76743. * @returns {Array} - returns decode Array of Buffers containg the original message
  76744. **/
  76745. exports.decode = function (input, stream) {
  76746. if (!input || input.length === 0) {
  76747. return new Buffer([])
  76748. }
  76749. input = toBuffer(input)
  76750. var decoded = _decode(input)
  76751. if (stream) {
  76752. return decoded
  76753. }
  76754. assert.equal(decoded.remainder.length, 0, 'invalid remainder')
  76755. return decoded.data
  76756. }
  76757. exports.getLength = function (input) {
  76758. if (!input || input.length === 0) {
  76759. return new Buffer([])
  76760. }
  76761. input = toBuffer(input)
  76762. var firstByte = input[0]
  76763. if (firstByte <= 0x7f) {
  76764. return input.length
  76765. } else if (firstByte <= 0xb7) {
  76766. return firstByte - 0x7f
  76767. } else if (firstByte <= 0xbf) {
  76768. return firstByte - 0xb6
  76769. } else if (firstByte <= 0xf7) {
  76770. // a list between 0-55 bytes long
  76771. return firstByte - 0xbf
  76772. } else {
  76773. // a list over 55 bytes long
  76774. var llength = firstByte - 0xf6
  76775. var length = safeParseInt(input.slice(1, llength).toString('hex'), 16)
  76776. return llength + length
  76777. }
  76778. }
  76779. function _decode (input) {
  76780. var length, llength, data, innerRemainder, d
  76781. var decoded = []
  76782. var firstByte = input[0]
  76783. if (firstByte <= 0x7f) {
  76784. // a single byte whose value is in the [0x00, 0x7f] range, that byte is its own RLP encoding.
  76785. return {
  76786. data: input.slice(0, 1),
  76787. remainder: input.slice(1)
  76788. }
  76789. } else if (firstByte <= 0xb7) {
  76790. // string is 0-55 bytes long. A single byte with value 0x80 plus the length of the string followed by the string
  76791. // The range of the first byte is [0x80, 0xb7]
  76792. length = firstByte - 0x7f
  76793. // set 0x80 null to 0
  76794. if (firstByte === 0x80) {
  76795. data = new Buffer([])
  76796. } else {
  76797. data = input.slice(1, length)
  76798. }
  76799. if (length === 2 && data[0] < 0x80) {
  76800. throw new Error('invalid rlp encoding: byte must be less 0x80')
  76801. }
  76802. return {
  76803. data: data,
  76804. remainder: input.slice(length)
  76805. }
  76806. } else if (firstByte <= 0xbf) {
  76807. llength = firstByte - 0xb6
  76808. length = safeParseInt(input.slice(1, llength).toString('hex'), 16)
  76809. data = input.slice(llength, length + llength)
  76810. if (data.length < length) {
  76811. throw (new Error('invalid RLP'))
  76812. }
  76813. return {
  76814. data: data,
  76815. remainder: input.slice(length + llength)
  76816. }
  76817. } else if (firstByte <= 0xf7) {
  76818. // a list between 0-55 bytes long
  76819. length = firstByte - 0xbf
  76820. innerRemainder = input.slice(1, length)
  76821. while (innerRemainder.length) {
  76822. d = _decode(innerRemainder)
  76823. decoded.push(d.data)
  76824. innerRemainder = d.remainder
  76825. }
  76826. return {
  76827. data: decoded,
  76828. remainder: input.slice(length)
  76829. }
  76830. } else {
  76831. // a list over 55 bytes long
  76832. llength = firstByte - 0xf6
  76833. length = safeParseInt(input.slice(1, llength).toString('hex'), 16)
  76834. var totalLength = llength + length
  76835. if (totalLength > input.length) {
  76836. throw new Error('invalid rlp: total length is larger than the data')
  76837. }
  76838. innerRemainder = input.slice(llength, totalLength)
  76839. if (innerRemainder.length === 0) {
  76840. throw new Error('invalid rlp, List has a invalid length')
  76841. }
  76842. while (innerRemainder.length) {
  76843. d = _decode(innerRemainder)
  76844. decoded.push(d.data)
  76845. innerRemainder = d.remainder
  76846. }
  76847. return {
  76848. data: decoded,
  76849. remainder: input.slice(totalLength)
  76850. }
  76851. }
  76852. }
  76853. function isHexPrefixed (str) {
  76854. return str.slice(0, 2) === '0x'
  76855. }
  76856. // Removes 0x from a given String
  76857. function stripHexPrefix (str) {
  76858. if (typeof str !== 'string') {
  76859. return str
  76860. }
  76861. return isHexPrefixed(str) ? str.slice(2) : str
  76862. }
  76863. function intToHex (i) {
  76864. var hex = i.toString(16)
  76865. if (hex.length % 2) {
  76866. hex = '0' + hex
  76867. }
  76868. return hex
  76869. }
  76870. function padToEven (a) {
  76871. if (a.length % 2) a = '0' + a
  76872. return a
  76873. }
  76874. function intToBuffer (i) {
  76875. var hex = intToHex(i)
  76876. return new Buffer(hex, 'hex')
  76877. }
  76878. function toBuffer (v) {
  76879. if (!Buffer.isBuffer(v)) {
  76880. if (typeof v === 'string') {
  76881. if (isHexPrefixed(v)) {
  76882. v = new Buffer(padToEven(stripHexPrefix(v)), 'hex')
  76883. } else {
  76884. v = new Buffer(v)
  76885. }
  76886. } else if (typeof v === 'number') {
  76887. if (!v) {
  76888. v = new Buffer([])
  76889. } else {
  76890. v = intToBuffer(v)
  76891. }
  76892. } else if (v === null || v === undefined) {
  76893. v = new Buffer([])
  76894. } else if (v.toArray) {
  76895. // converts a BN to a Buffer
  76896. v = new Buffer(v.toArray())
  76897. } else {
  76898. throw new Error('invalid type')
  76899. }
  76900. }
  76901. return v
  76902. }
  76903. }).call(this,require("buffer").Buffer)
  76904. },{"assert":61,"buffer":65}],46:[function(require,module,exports){
  76905. 'use strict'
  76906. module.exports = require('./lib')(require('./lib/elliptic'))
  76907. },{"./lib":50,"./lib/elliptic":49}],47:[function(require,module,exports){
  76908. (function (Buffer){
  76909. 'use strict'
  76910. var toString = Object.prototype.toString
  76911. // TypeError
  76912. exports.isArray = function (value, message) {
  76913. if (!Array.isArray(value)) throw TypeError(message)
  76914. }
  76915. exports.isBoolean = function (value, message) {
  76916. if (toString.call(value) !== '[object Boolean]') throw TypeError(message)
  76917. }
  76918. exports.isBuffer = function (value, message) {
  76919. if (!Buffer.isBuffer(value)) throw TypeError(message)
  76920. }
  76921. exports.isFunction = function (value, message) {
  76922. if (toString.call(value) !== '[object Function]') throw TypeError(message)
  76923. }
  76924. exports.isNumber = function (value, message) {
  76925. if (toString.call(value) !== '[object Number]') throw TypeError(message)
  76926. }
  76927. exports.isObject = function (value, message) {
  76928. if (toString.call(value) !== '[object Object]') throw TypeError(message)
  76929. }
  76930. // RangeError
  76931. exports.isBufferLength = function (buffer, length, message) {
  76932. if (buffer.length !== length) throw RangeError(message)
  76933. }
  76934. exports.isBufferLength2 = function (buffer, length1, length2, message) {
  76935. if (buffer.length !== length1 && buffer.length !== length2) throw RangeError(message)
  76936. }
  76937. exports.isLengthGTZero = function (value, message) {
  76938. if (value.length === 0) throw RangeError(message)
  76939. }
  76940. exports.isNumberInInterval = function (number, x, y, message) {
  76941. if (number <= x || number >= y) throw RangeError(message)
  76942. }
  76943. }).call(this,{"isBuffer":require("../../../../../../../../../usr/lib/node_modules/browserify/node_modules/is-buffer/index.js")})
  76944. },{"../../../../../../../../../usr/lib/node_modules/browserify/node_modules/is-buffer/index.js":70}],48:[function(require,module,exports){
  76945. (function (Buffer){
  76946. 'use strict'
  76947. var bip66 = require('bip66')
  76948. var EC_PRIVKEY_EXPORT_DER_COMPRESSED = new Buffer([
  76949. // begin
  76950. 0x30, 0x81, 0xd3, 0x02, 0x01, 0x01, 0x04, 0x20,
  76951. // private key
  76952. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  76953. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  76954. // middle
  76955. 0xa0, 0x81, 0x85, 0x30, 0x81, 0x82, 0x02, 0x01, 0x01, 0x30, 0x2c, 0x06, 0x07, 0x2a, 0x86, 0x48,
  76956. 0xcE, 0x3d, 0x01, 0x01, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  76957. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  76958. 0xff, 0xff, 0xfE, 0xff, 0xff, 0xfc, 0x2f, 0x30, 0x06, 0x04, 0x01, 0x00, 0x04, 0x01, 0x07, 0x04,
  76959. 0x21, 0x02, 0x79, 0xbE, 0x66, 0x7E, 0xf9, 0xdc, 0xbb, 0xac, 0x55, 0xa0, 0x62, 0x95, 0xcE, 0x87,
  76960. 0x0b, 0x07, 0x02, 0x9b, 0xfc, 0xdb, 0x2d, 0xcE, 0x28, 0xd9, 0x59, 0xf2, 0x81, 0x5b, 0x16, 0xf8,
  76961. 0x17, 0x98, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  76962. 0xff, 0xff, 0xff, 0xff, 0xfE, 0xba, 0xaE, 0xdc, 0xE6, 0xaf, 0x48, 0xa0, 0x3b, 0xbf, 0xd2, 0x5E,
  76963. 0x8c, 0xd0, 0x36, 0x41, 0x41, 0x02, 0x01, 0x01, 0xa1, 0x24, 0x03, 0x22, 0x00,
  76964. // public key
  76965. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  76966. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  76967. 0x00
  76968. ])
  76969. var EC_PRIVKEY_EXPORT_DER_UNCOMPRESSED = new Buffer([
  76970. // begin
  76971. 0x30, 0x82, 0x01, 0x13, 0x02, 0x01, 0x01, 0x04, 0x20,
  76972. // private key
  76973. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  76974. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  76975. // middle
  76976. 0xa0, 0x81, 0xa5, 0x30, 0x81, 0xa2, 0x02, 0x01, 0x01, 0x30, 0x2c, 0x06, 0x07, 0x2a, 0x86, 0x48,
  76977. 0xcE, 0x3d, 0x01, 0x01, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  76978. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  76979. 0xff, 0xff, 0xfE, 0xff, 0xff, 0xfc, 0x2f, 0x30, 0x06, 0x04, 0x01, 0x00, 0x04, 0x01, 0x07, 0x04,
  76980. 0x41, 0x04, 0x79, 0xbE, 0x66, 0x7E, 0xf9, 0xdc, 0xbb, 0xac, 0x55, 0xa0, 0x62, 0x95, 0xcE, 0x87,
  76981. 0x0b, 0x07, 0x02, 0x9b, 0xfc, 0xdb, 0x2d, 0xcE, 0x28, 0xd9, 0x59, 0xf2, 0x81, 0x5b, 0x16, 0xf8,
  76982. 0x17, 0x98, 0x48, 0x3a, 0xda, 0x77, 0x26, 0xa3, 0xc4, 0x65, 0x5d, 0xa4, 0xfb, 0xfc, 0x0E, 0x11,
  76983. 0x08, 0xa8, 0xfd, 0x17, 0xb4, 0x48, 0xa6, 0x85, 0x54, 0x19, 0x9c, 0x47, 0xd0, 0x8f, 0xfb, 0x10,
  76984. 0xd4, 0xb8, 0x02, 0x21, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  76985. 0xff, 0xff, 0xff, 0xff, 0xfE, 0xba, 0xaE, 0xdc, 0xE6, 0xaf, 0x48, 0xa0, 0x3b, 0xbf, 0xd2, 0x5E,
  76986. 0x8c, 0xd0, 0x36, 0x41, 0x41, 0x02, 0x01, 0x01, 0xa1, 0x44, 0x03, 0x42, 0x00,
  76987. // public key
  76988. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  76989. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  76990. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  76991. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  76992. 0x00
  76993. ])
  76994. var ZERO_BUFFER_32 = new Buffer([
  76995. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  76996. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  76997. ])
  76998. exports.privateKeyExport = function (privateKey, publicKey, compressed) {
  76999. var result = new Buffer(compressed ? EC_PRIVKEY_EXPORT_DER_COMPRESSED : EC_PRIVKEY_EXPORT_DER_UNCOMPRESSED)
  77000. privateKey.copy(result, compressed ? 8 : 9)
  77001. publicKey.copy(result, compressed ? 181 : 214)
  77002. return result
  77003. }
  77004. exports.privateKeyImport = function (privateKey) {
  77005. var length = privateKey.length
  77006. // sequence header
  77007. var index = 0
  77008. if (length < index + 1 || privateKey[index] !== 0x30) return
  77009. index += 1
  77010. // sequence length constructor
  77011. if (length < index + 1 || !(privateKey[index] & 0x80)) return
  77012. var lenb = privateKey[index] & 0x7f
  77013. index += 1
  77014. if (lenb < 1 || lenb > 2) return
  77015. if (length < index + lenb) return
  77016. // sequence length
  77017. var len = privateKey[index + lenb - 1] | (lenb > 1 ? privateKey[index + lenb - 2] << 8 : 0)
  77018. index += lenb
  77019. if (length < index + len) return
  77020. // sequence element 0: version number (=1)
  77021. if (length < index + 3 ||
  77022. privateKey[index] !== 0x02 ||
  77023. privateKey[index + 1] !== 0x01 ||
  77024. privateKey[index + 2] !== 0x01) {
  77025. return
  77026. }
  77027. index += 3
  77028. // sequence element 1: octet string, up to 32 bytes
  77029. if (length < index + 2 ||
  77030. privateKey[index] !== 0x04 ||
  77031. privateKey[index + 1] > 0x20 ||
  77032. length < index + 2 + privateKey[index + 1]) {
  77033. return
  77034. }
  77035. return privateKey.slice(index + 2, index + 2 + privateKey[index + 1])
  77036. }
  77037. exports.signatureExport = function (sigObj) {
  77038. var r = Buffer.concat([new Buffer([0]), sigObj.r])
  77039. for (var lenR = 33, posR = 0; lenR > 1 && r[posR] === 0x00 && !(r[posR + 1] & 0x80); --lenR, ++posR);
  77040. var s = Buffer.concat([new Buffer([0]), sigObj.s])
  77041. for (var lenS = 33, posS = 0; lenS > 1 && s[posS] === 0x00 && !(s[posS + 1] & 0x80); --lenS, ++posS);
  77042. return bip66.encode(r.slice(posR), s.slice(posS))
  77043. }
  77044. exports.signatureImport = function (sig) {
  77045. var r = new Buffer(ZERO_BUFFER_32)
  77046. var s = new Buffer(ZERO_BUFFER_32)
  77047. try {
  77048. var sigObj = bip66.decode(sig)
  77049. if (sigObj.r.length === 33 && sigObj.r[0] === 0x00) sigObj.r = sigObj.r.slice(1)
  77050. if (sigObj.r.length > 32) throw new Error('R length is too long')
  77051. if (sigObj.s.length === 33 && sigObj.s[0] === 0x00) sigObj.s = sigObj.s.slice(1)
  77052. if (sigObj.s.length > 32) throw new Error('S length is too long')
  77053. } catch (err) {
  77054. return
  77055. }
  77056. sigObj.r.copy(r, 32 - sigObj.r.length)
  77057. sigObj.s.copy(s, 32 - sigObj.s.length)
  77058. return { r: r, s: s }
  77059. }
  77060. exports.signatureImportLax = function (sig) {
  77061. var r = new Buffer(ZERO_BUFFER_32)
  77062. var s = new Buffer(ZERO_BUFFER_32)
  77063. var length = sig.length
  77064. var index = 0
  77065. // sequence tag byte
  77066. if (sig[index++] !== 0x30) return
  77067. // sequence length byte
  77068. var lenbyte = sig[index++]
  77069. if (lenbyte & 0x80) {
  77070. index += lenbyte - 0x80
  77071. if (index > length) return
  77072. }
  77073. // sequence tag byte for r
  77074. if (sig[index++] !== 0x02) return
  77075. // length for r
  77076. var rlen = sig[index++]
  77077. if (rlen & 0x80) {
  77078. lenbyte = rlen - 0x80
  77079. if (index + lenbyte > length) return
  77080. for (; lenbyte > 0 && sig[index] === 0x00; index += 1, lenbyte -= 1);
  77081. for (rlen = 0; lenbyte > 0; index += 1, lenbyte -= 1) rlen = (rlen << 8) + sig[index]
  77082. }
  77083. if (rlen > length - index) return
  77084. var rindex = index
  77085. index += rlen
  77086. // sequence tag byte for s
  77087. if (sig[index++] !== 0x02) return
  77088. // length for s
  77089. var slen = sig[index++]
  77090. if (slen & 0x80) {
  77091. lenbyte = slen - 0x80
  77092. if (index + lenbyte > length) return
  77093. for (; lenbyte > 0 && sig[index] === 0x00; index += 1, lenbyte -= 1);
  77094. for (slen = 0; lenbyte > 0; index += 1, lenbyte -= 1) slen = (slen << 8) + sig[index]
  77095. }
  77096. if (slen > length - index) return
  77097. var sindex = index
  77098. index += slen
  77099. // ignore leading zeros in r
  77100. for (; rlen > 0 && sig[rindex] === 0x00; rlen -= 1, rindex += 1);
  77101. // copy r value
  77102. if (rlen > 32) return
  77103. var rvalue = sig.slice(rindex, rindex + rlen)
  77104. rvalue.copy(r, 32 - rvalue.length)
  77105. // ignore leading zeros in s
  77106. for (; slen > 0 && sig[sindex] === 0x00; slen -= 1, sindex += 1);
  77107. // copy s value
  77108. if (slen > 32) return
  77109. var svalue = sig.slice(sindex, sindex + slen)
  77110. svalue.copy(s, 32 - svalue.length)
  77111. return { r: r, s: s }
  77112. }
  77113. }).call(this,require("buffer").Buffer)
  77114. },{"bip66":3,"buffer":65}],49:[function(require,module,exports){
  77115. (function (Buffer){
  77116. 'use strict'
  77117. var createHash = require('create-hash')
  77118. var BN = require('bn.js')
  77119. var EC = require('elliptic').ec
  77120. var messages = require('../messages.json')
  77121. var ec = new EC('secp256k1')
  77122. var ecparams = ec.curve
  77123. function loadCompressedPublicKey (first, xBuffer) {
  77124. var x = new BN(xBuffer)
  77125. // overflow
  77126. if (x.cmp(ecparams.p) >= 0) return null
  77127. x = x.toRed(ecparams.red)
  77128. // compute corresponding Y
  77129. var y = x.redSqr().redIMul(x).redIAdd(ecparams.b).redSqrt()
  77130. if ((first === 0x03) !== y.isOdd()) y = y.redNeg()
  77131. return ec.keyPair({ pub: { x: x, y: y } })
  77132. }
  77133. function loadUncompressedPublicKey (first, xBuffer, yBuffer) {
  77134. var x = new BN(xBuffer)
  77135. var y = new BN(yBuffer)
  77136. // overflow
  77137. if (x.cmp(ecparams.p) >= 0 || y.cmp(ecparams.p) >= 0) return null
  77138. x = x.toRed(ecparams.red)
  77139. y = y.toRed(ecparams.red)
  77140. // is odd flag
  77141. if ((first === 0x06 || first === 0x07) && y.isOdd() !== (first === 0x07)) return null
  77142. // x*x*x + b = y*y
  77143. var x3 = x.redSqr().redIMul(x)
  77144. if (!y.redSqr().redISub(x3.redIAdd(ecparams.b)).isZero()) return null
  77145. return ec.keyPair({ pub: { x: x, y: y } })
  77146. }
  77147. function loadPublicKey (publicKey) {
  77148. var first = publicKey[0]
  77149. switch (first) {
  77150. case 0x02:
  77151. case 0x03:
  77152. if (publicKey.length !== 33) return null
  77153. return loadCompressedPublicKey(first, publicKey.slice(1, 33))
  77154. case 0x04:
  77155. case 0x06:
  77156. case 0x07:
  77157. if (publicKey.length !== 65) return null
  77158. return loadUncompressedPublicKey(first, publicKey.slice(1, 33), publicKey.slice(33, 65))
  77159. default:
  77160. return null
  77161. }
  77162. }
  77163. exports.privateKeyVerify = function (privateKey) {
  77164. var bn = new BN(privateKey)
  77165. return bn.cmp(ecparams.n) < 0 && !bn.isZero()
  77166. }
  77167. exports.privateKeyExport = function (privateKey, compressed) {
  77168. var d = new BN(privateKey)
  77169. if (d.cmp(ecparams.n) >= 0 || d.isZero()) throw new Error(messages.EC_PRIVATE_KEY_EXPORT_DER_FAIL)
  77170. return new Buffer(ec.keyFromPrivate(privateKey).getPublic(compressed, true))
  77171. }
  77172. exports.privateKeyTweakAdd = function (privateKey, tweak) {
  77173. var bn = new BN(tweak)
  77174. if (bn.cmp(ecparams.n) >= 0) throw new Error(messages.EC_PRIVATE_KEY_TWEAK_ADD_FAIL)
  77175. bn.iadd(new BN(privateKey))
  77176. if (bn.cmp(ecparams.n) >= 0) bn.isub(ecparams.n)
  77177. if (bn.isZero()) throw new Error(messages.EC_PRIVATE_KEY_TWEAK_ADD_FAIL)
  77178. return bn.toArrayLike(Buffer, 'be', 32)
  77179. }
  77180. exports.privateKeyTweakMul = function (privateKey, tweak) {
  77181. var bn = new BN(tweak)
  77182. if (bn.cmp(ecparams.n) >= 0 || bn.isZero()) throw new Error(messages.EC_PRIVATE_KEY_TWEAK_MUL_FAIL)
  77183. bn.imul(new BN(privateKey))
  77184. if (bn.cmp(ecparams.n)) bn = bn.umod(ecparams.n)
  77185. return bn.toArrayLike(Buffer, 'be', 32)
  77186. }
  77187. exports.publicKeyCreate = function (privateKey, compressed) {
  77188. var d = new BN(privateKey)
  77189. if (d.cmp(ecparams.n) >= 0 || d.isZero()) throw new Error(messages.EC_PUBLIC_KEY_CREATE_FAIL)
  77190. return new Buffer(ec.keyFromPrivate(privateKey).getPublic(compressed, true))
  77191. }
  77192. exports.publicKeyConvert = function (publicKey, compressed) {
  77193. var pair = loadPublicKey(publicKey)
  77194. if (pair === null) throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL)
  77195. return new Buffer(pair.getPublic(compressed, true))
  77196. }
  77197. exports.publicKeyVerify = function (publicKey) {
  77198. return loadPublicKey(publicKey) !== null
  77199. }
  77200. exports.publicKeyTweakAdd = function (publicKey, tweak, compressed) {
  77201. var pair = loadPublicKey(publicKey)
  77202. if (pair === null) throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL)
  77203. tweak = new BN(tweak)
  77204. if (tweak.cmp(ecparams.n) >= 0) throw new Error(messages.EC_PUBLIC_KEY_TWEAK_ADD_FAIL)
  77205. return new Buffer(ecparams.g.mul(tweak).add(pair.pub).encode(true, compressed))
  77206. }
  77207. exports.publicKeyTweakMul = function (publicKey, tweak, compressed) {
  77208. var pair = loadPublicKey(publicKey)
  77209. if (pair === null) throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL)
  77210. tweak = new BN(tweak)
  77211. if (tweak.cmp(ecparams.n) >= 0 || tweak.isZero()) throw new Error(messages.EC_PUBLIC_KEY_TWEAK_MUL_FAIL)
  77212. return new Buffer(pair.pub.mul(tweak).encode(true, compressed))
  77213. }
  77214. exports.publicKeyCombine = function (publicKeys, compressed) {
  77215. var pairs = new Array(publicKeys.length)
  77216. for (var i = 0; i < publicKeys.length; ++i) {
  77217. pairs[i] = loadPublicKey(publicKeys[i])
  77218. if (pairs[i] === null) throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL)
  77219. }
  77220. var point = pairs[0].pub
  77221. for (var j = 1; j < pairs.length; ++j) point = point.add(pairs[j].pub)
  77222. if (point.isInfinity()) throw new Error(messages.EC_PUBLIC_KEY_COMBINE_FAIL)
  77223. return new Buffer(point.encode(true, compressed))
  77224. }
  77225. exports.signatureNormalize = function (signature) {
  77226. var r = new BN(signature.slice(0, 32))
  77227. var s = new BN(signature.slice(32, 64))
  77228. if (r.cmp(ecparams.n) >= 0 || s.cmp(ecparams.n) >= 0) throw new Error(messages.ECDSA_SIGNATURE_PARSE_FAIL)
  77229. var result = new Buffer(signature)
  77230. if (s.cmp(ec.nh) === 1) ecparams.n.sub(s).toArrayLike(Buffer, 'be', 32).copy(result, 32)
  77231. return result
  77232. }
  77233. exports.signatureExport = function (signature) {
  77234. var r = signature.slice(0, 32)
  77235. var s = signature.slice(32, 64)
  77236. if (new BN(r).cmp(ecparams.n) >= 0 || new BN(s).cmp(ecparams.n) >= 0) throw new Error(messages.ECDSA_SIGNATURE_PARSE_FAIL)
  77237. return { r: r, s: s }
  77238. }
  77239. exports.signatureImport = function (sigObj) {
  77240. var r = new BN(sigObj.r)
  77241. if (r.cmp(ecparams.n) >= 0) r = new BN(0)
  77242. var s = new BN(sigObj.s)
  77243. if (s.cmp(ecparams.n) >= 0) s = new BN(0)
  77244. return Buffer.concat([
  77245. r.toArrayLike(Buffer, 'be', 32),
  77246. s.toArrayLike(Buffer, 'be', 32)
  77247. ])
  77248. }
  77249. exports.sign = function (message, privateKey, noncefn, data) {
  77250. if (typeof noncefn === 'function') {
  77251. var getNonce = noncefn
  77252. noncefn = function (counter) {
  77253. var nonce = getNonce(message, privateKey, null, data, counter)
  77254. if (!Buffer.isBuffer(nonce) || nonce.length !== 32) throw new Error(messages.ECDSA_SIGN_FAIL)
  77255. return new BN(nonce)
  77256. }
  77257. }
  77258. var d = new BN(privateKey)
  77259. if (d.cmp(ecparams.n) >= 0 || d.isZero()) throw new Error(messages.ECDSA_SIGN_FAIL)
  77260. var result = ec.sign(message, privateKey, { canonical: true, k: noncefn, pers: data })
  77261. return {
  77262. signature: Buffer.concat([
  77263. result.r.toArrayLike(Buffer, 'be', 32),
  77264. result.s.toArrayLike(Buffer, 'be', 32)
  77265. ]),
  77266. recovery: result.recoveryParam
  77267. }
  77268. }
  77269. exports.verify = function (message, signature, publicKey) {
  77270. var sigObj = {r: signature.slice(0, 32), s: signature.slice(32, 64)}
  77271. var sigr = new BN(sigObj.r)
  77272. var sigs = new BN(sigObj.s)
  77273. if (sigr.cmp(ecparams.n) >= 0 || sigs.cmp(ecparams.n) >= 0) throw new Error(messages.ECDSA_SIGNATURE_PARSE_FAIL)
  77274. if (sigs.cmp(ec.nh) === 1 || sigr.isZero() || sigs.isZero()) return false
  77275. var pair = loadPublicKey(publicKey)
  77276. if (pair === null) throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL)
  77277. return ec.verify(message, sigObj, {x: pair.pub.x, y: pair.pub.y})
  77278. }
  77279. exports.recover = function (message, signature, recovery, compressed) {
  77280. var sigObj = {r: signature.slice(0, 32), s: signature.slice(32, 64)}
  77281. var sigr = new BN(sigObj.r)
  77282. var sigs = new BN(sigObj.s)
  77283. if (sigr.cmp(ecparams.n) >= 0 || sigs.cmp(ecparams.n) >= 0) throw new Error(messages.ECDSA_SIGNATURE_PARSE_FAIL)
  77284. try {
  77285. if (sigr.isZero() || sigs.isZero()) throw new Error()
  77286. var point = ec.recoverPubKey(message, sigObj, recovery)
  77287. return new Buffer(point.encode(true, compressed))
  77288. } catch (err) {
  77289. throw new Error(messages.ECDSA_RECOVER_FAIL)
  77290. }
  77291. }
  77292. exports.ecdh = function (publicKey, privateKey) {
  77293. var shared = exports.ecdhUnsafe(publicKey, privateKey, true)
  77294. return createHash('sha256').update(shared).digest()
  77295. }
  77296. exports.ecdhUnsafe = function (publicKey, privateKey, compressed) {
  77297. var pair = loadPublicKey(publicKey)
  77298. if (pair === null) throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL)
  77299. var scalar = new BN(privateKey)
  77300. if (scalar.cmp(ecparams.n) >= 0 || scalar.isZero()) throw new Error(messages.ECDH_FAIL)
  77301. return new Buffer(pair.pub.mul(scalar).encode(true, compressed))
  77302. }
  77303. }).call(this,require("buffer").Buffer)
  77304. },{"../messages.json":51,"bn.js":4,"buffer":65,"create-hash":7,"elliptic":10}],50:[function(require,module,exports){
  77305. 'use strict'
  77306. var assert = require('./assert')
  77307. var der = require('./der')
  77308. var messages = require('./messages.json')
  77309. function initCompressedValue (value, defaultValue) {
  77310. if (value === undefined) return defaultValue
  77311. assert.isBoolean(value, messages.COMPRESSED_TYPE_INVALID)
  77312. return value
  77313. }
  77314. module.exports = function (secp256k1) {
  77315. return {
  77316. privateKeyVerify: function (privateKey) {
  77317. assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID)
  77318. return privateKey.length === 32 && secp256k1.privateKeyVerify(privateKey)
  77319. },
  77320. privateKeyExport: function (privateKey, compressed) {
  77321. assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID)
  77322. assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID)
  77323. compressed = initCompressedValue(compressed, true)
  77324. var publicKey = secp256k1.privateKeyExport(privateKey, compressed)
  77325. return der.privateKeyExport(privateKey, publicKey, compressed)
  77326. },
  77327. privateKeyImport: function (privateKey) {
  77328. assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID)
  77329. privateKey = der.privateKeyImport(privateKey)
  77330. if (privateKey && privateKey.length === 32 && secp256k1.privateKeyVerify(privateKey)) return privateKey
  77331. throw new Error(messages.EC_PRIVATE_KEY_IMPORT_DER_FAIL)
  77332. },
  77333. privateKeyTweakAdd: function (privateKey, tweak) {
  77334. assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID)
  77335. assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID)
  77336. assert.isBuffer(tweak, messages.TWEAK_TYPE_INVALID)
  77337. assert.isBufferLength(tweak, 32, messages.TWEAK_LENGTH_INVALID)
  77338. return secp256k1.privateKeyTweakAdd(privateKey, tweak)
  77339. },
  77340. privateKeyTweakMul: function (privateKey, tweak) {
  77341. assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID)
  77342. assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID)
  77343. assert.isBuffer(tweak, messages.TWEAK_TYPE_INVALID)
  77344. assert.isBufferLength(tweak, 32, messages.TWEAK_LENGTH_INVALID)
  77345. return secp256k1.privateKeyTweakMul(privateKey, tweak)
  77346. },
  77347. publicKeyCreate: function (privateKey, compressed) {
  77348. assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID)
  77349. assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID)
  77350. compressed = initCompressedValue(compressed, true)
  77351. return secp256k1.publicKeyCreate(privateKey, compressed)
  77352. },
  77353. publicKeyConvert: function (publicKey, compressed) {
  77354. assert.isBuffer(publicKey, messages.EC_PUBLIC_KEY_TYPE_INVALID)
  77355. assert.isBufferLength2(publicKey, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID)
  77356. compressed = initCompressedValue(compressed, true)
  77357. return secp256k1.publicKeyConvert(publicKey, compressed)
  77358. },
  77359. publicKeyVerify: function (publicKey) {
  77360. assert.isBuffer(publicKey, messages.EC_PUBLIC_KEY_TYPE_INVALID)
  77361. return secp256k1.publicKeyVerify(publicKey)
  77362. },
  77363. publicKeyTweakAdd: function (publicKey, tweak, compressed) {
  77364. assert.isBuffer(publicKey, messages.EC_PUBLIC_KEY_TYPE_INVALID)
  77365. assert.isBufferLength2(publicKey, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID)
  77366. assert.isBuffer(tweak, messages.TWEAK_TYPE_INVALID)
  77367. assert.isBufferLength(tweak, 32, messages.TWEAK_LENGTH_INVALID)
  77368. compressed = initCompressedValue(compressed, true)
  77369. return secp256k1.publicKeyTweakAdd(publicKey, tweak, compressed)
  77370. },
  77371. publicKeyTweakMul: function (publicKey, tweak, compressed) {
  77372. assert.isBuffer(publicKey, messages.EC_PUBLIC_KEY_TYPE_INVALID)
  77373. assert.isBufferLength2(publicKey, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID)
  77374. assert.isBuffer(tweak, messages.TWEAK_TYPE_INVALID)
  77375. assert.isBufferLength(tweak, 32, messages.TWEAK_LENGTH_INVALID)
  77376. compressed = initCompressedValue(compressed, true)
  77377. return secp256k1.publicKeyTweakMul(publicKey, tweak, compressed)
  77378. },
  77379. publicKeyCombine: function (publicKeys, compressed) {
  77380. assert.isArray(publicKeys, messages.EC_PUBLIC_KEYS_TYPE_INVALID)
  77381. assert.isLengthGTZero(publicKeys, messages.EC_PUBLIC_KEYS_LENGTH_INVALID)
  77382. for (var i = 0; i < publicKeys.length; ++i) {
  77383. assert.isBuffer(publicKeys[i], messages.EC_PUBLIC_KEY_TYPE_INVALID)
  77384. assert.isBufferLength2(publicKeys[i], 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID)
  77385. }
  77386. compressed = initCompressedValue(compressed, true)
  77387. return secp256k1.publicKeyCombine(publicKeys, compressed)
  77388. },
  77389. signatureNormalize: function (signature) {
  77390. assert.isBuffer(signature, messages.ECDSA_SIGNATURE_TYPE_INVALID)
  77391. assert.isBufferLength(signature, 64, messages.ECDSA_SIGNATURE_LENGTH_INVALID)
  77392. return secp256k1.signatureNormalize(signature)
  77393. },
  77394. signatureExport: function (signature) {
  77395. assert.isBuffer(signature, messages.ECDSA_SIGNATURE_TYPE_INVALID)
  77396. assert.isBufferLength(signature, 64, messages.ECDSA_SIGNATURE_LENGTH_INVALID)
  77397. var sigObj = secp256k1.signatureExport(signature)
  77398. return der.signatureExport(sigObj)
  77399. },
  77400. signatureImport: function (sig) {
  77401. assert.isBuffer(sig, messages.ECDSA_SIGNATURE_TYPE_INVALID)
  77402. assert.isLengthGTZero(sig, messages.ECDSA_SIGNATURE_LENGTH_INVALID)
  77403. var sigObj = der.signatureImport(sig)
  77404. if (sigObj) return secp256k1.signatureImport(sigObj)
  77405. throw new Error(messages.ECDSA_SIGNATURE_PARSE_DER_FAIL)
  77406. },
  77407. signatureImportLax: function (sig) {
  77408. assert.isBuffer(sig, messages.ECDSA_SIGNATURE_TYPE_INVALID)
  77409. assert.isLengthGTZero(sig, messages.ECDSA_SIGNATURE_LENGTH_INVALID)
  77410. var sigObj = der.signatureImportLax(sig)
  77411. if (sigObj) return secp256k1.signatureImport(sigObj)
  77412. throw new Error(messages.ECDSA_SIGNATURE_PARSE_DER_FAIL)
  77413. },
  77414. sign: function (message, privateKey, options) {
  77415. assert.isBuffer(message, messages.MSG32_TYPE_INVALID)
  77416. assert.isBufferLength(message, 32, messages.MSG32_LENGTH_INVALID)
  77417. assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID)
  77418. assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID)
  77419. var data = null
  77420. var noncefn = null
  77421. if (options !== undefined) {
  77422. assert.isObject(options, messages.OPTIONS_TYPE_INVALID)
  77423. if (options.data !== undefined) {
  77424. assert.isBuffer(options.data, messages.OPTIONS_DATA_TYPE_INVALID)
  77425. assert.isBufferLength(options.data, 32, messages.OPTIONS_DATA_LENGTH_INVALID)
  77426. data = options.data
  77427. }
  77428. if (options.noncefn !== undefined) {
  77429. assert.isFunction(options.noncefn, messages.OPTIONS_NONCEFN_TYPE_INVALID)
  77430. noncefn = options.noncefn
  77431. }
  77432. }
  77433. return secp256k1.sign(message, privateKey, noncefn, data)
  77434. },
  77435. verify: function (message, signature, publicKey) {
  77436. assert.isBuffer(message, messages.MSG32_TYPE_INVALID)
  77437. assert.isBufferLength(message, 32, messages.MSG32_LENGTH_INVALID)
  77438. assert.isBuffer(signature, messages.ECDSA_SIGNATURE_TYPE_INVALID)
  77439. assert.isBufferLength(signature, 64, messages.ECDSA_SIGNATURE_LENGTH_INVALID)
  77440. assert.isBuffer(publicKey, messages.EC_PUBLIC_KEY_TYPE_INVALID)
  77441. assert.isBufferLength2(publicKey, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID)
  77442. return secp256k1.verify(message, signature, publicKey)
  77443. },
  77444. recover: function (message, signature, recovery, compressed) {
  77445. assert.isBuffer(message, messages.MSG32_TYPE_INVALID)
  77446. assert.isBufferLength(message, 32, messages.MSG32_LENGTH_INVALID)
  77447. assert.isBuffer(signature, messages.ECDSA_SIGNATURE_TYPE_INVALID)
  77448. assert.isBufferLength(signature, 64, messages.ECDSA_SIGNATURE_LENGTH_INVALID)
  77449. assert.isNumber(recovery, messages.RECOVERY_ID_TYPE_INVALID)
  77450. assert.isNumberInInterval(recovery, -1, 4, messages.RECOVERY_ID_VALUE_INVALID)
  77451. compressed = initCompressedValue(compressed, true)
  77452. return secp256k1.recover(message, signature, recovery, compressed)
  77453. },
  77454. ecdh: function (publicKey, privateKey) {
  77455. assert.isBuffer(publicKey, messages.EC_PUBLIC_KEY_TYPE_INVALID)
  77456. assert.isBufferLength2(publicKey, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID)
  77457. assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID)
  77458. assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID)
  77459. return secp256k1.ecdh(publicKey, privateKey)
  77460. },
  77461. ecdhUnsafe: function (publicKey, privateKey, compressed) {
  77462. assert.isBuffer(publicKey, messages.EC_PUBLIC_KEY_TYPE_INVALID)
  77463. assert.isBufferLength2(publicKey, 33, 65, messages.EC_PUBLIC_KEY_LENGTH_INVALID)
  77464. assert.isBuffer(privateKey, messages.EC_PRIVATE_KEY_TYPE_INVALID)
  77465. assert.isBufferLength(privateKey, 32, messages.EC_PRIVATE_KEY_LENGTH_INVALID)
  77466. compressed = initCompressedValue(compressed, true)
  77467. return secp256k1.ecdhUnsafe(publicKey, privateKey, compressed)
  77468. }
  77469. }
  77470. }
  77471. },{"./assert":47,"./der":48,"./messages.json":51}],51:[function(require,module,exports){
  77472. module.exports={
  77473. "COMPRESSED_TYPE_INVALID": "compressed should be a boolean",
  77474. "EC_PRIVATE_KEY_TYPE_INVALID": "private key should be a Buffer",
  77475. "EC_PRIVATE_KEY_LENGTH_INVALID": "private key length is invalid",
  77476. "EC_PRIVATE_KEY_TWEAK_ADD_FAIL": "tweak out of range or resulting private key is invalid",
  77477. "EC_PRIVATE_KEY_TWEAK_MUL_FAIL": "tweak out of range",
  77478. "EC_PRIVATE_KEY_EXPORT_DER_FAIL": "couldn't export to DER format",
  77479. "EC_PRIVATE_KEY_IMPORT_DER_FAIL": "couldn't import from DER format",
  77480. "EC_PUBLIC_KEYS_TYPE_INVALID": "public keys should be an Array",
  77481. "EC_PUBLIC_KEYS_LENGTH_INVALID": "public keys Array should have at least 1 element",
  77482. "EC_PUBLIC_KEY_TYPE_INVALID": "public key should be a Buffer",
  77483. "EC_PUBLIC_KEY_LENGTH_INVALID": "public key length is invalid",
  77484. "EC_PUBLIC_KEY_PARSE_FAIL": "the public key could not be parsed or is invalid",
  77485. "EC_PUBLIC_KEY_CREATE_FAIL": "private was invalid, try again",
  77486. "EC_PUBLIC_KEY_TWEAK_ADD_FAIL": "tweak out of range or resulting public key is invalid",
  77487. "EC_PUBLIC_KEY_TWEAK_MUL_FAIL": "tweak out of range",
  77488. "EC_PUBLIC_KEY_COMBINE_FAIL": "the sum of the public keys is not valid",
  77489. "ECDH_FAIL": "scalar was invalid (zero or overflow)",
  77490. "ECDSA_SIGNATURE_TYPE_INVALID": "signature should be a Buffer",
  77491. "ECDSA_SIGNATURE_LENGTH_INVALID": "signature length is invalid",
  77492. "ECDSA_SIGNATURE_PARSE_FAIL": "couldn't parse signature",
  77493. "ECDSA_SIGNATURE_PARSE_DER_FAIL": "couldn't parse DER signature",
  77494. "ECDSA_SIGNATURE_SERIALIZE_DER_FAIL": "couldn't serialize signature to DER format",
  77495. "ECDSA_SIGN_FAIL": "nonce generation function failed or private key is invalid",
  77496. "ECDSA_RECOVER_FAIL": "couldn't recover public key from signature",
  77497. "MSG32_TYPE_INVALID": "message should be a Buffer",
  77498. "MSG32_LENGTH_INVALID": "message length is invalid",
  77499. "OPTIONS_TYPE_INVALID": "options should be an Object",
  77500. "OPTIONS_DATA_TYPE_INVALID": "options.data should be a Buffer",
  77501. "OPTIONS_DATA_LENGTH_INVALID": "options.data length is invalid",
  77502. "OPTIONS_NONCEFN_TYPE_INVALID": "options.noncefn should be a Function",
  77503. "RECOVERY_ID_TYPE_INVALID": "recovery should be a Number",
  77504. "RECOVERY_ID_VALUE_INVALID": "recovery should have value between -1 and 4",
  77505. "TWEAK_TYPE_INVALID": "tweak should be a Buffer",
  77506. "TWEAK_LENGTH_INVALID": "tweak length is invalid"
  77507. }
  77508. },{}],52:[function(require,module,exports){
  77509. (function (Buffer){
  77510. // prototype class for hash functions
  77511. function Hash (blockSize, finalSize) {
  77512. this._block = new Buffer(blockSize)
  77513. this._finalSize = finalSize
  77514. this._blockSize = blockSize
  77515. this._len = 0
  77516. this._s = 0
  77517. }
  77518. Hash.prototype.update = function (data, enc) {
  77519. if (typeof data === 'string') {
  77520. enc = enc || 'utf8'
  77521. data = new Buffer(data, enc)
  77522. }
  77523. var l = this._len += data.length
  77524. var s = this._s || 0
  77525. var f = 0
  77526. var buffer = this._block
  77527. while (s < l) {
  77528. var t = Math.min(data.length, f + this._blockSize - (s % this._blockSize))
  77529. var ch = (t - f)
  77530. for (var i = 0; i < ch; i++) {
  77531. buffer[(s % this._blockSize) + i] = data[i + f]
  77532. }
  77533. s += ch
  77534. f += ch
  77535. if ((s % this._blockSize) === 0) {
  77536. this._update(buffer)
  77537. }
  77538. }
  77539. this._s = s
  77540. return this
  77541. }
  77542. Hash.prototype.digest = function (enc) {
  77543. // Suppose the length of the message M, in bits, is l
  77544. var l = this._len * 8
  77545. // Append the bit 1 to the end of the message
  77546. this._block[this._len % this._blockSize] = 0x80
  77547. // and then k zero bits, where k is the smallest non-negative solution to the equation (l + 1 + k) === finalSize mod blockSize
  77548. this._block.fill(0, this._len % this._blockSize + 1)
  77549. if (l % (this._blockSize * 8) >= this._finalSize * 8) {
  77550. this._update(this._block)
  77551. this._block.fill(0)
  77552. }
  77553. // to this append the block which is equal to the number l written in binary
  77554. // TODO: handle case where l is > Math.pow(2, 29)
  77555. this._block.writeInt32BE(l, this._blockSize - 4)
  77556. var hash = this._update(this._block) || this._hash()
  77557. return enc ? hash.toString(enc) : hash
  77558. }
  77559. Hash.prototype._update = function () {
  77560. throw new Error('_update must be implemented by subclass')
  77561. }
  77562. module.exports = Hash
  77563. }).call(this,require("buffer").Buffer)
  77564. },{"buffer":65}],53:[function(require,module,exports){
  77565. var exports = module.exports = function SHA (algorithm) {
  77566. algorithm = algorithm.toLowerCase()
  77567. var Algorithm = exports[algorithm]
  77568. if (!Algorithm) throw new Error(algorithm + ' is not supported (we accept pull requests)')
  77569. return new Algorithm()
  77570. }
  77571. exports.sha = require('./sha')
  77572. exports.sha1 = require('./sha1')
  77573. exports.sha224 = require('./sha224')
  77574. exports.sha256 = require('./sha256')
  77575. exports.sha384 = require('./sha384')
  77576. exports.sha512 = require('./sha512')
  77577. },{"./sha":54,"./sha1":55,"./sha224":56,"./sha256":57,"./sha384":58,"./sha512":59}],54:[function(require,module,exports){
  77578. (function (Buffer){
  77579. /*
  77580. * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined
  77581. * in FIPS PUB 180-1
  77582. * This source code is derived from sha1.js of the same repository.
  77583. * The difference between SHA-0 and SHA-1 is just a bitwise rotate left
  77584. * operation was added.
  77585. */
  77586. var inherits = require('inherits')
  77587. var Hash = require('./hash')
  77588. var K = [
  77589. 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
  77590. ]
  77591. var W = new Array(80)
  77592. function Sha () {
  77593. this.init()
  77594. this._w = W
  77595. Hash.call(this, 64, 56)
  77596. }
  77597. inherits(Sha, Hash)
  77598. Sha.prototype.init = function () {
  77599. this._a = 0x67452301
  77600. this._b = 0xefcdab89
  77601. this._c = 0x98badcfe
  77602. this._d = 0x10325476
  77603. this._e = 0xc3d2e1f0
  77604. return this
  77605. }
  77606. function rotl5 (num) {
  77607. return (num << 5) | (num >>> 27)
  77608. }
  77609. function rotl30 (num) {
  77610. return (num << 30) | (num >>> 2)
  77611. }
  77612. function ft (s, b, c, d) {
  77613. if (s === 0) return (b & c) | ((~b) & d)
  77614. if (s === 2) return (b & c) | (b & d) | (c & d)
  77615. return b ^ c ^ d
  77616. }
  77617. Sha.prototype._update = function (M) {
  77618. var W = this._w
  77619. var a = this._a | 0
  77620. var b = this._b | 0
  77621. var c = this._c | 0
  77622. var d = this._d | 0
  77623. var e = this._e | 0
  77624. for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
  77625. for (; i < 80; ++i) W[i] = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]
  77626. for (var j = 0; j < 80; ++j) {
  77627. var s = ~~(j / 20)
  77628. var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0
  77629. e = d
  77630. d = c
  77631. c = rotl30(b)
  77632. b = a
  77633. a = t
  77634. }
  77635. this._a = (a + this._a) | 0
  77636. this._b = (b + this._b) | 0
  77637. this._c = (c + this._c) | 0
  77638. this._d = (d + this._d) | 0
  77639. this._e = (e + this._e) | 0
  77640. }
  77641. Sha.prototype._hash = function () {
  77642. var H = new Buffer(20)
  77643. H.writeInt32BE(this._a | 0, 0)
  77644. H.writeInt32BE(this._b | 0, 4)
  77645. H.writeInt32BE(this._c | 0, 8)
  77646. H.writeInt32BE(this._d | 0, 12)
  77647. H.writeInt32BE(this._e | 0, 16)
  77648. return H
  77649. }
  77650. module.exports = Sha
  77651. }).call(this,require("buffer").Buffer)
  77652. },{"./hash":52,"buffer":65,"inherits":34}],55:[function(require,module,exports){
  77653. (function (Buffer){
  77654. /*
  77655. * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
  77656. * in FIPS PUB 180-1
  77657. * Version 2.1a Copyright Paul Johnston 2000 - 2002.
  77658. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  77659. * Distributed under the BSD License
  77660. * See http://pajhome.org.uk/crypt/md5 for details.
  77661. */
  77662. var inherits = require('inherits')
  77663. var Hash = require('./hash')
  77664. var K = [
  77665. 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
  77666. ]
  77667. var W = new Array(80)
  77668. function Sha1 () {
  77669. this.init()
  77670. this._w = W
  77671. Hash.call(this, 64, 56)
  77672. }
  77673. inherits(Sha1, Hash)
  77674. Sha1.prototype.init = function () {
  77675. this._a = 0x67452301
  77676. this._b = 0xefcdab89
  77677. this._c = 0x98badcfe
  77678. this._d = 0x10325476
  77679. this._e = 0xc3d2e1f0
  77680. return this
  77681. }
  77682. function rotl1 (num) {
  77683. return (num << 1) | (num >>> 31)
  77684. }
  77685. function rotl5 (num) {
  77686. return (num << 5) | (num >>> 27)
  77687. }
  77688. function rotl30 (num) {
  77689. return (num << 30) | (num >>> 2)
  77690. }
  77691. function ft (s, b, c, d) {
  77692. if (s === 0) return (b & c) | ((~b) & d)
  77693. if (s === 2) return (b & c) | (b & d) | (c & d)
  77694. return b ^ c ^ d
  77695. }
  77696. Sha1.prototype._update = function (M) {
  77697. var W = this._w
  77698. var a = this._a | 0
  77699. var b = this._b | 0
  77700. var c = this._c | 0
  77701. var d = this._d | 0
  77702. var e = this._e | 0
  77703. for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
  77704. for (; i < 80; ++i) W[i] = rotl1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16])
  77705. for (var j = 0; j < 80; ++j) {
  77706. var s = ~~(j / 20)
  77707. var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0
  77708. e = d
  77709. d = c
  77710. c = rotl30(b)
  77711. b = a
  77712. a = t
  77713. }
  77714. this._a = (a + this._a) | 0
  77715. this._b = (b + this._b) | 0
  77716. this._c = (c + this._c) | 0
  77717. this._d = (d + this._d) | 0
  77718. this._e = (e + this._e) | 0
  77719. }
  77720. Sha1.prototype._hash = function () {
  77721. var H = new Buffer(20)
  77722. H.writeInt32BE(this._a | 0, 0)
  77723. H.writeInt32BE(this._b | 0, 4)
  77724. H.writeInt32BE(this._c | 0, 8)
  77725. H.writeInt32BE(this._d | 0, 12)
  77726. H.writeInt32BE(this._e | 0, 16)
  77727. return H
  77728. }
  77729. module.exports = Sha1
  77730. }).call(this,require("buffer").Buffer)
  77731. },{"./hash":52,"buffer":65,"inherits":34}],56:[function(require,module,exports){
  77732. (function (Buffer){
  77733. /**
  77734. * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
  77735. * in FIPS 180-2
  77736. * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
  77737. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  77738. *
  77739. */
  77740. var inherits = require('inherits')
  77741. var Sha256 = require('./sha256')
  77742. var Hash = require('./hash')
  77743. var W = new Array(64)
  77744. function Sha224 () {
  77745. this.init()
  77746. this._w = W // new Array(64)
  77747. Hash.call(this, 64, 56)
  77748. }
  77749. inherits(Sha224, Sha256)
  77750. Sha224.prototype.init = function () {
  77751. this._a = 0xc1059ed8
  77752. this._b = 0x367cd507
  77753. this._c = 0x3070dd17
  77754. this._d = 0xf70e5939
  77755. this._e = 0xffc00b31
  77756. this._f = 0x68581511
  77757. this._g = 0x64f98fa7
  77758. this._h = 0xbefa4fa4
  77759. return this
  77760. }
  77761. Sha224.prototype._hash = function () {
  77762. var H = new Buffer(28)
  77763. H.writeInt32BE(this._a, 0)
  77764. H.writeInt32BE(this._b, 4)
  77765. H.writeInt32BE(this._c, 8)
  77766. H.writeInt32BE(this._d, 12)
  77767. H.writeInt32BE(this._e, 16)
  77768. H.writeInt32BE(this._f, 20)
  77769. H.writeInt32BE(this._g, 24)
  77770. return H
  77771. }
  77772. module.exports = Sha224
  77773. }).call(this,require("buffer").Buffer)
  77774. },{"./hash":52,"./sha256":57,"buffer":65,"inherits":34}],57:[function(require,module,exports){
  77775. (function (Buffer){
  77776. /**
  77777. * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
  77778. * in FIPS 180-2
  77779. * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
  77780. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  77781. *
  77782. */
  77783. var inherits = require('inherits')
  77784. var Hash = require('./hash')
  77785. var K = [
  77786. 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
  77787. 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
  77788. 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
  77789. 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
  77790. 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
  77791. 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
  77792. 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
  77793. 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
  77794. 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
  77795. 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
  77796. 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
  77797. 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
  77798. 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
  77799. 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
  77800. 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
  77801. 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2
  77802. ]
  77803. var W = new Array(64)
  77804. function Sha256 () {
  77805. this.init()
  77806. this._w = W // new Array(64)
  77807. Hash.call(this, 64, 56)
  77808. }
  77809. inherits(Sha256, Hash)
  77810. Sha256.prototype.init = function () {
  77811. this._a = 0x6a09e667
  77812. this._b = 0xbb67ae85
  77813. this._c = 0x3c6ef372
  77814. this._d = 0xa54ff53a
  77815. this._e = 0x510e527f
  77816. this._f = 0x9b05688c
  77817. this._g = 0x1f83d9ab
  77818. this._h = 0x5be0cd19
  77819. return this
  77820. }
  77821. function ch (x, y, z) {
  77822. return z ^ (x & (y ^ z))
  77823. }
  77824. function maj (x, y, z) {
  77825. return (x & y) | (z & (x | y))
  77826. }
  77827. function sigma0 (x) {
  77828. return (x >>> 2 | x << 30) ^ (x >>> 13 | x << 19) ^ (x >>> 22 | x << 10)
  77829. }
  77830. function sigma1 (x) {
  77831. return (x >>> 6 | x << 26) ^ (x >>> 11 | x << 21) ^ (x >>> 25 | x << 7)
  77832. }
  77833. function gamma0 (x) {
  77834. return (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ (x >>> 3)
  77835. }
  77836. function gamma1 (x) {
  77837. return (x >>> 17 | x << 15) ^ (x >>> 19 | x << 13) ^ (x >>> 10)
  77838. }
  77839. Sha256.prototype._update = function (M) {
  77840. var W = this._w
  77841. var a = this._a | 0
  77842. var b = this._b | 0
  77843. var c = this._c | 0
  77844. var d = this._d | 0
  77845. var e = this._e | 0
  77846. var f = this._f | 0
  77847. var g = this._g | 0
  77848. var h = this._h | 0
  77849. for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
  77850. for (; i < 64; ++i) W[i] = (gamma1(W[i - 2]) + W[i - 7] + gamma0(W[i - 15]) + W[i - 16]) | 0
  77851. for (var j = 0; j < 64; ++j) {
  77852. var T1 = (h + sigma1(e) + ch(e, f, g) + K[j] + W[j]) | 0
  77853. var T2 = (sigma0(a) + maj(a, b, c)) | 0
  77854. h = g
  77855. g = f
  77856. f = e
  77857. e = (d + T1) | 0
  77858. d = c
  77859. c = b
  77860. b = a
  77861. a = (T1 + T2) | 0
  77862. }
  77863. this._a = (a + this._a) | 0
  77864. this._b = (b + this._b) | 0
  77865. this._c = (c + this._c) | 0
  77866. this._d = (d + this._d) | 0
  77867. this._e = (e + this._e) | 0
  77868. this._f = (f + this._f) | 0
  77869. this._g = (g + this._g) | 0
  77870. this._h = (h + this._h) | 0
  77871. }
  77872. Sha256.prototype._hash = function () {
  77873. var H = new Buffer(32)
  77874. H.writeInt32BE(this._a, 0)
  77875. H.writeInt32BE(this._b, 4)
  77876. H.writeInt32BE(this._c, 8)
  77877. H.writeInt32BE(this._d, 12)
  77878. H.writeInt32BE(this._e, 16)
  77879. H.writeInt32BE(this._f, 20)
  77880. H.writeInt32BE(this._g, 24)
  77881. H.writeInt32BE(this._h, 28)
  77882. return H
  77883. }
  77884. module.exports = Sha256
  77885. }).call(this,require("buffer").Buffer)
  77886. },{"./hash":52,"buffer":65,"inherits":34}],58:[function(require,module,exports){
  77887. (function (Buffer){
  77888. var inherits = require('inherits')
  77889. var SHA512 = require('./sha512')
  77890. var Hash = require('./hash')
  77891. var W = new Array(160)
  77892. function Sha384 () {
  77893. this.init()
  77894. this._w = W
  77895. Hash.call(this, 128, 112)
  77896. }
  77897. inherits(Sha384, SHA512)
  77898. Sha384.prototype.init = function () {
  77899. this._ah = 0xcbbb9d5d
  77900. this._bh = 0x629a292a
  77901. this._ch = 0x9159015a
  77902. this._dh = 0x152fecd8
  77903. this._eh = 0x67332667
  77904. this._fh = 0x8eb44a87
  77905. this._gh = 0xdb0c2e0d
  77906. this._hh = 0x47b5481d
  77907. this._al = 0xc1059ed8
  77908. this._bl = 0x367cd507
  77909. this._cl = 0x3070dd17
  77910. this._dl = 0xf70e5939
  77911. this._el = 0xffc00b31
  77912. this._fl = 0x68581511
  77913. this._gl = 0x64f98fa7
  77914. this._hl = 0xbefa4fa4
  77915. return this
  77916. }
  77917. Sha384.prototype._hash = function () {
  77918. var H = new Buffer(48)
  77919. function writeInt64BE (h, l, offset) {
  77920. H.writeInt32BE(h, offset)
  77921. H.writeInt32BE(l, offset + 4)
  77922. }
  77923. writeInt64BE(this._ah, this._al, 0)
  77924. writeInt64BE(this._bh, this._bl, 8)
  77925. writeInt64BE(this._ch, this._cl, 16)
  77926. writeInt64BE(this._dh, this._dl, 24)
  77927. writeInt64BE(this._eh, this._el, 32)
  77928. writeInt64BE(this._fh, this._fl, 40)
  77929. return H
  77930. }
  77931. module.exports = Sha384
  77932. }).call(this,require("buffer").Buffer)
  77933. },{"./hash":52,"./sha512":59,"buffer":65,"inherits":34}],59:[function(require,module,exports){
  77934. (function (Buffer){
  77935. var inherits = require('inherits')
  77936. var Hash = require('./hash')
  77937. var K = [
  77938. 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
  77939. 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
  77940. 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
  77941. 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
  77942. 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
  77943. 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
  77944. 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
  77945. 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
  77946. 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
  77947. 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
  77948. 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
  77949. 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
  77950. 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
  77951. 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
  77952. 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
  77953. 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
  77954. 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
  77955. 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
  77956. 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
  77957. 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
  77958. 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
  77959. 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
  77960. 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
  77961. 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
  77962. 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
  77963. 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
  77964. 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
  77965. 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
  77966. 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
  77967. 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
  77968. 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
  77969. 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
  77970. 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
  77971. 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
  77972. 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
  77973. 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
  77974. 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
  77975. 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
  77976. 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
  77977. 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
  77978. ]
  77979. var W = new Array(160)
  77980. function Sha512 () {
  77981. this.init()
  77982. this._w = W
  77983. Hash.call(this, 128, 112)
  77984. }
  77985. inherits(Sha512, Hash)
  77986. Sha512.prototype.init = function () {
  77987. this._ah = 0x6a09e667
  77988. this._bh = 0xbb67ae85
  77989. this._ch = 0x3c6ef372
  77990. this._dh = 0xa54ff53a
  77991. this._eh = 0x510e527f
  77992. this._fh = 0x9b05688c
  77993. this._gh = 0x1f83d9ab
  77994. this._hh = 0x5be0cd19
  77995. this._al = 0xf3bcc908
  77996. this._bl = 0x84caa73b
  77997. this._cl = 0xfe94f82b
  77998. this._dl = 0x5f1d36f1
  77999. this._el = 0xade682d1
  78000. this._fl = 0x2b3e6c1f
  78001. this._gl = 0xfb41bd6b
  78002. this._hl = 0x137e2179
  78003. return this
  78004. }
  78005. function Ch (x, y, z) {
  78006. return z ^ (x & (y ^ z))
  78007. }
  78008. function maj (x, y, z) {
  78009. return (x & y) | (z & (x | y))
  78010. }
  78011. function sigma0 (x, xl) {
  78012. return (x >>> 28 | xl << 4) ^ (xl >>> 2 | x << 30) ^ (xl >>> 7 | x << 25)
  78013. }
  78014. function sigma1 (x, xl) {
  78015. return (x >>> 14 | xl << 18) ^ (x >>> 18 | xl << 14) ^ (xl >>> 9 | x << 23)
  78016. }
  78017. function Gamma0 (x, xl) {
  78018. return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7)
  78019. }
  78020. function Gamma0l (x, xl) {
  78021. return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7 | xl << 25)
  78022. }
  78023. function Gamma1 (x, xl) {
  78024. return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6)
  78025. }
  78026. function Gamma1l (x, xl) {
  78027. return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6 | xl << 26)
  78028. }
  78029. function getCarry (a, b) {
  78030. return (a >>> 0) < (b >>> 0) ? 1 : 0
  78031. }
  78032. Sha512.prototype._update = function (M) {
  78033. var W = this._w
  78034. var ah = this._ah | 0
  78035. var bh = this._bh | 0
  78036. var ch = this._ch | 0
  78037. var dh = this._dh | 0
  78038. var eh = this._eh | 0
  78039. var fh = this._fh | 0
  78040. var gh = this._gh | 0
  78041. var hh = this._hh | 0
  78042. var al = this._al | 0
  78043. var bl = this._bl | 0
  78044. var cl = this._cl | 0
  78045. var dl = this._dl | 0
  78046. var el = this._el | 0
  78047. var fl = this._fl | 0
  78048. var gl = this._gl | 0
  78049. var hl = this._hl | 0
  78050. for (var i = 0; i < 32; i += 2) {
  78051. W[i] = M.readInt32BE(i * 4)
  78052. W[i + 1] = M.readInt32BE(i * 4 + 4)
  78053. }
  78054. for (; i < 160; i += 2) {
  78055. var xh = W[i - 15 * 2]
  78056. var xl = W[i - 15 * 2 + 1]
  78057. var gamma0 = Gamma0(xh, xl)
  78058. var gamma0l = Gamma0l(xl, xh)
  78059. xh = W[i - 2 * 2]
  78060. xl = W[i - 2 * 2 + 1]
  78061. var gamma1 = Gamma1(xh, xl)
  78062. var gamma1l = Gamma1l(xl, xh)
  78063. // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
  78064. var Wi7h = W[i - 7 * 2]
  78065. var Wi7l = W[i - 7 * 2 + 1]
  78066. var Wi16h = W[i - 16 * 2]
  78067. var Wi16l = W[i - 16 * 2 + 1]
  78068. var Wil = (gamma0l + Wi7l) | 0
  78069. var Wih = (gamma0 + Wi7h + getCarry(Wil, gamma0l)) | 0
  78070. Wil = (Wil + gamma1l) | 0
  78071. Wih = (Wih + gamma1 + getCarry(Wil, gamma1l)) | 0
  78072. Wil = (Wil + Wi16l) | 0
  78073. Wih = (Wih + Wi16h + getCarry(Wil, Wi16l)) | 0
  78074. W[i] = Wih
  78075. W[i + 1] = Wil
  78076. }
  78077. for (var j = 0; j < 160; j += 2) {
  78078. Wih = W[j]
  78079. Wil = W[j + 1]
  78080. var majh = maj(ah, bh, ch)
  78081. var majl = maj(al, bl, cl)
  78082. var sigma0h = sigma0(ah, al)
  78083. var sigma0l = sigma0(al, ah)
  78084. var sigma1h = sigma1(eh, el)
  78085. var sigma1l = sigma1(el, eh)
  78086. // t1 = h + sigma1 + ch + K[j] + W[j]
  78087. var Kih = K[j]
  78088. var Kil = K[j + 1]
  78089. var chh = Ch(eh, fh, gh)
  78090. var chl = Ch(el, fl, gl)
  78091. var t1l = (hl + sigma1l) | 0
  78092. var t1h = (hh + sigma1h + getCarry(t1l, hl)) | 0
  78093. t1l = (t1l + chl) | 0
  78094. t1h = (t1h + chh + getCarry(t1l, chl)) | 0
  78095. t1l = (t1l + Kil) | 0
  78096. t1h = (t1h + Kih + getCarry(t1l, Kil)) | 0
  78097. t1l = (t1l + Wil) | 0
  78098. t1h = (t1h + Wih + getCarry(t1l, Wil)) | 0
  78099. // t2 = sigma0 + maj
  78100. var t2l = (sigma0l + majl) | 0
  78101. var t2h = (sigma0h + majh + getCarry(t2l, sigma0l)) | 0
  78102. hh = gh
  78103. hl = gl
  78104. gh = fh
  78105. gl = fl
  78106. fh = eh
  78107. fl = el
  78108. el = (dl + t1l) | 0
  78109. eh = (dh + t1h + getCarry(el, dl)) | 0
  78110. dh = ch
  78111. dl = cl
  78112. ch = bh
  78113. cl = bl
  78114. bh = ah
  78115. bl = al
  78116. al = (t1l + t2l) | 0
  78117. ah = (t1h + t2h + getCarry(al, t1l)) | 0
  78118. }
  78119. this._al = (this._al + al) | 0
  78120. this._bl = (this._bl + bl) | 0
  78121. this._cl = (this._cl + cl) | 0
  78122. this._dl = (this._dl + dl) | 0
  78123. this._el = (this._el + el) | 0
  78124. this._fl = (this._fl + fl) | 0
  78125. this._gl = (this._gl + gl) | 0
  78126. this._hl = (this._hl + hl) | 0
  78127. this._ah = (this._ah + ah + getCarry(this._al, al)) | 0
  78128. this._bh = (this._bh + bh + getCarry(this._bl, bl)) | 0
  78129. this._ch = (this._ch + ch + getCarry(this._cl, cl)) | 0
  78130. this._dh = (this._dh + dh + getCarry(this._dl, dl)) | 0
  78131. this._eh = (this._eh + eh + getCarry(this._el, el)) | 0
  78132. this._fh = (this._fh + fh + getCarry(this._fl, fl)) | 0
  78133. this._gh = (this._gh + gh + getCarry(this._gl, gl)) | 0
  78134. this._hh = (this._hh + hh + getCarry(this._hl, hl)) | 0
  78135. }
  78136. Sha512.prototype._hash = function () {
  78137. var H = new Buffer(64)
  78138. function writeInt64BE (h, l, offset) {
  78139. H.writeInt32BE(h, offset)
  78140. H.writeInt32BE(l, offset + 4)
  78141. }
  78142. writeInt64BE(this._ah, this._al, 0)
  78143. writeInt64BE(this._bh, this._bl, 8)
  78144. writeInt64BE(this._ch, this._cl, 16)
  78145. writeInt64BE(this._dh, this._dl, 24)
  78146. writeInt64BE(this._eh, this._el, 32)
  78147. writeInt64BE(this._fh, this._fl, 40)
  78148. writeInt64BE(this._gh, this._gl, 48)
  78149. writeInt64BE(this._hh, this._hl, 56)
  78150. return H
  78151. }
  78152. module.exports = Sha512
  78153. }).call(this,require("buffer").Buffer)
  78154. },{"./hash":52,"buffer":65,"inherits":34}],60:[function(require,module,exports){
  78155. var isHexPrefixed = require('is-hex-prefixed');
  78156. /**
  78157. * Removes '0x' from a given `String` is present
  78158. * @param {String} str the string value
  78159. * @return {String|Optional} a string by pass if necessary
  78160. */
  78161. module.exports = function stripHexPrefix(str) {
  78162. if (typeof str !== 'string') {
  78163. return str;
  78164. }
  78165. return isHexPrefixed(str) ? str.slice(2) : str;
  78166. }
  78167. },{"is-hex-prefixed":35}],61:[function(require,module,exports){
  78168. (function (global){
  78169. 'use strict';
  78170. // compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js
  78171. // original notice:
  78172. /*!
  78173. * The buffer module from node.js, for the browser.
  78174. *
  78175. * @author Feross Aboukhadijeh <[email protected]> <http://feross.org>
  78176. * @license MIT
  78177. */
  78178. function compare(a, b) {
  78179. if (a === b) {
  78180. return 0;
  78181. }
  78182. var x = a.length;
  78183. var y = b.length;
  78184. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  78185. if (a[i] !== b[i]) {
  78186. x = a[i];
  78187. y = b[i];
  78188. break;
  78189. }
  78190. }
  78191. if (x < y) {
  78192. return -1;
  78193. }
  78194. if (y < x) {
  78195. return 1;
  78196. }
  78197. return 0;
  78198. }
  78199. function isBuffer(b) {
  78200. if (global.Buffer && typeof global.Buffer.isBuffer === 'function') {
  78201. return global.Buffer.isBuffer(b);
  78202. }
  78203. return !!(b != null && b._isBuffer);
  78204. }
  78205. // based on node assert, original notice:
  78206. // http://wiki.commonjs.org/wiki/Unit_Testing/1.0
  78207. //
  78208. // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
  78209. //
  78210. // Originally from narwhal.js (http://narwhaljs.org)
  78211. // Copyright (c) 2009 Thomas Robinson <280north.com>
  78212. //
  78213. // Permission is hereby granted, free of charge, to any person obtaining a copy
  78214. // of this software and associated documentation files (the 'Software'), to
  78215. // deal in the Software without restriction, including without limitation the
  78216. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  78217. // sell copies of the Software, and to permit persons to whom the Software is
  78218. // furnished to do so, subject to the following conditions:
  78219. //
  78220. // The above copyright notice and this permission notice shall be included in
  78221. // all copies or substantial portions of the Software.
  78222. //
  78223. // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  78224. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  78225. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  78226. // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  78227. // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  78228. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  78229. var util = require('util/');
  78230. var hasOwn = Object.prototype.hasOwnProperty;
  78231. var pSlice = Array.prototype.slice;
  78232. var functionsHaveNames = (function () {
  78233. return function foo() {}.name === 'foo';
  78234. }());
  78235. function pToString (obj) {
  78236. return Object.prototype.toString.call(obj);
  78237. }
  78238. function isView(arrbuf) {
  78239. if (isBuffer(arrbuf)) {
  78240. return false;
  78241. }
  78242. if (typeof global.ArrayBuffer !== 'function') {
  78243. return false;
  78244. }
  78245. if (typeof ArrayBuffer.isView === 'function') {
  78246. return ArrayBuffer.isView(arrbuf);
  78247. }
  78248. if (!arrbuf) {
  78249. return false;
  78250. }
  78251. if (arrbuf instanceof DataView) {
  78252. return true;
  78253. }
  78254. if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) {
  78255. return true;
  78256. }
  78257. return false;
  78258. }
  78259. // 1. The assert module provides functions that throw
  78260. // AssertionError's when particular conditions are not met. The
  78261. // assert module must conform to the following interface.
  78262. var assert = module.exports = ok;
  78263. // 2. The AssertionError is defined in assert.
  78264. // new assert.AssertionError({ message: message,
  78265. // actual: actual,
  78266. // expected: expected })
  78267. var regex = /\s*function\s+([^\(\s]*)\s*/;
  78268. // based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js
  78269. function getName(func) {
  78270. if (!util.isFunction(func)) {
  78271. return;
  78272. }
  78273. if (functionsHaveNames) {
  78274. return func.name;
  78275. }
  78276. var str = func.toString();
  78277. var match = str.match(regex);
  78278. return match && match[1];
  78279. }
  78280. assert.AssertionError = function AssertionError(options) {
  78281. this.name = 'AssertionError';
  78282. this.actual = options.actual;
  78283. this.expected = options.expected;
  78284. this.operator = options.operator;
  78285. if (options.message) {
  78286. this.message = options.message;
  78287. this.generatedMessage = false;
  78288. } else {
  78289. this.message = getMessage(this);
  78290. this.generatedMessage = true;
  78291. }
  78292. var stackStartFunction = options.stackStartFunction || fail;
  78293. if (Error.captureStackTrace) {
  78294. Error.captureStackTrace(this, stackStartFunction);
  78295. } else {
  78296. // non v8 browsers so we can have a stacktrace
  78297. var err = new Error();
  78298. if (err.stack) {
  78299. var out = err.stack;
  78300. // try to strip useless frames
  78301. var fn_name = getName(stackStartFunction);
  78302. var idx = out.indexOf('\n' + fn_name);
  78303. if (idx >= 0) {
  78304. // once we have located the function frame
  78305. // we need to strip out everything before it (and its line)
  78306. var next_line = out.indexOf('\n', idx + 1);
  78307. out = out.substring(next_line + 1);
  78308. }
  78309. this.stack = out;
  78310. }
  78311. }
  78312. };
  78313. // assert.AssertionError instanceof Error
  78314. util.inherits(assert.AssertionError, Error);
  78315. function truncate(s, n) {
  78316. if (typeof s === 'string') {
  78317. return s.length < n ? s : s.slice(0, n);
  78318. } else {
  78319. return s;
  78320. }
  78321. }
  78322. function inspect(something) {
  78323. if (functionsHaveNames || !util.isFunction(something)) {
  78324. return util.inspect(something);
  78325. }
  78326. var rawname = getName(something);
  78327. var name = rawname ? ': ' + rawname : '';
  78328. return '[Function' + name + ']';
  78329. }
  78330. function getMessage(self) {
  78331. return truncate(inspect(self.actual), 128) + ' ' +
  78332. self.operator + ' ' +
  78333. truncate(inspect(self.expected), 128);
  78334. }
  78335. // At present only the three keys mentioned above are used and
  78336. // understood by the spec. Implementations or sub modules can pass
  78337. // other keys to the AssertionError's constructor - they will be
  78338. // ignored.
  78339. // 3. All of the following functions must throw an AssertionError
  78340. // when a corresponding condition is not met, with a message that
  78341. // may be undefined if not provided. All assertion methods provide
  78342. // both the actual and expected values to the assertion error for
  78343. // display purposes.
  78344. function fail(actual, expected, message, operator, stackStartFunction) {
  78345. throw new assert.AssertionError({
  78346. message: message,
  78347. actual: actual,
  78348. expected: expected,
  78349. operator: operator,
  78350. stackStartFunction: stackStartFunction
  78351. });
  78352. }
  78353. // EXTENSION! allows for well behaved errors defined elsewhere.
  78354. assert.fail = fail;
  78355. // 4. Pure assertion tests whether a value is truthy, as determined
  78356. // by !!guard.
  78357. // assert.ok(guard, message_opt);
  78358. // This statement is equivalent to assert.equal(true, !!guard,
  78359. // message_opt);. To test strictly for the value true, use
  78360. // assert.strictEqual(true, guard, message_opt);.
  78361. function ok(value, message) {
  78362. if (!value) fail(value, true, message, '==', assert.ok);
  78363. }
  78364. assert.ok = ok;
  78365. // 5. The equality assertion tests shallow, coercive equality with
  78366. // ==.
  78367. // assert.equal(actual, expected, message_opt);
  78368. assert.equal = function equal(actual, expected, message) {
  78369. if (actual != expected) fail(actual, expected, message, '==', assert.equal);
  78370. };
  78371. // 6. The non-equality assertion tests for whether two objects are not equal
  78372. // with != assert.notEqual(actual, expected, message_opt);
  78373. assert.notEqual = function notEqual(actual, expected, message) {
  78374. if (actual == expected) {
  78375. fail(actual, expected, message, '!=', assert.notEqual);
  78376. }
  78377. };
  78378. // 7. The equivalence assertion tests a deep equality relation.
  78379. // assert.deepEqual(actual, expected, message_opt);
  78380. assert.deepEqual = function deepEqual(actual, expected, message) {
  78381. if (!_deepEqual(actual, expected, false)) {
  78382. fail(actual, expected, message, 'deepEqual', assert.deepEqual);
  78383. }
  78384. };
  78385. assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {
  78386. if (!_deepEqual(actual, expected, true)) {
  78387. fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual);
  78388. }
  78389. };
  78390. function _deepEqual(actual, expected, strict, memos) {
  78391. // 7.1. All identical values are equivalent, as determined by ===.
  78392. if (actual === expected) {
  78393. return true;
  78394. } else if (isBuffer(actual) && isBuffer(expected)) {
  78395. return compare(actual, expected) === 0;
  78396. // 7.2. If the expected value is a Date object, the actual value is
  78397. // equivalent if it is also a Date object that refers to the same time.
  78398. } else if (util.isDate(actual) && util.isDate(expected)) {
  78399. return actual.getTime() === expected.getTime();
  78400. // 7.3 If the expected value is a RegExp object, the actual value is
  78401. // equivalent if it is also a RegExp object with the same source and
  78402. // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
  78403. } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
  78404. return actual.source === expected.source &&
  78405. actual.global === expected.global &&
  78406. actual.multiline === expected.multiline &&
  78407. actual.lastIndex === expected.lastIndex &&
  78408. actual.ignoreCase === expected.ignoreCase;
  78409. // 7.4. Other pairs that do not both pass typeof value == 'object',
  78410. // equivalence is determined by ==.
  78411. } else if ((actual === null || typeof actual !== 'object') &&
  78412. (expected === null || typeof expected !== 'object')) {
  78413. return strict ? actual === expected : actual == expected;
  78414. // If both values are instances of typed arrays, wrap their underlying
  78415. // ArrayBuffers in a Buffer each to increase performance
  78416. // This optimization requires the arrays to have the same type as checked by
  78417. // Object.prototype.toString (aka pToString). Never perform binary
  78418. // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their
  78419. // bit patterns are not identical.
  78420. } else if (isView(actual) && isView(expected) &&
  78421. pToString(actual) === pToString(expected) &&
  78422. !(actual instanceof Float32Array ||
  78423. actual instanceof Float64Array)) {
  78424. return compare(new Uint8Array(actual.buffer),
  78425. new Uint8Array(expected.buffer)) === 0;
  78426. // 7.5 For all other Object pairs, including Array objects, equivalence is
  78427. // determined by having the same number of owned properties (as verified
  78428. // with Object.prototype.hasOwnProperty.call), the same set of keys
  78429. // (although not necessarily the same order), equivalent values for every
  78430. // corresponding key, and an identical 'prototype' property. Note: this
  78431. // accounts for both named and indexed properties on Arrays.
  78432. } else if (isBuffer(actual) !== isBuffer(expected)) {
  78433. return false;
  78434. } else {
  78435. memos = memos || {actual: [], expected: []};
  78436. var actualIndex = memos.actual.indexOf(actual);
  78437. if (actualIndex !== -1) {
  78438. if (actualIndex === memos.expected.indexOf(expected)) {
  78439. return true;
  78440. }
  78441. }
  78442. memos.actual.push(actual);
  78443. memos.expected.push(expected);
  78444. return objEquiv(actual, expected, strict, memos);
  78445. }
  78446. }
  78447. function isArguments(object) {
  78448. return Object.prototype.toString.call(object) == '[object Arguments]';
  78449. }
  78450. function objEquiv(a, b, strict, actualVisitedObjects) {
  78451. if (a === null || a === undefined || b === null || b === undefined)
  78452. return false;
  78453. // if one is a primitive, the other must be same
  78454. if (util.isPrimitive(a) || util.isPrimitive(b))
  78455. return a === b;
  78456. if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))
  78457. return false;
  78458. var aIsArgs = isArguments(a);
  78459. var bIsArgs = isArguments(b);
  78460. if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
  78461. return false;
  78462. if (aIsArgs) {
  78463. a = pSlice.call(a);
  78464. b = pSlice.call(b);
  78465. return _deepEqual(a, b, strict);
  78466. }
  78467. var ka = objectKeys(a);
  78468. var kb = objectKeys(b);
  78469. var key, i;
  78470. // having the same number of owned properties (keys incorporates
  78471. // hasOwnProperty)
  78472. if (ka.length !== kb.length)
  78473. return false;
  78474. //the same set of keys (although not necessarily the same order),
  78475. ka.sort();
  78476. kb.sort();
  78477. //~~~cheap key test
  78478. for (i = ka.length - 1; i >= 0; i--) {
  78479. if (ka[i] !== kb[i])
  78480. return false;
  78481. }
  78482. //equivalent values for every corresponding key, and
  78483. //~~~possibly expensive deep test
  78484. for (i = ka.length - 1; i >= 0; i--) {
  78485. key = ka[i];
  78486. if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects))
  78487. return false;
  78488. }
  78489. return true;
  78490. }
  78491. // 8. The non-equivalence assertion tests for any deep inequality.
  78492. // assert.notDeepEqual(actual, expected, message_opt);
  78493. assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
  78494. if (_deepEqual(actual, expected, false)) {
  78495. fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
  78496. }
  78497. };
  78498. assert.notDeepStrictEqual = notDeepStrictEqual;
  78499. function notDeepStrictEqual(actual, expected, message) {
  78500. if (_deepEqual(actual, expected, true)) {
  78501. fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual);
  78502. }
  78503. }
  78504. // 9. The strict equality assertion tests strict equality, as determined by ===.
  78505. // assert.strictEqual(actual, expected, message_opt);
  78506. assert.strictEqual = function strictEqual(actual, expected, message) {
  78507. if (actual !== expected) {
  78508. fail(actual, expected, message, '===', assert.strictEqual);
  78509. }
  78510. };
  78511. // 10. The strict non-equality assertion tests for strict inequality, as
  78512. // determined by !==. assert.notStrictEqual(actual, expected, message_opt);
  78513. assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
  78514. if (actual === expected) {
  78515. fail(actual, expected, message, '!==', assert.notStrictEqual);
  78516. }
  78517. };
  78518. function expectedException(actual, expected) {
  78519. if (!actual || !expected) {
  78520. return false;
  78521. }
  78522. if (Object.prototype.toString.call(expected) == '[object RegExp]') {
  78523. return expected.test(actual);
  78524. }
  78525. try {
  78526. if (actual instanceof expected) {
  78527. return true;
  78528. }
  78529. } catch (e) {
  78530. // Ignore. The instanceof check doesn't work for arrow functions.
  78531. }
  78532. if (Error.isPrototypeOf(expected)) {
  78533. return false;
  78534. }
  78535. return expected.call({}, actual) === true;
  78536. }
  78537. function _tryBlock(block) {
  78538. var error;
  78539. try {
  78540. block();
  78541. } catch (e) {
  78542. error = e;
  78543. }
  78544. return error;
  78545. }
  78546. function _throws(shouldThrow, block, expected, message) {
  78547. var actual;
  78548. if (typeof block !== 'function') {
  78549. throw new TypeError('"block" argument must be a function');
  78550. }
  78551. if (typeof expected === 'string') {
  78552. message = expected;
  78553. expected = null;
  78554. }
  78555. actual = _tryBlock(block);
  78556. message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
  78557. (message ? ' ' + message : '.');
  78558. if (shouldThrow && !actual) {
  78559. fail(actual, expected, 'Missing expected exception' + message);
  78560. }
  78561. var userProvidedMessage = typeof message === 'string';
  78562. var isUnwantedException = !shouldThrow && util.isError(actual);
  78563. var isUnexpectedException = !shouldThrow && actual && !expected;
  78564. if ((isUnwantedException &&
  78565. userProvidedMessage &&
  78566. expectedException(actual, expected)) ||
  78567. isUnexpectedException) {
  78568. fail(actual, expected, 'Got unwanted exception' + message);
  78569. }
  78570. if ((shouldThrow && actual && expected &&
  78571. !expectedException(actual, expected)) || (!shouldThrow && actual)) {
  78572. throw actual;
  78573. }
  78574. }
  78575. // 11. Expected to throw an error:
  78576. // assert.throws(block, Error_opt, message_opt);
  78577. assert.throws = function(block, /*optional*/error, /*optional*/message) {
  78578. _throws(true, block, error, message);
  78579. };
  78580. // EXTENSION! This is annoying to write outside this module.
  78581. assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) {
  78582. _throws(false, block, error, message);
  78583. };
  78584. assert.ifError = function(err) { if (err) throw err; };
  78585. var objectKeys = Object.keys || function (obj) {
  78586. var keys = [];
  78587. for (var key in obj) {
  78588. if (hasOwn.call(obj, key)) keys.push(key);
  78589. }
  78590. return keys;
  78591. };
  78592. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  78593. },{"util/":90}],62:[function(require,module,exports){
  78594. 'use strict'
  78595. exports.byteLength = byteLength
  78596. exports.toByteArray = toByteArray
  78597. exports.fromByteArray = fromByteArray
  78598. var lookup = []
  78599. var revLookup = []
  78600. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  78601. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  78602. for (var i = 0, len = code.length; i < len; ++i) {
  78603. lookup[i] = code[i]
  78604. revLookup[code.charCodeAt(i)] = i
  78605. }
  78606. revLookup['-'.charCodeAt(0)] = 62
  78607. revLookup['_'.charCodeAt(0)] = 63
  78608. function placeHoldersCount (b64) {
  78609. var len = b64.length
  78610. if (len % 4 > 0) {
  78611. throw new Error('Invalid string. Length must be a multiple of 4')
  78612. }
  78613. // the number of equal signs (place holders)
  78614. // if there are two placeholders, than the two characters before it
  78615. // represent one byte
  78616. // if there is only one, then the three characters before it represent 2 bytes
  78617. // this is just a cheap hack to not do indexOf twice
  78618. return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
  78619. }
  78620. function byteLength (b64) {
  78621. // base64 is 4/3 + up to two characters of the original data
  78622. return b64.length * 3 / 4 - placeHoldersCount(b64)
  78623. }
  78624. function toByteArray (b64) {
  78625. var i, j, l, tmp, placeHolders, arr
  78626. var len = b64.length
  78627. placeHolders = placeHoldersCount(b64)
  78628. arr = new Arr(len * 3 / 4 - placeHolders)
  78629. // if there are placeholders, only get up to the last complete 4 chars
  78630. l = placeHolders > 0 ? len - 4 : len
  78631. var L = 0
  78632. for (i = 0, j = 0; i < l; i += 4, j += 3) {
  78633. tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
  78634. arr[L++] = (tmp >> 16) & 0xFF
  78635. arr[L++] = (tmp >> 8) & 0xFF
  78636. arr[L++] = tmp & 0xFF
  78637. }
  78638. if (placeHolders === 2) {
  78639. tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)
  78640. arr[L++] = tmp & 0xFF
  78641. } else if (placeHolders === 1) {
  78642. tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)
  78643. arr[L++] = (tmp >> 8) & 0xFF
  78644. arr[L++] = tmp & 0xFF
  78645. }
  78646. return arr
  78647. }
  78648. function tripletToBase64 (num) {
  78649. return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
  78650. }
  78651. function encodeChunk (uint8, start, end) {
  78652. var tmp
  78653. var output = []
  78654. for (var i = start; i < end; i += 3) {
  78655. tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
  78656. output.push(tripletToBase64(tmp))
  78657. }
  78658. return output.join('')
  78659. }
  78660. function fromByteArray (uint8) {
  78661. var tmp
  78662. var len = uint8.length
  78663. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  78664. var output = ''
  78665. var parts = []
  78666. var maxChunkLength = 16383 // must be multiple of 3
  78667. // go through the array every three bytes, we'll deal with trailing stuff later
  78668. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  78669. parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
  78670. }
  78671. // pad the end with zeros, but make sure to not forget the extra bytes
  78672. if (extraBytes === 1) {
  78673. tmp = uint8[len - 1]
  78674. output += lookup[tmp >> 2]
  78675. output += lookup[(tmp << 4) & 0x3F]
  78676. output += '=='
  78677. } else if (extraBytes === 2) {
  78678. tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
  78679. output += lookup[tmp >> 10]
  78680. output += lookup[(tmp >> 4) & 0x3F]
  78681. output += lookup[(tmp << 2) & 0x3F]
  78682. output += '='
  78683. }
  78684. parts.push(output)
  78685. return parts.join('')
  78686. }
  78687. },{}],63:[function(require,module,exports){
  78688. },{}],64:[function(require,module,exports){
  78689. (function (global){
  78690. 'use strict';
  78691. var buffer = require('buffer');
  78692. var Buffer = buffer.Buffer;
  78693. var SlowBuffer = buffer.SlowBuffer;
  78694. var MAX_LEN = buffer.kMaxLength || 2147483647;
  78695. exports.alloc = function alloc(size, fill, encoding) {
  78696. if (typeof Buffer.alloc === 'function') {
  78697. return Buffer.alloc(size, fill, encoding);
  78698. }
  78699. if (typeof encoding === 'number') {
  78700. throw new TypeError('encoding must not be number');
  78701. }
  78702. if (typeof size !== 'number') {
  78703. throw new TypeError('size must be a number');
  78704. }
  78705. if (size > MAX_LEN) {
  78706. throw new RangeError('size is too large');
  78707. }
  78708. var enc = encoding;
  78709. var _fill = fill;
  78710. if (_fill === undefined) {
  78711. enc = undefined;
  78712. _fill = 0;
  78713. }
  78714. var buf = new Buffer(size);
  78715. if (typeof _fill === 'string') {
  78716. var fillBuf = new Buffer(_fill, enc);
  78717. var flen = fillBuf.length;
  78718. var i = -1;
  78719. while (++i < size) {
  78720. buf[i] = fillBuf[i % flen];
  78721. }
  78722. } else {
  78723. buf.fill(_fill);
  78724. }
  78725. return buf;
  78726. }
  78727. exports.allocUnsafe = function allocUnsafe(size) {
  78728. if (typeof Buffer.allocUnsafe === 'function') {
  78729. return Buffer.allocUnsafe(size);
  78730. }
  78731. if (typeof size !== 'number') {
  78732. throw new TypeError('size must be a number');
  78733. }
  78734. if (size > MAX_LEN) {
  78735. throw new RangeError('size is too large');
  78736. }
  78737. return new Buffer(size);
  78738. }
  78739. exports.from = function from(value, encodingOrOffset, length) {
  78740. if (typeof Buffer.from === 'function' && (!global.Uint8Array || Uint8Array.from !== Buffer.from)) {
  78741. return Buffer.from(value, encodingOrOffset, length);
  78742. }
  78743. if (typeof value === 'number') {
  78744. throw new TypeError('"value" argument must not be a number');
  78745. }
  78746. if (typeof value === 'string') {
  78747. return new Buffer(value, encodingOrOffset);
  78748. }
  78749. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  78750. var offset = encodingOrOffset;
  78751. if (arguments.length === 1) {
  78752. return new Buffer(value);
  78753. }
  78754. if (typeof offset === 'undefined') {
  78755. offset = 0;
  78756. }
  78757. var len = length;
  78758. if (typeof len === 'undefined') {
  78759. len = value.byteLength - offset;
  78760. }
  78761. if (offset >= value.byteLength) {
  78762. throw new RangeError('\'offset\' is out of bounds');
  78763. }
  78764. if (len > value.byteLength - offset) {
  78765. throw new RangeError('\'length\' is out of bounds');
  78766. }
  78767. return new Buffer(value.slice(offset, offset + len));
  78768. }
  78769. if (Buffer.isBuffer(value)) {
  78770. var out = new Buffer(value.length);
  78771. value.copy(out, 0, 0, value.length);
  78772. return out;
  78773. }
  78774. if (value) {
  78775. if (Array.isArray(value) || (typeof ArrayBuffer !== 'undefined' && value.buffer instanceof ArrayBuffer) || 'length' in value) {
  78776. return new Buffer(value);
  78777. }
  78778. if (value.type === 'Buffer' && Array.isArray(value.data)) {
  78779. return new Buffer(value.data);
  78780. }
  78781. }
  78782. throw new TypeError('First argument must be a string, Buffer, ' + 'ArrayBuffer, Array, or array-like object.');
  78783. }
  78784. exports.allocUnsafeSlow = function allocUnsafeSlow(size) {
  78785. if (typeof Buffer.allocUnsafeSlow === 'function') {
  78786. return Buffer.allocUnsafeSlow(size);
  78787. }
  78788. if (typeof size !== 'number') {
  78789. throw new TypeError('size must be a number');
  78790. }
  78791. if (size >= MAX_LEN) {
  78792. throw new RangeError('size is too large');
  78793. }
  78794. return new SlowBuffer(size);
  78795. }
  78796. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  78797. },{"buffer":65}],65:[function(require,module,exports){
  78798. /*!
  78799. * The buffer module from node.js, for the browser.
  78800. *
  78801. * @author Feross Aboukhadijeh <[email protected]> <http://feross.org>
  78802. * @license MIT
  78803. */
  78804. /* eslint-disable no-proto */
  78805. 'use strict'
  78806. var base64 = require('base64-js')
  78807. var ieee754 = require('ieee754')
  78808. exports.Buffer = Buffer
  78809. exports.SlowBuffer = SlowBuffer
  78810. exports.INSPECT_MAX_BYTES = 50
  78811. var K_MAX_LENGTH = 0x7fffffff
  78812. exports.kMaxLength = K_MAX_LENGTH
  78813. /**
  78814. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  78815. * === true Use Uint8Array implementation (fastest)
  78816. * === false Print warning and recommend using `buffer` v4.x which has an Object
  78817. * implementation (most compatible, even IE6)
  78818. *
  78819. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  78820. * Opera 11.6+, iOS 4.2+.
  78821. *
  78822. * We report that the browser does not support typed arrays if the are not subclassable
  78823. * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
  78824. * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
  78825. * for __proto__ and has a buggy typed array implementation.
  78826. */
  78827. Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
  78828. if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
  78829. typeof console.error === 'function') {
  78830. console.error(
  78831. 'This browser lacks typed array (Uint8Array) support which is required by ' +
  78832. '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
  78833. )
  78834. }
  78835. function typedArraySupport () {
  78836. // Can typed array instances can be augmented?
  78837. try {
  78838. var arr = new Uint8Array(1)
  78839. arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
  78840. return arr.foo() === 42
  78841. } catch (e) {
  78842. return false
  78843. }
  78844. }
  78845. function createBuffer (length) {
  78846. if (length > K_MAX_LENGTH) {
  78847. throw new RangeError('Invalid typed array length')
  78848. }
  78849. // Return an augmented `Uint8Array` instance
  78850. var buf = new Uint8Array(length)
  78851. buf.__proto__ = Buffer.prototype
  78852. return buf
  78853. }
  78854. /**
  78855. * The Buffer constructor returns instances of `Uint8Array` that have their
  78856. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  78857. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  78858. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  78859. * returns a single octet.
  78860. *
  78861. * The `Uint8Array` prototype remains unmodified.
  78862. */
  78863. function Buffer (arg, encodingOrOffset, length) {
  78864. // Common case.
  78865. if (typeof arg === 'number') {
  78866. if (typeof encodingOrOffset === 'string') {
  78867. throw new Error(
  78868. 'If encoding is specified then the first argument must be a string'
  78869. )
  78870. }
  78871. return allocUnsafe(arg)
  78872. }
  78873. return from(arg, encodingOrOffset, length)
  78874. }
  78875. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  78876. if (typeof Symbol !== 'undefined' && Symbol.species &&
  78877. Buffer[Symbol.species] === Buffer) {
  78878. Object.defineProperty(Buffer, Symbol.species, {
  78879. value: null,
  78880. configurable: true,
  78881. enumerable: false,
  78882. writable: false
  78883. })
  78884. }
  78885. Buffer.poolSize = 8192 // not used by this implementation
  78886. function from (value, encodingOrOffset, length) {
  78887. if (typeof value === 'number') {
  78888. throw new TypeError('"value" argument must not be a number')
  78889. }
  78890. if (value instanceof ArrayBuffer) {
  78891. return fromArrayBuffer(value, encodingOrOffset, length)
  78892. }
  78893. if (typeof value === 'string') {
  78894. return fromString(value, encodingOrOffset)
  78895. }
  78896. return fromObject(value)
  78897. }
  78898. /**
  78899. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  78900. * if value is a number.
  78901. * Buffer.from(str[, encoding])
  78902. * Buffer.from(array)
  78903. * Buffer.from(buffer)
  78904. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  78905. **/
  78906. Buffer.from = function (value, encodingOrOffset, length) {
  78907. return from(value, encodingOrOffset, length)
  78908. }
  78909. // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
  78910. // https://github.com/feross/buffer/pull/148
  78911. Buffer.prototype.__proto__ = Uint8Array.prototype
  78912. Buffer.__proto__ = Uint8Array
  78913. function assertSize (size) {
  78914. if (typeof size !== 'number') {
  78915. throw new TypeError('"size" argument must be a number')
  78916. } else if (size < 0) {
  78917. throw new RangeError('"size" argument must not be negative')
  78918. }
  78919. }
  78920. function alloc (size, fill, encoding) {
  78921. assertSize(size)
  78922. if (size <= 0) {
  78923. return createBuffer(size)
  78924. }
  78925. if (fill !== undefined) {
  78926. // Only pay attention to encoding if it's a string. This
  78927. // prevents accidentally sending in a number that would
  78928. // be interpretted as a start offset.
  78929. return typeof encoding === 'string'
  78930. ? createBuffer(size).fill(fill, encoding)
  78931. : createBuffer(size).fill(fill)
  78932. }
  78933. return createBuffer(size)
  78934. }
  78935. /**
  78936. * Creates a new filled Buffer instance.
  78937. * alloc(size[, fill[, encoding]])
  78938. **/
  78939. Buffer.alloc = function (size, fill, encoding) {
  78940. return alloc(size, fill, encoding)
  78941. }
  78942. function allocUnsafe (size) {
  78943. assertSize(size)
  78944. return createBuffer(size < 0 ? 0 : checked(size) | 0)
  78945. }
  78946. /**
  78947. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  78948. * */
  78949. Buffer.allocUnsafe = function (size) {
  78950. return allocUnsafe(size)
  78951. }
  78952. /**
  78953. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  78954. */
  78955. Buffer.allocUnsafeSlow = function (size) {
  78956. return allocUnsafe(size)
  78957. }
  78958. function fromString (string, encoding) {
  78959. if (typeof encoding !== 'string' || encoding === '') {
  78960. encoding = 'utf8'
  78961. }
  78962. if (!Buffer.isEncoding(encoding)) {
  78963. throw new TypeError('"encoding" must be a valid string encoding')
  78964. }
  78965. var length = byteLength(string, encoding) | 0
  78966. var buf = createBuffer(length)
  78967. var actual = buf.write(string, encoding)
  78968. if (actual !== length) {
  78969. // Writing a hex string, for example, that contains invalid characters will
  78970. // cause everything after the first invalid character to be ignored. (e.g.
  78971. // 'abxxcd' will be treated as 'ab')
  78972. buf = buf.slice(0, actual)
  78973. }
  78974. return buf
  78975. }
  78976. function fromArrayLike (array) {
  78977. var length = array.length < 0 ? 0 : checked(array.length) | 0
  78978. var buf = createBuffer(length)
  78979. for (var i = 0; i < length; i += 1) {
  78980. buf[i] = array[i] & 255
  78981. }
  78982. return buf
  78983. }
  78984. function fromArrayBuffer (array, byteOffset, length) {
  78985. if (byteOffset < 0 || array.byteLength < byteOffset) {
  78986. throw new RangeError('\'offset\' is out of bounds')
  78987. }
  78988. if (array.byteLength < byteOffset + (length || 0)) {
  78989. throw new RangeError('\'length\' is out of bounds')
  78990. }
  78991. var buf
  78992. if (byteOffset === undefined && length === undefined) {
  78993. buf = new Uint8Array(array)
  78994. } else if (length === undefined) {
  78995. buf = new Uint8Array(array, byteOffset)
  78996. } else {
  78997. buf = new Uint8Array(array, byteOffset, length)
  78998. }
  78999. // Return an augmented `Uint8Array` instance
  79000. buf.__proto__ = Buffer.prototype
  79001. return buf
  79002. }
  79003. function fromObject (obj) {
  79004. if (Buffer.isBuffer(obj)) {
  79005. var len = checked(obj.length) | 0
  79006. var buf = createBuffer(len)
  79007. if (buf.length === 0) {
  79008. return buf
  79009. }
  79010. obj.copy(buf, 0, 0, len)
  79011. return buf
  79012. }
  79013. if (obj) {
  79014. if (ArrayBuffer.isView(obj) || 'length' in obj) {
  79015. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  79016. return createBuffer(0)
  79017. }
  79018. return fromArrayLike(obj)
  79019. }
  79020. if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
  79021. return fromArrayLike(obj.data)
  79022. }
  79023. }
  79024. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  79025. }
  79026. function checked (length) {
  79027. // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
  79028. // length is NaN (which is otherwise coerced to zero.)
  79029. if (length >= K_MAX_LENGTH) {
  79030. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  79031. 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
  79032. }
  79033. return length | 0
  79034. }
  79035. function SlowBuffer (length) {
  79036. if (+length != length) { // eslint-disable-line eqeqeq
  79037. length = 0
  79038. }
  79039. return Buffer.alloc(+length)
  79040. }
  79041. Buffer.isBuffer = function isBuffer (b) {
  79042. return b != null && b._isBuffer === true
  79043. }
  79044. Buffer.compare = function compare (a, b) {
  79045. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  79046. throw new TypeError('Arguments must be Buffers')
  79047. }
  79048. if (a === b) return 0
  79049. var x = a.length
  79050. var y = b.length
  79051. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  79052. if (a[i] !== b[i]) {
  79053. x = a[i]
  79054. y = b[i]
  79055. break
  79056. }
  79057. }
  79058. if (x < y) return -1
  79059. if (y < x) return 1
  79060. return 0
  79061. }
  79062. Buffer.isEncoding = function isEncoding (encoding) {
  79063. switch (String(encoding).toLowerCase()) {
  79064. case 'hex':
  79065. case 'utf8':
  79066. case 'utf-8':
  79067. case 'ascii':
  79068. case 'latin1':
  79069. case 'binary':
  79070. case 'base64':
  79071. case 'ucs2':
  79072. case 'ucs-2':
  79073. case 'utf16le':
  79074. case 'utf-16le':
  79075. return true
  79076. default:
  79077. return false
  79078. }
  79079. }
  79080. Buffer.concat = function concat (list, length) {
  79081. if (!Array.isArray(list)) {
  79082. throw new TypeError('"list" argument must be an Array of Buffers')
  79083. }
  79084. if (list.length === 0) {
  79085. return Buffer.alloc(0)
  79086. }
  79087. var i
  79088. if (length === undefined) {
  79089. length = 0
  79090. for (i = 0; i < list.length; ++i) {
  79091. length += list[i].length
  79092. }
  79093. }
  79094. var buffer = Buffer.allocUnsafe(length)
  79095. var pos = 0
  79096. for (i = 0; i < list.length; ++i) {
  79097. var buf = list[i]
  79098. if (!Buffer.isBuffer(buf)) {
  79099. throw new TypeError('"list" argument must be an Array of Buffers')
  79100. }
  79101. buf.copy(buffer, pos)
  79102. pos += buf.length
  79103. }
  79104. return buffer
  79105. }
  79106. function byteLength (string, encoding) {
  79107. if (Buffer.isBuffer(string)) {
  79108. return string.length
  79109. }
  79110. if (ArrayBuffer.isView(string) || string instanceof ArrayBuffer) {
  79111. return string.byteLength
  79112. }
  79113. if (typeof string !== 'string') {
  79114. string = '' + string
  79115. }
  79116. var len = string.length
  79117. if (len === 0) return 0
  79118. // Use a for loop to avoid recursion
  79119. var loweredCase = false
  79120. for (;;) {
  79121. switch (encoding) {
  79122. case 'ascii':
  79123. case 'latin1':
  79124. case 'binary':
  79125. return len
  79126. case 'utf8':
  79127. case 'utf-8':
  79128. case undefined:
  79129. return utf8ToBytes(string).length
  79130. case 'ucs2':
  79131. case 'ucs-2':
  79132. case 'utf16le':
  79133. case 'utf-16le':
  79134. return len * 2
  79135. case 'hex':
  79136. return len >>> 1
  79137. case 'base64':
  79138. return base64ToBytes(string).length
  79139. default:
  79140. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  79141. encoding = ('' + encoding).toLowerCase()
  79142. loweredCase = true
  79143. }
  79144. }
  79145. }
  79146. Buffer.byteLength = byteLength
  79147. function slowToString (encoding, start, end) {
  79148. var loweredCase = false
  79149. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  79150. // property of a typed array.
  79151. // This behaves neither like String nor Uint8Array in that we set start/end
  79152. // to their upper/lower bounds if the value passed is out of range.
  79153. // undefined is handled specially as per ECMA-262 6th Edition,
  79154. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  79155. if (start === undefined || start < 0) {
  79156. start = 0
  79157. }
  79158. // Return early if start > this.length. Done here to prevent potential uint32
  79159. // coercion fail below.
  79160. if (start > this.length) {
  79161. return ''
  79162. }
  79163. if (end === undefined || end > this.length) {
  79164. end = this.length
  79165. }
  79166. if (end <= 0) {
  79167. return ''
  79168. }
  79169. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  79170. end >>>= 0
  79171. start >>>= 0
  79172. if (end <= start) {
  79173. return ''
  79174. }
  79175. if (!encoding) encoding = 'utf8'
  79176. while (true) {
  79177. switch (encoding) {
  79178. case 'hex':
  79179. return hexSlice(this, start, end)
  79180. case 'utf8':
  79181. case 'utf-8':
  79182. return utf8Slice(this, start, end)
  79183. case 'ascii':
  79184. return asciiSlice(this, start, end)
  79185. case 'latin1':
  79186. case 'binary':
  79187. return latin1Slice(this, start, end)
  79188. case 'base64':
  79189. return base64Slice(this, start, end)
  79190. case 'ucs2':
  79191. case 'ucs-2':
  79192. case 'utf16le':
  79193. case 'utf-16le':
  79194. return utf16leSlice(this, start, end)
  79195. default:
  79196. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  79197. encoding = (encoding + '').toLowerCase()
  79198. loweredCase = true
  79199. }
  79200. }
  79201. }
  79202. // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
  79203. // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
  79204. // reliably in a browserify context because there could be multiple different
  79205. // copies of the 'buffer' package in use. This method works even for Buffer
  79206. // instances that were created from another copy of the `buffer` package.
  79207. // See: https://github.com/feross/buffer/issues/154
  79208. Buffer.prototype._isBuffer = true
  79209. function swap (b, n, m) {
  79210. var i = b[n]
  79211. b[n] = b[m]
  79212. b[m] = i
  79213. }
  79214. Buffer.prototype.swap16 = function swap16 () {
  79215. var len = this.length
  79216. if (len % 2 !== 0) {
  79217. throw new RangeError('Buffer size must be a multiple of 16-bits')
  79218. }
  79219. for (var i = 0; i < len; i += 2) {
  79220. swap(this, i, i + 1)
  79221. }
  79222. return this
  79223. }
  79224. Buffer.prototype.swap32 = function swap32 () {
  79225. var len = this.length
  79226. if (len % 4 !== 0) {
  79227. throw new RangeError('Buffer size must be a multiple of 32-bits')
  79228. }
  79229. for (var i = 0; i < len; i += 4) {
  79230. swap(this, i, i + 3)
  79231. swap(this, i + 1, i + 2)
  79232. }
  79233. return this
  79234. }
  79235. Buffer.prototype.swap64 = function swap64 () {
  79236. var len = this.length
  79237. if (len % 8 !== 0) {
  79238. throw new RangeError('Buffer size must be a multiple of 64-bits')
  79239. }
  79240. for (var i = 0; i < len; i += 8) {
  79241. swap(this, i, i + 7)
  79242. swap(this, i + 1, i + 6)
  79243. swap(this, i + 2, i + 5)
  79244. swap(this, i + 3, i + 4)
  79245. }
  79246. return this
  79247. }
  79248. Buffer.prototype.toString = function toString () {
  79249. var length = this.length
  79250. if (length === 0) return ''
  79251. if (arguments.length === 0) return utf8Slice(this, 0, length)
  79252. return slowToString.apply(this, arguments)
  79253. }
  79254. Buffer.prototype.equals = function equals (b) {
  79255. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  79256. if (this === b) return true
  79257. return Buffer.compare(this, b) === 0
  79258. }
  79259. Buffer.prototype.inspect = function inspect () {
  79260. var str = ''
  79261. var max = exports.INSPECT_MAX_BYTES
  79262. if (this.length > 0) {
  79263. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  79264. if (this.length > max) str += ' ... '
  79265. }
  79266. return '<Buffer ' + str + '>'
  79267. }
  79268. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  79269. if (!Buffer.isBuffer(target)) {
  79270. throw new TypeError('Argument must be a Buffer')
  79271. }
  79272. if (start === undefined) {
  79273. start = 0
  79274. }
  79275. if (end === undefined) {
  79276. end = target ? target.length : 0
  79277. }
  79278. if (thisStart === undefined) {
  79279. thisStart = 0
  79280. }
  79281. if (thisEnd === undefined) {
  79282. thisEnd = this.length
  79283. }
  79284. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  79285. throw new RangeError('out of range index')
  79286. }
  79287. if (thisStart >= thisEnd && start >= end) {
  79288. return 0
  79289. }
  79290. if (thisStart >= thisEnd) {
  79291. return -1
  79292. }
  79293. if (start >= end) {
  79294. return 1
  79295. }
  79296. start >>>= 0
  79297. end >>>= 0
  79298. thisStart >>>= 0
  79299. thisEnd >>>= 0
  79300. if (this === target) return 0
  79301. var x = thisEnd - thisStart
  79302. var y = end - start
  79303. var len = Math.min(x, y)
  79304. var thisCopy = this.slice(thisStart, thisEnd)
  79305. var targetCopy = target.slice(start, end)
  79306. for (var i = 0; i < len; ++i) {
  79307. if (thisCopy[i] !== targetCopy[i]) {
  79308. x = thisCopy[i]
  79309. y = targetCopy[i]
  79310. break
  79311. }
  79312. }
  79313. if (x < y) return -1
  79314. if (y < x) return 1
  79315. return 0
  79316. }
  79317. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  79318. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  79319. //
  79320. // Arguments:
  79321. // - buffer - a Buffer to search
  79322. // - val - a string, Buffer, or number
  79323. // - byteOffset - an index into `buffer`; will be clamped to an int32
  79324. // - encoding - an optional encoding, relevant is val is a string
  79325. // - dir - true for indexOf, false for lastIndexOf
  79326. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  79327. // Empty buffer means no match
  79328. if (buffer.length === 0) return -1
  79329. // Normalize byteOffset
  79330. if (typeof byteOffset === 'string') {
  79331. encoding = byteOffset
  79332. byteOffset = 0
  79333. } else if (byteOffset > 0x7fffffff) {
  79334. byteOffset = 0x7fffffff
  79335. } else if (byteOffset < -0x80000000) {
  79336. byteOffset = -0x80000000
  79337. }
  79338. byteOffset = +byteOffset // Coerce to Number.
  79339. if (isNaN(byteOffset)) {
  79340. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  79341. byteOffset = dir ? 0 : (buffer.length - 1)
  79342. }
  79343. // Normalize byteOffset: negative offsets start from the end of the buffer
  79344. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  79345. if (byteOffset >= buffer.length) {
  79346. if (dir) return -1
  79347. else byteOffset = buffer.length - 1
  79348. } else if (byteOffset < 0) {
  79349. if (dir) byteOffset = 0
  79350. else return -1
  79351. }
  79352. // Normalize val
  79353. if (typeof val === 'string') {
  79354. val = Buffer.from(val, encoding)
  79355. }
  79356. // Finally, search either indexOf (if dir is true) or lastIndexOf
  79357. if (Buffer.isBuffer(val)) {
  79358. // Special case: looking for empty string/buffer always fails
  79359. if (val.length === 0) {
  79360. return -1
  79361. }
  79362. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  79363. } else if (typeof val === 'number') {
  79364. val = val & 0xFF // Search for a byte value [0-255]
  79365. if (typeof Uint8Array.prototype.indexOf === 'function') {
  79366. if (dir) {
  79367. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  79368. } else {
  79369. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  79370. }
  79371. }
  79372. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  79373. }
  79374. throw new TypeError('val must be string, number or Buffer')
  79375. }
  79376. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  79377. var indexSize = 1
  79378. var arrLength = arr.length
  79379. var valLength = val.length
  79380. if (encoding !== undefined) {
  79381. encoding = String(encoding).toLowerCase()
  79382. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  79383. encoding === 'utf16le' || encoding === 'utf-16le') {
  79384. if (arr.length < 2 || val.length < 2) {
  79385. return -1
  79386. }
  79387. indexSize = 2
  79388. arrLength /= 2
  79389. valLength /= 2
  79390. byteOffset /= 2
  79391. }
  79392. }
  79393. function read (buf, i) {
  79394. if (indexSize === 1) {
  79395. return buf[i]
  79396. } else {
  79397. return buf.readUInt16BE(i * indexSize)
  79398. }
  79399. }
  79400. var i
  79401. if (dir) {
  79402. var foundIndex = -1
  79403. for (i = byteOffset; i < arrLength; i++) {
  79404. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  79405. if (foundIndex === -1) foundIndex = i
  79406. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  79407. } else {
  79408. if (foundIndex !== -1) i -= i - foundIndex
  79409. foundIndex = -1
  79410. }
  79411. }
  79412. } else {
  79413. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  79414. for (i = byteOffset; i >= 0; i--) {
  79415. var found = true
  79416. for (var j = 0; j < valLength; j++) {
  79417. if (read(arr, i + j) !== read(val, j)) {
  79418. found = false
  79419. break
  79420. }
  79421. }
  79422. if (found) return i
  79423. }
  79424. }
  79425. return -1
  79426. }
  79427. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  79428. return this.indexOf(val, byteOffset, encoding) !== -1
  79429. }
  79430. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  79431. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  79432. }
  79433. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  79434. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  79435. }
  79436. function hexWrite (buf, string, offset, length) {
  79437. offset = Number(offset) || 0
  79438. var remaining = buf.length - offset
  79439. if (!length) {
  79440. length = remaining
  79441. } else {
  79442. length = Number(length)
  79443. if (length > remaining) {
  79444. length = remaining
  79445. }
  79446. }
  79447. // must be an even number of digits
  79448. var strLen = string.length
  79449. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  79450. if (length > strLen / 2) {
  79451. length = strLen / 2
  79452. }
  79453. for (var i = 0; i < length; ++i) {
  79454. var parsed = parseInt(string.substr(i * 2, 2), 16)
  79455. if (isNaN(parsed)) return i
  79456. buf[offset + i] = parsed
  79457. }
  79458. return i
  79459. }
  79460. function utf8Write (buf, string, offset, length) {
  79461. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  79462. }
  79463. function asciiWrite (buf, string, offset, length) {
  79464. return blitBuffer(asciiToBytes(string), buf, offset, length)
  79465. }
  79466. function latin1Write (buf, string, offset, length) {
  79467. return asciiWrite(buf, string, offset, length)
  79468. }
  79469. function base64Write (buf, string, offset, length) {
  79470. return blitBuffer(base64ToBytes(string), buf, offset, length)
  79471. }
  79472. function ucs2Write (buf, string, offset, length) {
  79473. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  79474. }
  79475. Buffer.prototype.write = function write (string, offset, length, encoding) {
  79476. // Buffer#write(string)
  79477. if (offset === undefined) {
  79478. encoding = 'utf8'
  79479. length = this.length
  79480. offset = 0
  79481. // Buffer#write(string, encoding)
  79482. } else if (length === undefined && typeof offset === 'string') {
  79483. encoding = offset
  79484. length = this.length
  79485. offset = 0
  79486. // Buffer#write(string, offset[, length][, encoding])
  79487. } else if (isFinite(offset)) {
  79488. offset = offset >>> 0
  79489. if (isFinite(length)) {
  79490. length = length >>> 0
  79491. if (encoding === undefined) encoding = 'utf8'
  79492. } else {
  79493. encoding = length
  79494. length = undefined
  79495. }
  79496. } else {
  79497. throw new Error(
  79498. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  79499. )
  79500. }
  79501. var remaining = this.length - offset
  79502. if (length === undefined || length > remaining) length = remaining
  79503. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  79504. throw new RangeError('Attempt to write outside buffer bounds')
  79505. }
  79506. if (!encoding) encoding = 'utf8'
  79507. var loweredCase = false
  79508. for (;;) {
  79509. switch (encoding) {
  79510. case 'hex':
  79511. return hexWrite(this, string, offset, length)
  79512. case 'utf8':
  79513. case 'utf-8':
  79514. return utf8Write(this, string, offset, length)
  79515. case 'ascii':
  79516. return asciiWrite(this, string, offset, length)
  79517. case 'latin1':
  79518. case 'binary':
  79519. return latin1Write(this, string, offset, length)
  79520. case 'base64':
  79521. // Warning: maxLength not taken into account in base64Write
  79522. return base64Write(this, string, offset, length)
  79523. case 'ucs2':
  79524. case 'ucs-2':
  79525. case 'utf16le':
  79526. case 'utf-16le':
  79527. return ucs2Write(this, string, offset, length)
  79528. default:
  79529. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  79530. encoding = ('' + encoding).toLowerCase()
  79531. loweredCase = true
  79532. }
  79533. }
  79534. }
  79535. Buffer.prototype.toJSON = function toJSON () {
  79536. return {
  79537. type: 'Buffer',
  79538. data: Array.prototype.slice.call(this._arr || this, 0)
  79539. }
  79540. }
  79541. function base64Slice (buf, start, end) {
  79542. if (start === 0 && end === buf.length) {
  79543. return base64.fromByteArray(buf)
  79544. } else {
  79545. return base64.fromByteArray(buf.slice(start, end))
  79546. }
  79547. }
  79548. function utf8Slice (buf, start, end) {
  79549. end = Math.min(buf.length, end)
  79550. var res = []
  79551. var i = start
  79552. while (i < end) {
  79553. var firstByte = buf[i]
  79554. var codePoint = null
  79555. var bytesPerSequence = (firstByte > 0xEF) ? 4
  79556. : (firstByte > 0xDF) ? 3
  79557. : (firstByte > 0xBF) ? 2
  79558. : 1
  79559. if (i + bytesPerSequence <= end) {
  79560. var secondByte, thirdByte, fourthByte, tempCodePoint
  79561. switch (bytesPerSequence) {
  79562. case 1:
  79563. if (firstByte < 0x80) {
  79564. codePoint = firstByte
  79565. }
  79566. break
  79567. case 2:
  79568. secondByte = buf[i + 1]
  79569. if ((secondByte & 0xC0) === 0x80) {
  79570. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  79571. if (tempCodePoint > 0x7F) {
  79572. codePoint = tempCodePoint
  79573. }
  79574. }
  79575. break
  79576. case 3:
  79577. secondByte = buf[i + 1]
  79578. thirdByte = buf[i + 2]
  79579. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  79580. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  79581. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  79582. codePoint = tempCodePoint
  79583. }
  79584. }
  79585. break
  79586. case 4:
  79587. secondByte = buf[i + 1]
  79588. thirdByte = buf[i + 2]
  79589. fourthByte = buf[i + 3]
  79590. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  79591. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  79592. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  79593. codePoint = tempCodePoint
  79594. }
  79595. }
  79596. }
  79597. }
  79598. if (codePoint === null) {
  79599. // we did not generate a valid codePoint so insert a
  79600. // replacement char (U+FFFD) and advance only 1 byte
  79601. codePoint = 0xFFFD
  79602. bytesPerSequence = 1
  79603. } else if (codePoint > 0xFFFF) {
  79604. // encode to utf16 (surrogate pair dance)
  79605. codePoint -= 0x10000
  79606. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  79607. codePoint = 0xDC00 | codePoint & 0x3FF
  79608. }
  79609. res.push(codePoint)
  79610. i += bytesPerSequence
  79611. }
  79612. return decodeCodePointsArray(res)
  79613. }
  79614. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  79615. // the lowest limit is Chrome, with 0x10000 args.
  79616. // We go 1 magnitude less, for safety
  79617. var MAX_ARGUMENTS_LENGTH = 0x1000
  79618. function decodeCodePointsArray (codePoints) {
  79619. var len = codePoints.length
  79620. if (len <= MAX_ARGUMENTS_LENGTH) {
  79621. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  79622. }
  79623. // Decode in chunks to avoid "call stack size exceeded".
  79624. var res = ''
  79625. var i = 0
  79626. while (i < len) {
  79627. res += String.fromCharCode.apply(
  79628. String,
  79629. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  79630. )
  79631. }
  79632. return res
  79633. }
  79634. function asciiSlice (buf, start, end) {
  79635. var ret = ''
  79636. end = Math.min(buf.length, end)
  79637. for (var i = start; i < end; ++i) {
  79638. ret += String.fromCharCode(buf[i] & 0x7F)
  79639. }
  79640. return ret
  79641. }
  79642. function latin1Slice (buf, start, end) {
  79643. var ret = ''
  79644. end = Math.min(buf.length, end)
  79645. for (var i = start; i < end; ++i) {
  79646. ret += String.fromCharCode(buf[i])
  79647. }
  79648. return ret
  79649. }
  79650. function hexSlice (buf, start, end) {
  79651. var len = buf.length
  79652. if (!start || start < 0) start = 0
  79653. if (!end || end < 0 || end > len) end = len
  79654. var out = ''
  79655. for (var i = start; i < end; ++i) {
  79656. out += toHex(buf[i])
  79657. }
  79658. return out
  79659. }
  79660. function utf16leSlice (buf, start, end) {
  79661. var bytes = buf.slice(start, end)
  79662. var res = ''
  79663. for (var i = 0; i < bytes.length; i += 2) {
  79664. res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
  79665. }
  79666. return res
  79667. }
  79668. Buffer.prototype.slice = function slice (start, end) {
  79669. var len = this.length
  79670. start = ~~start
  79671. end = end === undefined ? len : ~~end
  79672. if (start < 0) {
  79673. start += len
  79674. if (start < 0) start = 0
  79675. } else if (start > len) {
  79676. start = len
  79677. }
  79678. if (end < 0) {
  79679. end += len
  79680. if (end < 0) end = 0
  79681. } else if (end > len) {
  79682. end = len
  79683. }
  79684. if (end < start) end = start
  79685. var newBuf = this.subarray(start, end)
  79686. // Return an augmented `Uint8Array` instance
  79687. newBuf.__proto__ = Buffer.prototype
  79688. return newBuf
  79689. }
  79690. /*
  79691. * Need to make sure that buffer isn't trying to write out of bounds.
  79692. */
  79693. function checkOffset (offset, ext, length) {
  79694. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  79695. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  79696. }
  79697. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  79698. offset = offset >>> 0
  79699. byteLength = byteLength >>> 0
  79700. if (!noAssert) checkOffset(offset, byteLength, this.length)
  79701. var val = this[offset]
  79702. var mul = 1
  79703. var i = 0
  79704. while (++i < byteLength && (mul *= 0x100)) {
  79705. val += this[offset + i] * mul
  79706. }
  79707. return val
  79708. }
  79709. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  79710. offset = offset >>> 0
  79711. byteLength = byteLength >>> 0
  79712. if (!noAssert) {
  79713. checkOffset(offset, byteLength, this.length)
  79714. }
  79715. var val = this[offset + --byteLength]
  79716. var mul = 1
  79717. while (byteLength > 0 && (mul *= 0x100)) {
  79718. val += this[offset + --byteLength] * mul
  79719. }
  79720. return val
  79721. }
  79722. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  79723. offset = offset >>> 0
  79724. if (!noAssert) checkOffset(offset, 1, this.length)
  79725. return this[offset]
  79726. }
  79727. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  79728. offset = offset >>> 0
  79729. if (!noAssert) checkOffset(offset, 2, this.length)
  79730. return this[offset] | (this[offset + 1] << 8)
  79731. }
  79732. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  79733. offset = offset >>> 0
  79734. if (!noAssert) checkOffset(offset, 2, this.length)
  79735. return (this[offset] << 8) | this[offset + 1]
  79736. }
  79737. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  79738. offset = offset >>> 0
  79739. if (!noAssert) checkOffset(offset, 4, this.length)
  79740. return ((this[offset]) |
  79741. (this[offset + 1] << 8) |
  79742. (this[offset + 2] << 16)) +
  79743. (this[offset + 3] * 0x1000000)
  79744. }
  79745. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  79746. offset = offset >>> 0
  79747. if (!noAssert) checkOffset(offset, 4, this.length)
  79748. return (this[offset] * 0x1000000) +
  79749. ((this[offset + 1] << 16) |
  79750. (this[offset + 2] << 8) |
  79751. this[offset + 3])
  79752. }
  79753. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  79754. offset = offset >>> 0
  79755. byteLength = byteLength >>> 0
  79756. if (!noAssert) checkOffset(offset, byteLength, this.length)
  79757. var val = this[offset]
  79758. var mul = 1
  79759. var i = 0
  79760. while (++i < byteLength && (mul *= 0x100)) {
  79761. val += this[offset + i] * mul
  79762. }
  79763. mul *= 0x80
  79764. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  79765. return val
  79766. }
  79767. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  79768. offset = offset >>> 0
  79769. byteLength = byteLength >>> 0
  79770. if (!noAssert) checkOffset(offset, byteLength, this.length)
  79771. var i = byteLength
  79772. var mul = 1
  79773. var val = this[offset + --i]
  79774. while (i > 0 && (mul *= 0x100)) {
  79775. val += this[offset + --i] * mul
  79776. }
  79777. mul *= 0x80
  79778. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  79779. return val
  79780. }
  79781. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  79782. offset = offset >>> 0
  79783. if (!noAssert) checkOffset(offset, 1, this.length)
  79784. if (!(this[offset] & 0x80)) return (this[offset])
  79785. return ((0xff - this[offset] + 1) * -1)
  79786. }
  79787. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  79788. offset = offset >>> 0
  79789. if (!noAssert) checkOffset(offset, 2, this.length)
  79790. var val = this[offset] | (this[offset + 1] << 8)
  79791. return (val & 0x8000) ? val | 0xFFFF0000 : val
  79792. }
  79793. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  79794. offset = offset >>> 0
  79795. if (!noAssert) checkOffset(offset, 2, this.length)
  79796. var val = this[offset + 1] | (this[offset] << 8)
  79797. return (val & 0x8000) ? val | 0xFFFF0000 : val
  79798. }
  79799. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  79800. offset = offset >>> 0
  79801. if (!noAssert) checkOffset(offset, 4, this.length)
  79802. return (this[offset]) |
  79803. (this[offset + 1] << 8) |
  79804. (this[offset + 2] << 16) |
  79805. (this[offset + 3] << 24)
  79806. }
  79807. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  79808. offset = offset >>> 0
  79809. if (!noAssert) checkOffset(offset, 4, this.length)
  79810. return (this[offset] << 24) |
  79811. (this[offset + 1] << 16) |
  79812. (this[offset + 2] << 8) |
  79813. (this[offset + 3])
  79814. }
  79815. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  79816. offset = offset >>> 0
  79817. if (!noAssert) checkOffset(offset, 4, this.length)
  79818. return ieee754.read(this, offset, true, 23, 4)
  79819. }
  79820. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  79821. offset = offset >>> 0
  79822. if (!noAssert) checkOffset(offset, 4, this.length)
  79823. return ieee754.read(this, offset, false, 23, 4)
  79824. }
  79825. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  79826. offset = offset >>> 0
  79827. if (!noAssert) checkOffset(offset, 8, this.length)
  79828. return ieee754.read(this, offset, true, 52, 8)
  79829. }
  79830. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  79831. offset = offset >>> 0
  79832. if (!noAssert) checkOffset(offset, 8, this.length)
  79833. return ieee754.read(this, offset, false, 52, 8)
  79834. }
  79835. function checkInt (buf, value, offset, ext, max, min) {
  79836. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  79837. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  79838. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  79839. }
  79840. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  79841. value = +value
  79842. offset = offset >>> 0
  79843. byteLength = byteLength >>> 0
  79844. if (!noAssert) {
  79845. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  79846. checkInt(this, value, offset, byteLength, maxBytes, 0)
  79847. }
  79848. var mul = 1
  79849. var i = 0
  79850. this[offset] = value & 0xFF
  79851. while (++i < byteLength && (mul *= 0x100)) {
  79852. this[offset + i] = (value / mul) & 0xFF
  79853. }
  79854. return offset + byteLength
  79855. }
  79856. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  79857. value = +value
  79858. offset = offset >>> 0
  79859. byteLength = byteLength >>> 0
  79860. if (!noAssert) {
  79861. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  79862. checkInt(this, value, offset, byteLength, maxBytes, 0)
  79863. }
  79864. var i = byteLength - 1
  79865. var mul = 1
  79866. this[offset + i] = value & 0xFF
  79867. while (--i >= 0 && (mul *= 0x100)) {
  79868. this[offset + i] = (value / mul) & 0xFF
  79869. }
  79870. return offset + byteLength
  79871. }
  79872. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  79873. value = +value
  79874. offset = offset >>> 0
  79875. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  79876. this[offset] = (value & 0xff)
  79877. return offset + 1
  79878. }
  79879. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  79880. value = +value
  79881. offset = offset >>> 0
  79882. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  79883. this[offset] = (value & 0xff)
  79884. this[offset + 1] = (value >>> 8)
  79885. return offset + 2
  79886. }
  79887. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  79888. value = +value
  79889. offset = offset >>> 0
  79890. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  79891. this[offset] = (value >>> 8)
  79892. this[offset + 1] = (value & 0xff)
  79893. return offset + 2
  79894. }
  79895. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  79896. value = +value
  79897. offset = offset >>> 0
  79898. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  79899. this[offset + 3] = (value >>> 24)
  79900. this[offset + 2] = (value >>> 16)
  79901. this[offset + 1] = (value >>> 8)
  79902. this[offset] = (value & 0xff)
  79903. return offset + 4
  79904. }
  79905. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  79906. value = +value
  79907. offset = offset >>> 0
  79908. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  79909. this[offset] = (value >>> 24)
  79910. this[offset + 1] = (value >>> 16)
  79911. this[offset + 2] = (value >>> 8)
  79912. this[offset + 3] = (value & 0xff)
  79913. return offset + 4
  79914. }
  79915. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  79916. value = +value
  79917. offset = offset >>> 0
  79918. if (!noAssert) {
  79919. var limit = Math.pow(2, (8 * byteLength) - 1)
  79920. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  79921. }
  79922. var i = 0
  79923. var mul = 1
  79924. var sub = 0
  79925. this[offset] = value & 0xFF
  79926. while (++i < byteLength && (mul *= 0x100)) {
  79927. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  79928. sub = 1
  79929. }
  79930. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  79931. }
  79932. return offset + byteLength
  79933. }
  79934. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  79935. value = +value
  79936. offset = offset >>> 0
  79937. if (!noAssert) {
  79938. var limit = Math.pow(2, (8 * byteLength) - 1)
  79939. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  79940. }
  79941. var i = byteLength - 1
  79942. var mul = 1
  79943. var sub = 0
  79944. this[offset + i] = value & 0xFF
  79945. while (--i >= 0 && (mul *= 0x100)) {
  79946. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  79947. sub = 1
  79948. }
  79949. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  79950. }
  79951. return offset + byteLength
  79952. }
  79953. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  79954. value = +value
  79955. offset = offset >>> 0
  79956. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  79957. if (value < 0) value = 0xff + value + 1
  79958. this[offset] = (value & 0xff)
  79959. return offset + 1
  79960. }
  79961. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  79962. value = +value
  79963. offset = offset >>> 0
  79964. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  79965. this[offset] = (value & 0xff)
  79966. this[offset + 1] = (value >>> 8)
  79967. return offset + 2
  79968. }
  79969. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  79970. value = +value
  79971. offset = offset >>> 0
  79972. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  79973. this[offset] = (value >>> 8)
  79974. this[offset + 1] = (value & 0xff)
  79975. return offset + 2
  79976. }
  79977. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  79978. value = +value
  79979. offset = offset >>> 0
  79980. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  79981. this[offset] = (value & 0xff)
  79982. this[offset + 1] = (value >>> 8)
  79983. this[offset + 2] = (value >>> 16)
  79984. this[offset + 3] = (value >>> 24)
  79985. return offset + 4
  79986. }
  79987. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  79988. value = +value
  79989. offset = offset >>> 0
  79990. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  79991. if (value < 0) value = 0xffffffff + value + 1
  79992. this[offset] = (value >>> 24)
  79993. this[offset + 1] = (value >>> 16)
  79994. this[offset + 2] = (value >>> 8)
  79995. this[offset + 3] = (value & 0xff)
  79996. return offset + 4
  79997. }
  79998. function checkIEEE754 (buf, value, offset, ext, max, min) {
  79999. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  80000. if (offset < 0) throw new RangeError('Index out of range')
  80001. }
  80002. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  80003. value = +value
  80004. offset = offset >>> 0
  80005. if (!noAssert) {
  80006. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  80007. }
  80008. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  80009. return offset + 4
  80010. }
  80011. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  80012. return writeFloat(this, value, offset, true, noAssert)
  80013. }
  80014. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  80015. return writeFloat(this, value, offset, false, noAssert)
  80016. }
  80017. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  80018. value = +value
  80019. offset = offset >>> 0
  80020. if (!noAssert) {
  80021. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  80022. }
  80023. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  80024. return offset + 8
  80025. }
  80026. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  80027. return writeDouble(this, value, offset, true, noAssert)
  80028. }
  80029. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  80030. return writeDouble(this, value, offset, false, noAssert)
  80031. }
  80032. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  80033. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  80034. if (!start) start = 0
  80035. if (!end && end !== 0) end = this.length
  80036. if (targetStart >= target.length) targetStart = target.length
  80037. if (!targetStart) targetStart = 0
  80038. if (end > 0 && end < start) end = start
  80039. // Copy 0 bytes; we're done
  80040. if (end === start) return 0
  80041. if (target.length === 0 || this.length === 0) return 0
  80042. // Fatal error conditions
  80043. if (targetStart < 0) {
  80044. throw new RangeError('targetStart out of bounds')
  80045. }
  80046. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  80047. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  80048. // Are we oob?
  80049. if (end > this.length) end = this.length
  80050. if (target.length - targetStart < end - start) {
  80051. end = target.length - targetStart + start
  80052. }
  80053. var len = end - start
  80054. var i
  80055. if (this === target && start < targetStart && targetStart < end) {
  80056. // descending copy from end
  80057. for (i = len - 1; i >= 0; --i) {
  80058. target[i + targetStart] = this[i + start]
  80059. }
  80060. } else if (len < 1000) {
  80061. // ascending copy from start
  80062. for (i = 0; i < len; ++i) {
  80063. target[i + targetStart] = this[i + start]
  80064. }
  80065. } else {
  80066. Uint8Array.prototype.set.call(
  80067. target,
  80068. this.subarray(start, start + len),
  80069. targetStart
  80070. )
  80071. }
  80072. return len
  80073. }
  80074. // Usage:
  80075. // buffer.fill(number[, offset[, end]])
  80076. // buffer.fill(buffer[, offset[, end]])
  80077. // buffer.fill(string[, offset[, end]][, encoding])
  80078. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  80079. // Handle string cases:
  80080. if (typeof val === 'string') {
  80081. if (typeof start === 'string') {
  80082. encoding = start
  80083. start = 0
  80084. end = this.length
  80085. } else if (typeof end === 'string') {
  80086. encoding = end
  80087. end = this.length
  80088. }
  80089. if (val.length === 1) {
  80090. var code = val.charCodeAt(0)
  80091. if (code < 256) {
  80092. val = code
  80093. }
  80094. }
  80095. if (encoding !== undefined && typeof encoding !== 'string') {
  80096. throw new TypeError('encoding must be a string')
  80097. }
  80098. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  80099. throw new TypeError('Unknown encoding: ' + encoding)
  80100. }
  80101. } else if (typeof val === 'number') {
  80102. val = val & 255
  80103. }
  80104. // Invalid ranges are not set to a default, so can range check early.
  80105. if (start < 0 || this.length < start || this.length < end) {
  80106. throw new RangeError('Out of range index')
  80107. }
  80108. if (end <= start) {
  80109. return this
  80110. }
  80111. start = start >>> 0
  80112. end = end === undefined ? this.length : end >>> 0
  80113. if (!val) val = 0
  80114. var i
  80115. if (typeof val === 'number') {
  80116. for (i = start; i < end; ++i) {
  80117. this[i] = val
  80118. }
  80119. } else {
  80120. var bytes = Buffer.isBuffer(val)
  80121. ? val
  80122. : new Buffer(val, encoding)
  80123. var len = bytes.length
  80124. for (i = 0; i < end - start; ++i) {
  80125. this[i + start] = bytes[i % len]
  80126. }
  80127. }
  80128. return this
  80129. }
  80130. // HELPER FUNCTIONS
  80131. // ================
  80132. var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
  80133. function base64clean (str) {
  80134. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  80135. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  80136. // Node converts strings with length < 2 to ''
  80137. if (str.length < 2) return ''
  80138. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  80139. while (str.length % 4 !== 0) {
  80140. str = str + '='
  80141. }
  80142. return str
  80143. }
  80144. function stringtrim (str) {
  80145. if (str.trim) return str.trim()
  80146. return str.replace(/^\s+|\s+$/g, '')
  80147. }
  80148. function toHex (n) {
  80149. if (n < 16) return '0' + n.toString(16)
  80150. return n.toString(16)
  80151. }
  80152. function utf8ToBytes (string, units) {
  80153. units = units || Infinity
  80154. var codePoint
  80155. var length = string.length
  80156. var leadSurrogate = null
  80157. var bytes = []
  80158. for (var i = 0; i < length; ++i) {
  80159. codePoint = string.charCodeAt(i)
  80160. // is surrogate component
  80161. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  80162. // last char was a lead
  80163. if (!leadSurrogate) {
  80164. // no lead yet
  80165. if (codePoint > 0xDBFF) {
  80166. // unexpected trail
  80167. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  80168. continue
  80169. } else if (i + 1 === length) {
  80170. // unpaired lead
  80171. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  80172. continue
  80173. }
  80174. // valid lead
  80175. leadSurrogate = codePoint
  80176. continue
  80177. }
  80178. // 2 leads in a row
  80179. if (codePoint < 0xDC00) {
  80180. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  80181. leadSurrogate = codePoint
  80182. continue
  80183. }
  80184. // valid surrogate pair
  80185. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  80186. } else if (leadSurrogate) {
  80187. // valid bmp char, but last char was a lead
  80188. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  80189. }
  80190. leadSurrogate = null
  80191. // encode utf8
  80192. if (codePoint < 0x80) {
  80193. if ((units -= 1) < 0) break
  80194. bytes.push(codePoint)
  80195. } else if (codePoint < 0x800) {
  80196. if ((units -= 2) < 0) break
  80197. bytes.push(
  80198. codePoint >> 0x6 | 0xC0,
  80199. codePoint & 0x3F | 0x80
  80200. )
  80201. } else if (codePoint < 0x10000) {
  80202. if ((units -= 3) < 0) break
  80203. bytes.push(
  80204. codePoint >> 0xC | 0xE0,
  80205. codePoint >> 0x6 & 0x3F | 0x80,
  80206. codePoint & 0x3F | 0x80
  80207. )
  80208. } else if (codePoint < 0x110000) {
  80209. if ((units -= 4) < 0) break
  80210. bytes.push(
  80211. codePoint >> 0x12 | 0xF0,
  80212. codePoint >> 0xC & 0x3F | 0x80,
  80213. codePoint >> 0x6 & 0x3F | 0x80,
  80214. codePoint & 0x3F | 0x80
  80215. )
  80216. } else {
  80217. throw new Error('Invalid code point')
  80218. }
  80219. }
  80220. return bytes
  80221. }
  80222. function asciiToBytes (str) {
  80223. var byteArray = []
  80224. for (var i = 0; i < str.length; ++i) {
  80225. // Node's code seems to be doing this and not & 0x7F..
  80226. byteArray.push(str.charCodeAt(i) & 0xFF)
  80227. }
  80228. return byteArray
  80229. }
  80230. function utf16leToBytes (str, units) {
  80231. var c, hi, lo
  80232. var byteArray = []
  80233. for (var i = 0; i < str.length; ++i) {
  80234. if ((units -= 2) < 0) break
  80235. c = str.charCodeAt(i)
  80236. hi = c >> 8
  80237. lo = c % 256
  80238. byteArray.push(lo)
  80239. byteArray.push(hi)
  80240. }
  80241. return byteArray
  80242. }
  80243. function base64ToBytes (str) {
  80244. return base64.toByteArray(base64clean(str))
  80245. }
  80246. function blitBuffer (src, dst, offset, length) {
  80247. for (var i = 0; i < length; ++i) {
  80248. if ((i + offset >= dst.length) || (i >= src.length)) break
  80249. dst[i + offset] = src[i]
  80250. }
  80251. return i
  80252. }
  80253. function isnan (val) {
  80254. return val !== val // eslint-disable-line no-self-compare
  80255. }
  80256. },{"base64-js":62,"ieee754":68}],66:[function(require,module,exports){
  80257. (function (Buffer){
  80258. // Copyright Joyent, Inc. and other Node contributors.
  80259. //
  80260. // Permission is hereby granted, free of charge, to any person obtaining a
  80261. // copy of this software and associated documentation files (the
  80262. // "Software"), to deal in the Software without restriction, including
  80263. // without limitation the rights to use, copy, modify, merge, publish,
  80264. // distribute, sublicense, and/or sell copies of the Software, and to permit
  80265. // persons to whom the Software is furnished to do so, subject to the
  80266. // following conditions:
  80267. //
  80268. // The above copyright notice and this permission notice shall be included
  80269. // in all copies or substantial portions of the Software.
  80270. //
  80271. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  80272. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  80273. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  80274. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  80275. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  80276. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  80277. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  80278. // NOTE: These type checking functions intentionally don't use `instanceof`
  80279. // because it is fragile and can be easily faked with `Object.create()`.
  80280. function isArray(arg) {
  80281. if (Array.isArray) {
  80282. return Array.isArray(arg);
  80283. }
  80284. return objectToString(arg) === '[object Array]';
  80285. }
  80286. exports.isArray = isArray;
  80287. function isBoolean(arg) {
  80288. return typeof arg === 'boolean';
  80289. }
  80290. exports.isBoolean = isBoolean;
  80291. function isNull(arg) {
  80292. return arg === null;
  80293. }
  80294. exports.isNull = isNull;
  80295. function isNullOrUndefined(arg) {
  80296. return arg == null;
  80297. }
  80298. exports.isNullOrUndefined = isNullOrUndefined;
  80299. function isNumber(arg) {
  80300. return typeof arg === 'number';
  80301. }
  80302. exports.isNumber = isNumber;
  80303. function isString(arg) {
  80304. return typeof arg === 'string';
  80305. }
  80306. exports.isString = isString;
  80307. function isSymbol(arg) {
  80308. return typeof arg === 'symbol';
  80309. }
  80310. exports.isSymbol = isSymbol;
  80311. function isUndefined(arg) {
  80312. return arg === void 0;
  80313. }
  80314. exports.isUndefined = isUndefined;
  80315. function isRegExp(re) {
  80316. return objectToString(re) === '[object RegExp]';
  80317. }
  80318. exports.isRegExp = isRegExp;
  80319. function isObject(arg) {
  80320. return typeof arg === 'object' && arg !== null;
  80321. }
  80322. exports.isObject = isObject;
  80323. function isDate(d) {
  80324. return objectToString(d) === '[object Date]';
  80325. }
  80326. exports.isDate = isDate;
  80327. function isError(e) {
  80328. return (objectToString(e) === '[object Error]' || e instanceof Error);
  80329. }
  80330. exports.isError = isError;
  80331. function isFunction(arg) {
  80332. return typeof arg === 'function';
  80333. }
  80334. exports.isFunction = isFunction;
  80335. function isPrimitive(arg) {
  80336. return arg === null ||
  80337. typeof arg === 'boolean' ||
  80338. typeof arg === 'number' ||
  80339. typeof arg === 'string' ||
  80340. typeof arg === 'symbol' || // ES6 symbol
  80341. typeof arg === 'undefined';
  80342. }
  80343. exports.isPrimitive = isPrimitive;
  80344. exports.isBuffer = Buffer.isBuffer;
  80345. function objectToString(o) {
  80346. return Object.prototype.toString.call(o);
  80347. }
  80348. }).call(this,{"isBuffer":require("../../is-buffer/index.js")})
  80349. },{"../../is-buffer/index.js":70}],67:[function(require,module,exports){
  80350. // Copyright Joyent, Inc. and other Node contributors.
  80351. //
  80352. // Permission is hereby granted, free of charge, to any person obtaining a
  80353. // copy of this software and associated documentation files (the
  80354. // "Software"), to deal in the Software without restriction, including
  80355. // without limitation the rights to use, copy, modify, merge, publish,
  80356. // distribute, sublicense, and/or sell copies of the Software, and to permit
  80357. // persons to whom the Software is furnished to do so, subject to the
  80358. // following conditions:
  80359. //
  80360. // The above copyright notice and this permission notice shall be included
  80361. // in all copies or substantial portions of the Software.
  80362. //
  80363. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  80364. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  80365. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  80366. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  80367. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  80368. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  80369. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  80370. function EventEmitter() {
  80371. this._events = this._events || {};
  80372. this._maxListeners = this._maxListeners || undefined;
  80373. }
  80374. module.exports = EventEmitter;
  80375. // Backwards-compat with node 0.10.x
  80376. EventEmitter.EventEmitter = EventEmitter;
  80377. EventEmitter.prototype._events = undefined;
  80378. EventEmitter.prototype._maxListeners = undefined;
  80379. // By default EventEmitters will print a warning if more than 10 listeners are
  80380. // added to it. This is a useful default which helps finding memory leaks.
  80381. EventEmitter.defaultMaxListeners = 10;
  80382. // Obviously not all Emitters should be limited to 10. This function allows
  80383. // that to be increased. Set to zero for unlimited.
  80384. EventEmitter.prototype.setMaxListeners = function(n) {
  80385. if (!isNumber(n) || n < 0 || isNaN(n))
  80386. throw TypeError('n must be a positive number');
  80387. this._maxListeners = n;
  80388. return this;
  80389. };
  80390. EventEmitter.prototype.emit = function(type) {
  80391. var er, handler, len, args, i, listeners;
  80392. if (!this._events)
  80393. this._events = {};
  80394. // If there is no 'error' event listener then throw.
  80395. if (type === 'error') {
  80396. if (!this._events.error ||
  80397. (isObject(this._events.error) && !this._events.error.length)) {
  80398. er = arguments[1];
  80399. if (er instanceof Error) {
  80400. throw er; // Unhandled 'error' event
  80401. } else {
  80402. // At least give some kind of context to the user
  80403. var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
  80404. err.context = er;
  80405. throw err;
  80406. }
  80407. }
  80408. }
  80409. handler = this._events[type];
  80410. if (isUndefined(handler))
  80411. return false;
  80412. if (isFunction(handler)) {
  80413. switch (arguments.length) {
  80414. // fast cases
  80415. case 1:
  80416. handler.call(this);
  80417. break;
  80418. case 2:
  80419. handler.call(this, arguments[1]);
  80420. break;
  80421. case 3:
  80422. handler.call(this, arguments[1], arguments[2]);
  80423. break;
  80424. // slower
  80425. default:
  80426. args = Array.prototype.slice.call(arguments, 1);
  80427. handler.apply(this, args);
  80428. }
  80429. } else if (isObject(handler)) {
  80430. args = Array.prototype.slice.call(arguments, 1);
  80431. listeners = handler.slice();
  80432. len = listeners.length;
  80433. for (i = 0; i < len; i++)
  80434. listeners[i].apply(this, args);
  80435. }
  80436. return true;
  80437. };
  80438. EventEmitter.prototype.addListener = function(type, listener) {
  80439. var m;
  80440. if (!isFunction(listener))
  80441. throw TypeError('listener must be a function');
  80442. if (!this._events)
  80443. this._events = {};
  80444. // To avoid recursion in the case that type === "newListener"! Before
  80445. // adding it to the listeners, first emit "newListener".
  80446. if (this._events.newListener)
  80447. this.emit('newListener', type,
  80448. isFunction(listener.listener) ?
  80449. listener.listener : listener);
  80450. if (!this._events[type])
  80451. // Optimize the case of one listener. Don't need the extra array object.
  80452. this._events[type] = listener;
  80453. else if (isObject(this._events[type]))
  80454. // If we've already got an array, just append.
  80455. this._events[type].push(listener);
  80456. else
  80457. // Adding the second element, need to change to array.
  80458. this._events[type] = [this._events[type], listener];
  80459. // Check for listener leak
  80460. if (isObject(this._events[type]) && !this._events[type].warned) {
  80461. if (!isUndefined(this._maxListeners)) {
  80462. m = this._maxListeners;
  80463. } else {
  80464. m = EventEmitter.defaultMaxListeners;
  80465. }
  80466. if (m && m > 0 && this._events[type].length > m) {
  80467. this._events[type].warned = true;
  80468. console.error('(node) warning: possible EventEmitter memory ' +
  80469. 'leak detected. %d listeners added. ' +
  80470. 'Use emitter.setMaxListeners() to increase limit.',
  80471. this._events[type].length);
  80472. if (typeof console.trace === 'function') {
  80473. // not supported in IE 10
  80474. console.trace();
  80475. }
  80476. }
  80477. }
  80478. return this;
  80479. };
  80480. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  80481. EventEmitter.prototype.once = function(type, listener) {
  80482. if (!isFunction(listener))
  80483. throw TypeError('listener must be a function');
  80484. var fired = false;
  80485. function g() {
  80486. this.removeListener(type, g);
  80487. if (!fired) {
  80488. fired = true;
  80489. listener.apply(this, arguments);
  80490. }
  80491. }
  80492. g.listener = listener;
  80493. this.on(type, g);
  80494. return this;
  80495. };
  80496. // emits a 'removeListener' event iff the listener was removed
  80497. EventEmitter.prototype.removeListener = function(type, listener) {
  80498. var list, position, length, i;
  80499. if (!isFunction(listener))
  80500. throw TypeError('listener must be a function');
  80501. if (!this._events || !this._events[type])
  80502. return this;
  80503. list = this._events[type];
  80504. length = list.length;
  80505. position = -1;
  80506. if (list === listener ||
  80507. (isFunction(list.listener) && list.listener === listener)) {
  80508. delete this._events[type];
  80509. if (this._events.removeListener)
  80510. this.emit('removeListener', type, listener);
  80511. } else if (isObject(list)) {
  80512. for (i = length; i-- > 0;) {
  80513. if (list[i] === listener ||
  80514. (list[i].listener && list[i].listener === listener)) {
  80515. position = i;
  80516. break;
  80517. }
  80518. }
  80519. if (position < 0)
  80520. return this;
  80521. if (list.length === 1) {
  80522. list.length = 0;
  80523. delete this._events[type];
  80524. } else {
  80525. list.splice(position, 1);
  80526. }
  80527. if (this._events.removeListener)
  80528. this.emit('removeListener', type, listener);
  80529. }
  80530. return this;
  80531. };
  80532. EventEmitter.prototype.removeAllListeners = function(type) {
  80533. var key, listeners;
  80534. if (!this._events)
  80535. return this;
  80536. // not listening for removeListener, no need to emit
  80537. if (!this._events.removeListener) {
  80538. if (arguments.length === 0)
  80539. this._events = {};
  80540. else if (this._events[type])
  80541. delete this._events[type];
  80542. return this;
  80543. }
  80544. // emit removeListener for all listeners on all events
  80545. if (arguments.length === 0) {
  80546. for (key in this._events) {
  80547. if (key === 'removeListener') continue;
  80548. this.removeAllListeners(key);
  80549. }
  80550. this.removeAllListeners('removeListener');
  80551. this._events = {};
  80552. return this;
  80553. }
  80554. listeners = this._events[type];
  80555. if (isFunction(listeners)) {
  80556. this.removeListener(type, listeners);
  80557. } else if (listeners) {
  80558. // LIFO order
  80559. while (listeners.length)
  80560. this.removeListener(type, listeners[listeners.length - 1]);
  80561. }
  80562. delete this._events[type];
  80563. return this;
  80564. };
  80565. EventEmitter.prototype.listeners = function(type) {
  80566. var ret;
  80567. if (!this._events || !this._events[type])
  80568. ret = [];
  80569. else if (isFunction(this._events[type]))
  80570. ret = [this._events[type]];
  80571. else
  80572. ret = this._events[type].slice();
  80573. return ret;
  80574. };
  80575. EventEmitter.prototype.listenerCount = function(type) {
  80576. if (this._events) {
  80577. var evlistener = this._events[type];
  80578. if (isFunction(evlistener))
  80579. return 1;
  80580. else if (evlistener)
  80581. return evlistener.length;
  80582. }
  80583. return 0;
  80584. };
  80585. EventEmitter.listenerCount = function(emitter, type) {
  80586. return emitter.listenerCount(type);
  80587. };
  80588. function isFunction(arg) {
  80589. return typeof arg === 'function';
  80590. }
  80591. function isNumber(arg) {
  80592. return typeof arg === 'number';
  80593. }
  80594. function isObject(arg) {
  80595. return typeof arg === 'object' && arg !== null;
  80596. }
  80597. function isUndefined(arg) {
  80598. return arg === void 0;
  80599. }
  80600. },{}],68:[function(require,module,exports){
  80601. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  80602. var e, m
  80603. var eLen = nBytes * 8 - mLen - 1
  80604. var eMax = (1 << eLen) - 1
  80605. var eBias = eMax >> 1
  80606. var nBits = -7
  80607. var i = isLE ? (nBytes - 1) : 0
  80608. var d = isLE ? -1 : 1
  80609. var s = buffer[offset + i]
  80610. i += d
  80611. e = s & ((1 << (-nBits)) - 1)
  80612. s >>= (-nBits)
  80613. nBits += eLen
  80614. for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  80615. m = e & ((1 << (-nBits)) - 1)
  80616. e >>= (-nBits)
  80617. nBits += mLen
  80618. for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  80619. if (e === 0) {
  80620. e = 1 - eBias
  80621. } else if (e === eMax) {
  80622. return m ? NaN : ((s ? -1 : 1) * Infinity)
  80623. } else {
  80624. m = m + Math.pow(2, mLen)
  80625. e = e - eBias
  80626. }
  80627. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  80628. }
  80629. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  80630. var e, m, c
  80631. var eLen = nBytes * 8 - mLen - 1
  80632. var eMax = (1 << eLen) - 1
  80633. var eBias = eMax >> 1
  80634. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  80635. var i = isLE ? 0 : (nBytes - 1)
  80636. var d = isLE ? 1 : -1
  80637. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  80638. value = Math.abs(value)
  80639. if (isNaN(value) || value === Infinity) {
  80640. m = isNaN(value) ? 1 : 0
  80641. e = eMax
  80642. } else {
  80643. e = Math.floor(Math.log(value) / Math.LN2)
  80644. if (value * (c = Math.pow(2, -e)) < 1) {
  80645. e--
  80646. c *= 2
  80647. }
  80648. if (e + eBias >= 1) {
  80649. value += rt / c
  80650. } else {
  80651. value += rt * Math.pow(2, 1 - eBias)
  80652. }
  80653. if (value * c >= 2) {
  80654. e++
  80655. c /= 2
  80656. }
  80657. if (e + eBias >= eMax) {
  80658. m = 0
  80659. e = eMax
  80660. } else if (e + eBias >= 1) {
  80661. m = (value * c - 1) * Math.pow(2, mLen)
  80662. e = e + eBias
  80663. } else {
  80664. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  80665. e = 0
  80666. }
  80667. }
  80668. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  80669. e = (e << mLen) | m
  80670. eLen += mLen
  80671. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  80672. buffer[offset + i - d] |= s * 128
  80673. }
  80674. },{}],69:[function(require,module,exports){
  80675. arguments[4][34][0].apply(exports,arguments)
  80676. },{"dup":34}],70:[function(require,module,exports){
  80677. /*!
  80678. * Determine if an object is a Buffer
  80679. *
  80680. * @author Feross Aboukhadijeh <[email protected]> <http://feross.org>
  80681. * @license MIT
  80682. */
  80683. // The _isBuffer check is for Safari 5-7 support, because it's missing
  80684. // Object.prototype.constructor. Remove this eventually
  80685. module.exports = function (obj) {
  80686. return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
  80687. }
  80688. function isBuffer (obj) {
  80689. return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
  80690. }
  80691. // For Node v0.10 support. Remove this eventually.
  80692. function isSlowBuffer (obj) {
  80693. return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
  80694. }
  80695. },{}],71:[function(require,module,exports){
  80696. var toString = {}.toString;
  80697. module.exports = Array.isArray || function (arr) {
  80698. return toString.call(arr) == '[object Array]';
  80699. };
  80700. },{}],72:[function(require,module,exports){
  80701. (function (process){
  80702. 'use strict';
  80703. if (!process.version ||
  80704. process.version.indexOf('v0.') === 0 ||
  80705. process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
  80706. module.exports = nextTick;
  80707. } else {
  80708. module.exports = process.nextTick;
  80709. }
  80710. function nextTick(fn, arg1, arg2, arg3) {
  80711. if (typeof fn !== 'function') {
  80712. throw new TypeError('"callback" argument must be a function');
  80713. }
  80714. var len = arguments.length;
  80715. var args, i;
  80716. switch (len) {
  80717. case 0:
  80718. case 1:
  80719. return process.nextTick(fn);
  80720. case 2:
  80721. return process.nextTick(function afterTickOne() {
  80722. fn.call(null, arg1);
  80723. });
  80724. case 3:
  80725. return process.nextTick(function afterTickTwo() {
  80726. fn.call(null, arg1, arg2);
  80727. });
  80728. case 4:
  80729. return process.nextTick(function afterTickThree() {
  80730. fn.call(null, arg1, arg2, arg3);
  80731. });
  80732. default:
  80733. args = new Array(len - 1);
  80734. i = 0;
  80735. while (i < args.length) {
  80736. args[i++] = arguments[i];
  80737. }
  80738. return process.nextTick(function afterTick() {
  80739. fn.apply(null, args);
  80740. });
  80741. }
  80742. }
  80743. }).call(this,require('_process'))
  80744. },{"_process":73}],73:[function(require,module,exports){
  80745. // shim for using process in browser
  80746. var process = module.exports = {};
  80747. // cached from whatever global is present so that test runners that stub it
  80748. // don't break things. But we need to wrap it in a try catch in case it is
  80749. // wrapped in strict mode code which doesn't define any globals. It's inside a
  80750. // function because try/catches deoptimize in certain engines.
  80751. var cachedSetTimeout;
  80752. var cachedClearTimeout;
  80753. function defaultSetTimout() {
  80754. throw new Error('setTimeout has not been defined');
  80755. }
  80756. function defaultClearTimeout () {
  80757. throw new Error('clearTimeout has not been defined');
  80758. }
  80759. (function () {
  80760. try {
  80761. if (typeof setTimeout === 'function') {
  80762. cachedSetTimeout = setTimeout;
  80763. } else {
  80764. cachedSetTimeout = defaultSetTimout;
  80765. }
  80766. } catch (e) {
  80767. cachedSetTimeout = defaultSetTimout;
  80768. }
  80769. try {
  80770. if (typeof clearTimeout === 'function') {
  80771. cachedClearTimeout = clearTimeout;
  80772. } else {
  80773. cachedClearTimeout = defaultClearTimeout;
  80774. }
  80775. } catch (e) {
  80776. cachedClearTimeout = defaultClearTimeout;
  80777. }
  80778. } ())
  80779. function runTimeout(fun) {
  80780. if (cachedSetTimeout === setTimeout) {
  80781. //normal enviroments in sane situations
  80782. return setTimeout(fun, 0);
  80783. }
  80784. // if setTimeout wasn't available but was latter defined
  80785. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  80786. cachedSetTimeout = setTimeout;
  80787. return setTimeout(fun, 0);
  80788. }
  80789. try {
  80790. // when when somebody has screwed with setTimeout but no I.E. maddness
  80791. return cachedSetTimeout(fun, 0);
  80792. } catch(e){
  80793. try {
  80794. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  80795. return cachedSetTimeout.call(null, fun, 0);
  80796. } catch(e){
  80797. // 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
  80798. return cachedSetTimeout.call(this, fun, 0);
  80799. }
  80800. }
  80801. }
  80802. function runClearTimeout(marker) {
  80803. if (cachedClearTimeout === clearTimeout) {
  80804. //normal enviroments in sane situations
  80805. return clearTimeout(marker);
  80806. }
  80807. // if clearTimeout wasn't available but was latter defined
  80808. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  80809. cachedClearTimeout = clearTimeout;
  80810. return clearTimeout(marker);
  80811. }
  80812. try {
  80813. // when when somebody has screwed with setTimeout but no I.E. maddness
  80814. return cachedClearTimeout(marker);
  80815. } catch (e){
  80816. try {
  80817. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  80818. return cachedClearTimeout.call(null, marker);
  80819. } catch (e){
  80820. // 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.
  80821. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  80822. return cachedClearTimeout.call(this, marker);
  80823. }
  80824. }
  80825. }
  80826. var queue = [];
  80827. var draining = false;
  80828. var currentQueue;
  80829. var queueIndex = -1;
  80830. function cleanUpNextTick() {
  80831. if (!draining || !currentQueue) {
  80832. return;
  80833. }
  80834. draining = false;
  80835. if (currentQueue.length) {
  80836. queue = currentQueue.concat(queue);
  80837. } else {
  80838. queueIndex = -1;
  80839. }
  80840. if (queue.length) {
  80841. drainQueue();
  80842. }
  80843. }
  80844. function drainQueue() {
  80845. if (draining) {
  80846. return;
  80847. }
  80848. var timeout = runTimeout(cleanUpNextTick);
  80849. draining = true;
  80850. var len = queue.length;
  80851. while(len) {
  80852. currentQueue = queue;
  80853. queue = [];
  80854. while (++queueIndex < len) {
  80855. if (currentQueue) {
  80856. currentQueue[queueIndex].run();
  80857. }
  80858. }
  80859. queueIndex = -1;
  80860. len = queue.length;
  80861. }
  80862. currentQueue = null;
  80863. draining = false;
  80864. runClearTimeout(timeout);
  80865. }
  80866. process.nextTick = function (fun) {
  80867. var args = new Array(arguments.length - 1);
  80868. if (arguments.length > 1) {
  80869. for (var i = 1; i < arguments.length; i++) {
  80870. args[i - 1] = arguments[i];
  80871. }
  80872. }
  80873. queue.push(new Item(fun, args));
  80874. if (queue.length === 1 && !draining) {
  80875. runTimeout(drainQueue);
  80876. }
  80877. };
  80878. // v8 likes predictible objects
  80879. function Item(fun, array) {
  80880. this.fun = fun;
  80881. this.array = array;
  80882. }
  80883. Item.prototype.run = function () {
  80884. this.fun.apply(null, this.array);
  80885. };
  80886. process.title = 'browser';
  80887. process.browser = true;
  80888. process.env = {};
  80889. process.argv = [];
  80890. process.version = ''; // empty string to avoid regexp issues
  80891. process.versions = {};
  80892. function noop() {}
  80893. process.on = noop;
  80894. process.addListener = noop;
  80895. process.once = noop;
  80896. process.off = noop;
  80897. process.removeListener = noop;
  80898. process.removeAllListeners = noop;
  80899. process.emit = noop;
  80900. process.binding = function (name) {
  80901. throw new Error('process.binding is not supported');
  80902. };
  80903. process.cwd = function () { return '/' };
  80904. process.chdir = function (dir) {
  80905. throw new Error('process.chdir is not supported');
  80906. };
  80907. process.umask = function() { return 0; };
  80908. },{}],74:[function(require,module,exports){
  80909. module.exports = require("./lib/_stream_duplex.js")
  80910. },{"./lib/_stream_duplex.js":75}],75:[function(require,module,exports){
  80911. // a duplex stream is just a stream that is both readable and writable.
  80912. // Since JS doesn't have multiple prototypal inheritance, this class
  80913. // prototypally inherits from Readable, and then parasitically from
  80914. // Writable.
  80915. 'use strict';
  80916. /*<replacement>*/
  80917. var objectKeys = Object.keys || function (obj) {
  80918. var keys = [];
  80919. for (var key in obj) {
  80920. keys.push(key);
  80921. }return keys;
  80922. };
  80923. /*</replacement>*/
  80924. module.exports = Duplex;
  80925. /*<replacement>*/
  80926. var processNextTick = require('process-nextick-args');
  80927. /*</replacement>*/
  80928. /*<replacement>*/
  80929. var util = require('core-util-is');
  80930. util.inherits = require('inherits');
  80931. /*</replacement>*/
  80932. var Readable = require('./_stream_readable');
  80933. var Writable = require('./_stream_writable');
  80934. util.inherits(Duplex, Readable);
  80935. var keys = objectKeys(Writable.prototype);
  80936. for (var v = 0; v < keys.length; v++) {
  80937. var method = keys[v];
  80938. if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
  80939. }
  80940. function Duplex(options) {
  80941. if (!(this instanceof Duplex)) return new Duplex(options);
  80942. Readable.call(this, options);
  80943. Writable.call(this, options);
  80944. if (options && options.readable === false) this.readable = false;
  80945. if (options && options.writable === false) this.writable = false;
  80946. this.allowHalfOpen = true;
  80947. if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
  80948. this.once('end', onend);
  80949. }
  80950. // the no-half-open enforcer
  80951. function onend() {
  80952. // if we allow half-open state, or if the writable side ended,
  80953. // then we're ok.
  80954. if (this.allowHalfOpen || this._writableState.ended) return;
  80955. // no more data can be written.
  80956. // But allow more writes to happen in this tick.
  80957. processNextTick(onEndNT, this);
  80958. }
  80959. function onEndNT(self) {
  80960. self.end();
  80961. }
  80962. function forEach(xs, f) {
  80963. for (var i = 0, l = xs.length; i < l; i++) {
  80964. f(xs[i], i);
  80965. }
  80966. }
  80967. },{"./_stream_readable":77,"./_stream_writable":79,"core-util-is":66,"inherits":69,"process-nextick-args":72}],76:[function(require,module,exports){
  80968. // a passthrough stream.
  80969. // basically just the most minimal sort of Transform stream.
  80970. // Every written chunk gets output as-is.
  80971. 'use strict';
  80972. module.exports = PassThrough;
  80973. var Transform = require('./_stream_transform');
  80974. /*<replacement>*/
  80975. var util = require('core-util-is');
  80976. util.inherits = require('inherits');
  80977. /*</replacement>*/
  80978. util.inherits(PassThrough, Transform);
  80979. function PassThrough(options) {
  80980. if (!(this instanceof PassThrough)) return new PassThrough(options);
  80981. Transform.call(this, options);
  80982. }
  80983. PassThrough.prototype._transform = function (chunk, encoding, cb) {
  80984. cb(null, chunk);
  80985. };
  80986. },{"./_stream_transform":78,"core-util-is":66,"inherits":69}],77:[function(require,module,exports){
  80987. (function (process){
  80988. 'use strict';
  80989. module.exports = Readable;
  80990. /*<replacement>*/
  80991. var processNextTick = require('process-nextick-args');
  80992. /*</replacement>*/
  80993. /*<replacement>*/
  80994. var isArray = require('isarray');
  80995. /*</replacement>*/
  80996. /*<replacement>*/
  80997. var Duplex;
  80998. /*</replacement>*/
  80999. Readable.ReadableState = ReadableState;
  81000. /*<replacement>*/
  81001. var EE = require('events').EventEmitter;
  81002. var EElistenerCount = function (emitter, type) {
  81003. return emitter.listeners(type).length;
  81004. };
  81005. /*</replacement>*/
  81006. /*<replacement>*/
  81007. var Stream;
  81008. (function () {
  81009. try {
  81010. Stream = require('st' + 'ream');
  81011. } catch (_) {} finally {
  81012. if (!Stream) Stream = require('events').EventEmitter;
  81013. }
  81014. })();
  81015. /*</replacement>*/
  81016. var Buffer = require('buffer').Buffer;
  81017. /*<replacement>*/
  81018. var bufferShim = require('buffer-shims');
  81019. /*</replacement>*/
  81020. /*<replacement>*/
  81021. var util = require('core-util-is');
  81022. util.inherits = require('inherits');
  81023. /*</replacement>*/
  81024. /*<replacement>*/
  81025. var debugUtil = require('util');
  81026. var debug = void 0;
  81027. if (debugUtil && debugUtil.debuglog) {
  81028. debug = debugUtil.debuglog('stream');
  81029. } else {
  81030. debug = function () {};
  81031. }
  81032. /*</replacement>*/
  81033. var BufferList = require('./internal/streams/BufferList');
  81034. var StringDecoder;
  81035. util.inherits(Readable, Stream);
  81036. function prependListener(emitter, event, fn) {
  81037. // Sadly this is not cacheable as some libraries bundle their own
  81038. // event emitter implementation with them.
  81039. if (typeof emitter.prependListener === 'function') {
  81040. return emitter.prependListener(event, fn);
  81041. } else {
  81042. // This is a hack to make sure that our error handler is attached before any
  81043. // userland ones. NEVER DO THIS. This is here only because this code needs
  81044. // to continue to work with older versions of Node.js that do not include
  81045. // the prependListener() method. The goal is to eventually remove this hack.
  81046. if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
  81047. }
  81048. }
  81049. function ReadableState(options, stream) {
  81050. Duplex = Duplex || require('./_stream_duplex');
  81051. options = options || {};
  81052. // object stream flag. Used to make read(n) ignore n and to
  81053. // make all the buffer merging and length checks go away
  81054. this.objectMode = !!options.objectMode;
  81055. if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
  81056. // the point at which it stops calling _read() to fill the buffer
  81057. // Note: 0 is a valid value, means "don't call _read preemptively ever"
  81058. var hwm = options.highWaterMark;
  81059. var defaultHwm = this.objectMode ? 16 : 16 * 1024;
  81060. this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
  81061. // cast to ints.
  81062. this.highWaterMark = ~ ~this.highWaterMark;
  81063. // A linked list is used to store data chunks instead of an array because the
  81064. // linked list can remove elements from the beginning faster than
  81065. // array.shift()
  81066. this.buffer = new BufferList();
  81067. this.length = 0;
  81068. this.pipes = null;
  81069. this.pipesCount = 0;
  81070. this.flowing = null;
  81071. this.ended = false;
  81072. this.endEmitted = false;
  81073. this.reading = false;
  81074. // a flag to be able to tell if the onwrite cb is called immediately,
  81075. // or on a later tick. We set this to true at first, because any
  81076. // actions that shouldn't happen until "later" should generally also
  81077. // not happen before the first write call.
  81078. this.sync = true;
  81079. // whenever we return null, then we set a flag to say
  81080. // that we're awaiting a 'readable' event emission.
  81081. this.needReadable = false;
  81082. this.emittedReadable = false;
  81083. this.readableListening = false;
  81084. this.resumeScheduled = false;
  81085. // Crypto is kind of old and crusty. Historically, its default string
  81086. // encoding is 'binary' so we have to make this configurable.
  81087. // Everything else in the universe uses 'utf8', though.
  81088. this.defaultEncoding = options.defaultEncoding || 'utf8';
  81089. // when piping, we only care about 'readable' events that happen
  81090. // after read()ing all the bytes and not getting any pushback.
  81091. this.ranOut = false;
  81092. // the number of writers that are awaiting a drain event in .pipe()s
  81093. this.awaitDrain = 0;
  81094. // if true, a maybeReadMore has been scheduled
  81095. this.readingMore = false;
  81096. this.decoder = null;
  81097. this.encoding = null;
  81098. if (options.encoding) {
  81099. if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
  81100. this.decoder = new StringDecoder(options.encoding);
  81101. this.encoding = options.encoding;
  81102. }
  81103. }
  81104. function Readable(options) {
  81105. Duplex = Duplex || require('./_stream_duplex');
  81106. if (!(this instanceof Readable)) return new Readable(options);
  81107. this._readableState = new ReadableState(options, this);
  81108. // legacy
  81109. this.readable = true;
  81110. if (options && typeof options.read === 'function') this._read = options.read;
  81111. Stream.call(this);
  81112. }
  81113. // Manually shove something into the read() buffer.
  81114. // This returns true if the highWaterMark has not been hit yet,
  81115. // similar to how Writable.write() returns true if you should
  81116. // write() some more.
  81117. Readable.prototype.push = function (chunk, encoding) {
  81118. var state = this._readableState;
  81119. if (!state.objectMode && typeof chunk === 'string') {
  81120. encoding = encoding || state.defaultEncoding;
  81121. if (encoding !== state.encoding) {
  81122. chunk = bufferShim.from(chunk, encoding);
  81123. encoding = '';
  81124. }
  81125. }
  81126. return readableAddChunk(this, state, chunk, encoding, false);
  81127. };
  81128. // Unshift should *always* be something directly out of read()
  81129. Readable.prototype.unshift = function (chunk) {
  81130. var state = this._readableState;
  81131. return readableAddChunk(this, state, chunk, '', true);
  81132. };
  81133. Readable.prototype.isPaused = function () {
  81134. return this._readableState.flowing === false;
  81135. };
  81136. function readableAddChunk(stream, state, chunk, encoding, addToFront) {
  81137. var er = chunkInvalid(state, chunk);
  81138. if (er) {
  81139. stream.emit('error', er);
  81140. } else if (chunk === null) {
  81141. state.reading = false;
  81142. onEofChunk(stream, state);
  81143. } else if (state.objectMode || chunk && chunk.length > 0) {
  81144. if (state.ended && !addToFront) {
  81145. var e = new Error('stream.push() after EOF');
  81146. stream.emit('error', e);
  81147. } else if (state.endEmitted && addToFront) {
  81148. var _e = new Error('stream.unshift() after end event');
  81149. stream.emit('error', _e);
  81150. } else {
  81151. var skipAdd;
  81152. if (state.decoder && !addToFront && !encoding) {
  81153. chunk = state.decoder.write(chunk);
  81154. skipAdd = !state.objectMode && chunk.length === 0;
  81155. }
  81156. if (!addToFront) state.reading = false;
  81157. // Don't add to the buffer if we've decoded to an empty string chunk and
  81158. // we're not in object mode
  81159. if (!skipAdd) {
  81160. // if we want the data now, just emit it.
  81161. if (state.flowing && state.length === 0 && !state.sync) {
  81162. stream.emit('data', chunk);
  81163. stream.read(0);
  81164. } else {
  81165. // update the buffer info.
  81166. state.length += state.objectMode ? 1 : chunk.length;
  81167. if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
  81168. if (state.needReadable) emitReadable(stream);
  81169. }
  81170. }
  81171. maybeReadMore(stream, state);
  81172. }
  81173. } else if (!addToFront) {
  81174. state.reading = false;
  81175. }
  81176. return needMoreData(state);
  81177. }
  81178. // if it's past the high water mark, we can push in some more.
  81179. // Also, if we have no data yet, we can stand some
  81180. // more bytes. This is to work around cases where hwm=0,
  81181. // such as the repl. Also, if the push() triggered a
  81182. // readable event, and the user called read(largeNumber) such that
  81183. // needReadable was set, then we ought to push more, so that another
  81184. // 'readable' event will be triggered.
  81185. function needMoreData(state) {
  81186. return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
  81187. }
  81188. // backwards compatibility.
  81189. Readable.prototype.setEncoding = function (enc) {
  81190. if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
  81191. this._readableState.decoder = new StringDecoder(enc);
  81192. this._readableState.encoding = enc;
  81193. return this;
  81194. };
  81195. // Don't raise the hwm > 8MB
  81196. var MAX_HWM = 0x800000;
  81197. function computeNewHighWaterMark(n) {
  81198. if (n >= MAX_HWM) {
  81199. n = MAX_HWM;
  81200. } else {
  81201. // Get the next highest power of 2 to prevent increasing hwm excessively in
  81202. // tiny amounts
  81203. n--;
  81204. n |= n >>> 1;
  81205. n |= n >>> 2;
  81206. n |= n >>> 4;
  81207. n |= n >>> 8;
  81208. n |= n >>> 16;
  81209. n++;
  81210. }
  81211. return n;
  81212. }
  81213. // This function is designed to be inlinable, so please take care when making
  81214. // changes to the function body.
  81215. function howMuchToRead(n, state) {
  81216. if (n <= 0 || state.length === 0 && state.ended) return 0;
  81217. if (state.objectMode) return 1;
  81218. if (n !== n) {
  81219. // Only flow one buffer at a time
  81220. if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
  81221. }
  81222. // If we're asking for more than the current hwm, then raise the hwm.
  81223. if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
  81224. if (n <= state.length) return n;
  81225. // Don't have enough
  81226. if (!state.ended) {
  81227. state.needReadable = true;
  81228. return 0;
  81229. }
  81230. return state.length;
  81231. }
  81232. // you can override either this method, or the async _read(n) below.
  81233. Readable.prototype.read = function (n) {
  81234. debug('read', n);
  81235. n = parseInt(n, 10);
  81236. var state = this._readableState;
  81237. var nOrig = n;
  81238. if (n !== 0) state.emittedReadable = false;
  81239. // if we're doing read(0) to trigger a readable event, but we
  81240. // already have a bunch of data in the buffer, then just trigger
  81241. // the 'readable' event and move on.
  81242. if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
  81243. debug('read: emitReadable', state.length, state.ended);
  81244. if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
  81245. return null;
  81246. }
  81247. n = howMuchToRead(n, state);
  81248. // if we've ended, and we're now clear, then finish it up.
  81249. if (n === 0 && state.ended) {
  81250. if (state.length === 0) endReadable(this);
  81251. return null;
  81252. }
  81253. // All the actual chunk generation logic needs to be
  81254. // *below* the call to _read. The reason is that in certain
  81255. // synthetic stream cases, such as passthrough streams, _read
  81256. // may be a completely synchronous operation which may change
  81257. // the state of the read buffer, providing enough data when
  81258. // before there was *not* enough.
  81259. //
  81260. // So, the steps are:
  81261. // 1. Figure out what the state of things will be after we do
  81262. // a read from the buffer.
  81263. //
  81264. // 2. If that resulting state will trigger a _read, then call _read.
  81265. // Note that this may be asynchronous, or synchronous. Yes, it is
  81266. // deeply ugly to write APIs this way, but that still doesn't mean
  81267. // that the Readable class should behave improperly, as streams are
  81268. // designed to be sync/async agnostic.
  81269. // Take note if the _read call is sync or async (ie, if the read call
  81270. // has returned yet), so that we know whether or not it's safe to emit
  81271. // 'readable' etc.
  81272. //
  81273. // 3. Actually pull the requested chunks out of the buffer and return.
  81274. // if we need a readable event, then we need to do some reading.
  81275. var doRead = state.needReadable;
  81276. debug('need readable', doRead);
  81277. // if we currently have less than the highWaterMark, then also read some
  81278. if (state.length === 0 || state.length - n < state.highWaterMark) {
  81279. doRead = true;
  81280. debug('length less than watermark', doRead);
  81281. }
  81282. // however, if we've ended, then there's no point, and if we're already
  81283. // reading, then it's unnecessary.
  81284. if (state.ended || state.reading) {
  81285. doRead = false;
  81286. debug('reading or ended', doRead);
  81287. } else if (doRead) {
  81288. debug('do read');
  81289. state.reading = true;
  81290. state.sync = true;
  81291. // if the length is currently zero, then we *need* a readable event.
  81292. if (state.length === 0) state.needReadable = true;
  81293. // call internal read method
  81294. this._read(state.highWaterMark);
  81295. state.sync = false;
  81296. // If _read pushed data synchronously, then `reading` will be false,
  81297. // and we need to re-evaluate how much data we can return to the user.
  81298. if (!state.reading) n = howMuchToRead(nOrig, state);
  81299. }
  81300. var ret;
  81301. if (n > 0) ret = fromList(n, state);else ret = null;
  81302. if (ret === null) {
  81303. state.needReadable = true;
  81304. n = 0;
  81305. } else {
  81306. state.length -= n;
  81307. }
  81308. if (state.length === 0) {
  81309. // If we have nothing in the buffer, then we want to know
  81310. // as soon as we *do* get something into the buffer.
  81311. if (!state.ended) state.needReadable = true;
  81312. // If we tried to read() past the EOF, then emit end on the next tick.
  81313. if (nOrig !== n && state.ended) endReadable(this);
  81314. }
  81315. if (ret !== null) this.emit('data', ret);
  81316. return ret;
  81317. };
  81318. function chunkInvalid(state, chunk) {
  81319. var er = null;
  81320. if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== null && chunk !== undefined && !state.objectMode) {
  81321. er = new TypeError('Invalid non-string/buffer chunk');
  81322. }
  81323. return er;
  81324. }
  81325. function onEofChunk(stream, state) {
  81326. if (state.ended) return;
  81327. if (state.decoder) {
  81328. var chunk = state.decoder.end();
  81329. if (chunk && chunk.length) {
  81330. state.buffer.push(chunk);
  81331. state.length += state.objectMode ? 1 : chunk.length;
  81332. }
  81333. }
  81334. state.ended = true;
  81335. // emit 'readable' now to make sure it gets picked up.
  81336. emitReadable(stream);
  81337. }
  81338. // Don't emit readable right away in sync mode, because this can trigger
  81339. // another read() call => stack overflow. This way, it might trigger
  81340. // a nextTick recursion warning, but that's not so bad.
  81341. function emitReadable(stream) {
  81342. var state = stream._readableState;
  81343. state.needReadable = false;
  81344. if (!state.emittedReadable) {
  81345. debug('emitReadable', state.flowing);
  81346. state.emittedReadable = true;
  81347. if (state.sync) processNextTick(emitReadable_, stream);else emitReadable_(stream);
  81348. }
  81349. }
  81350. function emitReadable_(stream) {
  81351. debug('emit readable');
  81352. stream.emit('readable');
  81353. flow(stream);
  81354. }
  81355. // at this point, the user has presumably seen the 'readable' event,
  81356. // and called read() to consume some data. that may have triggered
  81357. // in turn another _read(n) call, in which case reading = true if
  81358. // it's in progress.
  81359. // However, if we're not ended, or reading, and the length < hwm,
  81360. // then go ahead and try to read some more preemptively.
  81361. function maybeReadMore(stream, state) {
  81362. if (!state.readingMore) {
  81363. state.readingMore = true;
  81364. processNextTick(maybeReadMore_, stream, state);
  81365. }
  81366. }
  81367. function maybeReadMore_(stream, state) {
  81368. var len = state.length;
  81369. while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
  81370. debug('maybeReadMore read 0');
  81371. stream.read(0);
  81372. if (len === state.length)
  81373. // didn't get any data, stop spinning.
  81374. break;else len = state.length;
  81375. }
  81376. state.readingMore = false;
  81377. }
  81378. // abstract method. to be overridden in specific implementation classes.
  81379. // call cb(er, data) where data is <= n in length.
  81380. // for virtual (non-string, non-buffer) streams, "length" is somewhat
  81381. // arbitrary, and perhaps not very meaningful.
  81382. Readable.prototype._read = function (n) {
  81383. this.emit('error', new Error('_read() is not implemented'));
  81384. };
  81385. Readable.prototype.pipe = function (dest, pipeOpts) {
  81386. var src = this;
  81387. var state = this._readableState;
  81388. switch (state.pipesCount) {
  81389. case 0:
  81390. state.pipes = dest;
  81391. break;
  81392. case 1:
  81393. state.pipes = [state.pipes, dest];
  81394. break;
  81395. default:
  81396. state.pipes.push(dest);
  81397. break;
  81398. }
  81399. state.pipesCount += 1;
  81400. debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
  81401. var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
  81402. var endFn = doEnd ? onend : cleanup;
  81403. if (state.endEmitted) processNextTick(endFn);else src.once('end', endFn);
  81404. dest.on('unpipe', onunpipe);
  81405. function onunpipe(readable) {
  81406. debug('onunpipe');
  81407. if (readable === src) {
  81408. cleanup();
  81409. }
  81410. }
  81411. function onend() {
  81412. debug('onend');
  81413. dest.end();
  81414. }
  81415. // when the dest drains, it reduces the awaitDrain counter
  81416. // on the source. This would be more elegant with a .once()
  81417. // handler in flow(), but adding and removing repeatedly is
  81418. // too slow.
  81419. var ondrain = pipeOnDrain(src);
  81420. dest.on('drain', ondrain);
  81421. var cleanedUp = false;
  81422. function cleanup() {
  81423. debug('cleanup');
  81424. // cleanup event handlers once the pipe is broken
  81425. dest.removeListener('close', onclose);
  81426. dest.removeListener('finish', onfinish);
  81427. dest.removeListener('drain', ondrain);
  81428. dest.removeListener('error', onerror);
  81429. dest.removeListener('unpipe', onunpipe);
  81430. src.removeListener('end', onend);
  81431. src.removeListener('end', cleanup);
  81432. src.removeListener('data', ondata);
  81433. cleanedUp = true;
  81434. // if the reader is waiting for a drain event from this
  81435. // specific writer, then it would cause it to never start
  81436. // flowing again.
  81437. // So, if this is awaiting a drain, then we just call it now.
  81438. // If we don't know, then assume that we are waiting for one.
  81439. if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
  81440. }
  81441. // If the user pushes more data while we're writing to dest then we'll end up
  81442. // in ondata again. However, we only want to increase awaitDrain once because
  81443. // dest will only emit one 'drain' event for the multiple writes.
  81444. // => Introduce a guard on increasing awaitDrain.
  81445. var increasedAwaitDrain = false;
  81446. src.on('data', ondata);
  81447. function ondata(chunk) {
  81448. debug('ondata');
  81449. increasedAwaitDrain = false;
  81450. var ret = dest.write(chunk);
  81451. if (false === ret && !increasedAwaitDrain) {
  81452. // If the user unpiped during `dest.write()`, it is possible
  81453. // to get stuck in a permanently paused state if that write
  81454. // also returned false.
  81455. // => Check whether `dest` is still a piping destination.
  81456. if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
  81457. debug('false write response, pause', src._readableState.awaitDrain);
  81458. src._readableState.awaitDrain++;
  81459. increasedAwaitDrain = true;
  81460. }
  81461. src.pause();
  81462. }
  81463. }
  81464. // if the dest has an error, then stop piping into it.
  81465. // however, don't suppress the throwing behavior for this.
  81466. function onerror(er) {
  81467. debug('onerror', er);
  81468. unpipe();
  81469. dest.removeListener('error', onerror);
  81470. if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
  81471. }
  81472. // Make sure our error handler is attached before userland ones.
  81473. prependListener(dest, 'error', onerror);
  81474. // Both close and finish should trigger unpipe, but only once.
  81475. function onclose() {
  81476. dest.removeListener('finish', onfinish);
  81477. unpipe();
  81478. }
  81479. dest.once('close', onclose);
  81480. function onfinish() {
  81481. debug('onfinish');
  81482. dest.removeListener('close', onclose);
  81483. unpipe();
  81484. }
  81485. dest.once('finish', onfinish);
  81486. function unpipe() {
  81487. debug('unpipe');
  81488. src.unpipe(dest);
  81489. }
  81490. // tell the dest that it's being piped to
  81491. dest.emit('pipe', src);
  81492. // start the flow if it hasn't been started already.
  81493. if (!state.flowing) {
  81494. debug('pipe resume');
  81495. src.resume();
  81496. }
  81497. return dest;
  81498. };
  81499. function pipeOnDrain(src) {
  81500. return function () {
  81501. var state = src._readableState;
  81502. debug('pipeOnDrain', state.awaitDrain);
  81503. if (state.awaitDrain) state.awaitDrain--;
  81504. if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
  81505. state.flowing = true;
  81506. flow(src);
  81507. }
  81508. };
  81509. }
  81510. Readable.prototype.unpipe = function (dest) {
  81511. var state = this._readableState;
  81512. // if we're not piping anywhere, then do nothing.
  81513. if (state.pipesCount === 0) return this;
  81514. // just one destination. most common case.
  81515. if (state.pipesCount === 1) {
  81516. // passed in one, but it's not the right one.
  81517. if (dest && dest !== state.pipes) return this;
  81518. if (!dest) dest = state.pipes;
  81519. // got a match.
  81520. state.pipes = null;
  81521. state.pipesCount = 0;
  81522. state.flowing = false;
  81523. if (dest) dest.emit('unpipe', this);
  81524. return this;
  81525. }
  81526. // slow case. multiple pipe destinations.
  81527. if (!dest) {
  81528. // remove all.
  81529. var dests = state.pipes;
  81530. var len = state.pipesCount;
  81531. state.pipes = null;
  81532. state.pipesCount = 0;
  81533. state.flowing = false;
  81534. for (var i = 0; i < len; i++) {
  81535. dests[i].emit('unpipe', this);
  81536. }return this;
  81537. }
  81538. // try to find the right one.
  81539. var index = indexOf(state.pipes, dest);
  81540. if (index === -1) return this;
  81541. state.pipes.splice(index, 1);
  81542. state.pipesCount -= 1;
  81543. if (state.pipesCount === 1) state.pipes = state.pipes[0];
  81544. dest.emit('unpipe', this);
  81545. return this;
  81546. };
  81547. // set up data events if they are asked for
  81548. // Ensure readable listeners eventually get something
  81549. Readable.prototype.on = function (ev, fn) {
  81550. var res = Stream.prototype.on.call(this, ev, fn);
  81551. if (ev === 'data') {
  81552. // Start flowing on next tick if stream isn't explicitly paused
  81553. if (this._readableState.flowing !== false) this.resume();
  81554. } else if (ev === 'readable') {
  81555. var state = this._readableState;
  81556. if (!state.endEmitted && !state.readableListening) {
  81557. state.readableListening = state.needReadable = true;
  81558. state.emittedReadable = false;
  81559. if (!state.reading) {
  81560. processNextTick(nReadingNextTick, this);
  81561. } else if (state.length) {
  81562. emitReadable(this, state);
  81563. }
  81564. }
  81565. }
  81566. return res;
  81567. };
  81568. Readable.prototype.addListener = Readable.prototype.on;
  81569. function nReadingNextTick(self) {
  81570. debug('readable nexttick read 0');
  81571. self.read(0);
  81572. }
  81573. // pause() and resume() are remnants of the legacy readable stream API
  81574. // If the user uses them, then switch into old mode.
  81575. Readable.prototype.resume = function () {
  81576. var state = this._readableState;
  81577. if (!state.flowing) {
  81578. debug('resume');
  81579. state.flowing = true;
  81580. resume(this, state);
  81581. }
  81582. return this;
  81583. };
  81584. function resume(stream, state) {
  81585. if (!state.resumeScheduled) {
  81586. state.resumeScheduled = true;
  81587. processNextTick(resume_, stream, state);
  81588. }
  81589. }
  81590. function resume_(stream, state) {
  81591. if (!state.reading) {
  81592. debug('resume read 0');
  81593. stream.read(0);
  81594. }
  81595. state.resumeScheduled = false;
  81596. state.awaitDrain = 0;
  81597. stream.emit('resume');
  81598. flow(stream);
  81599. if (state.flowing && !state.reading) stream.read(0);
  81600. }
  81601. Readable.prototype.pause = function () {
  81602. debug('call pause flowing=%j', this._readableState.flowing);
  81603. if (false !== this._readableState.flowing) {
  81604. debug('pause');
  81605. this._readableState.flowing = false;
  81606. this.emit('pause');
  81607. }
  81608. return this;
  81609. };
  81610. function flow(stream) {
  81611. var state = stream._readableState;
  81612. debug('flow', state.flowing);
  81613. while (state.flowing && stream.read() !== null) {}
  81614. }
  81615. // wrap an old-style stream as the async data source.
  81616. // This is *not* part of the readable stream interface.
  81617. // It is an ugly unfortunate mess of history.
  81618. Readable.prototype.wrap = function (stream) {
  81619. var state = this._readableState;
  81620. var paused = false;
  81621. var self = this;
  81622. stream.on('end', function () {
  81623. debug('wrapped end');
  81624. if (state.decoder && !state.ended) {
  81625. var chunk = state.decoder.end();
  81626. if (chunk && chunk.length) self.push(chunk);
  81627. }
  81628. self.push(null);
  81629. });
  81630. stream.on('data', function (chunk) {
  81631. debug('wrapped data');
  81632. if (state.decoder) chunk = state.decoder.write(chunk);
  81633. // don't skip over falsy values in objectMode
  81634. if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
  81635. var ret = self.push(chunk);
  81636. if (!ret) {
  81637. paused = true;
  81638. stream.pause();
  81639. }
  81640. });
  81641. // proxy all the other methods.
  81642. // important when wrapping filters and duplexes.
  81643. for (var i in stream) {
  81644. if (this[i] === undefined && typeof stream[i] === 'function') {
  81645. this[i] = function (method) {
  81646. return function () {
  81647. return stream[method].apply(stream, arguments);
  81648. };
  81649. }(i);
  81650. }
  81651. }
  81652. // proxy certain important events.
  81653. var events = ['error', 'close', 'destroy', 'pause', 'resume'];
  81654. forEach(events, function (ev) {
  81655. stream.on(ev, self.emit.bind(self, ev));
  81656. });
  81657. // when we try to consume some more bytes, simply unpause the
  81658. // underlying stream.
  81659. self._read = function (n) {
  81660. debug('wrapped _read', n);
  81661. if (paused) {
  81662. paused = false;
  81663. stream.resume();
  81664. }
  81665. };
  81666. return self;
  81667. };
  81668. // exposed for testing purposes only.
  81669. Readable._fromList = fromList;
  81670. // Pluck off n bytes from an array of buffers.
  81671. // Length is the combined lengths of all the buffers in the list.
  81672. // This function is designed to be inlinable, so please take care when making
  81673. // changes to the function body.
  81674. function fromList(n, state) {
  81675. // nothing buffered
  81676. if (state.length === 0) return null;
  81677. var ret;
  81678. if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
  81679. // read it all, truncate the list
  81680. if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);
  81681. state.buffer.clear();
  81682. } else {
  81683. // read part of list
  81684. ret = fromListPartial(n, state.buffer, state.decoder);
  81685. }
  81686. return ret;
  81687. }
  81688. // Extracts only enough buffered data to satisfy the amount requested.
  81689. // This function is designed to be inlinable, so please take care when making
  81690. // changes to the function body.
  81691. function fromListPartial(n, list, hasStrings) {
  81692. var ret;
  81693. if (n < list.head.data.length) {
  81694. // slice is the same for buffers and strings
  81695. ret = list.head.data.slice(0, n);
  81696. list.head.data = list.head.data.slice(n);
  81697. } else if (n === list.head.data.length) {
  81698. // first chunk is a perfect match
  81699. ret = list.shift();
  81700. } else {
  81701. // result spans more than one buffer
  81702. ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
  81703. }
  81704. return ret;
  81705. }
  81706. // Copies a specified amount of characters from the list of buffered data
  81707. // chunks.
  81708. // This function is designed to be inlinable, so please take care when making
  81709. // changes to the function body.
  81710. function copyFromBufferString(n, list) {
  81711. var p = list.head;
  81712. var c = 1;
  81713. var ret = p.data;
  81714. n -= ret.length;
  81715. while (p = p.next) {
  81716. var str = p.data;
  81717. var nb = n > str.length ? str.length : n;
  81718. if (nb === str.length) ret += str;else ret += str.slice(0, n);
  81719. n -= nb;
  81720. if (n === 0) {
  81721. if (nb === str.length) {
  81722. ++c;
  81723. if (p.next) list.head = p.next;else list.head = list.tail = null;
  81724. } else {
  81725. list.head = p;
  81726. p.data = str.slice(nb);
  81727. }
  81728. break;
  81729. }
  81730. ++c;
  81731. }
  81732. list.length -= c;
  81733. return ret;
  81734. }
  81735. // Copies a specified amount of bytes from the list of buffered data chunks.
  81736. // This function is designed to be inlinable, so please take care when making
  81737. // changes to the function body.
  81738. function copyFromBuffer(n, list) {
  81739. var ret = bufferShim.allocUnsafe(n);
  81740. var p = list.head;
  81741. var c = 1;
  81742. p.data.copy(ret);
  81743. n -= p.data.length;
  81744. while (p = p.next) {
  81745. var buf = p.data;
  81746. var nb = n > buf.length ? buf.length : n;
  81747. buf.copy(ret, ret.length - n, 0, nb);
  81748. n -= nb;
  81749. if (n === 0) {
  81750. if (nb === buf.length) {
  81751. ++c;
  81752. if (p.next) list.head = p.next;else list.head = list.tail = null;
  81753. } else {
  81754. list.head = p;
  81755. p.data = buf.slice(nb);
  81756. }
  81757. break;
  81758. }
  81759. ++c;
  81760. }
  81761. list.length -= c;
  81762. return ret;
  81763. }
  81764. function endReadable(stream) {
  81765. var state = stream._readableState;
  81766. // If we get here before consuming all the bytes, then that is a
  81767. // bug in node. Should never happen.
  81768. if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
  81769. if (!state.endEmitted) {
  81770. state.ended = true;
  81771. processNextTick(endReadableNT, state, stream);
  81772. }
  81773. }
  81774. function endReadableNT(state, stream) {
  81775. // Check that we didn't get one last unshift.
  81776. if (!state.endEmitted && state.length === 0) {
  81777. state.endEmitted = true;
  81778. stream.readable = false;
  81779. stream.emit('end');
  81780. }
  81781. }
  81782. function forEach(xs, f) {
  81783. for (var i = 0, l = xs.length; i < l; i++) {
  81784. f(xs[i], i);
  81785. }
  81786. }
  81787. function indexOf(xs, x) {
  81788. for (var i = 0, l = xs.length; i < l; i++) {
  81789. if (xs[i] === x) return i;
  81790. }
  81791. return -1;
  81792. }
  81793. }).call(this,require('_process'))
  81794. },{"./_stream_duplex":75,"./internal/streams/BufferList":80,"_process":73,"buffer":65,"buffer-shims":64,"core-util-is":66,"events":67,"inherits":69,"isarray":71,"process-nextick-args":72,"string_decoder/":86,"util":63}],78:[function(require,module,exports){
  81795. // a transform stream is a readable/writable stream where you do
  81796. // something with the data. Sometimes it's called a "filter",
  81797. // but that's not a great name for it, since that implies a thing where
  81798. // some bits pass through, and others are simply ignored. (That would
  81799. // be a valid example of a transform, of course.)
  81800. //
  81801. // While the output is causally related to the input, it's not a
  81802. // necessarily symmetric or synchronous transformation. For example,
  81803. // a zlib stream might take multiple plain-text writes(), and then
  81804. // emit a single compressed chunk some time in the future.
  81805. //
  81806. // Here's how this works:
  81807. //
  81808. // The Transform stream has all the aspects of the readable and writable
  81809. // stream classes. When you write(chunk), that calls _write(chunk,cb)
  81810. // internally, and returns false if there's a lot of pending writes
  81811. // buffered up. When you call read(), that calls _read(n) until
  81812. // there's enough pending readable data buffered up.
  81813. //
  81814. // In a transform stream, the written data is placed in a buffer. When
  81815. // _read(n) is called, it transforms the queued up data, calling the
  81816. // buffered _write cb's as it consumes chunks. If consuming a single
  81817. // written chunk would result in multiple output chunks, then the first
  81818. // outputted bit calls the readcb, and subsequent chunks just go into
  81819. // the read buffer, and will cause it to emit 'readable' if necessary.
  81820. //
  81821. // This way, back-pressure is actually determined by the reading side,
  81822. // since _read has to be called to start processing a new chunk. However,
  81823. // a pathological inflate type of transform can cause excessive buffering
  81824. // here. For example, imagine a stream where every byte of input is
  81825. // interpreted as an integer from 0-255, and then results in that many
  81826. // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
  81827. // 1kb of data being output. In this case, you could write a very small
  81828. // amount of input, and end up with a very large amount of output. In
  81829. // such a pathological inflating mechanism, there'd be no way to tell
  81830. // the system to stop doing the transform. A single 4MB write could
  81831. // cause the system to run out of memory.
  81832. //
  81833. // However, even in such a pathological case, only a single written chunk
  81834. // would be consumed, and then the rest would wait (un-transformed) until
  81835. // the results of the previous transformed chunk were consumed.
  81836. 'use strict';
  81837. module.exports = Transform;
  81838. var Duplex = require('./_stream_duplex');
  81839. /*<replacement>*/
  81840. var util = require('core-util-is');
  81841. util.inherits = require('inherits');
  81842. /*</replacement>*/
  81843. util.inherits(Transform, Duplex);
  81844. function TransformState(stream) {
  81845. this.afterTransform = function (er, data) {
  81846. return afterTransform(stream, er, data);
  81847. };
  81848. this.needTransform = false;
  81849. this.transforming = false;
  81850. this.writecb = null;
  81851. this.writechunk = null;
  81852. this.writeencoding = null;
  81853. }
  81854. function afterTransform(stream, er, data) {
  81855. var ts = stream._transformState;
  81856. ts.transforming = false;
  81857. var cb = ts.writecb;
  81858. if (!cb) return stream.emit('error', new Error('no writecb in Transform class'));
  81859. ts.writechunk = null;
  81860. ts.writecb = null;
  81861. if (data !== null && data !== undefined) stream.push(data);
  81862. cb(er);
  81863. var rs = stream._readableState;
  81864. rs.reading = false;
  81865. if (rs.needReadable || rs.length < rs.highWaterMark) {
  81866. stream._read(rs.highWaterMark);
  81867. }
  81868. }
  81869. function Transform(options) {
  81870. if (!(this instanceof Transform)) return new Transform(options);
  81871. Duplex.call(this, options);
  81872. this._transformState = new TransformState(this);
  81873. var stream = this;
  81874. // start out asking for a readable event once data is transformed.
  81875. this._readableState.needReadable = true;
  81876. // we have implemented the _read method, and done the other things
  81877. // that Readable wants before the first _read call, so unset the
  81878. // sync guard flag.
  81879. this._readableState.sync = false;
  81880. if (options) {
  81881. if (typeof options.transform === 'function') this._transform = options.transform;
  81882. if (typeof options.flush === 'function') this._flush = options.flush;
  81883. }
  81884. // When the writable side finishes, then flush out anything remaining.
  81885. this.once('prefinish', function () {
  81886. if (typeof this._flush === 'function') this._flush(function (er, data) {
  81887. done(stream, er, data);
  81888. });else done(stream);
  81889. });
  81890. }
  81891. Transform.prototype.push = function (chunk, encoding) {
  81892. this._transformState.needTransform = false;
  81893. return Duplex.prototype.push.call(this, chunk, encoding);
  81894. };
  81895. // This is the part where you do stuff!
  81896. // override this function in implementation classes.
  81897. // 'chunk' is an input chunk.
  81898. //
  81899. // Call `push(newChunk)` to pass along transformed output
  81900. // to the readable side. You may call 'push' zero or more times.
  81901. //
  81902. // Call `cb(err)` when you are done with this chunk. If you pass
  81903. // an error, then that'll put the hurt on the whole operation. If you
  81904. // never call cb(), then you'll never get another chunk.
  81905. Transform.prototype._transform = function (chunk, encoding, cb) {
  81906. throw new Error('_transform() is not implemented');
  81907. };
  81908. Transform.prototype._write = function (chunk, encoding, cb) {
  81909. var ts = this._transformState;
  81910. ts.writecb = cb;
  81911. ts.writechunk = chunk;
  81912. ts.writeencoding = encoding;
  81913. if (!ts.transforming) {
  81914. var rs = this._readableState;
  81915. if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
  81916. }
  81917. };
  81918. // Doesn't matter what the args are here.
  81919. // _transform does all the work.
  81920. // That we got here means that the readable side wants more data.
  81921. Transform.prototype._read = function (n) {
  81922. var ts = this._transformState;
  81923. if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
  81924. ts.transforming = true;
  81925. this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
  81926. } else {
  81927. // mark that we need a transform, so that any data that comes in
  81928. // will get processed, now that we've asked for it.
  81929. ts.needTransform = true;
  81930. }
  81931. };
  81932. function done(stream, er, data) {
  81933. if (er) return stream.emit('error', er);
  81934. if (data !== null && data !== undefined) stream.push(data);
  81935. // if there's nothing in the write buffer, then that means
  81936. // that nothing more will ever be provided
  81937. var ws = stream._writableState;
  81938. var ts = stream._transformState;
  81939. if (ws.length) throw new Error('Calling transform done when ws.length != 0');
  81940. if (ts.transforming) throw new Error('Calling transform done when still transforming');
  81941. return stream.push(null);
  81942. }
  81943. },{"./_stream_duplex":75,"core-util-is":66,"inherits":69}],79:[function(require,module,exports){
  81944. (function (process){
  81945. // A bit simpler than readable streams.
  81946. // Implement an async ._write(chunk, encoding, cb), and it'll handle all
  81947. // the drain event emission and buffering.
  81948. 'use strict';
  81949. module.exports = Writable;
  81950. /*<replacement>*/
  81951. var processNextTick = require('process-nextick-args');
  81952. /*</replacement>*/
  81953. /*<replacement>*/
  81954. var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick;
  81955. /*</replacement>*/
  81956. /*<replacement>*/
  81957. var Duplex;
  81958. /*</replacement>*/
  81959. Writable.WritableState = WritableState;
  81960. /*<replacement>*/
  81961. var util = require('core-util-is');
  81962. util.inherits = require('inherits');
  81963. /*</replacement>*/
  81964. /*<replacement>*/
  81965. var internalUtil = {
  81966. deprecate: require('util-deprecate')
  81967. };
  81968. /*</replacement>*/
  81969. /*<replacement>*/
  81970. var Stream;
  81971. (function () {
  81972. try {
  81973. Stream = require('st' + 'ream');
  81974. } catch (_) {} finally {
  81975. if (!Stream) Stream = require('events').EventEmitter;
  81976. }
  81977. })();
  81978. /*</replacement>*/
  81979. var Buffer = require('buffer').Buffer;
  81980. /*<replacement>*/
  81981. var bufferShim = require('buffer-shims');
  81982. /*</replacement>*/
  81983. util.inherits(Writable, Stream);
  81984. function nop() {}
  81985. function WriteReq(chunk, encoding, cb) {
  81986. this.chunk = chunk;
  81987. this.encoding = encoding;
  81988. this.callback = cb;
  81989. this.next = null;
  81990. }
  81991. function WritableState(options, stream) {
  81992. Duplex = Duplex || require('./_stream_duplex');
  81993. options = options || {};
  81994. // object stream flag to indicate whether or not this stream
  81995. // contains buffers or objects.
  81996. this.objectMode = !!options.objectMode;
  81997. if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
  81998. // the point at which write() starts returning false
  81999. // Note: 0 is a valid value, means that we always return false if
  82000. // the entire buffer is not flushed immediately on write()
  82001. var hwm = options.highWaterMark;
  82002. var defaultHwm = this.objectMode ? 16 : 16 * 1024;
  82003. this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
  82004. // cast to ints.
  82005. this.highWaterMark = ~ ~this.highWaterMark;
  82006. // drain event flag.
  82007. this.needDrain = false;
  82008. // at the start of calling end()
  82009. this.ending = false;
  82010. // when end() has been called, and returned
  82011. this.ended = false;
  82012. // when 'finish' is emitted
  82013. this.finished = false;
  82014. // should we decode strings into buffers before passing to _write?
  82015. // this is here so that some node-core streams can optimize string
  82016. // handling at a lower level.
  82017. var noDecode = options.decodeStrings === false;
  82018. this.decodeStrings = !noDecode;
  82019. // Crypto is kind of old and crusty. Historically, its default string
  82020. // encoding is 'binary' so we have to make this configurable.
  82021. // Everything else in the universe uses 'utf8', though.
  82022. this.defaultEncoding = options.defaultEncoding || 'utf8';
  82023. // not an actual buffer we keep track of, but a measurement
  82024. // of how much we're waiting to get pushed to some underlying
  82025. // socket or file.
  82026. this.length = 0;
  82027. // a flag to see when we're in the middle of a write.
  82028. this.writing = false;
  82029. // when true all writes will be buffered until .uncork() call
  82030. this.corked = 0;
  82031. // a flag to be able to tell if the onwrite cb is called immediately,
  82032. // or on a later tick. We set this to true at first, because any
  82033. // actions that shouldn't happen until "later" should generally also
  82034. // not happen before the first write call.
  82035. this.sync = true;
  82036. // a flag to know if we're processing previously buffered items, which
  82037. // may call the _write() callback in the same tick, so that we don't
  82038. // end up in an overlapped onwrite situation.
  82039. this.bufferProcessing = false;
  82040. // the callback that's passed to _write(chunk,cb)
  82041. this.onwrite = function (er) {
  82042. onwrite(stream, er);
  82043. };
  82044. // the callback that the user supplies to write(chunk,encoding,cb)
  82045. this.writecb = null;
  82046. // the amount that is being written when _write is called.
  82047. this.writelen = 0;
  82048. this.bufferedRequest = null;
  82049. this.lastBufferedRequest = null;
  82050. // number of pending user-supplied write callbacks
  82051. // this must be 0 before 'finish' can be emitted
  82052. this.pendingcb = 0;
  82053. // emit prefinish if the only thing we're waiting for is _write cbs
  82054. // This is relevant for synchronous Transform streams
  82055. this.prefinished = false;
  82056. // True if the error was already emitted and should not be thrown again
  82057. this.errorEmitted = false;
  82058. // count buffered requests
  82059. this.bufferedRequestCount = 0;
  82060. // allocate the first CorkedRequest, there is always
  82061. // one allocated and free to use, and we maintain at most two
  82062. this.corkedRequestsFree = new CorkedRequest(this);
  82063. }
  82064. WritableState.prototype.getBuffer = function getBuffer() {
  82065. var current = this.bufferedRequest;
  82066. var out = [];
  82067. while (current) {
  82068. out.push(current);
  82069. current = current.next;
  82070. }
  82071. return out;
  82072. };
  82073. (function () {
  82074. try {
  82075. Object.defineProperty(WritableState.prototype, 'buffer', {
  82076. get: internalUtil.deprecate(function () {
  82077. return this.getBuffer();
  82078. }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.')
  82079. });
  82080. } catch (_) {}
  82081. })();
  82082. // Test _writableState for inheritance to account for Duplex streams,
  82083. // whose prototype chain only points to Readable.
  82084. var realHasInstance;
  82085. if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
  82086. realHasInstance = Function.prototype[Symbol.hasInstance];
  82087. Object.defineProperty(Writable, Symbol.hasInstance, {
  82088. value: function (object) {
  82089. if (realHasInstance.call(this, object)) return true;
  82090. return object && object._writableState instanceof WritableState;
  82091. }
  82092. });
  82093. } else {
  82094. realHasInstance = function (object) {
  82095. return object instanceof this;
  82096. };
  82097. }
  82098. function Writable(options) {
  82099. Duplex = Duplex || require('./_stream_duplex');
  82100. // Writable ctor is applied to Duplexes, too.
  82101. // `realHasInstance` is necessary because using plain `instanceof`
  82102. // would return false, as no `_writableState` property is attached.
  82103. // Trying to use the custom `instanceof` for Writable here will also break the
  82104. // Node.js LazyTransform implementation, which has a non-trivial getter for
  82105. // `_writableState` that would lead to infinite recursion.
  82106. if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
  82107. return new Writable(options);
  82108. }
  82109. this._writableState = new WritableState(options, this);
  82110. // legacy.
  82111. this.writable = true;
  82112. if (options) {
  82113. if (typeof options.write === 'function') this._write = options.write;
  82114. if (typeof options.writev === 'function') this._writev = options.writev;
  82115. }
  82116. Stream.call(this);
  82117. }
  82118. // Otherwise people can pipe Writable streams, which is just wrong.
  82119. Writable.prototype.pipe = function () {
  82120. this.emit('error', new Error('Cannot pipe, not readable'));
  82121. };
  82122. function writeAfterEnd(stream, cb) {
  82123. var er = new Error('write after end');
  82124. // TODO: defer error events consistently everywhere, not just the cb
  82125. stream.emit('error', er);
  82126. processNextTick(cb, er);
  82127. }
  82128. // If we get something that is not a buffer, string, null, or undefined,
  82129. // and we're not in objectMode, then that's an error.
  82130. // Otherwise stream chunks are all considered to be of length=1, and the
  82131. // watermarks determine how many objects to keep in the buffer, rather than
  82132. // how many bytes or characters.
  82133. function validChunk(stream, state, chunk, cb) {
  82134. var valid = true;
  82135. var er = false;
  82136. // Always throw error if a null is written
  82137. // if we are not in object mode then throw
  82138. // if it is not a buffer, string, or undefined.
  82139. if (chunk === null) {
  82140. er = new TypeError('May not write null values to stream');
  82141. } else if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
  82142. er = new TypeError('Invalid non-string/buffer chunk');
  82143. }
  82144. if (er) {
  82145. stream.emit('error', er);
  82146. processNextTick(cb, er);
  82147. valid = false;
  82148. }
  82149. return valid;
  82150. }
  82151. Writable.prototype.write = function (chunk, encoding, cb) {
  82152. var state = this._writableState;
  82153. var ret = false;
  82154. if (typeof encoding === 'function') {
  82155. cb = encoding;
  82156. encoding = null;
  82157. }
  82158. if (Buffer.isBuffer(chunk)) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
  82159. if (typeof cb !== 'function') cb = nop;
  82160. if (state.ended) writeAfterEnd(this, cb);else if (validChunk(this, state, chunk, cb)) {
  82161. state.pendingcb++;
  82162. ret = writeOrBuffer(this, state, chunk, encoding, cb);
  82163. }
  82164. return ret;
  82165. };
  82166. Writable.prototype.cork = function () {
  82167. var state = this._writableState;
  82168. state.corked++;
  82169. };
  82170. Writable.prototype.uncork = function () {
  82171. var state = this._writableState;
  82172. if (state.corked) {
  82173. state.corked--;
  82174. if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
  82175. }
  82176. };
  82177. Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
  82178. // node::ParseEncoding() requires lower case.
  82179. if (typeof encoding === 'string') encoding = encoding.toLowerCase();
  82180. if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
  82181. this._writableState.defaultEncoding = encoding;
  82182. return this;
  82183. };
  82184. function decodeChunk(state, chunk, encoding) {
  82185. if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
  82186. chunk = bufferShim.from(chunk, encoding);
  82187. }
  82188. return chunk;
  82189. }
  82190. // if we're already writing something, then just put this
  82191. // in the queue, and wait our turn. Otherwise, call _write
  82192. // If we return false, then we need a drain event, so set that flag.
  82193. function writeOrBuffer(stream, state, chunk, encoding, cb) {
  82194. chunk = decodeChunk(state, chunk, encoding);
  82195. if (Buffer.isBuffer(chunk)) encoding = 'buffer';
  82196. var len = state.objectMode ? 1 : chunk.length;
  82197. state.length += len;
  82198. var ret = state.length < state.highWaterMark;
  82199. // we must ensure that previous needDrain will not be reset to false.
  82200. if (!ret) state.needDrain = true;
  82201. if (state.writing || state.corked) {
  82202. var last = state.lastBufferedRequest;
  82203. state.lastBufferedRequest = new WriteReq(chunk, encoding, cb);
  82204. if (last) {
  82205. last.next = state.lastBufferedRequest;
  82206. } else {
  82207. state.bufferedRequest = state.lastBufferedRequest;
  82208. }
  82209. state.bufferedRequestCount += 1;
  82210. } else {
  82211. doWrite(stream, state, false, len, chunk, encoding, cb);
  82212. }
  82213. return ret;
  82214. }
  82215. function doWrite(stream, state, writev, len, chunk, encoding, cb) {
  82216. state.writelen = len;
  82217. state.writecb = cb;
  82218. state.writing = true;
  82219. state.sync = true;
  82220. if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
  82221. state.sync = false;
  82222. }
  82223. function onwriteError(stream, state, sync, er, cb) {
  82224. --state.pendingcb;
  82225. if (sync) processNextTick(cb, er);else cb(er);
  82226. stream._writableState.errorEmitted = true;
  82227. stream.emit('error', er);
  82228. }
  82229. function onwriteStateUpdate(state) {
  82230. state.writing = false;
  82231. state.writecb = null;
  82232. state.length -= state.writelen;
  82233. state.writelen = 0;
  82234. }
  82235. function onwrite(stream, er) {
  82236. var state = stream._writableState;
  82237. var sync = state.sync;
  82238. var cb = state.writecb;
  82239. onwriteStateUpdate(state);
  82240. if (er) onwriteError(stream, state, sync, er, cb);else {
  82241. // Check if we're actually ready to finish, but don't emit yet
  82242. var finished = needFinish(state);
  82243. if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
  82244. clearBuffer(stream, state);
  82245. }
  82246. if (sync) {
  82247. /*<replacement>*/
  82248. asyncWrite(afterWrite, stream, state, finished, cb);
  82249. /*</replacement>*/
  82250. } else {
  82251. afterWrite(stream, state, finished, cb);
  82252. }
  82253. }
  82254. }
  82255. function afterWrite(stream, state, finished, cb) {
  82256. if (!finished) onwriteDrain(stream, state);
  82257. state.pendingcb--;
  82258. cb();
  82259. finishMaybe(stream, state);
  82260. }
  82261. // Must force callback to be called on nextTick, so that we don't
  82262. // emit 'drain' before the write() consumer gets the 'false' return
  82263. // value, and has a chance to attach a 'drain' listener.
  82264. function onwriteDrain(stream, state) {
  82265. if (state.length === 0 && state.needDrain) {
  82266. state.needDrain = false;
  82267. stream.emit('drain');
  82268. }
  82269. }
  82270. // if there's something in the buffer waiting, then process it
  82271. function clearBuffer(stream, state) {
  82272. state.bufferProcessing = true;
  82273. var entry = state.bufferedRequest;
  82274. if (stream._writev && entry && entry.next) {
  82275. // Fast case, write everything using _writev()
  82276. var l = state.bufferedRequestCount;
  82277. var buffer = new Array(l);
  82278. var holder = state.corkedRequestsFree;
  82279. holder.entry = entry;
  82280. var count = 0;
  82281. while (entry) {
  82282. buffer[count] = entry;
  82283. entry = entry.next;
  82284. count += 1;
  82285. }
  82286. doWrite(stream, state, true, state.length, buffer, '', holder.finish);
  82287. // doWrite is almost always async, defer these to save a bit of time
  82288. // as the hot path ends with doWrite
  82289. state.pendingcb++;
  82290. state.lastBufferedRequest = null;
  82291. if (holder.next) {
  82292. state.corkedRequestsFree = holder.next;
  82293. holder.next = null;
  82294. } else {
  82295. state.corkedRequestsFree = new CorkedRequest(state);
  82296. }
  82297. } else {
  82298. // Slow case, write chunks one-by-one
  82299. while (entry) {
  82300. var chunk = entry.chunk;
  82301. var encoding = entry.encoding;
  82302. var cb = entry.callback;
  82303. var len = state.objectMode ? 1 : chunk.length;
  82304. doWrite(stream, state, false, len, chunk, encoding, cb);
  82305. entry = entry.next;
  82306. // if we didn't call the onwrite immediately, then
  82307. // it means that we need to wait until it does.
  82308. // also, that means that the chunk and cb are currently
  82309. // being processed, so move the buffer counter past them.
  82310. if (state.writing) {
  82311. break;
  82312. }
  82313. }
  82314. if (entry === null) state.lastBufferedRequest = null;
  82315. }
  82316. state.bufferedRequestCount = 0;
  82317. state.bufferedRequest = entry;
  82318. state.bufferProcessing = false;
  82319. }
  82320. Writable.prototype._write = function (chunk, encoding, cb) {
  82321. cb(new Error('_write() is not implemented'));
  82322. };
  82323. Writable.prototype._writev = null;
  82324. Writable.prototype.end = function (chunk, encoding, cb) {
  82325. var state = this._writableState;
  82326. if (typeof chunk === 'function') {
  82327. cb = chunk;
  82328. chunk = null;
  82329. encoding = null;
  82330. } else if (typeof encoding === 'function') {
  82331. cb = encoding;
  82332. encoding = null;
  82333. }
  82334. if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
  82335. // .end() fully uncorks
  82336. if (state.corked) {
  82337. state.corked = 1;
  82338. this.uncork();
  82339. }
  82340. // ignore unnecessary end() calls.
  82341. if (!state.ending && !state.finished) endWritable(this, state, cb);
  82342. };
  82343. function needFinish(state) {
  82344. return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
  82345. }
  82346. function prefinish(stream, state) {
  82347. if (!state.prefinished) {
  82348. state.prefinished = true;
  82349. stream.emit('prefinish');
  82350. }
  82351. }
  82352. function finishMaybe(stream, state) {
  82353. var need = needFinish(state);
  82354. if (need) {
  82355. if (state.pendingcb === 0) {
  82356. prefinish(stream, state);
  82357. state.finished = true;
  82358. stream.emit('finish');
  82359. } else {
  82360. prefinish(stream, state);
  82361. }
  82362. }
  82363. return need;
  82364. }
  82365. function endWritable(stream, state, cb) {
  82366. state.ending = true;
  82367. finishMaybe(stream, state);
  82368. if (cb) {
  82369. if (state.finished) processNextTick(cb);else stream.once('finish', cb);
  82370. }
  82371. state.ended = true;
  82372. stream.writable = false;
  82373. }
  82374. // It seems a linked list but it is not
  82375. // there will be only 2 of these for each stream
  82376. function CorkedRequest(state) {
  82377. var _this = this;
  82378. this.next = null;
  82379. this.entry = null;
  82380. this.finish = function (err) {
  82381. var entry = _this.entry;
  82382. _this.entry = null;
  82383. while (entry) {
  82384. var cb = entry.callback;
  82385. state.pendingcb--;
  82386. cb(err);
  82387. entry = entry.next;
  82388. }
  82389. if (state.corkedRequestsFree) {
  82390. state.corkedRequestsFree.next = _this;
  82391. } else {
  82392. state.corkedRequestsFree = _this;
  82393. }
  82394. };
  82395. }
  82396. }).call(this,require('_process'))
  82397. },{"./_stream_duplex":75,"_process":73,"buffer":65,"buffer-shims":64,"core-util-is":66,"events":67,"inherits":69,"process-nextick-args":72,"util-deprecate":87}],80:[function(require,module,exports){
  82398. 'use strict';
  82399. var Buffer = require('buffer').Buffer;
  82400. /*<replacement>*/
  82401. var bufferShim = require('buffer-shims');
  82402. /*</replacement>*/
  82403. module.exports = BufferList;
  82404. function BufferList() {
  82405. this.head = null;
  82406. this.tail = null;
  82407. this.length = 0;
  82408. }
  82409. BufferList.prototype.push = function (v) {
  82410. var entry = { data: v, next: null };
  82411. if (this.length > 0) this.tail.next = entry;else this.head = entry;
  82412. this.tail = entry;
  82413. ++this.length;
  82414. };
  82415. BufferList.prototype.unshift = function (v) {
  82416. var entry = { data: v, next: this.head };
  82417. if (this.length === 0) this.tail = entry;
  82418. this.head = entry;
  82419. ++this.length;
  82420. };
  82421. BufferList.prototype.shift = function () {
  82422. if (this.length === 0) return;
  82423. var ret = this.head.data;
  82424. if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
  82425. --this.length;
  82426. return ret;
  82427. };
  82428. BufferList.prototype.clear = function () {
  82429. this.head = this.tail = null;
  82430. this.length = 0;
  82431. };
  82432. BufferList.prototype.join = function (s) {
  82433. if (this.length === 0) return '';
  82434. var p = this.head;
  82435. var ret = '' + p.data;
  82436. while (p = p.next) {
  82437. ret += s + p.data;
  82438. }return ret;
  82439. };
  82440. BufferList.prototype.concat = function (n) {
  82441. if (this.length === 0) return bufferShim.alloc(0);
  82442. if (this.length === 1) return this.head.data;
  82443. var ret = bufferShim.allocUnsafe(n >>> 0);
  82444. var p = this.head;
  82445. var i = 0;
  82446. while (p) {
  82447. p.data.copy(ret, i);
  82448. i += p.data.length;
  82449. p = p.next;
  82450. }
  82451. return ret;
  82452. };
  82453. },{"buffer":65,"buffer-shims":64}],81:[function(require,module,exports){
  82454. module.exports = require("./lib/_stream_passthrough.js")
  82455. },{"./lib/_stream_passthrough.js":76}],82:[function(require,module,exports){
  82456. (function (process){
  82457. var Stream = (function (){
  82458. try {
  82459. return require('st' + 'ream'); // hack to fix a circular dependency issue when used with browserify
  82460. } catch(_){}
  82461. }());
  82462. exports = module.exports = require('./lib/_stream_readable.js');
  82463. exports.Stream = Stream || exports;
  82464. exports.Readable = exports;
  82465. exports.Writable = require('./lib/_stream_writable.js');
  82466. exports.Duplex = require('./lib/_stream_duplex.js');
  82467. exports.Transform = require('./lib/_stream_transform.js');
  82468. exports.PassThrough = require('./lib/_stream_passthrough.js');
  82469. if (!process.browser && process.env.READABLE_STREAM === 'disable' && Stream) {
  82470. module.exports = Stream;
  82471. }
  82472. }).call(this,require('_process'))
  82473. },{"./lib/_stream_duplex.js":75,"./lib/_stream_passthrough.js":76,"./lib/_stream_readable.js":77,"./lib/_stream_transform.js":78,"./lib/_stream_writable.js":79,"_process":73}],83:[function(require,module,exports){
  82474. module.exports = require("./lib/_stream_transform.js")
  82475. },{"./lib/_stream_transform.js":78}],84:[function(require,module,exports){
  82476. module.exports = require("./lib/_stream_writable.js")
  82477. },{"./lib/_stream_writable.js":79}],85:[function(require,module,exports){
  82478. // Copyright Joyent, Inc. and other Node contributors.
  82479. //
  82480. // Permission is hereby granted, free of charge, to any person obtaining a
  82481. // copy of this software and associated documentation files (the
  82482. // "Software"), to deal in the Software without restriction, including
  82483. // without limitation the rights to use, copy, modify, merge, publish,
  82484. // distribute, sublicense, and/or sell copies of the Software, and to permit
  82485. // persons to whom the Software is furnished to do so, subject to the
  82486. // following conditions:
  82487. //
  82488. // The above copyright notice and this permission notice shall be included
  82489. // in all copies or substantial portions of the Software.
  82490. //
  82491. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  82492. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  82493. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  82494. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  82495. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  82496. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  82497. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  82498. module.exports = Stream;
  82499. var EE = require('events').EventEmitter;
  82500. var inherits = require('inherits');
  82501. inherits(Stream, EE);
  82502. Stream.Readable = require('readable-stream/readable.js');
  82503. Stream.Writable = require('readable-stream/writable.js');
  82504. Stream.Duplex = require('readable-stream/duplex.js');
  82505. Stream.Transform = require('readable-stream/transform.js');
  82506. Stream.PassThrough = require('readable-stream/passthrough.js');
  82507. // Backwards-compat with node 0.4.x
  82508. Stream.Stream = Stream;
  82509. // old-style streams. Note that the pipe method (the only relevant
  82510. // part of this class) is overridden in the Readable class.
  82511. function Stream() {
  82512. EE.call(this);
  82513. }
  82514. Stream.prototype.pipe = function(dest, options) {
  82515. var source = this;
  82516. function ondata(chunk) {
  82517. if (dest.writable) {
  82518. if (false === dest.write(chunk) && source.pause) {
  82519. source.pause();
  82520. }
  82521. }
  82522. }
  82523. source.on('data', ondata);
  82524. function ondrain() {
  82525. if (source.readable && source.resume) {
  82526. source.resume();
  82527. }
  82528. }
  82529. dest.on('drain', ondrain);
  82530. // If the 'end' option is not supplied, dest.end() will be called when
  82531. // source gets the 'end' or 'close' events. Only dest.end() once.
  82532. if (!dest._isStdio && (!options || options.end !== false)) {
  82533. source.on('end', onend);
  82534. source.on('close', onclose);
  82535. }
  82536. var didOnEnd = false;
  82537. function onend() {
  82538. if (didOnEnd) return;
  82539. didOnEnd = true;
  82540. dest.end();
  82541. }
  82542. function onclose() {
  82543. if (didOnEnd) return;
  82544. didOnEnd = true;
  82545. if (typeof dest.destroy === 'function') dest.destroy();
  82546. }
  82547. // don't leave dangling pipes when there are errors.
  82548. function onerror(er) {
  82549. cleanup();
  82550. if (EE.listenerCount(this, 'error') === 0) {
  82551. throw er; // Unhandled stream error in pipe.
  82552. }
  82553. }
  82554. source.on('error', onerror);
  82555. dest.on('error', onerror);
  82556. // remove all the event listeners that were added.
  82557. function cleanup() {
  82558. source.removeListener('data', ondata);
  82559. dest.removeListener('drain', ondrain);
  82560. source.removeListener('end', onend);
  82561. source.removeListener('close', onclose);
  82562. source.removeListener('error', onerror);
  82563. dest.removeListener('error', onerror);
  82564. source.removeListener('end', cleanup);
  82565. source.removeListener('close', cleanup);
  82566. dest.removeListener('close', cleanup);
  82567. }
  82568. source.on('end', cleanup);
  82569. source.on('close', cleanup);
  82570. dest.on('close', cleanup);
  82571. dest.emit('pipe', source);
  82572. // Allow for unix-like usage: A.pipe(B).pipe(C)
  82573. return dest;
  82574. };
  82575. },{"events":67,"inherits":69,"readable-stream/duplex.js":74,"readable-stream/passthrough.js":81,"readable-stream/readable.js":82,"readable-stream/transform.js":83,"readable-stream/writable.js":84}],86:[function(require,module,exports){
  82576. // Copyright Joyent, Inc. and other Node contributors.
  82577. //
  82578. // Permission is hereby granted, free of charge, to any person obtaining a
  82579. // copy of this software and associated documentation files (the
  82580. // "Software"), to deal in the Software without restriction, including
  82581. // without limitation the rights to use, copy, modify, merge, publish,
  82582. // distribute, sublicense, and/or sell copies of the Software, and to permit
  82583. // persons to whom the Software is furnished to do so, subject to the
  82584. // following conditions:
  82585. //
  82586. // The above copyright notice and this permission notice shall be included
  82587. // in all copies or substantial portions of the Software.
  82588. //
  82589. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  82590. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  82591. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  82592. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  82593. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  82594. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  82595. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  82596. var Buffer = require('buffer').Buffer;
  82597. var isBufferEncoding = Buffer.isEncoding
  82598. || function(encoding) {
  82599. switch (encoding && encoding.toLowerCase()) {
  82600. 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': return true;
  82601. default: return false;
  82602. }
  82603. }
  82604. function assertEncoding(encoding) {
  82605. if (encoding && !isBufferEncoding(encoding)) {
  82606. throw new Error('Unknown encoding: ' + encoding);
  82607. }
  82608. }
  82609. // StringDecoder provides an interface for efficiently splitting a series of
  82610. // buffers into a series of JS strings without breaking apart multi-byte
  82611. // characters. CESU-8 is handled as part of the UTF-8 encoding.
  82612. //
  82613. // @TODO Handling all encodings inside a single object makes it very difficult
  82614. // to reason about this code, so it should be split up in the future.
  82615. // @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code
  82616. // points as used by CESU-8.
  82617. var StringDecoder = exports.StringDecoder = function(encoding) {
  82618. this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
  82619. assertEncoding(encoding);
  82620. switch (this.encoding) {
  82621. case 'utf8':
  82622. // CESU-8 represents each of Surrogate Pair by 3-bytes
  82623. this.surrogateSize = 3;
  82624. break;
  82625. case 'ucs2':
  82626. case 'utf16le':
  82627. // UTF-16 represents each of Surrogate Pair by 2-bytes
  82628. this.surrogateSize = 2;
  82629. this.detectIncompleteChar = utf16DetectIncompleteChar;
  82630. break;
  82631. case 'base64':
  82632. // Base-64 stores 3 bytes in 4 chars, and pads the remainder.
  82633. this.surrogateSize = 3;
  82634. this.detectIncompleteChar = base64DetectIncompleteChar;
  82635. break;
  82636. default:
  82637. this.write = passThroughWrite;
  82638. return;
  82639. }
  82640. // Enough space to store all bytes of a single character. UTF-8 needs 4
  82641. // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate).
  82642. this.charBuffer = new Buffer(6);
  82643. // Number of bytes received for the current incomplete multi-byte character.
  82644. this.charReceived = 0;
  82645. // Number of bytes expected for the current incomplete multi-byte character.
  82646. this.charLength = 0;
  82647. };
  82648. // write decodes the given buffer and returns it as JS string that is
  82649. // guaranteed to not contain any partial multi-byte characters. Any partial
  82650. // character found at the end of the buffer is buffered up, and will be
  82651. // returned when calling write again with the remaining bytes.
  82652. //
  82653. // Note: Converting a Buffer containing an orphan surrogate to a String
  82654. // currently works, but converting a String to a Buffer (via `new Buffer`, or
  82655. // Buffer#write) will replace incomplete surrogates with the unicode
  82656. // replacement character. See https://codereview.chromium.org/121173009/ .
  82657. StringDecoder.prototype.write = function(buffer) {
  82658. var charStr = '';
  82659. // if our last write ended with an incomplete multibyte character
  82660. while (this.charLength) {
  82661. // determine how many remaining bytes this buffer has to offer for this char
  82662. var available = (buffer.length >= this.charLength - this.charReceived) ?
  82663. this.charLength - this.charReceived :
  82664. buffer.length;
  82665. // add the new bytes to the char buffer
  82666. buffer.copy(this.charBuffer, this.charReceived, 0, available);
  82667. this.charReceived += available;
  82668. if (this.charReceived < this.charLength) {
  82669. // still not enough chars in this buffer? wait for more ...
  82670. return '';
  82671. }
  82672. // remove bytes belonging to the current character from the buffer
  82673. buffer = buffer.slice(available, buffer.length);
  82674. // get the character that was split
  82675. charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
  82676. // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
  82677. var charCode = charStr.charCodeAt(charStr.length - 1);
  82678. if (charCode >= 0xD800 && charCode <= 0xDBFF) {
  82679. this.charLength += this.surrogateSize;
  82680. charStr = '';
  82681. continue;
  82682. }
  82683. this.charReceived = this.charLength = 0;
  82684. // if there are no more bytes in this buffer, just emit our char
  82685. if (buffer.length === 0) {
  82686. return charStr;
  82687. }
  82688. break;
  82689. }
  82690. // determine and set charLength / charReceived
  82691. this.detectIncompleteChar(buffer);
  82692. var end = buffer.length;
  82693. if (this.charLength) {
  82694. // buffer the incomplete character bytes we got
  82695. buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end);
  82696. end -= this.charReceived;
  82697. }
  82698. charStr += buffer.toString(this.encoding, 0, end);
  82699. var end = charStr.length - 1;
  82700. var charCode = charStr.charCodeAt(end);
  82701. // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
  82702. if (charCode >= 0xD800 && charCode <= 0xDBFF) {
  82703. var size = this.surrogateSize;
  82704. this.charLength += size;
  82705. this.charReceived += size;
  82706. this.charBuffer.copy(this.charBuffer, size, 0, size);
  82707. buffer.copy(this.charBuffer, 0, 0, size);
  82708. return charStr.substring(0, end);
  82709. }
  82710. // or just emit the charStr
  82711. return charStr;
  82712. };
  82713. // detectIncompleteChar determines if there is an incomplete UTF-8 character at
  82714. // the end of the given buffer. If so, it sets this.charLength to the byte
  82715. // length that character, and sets this.charReceived to the number of bytes
  82716. // that are available for this character.
  82717. StringDecoder.prototype.detectIncompleteChar = function(buffer) {
  82718. // determine how many bytes we have to check at the end of this buffer
  82719. var i = (buffer.length >= 3) ? 3 : buffer.length;
  82720. // Figure out if one of the last i bytes of our buffer announces an
  82721. // incomplete char.
  82722. for (; i > 0; i--) {
  82723. var c = buffer[buffer.length - i];
  82724. // See http://en.wikipedia.org/wiki/UTF-8#Description
  82725. // 110XXXXX
  82726. if (i == 1 && c >> 5 == 0x06) {
  82727. this.charLength = 2;
  82728. break;
  82729. }
  82730. // 1110XXXX
  82731. if (i <= 2 && c >> 4 == 0x0E) {
  82732. this.charLength = 3;
  82733. break;
  82734. }
  82735. // 11110XXX
  82736. if (i <= 3 && c >> 3 == 0x1E) {
  82737. this.charLength = 4;
  82738. break;
  82739. }
  82740. }
  82741. this.charReceived = i;
  82742. };
  82743. StringDecoder.prototype.end = function(buffer) {
  82744. var res = '';
  82745. if (buffer && buffer.length)
  82746. res = this.write(buffer);
  82747. if (this.charReceived) {
  82748. var cr = this.charReceived;
  82749. var buf = this.charBuffer;
  82750. var enc = this.encoding;
  82751. res += buf.slice(0, cr).toString(enc);
  82752. }
  82753. return res;
  82754. };
  82755. function passThroughWrite(buffer) {
  82756. return buffer.toString(this.encoding);
  82757. }
  82758. function utf16DetectIncompleteChar(buffer) {
  82759. this.charReceived = buffer.length % 2;
  82760. this.charLength = this.charReceived ? 2 : 0;
  82761. }
  82762. function base64DetectIncompleteChar(buffer) {
  82763. this.charReceived = buffer.length % 3;
  82764. this.charLength = this.charReceived ? 3 : 0;
  82765. }
  82766. },{"buffer":65}],87:[function(require,module,exports){
  82767. (function (global){
  82768. /**
  82769. * Module exports.
  82770. */
  82771. module.exports = deprecate;
  82772. /**
  82773. * Mark that a method should not be used.
  82774. * Returns a modified function which warns once by default.
  82775. *
  82776. * If `localStorage.noDeprecation = true` is set, then it is a no-op.
  82777. *
  82778. * If `localStorage.throwDeprecation = true` is set, then deprecated functions
  82779. * will throw an Error when invoked.
  82780. *
  82781. * If `localStorage.traceDeprecation = true` is set, then deprecated functions
  82782. * will invoke `console.trace()` instead of `console.error()`.
  82783. *
  82784. * @param {Function} fn - the function to deprecate
  82785. * @param {String} msg - the string to print to the console when `fn` is invoked
  82786. * @returns {Function} a new "deprecated" version of `fn`
  82787. * @api public
  82788. */
  82789. function deprecate (fn, msg) {
  82790. if (config('noDeprecation')) {
  82791. return fn;
  82792. }
  82793. var warned = false;
  82794. function deprecated() {
  82795. if (!warned) {
  82796. if (config('throwDeprecation')) {
  82797. throw new Error(msg);
  82798. } else if (config('traceDeprecation')) {
  82799. console.trace(msg);
  82800. } else {
  82801. console.warn(msg);
  82802. }
  82803. warned = true;
  82804. }
  82805. return fn.apply(this, arguments);
  82806. }
  82807. return deprecated;
  82808. }
  82809. /**
  82810. * Checks `localStorage` for boolean values for the given `name`.
  82811. *
  82812. * @param {String} name
  82813. * @returns {Boolean}
  82814. * @api private
  82815. */
  82816. function config (name) {
  82817. // accessing global.localStorage can trigger a DOMException in sandboxed iframes
  82818. try {
  82819. if (!global.localStorage) return false;
  82820. } catch (_) {
  82821. return false;
  82822. }
  82823. var val = global.localStorage[name];
  82824. if (null == val) return false;
  82825. return String(val).toLowerCase() === 'true';
  82826. }
  82827. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  82828. },{}],88:[function(require,module,exports){
  82829. arguments[4][34][0].apply(exports,arguments)
  82830. },{"dup":34}],89:[function(require,module,exports){
  82831. module.exports = function isBuffer(arg) {
  82832. return arg && typeof arg === 'object'
  82833. && typeof arg.copy === 'function'
  82834. && typeof arg.fill === 'function'
  82835. && typeof arg.readUInt8 === 'function';
  82836. }
  82837. },{}],90:[function(require,module,exports){
  82838. (function (process,global){
  82839. // Copyright Joyent, Inc. and other Node contributors.
  82840. //
  82841. // Permission is hereby granted, free of charge, to any person obtaining a
  82842. // copy of this software and associated documentation files (the
  82843. // "Software"), to deal in the Software without restriction, including
  82844. // without limitation the rights to use, copy, modify, merge, publish,
  82845. // distribute, sublicense, and/or sell copies of the Software, and to permit
  82846. // persons to whom the Software is furnished to do so, subject to the
  82847. // following conditions:
  82848. //
  82849. // The above copyright notice and this permission notice shall be included
  82850. // in all copies or substantial portions of the Software.
  82851. //
  82852. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  82853. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  82854. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  82855. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  82856. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  82857. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  82858. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  82859. var formatRegExp = /%[sdj%]/g;
  82860. exports.format = function(f) {
  82861. if (!isString(f)) {
  82862. var objects = [];
  82863. for (var i = 0; i < arguments.length; i++) {
  82864. objects.push(inspect(arguments[i]));
  82865. }
  82866. return objects.join(' ');
  82867. }
  82868. var i = 1;
  82869. var args = arguments;
  82870. var len = args.length;
  82871. var str = String(f).replace(formatRegExp, function(x) {
  82872. if (x === '%%') return '%';
  82873. if (i >= len) return x;
  82874. switch (x) {
  82875. case '%s': return String(args[i++]);
  82876. case '%d': return Number(args[i++]);
  82877. case '%j':
  82878. try {
  82879. return JSON.stringify(args[i++]);
  82880. } catch (_) {
  82881. return '[Circular]';
  82882. }
  82883. default:
  82884. return x;
  82885. }
  82886. });
  82887. for (var x = args[i]; i < len; x = args[++i]) {
  82888. if (isNull(x) || !isObject(x)) {
  82889. str += ' ' + x;
  82890. } else {
  82891. str += ' ' + inspect(x);
  82892. }
  82893. }
  82894. return str;
  82895. };
  82896. // Mark that a method should not be used.
  82897. // Returns a modified function which warns once by default.
  82898. // If --no-deprecation is set, then it is a no-op.
  82899. exports.deprecate = function(fn, msg) {
  82900. // Allow for deprecating things in the process of starting up.
  82901. if (isUndefined(global.process)) {
  82902. return function() {
  82903. return exports.deprecate(fn, msg).apply(this, arguments);
  82904. };
  82905. }
  82906. if (process.noDeprecation === true) {
  82907. return fn;
  82908. }
  82909. var warned = false;
  82910. function deprecated() {
  82911. if (!warned) {
  82912. if (process.throwDeprecation) {
  82913. throw new Error(msg);
  82914. } else if (process.traceDeprecation) {
  82915. console.trace(msg);
  82916. } else {
  82917. console.error(msg);
  82918. }
  82919. warned = true;
  82920. }
  82921. return fn.apply(this, arguments);
  82922. }
  82923. return deprecated;
  82924. };
  82925. var debugs = {};
  82926. var debugEnviron;
  82927. exports.debuglog = function(set) {
  82928. if (isUndefined(debugEnviron))
  82929. debugEnviron = process.env.NODE_DEBUG || '';
  82930. set = set.toUpperCase();
  82931. if (!debugs[set]) {
  82932. if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
  82933. var pid = process.pid;
  82934. debugs[set] = function() {
  82935. var msg = exports.format.apply(exports, arguments);
  82936. console.error('%s %d: %s', set, pid, msg);
  82937. };
  82938. } else {
  82939. debugs[set] = function() {};
  82940. }
  82941. }
  82942. return debugs[set];
  82943. };
  82944. /**
  82945. * Echos the value of a value. Trys to print the value out
  82946. * in the best way possible given the different types.
  82947. *
  82948. * @param {Object} obj The object to print out.
  82949. * @param {Object} opts Optional options object that alters the output.
  82950. */
  82951. /* legacy: obj, showHidden, depth, colors*/
  82952. function inspect(obj, opts) {
  82953. // default options
  82954. var ctx = {
  82955. seen: [],
  82956. stylize: stylizeNoColor
  82957. };
  82958. // legacy...
  82959. if (arguments.length >= 3) ctx.depth = arguments[2];
  82960. if (arguments.length >= 4) ctx.colors = arguments[3];
  82961. if (isBoolean(opts)) {
  82962. // legacy...
  82963. ctx.showHidden = opts;
  82964. } else if (opts) {
  82965. // got an "options" object
  82966. exports._extend(ctx, opts);
  82967. }
  82968. // set default options
  82969. if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
  82970. if (isUndefined(ctx.depth)) ctx.depth = 2;
  82971. if (isUndefined(ctx.colors)) ctx.colors = false;
  82972. if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
  82973. if (ctx.colors) ctx.stylize = stylizeWithColor;
  82974. return formatValue(ctx, obj, ctx.depth);
  82975. }
  82976. exports.inspect = inspect;
  82977. // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  82978. inspect.colors = {
  82979. 'bold' : [1, 22],
  82980. 'italic' : [3, 23],
  82981. 'underline' : [4, 24],
  82982. 'inverse' : [7, 27],
  82983. 'white' : [37, 39],
  82984. 'grey' : [90, 39],
  82985. 'black' : [30, 39],
  82986. 'blue' : [34, 39],
  82987. 'cyan' : [36, 39],
  82988. 'green' : [32, 39],
  82989. 'magenta' : [35, 39],
  82990. 'red' : [31, 39],
  82991. 'yellow' : [33, 39]
  82992. };
  82993. // Don't use 'blue' not visible on cmd.exe
  82994. inspect.styles = {
  82995. 'special': 'cyan',
  82996. 'number': 'yellow',
  82997. 'boolean': 'yellow',
  82998. 'undefined': 'grey',
  82999. 'null': 'bold',
  83000. 'string': 'green',
  83001. 'date': 'magenta',
  83002. // "name": intentionally not styling
  83003. 'regexp': 'red'
  83004. };
  83005. function stylizeWithColor(str, styleType) {
  83006. var style = inspect.styles[styleType];
  83007. if (style) {
  83008. return '\u001b[' + inspect.colors[style][0] + 'm' + str +
  83009. '\u001b[' + inspect.colors[style][1] + 'm';
  83010. } else {
  83011. return str;
  83012. }
  83013. }
  83014. function stylizeNoColor(str, styleType) {
  83015. return str;
  83016. }
  83017. function arrayToHash(array) {
  83018. var hash = {};
  83019. array.forEach(function(val, idx) {
  83020. hash[val] = true;
  83021. });
  83022. return hash;
  83023. }
  83024. function formatValue(ctx, value, recurseTimes) {
  83025. // Provide a hook for user-specified inspect functions.
  83026. // Check that value is an object with an inspect function on it
  83027. if (ctx.customInspect &&
  83028. value &&
  83029. isFunction(value.inspect) &&
  83030. // Filter out the util module, it's inspect function is special
  83031. value.inspect !== exports.inspect &&
  83032. // Also filter out any prototype objects using the circular check.
  83033. !(value.constructor && value.constructor.prototype === value)) {
  83034. var ret = value.inspect(recurseTimes, ctx);
  83035. if (!isString(ret)) {
  83036. ret = formatValue(ctx, ret, recurseTimes);
  83037. }
  83038. return ret;
  83039. }
  83040. // Primitive types cannot have properties
  83041. var primitive = formatPrimitive(ctx, value);
  83042. if (primitive) {
  83043. return primitive;
  83044. }
  83045. // Look up the keys of the object.
  83046. var keys = Object.keys(value);
  83047. var visibleKeys = arrayToHash(keys);
  83048. if (ctx.showHidden) {
  83049. keys = Object.getOwnPropertyNames(value);
  83050. }
  83051. // IE doesn't make error fields non-enumerable
  83052. // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
  83053. if (isError(value)
  83054. && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
  83055. return formatError(value);
  83056. }
  83057. // Some type of object without properties can be shortcutted.
  83058. if (keys.length === 0) {
  83059. if (isFunction(value)) {
  83060. var name = value.name ? ': ' + value.name : '';
  83061. return ctx.stylize('[Function' + name + ']', 'special');
  83062. }
  83063. if (isRegExp(value)) {
  83064. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  83065. }
  83066. if (isDate(value)) {
  83067. return ctx.stylize(Date.prototype.toString.call(value), 'date');
  83068. }
  83069. if (isError(value)) {
  83070. return formatError(value);
  83071. }
  83072. }
  83073. var base = '', array = false, braces = ['{', '}'];
  83074. // Make Array say that they are Array
  83075. if (isArray(value)) {
  83076. array = true;
  83077. braces = ['[', ']'];
  83078. }
  83079. // Make functions say that they are functions
  83080. if (isFunction(value)) {
  83081. var n = value.name ? ': ' + value.name : '';
  83082. base = ' [Function' + n + ']';
  83083. }
  83084. // Make RegExps say that they are RegExps
  83085. if (isRegExp(value)) {
  83086. base = ' ' + RegExp.prototype.toString.call(value);
  83087. }
  83088. // Make dates with properties first say the date
  83089. if (isDate(value)) {
  83090. base = ' ' + Date.prototype.toUTCString.call(value);
  83091. }
  83092. // Make error with message first say the error
  83093. if (isError(value)) {
  83094. base = ' ' + formatError(value);
  83095. }
  83096. if (keys.length === 0 && (!array || value.length == 0)) {
  83097. return braces[0] + base + braces[1];
  83098. }
  83099. if (recurseTimes < 0) {
  83100. if (isRegExp(value)) {
  83101. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  83102. } else {
  83103. return ctx.stylize('[Object]', 'special');
  83104. }
  83105. }
  83106. ctx.seen.push(value);
  83107. var output;
  83108. if (array) {
  83109. output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
  83110. } else {
  83111. output = keys.map(function(key) {
  83112. return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
  83113. });
  83114. }
  83115. ctx.seen.pop();
  83116. return reduceToSingleString(output, base, braces);
  83117. }
  83118. function formatPrimitive(ctx, value) {
  83119. if (isUndefined(value))
  83120. return ctx.stylize('undefined', 'undefined');
  83121. if (isString(value)) {
  83122. var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
  83123. .replace(/'/g, "\\'")
  83124. .replace(/\\"/g, '"') + '\'';
  83125. return ctx.stylize(simple, 'string');
  83126. }
  83127. if (isNumber(value))
  83128. return ctx.stylize('' + value, 'number');
  83129. if (isBoolean(value))
  83130. return ctx.stylize('' + value, 'boolean');
  83131. // For some reason typeof null is "object", so special case here.
  83132. if (isNull(value))
  83133. return ctx.stylize('null', 'null');
  83134. }
  83135. function formatError(value) {
  83136. return '[' + Error.prototype.toString.call(value) + ']';
  83137. }
  83138. function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
  83139. var output = [];
  83140. for (var i = 0, l = value.length; i < l; ++i) {
  83141. if (hasOwnProperty(value, String(i))) {
  83142. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  83143. String(i), true));
  83144. } else {
  83145. output.push('');
  83146. }
  83147. }
  83148. keys.forEach(function(key) {
  83149. if (!key.match(/^\d+$/)) {
  83150. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  83151. key, true));
  83152. }
  83153. });
  83154. return output;
  83155. }
  83156. function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
  83157. var name, str, desc;
  83158. desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
  83159. if (desc.get) {
  83160. if (desc.set) {
  83161. str = ctx.stylize('[Getter/Setter]', 'special');
  83162. } else {
  83163. str = ctx.stylize('[Getter]', 'special');
  83164. }
  83165. } else {
  83166. if (desc.set) {
  83167. str = ctx.stylize('[Setter]', 'special');
  83168. }
  83169. }
  83170. if (!hasOwnProperty(visibleKeys, key)) {
  83171. name = '[' + key + ']';
  83172. }
  83173. if (!str) {
  83174. if (ctx.seen.indexOf(desc.value) < 0) {
  83175. if (isNull(recurseTimes)) {
  83176. str = formatValue(ctx, desc.value, null);
  83177. } else {
  83178. str = formatValue(ctx, desc.value, recurseTimes - 1);
  83179. }
  83180. if (str.indexOf('\n') > -1) {
  83181. if (array) {
  83182. str = str.split('\n').map(function(line) {
  83183. return ' ' + line;
  83184. }).join('\n').substr(2);
  83185. } else {
  83186. str = '\n' + str.split('\n').map(function(line) {
  83187. return ' ' + line;
  83188. }).join('\n');
  83189. }
  83190. }
  83191. } else {
  83192. str = ctx.stylize('[Circular]', 'special');
  83193. }
  83194. }
  83195. if (isUndefined(name)) {
  83196. if (array && key.match(/^\d+$/)) {
  83197. return str;
  83198. }
  83199. name = JSON.stringify('' + key);
  83200. if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
  83201. name = name.substr(1, name.length - 2);
  83202. name = ctx.stylize(name, 'name');
  83203. } else {
  83204. name = name.replace(/'/g, "\\'")
  83205. .replace(/\\"/g, '"')
  83206. .replace(/(^"|"$)/g, "'");
  83207. name = ctx.stylize(name, 'string');
  83208. }
  83209. }
  83210. return name + ': ' + str;
  83211. }
  83212. function reduceToSingleString(output, base, braces) {
  83213. var numLinesEst = 0;
  83214. var length = output.reduce(function(prev, cur) {
  83215. numLinesEst++;
  83216. if (cur.indexOf('\n') >= 0) numLinesEst++;
  83217. return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
  83218. }, 0);
  83219. if (length > 60) {
  83220. return braces[0] +
  83221. (base === '' ? '' : base + '\n ') +
  83222. ' ' +
  83223. output.join(',\n ') +
  83224. ' ' +
  83225. braces[1];
  83226. }
  83227. return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  83228. }
  83229. // NOTE: These type checking functions intentionally don't use `instanceof`
  83230. // because it is fragile and can be easily faked with `Object.create()`.
  83231. function isArray(ar) {
  83232. return Array.isArray(ar);
  83233. }
  83234. exports.isArray = isArray;
  83235. function isBoolean(arg) {
  83236. return typeof arg === 'boolean';
  83237. }
  83238. exports.isBoolean = isBoolean;
  83239. function isNull(arg) {
  83240. return arg === null;
  83241. }
  83242. exports.isNull = isNull;
  83243. function isNullOrUndefined(arg) {
  83244. return arg == null;
  83245. }
  83246. exports.isNullOrUndefined = isNullOrUndefined;
  83247. function isNumber(arg) {
  83248. return typeof arg === 'number';
  83249. }
  83250. exports.isNumber = isNumber;
  83251. function isString(arg) {
  83252. return typeof arg === 'string';
  83253. }
  83254. exports.isString = isString;
  83255. function isSymbol(arg) {
  83256. return typeof arg === 'symbol';
  83257. }
  83258. exports.isSymbol = isSymbol;
  83259. function isUndefined(arg) {
  83260. return arg === void 0;
  83261. }
  83262. exports.isUndefined = isUndefined;
  83263. function isRegExp(re) {
  83264. return isObject(re) && objectToString(re) === '[object RegExp]';
  83265. }
  83266. exports.isRegExp = isRegExp;
  83267. function isObject(arg) {
  83268. return typeof arg === 'object' && arg !== null;
  83269. }
  83270. exports.isObject = isObject;
  83271. function isDate(d) {
  83272. return isObject(d) && objectToString(d) === '[object Date]';
  83273. }
  83274. exports.isDate = isDate;
  83275. function isError(e) {
  83276. return isObject(e) &&
  83277. (objectToString(e) === '[object Error]' || e instanceof Error);
  83278. }
  83279. exports.isError = isError;
  83280. function isFunction(arg) {
  83281. return typeof arg === 'function';
  83282. }
  83283. exports.isFunction = isFunction;
  83284. function isPrimitive(arg) {
  83285. return arg === null ||
  83286. typeof arg === 'boolean' ||
  83287. typeof arg === 'number' ||
  83288. typeof arg === 'string' ||
  83289. typeof arg === 'symbol' || // ES6 symbol
  83290. typeof arg === 'undefined';
  83291. }
  83292. exports.isPrimitive = isPrimitive;
  83293. exports.isBuffer = require('./support/isBuffer');
  83294. function objectToString(o) {
  83295. return Object.prototype.toString.call(o);
  83296. }
  83297. function pad(n) {
  83298. return n < 10 ? '0' + n.toString(10) : n.toString(10);
  83299. }
  83300. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
  83301. 'Oct', 'Nov', 'Dec'];
  83302. // 26 Feb 16:19:34
  83303. function timestamp() {
  83304. var d = new Date();
  83305. var time = [pad(d.getHours()),
  83306. pad(d.getMinutes()),
  83307. pad(d.getSeconds())].join(':');
  83308. return [d.getDate(), months[d.getMonth()], time].join(' ');
  83309. }
  83310. // log is just a thin wrapper to console.log that prepends a timestamp
  83311. exports.log = function() {
  83312. console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
  83313. };
  83314. /**
  83315. * Inherit the prototype methods from one constructor into another.
  83316. *
  83317. * The Function.prototype.inherits from lang.js rewritten as a standalone
  83318. * function (not on Function.prototype). NOTE: If this file is to be loaded
  83319. * during bootstrapping this function needs to be rewritten using some native
  83320. * functions as prototype setup using normal JavaScript does not work as
  83321. * expected during bootstrapping (see mirror.js in r114903).
  83322. *
  83323. * @param {function} ctor Constructor function which needs to inherit the
  83324. * prototype.
  83325. * @param {function} superCtor Constructor function to inherit prototype from.
  83326. */
  83327. exports.inherits = require('inherits');
  83328. exports._extend = function(origin, add) {
  83329. // Don't do anything if add isn't an object
  83330. if (!add || !isObject(add)) return origin;
  83331. var keys = Object.keys(add);
  83332. var i = keys.length;
  83333. while (i--) {
  83334. origin[keys[i]] = add[keys[i]];
  83335. }
  83336. return origin;
  83337. };
  83338. function hasOwnProperty(obj, prop) {
  83339. return Object.prototype.hasOwnProperty.call(obj, prop);
  83340. }
  83341. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  83342. },{"./support/isBuffer":89,"_process":73,"inherits":88}]},{},[1]);
  83343. (function(web3){
  83344. var MOVES = {
  83345. SELECT : 3,
  83346. BET : 5,
  83347. CALL : 7,
  83348. PROOF : 11,
  83349. FOLD : 13,
  83350. LEAVE : 17
  83351. };
  83352. var ROUNDTYPES = {
  83353. READY : 666,
  83354. SELECT : MOVES.SELECT,
  83355. BET : MOVES.BET,
  83356. CALLFOLD: MOVES.CALL * MOVES.FOLD,
  83357. PROVE : MOVES.PROOF
  83358. };
  83359. var ROUNDS = [
  83360. // ROUNDTYPES.READY,
  83361. ROUNDTYPES.SELECT,
  83362. ROUNDTYPES.BET,
  83363. ROUNDTYPES.CALLFOLD,
  83364. ROUNDTYPES.SELECT,
  83365. ROUNDTYPES.BET,
  83366. ROUNDTYPES.CALLFOLD,
  83367. ROUNDTYPES.SELECT,
  83368. ROUNDTYPES.BET,
  83369. ROUNDTYPES.CALLFOLD,
  83370. ROUNDTYPES.PROVE,
  83371. ROUNDTYPES.BET,
  83372. ROUNDTYPES.CALLFOLD,
  83373. ROUNDTYPES.PROVE,
  83374. ROUNDTYPES.PROVE
  83375. ];
  83376. var SELECTINDEXES = [1,0,0,2,0,0,3,0,0,5,0,0,6,7];
  83377. var PROOFTOSELECT = [0,1,4,7];
  83378. web3.Game = {
  83379. MOVES : MOVES,
  83380. ROUNDS : ROUNDS,
  83381. ROUNDTYPES : ROUNDTYPES
  83382. };
  83383. var _stack = [];
  83384. var _roundStack = [];
  83385. var _isAlreadySelected = {
  83386. };
  83387. var currentState = {};
  83388. var _gameState = {};
  83389. var _onStateChange;
  83390. var _onRoundChange;
  83391. // SAVE MOVES //
  83392. web3.Game.saveMove = function(move){
  83393. currentState[move.who] = move;
  83394. if(currentState[getOther(move.who)])
  83395. return this.saveState();
  83396. if(move.type == MOVES.FOLD){ // TODO -- this is propably wrong but i can hhandle it ftm
  83397. return this.saveState();
  83398. }
  83399. return true;
  83400. };
  83401. web3.Game.isAvailableNow = function(type){
  83402. return ROUNDS[_roundStack.length] % type == 0;
  83403. }
  83404. web3.Game.isValidMove = function(move){ // GAME STATE CONTRAINT FUNCTION
  83405. var type = move.type;
  83406. if(!this.isAvailableNow(type))return false;
  83407. switch(type){
  83408. case MOVES.SELECT :
  83409. var opp = getOther(move.who);
  83410. if(!isCorrectSelectIndex(move.data.selectIndex))return false;
  83411. if(_gameState.selected[opp][move.data[opp] % 6])return false;
  83412. if(_gameState.hidden[move.who][move.data.selectIndex])return false; // already selected
  83413. if(move.data[move.who].length != 66)return false;
  83414. return true;
  83415. case MOVES.PROOF :
  83416. var data = move.data[move.who];
  83417. //if(web3.sha3(JSON.stringify(data)) != _roundStack[SELECTINDEXES.indexOf(move.data.selectIndex%4)][move.who].data[move.who])return false;
  83418. if(_gameState.selected[getOther(move.who)][move.data[move.who] % 6])return false;
  83419. if(_gameState.hidden[move.who][move.data.selectIndex%4] != web3.sha3(JSON.stringify(data)))return false;
  83420. return true;
  83421. case MOVES.BET :
  83422. var data = move.data.amount;
  83423. if( data < 0 || parseInt(data) != data)return false;
  83424. if( _gameState.coins[move.who] < data )return false;
  83425. if( _gameState.coins[getOther(move.who)] < data)return false;
  83426. return true;
  83427. case MOVES.FOLD :
  83428. if( _gameState.bets[getOther(move.who)] < _gameState.bets[move.who] )return false;
  83429. return true;
  83430. case MOVES.CALL :
  83431. return true;
  83432. }
  83433. };
  83434. web3.Game.performMove = function(move){ // GAME STATE CHANGING FUNCTION
  83435. if(!this.isValidMove(move))return false;
  83436. switch(move.type){
  83437. case MOVES.SELECT :
  83438. var opp = getOther(move.who);
  83439. _gameState.selected[opp][move.data[opp] % 6] = SELECTINDEXES[_roundStack.length];
  83440. _gameState.hidden[move.who][move.data.selectIndex] = move.data[move.who]; // Dictionary of hidden hashes
  83441. break;
  83442. case MOVES.PROOF :
  83443. var data = move.data[move.who];
  83444. if(web3.sha3(JSON.stringify(data)) != _gameState.hidden[move.who][this.getCurrentProofIndex()%4])return false;
  83445. _gameState.hidden[move.who][this.getCurrentProofIndex()%4] = data;
  83446. break;
  83447. case MOVES.BET :
  83448. var data = move.data.amount;
  83449. _gameState.coins[move.who] -= data;
  83450. _gameState.pot += data;
  83451. _gameState.bets[move.who] = data;
  83452. break;
  83453. case MOVES.FOLD :
  83454. _gameState.fold[move.who] = true;
  83455. break;
  83456. case MOVES.CALL :
  83457. var def = Math.step(_gameState.bets[getOther(move.who)] - _gameState.bets[move.who]);
  83458. _gameState.coins[move.who] -= def;
  83459. _gameState.pot += def;
  83460. break;
  83461. }
  83462. return this.saveMove(move);
  83463. };
  83464. web3.Game.getCurrentProofIndex = function(){
  83465. return SELECTINDEXES[_roundStack.length];
  83466. };
  83467. web3.Game.saveProof = function(index, proof){
  83468. this.proofs[index] = proof;
  83469. };
  83470. // SAVE ROUND //
  83471. web3.Game.saveRound = function(){
  83472. _stack.push(_roundStack);
  83473. _roundStack = [];
  83474. // TODO calculate winner!!!
  83475. //
  83476. _isAlreadySelected[web3.eth.defaultAccount] = [0,0,0,0,0,0];
  83477. _isAlreadySelected[web3.eth.opponentAccount] = [0,0,0,0,0,0];
  83478. _gameState.coins[web3.eth.defaultAccount] -= 1;
  83479. _gameState.coins[web3.eth.opponentAccount] -= 1;
  83480. _gameState.hidden[web3.eth.defaultAccount] = {};
  83481. _gameState.hidden[web3.eth.opponentAccount] = {};
  83482. _gameState.pot = 2;
  83483. _gameState.round++;
  83484. _gameState.roundstate = 0;
  83485. _gameState.bets[web3.eth.defaultAccount] = 0;
  83486. _gameState.bets[web3.eth.opponentAccount] = 0
  83487. _gameState.selected[web3.eth.defaultAccount] = [0,0,0,0,0,0];
  83488. _gameState.selected[web3.eth.opponentAccount] = [0,0,0,0,0,0];
  83489. _gameState.fold[web3.eth.defaultAccount] = false;
  83490. _gameState.fold[web3.eth.opponentAccount] = false;
  83491. this.proofs = {};
  83492. this.saveToDB();
  83493. if(_onRoundChange)_onRoundChange();
  83494. return true;
  83495. };
  83496. // GAME STATE ///
  83497. web3.Game.saveState = function(){
  83498. _roundStack.push(currentState);
  83499. _gameState.roundstate ++;
  83500. currentState = {};
  83501. if(_onStateChange)_onStateChange();
  83502. if(this.isValidRound())return this.saveRound();
  83503. this.saveToDB();
  83504. return true;
  83505. };
  83506. web3.Game.checkRound = function(){
  83507. if(this.isValidRound())return this.saveRound();
  83508. return false;
  83509. }
  83510. web3.Game.setOnStateChange = function(fn){_onStateChange = fn;}
  83511. web3.Game.clearOnStateChange = function(){delete _onStateChange;}
  83512. web3.Game.setOnRoundChange = function(fn){_onRoundChange = fn;}
  83513. web3.Game.clearOnRoundChange = function(){delete _onRoundChange;}
  83514. // ROUND //
  83515. // function hasRoundFinished(){
  83516. // //_roundStack;
  83517. // if(web3.Game.isValidRound(currentState)){
  83518. // web3.Game.saveRound();
  83519. // }
  83520. // else{
  83521. // // Something is invalid!!!
  83522. // console.log(currentState);
  83523. // throw new Error("This state is not valid! ^^");
  83524. // }
  83525. // }
  83526. web3.Game._givemoney = function(addr){
  83527. _gameState.coins[addr] += _gameState.pot;
  83528. _gameState.pot = 0;
  83529. };
  83530. web3.Game.isValidRound = function(){
  83531. if(_gameState.fold[web3.eth.defaultAccount]){
  83532. this._givemoney(web3.eth.opponentAccount);
  83533. return true;
  83534. }
  83535. if(_gameState.fold[web3.eth.opponentAccount]){
  83536. this._givemoney(web3.eth.defaultAccount);
  83537. return true;
  83538. }
  83539. if(_gameState.roundstate == SELECTINDEXES.length){
  83540. var sums = this.findSums();
  83541. if(sums[web3.eth.defaultAccount] > sums[web3.eth.opponentAccount]){ // TODO - check equality
  83542. this._givemoney(web3.eth.defaultAccount);
  83543. return true;
  83544. }
  83545. else{
  83546. this._givemoney(web3.eth.opponentAccount);
  83547. return true;
  83548. }
  83549. }
  83550. return false;
  83551. };
  83552. // MOVE CREATION ///
  83553. web3.Game._createMove = function (type, data){
  83554. if( type != web3.Game.MOVES.SELECT &&
  83555. type != web3.Game.MOVES.BET &&
  83556. type != web3.Game.MOVES.FOLD &&
  83557. type != web3.Game.MOVES.CALL &&
  83558. type != web3.Game.MOVES.PROOF &&
  83559. type != web3.Game.MOVES.LEAVE )
  83560. throw new Error("This type of move doesnt exist. Type : " + type);
  83561. var move = {
  83562. who : web3.eth.defaultAccount,
  83563. type : type,
  83564. data : JSON.parse(JSON.stringify(data))
  83565. //lastState : _calculateLastStateHash()
  83566. };
  83567. return move;
  83568. };
  83569. web3.Game.createSelectMove = function (mdata1, mdata2){
  83570. if(!this.isAvailableNow(MOVES.SELECT))throw new Error("This type of move is not available now");
  83571. data1 = this.applyRotation(mdata1);
  83572. data2 = this.applyRotation(mdata2);
  83573. if(data1 < 0 || data1 > 5 )throw new Error("A SELECT Move is always between [0-5]");
  83574. if(data2 < 0 || data2 > 5 )throw new Error("A SELECT Move is always between [0-5]");
  83575. if(_gameState.selected[web3.eth.opponentAccount][data2])throw new Error("You cannot select an already selected column");
  83576. if(_isAlreadySelected[web3.eth.defaultAccount][data1])throw new Error("You cannot select an already selected column");
  83577. var cryptoData1 = _findRandomBigNumber(data1, 6);
  83578. var cryptoData2 = _findRandomBigNumber(data2, 6);
  83579. _isAlreadySelected[web3.eth.defaultAccount][data1] = SELECTINDEXES[_roundStack.length];
  83580. var cryptoData = {
  83581. selectIndex : SELECTINDEXES[_roundStack.length]
  83582. };
  83583. cryptoData[web3.eth.defaultAccount] = web3.sha3(''+cryptoData1);
  83584. cryptoData[web3.eth.opponentAccount] = cryptoData2;
  83585. var move = this._createMove(web3.Game.MOVES.SELECT, cryptoData);
  83586. cryptoData[web3.eth.defaultAccount] = cryptoData1;
  83587. var proof = this.createProofMove(cryptoData);
  83588. return {
  83589. move : move,
  83590. proof: proof
  83591. };
  83592. };
  83593. web3.Game.createBetMove = function (amount){
  83594. if(!this.isAvailableNow(MOVES.BET))throw new Error("This type of move is not available now");
  83595. if(amount < 0 || parseInt(amount) != amount)throw new Error("Amount parameter must be positive integer or 0!")
  83596. if(amount > _gameState.coins[web3.eth.defaultAccount])throw new Error("Not enough coins to bet! Current Coins:" + _gameState.coins[web3.eth.defaultAccount] + " Amount requested:" + amount );
  83597. if(amount > _gameState.coins[web3.eth.opponentAccount])throw new Error("Not enough opponent coins to bet! Current Coins:" + _gameState.coins[web3.eth.opponentAccount] + " Amount requested:" + amount );
  83598. var cryptoData = {
  83599. amount : amount
  83600. };
  83601. var move = this._createMove(web3.Game.MOVES.BET, cryptoData);
  83602. return move;
  83603. };
  83604. web3.Game.createCallMove = function (data){
  83605. if(!this.isAvailableNow(MOVES.CALL))throw new Error("This type of move is not available now");
  83606. var cryptoData = {
  83607. };
  83608. var move = this._createMove(web3.Game.MOVES.CALL, cryptoData);
  83609. return move;
  83610. };
  83611. web3.Game.createFoldMove = function (data){
  83612. if(!this.isAvailableNow(MOVES.FOLD))throw new Error("This type of move is not available now");
  83613. var cryptoData = {
  83614. };
  83615. var move = this._createMove(web3.Game.MOVES.FOLD, cryptoData);
  83616. return move;
  83617. };
  83618. web3.Game.createProofMove = function (data){
  83619. var r = this._createMove(web3.Game.MOVES.PROOF, data);
  83620. return r;
  83621. };
  83622. web3.Game.getProofMove = function (index){
  83623. return this.proofs[index];
  83624. };
  83625. web3.Game.saveToDB = function(){
  83626. web3.db.putString(web3.db.DBNAME,"THEREAREDATA","true");
  83627. web3.db.putString(web3.db.DBNAME,"_stack",JSON.stringify(_stack));
  83628. web3.db.putString(web3.db.DBNAME,"_roundStack",JSON.stringify(_roundStack));
  83629. web3.db.putString(web3.db.DBNAME,"_isAlreadySelected",JSON.stringify(_isAlreadySelected));
  83630. web3.db.putString(web3.db.DBNAME,"_currentState",JSON.stringify(currentState));
  83631. web3.db.putString(web3.db.DBNAME,"_gameState",JSON.stringify(_gameState));
  83632. web3.db.putString(web3.db.DBNAME,"_stack",JSON.stringify(_stack));
  83633. web3.db.putString(web3.db.DBNAME,"proofs",JSON.stringify(this.proofs));
  83634. }
  83635. web3.Game.clearDB = function(){
  83636. web3.db.putString(web3.db.DBNAME,"THEREAREDATA",undefined);
  83637. }
  83638. web3.Game.loadFromDB = function(){
  83639. if(!web3.db.getString(web3.db.DBNAME,"THEREAREDATA"))return;
  83640. _stack = JSON.parse(web3.db.getString(web3.db.DBNAME,"_stack"));
  83641. _roundStack = JSON.parse(web3.db.getString(web3.db.DBNAME,"_roundStack"));
  83642. _isAlreadySelected = JSON.parse(web3.db.getString(web3.db.DBNAME,"_isAlreadySelected"));
  83643. _currentState = JSON.parse(web3.db.getString(web3.db.DBNAME,"_currentState"));
  83644. _gameState = JSON.parse(web3.db.getString(web3.db.DBNAME,"_gameState"));
  83645. _stack = JSON.parse(web3.db.getString(web3.db.DBNAME,"_stack"));
  83646. this.proofs = JSON.parse(web3.db.getString(web3.db.DBNAME,"proofs"));
  83647. }
  83648. //////////////////////
  83649. /// GAME HELPERS ////
  83650. web3.Game.calculateMySum =function (){
  83651. };
  83652. web3.Game.calculateMyMoney = function(){
  83653. };
  83654. web3.Game.getMapArray = function(){
  83655. return this._maparray;
  83656. };
  83657. web3.Game.getState = function(){
  83658. return _gameState;
  83659. };
  83660. web3.Game.getStack = function(){
  83661. return _stack;
  83662. };
  83663. web3.Game.getRoundStack = function(){
  83664. return _roundStack;
  83665. };
  83666. web3.Game.haveSelected = function(i){
  83667. i = this.applyRotation(i);
  83668. return _isAlreadySelected[web3.eth.defaultAccount][i] != 0;
  83669. };
  83670. web3.Game.isMyNumber = function(i,j){
  83671. j = this.applyRotation(j);
  83672. return _isAlreadySelected[web3.eth.defaultAccount][j] == _gameState.selected[web3.eth.defaultAccount][i]
  83673. && _isAlreadySelected[web3.eth.defaultAccount][j] != 0;
  83674. };
  83675. web3.Game.findSums = function(){
  83676. var sums = {
  83677. [web3.eth.defaultAccount] : 0,
  83678. [web3.eth.opponentAccount]: 0
  83679. };
  83680. var map = calculateMapArray(this.maphash, this._mapRotation);
  83681. for(var i=0;i<6;i++)
  83682. for (var j = 0; j < 6; j++)
  83683. if(web3.Game.isMyNumber(i,j))
  83684. sums[web3.eth.defaultAccount] += map[i][j];
  83685. else if(web3.Game.isOpponentNumber(i,j))
  83686. sums[web3.eth.opponentAccount] += map[i][j];
  83687. return sums;
  83688. };
  83689. web3.Game.isOpponentNumber = function(i,j){
  83690. j = this.applyRotation(j);
  83691. return _gameState.hidden[web3.eth.opponentAccount][_gameState.selected[web3.eth.opponentAccount][j]] % 6 == i && typeof _gameState.hidden[web3.eth.opponentAccount][_gameState.selected[web3.eth.opponentAccount][j]] == "number" ;
  83692. };
  83693. web3.Game.reset = function(){
  83694. web3.Game.init();
  83695. }
  83696. web3.Game.setMapRotation = function(r){
  83697. this._mapRotation = r;
  83698. this._maparray = calculateMapArray(this.maphash, this._mapRotation);
  83699. };
  83700. web3.Game.getMapRotation = function(){
  83701. return web3.Game._mapRotation;
  83702. };
  83703. web3.Game.applyRotation = function(d){
  83704. if(this._mapRotation == 1){
  83705. d = 5 - d;
  83706. }
  83707. return d;
  83708. };
  83709. var _applyStateRotation = function(arr){
  83710. var a = [];
  83711. for(var i = 0; i < arr.length; i ++){
  83712. a.push(arr[5-i]);
  83713. }
  83714. return a;
  83715. };
  83716. web3.Game.applyStateRotation = function(s){
  83717. var r = JSON.parse(JSON.stringify(s));
  83718. if(this._mapRotation == 1){
  83719. r.selected[web3.eth.opponentAccount] = _applyStateRotation(s.selected[web3.eth.opponentAccount]);
  83720. }
  83721. return r;
  83722. };
  83723. /// INIT //
  83724. web3.Game.init = function(mapHash){
  83725. this.maphash = mapHash;
  83726. this._maparray = calculateMapArray(this.maphash);
  83727. _stack = [];
  83728. _roundStack = [];
  83729. currentState = {};
  83730. _isAlreadySelected[web3.eth.defaultAccount] = [0,0,0,0,0,0];
  83731. _isAlreadySelected[web3.eth.opponentAccount]= [0,0,0,0,0,0];
  83732. _gameState = {
  83733. coins : {
  83734. [web3.eth.defaultAccount] : 99, // TODO CHANGE web3.eth.defaultAccount and opAcc to be settable to object
  83735. [web3.eth.opponentAccount]: 99
  83736. },
  83737. selected :{
  83738. [web3.eth.defaultAccount] : [0,0,0,0,0,0],
  83739. [web3.eth.opponentAccount]: [0,0,0,0,0,0]
  83740. },
  83741. pot : 2,
  83742. round : 1,
  83743. roundstate : 0,
  83744. bets : {
  83745. [web3.eth.defaultAccount] : 0,
  83746. [web3.eth.opponentAccount]: 0
  83747. },
  83748. fold : {
  83749. [web3.eth.defaultAccount] : 0,
  83750. [web3.eth.opponentAccount]: 0
  83751. },
  83752. hidden :{
  83753. [web3.eth.defaultAccount] : {},
  83754. [web3.eth.opponentAccount]: {}
  83755. }
  83756. };
  83757. this.proofs = {};
  83758. };
  83759. // STATE INTERCEPTOR
  83760. web3.Game._stateInterceptor = function(data, original){
  83761. if(data.signature.data.stateConflict){
  83762. if( data.signature.data.myCurrentState ){
  83763. // verify and reset Game
  83764. return false;
  83765. }
  83766. // send My state
  83767. var data = {
  83768. myCurrentState : {
  83769. stack : web3.Game.getStack()
  83770. }
  83771. };
  83772. return false;
  83773. }
  83774. return data;
  83775. };
  83776. function isCorrectSelectIndex(index){
  83777. return SELECTINDEXES[_roundStack.length] == index;
  83778. }
  83779. // PRIVATE HELPERS //
  83780. function _calculateLastStateHash(){
  83781. var hash = web3.sha3(_gameState);
  83782. return hash;
  83783. }
  83784. function _findRandomBigNumber(num, field){
  83785. var randomNumber = Math.floor(10000000000 + Math.random() * 90000000000);
  83786. while(randomNumber % field != num){
  83787. randomNumber++;
  83788. }
  83789. return randomNumber;
  83790. }
  83791. function getOther(acc){
  83792. return acc == web3.eth.defaultAccount ? web3.eth.opponentAccount : web3.eth.defaultAccount;
  83793. }
  83794. /////////////////////
  83795. //// CALCULATIONS ///
  83796. /////////////////////
  83797. function hashToNumbers(hash){
  83798. var nums = [];
  83799. hash = hash.substr(2);
  83800. for(var i=0;i<32;i++){
  83801. var b = hash.substr(2*i, 2*i+2);
  83802. nums.push(web3.toDecimal('0x'+b));
  83803. }
  83804. return nums;
  83805. }
  83806. /////////////////////
  83807. function getNewMapHash(mapHash){
  83808. return web3.sha3(web3.sha3(web3.sha3(mapHash)));
  83809. }
  83810. function calculateMapArray(mapHash, rot){
  83811. console.log("Calculating map array for map hash: " + mapHash);
  83812. var first32Hash = mapHash,
  83813. second32Hash = web3.sha3(first32Hash),
  83814. third32Hash = web3.sha3(second32Hash);
  83815. // Make hash to numbers
  83816. var numbers = hashToNumbers(first32Hash)
  83817. .concat(hashToNumbers(second32Hash))
  83818. .concat(hashToNumbers(third32Hash));
  83819. // init mapArray
  83820. var maparray = [];
  83821. for(var i=0;i<6;i++){
  83822. maparray.push([]);
  83823. for(var j=0;j<6;j++){
  83824. maparray[i][j] = i*6 + j + 1;
  83825. }
  83826. }
  83827. ///
  83828. /// helper local swapPosition
  83829. function swapPositions(a,b){
  83830. a = a % 36
  83831. ai = a % 6;
  83832. aj = parseInt(a / 6);
  83833. b = b % 36
  83834. bi = b % 6;
  83835. bj = parseInt(b / 6);
  83836. var temp = maparray[ai][aj];
  83837. maparray[ai][aj] = maparray[bi][bj];
  83838. maparray[bi][bj] = temp;
  83839. }
  83840. ///
  83841. for(var i=0;i<numbers.length;i++){
  83842. swapPositions(i, numbers[i]);
  83843. }
  83844. ////////////////////////////////
  83845. //console.log(maparray);
  83846. ////////////////////////////////
  83847. // Rotate based on rot
  83848. if(rot == 1){
  83849. var f = 3;
  83850. var c = 3;
  83851. var n = 6;
  83852. for(var k = 0;k < 3;k++)
  83853. for( var x = 0; x < f; x++ ){
  83854. for(var y = 0; y <c;y++ ){
  83855. var temp = maparray[x][y];
  83856. maparray[x][y] = maparray[y][n-1-x];
  83857. maparray[y][n-1-x] = maparray[n-1-x][n-1-y];
  83858. maparray[n-1-x][n-1-y] = maparray[n-1-y][x];
  83859. maparray[n-1-y][x] = temp;
  83860. }
  83861. }
  83862. }
  83863. return maparray;
  83864. }
  83865. // Math Helpers
  83866. Math.step = function(x){return x < 0 ? 0 : x;};
  83867. })(web3);
  83868. (function(web3){
  83869. web3.Lib = {};
  83870. var _toRVS = function(data){
  83871. var res = {};
  83872. var signed = data.signature;
  83873. res.r = web3.Utils.toBuffer(signed.slice(0,66));
  83874. res.s = web3.Utils.toBuffer("0x"+signed.slice(66,130));
  83875. res.v = web3.Utils.bufferToInt(web3.Utils.toBuffer("0x"+signed.slice(130,132)));
  83876. res.m = web3.Utils.toBuffer(web3.sha3("\x19Ethereum Signed Message:\n" + data.data.length + data.data));
  83877. return res;
  83878. }
  83879. web3.Lib.signData = function(acc, data){
  83880. var hash = web3.sha3(JSON.stringify(data));
  83881. var signed = web3.eth.sign(acc, web3.toHex(JSON.stringify(data)));
  83882. console.log("Requested sign by account : " + acc);
  83883. return {
  83884. data : JSON.stringify(data),
  83885. dataHash : hash,
  83886. signature: signed
  83887. };
  83888. }
  83889. web3.Lib.verifySignature = function(acc, data){
  83890. var data = _toRVS(data);
  83891. // SimpleStorage.sig_verify(web3.Utils.bufferToHex(this.m), sig).then(function(r){
  83892. // console.log("SmartContract BEST verification : ");
  83893. // console.log(r);
  83894. // });
  83895. var pubKey = web3.Utils.ecrecover(data.m, data.v, data.r, data.s);
  83896. var addrBuf = web3.Utils.pubToAddress(pubKey);
  83897. var addr = web3.Utils.bufferToHex(addrBuf);
  83898. return acc == addr;
  83899. }
  83900. // CHANGE web3.db to localStorage!!!
  83901. web3.db.getString = function(a,k){
  83902. return localStorage[a+k];
  83903. }
  83904. web3.db.putString = function(a,k,v){
  83905. localStorage.setItem(a+k,v);
  83906. }
  83907. ////////////////////////////////
  83908. web3.Lib.DB = {
  83909. _dbname : "defaultDBName",
  83910. setJSON : function(k,d){
  83911. web3.db.putString(this._dbname, k, JSON.stringify(d));
  83912. },
  83913. getSON : function(d){
  83914. return JSON.parse(web3.db.getString(this._dbname,d));
  83915. },
  83916. set : function(k,d){
  83917. web3.db.putString(this._dbname, k, d);
  83918. },
  83919. get : function(d){
  83920. return web3.db.getString(this._dbname,d);
  83921. },
  83922. setDB : function(name){
  83923. this._dbname = name;
  83924. }
  83925. };
  83926. web3.Lib.initWhisper = function(channel, fn) {
  83927. if(typeof channel == undefined)
  83928. channel = web3.sha3("[]Custom Lobby").substr(2);
  83929. function _setFunction(fn){
  83930. EmbarkJS.Messages.listenTo({topic: [channel]}).then(fn);
  83931. };
  83932. function send(msg){
  83933. EmbarkJS.Messages.sendMessage({topic: channel, data: msg});
  83934. };
  83935. console.log("Whisper version : " + web3.version.whisper);
  83936. return new Promise(function(resolve, reject){
  83937. web3.version.getWhisper(function(err, res) {
  83938. if (err) {
  83939. console.log("[!] --> No Whisper - no communication");
  83940. reject(err);
  83941. } else {
  83942. //EmbarkJS.Messages.setProvider('whisper');
  83943. if(fn){
  83944. _setFunction(fn);
  83945. }
  83946. var r = {
  83947. func : fn,
  83948. channel : channel,
  83949. setFunction : _setFunction,
  83950. send : send
  83951. };
  83952. resolve(r);
  83953. }
  83954. });
  83955. });
  83956. }
  83957. })(web3);
  83958. (function(){
  83959. var RESENDTIME = 2000;
  83960. function resendOnFail(){
  83961. setTimeout(resendOnFail, RESENDTIME);
  83962. // var length = Object.keys(myClass._ACKs).length;
  83963. // for(var i in myClass._ACKs){
  83964. // myClass.sendPacket(myClass._ACKs[i]);
  83965. // }
  83966. myClass.queue.trySend();
  83967. };
  83968. var randomNumber = parseInt(Math.random() * 100000.0);
  83969. console.log(randomNumber);
  83970. var myClass = {
  83971. queue : {
  83972. _queue: [],
  83973. send : function(data){
  83974. // Create
  83975. console.log("Move added to the queue: " + web3.sha3(data.signature.data));
  83976. this._queue.push(data);
  83977. console.log(this._queue);
  83978. },
  83979. pop : function(data){
  83980. },
  83981. trySend : function(){
  83982. if(!this._queue.length)return;
  83983. var data = this._queue[0];
  83984. myClass.sockets[myClass._channel].send(data);
  83985. },
  83986. _getHash : function(){
  83987. if(!this._queue.length)return undefined;
  83988. var data = this._queue[0];
  83989. var hash = web3.sha3(data.signature.data); // already stringified!
  83990. //console.log(hash);
  83991. return hash;
  83992. },
  83993. recievedACK : function(data){
  83994. if(data.ACK){
  83995. //console.log("Testing recieved ACK : " + data.signature.data.ackSignature);
  83996. if(data.signature.data.ackSignature == this._getHash()){
  83997. //save ACK in stack
  83998. var item = this._queue.shift();
  83999. console.log("recievedACK for : " + data.signature.data.ackSignature);
  84000. console.log(this._queue);
  84001. return item;
  84002. }
  84003. }
  84004. return false;
  84005. }
  84006. },
  84007. sockets : {},
  84008. _channel: "defaultGAMECHANNEL1",
  84009. _fn : function(){},
  84010. _proof : false,
  84011. _address : "",
  84012. _solo : false,
  84013. _ACKs : {},
  84014. _interceptors : [],
  84015. _interceptor : function(data){
  84016. var temp = data;
  84017. for(var i=0; i < myClass._interceptors.length ; i++){
  84018. temp = myClass._interceptors[i].call(myClass, temp, data);
  84019. if(temp === false){
  84020. return false;
  84021. }
  84022. }
  84023. return true;
  84024. },
  84025. __soloInterceptor : function(data){
  84026. if(this._solo && data.who != this._address)return false;
  84027. if(!this.verifyMessage(data)){
  84028. console.log("Verification Failed for:");
  84029. console.log(data);
  84030. return false;
  84031. }
  84032. // parse Data !!!
  84033. data.signature.data = JSON.parse(data.signature.data);
  84034. if(data.ACK){
  84035. this.queue.recievedACK(data);
  84036. }
  84037. return data;
  84038. //
  84039. },
  84040. __proofInterceptor : function(data){
  84041. if(data.signature.data.proof){
  84042. //console.log("Proof.. Sending last packet!");
  84043. this.saveProof(data);
  84044. this.sendLastPacket();
  84045. this.sendACK(data);
  84046. return false;
  84047. }
  84048. else{
  84049. if(this._proof){
  84050. if(this.verifyProof(data, this._proof)){
  84051. //console.log("GOOD PROOF");
  84052. this.sendACK(data);
  84053. this.clearProof();
  84054. return data.signature.data;
  84055. }
  84056. else{
  84057. // BAD PROOF REPORT!!
  84058. //console.log("BAD PROOF");
  84059. return false;
  84060. }
  84061. }
  84062. else{
  84063. return false;
  84064. //console.log("-Discarding");
  84065. // i have no proof...
  84066. // i can either save or discard
  84067. }
  84068. }
  84069. return data;
  84070. },
  84071. __saveDataInterceptor : function(data,original) {
  84072. // save original to a stack!!!;
  84073. return data;
  84074. },
  84075. setSolo : function(add){
  84076. this._address = add;
  84077. this._solo = true;
  84078. },
  84079. setSoloInterceptor : function(){
  84080. this._interceptors.push(this.__soloInterceptor);
  84081. },
  84082. setProofInterceptor : function(){
  84083. this._interceptors.push(this.__proofInterceptor);
  84084. },
  84085. setSaveInterceptor : function(){
  84086. this._interceptors.push(this.__saveDataInterceptor);
  84087. },
  84088. addInterceptor : function(fn){
  84089. this._interceptors.push(fn);
  84090. },
  84091. startListening : function(){
  84092. var self = this;
  84093. // Establish whisper connection //
  84094. return web3.Lib.initWhisper(this._channel)
  84095. .then(function(w){
  84096. w.setFunction(self._interceptor); // w.setFunction ( interceptor of fn that will handle ACKs and will send the next on queue!!)
  84097. self.sockets[self._channel] = w;
  84098. });
  84099. },
  84100. stopListening : function(){
  84101. // todo
  84102. },
  84103. sendPacketWaitForVerification : function(packet){
  84104. packet.randomNumber = randomNumber++;
  84105. this._vpacket = packet;
  84106. // console.log("PREPARING : ")
  84107. // console.log(packet);
  84108. this.sendProof(packet);
  84109. if(this._proof)this.sendLastPacket();
  84110. },
  84111. sendLastPacket : function(){
  84112. if(this._vpacket){
  84113. // console.log("SENDING:");
  84114. // console.log(this._vpacket);
  84115. this.sendPacket(this._vpacket);
  84116. delete this._vpacket;
  84117. }
  84118. },
  84119. sendPacket : function(packet){
  84120. var sign = web3.Lib.signData(web3.eth.defaultAccount, packet);
  84121. return this.queue.send({
  84122. who : web3.eth.defaultAccount,
  84123. signature : sign
  84124. });
  84125. },
  84126. sendProof : function(data){
  84127. var hash = web3.sha3(JSON.stringify(data));
  84128. var dataToSign = { datahash : hash, proof : true};
  84129. var sign = web3.Lib.signData(web3.eth.defaultAccount, dataToSign );
  84130. this.queue.send({
  84131. who : web3.eth.defaultAccount,
  84132. signature : sign
  84133. });
  84134. },
  84135. clearProof : function(){
  84136. delete this._proof;
  84137. },
  84138. saveProof : function(p){
  84139. this._proof = p;
  84140. },
  84141. verifyMessage : function(packet){
  84142. return web3.Lib.verifySignature(packet.who, packet.signature);
  84143. },
  84144. verifyProof : function(packet, proof){
  84145. var hash = web3.sha3(JSON.stringify(packet.signature.data));
  84146. if( proof.signature.data.datahash != hash )return false;
  84147. return true;
  84148. },
  84149. sendACK : function(packet){
  84150. // Send Verification For Signed Data
  84151. //var dataToSign = JSON.stringify(packet);//data.signature.dataHash.substr(2);
  84152. var hash = web3.sha3(JSON.stringify(packet.signature.data));
  84153. var dataToSign = {
  84154. ackSignature : hash
  84155. };
  84156. var verificationForSignature = web3.Lib.signData(web3.eth.defaultAccount, dataToSign);
  84157. this.sockets[this._channel].send({
  84158. who : web3.eth.defaultAccount,
  84159. signature : verificationForSignature,
  84160. ACK : true
  84161. });
  84162. },
  84163. setChannel : function(ch){
  84164. this._channel = ch;
  84165. },
  84166. init : function(){
  84167. setTimeout(resendOnFail, RESENDTIME);
  84168. }
  84169. };
  84170. web3.NetLib = myClass;
  84171. })();